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 | /** |
Yingying Tang | 80e15f3 | 2016-09-27 18:23:01 +0800 | [diff] [blame] | 8950 | * wlan_hdd_cfg80211_deinit() - Deinit cfg80211 |
| 8951 | * @wiphy: the wiphy to validate against |
Abhishek Singh | f512bf3 | 2016-05-04 16:47:46 +0530 | [diff] [blame] | 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 | |
Yingying Tang | 80e15f3 | 2016-09-27 18:23:01 +0800 | [diff] [blame] | 8973 | /** |
| 8974 | * wlan_hdd_update_band_cap() - update capabilities for supported bands |
| 8975 | * @hdd_ctx: HDD context |
| 8976 | * |
| 8977 | * this function will update capabilities for supported bands |
| 8978 | * |
| 8979 | * Return: void |
| 8980 | */ |
| 8981 | static void wlan_hdd_update_band_cap(hdd_context_t *hdd_ctx) |
| 8982 | { |
| 8983 | uint32_t val32; |
| 8984 | uint16_t val16; |
| 8985 | tSirMacHTCapabilityInfo *ht_cap_info; |
| 8986 | QDF_STATUS status; |
| 8987 | |
| 8988 | status = sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_HT_CAP_INFO, &val32); |
| 8989 | if (QDF_STATUS_SUCCESS != status) { |
| 8990 | hdd_err("could not get HT capability info"); |
| 8991 | val32 = 0; |
| 8992 | } |
| 8993 | val16 = (uint16_t)val32; |
| 8994 | ht_cap_info = (tSirMacHTCapabilityInfo *)&val16; |
| 8995 | |
| 8996 | if (ht_cap_info->txSTBC == true) { |
| 8997 | if (NULL != hdd_ctx->wiphy->bands[NL80211_BAND_2GHZ]) |
| 8998 | hdd_ctx->wiphy->bands[NL80211_BAND_2GHZ]->ht_cap.cap |= |
| 8999 | IEEE80211_HT_CAP_TX_STBC; |
| 9000 | if (NULL != hdd_ctx->wiphy->bands[NL80211_BAND_5GHZ]) |
| 9001 | hdd_ctx->wiphy->bands[NL80211_BAND_5GHZ]->ht_cap.cap |= |
| 9002 | IEEE80211_HT_CAP_TX_STBC; |
| 9003 | } |
Yingying Tang | 3ba3dbc | 2016-09-27 16:36:58 +0800 | [diff] [blame^] | 9004 | |
| 9005 | if (!sme_is_feature_supported_by_fw(DOT11AC)) { |
| 9006 | hdd_ctx->wiphy->bands[NL80211_BAND_2GHZ]-> |
| 9007 | vht_cap.vht_supported = 0; |
| 9008 | hdd_ctx->wiphy->bands[NL80211_BAND_2GHZ]->vht_cap.cap = 0; |
| 9009 | hdd_ctx->wiphy->bands[NL80211_BAND_5GHZ]-> |
| 9010 | vht_cap.vht_supported = 0; |
| 9011 | hdd_ctx->wiphy->bands[NL80211_BAND_5GHZ]->vht_cap.cap = 0; |
| 9012 | } |
Yingying Tang | 80e15f3 | 2016-09-27 18:23:01 +0800 | [diff] [blame] | 9013 | } |
| 9014 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9015 | /* |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 9016 | * In this function, wiphy structure is updated after QDF |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9017 | * initialization. In wlan_hdd_cfg80211_init, only the |
| 9018 | * default values will be initialized. The final initialization |
| 9019 | * of all required members can be done here. |
| 9020 | */ |
Yingying Tang | 80e15f3 | 2016-09-27 18:23:01 +0800 | [diff] [blame] | 9021 | void wlan_hdd_update_wiphy(hdd_context_t *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9022 | { |
Yingying Tang | 80e15f3 | 2016-09-27 18:23:01 +0800 | [diff] [blame] | 9023 | hdd_ctx->wiphy->max_ap_assoc_sta = hdd_ctx->config->maxNumberOfPeers; |
| 9024 | |
| 9025 | wlan_hdd_update_band_cap(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9026 | } |
| 9027 | |
Yingying Tang | 3ba3dbc | 2016-09-27 16:36:58 +0800 | [diff] [blame^] | 9028 | /** |
| 9029 | * wlan_hdd_update_11n_mode - update 11n mode in hdd cfg |
| 9030 | * @cfg: hdd cfg |
| 9031 | * |
| 9032 | * this function update 11n mode in hdd cfg |
| 9033 | * |
| 9034 | * Return: void |
| 9035 | */ |
| 9036 | void wlan_hdd_update_11n_mode(struct hdd_config *cfg) |
| 9037 | { |
| 9038 | if (sme_is_feature_supported_by_fw(DOT11AC)) { |
| 9039 | hdd_notice("support 11ac"); |
| 9040 | } else { |
| 9041 | hdd_notice("not support 11ac"); |
| 9042 | if ((cfg->dot11Mode == eHDD_DOT11_MODE_11ac_ONLY) || |
| 9043 | (cfg->dot11Mode == eHDD_DOT11_MODE_11ac)) { |
| 9044 | cfg->dot11Mode = eHDD_DOT11_MODE_11n; |
| 9045 | cfg->sap_p2p_11ac_override = 0; |
| 9046 | } |
| 9047 | } |
| 9048 | } |
| 9049 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9050 | /* In this function we are registering wiphy. */ |
| 9051 | int wlan_hdd_cfg80211_register(struct wiphy *wiphy) |
| 9052 | { |
| 9053 | ENTER(); |
| 9054 | /* Register our wiphy dev with cfg80211 */ |
| 9055 | if (0 > wiphy_register(wiphy)) { |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 9056 | hdd_err("wiphy register failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9057 | return -EIO; |
| 9058 | } |
| 9059 | |
| 9060 | EXIT(); |
| 9061 | return 0; |
| 9062 | } |
| 9063 | |
| 9064 | /* |
| 9065 | HDD function to update wiphy capability based on target offload status. |
| 9066 | |
| 9067 | wlan_hdd_cfg80211_init() does initialization of all wiphy related |
| 9068 | capability even before downloading firmware to the target. In discrete |
| 9069 | case, host will get know certain offload capability (say sched_scan |
| 9070 | caps) only after downloading firmware to the target and target boots up. |
| 9071 | This function is used to override setting done in wlan_hdd_cfg80211_init() |
| 9072 | based on target capability. |
| 9073 | */ |
| 9074 | void wlan_hdd_cfg80211_update_wiphy_caps(struct wiphy *wiphy) |
| 9075 | { |
| 9076 | #ifdef FEATURE_WLAN_SCAN_PNO |
| 9077 | hdd_context_t *pHddCtx = wiphy_priv(wiphy); |
| 9078 | struct hdd_config *pCfg = pHddCtx->config; |
| 9079 | |
| 9080 | /* wlan_hdd_cfg80211_init() sets sched_scan caps already in wiphy before |
| 9081 | * control comes here. Here just we need to clear it if firmware doesn't |
| 9082 | * have PNO support. */ |
| 9083 | if (!pCfg->PnoOffload) { |
| 9084 | wiphy->flags &= ~WIPHY_FLAG_SUPPORTS_SCHED_SCAN; |
| 9085 | wiphy->max_sched_scan_ssids = 0; |
| 9086 | wiphy->max_match_sets = 0; |
| 9087 | wiphy->max_sched_scan_ie_len = 0; |
| 9088 | } |
| 9089 | #endif |
| 9090 | } |
| 9091 | |
| 9092 | /* This function registers for all frame which supplicant is interested in */ |
| 9093 | void wlan_hdd_cfg80211_register_frames(hdd_adapter_t *pAdapter) |
| 9094 | { |
| 9095 | tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter); |
| 9096 | /* Register for all P2P action, public action etc frames */ |
| 9097 | uint16_t type = (SIR_MAC_MGMT_FRAME << 2) | (SIR_MAC_MGMT_ACTION << 4); |
| 9098 | |
| 9099 | ENTER(); |
| 9100 | |
Abhishek Singh | 7996eb7 | 2015-12-30 17:24:02 +0530 | [diff] [blame] | 9101 | /* Register frame indication call back */ |
| 9102 | sme_register_mgmt_frame_ind_callback(hHal, hdd_indicate_mgmt_frame); |
| 9103 | |
Selvaraj, Sridhar | 4577a9b | 2016-09-04 15:17:07 +0530 | [diff] [blame] | 9104 | /* Register for p2p ack indication */ |
| 9105 | sme_register_p2p_ack_ind_callback(hHal, hdd_send_action_cnf_cb); |
| 9106 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9107 | /* Right now we are registering these frame when driver is getting |
| 9108 | initialized. Once we will move to 2.6.37 kernel, in which we have |
| 9109 | frame register ops, we will move this code as a part of that */ |
| 9110 | /* GAS Initial Request */ |
| 9111 | sme_register_mgmt_frame(hHal, SME_SESSION_ID_ANY, type, |
| 9112 | (uint8_t *) GAS_INITIAL_REQ, |
| 9113 | GAS_INITIAL_REQ_SIZE); |
| 9114 | |
| 9115 | /* GAS Initial Response */ |
| 9116 | sme_register_mgmt_frame(hHal, SME_SESSION_ID_ANY, type, |
| 9117 | (uint8_t *) GAS_INITIAL_RSP, |
| 9118 | GAS_INITIAL_RSP_SIZE); |
| 9119 | |
| 9120 | /* GAS Comeback Request */ |
| 9121 | sme_register_mgmt_frame(hHal, SME_SESSION_ID_ANY, type, |
| 9122 | (uint8_t *) GAS_COMEBACK_REQ, |
| 9123 | GAS_COMEBACK_REQ_SIZE); |
| 9124 | |
| 9125 | /* GAS Comeback Response */ |
| 9126 | sme_register_mgmt_frame(hHal, SME_SESSION_ID_ANY, type, |
| 9127 | (uint8_t *) GAS_COMEBACK_RSP, |
| 9128 | GAS_COMEBACK_RSP_SIZE); |
| 9129 | |
| 9130 | /* P2P Public Action */ |
| 9131 | sme_register_mgmt_frame(hHal, SME_SESSION_ID_ANY, type, |
| 9132 | (uint8_t *) P2P_PUBLIC_ACTION_FRAME, |
| 9133 | P2P_PUBLIC_ACTION_FRAME_SIZE); |
| 9134 | |
| 9135 | /* P2P Action */ |
| 9136 | sme_register_mgmt_frame(hHal, SME_SESSION_ID_ANY, type, |
| 9137 | (uint8_t *) P2P_ACTION_FRAME, |
| 9138 | P2P_ACTION_FRAME_SIZE); |
| 9139 | |
| 9140 | /* WNM BSS Transition Request frame */ |
| 9141 | sme_register_mgmt_frame(hHal, SME_SESSION_ID_ANY, type, |
| 9142 | (uint8_t *) WNM_BSS_ACTION_FRAME, |
| 9143 | WNM_BSS_ACTION_FRAME_SIZE); |
| 9144 | |
| 9145 | /* WNM-Notification */ |
| 9146 | sme_register_mgmt_frame(hHal, pAdapter->sessionId, type, |
| 9147 | (uint8_t *) WNM_NOTIFICATION_FRAME, |
| 9148 | WNM_NOTIFICATION_FRAME_SIZE); |
| 9149 | } |
| 9150 | |
| 9151 | void wlan_hdd_cfg80211_deregister_frames(hdd_adapter_t *pAdapter) |
| 9152 | { |
| 9153 | tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter); |
| 9154 | /* Register for all P2P action, public action etc frames */ |
| 9155 | uint16_t type = (SIR_MAC_MGMT_FRAME << 2) | (SIR_MAC_MGMT_ACTION << 4); |
| 9156 | |
| 9157 | ENTER(); |
| 9158 | |
| 9159 | /* Right now we are registering these frame when driver is getting |
| 9160 | initialized. Once we will move to 2.6.37 kernel, in which we have |
| 9161 | frame register ops, we will move this code as a part of that */ |
| 9162 | /* GAS Initial Request */ |
| 9163 | |
| 9164 | sme_deregister_mgmt_frame(hHal, SME_SESSION_ID_ANY, type, |
| 9165 | (uint8_t *) GAS_INITIAL_REQ, |
| 9166 | GAS_INITIAL_REQ_SIZE); |
| 9167 | |
| 9168 | /* GAS Initial Response */ |
| 9169 | sme_deregister_mgmt_frame(hHal, SME_SESSION_ID_ANY, type, |
| 9170 | (uint8_t *) GAS_INITIAL_RSP, |
| 9171 | GAS_INITIAL_RSP_SIZE); |
| 9172 | |
| 9173 | /* GAS Comeback Request */ |
| 9174 | sme_deregister_mgmt_frame(hHal, SME_SESSION_ID_ANY, type, |
| 9175 | (uint8_t *) GAS_COMEBACK_REQ, |
| 9176 | GAS_COMEBACK_REQ_SIZE); |
| 9177 | |
| 9178 | /* GAS Comeback Response */ |
| 9179 | sme_deregister_mgmt_frame(hHal, SME_SESSION_ID_ANY, type, |
| 9180 | (uint8_t *) GAS_COMEBACK_RSP, |
| 9181 | GAS_COMEBACK_RSP_SIZE); |
| 9182 | |
| 9183 | /* P2P Public Action */ |
| 9184 | sme_deregister_mgmt_frame(hHal, SME_SESSION_ID_ANY, type, |
| 9185 | (uint8_t *) P2P_PUBLIC_ACTION_FRAME, |
| 9186 | P2P_PUBLIC_ACTION_FRAME_SIZE); |
| 9187 | |
| 9188 | /* P2P Action */ |
| 9189 | sme_deregister_mgmt_frame(hHal, SME_SESSION_ID_ANY, type, |
| 9190 | (uint8_t *) P2P_ACTION_FRAME, |
| 9191 | P2P_ACTION_FRAME_SIZE); |
| 9192 | |
| 9193 | /* WNM-Notification */ |
| 9194 | sme_deregister_mgmt_frame(hHal, pAdapter->sessionId, type, |
| 9195 | (uint8_t *) WNM_NOTIFICATION_FRAME, |
| 9196 | WNM_NOTIFICATION_FRAME_SIZE); |
| 9197 | } |
| 9198 | |
| 9199 | #ifdef FEATURE_WLAN_WAPI |
| 9200 | void wlan_hdd_cfg80211_set_key_wapi(hdd_adapter_t *pAdapter, uint8_t key_index, |
| 9201 | const uint8_t *mac_addr, const uint8_t *key, |
| 9202 | int key_Len) |
| 9203 | { |
| 9204 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 9205 | tCsrRoamSetKey setKey; |
| 9206 | bool isConnected = true; |
| 9207 | int status = 0; |
| 9208 | uint32_t roamId = 0xFF; |
| 9209 | uint8_t *pKeyPtr = NULL; |
| 9210 | int n = 0; |
| 9211 | |
Jeff Johnson | 46b4079 | 2016-06-29 14:03:14 -0700 | [diff] [blame] | 9212 | hdd_notice("Device_mode %s(%d)", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9213 | hdd_device_mode_to_string(pAdapter->device_mode), |
| 9214 | pAdapter->device_mode); |
| 9215 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 9216 | qdf_mem_zero(&setKey, sizeof(tCsrRoamSetKey)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9217 | setKey.keyId = key_index; /* Store Key ID */ |
| 9218 | setKey.encType = eCSR_ENCRYPT_TYPE_WPI; /* SET WAPI Encryption */ |
| 9219 | setKey.keyDirection = eSIR_TX_RX; /* Key Directionn both TX and RX */ |
| 9220 | setKey.paeRole = 0; /* the PAE role */ |
| 9221 | if (!mac_addr || is_broadcast_ether_addr(mac_addr)) { |
Anurag Chouhan | c554842 | 2016-02-24 18:33:27 +0530 | [diff] [blame] | 9222 | qdf_set_macaddr_broadcast(&setKey.peerMac); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9223 | } else { |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 9224 | qdf_mem_copy(setKey.peerMac.bytes, mac_addr, QDF_MAC_ADDR_SIZE); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9225 | } |
| 9226 | setKey.keyLength = key_Len; |
| 9227 | pKeyPtr = setKey.Key; |
| 9228 | memcpy(pKeyPtr, key, key_Len); |
| 9229 | |
Jeff Johnson | 46b4079 | 2016-06-29 14:03:14 -0700 | [diff] [blame] | 9230 | hdd_notice("WAPI KEY LENGTH:0x%04x", key_Len); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9231 | for (n = 0; n < key_Len; n++) |
Jeff Johnson | 46b4079 | 2016-06-29 14:03:14 -0700 | [diff] [blame] | 9232 | hdd_notice("WAPI KEY Data[%d]:%02x ", |
| 9233 | n, setKey.Key[n]); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9234 | |
| 9235 | pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY; |
| 9236 | if (isConnected) { |
| 9237 | status = sme_roam_set_key(WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 9238 | pAdapter->sessionId, &setKey, &roamId); |
| 9239 | } |
| 9240 | if (status != 0) { |
Jeff Johnson | 46b4079 | 2016-06-29 14:03:14 -0700 | [diff] [blame] | 9241 | hdd_err("sme_roam_set_key returned ERROR status= %d", |
| 9242 | status); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9243 | pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE; |
| 9244 | } |
| 9245 | } |
| 9246 | #endif /* FEATURE_WLAN_WAPI */ |
| 9247 | |
| 9248 | uint8_t *wlan_hdd_cfg80211_get_ie_ptr(const uint8_t *ies_ptr, int length, |
| 9249 | uint8_t eid) |
| 9250 | { |
| 9251 | int left = length; |
| 9252 | uint8_t *ptr = (uint8_t *)ies_ptr; |
| 9253 | uint8_t elem_id, elem_len; |
| 9254 | |
| 9255 | while (left >= 2) { |
| 9256 | elem_id = ptr[0]; |
| 9257 | elem_len = ptr[1]; |
| 9258 | left -= 2; |
| 9259 | if (elem_len > left) { |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 9260 | hdd_alert("Invalid IEs eid = %d elem_len=%d left=%d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9261 | eid, elem_len, left); |
| 9262 | return NULL; |
| 9263 | } |
| 9264 | if (elem_id == eid) { |
| 9265 | return ptr; |
| 9266 | } |
| 9267 | |
| 9268 | left -= elem_len; |
| 9269 | ptr += (elem_len + 2); |
| 9270 | } |
| 9271 | return NULL; |
| 9272 | } |
| 9273 | |
| 9274 | /* |
| 9275 | * FUNCTION: wlan_hdd_validate_operation_channel |
| 9276 | * called by wlan_hdd_cfg80211_start_bss() and |
| 9277 | * wlan_hdd_set_channel() |
| 9278 | * This function validates whether given channel is part of valid |
| 9279 | * channel list. |
| 9280 | */ |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 9281 | QDF_STATUS wlan_hdd_validate_operation_channel(hdd_adapter_t *pAdapter, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9282 | int channel) |
| 9283 | { |
| 9284 | |
| 9285 | uint32_t num_ch = 0; |
| 9286 | u8 valid_ch[WNI_CFG_VALID_CHANNEL_LIST_LEN]; |
| 9287 | u32 indx = 0; |
| 9288 | tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter); |
| 9289 | uint8_t fValidChannel = false, count = 0; |
| 9290 | struct hdd_config *hdd_pConfig_ini = (WLAN_HDD_GET_CTX(pAdapter))->config; |
| 9291 | |
| 9292 | num_ch = WNI_CFG_VALID_CHANNEL_LIST_LEN; |
| 9293 | |
| 9294 | if (hdd_pConfig_ini->sapAllowAllChannel) { |
| 9295 | /* Validate the channel */ |
Amar Singhal | b8d4f15 | 2016-02-10 10:21:43 -0800 | [diff] [blame] | 9296 | for (count = CHAN_ENUM_1; count <= CHAN_ENUM_165; count++) { |
Amar Singhal | 7a1726a | 2015-10-14 16:28:11 -0700 | [diff] [blame] | 9297 | if (channel == CDS_CHANNEL_NUM(count)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9298 | fValidChannel = true; |
| 9299 | break; |
| 9300 | } |
| 9301 | } |
| 9302 | if (fValidChannel != true) { |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 9303 | hdd_err("Invalid Channel [%d]", channel); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 9304 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9305 | } |
| 9306 | } else { |
| 9307 | if (0 != sme_cfg_get_str(hHal, WNI_CFG_VALID_CHANNEL_LIST, |
| 9308 | valid_ch, &num_ch)) { |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 9309 | hdd_err("failed to get valid channel list"); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 9310 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9311 | } |
| 9312 | for (indx = 0; indx < num_ch; indx++) { |
| 9313 | if (channel == valid_ch[indx]) { |
| 9314 | break; |
| 9315 | } |
| 9316 | } |
| 9317 | |
| 9318 | if (indx >= num_ch) { |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 9319 | hdd_err("Invalid Channel [%d]", channel); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 9320 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9321 | } |
| 9322 | } |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 9323 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9324 | |
| 9325 | } |
| 9326 | |
| 9327 | #ifdef DHCP_SERVER_OFFLOAD |
| 9328 | static void wlan_hdd_set_dhcp_server_offload(hdd_adapter_t *pHostapdAdapter) |
| 9329 | { |
| 9330 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter); |
| 9331 | tpSirDhcpSrvOffloadInfo pDhcpSrvInfo; |
| 9332 | uint8_t numEntries = 0; |
| 9333 | uint8_t srv_ip[IPADDR_NUM_ENTRIES]; |
| 9334 | uint8_t num; |
| 9335 | uint32_t temp; |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 9336 | pDhcpSrvInfo = qdf_mem_malloc(sizeof(*pDhcpSrvInfo)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9337 | if (NULL == pDhcpSrvInfo) { |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 9338 | hdd_err("could not allocate tDhcpSrvOffloadInfo!"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9339 | return; |
| 9340 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9341 | pDhcpSrvInfo->vdev_id = pHostapdAdapter->sessionId; |
| 9342 | pDhcpSrvInfo->dhcpSrvOffloadEnabled = true; |
| 9343 | pDhcpSrvInfo->dhcpClientNum = pHddCtx->config->dhcpMaxNumClients; |
| 9344 | hdd_string_to_u8_array(pHddCtx->config->dhcpServerIP, |
| 9345 | srv_ip, &numEntries, IPADDR_NUM_ENTRIES); |
| 9346 | if (numEntries != IPADDR_NUM_ENTRIES) { |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 9347 | 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] | 9348 | goto end; |
| 9349 | } |
| 9350 | if ((srv_ip[0] >= 224) && (srv_ip[0] <= 239)) { |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 9351 | 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] | 9352 | goto end; |
| 9353 | } |
| 9354 | if (srv_ip[IPADDR_NUM_ENTRIES - 1] >= 100) { |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 9355 | 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] | 9356 | goto end; |
| 9357 | } |
| 9358 | for (num = 0; num < numEntries; num++) { |
| 9359 | temp = srv_ip[num]; |
| 9360 | pDhcpSrvInfo->dhcpSrvIP |= (temp << (8 * num)); |
| 9361 | } |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 9362 | if (QDF_STATUS_SUCCESS != |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9363 | sme_set_dhcp_srv_offload(pHddCtx->hHal, pDhcpSrvInfo)) { |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 9364 | hdd_err("sme_setDHCPSrvOffload fail!"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9365 | goto end; |
| 9366 | } |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 9367 | hdd_info("enable DHCP Server offload successfully!"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9368 | end: |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 9369 | qdf_mem_free(pDhcpSrvInfo); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9370 | return; |
| 9371 | } |
| 9372 | #endif /* DHCP_SERVER_OFFLOAD */ |
| 9373 | |
| 9374 | static int __wlan_hdd_cfg80211_change_bss(struct wiphy *wiphy, |
| 9375 | struct net_device *dev, |
| 9376 | struct bss_parameters *params) |
| 9377 | { |
| 9378 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 9379 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 9380 | int ret = 0; |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 9381 | QDF_STATUS qdf_ret_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9382 | |
| 9383 | ENTER(); |
| 9384 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 9385 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 9386 | hdd_err("Command not allowed in FTM mode"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9387 | return -EINVAL; |
| 9388 | } |
| 9389 | |
Hanumanth Reddy Pothula | d9491f4 | 2016-10-24 19:08:38 +0530 | [diff] [blame] | 9390 | if (wlan_hdd_validate_session_id(pAdapter->sessionId)) { |
| 9391 | hdd_err("invalid session id: %d", pAdapter->sessionId); |
| 9392 | return -EINVAL; |
| 9393 | } |
| 9394 | |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 9395 | MTRACE(qdf_trace(QDF_MODULE_ID_HDD, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9396 | TRACE_CODE_HDD_CFG80211_CHANGE_BSS, |
| 9397 | pAdapter->sessionId, params->ap_isolate)); |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 9398 | hdd_notice("Device_mode %s(%d), ap_isolate = %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9399 | hdd_device_mode_to_string(pAdapter->device_mode), |
| 9400 | pAdapter->device_mode, params->ap_isolate); |
| 9401 | |
| 9402 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 9403 | ret = wlan_hdd_validate_context(pHddCtx); |
Hanumantha Reddy Pothula | 2db50ed | 2015-11-23 10:48:33 +0530 | [diff] [blame] | 9404 | if (0 != ret) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9405 | return ret; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9406 | |
Krunal Soni | b4326f2 | 2016-03-10 13:05:51 -0800 | [diff] [blame] | 9407 | if (!(pAdapter->device_mode == QDF_SAP_MODE || |
| 9408 | pAdapter->device_mode == QDF_P2P_GO_MODE)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9409 | return -EOPNOTSUPP; |
| 9410 | } |
| 9411 | |
| 9412 | /* ap_isolate == -1 means that in change bss, upper layer doesn't |
| 9413 | * want to update this parameter */ |
| 9414 | if (-1 != params->ap_isolate) { |
| 9415 | pAdapter->sessionCtx.ap.apDisableIntraBssFwd = |
| 9416 | !!params->ap_isolate; |
| 9417 | |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 9418 | qdf_ret_status = sme_ap_disable_intra_bss_fwd(pHddCtx->hHal, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9419 | pAdapter->sessionId, |
| 9420 | pAdapter->sessionCtx. |
| 9421 | ap. |
| 9422 | apDisableIntraBssFwd); |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 9423 | if (!QDF_IS_STATUS_SUCCESS(qdf_ret_status)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9424 | ret = -EINVAL; |
| 9425 | } |
| 9426 | } |
| 9427 | |
| 9428 | EXIT(); |
| 9429 | return ret; |
| 9430 | } |
| 9431 | |
Krunal Soni | 8c37e32 | 2016-02-03 16:08:37 -0800 | [diff] [blame] | 9432 | /** |
| 9433 | * wlan_hdd_change_client_iface_to_new_mode() - to change iface to provided mode |
| 9434 | * @ndev: pointer to net device provided by supplicant |
| 9435 | * @type: type of the interface, upper layer wanted to change |
| 9436 | * |
| 9437 | * Upper layer provides the new interface mode that needs to be changed |
| 9438 | * for given net device |
| 9439 | * |
| 9440 | * Return: success or failure in terms of integer value |
| 9441 | */ |
| 9442 | 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] | 9443 | enum nl80211_iftype type) |
| 9444 | { |
Krunal Soni | 8c37e32 | 2016-02-03 16:08:37 -0800 | [diff] [blame] | 9445 | hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(ndev); |
| 9446 | hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 9447 | struct hdd_config *config = hdd_ctx->config; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9448 | hdd_wext_state_t *wext; |
| 9449 | struct wireless_dev *wdev; |
Arun Khandavalli | b2f6c26 | 2016-08-18 19:07:19 +0530 | [diff] [blame] | 9450 | QDF_STATUS status = QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9451 | |
| 9452 | ENTER(); |
| 9453 | |
Krunal Soni | 8c37e32 | 2016-02-03 16:08:37 -0800 | [diff] [blame] | 9454 | if (test_bit(ACS_IN_PROGRESS, &hdd_ctx->g_event_flags)) { |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 9455 | hdd_notice("ACS is in progress, don't change iface!"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9456 | return 0; |
| 9457 | } |
| 9458 | |
| 9459 | wdev = ndev->ieee80211_ptr; |
Krunal Soni | 8c37e32 | 2016-02-03 16:08:37 -0800 | [diff] [blame] | 9460 | hdd_stop_adapter(hdd_ctx, adapter, true); |
| 9461 | hdd_deinit_adapter(hdd_ctx, adapter, true); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9462 | wdev->iftype = type; |
| 9463 | /*Check for sub-string p2p to confirm its a p2p interface */ |
| 9464 | if (NULL != strnstr(ndev->name, "p2p", 3)) { |
Krunal Soni | 8c37e32 | 2016-02-03 16:08:37 -0800 | [diff] [blame] | 9465 | adapter->device_mode = |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9466 | (type == NL80211_IFTYPE_STATION) ? |
Krunal Soni | b4326f2 | 2016-03-10 13:05:51 -0800 | [diff] [blame] | 9467 | QDF_P2P_DEVICE_MODE : QDF_P2P_CLIENT_MODE; |
Krunal Soni | 8c37e32 | 2016-02-03 16:08:37 -0800 | [diff] [blame] | 9468 | } else if (type == NL80211_IFTYPE_ADHOC) { |
Krunal Soni | b4326f2 | 2016-03-10 13:05:51 -0800 | [diff] [blame] | 9469 | adapter->device_mode = QDF_IBSS_MODE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9470 | } else { |
Krunal Soni | 8c37e32 | 2016-02-03 16:08:37 -0800 | [diff] [blame] | 9471 | adapter->device_mode = |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9472 | (type == NL80211_IFTYPE_STATION) ? |
Krunal Soni | b4326f2 | 2016-03-10 13:05:51 -0800 | [diff] [blame] | 9473 | QDF_STA_MODE : QDF_P2P_CLIENT_MODE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9474 | } |
Krunal Soni | 8c37e32 | 2016-02-03 16:08:37 -0800 | [diff] [blame] | 9475 | memset(&adapter->sessionCtx, 0, sizeof(adapter->sessionCtx)); |
| 9476 | hdd_set_station_ops(adapter->dev); |
Krunal Soni | 8c37e32 | 2016-02-03 16:08:37 -0800 | [diff] [blame] | 9477 | wext = WLAN_HDD_GET_WEXT_STATE_PTR(adapter); |
| 9478 | wext->roamProfile.pAddIEScan = adapter->scan_info.scanAddIE.addIEdata; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9479 | wext->roamProfile.nAddIEScanLength = |
Krunal Soni | 8c37e32 | 2016-02-03 16:08:37 -0800 | [diff] [blame] | 9480 | adapter->scan_info.scanAddIE.length; |
| 9481 | if (type == NL80211_IFTYPE_ADHOC) { |
Arun Khandavalli | b2f6c26 | 2016-08-18 19:07:19 +0530 | [diff] [blame] | 9482 | status = hdd_init_station_mode(adapter); |
Krunal Soni | 8c37e32 | 2016-02-03 16:08:37 -0800 | [diff] [blame] | 9483 | wext->roamProfile.BSSType = eCSR_BSS_TYPE_START_IBSS; |
| 9484 | wext->roamProfile.phyMode = |
| 9485 | hdd_cfg_xlate_to_csr_phy_mode(config->dot11Mode); |
| 9486 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9487 | EXIT(); |
| 9488 | return status; |
| 9489 | } |
| 9490 | |
| 9491 | static int wlan_hdd_cfg80211_change_bss(struct wiphy *wiphy, |
| 9492 | struct net_device *dev, |
| 9493 | struct bss_parameters *params) |
| 9494 | { |
| 9495 | int ret; |
| 9496 | |
| 9497 | cds_ssr_protect(__func__); |
| 9498 | ret = __wlan_hdd_cfg80211_change_bss(wiphy, dev, params); |
| 9499 | cds_ssr_unprotect(__func__); |
| 9500 | |
| 9501 | return ret; |
| 9502 | } |
| 9503 | |
| 9504 | /* FUNCTION: wlan_hdd_change_country_code_cd |
| 9505 | * to wait for contry code completion |
| 9506 | */ |
| 9507 | void *wlan_hdd_change_country_code_cb(void *pAdapter) |
| 9508 | { |
| 9509 | hdd_adapter_t *call_back_pAdapter = pAdapter; |
| 9510 | complete(&call_back_pAdapter->change_country_code); |
| 9511 | return NULL; |
| 9512 | } |
| 9513 | |
Rajeev Kumar | 98edb77 | 2016-01-19 12:42:19 -0800 | [diff] [blame] | 9514 | /** |
| 9515 | * __wlan_hdd_cfg80211_change_iface() - change interface cfg80211 op |
| 9516 | * @wiphy: Pointer to the wiphy structure |
| 9517 | * @ndev: Pointer to the net device |
| 9518 | * @type: Interface type |
| 9519 | * @flags: Flags for change interface |
| 9520 | * @params: Pointer to change interface parameters |
| 9521 | * |
| 9522 | * Return: 0 for success, error number on failure. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9523 | */ |
| 9524 | static int __wlan_hdd_cfg80211_change_iface(struct wiphy *wiphy, |
| 9525 | struct net_device *ndev, |
| 9526 | enum nl80211_iftype type, |
| 9527 | u32 *flags, |
| 9528 | struct vif_params *params) |
| 9529 | { |
| 9530 | struct wireless_dev *wdev; |
| 9531 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(ndev); |
| 9532 | hdd_context_t *pHddCtx; |
| 9533 | tCsrRoamProfile *pRoamProfile = NULL; |
| 9534 | eCsrRoamBssType LastBSSType; |
| 9535 | struct hdd_config *pConfig = NULL; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 9536 | QDF_STATUS vstatus; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9537 | int status; |
| 9538 | |
| 9539 | ENTER(); |
| 9540 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 9541 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 9542 | hdd_err("Command not allowed in FTM mode"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9543 | return -EINVAL; |
| 9544 | } |
| 9545 | |
| 9546 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 9547 | status = wlan_hdd_validate_context(pHddCtx); |
Hanumantha Reddy Pothula | 2db50ed | 2015-11-23 10:48:33 +0530 | [diff] [blame] | 9548 | if (0 != status) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9549 | return status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9550 | |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 9551 | MTRACE(qdf_trace(QDF_MODULE_ID_HDD, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9552 | TRACE_CODE_HDD_CFG80211_CHANGE_IFACE, |
| 9553 | pAdapter->sessionId, type)); |
| 9554 | |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 9555 | hdd_notice("Device_mode = %d, IFTYPE = 0x%x", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9556 | pAdapter->device_mode, type); |
| 9557 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9558 | status = hdd_wlan_start_modules(pHddCtx, pAdapter, false); |
| 9559 | if (status) { |
| 9560 | hdd_err("Failed to start modules"); |
| 9561 | return -EINVAL; |
| 9562 | } |
| 9563 | |
Tushnim Bhattacharyya | ca50b32 | 2015-12-28 17:14:36 -0800 | [diff] [blame] | 9564 | if (!cds_allow_concurrency( |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9565 | wlan_hdd_convert_nl_iftype_to_hdd_type(type), |
| 9566 | 0, HW_MODE_20_MHZ)) { |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 9567 | hdd_debug("This concurrency combination is not allowed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9568 | return -EINVAL; |
| 9569 | } |
| 9570 | |
| 9571 | pConfig = pHddCtx->config; |
| 9572 | wdev = ndev->ieee80211_ptr; |
| 9573 | |
| 9574 | /* Reset the current device mode bit mask */ |
Tushnim Bhattacharyya | ca50b32 | 2015-12-28 17:14:36 -0800 | [diff] [blame] | 9575 | cds_clear_concurrency_mode(pAdapter->device_mode); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9576 | |
| 9577 | hdd_tdls_notify_mode_change(pAdapter, pHddCtx); |
| 9578 | |
Krunal Soni | b4326f2 | 2016-03-10 13:05:51 -0800 | [diff] [blame] | 9579 | if ((pAdapter->device_mode == QDF_STA_MODE) || |
| 9580 | (pAdapter->device_mode == QDF_P2P_CLIENT_MODE) || |
| 9581 | (pAdapter->device_mode == QDF_P2P_DEVICE_MODE) || |
| 9582 | (pAdapter->device_mode == QDF_IBSS_MODE)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9583 | hdd_wext_state_t *pWextState = |
| 9584 | WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
| 9585 | |
| 9586 | pRoamProfile = &pWextState->roamProfile; |
| 9587 | LastBSSType = pRoamProfile->BSSType; |
| 9588 | |
| 9589 | switch (type) { |
| 9590 | case NL80211_IFTYPE_STATION: |
| 9591 | case NL80211_IFTYPE_P2P_CLIENT: |
Krunal Soni | 8c37e32 | 2016-02-03 16:08:37 -0800 | [diff] [blame] | 9592 | case NL80211_IFTYPE_ADHOC: |
| 9593 | if (type == NL80211_IFTYPE_ADHOC) { |
| 9594 | wlan_hdd_tdls_exit(pAdapter); |
| 9595 | hdd_deregister_tx_flow_control(pAdapter); |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 9596 | hdd_notice("Setting interface Type to ADHOC"); |
Krunal Soni | 8c37e32 | 2016-02-03 16:08:37 -0800 | [diff] [blame] | 9597 | } |
| 9598 | vstatus = wlan_hdd_change_client_iface_to_new_mode(ndev, |
| 9599 | type); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 9600 | if (vstatus != QDF_STATUS_SUCCESS) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9601 | return -EINVAL; |
Arun Khandavalli | b2f6c26 | 2016-08-18 19:07:19 +0530 | [diff] [blame] | 9602 | if (hdd_start_adapter(pAdapter)) { |
| 9603 | hdd_err("Failed to start adapter :%d", |
| 9604 | pAdapter->device_mode); |
| 9605 | return -EINVAL; |
| 9606 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9607 | goto done; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9608 | case NL80211_IFTYPE_AP: |
| 9609 | case NL80211_IFTYPE_P2P_GO: |
| 9610 | { |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 9611 | hdd_info("Setting interface Type to %s", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9612 | (type == |
| 9613 | NL80211_IFTYPE_AP) ? "SoftAP" : |
| 9614 | "P2pGo"); |
| 9615 | |
| 9616 | /* Cancel any remain on channel for GO mode */ |
| 9617 | if (NL80211_IFTYPE_P2P_GO == type) { |
| 9618 | wlan_hdd_cancel_existing_remain_on_channel |
| 9619 | (pAdapter); |
| 9620 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9621 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9622 | hdd_stop_adapter(pHddCtx, pAdapter, true); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9623 | /* De-init the adapter */ |
| 9624 | hdd_deinit_adapter(pHddCtx, pAdapter, true); |
| 9625 | memset(&pAdapter->sessionCtx, 0, |
| 9626 | sizeof(pAdapter->sessionCtx)); |
| 9627 | pAdapter->device_mode = |
| 9628 | (type == |
Krunal Soni | b4326f2 | 2016-03-10 13:05:51 -0800 | [diff] [blame] | 9629 | NL80211_IFTYPE_AP) ? QDF_SAP_MODE : |
| 9630 | QDF_P2P_GO_MODE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9631 | |
| 9632 | /* |
| 9633 | * Fw will take care incase of concurrency |
| 9634 | */ |
| 9635 | |
Krunal Soni | b4326f2 | 2016-03-10 13:05:51 -0800 | [diff] [blame] | 9636 | if ((QDF_SAP_MODE == pAdapter->device_mode) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9637 | && (pConfig->apRandomBssidEnabled)) { |
| 9638 | /* To meet Android requirements create a randomized |
| 9639 | MAC address of the form 02:1A:11:Fx:xx:xx */ |
| 9640 | get_random_bytes(&ndev->dev_addr[3], 3); |
| 9641 | ndev->dev_addr[0] = 0x02; |
| 9642 | ndev->dev_addr[1] = 0x1A; |
| 9643 | ndev->dev_addr[2] = 0x11; |
| 9644 | ndev->dev_addr[3] |= 0xF0; |
| 9645 | memcpy(pAdapter->macAddressCurrent. |
| 9646 | bytes, ndev->dev_addr, |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 9647 | QDF_MAC_ADDR_SIZE); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9648 | pr_info("wlan: Generated HotSpot BSSID " |
| 9649 | MAC_ADDRESS_STR "\n", |
| 9650 | MAC_ADDR_ARRAY(ndev->dev_addr)); |
| 9651 | } |
| 9652 | |
| 9653 | hdd_set_ap_ops(pAdapter->dev); |
| 9654 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9655 | if (hdd_start_adapter(pAdapter)) { |
| 9656 | hdd_err("Error initializing the ap mode"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9657 | return -EINVAL; |
| 9658 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9659 | /* Interface type changed update in wiphy structure */ |
| 9660 | if (wdev) { |
| 9661 | wdev->iftype = type; |
| 9662 | } else { |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 9663 | hdd_err("Wireless dev is NULL"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9664 | return -EINVAL; |
| 9665 | } |
| 9666 | goto done; |
| 9667 | } |
| 9668 | |
| 9669 | default: |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 9670 | hdd_err("Unsupported interface type (%d)", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9671 | type); |
| 9672 | return -EOPNOTSUPP; |
| 9673 | } |
Krunal Soni | b4326f2 | 2016-03-10 13:05:51 -0800 | [diff] [blame] | 9674 | } else if ((pAdapter->device_mode == QDF_SAP_MODE) || |
| 9675 | (pAdapter->device_mode == QDF_P2P_GO_MODE)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9676 | switch (type) { |
| 9677 | case NL80211_IFTYPE_STATION: |
| 9678 | case NL80211_IFTYPE_P2P_CLIENT: |
| 9679 | case NL80211_IFTYPE_ADHOC: |
Krunal Soni | 8c37e32 | 2016-02-03 16:08:37 -0800 | [diff] [blame] | 9680 | status = wlan_hdd_change_client_iface_to_new_mode(ndev, |
| 9681 | type); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 9682 | if (status != QDF_STATUS_SUCCESS) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9683 | return status; |
Arun Khandavalli | b2f6c26 | 2016-08-18 19:07:19 +0530 | [diff] [blame] | 9684 | if (hdd_start_adapter(pAdapter)) { |
| 9685 | hdd_err("Failed to start adapter :%d", |
| 9686 | pAdapter->device_mode); |
| 9687 | return -EINVAL; |
| 9688 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9689 | goto done; |
| 9690 | |
| 9691 | case NL80211_IFTYPE_AP: |
| 9692 | case NL80211_IFTYPE_P2P_GO: |
| 9693 | wdev->iftype = type; |
| 9694 | pAdapter->device_mode = (type == NL80211_IFTYPE_AP) ? |
Krunal Soni | b4326f2 | 2016-03-10 13:05:51 -0800 | [diff] [blame] | 9695 | QDF_SAP_MODE : QDF_P2P_GO_MODE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9696 | goto done; |
| 9697 | |
| 9698 | default: |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 9699 | hdd_err("Unsupported interface type(%d)", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9700 | type); |
| 9701 | return -EOPNOTSUPP; |
| 9702 | } |
| 9703 | } else { |
Jeff Johnson | 7784811 | 2016-06-29 14:52:06 -0700 | [diff] [blame] | 9704 | hdd_err("Unsupported device mode(%d)", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9705 | pAdapter->device_mode); |
| 9706 | return -EOPNOTSUPP; |
| 9707 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9708 | done: |
| 9709 | /* Set bitmask based on updated value */ |
Tushnim Bhattacharyya | ca50b32 | 2015-12-28 17:14:36 -0800 | [diff] [blame] | 9710 | cds_set_concurrency_mode(pAdapter->device_mode); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9711 | |
Jeff Johnson | 2ae6f71 | 2016-09-23 15:08:48 -0700 | [diff] [blame] | 9712 | hdd_lpass_notify_mode_change(pAdapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9713 | |
| 9714 | EXIT(); |
| 9715 | return 0; |
| 9716 | } |
| 9717 | |
Rajeev Kumar | 98edb77 | 2016-01-19 12:42:19 -0800 | [diff] [blame] | 9718 | /** |
| 9719 | * wlan_hdd_cfg80211_change_iface() - change interface cfg80211 op |
| 9720 | * @wiphy: Pointer to the wiphy structure |
| 9721 | * @ndev: Pointer to the net device |
| 9722 | * @type: Interface type |
| 9723 | * @flags: Flags for change interface |
| 9724 | * @params: Pointer to change interface parameters |
| 9725 | * |
| 9726 | * Return: 0 for success, error number on failure. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9727 | */ |
| 9728 | static int wlan_hdd_cfg80211_change_iface(struct wiphy *wiphy, |
| 9729 | struct net_device *ndev, |
| 9730 | enum nl80211_iftype type, |
| 9731 | u32 *flags, |
| 9732 | struct vif_params *params) |
| 9733 | { |
| 9734 | int ret; |
| 9735 | |
| 9736 | cds_ssr_protect(__func__); |
| 9737 | ret = |
| 9738 | __wlan_hdd_cfg80211_change_iface(wiphy, ndev, type, flags, params); |
| 9739 | cds_ssr_unprotect(__func__); |
| 9740 | |
| 9741 | return ret; |
| 9742 | } |
| 9743 | |
| 9744 | #ifdef FEATURE_WLAN_TDLS |
| 9745 | static bool wlan_hdd_is_duplicate_channel(uint8_t *arr, |
| 9746 | int index, uint8_t match) |
| 9747 | { |
| 9748 | int i; |
| 9749 | for (i = 0; i < index; i++) { |
| 9750 | if (arr[i] == match) |
| 9751 | return true; |
| 9752 | } |
| 9753 | return false; |
| 9754 | } |
| 9755 | #endif |
| 9756 | |
| 9757 | /** |
| 9758 | * __wlan_hdd_change_station() - change station |
| 9759 | * @wiphy: Pointer to the wiphy structure |
| 9760 | * @dev: Pointer to the net device. |
| 9761 | * @mac: bssid |
| 9762 | * @params: Pointer to station parameters |
| 9763 | * |
| 9764 | * Return: 0 for success, error number on failure. |
| 9765 | */ |
| 9766 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 16, 0)) |
| 9767 | static int __wlan_hdd_change_station(struct wiphy *wiphy, |
| 9768 | struct net_device *dev, |
| 9769 | const uint8_t *mac, |
| 9770 | struct station_parameters *params) |
| 9771 | #else |
| 9772 | static int __wlan_hdd_change_station(struct wiphy *wiphy, |
| 9773 | struct net_device *dev, |
| 9774 | uint8_t *mac, |
| 9775 | struct station_parameters *params) |
| 9776 | #endif |
| 9777 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 9778 | QDF_STATUS status = QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9779 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 9780 | hdd_context_t *pHddCtx; |
| 9781 | hdd_station_ctx_t *pHddStaCtx; |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 9782 | struct qdf_mac_addr STAMacAddress; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9783 | #ifdef FEATURE_WLAN_TDLS |
| 9784 | tCsrStaParams StaParams = { 0 }; |
| 9785 | uint8_t isBufSta = 0; |
| 9786 | uint8_t isOffChannelSupported = 0; |
Nitesh Shah | 99934ac | 2016-09-05 15:54:08 +0530 | [diff] [blame] | 9787 | bool is_qos_wmm_sta = false; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9788 | #endif |
| 9789 | int ret; |
| 9790 | |
| 9791 | ENTER(); |
| 9792 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 9793 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 9794 | hdd_err("Command not allowed in FTM mode"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9795 | return -EINVAL; |
| 9796 | } |
| 9797 | |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 9798 | MTRACE(qdf_trace(QDF_MODULE_ID_HDD, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9799 | TRACE_CODE_HDD_CHANGE_STATION, |
| 9800 | pAdapter->sessionId, params->listen_interval)); |
| 9801 | |
Hanumanth Reddy Pothula | d9491f4 | 2016-10-24 19:08:38 +0530 | [diff] [blame] | 9802 | if (wlan_hdd_validate_session_id(pAdapter->sessionId)) { |
| 9803 | hdd_err("invalid session id: %d", pAdapter->sessionId); |
| 9804 | return -EINVAL; |
| 9805 | } |
| 9806 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9807 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 9808 | ret = wlan_hdd_validate_context(pHddCtx); |
Hanumantha Reddy Pothula | 2db50ed | 2015-11-23 10:48:33 +0530 | [diff] [blame] | 9809 | if (0 != ret) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9810 | return ret; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9811 | |
| 9812 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 9813 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 9814 | qdf_mem_copy(STAMacAddress.bytes, mac, QDF_MAC_ADDR_SIZE); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9815 | |
Krunal Soni | b4326f2 | 2016-03-10 13:05:51 -0800 | [diff] [blame] | 9816 | if ((pAdapter->device_mode == QDF_SAP_MODE) || |
| 9817 | (pAdapter->device_mode == QDF_P2P_GO_MODE)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9818 | if (params->sta_flags_set & BIT(NL80211_STA_FLAG_AUTHORIZED)) { |
| 9819 | status = |
| 9820 | hdd_softap_change_sta_state(pAdapter, |
| 9821 | &STAMacAddress, |
Dhanashri Atre | b08959a | 2016-03-01 17:28:03 -0800 | [diff] [blame] | 9822 | OL_TXRX_PEER_STATE_AUTH); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9823 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 9824 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 9825 | hdd_notice("Not able to change TL state to AUTHENTICATED"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9826 | return -EINVAL; |
| 9827 | } |
| 9828 | } |
Krunal Soni | b4326f2 | 2016-03-10 13:05:51 -0800 | [diff] [blame] | 9829 | } else if ((pAdapter->device_mode == QDF_STA_MODE) || |
| 9830 | (pAdapter->device_mode == QDF_P2P_CLIENT_MODE)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9831 | #ifdef FEATURE_WLAN_TDLS |
| 9832 | if (params->sta_flags_set & BIT(NL80211_STA_FLAG_TDLS_PEER)) { |
Naveen Rawat | 64e477e | 2016-05-20 10:34:56 -0700 | [diff] [blame] | 9833 | |
| 9834 | if (cds_is_sub_20_mhz_enabled()) { |
| 9835 | hdd_err("TDLS not allowed with sub 20 MHz"); |
| 9836 | return -EINVAL; |
| 9837 | } |
| 9838 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9839 | StaParams.capability = params->capability; |
| 9840 | StaParams.uapsd_queues = params->uapsd_queues; |
| 9841 | StaParams.max_sp = params->max_sp; |
| 9842 | |
| 9843 | /* Convert (first channel , number of channels) tuple to |
| 9844 | * the total list of channels. This goes with the assumption |
| 9845 | * that if the first channel is < 14, then the next channels |
| 9846 | * are an incremental of 1 else an incremental of 4 till the number |
| 9847 | * of channels. |
| 9848 | */ |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 9849 | hdd_notice("params->supported_channels_len: %d", params->supported_channels_len); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9850 | if (0 != params->supported_channels_len) { |
| 9851 | int i = 0, j = 0, k = 0, no_of_channels = 0; |
| 9852 | int num_unique_channels; |
| 9853 | int next; |
| 9854 | for (i = 0; |
| 9855 | i < params->supported_channels_len |
| 9856 | && j < SIR_MAC_MAX_SUPP_CHANNELS; i += 2) { |
| 9857 | int wifi_chan_index; |
| 9858 | if (!wlan_hdd_is_duplicate_channel |
| 9859 | (StaParams.supported_channels, j, |
| 9860 | params->supported_channels[i])) { |
| 9861 | StaParams. |
| 9862 | supported_channels[j] = |
| 9863 | params-> |
| 9864 | supported_channels[i]; |
| 9865 | } else { |
| 9866 | continue; |
| 9867 | } |
| 9868 | wifi_chan_index = |
| 9869 | ((StaParams.supported_channels[j] <= |
| 9870 | HDD_CHANNEL_14) ? 1 : 4); |
| 9871 | no_of_channels = |
| 9872 | params->supported_channels[i + 1]; |
| 9873 | |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 9874 | 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] | 9875 | StaParams. |
| 9876 | supported_channels[j], |
| 9877 | wifi_chan_index, |
| 9878 | no_of_channels); |
| 9879 | for (k = 1; k <= no_of_channels && |
| 9880 | j < SIR_MAC_MAX_SUPP_CHANNELS - 1; |
| 9881 | k++) { |
| 9882 | next = |
| 9883 | StaParams. |
| 9884 | supported_channels[j] + |
| 9885 | wifi_chan_index; |
| 9886 | if (!wlan_hdd_is_duplicate_channel(StaParams.supported_channels, j + 1, next)) { |
| 9887 | StaParams. |
| 9888 | supported_channels[j |
| 9889 | + |
| 9890 | 1] |
| 9891 | = next; |
| 9892 | } else { |
| 9893 | continue; |
| 9894 | } |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 9895 | 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] | 9896 | j + 1, |
| 9897 | StaParams. |
| 9898 | supported_channels[j + |
| 9899 | 1]); |
| 9900 | j += 1; |
| 9901 | } |
| 9902 | } |
| 9903 | num_unique_channels = j + 1; |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 9904 | hdd_notice("Unique Channel List"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9905 | for (i = 0; i < num_unique_channels; i++) { |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 9906 | hdd_notice("StaParams.supported_channels[%d]: %d,", i, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9907 | StaParams. |
| 9908 | supported_channels[i]); |
| 9909 | } |
| 9910 | if (MAX_CHANNEL < num_unique_channels) |
| 9911 | num_unique_channels = MAX_CHANNEL; |
| 9912 | StaParams.supported_channels_len = |
| 9913 | num_unique_channels; |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 9914 | hdd_notice("After removing duplcates StaParams.supported_channels_len: %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9915 | StaParams.supported_channels_len); |
| 9916 | } |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 9917 | qdf_mem_copy(StaParams.supported_oper_classes, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9918 | params->supported_oper_classes, |
| 9919 | params->supported_oper_classes_len); |
| 9920 | StaParams.supported_oper_classes_len = |
| 9921 | params->supported_oper_classes_len; |
| 9922 | |
| 9923 | if (0 != params->ext_capab_len) |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 9924 | qdf_mem_copy(StaParams.extn_capability, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9925 | params->ext_capab, |
| 9926 | sizeof(StaParams.extn_capability)); |
| 9927 | |
| 9928 | if (NULL != params->ht_capa) { |
| 9929 | StaParams.htcap_present = 1; |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 9930 | qdf_mem_copy(&StaParams.HTCap, params->ht_capa, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9931 | sizeof(tSirHTCap)); |
| 9932 | } |
| 9933 | |
| 9934 | StaParams.supported_rates_len = |
| 9935 | params->supported_rates_len; |
| 9936 | |
| 9937 | /* Note : The Maximum sizeof supported_rates sent by the Supplicant is 32. |
| 9938 | * The supported_rates array , for all the structures propogating till Add Sta |
| 9939 | * to the firmware has to be modified , if the supplicant (ieee80211) is |
| 9940 | * modified to send more rates. |
| 9941 | */ |
| 9942 | |
| 9943 | /* To avoid Data Currption , set to max length to SIR_MAC_MAX_SUPP_RATES |
| 9944 | */ |
| 9945 | if (StaParams.supported_rates_len > |
| 9946 | SIR_MAC_MAX_SUPP_RATES) |
| 9947 | StaParams.supported_rates_len = |
| 9948 | SIR_MAC_MAX_SUPP_RATES; |
| 9949 | |
| 9950 | if (0 != StaParams.supported_rates_len) { |
| 9951 | int i = 0; |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 9952 | qdf_mem_copy(StaParams.supported_rates, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9953 | params->supported_rates, |
| 9954 | StaParams.supported_rates_len); |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 9955 | hdd_notice("Supported Rates with Length %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9956 | StaParams.supported_rates_len); |
| 9957 | for (i = 0; i < StaParams.supported_rates_len; |
| 9958 | i++) |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 9959 | hdd_notice("[%d]: %0x", i, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9960 | StaParams.supported_rates[i]); |
| 9961 | } |
| 9962 | |
| 9963 | if (NULL != params->vht_capa) { |
| 9964 | StaParams.vhtcap_present = 1; |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 9965 | qdf_mem_copy(&StaParams.VHTCap, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9966 | params->vht_capa, |
| 9967 | sizeof(tSirVHTCap)); |
| 9968 | } |
| 9969 | |
| 9970 | if (0 != params->ext_capab_len) { |
| 9971 | /*Define A Macro : TODO Sunil */ |
| 9972 | if ((1 << 4) & StaParams.extn_capability[3]) { |
| 9973 | isBufSta = 1; |
| 9974 | } |
| 9975 | /* TDLS Channel Switching Support */ |
| 9976 | if ((1 << 6) & StaParams.extn_capability[3]) { |
| 9977 | isOffChannelSupported = 1; |
| 9978 | } |
| 9979 | } |
| 9980 | |
Nitesh Shah | 99934ac | 2016-09-05 15:54:08 +0530 | [diff] [blame] | 9981 | if (pHddCtx->config->fEnableTDLSWmmMode && |
Nitesh Shah | d8ff632 | 2016-09-05 15:55:21 +0530 | [diff] [blame] | 9982 | (params->ht_capa || params->vht_capa || |
| 9983 | (params->sta_flags_set & BIT(NL80211_STA_FLAG_WME)))) |
Nitesh Shah | 99934ac | 2016-09-05 15:54:08 +0530 | [diff] [blame] | 9984 | is_qos_wmm_sta = true; |
| 9985 | |
| 9986 | hdd_notice("%s: TDLS Peer is QOS capable" |
| 9987 | " is_qos_wmm_sta= %d HTcapPresent = %d", |
| 9988 | __func__, is_qos_wmm_sta, |
| 9989 | StaParams.htcap_present); |
| 9990 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9991 | status = wlan_hdd_tdls_set_peer_caps(pAdapter, mac, |
Nitesh Shah | 99934ac | 2016-09-05 15:54:08 +0530 | [diff] [blame] | 9992 | &StaParams, |
| 9993 | isBufSta, |
| 9994 | isOffChannelSupported, |
| 9995 | is_qos_wmm_sta); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 9996 | if (QDF_STATUS_SUCCESS != status) { |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 9997 | hdd_err("wlan_hdd_tdls_set_peer_caps failed!"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9998 | return -EINVAL; |
| 9999 | } |
| 10000 | |
| 10001 | status = |
| 10002 | wlan_hdd_tdls_add_station(wiphy, dev, mac, 1, |
| 10003 | &StaParams); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 10004 | if (QDF_STATUS_SUCCESS != status) { |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 10005 | hdd_err("wlan_hdd_tdls_add_station failed!"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10006 | return -EINVAL; |
| 10007 | } |
| 10008 | } |
| 10009 | #endif |
| 10010 | } |
| 10011 | EXIT(); |
| 10012 | return ret; |
| 10013 | } |
| 10014 | |
| 10015 | /** |
| 10016 | * wlan_hdd_change_station() - cfg80211 change station handler function |
| 10017 | * @wiphy: Pointer to the wiphy structure |
| 10018 | * @dev: Pointer to the net device. |
| 10019 | * @mac: bssid |
| 10020 | * @params: Pointer to station parameters |
| 10021 | * |
| 10022 | * This is the cfg80211 change station handler function which invokes |
| 10023 | * the internal function @__wlan_hdd_change_station with |
| 10024 | * SSR protection. |
| 10025 | * |
| 10026 | * Return: 0 for success, error number on failure. |
| 10027 | */ |
| 10028 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 16, 0)) || defined(WITH_BACKPORTS) |
| 10029 | static int wlan_hdd_change_station(struct wiphy *wiphy, |
| 10030 | struct net_device *dev, |
| 10031 | const u8 *mac, |
| 10032 | struct station_parameters *params) |
| 10033 | #else |
| 10034 | static int wlan_hdd_change_station(struct wiphy *wiphy, |
| 10035 | struct net_device *dev, |
| 10036 | u8 *mac, |
| 10037 | struct station_parameters *params) |
| 10038 | #endif |
| 10039 | { |
| 10040 | int ret; |
| 10041 | |
| 10042 | cds_ssr_protect(__func__); |
| 10043 | ret = __wlan_hdd_change_station(wiphy, dev, mac, params); |
| 10044 | cds_ssr_unprotect(__func__); |
| 10045 | |
| 10046 | return ret; |
| 10047 | } |
| 10048 | |
| 10049 | /* |
| 10050 | * FUNCTION: __wlan_hdd_cfg80211_add_key |
| 10051 | * This function is used to initialize the key information |
| 10052 | */ |
| 10053 | static int __wlan_hdd_cfg80211_add_key(struct wiphy *wiphy, |
| 10054 | struct net_device *ndev, |
| 10055 | u8 key_index, bool pairwise, |
| 10056 | const u8 *mac_addr, |
| 10057 | struct key_params *params) |
| 10058 | { |
| 10059 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(ndev); |
| 10060 | tCsrRoamSetKey setKey; |
| 10061 | int status; |
| 10062 | uint32_t roamId = 0xFF; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10063 | hdd_hostapd_state_t *pHostapdState; |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 10064 | QDF_STATUS qdf_ret_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10065 | hdd_context_t *pHddCtx; |
| 10066 | hdd_ap_ctx_t *ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter); |
| 10067 | |
| 10068 | ENTER(); |
| 10069 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 10070 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 10071 | hdd_err("Command not allowed in FTM mode"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10072 | return -EINVAL; |
| 10073 | } |
| 10074 | |
Hanumanth Reddy Pothula | d9491f4 | 2016-10-24 19:08:38 +0530 | [diff] [blame] | 10075 | if (wlan_hdd_validate_session_id(pAdapter->sessionId)) { |
| 10076 | hdd_err("invalid session id: %d", pAdapter->sessionId); |
| 10077 | return -EINVAL; |
| 10078 | } |
| 10079 | |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 10080 | MTRACE(qdf_trace(QDF_MODULE_ID_HDD, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10081 | TRACE_CODE_HDD_CFG80211_ADD_KEY, |
| 10082 | pAdapter->sessionId, params->key_len)); |
| 10083 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 10084 | status = wlan_hdd_validate_context(pHddCtx); |
| 10085 | |
Hanumantha Reddy Pothula | 2db50ed | 2015-11-23 10:48:33 +0530 | [diff] [blame] | 10086 | if (0 != status) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10087 | return status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10088 | |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 10089 | hdd_notice("Device_mode %s(%d)", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10090 | hdd_device_mode_to_string(pAdapter->device_mode), |
| 10091 | pAdapter->device_mode); |
| 10092 | |
| 10093 | if (CSR_MAX_NUM_KEY <= key_index) { |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 10094 | hdd_err("Invalid key index %d", key_index); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10095 | |
| 10096 | return -EINVAL; |
| 10097 | } |
| 10098 | |
| 10099 | if (CSR_MAX_KEY_LEN < params->key_len) { |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 10100 | hdd_err("Invalid key length %d", params->key_len); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10101 | |
| 10102 | return -EINVAL; |
| 10103 | } |
| 10104 | |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 10105 | 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] | 10106 | |
| 10107 | /*extract key idx, key len and key */ |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 10108 | qdf_mem_zero(&setKey, sizeof(tCsrRoamSetKey)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10109 | setKey.keyId = key_index; |
| 10110 | setKey.keyLength = params->key_len; |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 10111 | qdf_mem_copy(&setKey.Key[0], params->key, params->key_len); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10112 | |
| 10113 | switch (params->cipher) { |
| 10114 | case WLAN_CIPHER_SUITE_WEP40: |
| 10115 | setKey.encType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY; |
| 10116 | break; |
| 10117 | |
| 10118 | case WLAN_CIPHER_SUITE_WEP104: |
| 10119 | setKey.encType = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY; |
| 10120 | break; |
| 10121 | |
| 10122 | case WLAN_CIPHER_SUITE_TKIP: |
| 10123 | { |
| 10124 | u8 *pKey = &setKey.Key[0]; |
| 10125 | setKey.encType = eCSR_ENCRYPT_TYPE_TKIP; |
| 10126 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 10127 | qdf_mem_zero(pKey, CSR_MAX_KEY_LEN); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10128 | |
| 10129 | /*Supplicant sends the 32bytes key in this order |
| 10130 | |
| 10131 | |--------------|----------|----------| |
| 10132 | | Tk1 |TX-MIC | RX Mic | |
| 10133 | |||--------------|----------|----------| |
| 10134 | <---16bytes---><--8bytes--><--8bytes--> |
| 10135 | |
| 10136 | */ |
| 10137 | /*Sme expects the 32 bytes key to be in the below order |
| 10138 | |
| 10139 | |--------------|----------|----------| |
| 10140 | | Tk1 |RX-MIC | TX Mic | |
| 10141 | |||--------------|----------|----------| |
| 10142 | <---16bytes---><--8bytes--><--8bytes--> |
| 10143 | */ |
| 10144 | /* Copy the Temporal Key 1 (TK1) */ |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 10145 | qdf_mem_copy(pKey, params->key, 16); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10146 | |
| 10147 | /*Copy the rx mic first */ |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 10148 | qdf_mem_copy(&pKey[16], ¶ms->key[24], 8); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10149 | |
| 10150 | /*Copy the tx mic */ |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 10151 | qdf_mem_copy(&pKey[24], ¶ms->key[16], 8); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10152 | |
| 10153 | break; |
| 10154 | } |
| 10155 | |
| 10156 | case WLAN_CIPHER_SUITE_CCMP: |
| 10157 | setKey.encType = eCSR_ENCRYPT_TYPE_AES; |
| 10158 | break; |
| 10159 | |
| 10160 | #ifdef FEATURE_WLAN_WAPI |
| 10161 | case WLAN_CIPHER_SUITE_SMS4: |
| 10162 | { |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 10163 | qdf_mem_zero(&setKey, sizeof(tCsrRoamSetKey)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10164 | wlan_hdd_cfg80211_set_key_wapi(pAdapter, key_index, |
| 10165 | mac_addr, params->key, |
| 10166 | params->key_len); |
| 10167 | return 0; |
| 10168 | } |
| 10169 | #endif |
| 10170 | |
| 10171 | #ifdef FEATURE_WLAN_ESE |
| 10172 | case WLAN_CIPHER_SUITE_KRK: |
| 10173 | setKey.encType = eCSR_ENCRYPT_TYPE_KRK; |
| 10174 | break; |
| 10175 | #ifdef WLAN_FEATURE_ROAM_OFFLOAD |
| 10176 | case WLAN_CIPHER_SUITE_BTK: |
| 10177 | setKey.encType = eCSR_ENCRYPT_TYPE_BTK; |
| 10178 | break; |
| 10179 | #endif |
| 10180 | #endif |
| 10181 | |
| 10182 | #ifdef WLAN_FEATURE_11W |
| 10183 | case WLAN_CIPHER_SUITE_AES_CMAC: |
| 10184 | setKey.encType = eCSR_ENCRYPT_TYPE_AES_CMAC; |
| 10185 | break; |
| 10186 | #endif |
| 10187 | |
| 10188 | default: |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 10189 | hdd_err("unsupported cipher type %u", params->cipher); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10190 | return -EOPNOTSUPP; |
| 10191 | } |
| 10192 | |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 10193 | hdd_info("encryption type %d", setKey.encType); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10194 | |
| 10195 | if (!pairwise) { |
| 10196 | /* set group key */ |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 10197 | hdd_notice("%s- %d: setting Broadcast key", __func__, __LINE__); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10198 | setKey.keyDirection = eSIR_RX_ONLY; |
Anurag Chouhan | c554842 | 2016-02-24 18:33:27 +0530 | [diff] [blame] | 10199 | qdf_set_macaddr_broadcast(&setKey.peerMac); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10200 | } else { |
| 10201 | /* set pairwise key */ |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 10202 | hdd_notice("%s- %d: setting pairwise key", __func__, __LINE__); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10203 | setKey.keyDirection = eSIR_TX_RX; |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 10204 | qdf_mem_copy(setKey.peerMac.bytes, mac_addr, QDF_MAC_ADDR_SIZE); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10205 | } |
Krunal Soni | b4326f2 | 2016-03-10 13:05:51 -0800 | [diff] [blame] | 10206 | if ((QDF_IBSS_MODE == pAdapter->device_mode) && !pairwise) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10207 | /* if a key is already installed, block all subsequent ones */ |
| 10208 | if (pAdapter->sessionCtx.station.ibss_enc_key_installed) { |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 10209 | hdd_info("IBSS key installed already"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10210 | return 0; |
| 10211 | } |
| 10212 | |
| 10213 | setKey.keyDirection = eSIR_TX_RX; |
| 10214 | /*Set the group key */ |
| 10215 | status = sme_roam_set_key(WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 10216 | pAdapter->sessionId, &setKey, &roamId); |
| 10217 | |
| 10218 | if (0 != status) { |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 10219 | hdd_err("sme_roam_set_key failed, returned %d", status); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10220 | return -EINVAL; |
| 10221 | } |
| 10222 | /*Save the keys here and call sme_roam_set_key for setting |
| 10223 | the PTK after peer joins the IBSS network */ |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 10224 | qdf_mem_copy(&pAdapter->sessionCtx.station.ibss_enc_key, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10225 | &setKey, sizeof(tCsrRoamSetKey)); |
| 10226 | |
| 10227 | pAdapter->sessionCtx.station.ibss_enc_key_installed = 1; |
| 10228 | return status; |
| 10229 | } |
Krunal Soni | b4326f2 | 2016-03-10 13:05:51 -0800 | [diff] [blame] | 10230 | if ((pAdapter->device_mode == QDF_SAP_MODE) || |
| 10231 | (pAdapter->device_mode == QDF_P2P_GO_MODE)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10232 | pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter); |
| 10233 | if (pHostapdState->bssState == BSS_START) { |
Dustin Brown | 6ba30a1 | 2016-09-13 13:59:43 -0700 | [diff] [blame] | 10234 | status = wlansap_set_key_sta( |
| 10235 | WLAN_HDD_GET_SAP_CTX_PTR(pAdapter), &setKey); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 10236 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 10237 | hdd_err("[%4d] wlansap_set_key_sta returned ERROR status= %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10238 | __LINE__, status); |
| 10239 | } |
| 10240 | } |
| 10241 | |
| 10242 | /* Save the key in ap ctx for use on START_BASS and restart */ |
| 10243 | if (pairwise || |
| 10244 | eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == setKey.encType || |
| 10245 | eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == setKey.encType) |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 10246 | qdf_mem_copy(&ap_ctx->wepKey[key_index], &setKey, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10247 | sizeof(tCsrRoamSetKey)); |
| 10248 | else |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 10249 | qdf_mem_copy(&ap_ctx->groupKey, &setKey, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10250 | sizeof(tCsrRoamSetKey)); |
| 10251 | |
Krunal Soni | b4326f2 | 2016-03-10 13:05:51 -0800 | [diff] [blame] | 10252 | } else if ((pAdapter->device_mode == QDF_STA_MODE) || |
| 10253 | (pAdapter->device_mode == QDF_P2P_CLIENT_MODE)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10254 | hdd_wext_state_t *pWextState = |
| 10255 | WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
| 10256 | hdd_station_ctx_t *pHddStaCtx = |
| 10257 | WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 10258 | |
| 10259 | if (!pairwise) { |
| 10260 | /* set group key */ |
| 10261 | if (pHddStaCtx->roam_info.deferKeyComplete) { |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 10262 | hdd_notice("%s- %d: Perform Set key Complete", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10263 | __func__, __LINE__); |
| 10264 | hdd_perform_roam_set_key_complete(pAdapter); |
| 10265 | } |
| 10266 | } |
| 10267 | |
| 10268 | pWextState->roamProfile.Keys.KeyLength[key_index] = |
| 10269 | (u8) params->key_len; |
| 10270 | |
| 10271 | pWextState->roamProfile.Keys.defaultIndex = key_index; |
| 10272 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 10273 | qdf_mem_copy(&pWextState->roamProfile.Keys. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10274 | KeyMaterial[key_index][0], params->key, |
| 10275 | params->key_len); |
| 10276 | |
| 10277 | pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY; |
| 10278 | |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 10279 | hdd_info("Set key for peerMac "MAC_ADDRESS_STR" direction %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10280 | MAC_ADDR_ARRAY(setKey.peerMac.bytes), |
| 10281 | setKey.keyDirection); |
| 10282 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10283 | /* The supplicant may attempt to set the PTK once pre-authentication |
| 10284 | is done. Save the key in the UMAC and include it in the ADD BSS |
| 10285 | request */ |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 10286 | 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] | 10287 | pAdapter->sessionId, &setKey); |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 10288 | if (qdf_ret_status == QDF_STATUS_FT_PREAUTH_KEY_SUCCESS) { |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 10289 | hdd_info("Update PreAuth Key success"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10290 | return 0; |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 10291 | } else if (qdf_ret_status == QDF_STATUS_FT_PREAUTH_KEY_FAILED) { |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 10292 | hdd_err("Update PreAuth Key failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10293 | return -EINVAL; |
| 10294 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10295 | |
| 10296 | /* issue set key request to SME */ |
| 10297 | status = sme_roam_set_key(WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 10298 | pAdapter->sessionId, &setKey, &roamId); |
| 10299 | |
| 10300 | if (0 != status) { |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 10301 | hdd_err("sme_roam_set_key failed, returned %d", status); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10302 | pHddStaCtx->roam_info.roamingState = |
| 10303 | HDD_ROAM_STATE_NONE; |
| 10304 | return -EINVAL; |
| 10305 | } |
| 10306 | |
| 10307 | /* in case of IBSS as there was no information available about WEP keys during |
| 10308 | * IBSS join, group key intialized with NULL key, so re-initialize group key |
| 10309 | * with correct value*/ |
| 10310 | if ((eCSR_BSS_TYPE_START_IBSS == |
| 10311 | pWextState->roamProfile.BSSType) |
| 10312 | && |
| 10313 | !((IW_AUTH_KEY_MGMT_802_1X == |
| 10314 | (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)) |
| 10315 | && (eCSR_AUTH_TYPE_OPEN_SYSTEM == |
| 10316 | pHddStaCtx->conn_info.authType) |
| 10317 | ) |
| 10318 | && ((WLAN_CIPHER_SUITE_WEP40 == params->cipher) |
| 10319 | || (WLAN_CIPHER_SUITE_WEP104 == params->cipher) |
| 10320 | ) |
| 10321 | ) { |
| 10322 | setKey.keyDirection = eSIR_RX_ONLY; |
Anurag Chouhan | c554842 | 2016-02-24 18:33:27 +0530 | [diff] [blame] | 10323 | qdf_set_macaddr_broadcast(&setKey.peerMac); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10324 | |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 10325 | hdd_info("Set key peerMac "MAC_ADDRESS_STR" direction %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10326 | MAC_ADDR_ARRAY(setKey.peerMac.bytes), |
| 10327 | setKey.keyDirection); |
| 10328 | |
| 10329 | status = sme_roam_set_key(WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 10330 | pAdapter->sessionId, &setKey, |
| 10331 | &roamId); |
| 10332 | |
| 10333 | if (0 != status) { |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 10334 | 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] | 10335 | pHddStaCtx->roam_info.roamingState = |
| 10336 | HDD_ROAM_STATE_NONE; |
| 10337 | return -EINVAL; |
| 10338 | } |
| 10339 | } |
| 10340 | } |
Hanumantha Reddy Pothula | 2db50ed | 2015-11-23 10:48:33 +0530 | [diff] [blame] | 10341 | EXIT(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10342 | return 0; |
| 10343 | } |
| 10344 | |
| 10345 | static int wlan_hdd_cfg80211_add_key(struct wiphy *wiphy, |
| 10346 | struct net_device *ndev, |
| 10347 | u8 key_index, bool pairwise, |
| 10348 | const u8 *mac_addr, |
| 10349 | struct key_params *params) |
| 10350 | { |
| 10351 | int ret; |
| 10352 | cds_ssr_protect(__func__); |
| 10353 | ret = __wlan_hdd_cfg80211_add_key(wiphy, ndev, key_index, pairwise, |
| 10354 | mac_addr, params); |
| 10355 | cds_ssr_unprotect(__func__); |
| 10356 | |
| 10357 | return ret; |
| 10358 | } |
| 10359 | |
| 10360 | /* |
| 10361 | * FUNCTION: __wlan_hdd_cfg80211_get_key |
| 10362 | * This function is used to get the key information |
| 10363 | */ |
| 10364 | static int __wlan_hdd_cfg80211_get_key(struct wiphy *wiphy, |
| 10365 | struct net_device *ndev, |
| 10366 | u8 key_index, bool pairwise, |
| 10367 | const u8 *mac_addr, void *cookie, |
| 10368 | void (*callback)(void *cookie, |
| 10369 | struct key_params *) |
| 10370 | ) |
| 10371 | { |
| 10372 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(ndev); |
| 10373 | hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
| 10374 | tCsrRoamProfile *pRoamProfile = &(pWextState->roamProfile); |
| 10375 | struct key_params params; |
| 10376 | |
| 10377 | ENTER(); |
| 10378 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 10379 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 10380 | hdd_err("Command not allowed in FTM mode"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10381 | return -EINVAL; |
| 10382 | } |
| 10383 | |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 10384 | hdd_notice("Device_mode %s(%d)", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10385 | hdd_device_mode_to_string(pAdapter->device_mode), |
| 10386 | pAdapter->device_mode); |
| 10387 | |
| 10388 | memset(¶ms, 0, sizeof(params)); |
| 10389 | |
| 10390 | if (CSR_MAX_NUM_KEY <= key_index) { |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 10391 | hdd_err("invalid key index %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10392 | key_index); |
| 10393 | return -EINVAL; |
| 10394 | } |
| 10395 | |
| 10396 | switch (pRoamProfile->EncryptionType.encryptionType[0]) { |
| 10397 | case eCSR_ENCRYPT_TYPE_NONE: |
| 10398 | params.cipher = IW_AUTH_CIPHER_NONE; |
| 10399 | break; |
| 10400 | |
| 10401 | case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY: |
| 10402 | case eCSR_ENCRYPT_TYPE_WEP40: |
| 10403 | params.cipher = WLAN_CIPHER_SUITE_WEP40; |
| 10404 | break; |
| 10405 | |
| 10406 | case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY: |
| 10407 | case eCSR_ENCRYPT_TYPE_WEP104: |
| 10408 | params.cipher = WLAN_CIPHER_SUITE_WEP104; |
| 10409 | break; |
| 10410 | |
| 10411 | case eCSR_ENCRYPT_TYPE_TKIP: |
| 10412 | params.cipher = WLAN_CIPHER_SUITE_TKIP; |
| 10413 | break; |
| 10414 | |
| 10415 | case eCSR_ENCRYPT_TYPE_AES: |
| 10416 | params.cipher = WLAN_CIPHER_SUITE_AES_CMAC; |
| 10417 | break; |
| 10418 | |
| 10419 | default: |
| 10420 | params.cipher = IW_AUTH_CIPHER_NONE; |
| 10421 | break; |
| 10422 | } |
| 10423 | |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 10424 | MTRACE(qdf_trace(QDF_MODULE_ID_HDD, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10425 | TRACE_CODE_HDD_CFG80211_GET_KEY, |
| 10426 | pAdapter->sessionId, params.cipher)); |
| 10427 | |
| 10428 | params.key_len = pRoamProfile->Keys.KeyLength[key_index]; |
| 10429 | params.seq_len = 0; |
| 10430 | params.seq = NULL; |
| 10431 | params.key = &pRoamProfile->Keys.KeyMaterial[key_index][0]; |
| 10432 | callback(cookie, ¶ms); |
| 10433 | |
| 10434 | EXIT(); |
| 10435 | return 0; |
| 10436 | } |
| 10437 | |
| 10438 | static int wlan_hdd_cfg80211_get_key(struct wiphy *wiphy, |
| 10439 | struct net_device *ndev, |
| 10440 | u8 key_index, bool pairwise, |
| 10441 | const u8 *mac_addr, void *cookie, |
| 10442 | void (*callback)(void *cookie, |
| 10443 | struct key_params *) |
| 10444 | ) |
| 10445 | { |
| 10446 | int ret; |
| 10447 | |
| 10448 | cds_ssr_protect(__func__); |
| 10449 | ret = __wlan_hdd_cfg80211_get_key(wiphy, ndev, key_index, pairwise, |
| 10450 | mac_addr, cookie, callback); |
| 10451 | cds_ssr_unprotect(__func__); |
| 10452 | |
| 10453 | return ret; |
| 10454 | } |
| 10455 | |
| 10456 | /** |
| 10457 | * __wlan_hdd_cfg80211_del_key() - Delete the encryption key for station |
| 10458 | * @wiphy: wiphy interface context |
| 10459 | * @ndev: pointer to net device |
| 10460 | * @key_index: Key index used in 802.11 frames |
| 10461 | * @unicast: true if it is unicast key |
| 10462 | * @multicast: true if it is multicast key |
| 10463 | * |
| 10464 | * This function is required for cfg80211_ops API. |
| 10465 | * It is used to delete the key information |
| 10466 | * Underlying hardware implementation does not have API to delete the |
| 10467 | * encryption key. It is automatically deleted when the peer is |
| 10468 | * removed. Hence this function currently does nothing. |
| 10469 | * Future implementation may interprete delete key operation to |
| 10470 | * replacing the key with a random junk value, effectively making it |
| 10471 | * useless. |
| 10472 | * |
| 10473 | * Return: status code, always 0. |
| 10474 | */ |
| 10475 | |
| 10476 | static int __wlan_hdd_cfg80211_del_key(struct wiphy *wiphy, |
| 10477 | struct net_device *ndev, |
| 10478 | u8 key_index, |
| 10479 | bool pairwise, const u8 *mac_addr) |
| 10480 | { |
| 10481 | EXIT(); |
| 10482 | return 0; |
| 10483 | } |
| 10484 | |
| 10485 | /** |
| 10486 | * wlan_hdd_cfg80211_del_key() - cfg80211 delete key handler function |
| 10487 | * @wiphy: Pointer to wiphy structure. |
| 10488 | * @dev: Pointer to net_device structure. |
| 10489 | * @key_index: key index |
| 10490 | * @pairwise: pairwise |
| 10491 | * @mac_addr: mac address |
| 10492 | * |
| 10493 | * This is the cfg80211 delete key handler function which invokes |
| 10494 | * the internal function @__wlan_hdd_cfg80211_del_key with |
| 10495 | * SSR protection. |
| 10496 | * |
| 10497 | * Return: 0 for success, error number on failure. |
| 10498 | */ |
| 10499 | static int wlan_hdd_cfg80211_del_key(struct wiphy *wiphy, |
| 10500 | struct net_device *dev, |
| 10501 | u8 key_index, |
| 10502 | bool pairwise, const u8 *mac_addr) |
| 10503 | { |
| 10504 | int ret; |
| 10505 | |
| 10506 | cds_ssr_protect(__func__); |
| 10507 | ret = __wlan_hdd_cfg80211_del_key(wiphy, dev, key_index, |
| 10508 | pairwise, mac_addr); |
| 10509 | cds_ssr_unprotect(__func__); |
| 10510 | |
| 10511 | return ret; |
| 10512 | } |
| 10513 | |
| 10514 | /* |
| 10515 | * FUNCTION: __wlan_hdd_cfg80211_set_default_key |
| 10516 | * This function is used to set the default tx key index |
| 10517 | */ |
| 10518 | static int __wlan_hdd_cfg80211_set_default_key(struct wiphy *wiphy, |
| 10519 | struct net_device *ndev, |
| 10520 | u8 key_index, |
| 10521 | bool unicast, bool multicast) |
| 10522 | { |
| 10523 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(ndev); |
| 10524 | hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
| 10525 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 10526 | hdd_context_t *pHddCtx; |
| 10527 | int status; |
| 10528 | |
| 10529 | ENTER(); |
| 10530 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 10531 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 10532 | hdd_err("Command not allowed in FTM mode"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10533 | return -EINVAL; |
| 10534 | } |
| 10535 | |
Hanumanth Reddy Pothula | d9491f4 | 2016-10-24 19:08:38 +0530 | [diff] [blame] | 10536 | if (wlan_hdd_validate_session_id(pAdapter->sessionId)) { |
| 10537 | hdd_err("invalid session id: %d", pAdapter->sessionId); |
| 10538 | return -EINVAL; |
| 10539 | } |
| 10540 | |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 10541 | MTRACE(qdf_trace(QDF_MODULE_ID_HDD, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10542 | TRACE_CODE_HDD_CFG80211_SET_DEFAULT_KEY, |
| 10543 | pAdapter->sessionId, key_index)); |
| 10544 | |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 10545 | hdd_notice("Device_mode %s(%d) key_index = %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10546 | hdd_device_mode_to_string(pAdapter->device_mode), |
| 10547 | pAdapter->device_mode, key_index); |
| 10548 | |
| 10549 | if (CSR_MAX_NUM_KEY <= key_index) { |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 10550 | hdd_err("Invalid key index %d", key_index); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10551 | return -EINVAL; |
| 10552 | } |
| 10553 | |
| 10554 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 10555 | status = wlan_hdd_validate_context(pHddCtx); |
| 10556 | |
Hanumantha Reddy Pothula | 2db50ed | 2015-11-23 10:48:33 +0530 | [diff] [blame] | 10557 | if (0 != status) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10558 | return status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10559 | |
Krunal Soni | b4326f2 | 2016-03-10 13:05:51 -0800 | [diff] [blame] | 10560 | if ((pAdapter->device_mode == QDF_STA_MODE) || |
| 10561 | (pAdapter->device_mode == QDF_P2P_CLIENT_MODE)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10562 | if ((eCSR_ENCRYPT_TYPE_TKIP != |
| 10563 | pHddStaCtx->conn_info.ucEncryptionType) && |
| 10564 | (eCSR_ENCRYPT_TYPE_AES != |
| 10565 | pHddStaCtx->conn_info.ucEncryptionType)) { |
| 10566 | /* If default key index is not same as previous one, |
| 10567 | * then update the default key index */ |
| 10568 | |
| 10569 | tCsrRoamSetKey setKey; |
| 10570 | uint32_t roamId = 0xFF; |
| 10571 | tCsrKeys *Keys = &pWextState->roamProfile.Keys; |
| 10572 | |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 10573 | hdd_info("Default tx key index %d", key_index); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10574 | |
| 10575 | Keys->defaultIndex = (u8) key_index; |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 10576 | qdf_mem_zero(&setKey, sizeof(tCsrRoamSetKey)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10577 | setKey.keyId = key_index; |
| 10578 | setKey.keyLength = Keys->KeyLength[key_index]; |
| 10579 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 10580 | qdf_mem_copy(&setKey.Key[0], |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10581 | &Keys->KeyMaterial[key_index][0], |
| 10582 | Keys->KeyLength[key_index]); |
| 10583 | |
| 10584 | setKey.keyDirection = eSIR_TX_RX; |
| 10585 | |
Anurag Chouhan | c554842 | 2016-02-24 18:33:27 +0530 | [diff] [blame] | 10586 | qdf_copy_macaddr(&setKey.peerMac, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10587 | &pHddStaCtx->conn_info.bssId); |
| 10588 | |
| 10589 | if (Keys->KeyLength[key_index] == CSR_WEP40_KEY_LEN && |
| 10590 | pWextState->roamProfile.EncryptionType. |
| 10591 | encryptionType[0] == eCSR_ENCRYPT_TYPE_WEP104) { |
| 10592 | /* In the case of dynamic wep supplicant hardcodes DWEP type |
| 10593 | * to eCSR_ENCRYPT_TYPE_WEP104 even though ap is configured for |
| 10594 | * WEP-40 encryption. In this canse the key length is 5 but the |
| 10595 | * encryption type is 104 hence checking the key langht(5) and |
| 10596 | * encryption type(104) and switching encryption type to 40*/ |
| 10597 | pWextState->roamProfile.EncryptionType. |
| 10598 | encryptionType[0] = eCSR_ENCRYPT_TYPE_WEP40; |
| 10599 | pWextState->roamProfile.mcEncryptionType. |
| 10600 | encryptionType[0] = eCSR_ENCRYPT_TYPE_WEP40; |
| 10601 | } |
| 10602 | |
| 10603 | setKey.encType = |
| 10604 | pWextState->roamProfile.EncryptionType. |
| 10605 | encryptionType[0]; |
| 10606 | |
| 10607 | /* Issue set key request */ |
| 10608 | status = sme_roam_set_key(WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 10609 | pAdapter->sessionId, &setKey, |
| 10610 | &roamId); |
| 10611 | |
| 10612 | if (0 != status) { |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 10613 | hdd_err("sme_roam_set_key failed, returned %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10614 | status); |
| 10615 | return -EINVAL; |
| 10616 | } |
| 10617 | } |
Krunal Soni | b4326f2 | 2016-03-10 13:05:51 -0800 | [diff] [blame] | 10618 | } else if (QDF_SAP_MODE == pAdapter->device_mode) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10619 | /* In SoftAp mode setting key direction for default mode */ |
| 10620 | if ((eCSR_ENCRYPT_TYPE_TKIP != |
| 10621 | pWextState->roamProfile.EncryptionType.encryptionType[0]) |
| 10622 | && (eCSR_ENCRYPT_TYPE_AES != |
| 10623 | pWextState->roamProfile.EncryptionType. |
| 10624 | encryptionType[0])) { |
| 10625 | /* Saving key direction for default key index to TX default */ |
| 10626 | hdd_ap_ctx_t *pAPCtx = |
| 10627 | WLAN_HDD_GET_AP_CTX_PTR(pAdapter); |
| 10628 | pAPCtx->wepKey[key_index].keyDirection = |
| 10629 | eSIR_TX_DEFAULT; |
Kondabattini, Ganesh | 702d90e | 2016-09-03 01:54:22 +0530 | [diff] [blame] | 10630 | hdd_info("WEP default key index set to SAP context %d", |
Masti, Narayanraddi | ab712a7 | 2016-08-04 11:59:11 +0530 | [diff] [blame] | 10631 | key_index); |
Kondabattini, Ganesh | 702d90e | 2016-09-03 01:54:22 +0530 | [diff] [blame] | 10632 | pAPCtx->wep_def_key_idx = key_index; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10633 | } |
| 10634 | } |
| 10635 | |
| 10636 | EXIT(); |
| 10637 | return status; |
| 10638 | } |
| 10639 | |
| 10640 | static int wlan_hdd_cfg80211_set_default_key(struct wiphy *wiphy, |
| 10641 | struct net_device *ndev, |
| 10642 | u8 key_index, |
| 10643 | bool unicast, bool multicast) |
| 10644 | { |
| 10645 | int ret; |
| 10646 | cds_ssr_protect(__func__); |
| 10647 | ret = |
| 10648 | __wlan_hdd_cfg80211_set_default_key(wiphy, ndev, key_index, unicast, |
| 10649 | multicast); |
| 10650 | cds_ssr_unprotect(__func__); |
| 10651 | |
| 10652 | return ret; |
| 10653 | } |
| 10654 | |
Abhishek Singh | c994160 | 2016-08-09 16:06:22 +0530 | [diff] [blame] | 10655 | /* |
| 10656 | * wlan_hdd_cfg80211_get_bss :to get the bss from kernel cache. |
| 10657 | * @wiphy: wiphy pointer |
| 10658 | * @channel: channel of the BSS |
| 10659 | * @bssid: Bssid of BSS |
| 10660 | * @ssid: Ssid of the BSS |
| 10661 | * @ssid_len: ssid length |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10662 | * |
Abhishek Singh | c994160 | 2016-08-09 16:06:22 +0530 | [diff] [blame] | 10663 | * Return: bss found in kernel cache |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10664 | */ |
Abhishek Singh | c994160 | 2016-08-09 16:06:22 +0530 | [diff] [blame] | 10665 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 1, 0)) && !defined(WITH_BACKPORTS) |
Jeff Johnson | 8b8a04b | 2016-10-05 15:49:43 -0700 | [diff] [blame] | 10666 | static |
Abhishek Singh | c994160 | 2016-08-09 16:06:22 +0530 | [diff] [blame] | 10667 | struct cfg80211_bss *wlan_hdd_cfg80211_get_bss(struct wiphy *wiphy, |
| 10668 | struct ieee80211_channel *channel, const u8 *bssid, |
| 10669 | const u8 *ssid, size_t ssid_len) |
| 10670 | { |
| 10671 | return cfg80211_get_bss(wiphy, channel, bssid, |
| 10672 | ssid, |
| 10673 | ssid_len, |
| 10674 | WLAN_CAPABILITY_ESS, |
| 10675 | WLAN_CAPABILITY_ESS); |
| 10676 | } |
| 10677 | #else |
Jeff Johnson | 8b8a04b | 2016-10-05 15:49:43 -0700 | [diff] [blame] | 10678 | static |
Abhishek Singh | c994160 | 2016-08-09 16:06:22 +0530 | [diff] [blame] | 10679 | struct cfg80211_bss *wlan_hdd_cfg80211_get_bss(struct wiphy *wiphy, |
| 10680 | struct ieee80211_channel *channel, const u8 *bssid, |
| 10681 | const u8 *ssid, size_t ssid_len) |
| 10682 | { |
| 10683 | return cfg80211_get_bss(wiphy, channel, bssid, |
| 10684 | ssid, |
| 10685 | ssid_len, |
| 10686 | IEEE80211_BSS_TYPE_ESS, |
| 10687 | IEEE80211_PRIVACY_ANY); |
| 10688 | } |
| 10689 | #endif |
| 10690 | |
| 10691 | |
| 10692 | /* |
| 10693 | * wlan_hdd_cfg80211_update_bss_list :to inform nl80211 |
| 10694 | * interface that BSS might have been lost. |
| 10695 | * @pAdapter: adaptor |
| 10696 | * @bssid: bssid which might have been lost |
| 10697 | * |
| 10698 | * Return: bss which is unlinked from kernel cache |
| 10699 | */ |
| 10700 | struct cfg80211_bss *wlan_hdd_cfg80211_update_bss_list( |
| 10701 | hdd_adapter_t *pAdapter, tSirMacAddr bssid) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10702 | { |
| 10703 | struct net_device *dev = pAdapter->dev; |
| 10704 | struct wireless_dev *wdev = dev->ieee80211_ptr; |
| 10705 | struct wiphy *wiphy = wdev->wiphy; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10706 | struct cfg80211_bss *bss = NULL; |
| 10707 | |
Abhishek Singh | c994160 | 2016-08-09 16:06:22 +0530 | [diff] [blame] | 10708 | bss = wlan_hdd_cfg80211_get_bss(wiphy, NULL, bssid, |
| 10709 | NULL, 0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10710 | if (bss == NULL) { |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 10711 | hdd_err("BSS not present"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10712 | } else { |
Abhishek Singh | c994160 | 2016-08-09 16:06:22 +0530 | [diff] [blame] | 10713 | hdd_info("cfg80211_unlink_bss called for BSSID " |
| 10714 | MAC_ADDRESS_STR, MAC_ADDR_ARRAY(bssid)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10715 | cfg80211_unlink_bss(wiphy, bss); |
| 10716 | } |
| 10717 | return bss; |
| 10718 | } |
| 10719 | |
Abhishek Singh | c994160 | 2016-08-09 16:06:22 +0530 | [diff] [blame] | 10720 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10721 | /** |
| 10722 | * wlan_hdd_cfg80211_inform_bss_frame() - inform bss details to NL80211 |
| 10723 | * @pAdapter: Pointer to adapter |
| 10724 | * @bss_desc: Pointer to bss descriptor |
| 10725 | * |
| 10726 | * This function is used to inform the BSS details to nl80211 interface. |
| 10727 | * |
| 10728 | * Return: struct cfg80211_bss pointer |
| 10729 | */ |
Selvaraj, Sridhar | fe696d2 | 2016-08-03 21:34:51 +0530 | [diff] [blame] | 10730 | struct cfg80211_bss *wlan_hdd_cfg80211_inform_bss_frame(hdd_adapter_t *pAdapter, |
| 10731 | tSirBssDescription *bss_desc) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10732 | { |
| 10733 | /* |
| 10734 | * cfg80211_inform_bss() is not updating ie field of bss entry, if entry |
| 10735 | * already exists in bss data base of cfg80211 for that particular BSS |
| 10736 | * ID. Using cfg80211_inform_bss_frame to update the bss entry instead |
| 10737 | * of cfg80211_inform_bss, But this call expects mgmt packet as input. |
| 10738 | * As of now there is no possibility to get the mgmt(probe response) |
| 10739 | * frame from PE, converting bss_desc to ieee80211_mgmt(probe response) |
| 10740 | * and passing to cfg80211_inform_bss_frame. |
| 10741 | */ |
| 10742 | struct net_device *dev = pAdapter->dev; |
| 10743 | struct wireless_dev *wdev = dev->ieee80211_ptr; |
| 10744 | struct wiphy *wiphy = wdev->wiphy; |
| 10745 | int chan_no = bss_desc->channelId; |
| 10746 | #ifdef WLAN_ENABLE_AGEIE_ON_SCAN_RESULTS |
| 10747 | qcom_ie_age *qie_age = NULL; |
| 10748 | int ie_length = |
| 10749 | GET_IE_LEN_IN_BSS_DESC(bss_desc->length) + sizeof(qcom_ie_age); |
| 10750 | #else |
| 10751 | int ie_length = GET_IE_LEN_IN_BSS_DESC(bss_desc->length); |
| 10752 | #endif |
| 10753 | const char *ie = |
| 10754 | ((ie_length != 0) ? (const char *)&bss_desc->ieFields : NULL); |
| 10755 | unsigned int freq; |
| 10756 | struct ieee80211_channel *chan; |
| 10757 | struct ieee80211_mgmt *mgmt = NULL; |
| 10758 | struct cfg80211_bss *bss_status = NULL; |
| 10759 | size_t frame_len = sizeof(struct ieee80211_mgmt) + ie_length; |
| 10760 | int rssi = 0; |
| 10761 | hdd_context_t *pHddCtx; |
| 10762 | int status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10763 | struct timespec ts; |
Deepak Dhamdhere | 68929ec | 2015-08-05 15:16:35 -0700 | [diff] [blame] | 10764 | struct hdd_config *cfg_param; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10765 | |
| 10766 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 10767 | status = wlan_hdd_validate_context(pHddCtx); |
Hanumantha Reddy Pothula | 2db50ed | 2015-11-23 10:48:33 +0530 | [diff] [blame] | 10768 | if (0 != status) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10769 | return NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10770 | |
Deepak Dhamdhere | 68929ec | 2015-08-05 15:16:35 -0700 | [diff] [blame] | 10771 | cfg_param = pHddCtx->config; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10772 | mgmt = kzalloc((sizeof(struct ieee80211_mgmt) + ie_length), GFP_KERNEL); |
| 10773 | if (!mgmt) { |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 10774 | hdd_err("memory allocation failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10775 | return NULL; |
| 10776 | } |
| 10777 | |
| 10778 | memcpy(mgmt->bssid, bss_desc->bssId, ETH_ALEN); |
| 10779 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10780 | /* Android does not want the timestamp from the frame. |
| 10781 | Instead it wants a monotonic increasing value */ |
Yuanyuan Liu | 2e03b41 | 2016-04-06 14:36:15 -0700 | [diff] [blame] | 10782 | get_monotonic_boottime(&ts); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10783 | mgmt->u.probe_resp.timestamp = |
| 10784 | ((u64) ts.tv_sec * 1000000) + (ts.tv_nsec / 1000); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10785 | |
| 10786 | mgmt->u.probe_resp.beacon_int = bss_desc->beaconInterval; |
| 10787 | mgmt->u.probe_resp.capab_info = bss_desc->capabilityInfo; |
| 10788 | |
| 10789 | #ifdef WLAN_ENABLE_AGEIE_ON_SCAN_RESULTS |
| 10790 | /* GPS Requirement: need age ie per entry. Using vendor specific. */ |
| 10791 | /* Assuming this is the last IE, copy at the end */ |
| 10792 | ie_length -= sizeof(qcom_ie_age); |
| 10793 | qie_age = (qcom_ie_age *) (mgmt->u.probe_resp.variable + ie_length); |
| 10794 | qie_age->element_id = QCOM_VENDOR_IE_ID; |
| 10795 | qie_age->len = QCOM_VENDOR_IE_AGE_LEN; |
| 10796 | qie_age->oui_1 = QCOM_OUI1; |
| 10797 | qie_age->oui_2 = QCOM_OUI2; |
| 10798 | qie_age->oui_3 = QCOM_OUI3; |
| 10799 | qie_age->type = QCOM_VENDOR_IE_AGE_TYPE; |
Deepthi Gowri | 6acee34 | 2016-10-28 15:00:38 +0530 | [diff] [blame] | 10800 | /* |
| 10801 | * Lowi expects the timestamp of bss in units of 1/10 ms. In driver |
| 10802 | * all bss related timestamp is in units of ms. Due to this when scan |
| 10803 | * results are sent to lowi the scan age is high.To address this, |
| 10804 | * send age in units of 1/10 ms. |
| 10805 | */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10806 | qie_age->age = |
Sarada Prasanna Garnayak | b3e06a6 | 2016-11-14 20:48:39 +0530 | [diff] [blame] | 10807 | (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] | 10808 | qie_age->tsf_delta = bss_desc->tsf_delta; |
Krishna Kumaar Natarajan | a4e1224 | 2016-04-01 18:44:39 -0700 | [diff] [blame] | 10809 | memcpy(&qie_age->beacon_tsf, bss_desc->timeStamp, |
| 10810 | sizeof(qie_age->beacon_tsf)); |
Krishna Kumaar Natarajan | 89a99d4 | 2016-08-04 15:44:38 -0700 | [diff] [blame] | 10811 | memcpy(&qie_age->seq_ctrl, &bss_desc->seq_ctrl, |
| 10812 | sizeof(qie_age->seq_ctrl)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10813 | #endif |
| 10814 | |
| 10815 | memcpy(mgmt->u.probe_resp.variable, ie, ie_length); |
| 10816 | if (bss_desc->fProbeRsp) { |
| 10817 | mgmt->frame_control |= |
| 10818 | (u16) (IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_PROBE_RESP); |
| 10819 | } else { |
| 10820 | mgmt->frame_control |= |
| 10821 | (u16) (IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_BEACON); |
| 10822 | } |
| 10823 | |
| 10824 | if (chan_no <= ARRAY_SIZE(hdd_channels_2_4_ghz) && |
Dustin Brown | a30892e | 2016-10-12 17:28:36 -0700 | [diff] [blame] | 10825 | (wiphy->bands[NL80211_BAND_2GHZ] != NULL)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10826 | freq = |
| 10827 | ieee80211_channel_to_frequency(chan_no, |
Dustin Brown | a30892e | 2016-10-12 17:28:36 -0700 | [diff] [blame] | 10828 | NL80211_BAND_2GHZ); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10829 | } else if ((chan_no > ARRAY_SIZE(hdd_channels_2_4_ghz)) |
Dustin Brown | a30892e | 2016-10-12 17:28:36 -0700 | [diff] [blame] | 10830 | && (wiphy->bands[NL80211_BAND_5GHZ] != NULL)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10831 | freq = |
| 10832 | ieee80211_channel_to_frequency(chan_no, |
Dustin Brown | a30892e | 2016-10-12 17:28:36 -0700 | [diff] [blame] | 10833 | NL80211_BAND_5GHZ); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10834 | } else { |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 10835 | hdd_err("Invalid chan_no %d", chan_no); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10836 | kfree(mgmt); |
| 10837 | return NULL; |
| 10838 | } |
| 10839 | |
| 10840 | chan = __ieee80211_get_channel(wiphy, freq); |
| 10841 | /* When the band is changed on the fly using the GUI, three things are done |
| 10842 | * 1. scan abort |
| 10843 | * 2. flush scan results from cache |
| 10844 | * 3. update the band with the new band user specified (refer to the |
| 10845 | * hdd_set_band_helper function) as part of the scan abort, message will be |
| 10846 | * queued to PE and we proceed with flushing and changinh the band. |
| 10847 | * PE will stop the scanning further and report back the results what ever |
| 10848 | * it had till now by calling the call back function. |
| 10849 | * if the time between update band and scandone call back is sufficient |
| 10850 | * enough the band change reflects in SME, SME validates the channels |
| 10851 | * and discards the channels correponding to previous band and calls back |
| 10852 | * with zero bss results. but if the time between band update and scan done |
| 10853 | * callback is very small then band change will not reflect in SME and SME |
| 10854 | * reports to HDD all the channels correponding to previous band.this is due |
| 10855 | * to race condition.but those channels are invalid to the new band and so |
| 10856 | * this function __ieee80211_get_channel will return NULL.Each time we |
| 10857 | * report scan result with this pointer null warning kernel trace is printed. |
| 10858 | * if the scan results contain large number of APs continuosly kernel |
| 10859 | * warning trace is printed and it will lead to apps watch dog bark. |
| 10860 | * So drop the bss and continue to next bss. |
| 10861 | */ |
| 10862 | if (chan == NULL) { |
Deepthi Gowri | 084c24d | 2016-09-01 15:55:09 +0530 | [diff] [blame] | 10863 | hdd_err("chan pointer is NULL, chan_no: %d freq: %d", |
| 10864 | chan_no, freq); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10865 | kfree(mgmt); |
| 10866 | return NULL; |
| 10867 | } |
| 10868 | |
Deepak Dhamdhere | 68929ec | 2015-08-05 15:16:35 -0700 | [diff] [blame] | 10869 | /* Based on .ini configuration, raw rssi can be reported for bss. |
| 10870 | * Raw rssi is typically used for estimating power. |
| 10871 | */ |
| 10872 | |
| 10873 | rssi = (cfg_param->inform_bss_rssi_raw) ? bss_desc->rssi_raw : |
| 10874 | bss_desc->rssi; |
| 10875 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10876 | /* Supplicant takes the signal strength in terms of mBm(100*dBm) */ |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 10877 | rssi = QDF_MIN(rssi, 0) * 100; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10878 | |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 10879 | hdd_notice("BSSID: " MAC_ADDRESS_STR " Channel:%d RSSI:%d TSF %u", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10880 | MAC_ADDR_ARRAY(mgmt->bssid), chan->center_freq, |
Sandeep Puligilla | 394da5d | 2016-05-06 01:26:29 -0700 | [diff] [blame] | 10881 | (int)(rssi / 100), |
| 10882 | bss_desc->timeStamp[0]); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10883 | |
| 10884 | bss_status = |
| 10885 | cfg80211_inform_bss_frame(wiphy, chan, mgmt, frame_len, rssi, |
| 10886 | GFP_KERNEL); |
| 10887 | kfree(mgmt); |
| 10888 | return bss_status; |
| 10889 | } |
| 10890 | |
| 10891 | /** |
| 10892 | * wlan_hdd_cfg80211_update_bss_db() - update bss database of CF80211 |
| 10893 | * @pAdapter: Pointer to adapter |
| 10894 | * @pRoamInfo: Pointer to roam info |
| 10895 | * |
| 10896 | * This function is used to update the BSS data base of CFG8011 |
| 10897 | * |
| 10898 | * Return: struct cfg80211_bss pointer |
| 10899 | */ |
| 10900 | struct cfg80211_bss *wlan_hdd_cfg80211_update_bss_db(hdd_adapter_t *pAdapter, |
| 10901 | tCsrRoamInfo *pRoamInfo) |
| 10902 | { |
| 10903 | tCsrRoamConnectedProfile roamProfile; |
| 10904 | tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter); |
| 10905 | struct cfg80211_bss *bss = NULL; |
| 10906 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10907 | memset(&roamProfile, 0, sizeof(tCsrRoamConnectedProfile)); |
| 10908 | sme_roam_get_connect_profile(hHal, pAdapter->sessionId, &roamProfile); |
| 10909 | |
| 10910 | if (NULL != roamProfile.pBssDesc) { |
| 10911 | bss = wlan_hdd_cfg80211_inform_bss_frame(pAdapter, |
| 10912 | roamProfile.pBssDesc); |
| 10913 | |
| 10914 | if (NULL == bss) |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 10915 | hdd_notice("wlan_hdd_cfg80211_inform_bss_frame returned NULL"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10916 | |
Naveen Rawat | df0a7e7 | 2016-01-06 18:35:53 -0800 | [diff] [blame] | 10917 | sme_roam_free_connect_profile(&roamProfile); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10918 | } else { |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 10919 | hdd_err("roamProfile.pBssDesc is NULL"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10920 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10921 | return bss; |
| 10922 | } |
| 10923 | /** |
| 10924 | * wlan_hdd_cfg80211_update_bss() - update bss |
| 10925 | * @wiphy: Pointer to wiphy |
| 10926 | * @pAdapter: Pointer to adapter |
| 10927 | * @scan_time: scan request timestamp |
| 10928 | * |
| 10929 | * Return: zero if success, non-zero otherwise |
| 10930 | */ |
| 10931 | int wlan_hdd_cfg80211_update_bss(struct wiphy *wiphy, |
| 10932 | hdd_adapter_t *pAdapter, |
| 10933 | uint32_t scan_time) |
| 10934 | { |
| 10935 | tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter); |
| 10936 | tCsrScanResultInfo *pScanResult; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 10937 | QDF_STATUS status = 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10938 | tScanResultHandle pResult; |
| 10939 | struct cfg80211_bss *bss_status = NULL; |
| 10940 | hdd_context_t *pHddCtx; |
| 10941 | int ret; |
| 10942 | |
| 10943 | ENTER(); |
| 10944 | |
Hanumanth Reddy Pothula | d9491f4 | 2016-10-24 19:08:38 +0530 | [diff] [blame] | 10945 | if (wlan_hdd_validate_session_id(pAdapter->sessionId)) { |
| 10946 | hdd_err("invalid session id: %d", pAdapter->sessionId); |
| 10947 | return -EINVAL; |
| 10948 | } |
| 10949 | |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 10950 | MTRACE(qdf_trace(QDF_MODULE_ID_HDD, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10951 | TRACE_CODE_HDD_CFG80211_UPDATE_BSS, |
| 10952 | NO_SESSION, pAdapter->sessionId)); |
| 10953 | |
| 10954 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 10955 | ret = wlan_hdd_validate_context(pHddCtx); |
Hanumantha Reddy Pothula | 2db50ed | 2015-11-23 10:48:33 +0530 | [diff] [blame] | 10956 | if (0 != ret) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10957 | return ret; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10958 | |
| 10959 | /* start getting scan results and populate cgf80211 BSS database */ |
| 10960 | status = sme_scan_get_result(hHal, pAdapter->sessionId, NULL, &pResult); |
| 10961 | |
| 10962 | /* no scan results */ |
| 10963 | if (NULL == pResult) { |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 10964 | hdd_err("No scan result Status %d", status); |
Kapil Gupta | 0ed58dc | 2016-04-22 15:35:26 +0530 | [diff] [blame] | 10965 | return -EAGAIN; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10966 | } |
| 10967 | |
| 10968 | pScanResult = sme_scan_result_get_first(hHal, pResult); |
| 10969 | |
| 10970 | while (pScanResult) { |
| 10971 | /* |
| 10972 | * - cfg80211_inform_bss() is not updating ie field of bss |
| 10973 | * entry if entry already exists in bss data base of cfg80211 |
| 10974 | * for that particular BSS ID. Using cfg80211_inform_bss_frame |
| 10975 | * to update thebss entry instead of cfg80211_inform_bss, |
| 10976 | * But this call expects mgmt packet as input. As of now |
| 10977 | * there is no possibility to get the mgmt(probe response) |
| 10978 | * frame from PE, converting bss_desc to |
| 10979 | * ieee80211_mgmt(probe response) and passing to c |
| 10980 | * fg80211_inform_bss_frame. |
| 10981 | * - Update BSS only if beacon timestamp is later than |
| 10982 | * scan request timestamp. |
| 10983 | */ |
| 10984 | if ((scan_time == 0) || |
| 10985 | (scan_time < |
Deepthi Gowri | 6acee34 | 2016-10-28 15:00:38 +0530 | [diff] [blame] | 10986 | pScanResult->BssDescriptor.received_time)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10987 | bss_status = |
| 10988 | wlan_hdd_cfg80211_inform_bss_frame(pAdapter, |
| 10989 | &pScanResult->BssDescriptor); |
| 10990 | |
| 10991 | if (NULL == bss_status) { |
| 10992 | hdd_info("NULL returned by cfg80211_inform_bss_frame"); |
| 10993 | } else { |
| 10994 | cfg80211_put_bss( |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10995 | wiphy, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10996 | bss_status); |
| 10997 | } |
| 10998 | } else { |
| 10999 | hdd_info("BSSID: " MAC_ADDRESS_STR " Skipped", |
| 11000 | MAC_ADDR_ARRAY(pScanResult->BssDescriptor.bssId)); |
| 11001 | } |
| 11002 | pScanResult = sme_scan_result_get_next(hHal, pResult); |
| 11003 | } |
| 11004 | |
| 11005 | sme_scan_result_purge(hHal, pResult); |
| 11006 | /* |
| 11007 | * For SAP mode, scan is invoked by hostapd during SAP start |
| 11008 | * if hostapd is restarted, we need to flush previous scan |
| 11009 | * result so that it will reflect environment change |
| 11010 | */ |
Krunal Soni | b4326f2 | 2016-03-10 13:05:51 -0800 | [diff] [blame] | 11011 | if (pAdapter->device_mode == QDF_SAP_MODE |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11012 | #ifdef FEATURE_WLAN_AP_AP_ACS_OPTIMIZE |
| 11013 | && pHddCtx->skip_acs_scan_status != eSAP_SKIP_ACS_SCAN |
| 11014 | #endif |
| 11015 | ) |
| 11016 | sme_scan_flush_result(hHal); |
| 11017 | |
| 11018 | EXIT(); |
| 11019 | return 0; |
| 11020 | } |
| 11021 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11022 | /** |
| 11023 | * wlan_hdd_cfg80211_pmksa_candidate_notify() - notify a new PMSKA candidate |
| 11024 | * @pAdapter: Pointer to adapter |
| 11025 | * @pRoamInfo: Pointer to roam info |
| 11026 | * @index: Index |
| 11027 | * @preauth: Preauth flag |
| 11028 | * |
| 11029 | * This function is used to notify the supplicant of a new PMKSA candidate. |
| 11030 | * |
| 11031 | * Return: 0 for success, non-zero for failure |
| 11032 | */ |
| 11033 | int wlan_hdd_cfg80211_pmksa_candidate_notify(hdd_adapter_t *pAdapter, |
| 11034 | tCsrRoamInfo *pRoamInfo, |
| 11035 | int index, bool preauth) |
| 11036 | { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11037 | struct net_device *dev = pAdapter->dev; |
| 11038 | hdd_context_t *pHddCtx = (hdd_context_t *) pAdapter->pHddCtx; |
| 11039 | |
| 11040 | ENTER(); |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 11041 | hdd_notice("is going to notify supplicant of:"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11042 | |
| 11043 | if (NULL == pRoamInfo) { |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 11044 | hdd_alert("pRoamInfo is NULL"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11045 | return -EINVAL; |
| 11046 | } |
| 11047 | |
| 11048 | if (true == hdd_is_okc_mode_enabled(pHddCtx)) { |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 11049 | hdd_notice(MAC_ADDRESS_STR, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11050 | MAC_ADDR_ARRAY(pRoamInfo->bssid.bytes)); |
| 11051 | cfg80211_pmksa_candidate_notify(dev, index, |
| 11052 | pRoamInfo->bssid.bytes, |
| 11053 | preauth, GFP_KERNEL); |
| 11054 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11055 | return 0; |
| 11056 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11057 | |
| 11058 | #ifdef FEATURE_WLAN_LFR_METRICS |
| 11059 | /** |
| 11060 | * wlan_hdd_cfg80211_roam_metrics_preauth() - roam metrics preauth |
| 11061 | * @pAdapter: Pointer to adapter |
| 11062 | * @pRoamInfo: Pointer to roam info |
| 11063 | * |
| 11064 | * 802.11r/LFR metrics reporting function to report preauth initiation |
| 11065 | * |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 11066 | * Return: QDF status |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11067 | */ |
| 11068 | #define MAX_LFR_METRICS_EVENT_LENGTH 100 |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 11069 | QDF_STATUS wlan_hdd_cfg80211_roam_metrics_preauth(hdd_adapter_t *pAdapter, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11070 | tCsrRoamInfo *pRoamInfo) |
| 11071 | { |
| 11072 | unsigned char metrics_notification[MAX_LFR_METRICS_EVENT_LENGTH + 1]; |
| 11073 | union iwreq_data wrqu; |
| 11074 | |
| 11075 | ENTER(); |
| 11076 | |
| 11077 | if (NULL == pAdapter) { |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 11078 | hdd_err("pAdapter is NULL!"); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 11079 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11080 | } |
| 11081 | |
| 11082 | /* create the event */ |
| 11083 | memset(&wrqu, 0, sizeof(wrqu)); |
| 11084 | memset(metrics_notification, 0, sizeof(metrics_notification)); |
| 11085 | |
| 11086 | wrqu.data.pointer = metrics_notification; |
| 11087 | wrqu.data.length = scnprintf(metrics_notification, |
| 11088 | sizeof(metrics_notification), |
| 11089 | "QCOM: LFR_PREAUTH_INIT " MAC_ADDRESS_STR, |
| 11090 | MAC_ADDR_ARRAY(pRoamInfo->bssid)); |
| 11091 | |
| 11092 | wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, |
| 11093 | metrics_notification); |
| 11094 | |
| 11095 | EXIT(); |
| 11096 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 11097 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11098 | } |
| 11099 | |
| 11100 | /** |
| 11101 | * wlan_hdd_cfg80211_roam_metrics_handover() - roam metrics hand over |
| 11102 | * @pAdapter: Pointer to adapter |
| 11103 | * @pRoamInfo: Pointer to roam info |
| 11104 | * @preauth_status: Preauth status |
| 11105 | * |
| 11106 | * 802.11r/LFR metrics reporting function to report handover initiation |
| 11107 | * |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 11108 | * Return: QDF status |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11109 | */ |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 11110 | QDF_STATUS |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11111 | wlan_hdd_cfg80211_roam_metrics_preauth_status(hdd_adapter_t *pAdapter, |
| 11112 | tCsrRoamInfo *pRoamInfo, |
| 11113 | bool preauth_status) |
| 11114 | { |
| 11115 | unsigned char metrics_notification[MAX_LFR_METRICS_EVENT_LENGTH + 1]; |
| 11116 | union iwreq_data wrqu; |
| 11117 | |
| 11118 | ENTER(); |
| 11119 | |
| 11120 | if (NULL == pAdapter) { |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 11121 | hdd_err("pAdapter is NULL!"); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 11122 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11123 | } |
| 11124 | |
| 11125 | /* create the event */ |
| 11126 | memset(&wrqu, 0, sizeof(wrqu)); |
| 11127 | memset(metrics_notification, 0, sizeof(metrics_notification)); |
| 11128 | |
| 11129 | scnprintf(metrics_notification, sizeof(metrics_notification), |
| 11130 | "QCOM: LFR_PREAUTH_STATUS " MAC_ADDRESS_STR, |
| 11131 | MAC_ADDR_ARRAY(pRoamInfo->bssid)); |
| 11132 | |
| 11133 | if (1 == preauth_status) |
| 11134 | strlcat(metrics_notification, " true", |
| 11135 | sizeof(metrics_notification)); |
| 11136 | else |
| 11137 | strlcat(metrics_notification, " false", |
| 11138 | sizeof(metrics_notification)); |
| 11139 | |
| 11140 | wrqu.data.pointer = metrics_notification; |
| 11141 | wrqu.data.length = strlen(metrics_notification); |
| 11142 | |
| 11143 | wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, |
| 11144 | metrics_notification); |
| 11145 | |
| 11146 | EXIT(); |
| 11147 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 11148 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11149 | } |
| 11150 | |
| 11151 | /** |
| 11152 | * wlan_hdd_cfg80211_roam_metrics_handover() - roam metrics hand over |
| 11153 | * @pAdapter: Pointer to adapter |
| 11154 | * @pRoamInfo: Pointer to roam info |
| 11155 | * |
| 11156 | * 802.11r/LFR metrics reporting function to report handover initiation |
| 11157 | * |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 11158 | * Return: QDF status |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11159 | */ |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 11160 | QDF_STATUS wlan_hdd_cfg80211_roam_metrics_handover(hdd_adapter_t *pAdapter, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11161 | tCsrRoamInfo *pRoamInfo) |
| 11162 | { |
| 11163 | unsigned char metrics_notification[MAX_LFR_METRICS_EVENT_LENGTH + 1]; |
| 11164 | union iwreq_data wrqu; |
| 11165 | |
| 11166 | ENTER(); |
| 11167 | |
| 11168 | if (NULL == pAdapter) { |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 11169 | hdd_err("pAdapter is NULL!"); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 11170 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11171 | } |
| 11172 | |
| 11173 | /* create the event */ |
| 11174 | memset(&wrqu, 0, sizeof(wrqu)); |
| 11175 | memset(metrics_notification, 0, sizeof(metrics_notification)); |
| 11176 | |
| 11177 | wrqu.data.pointer = metrics_notification; |
| 11178 | wrqu.data.length = scnprintf(metrics_notification, |
| 11179 | sizeof(metrics_notification), |
| 11180 | "QCOM: LFR_PREAUTH_HANDOVER " |
| 11181 | MAC_ADDRESS_STR, |
| 11182 | MAC_ADDR_ARRAY(pRoamInfo->bssid)); |
| 11183 | |
| 11184 | wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, |
| 11185 | metrics_notification); |
| 11186 | |
| 11187 | EXIT(); |
| 11188 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 11189 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11190 | } |
| 11191 | #endif |
| 11192 | |
| 11193 | /** |
| 11194 | * hdd_select_cbmode() - select channel bonding mode |
| 11195 | * @pAdapter: Pointer to adapter |
| 11196 | * @operatingChannel: Operating channel |
Naveen Rawat | c77e6e7 | 2016-08-05 15:19:03 -0700 | [diff] [blame] | 11197 | * @ch_params: channel info struct to populate |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11198 | * |
| 11199 | * Return: none |
| 11200 | */ |
Naveen Rawat | c77e6e7 | 2016-08-05 15:19:03 -0700 | [diff] [blame] | 11201 | void hdd_select_cbmode(hdd_adapter_t *pAdapter, uint8_t operationChannel, |
| 11202 | struct ch_params_s *ch_params) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11203 | { |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 11204 | 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] | 11205 | struct hdd_mon_set_ch_info *ch_info = &station_ctx->ch_info; |
Sandeep Puligilla | 1cc23f6 | 2016-04-27 16:52:49 -0700 | [diff] [blame] | 11206 | uint8_t sec_ch = 0; |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 11207 | |
Sandeep Puligilla | 1cc23f6 | 2016-04-27 16:52:49 -0700 | [diff] [blame] | 11208 | /* |
| 11209 | * CDS api expects secondary channel for calculating |
| 11210 | * the channel params |
| 11211 | */ |
Naveen Rawat | c77e6e7 | 2016-08-05 15:19:03 -0700 | [diff] [blame] | 11212 | if ((ch_params->ch_width == CH_WIDTH_40MHZ) && |
Sandeep Puligilla | 1cc23f6 | 2016-04-27 16:52:49 -0700 | [diff] [blame] | 11213 | (CDS_IS_CHANNEL_24GHZ(operationChannel))) { |
| 11214 | if (operationChannel >= 1 && operationChannel <= 5) |
| 11215 | sec_ch = operationChannel + 4; |
| 11216 | else if (operationChannel >= 6 && operationChannel <= 13) |
| 11217 | sec_ch = operationChannel - 4; |
| 11218 | } |
| 11219 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11220 | /* This call decides required channel bonding mode */ |
Naveen Rawat | c77e6e7 | 2016-08-05 15:19:03 -0700 | [diff] [blame] | 11221 | cds_set_channel_params(operationChannel, sec_ch, ch_params); |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 11222 | |
| 11223 | if (QDF_GLOBAL_MONITOR_MODE == cds_get_conparam()) { |
Naveen Rawat | c77e6e7 | 2016-08-05 15:19:03 -0700 | [diff] [blame] | 11224 | eHddDot11Mode hdd_dot11_mode; |
| 11225 | uint8_t iniDot11Mode = |
| 11226 | (WLAN_HDD_GET_CTX(pAdapter))->config->dot11Mode; |
| 11227 | |
| 11228 | hdd_notice("Dot11Mode is %u", iniDot11Mode); |
| 11229 | switch (iniDot11Mode) { |
| 11230 | case eHDD_DOT11_MODE_AUTO: |
| 11231 | case eHDD_DOT11_MODE_11ac: |
| 11232 | case eHDD_DOT11_MODE_11ac_ONLY: |
| 11233 | if (sme_is_feature_supported_by_fw(DOT11AC)) |
| 11234 | hdd_dot11_mode = eHDD_DOT11_MODE_11ac; |
| 11235 | else |
| 11236 | hdd_dot11_mode = eHDD_DOT11_MODE_11n; |
| 11237 | break; |
| 11238 | case eHDD_DOT11_MODE_11n: |
| 11239 | case eHDD_DOT11_MODE_11n_ONLY: |
| 11240 | hdd_dot11_mode = eHDD_DOT11_MODE_11n; |
| 11241 | break; |
| 11242 | default: |
| 11243 | hdd_dot11_mode = iniDot11Mode; |
| 11244 | break; |
| 11245 | } |
| 11246 | ch_info->channel_width = ch_params->ch_width; |
| 11247 | ch_info->phy_mode = |
| 11248 | hdd_cfg_xlate_to_csr_phy_mode(hdd_dot11_mode); |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 11249 | ch_info->channel = operationChannel; |
Naveen Rawat | c77e6e7 | 2016-08-05 15:19:03 -0700 | [diff] [blame] | 11250 | ch_info->cb_mode = ch_params->ch_width; |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 11251 | hdd_info("ch_info width %d, phymode %d channel %d", |
| 11252 | ch_info->channel_width, ch_info->phy_mode, |
| 11253 | ch_info->channel); |
| 11254 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11255 | } |
| 11256 | |
Rajeev Kumar | 249ea8d | 2016-04-15 16:57:46 -0700 | [diff] [blame] | 11257 | /** |
| 11258 | * wlan_hdd_handle_sap_sta_dfs_conc() - to handle SAP STA DFS conc |
| 11259 | * @adapter: STA adapter |
| 11260 | * @roam_profile: STA roam profile |
| 11261 | * |
| 11262 | * This routine will move SAP from dfs to non-dfs, if sta is coming up. |
| 11263 | * |
| 11264 | * Return: false if sta-sap conc is not allowed, else return true |
| 11265 | */ |
| 11266 | static bool wlan_hdd_handle_sap_sta_dfs_conc(hdd_adapter_t *adapter, |
| 11267 | tCsrRoamProfile *roam_profile) |
| 11268 | { |
| 11269 | hdd_context_t *hdd_ctx; |
| 11270 | hdd_adapter_t *ap_adapter; |
| 11271 | hdd_ap_ctx_t *hdd_ap_ctx; |
| 11272 | hdd_hostapd_state_t *hostapd_state; |
| 11273 | uint8_t channel = 0; |
| 11274 | QDF_STATUS status; |
| 11275 | |
| 11276 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 11277 | if (!hdd_ctx) { |
| 11278 | hdd_err("HDD context is NULL"); |
| 11279 | return true; |
| 11280 | } |
| 11281 | |
| 11282 | ap_adapter = hdd_get_adapter(hdd_ctx, QDF_SAP_MODE); |
| 11283 | /* probably no sap running, no handling required */ |
| 11284 | if (ap_adapter == NULL) |
| 11285 | return true; |
| 11286 | |
| 11287 | /* |
| 11288 | * sap is not in started state, so it is fine to go ahead with sta. |
| 11289 | * if sap is currently doing CAC then don't allow sta to go further. |
| 11290 | */ |
| 11291 | if (!test_bit(SOFTAP_BSS_STARTED, &(ap_adapter)->event_flags) && |
| 11292 | (hdd_ctx->dev_dfs_cac_status != DFS_CAC_IN_PROGRESS)) |
| 11293 | return true; |
| 11294 | |
| 11295 | if (hdd_ctx->dev_dfs_cac_status == DFS_CAC_IN_PROGRESS) { |
| 11296 | hdd_err("Concurrent SAP is in CAC state, STA is not allowed"); |
| 11297 | return false; |
| 11298 | } |
| 11299 | |
| 11300 | /* |
| 11301 | * log and return error, if we allow STA to go through, we don't |
| 11302 | * know what is going to happen better stop sta connection |
| 11303 | */ |
| 11304 | hdd_ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(ap_adapter); |
| 11305 | if (NULL == hdd_ap_ctx) { |
| 11306 | hdd_err("AP context not found"); |
| 11307 | return false; |
| 11308 | } |
| 11309 | |
| 11310 | /* sap is on non-dfs channel, nothing to handle */ |
| 11311 | if (!CDS_IS_DFS_CH(hdd_ap_ctx->operatingChannel)) { |
| 11312 | hdd_info("sap is on non-dfs channel, sta is allowed"); |
| 11313 | return true; |
| 11314 | } |
| 11315 | /* |
| 11316 | * 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] | 11317 | * connect by passing its roam_profile. |
Rajeev Kumar | 249ea8d | 2016-04-15 16:57:46 -0700 | [diff] [blame] | 11318 | */ |
| 11319 | status = cds_get_channel_from_scan_result(adapter, |
| 11320 | roam_profile, &channel); |
| 11321 | |
Nitesh Shah | 5977452 | 2016-09-16 15:14:21 +0530 | [diff] [blame] | 11322 | /* |
| 11323 | * If the STA's channel is 2.4 GHz, then set pcl with only 2.4 GHz |
| 11324 | * channels for roaming case. |
| 11325 | */ |
| 11326 | if (CDS_IS_CHANNEL_24GHZ(channel)) { |
| 11327 | hdd_info("sap is on dfs, new sta conn on 2.4 is allowed"); |
| 11328 | return true; |
| 11329 | } |
| 11330 | |
| 11331 | /* |
| 11332 | * If channel is 0 or DFS then better to call pcl and find out the |
| 11333 | * best channel. If channel is non-dfs 5 GHz then better move SAP |
| 11334 | * to STA's channel to make scc, so we have room for 3port MCC |
| 11335 | * scenario. |
| 11336 | */ |
| 11337 | if ((0 == channel) || CDS_IS_DFS_CH(channel)) |
Rajeev Kumar | 249ea8d | 2016-04-15 16:57:46 -0700 | [diff] [blame] | 11338 | channel = cds_get_nondfs_preferred_channel(CDS_SAP_MODE, |
| 11339 | true); |
| 11340 | |
| 11341 | hostapd_state = WLAN_HDD_GET_HOSTAP_STATE_PTR(ap_adapter); |
| 11342 | qdf_event_reset(&hostapd_state->qdf_event); |
| 11343 | status = wlansap_set_channel_change_with_csa( |
| 11344 | WLAN_HDD_GET_SAP_CTX_PTR(ap_adapter), channel, |
| 11345 | hdd_ap_ctx->sapConfig.ch_width_orig); |
| 11346 | |
| 11347 | if (QDF_STATUS_SUCCESS != status) { |
| 11348 | hdd_err("Set channel with CSA IE failed, can't allow STA"); |
| 11349 | return false; |
| 11350 | } |
| 11351 | |
| 11352 | /* |
| 11353 | * wait here for SAP to finish the channel switch. When channel |
| 11354 | * switch happens, SAP sends few beacons with CSA_IE. After |
| 11355 | * successfully Transmission of those beacons, it will move its |
| 11356 | * state from started to disconnected and move to new channel. |
| 11357 | * once it moves to new channel, sap again moves its state |
| 11358 | * machine from disconnected to started and set this event. |
| 11359 | * wait for 10 secs to finish this. |
| 11360 | */ |
| 11361 | status = qdf_wait_single_event(&hostapd_state->qdf_event, 10000); |
| 11362 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 11363 | hdd_err("wait for qdf_event failed, STA not allowed!!"); |
| 11364 | return false; |
| 11365 | } |
| 11366 | |
| 11367 | return true; |
| 11368 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11369 | |
Krunal Soni | 3194942 | 2016-07-29 17:17:53 -0700 | [diff] [blame] | 11370 | /** |
| 11371 | * wlan_hdd_cfg80211_connect_start() - to start the association process |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11372 | * @pAdapter: Pointer to adapter |
Krunal Soni | 3194942 | 2016-07-29 17:17:53 -0700 | [diff] [blame] | 11373 | * @ssid: Pointer to ssid |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11374 | * @ssid_len: Length of ssid |
| 11375 | * @bssid: Pointer to bssid |
Krunal Soni | 3194942 | 2016-07-29 17:17:53 -0700 | [diff] [blame] | 11376 | * @bssid_hint: Pointer to bssid hint |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11377 | * @operatingChannel: Operating channel |
Naveen Rawat | c77e6e7 | 2016-08-05 15:19:03 -0700 | [diff] [blame] | 11378 | * @ch_width: channel width. this is needed only for IBSS |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11379 | * |
| 11380 | * This function is used to start the association process |
| 11381 | * |
| 11382 | * Return: 0 for success, non-zero for failure |
| 11383 | */ |
Krunal Soni | 3194942 | 2016-07-29 17:17:53 -0700 | [diff] [blame] | 11384 | static int wlan_hdd_cfg80211_connect_start(hdd_adapter_t *pAdapter, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11385 | const u8 *ssid, size_t ssid_len, |
Krunal Soni | 3194942 | 2016-07-29 17:17:53 -0700 | [diff] [blame] | 11386 | const u8 *bssid, const u8 *bssid_hint, |
Naveen Rawat | c77e6e7 | 2016-08-05 15:19:03 -0700 | [diff] [blame] | 11387 | u8 operatingChannel, |
| 11388 | enum nl80211_chan_width ch_width) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11389 | { |
| 11390 | int status = 0; |
| 11391 | hdd_wext_state_t *pWextState; |
| 11392 | hdd_context_t *pHddCtx; |
Anurag Chouhan | 5de8d17 | 2016-07-13 14:44:28 +0530 | [diff] [blame] | 11393 | hdd_station_ctx_t *hdd_sta_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11394 | uint32_t roamId; |
| 11395 | tCsrRoamProfile *pRoamProfile; |
| 11396 | eCsrAuthType RSNAuthType; |
| 11397 | tSmeConfigParams *sme_config; |
Nitesh Shah | 044fd67 | 2016-10-13 18:53:25 +0530 | [diff] [blame] | 11398 | uint8_t channel = 0; |
| 11399 | struct sir_hw_mode_params hw_mode; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11400 | |
| 11401 | ENTER(); |
| 11402 | |
| 11403 | pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
| 11404 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
Anurag Chouhan | 5de8d17 | 2016-07-13 14:44:28 +0530 | [diff] [blame] | 11405 | hdd_sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11406 | |
| 11407 | status = wlan_hdd_validate_context(pHddCtx); |
Hanumantha Reddy Pothula | 2db50ed | 2015-11-23 10:48:33 +0530 | [diff] [blame] | 11408 | if (status) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11409 | return status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11410 | |
| 11411 | if (SIR_MAC_MAX_SSID_LENGTH < ssid_len) { |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 11412 | hdd_err("wrong SSID len"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11413 | return -EINVAL; |
| 11414 | } |
| 11415 | |
| 11416 | pRoamProfile = &pWextState->roamProfile; |
Anurag Chouhan | d939d3d | 2016-07-20 17:45:48 +0530 | [diff] [blame] | 11417 | qdf_mem_zero(&hdd_sta_ctx->conn_info.conn_flag, |
| 11418 | sizeof(hdd_sta_ctx->conn_info.conn_flag)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11419 | |
| 11420 | if (pRoamProfile) { |
| 11421 | hdd_station_ctx_t *pHddStaCtx; |
| 11422 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 11423 | |
| 11424 | if (HDD_WMM_USER_MODE_NO_QOS == |
| 11425 | (WLAN_HDD_GET_CTX(pAdapter))->config->WmmMode) { |
| 11426 | /*QoS not enabled in cfg file */ |
| 11427 | pRoamProfile->uapsd_mask = 0; |
| 11428 | } else { |
| 11429 | /*QoS enabled, update uapsd mask from cfg file */ |
| 11430 | pRoamProfile->uapsd_mask = |
| 11431 | (WLAN_HDD_GET_CTX(pAdapter))->config->UapsdMask; |
| 11432 | } |
| 11433 | |
| 11434 | pRoamProfile->SSIDs.numOfSSIDs = 1; |
| 11435 | pRoamProfile->SSIDs.SSIDList->SSID.length = ssid_len; |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 11436 | qdf_mem_zero(pRoamProfile->SSIDs.SSIDList->SSID.ssId, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11437 | sizeof(pRoamProfile->SSIDs.SSIDList->SSID.ssId)); |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 11438 | qdf_mem_copy((void *)(pRoamProfile->SSIDs.SSIDList->SSID.ssId), |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11439 | ssid, ssid_len); |
| 11440 | |
Sreelakshmi Konamki | bda5bbf | 2016-09-12 18:38:10 +0530 | [diff] [blame] | 11441 | pRoamProfile->do_not_roam = false; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11442 | if (bssid) { |
| 11443 | pRoamProfile->BSSIDs.numOfBSSIDs = 1; |
Sreelakshmi Konamki | bda5bbf | 2016-09-12 18:38:10 +0530 | [diff] [blame] | 11444 | pRoamProfile->do_not_roam = true; |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 11445 | qdf_mem_copy((void *)(pRoamProfile->BSSIDs.bssid), |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 11446 | bssid, QDF_MAC_ADDR_SIZE); |
Krunal Soni | 3194942 | 2016-07-29 17:17:53 -0700 | [diff] [blame] | 11447 | /* |
| 11448 | * Save BSSID in seperate variable as |
| 11449 | * pRoamProfile's BSSID is getting zeroed out in the |
| 11450 | * association process. In case of join failure |
| 11451 | * we should send valid BSSID to supplicant |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11452 | */ |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 11453 | qdf_mem_copy((void *)(pWextState->req_bssId.bytes), |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 11454 | bssid, QDF_MAC_ADDR_SIZE); |
Krunal Soni | 35b404c | 2016-07-14 23:36:00 -0700 | [diff] [blame] | 11455 | hdd_info("bssid is given by upper layer %pM", bssid); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11456 | } else if (bssid_hint) { |
| 11457 | pRoamProfile->BSSIDs.numOfBSSIDs = 1; |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 11458 | qdf_mem_copy((void *)(pRoamProfile->BSSIDs.bssid), |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 11459 | bssid_hint, QDF_MAC_ADDR_SIZE); |
Krunal Soni | 3194942 | 2016-07-29 17:17:53 -0700 | [diff] [blame] | 11460 | /* |
| 11461 | * Save BSSID in a separate variable as |
| 11462 | * pRoamProfile's BSSID is getting zeroed out in the |
| 11463 | * association process. In case of join failure |
| 11464 | * we should send valid BSSID to supplicant |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11465 | */ |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 11466 | qdf_mem_copy((void *)(pWextState->req_bssId.bytes), |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 11467 | bssid_hint, QDF_MAC_ADDR_SIZE); |
Krunal Soni | 35b404c | 2016-07-14 23:36:00 -0700 | [diff] [blame] | 11468 | hdd_info("bssid_hint is given by upper layer %pM", |
| 11469 | bssid_hint); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11470 | } else { |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 11471 | qdf_mem_zero((void *)(pRoamProfile->BSSIDs.bssid), |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 11472 | QDF_MAC_ADDR_SIZE); |
Krunal Soni | 35b404c | 2016-07-14 23:36:00 -0700 | [diff] [blame] | 11473 | hdd_info("no bssid given by upper layer"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11474 | } |
| 11475 | |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 11476 | hdd_notice("Connect to SSID: %.*s operating Channel: %u", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11477 | pRoamProfile->SSIDs.SSIDList->SSID.length, |
| 11478 | pRoamProfile->SSIDs.SSIDList->SSID.ssId, |
| 11479 | operatingChannel); |
| 11480 | |
| 11481 | if ((IW_AUTH_WPA_VERSION_WPA == pWextState->wpaVersion) || |
| 11482 | (IW_AUTH_WPA_VERSION_WPA2 == pWextState->wpaVersion)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11483 | hdd_set_genie_to_csr(pAdapter, &RSNAuthType); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11484 | hdd_set_csr_auth_type(pAdapter, RSNAuthType); |
| 11485 | } |
| 11486 | #ifdef FEATURE_WLAN_WAPI |
| 11487 | if (pAdapter->wapi_info.nWapiMode) { |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 11488 | hdd_notice("Setting WAPI AUTH Type and Encryption Mode values"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11489 | switch (pAdapter->wapi_info.wapiAuthMode) { |
| 11490 | case WAPI_AUTH_MODE_PSK: |
| 11491 | { |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 11492 | hdd_notice("WAPI AUTH TYPE: PSK: %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11493 | pAdapter->wapi_info.wapiAuthMode); |
| 11494 | pRoamProfile->AuthType.authType[0] = |
| 11495 | eCSR_AUTH_TYPE_WAPI_WAI_PSK; |
| 11496 | break; |
| 11497 | } |
| 11498 | case WAPI_AUTH_MODE_CERT: |
| 11499 | { |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 11500 | hdd_notice("WAPI AUTH TYPE: CERT: %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11501 | pAdapter->wapi_info.wapiAuthMode); |
| 11502 | pRoamProfile->AuthType.authType[0] = |
| 11503 | eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE; |
| 11504 | break; |
| 11505 | } |
| 11506 | } /* End of switch */ |
| 11507 | if (pAdapter->wapi_info.wapiAuthMode == |
| 11508 | WAPI_AUTH_MODE_PSK |
| 11509 | || pAdapter->wapi_info.wapiAuthMode == |
| 11510 | WAPI_AUTH_MODE_CERT) { |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 11511 | hdd_notice("WAPI PAIRWISE/GROUP ENCRYPTION: WPI"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11512 | pRoamProfile->AuthType.numEntries = 1; |
| 11513 | pRoamProfile->EncryptionType.numEntries = 1; |
| 11514 | pRoamProfile->EncryptionType.encryptionType[0] = |
| 11515 | eCSR_ENCRYPT_TYPE_WPI; |
| 11516 | pRoamProfile->mcEncryptionType.numEntries = 1; |
| 11517 | pRoamProfile->mcEncryptionType. |
| 11518 | encryptionType[0] = eCSR_ENCRYPT_TYPE_WPI; |
| 11519 | } |
| 11520 | } |
Krunal Soni | 3194942 | 2016-07-29 17:17:53 -0700 | [diff] [blame] | 11521 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11522 | #ifdef WLAN_FEATURE_GTK_OFFLOAD |
| 11523 | /* Initializing gtkOffloadReqParams */ |
Krunal Soni | b4326f2 | 2016-03-10 13:05:51 -0800 | [diff] [blame] | 11524 | if ((QDF_STA_MODE == pAdapter->device_mode) || |
| 11525 | (QDF_P2P_CLIENT_MODE == pAdapter->device_mode)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11526 | memset(&pHddStaCtx->gtkOffloadReqParams, 0, |
| 11527 | sizeof(tSirGtkOffloadParams)); |
| 11528 | pHddStaCtx->gtkOffloadReqParams.ulFlags = |
| 11529 | GTK_OFFLOAD_DISABLE; |
| 11530 | } |
| 11531 | #endif |
| 11532 | pRoamProfile->csrPersona = pAdapter->device_mode; |
| 11533 | |
| 11534 | if (operatingChannel) { |
| 11535 | pRoamProfile->ChannelInfo.ChannelList = |
| 11536 | &operatingChannel; |
| 11537 | pRoamProfile->ChannelInfo.numOfChannels = 1; |
| 11538 | } else { |
| 11539 | pRoamProfile->ChannelInfo.ChannelList = NULL; |
| 11540 | pRoamProfile->ChannelInfo.numOfChannels = 0; |
| 11541 | } |
Krunal Soni | b4326f2 | 2016-03-10 13:05:51 -0800 | [diff] [blame] | 11542 | if ((QDF_IBSS_MODE == pAdapter->device_mode) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11543 | && operatingChannel) { |
| 11544 | /* |
| 11545 | * Need to post the IBSS power save parameters |
| 11546 | * to WMA. WMA will configure this parameters |
| 11547 | * to firmware if power save is enabled by the |
| 11548 | * firmware. |
| 11549 | */ |
| 11550 | status = hdd_set_ibss_power_save_params(pAdapter); |
| 11551 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 11552 | if (QDF_STATUS_SUCCESS != status) { |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 11553 | hdd_err("Set IBSS Power Save Params Failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11554 | return -EINVAL; |
| 11555 | } |
Naveen Rawat | c77e6e7 | 2016-08-05 15:19:03 -0700 | [diff] [blame] | 11556 | pRoamProfile->ch_params.ch_width = |
| 11557 | hdd_map_nl_chan_width(ch_width); |
Nitesh Shah | 87335a5 | 2016-09-05 15:47:32 +0530 | [diff] [blame] | 11558 | /* |
| 11559 | * In IBSS mode while operating in 2.4 GHz, |
| 11560 | * the device supports only 20 MHz. |
| 11561 | */ |
| 11562 | if (CDS_IS_CHANNEL_24GHZ(operatingChannel)) |
| 11563 | pRoamProfile->ch_params.ch_width = |
| 11564 | CH_WIDTH_20MHZ; |
Naveen Rawat | c77e6e7 | 2016-08-05 15:19:03 -0700 | [diff] [blame] | 11565 | hdd_select_cbmode(pAdapter, operatingChannel, |
| 11566 | &pRoamProfile->ch_params); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11567 | } |
Abhishek Singh | 99bce86 | 2016-06-20 15:10:51 +0530 | [diff] [blame] | 11568 | /* |
| 11569 | * if MFPEnabled is set but the peer AP is non-PMF i.e 80211w=2 |
| 11570 | * or pmf=2 is an explicit configuration in the supplicant |
| 11571 | * configuration, drop the connection request. |
| 11572 | */ |
| 11573 | if (pWextState->roamProfile.MFPEnabled && |
| 11574 | !(pWextState->roamProfile.MFPRequired || |
| 11575 | pWextState->roamProfile.MFPCapable)) { |
| 11576 | hdd_err("Drop connect req as supplicant has indicated PMF req for a non-PMF peer. MFPEnabled %d MFPRequired %d MFPCapable %d", |
| 11577 | pWextState->roamProfile.MFPEnabled, |
| 11578 | pWextState->roamProfile.MFPRequired, |
| 11579 | pWextState->roamProfile.MFPCapable); |
| 11580 | return -EINVAL; |
| 11581 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11582 | |
Krunal Soni | 3091bcc | 2016-06-23 12:28:21 -0700 | [diff] [blame] | 11583 | if (true == cds_is_connection_in_progress()) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11584 | hdd_err("Connection refused: conn in progress"); |
| 11585 | return -EINVAL; |
| 11586 | } |
| 11587 | |
Krunal Soni | 3194942 | 2016-07-29 17:17:53 -0700 | [diff] [blame] | 11588 | /* |
| 11589 | * After 8-way handshake supplicant should give the scan command |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11590 | * in that it update the additional IEs, But because of scan |
Krunal Soni | 3194942 | 2016-07-29 17:17:53 -0700 | [diff] [blame] | 11591 | * enhancements, the supplicant is not issuing the scan command |
| 11592 | * now. So the unicast frames which are sent from the host are |
| 11593 | * not having the additional IEs. If it is P2P CLIENT and there |
| 11594 | * is no additional IE present in roamProfile, then use the |
| 11595 | * addtional IE form scan_info |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11596 | */ |
| 11597 | |
Krunal Soni | b4326f2 | 2016-03-10 13:05:51 -0800 | [diff] [blame] | 11598 | if ((pAdapter->device_mode == QDF_P2P_CLIENT_MODE) && |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11599 | (!pRoamProfile->pAddIEScan)) { |
| 11600 | pRoamProfile->pAddIEScan = |
| 11601 | &pAdapter->scan_info.scanAddIE.addIEdata[0]; |
| 11602 | pRoamProfile->nAddIEScanLength = |
| 11603 | pAdapter->scan_info.scanAddIE.length; |
| 11604 | } |
| 11605 | /* |
| 11606 | * When policy manager is enabled from ini file, we shouldn't |
| 11607 | * check for other concurrency rules. |
| 11608 | */ |
Krunal Soni | 3091bcc | 2016-06-23 12:28:21 -0700 | [diff] [blame] | 11609 | if (wma_is_hw_dbs_capable() == false) { |
Tushnim Bhattacharyya | 4adb368 | 2016-01-07 15:07:12 -0800 | [diff] [blame] | 11610 | cds_handle_conc_rule1(pAdapter, pRoamProfile); |
Tushnim Bhattacharyya | ca50b32 | 2015-12-28 17:14:36 -0800 | [diff] [blame] | 11611 | if (true != cds_handle_conc_rule2( |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11612 | pAdapter, pRoamProfile, &roamId)) |
| 11613 | return 0; |
| 11614 | } |
| 11615 | |
Krunal Soni | 3091bcc | 2016-06-23 12:28:21 -0700 | [diff] [blame] | 11616 | if ((wma_is_hw_dbs_capable() == true) && |
Rajeev Kumar | 249ea8d | 2016-04-15 16:57:46 -0700 | [diff] [blame] | 11617 | (false == wlan_hdd_handle_sap_sta_dfs_conc(pAdapter, |
| 11618 | pRoamProfile))) { |
| 11619 | hdd_err("sap-sta conc will fail, can't allow sta"); |
| 11620 | hdd_conn_set_connection_state(pAdapter, |
| 11621 | eConnectionState_NotConnected); |
| 11622 | return -ENOMEM; |
| 11623 | } |
| 11624 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 11625 | sme_config = qdf_mem_malloc(sizeof(*sme_config)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11626 | if (!sme_config) { |
| 11627 | hdd_err("unable to allocate sme_config"); |
Rajeev Kumar | 249ea8d | 2016-04-15 16:57:46 -0700 | [diff] [blame] | 11628 | hdd_conn_set_connection_state(pAdapter, |
| 11629 | eConnectionState_NotConnected); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11630 | return -ENOMEM; |
| 11631 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11632 | sme_get_config_param(pHddCtx->hHal, sme_config); |
| 11633 | /* These values are not sessionized. So, any change in these SME |
| 11634 | * configs on an older or parallel interface will affect the |
| 11635 | * cb mode. So, restoring the default INI params before starting |
| 11636 | * interfaces such as sta, cli etc., |
| 11637 | */ |
| 11638 | sme_config->csrConfig.channelBondingMode5GHz = |
| 11639 | pHddCtx->config->nChannelBondingMode5GHz; |
| 11640 | sme_config->csrConfig.channelBondingMode24GHz = |
| 11641 | pHddCtx->config->nChannelBondingMode24GHz; |
| 11642 | sme_update_config(pHddCtx->hHal, sme_config); |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 11643 | qdf_mem_free(sme_config); |
Agrawal Ashish | 6b01576 | 2016-05-05 11:22:18 +0530 | [diff] [blame] | 11644 | /* |
| 11645 | * Change conn_state to connecting before sme_roam_connect(), |
| 11646 | * because sme_roam_connect() has a direct path to call |
| 11647 | * hdd_sme_roam_callback(), which will change the conn_state |
| 11648 | * If direct path, conn_state will be accordingly changed to |
| 11649 | * NotConnected or Associated by either |
| 11650 | * hdd_association_completion_handler() or |
| 11651 | * hdd_dis_connect_handler() in sme_RoamCallback()if |
| 11652 | * sme_RomConnect is to be queued, |
| 11653 | * Connecting state will remain until it is completed. |
| 11654 | * |
| 11655 | * If connection state is not changed, connection state will |
| 11656 | * remain in eConnectionState_NotConnected state. |
| 11657 | * In hdd_association_completion_handler, "hddDisconInProgress" |
| 11658 | * is set to true if conn state is |
| 11659 | * eConnectionState_NotConnected. |
| 11660 | * If "hddDisconInProgress" is set to true then cfg80211 layer |
| 11661 | * is not informed of connect result indication which |
| 11662 | * is an issue. |
| 11663 | */ |
| 11664 | if (QDF_STA_MODE == pAdapter->device_mode || |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 11665 | QDF_P2P_CLIENT_MODE == pAdapter->device_mode) |
Agrawal Ashish | 6b01576 | 2016-05-05 11:22:18 +0530 | [diff] [blame] | 11666 | hdd_conn_set_connection_state(pAdapter, |
| 11667 | eConnectionState_Connecting); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11668 | |
Komal Seelam | a89be8d | 2016-09-29 11:09:26 +0530 | [diff] [blame] | 11669 | qdf_runtime_pm_prevent_suspend(pAdapter->connect_rpm_ctx. |
| 11670 | connect); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11671 | status = sme_roam_connect(WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 11672 | pAdapter->sessionId, pRoamProfile, |
| 11673 | &roamId); |
| 11674 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 11675 | if ((QDF_STATUS_SUCCESS != status) && |
Krunal Soni | b4326f2 | 2016-03-10 13:05:51 -0800 | [diff] [blame] | 11676 | (QDF_STA_MODE == pAdapter->device_mode || |
| 11677 | QDF_P2P_CLIENT_MODE == pAdapter->device_mode)) { |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 11678 | hdd_err("sme_roam_connect (session %d) failed with " |
| 11679 | "status %d. -> NotConnected", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11680 | pAdapter->sessionId, status); |
| 11681 | /* change back to NotAssociated */ |
| 11682 | hdd_conn_set_connection_state(pAdapter, |
| 11683 | eConnectionState_NotConnected); |
Komal Seelam | a89be8d | 2016-09-29 11:09:26 +0530 | [diff] [blame] | 11684 | qdf_runtime_pm_allow_suspend(pAdapter->connect_rpm_ctx. |
| 11685 | connect); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11686 | } |
| 11687 | |
| 11688 | pRoamProfile->ChannelInfo.ChannelList = NULL; |
| 11689 | pRoamProfile->ChannelInfo.numOfChannels = 0; |
| 11690 | |
Nitesh Shah | 044fd67 | 2016-10-13 18:53:25 +0530 | [diff] [blame] | 11691 | if (!QDF_IS_STATUS_SUCCESS( |
| 11692 | wma_get_current_hw_mode(&hw_mode))) { |
| 11693 | hdd_err("wma_get_current_hw_mode failed"); |
| 11694 | return status; |
| 11695 | } |
| 11696 | |
| 11697 | if ((QDF_STA_MODE == pAdapter->device_mode) |
| 11698 | && hw_mode.dbs_cap) { |
| 11699 | cds_get_channel_from_scan_result(pAdapter, |
| 11700 | pRoamProfile, &channel); |
| 11701 | if (channel) |
| 11702 | cds_checkn_update_hw_mode_single_mac_mode |
| 11703 | (channel); |
| 11704 | } |
| 11705 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11706 | } else { |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 11707 | hdd_err("No valid Roam profile"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11708 | return -EINVAL; |
| 11709 | } |
| 11710 | EXIT(); |
| 11711 | return status; |
| 11712 | } |
| 11713 | |
| 11714 | /** |
| 11715 | * wlan_hdd_cfg80211_set_auth_type() - set auth type |
| 11716 | * @pAdapter: Pointer to adapter |
| 11717 | * @auth_type: Auth type |
| 11718 | * |
| 11719 | * This function is used to set the authentication type (OPEN/SHARED). |
| 11720 | * |
| 11721 | * Return: 0 for success, non-zero for failure |
| 11722 | */ |
| 11723 | static int wlan_hdd_cfg80211_set_auth_type(hdd_adapter_t *pAdapter, |
| 11724 | enum nl80211_auth_type auth_type) |
| 11725 | { |
| 11726 | hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
| 11727 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 11728 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11729 | /*set authentication type */ |
| 11730 | switch (auth_type) { |
| 11731 | case NL80211_AUTHTYPE_AUTOMATIC: |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 11732 | hdd_notice("set authentication type to AUTOSWITCH"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11733 | pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_AUTOSWITCH; |
| 11734 | break; |
| 11735 | |
| 11736 | case NL80211_AUTHTYPE_OPEN_SYSTEM: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11737 | case NL80211_AUTHTYPE_FT: |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 11738 | hdd_notice("set authentication type to OPEN"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11739 | pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM; |
| 11740 | break; |
| 11741 | |
| 11742 | case NL80211_AUTHTYPE_SHARED_KEY: |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 11743 | hdd_notice("set authentication type to SHARED"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11744 | pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_SHARED_KEY; |
| 11745 | break; |
| 11746 | #ifdef FEATURE_WLAN_ESE |
| 11747 | case NL80211_AUTHTYPE_NETWORK_EAP: |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 11748 | hdd_notice("set authentication type to CCKM WPA"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11749 | pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_CCKM_WPA; |
| 11750 | break; |
| 11751 | #endif |
| 11752 | |
| 11753 | default: |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 11754 | hdd_err("Unsupported authentication type %d", auth_type); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11755 | pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_UNKNOWN; |
| 11756 | return -EINVAL; |
| 11757 | } |
| 11758 | |
| 11759 | pWextState->roamProfile.AuthType.authType[0] = |
| 11760 | pHddStaCtx->conn_info.authType; |
| 11761 | return 0; |
| 11762 | } |
| 11763 | |
| 11764 | /** |
| 11765 | * wlan_hdd_set_akm_suite() - set key management type |
| 11766 | * @pAdapter: Pointer to adapter |
| 11767 | * @key_mgmt: Key management type |
| 11768 | * |
| 11769 | * This function is used to set the key mgmt type(PSK/8021x). |
| 11770 | * |
| 11771 | * Return: 0 for success, non-zero for failure |
| 11772 | */ |
| 11773 | static int wlan_hdd_set_akm_suite(hdd_adapter_t *pAdapter, u32 key_mgmt) |
| 11774 | { |
| 11775 | hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
| 11776 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11777 | #define WLAN_AKM_SUITE_8021X_SHA256 0x000FAC05 |
| 11778 | #define WLAN_AKM_SUITE_PSK_SHA256 0x000FAC06 |
| 11779 | /*set key mgmt type */ |
| 11780 | switch (key_mgmt) { |
| 11781 | case WLAN_AKM_SUITE_PSK: |
| 11782 | case WLAN_AKM_SUITE_PSK_SHA256: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11783 | case WLAN_AKM_SUITE_FT_PSK: |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 11784 | hdd_notice("setting key mgmt type to PSK"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11785 | pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_PSK; |
| 11786 | break; |
| 11787 | |
| 11788 | case WLAN_AKM_SUITE_8021X_SHA256: |
| 11789 | case WLAN_AKM_SUITE_8021X: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11790 | case WLAN_AKM_SUITE_FT_8021X: |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 11791 | hdd_notice("setting key mgmt type to 8021x"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11792 | pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_802_1X; |
| 11793 | break; |
| 11794 | #ifdef FEATURE_WLAN_ESE |
| 11795 | #define WLAN_AKM_SUITE_CCKM 0x00409600 /* Should be in ieee802_11_defs.h */ |
| 11796 | #define IW_AUTH_KEY_MGMT_CCKM 8 /* Should be in linux/wireless.h */ |
| 11797 | case WLAN_AKM_SUITE_CCKM: |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 11798 | hdd_notice("setting key mgmt type to CCKM"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11799 | pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_CCKM; |
| 11800 | break; |
| 11801 | #endif |
| 11802 | #ifndef WLAN_AKM_SUITE_OSEN |
| 11803 | #define WLAN_AKM_SUITE_OSEN 0x506f9a01 /* Should be in ieee802_11_defs.h */ |
| 11804 | #endif |
| 11805 | case WLAN_AKM_SUITE_OSEN: |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 11806 | hdd_notice("setting key mgmt type to OSEN"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11807 | pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_802_1X; |
| 11808 | break; |
| 11809 | |
| 11810 | default: |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 11811 | hdd_err("Unsupported key mgmt type %d", key_mgmt); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11812 | return -EINVAL; |
| 11813 | |
| 11814 | } |
| 11815 | return 0; |
| 11816 | } |
| 11817 | |
| 11818 | /** |
| 11819 | * wlan_hdd_cfg80211_set_cipher() - set encryption type |
| 11820 | * @pAdapter: Pointer to adapter |
| 11821 | * @cipher: Cipher type |
| 11822 | * @ucast: Unicast flag |
| 11823 | * |
| 11824 | * This function is used to set the encryption type |
| 11825 | * (NONE/WEP40/WEP104/TKIP/CCMP). |
| 11826 | * |
| 11827 | * Return: 0 for success, non-zero for failure |
| 11828 | */ |
| 11829 | static int wlan_hdd_cfg80211_set_cipher(hdd_adapter_t *pAdapter, |
| 11830 | u32 cipher, bool ucast) |
| 11831 | { |
| 11832 | eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE; |
| 11833 | hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
| 11834 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 11835 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11836 | if (!cipher) { |
Srinivas Girigowda | f2599dd | 2015-11-16 18:20:46 -0800 | [diff] [blame] | 11837 | hdd_info("received cipher %d - considering none", cipher); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11838 | encryptionType = eCSR_ENCRYPT_TYPE_NONE; |
| 11839 | } else { |
| 11840 | |
| 11841 | /*set encryption method */ |
| 11842 | switch (cipher) { |
| 11843 | case IW_AUTH_CIPHER_NONE: |
| 11844 | encryptionType = eCSR_ENCRYPT_TYPE_NONE; |
| 11845 | break; |
| 11846 | |
| 11847 | case WLAN_CIPHER_SUITE_WEP40: |
| 11848 | encryptionType = eCSR_ENCRYPT_TYPE_WEP40; |
| 11849 | break; |
| 11850 | |
| 11851 | case WLAN_CIPHER_SUITE_WEP104: |
| 11852 | encryptionType = eCSR_ENCRYPT_TYPE_WEP104; |
| 11853 | break; |
| 11854 | |
| 11855 | case WLAN_CIPHER_SUITE_TKIP: |
| 11856 | encryptionType = eCSR_ENCRYPT_TYPE_TKIP; |
| 11857 | break; |
| 11858 | |
| 11859 | case WLAN_CIPHER_SUITE_CCMP: |
| 11860 | encryptionType = eCSR_ENCRYPT_TYPE_AES; |
| 11861 | break; |
| 11862 | #ifdef FEATURE_WLAN_WAPI |
| 11863 | case WLAN_CIPHER_SUITE_SMS4: |
| 11864 | encryptionType = eCSR_ENCRYPT_TYPE_WPI; |
| 11865 | break; |
| 11866 | #endif |
| 11867 | |
| 11868 | #ifdef FEATURE_WLAN_ESE |
| 11869 | case WLAN_CIPHER_SUITE_KRK: |
| 11870 | encryptionType = eCSR_ENCRYPT_TYPE_KRK; |
| 11871 | break; |
| 11872 | #ifdef WLAN_FEATURE_ROAM_OFFLOAD |
| 11873 | case WLAN_CIPHER_SUITE_BTK: |
| 11874 | encryptionType = eCSR_ENCRYPT_TYPE_BTK; |
| 11875 | break; |
| 11876 | #endif |
| 11877 | #endif |
| 11878 | default: |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 11879 | hdd_err("Unsupported cipher type %d", cipher); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11880 | return -EOPNOTSUPP; |
| 11881 | } |
| 11882 | } |
| 11883 | |
| 11884 | if (ucast) { |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 11885 | hdd_notice("setting unicast cipher type to %d", encryptionType); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11886 | pHddStaCtx->conn_info.ucEncryptionType = encryptionType; |
| 11887 | pWextState->roamProfile.EncryptionType.numEntries = 1; |
| 11888 | pWextState->roamProfile.EncryptionType.encryptionType[0] = |
| 11889 | encryptionType; |
| 11890 | } else { |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 11891 | hdd_notice("setting mcast cipher type to %d", encryptionType); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11892 | pHddStaCtx->conn_info.mcEncryptionType = encryptionType; |
| 11893 | pWextState->roamProfile.mcEncryptionType.numEntries = 1; |
| 11894 | pWextState->roamProfile.mcEncryptionType.encryptionType[0] = |
| 11895 | encryptionType; |
| 11896 | } |
| 11897 | |
| 11898 | return 0; |
| 11899 | } |
| 11900 | |
| 11901 | /** |
Selvaraj, Sridhar | a7fc763 | 2016-09-04 13:13:38 +0530 | [diff] [blame] | 11902 | * wlan_hdd_add_assoc_ie() - Add Assoc IE to roamProfile |
| 11903 | * @wext_state: Pointer to wext state |
| 11904 | * @gen_ie: Pointer to IE data |
| 11905 | * @len: length of IE data |
| 11906 | * |
| 11907 | * Return: 0 for success, non-zero for failure |
| 11908 | */ |
| 11909 | static int wlan_hdd_add_assoc_ie(hdd_wext_state_t *wext_state, |
| 11910 | const uint8_t *gen_ie, uint16_t len) |
| 11911 | { |
| 11912 | uint16_t cur_add_ie_len = |
| 11913 | wext_state->assocAddIE.length; |
| 11914 | |
| 11915 | if (SIR_MAC_MAX_ADD_IE_LENGTH < |
| 11916 | (wext_state->assocAddIE.length + len)) { |
| 11917 | hdd_err("Cannot accommodate assocAddIE Need bigger buffer space"); |
| 11918 | QDF_ASSERT(0); |
| 11919 | return -ENOMEM; |
| 11920 | } |
| 11921 | memcpy(wext_state->assocAddIE.addIEdata + |
| 11922 | cur_add_ie_len, gen_ie, len); |
| 11923 | wext_state->assocAddIE.length += len; |
| 11924 | |
| 11925 | wext_state->roamProfile.pAddIEAssoc = |
| 11926 | wext_state->assocAddIE.addIEdata; |
| 11927 | wext_state->roamProfile.nAddIEAssocLength = |
| 11928 | wext_state->assocAddIE.length; |
| 11929 | return 0; |
| 11930 | } |
| 11931 | |
| 11932 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11933 | * wlan_hdd_cfg80211_set_ie() - set IEs |
| 11934 | * @pAdapter: Pointer to adapter |
| 11935 | * @ie: Pointer ot ie |
| 11936 | * @ie: IE length |
| 11937 | * |
| 11938 | * Return: 0 for success, non-zero for failure |
| 11939 | */ |
Jeff Johnson | 8b8a04b | 2016-10-05 15:49:43 -0700 | [diff] [blame] | 11940 | 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] | 11941 | size_t ie_len) |
| 11942 | { |
| 11943 | hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
| 11944 | const uint8_t *genie = ie; |
| 11945 | uint16_t remLen = ie_len; |
| 11946 | #ifdef FEATURE_WLAN_WAPI |
| 11947 | uint32_t akmsuite[MAX_NUM_AKM_SUITES]; |
| 11948 | u16 *tmp; |
| 11949 | uint16_t akmsuiteCount; |
| 11950 | int *akmlist; |
| 11951 | #endif |
Selvaraj, Sridhar | a7fc763 | 2016-09-04 13:13:38 +0530 | [diff] [blame] | 11952 | int status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11953 | |
| 11954 | /* clear previous assocAddIE */ |
| 11955 | pWextState->assocAddIE.length = 0; |
| 11956 | pWextState->roamProfile.bWPSAssociation = false; |
| 11957 | pWextState->roamProfile.bOSENAssociation = false; |
| 11958 | |
| 11959 | while (remLen >= 2) { |
| 11960 | uint16_t eLen = 0; |
| 11961 | uint8_t elementId; |
| 11962 | elementId = *genie++; |
| 11963 | eLen = *genie++; |
| 11964 | remLen -= 2; |
| 11965 | |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 11966 | hdd_notice("IE[0x%X], LEN[%d]", elementId, eLen); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11967 | |
| 11968 | switch (elementId) { |
| 11969 | case DOT11F_EID_WPA: |
| 11970 | 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] | 11971 | hdd_err("Invalid WPA IE"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11972 | return -EINVAL; |
| 11973 | } else if (0 == |
| 11974 | memcmp(&genie[0], "\x00\x50\xf2\x04", 4)) { |
| 11975 | uint16_t curAddIELen = |
| 11976 | pWextState->assocAddIE.length; |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 11977 | hdd_notice("Set WPS IE(len %d)", eLen + 2); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11978 | |
| 11979 | if (SIR_MAC_MAX_ADD_IE_LENGTH < |
| 11980 | (pWextState->assocAddIE.length + eLen)) { |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 11981 | hdd_err("Cannot accommodate assocAddIE. Need bigger buffer space"); |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 11982 | QDF_ASSERT(0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11983 | return -ENOMEM; |
| 11984 | } |
| 11985 | /* WSC IE is saved to Additional IE ; it should be accumulated to handle WPS IE + P2P IE */ |
| 11986 | memcpy(pWextState->assocAddIE.addIEdata + |
| 11987 | curAddIELen, genie - 2, eLen + 2); |
| 11988 | pWextState->assocAddIE.length += eLen + 2; |
| 11989 | |
| 11990 | pWextState->roamProfile.bWPSAssociation = true; |
| 11991 | pWextState->roamProfile.pAddIEAssoc = |
| 11992 | pWextState->assocAddIE.addIEdata; |
| 11993 | pWextState->roamProfile.nAddIEAssocLength = |
| 11994 | pWextState->assocAddIE.length; |
| 11995 | } else if (0 == memcmp(&genie[0], "\x00\x50\xf2", 3)) { |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 11996 | hdd_notice("Set WPA IE (len %d)", eLen + 2); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11997 | memset(pWextState->WPARSNIE, 0, |
| 11998 | MAX_WPA_RSN_IE_LEN); |
| 11999 | memcpy(pWextState->WPARSNIE, genie - 2, |
| 12000 | (eLen + 2)); |
| 12001 | pWextState->roamProfile.pWPAReqIE = |
| 12002 | pWextState->WPARSNIE; |
| 12003 | pWextState->roamProfile.nWPAReqIELength = eLen + 2; /* ie_len; */ |
| 12004 | } else if ((0 == memcmp(&genie[0], P2P_OUI_TYPE, |
| 12005 | P2P_OUI_TYPE_SIZE))) { |
| 12006 | uint16_t curAddIELen = |
| 12007 | pWextState->assocAddIE.length; |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 12008 | hdd_notice("Set P2P IE(len %d)", eLen + 2); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12009 | |
| 12010 | if (SIR_MAC_MAX_ADD_IE_LENGTH < |
| 12011 | (pWextState->assocAddIE.length + eLen)) { |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 12012 | hdd_err("Cannot accommodate assocAddIE Need bigger buffer space"); |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 12013 | QDF_ASSERT(0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12014 | return -ENOMEM; |
| 12015 | } |
| 12016 | /* P2P IE is saved to Additional IE ; it should be accumulated to handle WPS IE + P2P IE */ |
| 12017 | memcpy(pWextState->assocAddIE.addIEdata + |
| 12018 | curAddIELen, genie - 2, eLen + 2); |
| 12019 | pWextState->assocAddIE.length += eLen + 2; |
| 12020 | |
| 12021 | pWextState->roamProfile.pAddIEAssoc = |
| 12022 | pWextState->assocAddIE.addIEdata; |
| 12023 | pWextState->roamProfile.nAddIEAssocLength = |
| 12024 | pWextState->assocAddIE.length; |
| 12025 | } |
| 12026 | #ifdef WLAN_FEATURE_WFD |
| 12027 | else if ((0 == memcmp(&genie[0], WFD_OUI_TYPE, |
| 12028 | WFD_OUI_TYPE_SIZE)) && |
| 12029 | /* Consider WFD IE, only for P2P Client */ |
Krunal Soni | b4326f2 | 2016-03-10 13:05:51 -0800 | [diff] [blame] | 12030 | (QDF_P2P_CLIENT_MODE == |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12031 | pAdapter->device_mode)) { |
| 12032 | uint16_t curAddIELen = |
| 12033 | pWextState->assocAddIE.length; |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 12034 | hdd_notice("Set WFD IE(len %d)", eLen + 2); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12035 | |
| 12036 | if (SIR_MAC_MAX_ADD_IE_LENGTH < |
| 12037 | (pWextState->assocAddIE.length + eLen)) { |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 12038 | hdd_err("Cannot accommodate assocAddIE Need bigger buffer space"); |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 12039 | QDF_ASSERT(0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12040 | return -ENOMEM; |
| 12041 | } |
| 12042 | /* WFD IE is saved to Additional IE ; it should |
| 12043 | * be accumulated to handle WPS IE + P2P IE + |
| 12044 | * WFD IE */ |
| 12045 | memcpy(pWextState->assocAddIE.addIEdata + |
| 12046 | curAddIELen, genie - 2, eLen + 2); |
| 12047 | pWextState->assocAddIE.length += eLen + 2; |
| 12048 | |
| 12049 | pWextState->roamProfile.pAddIEAssoc = |
| 12050 | pWextState->assocAddIE.addIEdata; |
| 12051 | pWextState->roamProfile.nAddIEAssocLength = |
| 12052 | pWextState->assocAddIE.length; |
| 12053 | } |
| 12054 | #endif |
| 12055 | /* Appending HS 2.0 Indication Element in Assiciation Request */ |
| 12056 | else if ((0 == memcmp(&genie[0], HS20_OUI_TYPE, |
| 12057 | HS20_OUI_TYPE_SIZE))) { |
| 12058 | uint16_t curAddIELen = |
| 12059 | pWextState->assocAddIE.length; |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 12060 | hdd_notice("Set HS20 IE(len %d)", eLen + 2); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12061 | |
| 12062 | if (SIR_MAC_MAX_ADD_IE_LENGTH < |
| 12063 | (pWextState->assocAddIE.length + eLen)) { |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 12064 | hdd_err("Cannot accommodate assocAddIE Need bigger buffer space"); |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 12065 | QDF_ASSERT(0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12066 | return -ENOMEM; |
| 12067 | } |
| 12068 | memcpy(pWextState->assocAddIE.addIEdata + |
| 12069 | curAddIELen, genie - 2, eLen + 2); |
| 12070 | pWextState->assocAddIE.length += eLen + 2; |
| 12071 | |
| 12072 | pWextState->roamProfile.pAddIEAssoc = |
| 12073 | pWextState->assocAddIE.addIEdata; |
| 12074 | pWextState->roamProfile.nAddIEAssocLength = |
| 12075 | pWextState->assocAddIE.length; |
| 12076 | } |
| 12077 | /* Appending OSEN Information Element in Assiciation Request */ |
| 12078 | else if ((0 == memcmp(&genie[0], OSEN_OUI_TYPE, |
| 12079 | OSEN_OUI_TYPE_SIZE))) { |
| 12080 | uint16_t curAddIELen = |
| 12081 | pWextState->assocAddIE.length; |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 12082 | hdd_notice("Set OSEN IE(len %d)", eLen + 2); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12083 | |
| 12084 | if (SIR_MAC_MAX_ADD_IE_LENGTH < |
| 12085 | (pWextState->assocAddIE.length + eLen)) { |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 12086 | hdd_err("Cannot accommodate assocAddIE Need bigger buffer space"); |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 12087 | QDF_ASSERT(0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12088 | return -ENOMEM; |
| 12089 | } |
| 12090 | memcpy(pWextState->assocAddIE.addIEdata + |
| 12091 | curAddIELen, genie - 2, eLen + 2); |
| 12092 | pWextState->assocAddIE.length += eLen + 2; |
| 12093 | |
| 12094 | pWextState->roamProfile.bOSENAssociation = true; |
| 12095 | pWextState->roamProfile.pAddIEAssoc = |
| 12096 | pWextState->assocAddIE.addIEdata; |
| 12097 | pWextState->roamProfile.nAddIEAssocLength = |
| 12098 | pWextState->assocAddIE.length; |
Selvaraj, Sridhar | a7fc763 | 2016-09-04 13:13:38 +0530 | [diff] [blame] | 12099 | } else if ((0 == memcmp(&genie[0], MBO_OUI_TYPE, |
| 12100 | MBO_OUI_TYPE_SIZE))){ |
| 12101 | hdd_info("Set MBO IE(len %d)", eLen + 2); |
| 12102 | status = wlan_hdd_add_assoc_ie(pWextState, |
| 12103 | genie - 2, eLen + 2); |
| 12104 | if (status) |
| 12105 | return status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12106 | } else { |
| 12107 | uint16_t add_ie_len = |
| 12108 | pWextState->assocAddIE.length; |
| 12109 | |
| 12110 | hdd_info("Set OSEN IE(len %d)", eLen + 2); |
| 12111 | |
| 12112 | if (SIR_MAC_MAX_ADD_IE_LENGTH < |
| 12113 | (pWextState->assocAddIE.length + eLen)) { |
| 12114 | hdd_err("Cannot accommodate assocAddIE Need bigger buffer space"); |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 12115 | QDF_ASSERT(0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12116 | return -ENOMEM; |
| 12117 | } |
| 12118 | |
| 12119 | memcpy(pWextState->assocAddIE.addIEdata + |
| 12120 | add_ie_len, genie - 2, eLen + 2); |
| 12121 | pWextState->assocAddIE.length += eLen + 2; |
| 12122 | |
| 12123 | pWextState->roamProfile.pAddIEAssoc = |
| 12124 | pWextState->assocAddIE.addIEdata; |
| 12125 | pWextState->roamProfile.nAddIEAssocLength = |
| 12126 | pWextState->assocAddIE.length; |
| 12127 | } |
| 12128 | break; |
| 12129 | case DOT11F_EID_RSN: |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 12130 | hdd_notice("Set RSN IE(len %d)", eLen + 2); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12131 | memset(pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN); |
| 12132 | memcpy(pWextState->WPARSNIE, genie - 2, |
| 12133 | (eLen + 2)); |
| 12134 | pWextState->roamProfile.pRSNReqIE = |
| 12135 | pWextState->WPARSNIE; |
| 12136 | pWextState->roamProfile.nRSNReqIELength = eLen + 2; /* ie_len; */ |
| 12137 | break; |
| 12138 | /* |
| 12139 | * Appending Extended Capabilities with Interworking bit set |
| 12140 | * in Assoc Req. |
| 12141 | * |
| 12142 | * In assoc req this EXT Cap will only be taken into account if |
| 12143 | * interworkingService bit is set to 1. Currently |
| 12144 | * driver is only interested in interworkingService capability |
| 12145 | * from supplicant. If in future any other EXT Cap info is |
| 12146 | * required from supplicat, it needs to be handled while |
| 12147 | * sending Assoc Req in LIM. |
| 12148 | */ |
| 12149 | case DOT11F_EID_EXTCAP: |
| 12150 | { |
| 12151 | uint16_t curAddIELen = |
| 12152 | pWextState->assocAddIE.length; |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 12153 | hdd_notice("Set Extended CAPS IE(len %d)", eLen + 2); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12154 | |
| 12155 | if (SIR_MAC_MAX_ADD_IE_LENGTH < |
| 12156 | (pWextState->assocAddIE.length + eLen)) { |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 12157 | hdd_err("Cannot accommodate assocAddIE Need bigger buffer space"); |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 12158 | QDF_ASSERT(0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12159 | return -ENOMEM; |
| 12160 | } |
| 12161 | memcpy(pWextState->assocAddIE.addIEdata + |
| 12162 | curAddIELen, genie - 2, eLen + 2); |
| 12163 | pWextState->assocAddIE.length += eLen + 2; |
| 12164 | |
| 12165 | pWextState->roamProfile.pAddIEAssoc = |
| 12166 | pWextState->assocAddIE.addIEdata; |
| 12167 | pWextState->roamProfile.nAddIEAssocLength = |
| 12168 | pWextState->assocAddIE.length; |
| 12169 | break; |
| 12170 | } |
| 12171 | #ifdef FEATURE_WLAN_WAPI |
| 12172 | case WLAN_EID_WAPI: |
| 12173 | /* Setting WAPI Mode to ON=1 */ |
| 12174 | pAdapter->wapi_info.nWapiMode = 1; |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 12175 | hdd_notice("WAPI MODE IS %u", pAdapter->wapi_info.nWapiMode); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12176 | tmp = (u16 *) ie; |
| 12177 | tmp = tmp + 2; /* Skip element Id and Len, Version */ |
| 12178 | akmsuiteCount = WPA_GET_LE16(tmp); |
| 12179 | tmp = tmp + 1; |
| 12180 | akmlist = (int *)(tmp); |
| 12181 | if (akmsuiteCount <= MAX_NUM_AKM_SUITES) { |
| 12182 | memcpy(akmsuite, akmlist, (4 * akmsuiteCount)); |
| 12183 | } else { |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 12184 | hdd_err("Invalid akmSuite count"); |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 12185 | QDF_ASSERT(0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12186 | return -EINVAL; |
| 12187 | } |
| 12188 | |
| 12189 | if (WAPI_PSK_AKM_SUITE == akmsuite[0]) { |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 12190 | hdd_notice("WAPI AUTH MODE SET TO PSK"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12191 | pAdapter->wapi_info.wapiAuthMode = |
| 12192 | WAPI_AUTH_MODE_PSK; |
| 12193 | } |
| 12194 | if (WAPI_CERT_AKM_SUITE == akmsuite[0]) { |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 12195 | hdd_notice("WAPI AUTH MODE SET TO CERTIFICATE"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12196 | pAdapter->wapi_info.wapiAuthMode = |
| 12197 | WAPI_AUTH_MODE_CERT; |
| 12198 | } |
| 12199 | break; |
| 12200 | #endif |
Selvaraj, Sridhar | a7fc763 | 2016-09-04 13:13:38 +0530 | [diff] [blame] | 12201 | case DOT11F_EID_SUPPOPERATINGCLASSES: |
| 12202 | { |
| 12203 | hdd_info("Set Supported Operating Classes IE(len %d)", eLen + 2); |
| 12204 | status = wlan_hdd_add_assoc_ie(pWextState, |
| 12205 | genie - 2, eLen + 2); |
| 12206 | if (status) |
| 12207 | return status; |
| 12208 | break; |
| 12209 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12210 | default: |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 12211 | hdd_err("Set UNKNOWN IE %X", elementId); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12212 | /* when Unknown IE is received we should break and continue |
| 12213 | * to the next IE in the buffer instead we were returning |
| 12214 | * so changing this to break */ |
| 12215 | break; |
| 12216 | } |
| 12217 | genie += eLen; |
| 12218 | remLen -= eLen; |
| 12219 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12220 | return 0; |
| 12221 | } |
| 12222 | |
| 12223 | /** |
| 12224 | * hdd_is_wpaie_present() - check for WPA ie |
| 12225 | * @ie: Pointer to ie |
| 12226 | * @ie_len: Ie length |
| 12227 | * |
| 12228 | * Parse the received IE to find the WPA IE |
| 12229 | * |
| 12230 | * Return: true if wpa ie is found else false |
| 12231 | */ |
| 12232 | static bool hdd_is_wpaie_present(const uint8_t *ie, uint8_t ie_len) |
| 12233 | { |
| 12234 | uint8_t eLen = 0; |
| 12235 | uint16_t remLen = ie_len; |
| 12236 | uint8_t elementId = 0; |
| 12237 | |
| 12238 | while (remLen >= 2) { |
| 12239 | elementId = *ie++; |
| 12240 | eLen = *ie++; |
| 12241 | remLen -= 2; |
| 12242 | if (eLen > remLen) { |
Jeff Johnson | ff5b9aa | 2016-06-29 15:10:30 -0700 | [diff] [blame] | 12243 | hdd_err("IE length is wrong %d", eLen); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12244 | return false; |
| 12245 | } |
| 12246 | if ((elementId == DOT11F_EID_WPA) && (remLen > 5)) { |
| 12247 | /* OUI - 0x00 0X50 0XF2 |
| 12248 | * WPA Information Element - 0x01 |
| 12249 | * WPA version - 0x01 |
| 12250 | */ |
| 12251 | if (0 == memcmp(&ie[0], "\x00\x50\xf2\x01\x01", 5)) |
| 12252 | return true; |
| 12253 | } |
| 12254 | ie += eLen; |
| 12255 | remLen -= eLen; |
| 12256 | } |
| 12257 | return false; |
| 12258 | } |
| 12259 | |
| 12260 | /** |
| 12261 | * wlan_hdd_cfg80211_set_privacy() - set security parameters during connection |
| 12262 | * @pAdapter: Pointer to adapter |
| 12263 | * @req: Pointer to security parameters |
| 12264 | * |
| 12265 | * Return: 0 for success, non-zero for failure |
| 12266 | */ |
Jeff Johnson | 8b8a04b | 2016-10-05 15:49:43 -0700 | [diff] [blame] | 12267 | static int wlan_hdd_cfg80211_set_privacy(hdd_adapter_t *pAdapter, |
| 12268 | struct cfg80211_connect_params *req) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12269 | { |
| 12270 | int status = 0; |
| 12271 | hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
| 12272 | ENTER(); |
| 12273 | |
| 12274 | /*set wpa version */ |
| 12275 | pWextState->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED; |
| 12276 | |
| 12277 | if (req->crypto.wpa_versions) { |
| 12278 | if (NL80211_WPA_VERSION_1 == req->crypto.wpa_versions) { |
| 12279 | pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA; |
| 12280 | } else if (NL80211_WPA_VERSION_2 == req->crypto.wpa_versions) { |
| 12281 | pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA2; |
| 12282 | } |
| 12283 | } |
| 12284 | |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 12285 | hdd_notice("set wpa version to %d", pWextState->wpaVersion); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12286 | |
| 12287 | /*set authentication type */ |
| 12288 | status = wlan_hdd_cfg80211_set_auth_type(pAdapter, req->auth_type); |
| 12289 | |
| 12290 | if (0 > status) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 12291 | hdd_err("failed to set authentication type "); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12292 | return status; |
| 12293 | } |
| 12294 | |
| 12295 | /*set key mgmt type */ |
| 12296 | if (req->crypto.n_akm_suites) { |
| 12297 | status = |
| 12298 | wlan_hdd_set_akm_suite(pAdapter, req->crypto.akm_suites[0]); |
| 12299 | if (0 > status) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 12300 | hdd_err("failed to set akm suite"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12301 | return status; |
| 12302 | } |
| 12303 | } |
| 12304 | |
| 12305 | /*set pairwise cipher type */ |
| 12306 | if (req->crypto.n_ciphers_pairwise) { |
| 12307 | status = wlan_hdd_cfg80211_set_cipher(pAdapter, |
| 12308 | req->crypto. |
| 12309 | ciphers_pairwise[0], |
| 12310 | true); |
| 12311 | if (0 > status) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 12312 | hdd_err("failed to set unicast cipher type"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12313 | return status; |
| 12314 | } |
| 12315 | } else { |
| 12316 | /*Reset previous cipher suite to none */ |
| 12317 | status = wlan_hdd_cfg80211_set_cipher(pAdapter, 0, true); |
| 12318 | if (0 > status) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 12319 | hdd_err("failed to set unicast cipher type"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12320 | return status; |
| 12321 | } |
| 12322 | } |
| 12323 | |
| 12324 | /*set group cipher type */ |
| 12325 | status = |
| 12326 | wlan_hdd_cfg80211_set_cipher(pAdapter, req->crypto.cipher_group, |
| 12327 | false); |
| 12328 | |
| 12329 | if (0 > status) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 12330 | hdd_err("failed to set mcast cipher type"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12331 | return status; |
| 12332 | } |
| 12333 | #ifdef WLAN_FEATURE_11W |
| 12334 | pWextState->roamProfile.MFPEnabled = (req->mfp == NL80211_MFP_REQUIRED); |
| 12335 | #endif |
| 12336 | |
| 12337 | /*parse WPA/RSN IE, and set the correspoing fileds in Roam profile */ |
| 12338 | if (req->ie_len) { |
| 12339 | status = |
| 12340 | wlan_hdd_cfg80211_set_ie(pAdapter, req->ie, req->ie_len); |
| 12341 | if (0 > status) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 12342 | hdd_err("failed to parse the WPA/RSN IE"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12343 | return status; |
| 12344 | } |
| 12345 | } |
| 12346 | |
| 12347 | /*incase of WEP set default key information */ |
| 12348 | if (req->key && req->key_len) { |
| 12349 | if ((WLAN_CIPHER_SUITE_WEP40 == req->crypto.ciphers_pairwise[0]) |
| 12350 | || (WLAN_CIPHER_SUITE_WEP104 == |
| 12351 | req->crypto.ciphers_pairwise[0]) |
| 12352 | ) { |
| 12353 | if (IW_AUTH_KEY_MGMT_802_1X |
| 12354 | == |
| 12355 | (pWextState-> |
| 12356 | authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 12357 | hdd_err("Dynamic WEP not supported"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12358 | return -EOPNOTSUPP; |
| 12359 | } else { |
| 12360 | u8 key_len = req->key_len; |
| 12361 | u8 key_idx = req->key_idx; |
| 12362 | |
| 12363 | if ((eCSR_SECURITY_WEP_KEYSIZE_MAX_BYTES >= |
| 12364 | key_len) |
| 12365 | && (CSR_MAX_NUM_KEY > key_idx) |
| 12366 | ) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 12367 | hdd_notice("setting default wep key, key_idx = %hu key_len %hu", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12368 | key_idx, key_len); |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 12369 | qdf_mem_copy(&pWextState->roamProfile. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12370 | Keys. |
| 12371 | KeyMaterial[key_idx][0], |
| 12372 | req->key, key_len); |
| 12373 | pWextState->roamProfile.Keys. |
| 12374 | KeyLength[key_idx] = (u8) key_len; |
| 12375 | pWextState->roamProfile.Keys. |
| 12376 | defaultIndex = (u8) key_idx; |
| 12377 | } |
| 12378 | } |
| 12379 | } |
| 12380 | } |
| 12381 | |
| 12382 | return status; |
| 12383 | } |
| 12384 | |
| 12385 | /** |
| 12386 | * wlan_hdd_try_disconnect() - try disconnnect from previous connection |
| 12387 | * @pAdapter: Pointer to adapter |
| 12388 | * |
| 12389 | * This function is used to disconnect from previous connection |
| 12390 | * |
| 12391 | * Return: 0 for success, non-zero for failure |
| 12392 | */ |
| 12393 | static int wlan_hdd_try_disconnect(hdd_adapter_t *pAdapter) |
| 12394 | { |
| 12395 | unsigned long rc; |
| 12396 | hdd_station_ctx_t *pHddStaCtx; |
Abhishek Singh | be1849b | 2016-01-19 14:12:00 +0530 | [diff] [blame] | 12397 | int status, result = 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12398 | |
| 12399 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 12400 | |
Jeff Johnson | 9edf957 | 2016-10-03 15:24:49 -0700 | [diff] [blame] | 12401 | if ((QDF_IBSS_MODE == pAdapter->device_mode) || |
Abhishek Singh | 03f992e | 2016-01-07 18:07:06 +0530 | [diff] [blame] | 12402 | (eConnectionState_Associated == pHddStaCtx->conn_info.connState) || |
| 12403 | (eConnectionState_Connecting == pHddStaCtx->conn_info.connState) || |
| 12404 | (eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12405 | hdd_conn_set_connection_state(pAdapter, |
| 12406 | eConnectionState_Disconnecting); |
| 12407 | /* Issue disconnect to CSR */ |
| 12408 | INIT_COMPLETION(pAdapter->disconnect_comp_var); |
Abhishek Singh | be1849b | 2016-01-19 14:12:00 +0530 | [diff] [blame] | 12409 | |
| 12410 | status = sme_roam_disconnect(WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 12411 | pAdapter->sessionId, |
| 12412 | eCSR_DISCONNECT_REASON_UNSPECIFIED); |
| 12413 | /* |
| 12414 | * Wait here instead of returning directly, this will block the |
| 12415 | * next connect command and allow processing of the scan for |
| 12416 | * ssid and the previous connect command in CSR. Else we might |
| 12417 | * hit some race conditions leading to SME and HDD out of sync. |
| 12418 | */ |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 12419 | if (QDF_STATUS_CMD_NOT_QUEUED == status) { |
Abhishek Singh | be1849b | 2016-01-19 14:12:00 +0530 | [diff] [blame] | 12420 | hdd_info("Already disconnected or connect was in sme/roam pending list and removed by disconnect"); |
| 12421 | } else if (0 != status) { |
| 12422 | hdd_err("csrRoamDisconnect failure, returned %d", |
| 12423 | (int)status); |
| 12424 | pHddStaCtx->staDebugState = status; |
| 12425 | result = -EINVAL; |
| 12426 | goto disconnected; |
| 12427 | } |
| 12428 | |
| 12429 | rc = wait_for_completion_timeout( |
| 12430 | &pAdapter->disconnect_comp_var, |
| 12431 | msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT)); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 12432 | if (!rc && (QDF_STATUS_CMD_NOT_QUEUED != status)) { |
Abhishek Singh | be1849b | 2016-01-19 14:12:00 +0530 | [diff] [blame] | 12433 | hdd_err("Sme disconnect event timed out session Id %d staDebugState %d", |
| 12434 | pAdapter->sessionId, pHddStaCtx->staDebugState); |
| 12435 | result = -ETIMEDOUT; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12436 | } |
| 12437 | } else if (eConnectionState_Disconnecting == |
Abhishek Singh | be1849b | 2016-01-19 14:12:00 +0530 | [diff] [blame] | 12438 | pHddStaCtx->conn_info.connState) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12439 | rc = wait_for_completion_timeout(&pAdapter->disconnect_comp_var, |
Abhishek Singh | be1849b | 2016-01-19 14:12:00 +0530 | [diff] [blame] | 12440 | msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12441 | if (!rc) { |
Abhishek Singh | be1849b | 2016-01-19 14:12:00 +0530 | [diff] [blame] | 12442 | hdd_err("Disconnect event timed out session Id %d staDebugState %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12443 | pAdapter->sessionId, pHddStaCtx->staDebugState); |
Abhishek Singh | be1849b | 2016-01-19 14:12:00 +0530 | [diff] [blame] | 12444 | result = -ETIMEDOUT; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12445 | } |
| 12446 | } |
Abhishek Singh | be1849b | 2016-01-19 14:12:00 +0530 | [diff] [blame] | 12447 | disconnected: |
Abhishek Singh | be1849b | 2016-01-19 14:12:00 +0530 | [diff] [blame] | 12448 | hdd_conn_set_connection_state(pAdapter, eConnectionState_NotConnected); |
| 12449 | return result; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12450 | } |
| 12451 | |
| 12452 | /** |
Varun Reddy Yeturu | 3e91dad | 2016-07-18 15:58:47 -0700 | [diff] [blame] | 12453 | * wlan_hdd_reassoc_bssid_hint() - Start reassociation if bssid is present |
| 12454 | * @adapter: Pointer to the HDD adapter |
| 12455 | * @req: Pointer to the structure cfg_connect_params receieved from user space |
Naveen Rawat | 0733290 | 2016-07-27 09:13:17 -0700 | [diff] [blame] | 12456 | * @status: out variable for status of reassoc request |
Varun Reddy Yeturu | 3e91dad | 2016-07-18 15:58:47 -0700 | [diff] [blame] | 12457 | * |
Selvaraj, Sridhar | 353be2f | 2016-09-27 15:01:41 +0530 | [diff] [blame] | 12458 | * This function will start reassociation if prev_bssid is set and bssid/ |
| 12459 | * bssid_hint, channel/channel_hint parameters are present in connect request. |
Varun Reddy Yeturu | 3e91dad | 2016-07-18 15:58:47 -0700 | [diff] [blame] | 12460 | * |
Naveen Rawat | 0733290 | 2016-07-27 09:13:17 -0700 | [diff] [blame] | 12461 | * Return: true if connect was for ReAssociation, false otherwise |
Varun Reddy Yeturu | 3e91dad | 2016-07-18 15:58:47 -0700 | [diff] [blame] | 12462 | */ |
Selvaraj, Sridhar | a11edcb | 2016-09-07 18:49:14 +0530 | [diff] [blame] | 12463 | #if defined(CFG80211_CONNECT_PREV_BSSID) || \ |
| 12464 | (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 7, 0)) |
Naveen Rawat | 0733290 | 2016-07-27 09:13:17 -0700 | [diff] [blame] | 12465 | static bool wlan_hdd_reassoc_bssid_hint(hdd_adapter_t *adapter, |
| 12466 | struct cfg80211_connect_params *req, |
| 12467 | int *status) |
Varun Reddy Yeturu | 3e91dad | 2016-07-18 15:58:47 -0700 | [diff] [blame] | 12468 | { |
Naveen Rawat | 0733290 | 2016-07-27 09:13:17 -0700 | [diff] [blame] | 12469 | bool reassoc = false; |
Selvaraj, Sridhar | 353be2f | 2016-09-27 15:01:41 +0530 | [diff] [blame] | 12470 | const uint8_t *bssid = NULL; |
| 12471 | uint16_t channel = 0; |
| 12472 | |
| 12473 | if (req->bssid) |
| 12474 | bssid = req->bssid; |
| 12475 | else if (req->bssid_hint) |
| 12476 | bssid = req->bssid_hint; |
| 12477 | |
| 12478 | if (req->channel) |
| 12479 | channel = req->channel->hw_value; |
| 12480 | else if (req->channel_hint) |
| 12481 | channel = req->channel_hint->hw_value; |
| 12482 | |
| 12483 | if (bssid && channel && req->prev_bssid) { |
Naveen Rawat | 0733290 | 2016-07-27 09:13:17 -0700 | [diff] [blame] | 12484 | reassoc = true; |
| 12485 | hdd_info(FL("REASSOC Attempt on channel %d to "MAC_ADDRESS_STR), |
Selvaraj, Sridhar | 353be2f | 2016-09-27 15:01:41 +0530 | [diff] [blame] | 12486 | channel, MAC_ADDR_ARRAY(bssid)); |
| 12487 | *status = hdd_reassoc(adapter, bssid, channel, |
Varun Reddy Yeturu | 3e91dad | 2016-07-18 15:58:47 -0700 | [diff] [blame] | 12488 | CONNECT_CMD_USERSPACE); |
Naveen Rawat | 0733290 | 2016-07-27 09:13:17 -0700 | [diff] [blame] | 12489 | hdd_debug("hdd_reassoc: status: %d", *status); |
Varun Reddy Yeturu | 3e91dad | 2016-07-18 15:58:47 -0700 | [diff] [blame] | 12490 | } |
Naveen Rawat | 0733290 | 2016-07-27 09:13:17 -0700 | [diff] [blame] | 12491 | return reassoc; |
Varun Reddy Yeturu | 3e91dad | 2016-07-18 15:58:47 -0700 | [diff] [blame] | 12492 | } |
| 12493 | #else |
Naveen Rawat | 0733290 | 2016-07-27 09:13:17 -0700 | [diff] [blame] | 12494 | static bool wlan_hdd_reassoc_bssid_hint(hdd_adapter_t *adapter, |
| 12495 | struct cfg80211_connect_params *req, |
| 12496 | int *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 | return false; |
Varun Reddy Yeturu | 3e91dad | 2016-07-18 15:58:47 -0700 | [diff] [blame] | 12499 | } |
| 12500 | #endif |
| 12501 | |
| 12502 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12503 | * __wlan_hdd_cfg80211_connect() - cfg80211 connect api |
| 12504 | * @wiphy: Pointer to wiphy |
| 12505 | * @dev: Pointer to network device |
| 12506 | * @req: Pointer to cfg80211 connect request |
| 12507 | * |
| 12508 | * This function is used to start the association process |
| 12509 | * |
| 12510 | * Return: 0 for success, non-zero for failure |
| 12511 | */ |
| 12512 | static int __wlan_hdd_cfg80211_connect(struct wiphy *wiphy, |
| 12513 | struct net_device *ndev, |
| 12514 | struct cfg80211_connect_params *req) |
| 12515 | { |
| 12516 | int status; |
Sreelakshmi Konamki | 6bd8a2e | 2015-11-03 16:30:32 +0530 | [diff] [blame] | 12517 | u16 channel; |
| 12518 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 15, 0)) |
| 12519 | const u8 *bssid_hint = req->bssid_hint; |
| 12520 | #else |
| 12521 | const u8 *bssid_hint = NULL; |
| 12522 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12523 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(ndev); |
| 12524 | hdd_context_t *pHddCtx; |
| 12525 | |
| 12526 | ENTER(); |
| 12527 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 12528 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 12529 | hdd_err("Command not allowed in FTM mode"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12530 | return -EINVAL; |
| 12531 | } |
| 12532 | |
Hanumanth Reddy Pothula | d9491f4 | 2016-10-24 19:08:38 +0530 | [diff] [blame] | 12533 | if (wlan_hdd_validate_session_id(pAdapter->sessionId)) { |
| 12534 | hdd_err("invalid session id: %d", pAdapter->sessionId); |
| 12535 | return -EINVAL; |
| 12536 | } |
| 12537 | |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 12538 | MTRACE(qdf_trace(QDF_MODULE_ID_HDD, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12539 | TRACE_CODE_HDD_CFG80211_CONNECT, |
| 12540 | pAdapter->sessionId, pAdapter->device_mode)); |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 12541 | hdd_notice("Device_mode %s(%d)", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12542 | hdd_device_mode_to_string(pAdapter->device_mode), |
| 12543 | pAdapter->device_mode); |
| 12544 | |
Krunal Soni | b4326f2 | 2016-03-10 13:05:51 -0800 | [diff] [blame] | 12545 | if (pAdapter->device_mode != QDF_STA_MODE && |
| 12546 | pAdapter->device_mode != QDF_P2P_CLIENT_MODE) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 12547 | hdd_err("Device_mode %s(%d) is not supported", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12548 | hdd_device_mode_to_string(pAdapter->device_mode), |
| 12549 | pAdapter->device_mode); |
| 12550 | return -EINVAL; |
| 12551 | } |
| 12552 | |
| 12553 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 12554 | if (!pHddCtx) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 12555 | hdd_err("HDD context is null"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12556 | return -EINVAL; |
| 12557 | } |
| 12558 | |
| 12559 | status = wlan_hdd_validate_context(pHddCtx); |
Hanumantha Reddy Pothula | 2db50ed | 2015-11-23 10:48:33 +0530 | [diff] [blame] | 12560 | if (0 != status) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12561 | return status; |
Varun Reddy Yeturu | 3e91dad | 2016-07-18 15:58:47 -0700 | [diff] [blame] | 12562 | |
Naveen Rawat | 0733290 | 2016-07-27 09:13:17 -0700 | [diff] [blame] | 12563 | if (true == wlan_hdd_reassoc_bssid_hint(pAdapter, req, &status)) |
Varun Reddy Yeturu | 3e91dad | 2016-07-18 15:58:47 -0700 | [diff] [blame] | 12564 | return status; |
| 12565 | |
Agrawal Ashish | f156e94 | 2016-08-04 14:54:47 +0530 | [diff] [blame] | 12566 | wlan_hdd_disable_roaming(pAdapter); |
| 12567 | |
| 12568 | /* Try disconnecting if already in connected state */ |
| 12569 | status = wlan_hdd_try_disconnect(pAdapter); |
| 12570 | if (0 > status) { |
| 12571 | hdd_err("Failed to disconnect the existing connection"); |
| 12572 | return -EALREADY; |
| 12573 | } |
| 12574 | |
| 12575 | /* Check for max concurrent connections after doing disconnect if any */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12576 | if (req->channel) { |
Tushnim Bhattacharyya | ca50b32 | 2015-12-28 17:14:36 -0800 | [diff] [blame] | 12577 | if (!cds_allow_concurrency( |
Krunal Soni | b4326f2 | 2016-03-10 13:05:51 -0800 | [diff] [blame] | 12578 | cds_convert_device_mode_to_qdf_type( |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12579 | pAdapter->device_mode), |
| 12580 | req->channel->hw_value, HW_MODE_20_MHZ)) { |
| 12581 | hdd_err("This concurrency combination is not allowed"); |
| 12582 | return -ECONNREFUSED; |
| 12583 | } |
| 12584 | } else { |
Tushnim Bhattacharyya | ca50b32 | 2015-12-28 17:14:36 -0800 | [diff] [blame] | 12585 | if (!cds_allow_concurrency( |
Krunal Soni | b4326f2 | 2016-03-10 13:05:51 -0800 | [diff] [blame] | 12586 | cds_convert_device_mode_to_qdf_type( |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12587 | pAdapter->device_mode), 0, HW_MODE_20_MHZ)) { |
| 12588 | hdd_err("This concurrency combination is not allowed"); |
| 12589 | return -ECONNREFUSED; |
| 12590 | } |
| 12591 | } |
Varun Reddy Yeturu | 3e91dad | 2016-07-18 15:58:47 -0700 | [diff] [blame] | 12592 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12593 | /*initialise security parameters */ |
| 12594 | status = wlan_hdd_cfg80211_set_privacy(pAdapter, req); |
| 12595 | |
| 12596 | if (0 > status) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 12597 | hdd_err("failed to set security params"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12598 | return status; |
| 12599 | } |
| 12600 | |
Sreelakshmi Konamki | 6bd8a2e | 2015-11-03 16:30:32 +0530 | [diff] [blame] | 12601 | if (req->channel) |
| 12602 | channel = req->channel->hw_value; |
| 12603 | else |
| 12604 | channel = 0; |
| 12605 | status = wlan_hdd_cfg80211_connect_start(pAdapter, req->ssid, |
| 12606 | req->ssid_len, req->bssid, |
Naveen Rawat | c77e6e7 | 2016-08-05 15:19:03 -0700 | [diff] [blame] | 12607 | bssid_hint, channel, 0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12608 | if (0 > status) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 12609 | hdd_err("connect failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12610 | return status; |
| 12611 | } |
| 12612 | EXIT(); |
| 12613 | return status; |
| 12614 | } |
| 12615 | |
| 12616 | /** |
| 12617 | * wlan_hdd_cfg80211_connect() - cfg80211 connect api |
| 12618 | * @wiphy: Pointer to wiphy |
| 12619 | * @dev: Pointer to network device |
| 12620 | * @req: Pointer to cfg80211 connect request |
| 12621 | * |
| 12622 | * Return: 0 for success, non-zero for failure |
| 12623 | */ |
| 12624 | static int wlan_hdd_cfg80211_connect(struct wiphy *wiphy, |
| 12625 | struct net_device *ndev, |
| 12626 | struct cfg80211_connect_params *req) |
| 12627 | { |
| 12628 | int ret; |
| 12629 | cds_ssr_protect(__func__); |
| 12630 | ret = __wlan_hdd_cfg80211_connect(wiphy, ndev, req); |
| 12631 | cds_ssr_unprotect(__func__); |
| 12632 | |
| 12633 | return ret; |
| 12634 | } |
| 12635 | |
| 12636 | /** |
| 12637 | * wlan_hdd_disconnect() - hdd disconnect api |
| 12638 | * @pAdapter: Pointer to adapter |
| 12639 | * @reason: Disconnect reason code |
| 12640 | * |
| 12641 | * This function is used to issue a disconnect request to SME |
| 12642 | * |
| 12643 | * Return: 0 for success, non-zero for failure |
| 12644 | */ |
Jeff Johnson | 8b8a04b | 2016-10-05 15:49:43 -0700 | [diff] [blame] | 12645 | static int wlan_hdd_disconnect(hdd_adapter_t *pAdapter, u16 reason) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12646 | { |
| 12647 | int status, result = 0; |
| 12648 | unsigned long rc; |
| 12649 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 12650 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 12651 | |
Hanumantha Reddy Pothula | 2db50ed | 2015-11-23 10:48:33 +0530 | [diff] [blame] | 12652 | ENTER(); |
| 12653 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12654 | status = wlan_hdd_validate_context(pHddCtx); |
| 12655 | |
Hanumantha Reddy Pothula | 2db50ed | 2015-11-23 10:48:33 +0530 | [diff] [blame] | 12656 | if (0 != status) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12657 | return status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12658 | |
| 12659 | /*stop tx queues */ |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 12660 | hdd_notice("Disabling queues"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12661 | wlan_hdd_netif_queue_control(pAdapter, WLAN_NETIF_TX_DISABLE_N_CARRIER, |
| 12662 | WLAN_CONTROL_PATH); |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 12663 | hdd_notice("Set HDD connState to eConnectionState_Disconnecting"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12664 | pHddStaCtx->conn_info.connState = eConnectionState_Disconnecting; |
| 12665 | INIT_COMPLETION(pAdapter->disconnect_comp_var); |
| 12666 | |
| 12667 | /*issue disconnect */ |
| 12668 | |
| 12669 | status = sme_roam_disconnect(WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 12670 | pAdapter->sessionId, reason); |
Abhishek Singh | acfdc92 | 2015-12-30 17:31:21 +0530 | [diff] [blame] | 12671 | /* |
| 12672 | * Wait here instead of returning directly, this will block the next |
| 12673 | * connect command and allow processing of the scan for ssid and |
| 12674 | * the previous connect command in CSR. Else we might hit some |
| 12675 | * race conditions leading to SME and HDD out of sync. |
| 12676 | */ |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 12677 | if (QDF_STATUS_CMD_NOT_QUEUED == status) { |
Abhishek Singh | be1849b | 2016-01-19 14:12:00 +0530 | [diff] [blame] | 12678 | 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] | 12679 | } else if (0 != status) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 12680 | hdd_err("csr_roam_disconnect failure, returned %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12681 | (int)status); |
| 12682 | pHddStaCtx->staDebugState = status; |
| 12683 | result = -EINVAL; |
| 12684 | goto disconnected; |
| 12685 | } |
| 12686 | rc = wait_for_completion_timeout(&pAdapter->disconnect_comp_var, |
| 12687 | msecs_to_jiffies |
| 12688 | (WLAN_WAIT_TIME_DISCONNECT)); |
| 12689 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 12690 | if (!rc && (QDF_STATUS_CMD_NOT_QUEUED != status)) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 12691 | hdd_err("Failed to disconnect, timed out"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12692 | result = -ETIMEDOUT; |
| 12693 | } |
| 12694 | disconnected: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12695 | hdd_conn_set_connection_state(pAdapter, eConnectionState_NotConnected); |
| 12696 | #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0) |
| 12697 | /* Sending disconnect event to userspace for kernel version < 3.11 |
| 12698 | * is handled by __cfg80211_disconnect call to __cfg80211_disconnected |
| 12699 | */ |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 12700 | hdd_notice("Send disconnected event to userspace"); |
Mahesh A Saptasagar | c35e8bf | 2016-06-17 20:03:46 +0530 | [diff] [blame] | 12701 | wlan_hdd_cfg80211_indicate_disconnect(pAdapter->dev, true, |
| 12702 | WLAN_REASON_UNSPECIFIED); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12703 | #endif |
| 12704 | |
| 12705 | return result; |
| 12706 | } |
| 12707 | |
| 12708 | /** |
Srinivas Girigowda | f2599dd | 2015-11-16 18:20:46 -0800 | [diff] [blame] | 12709 | * hdd_ieee80211_reason_code_to_str() - return string conversion of reason code |
| 12710 | * @reason: ieee80211 reason code. |
| 12711 | * |
| 12712 | * This utility function helps log string conversion of reason code. |
| 12713 | * |
| 12714 | * Return: string conversion of reason code, if match found; |
| 12715 | * "Unknown" otherwise. |
| 12716 | */ |
| 12717 | static const char *hdd_ieee80211_reason_code_to_str(uint16_t reason) |
| 12718 | { |
| 12719 | switch (reason) { |
| 12720 | CASE_RETURN_STRING(WLAN_REASON_UNSPECIFIED); |
| 12721 | CASE_RETURN_STRING(WLAN_REASON_PREV_AUTH_NOT_VALID); |
| 12722 | CASE_RETURN_STRING(WLAN_REASON_DEAUTH_LEAVING); |
| 12723 | CASE_RETURN_STRING(WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY); |
| 12724 | CASE_RETURN_STRING(WLAN_REASON_DISASSOC_AP_BUSY); |
| 12725 | CASE_RETURN_STRING(WLAN_REASON_CLASS2_FRAME_FROM_NONAUTH_STA); |
| 12726 | CASE_RETURN_STRING(WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA); |
| 12727 | CASE_RETURN_STRING(WLAN_REASON_DISASSOC_STA_HAS_LEFT); |
| 12728 | CASE_RETURN_STRING(WLAN_REASON_STA_REQ_ASSOC_WITHOUT_AUTH); |
| 12729 | CASE_RETURN_STRING(WLAN_REASON_DISASSOC_BAD_POWER); |
| 12730 | CASE_RETURN_STRING(WLAN_REASON_DISASSOC_BAD_SUPP_CHAN); |
| 12731 | CASE_RETURN_STRING(WLAN_REASON_INVALID_IE); |
| 12732 | CASE_RETURN_STRING(WLAN_REASON_MIC_FAILURE); |
| 12733 | CASE_RETURN_STRING(WLAN_REASON_4WAY_HANDSHAKE_TIMEOUT); |
| 12734 | CASE_RETURN_STRING(WLAN_REASON_GROUP_KEY_HANDSHAKE_TIMEOUT); |
| 12735 | CASE_RETURN_STRING(WLAN_REASON_IE_DIFFERENT); |
| 12736 | CASE_RETURN_STRING(WLAN_REASON_INVALID_GROUP_CIPHER); |
| 12737 | CASE_RETURN_STRING(WLAN_REASON_INVALID_PAIRWISE_CIPHER); |
| 12738 | CASE_RETURN_STRING(WLAN_REASON_INVALID_AKMP); |
| 12739 | CASE_RETURN_STRING(WLAN_REASON_UNSUPP_RSN_VERSION); |
| 12740 | CASE_RETURN_STRING(WLAN_REASON_INVALID_RSN_IE_CAP); |
| 12741 | CASE_RETURN_STRING(WLAN_REASON_IEEE8021X_FAILED); |
| 12742 | CASE_RETURN_STRING(WLAN_REASON_CIPHER_SUITE_REJECTED); |
| 12743 | CASE_RETURN_STRING(WLAN_REASON_DISASSOC_UNSPECIFIED_QOS); |
| 12744 | CASE_RETURN_STRING(WLAN_REASON_DISASSOC_QAP_NO_BANDWIDTH); |
| 12745 | CASE_RETURN_STRING(WLAN_REASON_DISASSOC_LOW_ACK); |
| 12746 | CASE_RETURN_STRING(WLAN_REASON_DISASSOC_QAP_EXCEED_TXOP); |
| 12747 | CASE_RETURN_STRING(WLAN_REASON_QSTA_LEAVE_QBSS); |
| 12748 | CASE_RETURN_STRING(WLAN_REASON_QSTA_NOT_USE); |
| 12749 | CASE_RETURN_STRING(WLAN_REASON_QSTA_REQUIRE_SETUP); |
| 12750 | CASE_RETURN_STRING(WLAN_REASON_QSTA_TIMEOUT); |
| 12751 | CASE_RETURN_STRING(WLAN_REASON_QSTA_CIPHER_NOT_SUPP); |
| 12752 | CASE_RETURN_STRING(WLAN_REASON_MESH_PEER_CANCELED); |
| 12753 | CASE_RETURN_STRING(WLAN_REASON_MESH_MAX_PEERS); |
| 12754 | CASE_RETURN_STRING(WLAN_REASON_MESH_CONFIG); |
| 12755 | CASE_RETURN_STRING(WLAN_REASON_MESH_CLOSE); |
| 12756 | CASE_RETURN_STRING(WLAN_REASON_MESH_MAX_RETRIES); |
| 12757 | CASE_RETURN_STRING(WLAN_REASON_MESH_CONFIRM_TIMEOUT); |
| 12758 | CASE_RETURN_STRING(WLAN_REASON_MESH_INVALID_GTK); |
| 12759 | CASE_RETURN_STRING(WLAN_REASON_MESH_INCONSISTENT_PARAM); |
| 12760 | CASE_RETURN_STRING(WLAN_REASON_MESH_INVALID_SECURITY); |
| 12761 | CASE_RETURN_STRING(WLAN_REASON_MESH_PATH_ERROR); |
| 12762 | CASE_RETURN_STRING(WLAN_REASON_MESH_PATH_NOFORWARD); |
| 12763 | CASE_RETURN_STRING(WLAN_REASON_MESH_PATH_DEST_UNREACHABLE); |
| 12764 | CASE_RETURN_STRING(WLAN_REASON_MAC_EXISTS_IN_MBSS); |
| 12765 | CASE_RETURN_STRING(WLAN_REASON_MESH_CHAN_REGULATORY); |
| 12766 | CASE_RETURN_STRING(WLAN_REASON_MESH_CHAN); |
| 12767 | default: |
| 12768 | return "Unknown"; |
| 12769 | } |
| 12770 | } |
| 12771 | |
| 12772 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12773 | * __wlan_hdd_cfg80211_disconnect() - cfg80211 disconnect api |
| 12774 | * @wiphy: Pointer to wiphy |
| 12775 | * @dev: Pointer to network device |
| 12776 | * @reason: Disconnect reason code |
| 12777 | * |
| 12778 | * This function is used to issue a disconnect request to SME |
| 12779 | * |
| 12780 | * Return: 0 for success, non-zero for failure |
| 12781 | */ |
| 12782 | static int __wlan_hdd_cfg80211_disconnect(struct wiphy *wiphy, |
| 12783 | struct net_device *dev, u16 reason) |
| 12784 | { |
| 12785 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 12786 | int status; |
| 12787 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 12788 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 12789 | #ifdef FEATURE_WLAN_TDLS |
| 12790 | uint8_t staIdx; |
| 12791 | #endif |
| 12792 | |
| 12793 | ENTER(); |
| 12794 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 12795 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 12796 | hdd_err("Command not allowed in FTM mode"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12797 | return -EINVAL; |
| 12798 | } |
| 12799 | |
Hanumanth Reddy Pothula | d9491f4 | 2016-10-24 19:08:38 +0530 | [diff] [blame] | 12800 | if (wlan_hdd_validate_session_id(pAdapter->sessionId)) { |
| 12801 | hdd_err("invalid session id: %d", pAdapter->sessionId); |
| 12802 | return -EINVAL; |
| 12803 | } |
| 12804 | |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 12805 | MTRACE(qdf_trace(QDF_MODULE_ID_HDD, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12806 | TRACE_CODE_HDD_CFG80211_DISCONNECT, |
| 12807 | pAdapter->sessionId, reason)); |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 12808 | hdd_notice("Device_mode %s(%d) reason code(%d)", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12809 | hdd_device_mode_to_string(pAdapter->device_mode), |
| 12810 | pAdapter->device_mode, reason); |
| 12811 | |
| 12812 | status = wlan_hdd_validate_context(pHddCtx); |
| 12813 | |
Hanumantha Reddy Pothula | 2db50ed | 2015-11-23 10:48:33 +0530 | [diff] [blame] | 12814 | if (0 != status) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12815 | return status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12816 | |
| 12817 | /* Issue disconnect request to SME, if station is in connected state */ |
| 12818 | if ((pHddStaCtx->conn_info.connState == eConnectionState_Associated) || |
| 12819 | (pHddStaCtx->conn_info.connState == eConnectionState_Connecting)) { |
| 12820 | eCsrRoamDisconnectReason reasonCode = |
| 12821 | eCSR_DISCONNECT_REASON_UNSPECIFIED; |
| 12822 | hdd_scaninfo_t *pScanInfo; |
| 12823 | |
| 12824 | switch (reason) { |
| 12825 | case WLAN_REASON_MIC_FAILURE: |
| 12826 | reasonCode = eCSR_DISCONNECT_REASON_MIC_ERROR; |
| 12827 | break; |
| 12828 | |
| 12829 | case WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY: |
| 12830 | case WLAN_REASON_DISASSOC_AP_BUSY: |
| 12831 | case WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA: |
| 12832 | reasonCode = eCSR_DISCONNECT_REASON_DISASSOC; |
| 12833 | break; |
| 12834 | |
| 12835 | case WLAN_REASON_PREV_AUTH_NOT_VALID: |
| 12836 | case WLAN_REASON_CLASS2_FRAME_FROM_NONAUTH_STA: |
| 12837 | reasonCode = eCSR_DISCONNECT_REASON_DEAUTH; |
| 12838 | break; |
| 12839 | |
| 12840 | case WLAN_REASON_DEAUTH_LEAVING: |
| 12841 | reasonCode = |
| 12842 | pHddCtx->config-> |
| 12843 | gEnableDeauthToDisassocMap ? |
| 12844 | eCSR_DISCONNECT_REASON_STA_HAS_LEFT : |
| 12845 | eCSR_DISCONNECT_REASON_DEAUTH; |
| 12846 | break; |
| 12847 | case WLAN_REASON_DISASSOC_STA_HAS_LEFT: |
| 12848 | reasonCode = eCSR_DISCONNECT_REASON_STA_HAS_LEFT; |
| 12849 | break; |
| 12850 | default: |
| 12851 | reasonCode = eCSR_DISCONNECT_REASON_UNSPECIFIED; |
| 12852 | break; |
| 12853 | } |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 12854 | hdd_notice("convert to internal reason %d to reasonCode %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12855 | reason, reasonCode); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12856 | pScanInfo = &pAdapter->scan_info; |
| 12857 | if (pScanInfo->mScanPending) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 12858 | hdd_notice("Disconnect is in progress, Aborting Scan"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12859 | hdd_abort_mac_scan(pHddCtx, pAdapter->sessionId, |
| 12860 | eCSR_SCAN_ABORT_DEFAULT); |
| 12861 | } |
Edhar, Mahesh Kumar | 732f698 | 2016-07-01 11:23:06 +0530 | [diff] [blame] | 12862 | wlan_hdd_cleanup_remain_on_channel_ctx(pAdapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12863 | #ifdef FEATURE_WLAN_TDLS |
| 12864 | /* First clean up the tdls peers if any */ |
| 12865 | for (staIdx = 0; staIdx < pHddCtx->max_num_tdls_sta; staIdx++) { |
| 12866 | if ((pHddCtx->tdlsConnInfo[staIdx].sessionId == |
| 12867 | pAdapter->sessionId) |
| 12868 | && (pHddCtx->tdlsConnInfo[staIdx].staId)) { |
| 12869 | uint8_t *mac; |
| 12870 | mac = |
| 12871 | pHddCtx->tdlsConnInfo[staIdx].peerMac.bytes; |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 12872 | hdd_notice("call sme_delete_tdls_peer_sta staId %d sessionId %d " |
| 12873 | MAC_ADDRESS_STR, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12874 | pHddCtx->tdlsConnInfo[staIdx].staId, |
| 12875 | pAdapter->sessionId, |
| 12876 | MAC_ADDR_ARRAY(mac)); |
| 12877 | sme_delete_tdls_peer_sta(WLAN_HDD_GET_HAL_CTX |
| 12878 | (pAdapter), |
| 12879 | pAdapter->sessionId, mac); |
| 12880 | } |
| 12881 | } |
| 12882 | #endif |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 12883 | hdd_notice("Disconnecting with reasoncode:%u", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12884 | reasonCode); |
Srinivas Girigowda | f2599dd | 2015-11-16 18:20:46 -0800 | [diff] [blame] | 12885 | hdd_info("Disconnect request from user space with reason: %s", |
| 12886 | hdd_ieee80211_reason_code_to_str(reason)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12887 | status = wlan_hdd_disconnect(pAdapter, reasonCode); |
| 12888 | if (0 != status) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 12889 | hdd_err("failure, returned %d", status); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12890 | return -EINVAL; |
| 12891 | } |
| 12892 | } else { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 12893 | hdd_err("unexpected cfg disconnect called while in state (%d)", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12894 | pHddStaCtx->conn_info.connState); |
| 12895 | } |
| 12896 | |
| 12897 | return status; |
| 12898 | } |
| 12899 | |
| 12900 | /** |
| 12901 | * wlan_hdd_cfg80211_disconnect() - cfg80211 disconnect api |
| 12902 | * @wiphy: Pointer to wiphy |
| 12903 | * @dev: Pointer to network device |
| 12904 | * @reason: Disconnect reason code |
| 12905 | * |
| 12906 | * Return: 0 for success, non-zero for failure |
| 12907 | */ |
| 12908 | static int wlan_hdd_cfg80211_disconnect(struct wiphy *wiphy, |
| 12909 | struct net_device *dev, u16 reason) |
| 12910 | { |
| 12911 | int ret; |
| 12912 | cds_ssr_protect(__func__); |
| 12913 | ret = __wlan_hdd_cfg80211_disconnect(wiphy, dev, reason); |
| 12914 | cds_ssr_unprotect(__func__); |
| 12915 | |
| 12916 | return ret; |
| 12917 | } |
| 12918 | |
| 12919 | /** |
| 12920 | * wlan_hdd_cfg80211_set_privacy_ibss() - set ibss privacy |
| 12921 | * @pAdapter: Pointer to adapter |
| 12922 | * @param: Pointer to IBSS parameters |
| 12923 | * |
| 12924 | * This function is used to initialize the security settings in IBSS mode |
| 12925 | * |
| 12926 | * Return: 0 for success, non-zero for failure |
| 12927 | */ |
| 12928 | static int wlan_hdd_cfg80211_set_privacy_ibss(hdd_adapter_t *pAdapter, |
| 12929 | struct cfg80211_ibss_params |
| 12930 | *params) |
| 12931 | { |
| 12932 | int status = 0; |
| 12933 | hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
| 12934 | eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE; |
| 12935 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 12936 | |
| 12937 | ENTER(); |
| 12938 | |
| 12939 | pWextState->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED; |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 12940 | qdf_mem_zero(&pHddStaCtx->ibss_enc_key, sizeof(tCsrRoamSetKey)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12941 | pHddStaCtx->ibss_enc_key_installed = 0; |
| 12942 | |
| 12943 | if (params->ie_len && (NULL != params->ie)) { |
| 12944 | if (wlan_hdd_cfg80211_get_ie_ptr(params->ie, |
| 12945 | params->ie_len, WLAN_EID_RSN)) { |
| 12946 | pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA2; |
| 12947 | encryptionType = eCSR_ENCRYPT_TYPE_AES; |
| 12948 | } else if (hdd_is_wpaie_present(params->ie, params->ie_len)) { |
| 12949 | tDot11fIEWPA dot11WPAIE; |
| 12950 | tHalHandle halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter); |
| 12951 | u8 *ie; |
| 12952 | |
| 12953 | memset(&dot11WPAIE, 0, sizeof(dot11WPAIE)); |
| 12954 | ie = wlan_hdd_cfg80211_get_ie_ptr(params->ie, |
| 12955 | params->ie_len, |
| 12956 | DOT11F_EID_WPA); |
| 12957 | if (NULL != ie) { |
| 12958 | pWextState->wpaVersion = |
| 12959 | IW_AUTH_WPA_VERSION_WPA; |
| 12960 | /* Unpack the WPA IE */ |
| 12961 | /* Skip past the EID byte and length byte - and four byte WiFi OUI */ |
| 12962 | dot11f_unpack_ie_wpa((tpAniSirGlobal) halHandle, |
| 12963 | &ie[2 + 4], |
| 12964 | ie[1] - 4, &dot11WPAIE); |
| 12965 | /*Extract the multicast cipher, the encType for unicast |
| 12966 | cipher for wpa-none is none */ |
| 12967 | encryptionType = |
| 12968 | hdd_translate_wpa_to_csr_encryption_type |
| 12969 | (dot11WPAIE.multicast_cipher); |
| 12970 | } |
| 12971 | } |
| 12972 | |
| 12973 | status = |
| 12974 | wlan_hdd_cfg80211_set_ie(pAdapter, params->ie, |
| 12975 | params->ie_len); |
| 12976 | |
| 12977 | if (0 > status) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 12978 | hdd_err("failed to parse WPA/RSN IE"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12979 | return status; |
| 12980 | } |
| 12981 | } |
| 12982 | |
| 12983 | pWextState->roamProfile.AuthType.authType[0] = |
| 12984 | pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM; |
| 12985 | |
| 12986 | if (params->privacy) { |
| 12987 | /* Security enabled IBSS, At this time there is no information |
| 12988 | * available about the security paramters, so initialise the |
| 12989 | * encryption type to eCSR_ENCRYPT_TYPE_WEP40_STATICKEY. |
| 12990 | * The correct security parameters will be updated later in |
| 12991 | * wlan_hdd_cfg80211_add_key Hal expects encryption type to be |
| 12992 | * set inorder enable privacy bit in beacons |
| 12993 | */ |
| 12994 | |
| 12995 | encryptionType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY; |
| 12996 | } |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 12997 | hdd_info("encryptionType=%d", encryptionType); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12998 | pHddStaCtx->conn_info.ucEncryptionType = encryptionType; |
| 12999 | pWextState->roamProfile.EncryptionType.numEntries = 1; |
| 13000 | pWextState->roamProfile.EncryptionType.encryptionType[0] = |
| 13001 | encryptionType; |
| 13002 | return status; |
| 13003 | } |
| 13004 | |
| 13005 | /** |
| 13006 | * __wlan_hdd_cfg80211_join_ibss() - join ibss |
| 13007 | * @wiphy: Pointer to wiphy |
| 13008 | * @dev: Pointer to network device |
| 13009 | * @param: Pointer to IBSS join parameters |
| 13010 | * |
| 13011 | * This function is used to create/join an IBSS network |
| 13012 | * |
| 13013 | * Return: 0 for success, non-zero for failure |
| 13014 | */ |
| 13015 | static int __wlan_hdd_cfg80211_join_ibss(struct wiphy *wiphy, |
| 13016 | struct net_device *dev, |
| 13017 | struct cfg80211_ibss_params *params) |
| 13018 | { |
| 13019 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 13020 | hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
| 13021 | tCsrRoamProfile *pRoamProfile; |
| 13022 | int status; |
| 13023 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 13024 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 13025 | struct qdf_mac_addr bssid; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13026 | u8 channelNum = 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13027 | |
| 13028 | ENTER(); |
| 13029 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 13030 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 13031 | hdd_err("Command not allowed in FTM mode"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13032 | return -EINVAL; |
| 13033 | } |
| 13034 | |
Hanumanth Reddy Pothula | d9491f4 | 2016-10-24 19:08:38 +0530 | [diff] [blame] | 13035 | if (wlan_hdd_validate_session_id(pAdapter->sessionId)) { |
| 13036 | hdd_err("invalid session id: %d", pAdapter->sessionId); |
| 13037 | return -EINVAL; |
| 13038 | } |
| 13039 | |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 13040 | MTRACE(qdf_trace(QDF_MODULE_ID_HDD, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13041 | TRACE_CODE_HDD_CFG80211_JOIN_IBSS, |
| 13042 | pAdapter->sessionId, pAdapter->device_mode)); |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 13043 | hdd_notice("Device_mode %s(%d)", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13044 | hdd_device_mode_to_string(pAdapter->device_mode), |
| 13045 | pAdapter->device_mode); |
| 13046 | |
| 13047 | status = wlan_hdd_validate_context(pHddCtx); |
| 13048 | |
Hanumantha Reddy Pothula | 2db50ed | 2015-11-23 10:48:33 +0530 | [diff] [blame] | 13049 | if (0 != status) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13050 | return status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13051 | |
| 13052 | if (NULL != |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 13053 | params->chandef.chan) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13054 | uint32_t numChans = WNI_CFG_VALID_CHANNEL_LIST_LEN; |
| 13055 | uint8_t validChan[WNI_CFG_VALID_CHANNEL_LIST_LEN]; |
| 13056 | tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter); |
| 13057 | int indx; |
| 13058 | |
| 13059 | /* Get channel number */ |
| 13060 | channelNum = ieee80211_frequency_to_channel( |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13061 | params-> |
| 13062 | chandef. |
| 13063 | chan-> |
| 13064 | center_freq); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13065 | |
| 13066 | if (0 != sme_cfg_get_str(hHal, WNI_CFG_VALID_CHANNEL_LIST, |
| 13067 | validChan, &numChans)) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 13068 | hdd_err("No valid channel list"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13069 | return -EOPNOTSUPP; |
| 13070 | } |
| 13071 | |
| 13072 | for (indx = 0; indx < numChans; indx++) { |
| 13073 | if (channelNum == validChan[indx]) { |
| 13074 | break; |
| 13075 | } |
| 13076 | } |
| 13077 | if (indx >= numChans) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 13078 | hdd_err("Not valid Channel %d", channelNum); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13079 | return -EINVAL; |
| 13080 | } |
| 13081 | } |
| 13082 | |
Tushnim Bhattacharyya | ca50b32 | 2015-12-28 17:14:36 -0800 | [diff] [blame] | 13083 | if (!cds_allow_concurrency(CDS_IBSS_MODE, channelNum, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13084 | HW_MODE_20_MHZ)) { |
| 13085 | hdd_err("This concurrency combination is not allowed"); |
| 13086 | return -ECONNREFUSED; |
| 13087 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13088 | |
Krunal Soni | 3091bcc | 2016-06-23 12:28:21 -0700 | [diff] [blame] | 13089 | status = qdf_reset_connection_update(); |
| 13090 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 13091 | hdd_err("ERR: clear event failed"); |
| 13092 | |
| 13093 | status = cds_current_connections_update(pAdapter->sessionId, |
| 13094 | channelNum, |
| 13095 | SIR_UPDATE_REASON_JOIN_IBSS); |
| 13096 | if (QDF_STATUS_E_FAILURE == status) { |
| 13097 | hdd_err("ERROR: connections update failed!!"); |
| 13098 | return -EINVAL; |
| 13099 | } |
| 13100 | |
| 13101 | if (QDF_STATUS_SUCCESS == status) { |
| 13102 | status = qdf_wait_for_connection_update(); |
| 13103 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 13104 | hdd_err("ERROR: qdf wait for event failed!!"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13105 | return -EINVAL; |
| 13106 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13107 | } |
| 13108 | |
| 13109 | /*Try disconnecting if already in connected state */ |
| 13110 | status = wlan_hdd_try_disconnect(pAdapter); |
| 13111 | if (0 > status) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 13112 | hdd_err("Failed to disconnect the existing IBSS connection"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13113 | return -EALREADY; |
| 13114 | } |
| 13115 | |
| 13116 | pRoamProfile = &pWextState->roamProfile; |
| 13117 | |
| 13118 | if (eCSR_BSS_TYPE_START_IBSS != pRoamProfile->BSSType) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 13119 | hdd_err("Interface type is not set to IBSS"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13120 | return -EINVAL; |
| 13121 | } |
| 13122 | |
| 13123 | /* enable selected protection checks in IBSS mode */ |
| 13124 | pRoamProfile->cfg_protection = IBSS_CFG_PROTECTION_ENABLE_MASK; |
| 13125 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 13126 | if (QDF_STATUS_E_FAILURE == sme_cfg_set_int(pHddCtx->hHal, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13127 | WNI_CFG_IBSS_ATIM_WIN_SIZE, |
| 13128 | pHddCtx->config-> |
| 13129 | ibssATIMWinSize)) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 13130 | 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] | 13131 | } |
| 13132 | |
| 13133 | /* BSSID is provided by upper layers hence no need to AUTO generate */ |
| 13134 | if (NULL != params->bssid) { |
| 13135 | 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] | 13136 | == QDF_STATUS_E_FAILURE) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 13137 | hdd_err("ccmCfgStInt failed for WNI_CFG_IBSS_AUTO_BSSID"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13138 | return -EIO; |
| 13139 | } |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 13140 | qdf_mem_copy(bssid.bytes, params->bssid, QDF_MAC_ADDR_SIZE); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13141 | } else if (pHddCtx->config->isCoalesingInIBSSAllowed == 0) { |
| 13142 | 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] | 13143 | == QDF_STATUS_E_FAILURE) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 13144 | hdd_err("ccmCfgStInt failed for WNI_CFG_IBSS_AUTO_BSSID"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13145 | return -EIO; |
| 13146 | } |
Anurag Chouhan | c554842 | 2016-02-24 18:33:27 +0530 | [diff] [blame] | 13147 | qdf_copy_macaddr(&bssid, &pHddCtx->config->IbssBssid); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13148 | } |
| 13149 | if ((params->beacon_interval > CFG_BEACON_INTERVAL_MIN) |
| 13150 | && (params->beacon_interval <= CFG_BEACON_INTERVAL_MAX)) |
| 13151 | pRoamProfile->beaconInterval = params->beacon_interval; |
| 13152 | else { |
| 13153 | pRoamProfile->beaconInterval = CFG_BEACON_INTERVAL_DEFAULT; |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 13154 | 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] | 13155 | params->beacon_interval, pRoamProfile->beaconInterval); |
| 13156 | } |
| 13157 | |
| 13158 | /* Set Channel */ |
| 13159 | if (channelNum) { |
| 13160 | /* Set the Operational Channel */ |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 13161 | hdd_info("set channel %d", channelNum); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13162 | pRoamProfile->ChannelInfo.numOfChannels = 1; |
| 13163 | pHddStaCtx->conn_info.operationChannel = channelNum; |
| 13164 | pRoamProfile->ChannelInfo.ChannelList = |
| 13165 | &pHddStaCtx->conn_info.operationChannel; |
| 13166 | } |
| 13167 | |
| 13168 | /* Initialize security parameters */ |
| 13169 | status = wlan_hdd_cfg80211_set_privacy_ibss(pAdapter, params); |
| 13170 | if (status < 0) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 13171 | hdd_err("failed to set security parameters"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13172 | return status; |
| 13173 | } |
| 13174 | |
| 13175 | /* Issue connect start */ |
| 13176 | status = wlan_hdd_cfg80211_connect_start(pAdapter, params->ssid, |
| 13177 | params->ssid_len, |
Naveen Rawat | c77e6e7 | 2016-08-05 15:19:03 -0700 | [diff] [blame] | 13178 | bssid.bytes, NULL, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13179 | pHddStaCtx->conn_info. |
Naveen Rawat | c77e6e7 | 2016-08-05 15:19:03 -0700 | [diff] [blame] | 13180 | operationChannel, |
| 13181 | params->chandef.width); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13182 | |
| 13183 | if (0 > status) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 13184 | hdd_err("connect failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13185 | return status; |
| 13186 | } |
Hanumantha Reddy Pothula | 2db50ed | 2015-11-23 10:48:33 +0530 | [diff] [blame] | 13187 | EXIT(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13188 | return 0; |
| 13189 | } |
| 13190 | |
| 13191 | /** |
| 13192 | * wlan_hdd_cfg80211_join_ibss() - join ibss |
| 13193 | * @wiphy: Pointer to wiphy |
| 13194 | * @dev: Pointer to network device |
| 13195 | * @param: Pointer to IBSS join parameters |
| 13196 | * |
| 13197 | * This function is used to create/join an IBSS network |
| 13198 | * |
| 13199 | * Return: 0 for success, non-zero for failure |
| 13200 | */ |
| 13201 | static int wlan_hdd_cfg80211_join_ibss(struct wiphy *wiphy, |
| 13202 | struct net_device *dev, |
| 13203 | struct cfg80211_ibss_params *params) |
| 13204 | { |
| 13205 | int ret = 0; |
| 13206 | |
| 13207 | cds_ssr_protect(__func__); |
| 13208 | ret = __wlan_hdd_cfg80211_join_ibss(wiphy, dev, params); |
| 13209 | cds_ssr_unprotect(__func__); |
| 13210 | |
| 13211 | return ret; |
| 13212 | } |
| 13213 | |
| 13214 | /** |
| 13215 | * __wlan_hdd_cfg80211_leave_ibss() - leave ibss |
| 13216 | * @wiphy: Pointer to wiphy |
| 13217 | * @dev: Pointer to network device |
| 13218 | * |
| 13219 | * This function is used to leave an IBSS network |
| 13220 | * |
| 13221 | * Return: 0 for success, non-zero for failure |
| 13222 | */ |
| 13223 | static int __wlan_hdd_cfg80211_leave_ibss(struct wiphy *wiphy, |
| 13224 | struct net_device *dev) |
| 13225 | { |
| 13226 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 13227 | hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
| 13228 | tCsrRoamProfile *pRoamProfile; |
| 13229 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 13230 | int status; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 13231 | QDF_STATUS hal_status; |
Chandrasekaran, Manishekar | 12a818a | 2015-12-18 11:44:56 +0530 | [diff] [blame] | 13232 | unsigned long rc; |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 13233 | tSirUpdateIE updateIE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13234 | |
| 13235 | ENTER(); |
| 13236 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 13237 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 13238 | hdd_err("Command not allowed in FTM mode"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13239 | return -EINVAL; |
| 13240 | } |
| 13241 | |
Hanumanth Reddy Pothula | d9491f4 | 2016-10-24 19:08:38 +0530 | [diff] [blame] | 13242 | if (wlan_hdd_validate_session_id(pAdapter->sessionId)) { |
| 13243 | hdd_err("invalid session id: %d", pAdapter->sessionId); |
| 13244 | return -EINVAL; |
| 13245 | } |
| 13246 | |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 13247 | MTRACE(qdf_trace(QDF_MODULE_ID_HDD, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13248 | TRACE_CODE_HDD_CFG80211_LEAVE_IBSS, |
| 13249 | pAdapter->sessionId, |
| 13250 | eCSR_DISCONNECT_REASON_IBSS_LEAVE)); |
| 13251 | status = wlan_hdd_validate_context(pHddCtx); |
Hanumantha Reddy Pothula | 2db50ed | 2015-11-23 10:48:33 +0530 | [diff] [blame] | 13252 | if (0 != status) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13253 | return status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13254 | |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 13255 | hdd_notice("Device_mode %s(%d)", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13256 | hdd_device_mode_to_string(pAdapter->device_mode), |
| 13257 | pAdapter->device_mode); |
| 13258 | if (NULL == pWextState) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 13259 | hdd_err("Data Storage Corruption"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13260 | return -EIO; |
| 13261 | } |
| 13262 | |
| 13263 | pRoamProfile = &pWextState->roamProfile; |
| 13264 | |
| 13265 | /* Issue disconnect only if interface type is set to IBSS */ |
| 13266 | if (eCSR_BSS_TYPE_START_IBSS != pRoamProfile->BSSType) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 13267 | hdd_err("BSS Type is not set to IBSS"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13268 | return -EINVAL; |
| 13269 | } |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 13270 | /* Clearing add IE of beacon */ |
| 13271 | qdf_mem_copy(updateIE.bssid.bytes, pAdapter->macAddressCurrent.bytes, |
| 13272 | sizeof(tSirMacAddr)); |
| 13273 | updateIE.smeSessionId = pAdapter->sessionId; |
| 13274 | updateIE.ieBufferlength = 0; |
| 13275 | updateIE.pAdditionIEBuffer = NULL; |
| 13276 | updateIE.append = true; |
| 13277 | updateIE.notify = true; |
| 13278 | if (sme_update_add_ie(WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 13279 | &updateIE, |
| 13280 | eUPDATE_IE_PROBE_BCN) == QDF_STATUS_E_FAILURE) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 13281 | hdd_err("Could not pass on PROBE_RSP_BCN data to PE"); |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 13282 | } |
| 13283 | |
| 13284 | /* Reset WNI_CFG_PROBE_RSP Flags */ |
| 13285 | wlan_hdd_reset_prob_rspies(pAdapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13286 | |
| 13287 | /* Issue Disconnect request */ |
| 13288 | INIT_COMPLETION(pAdapter->disconnect_comp_var); |
| 13289 | hal_status = sme_roam_disconnect(WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 13290 | pAdapter->sessionId, |
| 13291 | eCSR_DISCONNECT_REASON_IBSS_LEAVE); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 13292 | if (!QDF_IS_STATUS_SUCCESS(hal_status)) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 13293 | hdd_err("sme_roam_disconnect failed hal_status(%d)", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13294 | hal_status); |
| 13295 | return -EAGAIN; |
| 13296 | } |
Chandrasekaran, Manishekar | 12a818a | 2015-12-18 11:44:56 +0530 | [diff] [blame] | 13297 | |
| 13298 | /* wait for mc thread to cleanup and then return to upper stack |
| 13299 | * so by the time upper layer calls the change interface, we are |
| 13300 | * all set to proceed further |
| 13301 | */ |
| 13302 | rc = wait_for_completion_timeout(&pAdapter->disconnect_comp_var, |
| 13303 | msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT)); |
| 13304 | if (!rc) { |
| 13305 | hdd_err("Failed to disconnect, timed out"); |
| 13306 | return -ETIMEDOUT; |
| 13307 | } |
| 13308 | |
Hanumantha Reddy Pothula | 2db50ed | 2015-11-23 10:48:33 +0530 | [diff] [blame] | 13309 | EXIT(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13310 | return 0; |
| 13311 | } |
| 13312 | |
| 13313 | /** |
| 13314 | * wlan_hdd_cfg80211_leave_ibss() - leave ibss |
| 13315 | * @wiphy: Pointer to wiphy |
| 13316 | * @dev: Pointer to network device |
| 13317 | * |
| 13318 | * This function is used to leave an IBSS network |
| 13319 | * |
| 13320 | * Return: 0 for success, non-zero for failure |
| 13321 | */ |
| 13322 | static int wlan_hdd_cfg80211_leave_ibss(struct wiphy *wiphy, |
| 13323 | struct net_device *dev) |
| 13324 | { |
| 13325 | int ret = 0; |
| 13326 | |
| 13327 | cds_ssr_protect(__func__); |
| 13328 | ret = __wlan_hdd_cfg80211_leave_ibss(wiphy, dev); |
| 13329 | cds_ssr_unprotect(__func__); |
| 13330 | |
| 13331 | return ret; |
| 13332 | } |
| 13333 | |
| 13334 | /** |
| 13335 | * __wlan_hdd_cfg80211_set_wiphy_params() - set wiphy parameters |
| 13336 | * @wiphy: Pointer to wiphy |
| 13337 | * @changed: Parameters changed |
| 13338 | * |
| 13339 | * This function is used to set the phy parameters. RTS Threshold/FRAG |
| 13340 | * Threshold/Retry Count etc. |
| 13341 | * |
| 13342 | * Return: 0 for success, non-zero for failure |
| 13343 | */ |
| 13344 | static int __wlan_hdd_cfg80211_set_wiphy_params(struct wiphy *wiphy, |
| 13345 | u32 changed) |
| 13346 | { |
| 13347 | hdd_context_t *pHddCtx = wiphy_priv(wiphy); |
| 13348 | tHalHandle hHal = pHddCtx->hHal; |
| 13349 | int status; |
| 13350 | |
| 13351 | ENTER(); |
| 13352 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 13353 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 13354 | hdd_err("Command not allowed in FTM mode"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13355 | return -EINVAL; |
| 13356 | } |
| 13357 | |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 13358 | MTRACE(qdf_trace(QDF_MODULE_ID_HDD, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13359 | TRACE_CODE_HDD_CFG80211_SET_WIPHY_PARAMS, |
| 13360 | NO_SESSION, wiphy->rts_threshold)); |
| 13361 | status = wlan_hdd_validate_context(pHddCtx); |
| 13362 | |
Hanumantha Reddy Pothula | 2db50ed | 2015-11-23 10:48:33 +0530 | [diff] [blame] | 13363 | if (0 != status) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13364 | return status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13365 | |
| 13366 | if (changed & WIPHY_PARAM_RTS_THRESHOLD) { |
| 13367 | u32 rts_threshold = (wiphy->rts_threshold == -1) ? |
| 13368 | WNI_CFG_RTS_THRESHOLD_STAMAX : wiphy->rts_threshold; |
| 13369 | |
| 13370 | if ((WNI_CFG_RTS_THRESHOLD_STAMIN > rts_threshold) || |
| 13371 | (WNI_CFG_RTS_THRESHOLD_STAMAX < rts_threshold)) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 13372 | hdd_err("Invalid RTS Threshold value %u", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13373 | rts_threshold); |
| 13374 | return -EINVAL; |
| 13375 | } |
| 13376 | |
| 13377 | if (0 != sme_cfg_set_int(hHal, WNI_CFG_RTS_THRESHOLD, |
| 13378 | rts_threshold)) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 13379 | hdd_err("sme_cfg_set_int failed for rts_threshold value %u", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13380 | rts_threshold); |
| 13381 | return -EIO; |
| 13382 | } |
| 13383 | |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 13384 | hdd_info("set rts threshold %u", rts_threshold); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13385 | } |
| 13386 | |
| 13387 | if (changed & WIPHY_PARAM_FRAG_THRESHOLD) { |
| 13388 | u16 frag_threshold = (wiphy->frag_threshold == -1) ? |
| 13389 | WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX : |
| 13390 | wiphy->frag_threshold; |
| 13391 | |
| 13392 | if ((WNI_CFG_FRAGMENTATION_THRESHOLD_STAMIN > frag_threshold) || |
| 13393 | (WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX < frag_threshold)) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 13394 | hdd_err("Invalid frag_threshold value %hu", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13395 | frag_threshold); |
| 13396 | return -EINVAL; |
| 13397 | } |
| 13398 | |
| 13399 | if (0 != sme_cfg_set_int(hHal, WNI_CFG_FRAGMENTATION_THRESHOLD, |
| 13400 | frag_threshold)) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 13401 | hdd_err("sme_cfg_set_int failed for frag_threshold value %hu", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13402 | frag_threshold); |
| 13403 | return -EIO; |
| 13404 | } |
| 13405 | |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 13406 | hdd_info("set frag threshold %hu", frag_threshold); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13407 | } |
| 13408 | |
| 13409 | if ((changed & WIPHY_PARAM_RETRY_SHORT) |
| 13410 | || (changed & WIPHY_PARAM_RETRY_LONG)) { |
| 13411 | u8 retry_value = (changed & WIPHY_PARAM_RETRY_SHORT) ? |
| 13412 | wiphy->retry_short : wiphy->retry_long; |
| 13413 | |
| 13414 | if ((WNI_CFG_LONG_RETRY_LIMIT_STAMIN > retry_value) || |
| 13415 | (WNI_CFG_LONG_RETRY_LIMIT_STAMAX < retry_value)) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 13416 | hdd_err("Invalid Retry count %hu", retry_value); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13417 | return -EINVAL; |
| 13418 | } |
| 13419 | |
| 13420 | if (changed & WIPHY_PARAM_RETRY_SHORT) { |
| 13421 | if (0 != sme_cfg_set_int(hHal, |
| 13422 | WNI_CFG_LONG_RETRY_LIMIT, |
| 13423 | retry_value)) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 13424 | hdd_err("sme_cfg_set_int failed for long retry count %hu", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13425 | retry_value); |
| 13426 | return -EIO; |
| 13427 | } |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 13428 | hdd_info("set long retry count %hu", retry_value); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13429 | } else if (changed & WIPHY_PARAM_RETRY_SHORT) { |
| 13430 | if (0 != sme_cfg_set_int(hHal, |
| 13431 | WNI_CFG_SHORT_RETRY_LIMIT, |
| 13432 | retry_value)) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 13433 | hdd_err("sme_cfg_set_int failed for short retry count %hu", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13434 | retry_value); |
| 13435 | return -EIO; |
| 13436 | } |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 13437 | hdd_info("set short retry count %hu", retry_value); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13438 | } |
| 13439 | } |
Hanumantha Reddy Pothula | 2db50ed | 2015-11-23 10:48:33 +0530 | [diff] [blame] | 13440 | EXIT(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13441 | return 0; |
| 13442 | } |
| 13443 | |
| 13444 | /** |
| 13445 | * wlan_hdd_cfg80211_set_wiphy_params() - set wiphy parameters |
| 13446 | * @wiphy: Pointer to wiphy |
| 13447 | * @changed: Parameters changed |
| 13448 | * |
| 13449 | * Return: 0 for success, non-zero for failure |
| 13450 | */ |
| 13451 | static int wlan_hdd_cfg80211_set_wiphy_params(struct wiphy *wiphy, u32 changed) |
| 13452 | { |
| 13453 | int ret; |
| 13454 | |
| 13455 | cds_ssr_protect(__func__); |
| 13456 | ret = __wlan_hdd_cfg80211_set_wiphy_params(wiphy, changed); |
| 13457 | cds_ssr_unprotect(__func__); |
| 13458 | |
| 13459 | return ret; |
| 13460 | } |
| 13461 | |
| 13462 | /** |
| 13463 | * __wlan_hdd_set_default_mgmt_key() - dummy implementation of set default mgmt |
| 13464 | * key |
| 13465 | * @wiphy: Pointer to wiphy |
| 13466 | * @dev: Pointer to network device |
| 13467 | * @key_index: Key index |
| 13468 | * |
| 13469 | * Return: 0 |
| 13470 | */ |
| 13471 | static int __wlan_hdd_set_default_mgmt_key(struct wiphy *wiphy, |
| 13472 | struct net_device *netdev, |
| 13473 | u8 key_index) |
| 13474 | { |
| 13475 | ENTER(); |
| 13476 | return 0; |
| 13477 | } |
| 13478 | |
| 13479 | /** |
| 13480 | * wlan_hdd_set_default_mgmt_key() - SSR wrapper for |
| 13481 | * wlan_hdd_set_default_mgmt_key |
| 13482 | * @wiphy: pointer to wiphy |
| 13483 | * @netdev: pointer to net_device structure |
| 13484 | * @key_index: key index |
| 13485 | * |
| 13486 | * Return: 0 on success, error number on failure |
| 13487 | */ |
| 13488 | static int wlan_hdd_set_default_mgmt_key(struct wiphy *wiphy, |
| 13489 | struct net_device *netdev, |
| 13490 | u8 key_index) |
| 13491 | { |
| 13492 | int ret; |
| 13493 | |
| 13494 | cds_ssr_protect(__func__); |
| 13495 | ret = __wlan_hdd_set_default_mgmt_key(wiphy, netdev, key_index); |
| 13496 | cds_ssr_unprotect(__func__); |
| 13497 | |
| 13498 | return ret; |
| 13499 | } |
| 13500 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13501 | /** |
| 13502 | * __wlan_hdd_set_txq_params() - dummy implementation of set tx queue params |
| 13503 | * @wiphy: Pointer to wiphy |
| 13504 | * @dev: Pointer to network device |
| 13505 | * @params: Pointer to tx queue parameters |
| 13506 | * |
| 13507 | * Return: 0 |
| 13508 | */ |
| 13509 | static int __wlan_hdd_set_txq_params(struct wiphy *wiphy, |
| 13510 | struct net_device *dev, |
| 13511 | struct ieee80211_txq_params *params) |
| 13512 | { |
| 13513 | ENTER(); |
| 13514 | return 0; |
| 13515 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13516 | |
| 13517 | /** |
| 13518 | * wlan_hdd_set_txq_params() - SSR wrapper for wlan_hdd_set_txq_params |
| 13519 | * @wiphy: pointer to wiphy |
| 13520 | * @netdev: pointer to net_device structure |
| 13521 | * @params: pointer to ieee80211_txq_params |
| 13522 | * |
| 13523 | * Return: 0 on success, error number on failure |
| 13524 | */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13525 | static int wlan_hdd_set_txq_params(struct wiphy *wiphy, |
| 13526 | struct net_device *dev, |
| 13527 | struct ieee80211_txq_params *params) |
| 13528 | { |
| 13529 | int ret; |
| 13530 | |
| 13531 | cds_ssr_protect(__func__); |
| 13532 | ret = __wlan_hdd_set_txq_params(wiphy, dev, params); |
| 13533 | cds_ssr_unprotect(__func__); |
| 13534 | |
| 13535 | return ret; |
| 13536 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13537 | |
| 13538 | /** |
| 13539 | * __wlan_hdd_cfg80211_del_station() - delete station v2 |
| 13540 | * @wiphy: Pointer to wiphy |
| 13541 | * @param: Pointer to delete station parameter |
| 13542 | * |
| 13543 | * Return: 0 for success, non-zero for failure |
| 13544 | */ |
| 13545 | static |
| 13546 | int __wlan_hdd_cfg80211_del_station(struct wiphy *wiphy, |
| 13547 | struct net_device *dev, |
| 13548 | struct tagCsrDelStaParams *pDelStaParams) |
| 13549 | { |
| 13550 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 13551 | hdd_context_t *pHddCtx; |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 13552 | QDF_STATUS qdf_status = QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13553 | hdd_hostapd_state_t *hapd_state; |
| 13554 | int status; |
| 13555 | uint8_t staId; |
| 13556 | uint8_t *mac; |
| 13557 | |
| 13558 | ENTER(); |
| 13559 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 13560 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 13561 | hdd_err("Command not allowed in FTM mode"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13562 | return -EINVAL; |
| 13563 | } |
| 13564 | |
Hanumanth Reddy Pothula | d9491f4 | 2016-10-24 19:08:38 +0530 | [diff] [blame] | 13565 | if (wlan_hdd_validate_session_id(pAdapter->sessionId)) { |
| 13566 | hdd_err("invalid session id: %d", pAdapter->sessionId); |
| 13567 | return -EINVAL; |
| 13568 | } |
| 13569 | |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 13570 | MTRACE(qdf_trace(QDF_MODULE_ID_HDD, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13571 | TRACE_CODE_HDD_CFG80211_DEL_STA, |
| 13572 | pAdapter->sessionId, pAdapter->device_mode)); |
| 13573 | |
| 13574 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 13575 | status = wlan_hdd_validate_context(pHddCtx); |
| 13576 | |
Hanumantha Reddy Pothula | 2db50ed | 2015-11-23 10:48:33 +0530 | [diff] [blame] | 13577 | if (0 != status) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13578 | return status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13579 | |
| 13580 | mac = (uint8_t *) pDelStaParams->peerMacAddr.bytes; |
| 13581 | |
Krunal Soni | b4326f2 | 2016-03-10 13:05:51 -0800 | [diff] [blame] | 13582 | if ((QDF_SAP_MODE == pAdapter->device_mode) || |
| 13583 | (QDF_P2P_GO_MODE == pAdapter->device_mode)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13584 | |
| 13585 | hapd_state = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter); |
| 13586 | if (!hapd_state) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 13587 | hdd_err("Hostapd State is Null"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13588 | return 0; |
| 13589 | } |
| 13590 | |
Anurag Chouhan | c554842 | 2016-02-24 18:33:27 +0530 | [diff] [blame] | 13591 | if (qdf_is_macaddr_broadcast((struct qdf_mac_addr *) mac)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13592 | uint16_t i; |
| 13593 | for (i = 0; i < WLAN_MAX_STA_COUNT; i++) { |
| 13594 | if ((pAdapter->aStaInfo[i].isUsed) && |
| 13595 | (!pAdapter->aStaInfo[i]. |
| 13596 | isDeauthInProgress)) { |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 13597 | qdf_mem_copy( |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13598 | mac, |
| 13599 | pAdapter->aStaInfo[i]. |
| 13600 | macAddrSTA.bytes, |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 13601 | QDF_MAC_ADDR_SIZE); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13602 | if (hdd_ipa_uc_is_enabled(pHddCtx)) { |
| 13603 | hdd_ipa_wlan_evt(pAdapter, |
| 13604 | pAdapter-> |
| 13605 | aStaInfo[i]. |
| 13606 | ucSTAId, |
Mohit Khanna | fa99aea | 2016-05-12 21:43:13 -0700 | [diff] [blame] | 13607 | HDD_IPA_CLIENT_DISCONNECT, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13608 | mac); |
| 13609 | } |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 13610 | hdd_notice("Delete STA with MAC::" |
| 13611 | MAC_ADDRESS_STR, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13612 | MAC_ADDR_ARRAY(mac)); |
| 13613 | |
| 13614 | if (pHddCtx->dev_dfs_cac_status == |
| 13615 | DFS_CAC_IN_PROGRESS) |
| 13616 | goto fn_end; |
| 13617 | |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 13618 | qdf_event_reset(&hapd_state->qdf_event); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13619 | hdd_softap_sta_disassoc(pAdapter, |
Deepthi Gowri | b3bfefd | 2016-09-13 15:14:34 +0530 | [diff] [blame] | 13620 | pDelStaParams); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 13621 | qdf_status = |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13622 | hdd_softap_sta_deauth(pAdapter, |
| 13623 | pDelStaParams); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 13624 | if (QDF_IS_STATUS_SUCCESS(qdf_status)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13625 | pAdapter->aStaInfo[i]. |
| 13626 | isDeauthInProgress = true; |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 13627 | qdf_status = |
| 13628 | qdf_wait_single_event( |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 13629 | &hapd_state->qdf_event, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13630 | 1000); |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 13631 | if (!QDF_IS_STATUS_SUCCESS( |
| 13632 | qdf_status)) |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 13633 | hdd_err("Deauth wait time expired"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13634 | } |
| 13635 | } |
| 13636 | } |
| 13637 | } else { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 13638 | qdf_status = |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13639 | hdd_softap_get_sta_id(pAdapter, |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 13640 | (struct qdf_mac_addr *) mac, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13641 | &staId); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 13642 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 13643 | hdd_notice("Skip DEL STA as this is not used::" |
| 13644 | MAC_ADDRESS_STR, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13645 | MAC_ADDR_ARRAY(mac)); |
| 13646 | return -ENOENT; |
| 13647 | } |
| 13648 | |
| 13649 | if (hdd_ipa_uc_is_enabled(pHddCtx)) { |
| 13650 | hdd_ipa_wlan_evt(pAdapter, staId, |
Mohit Khanna | fa99aea | 2016-05-12 21:43:13 -0700 | [diff] [blame] | 13651 | HDD_IPA_CLIENT_DISCONNECT, mac); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13652 | } |
| 13653 | |
| 13654 | if (pAdapter->aStaInfo[staId].isDeauthInProgress == |
| 13655 | true) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 13656 | hdd_notice("Skip DEL STA as deauth is in progress::" |
| 13657 | MAC_ADDRESS_STR, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13658 | MAC_ADDR_ARRAY(mac)); |
| 13659 | return -ENOENT; |
| 13660 | } |
| 13661 | |
| 13662 | pAdapter->aStaInfo[staId].isDeauthInProgress = true; |
| 13663 | |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 13664 | hdd_notice("Delete STA with MAC::" MAC_ADDRESS_STR, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13665 | MAC_ADDR_ARRAY(mac)); |
| 13666 | |
| 13667 | /* Case: SAP in ACS selected DFS ch and client connected |
| 13668 | * Now Radar detected. Then if random channel is another |
| 13669 | * DFS ch then new CAC is initiated and no TX allowed. |
| 13670 | * So do not send any mgmt frames as it will timeout |
| 13671 | * during CAC. |
| 13672 | */ |
| 13673 | |
| 13674 | if (pHddCtx->dev_dfs_cac_status == DFS_CAC_IN_PROGRESS) |
| 13675 | goto fn_end; |
| 13676 | |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 13677 | qdf_event_reset(&hapd_state->qdf_event); |
Kondabattini, Ganesh | 3f2d02c | 2016-09-13 12:23:47 +0530 | [diff] [blame] | 13678 | sme_send_disassoc_req_frame(WLAN_HDD_GET_HAL_CTX |
| 13679 | (pAdapter), pAdapter->sessionId, |
| 13680 | (uint8_t *)&pDelStaParams->peerMacAddr, |
| 13681 | pDelStaParams->reason_code, 0); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 13682 | qdf_status = hdd_softap_sta_deauth(pAdapter, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13683 | pDelStaParams); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 13684 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13685 | pAdapter->aStaInfo[staId].isDeauthInProgress = |
| 13686 | false; |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 13687 | hdd_notice("STA removal failed for ::" |
| 13688 | MAC_ADDRESS_STR, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13689 | MAC_ADDR_ARRAY(mac)); |
| 13690 | return -ENOENT; |
| 13691 | } else { |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 13692 | qdf_status = qdf_wait_single_event( |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 13693 | &hapd_state->qdf_event, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13694 | 1000); |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 13695 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 13696 | hdd_err("Deauth wait time expired"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13697 | } |
| 13698 | } |
| 13699 | } |
| 13700 | |
| 13701 | fn_end: |
| 13702 | EXIT(); |
| 13703 | return 0; |
| 13704 | } |
| 13705 | |
Ryan Hsu | 8ecb0fa | 2016-01-18 15:40:55 -0800 | [diff] [blame] | 13706 | #if defined(USE_CFG80211_DEL_STA_V2) |
| 13707 | /** |
| 13708 | * wlan_hdd_del_station() - delete station wrapper |
| 13709 | * @adapter: pointer to the hdd adapter |
| 13710 | * |
| 13711 | * Return: None |
| 13712 | */ |
| 13713 | void wlan_hdd_del_station(hdd_adapter_t *adapter) |
| 13714 | { |
| 13715 | struct station_del_parameters del_sta; |
| 13716 | del_sta.mac = NULL; |
| 13717 | del_sta.subtype = SIR_MAC_MGMT_DEAUTH >> 4; |
| 13718 | del_sta.reason_code = eCsrForcedDeauthSta; |
| 13719 | |
| 13720 | wlan_hdd_cfg80211_del_station(adapter->wdev.wiphy, adapter->dev, |
| 13721 | &del_sta); |
| 13722 | } |
| 13723 | #else |
| 13724 | void wlan_hdd_del_station(hdd_adapter_t *adapter) |
| 13725 | { |
| 13726 | wlan_hdd_cfg80211_del_station(adapter->wdev.wiphy, adapter->dev, NULL); |
| 13727 | } |
| 13728 | #endif |
| 13729 | |
| 13730 | #if defined(USE_CFG80211_DEL_STA_V2) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13731 | /** |
| 13732 | * wlan_hdd_cfg80211_del_station() - delete station v2 |
| 13733 | * @wiphy: Pointer to wiphy |
| 13734 | * @param: Pointer to delete station parameter |
| 13735 | * |
| 13736 | * Return: 0 for success, non-zero for failure |
| 13737 | */ |
| 13738 | int wlan_hdd_cfg80211_del_station(struct wiphy *wiphy, |
| 13739 | struct net_device *dev, |
| 13740 | struct station_del_parameters *param) |
| 13741 | #else |
| 13742 | /** |
| 13743 | * wlan_hdd_cfg80211_del_station() - delete station |
| 13744 | * @wiphy: Pointer to wiphy |
| 13745 | * @mac: Pointer to station mac address |
| 13746 | * |
| 13747 | * Return: 0 for success, non-zero for failure |
| 13748 | */ |
| 13749 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 16, 0)) |
| 13750 | int wlan_hdd_cfg80211_del_station(struct wiphy *wiphy, |
| 13751 | struct net_device *dev, |
| 13752 | const uint8_t *mac) |
| 13753 | #else |
| 13754 | int wlan_hdd_cfg80211_del_station(struct wiphy *wiphy, |
| 13755 | struct net_device *dev, |
| 13756 | uint8_t *mac) |
| 13757 | #endif |
| 13758 | #endif |
| 13759 | { |
| 13760 | int ret; |
| 13761 | struct tagCsrDelStaParams delStaParams; |
| 13762 | |
| 13763 | cds_ssr_protect(__func__); |
Ryan Hsu | 8ecb0fa | 2016-01-18 15:40:55 -0800 | [diff] [blame] | 13764 | #if defined(USE_CFG80211_DEL_STA_V2) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13765 | if (NULL == param) { |
Ryan Hsu | 8ecb0fa | 2016-01-18 15:40:55 -0800 | [diff] [blame] | 13766 | hdd_err("Invalid argument passed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13767 | return -EINVAL; |
| 13768 | } |
| 13769 | wlansap_populate_del_sta_params(param->mac, param->reason_code, |
| 13770 | param->subtype, &delStaParams); |
| 13771 | #else |
| 13772 | wlansap_populate_del_sta_params(mac, eSIR_MAC_DEAUTH_LEAVING_BSS_REASON, |
| 13773 | (SIR_MAC_MGMT_DEAUTH >> 4), |
| 13774 | &delStaParams); |
| 13775 | #endif |
| 13776 | ret = __wlan_hdd_cfg80211_del_station(wiphy, dev, &delStaParams); |
| 13777 | cds_ssr_unprotect(__func__); |
| 13778 | |
| 13779 | return ret; |
| 13780 | } |
| 13781 | |
| 13782 | /** |
| 13783 | * __wlan_hdd_cfg80211_add_station() - add station |
| 13784 | * @wiphy: Pointer to wiphy |
| 13785 | * @mac: Pointer to station mac address |
| 13786 | * @pmksa: Pointer to add station parameter |
| 13787 | * |
| 13788 | * Return: 0 for success, non-zero for failure |
| 13789 | */ |
| 13790 | static int __wlan_hdd_cfg80211_add_station(struct wiphy *wiphy, |
| 13791 | struct net_device *dev, |
| 13792 | const uint8_t *mac, |
| 13793 | struct station_parameters *params) |
| 13794 | { |
| 13795 | int status = -EPERM; |
| 13796 | #ifdef FEATURE_WLAN_TDLS |
| 13797 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 13798 | hdd_context_t *pHddCtx = wiphy_priv(wiphy); |
| 13799 | u32 mask, set; |
| 13800 | |
| 13801 | ENTER(); |
| 13802 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 13803 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 13804 | hdd_err("Command not allowed in FTM mode"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13805 | return -EINVAL; |
| 13806 | } |
| 13807 | |
Hanumanth Reddy Pothula | d9491f4 | 2016-10-24 19:08:38 +0530 | [diff] [blame] | 13808 | if (wlan_hdd_validate_session_id(pAdapter->sessionId)) { |
| 13809 | hdd_err("invalid session id: %d", pAdapter->sessionId); |
| 13810 | return -EINVAL; |
| 13811 | } |
| 13812 | |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 13813 | MTRACE(qdf_trace(QDF_MODULE_ID_HDD, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13814 | TRACE_CODE_HDD_CFG80211_ADD_STA, |
| 13815 | pAdapter->sessionId, params->listen_interval)); |
| 13816 | |
Hanumantha Reddy Pothula | 2db50ed | 2015-11-23 10:48:33 +0530 | [diff] [blame] | 13817 | if (0 != wlan_hdd_validate_context(pHddCtx)) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13818 | return -EINVAL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13819 | |
| 13820 | mask = params->sta_flags_mask; |
| 13821 | |
| 13822 | set = params->sta_flags_set; |
| 13823 | |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 13824 | 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] | 13825 | MAC_ADDR_ARRAY(mac)); |
| 13826 | |
| 13827 | if (mask & BIT(NL80211_STA_FLAG_TDLS_PEER)) { |
| 13828 | if (set & BIT(NL80211_STA_FLAG_TDLS_PEER)) { |
| 13829 | status = |
| 13830 | wlan_hdd_tdls_add_station(wiphy, dev, mac, 0, NULL); |
| 13831 | } |
| 13832 | } |
| 13833 | #endif |
Hanumantha Reddy Pothula | 2db50ed | 2015-11-23 10:48:33 +0530 | [diff] [blame] | 13834 | EXIT(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13835 | return status; |
| 13836 | } |
| 13837 | |
| 13838 | /** |
| 13839 | * wlan_hdd_cfg80211_add_station() - add station |
| 13840 | * @wiphy: Pointer to wiphy |
| 13841 | * @mac: Pointer to station mac address |
| 13842 | * @pmksa: Pointer to add station parameter |
| 13843 | * |
| 13844 | * Return: 0 for success, non-zero for failure |
| 13845 | */ |
| 13846 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 16, 0)) |
| 13847 | static int wlan_hdd_cfg80211_add_station(struct wiphy *wiphy, |
| 13848 | struct net_device *dev, |
| 13849 | const uint8_t *mac, |
| 13850 | struct station_parameters *params) |
| 13851 | #else |
| 13852 | static int wlan_hdd_cfg80211_add_station(struct wiphy *wiphy, |
| 13853 | struct net_device *dev, uint8_t *mac, |
| 13854 | struct station_parameters *params) |
| 13855 | #endif |
| 13856 | { |
| 13857 | int ret; |
| 13858 | |
| 13859 | cds_ssr_protect(__func__); |
| 13860 | ret = __wlan_hdd_cfg80211_add_station(wiphy, dev, mac, params); |
| 13861 | cds_ssr_unprotect(__func__); |
| 13862 | |
| 13863 | return ret; |
| 13864 | } |
| 13865 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13866 | /** |
| 13867 | * __wlan_hdd_cfg80211_set_pmksa() - set pmksa |
| 13868 | * @wiphy: Pointer to wiphy |
| 13869 | * @dev: Pointer to network device |
| 13870 | * @pmksa: Pointer to set pmksa parameter |
| 13871 | * |
| 13872 | * Return: 0 for success, non-zero for failure |
| 13873 | */ |
| 13874 | static int __wlan_hdd_cfg80211_set_pmksa(struct wiphy *wiphy, |
| 13875 | struct net_device *dev, |
| 13876 | struct cfg80211_pmksa *pmksa) |
| 13877 | { |
| 13878 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 13879 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 13880 | tHalHandle halHandle; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 13881 | QDF_STATUS result = QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13882 | int status; |
| 13883 | tPmkidCacheInfo pmk_id; |
| 13884 | |
Hanumantha Reddy Pothula | 2db50ed | 2015-11-23 10:48:33 +0530 | [diff] [blame] | 13885 | ENTER(); |
| 13886 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 13887 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 13888 | hdd_err("Command not allowed in FTM mode"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13889 | return -EINVAL; |
| 13890 | } |
| 13891 | |
Hanumanth Reddy Pothula | d9491f4 | 2016-10-24 19:08:38 +0530 | [diff] [blame] | 13892 | if (wlan_hdd_validate_session_id(pAdapter->sessionId)) { |
| 13893 | hdd_err("invalid session id: %d", pAdapter->sessionId); |
| 13894 | return -EINVAL; |
| 13895 | } |
| 13896 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13897 | if (!pmksa) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 13898 | hdd_err("pmksa is NULL"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13899 | return -EINVAL; |
| 13900 | } |
| 13901 | |
| 13902 | if (!pmksa->bssid || !pmksa->pmkid) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 13903 | hdd_err("pmksa->bssid(%p) or pmksa->pmkid(%p) is NULL", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13904 | pmksa->bssid, pmksa->pmkid); |
| 13905 | return -EINVAL; |
| 13906 | } |
| 13907 | |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 13908 | hdd_warn("set PMKSA for " MAC_ADDRESS_STR, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13909 | MAC_ADDR_ARRAY(pmksa->bssid)); |
| 13910 | |
| 13911 | status = wlan_hdd_validate_context(pHddCtx); |
| 13912 | |
Hanumantha Reddy Pothula | 2db50ed | 2015-11-23 10:48:33 +0530 | [diff] [blame] | 13913 | if (0 != status) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13914 | return status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13915 | |
| 13916 | halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter); |
| 13917 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 13918 | qdf_mem_copy(pmk_id.BSSID.bytes, pmksa->bssid, QDF_MAC_ADDR_SIZE); |
| 13919 | qdf_mem_copy(pmk_id.PMKID, pmksa->pmkid, CSR_RSN_PMKID_SIZE); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13920 | |
| 13921 | /* Add to the PMKSA ID Cache in CSR */ |
| 13922 | result = sme_roam_set_pmkid_cache(halHandle, pAdapter->sessionId, |
| 13923 | &pmk_id, 1, false); |
| 13924 | |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 13925 | MTRACE(qdf_trace(QDF_MODULE_ID_HDD, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13926 | TRACE_CODE_HDD_CFG80211_SET_PMKSA, |
| 13927 | pAdapter->sessionId, result)); |
| 13928 | |
Hanumantha Reddy Pothula | 2db50ed | 2015-11-23 10:48:33 +0530 | [diff] [blame] | 13929 | EXIT(); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 13930 | return QDF_IS_STATUS_SUCCESS(result) ? 0 : -EINVAL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13931 | } |
| 13932 | |
| 13933 | /** |
| 13934 | * wlan_hdd_cfg80211_set_pmksa() - set pmksa |
| 13935 | * @wiphy: Pointer to wiphy |
| 13936 | * @dev: Pointer to network device |
| 13937 | * @pmksa: Pointer to set pmksa parameter |
| 13938 | * |
| 13939 | * Return: 0 for success, non-zero for failure |
| 13940 | */ |
| 13941 | static int wlan_hdd_cfg80211_set_pmksa(struct wiphy *wiphy, |
| 13942 | struct net_device *dev, |
| 13943 | struct cfg80211_pmksa *pmksa) |
| 13944 | { |
| 13945 | int ret; |
| 13946 | |
| 13947 | cds_ssr_protect(__func__); |
| 13948 | ret = __wlan_hdd_cfg80211_set_pmksa(wiphy, dev, pmksa); |
| 13949 | cds_ssr_unprotect(__func__); |
| 13950 | |
| 13951 | return ret; |
| 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 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 13967 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 13968 | tHalHandle halHandle; |
| 13969 | int status = 0; |
| 13970 | |
Hanumantha Reddy Pothula | 2db50ed | 2015-11-23 10:48:33 +0530 | [diff] [blame] | 13971 | ENTER(); |
| 13972 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 13973 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 13974 | hdd_err("Command not allowed in FTM mode"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13975 | return -EINVAL; |
| 13976 | } |
| 13977 | |
Hanumanth Reddy Pothula | d9491f4 | 2016-10-24 19:08:38 +0530 | [diff] [blame] | 13978 | if (wlan_hdd_validate_session_id(pAdapter->sessionId)) { |
| 13979 | hdd_err("invalid session id: %d", pAdapter->sessionId); |
| 13980 | return -EINVAL; |
| 13981 | } |
| 13982 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13983 | if (!pmksa) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 13984 | hdd_err("pmksa is NULL"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13985 | return -EINVAL; |
| 13986 | } |
| 13987 | |
| 13988 | if (!pmksa->bssid) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 13989 | hdd_err("pmksa->bssid is NULL"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13990 | return -EINVAL; |
| 13991 | } |
| 13992 | |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 13993 | hdd_debug("Deleting PMKSA for " MAC_ADDRESS_STR, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13994 | MAC_ADDR_ARRAY(pmksa->bssid)); |
| 13995 | |
| 13996 | status = wlan_hdd_validate_context(pHddCtx); |
| 13997 | |
Hanumantha Reddy Pothula | 2db50ed | 2015-11-23 10:48:33 +0530 | [diff] [blame] | 13998 | if (0 != status) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13999 | return status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14000 | |
| 14001 | halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter); |
| 14002 | |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 14003 | MTRACE(qdf_trace(QDF_MODULE_ID_HDD, |
Sreelakshmi Konamki | 6744cff | 2015-09-07 12:10:39 +0530 | [diff] [blame] | 14004 | TRACE_CODE_HDD_CFG80211_DEL_PMKSA, |
| 14005 | pAdapter->sessionId, 0)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14006 | /* Delete the PMKID CSR cache */ |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 14007 | if (QDF_STATUS_SUCCESS != |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14008 | sme_roam_del_pmkid_from_cache(halHandle, |
| 14009 | pAdapter->sessionId, pmksa->bssid, |
| 14010 | false)) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 14011 | hdd_err("Failed to delete PMKSA for " MAC_ADDRESS_STR, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14012 | MAC_ADDR_ARRAY(pmksa->bssid)); |
| 14013 | status = -EINVAL; |
| 14014 | } |
Hanumantha Reddy Pothula | 2db50ed | 2015-11-23 10:48:33 +0530 | [diff] [blame] | 14015 | EXIT(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14016 | return status; |
| 14017 | } |
| 14018 | |
| 14019 | /** |
| 14020 | * wlan_hdd_cfg80211_del_pmksa() - delete pmksa |
| 14021 | * @wiphy: Pointer to wiphy |
| 14022 | * @dev: Pointer to network device |
| 14023 | * @pmksa: Pointer to pmksa parameter |
| 14024 | * |
| 14025 | * Return: 0 for success, non-zero for failure |
| 14026 | */ |
| 14027 | static int wlan_hdd_cfg80211_del_pmksa(struct wiphy *wiphy, |
| 14028 | struct net_device *dev, |
| 14029 | struct cfg80211_pmksa *pmksa) |
| 14030 | { |
| 14031 | int ret; |
| 14032 | |
| 14033 | cds_ssr_protect(__func__); |
| 14034 | ret = __wlan_hdd_cfg80211_del_pmksa(wiphy, dev, pmksa); |
| 14035 | cds_ssr_unprotect(__func__); |
| 14036 | |
| 14037 | return ret; |
| 14038 | |
| 14039 | } |
| 14040 | |
| 14041 | /** |
| 14042 | * __wlan_hdd_cfg80211_flush_pmksa() - flush pmksa |
| 14043 | * @wiphy: Pointer to wiphy |
| 14044 | * @dev: Pointer to network device |
| 14045 | * |
| 14046 | * Return: 0 for success, non-zero for failure |
| 14047 | */ |
| 14048 | static int __wlan_hdd_cfg80211_flush_pmksa(struct wiphy *wiphy, |
| 14049 | struct net_device *dev) |
| 14050 | { |
| 14051 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 14052 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 14053 | tHalHandle halHandle; |
| 14054 | int status = 0; |
| 14055 | |
Hanumantha Reddy Pothula | 2db50ed | 2015-11-23 10:48:33 +0530 | [diff] [blame] | 14056 | ENTER(); |
| 14057 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 14058 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 14059 | hdd_err("Command not allowed in FTM mode"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14060 | return -EINVAL; |
| 14061 | } |
| 14062 | |
Hanumanth Reddy Pothula | d9491f4 | 2016-10-24 19:08:38 +0530 | [diff] [blame] | 14063 | if (wlan_hdd_validate_session_id(pAdapter->sessionId)) { |
| 14064 | hdd_err("invalid session id: %d", pAdapter->sessionId); |
| 14065 | return -EINVAL; |
| 14066 | } |
| 14067 | |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 14068 | hdd_warn("Flushing PMKSA"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14069 | |
| 14070 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 14071 | status = wlan_hdd_validate_context(pHddCtx); |
| 14072 | |
Hanumantha Reddy Pothula | 2db50ed | 2015-11-23 10:48:33 +0530 | [diff] [blame] | 14073 | if (0 != status) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14074 | return status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14075 | |
| 14076 | /* Retrieve halHandle */ |
| 14077 | halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter); |
| 14078 | |
| 14079 | /* Flush the PMKID cache in CSR */ |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 14080 | if (QDF_STATUS_SUCCESS != |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14081 | sme_roam_del_pmkid_from_cache(halHandle, pAdapter->sessionId, NULL, |
| 14082 | true)) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 14083 | hdd_err("Cannot flush PMKIDCache"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14084 | status = -EINVAL; |
| 14085 | } |
Hanumantha Reddy Pothula | 2db50ed | 2015-11-23 10:48:33 +0530 | [diff] [blame] | 14086 | EXIT(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14087 | return status; |
| 14088 | } |
| 14089 | |
| 14090 | /** |
| 14091 | * wlan_hdd_cfg80211_flush_pmksa() - flush pmksa |
| 14092 | * @wiphy: Pointer to wiphy |
| 14093 | * @dev: Pointer to network device |
| 14094 | * |
| 14095 | * Return: 0 for success, non-zero for failure |
| 14096 | */ |
| 14097 | static int wlan_hdd_cfg80211_flush_pmksa(struct wiphy *wiphy, |
| 14098 | struct net_device *dev) |
| 14099 | { |
| 14100 | int ret; |
| 14101 | |
| 14102 | cds_ssr_protect(__func__); |
| 14103 | ret = __wlan_hdd_cfg80211_flush_pmksa(wiphy, dev); |
| 14104 | cds_ssr_unprotect(__func__); |
| 14105 | |
| 14106 | return ret; |
| 14107 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14108 | |
Deepak Dhamdhere | 9f09e75 | 2016-01-09 23:17:25 -0800 | [diff] [blame] | 14109 | #if defined(KERNEL_SUPPORT_11R_CFG80211) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14110 | /** |
| 14111 | * __wlan_hdd_cfg80211_update_ft_ies() - update fast transition ies |
| 14112 | * @wiphy: Pointer to wiphy |
| 14113 | * @dev: Pointer to network device |
| 14114 | * @ftie: Pointer to fast transition ie parameter |
| 14115 | * |
| 14116 | * Return: 0 for success, non-zero for failure |
| 14117 | */ |
| 14118 | static int |
| 14119 | __wlan_hdd_cfg80211_update_ft_ies(struct wiphy *wiphy, |
| 14120 | struct net_device *dev, |
| 14121 | struct cfg80211_update_ft_ies_params *ftie) |
| 14122 | { |
| 14123 | hdd_context_t *hdd_ctx = wiphy_priv(wiphy); |
| 14124 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 14125 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 14126 | int status; |
| 14127 | |
Hanumantha Reddy Pothula | 2db50ed | 2015-11-23 10:48:33 +0530 | [diff] [blame] | 14128 | ENTER(); |
| 14129 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14130 | status = wlan_hdd_validate_context(hdd_ctx); |
| 14131 | if (status) |
| 14132 | return status; |
| 14133 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 14134 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 14135 | hdd_err("Command not allowed in FTM mode"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14136 | return -EINVAL; |
| 14137 | } |
| 14138 | |
Hanumanth Reddy Pothula | d9491f4 | 2016-10-24 19:08:38 +0530 | [diff] [blame] | 14139 | if (wlan_hdd_validate_session_id(pAdapter->sessionId)) { |
| 14140 | hdd_err("invalid session id: %d", pAdapter->sessionId); |
| 14141 | return -EINVAL; |
| 14142 | } |
| 14143 | |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 14144 | MTRACE(qdf_trace(QDF_MODULE_ID_HDD, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14145 | TRACE_CODE_HDD_CFG80211_UPDATE_FT_IES, |
| 14146 | pAdapter->sessionId, pHddStaCtx->conn_info.connState)); |
| 14147 | /* Added for debug on reception of Re-assoc Req. */ |
| 14148 | if (eConnectionState_Associated != pHddStaCtx->conn_info.connState) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 14149 | hdd_err("Called with Ie of length = %zu when not associated", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14150 | ftie->ie_len); |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 14151 | hdd_err("Should be Re-assoc Req IEs"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14152 | } |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 14153 | hdd_notice("%s called with Ie of length = %zu", __func__, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14154 | ftie->ie_len); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14155 | |
| 14156 | /* Pass the received FT IEs to SME */ |
| 14157 | sme_set_ft_ies(WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, |
| 14158 | (const u8 *)ftie->ie, ftie->ie_len); |
Hanumantha Reddy Pothula | 2db50ed | 2015-11-23 10:48:33 +0530 | [diff] [blame] | 14159 | EXIT(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14160 | return 0; |
| 14161 | } |
| 14162 | |
| 14163 | /** |
| 14164 | * wlan_hdd_cfg80211_update_ft_ies() - update fast transition ies |
| 14165 | * @wiphy: Pointer to wiphy |
| 14166 | * @dev: Pointer to network device |
| 14167 | * @ftie: Pointer to fast transition ie parameter |
| 14168 | * |
| 14169 | * Return: 0 for success, non-zero for failure |
| 14170 | */ |
| 14171 | static int |
| 14172 | wlan_hdd_cfg80211_update_ft_ies(struct wiphy *wiphy, |
| 14173 | struct net_device *dev, |
| 14174 | struct cfg80211_update_ft_ies_params *ftie) |
| 14175 | { |
| 14176 | int ret; |
| 14177 | |
| 14178 | cds_ssr_protect(__func__); |
| 14179 | ret = __wlan_hdd_cfg80211_update_ft_ies(wiphy, dev, ftie); |
| 14180 | cds_ssr_unprotect(__func__); |
| 14181 | |
| 14182 | return ret; |
| 14183 | } |
| 14184 | #endif |
| 14185 | |
| 14186 | #ifdef WLAN_FEATURE_GTK_OFFLOAD |
| 14187 | /** |
| 14188 | * wlan_hdd_cfg80211_update_replay_counter_callback() - replay counter callback |
| 14189 | * @callbackContext: Callback context |
| 14190 | * @pGtkOffloadGetInfoRsp: Pointer to gtk offload response parameter |
| 14191 | * |
| 14192 | * Callback rountine called upon receiving response for get offload info |
| 14193 | * |
| 14194 | * Return: none |
| 14195 | */ |
| 14196 | void wlan_hdd_cfg80211_update_replay_counter_callback(void *callbackContext, |
| 14197 | tpSirGtkOffloadGetInfoRspParams |
| 14198 | pGtkOffloadGetInfoRsp) |
| 14199 | { |
| 14200 | hdd_adapter_t *pAdapter = (hdd_adapter_t *) callbackContext; |
| 14201 | uint8_t tempReplayCounter[8]; |
| 14202 | hdd_station_ctx_t *pHddStaCtx; |
| 14203 | |
| 14204 | ENTER(); |
| 14205 | |
| 14206 | if (NULL == pAdapter) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 14207 | hdd_err("HDD adapter is Null"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14208 | return; |
| 14209 | } |
| 14210 | |
| 14211 | if (NULL == pGtkOffloadGetInfoRsp) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 14212 | hdd_err("pGtkOffloadGetInfoRsp is Null"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14213 | return; |
| 14214 | } |
| 14215 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 14216 | if (QDF_STATUS_SUCCESS != pGtkOffloadGetInfoRsp->ulStatus) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 14217 | hdd_err("wlan Failed to get replay counter value"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14218 | return; |
| 14219 | } |
| 14220 | |
| 14221 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 14222 | /* Update replay counter */ |
| 14223 | pHddStaCtx->gtkOffloadReqParams.ullKeyReplayCounter = |
| 14224 | pGtkOffloadGetInfoRsp->ullKeyReplayCounter; |
| 14225 | |
| 14226 | { |
| 14227 | /* changing from little to big endian since supplicant |
| 14228 | * works on big endian format |
| 14229 | */ |
| 14230 | int i; |
| 14231 | uint8_t *p = |
| 14232 | (uint8_t *) &pGtkOffloadGetInfoRsp->ullKeyReplayCounter; |
| 14233 | |
| 14234 | for (i = 0; i < 8; i++) { |
| 14235 | tempReplayCounter[7 - i] = (uint8_t) p[i]; |
| 14236 | } |
| 14237 | } |
| 14238 | |
| 14239 | /* Update replay counter to NL */ |
Srinivas Girigowda | 2213b1d | 2015-11-20 17:10:11 -0800 | [diff] [blame] | 14240 | cfg80211_gtk_rekey_notify(pAdapter->dev, |
| 14241 | pGtkOffloadGetInfoRsp->bssid.bytes, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14242 | tempReplayCounter, GFP_KERNEL); |
| 14243 | } |
| 14244 | |
| 14245 | /** |
| 14246 | * __wlan_hdd_cfg80211_set_rekey_data() - set rekey data |
| 14247 | * @wiphy: Pointer to wiphy |
| 14248 | * @dev: Pointer to network device |
| 14249 | * @data: Pointer to rekey data |
| 14250 | * |
| 14251 | * This function is used to offload GTK rekeying job to the firmware. |
| 14252 | * |
| 14253 | * Return: 0 for success, non-zero for failure |
| 14254 | */ |
Jeff Johnson | 8b8a04b | 2016-10-05 15:49:43 -0700 | [diff] [blame] | 14255 | static |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14256 | int __wlan_hdd_cfg80211_set_rekey_data(struct wiphy *wiphy, |
| 14257 | struct net_device *dev, |
| 14258 | struct cfg80211_gtk_rekey_data *data) |
| 14259 | { |
| 14260 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 14261 | hdd_context_t *pHddCtx = wiphy_priv(wiphy); |
| 14262 | hdd_station_ctx_t *pHddStaCtx; |
| 14263 | tHalHandle hHal; |
| 14264 | int result; |
| 14265 | tSirGtkOffloadParams hddGtkOffloadReqParams; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 14266 | QDF_STATUS status = QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14267 | |
| 14268 | ENTER(); |
| 14269 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 14270 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 14271 | hdd_err("Command not allowed in FTM mode"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14272 | return -EINVAL; |
| 14273 | } |
| 14274 | |
Hanumanth Reddy Pothula | d9491f4 | 2016-10-24 19:08:38 +0530 | [diff] [blame] | 14275 | if (wlan_hdd_validate_session_id(pAdapter->sessionId)) { |
| 14276 | hdd_err("invalid session id: %d", pAdapter->sessionId); |
| 14277 | return -EINVAL; |
| 14278 | } |
| 14279 | |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 14280 | MTRACE(qdf_trace(QDF_MODULE_ID_HDD, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14281 | TRACE_CODE_HDD_CFG80211_SET_REKEY_DATA, |
| 14282 | pAdapter->sessionId, pAdapter->device_mode)); |
| 14283 | |
| 14284 | result = wlan_hdd_validate_context(pHddCtx); |
| 14285 | |
Hanumantha Reddy Pothula | 2db50ed | 2015-11-23 10:48:33 +0530 | [diff] [blame] | 14286 | if (0 != result) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14287 | return result; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14288 | |
| 14289 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 14290 | hHal = WLAN_HDD_GET_HAL_CTX(pAdapter); |
| 14291 | if (NULL == hHal) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 14292 | hdd_err("HAL context is Null!!!"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14293 | return -EAGAIN; |
| 14294 | } |
| 14295 | |
| 14296 | pHddStaCtx->gtkOffloadReqParams.ulFlags = GTK_OFFLOAD_ENABLE; |
| 14297 | memcpy(pHddStaCtx->gtkOffloadReqParams.aKCK, data->kck, |
| 14298 | NL80211_KCK_LEN); |
| 14299 | memcpy(pHddStaCtx->gtkOffloadReqParams.aKEK, data->kek, |
| 14300 | NL80211_KEK_LEN); |
Anurag Chouhan | c554842 | 2016-02-24 18:33:27 +0530 | [diff] [blame] | 14301 | qdf_copy_macaddr(&pHddStaCtx->gtkOffloadReqParams.bssid, |
Srinivas Girigowda | 2213b1d | 2015-11-20 17:10:11 -0800 | [diff] [blame] | 14302 | &pHddStaCtx->conn_info.bssId); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14303 | { |
| 14304 | /* changing from big to little endian since driver |
| 14305 | * works on little endian format |
| 14306 | */ |
| 14307 | uint8_t *p = |
| 14308 | (uint8_t *) &pHddStaCtx->gtkOffloadReqParams. |
| 14309 | ullKeyReplayCounter; |
| 14310 | int i; |
| 14311 | |
| 14312 | for (i = 0; i < 8; i++) { |
| 14313 | p[7 - i] = data->replay_ctr[i]; |
| 14314 | } |
| 14315 | } |
| 14316 | |
| 14317 | if (true == pHddCtx->hdd_wlan_suspended) { |
| 14318 | /* if wlan is suspended, enable GTK offload directly from here */ |
| 14319 | memcpy(&hddGtkOffloadReqParams, |
| 14320 | &pHddStaCtx->gtkOffloadReqParams, |
| 14321 | sizeof(tSirGtkOffloadParams)); |
| 14322 | status = |
| 14323 | sme_set_gtk_offload(hHal, &hddGtkOffloadReqParams, |
| 14324 | pAdapter->sessionId); |
| 14325 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 14326 | if (QDF_STATUS_SUCCESS != status) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 14327 | hdd_err("sme_set_gtk_offload failed, status(%d)", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14328 | status); |
| 14329 | return -EINVAL; |
| 14330 | } |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 14331 | hdd_notice("sme_set_gtk_offload successful"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14332 | } else { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 14333 | hdd_notice("wlan not suspended GTKOffload request is stored"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14334 | } |
Hanumantha Reddy Pothula | 2db50ed | 2015-11-23 10:48:33 +0530 | [diff] [blame] | 14335 | EXIT(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14336 | return result; |
| 14337 | } |
| 14338 | |
| 14339 | /** |
| 14340 | * wlan_hdd_cfg80211_set_rekey_data() - set rekey data |
| 14341 | * @wiphy: Pointer to wiphy |
| 14342 | * @dev: Pointer to network device |
| 14343 | * @data: Pointer to rekey data |
| 14344 | * |
| 14345 | * This function is used to offload GTK rekeying job to the firmware. |
| 14346 | * |
| 14347 | * Return: 0 for success, non-zero for failure |
| 14348 | */ |
Jeff Johnson | 8b8a04b | 2016-10-05 15:49:43 -0700 | [diff] [blame] | 14349 | static |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14350 | int wlan_hdd_cfg80211_set_rekey_data(struct wiphy *wiphy, |
| 14351 | struct net_device *dev, |
| 14352 | struct cfg80211_gtk_rekey_data *data) |
| 14353 | { |
| 14354 | int ret; |
| 14355 | |
| 14356 | cds_ssr_protect(__func__); |
| 14357 | ret = __wlan_hdd_cfg80211_set_rekey_data(wiphy, dev, data); |
| 14358 | cds_ssr_unprotect(__func__); |
| 14359 | |
| 14360 | return ret; |
| 14361 | } |
| 14362 | #endif /*WLAN_FEATURE_GTK_OFFLOAD */ |
| 14363 | |
| 14364 | /** |
| 14365 | * __wlan_hdd_cfg80211_set_mac_acl() - set access control policy |
| 14366 | * @wiphy: Pointer to wiphy |
| 14367 | * @dev: Pointer to network device |
| 14368 | * @param: Pointer to access control parameter |
| 14369 | * |
| 14370 | * Return: 0 for success, non-zero for failure |
| 14371 | */ |
| 14372 | static int __wlan_hdd_cfg80211_set_mac_acl(struct wiphy *wiphy, |
| 14373 | struct net_device *dev, |
| 14374 | const struct cfg80211_acl_data *params) |
| 14375 | { |
| 14376 | int i; |
| 14377 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 14378 | hdd_hostapd_state_t *pHostapdState; |
| 14379 | tsap_Config_t *pConfig; |
| 14380 | v_CONTEXT_t p_cds_context = NULL; |
| 14381 | hdd_context_t *pHddCtx; |
| 14382 | int status; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 14383 | QDF_STATUS qdf_status = QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14384 | |
| 14385 | ENTER(); |
| 14386 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 14387 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 14388 | hdd_err("Command not allowed in FTM mode"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14389 | return -EINVAL; |
| 14390 | } |
| 14391 | |
| 14392 | if (NULL == params) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 14393 | hdd_err("params is Null"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14394 | return -EINVAL; |
| 14395 | } |
| 14396 | |
| 14397 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 14398 | status = wlan_hdd_validate_context(pHddCtx); |
| 14399 | |
Hanumantha Reddy Pothula | 2db50ed | 2015-11-23 10:48:33 +0530 | [diff] [blame] | 14400 | if (0 != status) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14401 | return status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14402 | |
| 14403 | p_cds_context = pHddCtx->pcds_context; |
| 14404 | pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter); |
| 14405 | |
| 14406 | if (NULL == pHostapdState) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 14407 | hdd_err("pHostapdState is Null"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14408 | return -EINVAL; |
| 14409 | } |
| 14410 | |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 14411 | hdd_err("acl policy: = %d no acl entries = %d", params->acl_policy, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14412 | params->n_acl_entries); |
| 14413 | |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 14414 | MTRACE(qdf_trace(QDF_MODULE_ID_HDD, |
Sreelakshmi Konamki | 6744cff | 2015-09-07 12:10:39 +0530 | [diff] [blame] | 14415 | TRACE_CODE_HDD_CFG80211_SET_MAC_ACL, |
| 14416 | pAdapter->sessionId, pAdapter->device_mode)); |
Krunal Soni | b4326f2 | 2016-03-10 13:05:51 -0800 | [diff] [blame] | 14417 | if (QDF_SAP_MODE == pAdapter->device_mode) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14418 | pConfig = &pAdapter->sessionCtx.ap.sapConfig; |
| 14419 | |
| 14420 | /* default value */ |
| 14421 | pConfig->num_accept_mac = 0; |
| 14422 | pConfig->num_deny_mac = 0; |
| 14423 | |
| 14424 | /** |
| 14425 | * access control policy |
| 14426 | * @NL80211_ACL_POLICY_ACCEPT_UNLESS_LISTED: Deny stations which are |
| 14427 | * listed in hostapd.deny file. |
| 14428 | * @NL80211_ACL_POLICY_DENY_UNLESS_LISTED: Allow stations which are |
| 14429 | * listed in hostapd.accept file. |
| 14430 | */ |
| 14431 | if (NL80211_ACL_POLICY_DENY_UNLESS_LISTED == params->acl_policy) { |
| 14432 | pConfig->SapMacaddr_acl = eSAP_DENY_UNLESS_ACCEPTED; |
| 14433 | } else if (NL80211_ACL_POLICY_ACCEPT_UNLESS_LISTED == |
| 14434 | params->acl_policy) { |
| 14435 | pConfig->SapMacaddr_acl = eSAP_ACCEPT_UNLESS_DENIED; |
| 14436 | } else { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 14437 | hdd_err("Acl Policy : %d is not supported", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14438 | params->acl_policy); |
| 14439 | return -ENOTSUPP; |
| 14440 | } |
| 14441 | |
| 14442 | if (eSAP_DENY_UNLESS_ACCEPTED == pConfig->SapMacaddr_acl) { |
| 14443 | pConfig->num_accept_mac = params->n_acl_entries; |
| 14444 | for (i = 0; i < params->n_acl_entries; i++) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 14445 | hdd_notice("** Add ACL MAC entry %i in WhiletList :" |
| 14446 | MAC_ADDRESS_STR, i, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14447 | MAC_ADDR_ARRAY( |
| 14448 | params->mac_addrs[i].addr)); |
| 14449 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 14450 | qdf_mem_copy(&pConfig->accept_mac[i], |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14451 | params->mac_addrs[i].addr, |
| 14452 | sizeof(qcmacaddr)); |
| 14453 | } |
| 14454 | } else if (eSAP_ACCEPT_UNLESS_DENIED == pConfig->SapMacaddr_acl) { |
| 14455 | pConfig->num_deny_mac = params->n_acl_entries; |
| 14456 | for (i = 0; i < params->n_acl_entries; i++) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 14457 | hdd_notice("** Add ACL MAC entry %i in BlackList :" |
| 14458 | MAC_ADDRESS_STR, i, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14459 | MAC_ADDR_ARRAY( |
| 14460 | params->mac_addrs[i].addr)); |
| 14461 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 14462 | qdf_mem_copy(&pConfig->deny_mac[i], |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14463 | params->mac_addrs[i].addr, |
| 14464 | sizeof(qcmacaddr)); |
| 14465 | } |
| 14466 | } |
Dustin Brown | 6ba30a1 | 2016-09-13 13:59:43 -0700 | [diff] [blame] | 14467 | qdf_status = wlansap_set_mac_acl( |
| 14468 | WLAN_HDD_GET_SAP_CTX_PTR(pAdapter), pConfig); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 14469 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 14470 | hdd_err("SAP Set Mac Acl fail"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14471 | return -EINVAL; |
| 14472 | } |
| 14473 | } else { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 14474 | hdd_notice("Invalid device_mode %s(%d)", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14475 | hdd_device_mode_to_string(pAdapter->device_mode), |
| 14476 | pAdapter->device_mode); |
| 14477 | return -EINVAL; |
| 14478 | } |
Hanumantha Reddy Pothula | 2db50ed | 2015-11-23 10:48:33 +0530 | [diff] [blame] | 14479 | EXIT(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14480 | return 0; |
| 14481 | } |
| 14482 | |
| 14483 | /** |
| 14484 | * wlan_hdd_cfg80211_set_mac_acl() - SSR wrapper for |
| 14485 | * __wlan_hdd_cfg80211_set_mac_acl |
| 14486 | * @wiphy: pointer to wiphy structure |
| 14487 | * @dev: pointer to net_device |
| 14488 | * @params: pointer to cfg80211_acl_data |
| 14489 | * |
| 14490 | * Return; 0 on success, error number otherwise |
| 14491 | */ |
| 14492 | static int |
| 14493 | wlan_hdd_cfg80211_set_mac_acl(struct wiphy *wiphy, |
| 14494 | struct net_device *dev, |
| 14495 | const struct cfg80211_acl_data *params) |
| 14496 | { |
| 14497 | int ret; |
| 14498 | |
| 14499 | cds_ssr_protect(__func__); |
| 14500 | ret = __wlan_hdd_cfg80211_set_mac_acl(wiphy, dev, params); |
| 14501 | cds_ssr_unprotect(__func__); |
| 14502 | |
| 14503 | return ret; |
| 14504 | } |
| 14505 | |
| 14506 | #ifdef WLAN_NL80211_TESTMODE |
| 14507 | #ifdef FEATURE_WLAN_LPHB |
| 14508 | /** |
| 14509 | * wlan_hdd_cfg80211_lphb_ind_handler() - handle low power heart beat indication |
| 14510 | * @pHddCtx: Pointer to hdd context |
| 14511 | * @lphbInd: Pointer to low power heart beat indication parameter |
| 14512 | * |
| 14513 | * Return: none |
| 14514 | */ |
Jeff Johnson | 8b8a04b | 2016-10-05 15:49:43 -0700 | [diff] [blame] | 14515 | static void wlan_hdd_cfg80211_lphb_ind_handler(void *pHddCtx, |
| 14516 | tSirLPHBInd *lphbInd) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14517 | { |
| 14518 | struct sk_buff *skb; |
| 14519 | |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 14520 | hdd_err("LPHB indication arrived"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14521 | |
Hanumantha Reddy Pothula | 2db50ed | 2015-11-23 10:48:33 +0530 | [diff] [blame] | 14522 | if (0 != wlan_hdd_validate_context((hdd_context_t *) pHddCtx)) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14523 | return; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14524 | |
| 14525 | if (NULL == lphbInd) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 14526 | hdd_err("invalid argument lphbInd"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14527 | return; |
| 14528 | } |
| 14529 | |
| 14530 | skb = cfg80211_testmode_alloc_event_skb(((hdd_context_t *) pHddCtx)-> |
| 14531 | wiphy, sizeof(tSirLPHBInd), |
| 14532 | GFP_ATOMIC); |
| 14533 | if (!skb) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 14534 | hdd_err("LPHB timeout, NL buffer alloc fail"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14535 | return; |
| 14536 | } |
| 14537 | |
| 14538 | 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] | 14539 | hdd_err("WLAN_HDD_TM_ATTR_CMD put fail"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14540 | goto nla_put_failure; |
| 14541 | } |
| 14542 | if (nla_put_u32(skb, WLAN_HDD_TM_ATTR_TYPE, lphbInd->protocolType)) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 14543 | hdd_err("WLAN_HDD_TM_ATTR_TYPE put fail"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14544 | goto nla_put_failure; |
| 14545 | } |
| 14546 | if (nla_put(skb, WLAN_HDD_TM_ATTR_DATA, sizeof(tSirLPHBInd), lphbInd)) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 14547 | hdd_err("WLAN_HDD_TM_ATTR_DATA put fail"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14548 | goto nla_put_failure; |
| 14549 | } |
| 14550 | cfg80211_testmode_event(skb, GFP_ATOMIC); |
| 14551 | return; |
| 14552 | |
| 14553 | nla_put_failure: |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 14554 | hdd_err("NLA Put fail"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14555 | kfree_skb(skb); |
| 14556 | |
| 14557 | return; |
| 14558 | } |
| 14559 | #endif /* FEATURE_WLAN_LPHB */ |
| 14560 | |
| 14561 | /** |
| 14562 | * __wlan_hdd_cfg80211_testmode() - test mode |
| 14563 | * @wiphy: Pointer to wiphy |
| 14564 | * @data: Data pointer |
| 14565 | * @len: Data length |
| 14566 | * |
| 14567 | * Return: 0 for success, non-zero for failure |
| 14568 | */ |
| 14569 | static int __wlan_hdd_cfg80211_testmode(struct wiphy *wiphy, |
| 14570 | void *data, int len) |
| 14571 | { |
| 14572 | struct nlattr *tb[WLAN_HDD_TM_ATTR_MAX + 1]; |
| 14573 | int err; |
| 14574 | hdd_context_t *pHddCtx = wiphy_priv(wiphy); |
| 14575 | |
Hanumantha Reddy Pothula | 2db50ed | 2015-11-23 10:48:33 +0530 | [diff] [blame] | 14576 | ENTER(); |
| 14577 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14578 | err = wlan_hdd_validate_context(pHddCtx); |
| 14579 | if (err) |
| 14580 | return err; |
| 14581 | |
| 14582 | err = nla_parse(tb, WLAN_HDD_TM_ATTR_MAX, data, |
| 14583 | len, wlan_hdd_tm_policy); |
| 14584 | if (err) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 14585 | hdd_err("Testmode INV ATTR"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14586 | return err; |
| 14587 | } |
| 14588 | |
| 14589 | if (!tb[WLAN_HDD_TM_ATTR_CMD]) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 14590 | hdd_err("Testmode INV CMD"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14591 | return -EINVAL; |
| 14592 | } |
| 14593 | |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 14594 | MTRACE(qdf_trace(QDF_MODULE_ID_HDD, |
Sreelakshmi Konamki | 6744cff | 2015-09-07 12:10:39 +0530 | [diff] [blame] | 14595 | TRACE_CODE_HDD_CFG80211_TESTMODE, |
| 14596 | NO_SESSION, nla_get_u32(tb[WLAN_HDD_TM_ATTR_CMD]))); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14597 | switch (nla_get_u32(tb[WLAN_HDD_TM_ATTR_CMD])) { |
| 14598 | #ifdef FEATURE_WLAN_LPHB |
| 14599 | /* Low Power Heartbeat configuration request */ |
| 14600 | case WLAN_HDD_TM_CMD_WLAN_HB: |
| 14601 | { |
| 14602 | int buf_len; |
| 14603 | void *buf; |
| 14604 | tSirLPHBReq *hb_params = NULL; |
| 14605 | tSirLPHBReq *hb_params_temp = NULL; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 14606 | QDF_STATUS smeStatus; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14607 | |
| 14608 | if (!tb[WLAN_HDD_TM_ATTR_DATA]) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 14609 | hdd_err("Testmode INV DATA"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14610 | return -EINVAL; |
| 14611 | } |
| 14612 | |
| 14613 | buf = nla_data(tb[WLAN_HDD_TM_ATTR_DATA]); |
| 14614 | buf_len = nla_len(tb[WLAN_HDD_TM_ATTR_DATA]); |
| 14615 | |
| 14616 | hb_params_temp = (tSirLPHBReq *) buf; |
| 14617 | if ((hb_params_temp->cmd == LPHB_SET_TCP_PARAMS_INDID) |
| 14618 | && (hb_params_temp->params.lphbTcpParamReq. |
| 14619 | timePeriodSec == 0)) |
| 14620 | return -EINVAL; |
| 14621 | |
| 14622 | hb_params = |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 14623 | (tSirLPHBReq *) qdf_mem_malloc(sizeof(tSirLPHBReq)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14624 | if (NULL == hb_params) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 14625 | hdd_err("Request Buffer Alloc Fail"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14626 | return -ENOMEM; |
| 14627 | } |
| 14628 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 14629 | qdf_mem_copy(hb_params, buf, buf_len); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14630 | smeStatus = |
| 14631 | sme_lphb_config_req((tHalHandle) (pHddCtx->hHal), |
| 14632 | hb_params, |
| 14633 | wlan_hdd_cfg80211_lphb_ind_handler); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 14634 | if (QDF_STATUS_SUCCESS != smeStatus) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 14635 | hdd_err("LPHB Config Fail, disable"); |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 14636 | qdf_mem_free(hb_params); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14637 | } |
| 14638 | return 0; |
| 14639 | } |
| 14640 | #endif /* FEATURE_WLAN_LPHB */ |
| 14641 | |
| 14642 | #if defined(QCA_WIFI_FTM) |
| 14643 | case WLAN_HDD_TM_CMD_WLAN_FTM: |
| 14644 | { |
| 14645 | int buf_len; |
| 14646 | void *buf; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 14647 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14648 | if (!tb[WLAN_HDD_TM_ATTR_DATA]) { |
Ryan Hsu | cfef0ae | 2016-04-28 10:20:46 -0700 | [diff] [blame] | 14649 | hdd_err("WLAN_HDD_TM_ATTR_DATA attribute is invalid"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14650 | return -EINVAL; |
| 14651 | } |
| 14652 | |
| 14653 | buf = nla_data(tb[WLAN_HDD_TM_ATTR_DATA]); |
| 14654 | buf_len = nla_len(tb[WLAN_HDD_TM_ATTR_DATA]); |
| 14655 | |
Ryan Hsu | cfef0ae | 2016-04-28 10:20:46 -0700 | [diff] [blame] | 14656 | hdd_info("****FTM Tx cmd len = %d*****", buf_len); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14657 | |
| 14658 | status = wlan_hdd_ftm_testmode_cmd(buf, buf_len); |
| 14659 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 14660 | if (status != QDF_STATUS_SUCCESS) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14661 | err = -EBUSY; |
| 14662 | break; |
| 14663 | } |
| 14664 | #endif |
| 14665 | |
| 14666 | default: |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 14667 | hdd_err("command %d not supported", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14668 | nla_get_u32(tb[WLAN_HDD_TM_ATTR_CMD])); |
| 14669 | return -EOPNOTSUPP; |
| 14670 | } |
Hanumantha Reddy Pothula | 2db50ed | 2015-11-23 10:48:33 +0530 | [diff] [blame] | 14671 | EXIT(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14672 | return err; |
| 14673 | } |
| 14674 | |
| 14675 | /** |
| 14676 | * wlan_hdd_cfg80211_testmode() - test mode |
| 14677 | * @wiphy: Pointer to wiphy |
| 14678 | * @dev: Pointer to network device |
| 14679 | * @data: Data pointer |
| 14680 | * @len: Data length |
| 14681 | * |
| 14682 | * Return: 0 for success, non-zero for failure |
| 14683 | */ |
| 14684 | static int wlan_hdd_cfg80211_testmode(struct wiphy *wiphy, |
| 14685 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 12, 0)) |
| 14686 | struct wireless_dev *wdev, |
| 14687 | #endif |
| 14688 | void *data, int len) |
| 14689 | { |
| 14690 | int ret; |
| 14691 | |
| 14692 | cds_ssr_protect(__func__); |
| 14693 | ret = __wlan_hdd_cfg80211_testmode(wiphy, data, len); |
| 14694 | cds_ssr_unprotect(__func__); |
| 14695 | |
| 14696 | return ret; |
| 14697 | } |
| 14698 | |
| 14699 | #if defined(QCA_WIFI_FTM) |
| 14700 | /** |
| 14701 | * wlan_hdd_testmode_rx_event() - test mode rx event handler |
| 14702 | * @buf: Pointer to buffer |
| 14703 | * @buf_len: Buffer length |
| 14704 | * |
| 14705 | * Return: none |
| 14706 | */ |
| 14707 | void wlan_hdd_testmode_rx_event(void *buf, size_t buf_len) |
| 14708 | { |
| 14709 | struct sk_buff *skb; |
| 14710 | hdd_context_t *hdd_ctx; |
| 14711 | |
| 14712 | if (!buf || !buf_len) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 14713 | 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] | 14714 | return; |
| 14715 | } |
| 14716 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 14717 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14718 | if (!hdd_ctx) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 14719 | hdd_err("hdd context invalid"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14720 | return; |
| 14721 | } |
| 14722 | |
| 14723 | skb = cfg80211_testmode_alloc_event_skb(hdd_ctx->wiphy, |
| 14724 | buf_len, GFP_KERNEL); |
| 14725 | if (!skb) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 14726 | hdd_err("failed to allocate testmode rx skb!"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14727 | return; |
| 14728 | } |
| 14729 | |
| 14730 | if (nla_put_u32(skb, WLAN_HDD_TM_ATTR_CMD, WLAN_HDD_TM_CMD_WLAN_FTM) || |
| 14731 | nla_put(skb, WLAN_HDD_TM_ATTR_DATA, buf_len, buf)) |
| 14732 | goto nla_put_failure; |
| 14733 | |
Ryan Hsu | cfef0ae | 2016-04-28 10:20:46 -0700 | [diff] [blame] | 14734 | hdd_info("****FTM Rx cmd len = %zu*****", buf_len); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14735 | |
| 14736 | cfg80211_testmode_event(skb, GFP_KERNEL); |
| 14737 | return; |
| 14738 | |
| 14739 | nla_put_failure: |
| 14740 | kfree_skb(skb); |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 14741 | hdd_err("nla_put failed on testmode rx skb!"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14742 | } |
| 14743 | #endif |
| 14744 | #endif /* CONFIG_NL80211_TESTMODE */ |
| 14745 | |
| 14746 | #ifdef QCA_HT_2040_COEX |
| 14747 | /** |
| 14748 | * __wlan_hdd_cfg80211_set_ap_channel_width() - set ap channel bandwidth |
| 14749 | * @wiphy: Pointer to wiphy |
| 14750 | * @dev: Pointer to network device |
| 14751 | * @chandef: Pointer to channel definition parameter |
| 14752 | * |
| 14753 | * Return: 0 for success, non-zero for failure |
| 14754 | */ |
| 14755 | static int |
| 14756 | __wlan_hdd_cfg80211_set_ap_channel_width(struct wiphy *wiphy, |
| 14757 | struct net_device *dev, |
| 14758 | struct cfg80211_chan_def *chandef) |
| 14759 | { |
| 14760 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 14761 | hdd_context_t *pHddCtx; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 14762 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14763 | tSmeConfigParams sme_config; |
Anurag Chouhan | 00ed527 | 2016-10-17 17:22:55 +0530 | [diff] [blame] | 14764 | bool cbModeChange = false; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14765 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 14766 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 14767 | hdd_err("Command not allowed in FTM mode"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14768 | return -EINVAL; |
| 14769 | } |
| 14770 | |
Hanumanth Reddy Pothula | d9491f4 | 2016-10-24 19:08:38 +0530 | [diff] [blame] | 14771 | if (wlan_hdd_validate_session_id(pAdapter->sessionId)) { |
| 14772 | hdd_err("invalid session id: %d", pAdapter->sessionId); |
| 14773 | return -EINVAL; |
| 14774 | } |
| 14775 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14776 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 14777 | status = wlan_hdd_validate_context(pHddCtx); |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 14778 | if (status) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14779 | return status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14780 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 14781 | qdf_mem_zero(&sme_config, sizeof(tSmeConfigParams)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14782 | sme_get_config_param(pHddCtx->hHal, &sme_config); |
| 14783 | switch (chandef->width) { |
| 14784 | case NL80211_CHAN_WIDTH_20: |
| 14785 | if (sme_config.csrConfig.channelBondingMode24GHz != |
| 14786 | eCSR_INI_SINGLE_CHANNEL_CENTERED) { |
| 14787 | sme_config.csrConfig.channelBondingMode24GHz = |
| 14788 | eCSR_INI_SINGLE_CHANNEL_CENTERED; |
| 14789 | sme_update_config(pHddCtx->hHal, &sme_config); |
| 14790 | cbModeChange = true; |
| 14791 | } |
| 14792 | break; |
| 14793 | |
| 14794 | case NL80211_CHAN_WIDTH_40: |
| 14795 | if (sme_config.csrConfig.channelBondingMode24GHz == |
| 14796 | eCSR_INI_SINGLE_CHANNEL_CENTERED) { |
| 14797 | if (NL80211_CHAN_HT40MINUS == |
| 14798 | cfg80211_get_chandef_type(chandef)) |
| 14799 | sme_config.csrConfig.channelBondingMode24GHz = |
| 14800 | eCSR_INI_DOUBLE_CHANNEL_HIGH_PRIMARY; |
| 14801 | else |
| 14802 | sme_config.csrConfig.channelBondingMode24GHz = |
| 14803 | eCSR_INI_DOUBLE_CHANNEL_LOW_PRIMARY; |
| 14804 | sme_update_config(pHddCtx->hHal, &sme_config); |
| 14805 | cbModeChange = true; |
| 14806 | } |
| 14807 | break; |
| 14808 | |
| 14809 | default: |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 14810 | hdd_err("Error!!! Invalid HT20/40 mode !"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14811 | return -EINVAL; |
| 14812 | } |
| 14813 | |
| 14814 | if (!cbModeChange) |
| 14815 | return 0; |
| 14816 | |
Krunal Soni | b4326f2 | 2016-03-10 13:05:51 -0800 | [diff] [blame] | 14817 | if (QDF_SAP_MODE != pAdapter->device_mode) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14818 | return 0; |
| 14819 | |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 14820 | hdd_notice("Channel bonding changed to %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14821 | sme_config.csrConfig.channelBondingMode24GHz); |
| 14822 | |
| 14823 | /* Change SAP ht2040 mode */ |
| 14824 | status = hdd_set_sap_ht2040_mode(pAdapter, |
| 14825 | cfg80211_get_chandef_type(chandef)); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 14826 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 14827 | hdd_err("Error!!! Cannot set SAP HT20/40 mode!"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14828 | return -EINVAL; |
| 14829 | } |
| 14830 | |
| 14831 | return 0; |
| 14832 | } |
| 14833 | |
| 14834 | /** |
| 14835 | * wlan_hdd_cfg80211_set_ap_channel_width() - set ap channel bandwidth |
| 14836 | * @wiphy: Pointer to wiphy |
| 14837 | * @dev: Pointer to network device |
| 14838 | * @chandef: Pointer to channel definition parameter |
| 14839 | * |
| 14840 | * Return: 0 for success, non-zero for failure |
| 14841 | */ |
| 14842 | static int |
| 14843 | wlan_hdd_cfg80211_set_ap_channel_width(struct wiphy *wiphy, |
| 14844 | struct net_device *dev, |
| 14845 | struct cfg80211_chan_def *chandef) |
| 14846 | { |
| 14847 | int ret; |
| 14848 | |
| 14849 | cds_ssr_protect(__func__); |
| 14850 | ret = __wlan_hdd_cfg80211_set_ap_channel_width(wiphy, dev, chandef); |
| 14851 | cds_ssr_unprotect(__func__); |
| 14852 | |
| 14853 | return ret; |
| 14854 | } |
| 14855 | #endif |
| 14856 | |
Abhishek Singh | 1bdb157 | 2015-10-16 16:24:19 +0530 | [diff] [blame] | 14857 | #ifdef CHANNEL_SWITCH_SUPPORTED |
| 14858 | /** |
| 14859 | * __wlan_hdd_cfg80211_channel_switch()- function to switch |
| 14860 | * channel in SAP/GO |
| 14861 | * @wiphy: wiphy pointer |
| 14862 | * @dev: dev pointer. |
| 14863 | * @csa_params: Change channel params |
| 14864 | * |
| 14865 | * This function is called to switch channel in SAP/GO |
| 14866 | * |
| 14867 | * Return: 0 if success else return non zero |
| 14868 | */ |
| 14869 | static int __wlan_hdd_cfg80211_channel_switch(struct wiphy *wiphy, |
| 14870 | struct net_device *dev, |
| 14871 | struct cfg80211_csa_settings *csa_params) |
| 14872 | { |
| 14873 | hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 14874 | hdd_context_t *hdd_ctx; |
| 14875 | uint8_t channel; |
| 14876 | uint16_t freq; |
| 14877 | int ret; |
Kiran Kumar Lokere | 1364467 | 2016-02-29 15:40:10 -0800 | [diff] [blame] | 14878 | enum phy_ch_width ch_width; |
Abhishek Singh | 1bdb157 | 2015-10-16 16:24:19 +0530 | [diff] [blame] | 14879 | |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 14880 | hdd_notice("Set Freq %d", |
Abhishek Singh | 1bdb157 | 2015-10-16 16:24:19 +0530 | [diff] [blame] | 14881 | csa_params->chandef.chan->center_freq); |
| 14882 | |
Hanumanth Reddy Pothula | d9491f4 | 2016-10-24 19:08:38 +0530 | [diff] [blame] | 14883 | if (wlan_hdd_validate_session_id(adapter->sessionId)) { |
| 14884 | hdd_err("invalid session id: %d", adapter->sessionId); |
| 14885 | return -EINVAL; |
| 14886 | } |
| 14887 | |
Abhishek Singh | 1bdb157 | 2015-10-16 16:24:19 +0530 | [diff] [blame] | 14888 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 14889 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 14890 | |
| 14891 | if (0 != ret) |
| 14892 | return ret; |
| 14893 | |
Krunal Soni | b4326f2 | 2016-03-10 13:05:51 -0800 | [diff] [blame] | 14894 | if ((QDF_P2P_GO_MODE != adapter->device_mode) && |
| 14895 | (QDF_SAP_MODE != adapter->device_mode)) |
Abhishek Singh | 1bdb157 | 2015-10-16 16:24:19 +0530 | [diff] [blame] | 14896 | return -ENOTSUPP; |
| 14897 | |
| 14898 | freq = csa_params->chandef.chan->center_freq; |
| 14899 | channel = cds_freq_to_chan(freq); |
| 14900 | |
Chandrasekaran, Manishekar | a74bb02 | 2016-01-12 18:37:43 +0530 | [diff] [blame] | 14901 | ch_width = hdd_map_nl_chan_width(csa_params->chandef.width); |
| 14902 | |
| 14903 | ret = hdd_softap_set_channel_change(dev, channel, ch_width); |
Abhishek Singh | 1bdb157 | 2015-10-16 16:24:19 +0530 | [diff] [blame] | 14904 | return ret; |
| 14905 | } |
| 14906 | |
| 14907 | /** |
| 14908 | * wlan_hdd_cfg80211_channel_switch()- function to switch |
| 14909 | * channel in SAP/GO |
| 14910 | * @wiphy: wiphy pointer |
| 14911 | * @dev: dev pointer. |
| 14912 | * @csa_params: Change channel params |
| 14913 | * |
| 14914 | * This function is called to switch channel in SAP/GO |
| 14915 | * |
| 14916 | * Return: 0 if success else return non zero |
| 14917 | */ |
| 14918 | static int wlan_hdd_cfg80211_channel_switch(struct wiphy *wiphy, |
| 14919 | struct net_device *dev, |
| 14920 | struct cfg80211_csa_settings *csa_params) |
| 14921 | { |
| 14922 | int ret; |
| 14923 | |
| 14924 | cds_ssr_protect(__func__); |
| 14925 | ret = __wlan_hdd_cfg80211_channel_switch(wiphy, dev, csa_params); |
| 14926 | cds_ssr_unprotect(__func__); |
| 14927 | return ret; |
| 14928 | } |
| 14929 | #endif |
| 14930 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14931 | /** |
| 14932 | * wlan_hdd_convert_nl_iftype_to_hdd_type() - provides the type |
| 14933 | * translation from NL to policy manager type |
| 14934 | * @type: Generic connection mode type defined in NL |
| 14935 | * |
| 14936 | * |
| 14937 | * This function provides the type translation |
| 14938 | * |
| 14939 | * Return: cds_con_mode enum |
| 14940 | */ |
| 14941 | enum cds_con_mode wlan_hdd_convert_nl_iftype_to_hdd_type( |
| 14942 | enum nl80211_iftype type) |
| 14943 | { |
| 14944 | enum cds_con_mode mode = CDS_MAX_NUM_OF_MODE; |
| 14945 | switch (type) { |
| 14946 | case NL80211_IFTYPE_STATION: |
| 14947 | mode = CDS_STA_MODE; |
| 14948 | break; |
| 14949 | case NL80211_IFTYPE_P2P_CLIENT: |
| 14950 | mode = CDS_P2P_CLIENT_MODE; |
| 14951 | break; |
| 14952 | case NL80211_IFTYPE_P2P_GO: |
| 14953 | mode = CDS_P2P_GO_MODE; |
| 14954 | break; |
| 14955 | case NL80211_IFTYPE_AP: |
| 14956 | mode = CDS_SAP_MODE; |
| 14957 | break; |
| 14958 | case NL80211_IFTYPE_ADHOC: |
| 14959 | mode = CDS_IBSS_MODE; |
| 14960 | break; |
| 14961 | default: |
Jeff Johnson | 3d8ac55 | 2016-06-29 15:21:37 -0700 | [diff] [blame] | 14962 | hdd_err("Unsupported interface type (%d)", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14963 | type); |
| 14964 | } |
| 14965 | return mode; |
| 14966 | } |
| 14967 | |
| 14968 | /** |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 14969 | * wlan_hdd_cfg80211_set_mon_ch() - Set monitor mode capture channel |
| 14970 | * @wiphy: Handle to struct wiphy to get handle to module context. |
| 14971 | * @chandef: Contains information about the capture channel to be set. |
| 14972 | * |
| 14973 | * This interface is called if and only if monitor mode interface alone is |
| 14974 | * active. |
| 14975 | * |
| 14976 | * Return: 0 success or error code on failure. |
| 14977 | */ |
| 14978 | static int __wlan_hdd_cfg80211_set_mon_ch(struct wiphy *wiphy, |
| 14979 | struct cfg80211_chan_def *chandef) |
| 14980 | { |
| 14981 | hdd_context_t *hdd_ctx = wiphy_priv(wiphy); |
| 14982 | hdd_adapter_t *adapter; |
| 14983 | hdd_station_ctx_t *sta_ctx; |
| 14984 | struct hdd_mon_set_ch_info *ch_info; |
| 14985 | QDF_STATUS status; |
| 14986 | tHalHandle hal_hdl; |
| 14987 | struct qdf_mac_addr bssid; |
| 14988 | tCsrRoamProfile roam_profile; |
| 14989 | struct ch_params_s ch_params; |
Sandeep Puligilla | 1cc23f6 | 2016-04-27 16:52:49 -0700 | [diff] [blame] | 14990 | uint8_t sec_ch = 0; |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 14991 | int ret; |
| 14992 | uint16_t chan_num = cds_freq_to_chan(chandef->chan->center_freq); |
| 14993 | |
| 14994 | ENTER(); |
| 14995 | |
| 14996 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 14997 | if (ret) |
| 14998 | return ret; |
| 14999 | |
| 15000 | hal_hdl = hdd_ctx->hHal; |
| 15001 | |
| 15002 | adapter = hdd_get_adapter(hdd_ctx, QDF_MONITOR_MODE); |
| 15003 | if (!adapter) |
| 15004 | return -EIO; |
| 15005 | |
| 15006 | hdd_info("%s: set monitor mode Channel %d and freq %d", |
| 15007 | adapter->dev->name, chan_num, chandef->chan->center_freq); |
| 15008 | |
| 15009 | sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
| 15010 | ch_info = &sta_ctx->ch_info; |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 15011 | roam_profile.ChannelInfo.ChannelList = &ch_info->channel; |
| 15012 | roam_profile.ChannelInfo.numOfChannels = 1; |
| 15013 | roam_profile.phyMode = ch_info->phy_mode; |
| 15014 | roam_profile.ch_params.ch_width = chandef->width; |
Naveen Rawat | c77e6e7 | 2016-08-05 15:19:03 -0700 | [diff] [blame] | 15015 | hdd_select_cbmode(adapter, chan_num, &roam_profile.ch_params); |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 15016 | |
| 15017 | qdf_mem_copy(bssid.bytes, adapter->macAddressCurrent.bytes, |
| 15018 | QDF_MAC_ADDR_SIZE); |
| 15019 | |
| 15020 | ch_params.ch_width = chandef->width; |
Sandeep Puligilla | 1cc23f6 | 2016-04-27 16:52:49 -0700 | [diff] [blame] | 15021 | /* |
| 15022 | * CDS api expects secondary channel for calculating |
| 15023 | * the channel params |
| 15024 | */ |
| 15025 | if ((ch_params.ch_width == CH_WIDTH_40MHZ) && |
| 15026 | (CDS_IS_CHANNEL_24GHZ(chan_num))) { |
| 15027 | if (chan_num >= 1 && chan_num <= 5) |
| 15028 | sec_ch = chan_num + 4; |
| 15029 | else if (chan_num >= 6 && chan_num <= 13) |
| 15030 | sec_ch = chan_num - 4; |
| 15031 | } |
| 15032 | cds_set_channel_params(chan_num, sec_ch, &ch_params); |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 15033 | status = sme_roam_channel_change_req(hal_hdl, bssid, &ch_params, |
| 15034 | &roam_profile); |
| 15035 | if (status) { |
| 15036 | hdd_err("Status: %d Failed to set sme_RoamChannel for monitor mode", |
| 15037 | status); |
| 15038 | ret = qdf_status_to_os_return(status); |
| 15039 | return ret; |
| 15040 | } |
| 15041 | EXIT(); |
| 15042 | return 0; |
| 15043 | } |
| 15044 | |
| 15045 | /** |
| 15046 | * wlan_hdd_cfg80211_set_mon_ch() - Set monitor mode capture channel |
| 15047 | * @wiphy: Handle to struct wiphy to get handle to module context. |
| 15048 | * @chandef: Contains information about the capture channel to be set. |
| 15049 | * |
| 15050 | * This interface is called if and only if monitor mode interface alone is |
| 15051 | * active. |
| 15052 | * |
| 15053 | * Return: 0 success or error code on failure. |
| 15054 | */ |
| 15055 | static int wlan_hdd_cfg80211_set_mon_ch(struct wiphy *wiphy, |
| 15056 | struct cfg80211_chan_def *chandef) |
| 15057 | { |
| 15058 | int ret; |
| 15059 | |
| 15060 | cds_ssr_protect(__func__); |
| 15061 | ret = __wlan_hdd_cfg80211_set_mon_ch(wiphy, chandef); |
| 15062 | cds_ssr_unprotect(__func__); |
| 15063 | return ret; |
| 15064 | } |
| 15065 | |
| 15066 | /** |
Mahesh A Saptasagar | 6dda202 | 2016-09-03 12:59:09 +0530 | [diff] [blame] | 15067 | * wlan_hdd_clear_link_layer_stats() - clear link layer stats |
| 15068 | * @adapter: pointer to adapter |
| 15069 | * |
| 15070 | * Wrapper function to clear link layer stats. |
| 15071 | * return - void |
| 15072 | */ |
| 15073 | void wlan_hdd_clear_link_layer_stats(hdd_adapter_t *adapter) |
| 15074 | { |
| 15075 | tSirLLStatsClearReq link_layer_stats_clear_req; |
| 15076 | tHalHandle hal = WLAN_HDD_GET_HAL_CTX(adapter); |
| 15077 | |
Mukul Sharma | 491021c | 2016-09-29 21:39:19 +0530 | [diff] [blame] | 15078 | link_layer_stats_clear_req.statsClearReqMask = WIFI_STATS_IFACE_AC | |
| 15079 | WIFI_STATS_IFACE_ALL_PEER; |
Mahesh A Saptasagar | 6dda202 | 2016-09-03 12:59:09 +0530 | [diff] [blame] | 15080 | link_layer_stats_clear_req.stopReq = 0; |
| 15081 | link_layer_stats_clear_req.reqId = 1; |
| 15082 | link_layer_stats_clear_req.staId = adapter->sessionId; |
| 15083 | sme_ll_stats_clear_req(hal, &link_layer_stats_clear_req); |
| 15084 | |
| 15085 | return; |
| 15086 | } |
| 15087 | |
| 15088 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15089 | * struct cfg80211_ops - cfg80211_ops |
| 15090 | * |
| 15091 | * @add_virtual_intf: Add virtual interface |
| 15092 | * @del_virtual_intf: Delete virtual interface |
| 15093 | * @change_virtual_intf: Change virtual interface |
| 15094 | * @change_station: Change station |
| 15095 | * @add_beacon: Add beacon in sap mode |
| 15096 | * @del_beacon: Delete beacon in sap mode |
| 15097 | * @set_beacon: Set beacon in sap mode |
| 15098 | * @start_ap: Start ap |
| 15099 | * @change_beacon: Change beacon |
| 15100 | * @stop_ap: Stop ap |
| 15101 | * @change_bss: Change bss |
| 15102 | * @add_key: Add key |
| 15103 | * @get_key: Get key |
| 15104 | * @del_key: Delete key |
| 15105 | * @set_default_key: Set default key |
| 15106 | * @set_channel: Set channel |
| 15107 | * @scan: Scan |
| 15108 | * @connect: Connect |
| 15109 | * @disconnect: Disconnect |
| 15110 | * @join_ibss = Join ibss |
| 15111 | * @leave_ibss = Leave ibss |
| 15112 | * @set_wiphy_params = Set wiphy params |
| 15113 | * @set_tx_power = Set tx power |
| 15114 | * @get_tx_power = get tx power |
| 15115 | * @remain_on_channel = Remain on channel |
| 15116 | * @cancel_remain_on_channel = Cancel remain on channel |
| 15117 | * @mgmt_tx = Tx management frame |
| 15118 | * @mgmt_tx_cancel_wait = Cancel management tx wait |
| 15119 | * @set_default_mgmt_key = Set default management key |
| 15120 | * @set_txq_params = Set tx queue parameters |
| 15121 | * @get_station = Get station |
| 15122 | * @set_power_mgmt = Set power management |
| 15123 | * @del_station = Delete station |
| 15124 | * @add_station = Add station |
| 15125 | * @set_pmksa = Set pmksa |
| 15126 | * @del_pmksa = Delete pmksa |
| 15127 | * @flush_pmksa = Flush pmksa |
| 15128 | * @update_ft_ies = Update FT IEs |
| 15129 | * @tdls_mgmt = Tdls management |
| 15130 | * @tdls_oper = Tdls operation |
| 15131 | * @set_rekey_data = Set rekey data |
| 15132 | * @sched_scan_start = Scheduled scan start |
| 15133 | * @sched_scan_stop = Scheduled scan stop |
| 15134 | * @resume = Resume wlan |
| 15135 | * @suspend = Suspend wlan |
| 15136 | * @set_mac_acl = Set mac acl |
| 15137 | * @testmode_cmd = Test mode command |
| 15138 | * @set_ap_chanwidth = Set AP channel bandwidth |
| 15139 | * @dump_survey = Dump survey |
| 15140 | * @key_mgmt_set_pmk = Set pmk key management |
| 15141 | */ |
| 15142 | static struct cfg80211_ops wlan_hdd_cfg80211_ops = { |
| 15143 | .add_virtual_intf = wlan_hdd_add_virtual_intf, |
| 15144 | .del_virtual_intf = wlan_hdd_del_virtual_intf, |
| 15145 | .change_virtual_intf = wlan_hdd_cfg80211_change_iface, |
| 15146 | .change_station = wlan_hdd_change_station, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15147 | .start_ap = wlan_hdd_cfg80211_start_ap, |
| 15148 | .change_beacon = wlan_hdd_cfg80211_change_beacon, |
| 15149 | .stop_ap = wlan_hdd_cfg80211_stop_ap, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15150 | .change_bss = wlan_hdd_cfg80211_change_bss, |
| 15151 | .add_key = wlan_hdd_cfg80211_add_key, |
| 15152 | .get_key = wlan_hdd_cfg80211_get_key, |
| 15153 | .del_key = wlan_hdd_cfg80211_del_key, |
| 15154 | .set_default_key = wlan_hdd_cfg80211_set_default_key, |
| 15155 | .scan = wlan_hdd_cfg80211_scan, |
| 15156 | .connect = wlan_hdd_cfg80211_connect, |
| 15157 | .disconnect = wlan_hdd_cfg80211_disconnect, |
| 15158 | .join_ibss = wlan_hdd_cfg80211_join_ibss, |
| 15159 | .leave_ibss = wlan_hdd_cfg80211_leave_ibss, |
| 15160 | .set_wiphy_params = wlan_hdd_cfg80211_set_wiphy_params, |
| 15161 | .set_tx_power = wlan_hdd_cfg80211_set_txpower, |
| 15162 | .get_tx_power = wlan_hdd_cfg80211_get_txpower, |
| 15163 | .remain_on_channel = wlan_hdd_cfg80211_remain_on_channel, |
| 15164 | .cancel_remain_on_channel = wlan_hdd_cfg80211_cancel_remain_on_channel, |
| 15165 | .mgmt_tx = wlan_hdd_mgmt_tx, |
| 15166 | .mgmt_tx_cancel_wait = wlan_hdd_cfg80211_mgmt_tx_cancel_wait, |
| 15167 | .set_default_mgmt_key = wlan_hdd_set_default_mgmt_key, |
| 15168 | .set_txq_params = wlan_hdd_set_txq_params, |
Himanshu Agarwal | 37e4241 | 2016-07-21 14:35:09 +0530 | [diff] [blame] | 15169 | .dump_station = wlan_hdd_cfg80211_dump_station, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15170 | .get_station = wlan_hdd_cfg80211_get_station, |
| 15171 | .set_power_mgmt = wlan_hdd_cfg80211_set_power_mgmt, |
| 15172 | .del_station = wlan_hdd_cfg80211_del_station, |
| 15173 | .add_station = wlan_hdd_cfg80211_add_station, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15174 | .set_pmksa = wlan_hdd_cfg80211_set_pmksa, |
| 15175 | .del_pmksa = wlan_hdd_cfg80211_del_pmksa, |
| 15176 | .flush_pmksa = wlan_hdd_cfg80211_flush_pmksa, |
Deepak Dhamdhere | 9f09e75 | 2016-01-09 23:17:25 -0800 | [diff] [blame] | 15177 | #if defined(KERNEL_SUPPORT_11R_CFG80211) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15178 | .update_ft_ies = wlan_hdd_cfg80211_update_ft_ies, |
| 15179 | #endif |
| 15180 | #ifdef FEATURE_WLAN_TDLS |
| 15181 | .tdls_mgmt = wlan_hdd_cfg80211_tdls_mgmt, |
| 15182 | .tdls_oper = wlan_hdd_cfg80211_tdls_oper, |
| 15183 | #endif |
| 15184 | #ifdef WLAN_FEATURE_GTK_OFFLOAD |
| 15185 | .set_rekey_data = wlan_hdd_cfg80211_set_rekey_data, |
| 15186 | #endif /* WLAN_FEATURE_GTK_OFFLOAD */ |
| 15187 | #ifdef FEATURE_WLAN_SCAN_PNO |
| 15188 | .sched_scan_start = wlan_hdd_cfg80211_sched_scan_start, |
| 15189 | .sched_scan_stop = wlan_hdd_cfg80211_sched_scan_stop, |
| 15190 | #endif /*FEATURE_WLAN_SCAN_PNO */ |
| 15191 | .resume = wlan_hdd_cfg80211_resume_wlan, |
| 15192 | .suspend = wlan_hdd_cfg80211_suspend_wlan, |
| 15193 | .set_mac_acl = wlan_hdd_cfg80211_set_mac_acl, |
| 15194 | #ifdef WLAN_NL80211_TESTMODE |
| 15195 | .testmode_cmd = wlan_hdd_cfg80211_testmode, |
| 15196 | #endif |
| 15197 | #ifdef QCA_HT_2040_COEX |
| 15198 | .set_ap_chanwidth = wlan_hdd_cfg80211_set_ap_channel_width, |
| 15199 | #endif |
| 15200 | .dump_survey = wlan_hdd_cfg80211_dump_survey, |
Abhishek Singh | 1bdb157 | 2015-10-16 16:24:19 +0530 | [diff] [blame] | 15201 | #ifdef CHANNEL_SWITCH_SUPPORTED |
| 15202 | .channel_switch = wlan_hdd_cfg80211_channel_switch, |
| 15203 | #endif |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 15204 | .set_monitor_channel = wlan_hdd_cfg80211_set_mon_ch, |
Vidyullatha, Kanchanapally | 528789e | 2016-05-11 20:38:37 +0530 | [diff] [blame] | 15205 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 5, 0)) || \ |
| 15206 | defined(CFG80211_ABORT_SCAN) |
| 15207 | .abort_scan = wlan_hdd_cfg80211_abort_scan, |
| 15208 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15209 | }; |