Kiran V | 1ccee93 | 2012-12-12 14:49:46 -0800 | [diff] [blame] | 1 | /* |
Pradeep Reddy POTTETI | c7822df | 2015-02-19 20:15:41 +0530 | [diff] [blame] | 2 | * Copyright (c) 2012-2015 The Linux Foundation. All rights reserved. |
Kiet Lam | 842dad0 | 2014-02-18 18:44:02 -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. |
Gopichand Nakkala | 0c1331e | 2013-01-07 22:49:07 -0800 | [diff] [blame] | 20 | */ |
Kiet Lam | 842dad0 | 2014-02-18 18:44:02 -0800 | [diff] [blame] | 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 | |
Kiran V | 1ccee93 | 2012-12-12 14:49:46 -0800 | [diff] [blame] | 28 | /**======================================================================== |
| 29 | |
| 30 | \file wlan_hdd_tdls.c |
| 31 | |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 32 | \brief WLAN Host Device Driver implementation for TDLS |
Kiran V | 1ccee93 | 2012-12-12 14:49:46 -0800 | [diff] [blame] | 33 | |
Kiran V | 1ccee93 | 2012-12-12 14:49:46 -0800 | [diff] [blame] | 34 | ========================================================================*/ |
| 35 | |
| 36 | #include <wlan_hdd_includes.h> |
| 37 | #include <wlan_hdd_hostapd.h> |
| 38 | #include <net/cfg80211.h> |
| 39 | #include <linux/netdevice.h> |
| 40 | #include <linux/skbuff.h> |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 41 | #include <linux/list.h> |
Kiran V | 1ccee93 | 2012-12-12 14:49:46 -0800 | [diff] [blame] | 42 | #include <linux/etherdevice.h> |
| 43 | #include <net/ieee80211_radiotap.h> |
| 44 | #include "wlan_hdd_tdls.h" |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 45 | #include "wlan_hdd_cfg80211.h" |
Masti, Narayanraddi | 1fb32a9 | 2015-06-29 13:14:06 +0530 | [diff] [blame] | 46 | #include "wlan_hdd_assoc.h" |
| 47 | #include "sme_Api.h" |
Mahesh A Saptasagar | 8b231b3 | 2014-08-11 11:58:15 +0530 | [diff] [blame] | 48 | #include "vos_sched.h" |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 49 | |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 50 | static tANI_S32 wlan_hdd_get_tdls_discovery_peer_cnt(tdlsCtx_t *pHddTdlsCtx); |
| 51 | static tANI_S32 wlan_hdd_tdls_peer_reset_discovery_processed(tdlsCtx_t *pHddTdlsCtx); |
| 52 | static void wlan_hdd_tdls_timers_destroy(tdlsCtx_t *pHddTdlsCtx); |
Madan Mohan Koyyalamudi | 693275b | 2013-07-22 19:14:09 +0530 | [diff] [blame] | 53 | static void wlan_hdd_tdls_peer_timers_destroy(tdlsCtx_t *pHddTdlsCtx); |
Sunil Dutt | 41de4e2 | 2013-11-14 18:09:02 +0530 | [diff] [blame] | 54 | int wpa_tdls_is_allowed_force_peer(tdlsCtx_t *pHddTdlsCtx, u8 *mac); |
Hoonki Lee | d37cbb3 | 2013-04-20 00:31:14 -0700 | [diff] [blame] | 55 | #ifdef CONFIG_TDLS_IMPLICIT |
Pradeep Reddy POTTETI | 9db32f0 | 2015-01-29 15:22:54 +0530 | [diff] [blame] | 56 | static void wlan_hdd_tdls_implicit_send_discovery_request(tdlsCtx_t *pHddTdlsCtx); |
Hoonki Lee | d37cbb3 | 2013-04-20 00:31:14 -0700 | [diff] [blame] | 57 | #endif |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 58 | |
Anand N Sunkad | b3ab97d | 2015-07-29 09:58:13 +0530 | [diff] [blame^] | 59 | static u8 wlan_hdd_tdls_hash_key ( |
| 60 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0)) |
| 61 | const u8 *mac |
| 62 | #else |
| 63 | u8 *mac |
| 64 | #endif |
| 65 | ) |
Hoonki Lee | f63df0d | 2013-01-16 19:29:14 -0800 | [diff] [blame] | 66 | { |
| 67 | int i; |
Hoonki Lee | 387663d | 2013-02-05 18:08:43 -0800 | [diff] [blame] | 68 | u8 key = 0; |
| 69 | |
| 70 | for (i = 0; i < 6; i++) |
| 71 | key ^= mac[i]; |
| 72 | |
| 73 | return key; |
| 74 | } |
| 75 | |
Masti, Narayanraddi | fdde4d0 | 2015-04-16 14:41:51 +0530 | [diff] [blame] | 76 | /** |
| 77 | * wlan_hdd_tdls_disable_offchan_and_teardown_links - Disable offchannel |
| 78 | * and teardown TDLS links |
| 79 | * @hddCtx : pointer to hdd context |
| 80 | * |
| 81 | * Return: None |
| 82 | */ |
| 83 | void wlan_hdd_tdls_disable_offchan_and_teardown_links(hdd_context_t *hddctx) |
| 84 | { |
| 85 | u16 connected_tdls_peers = 0; |
Masti, Narayanraddi | 1fb32a9 | 2015-06-29 13:14:06 +0530 | [diff] [blame] | 86 | u8 staIdx; |
Masti, Narayanraddi | 471e938 | 2015-07-23 18:51:29 +0530 | [diff] [blame] | 87 | hddTdlsPeer_t *curr_peer = NULL; |
Masti, Narayanraddi | fdde4d0 | 2015-04-16 14:41:51 +0530 | [diff] [blame] | 88 | hdd_adapter_t *adapter = NULL; |
| 89 | |
| 90 | if (eTDLS_SUPPORT_NOT_ENABLED == hddctx->tdls_mode) { |
| 91 | hddLog(LOG1, FL("TDLS mode is disabled OR not enabled in FW")); |
| 92 | return ; |
| 93 | } |
| 94 | |
| 95 | adapter = hdd_get_adapter(hddctx, WLAN_HDD_INFRA_STATION); |
| 96 | |
| 97 | if (adapter == NULL) { |
| 98 | hddLog(LOGE, FL("Station Adapter Not Found")); |
Masti, Narayanraddi | 70e5b47 | 2015-08-04 12:54:16 +0530 | [diff] [blame] | 99 | goto done; |
Masti, Narayanraddi | fdde4d0 | 2015-04-16 14:41:51 +0530 | [diff] [blame] | 100 | } |
| 101 | |
| 102 | connected_tdls_peers = wlan_hdd_tdlsConnectedPeers(adapter); |
Masti, Narayanraddi | 1fb32a9 | 2015-06-29 13:14:06 +0530 | [diff] [blame] | 103 | if (!connected_tdls_peers) { |
Masti, Narayanraddi | 70e5b47 | 2015-08-04 12:54:16 +0530 | [diff] [blame] | 104 | hddLog(LOG1, FL("No TDLS connected peers to delete TDLS peers")); |
| 105 | goto done; |
Masti, Narayanraddi | 1fb32a9 | 2015-06-29 13:14:06 +0530 | [diff] [blame] | 106 | } |
Masti, Narayanraddi | fdde4d0 | 2015-04-16 14:41:51 +0530 | [diff] [blame] | 107 | |
Masti, Narayanraddi | 471e938 | 2015-07-23 18:51:29 +0530 | [diff] [blame] | 108 | /* TDLS is not supported in case of concurrency |
| 109 | * Disable TDLS Offchannel to avoid more than two concurrent channels. |
| 110 | */ |
| 111 | if (connected_tdls_peers == 1) { |
| 112 | curr_peer = wlan_hdd_tdls_get_connected_peer(adapter); |
| 113 | if (curr_peer && (curr_peer->isOffChannelConfigured == TRUE)) { |
| 114 | hddLog(LOG1, FL("%s: Concurrency detected, Disable " |
| 115 | "TDLS channel switch"), __func__); |
| 116 | curr_peer->isOffChannelEstablished = FALSE; |
| 117 | sme_SendTdlsChanSwitchReq(WLAN_HDD_GET_HAL_CTX(adapter), |
| 118 | adapter->sessionId, |
| 119 | curr_peer->peerMac, |
| 120 | curr_peer->peerParams.channel, |
| 121 | TDLS_OFF_CHANNEL_BW_OFFSET, |
| 122 | TDLS_CHANNEL_SWITCH_DISABLE); |
Masti, Narayanraddi | fdde4d0 | 2015-04-16 14:41:51 +0530 | [diff] [blame] | 123 | } |
| 124 | } |
Masti, Narayanraddi | 471e938 | 2015-07-23 18:51:29 +0530 | [diff] [blame] | 125 | |
| 126 | /* Send Msg to PE for sending deauth and deleting all the TDLS peers */ |
| 127 | sme_DeleteAllTDLSPeers(hddctx->hHal, adapter->sessionId); |
| 128 | |
| 129 | /* As mentioned above TDLS is not supported in case of concurrency |
| 130 | * Find the connected peer and generate TDLS teardown indication to |
| 131 | * supplicant. |
| 132 | */ |
| 133 | for (staIdx = 0; staIdx < HDD_MAX_NUM_TDLS_STA; staIdx++) { |
| 134 | if (!hddctx->tdlsConnInfo[staIdx].staId) |
| 135 | continue; |
| 136 | |
| 137 | curr_peer = wlan_hdd_tdls_find_all_peer(hddctx, |
| 138 | hddctx->tdlsConnInfo[staIdx].peerMac.bytes); |
| 139 | |
| 140 | if (!curr_peer) |
| 141 | continue; |
| 142 | |
| 143 | /* Del Sta happened already as part of sme_DeleteAllTDLSPeers |
| 144 | * Hence clear hdd data structure. |
| 145 | */ |
| 146 | hdd_roamDeregisterTDLSSTA(adapter, |
| 147 | hddctx->tdlsConnInfo[staIdx].staId); |
| 148 | wlan_hdd_tdls_decrement_peer_count(adapter); |
| 149 | wlan_hdd_tdls_reset_peer(adapter, curr_peer->peerMac); |
| 150 | |
| 151 | hddctx->tdlsConnInfo[staIdx].staId = 0 ; |
| 152 | hddctx->tdlsConnInfo[staIdx].sessionId = 255; |
| 153 | vos_mem_zero(&hddctx->tdlsConnInfo[staIdx].peerMac, |
| 154 | sizeof(v_MACADDR_t)) ; |
| 155 | wlan_hdd_tdls_check_bmps(adapter); |
| 156 | |
| 157 | hddLog(LOG1, FL("indicate TDLS teardown (staId %d)"), |
| 158 | curr_peer->staId); |
| 159 | |
| 160 | /* Indicate teardown to supplicant */ |
| 161 | wlan_hdd_tdls_indicate_teardown( |
| 162 | curr_peer->pHddTdlsCtx->pAdapter, |
| 163 | curr_peer, |
| 164 | eSIR_MAC_TDLS_TEARDOWN_UNSPEC_REASON); |
| 165 | } |
| 166 | |
Masti, Narayanraddi | 70e5b47 | 2015-08-04 12:54:16 +0530 | [diff] [blame] | 167 | done: |
Masti, Narayanraddi | fdde4d0 | 2015-04-16 14:41:51 +0530 | [diff] [blame] | 168 | wlan_hdd_tdls_set_mode(hddctx, eTDLS_SUPPORT_DISABLED, FALSE); |
| 169 | hddLog(LOG1, FL("TDLS Support Disabled")); |
| 170 | } |
| 171 | |
| 172 | /** |
| 173 | * hdd_tdls_notify_mode_change - Notify mode change |
| 174 | * @adapter: pointer to hdd adapter |
| 175 | * @hddCtx : pointer to hdd context |
| 176 | * |
| 177 | * Return: None |
| 178 | */ |
| 179 | void hdd_tdls_notify_mode_change(hdd_adapter_t *adapter, hdd_context_t *hddctx) |
| 180 | { |
| 181 | if (adapter->device_mode != WLAN_HDD_INFRA_STATION) |
| 182 | wlan_hdd_tdls_disable_offchan_and_teardown_links(hddctx); |
| 183 | } |
| 184 | |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 185 | static v_VOID_t wlan_hdd_tdls_start_peer_discover_timer(tdlsCtx_t *pHddTdlsCtx, |
| 186 | tANI_BOOLEAN mutexLock, |
| 187 | v_U32_t discoveryExpiry) |
Gopichand Nakkala | eb69b60 | 2013-02-27 11:40:31 -0800 | [diff] [blame] | 188 | { |
Gopichand Nakkala | eb69b60 | 2013-02-27 11:40:31 -0800 | [diff] [blame] | 189 | hdd_station_ctx_t *pHddStaCtx; |
Madan Mohan Koyyalamudi | 263cec1 | 2013-10-07 10:57:50 +0530 | [diff] [blame] | 190 | hdd_context_t *pHddCtx; |
| 191 | |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 192 | ENTER(); |
| 193 | |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 194 | if ((NULL == pHddTdlsCtx) || (NULL == pHddTdlsCtx->pAdapter) ) |
| 195 | { |
| 196 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 197 | FL(" pHddTdlsCtx or pAdapter points to NULL")); |
Madan Mohan Koyyalamudi | 263cec1 | 2013-10-07 10:57:50 +0530 | [diff] [blame] | 198 | return; |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 199 | } |
Madan Mohan Koyyalamudi | 263cec1 | 2013-10-07 10:57:50 +0530 | [diff] [blame] | 200 | |
| 201 | pHddCtx = WLAN_HDD_GET_CTX( pHddTdlsCtx->pAdapter ); |
| 202 | |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 203 | if(0 != (wlan_hdd_validate_context(pHddCtx))) |
| 204 | { |
Madan Mohan Koyyalamudi | 263cec1 | 2013-10-07 10:57:50 +0530 | [diff] [blame] | 205 | return; |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 206 | } |
Gopichand Nakkala | eb69b60 | 2013-02-27 11:40:31 -0800 | [diff] [blame] | 207 | |
Gopichand Nakkala | eb69b60 | 2013-02-27 11:40:31 -0800 | [diff] [blame] | 208 | if ( mutexLock ) |
| 209 | { |
Rajesh Chauhan | a34c6e6 | 2014-03-25 16:37:58 +0530 | [diff] [blame] | 210 | mutex_lock(&pHddCtx->tdls_lock); |
Gopichand Nakkala | eb69b60 | 2013-02-27 11:40:31 -0800 | [diff] [blame] | 211 | } |
Gopichand Nakkala | eb69b60 | 2013-02-27 11:40:31 -0800 | [diff] [blame] | 212 | |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 213 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pHddTdlsCtx->pAdapter); |
Deepthi Gowri | 681c943 | 2015-05-14 11:51:11 +0530 | [diff] [blame] | 214 | |
Gopichand Nakkala | 3046fc9 | 2013-03-23 13:56:43 -0700 | [diff] [blame] | 215 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "beacon rssi: %d", |
| 216 | pHddTdlsCtx->ap_rssi); |
| 217 | |
Gopichand Nakkala | eb69b60 | 2013-02-27 11:40:31 -0800 | [diff] [blame] | 218 | if ( mutexLock ) |
Madan Mohan Koyyalamudi | 263cec1 | 2013-10-07 10:57:50 +0530 | [diff] [blame] | 219 | mutex_unlock(&pHddCtx->tdls_lock); |
Gopichand Nakkala | eb69b60 | 2013-02-27 11:40:31 -0800 | [diff] [blame] | 220 | |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 221 | EXIT(); |
Gopichand Nakkala | eb69b60 | 2013-02-27 11:40:31 -0800 | [diff] [blame] | 222 | return; |
| 223 | } |
| 224 | |
Hoonki Lee | d37cbb3 | 2013-04-20 00:31:14 -0700 | [diff] [blame] | 225 | #ifdef TDLS_USE_SEPARATE_DISCOVERY_TIMER |
Hoonki Lee | 387663d | 2013-02-05 18:08:43 -0800 | [diff] [blame] | 226 | static v_VOID_t wlan_hdd_tdls_discover_peer_cb( v_PVOID_t userData ) |
| 227 | { |
| 228 | int i; |
| 229 | struct list_head *head; |
| 230 | struct list_head *pos; |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 231 | hddTdlsPeer_t *curr_peer; |
Madan Mohan Koyyalamudi | 263cec1 | 2013-10-07 10:57:50 +0530 | [diff] [blame] | 232 | hdd_context_t *pHddCtx; |
Mahesh A Saptasagar | 170b508 | 2015-02-16 18:50:54 +0530 | [diff] [blame] | 233 | tdlsCtx_t *pHddTdlsCtx; |
Gopichand Nakkala | c369458 | 2013-02-13 20:51:22 -0800 | [diff] [blame] | 234 | int discover_req_sent = 0; |
| 235 | v_U32_t discover_expiry = TDLS_SUB_DISCOVERY_PERIOD; |
Gopichand Nakkala | eb69b60 | 2013-02-27 11:40:31 -0800 | [diff] [blame] | 236 | tANI_BOOLEAN doMutexLock = eANI_BOOLEAN_TRUE; |
Mahesh A Saptasagar | 170b508 | 2015-02-16 18:50:54 +0530 | [diff] [blame] | 237 | v_CONTEXT_t pVosContext; |
Gopichand Nakkala | c369458 | 2013-02-13 20:51:22 -0800 | [diff] [blame] | 238 | |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 239 | ENTER(); |
| 240 | |
Mahesh A Saptasagar | 170b508 | 2015-02-16 18:50:54 +0530 | [diff] [blame] | 241 | pVosContext = vos_get_global_context(VOS_MODULE_ID_HDD, NULL); |
| 242 | if (NULL == pVosContext) |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 243 | { |
| 244 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Mahesh A Saptasagar | 170b508 | 2015-02-16 18:50:54 +0530 | [diff] [blame] | 245 | FL("pVosContext points to NULL")); |
Madan Mohan Koyyalamudi | 263cec1 | 2013-10-07 10:57:50 +0530 | [diff] [blame] | 246 | return; |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 247 | } |
Madan Mohan Koyyalamudi | 263cec1 | 2013-10-07 10:57:50 +0530 | [diff] [blame] | 248 | |
Mahesh A Saptasagar | 170b508 | 2015-02-16 18:50:54 +0530 | [diff] [blame] | 249 | pHddCtx = vos_get_context(VOS_MODULE_ID_HDD, pVosContext); |
| 250 | if (0 != (wlan_hdd_validate_context(pHddCtx))) |
Sushant Kaushik | 15c4c52 | 2014-08-14 12:24:49 +0530 | [diff] [blame] | 251 | { |
Madan Mohan Koyyalamudi | 263cec1 | 2013-10-07 10:57:50 +0530 | [diff] [blame] | 252 | return; |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 253 | } |
Madan Mohan Koyyalamudi | 263cec1 | 2013-10-07 10:57:50 +0530 | [diff] [blame] | 254 | |
Rajesh Chauhan | a34c6e6 | 2014-03-25 16:37:58 +0530 | [diff] [blame] | 255 | mutex_lock(&pHddCtx->tdls_lock); |
Mahesh A Saptasagar | 170b508 | 2015-02-16 18:50:54 +0530 | [diff] [blame] | 256 | pHddTdlsCtx = (tdlsCtx_t *)userData; |
| 257 | if (0 != (wlan_hdd_validate_tdls_context(pHddCtx, pHddTdlsCtx))) |
| 258 | { |
| 259 | mutex_unlock(&pHddCtx->tdls_lock); |
| 260 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 261 | FL("Invalid pHddTdlsCtx context")); |
| 262 | return; |
| 263 | } |
Hoonki Lee | bfee034 | 2013-01-21 16:43:45 -0800 | [diff] [blame] | 264 | |
Hoonki Lee | 387663d | 2013-02-05 18:08:43 -0800 | [diff] [blame] | 265 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: ", __func__); |
| 266 | |
Gopichand Nakkala | c369458 | 2013-02-13 20:51:22 -0800 | [diff] [blame] | 267 | if (0 == pHddTdlsCtx->discovery_peer_cnt) |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 268 | pHddTdlsCtx->discovery_peer_cnt = wlan_hdd_get_tdls_discovery_peer_cnt(pHddTdlsCtx); |
Gopichand Nakkala | c369458 | 2013-02-13 20:51:22 -0800 | [diff] [blame] | 269 | |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 270 | for (i = 0; i < 256; i++) { |
Hoonki Lee | 387663d | 2013-02-05 18:08:43 -0800 | [diff] [blame] | 271 | head = &pHddTdlsCtx->peer_list[i]; |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 272 | |
Hoonki Lee | 387663d | 2013-02-05 18:08:43 -0800 | [diff] [blame] | 273 | list_for_each (pos, head) { |
| 274 | curr_peer = list_entry (pos, hddTdlsPeer_t, node); |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 275 | |
Masti, Narayanraddi | 34e0e56 | 2015-03-05 18:23:03 +0530 | [diff] [blame] | 276 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Chilam Ng | 0112041 | 2013-02-19 18:32:21 -0800 | [diff] [blame] | 277 | "%d " MAC_ADDRESS_STR " %d %d, %d %d %d %d", i, |
| 278 | MAC_ADDR_ARRAY(curr_peer->peerMac), |
Gopichand Nakkala | c369458 | 2013-02-13 20:51:22 -0800 | [diff] [blame] | 279 | curr_peer->discovery_processed, |
| 280 | discover_req_sent, |
Gopichand Nakkala | 2a0a157 | 2013-02-10 21:39:16 -0800 | [diff] [blame] | 281 | curr_peer->tdls_support, |
| 282 | curr_peer->link_status, |
| 283 | curr_peer->discovery_attempt, |
| 284 | pHddTdlsCtx->threshold_config.discovery_tries_n); |
Hoonki Lee | 387663d | 2013-02-05 18:08:43 -0800 | [diff] [blame] | 285 | |
Gopichand Nakkala | c369458 | 2013-02-13 20:51:22 -0800 | [diff] [blame] | 286 | if (discover_req_sent < TDLS_MAX_DISCOVER_REQS_PER_TIMER) { |
| 287 | if (!curr_peer->discovery_processed) { |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 288 | |
Gopichand Nakkala | c369458 | 2013-02-13 20:51:22 -0800 | [diff] [blame] | 289 | curr_peer->discovery_processed = 1; |
| 290 | discover_req_sent++; |
| 291 | pHddTdlsCtx->discovery_peer_cnt--; |
| 292 | |
| 293 | if ((eTDLS_CAP_UNKNOWN == curr_peer->tdls_support) && |
Gopichand Nakkala | 901e892 | 2013-03-04 23:45:58 -0800 | [diff] [blame] | 294 | (eTDLS_LINK_IDLE == curr_peer->link_status) && |
Gopichand Nakkala | b88f677 | 2013-02-27 18:12:56 -0800 | [diff] [blame] | 295 | (curr_peer->tx_pkt >= |
| 296 | pHddTdlsCtx->threshold_config.tx_packet_n)) { |
Gopichand Nakkala | 273d5a0 | 2013-02-19 15:15:09 -0800 | [diff] [blame] | 297 | |
| 298 | if (curr_peer->discovery_attempt < |
| 299 | pHddTdlsCtx->threshold_config.discovery_tries_n) { |
Pradeep Reddy POTTETI | 9db32f0 | 2015-01-29 15:22:54 +0530 | [diff] [blame] | 300 | cfg80211_tdls_oper_request( |
| 301 | pHddTdlsCtx->pAdapter->dev, |
| 302 | curr_peer->peerMac, |
| 303 | NL80211_TDLS_DISCOVERY_REQ, |
| 304 | FALSE, |
| 305 | GFP_KERNEL); |
Gopichand Nakkala | 273d5a0 | 2013-02-19 15:15:09 -0800 | [diff] [blame] | 306 | curr_peer->discovery_attempt++; |
| 307 | } |
| 308 | else |
| 309 | { |
Masti, Narayanraddi | 34e0e56 | 2015-03-05 18:23:03 +0530 | [diff] [blame] | 310 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, |
Gopichand Nakkala | 273d5a0 | 2013-02-19 15:15:09 -0800 | [diff] [blame] | 311 | "%s: Maximum Discovery retries reached", __func__); |
| 312 | curr_peer->tdls_support = eTDLS_CAP_NOT_SUPPORTED; |
| 313 | } |
Gopichand Nakkala | c369458 | 2013-02-13 20:51:22 -0800 | [diff] [blame] | 314 | |
| 315 | } |
| 316 | } |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 317 | } |
Gopichand Nakkala | c369458 | 2013-02-13 20:51:22 -0800 | [diff] [blame] | 318 | else |
| 319 | goto exit_loop; |
Hoonki Lee | 387663d | 2013-02-05 18:08:43 -0800 | [diff] [blame] | 320 | } |
Hoonki Lee | f63df0d | 2013-01-16 19:29:14 -0800 | [diff] [blame] | 321 | } |
Gopichand Nakkala | c369458 | 2013-02-13 20:51:22 -0800 | [diff] [blame] | 322 | exit_loop: |
Hoonki Lee | f63df0d | 2013-01-16 19:29:14 -0800 | [diff] [blame] | 323 | |
Gopichand Nakkala | c369458 | 2013-02-13 20:51:22 -0800 | [diff] [blame] | 324 | if (0 != pHddTdlsCtx->discovery_peer_cnt) { |
Masti, Narayanraddi | 34e0e56 | 2015-03-05 18:23:03 +0530 | [diff] [blame] | 325 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Gopichand Nakkala | c369458 | 2013-02-13 20:51:22 -0800 | [diff] [blame] | 326 | "discovery_peer_cnt is %d , Starting SUB_DISCOVERY_TIMER", |
| 327 | pHddTdlsCtx->discovery_peer_cnt); |
| 328 | discover_expiry = TDLS_SUB_DISCOVERY_PERIOD; |
Gopichand Nakkala | eb69b60 | 2013-02-27 11:40:31 -0800 | [diff] [blame] | 329 | doMutexLock = eANI_BOOLEAN_FALSE; |
Gopichand Nakkala | c369458 | 2013-02-13 20:51:22 -0800 | [diff] [blame] | 330 | goto done; |
| 331 | } |
Gopichand Nakkala | c369458 | 2013-02-13 20:51:22 -0800 | [diff] [blame] | 332 | discover_expiry = pHddTdlsCtx->threshold_config.discovery_period_t; |
| 333 | |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 334 | wlan_hdd_tdls_peer_reset_discovery_processed(pHddTdlsCtx); |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 335 | |
Madan Mohan Koyyalamudi | 263cec1 | 2013-10-07 10:57:50 +0530 | [diff] [blame] | 336 | mutex_unlock(&pHddCtx->tdls_lock); |
Gopichand Nakkala | 638ebc7 | 2013-03-21 18:04:02 -0700 | [diff] [blame] | 337 | |
Gopichand Nakkala | eb69b60 | 2013-02-27 11:40:31 -0800 | [diff] [blame] | 338 | /* Commenting out the following function as it was introducing |
| 339 | * a race condition when pHddTdlsCtx is deleted. Also , this |
| 340 | * function is consuming more time in the timer callback. |
| 341 | * RSSI based trigger needs to revisit this part of the code. |
| 342 | */ |
| 343 | |
| 344 | /* |
| 345 | * wlan_hdd_get_rssi(pAdapter, &pHddTdlsCtx->ap_rssi); |
| 346 | */ |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 347 | |
Gopichand Nakkala | c369458 | 2013-02-13 20:51:22 -0800 | [diff] [blame] | 348 | done: |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 349 | wlan_hdd_tdls_start_peer_discover_timer(pHddTdlsCtx, doMutexLock, discover_expiry); |
Gopichand Nakkala | 91b0926 | 2013-02-10 14:27:02 -0800 | [diff] [blame] | 350 | |
Gopichand Nakkala | eb69b60 | 2013-02-27 11:40:31 -0800 | [diff] [blame] | 351 | if ( !doMutexLock ) |
Madan Mohan Koyyalamudi | 263cec1 | 2013-10-07 10:57:50 +0530 | [diff] [blame] | 352 | mutex_unlock(&pHddCtx->tdls_lock); |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 353 | EXIT(); |
Gopichand Nakkala | eb69b60 | 2013-02-27 11:40:31 -0800 | [diff] [blame] | 354 | return; |
Hoonki Lee | f63df0d | 2013-01-16 19:29:14 -0800 | [diff] [blame] | 355 | } |
Hoonki Lee | d37cbb3 | 2013-04-20 00:31:14 -0700 | [diff] [blame] | 356 | #endif |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 357 | |
Hoonki Lee | 387663d | 2013-02-05 18:08:43 -0800 | [diff] [blame] | 358 | static v_VOID_t wlan_hdd_tdls_update_peer_cb( v_PVOID_t userData ) |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 359 | { |
| 360 | int i; |
Hoonki Lee | 387663d | 2013-02-05 18:08:43 -0800 | [diff] [blame] | 361 | struct list_head *head; |
| 362 | struct list_head *pos; |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 363 | hddTdlsPeer_t *curr_peer; |
Mahesh A Saptasagar | 170b508 | 2015-02-16 18:50:54 +0530 | [diff] [blame] | 364 | tdlsCtx_t *pHddTdlsCtx; |
Madan Mohan Koyyalamudi | 263cec1 | 2013-10-07 10:57:50 +0530 | [diff] [blame] | 365 | hdd_context_t *pHddCtx; |
Mahesh A Saptasagar | 170b508 | 2015-02-16 18:50:54 +0530 | [diff] [blame] | 366 | v_CONTEXT_t pVosContext; |
Hoonki Lee | bfee034 | 2013-01-21 16:43:45 -0800 | [diff] [blame] | 367 | |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 368 | ENTER(); |
Mahesh A Saptasagar | 170b508 | 2015-02-16 18:50:54 +0530 | [diff] [blame] | 369 | pVosContext = vos_get_global_context(VOS_MODULE_ID_HDD, NULL); |
| 370 | if (NULL == pVosContext) |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 371 | { |
| 372 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Mahesh A Saptasagar | 170b508 | 2015-02-16 18:50:54 +0530 | [diff] [blame] | 373 | FL("pVosContext points to NULL")); |
Madan Mohan Koyyalamudi | 263cec1 | 2013-10-07 10:57:50 +0530 | [diff] [blame] | 374 | return; |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 375 | } |
Mahesh A Saptasagar | 170b508 | 2015-02-16 18:50:54 +0530 | [diff] [blame] | 376 | pHddCtx = vos_get_context(VOS_MODULE_ID_HDD, pVosContext); |
| 377 | if (0 != (wlan_hdd_validate_context(pHddCtx))) |
Sushant Kaushik | 15c4c52 | 2014-08-14 12:24:49 +0530 | [diff] [blame] | 378 | { |
Madan Mohan Koyyalamudi | 263cec1 | 2013-10-07 10:57:50 +0530 | [diff] [blame] | 379 | return; |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 380 | } |
Rajesh Chauhan | a34c6e6 | 2014-03-25 16:37:58 +0530 | [diff] [blame] | 381 | mutex_lock(&pHddCtx->tdls_lock); |
Mahesh A Saptasagar | 170b508 | 2015-02-16 18:50:54 +0530 | [diff] [blame] | 382 | pHddTdlsCtx = (tdlsCtx_t *)userData; |
| 383 | if (0 != (wlan_hdd_validate_tdls_context(pHddCtx, pHddTdlsCtx))) |
| 384 | { |
| 385 | mutex_unlock(&pHddCtx->tdls_lock); |
| 386 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 387 | FL("Invalid pHddTdlsCtx context")); |
| 388 | return; |
| 389 | } |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 390 | for (i = 0; i < 256; i++) { |
Hoonki Lee | 387663d | 2013-02-05 18:08:43 -0800 | [diff] [blame] | 391 | head = &pHddTdlsCtx->peer_list[i]; |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 392 | |
Hoonki Lee | 387663d | 2013-02-05 18:08:43 -0800 | [diff] [blame] | 393 | list_for_each (pos, head) { |
| 394 | curr_peer = list_entry (pos, hddTdlsPeer_t, node); |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 395 | |
Masti, Narayanraddi | 34e0e56 | 2015-03-05 18:23:03 +0530 | [diff] [blame] | 396 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Hoonki Lee | 66b75f3 | 2013-04-16 18:30:07 -0700 | [diff] [blame] | 397 | "%s: " MAC_ADDRESS_STR " link_status %d" |
| 398 | " tdls_support %d", __func__, MAC_ADDR_ARRAY(curr_peer->peerMac), |
Gopichand Nakkala | 34d1b06 | 2013-03-19 15:28:33 -0700 | [diff] [blame] | 399 | curr_peer->link_status, curr_peer->tdls_support); |
Hoonki Lee | 387663d | 2013-02-05 18:08:43 -0800 | [diff] [blame] | 400 | |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 401 | if (eTDLS_CAP_SUPPORTED == curr_peer->tdls_support) { |
Masti, Narayanraddi | 34e0e56 | 2015-03-05 18:23:03 +0530 | [diff] [blame] | 402 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Hoonki Lee | 66b75f3 | 2013-04-16 18:30:07 -0700 | [diff] [blame] | 403 | "tx %d, rx %d (thr.pkt %d/idle %d), rssi %d (thr.trig %d/hys %d/tear %d)", |
| 404 | curr_peer->tx_pkt, curr_peer->rx_pkt, |
Hoonki Lee | 5a4b217 | 2013-01-29 01:45:53 -0800 | [diff] [blame] | 405 | pHddTdlsCtx->threshold_config.tx_packet_n, |
Hoonki Lee | 66b75f3 | 2013-04-16 18:30:07 -0700 | [diff] [blame] | 406 | pHddTdlsCtx->threshold_config.idle_packet_n, |
| 407 | curr_peer->rssi, |
| 408 | pHddTdlsCtx->threshold_config.rssi_trigger_threshold, |
| 409 | pHddTdlsCtx->threshold_config.rssi_hysteresis, |
| 410 | pHddTdlsCtx->threshold_config.rssi_teardown_threshold); |
Chilam Ng | 0112041 | 2013-02-19 18:32:21 -0800 | [diff] [blame] | 411 | |
Gopichand Nakkala | 901e892 | 2013-03-04 23:45:58 -0800 | [diff] [blame] | 412 | if ((eTDLS_LINK_IDLE == curr_peer->link_status) || |
| 413 | (eTDLS_LINK_DISCOVERING == curr_peer->link_status)){ |
Sunil Dutt | 961ecbd | 2013-11-28 20:04:07 +0530 | [diff] [blame] | 414 | |
| 415 | if (pHddCtx->cfg_ini->fTDLSExternalControl && |
| 416 | (FALSE == curr_peer->isForcedPeer)) { |
| 417 | continue; |
| 418 | } |
| 419 | |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 420 | if (curr_peer->tx_pkt >= |
| 421 | pHddTdlsCtx->threshold_config.tx_packet_n) { |
Hoonki Lee | 5a4b217 | 2013-01-29 01:45:53 -0800 | [diff] [blame] | 422 | |
Gopichand Nakkala | 8b00c63 | 2013-03-08 19:47:52 -0800 | [diff] [blame] | 423 | if (HDD_MAX_NUM_TDLS_STA > wlan_hdd_tdlsConnectedPeers(pHddTdlsCtx->pAdapter)) |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 424 | { |
| 425 | |
Masti, Narayanraddi | 34e0e56 | 2015-03-05 18:23:03 +0530 | [diff] [blame] | 426 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 427 | "Tput trigger TDLS pre-setup"); |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 428 | #ifdef CONFIG_TDLS_IMPLICIT |
Pradeep Reddy POTTETI | 9db32f0 | 2015-01-29 15:22:54 +0530 | [diff] [blame] | 429 | pHddTdlsCtx->curr_candidate = curr_peer; |
| 430 | wlan_hdd_tdls_implicit_send_discovery_request(pHddTdlsCtx); |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 431 | #endif |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 432 | } |
| 433 | else |
| 434 | { |
Masti, Narayanraddi | 34e0e56 | 2015-03-05 18:23:03 +0530 | [diff] [blame] | 435 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Gopichand Nakkala | 8b00c63 | 2013-03-08 19:47:52 -0800 | [diff] [blame] | 436 | "%s: Maximum peer connected already! %d", |
| 437 | __func__, wlan_hdd_tdlsConnectedPeers(pHddTdlsCtx->pAdapter) ); |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 438 | } |
Hoonki Lee | cdd8e96 | 2013-01-20 00:45:46 -0800 | [diff] [blame] | 439 | goto next_peer; |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 440 | } |
Hoonki Lee | fb8df67 | 2013-04-10 18:20:34 -0700 | [diff] [blame] | 441 | } |
| 442 | else if (eTDLS_LINK_CONNECTED == curr_peer->link_status) { |
Chilam Ng | 0112041 | 2013-02-19 18:32:21 -0800 | [diff] [blame] | 443 | if ((tANI_S32)curr_peer->rssi < |
| 444 | (tANI_S32)pHddTdlsCtx->threshold_config.rssi_teardown_threshold) { |
Hoonki Lee | 5a4b217 | 2013-01-29 01:45:53 -0800 | [diff] [blame] | 445 | |
Chilam Ng | 0112041 | 2013-02-19 18:32:21 -0800 | [diff] [blame] | 446 | VOS_TRACE( VOS_MODULE_ID_HDD, |
| 447 | VOS_TRACE_LEVEL_WARN, |
| 448 | "Tear down - low RSSI: " MAC_ADDRESS_STR "!", |
| 449 | MAC_ADDR_ARRAY(curr_peer->peerMac)); |
| 450 | #ifdef CONFIG_TDLS_IMPLICIT |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 451 | wlan_hdd_tdls_indicate_teardown(pHddTdlsCtx->pAdapter, |
| 452 | curr_peer, |
| 453 | eSIR_MAC_TDLS_TEARDOWN_UNSPEC_REASON); |
Chilam Ng | 0112041 | 2013-02-19 18:32:21 -0800 | [diff] [blame] | 454 | #endif |
Hoonki Lee | cdd8e96 | 2013-01-20 00:45:46 -0800 | [diff] [blame] | 455 | goto next_peer; |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 456 | } |
Chilam Ng | 0112041 | 2013-02-19 18:32:21 -0800 | [diff] [blame] | 457 | |
Naresh Jayaram | db4514b | 2013-11-25 18:08:10 +0530 | [diff] [blame] | 458 | /* Only teardown based on non zero idle packet threshold, to address a use |
| 459 | * case where this threshold does not get consider for TEAR DOWN. |
| 460 | */ |
| 461 | |
| 462 | if (( 0 != pHddTdlsCtx->threshold_config.idle_packet_n ) && |
| 463 | ((curr_peer->tx_pkt < |
Chilam Ng | 0112041 | 2013-02-19 18:32:21 -0800 | [diff] [blame] | 464 | pHddTdlsCtx->threshold_config.idle_packet_n) && |
| 465 | (curr_peer->rx_pkt < |
Naresh Jayaram | db4514b | 2013-11-25 18:08:10 +0530 | [diff] [blame] | 466 | pHddTdlsCtx->threshold_config.idle_packet_n))) { |
Chilam Ng | 0112041 | 2013-02-19 18:32:21 -0800 | [diff] [blame] | 467 | if (VOS_TIMER_STATE_RUNNING != |
| 468 | vos_timer_getCurrentState(&curr_peer->peerIdleTimer)) { |
| 469 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, |
| 470 | "Tx/Rx Idle timer start: " MAC_ADDRESS_STR "!", |
| 471 | MAC_ADDR_ARRAY(curr_peer->peerMac)); |
Gopichand Nakkala | 3046fc9 | 2013-03-23 13:56:43 -0700 | [diff] [blame] | 472 | wlan_hdd_tdls_timer_restart(pHddTdlsCtx->pAdapter, |
| 473 | &curr_peer->peerIdleTimer, |
| 474 | pHddTdlsCtx->threshold_config.idle_timeout_t); |
Chilam Ng | 0112041 | 2013-02-19 18:32:21 -0800 | [diff] [blame] | 475 | } |
| 476 | } else { |
Hoonki Lee | 5a4b217 | 2013-01-29 01:45:53 -0800 | [diff] [blame] | 477 | if (VOS_TIMER_STATE_RUNNING == |
| 478 | vos_timer_getCurrentState(&curr_peer->peerIdleTimer)) { |
Chilam Ng | 0112041 | 2013-02-19 18:32:21 -0800 | [diff] [blame] | 479 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, |
| 480 | "Tx/Rx Idle timer stop: " MAC_ADDRESS_STR "!", |
| 481 | MAC_ADDR_ARRAY(curr_peer->peerMac)); |
| 482 | vos_timer_stop( &curr_peer->peerIdleTimer); |
Hoonki Lee | 5a4b217 | 2013-01-29 01:45:53 -0800 | [diff] [blame] | 483 | } |
Hoonki Lee | 5a4b217 | 2013-01-29 01:45:53 -0800 | [diff] [blame] | 484 | } |
Chilam Ng | 0112041 | 2013-02-19 18:32:21 -0800 | [diff] [blame] | 485 | |
Hoonki Lee | cdd8e96 | 2013-01-20 00:45:46 -0800 | [diff] [blame] | 486 | // if (curr_peer->rssi < |
| 487 | // (pHddTdlsCtx->threshold_config.rssi_hysteresis + |
| 488 | // pHddTdlsCtx->ap_rssi)) { |
| 489 | // |
| 490 | //#ifdef CONFIG_TDLS_IMPLICIT |
| 491 | // cfg80211_tdls_oper_request(pHddTdlsCtx->dev, |
| 492 | // curr_peer->peerMac, |
| 493 | // NL80211_TDLS_TEARDOWN, FALSE, |
| 494 | // GFP_KERNEL); |
| 495 | //#endif |
| 496 | // } |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 497 | } |
Chilam Ng | 0112041 | 2013-02-19 18:32:21 -0800 | [diff] [blame] | 498 | } else if (eTDLS_CAP_UNKNOWN == curr_peer->tdls_support) { |
Sunil Dutt | 961ecbd | 2013-11-28 20:04:07 +0530 | [diff] [blame] | 499 | |
| 500 | if (pHddCtx->cfg_ini->fTDLSExternalControl && |
| 501 | (FALSE == curr_peer->isForcedPeer)) { |
| 502 | continue; |
| 503 | } |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 504 | if (!TDLS_IS_CONNECTED(curr_peer)) { |
Chilam Ng | 0112041 | 2013-02-19 18:32:21 -0800 | [diff] [blame] | 505 | if (curr_peer->tx_pkt >= |
| 506 | pHddTdlsCtx->threshold_config.tx_packet_n) { |
Chilam Ng | 0112041 | 2013-02-19 18:32:21 -0800 | [diff] [blame] | 507 | |
Sunil Dutt | b0d3924 | 2014-09-10 23:54:51 +0530 | [diff] [blame] | 508 | /* Ignore discovery attempt if External Control is enabled, that |
| 509 | * is, peer is forced. In that case, continue discovery attempt |
| 510 | * regardless attempt count |
| 511 | */ |
| 512 | if (curr_peer->isForcedPeer || curr_peer->discovery_attempt++ < |
Chilam Ng | 0112041 | 2013-02-19 18:32:21 -0800 | [diff] [blame] | 513 | pHddTdlsCtx->threshold_config.discovery_tries_n) { |
Masti, Narayanraddi | 34e0e56 | 2015-03-05 18:23:03 +0530 | [diff] [blame] | 514 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 515 | "TDLS UNKNOWN discover "); |
Hoonki Lee | d37cbb3 | 2013-04-20 00:31:14 -0700 | [diff] [blame] | 516 | #ifdef CONFIG_TDLS_IMPLICIT |
Pradeep Reddy POTTETI | 9db32f0 | 2015-01-29 15:22:54 +0530 | [diff] [blame] | 517 | pHddTdlsCtx->curr_candidate = curr_peer; |
| 518 | wlan_hdd_tdls_implicit_send_discovery_request(pHddTdlsCtx); |
Hoonki Lee | d37cbb3 | 2013-04-20 00:31:14 -0700 | [diff] [blame] | 519 | #endif |
Chilam Ng | 0112041 | 2013-02-19 18:32:21 -0800 | [diff] [blame] | 520 | } |
Gopichand Nakkala | 901e892 | 2013-03-04 23:45:58 -0800 | [diff] [blame] | 521 | else |
Gopichand Nakkala | 8b00c63 | 2013-03-08 19:47:52 -0800 | [diff] [blame] | 522 | { |
Gopichand Nakkala | 901e892 | 2013-03-04 23:45:58 -0800 | [diff] [blame] | 523 | curr_peer->tdls_support = eTDLS_CAP_NOT_SUPPORTED; |
Atul Mittal | 115287b | 2014-07-08 13:26:33 +0530 | [diff] [blame] | 524 | wlan_hdd_tdls_set_peer_link_status( |
| 525 | curr_peer, |
| 526 | eTDLS_LINK_IDLE, |
| 527 | eTDLS_LINK_NOT_SUPPORTED); |
| 528 | |
Gopichand Nakkala | 8b00c63 | 2013-03-08 19:47:52 -0800 | [diff] [blame] | 529 | } |
Chilam Ng | 0112041 | 2013-02-19 18:32:21 -0800 | [diff] [blame] | 530 | } |
| 531 | } |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 532 | } |
| 533 | |
Hoonki Lee | cdd8e96 | 2013-01-20 00:45:46 -0800 | [diff] [blame] | 534 | next_peer: |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 535 | curr_peer->tx_pkt = 0; |
Chilam Ng | 1279e23 | 2013-01-25 15:06:52 -0800 | [diff] [blame] | 536 | curr_peer->rx_pkt = 0; |
Hoonki Lee | 387663d | 2013-02-05 18:08:43 -0800 | [diff] [blame] | 537 | } |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 538 | } |
| 539 | |
Gopichand Nakkala | 3046fc9 | 2013-03-23 13:56:43 -0700 | [diff] [blame] | 540 | wlan_hdd_tdls_timer_restart(pHddTdlsCtx->pAdapter, |
| 541 | &pHddTdlsCtx->peerUpdateTimer, |
| 542 | pHddTdlsCtx->threshold_config.tx_period_t); |
Madan Mohan Koyyalamudi | 263cec1 | 2013-10-07 10:57:50 +0530 | [diff] [blame] | 543 | mutex_unlock(&pHddCtx->tdls_lock); |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 544 | EXIT(); |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 545 | } |
| 546 | |
Chilam Ng | 1279e23 | 2013-01-25 15:06:52 -0800 | [diff] [blame] | 547 | static v_VOID_t wlan_hdd_tdls_idle_cb( v_PVOID_t userData ) |
| 548 | { |
Lee Hoonki | c1262f2 | 2013-01-24 21:59:00 -0800 | [diff] [blame] | 549 | #ifdef CONFIG_TDLS_IMPLICIT |
Mahesh A Saptasagar | 170b508 | 2015-02-16 18:50:54 +0530 | [diff] [blame] | 550 | hddTdlsPeer_t *curr_peer; |
Madan Mohan Koyyalamudi | 263cec1 | 2013-10-07 10:57:50 +0530 | [diff] [blame] | 551 | tdlsCtx_t *pHddTdlsCtx; |
| 552 | hdd_context_t *pHddCtx; |
Mahesh A Saptasagar | 170b508 | 2015-02-16 18:50:54 +0530 | [diff] [blame] | 553 | v_CONTEXT_t pVosContext; |
Chilam Ng | 1279e23 | 2013-01-25 15:06:52 -0800 | [diff] [blame] | 554 | |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 555 | ENTER(); |
| 556 | |
Mahesh A Saptasagar | 170b508 | 2015-02-16 18:50:54 +0530 | [diff] [blame] | 557 | pVosContext = vos_get_global_context(VOS_MODULE_ID_HDD, NULL); |
| 558 | if (NULL == pVosContext) |
| 559 | { |
| 560 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 561 | FL("pVosContext points to NULL")); |
| 562 | return; |
| 563 | } |
| 564 | pHddCtx = vos_get_context(VOS_MODULE_ID_HDD, pVosContext); |
| 565 | if (0 != (wlan_hdd_validate_context(pHddCtx))) |
| 566 | { |
Mahesh A Saptasagar | 170b508 | 2015-02-16 18:50:54 +0530 | [diff] [blame] | 567 | return; |
| 568 | } |
| 569 | |
| 570 | mutex_lock(&pHddCtx->tdls_lock); |
| 571 | |
| 572 | curr_peer = (hddTdlsPeer_t *)userData; |
Rajesh Chauhan | 1ace600 | 2013-04-18 18:08:21 -0700 | [diff] [blame] | 573 | if (NULL == curr_peer) |
| 574 | { |
Mahesh A Saptasagar | 170b508 | 2015-02-16 18:50:54 +0530 | [diff] [blame] | 575 | mutex_unlock(&pHddCtx->tdls_lock); |
Rajesh Chauhan | 1ace600 | 2013-04-18 18:08:21 -0700 | [diff] [blame] | 576 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 577 | FL("Invalid tdls idle timer expired")); |
Rajesh Chauhan | 1ace600 | 2013-04-18 18:08:21 -0700 | [diff] [blame] | 578 | return; |
| 579 | } |
Mahesh A Saptasagar | 170b508 | 2015-02-16 18:50:54 +0530 | [diff] [blame] | 580 | |
Madan Mohan Koyyalamudi | 263cec1 | 2013-10-07 10:57:50 +0530 | [diff] [blame] | 581 | pHddTdlsCtx = curr_peer->pHddTdlsCtx; |
Mahesh A Saptasagar | 170b508 | 2015-02-16 18:50:54 +0530 | [diff] [blame] | 582 | if (0 != (wlan_hdd_validate_tdls_context(pHddCtx, pHddTdlsCtx))) |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 583 | { |
Mahesh A Saptasagar | 170b508 | 2015-02-16 18:50:54 +0530 | [diff] [blame] | 584 | mutex_unlock(&pHddCtx->tdls_lock); |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 585 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Mahesh A Saptasagar | 170b508 | 2015-02-16 18:50:54 +0530 | [diff] [blame] | 586 | FL("Invalid pHddTdlsCtx context")); |
Madan Mohan Koyyalamudi | 263cec1 | 2013-10-07 10:57:50 +0530 | [diff] [blame] | 587 | return; |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 588 | } |
Rajesh Chauhan | 1ace600 | 2013-04-18 18:08:21 -0700 | [diff] [blame] | 589 | |
Masti, Narayanraddi | 34e0e56 | 2015-03-05 18:23:03 +0530 | [diff] [blame] | 590 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 591 | "%s: Tx/Rx Idle " MAC_ADDRESS_STR " tx_pkt: %d, rx_pkt: %d, idle_packet_n: %d", |
Rajesh Chauhan | 1ace600 | 2013-04-18 18:08:21 -0700 | [diff] [blame] | 592 | __func__, MAC_ADDR_ARRAY(curr_peer->peerMac), |
| 593 | curr_peer->tx_pkt, |
| 594 | curr_peer->rx_pkt, |
| 595 | curr_peer->pHddTdlsCtx->threshold_config.idle_packet_n); |
| 596 | |
Rajesh Chauhan | 1ace600 | 2013-04-18 18:08:21 -0700 | [diff] [blame] | 597 | /* Check tx/rx statistics on this tdls link for recent activities and |
| 598 | * then decide whether to tear down the link or keep it. |
| 599 | */ |
| 600 | if ((curr_peer->tx_pkt >= curr_peer->pHddTdlsCtx->threshold_config.idle_packet_n) || (curr_peer->rx_pkt >= curr_peer->pHddTdlsCtx->threshold_config.idle_packet_n)) |
| 601 | { |
| 602 | /* this tdls link got back to normal, so keep it */ |
Masti, Narayanraddi | 34e0e56 | 2015-03-05 18:23:03 +0530 | [diff] [blame] | 603 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Rajesh Chauhan | 1ace600 | 2013-04-18 18:08:21 -0700 | [diff] [blame] | 604 | "%s: tdls link to " MAC_ADDRESS_STR " back to normal, will stay", |
| 605 | __func__, MAC_ADDR_ARRAY(curr_peer->peerMac)); |
| 606 | } |
| 607 | else |
| 608 | { |
| 609 | /* this tdls link needs to get torn down */ |
Masti, Narayanraddi | 34e0e56 | 2015-03-05 18:23:03 +0530 | [diff] [blame] | 610 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Rajesh Chauhan | 1ace600 | 2013-04-18 18:08:21 -0700 | [diff] [blame] | 611 | "%s: trigger tdls link to " MAC_ADDRESS_STR " down", |
| 612 | __func__, MAC_ADDR_ARRAY(curr_peer->peerMac)); |
| 613 | |
| 614 | wlan_hdd_tdls_indicate_teardown(curr_peer->pHddTdlsCtx->pAdapter, |
| 615 | curr_peer, |
| 616 | eSIR_MAC_TDLS_TEARDOWN_UNSPEC_REASON); |
| 617 | } |
Madan Mohan Koyyalamudi | 263cec1 | 2013-10-07 10:57:50 +0530 | [diff] [blame] | 618 | mutex_unlock(&pHddCtx->tdls_lock); |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 619 | EXIT(); |
Chilam Ng | 1279e23 | 2013-01-25 15:06:52 -0800 | [diff] [blame] | 620 | #endif |
| 621 | } |
| 622 | |
Gopichand Nakkala | 75e7b28 | 2013-03-15 18:37:13 -0700 | [diff] [blame] | 623 | static v_VOID_t wlan_hdd_tdls_discovery_timeout_peer_cb(v_PVOID_t userData) |
| 624 | { |
Gopichand Nakkala | ccd3a38 | 2013-03-19 13:56:10 -0700 | [diff] [blame] | 625 | int i; |
| 626 | struct list_head *head; |
| 627 | hddTdlsPeer_t *tmp; |
| 628 | struct list_head *pos, *q; |
Gopichand Nakkala | 75e7b28 | 2013-03-15 18:37:13 -0700 | [diff] [blame] | 629 | tdlsCtx_t *pHddTdlsCtx; |
Madan Mohan Koyyalamudi | 263cec1 | 2013-10-07 10:57:50 +0530 | [diff] [blame] | 630 | hdd_context_t *pHddCtx; |
Mahesh A Saptasagar | 170b508 | 2015-02-16 18:50:54 +0530 | [diff] [blame] | 631 | v_CONTEXT_t pVosContext; |
Gopichand Nakkala | 75e7b28 | 2013-03-15 18:37:13 -0700 | [diff] [blame] | 632 | |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 633 | ENTER(); |
Mahesh A Saptasagar | 170b508 | 2015-02-16 18:50:54 +0530 | [diff] [blame] | 634 | pVosContext = vos_get_global_context(VOS_MODULE_ID_HDD, NULL); |
| 635 | if (NULL == pVosContext) |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 636 | { |
| 637 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Mahesh A Saptasagar | 170b508 | 2015-02-16 18:50:54 +0530 | [diff] [blame] | 638 | FL("pVosContext points to NULL")); |
Madan Mohan Koyyalamudi | 263cec1 | 2013-10-07 10:57:50 +0530 | [diff] [blame] | 639 | return; |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 640 | } |
Madan Mohan Koyyalamudi | 263cec1 | 2013-10-07 10:57:50 +0530 | [diff] [blame] | 641 | |
Mahesh A Saptasagar | 170b508 | 2015-02-16 18:50:54 +0530 | [diff] [blame] | 642 | pHddCtx = vos_get_context(VOS_MODULE_ID_HDD, pVosContext); |
| 643 | if (0 != (wlan_hdd_validate_context(pHddCtx))) |
Sushant Kaushik | 15c4c52 | 2014-08-14 12:24:49 +0530 | [diff] [blame] | 644 | { |
Madan Mohan Koyyalamudi | 263cec1 | 2013-10-07 10:57:50 +0530 | [diff] [blame] | 645 | return; |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 646 | } |
Madan Mohan Koyyalamudi | 263cec1 | 2013-10-07 10:57:50 +0530 | [diff] [blame] | 647 | |
Rajesh Chauhan | a34c6e6 | 2014-03-25 16:37:58 +0530 | [diff] [blame] | 648 | mutex_lock(&pHddCtx->tdls_lock); |
Gopichand Nakkala | ccd3a38 | 2013-03-19 13:56:10 -0700 | [diff] [blame] | 649 | |
Mahesh A Saptasagar | 170b508 | 2015-02-16 18:50:54 +0530 | [diff] [blame] | 650 | pHddTdlsCtx = (tdlsCtx_t *)userData; |
| 651 | if (0 != (wlan_hdd_validate_tdls_context(pHddCtx, pHddTdlsCtx))) |
| 652 | { |
| 653 | mutex_unlock(&pHddCtx->tdls_lock); |
| 654 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 655 | FL("Invalid pHddTdlsCtx context")); |
| 656 | return; |
| 657 | } |
| 658 | |
Gopichand Nakkala | ccd3a38 | 2013-03-19 13:56:10 -0700 | [diff] [blame] | 659 | for (i = 0; i < 256; i++) { |
| 660 | head = &pHddTdlsCtx->peer_list[i]; |
| 661 | list_for_each_safe (pos, q, head) { |
| 662 | tmp = list_entry(pos, hddTdlsPeer_t, node); |
| 663 | if (eTDLS_LINK_DISCOVERING == tmp->link_status) |
| 664 | { |
Masti, Narayanraddi | 34e0e56 | 2015-03-05 18:23:03 +0530 | [diff] [blame] | 665 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Gopichand Nakkala | ccd3a38 | 2013-03-19 13:56:10 -0700 | [diff] [blame] | 666 | "%s: " MAC_ADDRESS_STR " to idle state", __func__, |
| 667 | MAC_ADDR_ARRAY(tmp->peerMac)); |
Atul Mittal | 115287b | 2014-07-08 13:26:33 +0530 | [diff] [blame] | 668 | wlan_hdd_tdls_set_peer_link_status( |
| 669 | tmp, |
| 670 | eTDLS_LINK_IDLE, |
Atul Mittal | ad630e4 | 2014-10-07 19:19:14 +0530 | [diff] [blame] | 671 | eTDLS_LINK_NOT_SUPPORTED); |
Gopichand Nakkala | ccd3a38 | 2013-03-19 13:56:10 -0700 | [diff] [blame] | 672 | } |
| 673 | } |
| 674 | } |
Gopichand Nakkala | 75e7b28 | 2013-03-15 18:37:13 -0700 | [diff] [blame] | 675 | |
| 676 | pHddTdlsCtx->discovery_sent_cnt = 0; |
Gopichand Nakkala | 34d1b06 | 2013-03-19 15:28:33 -0700 | [diff] [blame] | 677 | wlan_hdd_tdls_check_power_save_prohibited(pHddTdlsCtx->pAdapter); |
Gopichand Nakkala | ccd3a38 | 2013-03-19 13:56:10 -0700 | [diff] [blame] | 678 | |
Madan Mohan Koyyalamudi | 263cec1 | 2013-10-07 10:57:50 +0530 | [diff] [blame] | 679 | mutex_unlock(&pHddCtx->tdls_lock); |
Gopichand Nakkala | ccd3a38 | 2013-03-19 13:56:10 -0700 | [diff] [blame] | 680 | |
Gopichand Nakkala | 75e7b28 | 2013-03-15 18:37:13 -0700 | [diff] [blame] | 681 | wlan_hdd_tdls_check_bmps(pHddTdlsCtx->pAdapter); |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 682 | EXIT(); |
Gopichand Nakkala | 75e7b28 | 2013-03-15 18:37:13 -0700 | [diff] [blame] | 683 | return; |
| 684 | } |
| 685 | |
Hoonki Lee | 1462135 | 2013-04-16 17:51:19 -0700 | [diff] [blame] | 686 | static v_VOID_t wlan_hdd_tdls_initiator_wait_cb( v_PVOID_t userData ) |
| 687 | { |
| 688 | hddTdlsPeer_t *curr_peer = (hddTdlsPeer_t *)userData; |
| 689 | tdlsCtx_t *pHddTdlsCtx; |
| 690 | |
Mahesh A Saptasagar | 4534e2b | 2015-03-05 20:45:41 +0530 | [diff] [blame] | 691 | ENTER(); |
Hoonki Lee | 1462135 | 2013-04-16 17:51:19 -0700 | [diff] [blame] | 692 | if ( NULL == curr_peer ) |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 693 | { |
| 694 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 695 | FL("curr_peer is NULL")); |
Hoonki Lee | 1462135 | 2013-04-16 17:51:19 -0700 | [diff] [blame] | 696 | return; |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 697 | } |
Hoonki Lee | 1462135 | 2013-04-16 17:51:19 -0700 | [diff] [blame] | 698 | |
| 699 | pHddTdlsCtx = curr_peer->pHddTdlsCtx; |
| 700 | |
| 701 | if ( NULL == pHddTdlsCtx ) |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 702 | { |
| 703 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 704 | FL("pHddTdlsCtx is NULL")); |
Hoonki Lee | 1462135 | 2013-04-16 17:51:19 -0700 | [diff] [blame] | 705 | return; |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 706 | } |
Mahesh A Saptasagar | 4534e2b | 2015-03-05 20:45:41 +0530 | [diff] [blame] | 707 | if (0 != (wlan_hdd_validate_context( |
| 708 | WLAN_HDD_GET_CTX(pHddTdlsCtx->pAdapter)))) |
| 709 | { |
| 710 | return; |
| 711 | } |
Hoonki Lee | 1462135 | 2013-04-16 17:51:19 -0700 | [diff] [blame] | 712 | WLANTL_ResumeDataTx( (WLAN_HDD_GET_CTX(pHddTdlsCtx->pAdapter))->pvosContext, |
| 713 | (v_U8_t *)&curr_peer->staId); |
Mahesh A Saptasagar | 4534e2b | 2015-03-05 20:45:41 +0530 | [diff] [blame] | 714 | EXIT(); |
Hoonki Lee | 1462135 | 2013-04-16 17:51:19 -0700 | [diff] [blame] | 715 | } |
| 716 | |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 717 | static void wlan_hdd_tdls_free_list(tdlsCtx_t *pHddTdlsCtx) |
Gopichand Nakkala | 91b0926 | 2013-02-10 14:27:02 -0800 | [diff] [blame] | 718 | { |
| 719 | int i; |
| 720 | struct list_head *head; |
| 721 | hddTdlsPeer_t *tmp; |
| 722 | struct list_head *pos, *q; |
| 723 | |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 724 | if (NULL == pHddTdlsCtx) |
| 725 | { |
| 726 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 727 | FL("pHddTdlsCtx is NULL")); |
| 728 | return; |
| 729 | } |
Gopichand Nakkala | 91b0926 | 2013-02-10 14:27:02 -0800 | [diff] [blame] | 730 | |
| 731 | for (i = 0; i < 256; i++) { |
| 732 | head = &pHddTdlsCtx->peer_list[i]; |
| 733 | list_for_each_safe (pos, q, head) { |
| 734 | tmp = list_entry(pos, hddTdlsPeer_t, node); |
| 735 | list_del(pos); |
| 736 | vos_mem_free(tmp); |
Srinivas Girigowda | 8d2348f | 2013-12-12 12:14:15 -0800 | [diff] [blame] | 737 | tmp = NULL; |
Gopichand Nakkala | 91b0926 | 2013-02-10 14:27:02 -0800 | [diff] [blame] | 738 | } |
| 739 | } |
Gopichand Nakkala | 91b0926 | 2013-02-10 14:27:02 -0800 | [diff] [blame] | 740 | } |
| 741 | |
Sameer Thalappil | bee426e | 2013-10-30 10:30:30 -0700 | [diff] [blame] | 742 | static void wlan_hdd_tdls_schedule_scan(struct work_struct *work) |
| 743 | { |
| 744 | tdls_scan_context_t *scan_ctx = |
| 745 | container_of(work, tdls_scan_context_t, tdls_scan_work.work); |
| 746 | |
| 747 | if (NULL == scan_ctx) |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 748 | { |
| 749 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 750 | FL("scan_ctx is NULL")); |
Sameer Thalappil | bee426e | 2013-10-30 10:30:30 -0700 | [diff] [blame] | 751 | return; |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 752 | } |
Sameer Thalappil | bee426e | 2013-10-30 10:30:30 -0700 | [diff] [blame] | 753 | |
| 754 | if (unlikely(TDLS_CTX_MAGIC != scan_ctx->magic)) |
| 755 | return; |
| 756 | |
| 757 | scan_ctx->attempt++; |
| 758 | |
| 759 | wlan_hdd_cfg80211_scan(scan_ctx->wiphy, |
| 760 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0)) |
| 761 | scan_ctx->dev, |
| 762 | #endif |
| 763 | scan_ctx->scan_request); |
| 764 | } |
| 765 | |
Pradeep Reddy POTTETI | f0569d7 | 2014-12-13 16:54:03 +0530 | [diff] [blame] | 766 | void wlan_hdd_tdls_btCoex_cb(void *data, int indType) |
| 767 | { |
| 768 | hdd_adapter_t *pAdapter; |
| 769 | hdd_context_t *pHddCtx; |
| 770 | u16 connectedTdlsPeers; |
| 771 | tdlsCtx_t *pHddTdlsCtx; |
| 772 | hddTdlsPeer_t *currPeer; |
| 773 | hdd_scaninfo_t *pScanInfo; |
| 774 | |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 775 | ENTER(); |
Pradeep Reddy POTTETI | f0569d7 | 2014-12-13 16:54:03 +0530 | [diff] [blame] | 776 | if ((NULL == data) || (indType < 0)) |
| 777 | { |
| 778 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 779 | FL("Invalid arguments")); |
| 780 | return; |
| 781 | } |
| 782 | |
| 783 | pHddCtx = (hdd_context_t *)data; |
| 784 | if (0 != (wlan_hdd_validate_context(pHddCtx))) |
| 785 | { |
Pradeep Reddy POTTETI | f0569d7 | 2014-12-13 16:54:03 +0530 | [diff] [blame] | 786 | return; |
| 787 | } |
| 788 | |
| 789 | /* if tdls is not enabled, then continue btCoex */ |
| 790 | if (eTDLS_SUPPORT_NOT_ENABLED == pHddCtx->tdls_mode) |
| 791 | { |
| 792 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 793 | FL("tdls is not enabled")); |
| 794 | return; |
| 795 | } |
| 796 | |
| 797 | /* get pAdapter context, do we need WLAN_HDD_P2P_CLIENT */ |
| 798 | pAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_INFRA_STATION); |
| 799 | if (NULL == pAdapter) |
| 800 | { |
| 801 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 802 | FL("pAdapter is not valid")); |
| 803 | return; |
| 804 | } |
| 805 | |
| 806 | pHddTdlsCtx = WLAN_HDD_GET_TDLS_CTX_PTR(pAdapter); |
| 807 | if (NULL == pHddTdlsCtx) |
| 808 | { |
| 809 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 810 | FL("pHddTdlsCtx is not valid")); |
| 811 | return; |
| 812 | } |
| 813 | |
| 814 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 815 | "%s: BtCoex notification type %d", __func__, indType); |
| 816 | /* BtCoex notification type enabled, Disable TDLS */ |
| 817 | if (indType == SIR_COEX_IND_TYPE_TDLS_DISABLE) |
| 818 | { |
Masti, Narayanraddi | 34e0e56 | 2015-03-05 18:23:03 +0530 | [diff] [blame] | 819 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Pradeep Reddy POTTETI | f0569d7 | 2014-12-13 16:54:03 +0530 | [diff] [blame] | 820 | FL("BtCoex notification, Disable TDLS")); |
| 821 | |
| 822 | pScanInfo = &pHddCtx->scan_info; |
| 823 | // Lets do abort scan if scan is pending |
| 824 | if ((pScanInfo != NULL) && pScanInfo->mScanPending) |
| 825 | { |
| 826 | hdd_abort_mac_scan(pHddCtx, pScanInfo->sessionId, |
| 827 | eCSR_SCAN_ABORT_DEFAULT); |
| 828 | } |
| 829 | |
| 830 | /* tdls is in progress */ |
Pradeep Reddy POTTETI | 9db32f0 | 2015-01-29 15:22:54 +0530 | [diff] [blame] | 831 | currPeer = wlan_hdd_tdls_is_progress(pHddCtx, NULL, 0, TRUE); |
Pradeep Reddy POTTETI | f0569d7 | 2014-12-13 16:54:03 +0530 | [diff] [blame] | 832 | if (NULL != currPeer) |
| 833 | { |
| 834 | wlan_hdd_tdls_set_peer_link_status (currPeer, |
| 835 | eTDLS_LINK_IDLE, |
| 836 | eTDLS_LINK_UNSPECIFIED); |
| 837 | } |
| 838 | |
| 839 | /* while tdls is up */ |
| 840 | if (eTDLS_SUPPORT_ENABLED == pHddCtx->tdls_mode || |
| 841 | eTDLS_SUPPORT_EXPLICIT_TRIGGER_ONLY == pHddCtx->tdls_mode) |
| 842 | { |
| 843 | connectedTdlsPeers = wlan_hdd_tdlsConnectedPeers(pAdapter); |
| 844 | /* disable implicit trigger logic & tdls operatoin */ |
| 845 | wlan_hdd_tdls_set_mode(pHddCtx, eTDLS_SUPPORT_DISABLED, FALSE); |
| 846 | pHddCtx->is_tdls_btc_enabled = FALSE; |
| 847 | |
| 848 | /* teardown the peers on the btcoex */ |
| 849 | if (connectedTdlsPeers) |
| 850 | { |
| 851 | tANI_U8 staIdx; |
| 852 | hddTdlsPeer_t *curr_peer; |
| 853 | |
| 854 | for (staIdx = 0; staIdx < HDD_MAX_NUM_TDLS_STA; staIdx++) |
| 855 | { |
| 856 | if (pHddCtx->tdlsConnInfo[staIdx].staId) |
| 857 | { |
Masti, Narayanraddi | 34e0e56 | 2015-03-05 18:23:03 +0530 | [diff] [blame] | 858 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 859 | ("%s: indicate TDLS teardown (staId %d)"), |
Pradeep Reddy POTTETI | f0569d7 | 2014-12-13 16:54:03 +0530 | [diff] [blame] | 860 | __func__,pHddCtx->tdlsConnInfo[staIdx].staId); |
| 861 | |
| 862 | #ifdef CONFIG_TDLS_IMPLICIT |
| 863 | curr_peer = wlan_hdd_tdls_find_all_peer(pHddCtx, |
| 864 | pHddCtx->tdlsConnInfo[staIdx].peerMac.bytes); |
| 865 | if(curr_peer) { |
| 866 | wlan_hdd_tdls_indicate_teardown( |
| 867 | curr_peer->pHddTdlsCtx->pAdapter, curr_peer, |
| 868 | eSIR_MAC_TDLS_TEARDOWN_UNSPEC_REASON); |
| 869 | } |
| 870 | #endif |
| 871 | } |
| 872 | } |
| 873 | } |
| 874 | } |
| 875 | } |
| 876 | /* BtCoex notification type enabled, Enable TDLS */ |
| 877 | else if (indType == SIR_COEX_IND_TYPE_TDLS_ENABLE) |
| 878 | { |
Masti, Narayanraddi | 34e0e56 | 2015-03-05 18:23:03 +0530 | [diff] [blame] | 879 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Pradeep Reddy POTTETI | f0569d7 | 2014-12-13 16:54:03 +0530 | [diff] [blame] | 880 | FL("BtCoex notification, Enable TDLS")); |
| 881 | /* if tdls was enabled before btCoex, re-enable tdls mode */ |
| 882 | if (eTDLS_SUPPORT_ENABLED == pHddCtx->tdls_mode_last || |
| 883 | eTDLS_SUPPORT_EXPLICIT_TRIGGER_ONLY == pHddCtx->tdls_mode_last) |
| 884 | { |
Masti, Narayanraddi | 34e0e56 | 2015-03-05 18:23:03 +0530 | [diff] [blame] | 885 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Pradeep Reddy POTTETI | f0569d7 | 2014-12-13 16:54:03 +0530 | [diff] [blame] | 886 | ("%s: revert tdls mode %d"), __func__, |
| 887 | pHddCtx->tdls_mode_last); |
| 888 | pHddCtx->is_tdls_btc_enabled = TRUE; |
| 889 | wlan_hdd_tdls_set_mode(pHddCtx, pHddCtx->tdls_mode_last, FALSE); |
| 890 | } |
| 891 | } |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 892 | EXIT(); |
Pradeep Reddy POTTETI | f0569d7 | 2014-12-13 16:54:03 +0530 | [diff] [blame] | 893 | return; |
| 894 | } |
| 895 | |
Agarwal Ashish | 4b87f92 | 2014-06-18 03:03:21 +0530 | [diff] [blame] | 896 | /* initialize TDLS global context */ |
| 897 | void wlan_hdd_tdls_init(hdd_context_t *pHddCtx ) |
| 898 | { |
| 899 | v_U8_t staIdx; |
Chandrasekaran, Manishekar | 0de84dc | 2015-03-10 15:12:34 +0530 | [diff] [blame] | 900 | eHalStatus status; |
Sameer Thalappil | bee426e | 2013-10-30 10:30:30 -0700 | [diff] [blame] | 901 | |
Agarwal Ashish | 4b87f92 | 2014-06-18 03:03:21 +0530 | [diff] [blame] | 902 | pHddCtx->connected_peer_count = 0; |
| 903 | |
| 904 | pHddCtx->tdls_scan_ctxt.magic = 0; |
| 905 | pHddCtx->tdls_scan_ctxt.attempt = 0; |
| 906 | pHddCtx->tdls_scan_ctxt.reject = 0; |
| 907 | pHddCtx->tdls_scan_ctxt.scan_request = NULL; |
| 908 | |
| 909 | for (staIdx = 0; staIdx < HDD_MAX_NUM_TDLS_STA; staIdx++) |
| 910 | { |
| 911 | pHddCtx->tdlsConnInfo[staIdx].staId = 0; |
| 912 | pHddCtx->tdlsConnInfo[staIdx].sessionId = 255; |
| 913 | vos_mem_zero(&pHddCtx->tdlsConnInfo[staIdx].peerMac, |
| 914 | sizeof(v_MACADDR_t)) ; |
| 915 | } |
Pradeep Reddy POTTETI | f0569d7 | 2014-12-13 16:54:03 +0530 | [diff] [blame] | 916 | pHddCtx->is_tdls_btc_enabled = TRUE; |
Chandrasekaran, Manishekar | 0de84dc | 2015-03-10 15:12:34 +0530 | [diff] [blame] | 917 | status = sme_RegisterBtCoexTDLSCallback(pHddCtx->hHal, |
| 918 | wlan_hdd_tdls_btCoex_cb); |
| 919 | if (status != eHAL_STATUS_SUCCESS) { |
| 920 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to register BT Coex TDLS callback")); |
| 921 | } |
Agarwal Ashish | 4b87f92 | 2014-06-18 03:03:21 +0530 | [diff] [blame] | 922 | |
| 923 | if (FALSE == pHddCtx->cfg_ini->fEnableTDLSImplicitTrigger) |
| 924 | { |
| 925 | pHddCtx->tdls_mode = eTDLS_SUPPORT_EXPLICIT_TRIGGER_ONLY; |
| 926 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s TDLS Implicit trigger not enabled!", __func__); |
| 927 | } |
| 928 | else |
| 929 | { |
| 930 | pHddCtx->tdls_mode = eTDLS_SUPPORT_ENABLED; |
| 931 | } |
| 932 | } |
| 933 | |
| 934 | int wlan_hdd_sta_tdls_init(hdd_adapter_t *pAdapter) |
Chilam Ng | 0112041 | 2013-02-19 18:32:21 -0800 | [diff] [blame] | 935 | { |
Chilam Ng | 0112041 | 2013-02-19 18:32:21 -0800 | [diff] [blame] | 936 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter ); |
Hoonki Lee | 2751190 | 2013-03-14 18:19:06 -0700 | [diff] [blame] | 937 | tdlsCtx_t *pHddTdlsCtx; |
Chilam Ng | 0112041 | 2013-02-19 18:32:21 -0800 | [diff] [blame] | 938 | int i; |
Sunil Dutt | 66485cb | 2013-12-19 19:05:03 +0530 | [diff] [blame] | 939 | if (NULL == pHddCtx) |
Mahesh A Saptasagar | 36cdc80 | 2015-01-07 18:41:17 +0530 | [diff] [blame] | 940 | { |
| 941 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s pHddCtx is NULL", __func__); |
Mahesh A Saptasagar | 170b508 | 2015-02-16 18:50:54 +0530 | [diff] [blame] | 942 | return -EINVAL; |
Mahesh A Saptasagar | 36cdc80 | 2015-01-07 18:41:17 +0530 | [diff] [blame] | 943 | } |
Sunil Dutt | 66485cb | 2013-12-19 19:05:03 +0530 | [diff] [blame] | 944 | |
Mahesh A Saptasagar | f5b8eff | 2015-01-31 01:07:07 +0530 | [diff] [blame] | 945 | if (test_bit(TDLS_INIT_DONE, &pAdapter->event_flags)) |
| 946 | { |
| 947 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Mahesh A Saptasagar | 170b508 | 2015-02-16 18:50:54 +0530 | [diff] [blame] | 948 | "%s: TDLS INIT DONE set to 1, no point in re-init", __func__); |
| 949 | return -EALREADY; |
Mahesh A Saptasagar | f5b8eff | 2015-01-31 01:07:07 +0530 | [diff] [blame] | 950 | } |
Sunil Dutt | 66485cb | 2013-12-19 19:05:03 +0530 | [diff] [blame] | 951 | |
Hoonki Lee | 2751190 | 2013-03-14 18:19:06 -0700 | [diff] [blame] | 952 | if ((FALSE == pHddCtx->cfg_ini->fEnableTDLSSupport) || |
| 953 | (FALSE == sme_IsFeatureSupportedByFW(TDLS))) |
| 954 | { |
| 955 | pHddCtx->tdls_mode = eTDLS_SUPPORT_NOT_ENABLED; |
| 956 | pAdapter->sessionCtx.station.pHddTdlsCtx = NULL; |
| 957 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s TDLS not enabled (%d) or FW doesn't support (%d)!", |
| 958 | __func__, pHddCtx->cfg_ini->fEnableTDLSSupport, |
| 959 | sme_IsFeatureSupportedByFW(TDLS)); |
Mahesh A Saptasagar | 170b508 | 2015-02-16 18:50:54 +0530 | [diff] [blame] | 960 | return -EINVAL; |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 961 | } |
Madan Mohan Koyyalamudi | 8174692 | 2013-07-17 14:38:51 +0530 | [diff] [blame] | 962 | /* TDLS is supported only in STA / P2P Client modes, |
| 963 | * hence the check for TDLS support in a specific Device mode. |
Madan Mohan Koyyalamudi | 8174692 | 2013-07-17 14:38:51 +0530 | [diff] [blame] | 964 | */ |
| 965 | if (0 == WLAN_HDD_IS_TDLS_SUPPORTED_ADAPTER(pAdapter)) |
| 966 | { |
Mahesh A Saptasagar | 36cdc80 | 2015-01-07 18:41:17 +0530 | [diff] [blame] | 967 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s TDLS is not supported in mode : %d", __func__, pAdapter->device_mode); |
Mahesh A Saptasagar | 170b508 | 2015-02-16 18:50:54 +0530 | [diff] [blame] | 968 | return -EINVAL; |
Madan Mohan Koyyalamudi | 8174692 | 2013-07-17 14:38:51 +0530 | [diff] [blame] | 969 | } |
| 970 | /* Check for the valid pHddTdlsCtx. If valid do not further |
| 971 | * allocate the memory, rather continue with the initialization. |
| 972 | * If tdls_initialization would get reinvoked without tdls_exit |
| 973 | * getting invoked (SSR) there is no point to further proceed |
| 974 | * with the memory allocations. |
| 975 | */ |
| 976 | if (NULL == pAdapter->sessionCtx.station.pHddTdlsCtx) |
| 977 | { |
| 978 | pHddTdlsCtx = vos_mem_malloc(sizeof(tdlsCtx_t)); |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 979 | |
Madan Mohan Koyyalamudi | 8174692 | 2013-07-17 14:38:51 +0530 | [diff] [blame] | 980 | if (NULL == pHddTdlsCtx) { |
| 981 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s malloc failed!", __func__); |
| 982 | pAdapter->sessionCtx.station.pHddTdlsCtx = NULL; |
Mahesh A Saptasagar | 170b508 | 2015-02-16 18:50:54 +0530 | [diff] [blame] | 983 | return -ENOMEM; |
Madan Mohan Koyyalamudi | 8174692 | 2013-07-17 14:38:51 +0530 | [diff] [blame] | 984 | } |
| 985 | /* initialize TDLS pAdater context */ |
| 986 | vos_mem_zero(pHddTdlsCtx, sizeof(tdlsCtx_t)); |
| 987 | #ifdef TDLS_USE_SEPARATE_DISCOVERY_TIMER |
| 988 | vos_timer_init(&pHddTdlsCtx->peerDiscoverTimer, |
| 989 | VOS_TIMER_TYPE_SW, |
| 990 | wlan_hdd_tdls_discover_peer_cb, |
| 991 | pHddTdlsCtx); |
| 992 | #endif |
Hoonki Lee | 2751190 | 2013-03-14 18:19:06 -0700 | [diff] [blame] | 993 | |
Madan Mohan Koyyalamudi | 8174692 | 2013-07-17 14:38:51 +0530 | [diff] [blame] | 994 | vos_timer_init(&pHddTdlsCtx->peerUpdateTimer, |
| 995 | VOS_TIMER_TYPE_SW, |
| 996 | wlan_hdd_tdls_update_peer_cb, |
| 997 | pHddTdlsCtx); |
| 998 | vos_timer_init(&pHddTdlsCtx->peerDiscoveryTimeoutTimer, |
| 999 | VOS_TIMER_TYPE_SW, |
| 1000 | wlan_hdd_tdls_discovery_timeout_peer_cb, |
| 1001 | pHddTdlsCtx); |
| 1002 | |
| 1003 | pAdapter->sessionCtx.station.pHddTdlsCtx = pHddTdlsCtx; |
Hoonki Lee | 2751190 | 2013-03-14 18:19:06 -0700 | [diff] [blame] | 1004 | } |
| 1005 | |
Madan Mohan Koyyalamudi | 8174692 | 2013-07-17 14:38:51 +0530 | [diff] [blame] | 1006 | pHddTdlsCtx = pAdapter->sessionCtx.station.pHddTdlsCtx; |
Hoonki Lee | 2751190 | 2013-03-14 18:19:06 -0700 | [diff] [blame] | 1007 | |
Gopichand Nakkala | ccd3a38 | 2013-03-19 13:56:10 -0700 | [diff] [blame] | 1008 | sme_SetTdlsPowerSaveProhibited(WLAN_HDD_GET_HAL_CTX(pAdapter), 0); |
Hoonki Lee | 2751190 | 2013-03-14 18:19:06 -0700 | [diff] [blame] | 1009 | |
Hoonki Lee | 2751190 | 2013-03-14 18:19:06 -0700 | [diff] [blame] | 1010 | pHddTdlsCtx->pAdapter = pAdapter; |
| 1011 | |
| 1012 | for (i = 0; i < 256; i++) |
| 1013 | { |
| 1014 | INIT_LIST_HEAD(&pHddTdlsCtx->peer_list[i]); |
| 1015 | } |
| 1016 | |
Hoonki Lee | d37cbb3 | 2013-04-20 00:31:14 -0700 | [diff] [blame] | 1017 | pHddTdlsCtx->curr_candidate = NULL; |
| 1018 | pHddTdlsCtx->magic = 0; |
| 1019 | |
Hoonki Lee | 2751190 | 2013-03-14 18:19:06 -0700 | [diff] [blame] | 1020 | /* remember configuration even if it is not used right now. it could be used later */ |
| 1021 | pHddTdlsCtx->threshold_config.tx_period_t = pHddCtx->cfg_ini->fTDLSTxStatsPeriod; |
| 1022 | pHddTdlsCtx->threshold_config.tx_packet_n = pHddCtx->cfg_ini->fTDLSTxPacketThreshold; |
| 1023 | pHddTdlsCtx->threshold_config.discovery_period_t = pHddCtx->cfg_ini->fTDLSDiscoveryPeriod; |
| 1024 | pHddTdlsCtx->threshold_config.discovery_tries_n = pHddCtx->cfg_ini->fTDLSMaxDiscoveryAttempt; |
| 1025 | pHddTdlsCtx->threshold_config.idle_timeout_t = pHddCtx->cfg_ini->fTDLSIdleTimeout; |
| 1026 | pHddTdlsCtx->threshold_config.idle_packet_n = pHddCtx->cfg_ini->fTDLSIdlePacketThreshold; |
| 1027 | pHddTdlsCtx->threshold_config.rssi_hysteresis = pHddCtx->cfg_ini->fTDLSRSSIHysteresis; |
| 1028 | pHddTdlsCtx->threshold_config.rssi_trigger_threshold = pHddCtx->cfg_ini->fTDLSRSSITriggerThreshold; |
| 1029 | pHddTdlsCtx->threshold_config.rssi_teardown_threshold = pHddCtx->cfg_ini->fTDLSRSSITeardownThreshold; |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 1030 | |
Anand N Sunkad | dc63c79 | 2015-06-03 14:33:24 +0530 | [diff] [blame] | 1031 | vos_init_delayed_work(&pHddCtx->tdls_scan_ctxt.tdls_scan_work, |
| 1032 | wlan_hdd_tdls_schedule_scan); |
| 1033 | set_bit(TDLS_INIT_DONE, &pAdapter->event_flags); |
Hoonki Lee | 2751190 | 2013-03-14 18:19:06 -0700 | [diff] [blame] | 1034 | |
| 1035 | return 0; |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 1036 | } |
| 1037 | |
Pradeep Reddy POTTETI | 2d4d5c4 | 2015-03-03 14:34:19 +0530 | [diff] [blame] | 1038 | void wlan_hdd_tdls_exit(hdd_adapter_t *pAdapter, tANI_BOOLEAN mutexLock) |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 1039 | { |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 1040 | tdlsCtx_t *pHddTdlsCtx; |
Hoonki Lee | 93e67ff | 2013-03-19 15:49:25 -0700 | [diff] [blame] | 1041 | hdd_context_t *pHddCtx; |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 1042 | |
Chandrasekaran, Manishekar | 41b8e1f | 2015-03-10 13:30:28 +0530 | [diff] [blame] | 1043 | if (!pAdapter) { |
| 1044 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD adpater is NULL")); |
| 1045 | return; |
| 1046 | } |
| 1047 | |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 1048 | /* |
| 1049 | * NOTE: The Callers of this function should ensure to acquire the |
Mahesh A Saptasagar | f5b8eff | 2015-01-31 01:07:07 +0530 | [diff] [blame] | 1050 | * tdls_lock to avoid any concurrent access to the Adapter and logp |
| 1051 | * protection has to be ensured. |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 1052 | */ |
| 1053 | |
Madan Mohan Koyyalamudi | 263cec1 | 2013-10-07 10:57:50 +0530 | [diff] [blame] | 1054 | pHddCtx = WLAN_HDD_GET_CTX( pAdapter ); |
Agarwal Ashish | 9ffa5b9 | 2014-11-18 21:07:02 +0530 | [diff] [blame] | 1055 | |
| 1056 | if (NULL == pHddCtx || NULL == pHddCtx->cfg_ini) |
Madan Mohan Koyyalamudi | 263cec1 | 2013-10-07 10:57:50 +0530 | [diff] [blame] | 1057 | { |
Agarwal Ashish | 9ffa5b9 | 2014-11-18 21:07:02 +0530 | [diff] [blame] | 1058 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1059 | "%s: HDD context is Null", __func__); |
| 1060 | return ; |
| 1061 | } |
Mahesh A Saptasagar | f5b8eff | 2015-01-31 01:07:07 +0530 | [diff] [blame] | 1062 | if (!test_bit(TDLS_INIT_DONE, &pAdapter->event_flags)) |
Agarwal Ashish | 9ffa5b9 | 2014-11-18 21:07:02 +0530 | [diff] [blame] | 1063 | { |
Mahesh A Saptasagar | f5b8eff | 2015-01-31 01:07:07 +0530 | [diff] [blame] | 1064 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1065 | "%s: TDLS INIT DONE set to 0, no point in exit", __func__); |
| 1066 | return; |
Madan Mohan Koyyalamudi | 263cec1 | 2013-10-07 10:57:50 +0530 | [diff] [blame] | 1067 | } |
Mahesh A Saptasagar | f5b8eff | 2015-01-31 01:07:07 +0530 | [diff] [blame] | 1068 | clear_bit(TDLS_INIT_DONE, &pAdapter->event_flags); |
Madan Mohan Koyyalamudi | 263cec1 | 2013-10-07 10:57:50 +0530 | [diff] [blame] | 1069 | |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 1070 | pHddTdlsCtx = WLAN_HDD_GET_TDLS_CTX_PTR(pAdapter); |
Gopichand Nakkala | 91b0926 | 2013-02-10 14:27:02 -0800 | [diff] [blame] | 1071 | if (NULL == pHddTdlsCtx) |
| 1072 | { |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 1073 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1074 | FL("pHddTdlsCtx is NULL")); |
Hoonki Lee | bfee034 | 2013-01-21 16:43:45 -0800 | [diff] [blame] | 1075 | return; |
| 1076 | } |
Mahesh A Saptasagar | f5b8eff | 2015-01-31 01:07:07 +0530 | [diff] [blame] | 1077 | |
Anand N Sunkad | 860e5ea | 2015-03-30 14:41:51 +0530 | [diff] [blame] | 1078 | vos_flush_delayed_work(&pHddCtx->tdls_scan_ctxt.tdls_scan_work); |
Hoonki Lee | bfee034 | 2013-01-21 16:43:45 -0800 | [diff] [blame] | 1079 | |
Gopichand Nakkala | 91b0926 | 2013-02-10 14:27:02 -0800 | [diff] [blame] | 1080 | /* must stop timer here before freeing peer list, because peerIdleTimer is |
| 1081 | part of peer list structure. */ |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 1082 | wlan_hdd_tdls_timers_destroy(pHddTdlsCtx); |
| 1083 | wlan_hdd_tdls_free_list(pHddTdlsCtx); |
Chilam Ng | a75d8b6 | 2013-01-29 01:35:59 -0800 | [diff] [blame] | 1084 | |
Hoonki Lee | 93e67ff | 2013-03-19 15:49:25 -0700 | [diff] [blame] | 1085 | wlan_hdd_tdls_free_scan_request(&pHddCtx->tdls_scan_ctxt); |
Sushant Kaushik | 15c4c52 | 2014-08-14 12:24:49 +0530 | [diff] [blame] | 1086 | pHddTdlsCtx->magic = 0; |
| 1087 | pHddTdlsCtx->pAdapter = NULL; |
Chilam Ng | a75d8b6 | 2013-01-29 01:35:59 -0800 | [diff] [blame] | 1088 | vos_mem_free(pHddTdlsCtx); |
Pradeep Reddy POTTETI | 59c90d6 | 2014-03-24 19:45:47 +0530 | [diff] [blame] | 1089 | pAdapter->sessionCtx.station.pHddTdlsCtx = NULL; |
Chilam Ng | a75d8b6 | 2013-01-29 01:35:59 -0800 | [diff] [blame] | 1090 | pHddTdlsCtx = NULL; |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 1091 | } |
| 1092 | |
Madan Mohan Koyyalamudi | 693275b | 2013-07-22 19:14:09 +0530 | [diff] [blame] | 1093 | /* stop all monitoring timers per Adapter */ |
| 1094 | static void wlan_hdd_tdls_monitor_timers_stop(tdlsCtx_t *pHddTdlsCtx) |
Gopichand Nakkala | c369458 | 2013-02-13 20:51:22 -0800 | [diff] [blame] | 1095 | { |
Hoonki Lee | d37cbb3 | 2013-04-20 00:31:14 -0700 | [diff] [blame] | 1096 | #ifdef TDLS_USE_SEPARATE_DISCOVERY_TIMER |
Gopichand Nakkala | c369458 | 2013-02-13 20:51:22 -0800 | [diff] [blame] | 1097 | vos_timer_stop(&pHddTdlsCtx->peerDiscoverTimer); |
Hoonki Lee | d37cbb3 | 2013-04-20 00:31:14 -0700 | [diff] [blame] | 1098 | #endif |
Gopichand Nakkala | c369458 | 2013-02-13 20:51:22 -0800 | [diff] [blame] | 1099 | vos_timer_stop(&pHddTdlsCtx->peerUpdateTimer); |
Gopichand Nakkala | 75e7b28 | 2013-03-15 18:37:13 -0700 | [diff] [blame] | 1100 | vos_timer_stop(&pHddTdlsCtx->peerDiscoveryTimeoutTimer); |
Madan Mohan Koyyalamudi | 693275b | 2013-07-22 19:14:09 +0530 | [diff] [blame] | 1101 | } |
Gopichand Nakkala | c369458 | 2013-02-13 20:51:22 -0800 | [diff] [blame] | 1102 | |
Madan Mohan Koyyalamudi | 693275b | 2013-07-22 19:14:09 +0530 | [diff] [blame] | 1103 | /* stop all per peer timers */ |
| 1104 | static void wlan_hdd_tdls_peer_timers_stop(tdlsCtx_t *pHddTdlsCtx) |
| 1105 | { |
| 1106 | int i; |
| 1107 | struct list_head *head; |
| 1108 | struct list_head *pos; |
| 1109 | hddTdlsPeer_t *curr_peer; |
Gopichand Nakkala | c369458 | 2013-02-13 20:51:22 -0800 | [diff] [blame] | 1110 | for (i = 0; i < 256; i++) |
| 1111 | { |
| 1112 | head = &pHddTdlsCtx->peer_list[i]; |
Gopichand Nakkala | c369458 | 2013-02-13 20:51:22 -0800 | [diff] [blame] | 1113 | list_for_each (pos, head) { |
| 1114 | curr_peer = list_entry (pos, hddTdlsPeer_t, node); |
Masti, Narayanraddi | 34e0e56 | 2015-03-05 18:23:03 +0530 | [diff] [blame] | 1115 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Chilam Ng | 0112041 | 2013-02-19 18:32:21 -0800 | [diff] [blame] | 1116 | "%s: " MAC_ADDRESS_STR " -> stop idle timer", |
Gopichand Nakkala | c369458 | 2013-02-13 20:51:22 -0800 | [diff] [blame] | 1117 | __func__, |
Chilam Ng | 0112041 | 2013-02-19 18:32:21 -0800 | [diff] [blame] | 1118 | MAC_ADDR_ARRAY(curr_peer->peerMac)); |
Gopichand Nakkala | c369458 | 2013-02-13 20:51:22 -0800 | [diff] [blame] | 1119 | vos_timer_stop ( &curr_peer->peerIdleTimer ); |
Hoonki Lee | 1462135 | 2013-04-16 17:51:19 -0700 | [diff] [blame] | 1120 | vos_timer_stop( &curr_peer->initiatorWaitTimeoutTimer ); |
Gopichand Nakkala | c369458 | 2013-02-13 20:51:22 -0800 | [diff] [blame] | 1121 | } |
| 1122 | } |
Gopichand Nakkala | c369458 | 2013-02-13 20:51:22 -0800 | [diff] [blame] | 1123 | } |
| 1124 | |
Madan Mohan Koyyalamudi | 693275b | 2013-07-22 19:14:09 +0530 | [diff] [blame] | 1125 | /* stop all the tdls timers running */ |
| 1126 | static void wlan_hdd_tdls_timers_stop(tdlsCtx_t *pHddTdlsCtx) |
Gopichand Nakkala | 91b0926 | 2013-02-10 14:27:02 -0800 | [diff] [blame] | 1127 | { |
Madan Mohan Koyyalamudi | 693275b | 2013-07-22 19:14:09 +0530 | [diff] [blame] | 1128 | wlan_hdd_tdls_monitor_timers_stop(pHddTdlsCtx); |
| 1129 | wlan_hdd_tdls_peer_timers_stop(pHddTdlsCtx); |
| 1130 | } |
Gopichand Nakkala | 91b0926 | 2013-02-10 14:27:02 -0800 | [diff] [blame] | 1131 | |
Madan Mohan Koyyalamudi | 693275b | 2013-07-22 19:14:09 +0530 | [diff] [blame] | 1132 | static void wlan_hdd_tdls_monitor_timers_destroy(tdlsCtx_t *pHddTdlsCtx) |
| 1133 | { |
Hoonki Lee | d37cbb3 | 2013-04-20 00:31:14 -0700 | [diff] [blame] | 1134 | #ifdef TDLS_USE_SEPARATE_DISCOVERY_TIMER |
Gopichand Nakkala | 91b0926 | 2013-02-10 14:27:02 -0800 | [diff] [blame] | 1135 | vos_timer_stop(&pHddTdlsCtx->peerDiscoverTimer); |
| 1136 | vos_timer_destroy(&pHddTdlsCtx->peerDiscoverTimer); |
Hoonki Lee | d37cbb3 | 2013-04-20 00:31:14 -0700 | [diff] [blame] | 1137 | #endif |
Gopichand Nakkala | 91b0926 | 2013-02-10 14:27:02 -0800 | [diff] [blame] | 1138 | vos_timer_stop(&pHddTdlsCtx->peerUpdateTimer); |
| 1139 | vos_timer_destroy(&pHddTdlsCtx->peerUpdateTimer); |
Gopichand Nakkala | 75e7b28 | 2013-03-15 18:37:13 -0700 | [diff] [blame] | 1140 | vos_timer_stop(&pHddTdlsCtx->peerDiscoveryTimeoutTimer); |
| 1141 | vos_timer_destroy(&pHddTdlsCtx->peerDiscoveryTimeoutTimer); |
Madan Mohan Koyyalamudi | 693275b | 2013-07-22 19:14:09 +0530 | [diff] [blame] | 1142 | } |
| 1143 | /*Free all the timers related to the TDLS peer */ |
| 1144 | static void wlan_hdd_tdls_peer_timers_destroy(tdlsCtx_t *pHddTdlsCtx) |
| 1145 | { |
| 1146 | int i; |
| 1147 | struct list_head *head; |
| 1148 | struct list_head *pos; |
| 1149 | hddTdlsPeer_t *curr_peer; |
Gopichand Nakkala | 91b0926 | 2013-02-10 14:27:02 -0800 | [diff] [blame] | 1150 | for (i = 0; i < 256; i++) |
| 1151 | { |
| 1152 | head = &pHddTdlsCtx->peer_list[i]; |
| 1153 | |
| 1154 | list_for_each (pos, head) { |
| 1155 | curr_peer = list_entry (pos, hddTdlsPeer_t, node); |
| 1156 | |
Masti, Narayanraddi | 34e0e56 | 2015-03-05 18:23:03 +0530 | [diff] [blame] | 1157 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Chilam Ng | 0112041 | 2013-02-19 18:32:21 -0800 | [diff] [blame] | 1158 | "%s: " MAC_ADDRESS_STR " -> destroy idle timer", |
Gopichand Nakkala | 91b0926 | 2013-02-10 14:27:02 -0800 | [diff] [blame] | 1159 | __func__, |
Chilam Ng | 0112041 | 2013-02-19 18:32:21 -0800 | [diff] [blame] | 1160 | MAC_ADDR_ARRAY(curr_peer->peerMac)); |
Gopichand Nakkala | 91b0926 | 2013-02-10 14:27:02 -0800 | [diff] [blame] | 1161 | vos_timer_stop ( &curr_peer->peerIdleTimer ); |
| 1162 | vos_timer_destroy ( &curr_peer->peerIdleTimer ); |
Hoonki Lee | 1462135 | 2013-04-16 17:51:19 -0700 | [diff] [blame] | 1163 | vos_timer_stop(&curr_peer->initiatorWaitTimeoutTimer); |
| 1164 | vos_timer_destroy(&curr_peer->initiatorWaitTimeoutTimer); |
Gopichand Nakkala | 91b0926 | 2013-02-10 14:27:02 -0800 | [diff] [blame] | 1165 | } |
| 1166 | } |
Madan Mohan Koyyalamudi | 693275b | 2013-07-22 19:14:09 +0530 | [diff] [blame] | 1167 | |
| 1168 | } |
| 1169 | |
| 1170 | /* destroy all the tdls timers running */ |
| 1171 | static void wlan_hdd_tdls_timers_destroy(tdlsCtx_t *pHddTdlsCtx) |
| 1172 | { |
| 1173 | wlan_hdd_tdls_monitor_timers_destroy(pHddTdlsCtx); |
| 1174 | wlan_hdd_tdls_peer_timers_destroy(pHddTdlsCtx); |
Gopichand Nakkala | 91b0926 | 2013-02-10 14:27:02 -0800 | [diff] [blame] | 1175 | } |
| 1176 | |
Hoonki Lee | 387663d | 2013-02-05 18:08:43 -0800 | [diff] [blame] | 1177 | /* if mac address exist, return pointer |
| 1178 | if mac address doesn't exist, create a list and add, return pointer |
| 1179 | return NULL if fails to get new mac address |
| 1180 | */ |
Anand N Sunkad | b3ab97d | 2015-07-29 09:58:13 +0530 | [diff] [blame^] | 1181 | hddTdlsPeer_t *wlan_hdd_tdls_get_peer(hdd_adapter_t *pAdapter, |
| 1182 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0)) |
| 1183 | const u8 *mac |
| 1184 | #else |
| 1185 | u8 *mac |
| 1186 | #endif |
| 1187 | ) |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 1188 | { |
Hoonki Lee | 387663d | 2013-02-05 18:08:43 -0800 | [diff] [blame] | 1189 | struct list_head *head; |
| 1190 | hddTdlsPeer_t *peer; |
| 1191 | u8 key; |
Gopichand Nakkala | 4ddf019 | 2013-03-27 13:41:20 -0700 | [diff] [blame] | 1192 | tdlsCtx_t *pHddTdlsCtx; |
Chandrasekaran, Manishekar | 41b8e1f | 2015-03-10 13:30:28 +0530 | [diff] [blame] | 1193 | hdd_context_t *pHddCtx; |
Madan Mohan Koyyalamudi | 263cec1 | 2013-10-07 10:57:50 +0530 | [diff] [blame] | 1194 | |
Chandrasekaran, Manishekar | 41b8e1f | 2015-03-10 13:30:28 +0530 | [diff] [blame] | 1195 | |
| 1196 | if (!pAdapter) { |
| 1197 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD adpater is NULL")); |
| 1198 | return NULL; |
| 1199 | } |
| 1200 | |
| 1201 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 1202 | if (0 != (wlan_hdd_validate_context(pHddCtx))) |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 1203 | { |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 1204 | return 0; |
| 1205 | } |
Hoonki Lee | bfee034 | 2013-01-21 16:43:45 -0800 | [diff] [blame] | 1206 | |
Hoonki Lee | 387663d | 2013-02-05 18:08:43 -0800 | [diff] [blame] | 1207 | /* if already there, just update */ |
Masti, Narayanraddi | 6dbcdbb | 2015-05-13 10:28:06 +0530 | [diff] [blame] | 1208 | peer = wlan_hdd_tdls_find_peer(pAdapter, mac, FALSE); |
Hoonki Lee | 387663d | 2013-02-05 18:08:43 -0800 | [diff] [blame] | 1209 | if (peer != NULL) |
| 1210 | { |
| 1211 | return peer; |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 1212 | } |
| 1213 | |
Hoonki Lee | 387663d | 2013-02-05 18:08:43 -0800 | [diff] [blame] | 1214 | /* not found, allocate and add the list */ |
| 1215 | peer = vos_mem_malloc(sizeof(hddTdlsPeer_t)); |
| 1216 | if (NULL == peer) { |
| 1217 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s peer malloc failed!", __func__); |
| 1218 | return NULL; |
| 1219 | } |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 1220 | |
Gopichand Nakkala | 4ddf019 | 2013-03-27 13:41:20 -0700 | [diff] [blame] | 1221 | pHddTdlsCtx = WLAN_HDD_GET_TDLS_CTX_PTR(pAdapter); |
| 1222 | |
| 1223 | if (NULL == pHddTdlsCtx) |
| 1224 | { |
| 1225 | vos_mem_free(peer); |
Hema Aparna Medicharla | 8bb6f78 | 2015-03-09 12:35:05 +0530 | [diff] [blame] | 1226 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 1227 | FL("pHddTdlsCtx is NULL")); |
Gopichand Nakkala | 4ddf019 | 2013-03-27 13:41:20 -0700 | [diff] [blame] | 1228 | return NULL; |
| 1229 | } |
| 1230 | |
| 1231 | key = wlan_hdd_tdls_hash_key(mac); |
| 1232 | head = &pHddTdlsCtx->peer_list[key]; |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 1233 | |
Hoonki Lee | 387663d | 2013-02-05 18:08:43 -0800 | [diff] [blame] | 1234 | vos_mem_zero(peer, sizeof(hddTdlsPeer_t)); |
| 1235 | vos_mem_copy(peer->peerMac, mac, sizeof(peer->peerMac)); |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 1236 | peer->pHddTdlsCtx = pHddTdlsCtx; |
Hoonki Lee | 387663d | 2013-02-05 18:08:43 -0800 | [diff] [blame] | 1237 | |
Gopichand Nakkala | 91b0926 | 2013-02-10 14:27:02 -0800 | [diff] [blame] | 1238 | vos_timer_init(&peer->peerIdleTimer, |
| 1239 | VOS_TIMER_TYPE_SW, |
| 1240 | wlan_hdd_tdls_idle_cb, |
| 1241 | peer); |
| 1242 | |
Hoonki Lee | 1462135 | 2013-04-16 17:51:19 -0700 | [diff] [blame] | 1243 | vos_timer_init(&peer->initiatorWaitTimeoutTimer, |
| 1244 | VOS_TIMER_TYPE_SW, |
| 1245 | wlan_hdd_tdls_initiator_wait_cb, |
| 1246 | peer); |
| 1247 | |
Hoonki Lee | 387663d | 2013-02-05 18:08:43 -0800 | [diff] [blame] | 1248 | list_add_tail(&peer->node, head); |
Hoonki Lee | 387663d | 2013-02-05 18:08:43 -0800 | [diff] [blame] | 1249 | |
| 1250 | return peer; |
| 1251 | } |
| 1252 | |
Gopichand Nakkala | 34d1b06 | 2013-03-19 15:28:33 -0700 | [diff] [blame] | 1253 | int wlan_hdd_tdls_set_cap(hdd_adapter_t *pAdapter, |
Hoonki Lee | 2751190 | 2013-03-14 18:19:06 -0700 | [diff] [blame] | 1254 | u8* mac, |
| 1255 | tTDLSCapType cap) |
| 1256 | { |
| 1257 | hddTdlsPeer_t *curr_peer; |
Masti, Narayanraddi | 6dbcdbb | 2015-05-13 10:28:06 +0530 | [diff] [blame] | 1258 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
Hoonki Lee | 2751190 | 2013-03-14 18:19:06 -0700 | [diff] [blame] | 1259 | |
Masti, Narayanraddi | 6dbcdbb | 2015-05-13 10:28:06 +0530 | [diff] [blame] | 1260 | if (0 != (wlan_hdd_validate_context(pHddCtx))) |
| 1261 | return -EINVAL; |
| 1262 | |
| 1263 | mutex_lock(&pHddCtx->tdls_lock); |
Gopichand Nakkala | 34d1b06 | 2013-03-19 15:28:33 -0700 | [diff] [blame] | 1264 | curr_peer = wlan_hdd_tdls_get_peer(pAdapter, mac); |
Hoonki Lee | 2751190 | 2013-03-14 18:19:06 -0700 | [diff] [blame] | 1265 | if (curr_peer == NULL) |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 1266 | { |
| 1267 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1268 | "%s: curr_peer is NULL", __func__); |
Masti, Narayanraddi | 6dbcdbb | 2015-05-13 10:28:06 +0530 | [diff] [blame] | 1269 | mutex_unlock(&pHddCtx->tdls_lock); |
Gopichand Nakkala | 34d1b06 | 2013-03-19 15:28:33 -0700 | [diff] [blame] | 1270 | return -1; |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 1271 | } |
Hoonki Lee | 2751190 | 2013-03-14 18:19:06 -0700 | [diff] [blame] | 1272 | |
| 1273 | curr_peer->tdls_support = cap; |
| 1274 | |
Masti, Narayanraddi | 6dbcdbb | 2015-05-13 10:28:06 +0530 | [diff] [blame] | 1275 | mutex_unlock(&pHddCtx->tdls_lock); |
Gopichand Nakkala | 34d1b06 | 2013-03-19 15:28:33 -0700 | [diff] [blame] | 1276 | return 0; |
Hoonki Lee | 2751190 | 2013-03-14 18:19:06 -0700 | [diff] [blame] | 1277 | } |
| 1278 | |
Atul Mittal | 115287b | 2014-07-08 13:26:33 +0530 | [diff] [blame] | 1279 | void wlan_hdd_tdls_set_peer_link_status(hddTdlsPeer_t *curr_peer, |
| 1280 | tTDLSLinkStatus status, |
| 1281 | tTDLSLinkReason reason) |
Hoonki Lee | 387663d | 2013-02-05 18:08:43 -0800 | [diff] [blame] | 1282 | { |
Atul Mittal | 115287b | 2014-07-08 13:26:33 +0530 | [diff] [blame] | 1283 | /*EXT TDLS*/ |
| 1284 | tANI_S32 state = 0; |
| 1285 | tANI_S32 res = 0; |
| 1286 | /*EXT TDLS*/ |
Hoonki Lee | 387663d | 2013-02-05 18:08:43 -0800 | [diff] [blame] | 1287 | if (curr_peer == NULL) |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 1288 | { |
| 1289 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1290 | "%s: curr_peer is NULL", __func__); |
Hoonki Lee | 387663d | 2013-02-05 18:08:43 -0800 | [diff] [blame] | 1291 | return; |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 1292 | } |
Hoonki Lee | 387663d | 2013-02-05 18:08:43 -0800 | [diff] [blame] | 1293 | |
Gopichand Nakkala | 8b00c63 | 2013-03-08 19:47:52 -0800 | [diff] [blame] | 1294 | hddLog(VOS_TRACE_LEVEL_WARN, "tdls set peer " MAC_ADDRESS_STR " link status to %u", |
Chilam Ng | 0112041 | 2013-02-19 18:32:21 -0800 | [diff] [blame] | 1295 | MAC_ADDR_ARRAY(curr_peer->peerMac), status); |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 1296 | |
| 1297 | curr_peer->link_status = status; |
| 1298 | |
Atul Mittal | 115287b | 2014-07-08 13:26:33 +0530 | [diff] [blame] | 1299 | /*EXT TDLS*/ |
| 1300 | if (curr_peer->isForcedPeer && curr_peer->state_change_notification) |
| 1301 | { |
| 1302 | /*save the reason for any further query*/ |
| 1303 | curr_peer->reason = reason; |
| 1304 | wlan_hdd_tdls_get_wifi_hal_state(curr_peer, &state, &res); |
| 1305 | |
| 1306 | (curr_peer->state_change_notification)( |
| 1307 | curr_peer->peerMac, |
| 1308 | state, |
| 1309 | res, |
| 1310 | curr_peer->pHddTdlsCtx->pAdapter); |
| 1311 | |
| 1312 | } |
| 1313 | /*EXT TDLS*/ |
| 1314 | |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 1315 | } |
| 1316 | |
Gopichand Nakkala | 8b00c63 | 2013-03-08 19:47:52 -0800 | [diff] [blame] | 1317 | void wlan_hdd_tdls_set_link_status(hdd_adapter_t *pAdapter, |
Anand N Sunkad | b3ab97d | 2015-07-29 09:58:13 +0530 | [diff] [blame^] | 1318 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0)) |
| 1319 | const u8 *mac, |
| 1320 | #else |
| 1321 | u8 *mac, |
| 1322 | #endif |
Atul Mittal | 115287b | 2014-07-08 13:26:33 +0530 | [diff] [blame] | 1323 | tTDLSLinkStatus linkStatus, |
| 1324 | tTDLSLinkReason reason) |
Gopichand Nakkala | 8b00c63 | 2013-03-08 19:47:52 -0800 | [diff] [blame] | 1325 | { |
Atul Mittal | 115287b | 2014-07-08 13:26:33 +0530 | [diff] [blame] | 1326 | |
| 1327 | /*EXT TDLS*/ |
| 1328 | tANI_S32 state = 0; |
| 1329 | tANI_S32 res = 0; |
| 1330 | /*EXT TDLS*/ |
Gopichand Nakkala | 8b00c63 | 2013-03-08 19:47:52 -0800 | [diff] [blame] | 1331 | hddTdlsPeer_t *curr_peer; |
| 1332 | |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 1333 | curr_peer = wlan_hdd_tdls_find_peer(pAdapter, mac, TRUE); |
Gopichand Nakkala | 8b00c63 | 2013-03-08 19:47:52 -0800 | [diff] [blame] | 1334 | if (curr_peer == NULL) |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 1335 | { |
| 1336 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1337 | "%s: curr_peer is NULL", __func__); |
Gopichand Nakkala | 8b00c63 | 2013-03-08 19:47:52 -0800 | [diff] [blame] | 1338 | return; |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 1339 | } |
Gopichand Nakkala | 8b00c63 | 2013-03-08 19:47:52 -0800 | [diff] [blame] | 1340 | |
| 1341 | curr_peer->link_status= linkStatus; |
| 1342 | |
Atul Mittal | 115287b | 2014-07-08 13:26:33 +0530 | [diff] [blame] | 1343 | /*EXT TDLS*/ |
| 1344 | |
| 1345 | if (curr_peer->isForcedPeer && curr_peer->state_change_notification) |
| 1346 | { |
| 1347 | /*save the reason for any further query*/ |
| 1348 | curr_peer->reason = reason; |
| 1349 | wlan_hdd_tdls_get_wifi_hal_state(curr_peer, &state, &res); |
| 1350 | |
| 1351 | (*curr_peer->state_change_notification)(mac, |
| 1352 | state, |
| 1353 | res, |
| 1354 | curr_peer->pHddTdlsCtx->pAdapter); |
| 1355 | |
| 1356 | } |
| 1357 | /*EXT TDLS*/ |
Gopichand Nakkala | 8b00c63 | 2013-03-08 19:47:52 -0800 | [diff] [blame] | 1358 | return; |
| 1359 | } |
| 1360 | |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 1361 | int wlan_hdd_tdls_recv_discovery_resp(hdd_adapter_t *pAdapter, u8 *mac) |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 1362 | { |
| 1363 | hddTdlsPeer_t *curr_peer; |
Gopichand Nakkala | 75e7b28 | 2013-03-15 18:37:13 -0700 | [diff] [blame] | 1364 | tdlsCtx_t *pHddTdlsCtx = WLAN_HDD_GET_TDLS_CTX_PTR(pAdapter); |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 1365 | hdd_context_t *pHddCtx; |
| 1366 | |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 1367 | ENTER(); |
| 1368 | |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 1369 | if ( NULL == pHddTdlsCtx ) |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 1370 | { |
| 1371 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Mahesh A Saptasagar | 36cdc80 | 2015-01-07 18:41:17 +0530 | [diff] [blame] | 1372 | FL("pHddTdlsCtx is NULL device mode = %d"), pAdapter->device_mode); |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 1373 | return -1; |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 1374 | } |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 1375 | |
| 1376 | pHddCtx = WLAN_HDD_GET_CTX(pHddTdlsCtx->pAdapter); |
| 1377 | |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 1378 | if(0 != (wlan_hdd_validate_context(pHddCtx))) |
| 1379 | { |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 1380 | return 0; |
| 1381 | } |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 1382 | |
Masti, Narayanraddi | 6dbcdbb | 2015-05-13 10:28:06 +0530 | [diff] [blame] | 1383 | mutex_lock(&pHddCtx->tdls_lock); |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 1384 | curr_peer = wlan_hdd_tdls_get_peer(pAdapter, mac); |
Gopichand Nakkala | 75e7b28 | 2013-03-15 18:37:13 -0700 | [diff] [blame] | 1385 | |
| 1386 | if (NULL == curr_peer) |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 1387 | { |
| 1388 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1389 | FL("curr_peer is NULL")); |
Masti, Narayanraddi | 6dbcdbb | 2015-05-13 10:28:06 +0530 | [diff] [blame] | 1390 | mutex_unlock(&pHddCtx->tdls_lock); |
Hoonki Lee | 387663d | 2013-02-05 18:08:43 -0800 | [diff] [blame] | 1391 | return -1; |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 1392 | } |
Masti, Narayanraddi | 6dbcdbb | 2015-05-13 10:28:06 +0530 | [diff] [blame] | 1393 | mutex_unlock(&pHddCtx->tdls_lock); |
Gopichand Nakkala | 75e7b28 | 2013-03-15 18:37:13 -0700 | [diff] [blame] | 1394 | |
| 1395 | if (pHddTdlsCtx->discovery_sent_cnt) |
| 1396 | pHddTdlsCtx->discovery_sent_cnt--; |
| 1397 | |
Rajesh Chauhan | a34c6e6 | 2014-03-25 16:37:58 +0530 | [diff] [blame] | 1398 | mutex_lock(&pHddCtx->tdls_lock); |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 1399 | |
Gopichand Nakkala | 34d1b06 | 2013-03-19 15:28:33 -0700 | [diff] [blame] | 1400 | wlan_hdd_tdls_check_power_save_prohibited(pAdapter); |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 1401 | |
| 1402 | mutex_unlock(&pHddCtx->tdls_lock); |
Gopichand Nakkala | 75e7b28 | 2013-03-15 18:37:13 -0700 | [diff] [blame] | 1403 | if (0 == pHddTdlsCtx->discovery_sent_cnt) |
Gopichand Nakkala | ccd3a38 | 2013-03-19 13:56:10 -0700 | [diff] [blame] | 1404 | { |
Gopichand Nakkala | 75e7b28 | 2013-03-15 18:37:13 -0700 | [diff] [blame] | 1405 | vos_timer_stop(&pHddTdlsCtx->peerDiscoveryTimeoutTimer); |
Gopichand Nakkala | ccd3a38 | 2013-03-19 13:56:10 -0700 | [diff] [blame] | 1406 | } |
Gopichand Nakkala | 75e7b28 | 2013-03-15 18:37:13 -0700 | [diff] [blame] | 1407 | |
Masti, Narayanraddi | 34e0e56 | 2015-03-05 18:23:03 +0530 | [diff] [blame] | 1408 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Jeff Johnson | 0299d0a | 2013-10-30 12:37:43 -0700 | [diff] [blame] | 1409 | "Discovery(%u) Response from " MAC_ADDRESS_STR " link_status %d", |
Gopichand Nakkala | 75e7b28 | 2013-03-15 18:37:13 -0700 | [diff] [blame] | 1410 | pHddTdlsCtx->discovery_sent_cnt, MAC_ADDR_ARRAY(curr_peer->peerMac), |
| 1411 | curr_peer->link_status); |
| 1412 | |
Gopichand Nakkala | 8b00c63 | 2013-03-08 19:47:52 -0800 | [diff] [blame] | 1413 | if (eTDLS_LINK_DISCOVERING == curr_peer->link_status) |
Gopichand Nakkala | 901e892 | 2013-03-04 23:45:58 -0800 | [diff] [blame] | 1414 | { |
Shailender Karmuchi | 13c0d08 | 2013-03-26 14:41:39 -0700 | [diff] [blame] | 1415 | /* Since we are here, it means Throughput threshold is alredy met. Make sure RSSI |
| 1416 | threshold is also met before setting up TDLS link*/ |
| 1417 | if ((tANI_S32) curr_peer->rssi > (tANI_S32) pHddTdlsCtx->threshold_config.rssi_trigger_threshold) |
| 1418 | { |
Atul Mittal | 115287b | 2014-07-08 13:26:33 +0530 | [diff] [blame] | 1419 | wlan_hdd_tdls_set_peer_link_status(curr_peer, |
| 1420 | eTDLS_LINK_DISCOVERED, |
| 1421 | eTDLS_LINK_SUCCESS); |
Masti, Narayanraddi | 34e0e56 | 2015-03-05 18:23:03 +0530 | [diff] [blame] | 1422 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Shailender Karmuchi | 13c0d08 | 2013-03-26 14:41:39 -0700 | [diff] [blame] | 1423 | "Rssi Threshold met: "MAC_ADDRESS_STR" rssi = %d threshold= %d" , |
| 1424 | MAC_ADDR_ARRAY(curr_peer->peerMac), curr_peer->rssi, |
| 1425 | pHddTdlsCtx->threshold_config.rssi_trigger_threshold); |
| 1426 | cfg80211_tdls_oper_request(pAdapter->dev, curr_peer->peerMac, NL80211_TDLS_SETUP, FALSE, GFP_KERNEL); |
| 1427 | } |
| 1428 | else |
| 1429 | { |
Masti, Narayanraddi | 34e0e56 | 2015-03-05 18:23:03 +0530 | [diff] [blame] | 1430 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Shailender Karmuchi | 13c0d08 | 2013-03-26 14:41:39 -0700 | [diff] [blame] | 1431 | "Rssi Threshold not met: "MAC_ADDRESS_STR" rssi = %d threshold = %d ", |
| 1432 | MAC_ADDR_ARRAY(curr_peer->peerMac), curr_peer->rssi, |
| 1433 | pHddTdlsCtx->threshold_config.rssi_trigger_threshold); |
Sunil Dutt | b0d3924 | 2014-09-10 23:54:51 +0530 | [diff] [blame] | 1434 | |
| 1435 | /* if RSSI threshold is not met then allow further discovery |
| 1436 | * attempts by decrementing count for the last attempt |
| 1437 | */ |
| 1438 | if (curr_peer->discovery_attempt) |
| 1439 | curr_peer->discovery_attempt--; |
| 1440 | |
Atul Mittal | 115287b | 2014-07-08 13:26:33 +0530 | [diff] [blame] | 1441 | wlan_hdd_tdls_set_peer_link_status(curr_peer, |
| 1442 | eTDLS_LINK_IDLE, |
| 1443 | eTDLS_LINK_UNSPECIFIED); |
Shailender Karmuchi | 13c0d08 | 2013-03-26 14:41:39 -0700 | [diff] [blame] | 1444 | } |
Gopichand Nakkala | 901e892 | 2013-03-04 23:45:58 -0800 | [diff] [blame] | 1445 | } |
Gopichand Nakkala | ccd3a38 | 2013-03-19 13:56:10 -0700 | [diff] [blame] | 1446 | else |
| 1447 | { |
| 1448 | wlan_hdd_tdls_check_bmps(pAdapter); |
| 1449 | } |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 1450 | |
Gopichand Nakkala | 901e892 | 2013-03-04 23:45:58 -0800 | [diff] [blame] | 1451 | curr_peer->tdls_support = eTDLS_CAP_SUPPORTED; |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 1452 | EXIT(); |
Hoonki Lee | 387663d | 2013-02-05 18:08:43 -0800 | [diff] [blame] | 1453 | return 0; |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 1454 | } |
| 1455 | |
Gopichand Nakkala | 79ff85d | 2013-05-27 17:05:29 +0530 | [diff] [blame] | 1456 | int wlan_hdd_tdls_set_peer_caps(hdd_adapter_t *pAdapter, |
Anand N Sunkad | b3ab97d | 2015-07-29 09:58:13 +0530 | [diff] [blame^] | 1457 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0)) |
| 1458 | const u8 *mac, |
| 1459 | #else |
Gopichand Nakkala | 79ff85d | 2013-05-27 17:05:29 +0530 | [diff] [blame] | 1460 | u8 *mac, |
Anand N Sunkad | b3ab97d | 2015-07-29 09:58:13 +0530 | [diff] [blame^] | 1461 | #endif |
Naresh Jayaram | 3180aa4 | 2014-02-12 21:47:26 +0530 | [diff] [blame] | 1462 | tCsrStaParams *StaParams, |
| 1463 | tANI_BOOLEAN isBufSta, |
| 1464 | tANI_BOOLEAN isOffChannelSupported) |
Gopichand Nakkala | 79ff85d | 2013-05-27 17:05:29 +0530 | [diff] [blame] | 1465 | { |
| 1466 | hddTdlsPeer_t *curr_peer; |
Masti, Narayanraddi | 6dbcdbb | 2015-05-13 10:28:06 +0530 | [diff] [blame] | 1467 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
Gopichand Nakkala | 79ff85d | 2013-05-27 17:05:29 +0530 | [diff] [blame] | 1468 | |
Masti, Narayanraddi | 6dbcdbb | 2015-05-13 10:28:06 +0530 | [diff] [blame] | 1469 | if (0 != (wlan_hdd_validate_context(pHddCtx))) |
| 1470 | return -EINVAL; |
| 1471 | |
| 1472 | mutex_lock(&pHddCtx->tdls_lock); |
Gopichand Nakkala | 79ff85d | 2013-05-27 17:05:29 +0530 | [diff] [blame] | 1473 | curr_peer = wlan_hdd_tdls_get_peer(pAdapter, mac); |
| 1474 | if (curr_peer == NULL) |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 1475 | { |
| 1476 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1477 | "%s: curr_peer is NULL", __func__); |
Masti, Narayanraddi | 6dbcdbb | 2015-05-13 10:28:06 +0530 | [diff] [blame] | 1478 | mutex_unlock(&pHddCtx->tdls_lock); |
Gopichand Nakkala | 79ff85d | 2013-05-27 17:05:29 +0530 | [diff] [blame] | 1479 | return -1; |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 1480 | } |
Gopichand Nakkala | 79ff85d | 2013-05-27 17:05:29 +0530 | [diff] [blame] | 1481 | |
Naresh Jayaram | 3180aa4 | 2014-02-12 21:47:26 +0530 | [diff] [blame] | 1482 | curr_peer->uapsdQueues = StaParams->uapsd_queues; |
| 1483 | curr_peer->maxSp = StaParams->max_sp; |
Gopichand Nakkala | 79ff85d | 2013-05-27 17:05:29 +0530 | [diff] [blame] | 1484 | curr_peer->isBufSta = isBufSta; |
Naresh Jayaram | 3180aa4 | 2014-02-12 21:47:26 +0530 | [diff] [blame] | 1485 | curr_peer->isOffChannelSupported = isOffChannelSupported; |
| 1486 | |
| 1487 | vos_mem_copy(curr_peer->supported_channels, |
| 1488 | StaParams->supported_channels, |
| 1489 | StaParams->supported_channels_len); |
| 1490 | |
| 1491 | curr_peer->supported_channels_len = |
| 1492 | StaParams->supported_channels_len; |
| 1493 | |
| 1494 | vos_mem_copy(curr_peer->supported_oper_classes, |
| 1495 | StaParams->supported_oper_classes, |
| 1496 | StaParams->supported_oper_classes_len); |
| 1497 | |
| 1498 | curr_peer->supported_oper_classes_len = |
| 1499 | StaParams->supported_oper_classes_len; |
Agarwal Ashish | 16020c4 | 2014-12-29 22:01:11 +0530 | [diff] [blame] | 1500 | curr_peer->qos = StaParams->capability & CAPABILITIES_QOS_OFFSET; |
Masti, Narayanraddi | 6dbcdbb | 2015-05-13 10:28:06 +0530 | [diff] [blame] | 1501 | |
| 1502 | mutex_unlock(&pHddCtx->tdls_lock); |
Gopichand Nakkala | 79ff85d | 2013-05-27 17:05:29 +0530 | [diff] [blame] | 1503 | return 0; |
| 1504 | } |
| 1505 | |
| 1506 | int wlan_hdd_tdls_get_link_establish_params(hdd_adapter_t *pAdapter, u8 *mac, |
| 1507 | tCsrTdlsLinkEstablishParams* tdlsLinkEstablishParams) |
| 1508 | { |
| 1509 | hddTdlsPeer_t *curr_peer; |
Masti, Narayanraddi | 6dbcdbb | 2015-05-13 10:28:06 +0530 | [diff] [blame] | 1510 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
Gopichand Nakkala | 79ff85d | 2013-05-27 17:05:29 +0530 | [diff] [blame] | 1511 | |
Masti, Narayanraddi | 6dbcdbb | 2015-05-13 10:28:06 +0530 | [diff] [blame] | 1512 | if (0 != (wlan_hdd_validate_context(pHddCtx))) |
| 1513 | return -EINVAL; |
| 1514 | |
| 1515 | mutex_lock(&pHddCtx->tdls_lock); |
Gopichand Nakkala | 79ff85d | 2013-05-27 17:05:29 +0530 | [diff] [blame] | 1516 | curr_peer = wlan_hdd_tdls_get_peer(pAdapter, mac); |
| 1517 | if (curr_peer == NULL) |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 1518 | { |
| 1519 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1520 | "%s: curr_peer is NULL", __func__); |
Masti, Narayanraddi | 6dbcdbb | 2015-05-13 10:28:06 +0530 | [diff] [blame] | 1521 | mutex_unlock(&pHddCtx->tdls_lock); |
Gopichand Nakkala | 79ff85d | 2013-05-27 17:05:29 +0530 | [diff] [blame] | 1522 | return -1; |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 1523 | } |
Gopichand Nakkala | 79ff85d | 2013-05-27 17:05:29 +0530 | [diff] [blame] | 1524 | |
| 1525 | tdlsLinkEstablishParams->isResponder = curr_peer->is_responder; |
| 1526 | tdlsLinkEstablishParams->uapsdQueues = curr_peer->uapsdQueues; |
| 1527 | tdlsLinkEstablishParams->maxSp = curr_peer->maxSp; |
| 1528 | tdlsLinkEstablishParams->isBufSta = curr_peer->isBufSta; |
Naresh Jayaram | 3180aa4 | 2014-02-12 21:47:26 +0530 | [diff] [blame] | 1529 | tdlsLinkEstablishParams->isOffChannelSupported = |
| 1530 | curr_peer->isOffChannelSupported; |
| 1531 | |
| 1532 | vos_mem_copy(tdlsLinkEstablishParams->supportedChannels, |
| 1533 | curr_peer->supported_channels, |
| 1534 | curr_peer->supported_channels_len); |
| 1535 | |
| 1536 | tdlsLinkEstablishParams->supportedChannelsLen = |
| 1537 | curr_peer->supported_channels_len; |
| 1538 | |
| 1539 | vos_mem_copy(tdlsLinkEstablishParams->supportedOperClasses, |
| 1540 | curr_peer->supported_oper_classes, |
| 1541 | curr_peer->supported_oper_classes_len); |
| 1542 | |
| 1543 | tdlsLinkEstablishParams->supportedOperClassesLen = |
| 1544 | curr_peer->supported_oper_classes_len; |
Agarwal Ashish | 16020c4 | 2014-12-29 22:01:11 +0530 | [diff] [blame] | 1545 | tdlsLinkEstablishParams->qos = curr_peer->qos; |
| 1546 | |
Masti, Narayanraddi | 6dbcdbb | 2015-05-13 10:28:06 +0530 | [diff] [blame] | 1547 | mutex_unlock(&pHddCtx->tdls_lock); |
Gopichand Nakkala | 79ff85d | 2013-05-27 17:05:29 +0530 | [diff] [blame] | 1548 | return 0; |
| 1549 | } |
| 1550 | |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 1551 | int wlan_hdd_tdls_set_rssi(hdd_adapter_t *pAdapter, u8 *mac, tANI_S8 rxRssi) |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 1552 | { |
| 1553 | hddTdlsPeer_t *curr_peer; |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 1554 | |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 1555 | curr_peer = wlan_hdd_tdls_find_peer(pAdapter, mac, TRUE); |
Hoonki Lee | 387663d | 2013-02-05 18:08:43 -0800 | [diff] [blame] | 1556 | if (curr_peer == NULL) |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 1557 | { |
| 1558 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1559 | "%s: curr_peer is NULL", __func__); |
Hoonki Lee | 387663d | 2013-02-05 18:08:43 -0800 | [diff] [blame] | 1560 | return -1; |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 1561 | } |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 1562 | |
| 1563 | curr_peer->rssi = rxRssi; |
| 1564 | |
Hoonki Lee | 387663d | 2013-02-05 18:08:43 -0800 | [diff] [blame] | 1565 | return 0; |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 1566 | } |
| 1567 | |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 1568 | int wlan_hdd_tdls_set_responder(hdd_adapter_t *pAdapter, u8 *mac, tANI_U8 responder) |
Hoonki Lee | a34dd89 | 2013-02-05 22:56:02 -0800 | [diff] [blame] | 1569 | { |
| 1570 | hddTdlsPeer_t *curr_peer; |
Masti, Narayanraddi | 6dbcdbb | 2015-05-13 10:28:06 +0530 | [diff] [blame] | 1571 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
Hoonki Lee | a34dd89 | 2013-02-05 22:56:02 -0800 | [diff] [blame] | 1572 | |
Masti, Narayanraddi | 6dbcdbb | 2015-05-13 10:28:06 +0530 | [diff] [blame] | 1573 | if (0 != (wlan_hdd_validate_context(pHddCtx))) |
| 1574 | return -EINVAL; |
| 1575 | |
| 1576 | mutex_lock(&pHddCtx->tdls_lock); |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 1577 | curr_peer = wlan_hdd_tdls_get_peer(pAdapter, mac); |
Gopichand Nakkala | 91b0926 | 2013-02-10 14:27:02 -0800 | [diff] [blame] | 1578 | if (curr_peer == NULL) |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 1579 | { |
| 1580 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1581 | "%s: curr_peer is NULL", __func__); |
Masti, Narayanraddi | 6dbcdbb | 2015-05-13 10:28:06 +0530 | [diff] [blame] | 1582 | mutex_unlock(&pHddCtx->tdls_lock); |
Hoonki Lee | a34dd89 | 2013-02-05 22:56:02 -0800 | [diff] [blame] | 1583 | return -1; |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 1584 | } |
Hoonki Lee | a34dd89 | 2013-02-05 22:56:02 -0800 | [diff] [blame] | 1585 | |
| 1586 | curr_peer->is_responder = responder; |
| 1587 | |
Masti, Narayanraddi | 6dbcdbb | 2015-05-13 10:28:06 +0530 | [diff] [blame] | 1588 | mutex_unlock(&pHddCtx->tdls_lock); |
Hoonki Lee | a34dd89 | 2013-02-05 22:56:02 -0800 | [diff] [blame] | 1589 | return 0; |
| 1590 | } |
| 1591 | |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 1592 | int wlan_hdd_tdls_get_responder(hdd_adapter_t *pAdapter, u8 *mac) |
Hoonki Lee | a34dd89 | 2013-02-05 22:56:02 -0800 | [diff] [blame] | 1593 | { |
| 1594 | hddTdlsPeer_t *curr_peer; |
| 1595 | |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 1596 | curr_peer = wlan_hdd_tdls_find_peer(pAdapter, mac, TRUE); |
Gopichand Nakkala | 91b0926 | 2013-02-10 14:27:02 -0800 | [diff] [blame] | 1597 | if (curr_peer == NULL) |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 1598 | { |
| 1599 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1600 | "%s: curr_peer is NULL", __func__); |
Hoonki Lee | a34dd89 | 2013-02-05 22:56:02 -0800 | [diff] [blame] | 1601 | return -1; |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 1602 | } |
Hoonki Lee | a34dd89 | 2013-02-05 22:56:02 -0800 | [diff] [blame] | 1603 | |
| 1604 | return (curr_peer->is_responder); |
| 1605 | } |
| 1606 | |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 1607 | int wlan_hdd_tdls_set_signature(hdd_adapter_t *pAdapter, u8 *mac, tANI_U8 uSignature) |
Hoonki Lee | 11f7dda | 2013-02-14 16:55:44 -0800 | [diff] [blame] | 1608 | { |
| 1609 | hddTdlsPeer_t *curr_peer; |
Masti, Narayanraddi | 6dbcdbb | 2015-05-13 10:28:06 +0530 | [diff] [blame] | 1610 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
Hoonki Lee | 11f7dda | 2013-02-14 16:55:44 -0800 | [diff] [blame] | 1611 | |
Masti, Narayanraddi | 6dbcdbb | 2015-05-13 10:28:06 +0530 | [diff] [blame] | 1612 | if (0 != (wlan_hdd_validate_context(pHddCtx))) |
| 1613 | return -EINVAL; |
| 1614 | |
| 1615 | mutex_lock(&pHddCtx->tdls_lock); |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 1616 | curr_peer = wlan_hdd_tdls_get_peer(pAdapter, mac); |
Hoonki Lee | 11f7dda | 2013-02-14 16:55:44 -0800 | [diff] [blame] | 1617 | if (curr_peer == NULL) |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 1618 | { |
| 1619 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1620 | "%s: curr_peer is NULL", __func__); |
Masti, Narayanraddi | 6dbcdbb | 2015-05-13 10:28:06 +0530 | [diff] [blame] | 1621 | mutex_unlock(&pHddCtx->tdls_lock); |
Hoonki Lee | 11f7dda | 2013-02-14 16:55:44 -0800 | [diff] [blame] | 1622 | return -1; |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 1623 | } |
Hoonki Lee | 11f7dda | 2013-02-14 16:55:44 -0800 | [diff] [blame] | 1624 | |
| 1625 | curr_peer->signature = uSignature; |
| 1626 | |
Masti, Narayanraddi | 6dbcdbb | 2015-05-13 10:28:06 +0530 | [diff] [blame] | 1627 | mutex_unlock(&pHddCtx->tdls_lock); |
Hoonki Lee | 11f7dda | 2013-02-14 16:55:44 -0800 | [diff] [blame] | 1628 | return 0; |
| 1629 | } |
| 1630 | |
Hoonki Lee | a34dd89 | 2013-02-05 22:56:02 -0800 | [diff] [blame] | 1631 | |
Hoonki Lee | 387663d | 2013-02-05 18:08:43 -0800 | [diff] [blame] | 1632 | void wlan_hdd_tdls_extract_da(struct sk_buff *skb, u8 *mac) |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 1633 | { |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 1634 | memcpy(mac, skb->data, 6); |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 1635 | } |
| 1636 | |
Hoonki Lee | 387663d | 2013-02-05 18:08:43 -0800 | [diff] [blame] | 1637 | void wlan_hdd_tdls_extract_sa(struct sk_buff *skb, u8 *mac) |
Chilam Ng | 1279e23 | 2013-01-25 15:06:52 -0800 | [diff] [blame] | 1638 | { |
Chilam Ng | 1279e23 | 2013-01-25 15:06:52 -0800 | [diff] [blame] | 1639 | memcpy(mac, skb->data+6, 6); |
Chilam Ng | 1279e23 | 2013-01-25 15:06:52 -0800 | [diff] [blame] | 1640 | } |
| 1641 | |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 1642 | int wlan_hdd_tdls_increment_pkt_count(hdd_adapter_t *pAdapter, u8 *mac, u8 tx) |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 1643 | { |
Hoonki Lee | 387663d | 2013-02-05 18:08:43 -0800 | [diff] [blame] | 1644 | hddTdlsPeer_t *curr_peer; |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 1645 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 1646 | |
Masti, Narayanraddi | 6dbcdbb | 2015-05-13 10:28:06 +0530 | [diff] [blame] | 1647 | if (0 != (wlan_hdd_validate_context(pHddCtx))) |
| 1648 | return -EINVAL; |
| 1649 | |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 1650 | if (eTDLS_SUPPORT_ENABLED != pHddCtx->tdls_mode) |
| 1651 | return -1; |
Hoonki Lee | bfee034 | 2013-01-21 16:43:45 -0800 | [diff] [blame] | 1652 | |
Masti, Narayanraddi | 6dbcdbb | 2015-05-13 10:28:06 +0530 | [diff] [blame] | 1653 | mutex_lock(&pHddCtx->tdls_lock); |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 1654 | curr_peer = wlan_hdd_tdls_get_peer(pAdapter, mac); |
Hoonki Lee | 387663d | 2013-02-05 18:08:43 -0800 | [diff] [blame] | 1655 | if (curr_peer == NULL) |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 1656 | { |
c_hpothu | e21931b | 2014-09-08 14:02:14 +0530 | [diff] [blame] | 1657 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 1658 | FL("curr_peer is NULL")); |
Masti, Narayanraddi | 6dbcdbb | 2015-05-13 10:28:06 +0530 | [diff] [blame] | 1659 | mutex_unlock(&pHddCtx->tdls_lock); |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 1660 | return -1; |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 1661 | } |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 1662 | |
Chilam Ng | 1279e23 | 2013-01-25 15:06:52 -0800 | [diff] [blame] | 1663 | if (tx) |
| 1664 | curr_peer->tx_pkt++; |
| 1665 | else |
| 1666 | curr_peer->rx_pkt++; |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 1667 | |
Masti, Narayanraddi | 6dbcdbb | 2015-05-13 10:28:06 +0530 | [diff] [blame] | 1668 | mutex_unlock(&pHddCtx->tdls_lock); |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 1669 | return 0; |
| 1670 | } |
| 1671 | |
Hoonki Lee | 2751190 | 2013-03-14 18:19:06 -0700 | [diff] [blame] | 1672 | static int wlan_hdd_tdls_check_config(tdls_config_params_t *config) |
| 1673 | { |
| 1674 | if (config->tdls > 2) |
| 1675 | { |
| 1676 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s invalid 1st argument %d. <0...2>", __func__, config->tdls); |
| 1677 | return -1; |
| 1678 | } |
| 1679 | if (config->tx_period_t < CFG_TDLS_TX_STATS_PERIOD_MIN || |
| 1680 | config->tx_period_t > CFG_TDLS_TX_STATS_PERIOD_MAX) |
| 1681 | { |
Jeff Johnson | 0299d0a | 2013-10-30 12:37:43 -0700 | [diff] [blame] | 1682 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s invalid 2nd argument %d. <%d...%ld>", __func__, config->tx_period_t, |
Hoonki Lee | 2751190 | 2013-03-14 18:19:06 -0700 | [diff] [blame] | 1683 | CFG_TDLS_TX_STATS_PERIOD_MIN, CFG_TDLS_TX_STATS_PERIOD_MAX); |
| 1684 | return -1; |
| 1685 | } |
| 1686 | if (config->tx_packet_n < CFG_TDLS_TX_PACKET_THRESHOLD_MIN || |
| 1687 | config->tx_packet_n > CFG_TDLS_TX_PACKET_THRESHOLD_MAX) |
| 1688 | { |
Jeff Johnson | 0299d0a | 2013-10-30 12:37:43 -0700 | [diff] [blame] | 1689 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s invalid 3rd argument %d. <%d...%ld>", __func__, config->tx_packet_n, |
Hoonki Lee | 2751190 | 2013-03-14 18:19:06 -0700 | [diff] [blame] | 1690 | CFG_TDLS_TX_PACKET_THRESHOLD_MIN, CFG_TDLS_TX_PACKET_THRESHOLD_MAX); |
| 1691 | return -1; |
| 1692 | } |
| 1693 | if (config->discovery_period_t < CFG_TDLS_DISCOVERY_PERIOD_MIN || |
| 1694 | config->discovery_period_t > CFG_TDLS_DISCOVERY_PERIOD_MAX) |
| 1695 | { |
Jeff Johnson | 0299d0a | 2013-10-30 12:37:43 -0700 | [diff] [blame] | 1696 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s invalid 4th argument %d. <%d...%ld>", __func__, config->discovery_period_t, |
Hoonki Lee | 2751190 | 2013-03-14 18:19:06 -0700 | [diff] [blame] | 1697 | CFG_TDLS_DISCOVERY_PERIOD_MIN, CFG_TDLS_DISCOVERY_PERIOD_MAX); |
| 1698 | return -1; |
| 1699 | } |
| 1700 | if (config->discovery_tries_n < CFG_TDLS_MAX_DISCOVERY_ATTEMPT_MIN || |
| 1701 | config->discovery_tries_n > CFG_TDLS_MAX_DISCOVERY_ATTEMPT_MAX) |
| 1702 | { |
| 1703 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s invalid 5th argument %d. <%d...%d>", __func__, config->discovery_tries_n, |
| 1704 | CFG_TDLS_MAX_DISCOVERY_ATTEMPT_MIN, CFG_TDLS_MAX_DISCOVERY_ATTEMPT_MAX); |
| 1705 | return -1; |
| 1706 | } |
| 1707 | if (config->idle_timeout_t < CFG_TDLS_IDLE_TIMEOUT_MIN || |
| 1708 | config->idle_timeout_t > CFG_TDLS_IDLE_TIMEOUT_MAX) |
| 1709 | { |
| 1710 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s invalid 6th argument %d. <%d...%d>", __func__, config->idle_timeout_t, |
| 1711 | CFG_TDLS_IDLE_TIMEOUT_MIN, CFG_TDLS_IDLE_TIMEOUT_MAX); |
| 1712 | return -1; |
| 1713 | } |
| 1714 | if (config->idle_packet_n < CFG_TDLS_IDLE_PACKET_THRESHOLD_MIN || |
| 1715 | config->idle_packet_n > CFG_TDLS_IDLE_PACKET_THRESHOLD_MAX) |
| 1716 | { |
| 1717 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s invalid 7th argument %d. <%d...%d>", __func__, config->idle_packet_n, |
| 1718 | CFG_TDLS_IDLE_PACKET_THRESHOLD_MIN, CFG_TDLS_IDLE_PACKET_THRESHOLD_MAX); |
| 1719 | return -1; |
| 1720 | } |
| 1721 | if (config->rssi_hysteresis < CFG_TDLS_RSSI_HYSTERESIS_MIN || |
| 1722 | config->rssi_hysteresis > CFG_TDLS_RSSI_HYSTERESIS_MAX) |
| 1723 | { |
| 1724 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s invalid 8th argument %d. <%d...%d>", __func__, config->rssi_hysteresis, |
| 1725 | CFG_TDLS_RSSI_HYSTERESIS_MIN, CFG_TDLS_RSSI_HYSTERESIS_MAX); |
| 1726 | return -1; |
| 1727 | } |
| 1728 | if (config->rssi_trigger_threshold < CFG_TDLS_RSSI_TRIGGER_THRESHOLD_MIN || |
| 1729 | config->rssi_trigger_threshold > CFG_TDLS_RSSI_TRIGGER_THRESHOLD_MAX) |
| 1730 | { |
| 1731 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s invalid 9th argument %d. <%d...%d>", __func__, config->rssi_trigger_threshold, |
| 1732 | CFG_TDLS_RSSI_TRIGGER_THRESHOLD_MIN, CFG_TDLS_RSSI_TRIGGER_THRESHOLD_MAX); |
| 1733 | return -1; |
| 1734 | } |
| 1735 | if (config->rssi_teardown_threshold < CFG_TDLS_RSSI_TEARDOWN_THRESHOLD_MIN || |
| 1736 | config->rssi_teardown_threshold > CFG_TDLS_RSSI_TEARDOWN_THRESHOLD_MAX) |
| 1737 | { |
| 1738 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s invalid 10th argument %d. <%d...%d>", __func__, config->rssi_teardown_threshold, |
| 1739 | CFG_TDLS_RSSI_TEARDOWN_THRESHOLD_MIN, CFG_TDLS_RSSI_TEARDOWN_THRESHOLD_MAX); |
| 1740 | return -1; |
| 1741 | } |
| 1742 | return 0; |
| 1743 | } |
| 1744 | |
Chilam Ng | 0112041 | 2013-02-19 18:32:21 -0800 | [diff] [blame] | 1745 | int wlan_hdd_tdls_set_params(struct net_device *dev, tdls_config_params_t *config) |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 1746 | { |
Chilam Ng | 0112041 | 2013-02-19 18:32:21 -0800 | [diff] [blame] | 1747 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 1748 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter ); |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 1749 | tdlsCtx_t *pHddTdlsCtx = WLAN_HDD_GET_TDLS_CTX_PTR(pAdapter); |
Hoonki Lee | 2751190 | 2013-03-14 18:19:06 -0700 | [diff] [blame] | 1750 | eTDLSSupportMode req_tdls_mode; |
Hoonki Lee | bfee034 | 2013-01-21 16:43:45 -0800 | [diff] [blame] | 1751 | |
Hoonki Lee | 2751190 | 2013-03-14 18:19:06 -0700 | [diff] [blame] | 1752 | if (NULL == pHddTdlsCtx) |
| 1753 | { |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 1754 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("TDLS not enabled!")); |
Hoonki Lee | 2751190 | 2013-03-14 18:19:06 -0700 | [diff] [blame] | 1755 | return -1; |
Chilam Ng | 0112041 | 2013-02-19 18:32:21 -0800 | [diff] [blame] | 1756 | } |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 1757 | |
Hoonki Lee | 2751190 | 2013-03-14 18:19:06 -0700 | [diff] [blame] | 1758 | if (wlan_hdd_tdls_check_config(config) != 0) |
| 1759 | { |
| 1760 | return -1; |
| 1761 | } |
| 1762 | |
| 1763 | /* config->tdls is mapped to 0->1, 1->2, 2->3 */ |
| 1764 | req_tdls_mode = config->tdls + 1; |
| 1765 | if (pHddCtx->tdls_mode == req_tdls_mode) |
| 1766 | { |
| 1767 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s already in mode %d", __func__, config->tdls); |
| 1768 | return -1; |
| 1769 | } |
| 1770 | |
| 1771 | /* copy the configuration only when given tdls mode is implicit trigger enable */ |
| 1772 | if (eTDLS_SUPPORT_ENABLED == req_tdls_mode) |
| 1773 | { |
Chilam Ng | 0112041 | 2013-02-19 18:32:21 -0800 | [diff] [blame] | 1774 | memcpy(&pHddTdlsCtx->threshold_config, config, sizeof(tdls_config_params_t)); |
| 1775 | } |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 1776 | |
Chilam Ng | 0112041 | 2013-02-19 18:32:21 -0800 | [diff] [blame] | 1777 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1778 | "iw set tdls params: %d %d %d %d %d %d %d %d %d %d", |
| 1779 | config->tdls, |
| 1780 | config->tx_period_t, |
| 1781 | config->tx_packet_n, |
| 1782 | config->discovery_period_t, |
| 1783 | config->discovery_tries_n, |
| 1784 | config->idle_timeout_t, |
| 1785 | config->idle_packet_n, |
| 1786 | config->rssi_hysteresis, |
| 1787 | config->rssi_trigger_threshold, |
| 1788 | config->rssi_teardown_threshold); |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 1789 | |
Gopichand Nakkala | dcbcf4e | 2013-03-23 14:32:39 -0700 | [diff] [blame] | 1790 | wlan_hdd_tdls_set_mode(pHddCtx, req_tdls_mode, TRUE); |
Chilam Ng | 0112041 | 2013-02-19 18:32:21 -0800 | [diff] [blame] | 1791 | |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 1792 | return 0; |
| 1793 | } |
| 1794 | |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 1795 | int wlan_hdd_tdls_set_sta_id(hdd_adapter_t *pAdapter, u8 *mac, u8 staId) |
Kiran V | 1ccee93 | 2012-12-12 14:49:46 -0800 | [diff] [blame] | 1796 | { |
Hoonki Lee | 387663d | 2013-02-05 18:08:43 -0800 | [diff] [blame] | 1797 | hddTdlsPeer_t *curr_peer; |
Masti, Narayanraddi | 6dbcdbb | 2015-05-13 10:28:06 +0530 | [diff] [blame] | 1798 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
Kiran V | 1ccee93 | 2012-12-12 14:49:46 -0800 | [diff] [blame] | 1799 | |
Masti, Narayanraddi | 6dbcdbb | 2015-05-13 10:28:06 +0530 | [diff] [blame] | 1800 | if (0 != (wlan_hdd_validate_context(pHddCtx))) |
| 1801 | return -EINVAL; |
| 1802 | |
| 1803 | mutex_lock(&pHddCtx->tdls_lock); |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 1804 | curr_peer = wlan_hdd_tdls_get_peer(pAdapter, mac); |
Hoonki Lee | 387663d | 2013-02-05 18:08:43 -0800 | [diff] [blame] | 1805 | if (curr_peer == NULL) |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 1806 | { |
| 1807 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1808 | "%s: curr_peer is NULL", __func__); |
Masti, Narayanraddi | 6dbcdbb | 2015-05-13 10:28:06 +0530 | [diff] [blame] | 1809 | mutex_unlock(&pHddCtx->tdls_lock); |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 1810 | return -1; |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 1811 | } |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 1812 | |
Hoonki Lee | 387663d | 2013-02-05 18:08:43 -0800 | [diff] [blame] | 1813 | curr_peer->staId = staId; |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 1814 | |
Masti, Narayanraddi | 6dbcdbb | 2015-05-13 10:28:06 +0530 | [diff] [blame] | 1815 | mutex_unlock(&pHddCtx->tdls_lock); |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 1816 | return 0; |
Kiran V | 1ccee93 | 2012-12-12 14:49:46 -0800 | [diff] [blame] | 1817 | } |
| 1818 | |
Naresh Jayaram | 937abdf | 2013-11-26 19:50:25 +0530 | [diff] [blame] | 1819 | int wlan_hdd_tdls_set_force_peer(hdd_adapter_t *pAdapter, u8 *mac, |
| 1820 | tANI_BOOLEAN forcePeer) |
Sunil Dutt | 41de4e2 | 2013-11-14 18:09:02 +0530 | [diff] [blame] | 1821 | { |
Naresh Jayaram | 937abdf | 2013-11-26 19:50:25 +0530 | [diff] [blame] | 1822 | hddTdlsPeer_t *curr_peer; |
Sunil Dutt | 41de4e2 | 2013-11-14 18:09:02 +0530 | [diff] [blame] | 1823 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 1824 | |
| 1825 | if ((NULL == pHddCtx)) return -1; |
| 1826 | |
Rajesh Chauhan | a34c6e6 | 2014-03-25 16:37:58 +0530 | [diff] [blame] | 1827 | mutex_lock(&pHddCtx->tdls_lock); |
| 1828 | |
Naresh Jayaram | 937abdf | 2013-11-26 19:50:25 +0530 | [diff] [blame] | 1829 | curr_peer = wlan_hdd_tdls_find_peer(pAdapter, mac, FALSE); |
| 1830 | if (curr_peer == NULL) |
Sunil Dutt | 41de4e2 | 2013-11-14 18:09:02 +0530 | [diff] [blame] | 1831 | goto error; |
Naresh Jayaram | 937abdf | 2013-11-26 19:50:25 +0530 | [diff] [blame] | 1832 | curr_peer->isForcedPeer = forcePeer; |
Naresh Jayaram | ca7bc3a | 2014-02-04 23:03:04 +0530 | [diff] [blame] | 1833 | |
| 1834 | mutex_unlock(&pHddCtx->tdls_lock); |
| 1835 | return 0; |
Sunil Dutt | 41de4e2 | 2013-11-14 18:09:02 +0530 | [diff] [blame] | 1836 | error: |
| 1837 | mutex_unlock(&pHddCtx->tdls_lock); |
| 1838 | return -1; |
| 1839 | } |
| 1840 | |
Hoonki Lee | 387663d | 2013-02-05 18:08:43 -0800 | [diff] [blame] | 1841 | /* if peerMac is found, then it returns pointer to hddTdlsPeer_t |
| 1842 | otherwise, it returns NULL |
| 1843 | */ |
Anand N Sunkad | b3ab97d | 2015-07-29 09:58:13 +0530 | [diff] [blame^] | 1844 | hddTdlsPeer_t *wlan_hdd_tdls_find_peer(hdd_adapter_t *pAdapter, |
| 1845 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0)) |
| 1846 | const u8 *mac, |
| 1847 | #else |
| 1848 | u8 *mac, |
| 1849 | #endif |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 1850 | tANI_BOOLEAN mutexLock) |
Kiran V | 1ccee93 | 2012-12-12 14:49:46 -0800 | [diff] [blame] | 1851 | { |
Hoonki Lee | 387663d | 2013-02-05 18:08:43 -0800 | [diff] [blame] | 1852 | u8 key; |
| 1853 | struct list_head *pos; |
| 1854 | struct list_head *head; |
| 1855 | hddTdlsPeer_t *curr_peer; |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 1856 | tdlsCtx_t *pHddTdlsCtx; |
Madan Mohan Koyyalamudi | 263cec1 | 2013-10-07 10:57:50 +0530 | [diff] [blame] | 1857 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
Hoonki Lee | 387663d | 2013-02-05 18:08:43 -0800 | [diff] [blame] | 1858 | |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 1859 | if(0 != (wlan_hdd_validate_context(pHddCtx))) |
| 1860 | { |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 1861 | return 0; |
| 1862 | } |
Hoonki Lee | 387663d | 2013-02-05 18:08:43 -0800 | [diff] [blame] | 1863 | |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 1864 | if ( mutexLock ) |
Hoonki Lee | 387663d | 2013-02-05 18:08:43 -0800 | [diff] [blame] | 1865 | { |
Rajesh Chauhan | a34c6e6 | 2014-03-25 16:37:58 +0530 | [diff] [blame] | 1866 | mutex_lock(&pHddCtx->tdls_lock); |
Hoonki Lee | 387663d | 2013-02-05 18:08:43 -0800 | [diff] [blame] | 1867 | } |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 1868 | pHddTdlsCtx = WLAN_HDD_GET_TDLS_CTX_PTR(pAdapter); |
Gopichand Nakkala | eb69b60 | 2013-02-27 11:40:31 -0800 | [diff] [blame] | 1869 | if (NULL == pHddTdlsCtx) |
| 1870 | { |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 1871 | if ( mutexLock ) |
| 1872 | mutex_unlock(&pHddCtx->tdls_lock); |
Gopichand Nakkala | eb69b60 | 2013-02-27 11:40:31 -0800 | [diff] [blame] | 1873 | return NULL; |
| 1874 | } |
| 1875 | |
| 1876 | key = wlan_hdd_tdls_hash_key(mac); |
| 1877 | |
| 1878 | head = &pHddTdlsCtx->peer_list[key]; |
Hoonki Lee | 387663d | 2013-02-05 18:08:43 -0800 | [diff] [blame] | 1879 | |
| 1880 | list_for_each(pos, head) { |
| 1881 | curr_peer = list_entry (pos, hddTdlsPeer_t, node); |
| 1882 | if (!memcmp(mac, curr_peer->peerMac, 6)) { |
| 1883 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 1884 | "findTdlsPeer: found staId %d", curr_peer->staId); |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 1885 | if ( mutexLock ) |
| 1886 | mutex_unlock(&pHddCtx->tdls_lock); |
Hoonki Lee | 387663d | 2013-02-05 18:08:43 -0800 | [diff] [blame] | 1887 | return curr_peer; |
| 1888 | } |
| 1889 | } |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 1890 | if ( mutexLock ) |
| 1891 | mutex_unlock(&pHddCtx->tdls_lock); |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 1892 | |
Hoonki Lee | 387663d | 2013-02-05 18:08:43 -0800 | [diff] [blame] | 1893 | return NULL; |
| 1894 | } |
| 1895 | |
Hoonki Lee | a6d49be | 2013-04-05 09:43:25 -0700 | [diff] [blame] | 1896 | hddTdlsPeer_t *wlan_hdd_tdls_find_all_peer(hdd_context_t *pHddCtx, u8 *mac) |
| 1897 | { |
| 1898 | hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL; |
| 1899 | hdd_adapter_t *pAdapter = NULL; |
| 1900 | tdlsCtx_t *pHddTdlsCtx = NULL; |
| 1901 | hddTdlsPeer_t *curr_peer= NULL; |
| 1902 | VOS_STATUS status = 0; |
| 1903 | |
Rajesh Chauhan | a34c6e6 | 2014-03-25 16:37:58 +0530 | [diff] [blame] | 1904 | mutex_lock(&pHddCtx->tdls_lock); |
Hoonki Lee | a6d49be | 2013-04-05 09:43:25 -0700 | [diff] [blame] | 1905 | status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode ); |
| 1906 | while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status ) |
| 1907 | { |
| 1908 | pAdapter = pAdapterNode->pAdapter; |
| 1909 | |
| 1910 | pHddTdlsCtx = WLAN_HDD_GET_TDLS_CTX_PTR(pAdapter); |
| 1911 | if (NULL != pHddTdlsCtx) |
| 1912 | { |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 1913 | curr_peer = wlan_hdd_tdls_find_peer(pAdapter, mac, FALSE); |
Hoonki Lee | a6d49be | 2013-04-05 09:43:25 -0700 | [diff] [blame] | 1914 | if (curr_peer) |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 1915 | { |
| 1916 | mutex_unlock(&pHddCtx->tdls_lock); |
Hoonki Lee | a6d49be | 2013-04-05 09:43:25 -0700 | [diff] [blame] | 1917 | return curr_peer; |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 1918 | } |
Hoonki Lee | a6d49be | 2013-04-05 09:43:25 -0700 | [diff] [blame] | 1919 | } |
| 1920 | status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 1921 | pAdapterNode = pNext; |
| 1922 | } |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 1923 | mutex_unlock(&pHddCtx->tdls_lock); |
Hoonki Lee | a6d49be | 2013-04-05 09:43:25 -0700 | [diff] [blame] | 1924 | return curr_peer; |
| 1925 | } |
| 1926 | |
| 1927 | |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 1928 | int wlan_hdd_tdls_reset_peer(hdd_adapter_t *pAdapter, u8 *mac) |
Hoonki Lee | 387663d | 2013-02-05 18:08:43 -0800 | [diff] [blame] | 1929 | { |
Chilam Ng | 0112041 | 2013-02-19 18:32:21 -0800 | [diff] [blame] | 1930 | hdd_context_t *pHddCtx; |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 1931 | hddTdlsPeer_t *curr_peer; |
Kiran V | 1ccee93 | 2012-12-12 14:49:46 -0800 | [diff] [blame] | 1932 | |
Chilam Ng | 0112041 | 2013-02-19 18:32:21 -0800 | [diff] [blame] | 1933 | pHddCtx = WLAN_HDD_GET_CTX( pAdapter ); |
| 1934 | |
Masti, Narayanraddi | 6dbcdbb | 2015-05-13 10:28:06 +0530 | [diff] [blame] | 1935 | if (0 != (wlan_hdd_validate_context(pHddCtx))) |
| 1936 | return -EINVAL; |
| 1937 | |
| 1938 | mutex_lock(&pHddCtx->tdls_lock); |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 1939 | curr_peer = wlan_hdd_tdls_get_peer(pAdapter, mac); |
Hoonki Lee | 387663d | 2013-02-05 18:08:43 -0800 | [diff] [blame] | 1940 | if (curr_peer == NULL) |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 1941 | { |
| 1942 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1943 | "%s: curr_peer is NULL", __func__); |
Masti, Narayanraddi | 6dbcdbb | 2015-05-13 10:28:06 +0530 | [diff] [blame] | 1944 | mutex_unlock(&pHddCtx->tdls_lock); |
Hoonki Lee | 387663d | 2013-02-05 18:08:43 -0800 | [diff] [blame] | 1945 | return -1; |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 1946 | } |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 1947 | |
Atul Mittal | 115287b | 2014-07-08 13:26:33 +0530 | [diff] [blame] | 1948 | wlan_hdd_tdls_set_peer_link_status(curr_peer, |
| 1949 | eTDLS_LINK_IDLE, |
| 1950 | eTDLS_LINK_UNSPECIFIED); |
Hoonki Lee | cdd8e96 | 2013-01-20 00:45:46 -0800 | [diff] [blame] | 1951 | curr_peer->staId = 0; |
Hoonki Lee | 387663d | 2013-02-05 18:08:43 -0800 | [diff] [blame] | 1952 | |
Pradeep Reddy POTTETI | edaeb5f | 2014-05-22 23:34:41 +0530 | [diff] [blame] | 1953 | /* Throughput Monitor shall disable the split scan when |
| 1954 | * TDLS scan coexistance is disabled.At this point of time |
| 1955 | * since TDLS scan coexistance is not meeting the criteria |
| 1956 | * to be operational, explicitly make it false to enable |
| 1957 | * throughput monitor takes the control of split scan. |
| 1958 | */ |
| 1959 | if (pHddCtx->isTdlsScanCoexistence == TRUE) |
| 1960 | { |
| 1961 | pHddCtx->isTdlsScanCoexistence = FALSE; |
| 1962 | } |
| 1963 | |
Chilam Ng | 0112041 | 2013-02-19 18:32:21 -0800 | [diff] [blame] | 1964 | if(eTDLS_SUPPORT_ENABLED == pHddCtx->tdls_mode) { |
Chilam Ng | a75d8b6 | 2013-01-29 01:35:59 -0800 | [diff] [blame] | 1965 | vos_timer_stop( &curr_peer->peerIdleTimer ); |
Chilam Ng | a75d8b6 | 2013-01-29 01:35:59 -0800 | [diff] [blame] | 1966 | } |
Masti, Narayanraddi | 6dbcdbb | 2015-05-13 10:28:06 +0530 | [diff] [blame] | 1967 | |
| 1968 | mutex_unlock(&pHddCtx->tdls_lock); |
Hoonki Lee | 387663d | 2013-02-05 18:08:43 -0800 | [diff] [blame] | 1969 | return 0; |
Hoonki Lee | cdd8e96 | 2013-01-20 00:45:46 -0800 | [diff] [blame] | 1970 | } |
| 1971 | |
Gopichand Nakkala | 638ebc7 | 2013-03-21 18:04:02 -0700 | [diff] [blame] | 1972 | /* Caller has to take the lock before calling this function */ |
Hoonki Lee | 2751190 | 2013-03-14 18:19:06 -0700 | [diff] [blame] | 1973 | static void wlan_tdd_tdls_reset_tx_rx(tdlsCtx_t *pHddTdlsCtx) |
| 1974 | { |
| 1975 | int i; |
| 1976 | struct list_head *head; |
| 1977 | hddTdlsPeer_t *tmp; |
| 1978 | struct list_head *pos, *q; |
| 1979 | |
Hoonki Lee | 2751190 | 2013-03-14 18:19:06 -0700 | [diff] [blame] | 1980 | for (i = 0; i < 256; i++) { |
| 1981 | head = &pHddTdlsCtx->peer_list[i]; |
| 1982 | list_for_each_safe (pos, q, head) { |
| 1983 | tmp = list_entry(pos, hddTdlsPeer_t, node); |
| 1984 | tmp->tx_pkt = 0; |
| 1985 | tmp->rx_pkt = 0; |
| 1986 | } |
| 1987 | } |
Hoonki Lee | 2751190 | 2013-03-14 18:19:06 -0700 | [diff] [blame] | 1988 | |
| 1989 | return ; |
| 1990 | } |
| 1991 | |
Gopichand Nakkala | 638ebc7 | 2013-03-21 18:04:02 -0700 | [diff] [blame] | 1992 | /* Caller has to take the lock before calling this function */ |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 1993 | static tANI_S32 wlan_hdd_tdls_peer_reset_discovery_processed(tdlsCtx_t *pHddTdlsCtx) |
Gopichand Nakkala | c369458 | 2013-02-13 20:51:22 -0800 | [diff] [blame] | 1994 | { |
| 1995 | int i; |
| 1996 | struct list_head *head; |
| 1997 | hddTdlsPeer_t *tmp; |
| 1998 | struct list_head *pos, *q; |
| 1999 | |
Gopichand Nakkala | c369458 | 2013-02-13 20:51:22 -0800 | [diff] [blame] | 2000 | pHddTdlsCtx->discovery_peer_cnt = 0; |
| 2001 | |
| 2002 | for (i = 0; i < 256; i++) { |
| 2003 | head = &pHddTdlsCtx->peer_list[i]; |
| 2004 | list_for_each_safe (pos, q, head) { |
| 2005 | tmp = list_entry(pos, hddTdlsPeer_t, node); |
| 2006 | tmp->discovery_processed = 0; |
| 2007 | } |
| 2008 | } |
Gopichand Nakkala | c369458 | 2013-02-13 20:51:22 -0800 | [diff] [blame] | 2009 | |
| 2010 | return 0; |
| 2011 | } |
| 2012 | |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 2013 | static tANI_S32 wlan_hdd_get_tdls_discovery_peer_cnt(tdlsCtx_t *pHddTdlsCtx) |
Gopichand Nakkala | c369458 | 2013-02-13 20:51:22 -0800 | [diff] [blame] | 2014 | { |
| 2015 | int i; |
| 2016 | struct list_head *head; |
| 2017 | struct list_head *pos, *q; |
| 2018 | int discovery_peer_cnt=0; |
| 2019 | hddTdlsPeer_t *tmp; |
| 2020 | |
Gopichand Nakkala | eb69b60 | 2013-02-27 11:40:31 -0800 | [diff] [blame] | 2021 | /* |
| 2022 | * This function expects the callers to acquire the Mutex. |
| 2023 | */ |
Gopichand Nakkala | c369458 | 2013-02-13 20:51:22 -0800 | [diff] [blame] | 2024 | |
| 2025 | for (i = 0; i < 256; i++) { |
| 2026 | head = &pHddTdlsCtx->peer_list[i]; |
| 2027 | list_for_each_safe (pos, q, head) { |
| 2028 | tmp = list_entry(pos, hddTdlsPeer_t, node); |
Masti, Narayanraddi | 34e0e56 | 2015-03-05 18:23:03 +0530 | [diff] [blame] | 2029 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Chilam Ng | 0112041 | 2013-02-19 18:32:21 -0800 | [diff] [blame] | 2030 | "%s, %d, " MAC_ADDRESS_STR, __func__, i, |
| 2031 | MAC_ADDR_ARRAY(tmp->peerMac)); |
Gopichand Nakkala | c369458 | 2013-02-13 20:51:22 -0800 | [diff] [blame] | 2032 | discovery_peer_cnt++; |
| 2033 | } |
| 2034 | } |
Gopichand Nakkala | c369458 | 2013-02-13 20:51:22 -0800 | [diff] [blame] | 2035 | return discovery_peer_cnt; |
| 2036 | } |
| 2037 | |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 2038 | tANI_U16 wlan_hdd_tdlsConnectedPeers(hdd_adapter_t *pAdapter) |
Lee Hoonki | c1262f2 | 2013-01-24 21:59:00 -0800 | [diff] [blame] | 2039 | { |
Hanumantha Reddy Pothula | da0fe36 | 2015-02-27 18:37:03 +0530 | [diff] [blame] | 2040 | hdd_context_t *pHddCtx = NULL; |
| 2041 | |
| 2042 | if ((NULL == pAdapter) || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic)) |
| 2043 | { |
| 2044 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2045 | FL("invalid pAdapter: %p"), pAdapter); |
| 2046 | return 0; |
| 2047 | } |
| 2048 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 2049 | |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 2050 | ENTER(); |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 2051 | if(0 != (wlan_hdd_validate_context(pHddCtx))) |
| 2052 | { |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 2053 | return 0; |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 2054 | } |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 2055 | EXIT(); |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 2056 | return pHddCtx->connected_peer_count; |
Lee Hoonki | c1262f2 | 2013-01-24 21:59:00 -0800 | [diff] [blame] | 2057 | } |
Chilam Ng | 16a2a1c | 2013-01-29 01:27:29 -0800 | [diff] [blame] | 2058 | |
Pradeep Reddy POTTETI | e309c15 | 2015-02-06 13:21:07 +0530 | [diff] [blame] | 2059 | hddTdlsPeer_t *wlan_hdd_tdls_get_connected_peer(hdd_adapter_t *pAdapter) |
Pradeep Reddy POTTETI | edaeb5f | 2014-05-22 23:34:41 +0530 | [diff] [blame] | 2060 | { |
| 2061 | int i; |
| 2062 | struct list_head *head; |
| 2063 | struct list_head *pos; |
| 2064 | hddTdlsPeer_t *curr_peer = NULL; |
| 2065 | tdlsCtx_t *pHddTdlsCtx; |
| 2066 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 2067 | |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 2068 | ENTER(); |
Pradeep Reddy POTTETI | edaeb5f | 2014-05-22 23:34:41 +0530 | [diff] [blame] | 2069 | if(0 != (wlan_hdd_validate_context(pHddCtx))) |
| 2070 | { |
Pradeep Reddy POTTETI | edaeb5f | 2014-05-22 23:34:41 +0530 | [diff] [blame] | 2071 | return NULL; |
| 2072 | } |
| 2073 | |
| 2074 | mutex_lock(&pHddCtx->tdls_lock); |
| 2075 | pHddTdlsCtx = WLAN_HDD_GET_TDLS_CTX_PTR(pAdapter); |
| 2076 | if (NULL == pHddTdlsCtx) { |
| 2077 | mutex_unlock(&pHddCtx->tdls_lock); |
| 2078 | return NULL; |
| 2079 | } |
| 2080 | for (i = 0; i < 256; i++) { |
| 2081 | head = &pHddTdlsCtx->peer_list[i]; |
| 2082 | |
| 2083 | list_for_each(pos, head) { |
| 2084 | curr_peer= list_entry (pos, hddTdlsPeer_t, node); |
Pradeep Reddy POTTETI | 8a62313 | 2014-06-26 16:07:06 +0530 | [diff] [blame] | 2085 | if (curr_peer && (curr_peer->link_status == eTDLS_LINK_CONNECTED)) |
Pradeep Reddy POTTETI | edaeb5f | 2014-05-22 23:34:41 +0530 | [diff] [blame] | 2086 | { |
| 2087 | mutex_unlock(&pHddCtx->tdls_lock); |
Masti, Narayanraddi | 34e0e56 | 2015-03-05 18:23:03 +0530 | [diff] [blame] | 2088 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Pradeep Reddy POTTETI | 8a62313 | 2014-06-26 16:07:06 +0530 | [diff] [blame] | 2089 | "%s: " MAC_ADDRESS_STR " eTDLS_LINK_CONNECTED", |
| 2090 | __func__, MAC_ADDR_ARRAY(curr_peer->peerMac)); |
Pradeep Reddy POTTETI | edaeb5f | 2014-05-22 23:34:41 +0530 | [diff] [blame] | 2091 | return curr_peer; |
| 2092 | } |
| 2093 | } |
| 2094 | } |
| 2095 | mutex_unlock(&pHddCtx->tdls_lock); |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 2096 | |
| 2097 | EXIT(); |
Pradeep Reddy POTTETI | edaeb5f | 2014-05-22 23:34:41 +0530 | [diff] [blame] | 2098 | return NULL; |
| 2099 | } |
| 2100 | |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 2101 | int wlan_hdd_tdls_get_all_peers(hdd_adapter_t *pAdapter, char *buf, int buflen) |
Chilam Ng | 16a2a1c | 2013-01-29 01:27:29 -0800 | [diff] [blame] | 2102 | { |
| 2103 | int i; |
| 2104 | int len, init_len; |
Hoonki Lee | 387663d | 2013-02-05 18:08:43 -0800 | [diff] [blame] | 2105 | struct list_head *head; |
| 2106 | struct list_head *pos; |
Chilam Ng | 16a2a1c | 2013-01-29 01:27:29 -0800 | [diff] [blame] | 2107 | hddTdlsPeer_t *curr_peer; |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 2108 | tdlsCtx_t *pHddTdlsCtx; |
Madan Mohan Koyyalamudi | 263cec1 | 2013-10-07 10:57:50 +0530 | [diff] [blame] | 2109 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 2110 | |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 2111 | ENTER(); |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 2112 | if(0 != (wlan_hdd_validate_context(pHddCtx))) |
| 2113 | { |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 2114 | return 0; |
Madan Mohan Koyyalamudi | 263cec1 | 2013-10-07 10:57:50 +0530 | [diff] [blame] | 2115 | } |
Chilam Ng | 16a2a1c | 2013-01-29 01:27:29 -0800 | [diff] [blame] | 2116 | |
Chilam Ng | 16a2a1c | 2013-01-29 01:27:29 -0800 | [diff] [blame] | 2117 | init_len = buflen; |
Sameer Thalappil | b0a3023 | 2013-09-27 15:37:48 -0700 | [diff] [blame] | 2118 | len = scnprintf(buf, buflen, "\n%-18s%-3s%-4s%-3s%-5s\n", |
| 2119 | "MAC", "Id", "cap", "up", "RSSI"); |
Chilam Ng | 16a2a1c | 2013-01-29 01:27:29 -0800 | [diff] [blame] | 2120 | buf += len; |
| 2121 | buflen -= len; |
| 2122 | /* 1234567890123456789012345678901234567 */ |
Sameer Thalappil | b0a3023 | 2013-09-27 15:37:48 -0700 | [diff] [blame] | 2123 | len = scnprintf(buf, buflen, "---------------------------------\n"); |
Chilam Ng | 16a2a1c | 2013-01-29 01:27:29 -0800 | [diff] [blame] | 2124 | buf += len; |
| 2125 | buflen -= len; |
| 2126 | |
Rajesh Chauhan | a34c6e6 | 2014-03-25 16:37:58 +0530 | [diff] [blame] | 2127 | mutex_lock(&pHddCtx->tdls_lock); |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 2128 | pHddTdlsCtx = WLAN_HDD_GET_TDLS_CTX_PTR(pAdapter); |
Gopichand Nakkala | eb69b60 | 2013-02-27 11:40:31 -0800 | [diff] [blame] | 2129 | if (NULL == pHddTdlsCtx) { |
Madan Mohan Koyyalamudi | 263cec1 | 2013-10-07 10:57:50 +0530 | [diff] [blame] | 2130 | mutex_unlock(&pHddCtx->tdls_lock); |
Sameer Thalappil | b0a3023 | 2013-09-27 15:37:48 -0700 | [diff] [blame] | 2131 | len = scnprintf(buf, buflen, "TDLS not enabled\n"); |
Gopichand Nakkala | eb69b60 | 2013-02-27 11:40:31 -0800 | [diff] [blame] | 2132 | return len; |
| 2133 | } |
Chilam Ng | 16a2a1c | 2013-01-29 01:27:29 -0800 | [diff] [blame] | 2134 | for (i = 0; i < 256; i++) { |
Hoonki Lee | 387663d | 2013-02-05 18:08:43 -0800 | [diff] [blame] | 2135 | head = &pHddTdlsCtx->peer_list[i]; |
Chilam Ng | 16a2a1c | 2013-01-29 01:27:29 -0800 | [diff] [blame] | 2136 | |
Hoonki Lee | 387663d | 2013-02-05 18:08:43 -0800 | [diff] [blame] | 2137 | list_for_each(pos, head) { |
| 2138 | curr_peer= list_entry (pos, hddTdlsPeer_t, node); |
Chilam Ng | 16a2a1c | 2013-01-29 01:27:29 -0800 | [diff] [blame] | 2139 | |
Hoonki Lee | 387663d | 2013-02-05 18:08:43 -0800 | [diff] [blame] | 2140 | if (buflen < 32+1) |
| 2141 | break; |
Sameer Thalappil | b0a3023 | 2013-09-27 15:37:48 -0700 | [diff] [blame] | 2142 | len = scnprintf(buf, buflen, |
Chilam Ng | 0112041 | 2013-02-19 18:32:21 -0800 | [diff] [blame] | 2143 | MAC_ADDRESS_STR"%3d%4s%3s%5d\n", |
| 2144 | MAC_ADDR_ARRAY(curr_peer->peerMac), |
Hoonki Lee | 387663d | 2013-02-05 18:08:43 -0800 | [diff] [blame] | 2145 | curr_peer->staId, |
| 2146 | (curr_peer->tdls_support == eTDLS_CAP_SUPPORTED) ? "Y":"N", |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 2147 | TDLS_IS_CONNECTED(curr_peer) ? "Y":"N", |
Hoonki Lee | 387663d | 2013-02-05 18:08:43 -0800 | [diff] [blame] | 2148 | curr_peer->rssi); |
| 2149 | buf += len; |
| 2150 | buflen -= len; |
Chilam Ng | 16a2a1c | 2013-01-29 01:27:29 -0800 | [diff] [blame] | 2151 | } |
| 2152 | } |
Madan Mohan Koyyalamudi | 263cec1 | 2013-10-07 10:57:50 +0530 | [diff] [blame] | 2153 | mutex_unlock(&pHddCtx->tdls_lock); |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 2154 | |
| 2155 | EXIT(); |
Chilam Ng | 16a2a1c | 2013-01-29 01:27:29 -0800 | [diff] [blame] | 2156 | return init_len-buflen; |
| 2157 | } |
Gopichand Nakkala | c369458 | 2013-02-13 20:51:22 -0800 | [diff] [blame] | 2158 | |
| 2159 | void wlan_hdd_tdls_connection_callback(hdd_adapter_t *pAdapter) |
| 2160 | { |
Mahesh A Saptasagar | 36cdc80 | 2015-01-07 18:41:17 +0530 | [diff] [blame] | 2161 | tdlsCtx_t *pHddTdlsCtx; |
Madan Mohan Koyyalamudi | 263cec1 | 2013-10-07 10:57:50 +0530 | [diff] [blame] | 2162 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
Gopichand Nakkala | 9d76a9b | 2013-02-28 15:38:37 -0800 | [diff] [blame] | 2163 | |
Mahesh A Saptasagar | 36cdc80 | 2015-01-07 18:41:17 +0530 | [diff] [blame] | 2164 | if ((NULL == pHddCtx)) |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 2165 | { |
Agarwal Ashish | bf98caf | 2014-03-25 13:29:11 +0530 | [diff] [blame] | 2166 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, |
| 2167 | FL("pHddCtx or pHddTdlsCtx points to NULL")); |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 2168 | return; |
| 2169 | } |
Madan Mohan Koyyalamudi | 263cec1 | 2013-10-07 10:57:50 +0530 | [diff] [blame] | 2170 | |
Rajesh Chauhan | a34c6e6 | 2014-03-25 16:37:58 +0530 | [diff] [blame] | 2171 | mutex_lock(&pHddCtx->tdls_lock); |
Gopichand Nakkala | 638ebc7 | 2013-03-21 18:04:02 -0700 | [diff] [blame] | 2172 | |
Mahesh A Saptasagar | 36cdc80 | 2015-01-07 18:41:17 +0530 | [diff] [blame] | 2173 | if (0 != wlan_hdd_sta_tdls_init(pAdapter)) |
| 2174 | { |
Mahesh A Saptasagar | 36cdc80 | 2015-01-07 18:41:17 +0530 | [diff] [blame] | 2175 | mutex_unlock(&pHddCtx->tdls_lock); |
Hema Aparna Medicharla | 8bb6f78 | 2015-03-09 12:35:05 +0530 | [diff] [blame] | 2176 | hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wlan_hdd_sta_tdls_init failed",__func__); |
Mahesh A Saptasagar | 36cdc80 | 2015-01-07 18:41:17 +0530 | [diff] [blame] | 2177 | return; |
| 2178 | } |
Mahesh A Saptasagar | 36cdc80 | 2015-01-07 18:41:17 +0530 | [diff] [blame] | 2179 | |
| 2180 | pHddTdlsCtx = WLAN_HDD_GET_TDLS_CTX_PTR(pAdapter); |
| 2181 | if ((NULL == pHddTdlsCtx)) |
| 2182 | { |
Hema Aparna Medicharla | 8bb6f78 | 2015-03-09 12:35:05 +0530 | [diff] [blame] | 2183 | mutex_unlock(&pHddCtx->tdls_lock); |
Mahesh A Saptasagar | 36cdc80 | 2015-01-07 18:41:17 +0530 | [diff] [blame] | 2184 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, |
| 2185 | FL("pHddCtx or pHddTdlsCtx points to NULL device mode = %d"), pAdapter->device_mode); |
Mahesh A Saptasagar | 36cdc80 | 2015-01-07 18:41:17 +0530 | [diff] [blame] | 2186 | return; |
| 2187 | } |
Masti, Narayanraddi | 34e0e56 | 2015-03-05 18:23:03 +0530 | [diff] [blame] | 2188 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Gopichand Nakkala | c369458 | 2013-02-13 20:51:22 -0800 | [diff] [blame] | 2189 | "%s, update %d discover %d", __func__, |
| 2190 | pHddTdlsCtx->threshold_config.tx_period_t, |
| 2191 | pHddTdlsCtx->threshold_config.discovery_period_t); |
| 2192 | |
Gopichand Nakkala | 9d76a9b | 2013-02-28 15:38:37 -0800 | [diff] [blame] | 2193 | if (eTDLS_SUPPORT_ENABLED == pHddCtx->tdls_mode) |
| 2194 | { |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 2195 | wlan_hdd_tdls_peer_reset_discovery_processed(pHddTdlsCtx); |
Gopichand Nakkala | 75e7b28 | 2013-03-15 18:37:13 -0700 | [diff] [blame] | 2196 | pHddTdlsCtx->discovery_sent_cnt = 0; |
Gopichand Nakkala | 34d1b06 | 2013-03-19 15:28:33 -0700 | [diff] [blame] | 2197 | wlan_hdd_tdls_check_power_save_prohibited(pHddTdlsCtx->pAdapter); |
Gopichand Nakkala | c369458 | 2013-02-13 20:51:22 -0800 | [diff] [blame] | 2198 | |
Gopichand Nakkala | 3046fc9 | 2013-03-23 13:56:43 -0700 | [diff] [blame] | 2199 | wlan_hdd_tdls_timer_restart(pHddTdlsCtx->pAdapter, |
| 2200 | &pHddTdlsCtx->peerUpdateTimer, |
| 2201 | pHddTdlsCtx->threshold_config.tx_period_t); |
Gopichand Nakkala | 9d76a9b | 2013-02-28 15:38:37 -0800 | [diff] [blame] | 2202 | } |
Madan Mohan Koyyalamudi | 263cec1 | 2013-10-07 10:57:50 +0530 | [diff] [blame] | 2203 | mutex_unlock(&pHddCtx->tdls_lock); |
Gopichand Nakkala | c369458 | 2013-02-13 20:51:22 -0800 | [diff] [blame] | 2204 | |
| 2205 | } |
| 2206 | |
| 2207 | void wlan_hdd_tdls_disconnection_callback(hdd_adapter_t *pAdapter) |
| 2208 | { |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 2209 | tdlsCtx_t *pHddTdlsCtx = WLAN_HDD_GET_TDLS_CTX_PTR(pAdapter); |
Madan Mohan Koyyalamudi | 263cec1 | 2013-10-07 10:57:50 +0530 | [diff] [blame] | 2210 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 2211 | |
Deepthi Gowri | bfd1713 | 2014-11-14 17:59:04 +0530 | [diff] [blame] | 2212 | if (NULL == pHddCtx) |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 2213 | { |
| 2214 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Deepthi Gowri | bfd1713 | 2014-11-14 17:59:04 +0530 | [diff] [blame] | 2215 | FL(" pHddCtx points to NULL")); |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 2216 | return; |
| 2217 | } |
Gopichand Nakkala | c369458 | 2013-02-13 20:51:22 -0800 | [diff] [blame] | 2218 | |
Masti, Narayanraddi | 34e0e56 | 2015-03-05 18:23:03 +0530 | [diff] [blame] | 2219 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s", __func__); |
Gopichand Nakkala | c369458 | 2013-02-13 20:51:22 -0800 | [diff] [blame] | 2220 | |
Gopichand Nakkala | eb69b60 | 2013-02-27 11:40:31 -0800 | [diff] [blame] | 2221 | if (NULL == pHddTdlsCtx) |
| 2222 | { |
Hema Aparna Medicharla | 8bb6f78 | 2015-03-09 12:35:05 +0530 | [diff] [blame] | 2223 | mutex_unlock(&pHddCtx->tdls_lock); |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 2224 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2225 | FL("pHddTdlsCtx is NULL")); |
Gopichand Nakkala | eb69b60 | 2013-02-27 11:40:31 -0800 | [diff] [blame] | 2226 | return; |
| 2227 | } |
Masti, Narayanraddi | de96b99 | 2015-01-08 13:00:58 +0530 | [diff] [blame] | 2228 | |
Pradeep Reddy POTTETI | 2d4d5c4 | 2015-03-03 14:34:19 +0530 | [diff] [blame] | 2229 | mutex_lock(&pHddCtx->tdls_lock); |
Masti, Narayanraddi | de96b99 | 2015-01-08 13:00:58 +0530 | [diff] [blame] | 2230 | |
Gopichand Nakkala | ccd3a38 | 2013-03-19 13:56:10 -0700 | [diff] [blame] | 2231 | pHddTdlsCtx->discovery_sent_cnt = 0; |
Gopichand Nakkala | 34d1b06 | 2013-03-19 15:28:33 -0700 | [diff] [blame] | 2232 | wlan_hdd_tdls_check_power_save_prohibited(pHddTdlsCtx->pAdapter); |
Gopichand Nakkala | eb69b60 | 2013-02-27 11:40:31 -0800 | [diff] [blame] | 2233 | |
Pradeep Reddy POTTETI | 2d4d5c4 | 2015-03-03 14:34:19 +0530 | [diff] [blame] | 2234 | wlan_hdd_tdls_exit(pAdapter, TRUE); |
Gopichand Nakkala | eb69b60 | 2013-02-27 11:40:31 -0800 | [diff] [blame] | 2235 | |
Madan Mohan Koyyalamudi | 263cec1 | 2013-10-07 10:57:50 +0530 | [diff] [blame] | 2236 | mutex_unlock(&pHddCtx->tdls_lock); |
Gopichand Nakkala | c369458 | 2013-02-13 20:51:22 -0800 | [diff] [blame] | 2237 | } |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 2238 | |
| 2239 | void wlan_hdd_tdls_mgmt_completion_callback(hdd_adapter_t *pAdapter, tANI_U32 statusCode) |
| 2240 | { |
| 2241 | pAdapter->mgmtTxCompletionStatus = statusCode; |
Masti, Narayanraddi | 34e0e56 | 2015-03-05 18:23:03 +0530 | [diff] [blame] | 2242 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 2243 | "%s: Mgmt TX Completion %d",__func__, statusCode); |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 2244 | complete(&pAdapter->tdls_mgmt_comp); |
| 2245 | } |
| 2246 | |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 2247 | void wlan_hdd_tdls_increment_peer_count(hdd_adapter_t *pAdapter) |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 2248 | { |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 2249 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 2250 | |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 2251 | ENTER(); |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 2252 | if(0 != (wlan_hdd_validate_context(pHddCtx))) |
| 2253 | { |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 2254 | return; |
| 2255 | } |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 2256 | |
Rajesh Chauhan | a34c6e6 | 2014-03-25 16:37:58 +0530 | [diff] [blame] | 2257 | mutex_lock(&pHddCtx->tdls_lock); |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 2258 | |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 2259 | pHddCtx->connected_peer_count++; |
Gopichand Nakkala | 34d1b06 | 2013-03-19 15:28:33 -0700 | [diff] [blame] | 2260 | wlan_hdd_tdls_check_power_save_prohibited(pAdapter); |
Gopichand Nakkala | ccd3a38 | 2013-03-19 13:56:10 -0700 | [diff] [blame] | 2261 | |
Masti, Narayanraddi | 34e0e56 | 2015-03-05 18:23:03 +0530 | [diff] [blame] | 2262 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: %d", |
Gopichand Nakkala | ccd3a38 | 2013-03-19 13:56:10 -0700 | [diff] [blame] | 2263 | __func__, pHddCtx->connected_peer_count); |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 2264 | |
| 2265 | mutex_unlock(&pHddCtx->tdls_lock); |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 2266 | |
| 2267 | EXIT(); |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 2268 | } |
| 2269 | |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 2270 | void wlan_hdd_tdls_decrement_peer_count(hdd_adapter_t *pAdapter) |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 2271 | { |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 2272 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 2273 | |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 2274 | ENTER(); |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 2275 | if(0 != (wlan_hdd_validate_context(pHddCtx))) |
| 2276 | { |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 2277 | return; |
| 2278 | } |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 2279 | |
Rajesh Chauhan | a34c6e6 | 2014-03-25 16:37:58 +0530 | [diff] [blame] | 2280 | mutex_lock(&pHddCtx->tdls_lock); |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 2281 | |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 2282 | if (pHddCtx->connected_peer_count) |
| 2283 | pHddCtx->connected_peer_count--; |
Gopichand Nakkala | 34d1b06 | 2013-03-19 15:28:33 -0700 | [diff] [blame] | 2284 | wlan_hdd_tdls_check_power_save_prohibited(pAdapter); |
Gopichand Nakkala | ccd3a38 | 2013-03-19 13:56:10 -0700 | [diff] [blame] | 2285 | |
Masti, Narayanraddi | 34e0e56 | 2015-03-05 18:23:03 +0530 | [diff] [blame] | 2286 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: %d", |
Gopichand Nakkala | ccd3a38 | 2013-03-19 13:56:10 -0700 | [diff] [blame] | 2287 | __func__, pHddCtx->connected_peer_count); |
| 2288 | |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 2289 | mutex_unlock(&pHddCtx->tdls_lock); |
| 2290 | |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 2291 | EXIT(); |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 2292 | } |
| 2293 | |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 2294 | void wlan_hdd_tdls_check_bmps(hdd_adapter_t *pAdapter) |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 2295 | { |
Hanumantha Reddy Pothula | da0fe36 | 2015-02-27 18:37:03 +0530 | [diff] [blame] | 2296 | |
| 2297 | tdlsCtx_t *pHddTdlsCtx = NULL; |
| 2298 | hdd_context_t *pHddCtx = NULL; |
Hoonki Lee | 1462135 | 2013-04-16 17:51:19 -0700 | [diff] [blame] | 2299 | hddTdlsPeer_t *curr_peer; |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 2300 | |
Hanumantha Reddy Pothula | da0fe36 | 2015-02-27 18:37:03 +0530 | [diff] [blame] | 2301 | if ((NULL == pAdapter) || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic)) |
| 2302 | { |
| 2303 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2304 | FL("invalid pAdapter: %p"), pAdapter); |
| 2305 | return; |
| 2306 | } |
| 2307 | |
| 2308 | pHddTdlsCtx = WLAN_HDD_GET_TDLS_CTX_PTR(pAdapter); |
| 2309 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 2310 | |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 2311 | if ((NULL == pHddCtx) || (NULL == pHddTdlsCtx)) |
| 2312 | { |
Sushant Kaushik | 125ae69 | 2014-11-25 17:38:48 +0530 | [diff] [blame] | 2313 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 2314 | FL(" pHddCtx or pHddTdlsCtx points to NULL")); |
| 2315 | return; |
| 2316 | } |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 2317 | |
Pradeep Reddy POTTETI | 9db32f0 | 2015-01-29 15:22:54 +0530 | [diff] [blame] | 2318 | curr_peer = wlan_hdd_tdls_is_progress(pHddCtx, NULL, 0, TRUE); |
Hoonki Lee | 1462135 | 2013-04-16 17:51:19 -0700 | [diff] [blame] | 2319 | if (NULL != curr_peer) |
| 2320 | { |
Masti, Narayanraddi | 34e0e56 | 2015-03-05 18:23:03 +0530 | [diff] [blame] | 2321 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Hoonki Lee | 1462135 | 2013-04-16 17:51:19 -0700 | [diff] [blame] | 2322 | "%s: tdls in progress. Dont check for BMPS " MAC_ADDRESS_STR, |
| 2323 | __func__, MAC_ADDR_ARRAY (curr_peer->peerMac)); |
| 2324 | return; |
| 2325 | } |
| 2326 | |
Hoonki Lee | 93e67ff | 2013-03-19 15:49:25 -0700 | [diff] [blame] | 2327 | if ((TDLS_CTX_MAGIC != pHddCtx->tdls_scan_ctxt.magic) && |
| 2328 | (0 == pHddCtx->connected_peer_count) && |
Gopichand Nakkala | 75e7b28 | 2013-03-15 18:37:13 -0700 | [diff] [blame] | 2329 | (0 == pHddTdlsCtx->discovery_sent_cnt)) |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 2330 | { |
Gopichand Nakkala | 75e7b28 | 2013-03-15 18:37:13 -0700 | [diff] [blame] | 2331 | if (FALSE == sme_IsPmcBmps(WLAN_HDD_GET_HAL_CTX(pAdapter))) |
| 2332 | { |
Masti, Narayanraddi | 34e0e56 | 2015-03-05 18:23:03 +0530 | [diff] [blame] | 2333 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, |
Gopichand Nakkala | ccd3a38 | 2013-03-19 13:56:10 -0700 | [diff] [blame] | 2334 | "%s: No TDLS peer connected/discovery sent. Enable BMPS", |
| 2335 | __func__); |
Gopichand Nakkala | 75e7b28 | 2013-03-15 18:37:13 -0700 | [diff] [blame] | 2336 | hdd_enable_bmps_imps(pHddCtx); |
| 2337 | } |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 2338 | } |
Gopichand Nakkala | 75e7b28 | 2013-03-15 18:37:13 -0700 | [diff] [blame] | 2339 | else |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 2340 | { |
Gopichand Nakkala | 75e7b28 | 2013-03-15 18:37:13 -0700 | [diff] [blame] | 2341 | if (TRUE == sme_IsPmcBmps(WLAN_HDD_GET_HAL_CTX(pAdapter))) |
| 2342 | { |
Masti, Narayanraddi | 34e0e56 | 2015-03-05 18:23:03 +0530 | [diff] [blame] | 2343 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Gopichand Nakkala | ccd3a38 | 2013-03-19 13:56:10 -0700 | [diff] [blame] | 2344 | "%s: TDLS peer connected. Disable BMPS", __func__); |
Gopichand Nakkala | 75e7b28 | 2013-03-15 18:37:13 -0700 | [diff] [blame] | 2345 | hdd_disable_bmps_imps(pHddCtx, WLAN_HDD_INFRA_STATION); |
| 2346 | } |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 2347 | } |
| 2348 | return; |
| 2349 | } |
| 2350 | |
Gopichand Nakkala | 34d1b06 | 2013-03-19 15:28:33 -0700 | [diff] [blame] | 2351 | u8 wlan_hdd_tdls_is_peer_progress(hdd_adapter_t *pAdapter, u8 *mac) |
| 2352 | { |
| 2353 | hddTdlsPeer_t *curr_peer; |
| 2354 | |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 2355 | curr_peer = wlan_hdd_tdls_find_peer(pAdapter, mac, TRUE); |
Gopichand Nakkala | 34d1b06 | 2013-03-19 15:28:33 -0700 | [diff] [blame] | 2356 | if (curr_peer == NULL) |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 2357 | { |
| 2358 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2359 | "%s: curr_peer is NULL", __func__); |
Gopichand Nakkala | 34d1b06 | 2013-03-19 15:28:33 -0700 | [diff] [blame] | 2360 | return 0; |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 2361 | } |
Gopichand Nakkala | 34d1b06 | 2013-03-19 15:28:33 -0700 | [diff] [blame] | 2362 | |
| 2363 | return (eTDLS_LINK_CONNECTING == curr_peer->link_status); |
| 2364 | } |
| 2365 | |
Hoonki Lee | fb8df67 | 2013-04-10 18:20:34 -0700 | [diff] [blame] | 2366 | /* return pointer to hddTdlsPeer_t if TDLS is ongoing. Otherwise return NULL. |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 2367 | * mac - if NULL check for all the peer list, otherwise, skip this mac when skip_self is TRUE |
| 2368 | * skip_self - if TRUE, skip this mac. otherwise, check all the peer list. if |
| 2369 | mac is NULL, this argument is ignored, and check for all the peer list. |
| 2370 | */ |
Anand N Sunkad | b3ab97d | 2015-07-29 09:58:13 +0530 | [diff] [blame^] | 2371 | static hddTdlsPeer_t *wlan_hdd_tdls_find_progress_peer(hdd_adapter_t *pAdapter, |
| 2372 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0)) |
| 2373 | const u8 *mac, |
| 2374 | #else |
| 2375 | u8 *mac, |
| 2376 | #endif |
| 2377 | u8 skip_self) |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 2378 | { |
| 2379 | int i; |
| 2380 | struct list_head *head; |
| 2381 | hddTdlsPeer_t *curr_peer; |
| 2382 | struct list_head *pos; |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 2383 | tdlsCtx_t *pHddTdlsCtx = WLAN_HDD_GET_TDLS_CTX_PTR(pAdapter);; |
Madan Mohan Koyyalamudi | 263cec1 | 2013-10-07 10:57:50 +0530 | [diff] [blame] | 2384 | |
Madan Mohan Koyyalamudi | 263cec1 | 2013-10-07 10:57:50 +0530 | [diff] [blame] | 2385 | if (NULL == pHddTdlsCtx) |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 2386 | { |
| 2387 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2388 | FL("pHddTdlsCtx is NULL")); |
Madan Mohan Koyyalamudi | 263cec1 | 2013-10-07 10:57:50 +0530 | [diff] [blame] | 2389 | return NULL; |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 2390 | } |
Madan Mohan Koyyalamudi | 263cec1 | 2013-10-07 10:57:50 +0530 | [diff] [blame] | 2391 | |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 2392 | for (i = 0; i < 256; i++) { |
| 2393 | head = &pHddTdlsCtx->peer_list[i]; |
| 2394 | list_for_each(pos, head) { |
| 2395 | curr_peer = list_entry (pos, hddTdlsPeer_t, node); |
| 2396 | if (skip_self && mac && !memcmp(mac, curr_peer->peerMac, 6)) { |
| 2397 | continue; |
| 2398 | } |
| 2399 | else |
| 2400 | { |
Gopichand Nakkala | 8b00c63 | 2013-03-08 19:47:52 -0800 | [diff] [blame] | 2401 | if (eTDLS_LINK_CONNECTING == curr_peer->link_status) |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 2402 | { |
Masti, Narayanraddi | 34e0e56 | 2015-03-05 18:23:03 +0530 | [diff] [blame] | 2403 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Gopichand Nakkala | 34d1b06 | 2013-03-19 15:28:33 -0700 | [diff] [blame] | 2404 | "%s:" MAC_ADDRESS_STR " eTDLS_LINK_CONNECTING", |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 2405 | __func__, MAC_ADDR_ARRAY(curr_peer->peerMac)); |
Hoonki Lee | fb8df67 | 2013-04-10 18:20:34 -0700 | [diff] [blame] | 2406 | return curr_peer; |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 2407 | } |
| 2408 | } |
| 2409 | } |
| 2410 | } |
Hoonki Lee | fb8df67 | 2013-04-10 18:20:34 -0700 | [diff] [blame] | 2411 | return NULL; |
| 2412 | } |
| 2413 | |
Anand N Sunkad | b3ab97d | 2015-07-29 09:58:13 +0530 | [diff] [blame^] | 2414 | hddTdlsPeer_t *wlan_hdd_tdls_is_progress(hdd_context_t *pHddCtx, |
| 2415 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0)) |
| 2416 | const u8 *mac, |
| 2417 | #else |
| 2418 | u8 *mac, |
| 2419 | #endif |
Pradeep Reddy POTTETI | 9db32f0 | 2015-01-29 15:22:54 +0530 | [diff] [blame] | 2420 | u8 skip_self, tANI_BOOLEAN mutexLock) |
Hoonki Lee | fb8df67 | 2013-04-10 18:20:34 -0700 | [diff] [blame] | 2421 | { |
| 2422 | hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL; |
| 2423 | hdd_adapter_t *pAdapter = NULL; |
| 2424 | tdlsCtx_t *pHddTdlsCtx = NULL; |
| 2425 | hddTdlsPeer_t *curr_peer= NULL; |
| 2426 | VOS_STATUS status = 0; |
| 2427 | |
Pradeep Reddy POTTETI | 9db32f0 | 2015-01-29 15:22:54 +0530 | [diff] [blame] | 2428 | if (mutexLock) |
| 2429 | { |
| 2430 | mutex_lock(&pHddCtx->tdls_lock); |
| 2431 | } |
Hoonki Lee | fb8df67 | 2013-04-10 18:20:34 -0700 | [diff] [blame] | 2432 | status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode ); |
| 2433 | while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status ) |
| 2434 | { |
| 2435 | pAdapter = pAdapterNode->pAdapter; |
| 2436 | |
| 2437 | pHddTdlsCtx = WLAN_HDD_GET_TDLS_CTX_PTR(pAdapter); |
| 2438 | if (NULL != pHddTdlsCtx) |
| 2439 | { |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 2440 | curr_peer = wlan_hdd_tdls_find_progress_peer(pAdapter, mac, skip_self); |
Hoonki Lee | fb8df67 | 2013-04-10 18:20:34 -0700 | [diff] [blame] | 2441 | if (curr_peer) |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 2442 | { |
Pradeep Reddy POTTETI | 9db32f0 | 2015-01-29 15:22:54 +0530 | [diff] [blame] | 2443 | if (mutexLock) |
| 2444 | mutex_unlock(&pHddCtx->tdls_lock); |
Hoonki Lee | fb8df67 | 2013-04-10 18:20:34 -0700 | [diff] [blame] | 2445 | return curr_peer; |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 2446 | } |
Hoonki Lee | fb8df67 | 2013-04-10 18:20:34 -0700 | [diff] [blame] | 2447 | } |
| 2448 | status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 2449 | pAdapterNode = pNext; |
| 2450 | } |
Pradeep Reddy POTTETI | 9db32f0 | 2015-01-29 15:22:54 +0530 | [diff] [blame] | 2451 | if (mutexLock) |
| 2452 | mutex_unlock(&pHddCtx->tdls_lock); |
Hoonki Lee | fb8df67 | 2013-04-10 18:20:34 -0700 | [diff] [blame] | 2453 | return NULL; |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 2454 | } |
Hoonki Lee | 2751190 | 2013-03-14 18:19:06 -0700 | [diff] [blame] | 2455 | |
| 2456 | static void wlan_hdd_tdls_implicit_disable(tdlsCtx_t *pHddTdlsCtx) |
| 2457 | { |
Hoonki Lee | 2751190 | 2013-03-14 18:19:06 -0700 | [diff] [blame] | 2458 | wlan_hdd_tdls_timers_stop(pHddTdlsCtx); |
Hoonki Lee | 2751190 | 2013-03-14 18:19:06 -0700 | [diff] [blame] | 2459 | } |
| 2460 | |
| 2461 | static void wlan_hdd_tdls_implicit_enable(tdlsCtx_t *pHddTdlsCtx) |
| 2462 | { |
| 2463 | wlan_hdd_tdls_peer_reset_discovery_processed(pHddTdlsCtx); |
Gopichand Nakkala | 75e7b28 | 2013-03-15 18:37:13 -0700 | [diff] [blame] | 2464 | pHddTdlsCtx->discovery_sent_cnt = 0; |
Hoonki Lee | 2751190 | 2013-03-14 18:19:06 -0700 | [diff] [blame] | 2465 | wlan_tdd_tdls_reset_tx_rx(pHddTdlsCtx); |
Gopichand Nakkala | 34d1b06 | 2013-03-19 15:28:33 -0700 | [diff] [blame] | 2466 | wlan_hdd_tdls_check_power_save_prohibited(pHddTdlsCtx->pAdapter); |
Gopichand Nakkala | ccd3a38 | 2013-03-19 13:56:10 -0700 | [diff] [blame] | 2467 | |
Hoonki Lee | 2751190 | 2013-03-14 18:19:06 -0700 | [diff] [blame] | 2468 | |
Gopichand Nakkala | 3046fc9 | 2013-03-23 13:56:43 -0700 | [diff] [blame] | 2469 | wlan_hdd_tdls_timer_restart(pHddTdlsCtx->pAdapter, |
| 2470 | &pHddTdlsCtx->peerUpdateTimer, |
| 2471 | pHddTdlsCtx->threshold_config.tx_period_t); |
Hoonki Lee | 2751190 | 2013-03-14 18:19:06 -0700 | [diff] [blame] | 2472 | } |
| 2473 | |
Gopichand Nakkala | dcbcf4e | 2013-03-23 14:32:39 -0700 | [diff] [blame] | 2474 | void wlan_hdd_tdls_set_mode(hdd_context_t *pHddCtx, |
| 2475 | eTDLSSupportMode tdls_mode, |
| 2476 | v_BOOL_t bUpdateLast) |
Hoonki Lee | 2751190 | 2013-03-14 18:19:06 -0700 | [diff] [blame] | 2477 | { |
| 2478 | hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL; |
| 2479 | VOS_STATUS status; |
| 2480 | hdd_adapter_t *pAdapter; |
| 2481 | tdlsCtx_t *pHddTdlsCtx; |
| 2482 | |
Masti, Narayanraddi | 34e0e56 | 2015-03-05 18:23:03 +0530 | [diff] [blame] | 2483 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 2484 | "%s mode %d", __func__, (int)tdls_mode); |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 2485 | |
| 2486 | if(0 != (wlan_hdd_validate_context(pHddCtx))) |
| 2487 | { |
Madan Mohan Koyyalamudi | 263cec1 | 2013-10-07 10:57:50 +0530 | [diff] [blame] | 2488 | return; |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 2489 | } |
Hoonki Lee | 2751190 | 2013-03-14 18:19:06 -0700 | [diff] [blame] | 2490 | |
Rajesh Chauhan | a34c6e6 | 2014-03-25 16:37:58 +0530 | [diff] [blame] | 2491 | mutex_lock(&pHddCtx->tdls_lock); |
Gopichand Nakkala | 638ebc7 | 2013-03-21 18:04:02 -0700 | [diff] [blame] | 2492 | |
Hoonki Lee | 93e67ff | 2013-03-19 15:49:25 -0700 | [diff] [blame] | 2493 | if (pHddCtx->tdls_mode == tdls_mode) |
| 2494 | { |
Hema Aparna Medicharla | 8bb6f78 | 2015-03-09 12:35:05 +0530 | [diff] [blame] | 2495 | mutex_unlock(&pHddCtx->tdls_lock); |
Masti, Narayanraddi | 34e0e56 | 2015-03-05 18:23:03 +0530 | [diff] [blame] | 2496 | hddLog(VOS_TRACE_LEVEL_INFO, "%s already in mode %d", __func__, |
| 2497 | (int)tdls_mode); |
Hoonki Lee | 93e67ff | 2013-03-19 15:49:25 -0700 | [diff] [blame] | 2498 | return; |
| 2499 | } |
| 2500 | |
Hoonki Lee | 2751190 | 2013-03-14 18:19:06 -0700 | [diff] [blame] | 2501 | status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode ); |
| 2502 | |
| 2503 | while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status ) |
| 2504 | { |
| 2505 | pAdapter = pAdapterNode->pAdapter; |
Hoonki Lee | a6d49be | 2013-04-05 09:43:25 -0700 | [diff] [blame] | 2506 | pHddTdlsCtx = WLAN_HDD_GET_TDLS_CTX_PTR(pAdapter); |
| 2507 | if (NULL != pHddTdlsCtx) |
Hoonki Lee | 2751190 | 2013-03-14 18:19:06 -0700 | [diff] [blame] | 2508 | { |
Hoonki Lee | a6d49be | 2013-04-05 09:43:25 -0700 | [diff] [blame] | 2509 | if(eTDLS_SUPPORT_ENABLED == tdls_mode) |
| 2510 | wlan_hdd_tdls_implicit_enable(pHddTdlsCtx); |
| 2511 | else if((eTDLS_SUPPORT_DISABLED == tdls_mode) || |
| 2512 | (eTDLS_SUPPORT_EXPLICIT_TRIGGER_ONLY == tdls_mode)) |
| 2513 | wlan_hdd_tdls_implicit_disable(pHddTdlsCtx); |
Hoonki Lee | 2751190 | 2013-03-14 18:19:06 -0700 | [diff] [blame] | 2514 | } |
| 2515 | status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 2516 | pAdapterNode = pNext; |
| 2517 | } |
Gopichand Nakkala | dcbcf4e | 2013-03-23 14:32:39 -0700 | [diff] [blame] | 2518 | if(bUpdateLast) |
| 2519 | { |
| 2520 | pHddCtx->tdls_mode_last = tdls_mode; |
| 2521 | } |
| 2522 | else |
| 2523 | { |
| 2524 | pHddCtx->tdls_mode_last = pHddCtx->tdls_mode; |
| 2525 | } |
Hoonki Lee | 2751190 | 2013-03-14 18:19:06 -0700 | [diff] [blame] | 2526 | pHddCtx->tdls_mode = tdls_mode; |
Gopichand Nakkala | dcbcf4e | 2013-03-23 14:32:39 -0700 | [diff] [blame] | 2527 | |
Madan Mohan Koyyalamudi | 263cec1 | 2013-10-07 10:57:50 +0530 | [diff] [blame] | 2528 | mutex_unlock(&pHddCtx->tdls_lock); |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 2529 | |
Hoonki Lee | 2751190 | 2013-03-14 18:19:06 -0700 | [diff] [blame] | 2530 | } |
Gopichand Nakkala | 75e7b28 | 2013-03-15 18:37:13 -0700 | [diff] [blame] | 2531 | |
Pradeep Reddy POTTETI | 9db32f0 | 2015-01-29 15:22:54 +0530 | [diff] [blame] | 2532 | static |
| 2533 | void wlan_hdd_tdls_implicit_send_discovery_request(tdlsCtx_t * pHddTdlsCtx) |
Gopichand Nakkala | 75e7b28 | 2013-03-15 18:37:13 -0700 | [diff] [blame] | 2534 | { |
Pradeep Reddy POTTETI | 9db32f0 | 2015-01-29 15:22:54 +0530 | [diff] [blame] | 2535 | hdd_context_t *pHddCtx = NULL; |
| 2536 | hddTdlsPeer_t *curr_peer = NULL, *temp_peer = NULL; |
Hoonki Lee | d37cbb3 | 2013-04-20 00:31:14 -0700 | [diff] [blame] | 2537 | |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 2538 | ENTER(); |
Hoonki Lee | d37cbb3 | 2013-04-20 00:31:14 -0700 | [diff] [blame] | 2539 | if (NULL == pHddTdlsCtx) |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 2540 | { |
| 2541 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2542 | FL("pHddTdlsCtx is NULL")); |
Hoonki Lee | d37cbb3 | 2013-04-20 00:31:14 -0700 | [diff] [blame] | 2543 | return; |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 2544 | } |
Hoonki Lee | d37cbb3 | 2013-04-20 00:31:14 -0700 | [diff] [blame] | 2545 | |
Hoonki Lee | d37cbb3 | 2013-04-20 00:31:14 -0700 | [diff] [blame] | 2546 | pHddCtx = WLAN_HDD_GET_CTX(pHddTdlsCtx->pAdapter); |
Hoonki Lee | fb8df67 | 2013-04-10 18:20:34 -0700 | [diff] [blame] | 2547 | |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 2548 | if(0 != (wlan_hdd_validate_context(pHddCtx))) |
| 2549 | { |
Hoonki Lee | fb8df67 | 2013-04-10 18:20:34 -0700 | [diff] [blame] | 2550 | return; |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 2551 | } |
Gopichand Nakkala | 75e7b28 | 2013-03-15 18:37:13 -0700 | [diff] [blame] | 2552 | |
Hoonki Lee | d37cbb3 | 2013-04-20 00:31:14 -0700 | [diff] [blame] | 2553 | curr_peer = pHddTdlsCtx->curr_candidate; |
Hoonki Lee | d37cbb3 | 2013-04-20 00:31:14 -0700 | [diff] [blame] | 2554 | if (NULL == curr_peer) |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 2555 | { |
| 2556 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2557 | FL("curr_peer is NULL")); |
| 2558 | |
Hoonki Lee | d37cbb3 | 2013-04-20 00:31:14 -0700 | [diff] [blame] | 2559 | return; |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 2560 | } |
Hoonki Lee | d37cbb3 | 2013-04-20 00:31:14 -0700 | [diff] [blame] | 2561 | |
Gopichand Nakkala | 75e7b28 | 2013-03-15 18:37:13 -0700 | [diff] [blame] | 2562 | if (TRUE == sme_IsPmcBmps(WLAN_HDD_GET_HAL_CTX(pHddTdlsCtx->pAdapter))) |
| 2563 | { |
Masti, Narayanraddi | 34e0e56 | 2015-03-05 18:23:03 +0530 | [diff] [blame] | 2564 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 2565 | "%s: Disable BMPS", __func__); |
Gopichand Nakkala | 75e7b28 | 2013-03-15 18:37:13 -0700 | [diff] [blame] | 2566 | hdd_disable_bmps_imps(pHddCtx, WLAN_HDD_INFRA_STATION); |
| 2567 | } |
Gopichand Nakkala | ccd3a38 | 2013-03-19 13:56:10 -0700 | [diff] [blame] | 2568 | |
Pradeep Reddy POTTETI | 9db32f0 | 2015-01-29 15:22:54 +0530 | [diff] [blame] | 2569 | /* This function is called in mutex_lock */ |
| 2570 | temp_peer = wlan_hdd_tdls_is_progress(pHddCtx, NULL, 0, FALSE); |
Hoonki Lee | fb8df67 | 2013-04-10 18:20:34 -0700 | [diff] [blame] | 2571 | if (NULL != temp_peer) |
| 2572 | { |
Pradeep Reddy POTTETI | 9db32f0 | 2015-01-29 15:22:54 +0530 | [diff] [blame] | 2573 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 2574 | "%s: " MAC_ADDRESS_STR " ongoing. pre_setup ignored", |
| 2575 | __func__, MAC_ADDR_ARRAY(temp_peer->peerMac)); |
Hoonki Lee | d37cbb3 | 2013-04-20 00:31:14 -0700 | [diff] [blame] | 2576 | goto done; |
Hoonki Lee | fb8df67 | 2013-04-10 18:20:34 -0700 | [diff] [blame] | 2577 | } |
| 2578 | |
Gopichand Nakkala | ccd3a38 | 2013-03-19 13:56:10 -0700 | [diff] [blame] | 2579 | if (eTDLS_CAP_UNKNOWN != curr_peer->tdls_support) |
Atul Mittal | 115287b | 2014-07-08 13:26:33 +0530 | [diff] [blame] | 2580 | wlan_hdd_tdls_set_peer_link_status(curr_peer, |
| 2581 | eTDLS_LINK_DISCOVERING, |
| 2582 | eTDLS_LINK_SUCCESS); |
Gopichand Nakkala | ccd3a38 | 2013-03-19 13:56:10 -0700 | [diff] [blame] | 2583 | |
Pradeep Reddy POTTETI | 9db32f0 | 2015-01-29 15:22:54 +0530 | [diff] [blame] | 2584 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 2585 | "%s: Implicit TDLS, Send Discovery request event", __func__); |
Hoonki Lee | d37cbb3 | 2013-04-20 00:31:14 -0700 | [diff] [blame] | 2586 | |
Pradeep Reddy POTTETI | 9db32f0 | 2015-01-29 15:22:54 +0530 | [diff] [blame] | 2587 | cfg80211_tdls_oper_request(pHddTdlsCtx->pAdapter->dev, |
| 2588 | curr_peer->peerMac, |
| 2589 | NL80211_TDLS_DISCOVERY_REQ, |
| 2590 | FALSE, |
| 2591 | GFP_KERNEL); |
Gopichand Nakkala | 75e7b28 | 2013-03-15 18:37:13 -0700 | [diff] [blame] | 2592 | pHddTdlsCtx->discovery_sent_cnt++; |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 2593 | |
Gopichand Nakkala | 34d1b06 | 2013-03-19 15:28:33 -0700 | [diff] [blame] | 2594 | wlan_hdd_tdls_check_power_save_prohibited(pHddTdlsCtx->pAdapter); |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 2595 | |
Pradeep Reddy POTTETI | 219ced3 | 2014-11-14 16:33:57 +0530 | [diff] [blame] | 2596 | wlan_hdd_tdls_timer_restart(pHddTdlsCtx->pAdapter, |
| 2597 | &pHddTdlsCtx->peerDiscoveryTimeoutTimer, |
| 2598 | pHddTdlsCtx->threshold_config.tx_period_t - TDLS_DISCOVERY_TIMEOUT_BEFORE_UPDATE); |
| 2599 | |
Pradeep Reddy POTTETI | 9db32f0 | 2015-01-29 15:22:54 +0530 | [diff] [blame] | 2600 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 2601 | "%s: discovery count %u timeout %u msec", |
| 2602 | __func__, pHddTdlsCtx->discovery_sent_cnt, |
| 2603 | pHddTdlsCtx->threshold_config.tx_period_t - TDLS_DISCOVERY_TIMEOUT_BEFORE_UPDATE); |
Gopichand Nakkala | 3046fc9 | 2013-03-23 13:56:43 -0700 | [diff] [blame] | 2604 | |
Hoonki Lee | d37cbb3 | 2013-04-20 00:31:14 -0700 | [diff] [blame] | 2605 | done: |
| 2606 | pHddTdlsCtx->curr_candidate = NULL; |
| 2607 | pHddTdlsCtx->magic = 0; |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 2608 | EXIT(); |
Gopichand Nakkala | 75e7b28 | 2013-03-15 18:37:13 -0700 | [diff] [blame] | 2609 | return; |
| 2610 | } |
Gopichand Nakkala | ccd3a38 | 2013-03-19 13:56:10 -0700 | [diff] [blame] | 2611 | |
| 2612 | tANI_U32 wlan_hdd_tdls_discovery_sent_cnt(hdd_context_t *pHddCtx) |
| 2613 | { |
| 2614 | hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL; |
| 2615 | hdd_adapter_t *pAdapter = NULL; |
| 2616 | tdlsCtx_t *pHddTdlsCtx = NULL; |
| 2617 | VOS_STATUS status = 0; |
| 2618 | tANI_U32 count = 0; |
| 2619 | |
| 2620 | status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode ); |
| 2621 | while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status ) |
| 2622 | { |
| 2623 | pAdapter = pAdapterNode->pAdapter; |
| 2624 | |
Hoonki Lee | a6d49be | 2013-04-05 09:43:25 -0700 | [diff] [blame] | 2625 | pHddTdlsCtx = WLAN_HDD_GET_TDLS_CTX_PTR(pAdapter); |
| 2626 | if (NULL != pHddTdlsCtx) |
Gopichand Nakkala | ccd3a38 | 2013-03-19 13:56:10 -0700 | [diff] [blame] | 2627 | { |
Hoonki Lee | a6d49be | 2013-04-05 09:43:25 -0700 | [diff] [blame] | 2628 | count = count + pHddTdlsCtx->discovery_sent_cnt; |
Gopichand Nakkala | ccd3a38 | 2013-03-19 13:56:10 -0700 | [diff] [blame] | 2629 | } |
| 2630 | status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 2631 | pAdapterNode = pNext; |
| 2632 | } |
| 2633 | return count; |
| 2634 | } |
| 2635 | |
Gopichand Nakkala | 34d1b06 | 2013-03-19 15:28:33 -0700 | [diff] [blame] | 2636 | void wlan_hdd_tdls_check_power_save_prohibited(hdd_adapter_t *pAdapter) |
Gopichand Nakkala | ccd3a38 | 2013-03-19 13:56:10 -0700 | [diff] [blame] | 2637 | { |
Hanumantha Reddy Pothula | da0fe36 | 2015-02-27 18:37:03 +0530 | [diff] [blame] | 2638 | tdlsCtx_t *pHddTdlsCtx = NULL; |
| 2639 | hdd_context_t *pHddCtx = NULL; |
Chandrasekaran, Manishekar | 41b8e1f | 2015-03-10 13:30:28 +0530 | [diff] [blame] | 2640 | |
Hanumantha Reddy Pothula | da0fe36 | 2015-02-27 18:37:03 +0530 | [diff] [blame] | 2641 | |
| 2642 | if ((NULL == pAdapter) || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic)) |
| 2643 | { |
| 2644 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2645 | FL("invalid pAdapter: %p"), pAdapter); |
Chandrasekaran, Manishekar | 41b8e1f | 2015-03-10 13:30:28 +0530 | [diff] [blame] | 2646 | return; |
| 2647 | } |
| 2648 | |
| 2649 | pHddTdlsCtx = WLAN_HDD_GET_TDLS_CTX_PTR(pAdapter); |
| 2650 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
Gopichand Nakkala | ccd3a38 | 2013-03-19 13:56:10 -0700 | [diff] [blame] | 2651 | |
| 2652 | if ((NULL == pHddTdlsCtx) || (NULL == pHddCtx)) |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 2653 | { |
| 2654 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2655 | FL(" pHddCtx or pHddTdlsCtx points to NULL")); |
Gopichand Nakkala | ccd3a38 | 2013-03-19 13:56:10 -0700 | [diff] [blame] | 2656 | return; |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 2657 | } |
Gopichand Nakkala | ccd3a38 | 2013-03-19 13:56:10 -0700 | [diff] [blame] | 2658 | |
| 2659 | if ((0 == pHddCtx->connected_peer_count) && |
| 2660 | (0 == wlan_hdd_tdls_discovery_sent_cnt(pHddCtx))) |
| 2661 | { |
| 2662 | sme_SetTdlsPowerSaveProhibited(WLAN_HDD_GET_HAL_CTX(pHddTdlsCtx->pAdapter), 0); |
| 2663 | return; |
| 2664 | } |
| 2665 | sme_SetTdlsPowerSaveProhibited(WLAN_HDD_GET_HAL_CTX(pHddTdlsCtx->pAdapter), 1); |
| 2666 | return; |
| 2667 | } |
Hoonki Lee | 93e67ff | 2013-03-19 15:49:25 -0700 | [diff] [blame] | 2668 | |
| 2669 | void wlan_hdd_tdls_free_scan_request (tdls_scan_context_t *tdls_scan_ctx) |
| 2670 | { |
| 2671 | if (NULL == tdls_scan_ctx) |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 2672 | { |
| 2673 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2674 | FL("tdls_scan_ctx is NULL")); |
Hoonki Lee | 93e67ff | 2013-03-19 15:49:25 -0700 | [diff] [blame] | 2675 | return; |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 2676 | } |
Hoonki Lee | 93e67ff | 2013-03-19 15:49:25 -0700 | [diff] [blame] | 2677 | |
Gopichand Nakkala | 3046fc9 | 2013-03-23 13:56:43 -0700 | [diff] [blame] | 2678 | tdls_scan_ctx->attempt = 0; |
Hoonki Lee | fb8df67 | 2013-04-10 18:20:34 -0700 | [diff] [blame] | 2679 | tdls_scan_ctx->reject = 0; |
Gopichand Nakkala | 3046fc9 | 2013-03-23 13:56:43 -0700 | [diff] [blame] | 2680 | tdls_scan_ctx->magic = 0; |
Hoonki Lee | 93e67ff | 2013-03-19 15:49:25 -0700 | [diff] [blame] | 2681 | tdls_scan_ctx->scan_request = NULL; |
| 2682 | return; |
| 2683 | } |
| 2684 | |
| 2685 | int wlan_hdd_tdls_copy_scan_context(hdd_context_t *pHddCtx, |
| 2686 | struct wiphy *wiphy, |
| 2687 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0)) |
| 2688 | struct net_device *dev, |
| 2689 | #endif |
| 2690 | struct cfg80211_scan_request *request) |
| 2691 | { |
| 2692 | tdls_scan_context_t *scan_ctx; |
| 2693 | |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 2694 | ENTER(); |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 2695 | if(0 != (wlan_hdd_validate_context(pHddCtx))) |
| 2696 | { |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 2697 | return 0; |
| 2698 | } |
Hoonki Lee | 93e67ff | 2013-03-19 15:49:25 -0700 | [diff] [blame] | 2699 | |
| 2700 | scan_ctx = &pHddCtx->tdls_scan_ctxt; |
| 2701 | |
| 2702 | scan_ctx->wiphy = wiphy; |
| 2703 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0)) |
| 2704 | scan_ctx->dev = dev; |
| 2705 | #endif |
| 2706 | |
| 2707 | scan_ctx->scan_request = request; |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 2708 | |
| 2709 | EXIT(); |
Hoonki Lee | 93e67ff | 2013-03-19 15:49:25 -0700 | [diff] [blame] | 2710 | return 0; |
| 2711 | } |
| 2712 | |
Hoonki Lee | 93e67ff | 2013-03-19 15:49:25 -0700 | [diff] [blame] | 2713 | static void wlan_hdd_tdls_scan_init_work(hdd_context_t *pHddCtx, |
| 2714 | struct wiphy *wiphy, |
| 2715 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0)) |
| 2716 | struct net_device *dev, |
| 2717 | #endif |
| 2718 | struct cfg80211_scan_request *request, |
| 2719 | unsigned long delay) |
| 2720 | { |
| 2721 | if (TDLS_CTX_MAGIC != pHddCtx->tdls_scan_ctxt.magic) |
| 2722 | { |
| 2723 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0)) |
| 2724 | wlan_hdd_tdls_copy_scan_context(pHddCtx, wiphy, dev, request); |
| 2725 | #else |
| 2726 | wlan_hdd_tdls_copy_scan_context(pHddCtx, wiphy, request); |
| 2727 | #endif |
| 2728 | pHddCtx->tdls_scan_ctxt.attempt = 0; |
| 2729 | pHddCtx->tdls_scan_ctxt.magic = TDLS_CTX_MAGIC; |
| 2730 | } |
Hoonki Lee | 93e67ff | 2013-03-19 15:49:25 -0700 | [diff] [blame] | 2731 | schedule_delayed_work(&pHddCtx->tdls_scan_ctxt.tdls_scan_work, delay); |
| 2732 | } |
| 2733 | |
| 2734 | /* return negative = caller should stop and return error code immediately |
| 2735 | return 0 = caller should stop and return success immediately |
| 2736 | return 1 = caller can continue to scan |
| 2737 | */ |
| 2738 | int wlan_hdd_tdls_scan_callback (hdd_adapter_t *pAdapter, |
| 2739 | struct wiphy *wiphy, |
| 2740 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0)) |
| 2741 | struct net_device *dev, |
| 2742 | #endif |
| 2743 | struct cfg80211_scan_request *request) |
| 2744 | { |
Hoonki Lee | 93e67ff | 2013-03-19 15:49:25 -0700 | [diff] [blame] | 2745 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 2746 | u16 connectedTdlsPeers; |
Pradeep Reddy POTTETI | edaeb5f | 2014-05-22 23:34:41 +0530 | [diff] [blame] | 2747 | hddTdlsPeer_t *curr_peer, *connected_peer; |
Hoonki Lee | 93e67ff | 2013-03-19 15:49:25 -0700 | [diff] [blame] | 2748 | unsigned long delay; |
Pradeep Reddy POTTETI | edaeb5f | 2014-05-22 23:34:41 +0530 | [diff] [blame] | 2749 | hdd_config_t *cfg_param = pHddCtx->cfg_ini; |
Hoonki Lee | 93e67ff | 2013-03-19 15:49:25 -0700 | [diff] [blame] | 2750 | |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 2751 | ENTER(); |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 2752 | if(0 != (wlan_hdd_validate_context(pHddCtx))) |
| 2753 | { |
Hoonki Lee | 93e67ff | 2013-03-19 15:49:25 -0700 | [diff] [blame] | 2754 | return 0; |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 2755 | } |
Hoonki Lee | 93e67ff | 2013-03-19 15:49:25 -0700 | [diff] [blame] | 2756 | |
| 2757 | /* if tdls is not enabled, then continue scan */ |
Pradeep Reddy POTTETI | f0569d7 | 2014-12-13 16:54:03 +0530 | [diff] [blame] | 2758 | if ((eTDLS_SUPPORT_NOT_ENABLED == pHddCtx->tdls_mode) || |
| 2759 | (pHddCtx->is_tdls_btc_enabled == FALSE)) |
Hoonki Lee | 93e67ff | 2013-03-19 15:49:25 -0700 | [diff] [blame] | 2760 | return 1; |
Pradeep Reddy POTTETI | 9db32f0 | 2015-01-29 15:22:54 +0530 | [diff] [blame] | 2761 | curr_peer = wlan_hdd_tdls_is_progress(pHddCtx, NULL, 0, TRUE); |
Hoonki Lee | fb8df67 | 2013-04-10 18:20:34 -0700 | [diff] [blame] | 2762 | if (NULL != curr_peer) |
Hoonki Lee | 93e67ff | 2013-03-19 15:49:25 -0700 | [diff] [blame] | 2763 | { |
Hoonki Lee | fb8df67 | 2013-04-10 18:20:34 -0700 | [diff] [blame] | 2764 | if (pHddCtx->tdls_scan_ctxt.reject++ >= TDLS_MAX_SCAN_REJECT) |
| 2765 | { |
| 2766 | pHddCtx->tdls_scan_ctxt.reject = 0; |
Masti, Narayanraddi | 34e0e56 | 2015-03-05 18:23:03 +0530 | [diff] [blame] | 2767 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Hoonki Lee | fb8df67 | 2013-04-10 18:20:34 -0700 | [diff] [blame] | 2768 | "%s: " MAC_ADDRESS_STR ". scan rejected %d. force it to idle", |
| 2769 | __func__, MAC_ADDR_ARRAY (curr_peer->peerMac), pHddCtx->tdls_scan_ctxt.reject); |
| 2770 | |
Atul Mittal | 115287b | 2014-07-08 13:26:33 +0530 | [diff] [blame] | 2771 | wlan_hdd_tdls_set_peer_link_status (curr_peer, |
| 2772 | eTDLS_LINK_IDLE, |
| 2773 | eTDLS_LINK_UNSPECIFIED); |
Hoonki Lee | fb8df67 | 2013-04-10 18:20:34 -0700 | [diff] [blame] | 2774 | return 1; |
| 2775 | } |
Masti, Narayanraddi | 34e0e56 | 2015-03-05 18:23:03 +0530 | [diff] [blame] | 2776 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Hoonki Lee | fb8df67 | 2013-04-10 18:20:34 -0700 | [diff] [blame] | 2777 | "%s: tdls in progress. scan rejected %d", |
| 2778 | __func__, pHddCtx->tdls_scan_ctxt.reject); |
Hoonki Lee | 93e67ff | 2013-03-19 15:49:25 -0700 | [diff] [blame] | 2779 | return -EBUSY; |
| 2780 | } |
| 2781 | |
| 2782 | /* tdls teardown is ongoing */ |
| 2783 | if (eTDLS_SUPPORT_DISABLED == pHddCtx->tdls_mode) |
| 2784 | { |
| 2785 | connectedTdlsPeers = wlan_hdd_tdlsConnectedPeers(pAdapter); |
| 2786 | if (connectedTdlsPeers && (pHddCtx->tdls_scan_ctxt.attempt < TDLS_MAX_SCAN_SCHEDULE)) |
| 2787 | { |
| 2788 | delay = (unsigned long)(TDLS_DELAY_SCAN_PER_CONNECTION*connectedTdlsPeers); |
Masti, Narayanraddi | 34e0e56 | 2015-03-05 18:23:03 +0530 | [diff] [blame] | 2789 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Hoonki Lee | 93e67ff | 2013-03-19 15:49:25 -0700 | [diff] [blame] | 2790 | "%s: tdls disabled, but still connected_peers %d attempt %d. schedule scan %lu msec", |
| 2791 | __func__, connectedTdlsPeers, pHddCtx->tdls_scan_ctxt.attempt, delay); |
| 2792 | |
| 2793 | wlan_hdd_tdls_scan_init_work (pHddCtx, wiphy, |
| 2794 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0)) |
| 2795 | dev, |
| 2796 | #endif |
| 2797 | request, |
| 2798 | msecs_to_jiffies(delay)); |
| 2799 | /* scan should not continue */ |
| 2800 | return 0; |
| 2801 | } |
| 2802 | /* no connected peer or max retry reached, scan continue */ |
Masti, Narayanraddi | 34e0e56 | 2015-03-05 18:23:03 +0530 | [diff] [blame] | 2803 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Hoonki Lee | 93e67ff | 2013-03-19 15:49:25 -0700 | [diff] [blame] | 2804 | "%s: tdls disabled. connected_peers %d attempt %d. scan allowed", |
| 2805 | __func__, connectedTdlsPeers, pHddCtx->tdls_scan_ctxt.attempt); |
| 2806 | return 1; |
| 2807 | } |
Agarwal Ashish | ef54a18 | 2014-12-16 15:07:31 +0530 | [diff] [blame] | 2808 | |
| 2809 | /* if fEnableTDLSScan flag is 1 ; driverwill allow scan even if |
| 2810 | * peer station is not buffer STA capable |
| 2811 | * |
| 2812 | * RX: If there is any RX activity, device will lose RX packets, |
| 2813 | * as peer will not be aware that device is off channel. |
| 2814 | * TX: TX is stopped whenever device initiate scan. |
| 2815 | */ |
| 2816 | if (pHddCtx->cfg_ini->fEnableTDLSScan == 1) |
| 2817 | { |
Masti, Narayanraddi | 34e0e56 | 2015-03-05 18:23:03 +0530 | [diff] [blame] | 2818 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Agarwal Ashish | ef54a18 | 2014-12-16 15:07:31 +0530 | [diff] [blame] | 2819 | FL("Allow SCAN in all TDLS cases")); |
| 2820 | return 1; |
| 2821 | } |
| 2822 | |
Hoonki Lee | 93e67ff | 2013-03-19 15:49:25 -0700 | [diff] [blame] | 2823 | /* while tdls is up, first time scan */ |
| 2824 | else if (eTDLS_SUPPORT_ENABLED == pHddCtx->tdls_mode || |
| 2825 | eTDLS_SUPPORT_EXPLICIT_TRIGGER_ONLY == pHddCtx->tdls_mode) |
| 2826 | { |
Hoonki Lee | 93e67ff | 2013-03-19 15:49:25 -0700 | [diff] [blame] | 2827 | connectedTdlsPeers = wlan_hdd_tdlsConnectedPeers(pAdapter); |
Pradeep Reddy POTTETI | edaeb5f | 2014-05-22 23:34:41 +0530 | [diff] [blame] | 2828 | |
| 2829 | /* check the TDLS link and Scan coexistance Capability */ |
| 2830 | if ( (TRUE == pHddCtx->cfg_ini->fEnableTDLSScanCoexSupport) && |
| 2831 | (TRUE == sme_IsFeatureSupportedByFW(TDLS_SCAN_COEXISTENCE)) && |
| 2832 | (connectedTdlsPeers == 1) ) |
| 2833 | { |
| 2834 | /* get connected peer information */ |
Pradeep Reddy POTTETI | e309c15 | 2015-02-06 13:21:07 +0530 | [diff] [blame] | 2835 | connected_peer = wlan_hdd_tdls_get_connected_peer(pAdapter); |
Pradeep Reddy POTTETI | edaeb5f | 2014-05-22 23:34:41 +0530 | [diff] [blame] | 2836 | if (NULL == connected_peer) { |
| 2837 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 2838 | "%s: Invalid connected_peer, Continue Scanning", __func__); |
| 2839 | /* scan should continue */ |
| 2840 | return 1; |
| 2841 | } |
Masti, Narayanraddi | 34e0e56 | 2015-03-05 18:23:03 +0530 | [diff] [blame] | 2842 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Pradeep Reddy POTTETI | edaeb5f | 2014-05-22 23:34:41 +0530 | [diff] [blame] | 2843 | ("%s: TDLS Scan Co-exist supported connectedTdlsPeers =%d buffersta =%d"), |
| 2844 | __func__,connectedTdlsPeers,connected_peer->isBufSta); |
| 2845 | |
| 2846 | if (connected_peer->isBufSta) |
| 2847 | { |
| 2848 | pHddCtx->isTdlsScanCoexistence = TRUE; |
| 2849 | if ((cfg_param->dynSplitscan) && (!pHddCtx->issplitscan_enabled)) |
| 2850 | { |
| 2851 | pHddCtx->issplitscan_enabled = TRUE; |
| 2852 | sme_enable_disable_split_scan( |
| 2853 | WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 2854 | cfg_param->nNumStaChanCombinedConc, |
| 2855 | cfg_param->nNumP2PChanCombinedConc); |
| 2856 | } |
Masti, Narayanraddi | 34e0e56 | 2015-03-05 18:23:03 +0530 | [diff] [blame] | 2857 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Pradeep Reddy POTTETI | edaeb5f | 2014-05-22 23:34:41 +0530 | [diff] [blame] | 2858 | ("%s:%d TDLS Scan Co-exist supported splitscan_enabled =%d "), |
| 2859 | __func__, __LINE__, pHddCtx->issplitscan_enabled); |
| 2860 | return 1; |
| 2861 | } |
| 2862 | |
| 2863 | } |
| 2864 | else |
| 2865 | { |
| 2866 | /* Throughput Monitor shall disable the split scan when |
| 2867 | * TDLS scan coexistance is disabled.At this point of time |
| 2868 | * since TDLS scan coexistance is not meeting the criteria |
| 2869 | * to be operational, explicitly make it false to enable |
| 2870 | * throughput monitor takes the control of split scan. |
| 2871 | */ |
| 2872 | pHddCtx->isTdlsScanCoexistence = FALSE; |
| 2873 | } |
Masti, Narayanraddi | 34e0e56 | 2015-03-05 18:23:03 +0530 | [diff] [blame] | 2874 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Pradeep Reddy POTTETI | edaeb5f | 2014-05-22 23:34:41 +0530 | [diff] [blame] | 2875 | ("%s: TDLS Scan Co-exist not supported connectedTdlsPeers =%d" |
| 2876 | " TDLSScanCoexSupport param =%d TDLS_SCAN_COEXISTENCE =%d"), |
| 2877 | __func__, connectedTdlsPeers, |
| 2878 | pHddCtx->cfg_ini->fEnableTDLSScanCoexSupport, |
| 2879 | sme_IsFeatureSupportedByFW(TDLS_SCAN_COEXISTENCE)); |
| 2880 | |
Atul Mittal | 5803b34 | 2014-09-04 15:31:19 +0530 | [diff] [blame] | 2881 | /* disable implicit trigger logic & tdls operatoin */ |
| 2882 | wlan_hdd_tdls_set_mode(pHddCtx, eTDLS_SUPPORT_DISABLED, FALSE); |
Pradeep Reddy POTTETI | edaeb5f | 2014-05-22 23:34:41 +0530 | [diff] [blame] | 2883 | /* fall back to the implementation of teardown the peers on the scan |
| 2884 | * when the number of connected peers are more than one. TDLS Scan |
| 2885 | * coexistance feature is exercised only when a single peer is |
| 2886 | * connected and the DUT shall not advertize the Buffer Sta capability, |
| 2887 | * so that the peer shall not go to the TDLS power save |
| 2888 | */ |
| 2889 | |
Hoonki Lee | 93e67ff | 2013-03-19 15:49:25 -0700 | [diff] [blame] | 2890 | if (connectedTdlsPeers) |
| 2891 | { |
| 2892 | tANI_U8 staIdx; |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 2893 | hddTdlsPeer_t *curr_peer; |
Hoonki Lee | 93e67ff | 2013-03-19 15:49:25 -0700 | [diff] [blame] | 2894 | |
| 2895 | for (staIdx = 0; staIdx < HDD_MAX_NUM_TDLS_STA; staIdx++) |
| 2896 | { |
| 2897 | if (pHddCtx->tdlsConnInfo[staIdx].staId) |
| 2898 | { |
Masti, Narayanraddi | 34e0e56 | 2015-03-05 18:23:03 +0530 | [diff] [blame] | 2899 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 2900 | ("%s: indicate TDLS teardown (staId %d)"), __func__, pHddCtx->tdlsConnInfo[staIdx].staId) ; |
Hoonki Lee | 93e67ff | 2013-03-19 15:49:25 -0700 | [diff] [blame] | 2901 | |
| 2902 | #ifdef CONFIG_TDLS_IMPLICIT |
Hoonki Lee | a6d49be | 2013-04-05 09:43:25 -0700 | [diff] [blame] | 2903 | curr_peer = wlan_hdd_tdls_find_all_peer(pHddCtx, pHddCtx->tdlsConnInfo[staIdx].peerMac.bytes); |
| 2904 | if(curr_peer) |
| 2905 | wlan_hdd_tdls_indicate_teardown(curr_peer->pHddTdlsCtx->pAdapter, curr_peer, eSIR_MAC_TDLS_TEARDOWN_UNSPEC_REASON); |
Hoonki Lee | 93e67ff | 2013-03-19 15:49:25 -0700 | [diff] [blame] | 2906 | #endif |
| 2907 | } |
| 2908 | } |
| 2909 | /* schedule scan */ |
| 2910 | delay = (unsigned long)(TDLS_DELAY_SCAN_PER_CONNECTION*connectedTdlsPeers); |
| 2911 | |
Masti, Narayanraddi | 34e0e56 | 2015-03-05 18:23:03 +0530 | [diff] [blame] | 2912 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Hoonki Lee | 93e67ff | 2013-03-19 15:49:25 -0700 | [diff] [blame] | 2913 | "%s: tdls enabled (mode %d), connected_peers %d. schedule scan %lu msec", |
| 2914 | __func__, pHddCtx->tdls_mode, wlan_hdd_tdlsConnectedPeers(pAdapter), |
| 2915 | delay); |
| 2916 | |
| 2917 | wlan_hdd_tdls_scan_init_work (pHddCtx, wiphy, |
| 2918 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0)) |
| 2919 | dev, |
| 2920 | #endif |
| 2921 | request, |
| 2922 | msecs_to_jiffies(delay)); |
| 2923 | /* scan should not continue */ |
| 2924 | return 0; |
| 2925 | } |
| 2926 | /* no connected peer, scan continue */ |
Masti, Narayanraddi | 34e0e56 | 2015-03-05 18:23:03 +0530 | [diff] [blame] | 2927 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Hoonki Lee | 93e67ff | 2013-03-19 15:49:25 -0700 | [diff] [blame] | 2928 | "%s: tdls_mode %d, and no tdls connection. scan allowed", |
| 2929 | __func__, pHddCtx->tdls_mode); |
| 2930 | } |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 2931 | EXIT(); |
Hoonki Lee | 93e67ff | 2013-03-19 15:49:25 -0700 | [diff] [blame] | 2932 | return 1; |
| 2933 | } |
| 2934 | |
| 2935 | void wlan_hdd_tdls_scan_done_callback(hdd_adapter_t *pAdapter) |
| 2936 | { |
| 2937 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
Hoonki Lee | 93e67ff | 2013-03-19 15:49:25 -0700 | [diff] [blame] | 2938 | |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 2939 | ENTER(); |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 2940 | if(0 != (wlan_hdd_validate_context(pHddCtx))) |
| 2941 | { |
Hoonki Lee | 93e67ff | 2013-03-19 15:49:25 -0700 | [diff] [blame] | 2942 | return; |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 2943 | } |
Hoonki Lee | 93e67ff | 2013-03-19 15:49:25 -0700 | [diff] [blame] | 2944 | |
Pradeep Reddy POTTETI | c7822df | 2015-02-19 20:15:41 +0530 | [diff] [blame] | 2945 | /* if tdls is not enabled or BtCoex is on then don't revert tdls mode */ |
| 2946 | if ((eTDLS_SUPPORT_NOT_ENABLED == pHddCtx->tdls_mode) || |
Chandrasekaran, Manishekar | 0de84dc | 2015-03-10 15:12:34 +0530 | [diff] [blame] | 2947 | (pHddCtx->is_tdls_btc_enabled == FALSE)) { |
| 2948 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to revert: Mode=%d, BTC enabled=%d"), |
| 2949 | pHddCtx->tdls_mode, pHddCtx->is_tdls_btc_enabled); |
Pradeep Reddy POTTETI | c7822df | 2015-02-19 20:15:41 +0530 | [diff] [blame] | 2950 | return; |
Chandrasekaran, Manishekar | 0de84dc | 2015-03-10 15:12:34 +0530 | [diff] [blame] | 2951 | } |
Sunil Dutt | 41de4e2 | 2013-11-14 18:09:02 +0530 | [diff] [blame] | 2952 | |
Hoonki Lee | 93e67ff | 2013-03-19 15:49:25 -0700 | [diff] [blame] | 2953 | /* free allocated memory at scan time */ |
Gopichand Nakkala | 3046fc9 | 2013-03-23 13:56:43 -0700 | [diff] [blame] | 2954 | wlan_hdd_tdls_free_scan_request (&pHddCtx->tdls_scan_ctxt); |
Hoonki Lee | 93e67ff | 2013-03-19 15:49:25 -0700 | [diff] [blame] | 2955 | |
| 2956 | /* if tdls was enabled before scan, re-enable tdls mode */ |
| 2957 | if(eTDLS_SUPPORT_ENABLED == pHddCtx->tdls_mode_last || |
| 2958 | eTDLS_SUPPORT_EXPLICIT_TRIGGER_ONLY == pHddCtx->tdls_mode_last) |
| 2959 | { |
Masti, Narayanraddi | 34e0e56 | 2015-03-05 18:23:03 +0530 | [diff] [blame] | 2960 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Hoonki Lee | 93e67ff | 2013-03-19 15:49:25 -0700 | [diff] [blame] | 2961 | ("%s: revert tdls mode %d"), __func__, pHddCtx->tdls_mode_last); |
| 2962 | |
Gopichand Nakkala | dcbcf4e | 2013-03-23 14:32:39 -0700 | [diff] [blame] | 2963 | wlan_hdd_tdls_set_mode(pHddCtx, pHddCtx->tdls_mode_last, FALSE); |
Hoonki Lee | 93e67ff | 2013-03-19 15:49:25 -0700 | [diff] [blame] | 2964 | } |
| 2965 | wlan_hdd_tdls_check_bmps(pAdapter); |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 2966 | |
| 2967 | EXIT(); |
Hoonki Lee | 93e67ff | 2013-03-19 15:49:25 -0700 | [diff] [blame] | 2968 | } |
Gopichand Nakkala | 3046fc9 | 2013-03-23 13:56:43 -0700 | [diff] [blame] | 2969 | |
| 2970 | void wlan_hdd_tdls_timer_restart(hdd_adapter_t *pAdapter, |
| 2971 | vos_timer_t *timer, |
| 2972 | v_U32_t expirationTime) |
| 2973 | { |
| 2974 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 2975 | |
| 2976 | if (NULL == pHddStaCtx) |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 2977 | { |
| 2978 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2979 | FL("pHddStaCtx is NULL")); |
Gopichand Nakkala | 3046fc9 | 2013-03-23 13:56:43 -0700 | [diff] [blame] | 2980 | return; |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 2981 | } |
Gopichand Nakkala | 3046fc9 | 2013-03-23 13:56:43 -0700 | [diff] [blame] | 2982 | |
| 2983 | /* Check whether driver load unload is in progress */ |
| 2984 | if(vos_is_load_unload_in_progress( VOS_MODULE_ID_VOSS, NULL)) |
| 2985 | { |
| 2986 | VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR, |
| 2987 | "%s: Driver load/unload is in progress.", __func__); |
| 2988 | return; |
| 2989 | } |
| 2990 | |
| 2991 | if (hdd_connIsConnected(pHddStaCtx)) |
| 2992 | { |
| 2993 | vos_timer_stop(timer); |
| 2994 | vos_timer_start(timer, expirationTime); |
| 2995 | } |
| 2996 | } |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 2997 | void wlan_hdd_tdls_indicate_teardown(hdd_adapter_t *pAdapter, |
| 2998 | hddTdlsPeer_t *curr_peer, |
| 2999 | tANI_U16 reason) |
| 3000 | { |
Pradeep Reddy POTTETI | 8a62313 | 2014-06-26 16:07:06 +0530 | [diff] [blame] | 3001 | hdd_context_t *pHddCtx; |
Pradeep Reddy POTTETI | edaeb5f | 2014-05-22 23:34:41 +0530 | [diff] [blame] | 3002 | |
Hanumantha Reddy Pothula | da0fe36 | 2015-02-27 18:37:03 +0530 | [diff] [blame] | 3003 | if ((NULL == pAdapter || WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic) || |
| 3004 | (NULL == curr_peer)) |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 3005 | { |
| 3006 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3007 | FL("parameters passed are invalid")); |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 3008 | return; |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 3009 | } |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 3010 | |
Pradeep Reddy POTTETI | 8a62313 | 2014-06-26 16:07:06 +0530 | [diff] [blame] | 3011 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 3012 | |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 3013 | if (eTDLS_LINK_CONNECTED != curr_peer->link_status) |
| 3014 | return; |
| 3015 | |
Pradeep Reddy POTTETI | edaeb5f | 2014-05-22 23:34:41 +0530 | [diff] [blame] | 3016 | /* Throughput Monitor shall disable the split scan when |
| 3017 | * TDLS scan coexistance is disabled.At this point of time |
| 3018 | * since TDLS scan coexistance is not meeting the criteria |
| 3019 | * to be operational, explicitly make it false to enable |
| 3020 | * throughput monitor takes the control of split scan. |
| 3021 | */ |
Pradeep Reddy POTTETI | 8a62313 | 2014-06-26 16:07:06 +0530 | [diff] [blame] | 3022 | if (pHddCtx && (pHddCtx->isTdlsScanCoexistence == TRUE)) |
Pradeep Reddy POTTETI | edaeb5f | 2014-05-22 23:34:41 +0530 | [diff] [blame] | 3023 | { |
| 3024 | pHddCtx->isTdlsScanCoexistence = FALSE; |
| 3025 | } |
| 3026 | |
Atul Mittal | 115287b | 2014-07-08 13:26:33 +0530 | [diff] [blame] | 3027 | wlan_hdd_tdls_set_peer_link_status(curr_peer, |
| 3028 | eTDLS_LINK_TEARING, |
Atul Mittal | 271a765 | 2014-09-12 13:18:22 +0530 | [diff] [blame] | 3029 | eTDLS_LINK_UNSPECIFIED); |
Agarwal Ashish | a7ef41d | 2015-06-25 18:00:26 +0530 | [diff] [blame] | 3030 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3031 | FL("Setting NL80211_TDLS_TEARDOWN, reason %d"), reason); |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 3032 | cfg80211_tdls_oper_request(pAdapter->dev, |
| 3033 | curr_peer->peerMac, |
| 3034 | NL80211_TDLS_TEARDOWN, |
| 3035 | reason, |
| 3036 | GFP_KERNEL); |
| 3037 | } |
Atul Mittal | 115287b | 2014-07-08 13:26:33 +0530 | [diff] [blame] | 3038 | |
| 3039 | |
| 3040 | /*EXT TDLS*/ |
| 3041 | int wlan_hdd_set_callback(hddTdlsPeer_t *curr_peer, |
| 3042 | cfg80211_exttdls_callback callback) |
| 3043 | { |
| 3044 | |
| 3045 | hdd_context_t *pHddCtx; |
| 3046 | hdd_adapter_t *pAdapter; |
| 3047 | |
| 3048 | if (!curr_peer) return -1; |
| 3049 | |
| 3050 | pAdapter = curr_peer->pHddTdlsCtx->pAdapter; |
| 3051 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 3052 | if ((NULL == pHddCtx)) return -1; |
| 3053 | |
| 3054 | mutex_lock(&pHddCtx->tdls_lock); |
| 3055 | |
| 3056 | curr_peer->state_change_notification = callback; |
| 3057 | |
| 3058 | mutex_unlock(&pHddCtx->tdls_lock); |
| 3059 | return 0; |
| 3060 | |
| 3061 | |
| 3062 | } |
| 3063 | |
| 3064 | void wlan_hdd_tdls_get_wifi_hal_state(hddTdlsPeer_t *curr_peer, |
| 3065 | tANI_S32 *state, |
| 3066 | tANI_S32 *reason) |
| 3067 | { |
| 3068 | *reason = curr_peer->reason; |
| 3069 | |
| 3070 | switch(curr_peer->link_status) |
| 3071 | { |
| 3072 | case eTDLS_LINK_IDLE: |
Atul Mittal | 115287b | 2014-07-08 13:26:33 +0530 | [diff] [blame] | 3073 | case eTDLS_LINK_DISCOVERED: |
| 3074 | *state = WIFI_TDLS_ENABLED; |
| 3075 | break; |
Atul Mittal | ad630e4 | 2014-10-07 19:19:14 +0530 | [diff] [blame] | 3076 | case eTDLS_LINK_DISCOVERING: |
Atul Mittal | 115287b | 2014-07-08 13:26:33 +0530 | [diff] [blame] | 3077 | case eTDLS_LINK_CONNECTING: |
| 3078 | *state = WIFI_TDLS_TRYING; |
| 3079 | break; |
| 3080 | case eTDLS_LINK_CONNECTED: |
Pradeep Reddy POTTETI | f3148e8 | 2015-04-16 12:10:33 +0530 | [diff] [blame] | 3081 | if (TRUE == curr_peer->isOffChannelEstablished) |
Pradeep Reddy POTTETI | 16d8333 | 2015-03-26 18:28:13 +0530 | [diff] [blame] | 3082 | { |
| 3083 | *state = WIFI_TDLS_ESTABLISHED_OFF_CHANNEL; |
| 3084 | } |
| 3085 | else |
| 3086 | { |
| 3087 | *state = WIFI_TDLS_ESTABLISHED; |
| 3088 | } |
Atul Mittal | 115287b | 2014-07-08 13:26:33 +0530 | [diff] [blame] | 3089 | break; |
| 3090 | case eTDLS_LINK_TEARING: |
| 3091 | *state = WIFI_TDLS_DROPPED; |
| 3092 | break; |
| 3093 | } |
| 3094 | |
| 3095 | } |
| 3096 | |
| 3097 | int wlan_hdd_tdls_get_status(hdd_adapter_t *pAdapter, |
| 3098 | tANI_U8* mac, |
| 3099 | tANI_S32 *state, |
| 3100 | tANI_S32 *reason) |
| 3101 | { |
| 3102 | |
| 3103 | hddTdlsPeer_t *curr_peer; |
Atul Mittal | a75fced | 2014-10-06 13:59:07 +0530 | [diff] [blame] | 3104 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
Atul Mittal | 115287b | 2014-07-08 13:26:33 +0530 | [diff] [blame] | 3105 | curr_peer = wlan_hdd_tdls_find_peer(pAdapter, mac, TRUE); |
| 3106 | if (curr_peer == NULL) |
| 3107 | { |
Atul Mittal | a75fced | 2014-10-06 13:59:07 +0530 | [diff] [blame] | 3108 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Atul Mittal | 115287b | 2014-07-08 13:26:33 +0530 | [diff] [blame] | 3109 | FL("curr_peer is NULL")); |
Atul Mittal | 115287b | 2014-07-08 13:26:33 +0530 | [diff] [blame] | 3110 | |
Atul Mittal | a75fced | 2014-10-06 13:59:07 +0530 | [diff] [blame] | 3111 | *state = WIFI_TDLS_DISABLED; |
| 3112 | *reason = eTDLS_LINK_UNSPECIFIED; |
| 3113 | } |
| 3114 | else |
| 3115 | { |
| 3116 | if (pHddCtx->cfg_ini->fTDLSExternalControl && |
| 3117 | (FALSE == curr_peer->isForcedPeer)) |
| 3118 | { |
| 3119 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3120 | FL("curr_peer is not Forced")); |
| 3121 | *state = WIFI_TDLS_DISABLED; |
| 3122 | *reason = eTDLS_LINK_UNSPECIFIED; |
| 3123 | } |
| 3124 | else |
| 3125 | { |
| 3126 | wlan_hdd_tdls_get_wifi_hal_state(curr_peer, state, reason); |
| 3127 | } |
| 3128 | } |
Atul Mittal | 115287b | 2014-07-08 13:26:33 +0530 | [diff] [blame] | 3129 | return (0); |
| 3130 | } |
| 3131 | |
Agarwal Ashish | ef54a18 | 2014-12-16 15:07:31 +0530 | [diff] [blame] | 3132 | int hdd_set_tdls_scan_type(hdd_adapter_t *pAdapter, |
| 3133 | tANI_U8 *ptr) |
| 3134 | { |
| 3135 | int tdls_scan_type; |
Hema Aparna Medicharla | 26b9804 | 2015-01-21 15:02:01 +0530 | [diff] [blame] | 3136 | hdd_context_t *pHddCtx; |
Agarwal Ashish | ef54a18 | 2014-12-16 15:07:31 +0530 | [diff] [blame] | 3137 | if (NULL == pAdapter) |
| 3138 | { |
| 3139 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3140 | "%s: pAdapter is NULL", __func__); |
| 3141 | return -EINVAL; |
| 3142 | } |
Hema Aparna Medicharla | 26b9804 | 2015-01-21 15:02:01 +0530 | [diff] [blame] | 3143 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
Agarwal Ashish | ef54a18 | 2014-12-16 15:07:31 +0530 | [diff] [blame] | 3144 | tdls_scan_type = ptr[9] - '0'; |
| 3145 | |
| 3146 | if (tdls_scan_type <= 2) |
| 3147 | { |
| 3148 | pHddCtx->cfg_ini->fEnableTDLSScan = tdls_scan_type; |
| 3149 | return 0; |
| 3150 | } |
| 3151 | else |
| 3152 | { |
| 3153 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3154 | " Wrong value is given for tdls_scan_type " |
| 3155 | " Making fEnableTDLSScan as 0 "); |
| 3156 | pHddCtx->cfg_ini->fEnableTDLSScan = 0; |
| 3157 | return -EINVAL; |
| 3158 | } |
| 3159 | } |
Mahesh A Saptasagar | 170b508 | 2015-02-16 18:50:54 +0530 | [diff] [blame] | 3160 | int wlan_hdd_validate_tdls_context(hdd_context_t *pHddCtx, |
| 3161 | tdlsCtx_t *pHddTdlsCtx) |
| 3162 | { |
| 3163 | VOS_STATUS status; |
| 3164 | int found = 0; |
| 3165 | hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL; |
| 3166 | hdd_adapter_t *pAdapter; |
Agarwal Ashish | ef54a18 | 2014-12-16 15:07:31 +0530 | [diff] [blame] | 3167 | |
Mahesh A Saptasagar | 170b508 | 2015-02-16 18:50:54 +0530 | [diff] [blame] | 3168 | if (NULL == pHddTdlsCtx) |
| 3169 | { |
| 3170 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3171 | FL("TDLS context is NULL")); |
| 3172 | return -EINVAL; |
| 3173 | } |
| 3174 | status = hdd_get_front_adapter(pHddCtx, &pAdapterNode); |
| 3175 | while (NULL != pAdapterNode && VOS_STATUS_SUCCESS == status) |
| 3176 | { |
| 3177 | pAdapter = pAdapterNode->pAdapter; |
| 3178 | if (NULL != pAdapter) |
| 3179 | { |
| 3180 | if (pHddTdlsCtx == pAdapter->sessionCtx.station.pHddTdlsCtx && |
| 3181 | (NULL != pHddTdlsCtx->pAdapter) && |
| 3182 | (WLAN_HDD_ADAPTER_MAGIC == pHddTdlsCtx->pAdapter->magic)) |
| 3183 | { |
| 3184 | found = 1; |
| 3185 | break; |
| 3186 | } |
| 3187 | } |
| 3188 | status = hdd_get_next_adapter (pHddCtx, pAdapterNode, &pNext); |
| 3189 | pAdapterNode = pNext; |
| 3190 | } |
| 3191 | if (found == 1) |
| 3192 | { |
| 3193 | return 0; |
| 3194 | } |
| 3195 | else |
| 3196 | { |
| 3197 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3198 | FL("TDLS context doesnot belongs to valid adapter")); |
| 3199 | return -EINVAL; |
| 3200 | } |
| 3201 | } |
Atul Mittal | 115287b | 2014-07-08 13:26:33 +0530 | [diff] [blame] | 3202 | /*EXT TDLS*/ |
| 3203 | |