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