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