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