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