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 | |
Sunil Dutt | 66485cb | 2013-12-19 19:05:03 +0530 | [diff] [blame] | 821 | |
Hoonki Lee | 2751190 | 2013-03-14 18:19:06 -0700 | [diff] [blame] | 822 | if ((FALSE == pHddCtx->cfg_ini->fEnableTDLSSupport) || |
| 823 | (FALSE == sme_IsFeatureSupportedByFW(TDLS))) |
| 824 | { |
| 825 | pHddCtx->tdls_mode = eTDLS_SUPPORT_NOT_ENABLED; |
| 826 | pAdapter->sessionCtx.station.pHddTdlsCtx = NULL; |
| 827 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s TDLS not enabled (%d) or FW doesn't support (%d)!", |
| 828 | __func__, pHddCtx->cfg_ini->fEnableTDLSSupport, |
| 829 | sme_IsFeatureSupportedByFW(TDLS)); |
| 830 | return 0; |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 831 | } |
Madan Mohan Koyyalamudi | 8174692 | 2013-07-17 14:38:51 +0530 | [diff] [blame] | 832 | /* TDLS is supported only in STA / P2P Client modes, |
| 833 | * hence the check for TDLS support in a specific Device mode. |
| 834 | * Do not return a failure rather do not continue further |
| 835 | * with the initialization as tdls_init would be called |
| 836 | * during the open adapter for a p2p interface at which point |
| 837 | * the device mode would be a P2P_DEVICE. The point here is to |
| 838 | * continue initialization for STA / P2P Client modes. |
| 839 | * TDLS exit also check for the device mode for clean up hence |
| 840 | * there is no issue even if success is returned. |
| 841 | */ |
| 842 | if (0 == WLAN_HDD_IS_TDLS_SUPPORTED_ADAPTER(pAdapter)) |
| 843 | { |
Mahesh A Saptasagar | 36cdc80 | 2015-01-07 18:41:17 +0530 | [diff] [blame] | 844 | 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] | 845 | return 0; |
| 846 | } |
| 847 | /* Check for the valid pHddTdlsCtx. If valid do not further |
| 848 | * allocate the memory, rather continue with the initialization. |
| 849 | * If tdls_initialization would get reinvoked without tdls_exit |
| 850 | * getting invoked (SSR) there is no point to further proceed |
| 851 | * with the memory allocations. |
| 852 | */ |
| 853 | if (NULL == pAdapter->sessionCtx.station.pHddTdlsCtx) |
| 854 | { |
| 855 | pHddTdlsCtx = vos_mem_malloc(sizeof(tdlsCtx_t)); |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 856 | |
Madan Mohan Koyyalamudi | 8174692 | 2013-07-17 14:38:51 +0530 | [diff] [blame] | 857 | if (NULL == pHddTdlsCtx) { |
| 858 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s malloc failed!", __func__); |
| 859 | pAdapter->sessionCtx.station.pHddTdlsCtx = NULL; |
Sunil Dutt | 66485cb | 2013-12-19 19:05:03 +0530 | [diff] [blame] | 860 | mutex_unlock(&pHddCtx->tdls_lock); |
Madan Mohan Koyyalamudi | 8174692 | 2013-07-17 14:38:51 +0530 | [diff] [blame] | 861 | return -1; |
| 862 | } |
| 863 | /* initialize TDLS pAdater context */ |
| 864 | vos_mem_zero(pHddTdlsCtx, sizeof(tdlsCtx_t)); |
| 865 | #ifdef TDLS_USE_SEPARATE_DISCOVERY_TIMER |
| 866 | vos_timer_init(&pHddTdlsCtx->peerDiscoverTimer, |
| 867 | VOS_TIMER_TYPE_SW, |
| 868 | wlan_hdd_tdls_discover_peer_cb, |
| 869 | pHddTdlsCtx); |
| 870 | #endif |
Hoonki Lee | 2751190 | 2013-03-14 18:19:06 -0700 | [diff] [blame] | 871 | |
Madan Mohan Koyyalamudi | 8174692 | 2013-07-17 14:38:51 +0530 | [diff] [blame] | 872 | vos_timer_init(&pHddTdlsCtx->peerUpdateTimer, |
| 873 | VOS_TIMER_TYPE_SW, |
| 874 | wlan_hdd_tdls_update_peer_cb, |
| 875 | pHddTdlsCtx); |
| 876 | vos_timer_init(&pHddTdlsCtx->peerDiscoveryTimeoutTimer, |
| 877 | VOS_TIMER_TYPE_SW, |
| 878 | wlan_hdd_tdls_discovery_timeout_peer_cb, |
| 879 | pHddTdlsCtx); |
| 880 | |
| 881 | pAdapter->sessionCtx.station.pHddTdlsCtx = pHddTdlsCtx; |
Hoonki Lee | 2751190 | 2013-03-14 18:19:06 -0700 | [diff] [blame] | 882 | } |
| 883 | |
Madan Mohan Koyyalamudi | 8174692 | 2013-07-17 14:38:51 +0530 | [diff] [blame] | 884 | pHddTdlsCtx = pAdapter->sessionCtx.station.pHddTdlsCtx; |
Hoonki Lee | 2751190 | 2013-03-14 18:19:06 -0700 | [diff] [blame] | 885 | |
Gopichand Nakkala | ccd3a38 | 2013-03-19 13:56:10 -0700 | [diff] [blame] | 886 | sme_SetTdlsPowerSaveProhibited(WLAN_HDD_GET_HAL_CTX(pAdapter), 0); |
Hoonki Lee | 2751190 | 2013-03-14 18:19:06 -0700 | [diff] [blame] | 887 | |
Hoonki Lee | 2751190 | 2013-03-14 18:19:06 -0700 | [diff] [blame] | 888 | pHddTdlsCtx->pAdapter = pAdapter; |
| 889 | |
| 890 | for (i = 0; i < 256; i++) |
| 891 | { |
| 892 | INIT_LIST_HEAD(&pHddTdlsCtx->peer_list[i]); |
| 893 | } |
| 894 | |
Hoonki Lee | d37cbb3 | 2013-04-20 00:31:14 -0700 | [diff] [blame] | 895 | pHddTdlsCtx->curr_candidate = NULL; |
| 896 | pHddTdlsCtx->magic = 0; |
| 897 | |
Hoonki Lee | 2751190 | 2013-03-14 18:19:06 -0700 | [diff] [blame] | 898 | /* remember configuration even if it is not used right now. it could be used later */ |
| 899 | pHddTdlsCtx->threshold_config.tx_period_t = pHddCtx->cfg_ini->fTDLSTxStatsPeriod; |
| 900 | pHddTdlsCtx->threshold_config.tx_packet_n = pHddCtx->cfg_ini->fTDLSTxPacketThreshold; |
| 901 | pHddTdlsCtx->threshold_config.discovery_period_t = pHddCtx->cfg_ini->fTDLSDiscoveryPeriod; |
| 902 | pHddTdlsCtx->threshold_config.discovery_tries_n = pHddCtx->cfg_ini->fTDLSMaxDiscoveryAttempt; |
| 903 | pHddTdlsCtx->threshold_config.idle_timeout_t = pHddCtx->cfg_ini->fTDLSIdleTimeout; |
| 904 | pHddTdlsCtx->threshold_config.idle_packet_n = pHddCtx->cfg_ini->fTDLSIdlePacketThreshold; |
| 905 | pHddTdlsCtx->threshold_config.rssi_hysteresis = pHddCtx->cfg_ini->fTDLSRSSIHysteresis; |
| 906 | pHddTdlsCtx->threshold_config.rssi_trigger_threshold = pHddCtx->cfg_ini->fTDLSRSSITriggerThreshold; |
| 907 | pHddTdlsCtx->threshold_config.rssi_teardown_threshold = pHddCtx->cfg_ini->fTDLSRSSITeardownThreshold; |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 908 | |
Sameer Thalappil | bee426e | 2013-10-30 10:30:30 -0700 | [diff] [blame] | 909 | INIT_WORK(&pHddTdlsCtx->implicit_setup, wlan_hdd_tdls_pre_setup); |
| 910 | INIT_DELAYED_WORK(&pHddCtx->tdls_scan_ctxt.tdls_scan_work, wlan_hdd_tdls_schedule_scan); |
Hoonki Lee | 2751190 | 2013-03-14 18:19:06 -0700 | [diff] [blame] | 911 | |
| 912 | return 0; |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 913 | } |
| 914 | |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 915 | void wlan_hdd_tdls_exit(hdd_adapter_t *pAdapter) |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 916 | { |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 917 | tdlsCtx_t *pHddTdlsCtx; |
Hoonki Lee | 93e67ff | 2013-03-19 15:49:25 -0700 | [diff] [blame] | 918 | hdd_context_t *pHddCtx; |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 919 | |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 920 | /* |
| 921 | * NOTE: The Callers of this function should ensure to acquire the |
| 922 | * tdls_lock to avoid any concurrent access to the Adapter. |
| 923 | */ |
| 924 | |
Madan Mohan Koyyalamudi | 263cec1 | 2013-10-07 10:57:50 +0530 | [diff] [blame] | 925 | pHddCtx = WLAN_HDD_GET_CTX( pAdapter ); |
Agarwal Ashish | 9ffa5b9 | 2014-11-18 21:07:02 +0530 | [diff] [blame] | 926 | |
| 927 | if (NULL == pHddCtx || NULL == pHddCtx->cfg_ini) |
Madan Mohan Koyyalamudi | 263cec1 | 2013-10-07 10:57:50 +0530 | [diff] [blame] | 928 | { |
Agarwal Ashish | 9ffa5b9 | 2014-11-18 21:07:02 +0530 | [diff] [blame] | 929 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 930 | "%s: HDD context is Null", __func__); |
| 931 | return ; |
| 932 | } |
| 933 | |
| 934 | if (pHddCtx->isLogpInProgress) |
| 935 | { |
| 936 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 937 | "%s: LOGP in Progress. Ignore!!!", __func__); |
| 938 | return ; |
Madan Mohan Koyyalamudi | 263cec1 | 2013-10-07 10:57:50 +0530 | [diff] [blame] | 939 | } |
| 940 | |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 941 | pHddTdlsCtx = WLAN_HDD_GET_TDLS_CTX_PTR(pAdapter); |
Gopichand Nakkala | 91b0926 | 2013-02-10 14:27:02 -0800 | [diff] [blame] | 942 | if (NULL == pHddTdlsCtx) |
| 943 | { |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 944 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 945 | FL("pHddTdlsCtx is NULL")); |
Hoonki Lee | bfee034 | 2013-01-21 16:43:45 -0800 | [diff] [blame] | 946 | return; |
| 947 | } |
Sameer Thalappil | bee426e | 2013-10-30 10:30:30 -0700 | [diff] [blame] | 948 | #ifdef WLAN_OPEN_SOURCE |
| 949 | cancel_work_sync(&pHddTdlsCtx->implicit_setup); |
| 950 | cancel_delayed_work_sync(&pHddCtx->tdls_scan_ctxt.tdls_scan_work); |
| 951 | #endif |
Hoonki Lee | bfee034 | 2013-01-21 16:43:45 -0800 | [diff] [blame] | 952 | |
Gopichand Nakkala | 91b0926 | 2013-02-10 14:27:02 -0800 | [diff] [blame] | 953 | /* must stop timer here before freeing peer list, because peerIdleTimer is |
| 954 | part of peer list structure. */ |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 955 | wlan_hdd_tdls_timers_destroy(pHddTdlsCtx); |
| 956 | wlan_hdd_tdls_free_list(pHddTdlsCtx); |
Chilam Ng | a75d8b6 | 2013-01-29 01:35:59 -0800 | [diff] [blame] | 957 | |
Hoonki Lee | 93e67ff | 2013-03-19 15:49:25 -0700 | [diff] [blame] | 958 | wlan_hdd_tdls_free_scan_request(&pHddCtx->tdls_scan_ctxt); |
Sushant Kaushik | 15c4c52 | 2014-08-14 12:24:49 +0530 | [diff] [blame] | 959 | pHddTdlsCtx->magic = 0; |
| 960 | pHddTdlsCtx->pAdapter = NULL; |
Chilam Ng | a75d8b6 | 2013-01-29 01:35:59 -0800 | [diff] [blame] | 961 | vos_mem_free(pHddTdlsCtx); |
Pradeep Reddy POTTETI | 59c90d6 | 2014-03-24 19:45:47 +0530 | [diff] [blame] | 962 | pAdapter->sessionCtx.station.pHddTdlsCtx = NULL; |
Chilam Ng | a75d8b6 | 2013-01-29 01:35:59 -0800 | [diff] [blame] | 963 | pHddTdlsCtx = NULL; |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 964 | } |
| 965 | |
Madan Mohan Koyyalamudi | 693275b | 2013-07-22 19:14:09 +0530 | [diff] [blame] | 966 | /* stop all monitoring timers per Adapter */ |
| 967 | static void wlan_hdd_tdls_monitor_timers_stop(tdlsCtx_t *pHddTdlsCtx) |
Gopichand Nakkala | c369458 | 2013-02-13 20:51:22 -0800 | [diff] [blame] | 968 | { |
Hoonki Lee | d37cbb3 | 2013-04-20 00:31:14 -0700 | [diff] [blame] | 969 | #ifdef TDLS_USE_SEPARATE_DISCOVERY_TIMER |
Gopichand Nakkala | c369458 | 2013-02-13 20:51:22 -0800 | [diff] [blame] | 970 | vos_timer_stop(&pHddTdlsCtx->peerDiscoverTimer); |
Hoonki Lee | d37cbb3 | 2013-04-20 00:31:14 -0700 | [diff] [blame] | 971 | #endif |
Gopichand Nakkala | c369458 | 2013-02-13 20:51:22 -0800 | [diff] [blame] | 972 | vos_timer_stop(&pHddTdlsCtx->peerUpdateTimer); |
Gopichand Nakkala | 75e7b28 | 2013-03-15 18:37:13 -0700 | [diff] [blame] | 973 | vos_timer_stop(&pHddTdlsCtx->peerDiscoveryTimeoutTimer); |
Madan Mohan Koyyalamudi | 693275b | 2013-07-22 19:14:09 +0530 | [diff] [blame] | 974 | } |
Gopichand Nakkala | c369458 | 2013-02-13 20:51:22 -0800 | [diff] [blame] | 975 | |
Madan Mohan Koyyalamudi | 693275b | 2013-07-22 19:14:09 +0530 | [diff] [blame] | 976 | /* stop all per peer timers */ |
| 977 | static void wlan_hdd_tdls_peer_timers_stop(tdlsCtx_t *pHddTdlsCtx) |
| 978 | { |
| 979 | int i; |
| 980 | struct list_head *head; |
| 981 | struct list_head *pos; |
| 982 | hddTdlsPeer_t *curr_peer; |
Gopichand Nakkala | c369458 | 2013-02-13 20:51:22 -0800 | [diff] [blame] | 983 | for (i = 0; i < 256; i++) |
| 984 | { |
| 985 | head = &pHddTdlsCtx->peer_list[i]; |
Gopichand Nakkala | c369458 | 2013-02-13 20:51:22 -0800 | [diff] [blame] | 986 | list_for_each (pos, head) { |
| 987 | curr_peer = list_entry (pos, hddTdlsPeer_t, node); |
Gopichand Nakkala | c369458 | 2013-02-13 20:51:22 -0800 | [diff] [blame] | 988 | VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
Chilam Ng | 0112041 | 2013-02-19 18:32:21 -0800 | [diff] [blame] | 989 | "%s: " MAC_ADDRESS_STR " -> stop idle timer", |
Gopichand Nakkala | c369458 | 2013-02-13 20:51:22 -0800 | [diff] [blame] | 990 | __func__, |
Chilam Ng | 0112041 | 2013-02-19 18:32:21 -0800 | [diff] [blame] | 991 | MAC_ADDR_ARRAY(curr_peer->peerMac)); |
Gopichand Nakkala | c369458 | 2013-02-13 20:51:22 -0800 | [diff] [blame] | 992 | vos_timer_stop ( &curr_peer->peerIdleTimer ); |
Hoonki Lee | 1462135 | 2013-04-16 17:51:19 -0700 | [diff] [blame] | 993 | vos_timer_stop( &curr_peer->initiatorWaitTimeoutTimer ); |
Gopichand Nakkala | c369458 | 2013-02-13 20:51:22 -0800 | [diff] [blame] | 994 | } |
| 995 | } |
Gopichand Nakkala | c369458 | 2013-02-13 20:51:22 -0800 | [diff] [blame] | 996 | } |
| 997 | |
Madan Mohan Koyyalamudi | 693275b | 2013-07-22 19:14:09 +0530 | [diff] [blame] | 998 | /* stop all the tdls timers running */ |
| 999 | static void wlan_hdd_tdls_timers_stop(tdlsCtx_t *pHddTdlsCtx) |
Gopichand Nakkala | 91b0926 | 2013-02-10 14:27:02 -0800 | [diff] [blame] | 1000 | { |
Madan Mohan Koyyalamudi | 693275b | 2013-07-22 19:14:09 +0530 | [diff] [blame] | 1001 | wlan_hdd_tdls_monitor_timers_stop(pHddTdlsCtx); |
| 1002 | wlan_hdd_tdls_peer_timers_stop(pHddTdlsCtx); |
| 1003 | } |
Gopichand Nakkala | 91b0926 | 2013-02-10 14:27:02 -0800 | [diff] [blame] | 1004 | |
Madan Mohan Koyyalamudi | 693275b | 2013-07-22 19:14:09 +0530 | [diff] [blame] | 1005 | static void wlan_hdd_tdls_monitor_timers_destroy(tdlsCtx_t *pHddTdlsCtx) |
| 1006 | { |
Hoonki Lee | d37cbb3 | 2013-04-20 00:31:14 -0700 | [diff] [blame] | 1007 | #ifdef TDLS_USE_SEPARATE_DISCOVERY_TIMER |
Gopichand Nakkala | 91b0926 | 2013-02-10 14:27:02 -0800 | [diff] [blame] | 1008 | vos_timer_stop(&pHddTdlsCtx->peerDiscoverTimer); |
| 1009 | vos_timer_destroy(&pHddTdlsCtx->peerDiscoverTimer); |
Hoonki Lee | d37cbb3 | 2013-04-20 00:31:14 -0700 | [diff] [blame] | 1010 | #endif |
Gopichand Nakkala | 91b0926 | 2013-02-10 14:27:02 -0800 | [diff] [blame] | 1011 | vos_timer_stop(&pHddTdlsCtx->peerUpdateTimer); |
| 1012 | vos_timer_destroy(&pHddTdlsCtx->peerUpdateTimer); |
Gopichand Nakkala | 75e7b28 | 2013-03-15 18:37:13 -0700 | [diff] [blame] | 1013 | vos_timer_stop(&pHddTdlsCtx->peerDiscoveryTimeoutTimer); |
| 1014 | vos_timer_destroy(&pHddTdlsCtx->peerDiscoveryTimeoutTimer); |
Madan Mohan Koyyalamudi | 693275b | 2013-07-22 19:14:09 +0530 | [diff] [blame] | 1015 | } |
| 1016 | /*Free all the timers related to the TDLS peer */ |
| 1017 | static void wlan_hdd_tdls_peer_timers_destroy(tdlsCtx_t *pHddTdlsCtx) |
| 1018 | { |
| 1019 | int i; |
| 1020 | struct list_head *head; |
| 1021 | struct list_head *pos; |
| 1022 | hddTdlsPeer_t *curr_peer; |
Gopichand Nakkala | 91b0926 | 2013-02-10 14:27:02 -0800 | [diff] [blame] | 1023 | for (i = 0; i < 256; i++) |
| 1024 | { |
| 1025 | head = &pHddTdlsCtx->peer_list[i]; |
| 1026 | |
| 1027 | list_for_each (pos, head) { |
| 1028 | curr_peer = list_entry (pos, hddTdlsPeer_t, node); |
| 1029 | |
| 1030 | VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
Chilam Ng | 0112041 | 2013-02-19 18:32:21 -0800 | [diff] [blame] | 1031 | "%s: " MAC_ADDRESS_STR " -> destroy idle timer", |
Gopichand Nakkala | 91b0926 | 2013-02-10 14:27:02 -0800 | [diff] [blame] | 1032 | __func__, |
Chilam Ng | 0112041 | 2013-02-19 18:32:21 -0800 | [diff] [blame] | 1033 | MAC_ADDR_ARRAY(curr_peer->peerMac)); |
Gopichand Nakkala | 91b0926 | 2013-02-10 14:27:02 -0800 | [diff] [blame] | 1034 | vos_timer_stop ( &curr_peer->peerIdleTimer ); |
| 1035 | vos_timer_destroy ( &curr_peer->peerIdleTimer ); |
Hoonki Lee | 1462135 | 2013-04-16 17:51:19 -0700 | [diff] [blame] | 1036 | vos_timer_stop(&curr_peer->initiatorWaitTimeoutTimer); |
| 1037 | vos_timer_destroy(&curr_peer->initiatorWaitTimeoutTimer); |
Gopichand Nakkala | 91b0926 | 2013-02-10 14:27:02 -0800 | [diff] [blame] | 1038 | } |
| 1039 | } |
Madan Mohan Koyyalamudi | 693275b | 2013-07-22 19:14:09 +0530 | [diff] [blame] | 1040 | |
| 1041 | } |
| 1042 | |
| 1043 | /* destroy all the tdls timers running */ |
| 1044 | static void wlan_hdd_tdls_timers_destroy(tdlsCtx_t *pHddTdlsCtx) |
| 1045 | { |
| 1046 | wlan_hdd_tdls_monitor_timers_destroy(pHddTdlsCtx); |
| 1047 | wlan_hdd_tdls_peer_timers_destroy(pHddTdlsCtx); |
Gopichand Nakkala | 91b0926 | 2013-02-10 14:27:02 -0800 | [diff] [blame] | 1048 | } |
| 1049 | |
Hoonki Lee | 387663d | 2013-02-05 18:08:43 -0800 | [diff] [blame] | 1050 | /* if mac address exist, return pointer |
| 1051 | if mac address doesn't exist, create a list and add, return pointer |
| 1052 | return NULL if fails to get new mac address |
| 1053 | */ |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 1054 | 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] | 1055 | { |
Hoonki Lee | 387663d | 2013-02-05 18:08:43 -0800 | [diff] [blame] | 1056 | struct list_head *head; |
| 1057 | hddTdlsPeer_t *peer; |
| 1058 | u8 key; |
Gopichand Nakkala | 4ddf019 | 2013-03-27 13:41:20 -0700 | [diff] [blame] | 1059 | tdlsCtx_t *pHddTdlsCtx; |
Madan Mohan Koyyalamudi | 263cec1 | 2013-10-07 10:57:50 +0530 | [diff] [blame] | 1060 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 1061 | |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 1062 | if(0 != (wlan_hdd_validate_context(pHddCtx))) |
| 1063 | { |
| 1064 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1065 | FL("pHddCtx is not valid")); |
| 1066 | return 0; |
| 1067 | } |
Hoonki Lee | bfee034 | 2013-01-21 16:43:45 -0800 | [diff] [blame] | 1068 | |
Hoonki Lee | 387663d | 2013-02-05 18:08:43 -0800 | [diff] [blame] | 1069 | /* if already there, just update */ |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 1070 | peer = wlan_hdd_tdls_find_peer(pAdapter, mac, TRUE); |
Hoonki Lee | 387663d | 2013-02-05 18:08:43 -0800 | [diff] [blame] | 1071 | if (peer != NULL) |
| 1072 | { |
| 1073 | return peer; |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 1074 | } |
| 1075 | |
Hoonki Lee | 387663d | 2013-02-05 18:08:43 -0800 | [diff] [blame] | 1076 | /* not found, allocate and add the list */ |
| 1077 | peer = vos_mem_malloc(sizeof(hddTdlsPeer_t)); |
| 1078 | if (NULL == peer) { |
| 1079 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s peer malloc failed!", __func__); |
| 1080 | return NULL; |
| 1081 | } |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 1082 | |
Rajesh Chauhan | a34c6e6 | 2014-03-25 16:37:58 +0530 | [diff] [blame] | 1083 | mutex_lock(&pHddCtx->tdls_lock); |
| 1084 | |
Gopichand Nakkala | 4ddf019 | 2013-03-27 13:41:20 -0700 | [diff] [blame] | 1085 | pHddTdlsCtx = WLAN_HDD_GET_TDLS_CTX_PTR(pAdapter); |
| 1086 | |
| 1087 | if (NULL == pHddTdlsCtx) |
| 1088 | { |
c_hpothu | e21931b | 2014-09-08 14:02:14 +0530 | [diff] [blame] | 1089 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 1090 | FL("pHddTdlsCtx is NULL")); |
Gopichand Nakkala | 4ddf019 | 2013-03-27 13:41:20 -0700 | [diff] [blame] | 1091 | vos_mem_free(peer); |
Madan Mohan Koyyalamudi | 263cec1 | 2013-10-07 10:57:50 +0530 | [diff] [blame] | 1092 | mutex_unlock(&pHddCtx->tdls_lock); |
Gopichand Nakkala | 4ddf019 | 2013-03-27 13:41:20 -0700 | [diff] [blame] | 1093 | return NULL; |
| 1094 | } |
| 1095 | |
| 1096 | key = wlan_hdd_tdls_hash_key(mac); |
| 1097 | head = &pHddTdlsCtx->peer_list[key]; |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 1098 | |
Hoonki Lee | 387663d | 2013-02-05 18:08:43 -0800 | [diff] [blame] | 1099 | vos_mem_zero(peer, sizeof(hddTdlsPeer_t)); |
| 1100 | vos_mem_copy(peer->peerMac, mac, sizeof(peer->peerMac)); |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 1101 | peer->pHddTdlsCtx = pHddTdlsCtx; |
Hoonki Lee | 387663d | 2013-02-05 18:08:43 -0800 | [diff] [blame] | 1102 | |
Gopichand Nakkala | 91b0926 | 2013-02-10 14:27:02 -0800 | [diff] [blame] | 1103 | vos_timer_init(&peer->peerIdleTimer, |
| 1104 | VOS_TIMER_TYPE_SW, |
| 1105 | wlan_hdd_tdls_idle_cb, |
| 1106 | peer); |
| 1107 | |
Hoonki Lee | 1462135 | 2013-04-16 17:51:19 -0700 | [diff] [blame] | 1108 | vos_timer_init(&peer->initiatorWaitTimeoutTimer, |
| 1109 | VOS_TIMER_TYPE_SW, |
| 1110 | wlan_hdd_tdls_initiator_wait_cb, |
| 1111 | peer); |
| 1112 | |
Hoonki Lee | 387663d | 2013-02-05 18:08:43 -0800 | [diff] [blame] | 1113 | list_add_tail(&peer->node, head); |
Madan Mohan Koyyalamudi | 263cec1 | 2013-10-07 10:57:50 +0530 | [diff] [blame] | 1114 | mutex_unlock(&pHddCtx->tdls_lock); |
Hoonki Lee | 387663d | 2013-02-05 18:08:43 -0800 | [diff] [blame] | 1115 | |
| 1116 | return peer; |
| 1117 | } |
| 1118 | |
Gopichand Nakkala | 34d1b06 | 2013-03-19 15:28:33 -0700 | [diff] [blame] | 1119 | int wlan_hdd_tdls_set_cap(hdd_adapter_t *pAdapter, |
Hoonki Lee | 2751190 | 2013-03-14 18:19:06 -0700 | [diff] [blame] | 1120 | u8* mac, |
| 1121 | tTDLSCapType cap) |
| 1122 | { |
| 1123 | hddTdlsPeer_t *curr_peer; |
| 1124 | |
Gopichand Nakkala | 34d1b06 | 2013-03-19 15:28:33 -0700 | [diff] [blame] | 1125 | curr_peer = wlan_hdd_tdls_get_peer(pAdapter, mac); |
Hoonki Lee | 2751190 | 2013-03-14 18:19:06 -0700 | [diff] [blame] | 1126 | if (curr_peer == NULL) |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 1127 | { |
| 1128 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1129 | "%s: curr_peer is NULL", __func__); |
Gopichand Nakkala | 34d1b06 | 2013-03-19 15:28:33 -0700 | [diff] [blame] | 1130 | return -1; |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 1131 | } |
Hoonki Lee | 2751190 | 2013-03-14 18:19:06 -0700 | [diff] [blame] | 1132 | |
| 1133 | curr_peer->tdls_support = cap; |
| 1134 | |
Gopichand Nakkala | 34d1b06 | 2013-03-19 15:28:33 -0700 | [diff] [blame] | 1135 | return 0; |
Hoonki Lee | 2751190 | 2013-03-14 18:19:06 -0700 | [diff] [blame] | 1136 | } |
| 1137 | |
Atul Mittal | 115287b | 2014-07-08 13:26:33 +0530 | [diff] [blame] | 1138 | void wlan_hdd_tdls_set_peer_link_status(hddTdlsPeer_t *curr_peer, |
| 1139 | tTDLSLinkStatus status, |
| 1140 | tTDLSLinkReason reason) |
Hoonki Lee | 387663d | 2013-02-05 18:08:43 -0800 | [diff] [blame] | 1141 | { |
Atul Mittal | 115287b | 2014-07-08 13:26:33 +0530 | [diff] [blame] | 1142 | /*EXT TDLS*/ |
| 1143 | tANI_S32 state = 0; |
| 1144 | tANI_S32 res = 0; |
| 1145 | /*EXT TDLS*/ |
Hoonki Lee | 387663d | 2013-02-05 18:08:43 -0800 | [diff] [blame] | 1146 | if (curr_peer == NULL) |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 1147 | { |
| 1148 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1149 | "%s: curr_peer is NULL", __func__); |
Hoonki Lee | 387663d | 2013-02-05 18:08:43 -0800 | [diff] [blame] | 1150 | return; |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 1151 | } |
Hoonki Lee | 387663d | 2013-02-05 18:08:43 -0800 | [diff] [blame] | 1152 | |
Gopichand Nakkala | 8b00c63 | 2013-03-08 19:47:52 -0800 | [diff] [blame] | 1153 | 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] | 1154 | MAC_ADDR_ARRAY(curr_peer->peerMac), status); |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 1155 | |
| 1156 | curr_peer->link_status = status; |
| 1157 | |
Atul Mittal | 115287b | 2014-07-08 13:26:33 +0530 | [diff] [blame] | 1158 | /*EXT TDLS*/ |
| 1159 | if (curr_peer->isForcedPeer && curr_peer->state_change_notification) |
| 1160 | { |
| 1161 | /*save the reason for any further query*/ |
| 1162 | curr_peer->reason = reason; |
| 1163 | wlan_hdd_tdls_get_wifi_hal_state(curr_peer, &state, &res); |
| 1164 | |
| 1165 | (curr_peer->state_change_notification)( |
| 1166 | curr_peer->peerMac, |
| 1167 | state, |
| 1168 | res, |
| 1169 | curr_peer->pHddTdlsCtx->pAdapter); |
| 1170 | |
| 1171 | } |
| 1172 | /*EXT TDLS*/ |
| 1173 | |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 1174 | } |
| 1175 | |
Gopichand Nakkala | 8b00c63 | 2013-03-08 19:47:52 -0800 | [diff] [blame] | 1176 | void wlan_hdd_tdls_set_link_status(hdd_adapter_t *pAdapter, |
| 1177 | u8* mac, |
Atul Mittal | 115287b | 2014-07-08 13:26:33 +0530 | [diff] [blame] | 1178 | tTDLSLinkStatus linkStatus, |
| 1179 | tTDLSLinkReason reason) |
Gopichand Nakkala | 8b00c63 | 2013-03-08 19:47:52 -0800 | [diff] [blame] | 1180 | { |
Atul Mittal | 115287b | 2014-07-08 13:26:33 +0530 | [diff] [blame] | 1181 | |
| 1182 | /*EXT TDLS*/ |
| 1183 | tANI_S32 state = 0; |
| 1184 | tANI_S32 res = 0; |
| 1185 | /*EXT TDLS*/ |
Gopichand Nakkala | 8b00c63 | 2013-03-08 19:47:52 -0800 | [diff] [blame] | 1186 | hddTdlsPeer_t *curr_peer; |
| 1187 | |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 1188 | curr_peer = wlan_hdd_tdls_find_peer(pAdapter, mac, TRUE); |
Gopichand Nakkala | 8b00c63 | 2013-03-08 19:47:52 -0800 | [diff] [blame] | 1189 | if (curr_peer == NULL) |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 1190 | { |
| 1191 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1192 | "%s: curr_peer is NULL", __func__); |
Gopichand Nakkala | 8b00c63 | 2013-03-08 19:47:52 -0800 | [diff] [blame] | 1193 | return; |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 1194 | } |
Gopichand Nakkala | 8b00c63 | 2013-03-08 19:47:52 -0800 | [diff] [blame] | 1195 | |
| 1196 | curr_peer->link_status= linkStatus; |
| 1197 | |
Atul Mittal | 115287b | 2014-07-08 13:26:33 +0530 | [diff] [blame] | 1198 | /*EXT TDLS*/ |
| 1199 | |
| 1200 | if (curr_peer->isForcedPeer && curr_peer->state_change_notification) |
| 1201 | { |
| 1202 | /*save the reason for any further query*/ |
| 1203 | curr_peer->reason = reason; |
| 1204 | wlan_hdd_tdls_get_wifi_hal_state(curr_peer, &state, &res); |
| 1205 | |
| 1206 | (*curr_peer->state_change_notification)(mac, |
| 1207 | state, |
| 1208 | res, |
| 1209 | curr_peer->pHddTdlsCtx->pAdapter); |
| 1210 | |
| 1211 | } |
| 1212 | /*EXT TDLS*/ |
Gopichand Nakkala | 8b00c63 | 2013-03-08 19:47:52 -0800 | [diff] [blame] | 1213 | return; |
| 1214 | } |
| 1215 | |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 1216 | 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] | 1217 | { |
| 1218 | hddTdlsPeer_t *curr_peer; |
Gopichand Nakkala | 75e7b28 | 2013-03-15 18:37:13 -0700 | [diff] [blame] | 1219 | tdlsCtx_t *pHddTdlsCtx = WLAN_HDD_GET_TDLS_CTX_PTR(pAdapter); |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 1220 | hdd_context_t *pHddCtx; |
| 1221 | |
| 1222 | if ( NULL == pHddTdlsCtx ) |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 1223 | { |
| 1224 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Mahesh A Saptasagar | 36cdc80 | 2015-01-07 18:41:17 +0530 | [diff] [blame] | 1225 | FL("pHddTdlsCtx is NULL device mode = %d"), pAdapter->device_mode); |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 1226 | return -1; |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 1227 | } |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 1228 | |
| 1229 | pHddCtx = WLAN_HDD_GET_CTX(pHddTdlsCtx->pAdapter); |
| 1230 | |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 1231 | if(0 != (wlan_hdd_validate_context(pHddCtx))) |
| 1232 | { |
| 1233 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1234 | FL("pHddCtx is not valid")); |
| 1235 | return 0; |
| 1236 | } |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 1237 | |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 1238 | curr_peer = wlan_hdd_tdls_get_peer(pAdapter, mac); |
Gopichand Nakkala | 75e7b28 | 2013-03-15 18:37:13 -0700 | [diff] [blame] | 1239 | |
| 1240 | if (NULL == curr_peer) |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 1241 | { |
| 1242 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1243 | FL("curr_peer is NULL")); |
Hoonki Lee | 387663d | 2013-02-05 18:08:43 -0800 | [diff] [blame] | 1244 | return -1; |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 1245 | } |
Gopichand Nakkala | 75e7b28 | 2013-03-15 18:37:13 -0700 | [diff] [blame] | 1246 | |
| 1247 | if (pHddTdlsCtx->discovery_sent_cnt) |
| 1248 | pHddTdlsCtx->discovery_sent_cnt--; |
| 1249 | |
Rajesh Chauhan | a34c6e6 | 2014-03-25 16:37:58 +0530 | [diff] [blame] | 1250 | mutex_lock(&pHddCtx->tdls_lock); |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 1251 | |
Gopichand Nakkala | 34d1b06 | 2013-03-19 15:28:33 -0700 | [diff] [blame] | 1252 | wlan_hdd_tdls_check_power_save_prohibited(pAdapter); |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 1253 | |
| 1254 | mutex_unlock(&pHddCtx->tdls_lock); |
Gopichand Nakkala | 75e7b28 | 2013-03-15 18:37:13 -0700 | [diff] [blame] | 1255 | if (0 == pHddTdlsCtx->discovery_sent_cnt) |
Gopichand Nakkala | ccd3a38 | 2013-03-19 13:56:10 -0700 | [diff] [blame] | 1256 | { |
Gopichand Nakkala | 75e7b28 | 2013-03-15 18:37:13 -0700 | [diff] [blame] | 1257 | vos_timer_stop(&pHddTdlsCtx->peerDiscoveryTimeoutTimer); |
Gopichand Nakkala | ccd3a38 | 2013-03-19 13:56:10 -0700 | [diff] [blame] | 1258 | } |
Gopichand Nakkala | 75e7b28 | 2013-03-15 18:37:13 -0700 | [diff] [blame] | 1259 | |
Gopichand Nakkala | 901e892 | 2013-03-04 23:45:58 -0800 | [diff] [blame] | 1260 | VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
Jeff Johnson | 0299d0a | 2013-10-30 12:37:43 -0700 | [diff] [blame] | 1261 | "Discovery(%u) Response from " MAC_ADDRESS_STR " link_status %d", |
Gopichand Nakkala | 75e7b28 | 2013-03-15 18:37:13 -0700 | [diff] [blame] | 1262 | pHddTdlsCtx->discovery_sent_cnt, MAC_ADDR_ARRAY(curr_peer->peerMac), |
| 1263 | curr_peer->link_status); |
| 1264 | |
Gopichand Nakkala | 8b00c63 | 2013-03-08 19:47:52 -0800 | [diff] [blame] | 1265 | if (eTDLS_LINK_DISCOVERING == curr_peer->link_status) |
Gopichand Nakkala | 901e892 | 2013-03-04 23:45:58 -0800 | [diff] [blame] | 1266 | { |
Shailender Karmuchi | 13c0d08 | 2013-03-26 14:41:39 -0700 | [diff] [blame] | 1267 | /* Since we are here, it means Throughput threshold is alredy met. Make sure RSSI |
| 1268 | threshold is also met before setting up TDLS link*/ |
| 1269 | if ((tANI_S32) curr_peer->rssi > (tANI_S32) pHddTdlsCtx->threshold_config.rssi_trigger_threshold) |
| 1270 | { |
Atul Mittal | 115287b | 2014-07-08 13:26:33 +0530 | [diff] [blame] | 1271 | wlan_hdd_tdls_set_peer_link_status(curr_peer, |
| 1272 | eTDLS_LINK_DISCOVERED, |
| 1273 | eTDLS_LINK_SUCCESS); |
Shailender Karmuchi | 13c0d08 | 2013-03-26 14:41:39 -0700 | [diff] [blame] | 1274 | VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
| 1275 | "Rssi Threshold met: "MAC_ADDRESS_STR" rssi = %d threshold= %d" , |
| 1276 | MAC_ADDR_ARRAY(curr_peer->peerMac), curr_peer->rssi, |
| 1277 | pHddTdlsCtx->threshold_config.rssi_trigger_threshold); |
| 1278 | cfg80211_tdls_oper_request(pAdapter->dev, curr_peer->peerMac, NL80211_TDLS_SETUP, FALSE, GFP_KERNEL); |
| 1279 | } |
| 1280 | else |
| 1281 | { |
| 1282 | VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
| 1283 | "Rssi Threshold not met: "MAC_ADDRESS_STR" rssi = %d threshold = %d ", |
| 1284 | MAC_ADDR_ARRAY(curr_peer->peerMac), curr_peer->rssi, |
| 1285 | pHddTdlsCtx->threshold_config.rssi_trigger_threshold); |
Sunil Dutt | b0d3924 | 2014-09-10 23:54:51 +0530 | [diff] [blame] | 1286 | |
| 1287 | /* if RSSI threshold is not met then allow further discovery |
| 1288 | * attempts by decrementing count for the last attempt |
| 1289 | */ |
| 1290 | if (curr_peer->discovery_attempt) |
| 1291 | curr_peer->discovery_attempt--; |
| 1292 | |
Atul Mittal | 115287b | 2014-07-08 13:26:33 +0530 | [diff] [blame] | 1293 | wlan_hdd_tdls_set_peer_link_status(curr_peer, |
| 1294 | eTDLS_LINK_IDLE, |
| 1295 | eTDLS_LINK_UNSPECIFIED); |
Shailender Karmuchi | 13c0d08 | 2013-03-26 14:41:39 -0700 | [diff] [blame] | 1296 | } |
Gopichand Nakkala | 901e892 | 2013-03-04 23:45:58 -0800 | [diff] [blame] | 1297 | } |
Gopichand Nakkala | ccd3a38 | 2013-03-19 13:56:10 -0700 | [diff] [blame] | 1298 | else |
| 1299 | { |
| 1300 | wlan_hdd_tdls_check_bmps(pAdapter); |
| 1301 | } |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 1302 | |
Gopichand Nakkala | 901e892 | 2013-03-04 23:45:58 -0800 | [diff] [blame] | 1303 | curr_peer->tdls_support = eTDLS_CAP_SUPPORTED; |
Hoonki Lee | 387663d | 2013-02-05 18:08:43 -0800 | [diff] [blame] | 1304 | return 0; |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 1305 | } |
| 1306 | |
Gopichand Nakkala | 79ff85d | 2013-05-27 17:05:29 +0530 | [diff] [blame] | 1307 | int wlan_hdd_tdls_set_peer_caps(hdd_adapter_t *pAdapter, |
| 1308 | u8 *mac, |
Naresh Jayaram | 3180aa4 | 2014-02-12 21:47:26 +0530 | [diff] [blame] | 1309 | tCsrStaParams *StaParams, |
| 1310 | tANI_BOOLEAN isBufSta, |
| 1311 | tANI_BOOLEAN isOffChannelSupported) |
Gopichand Nakkala | 79ff85d | 2013-05-27 17:05:29 +0530 | [diff] [blame] | 1312 | { |
| 1313 | hddTdlsPeer_t *curr_peer; |
| 1314 | |
| 1315 | curr_peer = wlan_hdd_tdls_get_peer(pAdapter, mac); |
| 1316 | if (curr_peer == NULL) |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 1317 | { |
| 1318 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1319 | "%s: curr_peer is NULL", __func__); |
Gopichand Nakkala | 79ff85d | 2013-05-27 17:05:29 +0530 | [diff] [blame] | 1320 | return -1; |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 1321 | } |
Gopichand Nakkala | 79ff85d | 2013-05-27 17:05:29 +0530 | [diff] [blame] | 1322 | |
Naresh Jayaram | 3180aa4 | 2014-02-12 21:47:26 +0530 | [diff] [blame] | 1323 | curr_peer->uapsdQueues = StaParams->uapsd_queues; |
| 1324 | curr_peer->maxSp = StaParams->max_sp; |
Gopichand Nakkala | 79ff85d | 2013-05-27 17:05:29 +0530 | [diff] [blame] | 1325 | curr_peer->isBufSta = isBufSta; |
Naresh Jayaram | 3180aa4 | 2014-02-12 21:47:26 +0530 | [diff] [blame] | 1326 | curr_peer->isOffChannelSupported = isOffChannelSupported; |
| 1327 | |
| 1328 | vos_mem_copy(curr_peer->supported_channels, |
| 1329 | StaParams->supported_channels, |
| 1330 | StaParams->supported_channels_len); |
| 1331 | |
| 1332 | curr_peer->supported_channels_len = |
| 1333 | StaParams->supported_channels_len; |
| 1334 | |
| 1335 | vos_mem_copy(curr_peer->supported_oper_classes, |
| 1336 | StaParams->supported_oper_classes, |
| 1337 | StaParams->supported_oper_classes_len); |
| 1338 | |
| 1339 | curr_peer->supported_oper_classes_len = |
| 1340 | StaParams->supported_oper_classes_len; |
Agarwal Ashish | 16020c4 | 2014-12-29 22:01:11 +0530 | [diff] [blame] | 1341 | curr_peer->qos = StaParams->capability & CAPABILITIES_QOS_OFFSET; |
Gopichand Nakkala | 79ff85d | 2013-05-27 17:05:29 +0530 | [diff] [blame] | 1342 | return 0; |
| 1343 | } |
| 1344 | |
| 1345 | int wlan_hdd_tdls_get_link_establish_params(hdd_adapter_t *pAdapter, u8 *mac, |
| 1346 | tCsrTdlsLinkEstablishParams* tdlsLinkEstablishParams) |
| 1347 | { |
| 1348 | hddTdlsPeer_t *curr_peer; |
| 1349 | |
| 1350 | curr_peer = wlan_hdd_tdls_get_peer(pAdapter, mac); |
| 1351 | if (curr_peer == NULL) |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 1352 | { |
| 1353 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1354 | "%s: curr_peer is NULL", __func__); |
Gopichand Nakkala | 79ff85d | 2013-05-27 17:05:29 +0530 | [diff] [blame] | 1355 | return -1; |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 1356 | } |
Gopichand Nakkala | 79ff85d | 2013-05-27 17:05:29 +0530 | [diff] [blame] | 1357 | |
| 1358 | tdlsLinkEstablishParams->isResponder = curr_peer->is_responder; |
| 1359 | tdlsLinkEstablishParams->uapsdQueues = curr_peer->uapsdQueues; |
| 1360 | tdlsLinkEstablishParams->maxSp = curr_peer->maxSp; |
| 1361 | tdlsLinkEstablishParams->isBufSta = curr_peer->isBufSta; |
Naresh Jayaram | 3180aa4 | 2014-02-12 21:47:26 +0530 | [diff] [blame] | 1362 | tdlsLinkEstablishParams->isOffChannelSupported = |
| 1363 | curr_peer->isOffChannelSupported; |
| 1364 | |
| 1365 | vos_mem_copy(tdlsLinkEstablishParams->supportedChannels, |
| 1366 | curr_peer->supported_channels, |
| 1367 | curr_peer->supported_channels_len); |
| 1368 | |
| 1369 | tdlsLinkEstablishParams->supportedChannelsLen = |
| 1370 | curr_peer->supported_channels_len; |
| 1371 | |
| 1372 | vos_mem_copy(tdlsLinkEstablishParams->supportedOperClasses, |
| 1373 | curr_peer->supported_oper_classes, |
| 1374 | curr_peer->supported_oper_classes_len); |
| 1375 | |
| 1376 | tdlsLinkEstablishParams->supportedOperClassesLen = |
| 1377 | curr_peer->supported_oper_classes_len; |
Agarwal Ashish | 16020c4 | 2014-12-29 22:01:11 +0530 | [diff] [blame] | 1378 | tdlsLinkEstablishParams->qos = curr_peer->qos; |
| 1379 | |
Gopichand Nakkala | 79ff85d | 2013-05-27 17:05:29 +0530 | [diff] [blame] | 1380 | return 0; |
| 1381 | } |
| 1382 | |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 1383 | 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] | 1384 | { |
| 1385 | hddTdlsPeer_t *curr_peer; |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 1386 | |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 1387 | curr_peer = wlan_hdd_tdls_find_peer(pAdapter, mac, TRUE); |
Hoonki Lee | 387663d | 2013-02-05 18:08:43 -0800 | [diff] [blame] | 1388 | if (curr_peer == NULL) |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 1389 | { |
| 1390 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1391 | "%s: curr_peer is NULL", __func__); |
Hoonki Lee | 387663d | 2013-02-05 18:08:43 -0800 | [diff] [blame] | 1392 | return -1; |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 1393 | } |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 1394 | |
| 1395 | curr_peer->rssi = rxRssi; |
| 1396 | |
Hoonki Lee | 387663d | 2013-02-05 18:08:43 -0800 | [diff] [blame] | 1397 | return 0; |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 1398 | } |
| 1399 | |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 1400 | 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] | 1401 | { |
| 1402 | hddTdlsPeer_t *curr_peer; |
| 1403 | |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 1404 | curr_peer = wlan_hdd_tdls_get_peer(pAdapter, mac); |
Gopichand Nakkala | 91b0926 | 2013-02-10 14:27:02 -0800 | [diff] [blame] | 1405 | if (curr_peer == NULL) |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 1406 | { |
| 1407 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1408 | "%s: curr_peer is NULL", __func__); |
Hoonki Lee | a34dd89 | 2013-02-05 22:56:02 -0800 | [diff] [blame] | 1409 | return -1; |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 1410 | } |
Hoonki Lee | a34dd89 | 2013-02-05 22:56:02 -0800 | [diff] [blame] | 1411 | |
| 1412 | curr_peer->is_responder = responder; |
| 1413 | |
| 1414 | return 0; |
| 1415 | } |
| 1416 | |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 1417 | int wlan_hdd_tdls_get_responder(hdd_adapter_t *pAdapter, u8 *mac) |
Hoonki Lee | a34dd89 | 2013-02-05 22:56:02 -0800 | [diff] [blame] | 1418 | { |
| 1419 | hddTdlsPeer_t *curr_peer; |
| 1420 | |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 1421 | curr_peer = wlan_hdd_tdls_find_peer(pAdapter, mac, TRUE); |
Gopichand Nakkala | 91b0926 | 2013-02-10 14:27:02 -0800 | [diff] [blame] | 1422 | if (curr_peer == NULL) |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 1423 | { |
| 1424 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1425 | "%s: curr_peer is NULL", __func__); |
Hoonki Lee | a34dd89 | 2013-02-05 22:56:02 -0800 | [diff] [blame] | 1426 | return -1; |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 1427 | } |
Hoonki Lee | a34dd89 | 2013-02-05 22:56:02 -0800 | [diff] [blame] | 1428 | |
| 1429 | return (curr_peer->is_responder); |
| 1430 | } |
| 1431 | |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 1432 | 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] | 1433 | { |
| 1434 | hddTdlsPeer_t *curr_peer; |
| 1435 | |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 1436 | curr_peer = wlan_hdd_tdls_get_peer(pAdapter, mac); |
Hoonki Lee | 11f7dda | 2013-02-14 16:55:44 -0800 | [diff] [blame] | 1437 | if (curr_peer == NULL) |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 1438 | { |
| 1439 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1440 | "%s: curr_peer is NULL", __func__); |
Hoonki Lee | 11f7dda | 2013-02-14 16:55:44 -0800 | [diff] [blame] | 1441 | return -1; |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 1442 | } |
Hoonki Lee | 11f7dda | 2013-02-14 16:55:44 -0800 | [diff] [blame] | 1443 | |
| 1444 | curr_peer->signature = uSignature; |
| 1445 | |
| 1446 | return 0; |
| 1447 | } |
| 1448 | |
Hoonki Lee | a34dd89 | 2013-02-05 22:56:02 -0800 | [diff] [blame] | 1449 | |
Hoonki Lee | 387663d | 2013-02-05 18:08:43 -0800 | [diff] [blame] | 1450 | void wlan_hdd_tdls_extract_da(struct sk_buff *skb, u8 *mac) |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 1451 | { |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 1452 | memcpy(mac, skb->data, 6); |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 1453 | } |
| 1454 | |
Hoonki Lee | 387663d | 2013-02-05 18:08:43 -0800 | [diff] [blame] | 1455 | void wlan_hdd_tdls_extract_sa(struct sk_buff *skb, u8 *mac) |
Chilam Ng | 1279e23 | 2013-01-25 15:06:52 -0800 | [diff] [blame] | 1456 | { |
Chilam Ng | 1279e23 | 2013-01-25 15:06:52 -0800 | [diff] [blame] | 1457 | memcpy(mac, skb->data+6, 6); |
Chilam Ng | 1279e23 | 2013-01-25 15:06:52 -0800 | [diff] [blame] | 1458 | } |
| 1459 | |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 1460 | 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] | 1461 | { |
Hoonki Lee | 387663d | 2013-02-05 18:08:43 -0800 | [diff] [blame] | 1462 | hddTdlsPeer_t *curr_peer; |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 1463 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 1464 | |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 1465 | if (eTDLS_SUPPORT_ENABLED != pHddCtx->tdls_mode) |
| 1466 | return -1; |
Hoonki Lee | bfee034 | 2013-01-21 16:43:45 -0800 | [diff] [blame] | 1467 | |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 1468 | curr_peer = wlan_hdd_tdls_get_peer(pAdapter, mac); |
Hoonki Lee | 387663d | 2013-02-05 18:08:43 -0800 | [diff] [blame] | 1469 | if (curr_peer == NULL) |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 1470 | { |
c_hpothu | e21931b | 2014-09-08 14:02:14 +0530 | [diff] [blame] | 1471 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 1472 | FL("curr_peer is NULL")); |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 1473 | return -1; |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 1474 | } |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 1475 | |
Chilam Ng | 1279e23 | 2013-01-25 15:06:52 -0800 | [diff] [blame] | 1476 | if (tx) |
| 1477 | curr_peer->tx_pkt++; |
| 1478 | else |
| 1479 | curr_peer->rx_pkt++; |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 1480 | |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 1481 | return 0; |
| 1482 | } |
| 1483 | |
Hoonki Lee | 2751190 | 2013-03-14 18:19:06 -0700 | [diff] [blame] | 1484 | static int wlan_hdd_tdls_check_config(tdls_config_params_t *config) |
| 1485 | { |
| 1486 | if (config->tdls > 2) |
| 1487 | { |
| 1488 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s invalid 1st argument %d. <0...2>", __func__, config->tdls); |
| 1489 | return -1; |
| 1490 | } |
| 1491 | if (config->tx_period_t < CFG_TDLS_TX_STATS_PERIOD_MIN || |
| 1492 | config->tx_period_t > CFG_TDLS_TX_STATS_PERIOD_MAX) |
| 1493 | { |
Jeff Johnson | 0299d0a | 2013-10-30 12:37:43 -0700 | [diff] [blame] | 1494 | 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] | 1495 | CFG_TDLS_TX_STATS_PERIOD_MIN, CFG_TDLS_TX_STATS_PERIOD_MAX); |
| 1496 | return -1; |
| 1497 | } |
| 1498 | if (config->tx_packet_n < CFG_TDLS_TX_PACKET_THRESHOLD_MIN || |
| 1499 | config->tx_packet_n > CFG_TDLS_TX_PACKET_THRESHOLD_MAX) |
| 1500 | { |
Jeff Johnson | 0299d0a | 2013-10-30 12:37:43 -0700 | [diff] [blame] | 1501 | 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] | 1502 | CFG_TDLS_TX_PACKET_THRESHOLD_MIN, CFG_TDLS_TX_PACKET_THRESHOLD_MAX); |
| 1503 | return -1; |
| 1504 | } |
| 1505 | if (config->discovery_period_t < CFG_TDLS_DISCOVERY_PERIOD_MIN || |
| 1506 | config->discovery_period_t > CFG_TDLS_DISCOVERY_PERIOD_MAX) |
| 1507 | { |
Jeff Johnson | 0299d0a | 2013-10-30 12:37:43 -0700 | [diff] [blame] | 1508 | 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] | 1509 | CFG_TDLS_DISCOVERY_PERIOD_MIN, CFG_TDLS_DISCOVERY_PERIOD_MAX); |
| 1510 | return -1; |
| 1511 | } |
| 1512 | if (config->discovery_tries_n < CFG_TDLS_MAX_DISCOVERY_ATTEMPT_MIN || |
| 1513 | config->discovery_tries_n > CFG_TDLS_MAX_DISCOVERY_ATTEMPT_MAX) |
| 1514 | { |
| 1515 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s invalid 5th argument %d. <%d...%d>", __func__, config->discovery_tries_n, |
| 1516 | CFG_TDLS_MAX_DISCOVERY_ATTEMPT_MIN, CFG_TDLS_MAX_DISCOVERY_ATTEMPT_MAX); |
| 1517 | return -1; |
| 1518 | } |
| 1519 | if (config->idle_timeout_t < CFG_TDLS_IDLE_TIMEOUT_MIN || |
| 1520 | config->idle_timeout_t > CFG_TDLS_IDLE_TIMEOUT_MAX) |
| 1521 | { |
| 1522 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s invalid 6th argument %d. <%d...%d>", __func__, config->idle_timeout_t, |
| 1523 | CFG_TDLS_IDLE_TIMEOUT_MIN, CFG_TDLS_IDLE_TIMEOUT_MAX); |
| 1524 | return -1; |
| 1525 | } |
| 1526 | if (config->idle_packet_n < CFG_TDLS_IDLE_PACKET_THRESHOLD_MIN || |
| 1527 | config->idle_packet_n > CFG_TDLS_IDLE_PACKET_THRESHOLD_MAX) |
| 1528 | { |
| 1529 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s invalid 7th argument %d. <%d...%d>", __func__, config->idle_packet_n, |
| 1530 | CFG_TDLS_IDLE_PACKET_THRESHOLD_MIN, CFG_TDLS_IDLE_PACKET_THRESHOLD_MAX); |
| 1531 | return -1; |
| 1532 | } |
| 1533 | if (config->rssi_hysteresis < CFG_TDLS_RSSI_HYSTERESIS_MIN || |
| 1534 | config->rssi_hysteresis > CFG_TDLS_RSSI_HYSTERESIS_MAX) |
| 1535 | { |
| 1536 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s invalid 8th argument %d. <%d...%d>", __func__, config->rssi_hysteresis, |
| 1537 | CFG_TDLS_RSSI_HYSTERESIS_MIN, CFG_TDLS_RSSI_HYSTERESIS_MAX); |
| 1538 | return -1; |
| 1539 | } |
| 1540 | if (config->rssi_trigger_threshold < CFG_TDLS_RSSI_TRIGGER_THRESHOLD_MIN || |
| 1541 | config->rssi_trigger_threshold > CFG_TDLS_RSSI_TRIGGER_THRESHOLD_MAX) |
| 1542 | { |
| 1543 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s invalid 9th argument %d. <%d...%d>", __func__, config->rssi_trigger_threshold, |
| 1544 | CFG_TDLS_RSSI_TRIGGER_THRESHOLD_MIN, CFG_TDLS_RSSI_TRIGGER_THRESHOLD_MAX); |
| 1545 | return -1; |
| 1546 | } |
| 1547 | if (config->rssi_teardown_threshold < CFG_TDLS_RSSI_TEARDOWN_THRESHOLD_MIN || |
| 1548 | config->rssi_teardown_threshold > CFG_TDLS_RSSI_TEARDOWN_THRESHOLD_MAX) |
| 1549 | { |
| 1550 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s invalid 10th argument %d. <%d...%d>", __func__, config->rssi_teardown_threshold, |
| 1551 | CFG_TDLS_RSSI_TEARDOWN_THRESHOLD_MIN, CFG_TDLS_RSSI_TEARDOWN_THRESHOLD_MAX); |
| 1552 | return -1; |
| 1553 | } |
| 1554 | return 0; |
| 1555 | } |
| 1556 | |
Chilam Ng | 0112041 | 2013-02-19 18:32:21 -0800 | [diff] [blame] | 1557 | 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] | 1558 | { |
Chilam Ng | 0112041 | 2013-02-19 18:32:21 -0800 | [diff] [blame] | 1559 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 1560 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter ); |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 1561 | tdlsCtx_t *pHddTdlsCtx = WLAN_HDD_GET_TDLS_CTX_PTR(pAdapter); |
Hoonki Lee | 2751190 | 2013-03-14 18:19:06 -0700 | [diff] [blame] | 1562 | eTDLSSupportMode req_tdls_mode; |
Hoonki Lee | bfee034 | 2013-01-21 16:43:45 -0800 | [diff] [blame] | 1563 | |
Hoonki Lee | 2751190 | 2013-03-14 18:19:06 -0700 | [diff] [blame] | 1564 | if (NULL == pHddTdlsCtx) |
| 1565 | { |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 1566 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("TDLS not enabled!")); |
Hoonki Lee | 2751190 | 2013-03-14 18:19:06 -0700 | [diff] [blame] | 1567 | return -1; |
Chilam Ng | 0112041 | 2013-02-19 18:32:21 -0800 | [diff] [blame] | 1568 | } |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 1569 | |
Hoonki Lee | 2751190 | 2013-03-14 18:19:06 -0700 | [diff] [blame] | 1570 | if (wlan_hdd_tdls_check_config(config) != 0) |
| 1571 | { |
| 1572 | return -1; |
| 1573 | } |
| 1574 | |
| 1575 | /* config->tdls is mapped to 0->1, 1->2, 2->3 */ |
| 1576 | req_tdls_mode = config->tdls + 1; |
| 1577 | if (pHddCtx->tdls_mode == req_tdls_mode) |
| 1578 | { |
| 1579 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s already in mode %d", __func__, config->tdls); |
| 1580 | return -1; |
| 1581 | } |
| 1582 | |
| 1583 | /* copy the configuration only when given tdls mode is implicit trigger enable */ |
| 1584 | if (eTDLS_SUPPORT_ENABLED == req_tdls_mode) |
| 1585 | { |
Chilam Ng | 0112041 | 2013-02-19 18:32:21 -0800 | [diff] [blame] | 1586 | memcpy(&pHddTdlsCtx->threshold_config, config, sizeof(tdls_config_params_t)); |
| 1587 | } |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 1588 | |
Chilam Ng | 0112041 | 2013-02-19 18:32:21 -0800 | [diff] [blame] | 1589 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1590 | "iw set tdls params: %d %d %d %d %d %d %d %d %d %d", |
| 1591 | config->tdls, |
| 1592 | config->tx_period_t, |
| 1593 | config->tx_packet_n, |
| 1594 | config->discovery_period_t, |
| 1595 | config->discovery_tries_n, |
| 1596 | config->idle_timeout_t, |
| 1597 | config->idle_packet_n, |
| 1598 | config->rssi_hysteresis, |
| 1599 | config->rssi_trigger_threshold, |
| 1600 | config->rssi_teardown_threshold); |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 1601 | |
Gopichand Nakkala | dcbcf4e | 2013-03-23 14:32:39 -0700 | [diff] [blame] | 1602 | wlan_hdd_tdls_set_mode(pHddCtx, req_tdls_mode, TRUE); |
Chilam Ng | 0112041 | 2013-02-19 18:32:21 -0800 | [diff] [blame] | 1603 | |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 1604 | return 0; |
| 1605 | } |
| 1606 | |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 1607 | 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] | 1608 | { |
Hoonki Lee | 387663d | 2013-02-05 18:08:43 -0800 | [diff] [blame] | 1609 | hddTdlsPeer_t *curr_peer; |
Kiran V | 1ccee93 | 2012-12-12 14:49:46 -0800 | [diff] [blame] | 1610 | |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 1611 | curr_peer = wlan_hdd_tdls_get_peer(pAdapter, mac); |
Hoonki Lee | 387663d | 2013-02-05 18:08:43 -0800 | [diff] [blame] | 1612 | if (curr_peer == NULL) |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 1613 | { |
| 1614 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1615 | "%s: curr_peer is NULL", __func__); |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 1616 | return -1; |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 1617 | } |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 1618 | |
Hoonki Lee | 387663d | 2013-02-05 18:08:43 -0800 | [diff] [blame] | 1619 | curr_peer->staId = staId; |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 1620 | |
| 1621 | return 0; |
Kiran V | 1ccee93 | 2012-12-12 14:49:46 -0800 | [diff] [blame] | 1622 | } |
| 1623 | |
Naresh Jayaram | 937abdf | 2013-11-26 19:50:25 +0530 | [diff] [blame] | 1624 | int wlan_hdd_tdls_set_force_peer(hdd_adapter_t *pAdapter, u8 *mac, |
| 1625 | tANI_BOOLEAN forcePeer) |
Sunil Dutt | 41de4e2 | 2013-11-14 18:09:02 +0530 | [diff] [blame] | 1626 | { |
Naresh Jayaram | 937abdf | 2013-11-26 19:50:25 +0530 | [diff] [blame] | 1627 | hddTdlsPeer_t *curr_peer; |
Sunil Dutt | 41de4e2 | 2013-11-14 18:09:02 +0530 | [diff] [blame] | 1628 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 1629 | |
| 1630 | if ((NULL == pHddCtx)) return -1; |
| 1631 | |
Rajesh Chauhan | a34c6e6 | 2014-03-25 16:37:58 +0530 | [diff] [blame] | 1632 | mutex_lock(&pHddCtx->tdls_lock); |
| 1633 | |
Naresh Jayaram | 937abdf | 2013-11-26 19:50:25 +0530 | [diff] [blame] | 1634 | curr_peer = wlan_hdd_tdls_find_peer(pAdapter, mac, FALSE); |
| 1635 | if (curr_peer == NULL) |
Sunil Dutt | 41de4e2 | 2013-11-14 18:09:02 +0530 | [diff] [blame] | 1636 | goto error; |
Naresh Jayaram | 937abdf | 2013-11-26 19:50:25 +0530 | [diff] [blame] | 1637 | curr_peer->isForcedPeer = forcePeer; |
Naresh Jayaram | ca7bc3a | 2014-02-04 23:03:04 +0530 | [diff] [blame] | 1638 | |
| 1639 | mutex_unlock(&pHddCtx->tdls_lock); |
| 1640 | return 0; |
Sunil Dutt | 41de4e2 | 2013-11-14 18:09:02 +0530 | [diff] [blame] | 1641 | error: |
| 1642 | mutex_unlock(&pHddCtx->tdls_lock); |
| 1643 | return -1; |
| 1644 | } |
| 1645 | |
Hoonki Lee | 387663d | 2013-02-05 18:08:43 -0800 | [diff] [blame] | 1646 | /* if peerMac is found, then it returns pointer to hddTdlsPeer_t |
| 1647 | otherwise, it returns NULL |
| 1648 | */ |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 1649 | hddTdlsPeer_t *wlan_hdd_tdls_find_peer(hdd_adapter_t *pAdapter, u8 *mac, |
| 1650 | tANI_BOOLEAN mutexLock) |
Kiran V | 1ccee93 | 2012-12-12 14:49:46 -0800 | [diff] [blame] | 1651 | { |
Hoonki Lee | 387663d | 2013-02-05 18:08:43 -0800 | [diff] [blame] | 1652 | u8 key; |
| 1653 | struct list_head *pos; |
| 1654 | struct list_head *head; |
| 1655 | hddTdlsPeer_t *curr_peer; |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 1656 | tdlsCtx_t *pHddTdlsCtx; |
Madan Mohan Koyyalamudi | 263cec1 | 2013-10-07 10:57:50 +0530 | [diff] [blame] | 1657 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
Hoonki Lee | 387663d | 2013-02-05 18:08:43 -0800 | [diff] [blame] | 1658 | |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 1659 | if(0 != (wlan_hdd_validate_context(pHddCtx))) |
| 1660 | { |
| 1661 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1662 | FL("pHddCtx is not valid")); |
| 1663 | return 0; |
| 1664 | } |
Hoonki Lee | 387663d | 2013-02-05 18:08:43 -0800 | [diff] [blame] | 1665 | |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 1666 | if ( mutexLock ) |
Hoonki Lee | 387663d | 2013-02-05 18:08:43 -0800 | [diff] [blame] | 1667 | { |
Rajesh Chauhan | a34c6e6 | 2014-03-25 16:37:58 +0530 | [diff] [blame] | 1668 | mutex_lock(&pHddCtx->tdls_lock); |
Hoonki Lee | 387663d | 2013-02-05 18:08:43 -0800 | [diff] [blame] | 1669 | } |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 1670 | pHddTdlsCtx = WLAN_HDD_GET_TDLS_CTX_PTR(pAdapter); |
Gopichand Nakkala | eb69b60 | 2013-02-27 11:40:31 -0800 | [diff] [blame] | 1671 | if (NULL == pHddTdlsCtx) |
| 1672 | { |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 1673 | if ( mutexLock ) |
| 1674 | mutex_unlock(&pHddCtx->tdls_lock); |
Gopichand Nakkala | eb69b60 | 2013-02-27 11:40:31 -0800 | [diff] [blame] | 1675 | return NULL; |
| 1676 | } |
| 1677 | |
| 1678 | key = wlan_hdd_tdls_hash_key(mac); |
| 1679 | |
| 1680 | head = &pHddTdlsCtx->peer_list[key]; |
Hoonki Lee | 387663d | 2013-02-05 18:08:43 -0800 | [diff] [blame] | 1681 | |
| 1682 | list_for_each(pos, head) { |
| 1683 | curr_peer = list_entry (pos, hddTdlsPeer_t, node); |
| 1684 | if (!memcmp(mac, curr_peer->peerMac, 6)) { |
| 1685 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 1686 | "findTdlsPeer: found staId %d", curr_peer->staId); |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 1687 | if ( mutexLock ) |
| 1688 | mutex_unlock(&pHddCtx->tdls_lock); |
Hoonki Lee | 387663d | 2013-02-05 18:08:43 -0800 | [diff] [blame] | 1689 | return curr_peer; |
| 1690 | } |
| 1691 | } |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 1692 | if ( mutexLock ) |
| 1693 | mutex_unlock(&pHddCtx->tdls_lock); |
Hoonki Lee | 387663d | 2013-02-05 18:08:43 -0800 | [diff] [blame] | 1694 | return NULL; |
| 1695 | } |
| 1696 | |
Hoonki Lee | a6d49be | 2013-04-05 09:43:25 -0700 | [diff] [blame] | 1697 | hddTdlsPeer_t *wlan_hdd_tdls_find_all_peer(hdd_context_t *pHddCtx, u8 *mac) |
| 1698 | { |
| 1699 | hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL; |
| 1700 | hdd_adapter_t *pAdapter = NULL; |
| 1701 | tdlsCtx_t *pHddTdlsCtx = NULL; |
| 1702 | hddTdlsPeer_t *curr_peer= NULL; |
| 1703 | VOS_STATUS status = 0; |
| 1704 | |
Rajesh Chauhan | a34c6e6 | 2014-03-25 16:37:58 +0530 | [diff] [blame] | 1705 | mutex_lock(&pHddCtx->tdls_lock); |
Hoonki Lee | a6d49be | 2013-04-05 09:43:25 -0700 | [diff] [blame] | 1706 | status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode ); |
| 1707 | while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status ) |
| 1708 | { |
| 1709 | pAdapter = pAdapterNode->pAdapter; |
| 1710 | |
| 1711 | pHddTdlsCtx = WLAN_HDD_GET_TDLS_CTX_PTR(pAdapter); |
| 1712 | if (NULL != pHddTdlsCtx) |
| 1713 | { |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 1714 | curr_peer = wlan_hdd_tdls_find_peer(pAdapter, mac, FALSE); |
Hoonki Lee | a6d49be | 2013-04-05 09:43:25 -0700 | [diff] [blame] | 1715 | if (curr_peer) |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 1716 | { |
| 1717 | mutex_unlock(&pHddCtx->tdls_lock); |
Hoonki Lee | a6d49be | 2013-04-05 09:43:25 -0700 | [diff] [blame] | 1718 | return curr_peer; |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 1719 | } |
Hoonki Lee | a6d49be | 2013-04-05 09:43:25 -0700 | [diff] [blame] | 1720 | } |
| 1721 | status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 1722 | pAdapterNode = pNext; |
| 1723 | } |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 1724 | mutex_unlock(&pHddCtx->tdls_lock); |
Hoonki Lee | a6d49be | 2013-04-05 09:43:25 -0700 | [diff] [blame] | 1725 | return curr_peer; |
| 1726 | } |
| 1727 | |
| 1728 | |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 1729 | int wlan_hdd_tdls_reset_peer(hdd_adapter_t *pAdapter, u8 *mac) |
Hoonki Lee | 387663d | 2013-02-05 18:08:43 -0800 | [diff] [blame] | 1730 | { |
Chilam Ng | 0112041 | 2013-02-19 18:32:21 -0800 | [diff] [blame] | 1731 | hdd_context_t *pHddCtx; |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 1732 | hddTdlsPeer_t *curr_peer; |
Kiran V | 1ccee93 | 2012-12-12 14:49:46 -0800 | [diff] [blame] | 1733 | |
Chilam Ng | 0112041 | 2013-02-19 18:32:21 -0800 | [diff] [blame] | 1734 | pHddCtx = WLAN_HDD_GET_CTX( pAdapter ); |
| 1735 | |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 1736 | curr_peer = wlan_hdd_tdls_get_peer(pAdapter, mac); |
Hoonki Lee | 387663d | 2013-02-05 18:08:43 -0800 | [diff] [blame] | 1737 | if (curr_peer == NULL) |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 1738 | { |
| 1739 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1740 | "%s: curr_peer is NULL", __func__); |
Hoonki Lee | 387663d | 2013-02-05 18:08:43 -0800 | [diff] [blame] | 1741 | return -1; |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 1742 | } |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 1743 | |
Atul Mittal | 115287b | 2014-07-08 13:26:33 +0530 | [diff] [blame] | 1744 | wlan_hdd_tdls_set_peer_link_status(curr_peer, |
| 1745 | eTDLS_LINK_IDLE, |
| 1746 | eTDLS_LINK_UNSPECIFIED); |
Hoonki Lee | cdd8e96 | 2013-01-20 00:45:46 -0800 | [diff] [blame] | 1747 | curr_peer->staId = 0; |
Hoonki Lee | 387663d | 2013-02-05 18:08:43 -0800 | [diff] [blame] | 1748 | |
Pradeep Reddy POTTETI | edaeb5f | 2014-05-22 23:34:41 +0530 | [diff] [blame] | 1749 | /* Throughput Monitor shall disable the split scan when |
| 1750 | * TDLS scan coexistance is disabled.At this point of time |
| 1751 | * since TDLS scan coexistance is not meeting the criteria |
| 1752 | * to be operational, explicitly make it false to enable |
| 1753 | * throughput monitor takes the control of split scan. |
| 1754 | */ |
| 1755 | if (pHddCtx->isTdlsScanCoexistence == TRUE) |
| 1756 | { |
| 1757 | pHddCtx->isTdlsScanCoexistence = FALSE; |
| 1758 | } |
| 1759 | |
Chilam Ng | 0112041 | 2013-02-19 18:32:21 -0800 | [diff] [blame] | 1760 | if(eTDLS_SUPPORT_ENABLED == pHddCtx->tdls_mode) { |
Chilam Ng | a75d8b6 | 2013-01-29 01:35:59 -0800 | [diff] [blame] | 1761 | vos_timer_stop( &curr_peer->peerIdleTimer ); |
Chilam Ng | a75d8b6 | 2013-01-29 01:35:59 -0800 | [diff] [blame] | 1762 | } |
Hoonki Lee | 387663d | 2013-02-05 18:08:43 -0800 | [diff] [blame] | 1763 | return 0; |
Hoonki Lee | cdd8e96 | 2013-01-20 00:45:46 -0800 | [diff] [blame] | 1764 | } |
| 1765 | |
Gopichand Nakkala | 638ebc7 | 2013-03-21 18:04:02 -0700 | [diff] [blame] | 1766 | /* Caller has to take the lock before calling this function */ |
Hoonki Lee | 2751190 | 2013-03-14 18:19:06 -0700 | [diff] [blame] | 1767 | static void wlan_tdd_tdls_reset_tx_rx(tdlsCtx_t *pHddTdlsCtx) |
| 1768 | { |
| 1769 | int i; |
| 1770 | struct list_head *head; |
| 1771 | hddTdlsPeer_t *tmp; |
| 1772 | struct list_head *pos, *q; |
| 1773 | |
Hoonki Lee | 2751190 | 2013-03-14 18:19:06 -0700 | [diff] [blame] | 1774 | for (i = 0; i < 256; i++) { |
| 1775 | head = &pHddTdlsCtx->peer_list[i]; |
| 1776 | list_for_each_safe (pos, q, head) { |
| 1777 | tmp = list_entry(pos, hddTdlsPeer_t, node); |
| 1778 | tmp->tx_pkt = 0; |
| 1779 | tmp->rx_pkt = 0; |
| 1780 | } |
| 1781 | } |
Hoonki Lee | 2751190 | 2013-03-14 18:19:06 -0700 | [diff] [blame] | 1782 | |
| 1783 | return ; |
| 1784 | } |
| 1785 | |
Gopichand Nakkala | 638ebc7 | 2013-03-21 18:04:02 -0700 | [diff] [blame] | 1786 | /* Caller has to take the lock before calling this function */ |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 1787 | 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] | 1788 | { |
| 1789 | int i; |
| 1790 | struct list_head *head; |
| 1791 | hddTdlsPeer_t *tmp; |
| 1792 | struct list_head *pos, *q; |
| 1793 | |
Gopichand Nakkala | c369458 | 2013-02-13 20:51:22 -0800 | [diff] [blame] | 1794 | pHddTdlsCtx->discovery_peer_cnt = 0; |
| 1795 | |
| 1796 | for (i = 0; i < 256; i++) { |
| 1797 | head = &pHddTdlsCtx->peer_list[i]; |
| 1798 | list_for_each_safe (pos, q, head) { |
| 1799 | tmp = list_entry(pos, hddTdlsPeer_t, node); |
| 1800 | tmp->discovery_processed = 0; |
| 1801 | } |
| 1802 | } |
Gopichand Nakkala | c369458 | 2013-02-13 20:51:22 -0800 | [diff] [blame] | 1803 | |
| 1804 | return 0; |
| 1805 | } |
| 1806 | |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 1807 | 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] | 1808 | { |
| 1809 | int i; |
| 1810 | struct list_head *head; |
| 1811 | struct list_head *pos, *q; |
| 1812 | int discovery_peer_cnt=0; |
| 1813 | hddTdlsPeer_t *tmp; |
| 1814 | |
Gopichand Nakkala | eb69b60 | 2013-02-27 11:40:31 -0800 | [diff] [blame] | 1815 | /* |
| 1816 | * This function expects the callers to acquire the Mutex. |
| 1817 | */ |
Gopichand Nakkala | c369458 | 2013-02-13 20:51:22 -0800 | [diff] [blame] | 1818 | |
| 1819 | for (i = 0; i < 256; i++) { |
| 1820 | head = &pHddTdlsCtx->peer_list[i]; |
| 1821 | list_for_each_safe (pos, q, head) { |
| 1822 | tmp = list_entry(pos, hddTdlsPeer_t, node); |
| 1823 | VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
Chilam Ng | 0112041 | 2013-02-19 18:32:21 -0800 | [diff] [blame] | 1824 | "%s, %d, " MAC_ADDRESS_STR, __func__, i, |
| 1825 | MAC_ADDR_ARRAY(tmp->peerMac)); |
Gopichand Nakkala | c369458 | 2013-02-13 20:51:22 -0800 | [diff] [blame] | 1826 | discovery_peer_cnt++; |
| 1827 | } |
| 1828 | } |
Gopichand Nakkala | c369458 | 2013-02-13 20:51:22 -0800 | [diff] [blame] | 1829 | return discovery_peer_cnt; |
| 1830 | } |
| 1831 | |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 1832 | tANI_U16 wlan_hdd_tdlsConnectedPeers(hdd_adapter_t *pAdapter) |
Lee Hoonki | c1262f2 | 2013-01-24 21:59:00 -0800 | [diff] [blame] | 1833 | { |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 1834 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 1835 | |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 1836 | if(0 != (wlan_hdd_validate_context(pHddCtx))) |
| 1837 | { |
| 1838 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1839 | FL("pHddCtx is not valid")); |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 1840 | return 0; |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 1841 | } |
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 | return pHddCtx->connected_peer_count; |
Lee Hoonki | c1262f2 | 2013-01-24 21:59:00 -0800 | [diff] [blame] | 1844 | } |
Chilam Ng | 16a2a1c | 2013-01-29 01:27:29 -0800 | [diff] [blame] | 1845 | |
Pradeep Reddy POTTETI | edaeb5f | 2014-05-22 23:34:41 +0530 | [diff] [blame] | 1846 | hddTdlsPeer_t *wlan_hdd_tdls_get_first_connected_peer(hdd_adapter_t *pAdapter) |
| 1847 | { |
| 1848 | int i; |
| 1849 | struct list_head *head; |
| 1850 | struct list_head *pos; |
| 1851 | hddTdlsPeer_t *curr_peer = NULL; |
| 1852 | tdlsCtx_t *pHddTdlsCtx; |
| 1853 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 1854 | |
| 1855 | if(0 != (wlan_hdd_validate_context(pHddCtx))) |
| 1856 | { |
| 1857 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1858 | FL("pHddCtx is not valid")); |
| 1859 | return NULL; |
| 1860 | } |
| 1861 | |
| 1862 | mutex_lock(&pHddCtx->tdls_lock); |
| 1863 | pHddTdlsCtx = WLAN_HDD_GET_TDLS_CTX_PTR(pAdapter); |
| 1864 | if (NULL == pHddTdlsCtx) { |
| 1865 | mutex_unlock(&pHddCtx->tdls_lock); |
| 1866 | return NULL; |
| 1867 | } |
| 1868 | for (i = 0; i < 256; i++) { |
| 1869 | head = &pHddTdlsCtx->peer_list[i]; |
| 1870 | |
| 1871 | list_for_each(pos, head) { |
| 1872 | curr_peer= list_entry (pos, hddTdlsPeer_t, node); |
Pradeep Reddy POTTETI | 8a62313 | 2014-06-26 16:07:06 +0530 | [diff] [blame] | 1873 | if (curr_peer && (curr_peer->link_status == eTDLS_LINK_CONNECTED)) |
Pradeep Reddy POTTETI | edaeb5f | 2014-05-22 23:34:41 +0530 | [diff] [blame] | 1874 | { |
| 1875 | mutex_unlock(&pHddCtx->tdls_lock); |
Pradeep Reddy POTTETI | 8a62313 | 2014-06-26 16:07:06 +0530 | [diff] [blame] | 1876 | VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
| 1877 | "%s: " MAC_ADDRESS_STR " eTDLS_LINK_CONNECTED", |
| 1878 | __func__, MAC_ADDR_ARRAY(curr_peer->peerMac)); |
Pradeep Reddy POTTETI | edaeb5f | 2014-05-22 23:34:41 +0530 | [diff] [blame] | 1879 | return curr_peer; |
| 1880 | } |
| 1881 | } |
| 1882 | } |
| 1883 | mutex_unlock(&pHddCtx->tdls_lock); |
| 1884 | return NULL; |
| 1885 | } |
| 1886 | |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 1887 | 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] | 1888 | { |
| 1889 | int i; |
| 1890 | int len, init_len; |
Hoonki Lee | 387663d | 2013-02-05 18:08:43 -0800 | [diff] [blame] | 1891 | struct list_head *head; |
| 1892 | struct list_head *pos; |
Chilam Ng | 16a2a1c | 2013-01-29 01:27:29 -0800 | [diff] [blame] | 1893 | hddTdlsPeer_t *curr_peer; |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 1894 | tdlsCtx_t *pHddTdlsCtx; |
Madan Mohan Koyyalamudi | 263cec1 | 2013-10-07 10:57:50 +0530 | [diff] [blame] | 1895 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 1896 | |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 1897 | if(0 != (wlan_hdd_validate_context(pHddCtx))) |
| 1898 | { |
| 1899 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1900 | FL("pHddCtx is not valid")); |
| 1901 | return 0; |
Madan Mohan Koyyalamudi | 263cec1 | 2013-10-07 10:57:50 +0530 | [diff] [blame] | 1902 | } |
Chilam Ng | 16a2a1c | 2013-01-29 01:27:29 -0800 | [diff] [blame] | 1903 | |
Chilam Ng | 16a2a1c | 2013-01-29 01:27:29 -0800 | [diff] [blame] | 1904 | init_len = buflen; |
Sameer Thalappil | b0a3023 | 2013-09-27 15:37:48 -0700 | [diff] [blame] | 1905 | len = scnprintf(buf, buflen, "\n%-18s%-3s%-4s%-3s%-5s\n", |
| 1906 | "MAC", "Id", "cap", "up", "RSSI"); |
Chilam Ng | 16a2a1c | 2013-01-29 01:27:29 -0800 | [diff] [blame] | 1907 | buf += len; |
| 1908 | buflen -= len; |
| 1909 | /* 1234567890123456789012345678901234567 */ |
Sameer Thalappil | b0a3023 | 2013-09-27 15:37:48 -0700 | [diff] [blame] | 1910 | len = scnprintf(buf, buflen, "---------------------------------\n"); |
Chilam Ng | 16a2a1c | 2013-01-29 01:27:29 -0800 | [diff] [blame] | 1911 | buf += len; |
| 1912 | buflen -= len; |
| 1913 | |
Rajesh Chauhan | a34c6e6 | 2014-03-25 16:37:58 +0530 | [diff] [blame] | 1914 | mutex_lock(&pHddCtx->tdls_lock); |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 1915 | pHddTdlsCtx = WLAN_HDD_GET_TDLS_CTX_PTR(pAdapter); |
Gopichand Nakkala | eb69b60 | 2013-02-27 11:40:31 -0800 | [diff] [blame] | 1916 | if (NULL == pHddTdlsCtx) { |
Madan Mohan Koyyalamudi | 263cec1 | 2013-10-07 10:57:50 +0530 | [diff] [blame] | 1917 | mutex_unlock(&pHddCtx->tdls_lock); |
Sameer Thalappil | b0a3023 | 2013-09-27 15:37:48 -0700 | [diff] [blame] | 1918 | len = scnprintf(buf, buflen, "TDLS not enabled\n"); |
Gopichand Nakkala | eb69b60 | 2013-02-27 11:40:31 -0800 | [diff] [blame] | 1919 | return len; |
| 1920 | } |
Chilam Ng | 16a2a1c | 2013-01-29 01:27:29 -0800 | [diff] [blame] | 1921 | for (i = 0; i < 256; i++) { |
Hoonki Lee | 387663d | 2013-02-05 18:08:43 -0800 | [diff] [blame] | 1922 | head = &pHddTdlsCtx->peer_list[i]; |
Chilam Ng | 16a2a1c | 2013-01-29 01:27:29 -0800 | [diff] [blame] | 1923 | |
Hoonki Lee | 387663d | 2013-02-05 18:08:43 -0800 | [diff] [blame] | 1924 | list_for_each(pos, head) { |
| 1925 | curr_peer= list_entry (pos, hddTdlsPeer_t, node); |
Chilam Ng | 16a2a1c | 2013-01-29 01:27:29 -0800 | [diff] [blame] | 1926 | |
Hoonki Lee | 387663d | 2013-02-05 18:08:43 -0800 | [diff] [blame] | 1927 | if (buflen < 32+1) |
| 1928 | break; |
Sameer Thalappil | b0a3023 | 2013-09-27 15:37:48 -0700 | [diff] [blame] | 1929 | len = scnprintf(buf, buflen, |
Chilam Ng | 0112041 | 2013-02-19 18:32:21 -0800 | [diff] [blame] | 1930 | MAC_ADDRESS_STR"%3d%4s%3s%5d\n", |
| 1931 | MAC_ADDR_ARRAY(curr_peer->peerMac), |
Hoonki Lee | 387663d | 2013-02-05 18:08:43 -0800 | [diff] [blame] | 1932 | curr_peer->staId, |
| 1933 | (curr_peer->tdls_support == eTDLS_CAP_SUPPORTED) ? "Y":"N", |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 1934 | TDLS_IS_CONNECTED(curr_peer) ? "Y":"N", |
Hoonki Lee | 387663d | 2013-02-05 18:08:43 -0800 | [diff] [blame] | 1935 | curr_peer->rssi); |
| 1936 | buf += len; |
| 1937 | buflen -= len; |
Chilam Ng | 16a2a1c | 2013-01-29 01:27:29 -0800 | [diff] [blame] | 1938 | } |
| 1939 | } |
Madan Mohan Koyyalamudi | 263cec1 | 2013-10-07 10:57:50 +0530 | [diff] [blame] | 1940 | mutex_unlock(&pHddCtx->tdls_lock); |
Chilam Ng | 16a2a1c | 2013-01-29 01:27:29 -0800 | [diff] [blame] | 1941 | return init_len-buflen; |
| 1942 | } |
Gopichand Nakkala | c369458 | 2013-02-13 20:51:22 -0800 | [diff] [blame] | 1943 | |
| 1944 | void wlan_hdd_tdls_connection_callback(hdd_adapter_t *pAdapter) |
| 1945 | { |
Mahesh A Saptasagar | 36cdc80 | 2015-01-07 18:41:17 +0530 | [diff] [blame] | 1946 | tdlsCtx_t *pHddTdlsCtx; |
Madan Mohan Koyyalamudi | 263cec1 | 2013-10-07 10:57:50 +0530 | [diff] [blame] | 1947 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
Gopichand Nakkala | 9d76a9b | 2013-02-28 15:38:37 -0800 | [diff] [blame] | 1948 | |
Mahesh A Saptasagar | 36cdc80 | 2015-01-07 18:41:17 +0530 | [diff] [blame] | 1949 | if ((NULL == pHddCtx)) |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 1950 | { |
Agarwal Ashish | bf98caf | 2014-03-25 13:29:11 +0530 | [diff] [blame] | 1951 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, |
| 1952 | FL("pHddCtx or pHddTdlsCtx points to NULL")); |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 1953 | return; |
| 1954 | } |
Madan Mohan Koyyalamudi | 263cec1 | 2013-10-07 10:57:50 +0530 | [diff] [blame] | 1955 | |
Rajesh Chauhan | a34c6e6 | 2014-03-25 16:37:58 +0530 | [diff] [blame] | 1956 | mutex_lock(&pHddCtx->tdls_lock); |
Gopichand Nakkala | 638ebc7 | 2013-03-21 18:04:02 -0700 | [diff] [blame] | 1957 | |
Mahesh A Saptasagar | 36cdc80 | 2015-01-07 18:41:17 +0530 | [diff] [blame] | 1958 | if (0 != wlan_hdd_sta_tdls_init(pAdapter)) |
| 1959 | { |
| 1960 | hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wlan_hdd_sta_tdls_init failed",__func__); |
| 1961 | mutex_unlock(&pHddCtx->tdls_lock); |
| 1962 | return; |
| 1963 | } |
| 1964 | set_bit(TDLS_INIT_DONE, &pAdapter->event_flags); |
| 1965 | |
| 1966 | pHddTdlsCtx = WLAN_HDD_GET_TDLS_CTX_PTR(pAdapter); |
| 1967 | if ((NULL == pHddTdlsCtx)) |
| 1968 | { |
| 1969 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, |
| 1970 | FL("pHddCtx or pHddTdlsCtx points to NULL device mode = %d"), pAdapter->device_mode); |
| 1971 | mutex_unlock(&pHddCtx->tdls_lock); |
| 1972 | return; |
| 1973 | } |
Gopichand Nakkala | c369458 | 2013-02-13 20:51:22 -0800 | [diff] [blame] | 1974 | VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
| 1975 | "%s, update %d discover %d", __func__, |
| 1976 | pHddTdlsCtx->threshold_config.tx_period_t, |
| 1977 | pHddTdlsCtx->threshold_config.discovery_period_t); |
| 1978 | |
Gopichand Nakkala | 9d76a9b | 2013-02-28 15:38:37 -0800 | [diff] [blame] | 1979 | if (eTDLS_SUPPORT_ENABLED == pHddCtx->tdls_mode) |
| 1980 | { |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 1981 | wlan_hdd_tdls_peer_reset_discovery_processed(pHddTdlsCtx); |
Gopichand Nakkala | 75e7b28 | 2013-03-15 18:37:13 -0700 | [diff] [blame] | 1982 | pHddTdlsCtx->discovery_sent_cnt = 0; |
Gopichand Nakkala | 34d1b06 | 2013-03-19 15:28:33 -0700 | [diff] [blame] | 1983 | wlan_hdd_tdls_check_power_save_prohibited(pHddTdlsCtx->pAdapter); |
Gopichand Nakkala | c369458 | 2013-02-13 20:51:22 -0800 | [diff] [blame] | 1984 | |
Gopichand Nakkala | 75e7b28 | 2013-03-15 18:37:13 -0700 | [diff] [blame] | 1985 | #ifdef FEATURE_WLAN_TDLS_INTERNAL |
Gopichand Nakkala | 3046fc9 | 2013-03-23 13:56:43 -0700 | [diff] [blame] | 1986 | wlan_hdd_tdls_timer_restart(pHddTdlsCtx->pAdapter, |
| 1987 | &pHddTdlsCtx->peerDiscoverTimer, |
| 1988 | pHddTdlsCtx->threshold_config.discovery_period_t); |
Gopichand Nakkala | 75e7b28 | 2013-03-15 18:37:13 -0700 | [diff] [blame] | 1989 | #endif |
Gopichand Nakkala | 3046fc9 | 2013-03-23 13:56:43 -0700 | [diff] [blame] | 1990 | wlan_hdd_tdls_timer_restart(pHddTdlsCtx->pAdapter, |
| 1991 | &pHddTdlsCtx->peerUpdateTimer, |
| 1992 | pHddTdlsCtx->threshold_config.tx_period_t); |
Gopichand Nakkala | 9d76a9b | 2013-02-28 15:38:37 -0800 | [diff] [blame] | 1993 | } |
Madan Mohan Koyyalamudi | 263cec1 | 2013-10-07 10:57:50 +0530 | [diff] [blame] | 1994 | mutex_unlock(&pHddCtx->tdls_lock); |
Gopichand Nakkala | c369458 | 2013-02-13 20:51:22 -0800 | [diff] [blame] | 1995 | |
| 1996 | } |
| 1997 | |
| 1998 | void wlan_hdd_tdls_disconnection_callback(hdd_adapter_t *pAdapter) |
| 1999 | { |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 2000 | tdlsCtx_t *pHddTdlsCtx = WLAN_HDD_GET_TDLS_CTX_PTR(pAdapter); |
Madan Mohan Koyyalamudi | 263cec1 | 2013-10-07 10:57:50 +0530 | [diff] [blame] | 2001 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 2002 | |
Deepthi Gowri | bfd1713 | 2014-11-14 17:59:04 +0530 | [diff] [blame] | 2003 | if (NULL == pHddCtx) |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 2004 | { |
| 2005 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Deepthi Gowri | bfd1713 | 2014-11-14 17:59:04 +0530 | [diff] [blame] | 2006 | FL(" pHddCtx points to NULL")); |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 2007 | return; |
| 2008 | } |
Gopichand Nakkala | c369458 | 2013-02-13 20:51:22 -0800 | [diff] [blame] | 2009 | |
| 2010 | VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,"%s", __func__); |
| 2011 | |
Rajesh Chauhan | a34c6e6 | 2014-03-25 16:37:58 +0530 | [diff] [blame] | 2012 | mutex_lock(&pHddCtx->tdls_lock); |
Gopichand Nakkala | eb69b60 | 2013-02-27 11:40:31 -0800 | [diff] [blame] | 2013 | if (NULL == pHddTdlsCtx) |
| 2014 | { |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 2015 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2016 | FL("pHddTdlsCtx is NULL")); |
Madan Mohan Koyyalamudi | 263cec1 | 2013-10-07 10:57:50 +0530 | [diff] [blame] | 2017 | mutex_unlock(&pHddCtx->tdls_lock); |
Gopichand Nakkala | eb69b60 | 2013-02-27 11:40:31 -0800 | [diff] [blame] | 2018 | return; |
| 2019 | } |
Masti, Narayanraddi | de96b99 | 2015-01-08 13:00:58 +0530 | [diff] [blame] | 2020 | |
| 2021 | #ifdef WLAN_OPEN_SOURCE |
| 2022 | cancel_work_sync(&pHddTdlsCtx->implicit_setup); |
| 2023 | #endif |
| 2024 | |
Gopichand Nakkala | ccd3a38 | 2013-03-19 13:56:10 -0700 | [diff] [blame] | 2025 | pHddTdlsCtx->discovery_sent_cnt = 0; |
Gopichand Nakkala | 34d1b06 | 2013-03-19 15:28:33 -0700 | [diff] [blame] | 2026 | wlan_hdd_tdls_check_power_save_prohibited(pHddTdlsCtx->pAdapter); |
Gopichand Nakkala | eb69b60 | 2013-02-27 11:40:31 -0800 | [diff] [blame] | 2027 | |
Mahesh A Saptasagar | 36cdc80 | 2015-01-07 18:41:17 +0530 | [diff] [blame] | 2028 | if(test_bit(TDLS_INIT_DONE, &pAdapter->event_flags)) |
| 2029 | { |
| 2030 | wlan_hdd_tdls_exit(pAdapter); |
| 2031 | clear_bit(TDLS_INIT_DONE, &pAdapter->event_flags); |
| 2032 | } |
Gopichand Nakkala | eb69b60 | 2013-02-27 11:40:31 -0800 | [diff] [blame] | 2033 | |
Madan Mohan Koyyalamudi | 263cec1 | 2013-10-07 10:57:50 +0530 | [diff] [blame] | 2034 | mutex_unlock(&pHddCtx->tdls_lock); |
Gopichand Nakkala | c369458 | 2013-02-13 20:51:22 -0800 | [diff] [blame] | 2035 | } |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 2036 | |
| 2037 | void wlan_hdd_tdls_mgmt_completion_callback(hdd_adapter_t *pAdapter, tANI_U32 statusCode) |
| 2038 | { |
| 2039 | pAdapter->mgmtTxCompletionStatus = statusCode; |
| 2040 | VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,"%s: Mgmt TX Completion %d", |
| 2041 | __func__, statusCode); |
| 2042 | complete(&pAdapter->tdls_mgmt_comp); |
| 2043 | } |
| 2044 | |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 2045 | void wlan_hdd_tdls_increment_peer_count(hdd_adapter_t *pAdapter) |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 2046 | { |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 2047 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 2048 | |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 2049 | if(0 != (wlan_hdd_validate_context(pHddCtx))) |
| 2050 | { |
| 2051 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2052 | FL("pHddCtx is not valid")); |
| 2053 | return; |
| 2054 | } |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 2055 | |
Rajesh Chauhan | a34c6e6 | 2014-03-25 16:37:58 +0530 | [diff] [blame] | 2056 | mutex_lock(&pHddCtx->tdls_lock); |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 2057 | |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 2058 | pHddCtx->connected_peer_count++; |
Gopichand Nakkala | 34d1b06 | 2013-03-19 15:28:33 -0700 | [diff] [blame] | 2059 | wlan_hdd_tdls_check_power_save_prohibited(pAdapter); |
Gopichand Nakkala | ccd3a38 | 2013-03-19 13:56:10 -0700 | [diff] [blame] | 2060 | |
| 2061 | VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, "%s: %d", |
| 2062 | __func__, pHddCtx->connected_peer_count); |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 2063 | |
| 2064 | mutex_unlock(&pHddCtx->tdls_lock); |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 2065 | } |
| 2066 | |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 2067 | void wlan_hdd_tdls_decrement_peer_count(hdd_adapter_t *pAdapter) |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 2068 | { |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 2069 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 2070 | |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 2071 | if(0 != (wlan_hdd_validate_context(pHddCtx))) |
| 2072 | { |
| 2073 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2074 | FL("pHddCtx is not valid")); |
| 2075 | return; |
| 2076 | } |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 2077 | |
Rajesh Chauhan | a34c6e6 | 2014-03-25 16:37:58 +0530 | [diff] [blame] | 2078 | mutex_lock(&pHddCtx->tdls_lock); |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 2079 | |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 2080 | if (pHddCtx->connected_peer_count) |
| 2081 | pHddCtx->connected_peer_count--; |
Gopichand Nakkala | 34d1b06 | 2013-03-19 15:28:33 -0700 | [diff] [blame] | 2082 | wlan_hdd_tdls_check_power_save_prohibited(pAdapter); |
Gopichand Nakkala | ccd3a38 | 2013-03-19 13:56:10 -0700 | [diff] [blame] | 2083 | |
| 2084 | VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, "%s: %d", |
| 2085 | __func__, pHddCtx->connected_peer_count); |
| 2086 | |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 2087 | mutex_unlock(&pHddCtx->tdls_lock); |
| 2088 | |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 2089 | } |
| 2090 | |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 2091 | void wlan_hdd_tdls_check_bmps(hdd_adapter_t *pAdapter) |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 2092 | { |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 2093 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
Gopichand Nakkala | 75e7b28 | 2013-03-15 18:37:13 -0700 | [diff] [blame] | 2094 | tdlsCtx_t *pHddTdlsCtx = WLAN_HDD_GET_TDLS_CTX_PTR(pAdapter); |
Hoonki Lee | 1462135 | 2013-04-16 17:51:19 -0700 | [diff] [blame] | 2095 | hddTdlsPeer_t *curr_peer; |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 2096 | |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 2097 | if ((NULL == pHddCtx) || (NULL == pHddTdlsCtx)) |
| 2098 | { |
Sushant Kaushik | 125ae69 | 2014-11-25 17:38:48 +0530 | [diff] [blame] | 2099 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 2100 | FL(" pHddCtx or pHddTdlsCtx points to NULL")); |
| 2101 | return; |
| 2102 | } |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 2103 | |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 2104 | curr_peer = wlan_hdd_tdls_is_progress(pHddCtx, NULL, 0); |
Hoonki Lee | 1462135 | 2013-04-16 17:51:19 -0700 | [diff] [blame] | 2105 | if (NULL != curr_peer) |
| 2106 | { |
| 2107 | VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
| 2108 | "%s: tdls in progress. Dont check for BMPS " MAC_ADDRESS_STR, |
| 2109 | __func__, MAC_ADDR_ARRAY (curr_peer->peerMac)); |
| 2110 | return; |
| 2111 | } |
| 2112 | |
Hoonki Lee | 93e67ff | 2013-03-19 15:49:25 -0700 | [diff] [blame] | 2113 | if ((TDLS_CTX_MAGIC != pHddCtx->tdls_scan_ctxt.magic) && |
| 2114 | (0 == pHddCtx->connected_peer_count) && |
Gopichand Nakkala | 75e7b28 | 2013-03-15 18:37:13 -0700 | [diff] [blame] | 2115 | (0 == pHddTdlsCtx->discovery_sent_cnt)) |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 2116 | { |
Gopichand Nakkala | 75e7b28 | 2013-03-15 18:37:13 -0700 | [diff] [blame] | 2117 | if (FALSE == sme_IsPmcBmps(WLAN_HDD_GET_HAL_CTX(pAdapter))) |
| 2118 | { |
| 2119 | VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
Gopichand Nakkala | ccd3a38 | 2013-03-19 13:56:10 -0700 | [diff] [blame] | 2120 | "%s: No TDLS peer connected/discovery sent. Enable BMPS", |
| 2121 | __func__); |
Gopichand Nakkala | 75e7b28 | 2013-03-15 18:37:13 -0700 | [diff] [blame] | 2122 | hdd_enable_bmps_imps(pHddCtx); |
| 2123 | } |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 2124 | } |
Gopichand Nakkala | 75e7b28 | 2013-03-15 18:37:13 -0700 | [diff] [blame] | 2125 | else |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 2126 | { |
Gopichand Nakkala | 75e7b28 | 2013-03-15 18:37:13 -0700 | [diff] [blame] | 2127 | if (TRUE == sme_IsPmcBmps(WLAN_HDD_GET_HAL_CTX(pAdapter))) |
| 2128 | { |
Gopichand Nakkala | ccd3a38 | 2013-03-19 13:56:10 -0700 | [diff] [blame] | 2129 | VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
| 2130 | "%s: TDLS peer connected. Disable BMPS", __func__); |
Gopichand Nakkala | 75e7b28 | 2013-03-15 18:37:13 -0700 | [diff] [blame] | 2131 | hdd_disable_bmps_imps(pHddCtx, WLAN_HDD_INFRA_STATION); |
| 2132 | } |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 2133 | } |
| 2134 | return; |
| 2135 | } |
| 2136 | |
Gopichand Nakkala | 34d1b06 | 2013-03-19 15:28:33 -0700 | [diff] [blame] | 2137 | u8 wlan_hdd_tdls_is_peer_progress(hdd_adapter_t *pAdapter, u8 *mac) |
| 2138 | { |
| 2139 | hddTdlsPeer_t *curr_peer; |
| 2140 | |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 2141 | curr_peer = wlan_hdd_tdls_find_peer(pAdapter, mac, TRUE); |
Gopichand Nakkala | 34d1b06 | 2013-03-19 15:28:33 -0700 | [diff] [blame] | 2142 | if (curr_peer == NULL) |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 2143 | { |
| 2144 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2145 | "%s: curr_peer is NULL", __func__); |
Gopichand Nakkala | 34d1b06 | 2013-03-19 15:28:33 -0700 | [diff] [blame] | 2146 | return 0; |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 2147 | } |
Gopichand Nakkala | 34d1b06 | 2013-03-19 15:28:33 -0700 | [diff] [blame] | 2148 | |
| 2149 | return (eTDLS_LINK_CONNECTING == curr_peer->link_status); |
| 2150 | } |
| 2151 | |
Hoonki Lee | fb8df67 | 2013-04-10 18:20:34 -0700 | [diff] [blame] | 2152 | /* return pointer to hddTdlsPeer_t if TDLS is ongoing. Otherwise return NULL. |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 2153 | * mac - if NULL check for all the peer list, otherwise, skip this mac when skip_self is TRUE |
| 2154 | * skip_self - if TRUE, skip this mac. otherwise, check all the peer list. if |
| 2155 | mac is NULL, this argument is ignored, and check for all the peer list. |
| 2156 | */ |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 2157 | 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] | 2158 | { |
| 2159 | int i; |
| 2160 | struct list_head *head; |
| 2161 | hddTdlsPeer_t *curr_peer; |
| 2162 | struct list_head *pos; |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 2163 | tdlsCtx_t *pHddTdlsCtx = WLAN_HDD_GET_TDLS_CTX_PTR(pAdapter);; |
Madan Mohan Koyyalamudi | 263cec1 | 2013-10-07 10:57:50 +0530 | [diff] [blame] | 2164 | |
Madan Mohan Koyyalamudi | 263cec1 | 2013-10-07 10:57:50 +0530 | [diff] [blame] | 2165 | if (NULL == pHddTdlsCtx) |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 2166 | { |
| 2167 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2168 | FL("pHddTdlsCtx is NULL")); |
Madan Mohan Koyyalamudi | 263cec1 | 2013-10-07 10:57:50 +0530 | [diff] [blame] | 2169 | return NULL; |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 2170 | } |
Madan Mohan Koyyalamudi | 263cec1 | 2013-10-07 10:57:50 +0530 | [diff] [blame] | 2171 | |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 2172 | for (i = 0; i < 256; i++) { |
| 2173 | head = &pHddTdlsCtx->peer_list[i]; |
| 2174 | list_for_each(pos, head) { |
| 2175 | curr_peer = list_entry (pos, hddTdlsPeer_t, node); |
| 2176 | if (skip_self && mac && !memcmp(mac, curr_peer->peerMac, 6)) { |
| 2177 | continue; |
| 2178 | } |
| 2179 | else |
| 2180 | { |
Gopichand Nakkala | 8b00c63 | 2013-03-08 19:47:52 -0800 | [diff] [blame] | 2181 | if (eTDLS_LINK_CONNECTING == curr_peer->link_status) |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 2182 | { |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 2183 | VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
Gopichand Nakkala | 34d1b06 | 2013-03-19 15:28:33 -0700 | [diff] [blame] | 2184 | "%s:" MAC_ADDRESS_STR " eTDLS_LINK_CONNECTING", |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 2185 | __func__, MAC_ADDR_ARRAY(curr_peer->peerMac)); |
Hoonki Lee | fb8df67 | 2013-04-10 18:20:34 -0700 | [diff] [blame] | 2186 | return curr_peer; |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 2187 | } |
| 2188 | } |
| 2189 | } |
| 2190 | } |
Hoonki Lee | fb8df67 | 2013-04-10 18:20:34 -0700 | [diff] [blame] | 2191 | return NULL; |
| 2192 | } |
| 2193 | |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 2194 | 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] | 2195 | { |
| 2196 | hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL; |
| 2197 | hdd_adapter_t *pAdapter = NULL; |
| 2198 | tdlsCtx_t *pHddTdlsCtx = NULL; |
| 2199 | hddTdlsPeer_t *curr_peer= NULL; |
| 2200 | VOS_STATUS status = 0; |
| 2201 | |
Rajesh Chauhan | a34c6e6 | 2014-03-25 16:37:58 +0530 | [diff] [blame] | 2202 | mutex_lock(&pHddCtx->tdls_lock); |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 2203 | |
Hoonki Lee | fb8df67 | 2013-04-10 18:20:34 -0700 | [diff] [blame] | 2204 | status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode ); |
| 2205 | while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status ) |
| 2206 | { |
| 2207 | pAdapter = pAdapterNode->pAdapter; |
| 2208 | |
| 2209 | pHddTdlsCtx = WLAN_HDD_GET_TDLS_CTX_PTR(pAdapter); |
| 2210 | if (NULL != pHddTdlsCtx) |
| 2211 | { |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 2212 | curr_peer = wlan_hdd_tdls_find_progress_peer(pAdapter, mac, skip_self); |
Hoonki Lee | fb8df67 | 2013-04-10 18:20:34 -0700 | [diff] [blame] | 2213 | if (curr_peer) |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 2214 | { |
| 2215 | mutex_unlock(&pHddCtx->tdls_lock); |
Hoonki Lee | fb8df67 | 2013-04-10 18:20:34 -0700 | [diff] [blame] | 2216 | return curr_peer; |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 2217 | } |
Hoonki Lee | fb8df67 | 2013-04-10 18:20:34 -0700 | [diff] [blame] | 2218 | } |
| 2219 | status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 2220 | pAdapterNode = pNext; |
| 2221 | } |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 2222 | mutex_unlock(&pHddCtx->tdls_lock); |
Hoonki Lee | fb8df67 | 2013-04-10 18:20:34 -0700 | [diff] [blame] | 2223 | return NULL; |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 2224 | } |
Hoonki Lee | 2751190 | 2013-03-14 18:19:06 -0700 | [diff] [blame] | 2225 | |
| 2226 | static void wlan_hdd_tdls_implicit_disable(tdlsCtx_t *pHddTdlsCtx) |
| 2227 | { |
Hoonki Lee | 2751190 | 2013-03-14 18:19:06 -0700 | [diff] [blame] | 2228 | wlan_hdd_tdls_timers_stop(pHddTdlsCtx); |
Hoonki Lee | 2751190 | 2013-03-14 18:19:06 -0700 | [diff] [blame] | 2229 | } |
| 2230 | |
| 2231 | static void wlan_hdd_tdls_implicit_enable(tdlsCtx_t *pHddTdlsCtx) |
| 2232 | { |
| 2233 | wlan_hdd_tdls_peer_reset_discovery_processed(pHddTdlsCtx); |
Gopichand Nakkala | 75e7b28 | 2013-03-15 18:37:13 -0700 | [diff] [blame] | 2234 | pHddTdlsCtx->discovery_sent_cnt = 0; |
Hoonki Lee | 2751190 | 2013-03-14 18:19:06 -0700 | [diff] [blame] | 2235 | wlan_tdd_tdls_reset_tx_rx(pHddTdlsCtx); |
Gopichand Nakkala | 34d1b06 | 2013-03-19 15:28:33 -0700 | [diff] [blame] | 2236 | wlan_hdd_tdls_check_power_save_prohibited(pHddTdlsCtx->pAdapter); |
Gopichand Nakkala | ccd3a38 | 2013-03-19 13:56:10 -0700 | [diff] [blame] | 2237 | |
Hoonki Lee | 2751190 | 2013-03-14 18:19:06 -0700 | [diff] [blame] | 2238 | |
Gopichand Nakkala | 75e7b28 | 2013-03-15 18:37:13 -0700 | [diff] [blame] | 2239 | #ifdef FEATURE_WLAN_TDLS_INTERNAL |
Gopichand Nakkala | 3046fc9 | 2013-03-23 13:56:43 -0700 | [diff] [blame] | 2240 | wlan_hdd_tdls_timer_restart(pHddTdlsCtx->pAdapter, |
| 2241 | &pHddTdlsCtx->peerDiscoverTimer, |
| 2242 | pHddTdlsCtx->threshold_config.discovery_period_t); |
Gopichand Nakkala | 75e7b28 | 2013-03-15 18:37:13 -0700 | [diff] [blame] | 2243 | #endif |
Gopichand Nakkala | 3046fc9 | 2013-03-23 13:56:43 -0700 | [diff] [blame] | 2244 | wlan_hdd_tdls_timer_restart(pHddTdlsCtx->pAdapter, |
| 2245 | &pHddTdlsCtx->peerUpdateTimer, |
| 2246 | pHddTdlsCtx->threshold_config.tx_period_t); |
Hoonki Lee | 2751190 | 2013-03-14 18:19:06 -0700 | [diff] [blame] | 2247 | } |
| 2248 | |
Gopichand Nakkala | dcbcf4e | 2013-03-23 14:32:39 -0700 | [diff] [blame] | 2249 | void wlan_hdd_tdls_set_mode(hdd_context_t *pHddCtx, |
| 2250 | eTDLSSupportMode tdls_mode, |
| 2251 | v_BOOL_t bUpdateLast) |
Hoonki Lee | 2751190 | 2013-03-14 18:19:06 -0700 | [diff] [blame] | 2252 | { |
| 2253 | hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL; |
| 2254 | VOS_STATUS status; |
| 2255 | hdd_adapter_t *pAdapter; |
| 2256 | tdlsCtx_t *pHddTdlsCtx; |
| 2257 | |
| 2258 | 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] | 2259 | |
| 2260 | if(0 != (wlan_hdd_validate_context(pHddCtx))) |
| 2261 | { |
| 2262 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2263 | FL("pHddCtx is not valid")); |
Madan Mohan Koyyalamudi | 263cec1 | 2013-10-07 10:57:50 +0530 | [diff] [blame] | 2264 | return; |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 2265 | } |
Hoonki Lee | 2751190 | 2013-03-14 18:19:06 -0700 | [diff] [blame] | 2266 | |
Rajesh Chauhan | a34c6e6 | 2014-03-25 16:37:58 +0530 | [diff] [blame] | 2267 | mutex_lock(&pHddCtx->tdls_lock); |
Gopichand Nakkala | 638ebc7 | 2013-03-21 18:04:02 -0700 | [diff] [blame] | 2268 | |
Hoonki Lee | 93e67ff | 2013-03-19 15:49:25 -0700 | [diff] [blame] | 2269 | if (pHddCtx->tdls_mode == tdls_mode) |
| 2270 | { |
Gopichand Nakkala | 4ddf019 | 2013-03-27 13:41:20 -0700 | [diff] [blame] | 2271 | 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] | 2272 | mutex_unlock(&pHddCtx->tdls_lock); |
Hoonki Lee | 93e67ff | 2013-03-19 15:49:25 -0700 | [diff] [blame] | 2273 | return; |
| 2274 | } |
| 2275 | |
Hoonki Lee | 2751190 | 2013-03-14 18:19:06 -0700 | [diff] [blame] | 2276 | status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode ); |
| 2277 | |
| 2278 | while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status ) |
| 2279 | { |
| 2280 | pAdapter = pAdapterNode->pAdapter; |
Hoonki Lee | a6d49be | 2013-04-05 09:43:25 -0700 | [diff] [blame] | 2281 | pHddTdlsCtx = WLAN_HDD_GET_TDLS_CTX_PTR(pAdapter); |
| 2282 | if (NULL != pHddTdlsCtx) |
Hoonki Lee | 2751190 | 2013-03-14 18:19:06 -0700 | [diff] [blame] | 2283 | { |
Hoonki Lee | a6d49be | 2013-04-05 09:43:25 -0700 | [diff] [blame] | 2284 | if(eTDLS_SUPPORT_ENABLED == tdls_mode) |
| 2285 | wlan_hdd_tdls_implicit_enable(pHddTdlsCtx); |
| 2286 | else if((eTDLS_SUPPORT_DISABLED == tdls_mode) || |
| 2287 | (eTDLS_SUPPORT_EXPLICIT_TRIGGER_ONLY == tdls_mode)) |
| 2288 | wlan_hdd_tdls_implicit_disable(pHddTdlsCtx); |
Hoonki Lee | 2751190 | 2013-03-14 18:19:06 -0700 | [diff] [blame] | 2289 | } |
| 2290 | status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 2291 | pAdapterNode = pNext; |
| 2292 | } |
Gopichand Nakkala | dcbcf4e | 2013-03-23 14:32:39 -0700 | [diff] [blame] | 2293 | if(bUpdateLast) |
| 2294 | { |
| 2295 | pHddCtx->tdls_mode_last = tdls_mode; |
| 2296 | } |
| 2297 | else |
| 2298 | { |
| 2299 | pHddCtx->tdls_mode_last = pHddCtx->tdls_mode; |
| 2300 | } |
Hoonki Lee | 2751190 | 2013-03-14 18:19:06 -0700 | [diff] [blame] | 2301 | pHddCtx->tdls_mode = tdls_mode; |
Gopichand Nakkala | dcbcf4e | 2013-03-23 14:32:39 -0700 | [diff] [blame] | 2302 | |
Madan Mohan Koyyalamudi | 263cec1 | 2013-10-07 10:57:50 +0530 | [diff] [blame] | 2303 | mutex_unlock(&pHddCtx->tdls_lock); |
Hoonki Lee | 2751190 | 2013-03-14 18:19:06 -0700 | [diff] [blame] | 2304 | } |
Gopichand Nakkala | 75e7b28 | 2013-03-15 18:37:13 -0700 | [diff] [blame] | 2305 | |
Mahesh A Saptasagar | 8b231b3 | 2014-08-11 11:58:15 +0530 | [diff] [blame] | 2306 | static void __wlan_hdd_tdls_pre_setup(struct work_struct *work) |
Gopichand Nakkala | 75e7b28 | 2013-03-15 18:37:13 -0700 | [diff] [blame] | 2307 | { |
Hoonki Lee | d37cbb3 | 2013-04-20 00:31:14 -0700 | [diff] [blame] | 2308 | tdlsCtx_t *pHddTdlsCtx = |
| 2309 | container_of(work, tdlsCtx_t, implicit_setup); |
| 2310 | hdd_context_t *pHddCtx; |
| 2311 | hddTdlsPeer_t *curr_peer; |
Hoonki Lee | fb8df67 | 2013-04-10 18:20:34 -0700 | [diff] [blame] | 2312 | hddTdlsPeer_t *temp_peer; |
Hoonki Lee | d37cbb3 | 2013-04-20 00:31:14 -0700 | [diff] [blame] | 2313 | int status; |
| 2314 | |
| 2315 | if (NULL == pHddTdlsCtx) |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 2316 | { |
| 2317 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2318 | FL("pHddTdlsCtx is NULL")); |
Hoonki Lee | d37cbb3 | 2013-04-20 00:31:14 -0700 | [diff] [blame] | 2319 | return; |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 2320 | } |
Hoonki Lee | d37cbb3 | 2013-04-20 00:31:14 -0700 | [diff] [blame] | 2321 | |
| 2322 | if (unlikely(TDLS_CTX_MAGIC != pHddTdlsCtx->magic)) |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 2323 | { |
| 2324 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2325 | "%s: tdls magic no missmatch %u", __func__, pHddTdlsCtx->magic); |
Hoonki Lee | d37cbb3 | 2013-04-20 00:31:14 -0700 | [diff] [blame] | 2326 | return; |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 2327 | } |
Hoonki Lee | d37cbb3 | 2013-04-20 00:31:14 -0700 | [diff] [blame] | 2328 | |
| 2329 | pHddCtx = WLAN_HDD_GET_CTX(pHddTdlsCtx->pAdapter); |
Hoonki Lee | fb8df67 | 2013-04-10 18:20:34 -0700 | [diff] [blame] | 2330 | |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 2331 | if(0 != (wlan_hdd_validate_context(pHddCtx))) |
| 2332 | { |
| 2333 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2334 | FL("pHddCtx is not valid")); |
Hoonki Lee | fb8df67 | 2013-04-10 18:20:34 -0700 | [diff] [blame] | 2335 | return; |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 2336 | } |
Gopichand Nakkala | 75e7b28 | 2013-03-15 18:37:13 -0700 | [diff] [blame] | 2337 | |
Hoonki Lee | d37cbb3 | 2013-04-20 00:31:14 -0700 | [diff] [blame] | 2338 | curr_peer = pHddTdlsCtx->curr_candidate; |
| 2339 | |
| 2340 | if (NULL == curr_peer) |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 2341 | { |
| 2342 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2343 | FL("curr_peer is NULL")); |
| 2344 | |
Hoonki Lee | d37cbb3 | 2013-04-20 00:31:14 -0700 | [diff] [blame] | 2345 | return; |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 2346 | } |
Hoonki Lee | d37cbb3 | 2013-04-20 00:31:14 -0700 | [diff] [blame] | 2347 | |
Gopichand Nakkala | 75e7b28 | 2013-03-15 18:37:13 -0700 | [diff] [blame] | 2348 | if (TRUE == sme_IsPmcBmps(WLAN_HDD_GET_HAL_CTX(pHddTdlsCtx->pAdapter))) |
| 2349 | { |
Gopichand Nakkala | ccd3a38 | 2013-03-19 13:56:10 -0700 | [diff] [blame] | 2350 | 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] | 2351 | hdd_disable_bmps_imps(pHddCtx, WLAN_HDD_INFRA_STATION); |
| 2352 | } |
Gopichand Nakkala | ccd3a38 | 2013-03-19 13:56:10 -0700 | [diff] [blame] | 2353 | |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 2354 | temp_peer = wlan_hdd_tdls_is_progress(pHddCtx, NULL, 0); |
Hoonki Lee | fb8df67 | 2013-04-10 18:20:34 -0700 | [diff] [blame] | 2355 | if (NULL != temp_peer) |
| 2356 | { |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 2357 | 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] | 2358 | __func__, MAC_ADDR_ARRAY(temp_peer->peerMac)); |
Hoonki Lee | d37cbb3 | 2013-04-20 00:31:14 -0700 | [diff] [blame] | 2359 | goto done; |
Hoonki Lee | fb8df67 | 2013-04-10 18:20:34 -0700 | [diff] [blame] | 2360 | } |
| 2361 | |
Gopichand Nakkala | ccd3a38 | 2013-03-19 13:56:10 -0700 | [diff] [blame] | 2362 | if (eTDLS_CAP_UNKNOWN != curr_peer->tdls_support) |
Atul Mittal | 115287b | 2014-07-08 13:26:33 +0530 | [diff] [blame] | 2363 | wlan_hdd_tdls_set_peer_link_status(curr_peer, |
| 2364 | eTDLS_LINK_DISCOVERING, |
| 2365 | eTDLS_LINK_SUCCESS); |
Gopichand Nakkala | ccd3a38 | 2013-03-19 13:56:10 -0700 | [diff] [blame] | 2366 | |
Hoonki Lee | d37cbb3 | 2013-04-20 00:31:14 -0700 | [diff] [blame] | 2367 | status = wlan_hdd_cfg80211_send_tdls_discover_req(pHddTdlsCtx->pAdapter->wdev.wiphy, |
| 2368 | pHddTdlsCtx->pAdapter->dev, |
| 2369 | curr_peer->peerMac); |
| 2370 | |
| 2371 | if (0 != status) |
| 2372 | { |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 2373 | 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] | 2374 | __func__, MAC_ADDR_ARRAY(curr_peer->peerMac)); |
| 2375 | if (eTDLS_CAP_UNKNOWN != curr_peer->tdls_support) |
Atul Mittal | 115287b | 2014-07-08 13:26:33 +0530 | [diff] [blame] | 2376 | wlan_hdd_tdls_set_peer_link_status(curr_peer, |
| 2377 | eTDLS_LINK_IDLE, |
| 2378 | eTDLS_LINK_UNSPECIFIED); |
Hoonki Lee | d37cbb3 | 2013-04-20 00:31:14 -0700 | [diff] [blame] | 2379 | goto done; |
| 2380 | } |
| 2381 | |
Gopichand Nakkala | 75e7b28 | 2013-03-15 18:37:13 -0700 | [diff] [blame] | 2382 | pHddTdlsCtx->discovery_sent_cnt++; |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 2383 | |
Rajesh Chauhan | a34c6e6 | 2014-03-25 16:37:58 +0530 | [diff] [blame] | 2384 | mutex_lock(&pHddCtx->tdls_lock); |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 2385 | |
Gopichand Nakkala | 34d1b06 | 2013-03-19 15:28:33 -0700 | [diff] [blame] | 2386 | wlan_hdd_tdls_check_power_save_prohibited(pHddTdlsCtx->pAdapter); |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 2387 | |
Pradeep Reddy POTTETI | 219ced3 | 2014-11-14 16:33:57 +0530 | [diff] [blame] | 2388 | wlan_hdd_tdls_timer_restart(pHddTdlsCtx->pAdapter, |
| 2389 | &pHddTdlsCtx->peerDiscoveryTimeoutTimer, |
| 2390 | pHddTdlsCtx->threshold_config.tx_period_t - TDLS_DISCOVERY_TIMEOUT_BEFORE_UPDATE); |
| 2391 | |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 2392 | mutex_unlock(&pHddCtx->tdls_lock); |
Jeff Johnson | 0299d0a | 2013-10-30 12:37:43 -0700 | [diff] [blame] | 2393 | 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] | 2394 | __func__, pHddTdlsCtx->discovery_sent_cnt, |
| 2395 | pHddTdlsCtx->threshold_config.tx_period_t - TDLS_DISCOVERY_TIMEOUT_BEFORE_UPDATE); |
Gopichand Nakkala | 3046fc9 | 2013-03-23 13:56:43 -0700 | [diff] [blame] | 2396 | |
Hoonki Lee | d37cbb3 | 2013-04-20 00:31:14 -0700 | [diff] [blame] | 2397 | done: |
| 2398 | pHddTdlsCtx->curr_candidate = NULL; |
| 2399 | pHddTdlsCtx->magic = 0; |
Gopichand Nakkala | 75e7b28 | 2013-03-15 18:37:13 -0700 | [diff] [blame] | 2400 | return; |
| 2401 | } |
Gopichand Nakkala | ccd3a38 | 2013-03-19 13:56:10 -0700 | [diff] [blame] | 2402 | |
Mahesh A Saptasagar | 8b231b3 | 2014-08-11 11:58:15 +0530 | [diff] [blame] | 2403 | |
| 2404 | static void wlan_hdd_tdls_pre_setup(struct work_struct *work) |
| 2405 | { |
| 2406 | vos_ssr_protect(__func__); |
| 2407 | __wlan_hdd_tdls_pre_setup(work); |
| 2408 | vos_ssr_unprotect(__func__); |
| 2409 | |
| 2410 | return; |
| 2411 | } |
| 2412 | |
Gopichand Nakkala | ccd3a38 | 2013-03-19 13:56:10 -0700 | [diff] [blame] | 2413 | tANI_U32 wlan_hdd_tdls_discovery_sent_cnt(hdd_context_t *pHddCtx) |
| 2414 | { |
| 2415 | hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL; |
| 2416 | hdd_adapter_t *pAdapter = NULL; |
| 2417 | tdlsCtx_t *pHddTdlsCtx = NULL; |
| 2418 | VOS_STATUS status = 0; |
| 2419 | tANI_U32 count = 0; |
| 2420 | |
| 2421 | status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode ); |
| 2422 | while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status ) |
| 2423 | { |
| 2424 | pAdapter = pAdapterNode->pAdapter; |
| 2425 | |
Hoonki Lee | a6d49be | 2013-04-05 09:43:25 -0700 | [diff] [blame] | 2426 | pHddTdlsCtx = WLAN_HDD_GET_TDLS_CTX_PTR(pAdapter); |
| 2427 | if (NULL != pHddTdlsCtx) |
Gopichand Nakkala | ccd3a38 | 2013-03-19 13:56:10 -0700 | [diff] [blame] | 2428 | { |
Hoonki Lee | a6d49be | 2013-04-05 09:43:25 -0700 | [diff] [blame] | 2429 | count = count + pHddTdlsCtx->discovery_sent_cnt; |
Gopichand Nakkala | ccd3a38 | 2013-03-19 13:56:10 -0700 | [diff] [blame] | 2430 | } |
| 2431 | status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 2432 | pAdapterNode = pNext; |
| 2433 | } |
| 2434 | return count; |
| 2435 | } |
| 2436 | |
Gopichand Nakkala | 34d1b06 | 2013-03-19 15:28:33 -0700 | [diff] [blame] | 2437 | void wlan_hdd_tdls_check_power_save_prohibited(hdd_adapter_t *pAdapter) |
Gopichand Nakkala | ccd3a38 | 2013-03-19 13:56:10 -0700 | [diff] [blame] | 2438 | { |
| 2439 | tdlsCtx_t *pHddTdlsCtx = WLAN_HDD_GET_TDLS_CTX_PTR(pAdapter); |
| 2440 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 2441 | |
| 2442 | if ((NULL == pHddTdlsCtx) || (NULL == pHddCtx)) |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 2443 | { |
| 2444 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2445 | FL(" pHddCtx or pHddTdlsCtx points to NULL")); |
Gopichand Nakkala | ccd3a38 | 2013-03-19 13:56:10 -0700 | [diff] [blame] | 2446 | return; |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 2447 | } |
Gopichand Nakkala | ccd3a38 | 2013-03-19 13:56:10 -0700 | [diff] [blame] | 2448 | |
| 2449 | if ((0 == pHddCtx->connected_peer_count) && |
| 2450 | (0 == wlan_hdd_tdls_discovery_sent_cnt(pHddCtx))) |
| 2451 | { |
| 2452 | sme_SetTdlsPowerSaveProhibited(WLAN_HDD_GET_HAL_CTX(pHddTdlsCtx->pAdapter), 0); |
| 2453 | return; |
| 2454 | } |
| 2455 | sme_SetTdlsPowerSaveProhibited(WLAN_HDD_GET_HAL_CTX(pHddTdlsCtx->pAdapter), 1); |
| 2456 | return; |
| 2457 | } |
Hoonki Lee | 93e67ff | 2013-03-19 15:49:25 -0700 | [diff] [blame] | 2458 | |
| 2459 | void wlan_hdd_tdls_free_scan_request (tdls_scan_context_t *tdls_scan_ctx) |
| 2460 | { |
| 2461 | if (NULL == tdls_scan_ctx) |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 2462 | { |
| 2463 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2464 | FL("tdls_scan_ctx is NULL")); |
Hoonki Lee | 93e67ff | 2013-03-19 15:49:25 -0700 | [diff] [blame] | 2465 | return; |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 2466 | } |
Hoonki Lee | 93e67ff | 2013-03-19 15:49:25 -0700 | [diff] [blame] | 2467 | |
Gopichand Nakkala | 3046fc9 | 2013-03-23 13:56:43 -0700 | [diff] [blame] | 2468 | tdls_scan_ctx->attempt = 0; |
Hoonki Lee | fb8df67 | 2013-04-10 18:20:34 -0700 | [diff] [blame] | 2469 | tdls_scan_ctx->reject = 0; |
Gopichand Nakkala | 3046fc9 | 2013-03-23 13:56:43 -0700 | [diff] [blame] | 2470 | tdls_scan_ctx->magic = 0; |
Hoonki Lee | 93e67ff | 2013-03-19 15:49:25 -0700 | [diff] [blame] | 2471 | tdls_scan_ctx->scan_request = NULL; |
| 2472 | return; |
| 2473 | } |
| 2474 | |
| 2475 | int wlan_hdd_tdls_copy_scan_context(hdd_context_t *pHddCtx, |
| 2476 | struct wiphy *wiphy, |
| 2477 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0)) |
| 2478 | struct net_device *dev, |
| 2479 | #endif |
| 2480 | struct cfg80211_scan_request *request) |
| 2481 | { |
| 2482 | tdls_scan_context_t *scan_ctx; |
| 2483 | |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 2484 | if(0 != (wlan_hdd_validate_context(pHddCtx))) |
| 2485 | { |
| 2486 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2487 | FL("pHddCtx is not valid")); |
| 2488 | return 0; |
| 2489 | } |
Hoonki Lee | 93e67ff | 2013-03-19 15:49:25 -0700 | [diff] [blame] | 2490 | |
| 2491 | scan_ctx = &pHddCtx->tdls_scan_ctxt; |
| 2492 | |
| 2493 | scan_ctx->wiphy = wiphy; |
| 2494 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0)) |
| 2495 | scan_ctx->dev = dev; |
| 2496 | #endif |
| 2497 | |
| 2498 | scan_ctx->scan_request = request; |
| 2499 | return 0; |
| 2500 | } |
| 2501 | |
Hoonki Lee | 93e67ff | 2013-03-19 15:49:25 -0700 | [diff] [blame] | 2502 | static void wlan_hdd_tdls_scan_init_work(hdd_context_t *pHddCtx, |
| 2503 | struct wiphy *wiphy, |
| 2504 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0)) |
| 2505 | struct net_device *dev, |
| 2506 | #endif |
| 2507 | struct cfg80211_scan_request *request, |
| 2508 | unsigned long delay) |
| 2509 | { |
| 2510 | if (TDLS_CTX_MAGIC != pHddCtx->tdls_scan_ctxt.magic) |
| 2511 | { |
| 2512 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0)) |
| 2513 | wlan_hdd_tdls_copy_scan_context(pHddCtx, wiphy, dev, request); |
| 2514 | #else |
| 2515 | wlan_hdd_tdls_copy_scan_context(pHddCtx, wiphy, request); |
| 2516 | #endif |
| 2517 | pHddCtx->tdls_scan_ctxt.attempt = 0; |
| 2518 | pHddCtx->tdls_scan_ctxt.magic = TDLS_CTX_MAGIC; |
| 2519 | } |
Hoonki Lee | 93e67ff | 2013-03-19 15:49:25 -0700 | [diff] [blame] | 2520 | schedule_delayed_work(&pHddCtx->tdls_scan_ctxt.tdls_scan_work, delay); |
| 2521 | } |
| 2522 | |
| 2523 | /* return negative = caller should stop and return error code immediately |
| 2524 | return 0 = caller should stop and return success immediately |
| 2525 | return 1 = caller can continue to scan |
| 2526 | */ |
| 2527 | int wlan_hdd_tdls_scan_callback (hdd_adapter_t *pAdapter, |
| 2528 | struct wiphy *wiphy, |
| 2529 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0)) |
| 2530 | struct net_device *dev, |
| 2531 | #endif |
| 2532 | struct cfg80211_scan_request *request) |
| 2533 | { |
Hoonki Lee | 93e67ff | 2013-03-19 15:49:25 -0700 | [diff] [blame] | 2534 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 2535 | u16 connectedTdlsPeers; |
Pradeep Reddy POTTETI | edaeb5f | 2014-05-22 23:34:41 +0530 | [diff] [blame] | 2536 | hddTdlsPeer_t *curr_peer, *connected_peer; |
Hoonki Lee | 93e67ff | 2013-03-19 15:49:25 -0700 | [diff] [blame] | 2537 | unsigned long delay; |
Pradeep Reddy POTTETI | edaeb5f | 2014-05-22 23:34:41 +0530 | [diff] [blame] | 2538 | hdd_config_t *cfg_param = pHddCtx->cfg_ini; |
Hoonki Lee | 93e67ff | 2013-03-19 15:49:25 -0700 | [diff] [blame] | 2539 | |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 2540 | if(0 != (wlan_hdd_validate_context(pHddCtx))) |
| 2541 | { |
| 2542 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2543 | FL("pHddCtx is not valid")); |
Hoonki Lee | 93e67ff | 2013-03-19 15:49:25 -0700 | [diff] [blame] | 2544 | return 0; |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 2545 | } |
Hoonki Lee | 93e67ff | 2013-03-19 15:49:25 -0700 | [diff] [blame] | 2546 | |
| 2547 | /* if tdls is not enabled, then continue scan */ |
Pradeep Reddy POTTETI | f0569d7 | 2014-12-13 16:54:03 +0530 | [diff] [blame] | 2548 | if ((eTDLS_SUPPORT_NOT_ENABLED == pHddCtx->tdls_mode) || |
| 2549 | (pHddCtx->is_tdls_btc_enabled == FALSE)) |
Hoonki Lee | 93e67ff | 2013-03-19 15:49:25 -0700 | [diff] [blame] | 2550 | return 1; |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 2551 | curr_peer = wlan_hdd_tdls_is_progress(pHddCtx, NULL, 0); |
Hoonki Lee | fb8df67 | 2013-04-10 18:20:34 -0700 | [diff] [blame] | 2552 | if (NULL != curr_peer) |
Hoonki Lee | 93e67ff | 2013-03-19 15:49:25 -0700 | [diff] [blame] | 2553 | { |
Hoonki Lee | fb8df67 | 2013-04-10 18:20:34 -0700 | [diff] [blame] | 2554 | if (pHddCtx->tdls_scan_ctxt.reject++ >= TDLS_MAX_SCAN_REJECT) |
| 2555 | { |
| 2556 | pHddCtx->tdls_scan_ctxt.reject = 0; |
| 2557 | VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
| 2558 | "%s: " MAC_ADDRESS_STR ". scan rejected %d. force it to idle", |
| 2559 | __func__, MAC_ADDR_ARRAY (curr_peer->peerMac), pHddCtx->tdls_scan_ctxt.reject); |
| 2560 | |
Atul Mittal | 115287b | 2014-07-08 13:26:33 +0530 | [diff] [blame] | 2561 | wlan_hdd_tdls_set_peer_link_status (curr_peer, |
| 2562 | eTDLS_LINK_IDLE, |
| 2563 | eTDLS_LINK_UNSPECIFIED); |
Hoonki Lee | fb8df67 | 2013-04-10 18:20:34 -0700 | [diff] [blame] | 2564 | return 1; |
| 2565 | } |
Hoonki Lee | 93e67ff | 2013-03-19 15:49:25 -0700 | [diff] [blame] | 2566 | VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
Hoonki Lee | fb8df67 | 2013-04-10 18:20:34 -0700 | [diff] [blame] | 2567 | "%s: tdls in progress. scan rejected %d", |
| 2568 | __func__, pHddCtx->tdls_scan_ctxt.reject); |
Hoonki Lee | 93e67ff | 2013-03-19 15:49:25 -0700 | [diff] [blame] | 2569 | return -EBUSY; |
| 2570 | } |
| 2571 | |
| 2572 | /* tdls teardown is ongoing */ |
| 2573 | if (eTDLS_SUPPORT_DISABLED == pHddCtx->tdls_mode) |
| 2574 | { |
| 2575 | connectedTdlsPeers = wlan_hdd_tdlsConnectedPeers(pAdapter); |
| 2576 | if (connectedTdlsPeers && (pHddCtx->tdls_scan_ctxt.attempt < TDLS_MAX_SCAN_SCHEDULE)) |
| 2577 | { |
| 2578 | delay = (unsigned long)(TDLS_DELAY_SCAN_PER_CONNECTION*connectedTdlsPeers); |
| 2579 | VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
| 2580 | "%s: tdls disabled, but still connected_peers %d attempt %d. schedule scan %lu msec", |
| 2581 | __func__, connectedTdlsPeers, pHddCtx->tdls_scan_ctxt.attempt, delay); |
| 2582 | |
| 2583 | wlan_hdd_tdls_scan_init_work (pHddCtx, wiphy, |
| 2584 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0)) |
| 2585 | dev, |
| 2586 | #endif |
| 2587 | request, |
| 2588 | msecs_to_jiffies(delay)); |
| 2589 | /* scan should not continue */ |
| 2590 | return 0; |
| 2591 | } |
| 2592 | /* no connected peer or max retry reached, scan continue */ |
| 2593 | VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
| 2594 | "%s: tdls disabled. connected_peers %d attempt %d. scan allowed", |
| 2595 | __func__, connectedTdlsPeers, pHddCtx->tdls_scan_ctxt.attempt); |
| 2596 | return 1; |
| 2597 | } |
Agarwal Ashish | ef54a18 | 2014-12-16 15:07:31 +0530 | [diff] [blame] | 2598 | |
| 2599 | /* if fEnableTDLSScan flag is 1 ; driverwill allow scan even if |
| 2600 | * peer station is not buffer STA capable |
| 2601 | * |
| 2602 | * RX: If there is any RX activity, device will lose RX packets, |
| 2603 | * as peer will not be aware that device is off channel. |
| 2604 | * TX: TX is stopped whenever device initiate scan. |
| 2605 | */ |
| 2606 | if (pHddCtx->cfg_ini->fEnableTDLSScan == 1) |
| 2607 | { |
| 2608 | VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
| 2609 | FL("Allow SCAN in all TDLS cases")); |
| 2610 | return 1; |
| 2611 | } |
| 2612 | |
Hoonki Lee | 93e67ff | 2013-03-19 15:49:25 -0700 | [diff] [blame] | 2613 | /* while tdls is up, first time scan */ |
| 2614 | else if (eTDLS_SUPPORT_ENABLED == pHddCtx->tdls_mode || |
| 2615 | eTDLS_SUPPORT_EXPLICIT_TRIGGER_ONLY == pHddCtx->tdls_mode) |
| 2616 | { |
Hoonki Lee | 93e67ff | 2013-03-19 15:49:25 -0700 | [diff] [blame] | 2617 | connectedTdlsPeers = wlan_hdd_tdlsConnectedPeers(pAdapter); |
Pradeep Reddy POTTETI | edaeb5f | 2014-05-22 23:34:41 +0530 | [diff] [blame] | 2618 | |
| 2619 | /* check the TDLS link and Scan coexistance Capability */ |
| 2620 | if ( (TRUE == pHddCtx->cfg_ini->fEnableTDLSScanCoexSupport) && |
| 2621 | (TRUE == sme_IsFeatureSupportedByFW(TDLS_SCAN_COEXISTENCE)) && |
| 2622 | (connectedTdlsPeers == 1) ) |
| 2623 | { |
| 2624 | /* get connected peer information */ |
| 2625 | connected_peer = wlan_hdd_tdls_get_first_connected_peer(pAdapter); |
| 2626 | if (NULL == connected_peer) { |
| 2627 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 2628 | "%s: Invalid connected_peer, Continue Scanning", __func__); |
| 2629 | /* scan should continue */ |
| 2630 | return 1; |
| 2631 | } |
| 2632 | VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
| 2633 | ("%s: TDLS Scan Co-exist supported connectedTdlsPeers =%d buffersta =%d"), |
| 2634 | __func__,connectedTdlsPeers,connected_peer->isBufSta); |
| 2635 | |
| 2636 | if (connected_peer->isBufSta) |
| 2637 | { |
| 2638 | pHddCtx->isTdlsScanCoexistence = TRUE; |
| 2639 | if ((cfg_param->dynSplitscan) && (!pHddCtx->issplitscan_enabled)) |
| 2640 | { |
| 2641 | pHddCtx->issplitscan_enabled = TRUE; |
| 2642 | sme_enable_disable_split_scan( |
| 2643 | WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 2644 | cfg_param->nNumStaChanCombinedConc, |
| 2645 | cfg_param->nNumP2PChanCombinedConc); |
| 2646 | } |
| 2647 | VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
| 2648 | ("%s:%d TDLS Scan Co-exist supported splitscan_enabled =%d "), |
| 2649 | __func__, __LINE__, pHddCtx->issplitscan_enabled); |
| 2650 | return 1; |
| 2651 | } |
| 2652 | |
| 2653 | } |
| 2654 | else |
| 2655 | { |
| 2656 | /* Throughput Monitor shall disable the split scan when |
| 2657 | * TDLS scan coexistance is disabled.At this point of time |
| 2658 | * since TDLS scan coexistance is not meeting the criteria |
| 2659 | * to be operational, explicitly make it false to enable |
| 2660 | * throughput monitor takes the control of split scan. |
| 2661 | */ |
| 2662 | pHddCtx->isTdlsScanCoexistence = FALSE; |
| 2663 | } |
| 2664 | VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
| 2665 | ("%s: TDLS Scan Co-exist not supported connectedTdlsPeers =%d" |
| 2666 | " TDLSScanCoexSupport param =%d TDLS_SCAN_COEXISTENCE =%d"), |
| 2667 | __func__, connectedTdlsPeers, |
| 2668 | pHddCtx->cfg_ini->fEnableTDLSScanCoexSupport, |
| 2669 | sme_IsFeatureSupportedByFW(TDLS_SCAN_COEXISTENCE)); |
| 2670 | |
Atul Mittal | 5803b34 | 2014-09-04 15:31:19 +0530 | [diff] [blame] | 2671 | /* disable implicit trigger logic & tdls operatoin */ |
| 2672 | wlan_hdd_tdls_set_mode(pHddCtx, eTDLS_SUPPORT_DISABLED, FALSE); |
Pradeep Reddy POTTETI | edaeb5f | 2014-05-22 23:34:41 +0530 | [diff] [blame] | 2673 | /* fall back to the implementation of teardown the peers on the scan |
| 2674 | * when the number of connected peers are more than one. TDLS Scan |
| 2675 | * coexistance feature is exercised only when a single peer is |
| 2676 | * connected and the DUT shall not advertize the Buffer Sta capability, |
| 2677 | * so that the peer shall not go to the TDLS power save |
| 2678 | */ |
| 2679 | |
Hoonki Lee | 93e67ff | 2013-03-19 15:49:25 -0700 | [diff] [blame] | 2680 | if (connectedTdlsPeers) |
| 2681 | { |
| 2682 | tANI_U8 staIdx; |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 2683 | hddTdlsPeer_t *curr_peer; |
Hoonki Lee | 93e67ff | 2013-03-19 15:49:25 -0700 | [diff] [blame] | 2684 | |
| 2685 | for (staIdx = 0; staIdx < HDD_MAX_NUM_TDLS_STA; staIdx++) |
| 2686 | { |
| 2687 | if (pHddCtx->tdlsConnInfo[staIdx].staId) |
| 2688 | { |
Gopichand Nakkala | 4ddf019 | 2013-03-27 13:41:20 -0700 | [diff] [blame] | 2689 | VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
Hoonki Lee | 93e67ff | 2013-03-19 15:49:25 -0700 | [diff] [blame] | 2690 | ("%s: indicate TDLS teadown (staId %d)"), __func__, pHddCtx->tdlsConnInfo[staIdx].staId) ; |
| 2691 | |
| 2692 | #ifdef CONFIG_TDLS_IMPLICIT |
Hoonki Lee | a6d49be | 2013-04-05 09:43:25 -0700 | [diff] [blame] | 2693 | curr_peer = wlan_hdd_tdls_find_all_peer(pHddCtx, pHddCtx->tdlsConnInfo[staIdx].peerMac.bytes); |
| 2694 | if(curr_peer) |
| 2695 | 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] | 2696 | #endif |
| 2697 | } |
| 2698 | } |
| 2699 | /* schedule scan */ |
| 2700 | delay = (unsigned long)(TDLS_DELAY_SCAN_PER_CONNECTION*connectedTdlsPeers); |
| 2701 | |
| 2702 | VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
| 2703 | "%s: tdls enabled (mode %d), connected_peers %d. schedule scan %lu msec", |
| 2704 | __func__, pHddCtx->tdls_mode, wlan_hdd_tdlsConnectedPeers(pAdapter), |
| 2705 | delay); |
| 2706 | |
| 2707 | wlan_hdd_tdls_scan_init_work (pHddCtx, wiphy, |
| 2708 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0)) |
| 2709 | dev, |
| 2710 | #endif |
| 2711 | request, |
| 2712 | msecs_to_jiffies(delay)); |
| 2713 | /* scan should not continue */ |
| 2714 | return 0; |
| 2715 | } |
| 2716 | /* no connected peer, scan continue */ |
| 2717 | VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
| 2718 | "%s: tdls_mode %d, and no tdls connection. scan allowed", |
| 2719 | __func__, pHddCtx->tdls_mode); |
| 2720 | } |
| 2721 | return 1; |
| 2722 | } |
| 2723 | |
| 2724 | void wlan_hdd_tdls_scan_done_callback(hdd_adapter_t *pAdapter) |
| 2725 | { |
| 2726 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
Hoonki Lee | 93e67ff | 2013-03-19 15:49:25 -0700 | [diff] [blame] | 2727 | |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 2728 | if(0 != (wlan_hdd_validate_context(pHddCtx))) |
| 2729 | { |
| 2730 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2731 | FL("pHddCtx is not valid")); |
Hoonki Lee | 93e67ff | 2013-03-19 15:49:25 -0700 | [diff] [blame] | 2732 | return; |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 2733 | } |
Hoonki Lee | 93e67ff | 2013-03-19 15:49:25 -0700 | [diff] [blame] | 2734 | |
Pradeep Reddy POTTETI | f0569d7 | 2014-12-13 16:54:03 +0530 | [diff] [blame] | 2735 | if (pHddCtx->is_tdls_btc_enabled == FALSE) |
| 2736 | return; |
Sunil Dutt | 41de4e2 | 2013-11-14 18:09:02 +0530 | [diff] [blame] | 2737 | |
Hoonki Lee | 93e67ff | 2013-03-19 15:49:25 -0700 | [diff] [blame] | 2738 | /* free allocated memory at scan time */ |
Gopichand Nakkala | 3046fc9 | 2013-03-23 13:56:43 -0700 | [diff] [blame] | 2739 | wlan_hdd_tdls_free_scan_request (&pHddCtx->tdls_scan_ctxt); |
Hoonki Lee | 93e67ff | 2013-03-19 15:49:25 -0700 | [diff] [blame] | 2740 | |
| 2741 | /* if tdls was enabled before scan, re-enable tdls mode */ |
| 2742 | if(eTDLS_SUPPORT_ENABLED == pHddCtx->tdls_mode_last || |
| 2743 | eTDLS_SUPPORT_EXPLICIT_TRIGGER_ONLY == pHddCtx->tdls_mode_last) |
| 2744 | { |
Gopichand Nakkala | 4ddf019 | 2013-03-27 13:41:20 -0700 | [diff] [blame] | 2745 | VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
Hoonki Lee | 93e67ff | 2013-03-19 15:49:25 -0700 | [diff] [blame] | 2746 | ("%s: revert tdls mode %d"), __func__, pHddCtx->tdls_mode_last); |
| 2747 | |
Gopichand Nakkala | dcbcf4e | 2013-03-23 14:32:39 -0700 | [diff] [blame] | 2748 | wlan_hdd_tdls_set_mode(pHddCtx, pHddCtx->tdls_mode_last, FALSE); |
Hoonki Lee | 93e67ff | 2013-03-19 15:49:25 -0700 | [diff] [blame] | 2749 | } |
| 2750 | wlan_hdd_tdls_check_bmps(pAdapter); |
| 2751 | } |
Gopichand Nakkala | 3046fc9 | 2013-03-23 13:56:43 -0700 | [diff] [blame] | 2752 | |
| 2753 | void wlan_hdd_tdls_timer_restart(hdd_adapter_t *pAdapter, |
| 2754 | vos_timer_t *timer, |
| 2755 | v_U32_t expirationTime) |
| 2756 | { |
| 2757 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 2758 | |
| 2759 | if (NULL == pHddStaCtx) |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 2760 | { |
| 2761 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2762 | FL("pHddStaCtx is NULL")); |
Gopichand Nakkala | 3046fc9 | 2013-03-23 13:56:43 -0700 | [diff] [blame] | 2763 | return; |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 2764 | } |
Gopichand Nakkala | 3046fc9 | 2013-03-23 13:56:43 -0700 | [diff] [blame] | 2765 | |
| 2766 | /* Check whether driver load unload is in progress */ |
| 2767 | if(vos_is_load_unload_in_progress( VOS_MODULE_ID_VOSS, NULL)) |
| 2768 | { |
| 2769 | VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR, |
| 2770 | "%s: Driver load/unload is in progress.", __func__); |
| 2771 | return; |
| 2772 | } |
| 2773 | |
| 2774 | if (hdd_connIsConnected(pHddStaCtx)) |
| 2775 | { |
| 2776 | vos_timer_stop(timer); |
| 2777 | vos_timer_start(timer, expirationTime); |
| 2778 | } |
| 2779 | } |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 2780 | void wlan_hdd_tdls_indicate_teardown(hdd_adapter_t *pAdapter, |
| 2781 | hddTdlsPeer_t *curr_peer, |
| 2782 | tANI_U16 reason) |
| 2783 | { |
Pradeep Reddy POTTETI | 8a62313 | 2014-06-26 16:07:06 +0530 | [diff] [blame] | 2784 | hdd_context_t *pHddCtx; |
Pradeep Reddy POTTETI | edaeb5f | 2014-05-22 23:34:41 +0530 | [diff] [blame] | 2785 | |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 2786 | if (NULL == pAdapter || NULL == curr_peer) |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 2787 | { |
| 2788 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2789 | FL("parameters passed are invalid")); |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 2790 | return; |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 2791 | } |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 2792 | |
Pradeep Reddy POTTETI | 8a62313 | 2014-06-26 16:07:06 +0530 | [diff] [blame] | 2793 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 2794 | |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 2795 | if (eTDLS_LINK_CONNECTED != curr_peer->link_status) |
| 2796 | return; |
| 2797 | |
Pradeep Reddy POTTETI | edaeb5f | 2014-05-22 23:34:41 +0530 | [diff] [blame] | 2798 | /* Throughput Monitor shall disable the split scan when |
| 2799 | * TDLS scan coexistance is disabled.At this point of time |
| 2800 | * since TDLS scan coexistance is not meeting the criteria |
| 2801 | * to be operational, explicitly make it false to enable |
| 2802 | * throughput monitor takes the control of split scan. |
| 2803 | */ |
Pradeep Reddy POTTETI | 8a62313 | 2014-06-26 16:07:06 +0530 | [diff] [blame] | 2804 | if (pHddCtx && (pHddCtx->isTdlsScanCoexistence == TRUE)) |
Pradeep Reddy POTTETI | edaeb5f | 2014-05-22 23:34:41 +0530 | [diff] [blame] | 2805 | { |
| 2806 | pHddCtx->isTdlsScanCoexistence = FALSE; |
| 2807 | } |
| 2808 | |
Atul Mittal | 115287b | 2014-07-08 13:26:33 +0530 | [diff] [blame] | 2809 | wlan_hdd_tdls_set_peer_link_status(curr_peer, |
| 2810 | eTDLS_LINK_TEARING, |
Atul Mittal | 271a765 | 2014-09-12 13:18:22 +0530 | [diff] [blame] | 2811 | eTDLS_LINK_UNSPECIFIED); |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 2812 | cfg80211_tdls_oper_request(pAdapter->dev, |
| 2813 | curr_peer->peerMac, |
| 2814 | NL80211_TDLS_TEARDOWN, |
| 2815 | reason, |
| 2816 | GFP_KERNEL); |
| 2817 | } |
Atul Mittal | 115287b | 2014-07-08 13:26:33 +0530 | [diff] [blame] | 2818 | |
| 2819 | |
| 2820 | /*EXT TDLS*/ |
| 2821 | int wlan_hdd_set_callback(hddTdlsPeer_t *curr_peer, |
| 2822 | cfg80211_exttdls_callback callback) |
| 2823 | { |
| 2824 | |
| 2825 | hdd_context_t *pHddCtx; |
| 2826 | hdd_adapter_t *pAdapter; |
| 2827 | |
| 2828 | if (!curr_peer) return -1; |
| 2829 | |
| 2830 | pAdapter = curr_peer->pHddTdlsCtx->pAdapter; |
| 2831 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 2832 | if ((NULL == pHddCtx)) return -1; |
| 2833 | |
| 2834 | mutex_lock(&pHddCtx->tdls_lock); |
| 2835 | |
| 2836 | curr_peer->state_change_notification = callback; |
| 2837 | |
| 2838 | mutex_unlock(&pHddCtx->tdls_lock); |
| 2839 | return 0; |
| 2840 | |
| 2841 | |
| 2842 | } |
| 2843 | |
| 2844 | void wlan_hdd_tdls_get_wifi_hal_state(hddTdlsPeer_t *curr_peer, |
| 2845 | tANI_S32 *state, |
| 2846 | tANI_S32 *reason) |
| 2847 | { |
| 2848 | *reason = curr_peer->reason; |
| 2849 | |
| 2850 | switch(curr_peer->link_status) |
| 2851 | { |
| 2852 | case eTDLS_LINK_IDLE: |
Atul Mittal | 115287b | 2014-07-08 13:26:33 +0530 | [diff] [blame] | 2853 | case eTDLS_LINK_DISCOVERED: |
| 2854 | *state = WIFI_TDLS_ENABLED; |
| 2855 | break; |
Atul Mittal | ad630e4 | 2014-10-07 19:19:14 +0530 | [diff] [blame] | 2856 | case eTDLS_LINK_DISCOVERING: |
Atul Mittal | 115287b | 2014-07-08 13:26:33 +0530 | [diff] [blame] | 2857 | case eTDLS_LINK_CONNECTING: |
| 2858 | *state = WIFI_TDLS_TRYING; |
| 2859 | break; |
| 2860 | case eTDLS_LINK_CONNECTED: |
| 2861 | *state = WIFI_TDLS_ESTABLISHED; |
| 2862 | break; |
| 2863 | case eTDLS_LINK_TEARING: |
| 2864 | *state = WIFI_TDLS_DROPPED; |
| 2865 | break; |
| 2866 | } |
| 2867 | |
| 2868 | } |
| 2869 | |
| 2870 | int wlan_hdd_tdls_get_status(hdd_adapter_t *pAdapter, |
| 2871 | tANI_U8* mac, |
| 2872 | tANI_S32 *state, |
| 2873 | tANI_S32 *reason) |
| 2874 | { |
| 2875 | |
| 2876 | hddTdlsPeer_t *curr_peer; |
Atul Mittal | a75fced | 2014-10-06 13:59:07 +0530 | [diff] [blame] | 2877 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
Atul Mittal | 115287b | 2014-07-08 13:26:33 +0530 | [diff] [blame] | 2878 | curr_peer = wlan_hdd_tdls_find_peer(pAdapter, mac, TRUE); |
| 2879 | if (curr_peer == NULL) |
| 2880 | { |
Atul Mittal | a75fced | 2014-10-06 13:59:07 +0530 | [diff] [blame] | 2881 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Atul Mittal | 115287b | 2014-07-08 13:26:33 +0530 | [diff] [blame] | 2882 | FL("curr_peer is NULL")); |
Atul Mittal | 115287b | 2014-07-08 13:26:33 +0530 | [diff] [blame] | 2883 | |
Atul Mittal | a75fced | 2014-10-06 13:59:07 +0530 | [diff] [blame] | 2884 | *state = WIFI_TDLS_DISABLED; |
| 2885 | *reason = eTDLS_LINK_UNSPECIFIED; |
| 2886 | } |
| 2887 | else |
| 2888 | { |
| 2889 | if (pHddCtx->cfg_ini->fTDLSExternalControl && |
| 2890 | (FALSE == curr_peer->isForcedPeer)) |
| 2891 | { |
| 2892 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2893 | FL("curr_peer is not Forced")); |
| 2894 | *state = WIFI_TDLS_DISABLED; |
| 2895 | *reason = eTDLS_LINK_UNSPECIFIED; |
| 2896 | } |
| 2897 | else |
| 2898 | { |
| 2899 | wlan_hdd_tdls_get_wifi_hal_state(curr_peer, state, reason); |
| 2900 | } |
| 2901 | } |
Atul Mittal | 115287b | 2014-07-08 13:26:33 +0530 | [diff] [blame] | 2902 | return (0); |
| 2903 | } |
| 2904 | |
Agarwal Ashish | ef54a18 | 2014-12-16 15:07:31 +0530 | [diff] [blame] | 2905 | int hdd_set_tdls_scan_type(hdd_adapter_t *pAdapter, |
| 2906 | tANI_U8 *ptr) |
| 2907 | { |
| 2908 | int tdls_scan_type; |
Hema Aparna Medicharla | 26b9804 | 2015-01-21 15:02:01 +0530 | [diff] [blame^] | 2909 | hdd_context_t *pHddCtx; |
Agarwal Ashish | ef54a18 | 2014-12-16 15:07:31 +0530 | [diff] [blame] | 2910 | if (NULL == pAdapter) |
| 2911 | { |
| 2912 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2913 | "%s: pAdapter is NULL", __func__); |
| 2914 | return -EINVAL; |
| 2915 | } |
Hema Aparna Medicharla | 26b9804 | 2015-01-21 15:02:01 +0530 | [diff] [blame^] | 2916 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
Agarwal Ashish | ef54a18 | 2014-12-16 15:07:31 +0530 | [diff] [blame] | 2917 | tdls_scan_type = ptr[9] - '0'; |
| 2918 | |
| 2919 | if (tdls_scan_type <= 2) |
| 2920 | { |
| 2921 | pHddCtx->cfg_ini->fEnableTDLSScan = tdls_scan_type; |
| 2922 | return 0; |
| 2923 | } |
| 2924 | else |
| 2925 | { |
| 2926 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2927 | " Wrong value is given for tdls_scan_type " |
| 2928 | " Making fEnableTDLSScan as 0 "); |
| 2929 | pHddCtx->cfg_ini->fEnableTDLSScan = 0; |
| 2930 | return -EINVAL; |
| 2931 | } |
| 2932 | } |
| 2933 | |
Atul Mittal | 115287b | 2014-07-08 13:26:33 +0530 | [diff] [blame] | 2934 | /*EXT TDLS*/ |
| 2935 | |