Kiran V | 1ccee93 | 2012-12-12 14:49:46 -0800 | [diff] [blame] | 1 | /* |
Gopichand Nakkala | 0c1331e | 2013-01-07 22:49:07 -0800 | [diff] [blame] | 2 | * Copyright (c) 2012-2013, The Linux Foundation. All rights reserved. |
| 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. |
| 20 | */ |
Kiran V | 1ccee93 | 2012-12-12 14:49:46 -0800 | [diff] [blame] | 21 | |
| 22 | /**======================================================================== |
| 23 | |
| 24 | \file wlan_hdd_tdls.c |
| 25 | |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 26 | \brief WLAN Host Device Driver implementation for TDLS |
Kiran V | 1ccee93 | 2012-12-12 14:49:46 -0800 | [diff] [blame] | 27 | |
Kiran V | 1ccee93 | 2012-12-12 14:49:46 -0800 | [diff] [blame] | 28 | ========================================================================*/ |
| 29 | |
| 30 | #include <wlan_hdd_includes.h> |
| 31 | #include <wlan_hdd_hostapd.h> |
| 32 | #include <net/cfg80211.h> |
| 33 | #include <linux/netdevice.h> |
| 34 | #include <linux/skbuff.h> |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 35 | #include <linux/list.h> |
Kiran V | 1ccee93 | 2012-12-12 14:49:46 -0800 | [diff] [blame] | 36 | #include <linux/etherdevice.h> |
| 37 | #include <net/ieee80211_radiotap.h> |
| 38 | #include "wlan_hdd_tdls.h" |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 39 | #include "wlan_hdd_cfg80211.h" |
Kiran V | 1ccee93 | 2012-12-12 14:49:46 -0800 | [diff] [blame] | 40 | |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 41 | |
Gopichand Nakkala | eb69b60 | 2013-02-27 11:40:31 -0800 | [diff] [blame] | 42 | static struct mutex tdls_lock; |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 43 | static tANI_S32 wlan_hdd_get_tdls_discovery_peer_cnt(tdlsCtx_t *pHddTdlsCtx); |
| 44 | static tANI_S32 wlan_hdd_tdls_peer_reset_discovery_processed(tdlsCtx_t *pHddTdlsCtx); |
| 45 | static void wlan_hdd_tdls_timers_destroy(tdlsCtx_t *pHddTdlsCtx); |
Hoonki Lee | d37cbb3 | 2013-04-20 00:31:14 -0700 | [diff] [blame] | 46 | #ifdef CONFIG_TDLS_IMPLICIT |
| 47 | static void wlan_hdd_tdls_pre_setup(struct work_struct *work); |
| 48 | #endif |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 49 | |
Hoonki Lee | 5a4b217 | 2013-01-29 01:45:53 -0800 | [diff] [blame] | 50 | #ifndef WLAN_FEATURE_TDLS_DEBUG |
| 51 | #define TDLS_LOG_LEVEL VOS_TRACE_LEVEL_INFO |
| 52 | #else |
| 53 | #define TDLS_LOG_LEVEL VOS_TRACE_LEVEL_WARN |
| 54 | #endif |
| 55 | |
Hoonki Lee | 387663d | 2013-02-05 18:08:43 -0800 | [diff] [blame] | 56 | static u8 wlan_hdd_tdls_hash_key (u8 *mac) |
Hoonki Lee | f63df0d | 2013-01-16 19:29:14 -0800 | [diff] [blame] | 57 | { |
| 58 | int i; |
Hoonki Lee | 387663d | 2013-02-05 18:08:43 -0800 | [diff] [blame] | 59 | u8 key = 0; |
| 60 | |
| 61 | for (i = 0; i < 6; i++) |
| 62 | key ^= mac[i]; |
| 63 | |
| 64 | return key; |
| 65 | } |
| 66 | |
Hoonki Lee | d37cbb3 | 2013-04-20 00:31:14 -0700 | [diff] [blame] | 67 | #ifdef CONFIG_TDLS_IMPLICIT |
| 68 | static void wlan_hdd_tdls_pre_setup_init_work(tdlsCtx_t * pHddTdlsCtx, |
| 69 | hddTdlsPeer_t *curr_candidate) |
| 70 | { |
| 71 | if (TDLS_CTX_MAGIC != pHddTdlsCtx->magic) |
| 72 | { |
| 73 | pHddTdlsCtx->curr_candidate = curr_candidate; |
| 74 | pHddTdlsCtx->magic = TDLS_CTX_MAGIC; |
| 75 | |
| 76 | INIT_WORK(&pHddTdlsCtx->implicit_setup, wlan_hdd_tdls_pre_setup); |
| 77 | schedule_work(&pHddTdlsCtx->implicit_setup); |
| 78 | } |
| 79 | } |
| 80 | #endif |
| 81 | |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 82 | static v_VOID_t wlan_hdd_tdls_start_peer_discover_timer(tdlsCtx_t *pHddTdlsCtx, |
| 83 | tANI_BOOLEAN mutexLock, |
| 84 | v_U32_t discoveryExpiry) |
Gopichand Nakkala | eb69b60 | 2013-02-27 11:40:31 -0800 | [diff] [blame] | 85 | { |
Gopichand Nakkala | eb69b60 | 2013-02-27 11:40:31 -0800 | [diff] [blame] | 86 | hdd_station_ctx_t *pHddStaCtx; |
| 87 | |
Gopichand Nakkala | eb69b60 | 2013-02-27 11:40:31 -0800 | [diff] [blame] | 88 | if ( mutexLock ) |
| 89 | { |
| 90 | if (mutex_lock_interruptible(&tdls_lock)) |
| 91 | { |
| 92 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 93 | "%s: unable to lock list: %d", __func__, __LINE__); |
| 94 | return; |
| 95 | } |
| 96 | } |
| 97 | if (NULL == pHddTdlsCtx) |
| 98 | { |
| 99 | if ( mutexLock ) |
| 100 | mutex_unlock(&tdls_lock); |
| 101 | return; |
| 102 | } |
| 103 | |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 104 | if (NULL == pHddTdlsCtx->pAdapter) |
Gopichand Nakkala | eb69b60 | 2013-02-27 11:40:31 -0800 | [diff] [blame] | 105 | { |
| 106 | if ( mutexLock ) |
| 107 | mutex_unlock(&tdls_lock); |
| 108 | return; |
| 109 | } |
| 110 | |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 111 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pHddTdlsCtx->pAdapter); |
Gopichand Nakkala | 75e7b28 | 2013-03-15 18:37:13 -0700 | [diff] [blame] | 112 | #ifdef FEATURE_WLAN_TDLS_INTERNAL |
Gopichand Nakkala | 3046fc9 | 2013-03-23 13:56:43 -0700 | [diff] [blame] | 113 | wlan_hdd_tdls_timer_restart(pHddTdlsCtx->pAdapter, |
| 114 | &pHddTdlsCtx->peerDiscoverTimer, |
| 115 | discoveryExpiry); |
Gopichand Nakkala | 75e7b28 | 2013-03-15 18:37:13 -0700 | [diff] [blame] | 116 | #endif |
Gopichand Nakkala | 3046fc9 | 2013-03-23 13:56:43 -0700 | [diff] [blame] | 117 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "beacon rssi: %d", |
| 118 | pHddTdlsCtx->ap_rssi); |
| 119 | |
Gopichand Nakkala | eb69b60 | 2013-02-27 11:40:31 -0800 | [diff] [blame] | 120 | if ( mutexLock ) |
| 121 | mutex_unlock(&tdls_lock); |
| 122 | |
| 123 | return; |
| 124 | } |
| 125 | |
Hoonki Lee | d37cbb3 | 2013-04-20 00:31:14 -0700 | [diff] [blame] | 126 | #ifdef TDLS_USE_SEPARATE_DISCOVERY_TIMER |
Hoonki Lee | 387663d | 2013-02-05 18:08:43 -0800 | [diff] [blame] | 127 | static v_VOID_t wlan_hdd_tdls_discover_peer_cb( v_PVOID_t userData ) |
| 128 | { |
| 129 | int i; |
| 130 | struct list_head *head; |
| 131 | struct list_head *pos; |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 132 | hddTdlsPeer_t *curr_peer; |
Gopichand Nakkala | c369458 | 2013-02-13 20:51:22 -0800 | [diff] [blame] | 133 | hdd_station_ctx_t *pHddStaCtx; |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 134 | tdlsCtx_t *pHddTdlsCtx = (tdlsCtx_t *)userData; |
Gopichand Nakkala | c369458 | 2013-02-13 20:51:22 -0800 | [diff] [blame] | 135 | int discover_req_sent = 0; |
| 136 | v_U32_t discover_expiry = TDLS_SUB_DISCOVERY_PERIOD; |
Gopichand Nakkala | eb69b60 | 2013-02-27 11:40:31 -0800 | [diff] [blame] | 137 | tANI_BOOLEAN doMutexLock = eANI_BOOLEAN_TRUE; |
Gopichand Nakkala | c369458 | 2013-02-13 20:51:22 -0800 | [diff] [blame] | 138 | |
Gopichand Nakkala | eb69b60 | 2013-02-27 11:40:31 -0800 | [diff] [blame] | 139 | if (mutex_lock_interruptible(&tdls_lock)) |
| 140 | { |
| 141 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 142 | "%s: unable to lock list : %d", __func__, __LINE__); |
| 143 | return; |
| 144 | } |
Hoonki Lee | bfee034 | 2013-01-21 16:43:45 -0800 | [diff] [blame] | 145 | |
Gopichand Nakkala | eb69b60 | 2013-02-27 11:40:31 -0800 | [diff] [blame] | 146 | if (NULL == pHddTdlsCtx) |
| 147 | { |
| 148 | mutex_unlock(&tdls_lock); |
| 149 | return; |
| 150 | } |
Hoonki Lee | bfee034 | 2013-01-21 16:43:45 -0800 | [diff] [blame] | 151 | |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 152 | if (NULL == pHddTdlsCtx->pAdapter) |
Gopichand Nakkala | eb69b60 | 2013-02-27 11:40:31 -0800 | [diff] [blame] | 153 | { |
| 154 | mutex_unlock(&tdls_lock); |
| 155 | return; |
| 156 | } |
Gopichand Nakkala | c369458 | 2013-02-13 20:51:22 -0800 | [diff] [blame] | 157 | |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 158 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pHddTdlsCtx->pAdapter); |
Hoonki Lee | f63df0d | 2013-01-16 19:29:14 -0800 | [diff] [blame] | 159 | |
Hoonki Lee | 387663d | 2013-02-05 18:08:43 -0800 | [diff] [blame] | 160 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: ", __func__); |
| 161 | |
Gopichand Nakkala | c369458 | 2013-02-13 20:51:22 -0800 | [diff] [blame] | 162 | if (0 == pHddTdlsCtx->discovery_peer_cnt) |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 163 | pHddTdlsCtx->discovery_peer_cnt = wlan_hdd_get_tdls_discovery_peer_cnt(pHddTdlsCtx); |
Gopichand Nakkala | c369458 | 2013-02-13 20:51:22 -0800 | [diff] [blame] | 164 | |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 165 | for (i = 0; i < 256; i++) { |
Hoonki Lee | 387663d | 2013-02-05 18:08:43 -0800 | [diff] [blame] | 166 | head = &pHddTdlsCtx->peer_list[i]; |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 167 | |
Hoonki Lee | 387663d | 2013-02-05 18:08:43 -0800 | [diff] [blame] | 168 | list_for_each (pos, head) { |
| 169 | curr_peer = list_entry (pos, hddTdlsPeer_t, node); |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 170 | |
Gopichand Nakkala | 2a0a157 | 2013-02-10 21:39:16 -0800 | [diff] [blame] | 171 | VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
Chilam Ng | 0112041 | 2013-02-19 18:32:21 -0800 | [diff] [blame] | 172 | "%d " MAC_ADDRESS_STR " %d %d, %d %d %d %d", i, |
| 173 | MAC_ADDR_ARRAY(curr_peer->peerMac), |
Gopichand Nakkala | c369458 | 2013-02-13 20:51:22 -0800 | [diff] [blame] | 174 | curr_peer->discovery_processed, |
| 175 | discover_req_sent, |
Gopichand Nakkala | 2a0a157 | 2013-02-10 21:39:16 -0800 | [diff] [blame] | 176 | curr_peer->tdls_support, |
| 177 | curr_peer->link_status, |
| 178 | curr_peer->discovery_attempt, |
| 179 | pHddTdlsCtx->threshold_config.discovery_tries_n); |
Hoonki Lee | 387663d | 2013-02-05 18:08:43 -0800 | [diff] [blame] | 180 | |
Gopichand Nakkala | c369458 | 2013-02-13 20:51:22 -0800 | [diff] [blame] | 181 | if (discover_req_sent < TDLS_MAX_DISCOVER_REQS_PER_TIMER) { |
| 182 | if (!curr_peer->discovery_processed) { |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 183 | |
Gopichand Nakkala | c369458 | 2013-02-13 20:51:22 -0800 | [diff] [blame] | 184 | curr_peer->discovery_processed = 1; |
| 185 | discover_req_sent++; |
| 186 | pHddTdlsCtx->discovery_peer_cnt--; |
| 187 | |
| 188 | if ((eTDLS_CAP_UNKNOWN == curr_peer->tdls_support) && |
Gopichand Nakkala | 901e892 | 2013-03-04 23:45:58 -0800 | [diff] [blame] | 189 | (eTDLS_LINK_IDLE == curr_peer->link_status) && |
Gopichand Nakkala | b88f677 | 2013-02-27 18:12:56 -0800 | [diff] [blame] | 190 | (curr_peer->tx_pkt >= |
| 191 | pHddTdlsCtx->threshold_config.tx_packet_n)) { |
Gopichand Nakkala | 273d5a0 | 2013-02-19 15:15:09 -0800 | [diff] [blame] | 192 | |
| 193 | if (curr_peer->discovery_attempt < |
| 194 | pHddTdlsCtx->threshold_config.discovery_tries_n) { |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 195 | sme_SendTdlsMgmtFrame(WLAN_HDD_GET_HAL_CTX(pHddTdlsCtx->pAdapter), |
| 196 | pHddTdlsCtx->pAdapter->sessionId, |
Gopichand Nakkala | c369458 | 2013-02-13 20:51:22 -0800 | [diff] [blame] | 197 | curr_peer->peerMac, |
| 198 | WLAN_TDLS_DISCOVERY_REQUEST, |
| 199 | 1, 0, NULL, 0, 0); |
Gopichand Nakkala | 273d5a0 | 2013-02-19 15:15:09 -0800 | [diff] [blame] | 200 | curr_peer->discovery_attempt++; |
| 201 | } |
| 202 | else |
| 203 | { |
| 204 | VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
| 205 | "%s: Maximum Discovery retries reached", __func__); |
| 206 | curr_peer->tdls_support = eTDLS_CAP_NOT_SUPPORTED; |
| 207 | } |
Gopichand Nakkala | c369458 | 2013-02-13 20:51:22 -0800 | [diff] [blame] | 208 | |
| 209 | } |
| 210 | } |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 211 | } |
Gopichand Nakkala | c369458 | 2013-02-13 20:51:22 -0800 | [diff] [blame] | 212 | else |
| 213 | goto exit_loop; |
Hoonki Lee | 387663d | 2013-02-05 18:08:43 -0800 | [diff] [blame] | 214 | } |
Hoonki Lee | f63df0d | 2013-01-16 19:29:14 -0800 | [diff] [blame] | 215 | } |
Gopichand Nakkala | c369458 | 2013-02-13 20:51:22 -0800 | [diff] [blame] | 216 | exit_loop: |
Hoonki Lee | f63df0d | 2013-01-16 19:29:14 -0800 | [diff] [blame] | 217 | |
Gopichand Nakkala | c369458 | 2013-02-13 20:51:22 -0800 | [diff] [blame] | 218 | if (0 != pHddTdlsCtx->discovery_peer_cnt) { |
| 219 | VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
| 220 | "discovery_peer_cnt is %d , Starting SUB_DISCOVERY_TIMER", |
| 221 | pHddTdlsCtx->discovery_peer_cnt); |
| 222 | discover_expiry = TDLS_SUB_DISCOVERY_PERIOD; |
Gopichand Nakkala | eb69b60 | 2013-02-27 11:40:31 -0800 | [diff] [blame] | 223 | doMutexLock = eANI_BOOLEAN_FALSE; |
Gopichand Nakkala | c369458 | 2013-02-13 20:51:22 -0800 | [diff] [blame] | 224 | goto done; |
| 225 | } |
Gopichand Nakkala | c369458 | 2013-02-13 20:51:22 -0800 | [diff] [blame] | 226 | discover_expiry = pHddTdlsCtx->threshold_config.discovery_period_t; |
| 227 | |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 228 | wlan_hdd_tdls_peer_reset_discovery_processed(pHddTdlsCtx); |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 229 | |
Gopichand Nakkala | 638ebc7 | 2013-03-21 18:04:02 -0700 | [diff] [blame] | 230 | mutex_unlock(&tdls_lock); |
| 231 | |
Gopichand Nakkala | eb69b60 | 2013-02-27 11:40:31 -0800 | [diff] [blame] | 232 | /* Commenting out the following function as it was introducing |
| 233 | * a race condition when pHddTdlsCtx is deleted. Also , this |
| 234 | * function is consuming more time in the timer callback. |
| 235 | * RSSI based trigger needs to revisit this part of the code. |
| 236 | */ |
| 237 | |
| 238 | /* |
| 239 | * wlan_hdd_get_rssi(pAdapter, &pHddTdlsCtx->ap_rssi); |
| 240 | */ |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 241 | |
Gopichand Nakkala | c369458 | 2013-02-13 20:51:22 -0800 | [diff] [blame] | 242 | done: |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 243 | wlan_hdd_tdls_start_peer_discover_timer(pHddTdlsCtx, doMutexLock, discover_expiry); |
Gopichand Nakkala | 91b0926 | 2013-02-10 14:27:02 -0800 | [diff] [blame] | 244 | |
Gopichand Nakkala | eb69b60 | 2013-02-27 11:40:31 -0800 | [diff] [blame] | 245 | if ( !doMutexLock ) |
| 246 | mutex_unlock(&tdls_lock); |
| 247 | return; |
Hoonki Lee | f63df0d | 2013-01-16 19:29:14 -0800 | [diff] [blame] | 248 | } |
Hoonki Lee | d37cbb3 | 2013-04-20 00:31:14 -0700 | [diff] [blame] | 249 | #endif |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 250 | |
Hoonki Lee | 387663d | 2013-02-05 18:08:43 -0800 | [diff] [blame] | 251 | 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] | 252 | { |
| 253 | int i; |
Hoonki Lee | 387663d | 2013-02-05 18:08:43 -0800 | [diff] [blame] | 254 | struct list_head *head; |
| 255 | struct list_head *pos; |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 256 | hddTdlsPeer_t *curr_peer; |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 257 | tdlsCtx_t *pHddTdlsCtx; |
Hoonki Lee | bfee034 | 2013-01-21 16:43:45 -0800 | [diff] [blame] | 258 | |
Gopichand Nakkala | eb69b60 | 2013-02-27 11:40:31 -0800 | [diff] [blame] | 259 | if (mutex_lock_interruptible(&tdls_lock)) |
Gopichand Nakkala | 91b0926 | 2013-02-10 14:27:02 -0800 | [diff] [blame] | 260 | { |
| 261 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 262 | "%s: unable to lock list", __func__); |
| 263 | return; |
| 264 | } |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 265 | pHddTdlsCtx = (tdlsCtx_t *)userData; |
Gopichand Nakkala | eb69b60 | 2013-02-27 11:40:31 -0800 | [diff] [blame] | 266 | if (NULL == pHddTdlsCtx) |
| 267 | { |
| 268 | mutex_unlock(&tdls_lock); |
| 269 | return; |
| 270 | } |
| 271 | |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 272 | if (NULL == pHddTdlsCtx->pAdapter) |
Gopichand Nakkala | 901e892 | 2013-03-04 23:45:58 -0800 | [diff] [blame] | 273 | { |
| 274 | mutex_unlock(&tdls_lock); |
| 275 | return; |
| 276 | } |
| 277 | |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 278 | for (i = 0; i < 256; i++) { |
Hoonki Lee | 387663d | 2013-02-05 18:08:43 -0800 | [diff] [blame] | 279 | head = &pHddTdlsCtx->peer_list[i]; |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 280 | |
Hoonki Lee | 387663d | 2013-02-05 18:08:43 -0800 | [diff] [blame] | 281 | list_for_each (pos, head) { |
| 282 | curr_peer = list_entry (pos, hddTdlsPeer_t, node); |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 283 | |
Gopichand Nakkala | 901e892 | 2013-03-04 23:45:58 -0800 | [diff] [blame] | 284 | VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
Hoonki Lee | 66b75f3 | 2013-04-16 18:30:07 -0700 | [diff] [blame] | 285 | "%s: " MAC_ADDRESS_STR " link_status %d" |
| 286 | " tdls_support %d", __func__, MAC_ADDR_ARRAY(curr_peer->peerMac), |
Gopichand Nakkala | 34d1b06 | 2013-03-19 15:28:33 -0700 | [diff] [blame] | 287 | curr_peer->link_status, curr_peer->tdls_support); |
Hoonki Lee | 387663d | 2013-02-05 18:08:43 -0800 | [diff] [blame] | 288 | |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 289 | if (eTDLS_CAP_SUPPORTED == curr_peer->tdls_support) { |
Hoonki Lee | 5a4b217 | 2013-01-29 01:45:53 -0800 | [diff] [blame] | 290 | VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
Hoonki Lee | 66b75f3 | 2013-04-16 18:30:07 -0700 | [diff] [blame] | 291 | "tx %d, rx %d (thr.pkt %d/idle %d), rssi %d (thr.trig %d/hys %d/tear %d)", |
| 292 | curr_peer->tx_pkt, curr_peer->rx_pkt, |
Hoonki Lee | 5a4b217 | 2013-01-29 01:45:53 -0800 | [diff] [blame] | 293 | pHddTdlsCtx->threshold_config.tx_packet_n, |
Hoonki Lee | 66b75f3 | 2013-04-16 18:30:07 -0700 | [diff] [blame] | 294 | pHddTdlsCtx->threshold_config.idle_packet_n, |
| 295 | curr_peer->rssi, |
| 296 | pHddTdlsCtx->threshold_config.rssi_trigger_threshold, |
| 297 | pHddTdlsCtx->threshold_config.rssi_hysteresis, |
| 298 | pHddTdlsCtx->threshold_config.rssi_teardown_threshold); |
Chilam Ng | 0112041 | 2013-02-19 18:32:21 -0800 | [diff] [blame] | 299 | |
Gopichand Nakkala | 901e892 | 2013-03-04 23:45:58 -0800 | [diff] [blame] | 300 | if ((eTDLS_LINK_IDLE == curr_peer->link_status) || |
| 301 | (eTDLS_LINK_DISCOVERING == curr_peer->link_status)){ |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 302 | if (curr_peer->tx_pkt >= |
| 303 | pHddTdlsCtx->threshold_config.tx_packet_n) { |
Hoonki Lee | 5a4b217 | 2013-01-29 01:45:53 -0800 | [diff] [blame] | 304 | |
Gopichand Nakkala | 8b00c63 | 2013-03-08 19:47:52 -0800 | [diff] [blame] | 305 | if (HDD_MAX_NUM_TDLS_STA > wlan_hdd_tdlsConnectedPeers(pHddTdlsCtx->pAdapter)) |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 306 | { |
| 307 | |
Gopichand Nakkala | 34d1b06 | 2013-03-19 15:28:33 -0700 | [diff] [blame] | 308 | 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] | 309 | #ifdef CONFIG_TDLS_IMPLICIT |
Hoonki Lee | d37cbb3 | 2013-04-20 00:31:14 -0700 | [diff] [blame] | 310 | wlan_hdd_tdls_pre_setup_init_work(pHddTdlsCtx, curr_peer); |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 311 | #endif |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 312 | } |
| 313 | else |
| 314 | { |
| 315 | VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
Gopichand Nakkala | 8b00c63 | 2013-03-08 19:47:52 -0800 | [diff] [blame] | 316 | "%s: Maximum peer connected already! %d", |
| 317 | __func__, wlan_hdd_tdlsConnectedPeers(pHddTdlsCtx->pAdapter) ); |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 318 | } |
Hoonki Lee | cdd8e96 | 2013-01-20 00:45:46 -0800 | [diff] [blame] | 319 | goto next_peer; |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 320 | } |
Hoonki Lee | fb8df67 | 2013-04-10 18:20:34 -0700 | [diff] [blame] | 321 | } |
| 322 | else if (eTDLS_LINK_CONNECTED == curr_peer->link_status) { |
Chilam Ng | 0112041 | 2013-02-19 18:32:21 -0800 | [diff] [blame] | 323 | if ((tANI_S32)curr_peer->rssi < |
| 324 | (tANI_S32)pHddTdlsCtx->threshold_config.rssi_teardown_threshold) { |
Hoonki Lee | 5a4b217 | 2013-01-29 01:45:53 -0800 | [diff] [blame] | 325 | |
Chilam Ng | 0112041 | 2013-02-19 18:32:21 -0800 | [diff] [blame] | 326 | VOS_TRACE( VOS_MODULE_ID_HDD, |
| 327 | VOS_TRACE_LEVEL_WARN, |
| 328 | "Tear down - low RSSI: " MAC_ADDRESS_STR "!", |
| 329 | MAC_ADDR_ARRAY(curr_peer->peerMac)); |
| 330 | #ifdef CONFIG_TDLS_IMPLICIT |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 331 | wlan_hdd_tdls_indicate_teardown(pHddTdlsCtx->pAdapter, |
| 332 | curr_peer, |
| 333 | eSIR_MAC_TDLS_TEARDOWN_UNSPEC_REASON); |
Chilam Ng | 0112041 | 2013-02-19 18:32:21 -0800 | [diff] [blame] | 334 | #endif |
Hoonki Lee | cdd8e96 | 2013-01-20 00:45:46 -0800 | [diff] [blame] | 335 | goto next_peer; |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 336 | } |
Chilam Ng | 0112041 | 2013-02-19 18:32:21 -0800 | [diff] [blame] | 337 | |
| 338 | if ((curr_peer->tx_pkt < |
| 339 | pHddTdlsCtx->threshold_config.idle_packet_n) && |
| 340 | (curr_peer->rx_pkt < |
| 341 | pHddTdlsCtx->threshold_config.idle_packet_n)) { |
| 342 | if (VOS_TIMER_STATE_RUNNING != |
| 343 | vos_timer_getCurrentState(&curr_peer->peerIdleTimer)) { |
| 344 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, |
| 345 | "Tx/Rx Idle timer start: " MAC_ADDRESS_STR "!", |
| 346 | MAC_ADDR_ARRAY(curr_peer->peerMac)); |
Gopichand Nakkala | 3046fc9 | 2013-03-23 13:56:43 -0700 | [diff] [blame] | 347 | wlan_hdd_tdls_timer_restart(pHddTdlsCtx->pAdapter, |
| 348 | &curr_peer->peerIdleTimer, |
| 349 | pHddTdlsCtx->threshold_config.idle_timeout_t); |
Chilam Ng | 0112041 | 2013-02-19 18:32:21 -0800 | [diff] [blame] | 350 | } |
| 351 | } else { |
Hoonki Lee | 5a4b217 | 2013-01-29 01:45:53 -0800 | [diff] [blame] | 352 | if (VOS_TIMER_STATE_RUNNING == |
| 353 | vos_timer_getCurrentState(&curr_peer->peerIdleTimer)) { |
Chilam Ng | 0112041 | 2013-02-19 18:32:21 -0800 | [diff] [blame] | 354 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, |
| 355 | "Tx/Rx Idle timer stop: " MAC_ADDRESS_STR "!", |
| 356 | MAC_ADDR_ARRAY(curr_peer->peerMac)); |
| 357 | vos_timer_stop( &curr_peer->peerIdleTimer); |
Hoonki Lee | 5a4b217 | 2013-01-29 01:45:53 -0800 | [diff] [blame] | 358 | } |
Hoonki Lee | 5a4b217 | 2013-01-29 01:45:53 -0800 | [diff] [blame] | 359 | } |
Chilam Ng | 0112041 | 2013-02-19 18:32:21 -0800 | [diff] [blame] | 360 | |
Hoonki Lee | cdd8e96 | 2013-01-20 00:45:46 -0800 | [diff] [blame] | 361 | // if (curr_peer->rssi < |
| 362 | // (pHddTdlsCtx->threshold_config.rssi_hysteresis + |
| 363 | // pHddTdlsCtx->ap_rssi)) { |
| 364 | // |
| 365 | //#ifdef CONFIG_TDLS_IMPLICIT |
| 366 | // cfg80211_tdls_oper_request(pHddTdlsCtx->dev, |
| 367 | // curr_peer->peerMac, |
| 368 | // NL80211_TDLS_TEARDOWN, FALSE, |
| 369 | // GFP_KERNEL); |
| 370 | //#endif |
| 371 | // } |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 372 | } |
Chilam Ng | 0112041 | 2013-02-19 18:32:21 -0800 | [diff] [blame] | 373 | } else if (eTDLS_CAP_UNKNOWN == curr_peer->tdls_support) { |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 374 | if (!TDLS_IS_CONNECTED(curr_peer)) { |
Chilam Ng | 0112041 | 2013-02-19 18:32:21 -0800 | [diff] [blame] | 375 | if (curr_peer->tx_pkt >= |
| 376 | pHddTdlsCtx->threshold_config.tx_packet_n) { |
Chilam Ng | 0112041 | 2013-02-19 18:32:21 -0800 | [diff] [blame] | 377 | |
Gopichand Nakkala | 062bcbd | 2013-03-29 18:14:47 -0700 | [diff] [blame] | 378 | if (curr_peer->discovery_attempt++ < |
Chilam Ng | 0112041 | 2013-02-19 18:32:21 -0800 | [diff] [blame] | 379 | pHddTdlsCtx->threshold_config.discovery_tries_n) { |
Gopichand Nakkala | 34d1b06 | 2013-03-19 15:28:33 -0700 | [diff] [blame] | 380 | VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, "TDLS UNKNOWN discover "); |
Hoonki Lee | d37cbb3 | 2013-04-20 00:31:14 -0700 | [diff] [blame] | 381 | #ifdef CONFIG_TDLS_IMPLICIT |
| 382 | wlan_hdd_tdls_pre_setup_init_work(pHddTdlsCtx, curr_peer); |
| 383 | #endif |
Chilam Ng | 0112041 | 2013-02-19 18:32:21 -0800 | [diff] [blame] | 384 | } |
Gopichand Nakkala | 901e892 | 2013-03-04 23:45:58 -0800 | [diff] [blame] | 385 | else |
Gopichand Nakkala | 8b00c63 | 2013-03-08 19:47:52 -0800 | [diff] [blame] | 386 | { |
Gopichand Nakkala | 901e892 | 2013-03-04 23:45:58 -0800 | [diff] [blame] | 387 | curr_peer->tdls_support = eTDLS_CAP_NOT_SUPPORTED; |
Gopichand Nakkala | 8b00c63 | 2013-03-08 19:47:52 -0800 | [diff] [blame] | 388 | curr_peer->link_status = eTDLS_LINK_IDLE; |
| 389 | } |
Chilam Ng | 0112041 | 2013-02-19 18:32:21 -0800 | [diff] [blame] | 390 | } |
| 391 | } |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 392 | } |
| 393 | |
Hoonki Lee | cdd8e96 | 2013-01-20 00:45:46 -0800 | [diff] [blame] | 394 | next_peer: |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 395 | curr_peer->tx_pkt = 0; |
Chilam Ng | 1279e23 | 2013-01-25 15:06:52 -0800 | [diff] [blame] | 396 | curr_peer->rx_pkt = 0; |
Hoonki Lee | 387663d | 2013-02-05 18:08:43 -0800 | [diff] [blame] | 397 | } |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 398 | } |
| 399 | |
Gopichand Nakkala | 3046fc9 | 2013-03-23 13:56:43 -0700 | [diff] [blame] | 400 | wlan_hdd_tdls_timer_restart(pHddTdlsCtx->pAdapter, |
| 401 | &pHddTdlsCtx->peerUpdateTimer, |
| 402 | pHddTdlsCtx->threshold_config.tx_period_t); |
Gopichand Nakkala | eb69b60 | 2013-02-27 11:40:31 -0800 | [diff] [blame] | 403 | mutex_unlock(&tdls_lock); |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 404 | } |
| 405 | |
Chilam Ng | 1279e23 | 2013-01-25 15:06:52 -0800 | [diff] [blame] | 406 | static v_VOID_t wlan_hdd_tdls_idle_cb( v_PVOID_t userData ) |
| 407 | { |
Lee Hoonki | c1262f2 | 2013-01-24 21:59:00 -0800 | [diff] [blame] | 408 | #ifdef CONFIG_TDLS_IMPLICIT |
Chilam Ng | 1279e23 | 2013-01-25 15:06:52 -0800 | [diff] [blame] | 409 | hddTdlsPeer_t *curr_peer = (hddTdlsPeer_t *)userData; |
| 410 | |
Rajesh Chauhan | 1ace600 | 2013-04-18 18:08:21 -0700 | [diff] [blame] | 411 | if (NULL == curr_peer) |
| 412 | { |
| 413 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 414 | "%s: Invalid tdls idle timer expired", __func__); |
| 415 | return; |
| 416 | } |
| 417 | |
| 418 | VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
| 419 | "%s: Tx/Rx Idle " MAC_ADDRESS_STR " tx_pkt: %d, rx_pkt: %d, idle_packet_n: %d\n", |
| 420 | __func__, MAC_ADDR_ARRAY(curr_peer->peerMac), |
| 421 | curr_peer->tx_pkt, |
| 422 | curr_peer->rx_pkt, |
| 423 | curr_peer->pHddTdlsCtx->threshold_config.idle_packet_n); |
| 424 | |
Gopichand Nakkala | eb69b60 | 2013-02-27 11:40:31 -0800 | [diff] [blame] | 425 | if (mutex_lock_interruptible(&tdls_lock)) |
Gopichand Nakkala | 91b0926 | 2013-02-10 14:27:02 -0800 | [diff] [blame] | 426 | { |
| 427 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 428 | "%s: unable to lock list", __func__); |
| 429 | return; |
| 430 | } |
Hoonki Lee | 5a4b217 | 2013-01-29 01:45:53 -0800 | [diff] [blame] | 431 | |
Rajesh Chauhan | 1ace600 | 2013-04-18 18:08:21 -0700 | [diff] [blame] | 432 | /* Check tx/rx statistics on this tdls link for recent activities and |
| 433 | * then decide whether to tear down the link or keep it. |
| 434 | */ |
| 435 | 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)) |
| 436 | { |
| 437 | /* this tdls link got back to normal, so keep it */ |
| 438 | VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
| 439 | "%s: tdls link to " MAC_ADDRESS_STR " back to normal, will stay", |
| 440 | __func__, MAC_ADDR_ARRAY(curr_peer->peerMac)); |
| 441 | } |
| 442 | else |
| 443 | { |
| 444 | /* this tdls link needs to get torn down */ |
| 445 | VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
| 446 | "%s: trigger tdls link to " MAC_ADDRESS_STR " down", |
| 447 | __func__, MAC_ADDR_ARRAY(curr_peer->peerMac)); |
| 448 | |
| 449 | wlan_hdd_tdls_indicate_teardown(curr_peer->pHddTdlsCtx->pAdapter, |
| 450 | curr_peer, |
| 451 | eSIR_MAC_TDLS_TEARDOWN_UNSPEC_REASON); |
| 452 | } |
Gopichand Nakkala | eb69b60 | 2013-02-27 11:40:31 -0800 | [diff] [blame] | 453 | mutex_unlock(&tdls_lock); |
Chilam Ng | 1279e23 | 2013-01-25 15:06:52 -0800 | [diff] [blame] | 454 | #endif |
| 455 | } |
| 456 | |
Gopichand Nakkala | 75e7b28 | 2013-03-15 18:37:13 -0700 | [diff] [blame] | 457 | static v_VOID_t wlan_hdd_tdls_discovery_timeout_peer_cb(v_PVOID_t userData) |
| 458 | { |
Gopichand Nakkala | ccd3a38 | 2013-03-19 13:56:10 -0700 | [diff] [blame] | 459 | int i; |
| 460 | struct list_head *head; |
| 461 | hddTdlsPeer_t *tmp; |
| 462 | struct list_head *pos, *q; |
Gopichand Nakkala | 75e7b28 | 2013-03-15 18:37:13 -0700 | [diff] [blame] | 463 | tdlsCtx_t *pHddTdlsCtx; |
| 464 | |
Gopichand Nakkala | ccd3a38 | 2013-03-19 13:56:10 -0700 | [diff] [blame] | 465 | if (mutex_lock_interruptible(&tdls_lock)) |
| 466 | { |
| 467 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 468 | "%s: unable to lock list", __func__); |
| 469 | return ; |
| 470 | } |
Gopichand Nakkala | 75e7b28 | 2013-03-15 18:37:13 -0700 | [diff] [blame] | 471 | pHddTdlsCtx = (tdlsCtx_t *)userData; |
Gopichand Nakkala | ccd3a38 | 2013-03-19 13:56:10 -0700 | [diff] [blame] | 472 | |
| 473 | if ( NULL == pHddTdlsCtx ) |
| 474 | { |
| 475 | mutex_unlock(&tdls_lock); |
| 476 | return ; |
| 477 | } |
| 478 | |
| 479 | for (i = 0; i < 256; i++) { |
| 480 | head = &pHddTdlsCtx->peer_list[i]; |
| 481 | list_for_each_safe (pos, q, head) { |
| 482 | tmp = list_entry(pos, hddTdlsPeer_t, node); |
| 483 | if (eTDLS_LINK_DISCOVERING == tmp->link_status) |
| 484 | { |
| 485 | VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
| 486 | "%s: " MAC_ADDRESS_STR " to idle state", __func__, |
| 487 | MAC_ADDR_ARRAY(tmp->peerMac)); |
| 488 | tmp->link_status = eTDLS_LINK_IDLE; |
| 489 | } |
| 490 | } |
| 491 | } |
Gopichand Nakkala | 75e7b28 | 2013-03-15 18:37:13 -0700 | [diff] [blame] | 492 | |
| 493 | pHddTdlsCtx->discovery_sent_cnt = 0; |
Gopichand Nakkala | 34d1b06 | 2013-03-19 15:28:33 -0700 | [diff] [blame] | 494 | wlan_hdd_tdls_check_power_save_prohibited(pHddTdlsCtx->pAdapter); |
Gopichand Nakkala | ccd3a38 | 2013-03-19 13:56:10 -0700 | [diff] [blame] | 495 | |
| 496 | mutex_unlock(&tdls_lock); |
| 497 | |
Gopichand Nakkala | 75e7b28 | 2013-03-15 18:37:13 -0700 | [diff] [blame] | 498 | wlan_hdd_tdls_check_bmps(pHddTdlsCtx->pAdapter); |
| 499 | |
| 500 | return; |
| 501 | } |
| 502 | |
Hoonki Lee | 1462135 | 2013-04-16 17:51:19 -0700 | [diff] [blame] | 503 | static v_VOID_t wlan_hdd_tdls_initiator_wait_cb( v_PVOID_t userData ) |
| 504 | { |
| 505 | hddTdlsPeer_t *curr_peer = (hddTdlsPeer_t *)userData; |
| 506 | tdlsCtx_t *pHddTdlsCtx; |
| 507 | |
| 508 | if ( NULL == curr_peer ) |
| 509 | return; |
| 510 | |
| 511 | pHddTdlsCtx = curr_peer->pHddTdlsCtx; |
| 512 | |
| 513 | if ( NULL == pHddTdlsCtx ) |
| 514 | return; |
| 515 | |
| 516 | WLANTL_ResumeDataTx( (WLAN_HDD_GET_CTX(pHddTdlsCtx->pAdapter))->pvosContext, |
| 517 | (v_U8_t *)&curr_peer->staId); |
| 518 | } |
| 519 | |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 520 | static void wlan_hdd_tdls_free_list(tdlsCtx_t *pHddTdlsCtx) |
Gopichand Nakkala | 91b0926 | 2013-02-10 14:27:02 -0800 | [diff] [blame] | 521 | { |
| 522 | int i; |
| 523 | struct list_head *head; |
| 524 | hddTdlsPeer_t *tmp; |
| 525 | struct list_head *pos, *q; |
| 526 | |
| 527 | if (NULL == pHddTdlsCtx) return; |
| 528 | |
Gopichand Nakkala | 91b0926 | 2013-02-10 14:27:02 -0800 | [diff] [blame] | 529 | |
| 530 | for (i = 0; i < 256; i++) { |
| 531 | head = &pHddTdlsCtx->peer_list[i]; |
| 532 | list_for_each_safe (pos, q, head) { |
| 533 | tmp = list_entry(pos, hddTdlsPeer_t, node); |
| 534 | list_del(pos); |
| 535 | vos_mem_free(tmp); |
| 536 | } |
| 537 | } |
Gopichand Nakkala | 91b0926 | 2013-02-10 14:27:02 -0800 | [diff] [blame] | 538 | } |
| 539 | |
Hoonki Lee | 2751190 | 2013-03-14 18:19:06 -0700 | [diff] [blame] | 540 | int wlan_hdd_tdls_init(hdd_adapter_t *pAdapter) |
Chilam Ng | 0112041 | 2013-02-19 18:32:21 -0800 | [diff] [blame] | 541 | { |
Chilam Ng | 0112041 | 2013-02-19 18:32:21 -0800 | [diff] [blame] | 542 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter ); |
Hoonki Lee | 2751190 | 2013-03-14 18:19:06 -0700 | [diff] [blame] | 543 | tdlsCtx_t *pHddTdlsCtx; |
Chilam Ng | 0112041 | 2013-02-19 18:32:21 -0800 | [diff] [blame] | 544 | int i; |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 545 | v_U8_t staIdx; |
Chilam Ng | 0112041 | 2013-02-19 18:32:21 -0800 | [diff] [blame] | 546 | |
Hoonki Lee | 2751190 | 2013-03-14 18:19:06 -0700 | [diff] [blame] | 547 | mutex_init(&tdls_lock); |
Chilam Ng | 0112041 | 2013-02-19 18:32:21 -0800 | [diff] [blame] | 548 | |
Hoonki Lee | 2751190 | 2013-03-14 18:19:06 -0700 | [diff] [blame] | 549 | if ((FALSE == pHddCtx->cfg_ini->fEnableTDLSSupport) || |
| 550 | (FALSE == sme_IsFeatureSupportedByFW(TDLS))) |
| 551 | { |
| 552 | pHddCtx->tdls_mode = eTDLS_SUPPORT_NOT_ENABLED; |
| 553 | pAdapter->sessionCtx.station.pHddTdlsCtx = NULL; |
| 554 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s TDLS not enabled (%d) or FW doesn't support (%d)!", |
| 555 | __func__, pHddCtx->cfg_ini->fEnableTDLSSupport, |
| 556 | sme_IsFeatureSupportedByFW(TDLS)); |
| 557 | return 0; |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 558 | } |
| 559 | |
Hoonki Lee | 2751190 | 2013-03-14 18:19:06 -0700 | [diff] [blame] | 560 | pHddTdlsCtx = vos_mem_malloc(sizeof(tdlsCtx_t)); |
| 561 | |
| 562 | if (NULL == pHddTdlsCtx) { |
| 563 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s malloc failed!", __func__); |
| 564 | pAdapter->sessionCtx.station.pHddTdlsCtx = NULL; |
| 565 | return -1; |
| 566 | } |
| 567 | |
| 568 | pAdapter->sessionCtx.station.pHddTdlsCtx = pHddTdlsCtx; |
| 569 | |
| 570 | /* initialize TDLS global context */ |
| 571 | pHddCtx->connected_peer_count = 0; |
Gopichand Nakkala | ccd3a38 | 2013-03-19 13:56:10 -0700 | [diff] [blame] | 572 | sme_SetTdlsPowerSaveProhibited(WLAN_HDD_GET_HAL_CTX(pAdapter), 0); |
Hoonki Lee | 2751190 | 2013-03-14 18:19:06 -0700 | [diff] [blame] | 573 | |
Hoonki Lee | 93e67ff | 2013-03-19 15:49:25 -0700 | [diff] [blame] | 574 | pHddCtx->tdls_scan_ctxt.magic = 0; |
Hoonki Lee | fb8df67 | 2013-04-10 18:20:34 -0700 | [diff] [blame] | 575 | pHddCtx->tdls_scan_ctxt.attempt = 0; |
| 576 | pHddCtx->tdls_scan_ctxt.reject = 0; |
Hoonki Lee | 93e67ff | 2013-03-19 15:49:25 -0700 | [diff] [blame] | 577 | pHddCtx->tdls_scan_ctxt.scan_request = NULL; |
| 578 | |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 579 | for (staIdx = 0; staIdx < HDD_MAX_NUM_TDLS_STA; staIdx++) |
| 580 | { |
| 581 | pHddCtx->tdlsConnInfo[staIdx].staId = 0; |
| 582 | pHddCtx->tdlsConnInfo[staIdx].sessionId = 255; |
| 583 | vos_mem_zero(&pHddCtx->tdlsConnInfo[staIdx].peerMac, |
| 584 | sizeof(v_MACADDR_t)) ; |
Chilam Ng | 0112041 | 2013-02-19 18:32:21 -0800 | [diff] [blame] | 585 | } |
| 586 | |
Hoonki Lee | 2751190 | 2013-03-14 18:19:06 -0700 | [diff] [blame] | 587 | /* initialize TDLS pAdater context */ |
| 588 | vos_mem_zero(pHddTdlsCtx, sizeof(tdlsCtx_t)); |
| 589 | |
| 590 | pHddTdlsCtx->pAdapter = pAdapter; |
| 591 | |
| 592 | for (i = 0; i < 256; i++) |
| 593 | { |
| 594 | INIT_LIST_HEAD(&pHddTdlsCtx->peer_list[i]); |
| 595 | } |
| 596 | |
Hoonki Lee | d37cbb3 | 2013-04-20 00:31:14 -0700 | [diff] [blame] | 597 | pHddTdlsCtx->curr_candidate = NULL; |
| 598 | pHddTdlsCtx->magic = 0; |
| 599 | |
| 600 | #ifdef TDLS_USE_SEPARATE_DISCOVERY_TIMER |
Chilam Ng | 0112041 | 2013-02-19 18:32:21 -0800 | [diff] [blame] | 601 | vos_timer_init(&pHddTdlsCtx->peerDiscoverTimer, |
| 602 | VOS_TIMER_TYPE_SW, |
| 603 | wlan_hdd_tdls_discover_peer_cb, |
| 604 | pHddTdlsCtx); |
Hoonki Lee | d37cbb3 | 2013-04-20 00:31:14 -0700 | [diff] [blame] | 605 | #endif |
Chilam Ng | 0112041 | 2013-02-19 18:32:21 -0800 | [diff] [blame] | 606 | |
| 607 | vos_timer_init(&pHddTdlsCtx->peerUpdateTimer, |
| 608 | VOS_TIMER_TYPE_SW, |
| 609 | wlan_hdd_tdls_update_peer_cb, |
| 610 | pHddTdlsCtx); |
Gopichand Nakkala | 75e7b28 | 2013-03-15 18:37:13 -0700 | [diff] [blame] | 611 | vos_timer_init(&pHddTdlsCtx->peerDiscoveryTimeoutTimer, |
| 612 | VOS_TIMER_TYPE_SW, |
| 613 | wlan_hdd_tdls_discovery_timeout_peer_cb, |
| 614 | pHddTdlsCtx); |
Chilam Ng | 0112041 | 2013-02-19 18:32:21 -0800 | [diff] [blame] | 615 | |
Hoonki Lee | 2751190 | 2013-03-14 18:19:06 -0700 | [diff] [blame] | 616 | /* remember configuration even if it is not used right now. it could be used later */ |
| 617 | pHddTdlsCtx->threshold_config.tx_period_t = pHddCtx->cfg_ini->fTDLSTxStatsPeriod; |
| 618 | pHddTdlsCtx->threshold_config.tx_packet_n = pHddCtx->cfg_ini->fTDLSTxPacketThreshold; |
| 619 | pHddTdlsCtx->threshold_config.discovery_period_t = pHddCtx->cfg_ini->fTDLSDiscoveryPeriod; |
| 620 | pHddTdlsCtx->threshold_config.discovery_tries_n = pHddCtx->cfg_ini->fTDLSMaxDiscoveryAttempt; |
| 621 | pHddTdlsCtx->threshold_config.idle_timeout_t = pHddCtx->cfg_ini->fTDLSIdleTimeout; |
| 622 | pHddTdlsCtx->threshold_config.idle_packet_n = pHddCtx->cfg_ini->fTDLSIdlePacketThreshold; |
| 623 | pHddTdlsCtx->threshold_config.rssi_hysteresis = pHddCtx->cfg_ini->fTDLSRSSIHysteresis; |
| 624 | pHddTdlsCtx->threshold_config.rssi_trigger_threshold = pHddCtx->cfg_ini->fTDLSRSSITriggerThreshold; |
| 625 | pHddTdlsCtx->threshold_config.rssi_teardown_threshold = pHddCtx->cfg_ini->fTDLSRSSITeardownThreshold; |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 626 | |
Chilam Ng | 0112041 | 2013-02-19 18:32:21 -0800 | [diff] [blame] | 627 | if (FALSE == pHddCtx->cfg_ini->fEnableTDLSImplicitTrigger) |
Hoonki Lee | 387663d | 2013-02-05 18:08:43 -0800 | [diff] [blame] | 628 | { |
Chilam Ng | 0112041 | 2013-02-19 18:32:21 -0800 | [diff] [blame] | 629 | pHddCtx->tdls_mode = eTDLS_SUPPORT_EXPLICIT_TRIGGER_ONLY; |
Hoonki Lee | bf870f3 | 2013-01-19 15:53:30 +0530 | [diff] [blame] | 630 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s TDLS Implicit trigger not enabled!", __func__); |
Hoonki Lee | bf870f3 | 2013-01-19 15:53:30 +0530 | [diff] [blame] | 631 | } |
Hoonki Lee | 2751190 | 2013-03-14 18:19:06 -0700 | [diff] [blame] | 632 | else |
| 633 | { |
| 634 | pHddCtx->tdls_mode = eTDLS_SUPPORT_ENABLED; |
Hoonki Lee | 2751190 | 2013-03-14 18:19:06 -0700 | [diff] [blame] | 635 | } |
| 636 | |
| 637 | return 0; |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 638 | } |
| 639 | |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 640 | void wlan_hdd_tdls_exit(hdd_adapter_t *pAdapter) |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 641 | { |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 642 | tdlsCtx_t *pHddTdlsCtx; |
Hoonki Lee | 93e67ff | 2013-03-19 15:49:25 -0700 | [diff] [blame] | 643 | hdd_context_t *pHddCtx; |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 644 | |
Gopichand Nakkala | eb69b60 | 2013-02-27 11:40:31 -0800 | [diff] [blame] | 645 | if (mutex_lock_interruptible(&tdls_lock)) |
| 646 | { |
| 647 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 648 | "%s: unable to lock list", __func__); |
| 649 | return; |
| 650 | } |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 651 | |
Hoonki Lee | 93e67ff | 2013-03-19 15:49:25 -0700 | [diff] [blame] | 652 | pHddCtx = WLAN_HDD_GET_CTX( pAdapter ); |
| 653 | if (NULL == pHddCtx) |
| 654 | { |
| 655 | mutex_unlock(&tdls_lock); |
| 656 | return; |
| 657 | } |
| 658 | |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 659 | pHddTdlsCtx = WLAN_HDD_GET_TDLS_CTX_PTR(pAdapter); |
Gopichand Nakkala | 91b0926 | 2013-02-10 14:27:02 -0800 | [diff] [blame] | 660 | if (NULL == pHddTdlsCtx) |
| 661 | { |
Gopichand Nakkala | eb69b60 | 2013-02-27 11:40:31 -0800 | [diff] [blame] | 662 | mutex_unlock(&tdls_lock); |
Hoonki Lee | bfee034 | 2013-01-21 16:43:45 -0800 | [diff] [blame] | 663 | hddLog(VOS_TRACE_LEVEL_WARN, "%s TDLS not enabled, exiting!", __func__); |
| 664 | return; |
| 665 | } |
| 666 | |
Gopichand Nakkala | 91b0926 | 2013-02-10 14:27:02 -0800 | [diff] [blame] | 667 | /* must stop timer here before freeing peer list, because peerIdleTimer is |
| 668 | part of peer list structure. */ |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 669 | wlan_hdd_tdls_timers_destroy(pHddTdlsCtx); |
| 670 | wlan_hdd_tdls_free_list(pHddTdlsCtx); |
Chilam Ng | a75d8b6 | 2013-01-29 01:35:59 -0800 | [diff] [blame] | 671 | |
Hoonki Lee | 93e67ff | 2013-03-19 15:49:25 -0700 | [diff] [blame] | 672 | wlan_hdd_tdls_free_scan_request(&pHddCtx->tdls_scan_ctxt); |
| 673 | |
Chilam Ng | a75d8b6 | 2013-01-29 01:35:59 -0800 | [diff] [blame] | 674 | vos_mem_free(pHddTdlsCtx); |
| 675 | pHddTdlsCtx = NULL; |
Gopichand Nakkala | eb69b60 | 2013-02-27 11:40:31 -0800 | [diff] [blame] | 676 | mutex_unlock(&tdls_lock); |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 677 | } |
| 678 | |
Gopichand Nakkala | c369458 | 2013-02-13 20:51:22 -0800 | [diff] [blame] | 679 | /* stop all the tdls timers running */ |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 680 | static void wlan_hdd_tdls_timers_stop(tdlsCtx_t *pHddTdlsCtx) |
Gopichand Nakkala | c369458 | 2013-02-13 20:51:22 -0800 | [diff] [blame] | 681 | { |
| 682 | int i; |
| 683 | struct list_head *head; |
| 684 | struct list_head *pos; |
| 685 | hddTdlsPeer_t *curr_peer; |
| 686 | |
Hoonki Lee | d37cbb3 | 2013-04-20 00:31:14 -0700 | [diff] [blame] | 687 | #ifdef TDLS_USE_SEPARATE_DISCOVERY_TIMER |
Gopichand Nakkala | c369458 | 2013-02-13 20:51:22 -0800 | [diff] [blame] | 688 | vos_timer_stop(&pHddTdlsCtx->peerDiscoverTimer); |
Hoonki Lee | d37cbb3 | 2013-04-20 00:31:14 -0700 | [diff] [blame] | 689 | #endif |
Gopichand Nakkala | c369458 | 2013-02-13 20:51:22 -0800 | [diff] [blame] | 690 | vos_timer_stop(&pHddTdlsCtx->peerUpdateTimer); |
Gopichand Nakkala | 75e7b28 | 2013-03-15 18:37:13 -0700 | [diff] [blame] | 691 | vos_timer_stop(&pHddTdlsCtx->peerDiscoveryTimeoutTimer); |
Gopichand Nakkala | c369458 | 2013-02-13 20:51:22 -0800 | [diff] [blame] | 692 | |
| 693 | for (i = 0; i < 256; i++) |
| 694 | { |
| 695 | head = &pHddTdlsCtx->peer_list[i]; |
| 696 | |
| 697 | list_for_each (pos, head) { |
| 698 | curr_peer = list_entry (pos, hddTdlsPeer_t, node); |
| 699 | |
| 700 | VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
Chilam Ng | 0112041 | 2013-02-19 18:32:21 -0800 | [diff] [blame] | 701 | "%s: " MAC_ADDRESS_STR " -> stop idle timer", |
Gopichand Nakkala | c369458 | 2013-02-13 20:51:22 -0800 | [diff] [blame] | 702 | __func__, |
Chilam Ng | 0112041 | 2013-02-19 18:32:21 -0800 | [diff] [blame] | 703 | MAC_ADDR_ARRAY(curr_peer->peerMac)); |
Gopichand Nakkala | c369458 | 2013-02-13 20:51:22 -0800 | [diff] [blame] | 704 | vos_timer_stop ( &curr_peer->peerIdleTimer ); |
Hoonki Lee | 1462135 | 2013-04-16 17:51:19 -0700 | [diff] [blame] | 705 | vos_timer_stop( &curr_peer->initiatorWaitTimeoutTimer ); |
Gopichand Nakkala | c369458 | 2013-02-13 20:51:22 -0800 | [diff] [blame] | 706 | } |
| 707 | } |
Gopichand Nakkala | c369458 | 2013-02-13 20:51:22 -0800 | [diff] [blame] | 708 | } |
| 709 | |
| 710 | /* destroy all the tdls timers running */ |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 711 | static void wlan_hdd_tdls_timers_destroy(tdlsCtx_t *pHddTdlsCtx) |
Gopichand Nakkala | 91b0926 | 2013-02-10 14:27:02 -0800 | [diff] [blame] | 712 | { |
| 713 | int i; |
| 714 | struct list_head *head; |
| 715 | struct list_head *pos; |
| 716 | hddTdlsPeer_t *curr_peer; |
| 717 | |
Hoonki Lee | d37cbb3 | 2013-04-20 00:31:14 -0700 | [diff] [blame] | 718 | #ifdef TDLS_USE_SEPARATE_DISCOVERY_TIMER |
Gopichand Nakkala | 91b0926 | 2013-02-10 14:27:02 -0800 | [diff] [blame] | 719 | vos_timer_stop(&pHddTdlsCtx->peerDiscoverTimer); |
| 720 | vos_timer_destroy(&pHddTdlsCtx->peerDiscoverTimer); |
Hoonki Lee | d37cbb3 | 2013-04-20 00:31:14 -0700 | [diff] [blame] | 721 | #endif |
Gopichand Nakkala | 91b0926 | 2013-02-10 14:27:02 -0800 | [diff] [blame] | 722 | vos_timer_stop(&pHddTdlsCtx->peerUpdateTimer); |
| 723 | vos_timer_destroy(&pHddTdlsCtx->peerUpdateTimer); |
Gopichand Nakkala | 75e7b28 | 2013-03-15 18:37:13 -0700 | [diff] [blame] | 724 | vos_timer_stop(&pHddTdlsCtx->peerDiscoveryTimeoutTimer); |
| 725 | vos_timer_destroy(&pHddTdlsCtx->peerDiscoveryTimeoutTimer); |
Gopichand Nakkala | 91b0926 | 2013-02-10 14:27:02 -0800 | [diff] [blame] | 726 | |
| 727 | for (i = 0; i < 256; i++) |
| 728 | { |
| 729 | head = &pHddTdlsCtx->peer_list[i]; |
| 730 | |
| 731 | list_for_each (pos, head) { |
| 732 | curr_peer = list_entry (pos, hddTdlsPeer_t, node); |
| 733 | |
| 734 | VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
Chilam Ng | 0112041 | 2013-02-19 18:32:21 -0800 | [diff] [blame] | 735 | "%s: " MAC_ADDRESS_STR " -> destroy idle timer", |
Gopichand Nakkala | 91b0926 | 2013-02-10 14:27:02 -0800 | [diff] [blame] | 736 | __func__, |
Chilam Ng | 0112041 | 2013-02-19 18:32:21 -0800 | [diff] [blame] | 737 | MAC_ADDR_ARRAY(curr_peer->peerMac)); |
Gopichand Nakkala | 91b0926 | 2013-02-10 14:27:02 -0800 | [diff] [blame] | 738 | vos_timer_stop ( &curr_peer->peerIdleTimer ); |
| 739 | vos_timer_destroy ( &curr_peer->peerIdleTimer ); |
Hoonki Lee | 1462135 | 2013-04-16 17:51:19 -0700 | [diff] [blame] | 740 | vos_timer_stop(&curr_peer->initiatorWaitTimeoutTimer); |
| 741 | vos_timer_destroy(&curr_peer->initiatorWaitTimeoutTimer); |
Gopichand Nakkala | 91b0926 | 2013-02-10 14:27:02 -0800 | [diff] [blame] | 742 | } |
| 743 | } |
| 744 | } |
| 745 | |
Hoonki Lee | 387663d | 2013-02-05 18:08:43 -0800 | [diff] [blame] | 746 | /* if mac address exist, return pointer |
| 747 | if mac address doesn't exist, create a list and add, return pointer |
| 748 | return NULL if fails to get new mac address |
| 749 | */ |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 750 | 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] | 751 | { |
Hoonki Lee | 387663d | 2013-02-05 18:08:43 -0800 | [diff] [blame] | 752 | struct list_head *head; |
| 753 | hddTdlsPeer_t *peer; |
| 754 | u8 key; |
Gopichand Nakkala | 4ddf019 | 2013-03-27 13:41:20 -0700 | [diff] [blame] | 755 | tdlsCtx_t *pHddTdlsCtx; |
Hoonki Lee | bfee034 | 2013-01-21 16:43:45 -0800 | [diff] [blame] | 756 | |
Hoonki Lee | 387663d | 2013-02-05 18:08:43 -0800 | [diff] [blame] | 757 | /* if already there, just update */ |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 758 | peer = wlan_hdd_tdls_find_peer(pAdapter, mac); |
Hoonki Lee | 387663d | 2013-02-05 18:08:43 -0800 | [diff] [blame] | 759 | if (peer != NULL) |
| 760 | { |
| 761 | return peer; |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 762 | } |
| 763 | |
Hoonki Lee | 387663d | 2013-02-05 18:08:43 -0800 | [diff] [blame] | 764 | /* not found, allocate and add the list */ |
| 765 | peer = vos_mem_malloc(sizeof(hddTdlsPeer_t)); |
| 766 | if (NULL == peer) { |
| 767 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s peer malloc failed!", __func__); |
| 768 | return NULL; |
| 769 | } |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 770 | |
Gopichand Nakkala | eb69b60 | 2013-02-27 11:40:31 -0800 | [diff] [blame] | 771 | if (mutex_lock_interruptible(&tdls_lock)) |
Hoonki Lee | 387663d | 2013-02-05 18:08:43 -0800 | [diff] [blame] | 772 | { |
| 773 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 774 | "%s: unable to lock list", __func__); |
Gopichand Nakkala | 4ddf019 | 2013-03-27 13:41:20 -0700 | [diff] [blame] | 775 | vos_mem_free(peer); |
Hoonki Lee | 387663d | 2013-02-05 18:08:43 -0800 | [diff] [blame] | 776 | return NULL; |
| 777 | } |
Gopichand Nakkala | 4ddf019 | 2013-03-27 13:41:20 -0700 | [diff] [blame] | 778 | pHddTdlsCtx = WLAN_HDD_GET_TDLS_CTX_PTR(pAdapter); |
| 779 | |
| 780 | if (NULL == pHddTdlsCtx) |
| 781 | { |
| 782 | vos_mem_free(peer); |
| 783 | mutex_unlock(&tdls_lock); |
| 784 | return NULL; |
| 785 | } |
| 786 | |
| 787 | key = wlan_hdd_tdls_hash_key(mac); |
| 788 | head = &pHddTdlsCtx->peer_list[key]; |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 789 | |
Hoonki Lee | 387663d | 2013-02-05 18:08:43 -0800 | [diff] [blame] | 790 | vos_mem_zero(peer, sizeof(hddTdlsPeer_t)); |
| 791 | vos_mem_copy(peer->peerMac, mac, sizeof(peer->peerMac)); |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 792 | peer->pHddTdlsCtx = pHddTdlsCtx; |
Hoonki Lee | 387663d | 2013-02-05 18:08:43 -0800 | [diff] [blame] | 793 | |
Gopichand Nakkala | 91b0926 | 2013-02-10 14:27:02 -0800 | [diff] [blame] | 794 | vos_timer_init(&peer->peerIdleTimer, |
| 795 | VOS_TIMER_TYPE_SW, |
| 796 | wlan_hdd_tdls_idle_cb, |
| 797 | peer); |
| 798 | |
Hoonki Lee | 1462135 | 2013-04-16 17:51:19 -0700 | [diff] [blame] | 799 | vos_timer_init(&peer->initiatorWaitTimeoutTimer, |
| 800 | VOS_TIMER_TYPE_SW, |
| 801 | wlan_hdd_tdls_initiator_wait_cb, |
| 802 | peer); |
| 803 | |
Hoonki Lee | 387663d | 2013-02-05 18:08:43 -0800 | [diff] [blame] | 804 | list_add_tail(&peer->node, head); |
Gopichand Nakkala | eb69b60 | 2013-02-27 11:40:31 -0800 | [diff] [blame] | 805 | mutex_unlock(&tdls_lock); |
Hoonki Lee | 387663d | 2013-02-05 18:08:43 -0800 | [diff] [blame] | 806 | |
| 807 | return peer; |
| 808 | } |
| 809 | |
Gopichand Nakkala | 34d1b06 | 2013-03-19 15:28:33 -0700 | [diff] [blame] | 810 | int wlan_hdd_tdls_set_cap(hdd_adapter_t *pAdapter, |
Hoonki Lee | 2751190 | 2013-03-14 18:19:06 -0700 | [diff] [blame] | 811 | u8* mac, |
| 812 | tTDLSCapType cap) |
| 813 | { |
| 814 | hddTdlsPeer_t *curr_peer; |
| 815 | |
Gopichand Nakkala | 34d1b06 | 2013-03-19 15:28:33 -0700 | [diff] [blame] | 816 | curr_peer = wlan_hdd_tdls_get_peer(pAdapter, mac); |
Hoonki Lee | 2751190 | 2013-03-14 18:19:06 -0700 | [diff] [blame] | 817 | if (curr_peer == NULL) |
Gopichand Nakkala | 34d1b06 | 2013-03-19 15:28:33 -0700 | [diff] [blame] | 818 | return -1; |
Hoonki Lee | 2751190 | 2013-03-14 18:19:06 -0700 | [diff] [blame] | 819 | |
| 820 | curr_peer->tdls_support = cap; |
| 821 | |
Gopichand Nakkala | 34d1b06 | 2013-03-19 15:28:33 -0700 | [diff] [blame] | 822 | return 0; |
Hoonki Lee | 2751190 | 2013-03-14 18:19:06 -0700 | [diff] [blame] | 823 | } |
| 824 | |
Gopichand Nakkala | 8b00c63 | 2013-03-08 19:47:52 -0800 | [diff] [blame] | 825 | void wlan_hdd_tdls_set_peer_link_status(hddTdlsPeer_t *curr_peer, tTDLSLinkStatus status) |
Hoonki Lee | 387663d | 2013-02-05 18:08:43 -0800 | [diff] [blame] | 826 | { |
| 827 | if (curr_peer == NULL) |
| 828 | return; |
| 829 | |
Gopichand Nakkala | 8b00c63 | 2013-03-08 19:47:52 -0800 | [diff] [blame] | 830 | 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] | 831 | MAC_ADDR_ARRAY(curr_peer->peerMac), status); |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 832 | |
| 833 | curr_peer->link_status = status; |
| 834 | |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 835 | } |
| 836 | |
Gopichand Nakkala | 8b00c63 | 2013-03-08 19:47:52 -0800 | [diff] [blame] | 837 | void wlan_hdd_tdls_set_link_status(hdd_adapter_t *pAdapter, |
| 838 | u8* mac, |
| 839 | tTDLSLinkStatus linkStatus) |
| 840 | { |
| 841 | hddTdlsPeer_t *curr_peer; |
| 842 | |
| 843 | curr_peer = wlan_hdd_tdls_find_peer(pAdapter, mac); |
| 844 | if (curr_peer == NULL) |
| 845 | return; |
| 846 | |
| 847 | curr_peer->link_status= linkStatus; |
| 848 | |
| 849 | return; |
| 850 | } |
| 851 | |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 852 | 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] | 853 | { |
| 854 | hddTdlsPeer_t *curr_peer; |
Gopichand Nakkala | 75e7b28 | 2013-03-15 18:37:13 -0700 | [diff] [blame] | 855 | tdlsCtx_t *pHddTdlsCtx = WLAN_HDD_GET_TDLS_CTX_PTR(pAdapter); |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 856 | |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 857 | curr_peer = wlan_hdd_tdls_get_peer(pAdapter, mac); |
Gopichand Nakkala | 75e7b28 | 2013-03-15 18:37:13 -0700 | [diff] [blame] | 858 | |
| 859 | if (NULL == curr_peer) |
Hoonki Lee | 387663d | 2013-02-05 18:08:43 -0800 | [diff] [blame] | 860 | return -1; |
Gopichand Nakkala | 75e7b28 | 2013-03-15 18:37:13 -0700 | [diff] [blame] | 861 | |
| 862 | if (pHddTdlsCtx->discovery_sent_cnt) |
| 863 | pHddTdlsCtx->discovery_sent_cnt--; |
| 864 | |
Gopichand Nakkala | 34d1b06 | 2013-03-19 15:28:33 -0700 | [diff] [blame] | 865 | wlan_hdd_tdls_check_power_save_prohibited(pAdapter); |
Gopichand Nakkala | 75e7b28 | 2013-03-15 18:37:13 -0700 | [diff] [blame] | 866 | if (0 == pHddTdlsCtx->discovery_sent_cnt) |
Gopichand Nakkala | ccd3a38 | 2013-03-19 13:56:10 -0700 | [diff] [blame] | 867 | { |
Gopichand Nakkala | 75e7b28 | 2013-03-15 18:37:13 -0700 | [diff] [blame] | 868 | vos_timer_stop(&pHddTdlsCtx->peerDiscoveryTimeoutTimer); |
Gopichand Nakkala | ccd3a38 | 2013-03-19 13:56:10 -0700 | [diff] [blame] | 869 | } |
Gopichand Nakkala | 75e7b28 | 2013-03-15 18:37:13 -0700 | [diff] [blame] | 870 | |
Gopichand Nakkala | 901e892 | 2013-03-04 23:45:58 -0800 | [diff] [blame] | 871 | VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
Gopichand Nakkala | 75e7b28 | 2013-03-15 18:37:13 -0700 | [diff] [blame] | 872 | "Discovery(%lu) Response from " MAC_ADDRESS_STR " link_status %d", |
| 873 | pHddTdlsCtx->discovery_sent_cnt, MAC_ADDR_ARRAY(curr_peer->peerMac), |
| 874 | curr_peer->link_status); |
| 875 | |
Gopichand Nakkala | 8b00c63 | 2013-03-08 19:47:52 -0800 | [diff] [blame] | 876 | if (eTDLS_LINK_DISCOVERING == curr_peer->link_status) |
Gopichand Nakkala | 901e892 | 2013-03-04 23:45:58 -0800 | [diff] [blame] | 877 | { |
Shailender Karmuchi | 13c0d08 | 2013-03-26 14:41:39 -0700 | [diff] [blame] | 878 | /* Since we are here, it means Throughput threshold is alredy met. Make sure RSSI |
| 879 | threshold is also met before setting up TDLS link*/ |
| 880 | if ((tANI_S32) curr_peer->rssi > (tANI_S32) pHddTdlsCtx->threshold_config.rssi_trigger_threshold) |
| 881 | { |
| 882 | curr_peer->link_status = eTDLS_LINK_DISCOVERED; |
| 883 | VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
| 884 | "Rssi Threshold met: "MAC_ADDRESS_STR" rssi = %d threshold= %d" , |
| 885 | MAC_ADDR_ARRAY(curr_peer->peerMac), curr_peer->rssi, |
| 886 | pHddTdlsCtx->threshold_config.rssi_trigger_threshold); |
| 887 | cfg80211_tdls_oper_request(pAdapter->dev, curr_peer->peerMac, NL80211_TDLS_SETUP, FALSE, GFP_KERNEL); |
| 888 | } |
| 889 | else |
| 890 | { |
| 891 | VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
| 892 | "Rssi Threshold not met: "MAC_ADDRESS_STR" rssi = %d threshold = %d ", |
| 893 | MAC_ADDR_ARRAY(curr_peer->peerMac), curr_peer->rssi, |
| 894 | pHddTdlsCtx->threshold_config.rssi_trigger_threshold); |
| 895 | curr_peer->link_status = eTDLS_LINK_IDLE; |
| 896 | } |
Gopichand Nakkala | 901e892 | 2013-03-04 23:45:58 -0800 | [diff] [blame] | 897 | } |
Gopichand Nakkala | ccd3a38 | 2013-03-19 13:56:10 -0700 | [diff] [blame] | 898 | else |
| 899 | { |
| 900 | wlan_hdd_tdls_check_bmps(pAdapter); |
| 901 | } |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 902 | |
Gopichand Nakkala | 901e892 | 2013-03-04 23:45:58 -0800 | [diff] [blame] | 903 | curr_peer->tdls_support = eTDLS_CAP_SUPPORTED; |
Hoonki Lee | 387663d | 2013-02-05 18:08:43 -0800 | [diff] [blame] | 904 | return 0; |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 905 | } |
| 906 | |
Gopichand Nakkala | 79ff85d | 2013-05-27 17:05:29 +0530 | [diff] [blame^] | 907 | int wlan_hdd_tdls_set_peer_caps(hdd_adapter_t *pAdapter, |
| 908 | u8 *mac, |
| 909 | tANI_U8 uapsdQueues, |
| 910 | tANI_U8 maxSp, |
| 911 | tANI_BOOLEAN isBufSta) |
| 912 | { |
| 913 | hddTdlsPeer_t *curr_peer; |
| 914 | |
| 915 | curr_peer = wlan_hdd_tdls_get_peer(pAdapter, mac); |
| 916 | if (curr_peer == NULL) |
| 917 | return -1; |
| 918 | |
| 919 | curr_peer->uapsdQueues = uapsdQueues; |
| 920 | curr_peer->maxSp = maxSp; |
| 921 | curr_peer->isBufSta = isBufSta; |
| 922 | return 0; |
| 923 | } |
| 924 | |
| 925 | int wlan_hdd_tdls_get_link_establish_params(hdd_adapter_t *pAdapter, u8 *mac, |
| 926 | tCsrTdlsLinkEstablishParams* tdlsLinkEstablishParams) |
| 927 | { |
| 928 | hddTdlsPeer_t *curr_peer; |
| 929 | |
| 930 | curr_peer = wlan_hdd_tdls_get_peer(pAdapter, mac); |
| 931 | if (curr_peer == NULL) |
| 932 | return -1; |
| 933 | |
| 934 | tdlsLinkEstablishParams->isResponder = curr_peer->is_responder; |
| 935 | tdlsLinkEstablishParams->uapsdQueues = curr_peer->uapsdQueues; |
| 936 | tdlsLinkEstablishParams->maxSp = curr_peer->maxSp; |
| 937 | tdlsLinkEstablishParams->isBufSta = curr_peer->isBufSta; |
| 938 | return 0; |
| 939 | } |
| 940 | |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 941 | 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] | 942 | { |
| 943 | hddTdlsPeer_t *curr_peer; |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 944 | |
Shailender Karmuchi | 13c0d08 | 2013-03-26 14:41:39 -0700 | [diff] [blame] | 945 | curr_peer = wlan_hdd_tdls_find_peer(pAdapter, mac); |
Hoonki Lee | 387663d | 2013-02-05 18:08:43 -0800 | [diff] [blame] | 946 | if (curr_peer == NULL) |
| 947 | return -1; |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 948 | |
| 949 | curr_peer->rssi = rxRssi; |
| 950 | |
Hoonki Lee | 387663d | 2013-02-05 18:08:43 -0800 | [diff] [blame] | 951 | return 0; |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 952 | } |
| 953 | |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 954 | 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] | 955 | { |
| 956 | hddTdlsPeer_t *curr_peer; |
| 957 | |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 958 | curr_peer = wlan_hdd_tdls_get_peer(pAdapter, mac); |
Gopichand Nakkala | 91b0926 | 2013-02-10 14:27:02 -0800 | [diff] [blame] | 959 | if (curr_peer == NULL) |
Hoonki Lee | a34dd89 | 2013-02-05 22:56:02 -0800 | [diff] [blame] | 960 | return -1; |
| 961 | |
| 962 | curr_peer->is_responder = responder; |
| 963 | |
| 964 | return 0; |
| 965 | } |
| 966 | |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 967 | int wlan_hdd_tdls_get_responder(hdd_adapter_t *pAdapter, u8 *mac) |
Hoonki Lee | a34dd89 | 2013-02-05 22:56:02 -0800 | [diff] [blame] | 968 | { |
| 969 | hddTdlsPeer_t *curr_peer; |
| 970 | |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 971 | curr_peer = wlan_hdd_tdls_find_peer(pAdapter, mac); |
Gopichand Nakkala | 91b0926 | 2013-02-10 14:27:02 -0800 | [diff] [blame] | 972 | if (curr_peer == NULL) |
Hoonki Lee | a34dd89 | 2013-02-05 22:56:02 -0800 | [diff] [blame] | 973 | return -1; |
| 974 | |
| 975 | return (curr_peer->is_responder); |
| 976 | } |
| 977 | |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 978 | 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] | 979 | { |
| 980 | hddTdlsPeer_t *curr_peer; |
| 981 | |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 982 | curr_peer = wlan_hdd_tdls_get_peer(pAdapter, mac); |
Hoonki Lee | 11f7dda | 2013-02-14 16:55:44 -0800 | [diff] [blame] | 983 | if (curr_peer == NULL) |
| 984 | return -1; |
| 985 | |
| 986 | curr_peer->signature = uSignature; |
| 987 | |
| 988 | return 0; |
| 989 | } |
| 990 | |
Hoonki Lee | a34dd89 | 2013-02-05 22:56:02 -0800 | [diff] [blame] | 991 | |
Hoonki Lee | 387663d | 2013-02-05 18:08:43 -0800 | [diff] [blame] | 992 | void wlan_hdd_tdls_extract_da(struct sk_buff *skb, u8 *mac) |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 993 | { |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 994 | memcpy(mac, skb->data, 6); |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 995 | } |
| 996 | |
Hoonki Lee | 387663d | 2013-02-05 18:08:43 -0800 | [diff] [blame] | 997 | void wlan_hdd_tdls_extract_sa(struct sk_buff *skb, u8 *mac) |
Chilam Ng | 1279e23 | 2013-01-25 15:06:52 -0800 | [diff] [blame] | 998 | { |
Chilam Ng | 1279e23 | 2013-01-25 15:06:52 -0800 | [diff] [blame] | 999 | memcpy(mac, skb->data+6, 6); |
Chilam Ng | 1279e23 | 2013-01-25 15:06:52 -0800 | [diff] [blame] | 1000 | } |
| 1001 | |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 1002 | 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] | 1003 | { |
Hoonki Lee | 387663d | 2013-02-05 18:08:43 -0800 | [diff] [blame] | 1004 | hddTdlsPeer_t *curr_peer; |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 1005 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 1006 | |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 1007 | if (eTDLS_SUPPORT_ENABLED != pHddCtx->tdls_mode) |
| 1008 | return -1; |
Hoonki Lee | bfee034 | 2013-01-21 16:43:45 -0800 | [diff] [blame] | 1009 | |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 1010 | curr_peer = wlan_hdd_tdls_get_peer(pAdapter, mac); |
Hoonki Lee | 387663d | 2013-02-05 18:08:43 -0800 | [diff] [blame] | 1011 | if (curr_peer == NULL) |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 1012 | return -1; |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 1013 | |
Chilam Ng | 1279e23 | 2013-01-25 15:06:52 -0800 | [diff] [blame] | 1014 | if (tx) |
| 1015 | curr_peer->tx_pkt++; |
| 1016 | else |
| 1017 | curr_peer->rx_pkt++; |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 1018 | |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 1019 | return 0; |
| 1020 | } |
| 1021 | |
Hoonki Lee | 2751190 | 2013-03-14 18:19:06 -0700 | [diff] [blame] | 1022 | static int wlan_hdd_tdls_check_config(tdls_config_params_t *config) |
| 1023 | { |
| 1024 | if (config->tdls > 2) |
| 1025 | { |
| 1026 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s invalid 1st argument %d. <0...2>", __func__, config->tdls); |
| 1027 | return -1; |
| 1028 | } |
| 1029 | if (config->tx_period_t < CFG_TDLS_TX_STATS_PERIOD_MIN || |
| 1030 | config->tx_period_t > CFG_TDLS_TX_STATS_PERIOD_MAX) |
| 1031 | { |
| 1032 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s invalid 2nd argument %d. <%d...%d>", __func__, config->tx_period_t, |
| 1033 | CFG_TDLS_TX_STATS_PERIOD_MIN, CFG_TDLS_TX_STATS_PERIOD_MAX); |
| 1034 | return -1; |
| 1035 | } |
| 1036 | if (config->tx_packet_n < CFG_TDLS_TX_PACKET_THRESHOLD_MIN || |
| 1037 | config->tx_packet_n > CFG_TDLS_TX_PACKET_THRESHOLD_MAX) |
| 1038 | { |
| 1039 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s invalid 3rd argument %d. <%d...%d>", __func__, config->tx_packet_n, |
| 1040 | CFG_TDLS_TX_PACKET_THRESHOLD_MIN, CFG_TDLS_TX_PACKET_THRESHOLD_MAX); |
| 1041 | return -1; |
| 1042 | } |
| 1043 | if (config->discovery_period_t < CFG_TDLS_DISCOVERY_PERIOD_MIN || |
| 1044 | config->discovery_period_t > CFG_TDLS_DISCOVERY_PERIOD_MAX) |
| 1045 | { |
| 1046 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s invalid 4th argument %d. <%d...%d>", __func__, config->discovery_period_t, |
| 1047 | CFG_TDLS_DISCOVERY_PERIOD_MIN, CFG_TDLS_DISCOVERY_PERIOD_MAX); |
| 1048 | return -1; |
| 1049 | } |
| 1050 | if (config->discovery_tries_n < CFG_TDLS_MAX_DISCOVERY_ATTEMPT_MIN || |
| 1051 | config->discovery_tries_n > CFG_TDLS_MAX_DISCOVERY_ATTEMPT_MAX) |
| 1052 | { |
| 1053 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s invalid 5th argument %d. <%d...%d>", __func__, config->discovery_tries_n, |
| 1054 | CFG_TDLS_MAX_DISCOVERY_ATTEMPT_MIN, CFG_TDLS_MAX_DISCOVERY_ATTEMPT_MAX); |
| 1055 | return -1; |
| 1056 | } |
| 1057 | if (config->idle_timeout_t < CFG_TDLS_IDLE_TIMEOUT_MIN || |
| 1058 | config->idle_timeout_t > CFG_TDLS_IDLE_TIMEOUT_MAX) |
| 1059 | { |
| 1060 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s invalid 6th argument %d. <%d...%d>", __func__, config->idle_timeout_t, |
| 1061 | CFG_TDLS_IDLE_TIMEOUT_MIN, CFG_TDLS_IDLE_TIMEOUT_MAX); |
| 1062 | return -1; |
| 1063 | } |
| 1064 | if (config->idle_packet_n < CFG_TDLS_IDLE_PACKET_THRESHOLD_MIN || |
| 1065 | config->idle_packet_n > CFG_TDLS_IDLE_PACKET_THRESHOLD_MAX) |
| 1066 | { |
| 1067 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s invalid 7th argument %d. <%d...%d>", __func__, config->idle_packet_n, |
| 1068 | CFG_TDLS_IDLE_PACKET_THRESHOLD_MIN, CFG_TDLS_IDLE_PACKET_THRESHOLD_MAX); |
| 1069 | return -1; |
| 1070 | } |
| 1071 | if (config->rssi_hysteresis < CFG_TDLS_RSSI_HYSTERESIS_MIN || |
| 1072 | config->rssi_hysteresis > CFG_TDLS_RSSI_HYSTERESIS_MAX) |
| 1073 | { |
| 1074 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s invalid 8th argument %d. <%d...%d>", __func__, config->rssi_hysteresis, |
| 1075 | CFG_TDLS_RSSI_HYSTERESIS_MIN, CFG_TDLS_RSSI_HYSTERESIS_MAX); |
| 1076 | return -1; |
| 1077 | } |
| 1078 | if (config->rssi_trigger_threshold < CFG_TDLS_RSSI_TRIGGER_THRESHOLD_MIN || |
| 1079 | config->rssi_trigger_threshold > CFG_TDLS_RSSI_TRIGGER_THRESHOLD_MAX) |
| 1080 | { |
| 1081 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s invalid 9th argument %d. <%d...%d>", __func__, config->rssi_trigger_threshold, |
| 1082 | CFG_TDLS_RSSI_TRIGGER_THRESHOLD_MIN, CFG_TDLS_RSSI_TRIGGER_THRESHOLD_MAX); |
| 1083 | return -1; |
| 1084 | } |
| 1085 | if (config->rssi_teardown_threshold < CFG_TDLS_RSSI_TEARDOWN_THRESHOLD_MIN || |
| 1086 | config->rssi_teardown_threshold > CFG_TDLS_RSSI_TEARDOWN_THRESHOLD_MAX) |
| 1087 | { |
| 1088 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s invalid 10th argument %d. <%d...%d>", __func__, config->rssi_teardown_threshold, |
| 1089 | CFG_TDLS_RSSI_TEARDOWN_THRESHOLD_MIN, CFG_TDLS_RSSI_TEARDOWN_THRESHOLD_MAX); |
| 1090 | return -1; |
| 1091 | } |
| 1092 | return 0; |
| 1093 | } |
| 1094 | |
Chilam Ng | 0112041 | 2013-02-19 18:32:21 -0800 | [diff] [blame] | 1095 | 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] | 1096 | { |
Chilam Ng | 0112041 | 2013-02-19 18:32:21 -0800 | [diff] [blame] | 1097 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 1098 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter ); |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 1099 | tdlsCtx_t *pHddTdlsCtx = WLAN_HDD_GET_TDLS_CTX_PTR(pAdapter); |
Hoonki Lee | 2751190 | 2013-03-14 18:19:06 -0700 | [diff] [blame] | 1100 | eTDLSSupportMode req_tdls_mode; |
Hoonki Lee | bfee034 | 2013-01-21 16:43:45 -0800 | [diff] [blame] | 1101 | |
Hoonki Lee | 2751190 | 2013-03-14 18:19:06 -0700 | [diff] [blame] | 1102 | if (NULL == pHddTdlsCtx) |
| 1103 | { |
| 1104 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s TDLS not enabled!", __func__); |
| 1105 | return -1; |
Chilam Ng | 0112041 | 2013-02-19 18:32:21 -0800 | [diff] [blame] | 1106 | } |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 1107 | |
Hoonki Lee | 2751190 | 2013-03-14 18:19:06 -0700 | [diff] [blame] | 1108 | if (wlan_hdd_tdls_check_config(config) != 0) |
| 1109 | { |
| 1110 | return -1; |
| 1111 | } |
| 1112 | |
| 1113 | /* config->tdls is mapped to 0->1, 1->2, 2->3 */ |
| 1114 | req_tdls_mode = config->tdls + 1; |
| 1115 | if (pHddCtx->tdls_mode == req_tdls_mode) |
| 1116 | { |
| 1117 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s already in mode %d", __func__, config->tdls); |
| 1118 | return -1; |
| 1119 | } |
| 1120 | |
| 1121 | /* copy the configuration only when given tdls mode is implicit trigger enable */ |
| 1122 | if (eTDLS_SUPPORT_ENABLED == req_tdls_mode) |
| 1123 | { |
Chilam Ng | 0112041 | 2013-02-19 18:32:21 -0800 | [diff] [blame] | 1124 | memcpy(&pHddTdlsCtx->threshold_config, config, sizeof(tdls_config_params_t)); |
| 1125 | } |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 1126 | |
Chilam Ng | 0112041 | 2013-02-19 18:32:21 -0800 | [diff] [blame] | 1127 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1128 | "iw set tdls params: %d %d %d %d %d %d %d %d %d %d", |
| 1129 | config->tdls, |
| 1130 | config->tx_period_t, |
| 1131 | config->tx_packet_n, |
| 1132 | config->discovery_period_t, |
| 1133 | config->discovery_tries_n, |
| 1134 | config->idle_timeout_t, |
| 1135 | config->idle_packet_n, |
| 1136 | config->rssi_hysteresis, |
| 1137 | config->rssi_trigger_threshold, |
| 1138 | config->rssi_teardown_threshold); |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 1139 | |
Gopichand Nakkala | dcbcf4e | 2013-03-23 14:32:39 -0700 | [diff] [blame] | 1140 | wlan_hdd_tdls_set_mode(pHddCtx, req_tdls_mode, TRUE); |
Chilam Ng | 0112041 | 2013-02-19 18:32:21 -0800 | [diff] [blame] | 1141 | |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 1142 | return 0; |
| 1143 | } |
| 1144 | |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 1145 | 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] | 1146 | { |
Hoonki Lee | 387663d | 2013-02-05 18:08:43 -0800 | [diff] [blame] | 1147 | hddTdlsPeer_t *curr_peer; |
Kiran V | 1ccee93 | 2012-12-12 14:49:46 -0800 | [diff] [blame] | 1148 | |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 1149 | curr_peer = wlan_hdd_tdls_get_peer(pAdapter, mac); |
Hoonki Lee | 387663d | 2013-02-05 18:08:43 -0800 | [diff] [blame] | 1150 | if (curr_peer == NULL) |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 1151 | return -1; |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 1152 | |
Hoonki Lee | 387663d | 2013-02-05 18:08:43 -0800 | [diff] [blame] | 1153 | curr_peer->staId = staId; |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 1154 | |
| 1155 | return 0; |
Kiran V | 1ccee93 | 2012-12-12 14:49:46 -0800 | [diff] [blame] | 1156 | } |
| 1157 | |
Hoonki Lee | 387663d | 2013-02-05 18:08:43 -0800 | [diff] [blame] | 1158 | /* if peerMac is found, then it returns pointer to hddTdlsPeer_t |
| 1159 | otherwise, it returns NULL |
| 1160 | */ |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 1161 | hddTdlsPeer_t *wlan_hdd_tdls_find_peer(hdd_adapter_t *pAdapter, u8 *mac) |
Kiran V | 1ccee93 | 2012-12-12 14:49:46 -0800 | [diff] [blame] | 1162 | { |
Hoonki Lee | 387663d | 2013-02-05 18:08:43 -0800 | [diff] [blame] | 1163 | u8 key; |
| 1164 | struct list_head *pos; |
| 1165 | struct list_head *head; |
| 1166 | hddTdlsPeer_t *curr_peer; |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 1167 | tdlsCtx_t *pHddTdlsCtx; |
Hoonki Lee | 387663d | 2013-02-05 18:08:43 -0800 | [diff] [blame] | 1168 | |
Hoonki Lee | 387663d | 2013-02-05 18:08:43 -0800 | [diff] [blame] | 1169 | |
Gopichand Nakkala | eb69b60 | 2013-02-27 11:40:31 -0800 | [diff] [blame] | 1170 | if (mutex_lock_interruptible(&tdls_lock)) |
Hoonki Lee | 387663d | 2013-02-05 18:08:43 -0800 | [diff] [blame] | 1171 | { |
| 1172 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1173 | "%s: unable to lock list", __func__); |
| 1174 | return NULL; |
| 1175 | } |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 1176 | pHddTdlsCtx = WLAN_HDD_GET_TDLS_CTX_PTR(pAdapter); |
Gopichand Nakkala | eb69b60 | 2013-02-27 11:40:31 -0800 | [diff] [blame] | 1177 | if (NULL == pHddTdlsCtx) |
| 1178 | { |
| 1179 | mutex_unlock(&tdls_lock); |
| 1180 | return NULL; |
| 1181 | } |
| 1182 | |
| 1183 | key = wlan_hdd_tdls_hash_key(mac); |
| 1184 | |
| 1185 | head = &pHddTdlsCtx->peer_list[key]; |
Hoonki Lee | 387663d | 2013-02-05 18:08:43 -0800 | [diff] [blame] | 1186 | |
| 1187 | list_for_each(pos, head) { |
| 1188 | curr_peer = list_entry (pos, hddTdlsPeer_t, node); |
| 1189 | if (!memcmp(mac, curr_peer->peerMac, 6)) { |
| 1190 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 1191 | "findTdlsPeer: found staId %d", curr_peer->staId); |
Gopichand Nakkala | eb69b60 | 2013-02-27 11:40:31 -0800 | [diff] [blame] | 1192 | mutex_unlock(&tdls_lock); |
Hoonki Lee | 387663d | 2013-02-05 18:08:43 -0800 | [diff] [blame] | 1193 | return curr_peer; |
| 1194 | } |
| 1195 | } |
| 1196 | |
Gopichand Nakkala | eb69b60 | 2013-02-27 11:40:31 -0800 | [diff] [blame] | 1197 | mutex_unlock(&tdls_lock); |
Hoonki Lee | 387663d | 2013-02-05 18:08:43 -0800 | [diff] [blame] | 1198 | return NULL; |
| 1199 | } |
| 1200 | |
Hoonki Lee | a6d49be | 2013-04-05 09:43:25 -0700 | [diff] [blame] | 1201 | hddTdlsPeer_t *wlan_hdd_tdls_find_all_peer(hdd_context_t *pHddCtx, u8 *mac) |
| 1202 | { |
| 1203 | hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL; |
| 1204 | hdd_adapter_t *pAdapter = NULL; |
| 1205 | tdlsCtx_t *pHddTdlsCtx = NULL; |
| 1206 | hddTdlsPeer_t *curr_peer= NULL; |
| 1207 | VOS_STATUS status = 0; |
| 1208 | |
| 1209 | status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode ); |
| 1210 | while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status ) |
| 1211 | { |
| 1212 | pAdapter = pAdapterNode->pAdapter; |
| 1213 | |
| 1214 | pHddTdlsCtx = WLAN_HDD_GET_TDLS_CTX_PTR(pAdapter); |
| 1215 | if (NULL != pHddTdlsCtx) |
| 1216 | { |
| 1217 | curr_peer = wlan_hdd_tdls_find_peer(pAdapter, mac); |
| 1218 | if (curr_peer) |
| 1219 | return curr_peer; |
| 1220 | } |
| 1221 | status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 1222 | pAdapterNode = pNext; |
| 1223 | } |
| 1224 | return curr_peer; |
| 1225 | } |
| 1226 | |
| 1227 | |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 1228 | int wlan_hdd_tdls_reset_peer(hdd_adapter_t *pAdapter, u8 *mac) |
Hoonki Lee | 387663d | 2013-02-05 18:08:43 -0800 | [diff] [blame] | 1229 | { |
Chilam Ng | 0112041 | 2013-02-19 18:32:21 -0800 | [diff] [blame] | 1230 | hdd_context_t *pHddCtx; |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 1231 | hddTdlsPeer_t *curr_peer; |
Kiran V | 1ccee93 | 2012-12-12 14:49:46 -0800 | [diff] [blame] | 1232 | |
Chilam Ng | 0112041 | 2013-02-19 18:32:21 -0800 | [diff] [blame] | 1233 | pHddCtx = WLAN_HDD_GET_CTX( pAdapter ); |
| 1234 | |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 1235 | curr_peer = wlan_hdd_tdls_get_peer(pAdapter, mac); |
Hoonki Lee | 387663d | 2013-02-05 18:08:43 -0800 | [diff] [blame] | 1236 | if (curr_peer == NULL) |
| 1237 | return -1; |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 1238 | |
Gopichand Nakkala | 901e892 | 2013-03-04 23:45:58 -0800 | [diff] [blame] | 1239 | curr_peer->link_status = eTDLS_LINK_IDLE; |
Hoonki Lee | cdd8e96 | 2013-01-20 00:45:46 -0800 | [diff] [blame] | 1240 | curr_peer->staId = 0; |
Hoonki Lee | 387663d | 2013-02-05 18:08:43 -0800 | [diff] [blame] | 1241 | |
Chilam Ng | 0112041 | 2013-02-19 18:32:21 -0800 | [diff] [blame] | 1242 | if(eTDLS_SUPPORT_ENABLED == pHddCtx->tdls_mode) { |
Chilam Ng | a75d8b6 | 2013-01-29 01:35:59 -0800 | [diff] [blame] | 1243 | vos_timer_stop( &curr_peer->peerIdleTimer ); |
Chilam Ng | a75d8b6 | 2013-01-29 01:35:59 -0800 | [diff] [blame] | 1244 | } |
Hoonki Lee | 387663d | 2013-02-05 18:08:43 -0800 | [diff] [blame] | 1245 | return 0; |
Hoonki Lee | cdd8e96 | 2013-01-20 00:45:46 -0800 | [diff] [blame] | 1246 | } |
| 1247 | |
Gopichand Nakkala | 638ebc7 | 2013-03-21 18:04:02 -0700 | [diff] [blame] | 1248 | /* Caller has to take the lock before calling this function */ |
Hoonki Lee | 2751190 | 2013-03-14 18:19:06 -0700 | [diff] [blame] | 1249 | static void wlan_tdd_tdls_reset_tx_rx(tdlsCtx_t *pHddTdlsCtx) |
| 1250 | { |
| 1251 | int i; |
| 1252 | struct list_head *head; |
| 1253 | hddTdlsPeer_t *tmp; |
| 1254 | struct list_head *pos, *q; |
| 1255 | |
Hoonki Lee | 2751190 | 2013-03-14 18:19:06 -0700 | [diff] [blame] | 1256 | for (i = 0; i < 256; i++) { |
| 1257 | head = &pHddTdlsCtx->peer_list[i]; |
| 1258 | list_for_each_safe (pos, q, head) { |
| 1259 | tmp = list_entry(pos, hddTdlsPeer_t, node); |
| 1260 | tmp->tx_pkt = 0; |
| 1261 | tmp->rx_pkt = 0; |
| 1262 | } |
| 1263 | } |
Hoonki Lee | 2751190 | 2013-03-14 18:19:06 -0700 | [diff] [blame] | 1264 | |
| 1265 | return ; |
| 1266 | } |
| 1267 | |
Gopichand Nakkala | 638ebc7 | 2013-03-21 18:04:02 -0700 | [diff] [blame] | 1268 | /* Caller has to take the lock before calling this function */ |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 1269 | 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] | 1270 | { |
| 1271 | int i; |
| 1272 | struct list_head *head; |
| 1273 | hddTdlsPeer_t *tmp; |
| 1274 | struct list_head *pos, *q; |
| 1275 | |
Gopichand Nakkala | c369458 | 2013-02-13 20:51:22 -0800 | [diff] [blame] | 1276 | pHddTdlsCtx->discovery_peer_cnt = 0; |
| 1277 | |
| 1278 | for (i = 0; i < 256; i++) { |
| 1279 | head = &pHddTdlsCtx->peer_list[i]; |
| 1280 | list_for_each_safe (pos, q, head) { |
| 1281 | tmp = list_entry(pos, hddTdlsPeer_t, node); |
| 1282 | tmp->discovery_processed = 0; |
| 1283 | } |
| 1284 | } |
Gopichand Nakkala | c369458 | 2013-02-13 20:51:22 -0800 | [diff] [blame] | 1285 | |
| 1286 | return 0; |
| 1287 | } |
| 1288 | |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 1289 | 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] | 1290 | { |
| 1291 | int i; |
| 1292 | struct list_head *head; |
| 1293 | struct list_head *pos, *q; |
| 1294 | int discovery_peer_cnt=0; |
| 1295 | hddTdlsPeer_t *tmp; |
| 1296 | |
Gopichand Nakkala | eb69b60 | 2013-02-27 11:40:31 -0800 | [diff] [blame] | 1297 | /* |
| 1298 | * This function expects the callers to acquire the Mutex. |
| 1299 | */ |
Gopichand Nakkala | c369458 | 2013-02-13 20:51:22 -0800 | [diff] [blame] | 1300 | |
| 1301 | for (i = 0; i < 256; i++) { |
| 1302 | head = &pHddTdlsCtx->peer_list[i]; |
| 1303 | list_for_each_safe (pos, q, head) { |
| 1304 | tmp = list_entry(pos, hddTdlsPeer_t, node); |
| 1305 | VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
Chilam Ng | 0112041 | 2013-02-19 18:32:21 -0800 | [diff] [blame] | 1306 | "%s, %d, " MAC_ADDRESS_STR, __func__, i, |
| 1307 | MAC_ADDR_ARRAY(tmp->peerMac)); |
Gopichand Nakkala | c369458 | 2013-02-13 20:51:22 -0800 | [diff] [blame] | 1308 | discovery_peer_cnt++; |
| 1309 | } |
| 1310 | } |
Gopichand Nakkala | c369458 | 2013-02-13 20:51:22 -0800 | [diff] [blame] | 1311 | return discovery_peer_cnt; |
| 1312 | } |
| 1313 | |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 1314 | tANI_U16 wlan_hdd_tdlsConnectedPeers(hdd_adapter_t *pAdapter) |
Lee Hoonki | c1262f2 | 2013-01-24 21:59:00 -0800 | [diff] [blame] | 1315 | { |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 1316 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 1317 | |
| 1318 | if (NULL == pHddCtx) |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 1319 | return 0; |
Lee Hoonki | c1262f2 | 2013-01-24 21:59:00 -0800 | [diff] [blame] | 1320 | |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 1321 | return pHddCtx->connected_peer_count; |
Lee Hoonki | c1262f2 | 2013-01-24 21:59:00 -0800 | [diff] [blame] | 1322 | } |
Chilam Ng | 16a2a1c | 2013-01-29 01:27:29 -0800 | [diff] [blame] | 1323 | |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 1324 | 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] | 1325 | { |
| 1326 | int i; |
| 1327 | int len, init_len; |
Hoonki Lee | 387663d | 2013-02-05 18:08:43 -0800 | [diff] [blame] | 1328 | struct list_head *head; |
| 1329 | struct list_head *pos; |
Chilam Ng | 16a2a1c | 2013-01-29 01:27:29 -0800 | [diff] [blame] | 1330 | hddTdlsPeer_t *curr_peer; |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 1331 | tdlsCtx_t *pHddTdlsCtx; |
Chilam Ng | 16a2a1c | 2013-01-29 01:27:29 -0800 | [diff] [blame] | 1332 | |
Chilam Ng | 16a2a1c | 2013-01-29 01:27:29 -0800 | [diff] [blame] | 1333 | |
| 1334 | init_len = buflen; |
| 1335 | len = snprintf(buf, buflen, "\n%-18s%-3s%-4s%-3s%-5s\n", "MAC", "Id", "cap", "up", "RSSI"); |
| 1336 | buf += len; |
| 1337 | buflen -= len; |
| 1338 | /* 1234567890123456789012345678901234567 */ |
| 1339 | len = snprintf(buf, buflen, "---------------------------------\n"); |
| 1340 | buf += len; |
| 1341 | buflen -= len; |
| 1342 | |
Gopichand Nakkala | eb69b60 | 2013-02-27 11:40:31 -0800 | [diff] [blame] | 1343 | if (mutex_lock_interruptible(&tdls_lock)) |
Gopichand Nakkala | 91b0926 | 2013-02-10 14:27:02 -0800 | [diff] [blame] | 1344 | { |
| 1345 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1346 | "%s: unable to lock list", __func__); |
| 1347 | return init_len-buflen; |
| 1348 | } |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 1349 | pHddTdlsCtx = WLAN_HDD_GET_TDLS_CTX_PTR(pAdapter); |
Gopichand Nakkala | eb69b60 | 2013-02-27 11:40:31 -0800 | [diff] [blame] | 1350 | if (NULL == pHddTdlsCtx) { |
| 1351 | mutex_unlock(&tdls_lock); |
| 1352 | len = snprintf(buf, buflen, "TDLS not enabled\n"); |
| 1353 | return len; |
| 1354 | } |
Chilam Ng | 16a2a1c | 2013-01-29 01:27:29 -0800 | [diff] [blame] | 1355 | for (i = 0; i < 256; i++) { |
Hoonki Lee | 387663d | 2013-02-05 18:08:43 -0800 | [diff] [blame] | 1356 | head = &pHddTdlsCtx->peer_list[i]; |
Chilam Ng | 16a2a1c | 2013-01-29 01:27:29 -0800 | [diff] [blame] | 1357 | |
Hoonki Lee | 387663d | 2013-02-05 18:08:43 -0800 | [diff] [blame] | 1358 | list_for_each(pos, head) { |
| 1359 | curr_peer= list_entry (pos, hddTdlsPeer_t, node); |
Chilam Ng | 16a2a1c | 2013-01-29 01:27:29 -0800 | [diff] [blame] | 1360 | |
Hoonki Lee | 387663d | 2013-02-05 18:08:43 -0800 | [diff] [blame] | 1361 | if (buflen < 32+1) |
| 1362 | break; |
| 1363 | len = snprintf(buf, buflen, |
Chilam Ng | 0112041 | 2013-02-19 18:32:21 -0800 | [diff] [blame] | 1364 | MAC_ADDRESS_STR"%3d%4s%3s%5d\n", |
| 1365 | MAC_ADDR_ARRAY(curr_peer->peerMac), |
Hoonki Lee | 387663d | 2013-02-05 18:08:43 -0800 | [diff] [blame] | 1366 | curr_peer->staId, |
| 1367 | (curr_peer->tdls_support == eTDLS_CAP_SUPPORTED) ? "Y":"N", |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 1368 | TDLS_IS_CONNECTED(curr_peer) ? "Y":"N", |
Hoonki Lee | 387663d | 2013-02-05 18:08:43 -0800 | [diff] [blame] | 1369 | curr_peer->rssi); |
| 1370 | buf += len; |
| 1371 | buflen -= len; |
Chilam Ng | 16a2a1c | 2013-01-29 01:27:29 -0800 | [diff] [blame] | 1372 | } |
| 1373 | } |
Gopichand Nakkala | eb69b60 | 2013-02-27 11:40:31 -0800 | [diff] [blame] | 1374 | mutex_unlock(&tdls_lock); |
Chilam Ng | 16a2a1c | 2013-01-29 01:27:29 -0800 | [diff] [blame] | 1375 | return init_len-buflen; |
| 1376 | } |
Gopichand Nakkala | c369458 | 2013-02-13 20:51:22 -0800 | [diff] [blame] | 1377 | |
| 1378 | void wlan_hdd_tdls_connection_callback(hdd_adapter_t *pAdapter) |
| 1379 | { |
Gopichand Nakkala | 9d76a9b | 2013-02-28 15:38:37 -0800 | [diff] [blame] | 1380 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter ); |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 1381 | tdlsCtx_t *pHddTdlsCtx = WLAN_HDD_GET_TDLS_CTX_PTR(pAdapter); |
Gopichand Nakkala | 9d76a9b | 2013-02-28 15:38:37 -0800 | [diff] [blame] | 1382 | |
Gopichand Nakkala | 638ebc7 | 2013-03-21 18:04:02 -0700 | [diff] [blame] | 1383 | if (mutex_lock_interruptible(&tdls_lock)) |
| 1384 | { |
| 1385 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1386 | "%s: unable to lock list", __func__); |
| 1387 | return; |
| 1388 | } |
| 1389 | |
| 1390 | if (NULL == pHddCtx || NULL == pHddTdlsCtx) |
| 1391 | { |
| 1392 | mutex_unlock(&tdls_lock); |
| 1393 | return; |
| 1394 | } |
Gopichand Nakkala | c369458 | 2013-02-13 20:51:22 -0800 | [diff] [blame] | 1395 | |
| 1396 | VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
| 1397 | "%s, update %d discover %d", __func__, |
| 1398 | pHddTdlsCtx->threshold_config.tx_period_t, |
| 1399 | pHddTdlsCtx->threshold_config.discovery_period_t); |
| 1400 | |
Gopichand Nakkala | 78a6c81 | 2013-05-13 16:39:49 +0530 | [diff] [blame] | 1401 | #ifdef FEATURE_WLAN_TDLS_OXYGEN_DISAPPEAR_AP |
| 1402 | pHddTdlsCtx->defer_link_lost_indication = FALSE; |
| 1403 | #endif |
Gopichand Nakkala | 9d76a9b | 2013-02-28 15:38:37 -0800 | [diff] [blame] | 1404 | if (eTDLS_SUPPORT_ENABLED == pHddCtx->tdls_mode) |
| 1405 | { |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 1406 | wlan_hdd_tdls_peer_reset_discovery_processed(pHddTdlsCtx); |
Gopichand Nakkala | 75e7b28 | 2013-03-15 18:37:13 -0700 | [diff] [blame] | 1407 | pHddTdlsCtx->discovery_sent_cnt = 0; |
Gopichand Nakkala | 34d1b06 | 2013-03-19 15:28:33 -0700 | [diff] [blame] | 1408 | wlan_hdd_tdls_check_power_save_prohibited(pHddTdlsCtx->pAdapter); |
Gopichand Nakkala | c369458 | 2013-02-13 20:51:22 -0800 | [diff] [blame] | 1409 | |
Gopichand Nakkala | 75e7b28 | 2013-03-15 18:37:13 -0700 | [diff] [blame] | 1410 | #ifdef FEATURE_WLAN_TDLS_INTERNAL |
Gopichand Nakkala | 3046fc9 | 2013-03-23 13:56:43 -0700 | [diff] [blame] | 1411 | wlan_hdd_tdls_timer_restart(pHddTdlsCtx->pAdapter, |
| 1412 | &pHddTdlsCtx->peerDiscoverTimer, |
| 1413 | pHddTdlsCtx->threshold_config.discovery_period_t); |
Gopichand Nakkala | 75e7b28 | 2013-03-15 18:37:13 -0700 | [diff] [blame] | 1414 | #endif |
Gopichand Nakkala | 3046fc9 | 2013-03-23 13:56:43 -0700 | [diff] [blame] | 1415 | wlan_hdd_tdls_timer_restart(pHddTdlsCtx->pAdapter, |
| 1416 | &pHddTdlsCtx->peerUpdateTimer, |
| 1417 | pHddTdlsCtx->threshold_config.tx_period_t); |
Gopichand Nakkala | 9d76a9b | 2013-02-28 15:38:37 -0800 | [diff] [blame] | 1418 | } |
Gopichand Nakkala | 638ebc7 | 2013-03-21 18:04:02 -0700 | [diff] [blame] | 1419 | mutex_unlock(&tdls_lock); |
Gopichand Nakkala | c369458 | 2013-02-13 20:51:22 -0800 | [diff] [blame] | 1420 | |
| 1421 | } |
| 1422 | |
| 1423 | void wlan_hdd_tdls_disconnection_callback(hdd_adapter_t *pAdapter) |
| 1424 | { |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 1425 | tdlsCtx_t *pHddTdlsCtx = WLAN_HDD_GET_TDLS_CTX_PTR(pAdapter); |
Gopichand Nakkala | c369458 | 2013-02-13 20:51:22 -0800 | [diff] [blame] | 1426 | |
| 1427 | VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,"%s", __func__); |
| 1428 | |
Gopichand Nakkala | eb69b60 | 2013-02-27 11:40:31 -0800 | [diff] [blame] | 1429 | if (mutex_lock_interruptible(&tdls_lock)) |
| 1430 | { |
| 1431 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1432 | "%s: unable to lock list", __func__); |
| 1433 | return; |
| 1434 | } |
| 1435 | if (NULL == pHddTdlsCtx) |
| 1436 | { |
| 1437 | mutex_unlock(&tdls_lock); |
| 1438 | return; |
| 1439 | } |
Gopichand Nakkala | 78a6c81 | 2013-05-13 16:39:49 +0530 | [diff] [blame] | 1440 | #ifdef FEATURE_WLAN_TDLS_OXYGEN_DISAPPEAR_AP |
| 1441 | pHddTdlsCtx->defer_link_lost_indication = FALSE; |
| 1442 | #endif |
Gopichand Nakkala | ccd3a38 | 2013-03-19 13:56:10 -0700 | [diff] [blame] | 1443 | pHddTdlsCtx->discovery_sent_cnt = 0; |
Gopichand Nakkala | 34d1b06 | 2013-03-19 15:28:33 -0700 | [diff] [blame] | 1444 | wlan_hdd_tdls_check_power_save_prohibited(pHddTdlsCtx->pAdapter); |
Gopichand Nakkala | eb69b60 | 2013-02-27 11:40:31 -0800 | [diff] [blame] | 1445 | |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 1446 | wlan_hdd_tdls_timers_stop(pHddTdlsCtx); |
| 1447 | wlan_hdd_tdls_free_list(pHddTdlsCtx); |
Gopichand Nakkala | eb69b60 | 2013-02-27 11:40:31 -0800 | [diff] [blame] | 1448 | |
| 1449 | mutex_unlock(&tdls_lock); |
Gopichand Nakkala | c369458 | 2013-02-13 20:51:22 -0800 | [diff] [blame] | 1450 | } |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 1451 | |
| 1452 | void wlan_hdd_tdls_mgmt_completion_callback(hdd_adapter_t *pAdapter, tANI_U32 statusCode) |
| 1453 | { |
| 1454 | pAdapter->mgmtTxCompletionStatus = statusCode; |
| 1455 | VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,"%s: Mgmt TX Completion %d", |
| 1456 | __func__, statusCode); |
| 1457 | complete(&pAdapter->tdls_mgmt_comp); |
| 1458 | } |
| 1459 | |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 1460 | void wlan_hdd_tdls_increment_peer_count(hdd_adapter_t *pAdapter) |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 1461 | { |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 1462 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 1463 | |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 1464 | if (NULL == pHddCtx) return; |
| 1465 | |
| 1466 | pHddCtx->connected_peer_count++; |
Gopichand Nakkala | 34d1b06 | 2013-03-19 15:28:33 -0700 | [diff] [blame] | 1467 | wlan_hdd_tdls_check_power_save_prohibited(pAdapter); |
Gopichand Nakkala | ccd3a38 | 2013-03-19 13:56:10 -0700 | [diff] [blame] | 1468 | |
| 1469 | VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, "%s: %d", |
| 1470 | __func__, pHddCtx->connected_peer_count); |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 1471 | } |
| 1472 | |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 1473 | void wlan_hdd_tdls_decrement_peer_count(hdd_adapter_t *pAdapter) |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 1474 | { |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 1475 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 1476 | |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 1477 | if (NULL == pHddCtx) return; |
| 1478 | |
| 1479 | if (pHddCtx->connected_peer_count) |
| 1480 | pHddCtx->connected_peer_count--; |
Gopichand Nakkala | 34d1b06 | 2013-03-19 15:28:33 -0700 | [diff] [blame] | 1481 | wlan_hdd_tdls_check_power_save_prohibited(pAdapter); |
Gopichand Nakkala | ccd3a38 | 2013-03-19 13:56:10 -0700 | [diff] [blame] | 1482 | |
| 1483 | VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, "%s: %d", |
| 1484 | __func__, pHddCtx->connected_peer_count); |
| 1485 | |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 1486 | } |
| 1487 | |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 1488 | void wlan_hdd_tdls_check_bmps(hdd_adapter_t *pAdapter) |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 1489 | { |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 1490 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
Gopichand Nakkala | 75e7b28 | 2013-03-15 18:37:13 -0700 | [diff] [blame] | 1491 | tdlsCtx_t *pHddTdlsCtx = WLAN_HDD_GET_TDLS_CTX_PTR(pAdapter); |
Hoonki Lee | 1462135 | 2013-04-16 17:51:19 -0700 | [diff] [blame] | 1492 | hddTdlsPeer_t *curr_peer; |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 1493 | |
Gopichand Nakkala | 16c0284 | 2013-03-18 12:31:35 -0700 | [diff] [blame] | 1494 | if ((NULL == pHddCtx) || (NULL == pHddTdlsCtx)) return; |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 1495 | |
Hoonki Lee | 1462135 | 2013-04-16 17:51:19 -0700 | [diff] [blame] | 1496 | curr_peer = wlan_hdd_tdls_is_progress(pHddCtx, NULL, 0, TRUE); |
| 1497 | if (NULL != curr_peer) |
| 1498 | { |
| 1499 | VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
| 1500 | "%s: tdls in progress. Dont check for BMPS " MAC_ADDRESS_STR, |
| 1501 | __func__, MAC_ADDR_ARRAY (curr_peer->peerMac)); |
| 1502 | return; |
| 1503 | } |
| 1504 | |
Hoonki Lee | 93e67ff | 2013-03-19 15:49:25 -0700 | [diff] [blame] | 1505 | if ((TDLS_CTX_MAGIC != pHddCtx->tdls_scan_ctxt.magic) && |
| 1506 | (0 == pHddCtx->connected_peer_count) && |
Gopichand Nakkala | 75e7b28 | 2013-03-15 18:37:13 -0700 | [diff] [blame] | 1507 | (0 == pHddTdlsCtx->discovery_sent_cnt)) |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 1508 | { |
Gopichand Nakkala | 75e7b28 | 2013-03-15 18:37:13 -0700 | [diff] [blame] | 1509 | if (FALSE == sme_IsPmcBmps(WLAN_HDD_GET_HAL_CTX(pAdapter))) |
| 1510 | { |
| 1511 | VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
Gopichand Nakkala | ccd3a38 | 2013-03-19 13:56:10 -0700 | [diff] [blame] | 1512 | "%s: No TDLS peer connected/discovery sent. Enable BMPS", |
| 1513 | __func__); |
Gopichand Nakkala | 75e7b28 | 2013-03-15 18:37:13 -0700 | [diff] [blame] | 1514 | hdd_enable_bmps_imps(pHddCtx); |
| 1515 | } |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 1516 | } |
Gopichand Nakkala | 75e7b28 | 2013-03-15 18:37:13 -0700 | [diff] [blame] | 1517 | else |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 1518 | { |
Gopichand Nakkala | 75e7b28 | 2013-03-15 18:37:13 -0700 | [diff] [blame] | 1519 | if (TRUE == sme_IsPmcBmps(WLAN_HDD_GET_HAL_CTX(pAdapter))) |
| 1520 | { |
Gopichand Nakkala | ccd3a38 | 2013-03-19 13:56:10 -0700 | [diff] [blame] | 1521 | VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
| 1522 | "%s: TDLS peer connected. Disable BMPS", __func__); |
Gopichand Nakkala | 75e7b28 | 2013-03-15 18:37:13 -0700 | [diff] [blame] | 1523 | hdd_disable_bmps_imps(pHddCtx, WLAN_HDD_INFRA_STATION); |
| 1524 | } |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 1525 | } |
| 1526 | return; |
| 1527 | } |
| 1528 | |
Gopichand Nakkala | 34d1b06 | 2013-03-19 15:28:33 -0700 | [diff] [blame] | 1529 | u8 wlan_hdd_tdls_is_peer_progress(hdd_adapter_t *pAdapter, u8 *mac) |
| 1530 | { |
| 1531 | hddTdlsPeer_t *curr_peer; |
| 1532 | |
| 1533 | curr_peer = wlan_hdd_tdls_find_peer(pAdapter, mac); |
| 1534 | if (curr_peer == NULL) |
| 1535 | return 0; |
| 1536 | |
| 1537 | return (eTDLS_LINK_CONNECTING == curr_peer->link_status); |
| 1538 | } |
| 1539 | |
Hoonki Lee | fb8df67 | 2013-04-10 18:20:34 -0700 | [diff] [blame] | 1540 | /* return pointer to hddTdlsPeer_t if TDLS is ongoing. Otherwise return NULL. |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 1541 | * mac - if NULL check for all the peer list, otherwise, skip this mac when skip_self is TRUE |
| 1542 | * skip_self - if TRUE, skip this mac. otherwise, check all the peer list. if |
| 1543 | mac is NULL, this argument is ignored, and check for all the peer list. |
| 1544 | */ |
Hoonki Lee | fb8df67 | 2013-04-10 18:20:34 -0700 | [diff] [blame] | 1545 | static hddTdlsPeer_t *wlan_hdd_tdls_find_progress_peer(hdd_adapter_t *pAdapter, u8 *mac, u8 skip_self, tANI_BOOLEAN mutexLock) |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 1546 | { |
| 1547 | int i; |
| 1548 | struct list_head *head; |
| 1549 | hddTdlsPeer_t *curr_peer; |
| 1550 | struct list_head *pos; |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 1551 | tdlsCtx_t *pHddTdlsCtx; |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 1552 | |
Hoonki Lee | fb8df67 | 2013-04-10 18:20:34 -0700 | [diff] [blame] | 1553 | if (mutexLock) |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 1554 | { |
Hoonki Lee | fb8df67 | 2013-04-10 18:20:34 -0700 | [diff] [blame] | 1555 | if (mutex_lock_interruptible(&tdls_lock)) |
| 1556 | { |
| 1557 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 1558 | "%s: unable to lock list", __func__); |
Hoonki Lee | fb8df67 | 2013-04-10 18:20:34 -0700 | [diff] [blame] | 1559 | return NULL; |
| 1560 | } |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 1561 | } |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 1562 | pHddTdlsCtx = WLAN_HDD_GET_TDLS_CTX_PTR(pAdapter); |
Gopichand Nakkala | eb69b60 | 2013-02-27 11:40:31 -0800 | [diff] [blame] | 1563 | if (NULL == pHddTdlsCtx) |
| 1564 | { |
Hoonki Lee | fb8df67 | 2013-04-10 18:20:34 -0700 | [diff] [blame] | 1565 | if (mutexLock) |
| 1566 | mutex_unlock(&tdls_lock); |
| 1567 | return NULL; |
Gopichand Nakkala | eb69b60 | 2013-02-27 11:40:31 -0800 | [diff] [blame] | 1568 | } |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 1569 | |
| 1570 | for (i = 0; i < 256; i++) { |
| 1571 | head = &pHddTdlsCtx->peer_list[i]; |
| 1572 | list_for_each(pos, head) { |
| 1573 | curr_peer = list_entry (pos, hddTdlsPeer_t, node); |
| 1574 | if (skip_self && mac && !memcmp(mac, curr_peer->peerMac, 6)) { |
| 1575 | continue; |
| 1576 | } |
| 1577 | else |
| 1578 | { |
Gopichand Nakkala | 8b00c63 | 2013-03-08 19:47:52 -0800 | [diff] [blame] | 1579 | if (eTDLS_LINK_CONNECTING == curr_peer->link_status) |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 1580 | { |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 1581 | VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
Gopichand Nakkala | 34d1b06 | 2013-03-19 15:28:33 -0700 | [diff] [blame] | 1582 | "%s:" MAC_ADDRESS_STR " eTDLS_LINK_CONNECTING", |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 1583 | __func__, MAC_ADDR_ARRAY(curr_peer->peerMac)); |
Hoonki Lee | fb8df67 | 2013-04-10 18:20:34 -0700 | [diff] [blame] | 1584 | if (mutexLock) |
| 1585 | mutex_unlock(&tdls_lock); |
| 1586 | return curr_peer; |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 1587 | } |
| 1588 | } |
| 1589 | } |
| 1590 | } |
| 1591 | |
Hoonki Lee | fb8df67 | 2013-04-10 18:20:34 -0700 | [diff] [blame] | 1592 | if (mutexLock) |
| 1593 | mutex_unlock(&tdls_lock); |
| 1594 | return NULL; |
| 1595 | } |
| 1596 | |
| 1597 | hddTdlsPeer_t *wlan_hdd_tdls_is_progress(hdd_context_t *pHddCtx, u8 *mac, u8 skip_self, tANI_BOOLEAN mutexLock) |
| 1598 | { |
| 1599 | hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL; |
| 1600 | hdd_adapter_t *pAdapter = NULL; |
| 1601 | tdlsCtx_t *pHddTdlsCtx = NULL; |
| 1602 | hddTdlsPeer_t *curr_peer= NULL; |
| 1603 | VOS_STATUS status = 0; |
| 1604 | |
| 1605 | status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode ); |
| 1606 | while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status ) |
| 1607 | { |
| 1608 | pAdapter = pAdapterNode->pAdapter; |
| 1609 | |
| 1610 | pHddTdlsCtx = WLAN_HDD_GET_TDLS_CTX_PTR(pAdapter); |
| 1611 | if (NULL != pHddTdlsCtx) |
| 1612 | { |
| 1613 | curr_peer = wlan_hdd_tdls_find_progress_peer(pAdapter, mac, skip_self, mutexLock); |
| 1614 | if (curr_peer) |
| 1615 | return curr_peer; |
| 1616 | } |
| 1617 | status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 1618 | pAdapterNode = pNext; |
| 1619 | } |
| 1620 | return NULL; |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 1621 | } |
Hoonki Lee | 2751190 | 2013-03-14 18:19:06 -0700 | [diff] [blame] | 1622 | |
| 1623 | static void wlan_hdd_tdls_implicit_disable(tdlsCtx_t *pHddTdlsCtx) |
| 1624 | { |
Hoonki Lee | 2751190 | 2013-03-14 18:19:06 -0700 | [diff] [blame] | 1625 | wlan_hdd_tdls_timers_stop(pHddTdlsCtx); |
Hoonki Lee | 2751190 | 2013-03-14 18:19:06 -0700 | [diff] [blame] | 1626 | } |
| 1627 | |
| 1628 | static void wlan_hdd_tdls_implicit_enable(tdlsCtx_t *pHddTdlsCtx) |
| 1629 | { |
| 1630 | wlan_hdd_tdls_peer_reset_discovery_processed(pHddTdlsCtx); |
Gopichand Nakkala | 75e7b28 | 2013-03-15 18:37:13 -0700 | [diff] [blame] | 1631 | pHddTdlsCtx->discovery_sent_cnt = 0; |
Hoonki Lee | 2751190 | 2013-03-14 18:19:06 -0700 | [diff] [blame] | 1632 | wlan_tdd_tdls_reset_tx_rx(pHddTdlsCtx); |
Gopichand Nakkala | 34d1b06 | 2013-03-19 15:28:33 -0700 | [diff] [blame] | 1633 | wlan_hdd_tdls_check_power_save_prohibited(pHddTdlsCtx->pAdapter); |
Gopichand Nakkala | ccd3a38 | 2013-03-19 13:56:10 -0700 | [diff] [blame] | 1634 | |
Hoonki Lee | 2751190 | 2013-03-14 18:19:06 -0700 | [diff] [blame] | 1635 | |
Gopichand Nakkala | 75e7b28 | 2013-03-15 18:37:13 -0700 | [diff] [blame] | 1636 | #ifdef FEATURE_WLAN_TDLS_INTERNAL |
Gopichand Nakkala | 3046fc9 | 2013-03-23 13:56:43 -0700 | [diff] [blame] | 1637 | wlan_hdd_tdls_timer_restart(pHddTdlsCtx->pAdapter, |
| 1638 | &pHddTdlsCtx->peerDiscoverTimer, |
| 1639 | pHddTdlsCtx->threshold_config.discovery_period_t); |
Gopichand Nakkala | 75e7b28 | 2013-03-15 18:37:13 -0700 | [diff] [blame] | 1640 | #endif |
Gopichand Nakkala | 3046fc9 | 2013-03-23 13:56:43 -0700 | [diff] [blame] | 1641 | wlan_hdd_tdls_timer_restart(pHddTdlsCtx->pAdapter, |
| 1642 | &pHddTdlsCtx->peerUpdateTimer, |
| 1643 | pHddTdlsCtx->threshold_config.tx_period_t); |
Hoonki Lee | 2751190 | 2013-03-14 18:19:06 -0700 | [diff] [blame] | 1644 | } |
| 1645 | |
Gopichand Nakkala | dcbcf4e | 2013-03-23 14:32:39 -0700 | [diff] [blame] | 1646 | void wlan_hdd_tdls_set_mode(hdd_context_t *pHddCtx, |
| 1647 | eTDLSSupportMode tdls_mode, |
| 1648 | v_BOOL_t bUpdateLast) |
Hoonki Lee | 2751190 | 2013-03-14 18:19:06 -0700 | [diff] [blame] | 1649 | { |
| 1650 | hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL; |
| 1651 | VOS_STATUS status; |
| 1652 | hdd_adapter_t *pAdapter; |
| 1653 | tdlsCtx_t *pHddTdlsCtx; |
| 1654 | |
| 1655 | VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,"%s mode %d", __func__, (int)tdls_mode); |
| 1656 | |
Gopichand Nakkala | 638ebc7 | 2013-03-21 18:04:02 -0700 | [diff] [blame] | 1657 | if (mutex_lock_interruptible(&tdls_lock)) |
| 1658 | { |
| 1659 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1660 | "%s: unable to lock list", __func__); |
| 1661 | return; |
| 1662 | } |
| 1663 | |
| 1664 | if (NULL == pHddCtx) |
| 1665 | { |
| 1666 | mutex_unlock(&tdls_lock); |
| 1667 | return; |
| 1668 | } |
Hoonki Lee | 93e67ff | 2013-03-19 15:49:25 -0700 | [diff] [blame] | 1669 | |
| 1670 | if (pHddCtx->tdls_mode == tdls_mode) |
| 1671 | { |
Gopichand Nakkala | 4ddf019 | 2013-03-27 13:41:20 -0700 | [diff] [blame] | 1672 | hddLog(TDLS_LOG_LEVEL, "%s already in mode %d", __func__, (int)tdls_mode); |
Gopichand Nakkala | 638ebc7 | 2013-03-21 18:04:02 -0700 | [diff] [blame] | 1673 | mutex_unlock(&tdls_lock); |
Hoonki Lee | 93e67ff | 2013-03-19 15:49:25 -0700 | [diff] [blame] | 1674 | return; |
| 1675 | } |
| 1676 | |
Hoonki Lee | 2751190 | 2013-03-14 18:19:06 -0700 | [diff] [blame] | 1677 | status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode ); |
| 1678 | |
| 1679 | while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status ) |
| 1680 | { |
| 1681 | pAdapter = pAdapterNode->pAdapter; |
Hoonki Lee | a6d49be | 2013-04-05 09:43:25 -0700 | [diff] [blame] | 1682 | pHddTdlsCtx = WLAN_HDD_GET_TDLS_CTX_PTR(pAdapter); |
| 1683 | if (NULL != pHddTdlsCtx) |
Hoonki Lee | 2751190 | 2013-03-14 18:19:06 -0700 | [diff] [blame] | 1684 | { |
Hoonki Lee | a6d49be | 2013-04-05 09:43:25 -0700 | [diff] [blame] | 1685 | if(eTDLS_SUPPORT_ENABLED == tdls_mode) |
| 1686 | wlan_hdd_tdls_implicit_enable(pHddTdlsCtx); |
| 1687 | else if((eTDLS_SUPPORT_DISABLED == tdls_mode) || |
| 1688 | (eTDLS_SUPPORT_EXPLICIT_TRIGGER_ONLY == tdls_mode)) |
| 1689 | wlan_hdd_tdls_implicit_disable(pHddTdlsCtx); |
Hoonki Lee | 2751190 | 2013-03-14 18:19:06 -0700 | [diff] [blame] | 1690 | } |
| 1691 | status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 1692 | pAdapterNode = pNext; |
| 1693 | } |
Gopichand Nakkala | dcbcf4e | 2013-03-23 14:32:39 -0700 | [diff] [blame] | 1694 | if(bUpdateLast) |
| 1695 | { |
| 1696 | pHddCtx->tdls_mode_last = tdls_mode; |
| 1697 | } |
| 1698 | else |
| 1699 | { |
| 1700 | pHddCtx->tdls_mode_last = pHddCtx->tdls_mode; |
| 1701 | } |
Hoonki Lee | 2751190 | 2013-03-14 18:19:06 -0700 | [diff] [blame] | 1702 | pHddCtx->tdls_mode = tdls_mode; |
Gopichand Nakkala | dcbcf4e | 2013-03-23 14:32:39 -0700 | [diff] [blame] | 1703 | |
Gopichand Nakkala | 638ebc7 | 2013-03-21 18:04:02 -0700 | [diff] [blame] | 1704 | mutex_unlock(&tdls_lock); |
Hoonki Lee | 2751190 | 2013-03-14 18:19:06 -0700 | [diff] [blame] | 1705 | } |
Gopichand Nakkala | 75e7b28 | 2013-03-15 18:37:13 -0700 | [diff] [blame] | 1706 | |
Hoonki Lee | d37cbb3 | 2013-04-20 00:31:14 -0700 | [diff] [blame] | 1707 | static void wlan_hdd_tdls_pre_setup(struct work_struct *work) |
Gopichand Nakkala | 75e7b28 | 2013-03-15 18:37:13 -0700 | [diff] [blame] | 1708 | { |
Hoonki Lee | d37cbb3 | 2013-04-20 00:31:14 -0700 | [diff] [blame] | 1709 | tdlsCtx_t *pHddTdlsCtx = |
| 1710 | container_of(work, tdlsCtx_t, implicit_setup); |
| 1711 | hdd_context_t *pHddCtx; |
| 1712 | hddTdlsPeer_t *curr_peer; |
Hoonki Lee | fb8df67 | 2013-04-10 18:20:34 -0700 | [diff] [blame] | 1713 | hddTdlsPeer_t *temp_peer; |
Hoonki Lee | d37cbb3 | 2013-04-20 00:31:14 -0700 | [diff] [blame] | 1714 | int status; |
| 1715 | |
| 1716 | if (NULL == pHddTdlsCtx) |
| 1717 | return; |
| 1718 | |
| 1719 | if (unlikely(TDLS_CTX_MAGIC != pHddTdlsCtx->magic)) |
| 1720 | return; |
| 1721 | |
| 1722 | pHddCtx = WLAN_HDD_GET_CTX(pHddTdlsCtx->pAdapter); |
Hoonki Lee | fb8df67 | 2013-04-10 18:20:34 -0700 | [diff] [blame] | 1723 | |
| 1724 | if (NULL == pHddCtx) |
| 1725 | return; |
Gopichand Nakkala | 75e7b28 | 2013-03-15 18:37:13 -0700 | [diff] [blame] | 1726 | |
Hoonki Lee | d37cbb3 | 2013-04-20 00:31:14 -0700 | [diff] [blame] | 1727 | curr_peer = pHddTdlsCtx->curr_candidate; |
| 1728 | |
| 1729 | if (NULL == curr_peer) |
| 1730 | return; |
| 1731 | |
Gopichand Nakkala | 75e7b28 | 2013-03-15 18:37:13 -0700 | [diff] [blame] | 1732 | if (TRUE == sme_IsPmcBmps(WLAN_HDD_GET_HAL_CTX(pHddTdlsCtx->pAdapter))) |
| 1733 | { |
Gopichand Nakkala | ccd3a38 | 2013-03-19 13:56:10 -0700 | [diff] [blame] | 1734 | 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] | 1735 | hdd_disable_bmps_imps(pHddCtx, WLAN_HDD_INFRA_STATION); |
| 1736 | } |
Gopichand Nakkala | ccd3a38 | 2013-03-19 13:56:10 -0700 | [diff] [blame] | 1737 | |
Hoonki Lee | fb8df67 | 2013-04-10 18:20:34 -0700 | [diff] [blame] | 1738 | temp_peer = wlan_hdd_tdls_is_progress(pHddCtx, NULL, 0, FALSE); |
| 1739 | if (NULL != temp_peer) |
| 1740 | { |
| 1741 | VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, "%s: " MAC_ADDRESS_STR " ongoing. pre_setup ignored\n", |
| 1742 | __func__, MAC_ADDR_ARRAY(temp_peer->peerMac)); |
Hoonki Lee | d37cbb3 | 2013-04-20 00:31:14 -0700 | [diff] [blame] | 1743 | goto done; |
Hoonki Lee | fb8df67 | 2013-04-10 18:20:34 -0700 | [diff] [blame] | 1744 | } |
| 1745 | |
Gopichand Nakkala | ccd3a38 | 2013-03-19 13:56:10 -0700 | [diff] [blame] | 1746 | if (eTDLS_CAP_UNKNOWN != curr_peer->tdls_support) |
| 1747 | curr_peer->link_status = eTDLS_LINK_DISCOVERING; |
| 1748 | |
Hoonki Lee | d37cbb3 | 2013-04-20 00:31:14 -0700 | [diff] [blame] | 1749 | status = wlan_hdd_cfg80211_send_tdls_discover_req(pHddTdlsCtx->pAdapter->wdev.wiphy, |
| 1750 | pHddTdlsCtx->pAdapter->dev, |
| 1751 | curr_peer->peerMac); |
| 1752 | |
| 1753 | if (0 != status) |
| 1754 | { |
| 1755 | VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, "%s: " MAC_ADDRESS_STR " discovery could not sent\n", |
| 1756 | __func__, MAC_ADDR_ARRAY(curr_peer->peerMac)); |
| 1757 | if (eTDLS_CAP_UNKNOWN != curr_peer->tdls_support) |
| 1758 | curr_peer->link_status = eTDLS_LINK_IDLE; |
| 1759 | goto done; |
| 1760 | } |
| 1761 | |
Gopichand Nakkala | 75e7b28 | 2013-03-15 18:37:13 -0700 | [diff] [blame] | 1762 | pHddTdlsCtx->discovery_sent_cnt++; |
Gopichand Nakkala | 34d1b06 | 2013-03-19 15:28:33 -0700 | [diff] [blame] | 1763 | wlan_hdd_tdls_check_power_save_prohibited(pHddTdlsCtx->pAdapter); |
Gopichand Nakkala | ccd3a38 | 2013-03-19 13:56:10 -0700 | [diff] [blame] | 1764 | VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, "%s: discovery count %lu timeout %lu msec", |
| 1765 | __func__, pHddTdlsCtx->discovery_sent_cnt, |
| 1766 | pHddTdlsCtx->threshold_config.tx_period_t - TDLS_DISCOVERY_TIMEOUT_BEFORE_UPDATE); |
Gopichand Nakkala | 3046fc9 | 2013-03-23 13:56:43 -0700 | [diff] [blame] | 1767 | |
| 1768 | wlan_hdd_tdls_timer_restart(pHddTdlsCtx->pAdapter, |
| 1769 | &pHddTdlsCtx->peerDiscoveryTimeoutTimer, |
| 1770 | pHddTdlsCtx->threshold_config.tx_period_t - TDLS_DISCOVERY_TIMEOUT_BEFORE_UPDATE); |
Gopichand Nakkala | 75e7b28 | 2013-03-15 18:37:13 -0700 | [diff] [blame] | 1771 | |
Hoonki Lee | d37cbb3 | 2013-04-20 00:31:14 -0700 | [diff] [blame] | 1772 | done: |
| 1773 | pHddTdlsCtx->curr_candidate = NULL; |
| 1774 | pHddTdlsCtx->magic = 0; |
Gopichand Nakkala | 75e7b28 | 2013-03-15 18:37:13 -0700 | [diff] [blame] | 1775 | return; |
| 1776 | } |
Gopichand Nakkala | ccd3a38 | 2013-03-19 13:56:10 -0700 | [diff] [blame] | 1777 | |
| 1778 | tANI_U32 wlan_hdd_tdls_discovery_sent_cnt(hdd_context_t *pHddCtx) |
| 1779 | { |
| 1780 | hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL; |
| 1781 | hdd_adapter_t *pAdapter = NULL; |
| 1782 | tdlsCtx_t *pHddTdlsCtx = NULL; |
| 1783 | VOS_STATUS status = 0; |
| 1784 | tANI_U32 count = 0; |
| 1785 | |
| 1786 | status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode ); |
| 1787 | while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status ) |
| 1788 | { |
| 1789 | pAdapter = pAdapterNode->pAdapter; |
| 1790 | |
Hoonki Lee | a6d49be | 2013-04-05 09:43:25 -0700 | [diff] [blame] | 1791 | pHddTdlsCtx = WLAN_HDD_GET_TDLS_CTX_PTR(pAdapter); |
| 1792 | if (NULL != pHddTdlsCtx) |
Gopichand Nakkala | ccd3a38 | 2013-03-19 13:56:10 -0700 | [diff] [blame] | 1793 | { |
Hoonki Lee | a6d49be | 2013-04-05 09:43:25 -0700 | [diff] [blame] | 1794 | count = count + pHddTdlsCtx->discovery_sent_cnt; |
Gopichand Nakkala | ccd3a38 | 2013-03-19 13:56:10 -0700 | [diff] [blame] | 1795 | } |
| 1796 | status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 1797 | pAdapterNode = pNext; |
| 1798 | } |
| 1799 | return count; |
| 1800 | } |
| 1801 | |
Gopichand Nakkala | 34d1b06 | 2013-03-19 15:28:33 -0700 | [diff] [blame] | 1802 | void wlan_hdd_tdls_check_power_save_prohibited(hdd_adapter_t *pAdapter) |
Gopichand Nakkala | ccd3a38 | 2013-03-19 13:56:10 -0700 | [diff] [blame] | 1803 | { |
| 1804 | tdlsCtx_t *pHddTdlsCtx = WLAN_HDD_GET_TDLS_CTX_PTR(pAdapter); |
| 1805 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 1806 | |
| 1807 | if ((NULL == pHddTdlsCtx) || (NULL == pHddCtx)) |
| 1808 | return; |
| 1809 | |
| 1810 | if ((0 == pHddCtx->connected_peer_count) && |
| 1811 | (0 == wlan_hdd_tdls_discovery_sent_cnt(pHddCtx))) |
| 1812 | { |
| 1813 | sme_SetTdlsPowerSaveProhibited(WLAN_HDD_GET_HAL_CTX(pHddTdlsCtx->pAdapter), 0); |
| 1814 | return; |
| 1815 | } |
| 1816 | sme_SetTdlsPowerSaveProhibited(WLAN_HDD_GET_HAL_CTX(pHddTdlsCtx->pAdapter), 1); |
| 1817 | return; |
| 1818 | } |
Hoonki Lee | 93e67ff | 2013-03-19 15:49:25 -0700 | [diff] [blame] | 1819 | |
| 1820 | void wlan_hdd_tdls_free_scan_request (tdls_scan_context_t *tdls_scan_ctx) |
| 1821 | { |
| 1822 | if (NULL == tdls_scan_ctx) |
| 1823 | return; |
| 1824 | |
Gopichand Nakkala | 3046fc9 | 2013-03-23 13:56:43 -0700 | [diff] [blame] | 1825 | tdls_scan_ctx->attempt = 0; |
Hoonki Lee | fb8df67 | 2013-04-10 18:20:34 -0700 | [diff] [blame] | 1826 | tdls_scan_ctx->reject = 0; |
Gopichand Nakkala | 3046fc9 | 2013-03-23 13:56:43 -0700 | [diff] [blame] | 1827 | tdls_scan_ctx->magic = 0; |
Hoonki Lee | 93e67ff | 2013-03-19 15:49:25 -0700 | [diff] [blame] | 1828 | tdls_scan_ctx->scan_request = NULL; |
| 1829 | return; |
| 1830 | } |
| 1831 | |
| 1832 | int wlan_hdd_tdls_copy_scan_context(hdd_context_t *pHddCtx, |
| 1833 | struct wiphy *wiphy, |
| 1834 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0)) |
| 1835 | struct net_device *dev, |
| 1836 | #endif |
| 1837 | struct cfg80211_scan_request *request) |
| 1838 | { |
| 1839 | tdls_scan_context_t *scan_ctx; |
| 1840 | |
| 1841 | if (NULL == pHddCtx ) |
| 1842 | return -1; |
| 1843 | |
| 1844 | scan_ctx = &pHddCtx->tdls_scan_ctxt; |
| 1845 | |
| 1846 | scan_ctx->wiphy = wiphy; |
| 1847 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0)) |
| 1848 | scan_ctx->dev = dev; |
| 1849 | #endif |
| 1850 | |
| 1851 | scan_ctx->scan_request = request; |
| 1852 | return 0; |
| 1853 | } |
| 1854 | |
| 1855 | static void wlan_hdd_tdls_schedule_scan(struct work_struct *work) |
| 1856 | { |
| 1857 | tdls_scan_context_t *scan_ctx = |
| 1858 | container_of(work, tdls_scan_context_t, tdls_scan_work.work); |
| 1859 | |
| 1860 | if (NULL == scan_ctx) |
| 1861 | return; |
| 1862 | |
| 1863 | if (unlikely(TDLS_CTX_MAGIC != scan_ctx->magic)) |
| 1864 | return; |
| 1865 | |
| 1866 | scan_ctx->attempt++; |
| 1867 | |
| 1868 | wlan_hdd_cfg80211_scan(scan_ctx->wiphy, |
| 1869 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0)) |
| 1870 | scan_ctx->dev, |
| 1871 | #endif |
| 1872 | scan_ctx->scan_request); |
| 1873 | } |
| 1874 | |
| 1875 | static void wlan_hdd_tdls_scan_init_work(hdd_context_t *pHddCtx, |
| 1876 | struct wiphy *wiphy, |
| 1877 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0)) |
| 1878 | struct net_device *dev, |
| 1879 | #endif |
| 1880 | struct cfg80211_scan_request *request, |
| 1881 | unsigned long delay) |
| 1882 | { |
| 1883 | if (TDLS_CTX_MAGIC != pHddCtx->tdls_scan_ctxt.magic) |
| 1884 | { |
| 1885 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0)) |
| 1886 | wlan_hdd_tdls_copy_scan_context(pHddCtx, wiphy, dev, request); |
| 1887 | #else |
| 1888 | wlan_hdd_tdls_copy_scan_context(pHddCtx, wiphy, request); |
| 1889 | #endif |
| 1890 | pHddCtx->tdls_scan_ctxt.attempt = 0; |
| 1891 | pHddCtx->tdls_scan_ctxt.magic = TDLS_CTX_MAGIC; |
| 1892 | } |
| 1893 | INIT_DELAYED_WORK(&pHddCtx->tdls_scan_ctxt.tdls_scan_work, wlan_hdd_tdls_schedule_scan); |
| 1894 | |
| 1895 | schedule_delayed_work(&pHddCtx->tdls_scan_ctxt.tdls_scan_work, delay); |
| 1896 | } |
| 1897 | |
| 1898 | /* return negative = caller should stop and return error code immediately |
| 1899 | return 0 = caller should stop and return success immediately |
| 1900 | return 1 = caller can continue to scan |
| 1901 | */ |
| 1902 | int wlan_hdd_tdls_scan_callback (hdd_adapter_t *pAdapter, |
| 1903 | struct wiphy *wiphy, |
| 1904 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0)) |
| 1905 | struct net_device *dev, |
| 1906 | #endif |
| 1907 | struct cfg80211_scan_request *request) |
| 1908 | { |
| 1909 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0)) |
| 1910 | struct net_device *dev = request->wdev->netdev; |
| 1911 | #endif |
| 1912 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 1913 | u16 connectedTdlsPeers; |
Hoonki Lee | fb8df67 | 2013-04-10 18:20:34 -0700 | [diff] [blame] | 1914 | hddTdlsPeer_t *curr_peer; |
Hoonki Lee | 93e67ff | 2013-03-19 15:49:25 -0700 | [diff] [blame] | 1915 | unsigned long delay; |
| 1916 | |
| 1917 | if (NULL == pHddCtx) |
| 1918 | return 0; |
| 1919 | |
| 1920 | /* if tdls is not enabled, then continue scan */ |
| 1921 | if (eTDLS_SUPPORT_NOT_ENABLED == pHddCtx->tdls_mode) |
| 1922 | return 1; |
| 1923 | |
Hoonki Lee | fb8df67 | 2013-04-10 18:20:34 -0700 | [diff] [blame] | 1924 | curr_peer = wlan_hdd_tdls_is_progress(pHddCtx, NULL, 0, TRUE); |
| 1925 | if (NULL != curr_peer) |
Hoonki Lee | 93e67ff | 2013-03-19 15:49:25 -0700 | [diff] [blame] | 1926 | { |
Hoonki Lee | fb8df67 | 2013-04-10 18:20:34 -0700 | [diff] [blame] | 1927 | if (pHddCtx->tdls_scan_ctxt.reject++ >= TDLS_MAX_SCAN_REJECT) |
| 1928 | { |
| 1929 | pHddCtx->tdls_scan_ctxt.reject = 0; |
| 1930 | VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
| 1931 | "%s: " MAC_ADDRESS_STR ". scan rejected %d. force it to idle", |
| 1932 | __func__, MAC_ADDR_ARRAY (curr_peer->peerMac), pHddCtx->tdls_scan_ctxt.reject); |
| 1933 | |
| 1934 | wlan_hdd_tdls_set_peer_link_status (curr_peer, eTDLS_LINK_IDLE); |
| 1935 | return 1; |
| 1936 | } |
Hoonki Lee | 93e67ff | 2013-03-19 15:49:25 -0700 | [diff] [blame] | 1937 | VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
Hoonki Lee | fb8df67 | 2013-04-10 18:20:34 -0700 | [diff] [blame] | 1938 | "%s: tdls in progress. scan rejected %d", |
| 1939 | __func__, pHddCtx->tdls_scan_ctxt.reject); |
Hoonki Lee | 93e67ff | 2013-03-19 15:49:25 -0700 | [diff] [blame] | 1940 | return -EBUSY; |
| 1941 | } |
| 1942 | |
| 1943 | /* tdls teardown is ongoing */ |
| 1944 | if (eTDLS_SUPPORT_DISABLED == pHddCtx->tdls_mode) |
| 1945 | { |
| 1946 | connectedTdlsPeers = wlan_hdd_tdlsConnectedPeers(pAdapter); |
| 1947 | if (connectedTdlsPeers && (pHddCtx->tdls_scan_ctxt.attempt < TDLS_MAX_SCAN_SCHEDULE)) |
| 1948 | { |
| 1949 | delay = (unsigned long)(TDLS_DELAY_SCAN_PER_CONNECTION*connectedTdlsPeers); |
| 1950 | VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
| 1951 | "%s: tdls disabled, but still connected_peers %d attempt %d. schedule scan %lu msec", |
| 1952 | __func__, connectedTdlsPeers, pHddCtx->tdls_scan_ctxt.attempt, delay); |
| 1953 | |
| 1954 | wlan_hdd_tdls_scan_init_work (pHddCtx, wiphy, |
| 1955 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0)) |
| 1956 | dev, |
| 1957 | #endif |
| 1958 | request, |
| 1959 | msecs_to_jiffies(delay)); |
| 1960 | /* scan should not continue */ |
| 1961 | return 0; |
| 1962 | } |
| 1963 | /* no connected peer or max retry reached, scan continue */ |
| 1964 | VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
| 1965 | "%s: tdls disabled. connected_peers %d attempt %d. scan allowed", |
| 1966 | __func__, connectedTdlsPeers, pHddCtx->tdls_scan_ctxt.attempt); |
| 1967 | return 1; |
| 1968 | } |
| 1969 | /* while tdls is up, first time scan */ |
| 1970 | else if (eTDLS_SUPPORT_ENABLED == pHddCtx->tdls_mode || |
| 1971 | eTDLS_SUPPORT_EXPLICIT_TRIGGER_ONLY == pHddCtx->tdls_mode) |
| 1972 | { |
| 1973 | /* disable implicit trigger logic & tdls operatoin */ |
Gopichand Nakkala | dcbcf4e | 2013-03-23 14:32:39 -0700 | [diff] [blame] | 1974 | wlan_hdd_tdls_set_mode(pHddCtx, eTDLS_SUPPORT_DISABLED, FALSE); |
Hoonki Lee | 93e67ff | 2013-03-19 15:49:25 -0700 | [diff] [blame] | 1975 | /* indicate the teardown all connected to peer */ |
| 1976 | connectedTdlsPeers = wlan_hdd_tdlsConnectedPeers(pAdapter); |
| 1977 | if (connectedTdlsPeers) |
| 1978 | { |
| 1979 | tANI_U8 staIdx; |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 1980 | hddTdlsPeer_t *curr_peer; |
Hoonki Lee | 93e67ff | 2013-03-19 15:49:25 -0700 | [diff] [blame] | 1981 | |
| 1982 | for (staIdx = 0; staIdx < HDD_MAX_NUM_TDLS_STA; staIdx++) |
| 1983 | { |
| 1984 | if (pHddCtx->tdlsConnInfo[staIdx].staId) |
| 1985 | { |
Gopichand Nakkala | 4ddf019 | 2013-03-27 13:41:20 -0700 | [diff] [blame] | 1986 | VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
Hoonki Lee | 93e67ff | 2013-03-19 15:49:25 -0700 | [diff] [blame] | 1987 | ("%s: indicate TDLS teadown (staId %d)"), __func__, pHddCtx->tdlsConnInfo[staIdx].staId) ; |
| 1988 | |
| 1989 | #ifdef CONFIG_TDLS_IMPLICIT |
Hoonki Lee | a6d49be | 2013-04-05 09:43:25 -0700 | [diff] [blame] | 1990 | curr_peer = wlan_hdd_tdls_find_all_peer(pHddCtx, pHddCtx->tdlsConnInfo[staIdx].peerMac.bytes); |
| 1991 | if(curr_peer) |
| 1992 | 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] | 1993 | #endif |
| 1994 | } |
| 1995 | } |
| 1996 | /* schedule scan */ |
| 1997 | delay = (unsigned long)(TDLS_DELAY_SCAN_PER_CONNECTION*connectedTdlsPeers); |
| 1998 | |
| 1999 | VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
| 2000 | "%s: tdls enabled (mode %d), connected_peers %d. schedule scan %lu msec", |
| 2001 | __func__, pHddCtx->tdls_mode, wlan_hdd_tdlsConnectedPeers(pAdapter), |
| 2002 | delay); |
| 2003 | |
| 2004 | wlan_hdd_tdls_scan_init_work (pHddCtx, wiphy, |
| 2005 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0)) |
| 2006 | dev, |
| 2007 | #endif |
| 2008 | request, |
| 2009 | msecs_to_jiffies(delay)); |
| 2010 | /* scan should not continue */ |
| 2011 | return 0; |
| 2012 | } |
| 2013 | /* no connected peer, scan continue */ |
| 2014 | VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
| 2015 | "%s: tdls_mode %d, and no tdls connection. scan allowed", |
| 2016 | __func__, pHddCtx->tdls_mode); |
| 2017 | } |
| 2018 | return 1; |
| 2019 | } |
| 2020 | |
| 2021 | void wlan_hdd_tdls_scan_done_callback(hdd_adapter_t *pAdapter) |
| 2022 | { |
| 2023 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
Hoonki Lee | 93e67ff | 2013-03-19 15:49:25 -0700 | [diff] [blame] | 2024 | |
| 2025 | if (NULL == pHddCtx) |
| 2026 | return; |
| 2027 | |
| 2028 | /* free allocated memory at scan time */ |
Gopichand Nakkala | 3046fc9 | 2013-03-23 13:56:43 -0700 | [diff] [blame] | 2029 | wlan_hdd_tdls_free_scan_request (&pHddCtx->tdls_scan_ctxt); |
Hoonki Lee | 93e67ff | 2013-03-19 15:49:25 -0700 | [diff] [blame] | 2030 | |
| 2031 | /* if tdls was enabled before scan, re-enable tdls mode */ |
| 2032 | if(eTDLS_SUPPORT_ENABLED == pHddCtx->tdls_mode_last || |
| 2033 | eTDLS_SUPPORT_EXPLICIT_TRIGGER_ONLY == pHddCtx->tdls_mode_last) |
| 2034 | { |
Gopichand Nakkala | 4ddf019 | 2013-03-27 13:41:20 -0700 | [diff] [blame] | 2035 | VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
Hoonki Lee | 93e67ff | 2013-03-19 15:49:25 -0700 | [diff] [blame] | 2036 | ("%s: revert tdls mode %d"), __func__, pHddCtx->tdls_mode_last); |
| 2037 | |
Gopichand Nakkala | dcbcf4e | 2013-03-23 14:32:39 -0700 | [diff] [blame] | 2038 | wlan_hdd_tdls_set_mode(pHddCtx, pHddCtx->tdls_mode_last, FALSE); |
Hoonki Lee | 93e67ff | 2013-03-19 15:49:25 -0700 | [diff] [blame] | 2039 | } |
| 2040 | wlan_hdd_tdls_check_bmps(pAdapter); |
| 2041 | } |
Gopichand Nakkala | 3046fc9 | 2013-03-23 13:56:43 -0700 | [diff] [blame] | 2042 | |
| 2043 | void wlan_hdd_tdls_timer_restart(hdd_adapter_t *pAdapter, |
| 2044 | vos_timer_t *timer, |
| 2045 | v_U32_t expirationTime) |
| 2046 | { |
| 2047 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 2048 | |
| 2049 | if (NULL == pHddStaCtx) |
| 2050 | return; |
| 2051 | |
| 2052 | /* Check whether driver load unload is in progress */ |
| 2053 | if(vos_is_load_unload_in_progress( VOS_MODULE_ID_VOSS, NULL)) |
| 2054 | { |
| 2055 | VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR, |
| 2056 | "%s: Driver load/unload is in progress.", __func__); |
| 2057 | return; |
| 2058 | } |
| 2059 | |
| 2060 | if (hdd_connIsConnected(pHddStaCtx)) |
| 2061 | { |
| 2062 | vos_timer_stop(timer); |
| 2063 | vos_timer_start(timer, expirationTime); |
| 2064 | } |
| 2065 | } |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 2066 | void wlan_hdd_tdls_indicate_teardown(hdd_adapter_t *pAdapter, |
| 2067 | hddTdlsPeer_t *curr_peer, |
| 2068 | tANI_U16 reason) |
| 2069 | { |
| 2070 | if (NULL == pAdapter || NULL == curr_peer) |
| 2071 | return; |
| 2072 | |
| 2073 | if (eTDLS_LINK_CONNECTED != curr_peer->link_status) |
| 2074 | return; |
| 2075 | |
| 2076 | wlan_hdd_tdls_set_peer_link_status(curr_peer, eTDLS_LINK_TEARING); |
| 2077 | cfg80211_tdls_oper_request(pAdapter->dev, |
| 2078 | curr_peer->peerMac, |
| 2079 | NL80211_TDLS_TEARDOWN, |
| 2080 | reason, |
| 2081 | GFP_KERNEL); |
| 2082 | } |