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