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