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