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