Kiran V | 1ccee93 | 2012-12-12 14:49:46 -0800 | [diff] [blame] | 1 | /* |
Pradeep Reddy POTTETI | c7822df | 2015-02-19 20:15:41 +0530 | [diff] [blame] | 2 | * Copyright (c) 2012-2015 The Linux Foundation. All rights reserved. |
Kiet Lam | 842dad0 | 2014-02-18 18:44:02 -0800 | [diff] [blame] | 3 | * |
| 4 | * Previously licensed under the ISC license by Qualcomm Atheros, Inc. |
| 5 | * |
| 6 | * |
| 7 | * Permission to use, copy, modify, and/or distribute this software for |
| 8 | * any purpose with or without fee is hereby granted, provided that the |
| 9 | * above copyright notice and this permission notice appear in all |
| 10 | * copies. |
| 11 | * |
| 12 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL |
| 13 | * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED |
| 14 | * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE |
| 15 | * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL |
| 16 | * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR |
| 17 | * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER |
| 18 | * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR |
| 19 | * PERFORMANCE OF THIS SOFTWARE. |
Gopichand Nakkala | 0c1331e | 2013-01-07 22:49:07 -0800 | [diff] [blame] | 20 | */ |
Kiet Lam | 842dad0 | 2014-02-18 18:44:02 -0800 | [diff] [blame] | 21 | |
| 22 | /* |
| 23 | * This file was originally distributed by Qualcomm Atheros, Inc. |
| 24 | * under proprietary terms before Copyright ownership was assigned |
| 25 | * to the Linux Foundation. |
| 26 | */ |
| 27 | |
Kiran V | 1ccee93 | 2012-12-12 14:49:46 -0800 | [diff] [blame] | 28 | /**======================================================================== |
| 29 | |
| 30 | \file wlan_hdd_tdls.c |
| 31 | |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 32 | \brief WLAN Host Device Driver implementation for TDLS |
Kiran V | 1ccee93 | 2012-12-12 14:49:46 -0800 | [diff] [blame] | 33 | |
Kiran V | 1ccee93 | 2012-12-12 14:49:46 -0800 | [diff] [blame] | 34 | ========================================================================*/ |
| 35 | |
| 36 | #include <wlan_hdd_includes.h> |
| 37 | #include <wlan_hdd_hostapd.h> |
| 38 | #include <net/cfg80211.h> |
| 39 | #include <linux/netdevice.h> |
| 40 | #include <linux/skbuff.h> |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 41 | #include <linux/list.h> |
Kiran V | 1ccee93 | 2012-12-12 14:49:46 -0800 | [diff] [blame] | 42 | #include <linux/etherdevice.h> |
| 43 | #include <net/ieee80211_radiotap.h> |
| 44 | #include "wlan_hdd_tdls.h" |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 45 | #include "wlan_hdd_cfg80211.h" |
Mahesh A Saptasagar | 8b231b3 | 2014-08-11 11:58:15 +0530 | [diff] [blame] | 46 | #include "vos_sched.h" |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 47 | |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 48 | static tANI_S32 wlan_hdd_get_tdls_discovery_peer_cnt(tdlsCtx_t *pHddTdlsCtx); |
| 49 | static tANI_S32 wlan_hdd_tdls_peer_reset_discovery_processed(tdlsCtx_t *pHddTdlsCtx); |
| 50 | static void wlan_hdd_tdls_timers_destroy(tdlsCtx_t *pHddTdlsCtx); |
Madan Mohan Koyyalamudi | 693275b | 2013-07-22 19:14:09 +0530 | [diff] [blame] | 51 | static void wlan_hdd_tdls_peer_timers_destroy(tdlsCtx_t *pHddTdlsCtx); |
Sunil Dutt | 41de4e2 | 2013-11-14 18:09:02 +0530 | [diff] [blame] | 52 | int wpa_tdls_is_allowed_force_peer(tdlsCtx_t *pHddTdlsCtx, u8 *mac); |
Hoonki Lee | d37cbb3 | 2013-04-20 00:31:14 -0700 | [diff] [blame] | 53 | #ifdef CONFIG_TDLS_IMPLICIT |
Pradeep Reddy POTTETI | 9db32f0 | 2015-01-29 15:22:54 +0530 | [diff] [blame] | 54 | static void wlan_hdd_tdls_implicit_send_discovery_request(tdlsCtx_t *pHddTdlsCtx); |
Hoonki Lee | d37cbb3 | 2013-04-20 00:31:14 -0700 | [diff] [blame] | 55 | #endif |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 56 | |
Hoonki Lee | 387663d | 2013-02-05 18:08:43 -0800 | [diff] [blame] | 57 | static u8 wlan_hdd_tdls_hash_key (u8 *mac) |
Hoonki Lee | f63df0d | 2013-01-16 19:29:14 -0800 | [diff] [blame] | 58 | { |
| 59 | int i; |
Hoonki Lee | 387663d | 2013-02-05 18:08:43 -0800 | [diff] [blame] | 60 | u8 key = 0; |
| 61 | |
| 62 | for (i = 0; i < 6; i++) |
| 63 | key ^= mac[i]; |
| 64 | |
| 65 | return key; |
| 66 | } |
| 67 | |
Masti, Narayanraddi | fdde4d0 | 2015-04-16 14:41:51 +0530 | [diff] [blame] | 68 | /** |
| 69 | * wlan_hdd_tdls_disable_offchan_and_teardown_links - Disable offchannel |
| 70 | * and teardown TDLS links |
| 71 | * @hddCtx : pointer to hdd context |
| 72 | * |
| 73 | * Return: None |
| 74 | */ |
| 75 | void wlan_hdd_tdls_disable_offchan_and_teardown_links(hdd_context_t *hddctx) |
| 76 | { |
| 77 | u16 connected_tdls_peers = 0; |
| 78 | u8 staidx; |
| 79 | hddTdlsPeer_t *curr_peer = NULL; |
| 80 | hdd_adapter_t *adapter = NULL; |
| 81 | |
| 82 | if (eTDLS_SUPPORT_NOT_ENABLED == hddctx->tdls_mode) { |
| 83 | hddLog(LOG1, FL("TDLS mode is disabled OR not enabled in FW")); |
| 84 | return ; |
| 85 | } |
| 86 | |
| 87 | adapter = hdd_get_adapter(hddctx, WLAN_HDD_INFRA_STATION); |
| 88 | |
| 89 | if (adapter == NULL) { |
| 90 | hddLog(LOGE, FL("Station Adapter Not Found")); |
| 91 | return; |
| 92 | } |
| 93 | |
| 94 | connected_tdls_peers = wlan_hdd_tdlsConnectedPeers(adapter); |
| 95 | |
| 96 | if (!connected_tdls_peers) |
| 97 | return ; |
| 98 | |
| 99 | /* TDLS is not supported in case of concurrency |
| 100 | * Disable TDLS Offchannel to avoid more than two concurrent channels. |
| 101 | */ |
| 102 | if (connected_tdls_peers == 1) { |
| 103 | curr_peer = wlan_hdd_tdls_get_connected_peer(adapter); |
| 104 | if (curr_peer && (curr_peer->isOffChannelConfigured == TRUE)) { |
| 105 | hddLog(LOG1, FL("%s: Concurrency detected, Disable " |
| 106 | "TDLS channel switch"), __func__); |
| 107 | |
| 108 | sme_SendTdlsChanSwitchReq(WLAN_HDD_GET_HAL_CTX(adapter), |
| 109 | adapter->sessionId, |
| 110 | curr_peer->peerMac, |
| 111 | curr_peer->peerParams.channel, |
| 112 | TDLS_OFF_CHANNEL_BW_OFFSET, |
| 113 | TDLS_CHANNEL_SWITCH_DISABLE); |
| 114 | } |
| 115 | } |
| 116 | |
| 117 | /* As mentioned above TDLS is not supported in case of concurrency |
| 118 | * Find the connected peer and generate TDLS teardown indication to |
| 119 | * supplicant. |
| 120 | */ |
| 121 | for (staidx = 0; staidx < HDD_MAX_NUM_TDLS_STA; staidx++) { |
| 122 | if (!hddctx->tdlsConnInfo[staidx].staId) |
| 123 | continue; |
| 124 | |
| 125 | curr_peer = wlan_hdd_tdls_find_all_peer(hddctx, |
| 126 | hddctx->tdlsConnInfo[staidx].peerMac.bytes); |
| 127 | |
| 128 | if (!curr_peer) |
| 129 | continue; |
| 130 | |
| 131 | hddLog(LOG1, FL("indicate TDLS teardown (staId %d)"), |
| 132 | curr_peer->staId); |
| 133 | |
| 134 | wlan_hdd_tdls_indicate_teardown( |
| 135 | curr_peer->pHddTdlsCtx->pAdapter, |
| 136 | curr_peer, |
| 137 | eSIR_MAC_TDLS_TEARDOWN_UNSPEC_REASON); |
| 138 | } |
| 139 | wlan_hdd_tdls_set_mode(hddctx, eTDLS_SUPPORT_DISABLED, FALSE); |
| 140 | hddLog(LOG1, FL("TDLS Support Disabled")); |
| 141 | } |
| 142 | |
| 143 | /** |
| 144 | * hdd_tdls_notify_mode_change - Notify mode change |
| 145 | * @adapter: pointer to hdd adapter |
| 146 | * @hddCtx : pointer to hdd context |
| 147 | * |
| 148 | * Return: None |
| 149 | */ |
| 150 | void hdd_tdls_notify_mode_change(hdd_adapter_t *adapter, hdd_context_t *hddctx) |
| 151 | { |
| 152 | if (adapter->device_mode != WLAN_HDD_INFRA_STATION) |
| 153 | wlan_hdd_tdls_disable_offchan_and_teardown_links(hddctx); |
| 154 | } |
| 155 | |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 156 | static v_VOID_t wlan_hdd_tdls_start_peer_discover_timer(tdlsCtx_t *pHddTdlsCtx, |
| 157 | tANI_BOOLEAN mutexLock, |
| 158 | v_U32_t discoveryExpiry) |
Gopichand Nakkala | eb69b60 | 2013-02-27 11:40:31 -0800 | [diff] [blame] | 159 | { |
Gopichand Nakkala | eb69b60 | 2013-02-27 11:40:31 -0800 | [diff] [blame] | 160 | hdd_station_ctx_t *pHddStaCtx; |
Madan Mohan Koyyalamudi | 263cec1 | 2013-10-07 10:57:50 +0530 | [diff] [blame] | 161 | hdd_context_t *pHddCtx; |
| 162 | |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 163 | ENTER(); |
| 164 | |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 165 | if ((NULL == pHddTdlsCtx) || (NULL == pHddTdlsCtx->pAdapter) ) |
| 166 | { |
| 167 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 168 | FL(" pHddTdlsCtx or pAdapter points to NULL")); |
Madan Mohan Koyyalamudi | 263cec1 | 2013-10-07 10:57:50 +0530 | [diff] [blame] | 169 | return; |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 170 | } |
Madan Mohan Koyyalamudi | 263cec1 | 2013-10-07 10:57:50 +0530 | [diff] [blame] | 171 | |
| 172 | pHddCtx = WLAN_HDD_GET_CTX( pHddTdlsCtx->pAdapter ); |
| 173 | |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 174 | if(0 != (wlan_hdd_validate_context(pHddCtx))) |
| 175 | { |
Madan Mohan Koyyalamudi | 263cec1 | 2013-10-07 10:57:50 +0530 | [diff] [blame] | 176 | return; |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 177 | } |
Gopichand Nakkala | eb69b60 | 2013-02-27 11:40:31 -0800 | [diff] [blame] | 178 | |
Gopichand Nakkala | eb69b60 | 2013-02-27 11:40:31 -0800 | [diff] [blame] | 179 | if ( mutexLock ) |
| 180 | { |
Rajesh Chauhan | a34c6e6 | 2014-03-25 16:37:58 +0530 | [diff] [blame] | 181 | mutex_lock(&pHddCtx->tdls_lock); |
Gopichand Nakkala | eb69b60 | 2013-02-27 11:40:31 -0800 | [diff] [blame] | 182 | } |
Gopichand Nakkala | eb69b60 | 2013-02-27 11:40:31 -0800 | [diff] [blame] | 183 | |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 184 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pHddTdlsCtx->pAdapter); |
Gopichand Nakkala | 75e7b28 | 2013-03-15 18:37:13 -0700 | [diff] [blame] | 185 | #ifdef FEATURE_WLAN_TDLS_INTERNAL |
Gopichand Nakkala | 3046fc9 | 2013-03-23 13:56:43 -0700 | [diff] [blame] | 186 | wlan_hdd_tdls_timer_restart(pHddTdlsCtx->pAdapter, |
| 187 | &pHddTdlsCtx->peerDiscoverTimer, |
| 188 | discoveryExpiry); |
Gopichand Nakkala | 75e7b28 | 2013-03-15 18:37:13 -0700 | [diff] [blame] | 189 | #endif |
Gopichand Nakkala | 3046fc9 | 2013-03-23 13:56:43 -0700 | [diff] [blame] | 190 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "beacon rssi: %d", |
| 191 | pHddTdlsCtx->ap_rssi); |
| 192 | |
Gopichand Nakkala | eb69b60 | 2013-02-27 11:40:31 -0800 | [diff] [blame] | 193 | if ( mutexLock ) |
Madan Mohan Koyyalamudi | 263cec1 | 2013-10-07 10:57:50 +0530 | [diff] [blame] | 194 | mutex_unlock(&pHddCtx->tdls_lock); |
Gopichand Nakkala | eb69b60 | 2013-02-27 11:40:31 -0800 | [diff] [blame] | 195 | |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 196 | EXIT(); |
Gopichand Nakkala | eb69b60 | 2013-02-27 11:40:31 -0800 | [diff] [blame] | 197 | return; |
| 198 | } |
| 199 | |
Hoonki Lee | d37cbb3 | 2013-04-20 00:31:14 -0700 | [diff] [blame] | 200 | #ifdef TDLS_USE_SEPARATE_DISCOVERY_TIMER |
Hoonki Lee | 387663d | 2013-02-05 18:08:43 -0800 | [diff] [blame] | 201 | static v_VOID_t wlan_hdd_tdls_discover_peer_cb( v_PVOID_t userData ) |
| 202 | { |
| 203 | int i; |
| 204 | struct list_head *head; |
| 205 | struct list_head *pos; |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 206 | hddTdlsPeer_t *curr_peer; |
Madan Mohan Koyyalamudi | 263cec1 | 2013-10-07 10:57:50 +0530 | [diff] [blame] | 207 | hdd_context_t *pHddCtx; |
Mahesh A Saptasagar | 170b508 | 2015-02-16 18:50:54 +0530 | [diff] [blame] | 208 | tdlsCtx_t *pHddTdlsCtx; |
Gopichand Nakkala | c369458 | 2013-02-13 20:51:22 -0800 | [diff] [blame] | 209 | int discover_req_sent = 0; |
| 210 | v_U32_t discover_expiry = TDLS_SUB_DISCOVERY_PERIOD; |
Gopichand Nakkala | eb69b60 | 2013-02-27 11:40:31 -0800 | [diff] [blame] | 211 | tANI_BOOLEAN doMutexLock = eANI_BOOLEAN_TRUE; |
Mahesh A Saptasagar | 170b508 | 2015-02-16 18:50:54 +0530 | [diff] [blame] | 212 | v_CONTEXT_t pVosContext; |
Gopichand Nakkala | c369458 | 2013-02-13 20:51:22 -0800 | [diff] [blame] | 213 | |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 214 | ENTER(); |
| 215 | |
Mahesh A Saptasagar | 170b508 | 2015-02-16 18:50:54 +0530 | [diff] [blame] | 216 | pVosContext = vos_get_global_context(VOS_MODULE_ID_HDD, NULL); |
| 217 | if (NULL == pVosContext) |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 218 | { |
| 219 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Mahesh A Saptasagar | 170b508 | 2015-02-16 18:50:54 +0530 | [diff] [blame] | 220 | FL("pVosContext points to NULL")); |
Madan Mohan Koyyalamudi | 263cec1 | 2013-10-07 10:57:50 +0530 | [diff] [blame] | 221 | return; |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 222 | } |
Madan Mohan Koyyalamudi | 263cec1 | 2013-10-07 10:57:50 +0530 | [diff] [blame] | 223 | |
Mahesh A Saptasagar | 170b508 | 2015-02-16 18:50:54 +0530 | [diff] [blame] | 224 | pHddCtx = vos_get_context(VOS_MODULE_ID_HDD, pVosContext); |
| 225 | if (0 != (wlan_hdd_validate_context(pHddCtx))) |
Sushant Kaushik | 15c4c52 | 2014-08-14 12:24:49 +0530 | [diff] [blame] | 226 | { |
Madan Mohan Koyyalamudi | 263cec1 | 2013-10-07 10:57:50 +0530 | [diff] [blame] | 227 | return; |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 228 | } |
Madan Mohan Koyyalamudi | 263cec1 | 2013-10-07 10:57:50 +0530 | [diff] [blame] | 229 | |
Rajesh Chauhan | a34c6e6 | 2014-03-25 16:37:58 +0530 | [diff] [blame] | 230 | mutex_lock(&pHddCtx->tdls_lock); |
Mahesh A Saptasagar | 170b508 | 2015-02-16 18:50:54 +0530 | [diff] [blame] | 231 | pHddTdlsCtx = (tdlsCtx_t *)userData; |
| 232 | if (0 != (wlan_hdd_validate_tdls_context(pHddCtx, pHddTdlsCtx))) |
| 233 | { |
| 234 | mutex_unlock(&pHddCtx->tdls_lock); |
| 235 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 236 | FL("Invalid pHddTdlsCtx context")); |
| 237 | return; |
| 238 | } |
Hoonki Lee | bfee034 | 2013-01-21 16:43:45 -0800 | [diff] [blame] | 239 | |
Hoonki Lee | 387663d | 2013-02-05 18:08:43 -0800 | [diff] [blame] | 240 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: ", __func__); |
| 241 | |
Gopichand Nakkala | c369458 | 2013-02-13 20:51:22 -0800 | [diff] [blame] | 242 | if (0 == pHddTdlsCtx->discovery_peer_cnt) |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 243 | pHddTdlsCtx->discovery_peer_cnt = wlan_hdd_get_tdls_discovery_peer_cnt(pHddTdlsCtx); |
Gopichand Nakkala | c369458 | 2013-02-13 20:51:22 -0800 | [diff] [blame] | 244 | |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 245 | for (i = 0; i < 256; i++) { |
Hoonki Lee | 387663d | 2013-02-05 18:08:43 -0800 | [diff] [blame] | 246 | head = &pHddTdlsCtx->peer_list[i]; |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 247 | |
Hoonki Lee | 387663d | 2013-02-05 18:08:43 -0800 | [diff] [blame] | 248 | list_for_each (pos, head) { |
| 249 | curr_peer = list_entry (pos, hddTdlsPeer_t, node); |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 250 | |
Masti, Narayanraddi | 34e0e56 | 2015-03-05 18:23:03 +0530 | [diff] [blame] | 251 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Chilam Ng | 0112041 | 2013-02-19 18:32:21 -0800 | [diff] [blame] | 252 | "%d " MAC_ADDRESS_STR " %d %d, %d %d %d %d", i, |
| 253 | MAC_ADDR_ARRAY(curr_peer->peerMac), |
Gopichand Nakkala | c369458 | 2013-02-13 20:51:22 -0800 | [diff] [blame] | 254 | curr_peer->discovery_processed, |
| 255 | discover_req_sent, |
Gopichand Nakkala | 2a0a157 | 2013-02-10 21:39:16 -0800 | [diff] [blame] | 256 | curr_peer->tdls_support, |
| 257 | curr_peer->link_status, |
| 258 | curr_peer->discovery_attempt, |
| 259 | pHddTdlsCtx->threshold_config.discovery_tries_n); |
Hoonki Lee | 387663d | 2013-02-05 18:08:43 -0800 | [diff] [blame] | 260 | |
Gopichand Nakkala | c369458 | 2013-02-13 20:51:22 -0800 | [diff] [blame] | 261 | if (discover_req_sent < TDLS_MAX_DISCOVER_REQS_PER_TIMER) { |
| 262 | if (!curr_peer->discovery_processed) { |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 263 | |
Gopichand Nakkala | c369458 | 2013-02-13 20:51:22 -0800 | [diff] [blame] | 264 | curr_peer->discovery_processed = 1; |
| 265 | discover_req_sent++; |
| 266 | pHddTdlsCtx->discovery_peer_cnt--; |
| 267 | |
| 268 | if ((eTDLS_CAP_UNKNOWN == curr_peer->tdls_support) && |
Gopichand Nakkala | 901e892 | 2013-03-04 23:45:58 -0800 | [diff] [blame] | 269 | (eTDLS_LINK_IDLE == curr_peer->link_status) && |
Gopichand Nakkala | b88f677 | 2013-02-27 18:12:56 -0800 | [diff] [blame] | 270 | (curr_peer->tx_pkt >= |
| 271 | pHddTdlsCtx->threshold_config.tx_packet_n)) { |
Gopichand Nakkala | 273d5a0 | 2013-02-19 15:15:09 -0800 | [diff] [blame] | 272 | |
| 273 | if (curr_peer->discovery_attempt < |
| 274 | pHddTdlsCtx->threshold_config.discovery_tries_n) { |
Pradeep Reddy POTTETI | 9db32f0 | 2015-01-29 15:22:54 +0530 | [diff] [blame] | 275 | cfg80211_tdls_oper_request( |
| 276 | pHddTdlsCtx->pAdapter->dev, |
| 277 | curr_peer->peerMac, |
| 278 | NL80211_TDLS_DISCOVERY_REQ, |
| 279 | FALSE, |
| 280 | GFP_KERNEL); |
Gopichand Nakkala | 273d5a0 | 2013-02-19 15:15:09 -0800 | [diff] [blame] | 281 | curr_peer->discovery_attempt++; |
| 282 | } |
| 283 | else |
| 284 | { |
Masti, Narayanraddi | 34e0e56 | 2015-03-05 18:23:03 +0530 | [diff] [blame] | 285 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, |
Gopichand Nakkala | 273d5a0 | 2013-02-19 15:15:09 -0800 | [diff] [blame] | 286 | "%s: Maximum Discovery retries reached", __func__); |
| 287 | curr_peer->tdls_support = eTDLS_CAP_NOT_SUPPORTED; |
| 288 | } |
Gopichand Nakkala | c369458 | 2013-02-13 20:51:22 -0800 | [diff] [blame] | 289 | |
| 290 | } |
| 291 | } |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 292 | } |
Gopichand Nakkala | c369458 | 2013-02-13 20:51:22 -0800 | [diff] [blame] | 293 | else |
| 294 | goto exit_loop; |
Hoonki Lee | 387663d | 2013-02-05 18:08:43 -0800 | [diff] [blame] | 295 | } |
Hoonki Lee | f63df0d | 2013-01-16 19:29:14 -0800 | [diff] [blame] | 296 | } |
Gopichand Nakkala | c369458 | 2013-02-13 20:51:22 -0800 | [diff] [blame] | 297 | exit_loop: |
Hoonki Lee | f63df0d | 2013-01-16 19:29:14 -0800 | [diff] [blame] | 298 | |
Gopichand Nakkala | c369458 | 2013-02-13 20:51:22 -0800 | [diff] [blame] | 299 | if (0 != pHddTdlsCtx->discovery_peer_cnt) { |
Masti, Narayanraddi | 34e0e56 | 2015-03-05 18:23:03 +0530 | [diff] [blame] | 300 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Gopichand Nakkala | c369458 | 2013-02-13 20:51:22 -0800 | [diff] [blame] | 301 | "discovery_peer_cnt is %d , Starting SUB_DISCOVERY_TIMER", |
| 302 | pHddTdlsCtx->discovery_peer_cnt); |
| 303 | discover_expiry = TDLS_SUB_DISCOVERY_PERIOD; |
Gopichand Nakkala | eb69b60 | 2013-02-27 11:40:31 -0800 | [diff] [blame] | 304 | doMutexLock = eANI_BOOLEAN_FALSE; |
Gopichand Nakkala | c369458 | 2013-02-13 20:51:22 -0800 | [diff] [blame] | 305 | goto done; |
| 306 | } |
Gopichand Nakkala | c369458 | 2013-02-13 20:51:22 -0800 | [diff] [blame] | 307 | discover_expiry = pHddTdlsCtx->threshold_config.discovery_period_t; |
| 308 | |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 309 | wlan_hdd_tdls_peer_reset_discovery_processed(pHddTdlsCtx); |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 310 | |
Madan Mohan Koyyalamudi | 263cec1 | 2013-10-07 10:57:50 +0530 | [diff] [blame] | 311 | mutex_unlock(&pHddCtx->tdls_lock); |
Gopichand Nakkala | 638ebc7 | 2013-03-21 18:04:02 -0700 | [diff] [blame] | 312 | |
Gopichand Nakkala | eb69b60 | 2013-02-27 11:40:31 -0800 | [diff] [blame] | 313 | /* Commenting out the following function as it was introducing |
| 314 | * a race condition when pHddTdlsCtx is deleted. Also , this |
| 315 | * function is consuming more time in the timer callback. |
| 316 | * RSSI based trigger needs to revisit this part of the code. |
| 317 | */ |
| 318 | |
| 319 | /* |
| 320 | * wlan_hdd_get_rssi(pAdapter, &pHddTdlsCtx->ap_rssi); |
| 321 | */ |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 322 | |
Gopichand Nakkala | c369458 | 2013-02-13 20:51:22 -0800 | [diff] [blame] | 323 | done: |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 324 | wlan_hdd_tdls_start_peer_discover_timer(pHddTdlsCtx, doMutexLock, discover_expiry); |
Gopichand Nakkala | 91b0926 | 2013-02-10 14:27:02 -0800 | [diff] [blame] | 325 | |
Gopichand Nakkala | eb69b60 | 2013-02-27 11:40:31 -0800 | [diff] [blame] | 326 | if ( !doMutexLock ) |
Madan Mohan Koyyalamudi | 263cec1 | 2013-10-07 10:57:50 +0530 | [diff] [blame] | 327 | mutex_unlock(&pHddCtx->tdls_lock); |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 328 | EXIT(); |
Gopichand Nakkala | eb69b60 | 2013-02-27 11:40:31 -0800 | [diff] [blame] | 329 | return; |
Hoonki Lee | f63df0d | 2013-01-16 19:29:14 -0800 | [diff] [blame] | 330 | } |
Hoonki Lee | d37cbb3 | 2013-04-20 00:31:14 -0700 | [diff] [blame] | 331 | #endif |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 332 | |
Hoonki Lee | 387663d | 2013-02-05 18:08:43 -0800 | [diff] [blame] | 333 | 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] | 334 | { |
| 335 | int i; |
Hoonki Lee | 387663d | 2013-02-05 18:08:43 -0800 | [diff] [blame] | 336 | struct list_head *head; |
| 337 | struct list_head *pos; |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 338 | hddTdlsPeer_t *curr_peer; |
Mahesh A Saptasagar | 170b508 | 2015-02-16 18:50:54 +0530 | [diff] [blame] | 339 | tdlsCtx_t *pHddTdlsCtx; |
Madan Mohan Koyyalamudi | 263cec1 | 2013-10-07 10:57:50 +0530 | [diff] [blame] | 340 | hdd_context_t *pHddCtx; |
Mahesh A Saptasagar | 170b508 | 2015-02-16 18:50:54 +0530 | [diff] [blame] | 341 | v_CONTEXT_t pVosContext; |
Hoonki Lee | bfee034 | 2013-01-21 16:43:45 -0800 | [diff] [blame] | 342 | |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 343 | ENTER(); |
Mahesh A Saptasagar | 170b508 | 2015-02-16 18:50:54 +0530 | [diff] [blame] | 344 | pVosContext = vos_get_global_context(VOS_MODULE_ID_HDD, NULL); |
| 345 | if (NULL == pVosContext) |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 346 | { |
| 347 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Mahesh A Saptasagar | 170b508 | 2015-02-16 18:50:54 +0530 | [diff] [blame] | 348 | FL("pVosContext points to NULL")); |
Madan Mohan Koyyalamudi | 263cec1 | 2013-10-07 10:57:50 +0530 | [diff] [blame] | 349 | return; |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 350 | } |
Mahesh A Saptasagar | 170b508 | 2015-02-16 18:50:54 +0530 | [diff] [blame] | 351 | pHddCtx = vos_get_context(VOS_MODULE_ID_HDD, pVosContext); |
| 352 | if (0 != (wlan_hdd_validate_context(pHddCtx))) |
Sushant Kaushik | 15c4c52 | 2014-08-14 12:24:49 +0530 | [diff] [blame] | 353 | { |
Madan Mohan Koyyalamudi | 263cec1 | 2013-10-07 10:57:50 +0530 | [diff] [blame] | 354 | return; |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 355 | } |
Rajesh Chauhan | a34c6e6 | 2014-03-25 16:37:58 +0530 | [diff] [blame] | 356 | mutex_lock(&pHddCtx->tdls_lock); |
Mahesh A Saptasagar | 170b508 | 2015-02-16 18:50:54 +0530 | [diff] [blame] | 357 | pHddTdlsCtx = (tdlsCtx_t *)userData; |
| 358 | if (0 != (wlan_hdd_validate_tdls_context(pHddCtx, pHddTdlsCtx))) |
| 359 | { |
| 360 | mutex_unlock(&pHddCtx->tdls_lock); |
| 361 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 362 | FL("Invalid pHddTdlsCtx context")); |
| 363 | return; |
| 364 | } |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 365 | for (i = 0; i < 256; i++) { |
Hoonki Lee | 387663d | 2013-02-05 18:08:43 -0800 | [diff] [blame] | 366 | head = &pHddTdlsCtx->peer_list[i]; |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 367 | |
Hoonki Lee | 387663d | 2013-02-05 18:08:43 -0800 | [diff] [blame] | 368 | list_for_each (pos, head) { |
| 369 | curr_peer = list_entry (pos, hddTdlsPeer_t, node); |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 370 | |
Masti, Narayanraddi | 34e0e56 | 2015-03-05 18:23:03 +0530 | [diff] [blame] | 371 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Hoonki Lee | 66b75f3 | 2013-04-16 18:30:07 -0700 | [diff] [blame] | 372 | "%s: " MAC_ADDRESS_STR " link_status %d" |
| 373 | " tdls_support %d", __func__, MAC_ADDR_ARRAY(curr_peer->peerMac), |
Gopichand Nakkala | 34d1b06 | 2013-03-19 15:28:33 -0700 | [diff] [blame] | 374 | curr_peer->link_status, curr_peer->tdls_support); |
Hoonki Lee | 387663d | 2013-02-05 18:08:43 -0800 | [diff] [blame] | 375 | |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 376 | if (eTDLS_CAP_SUPPORTED == curr_peer->tdls_support) { |
Masti, Narayanraddi | 34e0e56 | 2015-03-05 18:23:03 +0530 | [diff] [blame] | 377 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Hoonki Lee | 66b75f3 | 2013-04-16 18:30:07 -0700 | [diff] [blame] | 378 | "tx %d, rx %d (thr.pkt %d/idle %d), rssi %d (thr.trig %d/hys %d/tear %d)", |
| 379 | curr_peer->tx_pkt, curr_peer->rx_pkt, |
Hoonki Lee | 5a4b217 | 2013-01-29 01:45:53 -0800 | [diff] [blame] | 380 | pHddTdlsCtx->threshold_config.tx_packet_n, |
Hoonki Lee | 66b75f3 | 2013-04-16 18:30:07 -0700 | [diff] [blame] | 381 | pHddTdlsCtx->threshold_config.idle_packet_n, |
| 382 | curr_peer->rssi, |
| 383 | pHddTdlsCtx->threshold_config.rssi_trigger_threshold, |
| 384 | pHddTdlsCtx->threshold_config.rssi_hysteresis, |
| 385 | pHddTdlsCtx->threshold_config.rssi_teardown_threshold); |
Chilam Ng | 0112041 | 2013-02-19 18:32:21 -0800 | [diff] [blame] | 386 | |
Gopichand Nakkala | 901e892 | 2013-03-04 23:45:58 -0800 | [diff] [blame] | 387 | if ((eTDLS_LINK_IDLE == curr_peer->link_status) || |
| 388 | (eTDLS_LINK_DISCOVERING == curr_peer->link_status)){ |
Sunil Dutt | 961ecbd | 2013-11-28 20:04:07 +0530 | [diff] [blame] | 389 | |
| 390 | if (pHddCtx->cfg_ini->fTDLSExternalControl && |
| 391 | (FALSE == curr_peer->isForcedPeer)) { |
| 392 | continue; |
| 393 | } |
| 394 | |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 395 | if (curr_peer->tx_pkt >= |
| 396 | pHddTdlsCtx->threshold_config.tx_packet_n) { |
Hoonki Lee | 5a4b217 | 2013-01-29 01:45:53 -0800 | [diff] [blame] | 397 | |
Gopichand Nakkala | 8b00c63 | 2013-03-08 19:47:52 -0800 | [diff] [blame] | 398 | if (HDD_MAX_NUM_TDLS_STA > wlan_hdd_tdlsConnectedPeers(pHddTdlsCtx->pAdapter)) |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 399 | { |
| 400 | |
Masti, Narayanraddi | 34e0e56 | 2015-03-05 18:23:03 +0530 | [diff] [blame] | 401 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 402 | "Tput trigger TDLS pre-setup"); |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 403 | #ifdef CONFIG_TDLS_IMPLICIT |
Pradeep Reddy POTTETI | 9db32f0 | 2015-01-29 15:22:54 +0530 | [diff] [blame] | 404 | pHddTdlsCtx->curr_candidate = curr_peer; |
| 405 | wlan_hdd_tdls_implicit_send_discovery_request(pHddTdlsCtx); |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 406 | #endif |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 407 | } |
| 408 | else |
| 409 | { |
Masti, Narayanraddi | 34e0e56 | 2015-03-05 18:23:03 +0530 | [diff] [blame] | 410 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Gopichand Nakkala | 8b00c63 | 2013-03-08 19:47:52 -0800 | [diff] [blame] | 411 | "%s: Maximum peer connected already! %d", |
| 412 | __func__, wlan_hdd_tdlsConnectedPeers(pHddTdlsCtx->pAdapter) ); |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 413 | } |
Hoonki Lee | cdd8e96 | 2013-01-20 00:45:46 -0800 | [diff] [blame] | 414 | goto next_peer; |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 415 | } |
Hoonki Lee | fb8df67 | 2013-04-10 18:20:34 -0700 | [diff] [blame] | 416 | } |
| 417 | else if (eTDLS_LINK_CONNECTED == curr_peer->link_status) { |
Chilam Ng | 0112041 | 2013-02-19 18:32:21 -0800 | [diff] [blame] | 418 | if ((tANI_S32)curr_peer->rssi < |
| 419 | (tANI_S32)pHddTdlsCtx->threshold_config.rssi_teardown_threshold) { |
Hoonki Lee | 5a4b217 | 2013-01-29 01:45:53 -0800 | [diff] [blame] | 420 | |
Chilam Ng | 0112041 | 2013-02-19 18:32:21 -0800 | [diff] [blame] | 421 | VOS_TRACE( VOS_MODULE_ID_HDD, |
| 422 | VOS_TRACE_LEVEL_WARN, |
| 423 | "Tear down - low RSSI: " MAC_ADDRESS_STR "!", |
| 424 | MAC_ADDR_ARRAY(curr_peer->peerMac)); |
| 425 | #ifdef CONFIG_TDLS_IMPLICIT |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 426 | wlan_hdd_tdls_indicate_teardown(pHddTdlsCtx->pAdapter, |
| 427 | curr_peer, |
| 428 | eSIR_MAC_TDLS_TEARDOWN_UNSPEC_REASON); |
Chilam Ng | 0112041 | 2013-02-19 18:32:21 -0800 | [diff] [blame] | 429 | #endif |
Hoonki Lee | cdd8e96 | 2013-01-20 00:45:46 -0800 | [diff] [blame] | 430 | goto next_peer; |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 431 | } |
Chilam Ng | 0112041 | 2013-02-19 18:32:21 -0800 | [diff] [blame] | 432 | |
Naresh Jayaram | db4514b | 2013-11-25 18:08:10 +0530 | [diff] [blame] | 433 | /* Only teardown based on non zero idle packet threshold, to address a use |
| 434 | * case where this threshold does not get consider for TEAR DOWN. |
| 435 | */ |
| 436 | |
| 437 | if (( 0 != pHddTdlsCtx->threshold_config.idle_packet_n ) && |
| 438 | ((curr_peer->tx_pkt < |
Chilam Ng | 0112041 | 2013-02-19 18:32:21 -0800 | [diff] [blame] | 439 | pHddTdlsCtx->threshold_config.idle_packet_n) && |
| 440 | (curr_peer->rx_pkt < |
Naresh Jayaram | db4514b | 2013-11-25 18:08:10 +0530 | [diff] [blame] | 441 | pHddTdlsCtx->threshold_config.idle_packet_n))) { |
Chilam Ng | 0112041 | 2013-02-19 18:32:21 -0800 | [diff] [blame] | 442 | if (VOS_TIMER_STATE_RUNNING != |
| 443 | vos_timer_getCurrentState(&curr_peer->peerIdleTimer)) { |
| 444 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, |
| 445 | "Tx/Rx Idle timer start: " MAC_ADDRESS_STR "!", |
| 446 | MAC_ADDR_ARRAY(curr_peer->peerMac)); |
Gopichand Nakkala | 3046fc9 | 2013-03-23 13:56:43 -0700 | [diff] [blame] | 447 | wlan_hdd_tdls_timer_restart(pHddTdlsCtx->pAdapter, |
| 448 | &curr_peer->peerIdleTimer, |
| 449 | pHddTdlsCtx->threshold_config.idle_timeout_t); |
Chilam Ng | 0112041 | 2013-02-19 18:32:21 -0800 | [diff] [blame] | 450 | } |
| 451 | } else { |
Hoonki Lee | 5a4b217 | 2013-01-29 01:45:53 -0800 | [diff] [blame] | 452 | if (VOS_TIMER_STATE_RUNNING == |
| 453 | vos_timer_getCurrentState(&curr_peer->peerIdleTimer)) { |
Chilam Ng | 0112041 | 2013-02-19 18:32:21 -0800 | [diff] [blame] | 454 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, |
| 455 | "Tx/Rx Idle timer stop: " MAC_ADDRESS_STR "!", |
| 456 | MAC_ADDR_ARRAY(curr_peer->peerMac)); |
| 457 | vos_timer_stop( &curr_peer->peerIdleTimer); |
Hoonki Lee | 5a4b217 | 2013-01-29 01:45:53 -0800 | [diff] [blame] | 458 | } |
Hoonki Lee | 5a4b217 | 2013-01-29 01:45:53 -0800 | [diff] [blame] | 459 | } |
Chilam Ng | 0112041 | 2013-02-19 18:32:21 -0800 | [diff] [blame] | 460 | |
Hoonki Lee | cdd8e96 | 2013-01-20 00:45:46 -0800 | [diff] [blame] | 461 | // if (curr_peer->rssi < |
| 462 | // (pHddTdlsCtx->threshold_config.rssi_hysteresis + |
| 463 | // pHddTdlsCtx->ap_rssi)) { |
| 464 | // |
| 465 | //#ifdef CONFIG_TDLS_IMPLICIT |
| 466 | // cfg80211_tdls_oper_request(pHddTdlsCtx->dev, |
| 467 | // curr_peer->peerMac, |
| 468 | // NL80211_TDLS_TEARDOWN, FALSE, |
| 469 | // GFP_KERNEL); |
| 470 | //#endif |
| 471 | // } |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 472 | } |
Chilam Ng | 0112041 | 2013-02-19 18:32:21 -0800 | [diff] [blame] | 473 | } else if (eTDLS_CAP_UNKNOWN == curr_peer->tdls_support) { |
Sunil Dutt | 961ecbd | 2013-11-28 20:04:07 +0530 | [diff] [blame] | 474 | |
| 475 | if (pHddCtx->cfg_ini->fTDLSExternalControl && |
| 476 | (FALSE == curr_peer->isForcedPeer)) { |
| 477 | continue; |
| 478 | } |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 479 | if (!TDLS_IS_CONNECTED(curr_peer)) { |
Chilam Ng | 0112041 | 2013-02-19 18:32:21 -0800 | [diff] [blame] | 480 | if (curr_peer->tx_pkt >= |
| 481 | pHddTdlsCtx->threshold_config.tx_packet_n) { |
Chilam Ng | 0112041 | 2013-02-19 18:32:21 -0800 | [diff] [blame] | 482 | |
Sunil Dutt | b0d3924 | 2014-09-10 23:54:51 +0530 | [diff] [blame] | 483 | /* Ignore discovery attempt if External Control is enabled, that |
| 484 | * is, peer is forced. In that case, continue discovery attempt |
| 485 | * regardless attempt count |
| 486 | */ |
| 487 | if (curr_peer->isForcedPeer || curr_peer->discovery_attempt++ < |
Chilam Ng | 0112041 | 2013-02-19 18:32:21 -0800 | [diff] [blame] | 488 | pHddTdlsCtx->threshold_config.discovery_tries_n) { |
Masti, Narayanraddi | 34e0e56 | 2015-03-05 18:23:03 +0530 | [diff] [blame] | 489 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 490 | "TDLS UNKNOWN discover "); |
Hoonki Lee | d37cbb3 | 2013-04-20 00:31:14 -0700 | [diff] [blame] | 491 | #ifdef CONFIG_TDLS_IMPLICIT |
Pradeep Reddy POTTETI | 9db32f0 | 2015-01-29 15:22:54 +0530 | [diff] [blame] | 492 | pHddTdlsCtx->curr_candidate = curr_peer; |
| 493 | wlan_hdd_tdls_implicit_send_discovery_request(pHddTdlsCtx); |
Hoonki Lee | d37cbb3 | 2013-04-20 00:31:14 -0700 | [diff] [blame] | 494 | #endif |
Chilam Ng | 0112041 | 2013-02-19 18:32:21 -0800 | [diff] [blame] | 495 | } |
Gopichand Nakkala | 901e892 | 2013-03-04 23:45:58 -0800 | [diff] [blame] | 496 | else |
Gopichand Nakkala | 8b00c63 | 2013-03-08 19:47:52 -0800 | [diff] [blame] | 497 | { |
Gopichand Nakkala | 901e892 | 2013-03-04 23:45:58 -0800 | [diff] [blame] | 498 | curr_peer->tdls_support = eTDLS_CAP_NOT_SUPPORTED; |
Atul Mittal | 115287b | 2014-07-08 13:26:33 +0530 | [diff] [blame] | 499 | wlan_hdd_tdls_set_peer_link_status( |
| 500 | curr_peer, |
| 501 | eTDLS_LINK_IDLE, |
| 502 | eTDLS_LINK_NOT_SUPPORTED); |
| 503 | |
Gopichand Nakkala | 8b00c63 | 2013-03-08 19:47:52 -0800 | [diff] [blame] | 504 | } |
Chilam Ng | 0112041 | 2013-02-19 18:32:21 -0800 | [diff] [blame] | 505 | } |
| 506 | } |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 507 | } |
| 508 | |
Hoonki Lee | cdd8e96 | 2013-01-20 00:45:46 -0800 | [diff] [blame] | 509 | next_peer: |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 510 | curr_peer->tx_pkt = 0; |
Chilam Ng | 1279e23 | 2013-01-25 15:06:52 -0800 | [diff] [blame] | 511 | curr_peer->rx_pkt = 0; |
Hoonki Lee | 387663d | 2013-02-05 18:08:43 -0800 | [diff] [blame] | 512 | } |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 513 | } |
| 514 | |
Gopichand Nakkala | 3046fc9 | 2013-03-23 13:56:43 -0700 | [diff] [blame] | 515 | wlan_hdd_tdls_timer_restart(pHddTdlsCtx->pAdapter, |
| 516 | &pHddTdlsCtx->peerUpdateTimer, |
| 517 | pHddTdlsCtx->threshold_config.tx_period_t); |
Madan Mohan Koyyalamudi | 263cec1 | 2013-10-07 10:57:50 +0530 | [diff] [blame] | 518 | mutex_unlock(&pHddCtx->tdls_lock); |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 519 | EXIT(); |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 520 | } |
| 521 | |
Chilam Ng | 1279e23 | 2013-01-25 15:06:52 -0800 | [diff] [blame] | 522 | static v_VOID_t wlan_hdd_tdls_idle_cb( v_PVOID_t userData ) |
| 523 | { |
Lee Hoonki | c1262f2 | 2013-01-24 21:59:00 -0800 | [diff] [blame] | 524 | #ifdef CONFIG_TDLS_IMPLICIT |
Mahesh A Saptasagar | 170b508 | 2015-02-16 18:50:54 +0530 | [diff] [blame] | 525 | hddTdlsPeer_t *curr_peer; |
Madan Mohan Koyyalamudi | 263cec1 | 2013-10-07 10:57:50 +0530 | [diff] [blame] | 526 | tdlsCtx_t *pHddTdlsCtx; |
| 527 | hdd_context_t *pHddCtx; |
Mahesh A Saptasagar | 170b508 | 2015-02-16 18:50:54 +0530 | [diff] [blame] | 528 | v_CONTEXT_t pVosContext; |
Chilam Ng | 1279e23 | 2013-01-25 15:06:52 -0800 | [diff] [blame] | 529 | |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 530 | ENTER(); |
| 531 | |
Mahesh A Saptasagar | 170b508 | 2015-02-16 18:50:54 +0530 | [diff] [blame] | 532 | pVosContext = vos_get_global_context(VOS_MODULE_ID_HDD, NULL); |
| 533 | if (NULL == pVosContext) |
| 534 | { |
| 535 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 536 | FL("pVosContext points to NULL")); |
| 537 | return; |
| 538 | } |
| 539 | pHddCtx = vos_get_context(VOS_MODULE_ID_HDD, pVosContext); |
| 540 | if (0 != (wlan_hdd_validate_context(pHddCtx))) |
| 541 | { |
Mahesh A Saptasagar | 170b508 | 2015-02-16 18:50:54 +0530 | [diff] [blame] | 542 | return; |
| 543 | } |
| 544 | |
| 545 | mutex_lock(&pHddCtx->tdls_lock); |
| 546 | |
| 547 | curr_peer = (hddTdlsPeer_t *)userData; |
Rajesh Chauhan | 1ace600 | 2013-04-18 18:08:21 -0700 | [diff] [blame] | 548 | if (NULL == curr_peer) |
| 549 | { |
Mahesh A Saptasagar | 170b508 | 2015-02-16 18:50:54 +0530 | [diff] [blame] | 550 | mutex_unlock(&pHddCtx->tdls_lock); |
Rajesh Chauhan | 1ace600 | 2013-04-18 18:08:21 -0700 | [diff] [blame] | 551 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 552 | FL("Invalid tdls idle timer expired")); |
Rajesh Chauhan | 1ace600 | 2013-04-18 18:08:21 -0700 | [diff] [blame] | 553 | return; |
| 554 | } |
Mahesh A Saptasagar | 170b508 | 2015-02-16 18:50:54 +0530 | [diff] [blame] | 555 | |
Madan Mohan Koyyalamudi | 263cec1 | 2013-10-07 10:57:50 +0530 | [diff] [blame] | 556 | pHddTdlsCtx = curr_peer->pHddTdlsCtx; |
Mahesh A Saptasagar | 170b508 | 2015-02-16 18:50:54 +0530 | [diff] [blame] | 557 | if (0 != (wlan_hdd_validate_tdls_context(pHddCtx, pHddTdlsCtx))) |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 558 | { |
Mahesh A Saptasagar | 170b508 | 2015-02-16 18:50:54 +0530 | [diff] [blame] | 559 | mutex_unlock(&pHddCtx->tdls_lock); |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 560 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Mahesh A Saptasagar | 170b508 | 2015-02-16 18:50:54 +0530 | [diff] [blame] | 561 | FL("Invalid pHddTdlsCtx context")); |
Madan Mohan Koyyalamudi | 263cec1 | 2013-10-07 10:57:50 +0530 | [diff] [blame] | 562 | return; |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 563 | } |
Rajesh Chauhan | 1ace600 | 2013-04-18 18:08:21 -0700 | [diff] [blame] | 564 | |
Masti, Narayanraddi | 34e0e56 | 2015-03-05 18:23:03 +0530 | [diff] [blame] | 565 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 566 | "%s: Tx/Rx Idle " MAC_ADDRESS_STR " tx_pkt: %d, rx_pkt: %d, idle_packet_n: %d", |
Rajesh Chauhan | 1ace600 | 2013-04-18 18:08:21 -0700 | [diff] [blame] | 567 | __func__, MAC_ADDR_ARRAY(curr_peer->peerMac), |
| 568 | curr_peer->tx_pkt, |
| 569 | curr_peer->rx_pkt, |
| 570 | curr_peer->pHddTdlsCtx->threshold_config.idle_packet_n); |
| 571 | |
Rajesh Chauhan | 1ace600 | 2013-04-18 18:08:21 -0700 | [diff] [blame] | 572 | /* Check tx/rx statistics on this tdls link for recent activities and |
| 573 | * then decide whether to tear down the link or keep it. |
| 574 | */ |
| 575 | if ((curr_peer->tx_pkt >= curr_peer->pHddTdlsCtx->threshold_config.idle_packet_n) || (curr_peer->rx_pkt >= curr_peer->pHddTdlsCtx->threshold_config.idle_packet_n)) |
| 576 | { |
| 577 | /* this tdls link got back to normal, so keep it */ |
Masti, Narayanraddi | 34e0e56 | 2015-03-05 18:23:03 +0530 | [diff] [blame] | 578 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Rajesh Chauhan | 1ace600 | 2013-04-18 18:08:21 -0700 | [diff] [blame] | 579 | "%s: tdls link to " MAC_ADDRESS_STR " back to normal, will stay", |
| 580 | __func__, MAC_ADDR_ARRAY(curr_peer->peerMac)); |
| 581 | } |
| 582 | else |
| 583 | { |
| 584 | /* this tdls link needs to get torn down */ |
Masti, Narayanraddi | 34e0e56 | 2015-03-05 18:23:03 +0530 | [diff] [blame] | 585 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Rajesh Chauhan | 1ace600 | 2013-04-18 18:08:21 -0700 | [diff] [blame] | 586 | "%s: trigger tdls link to " MAC_ADDRESS_STR " down", |
| 587 | __func__, MAC_ADDR_ARRAY(curr_peer->peerMac)); |
| 588 | |
| 589 | wlan_hdd_tdls_indicate_teardown(curr_peer->pHddTdlsCtx->pAdapter, |
| 590 | curr_peer, |
| 591 | eSIR_MAC_TDLS_TEARDOWN_UNSPEC_REASON); |
| 592 | } |
Madan Mohan Koyyalamudi | 263cec1 | 2013-10-07 10:57:50 +0530 | [diff] [blame] | 593 | mutex_unlock(&pHddCtx->tdls_lock); |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 594 | EXIT(); |
Chilam Ng | 1279e23 | 2013-01-25 15:06:52 -0800 | [diff] [blame] | 595 | #endif |
| 596 | } |
| 597 | |
Gopichand Nakkala | 75e7b28 | 2013-03-15 18:37:13 -0700 | [diff] [blame] | 598 | static v_VOID_t wlan_hdd_tdls_discovery_timeout_peer_cb(v_PVOID_t userData) |
| 599 | { |
Gopichand Nakkala | ccd3a38 | 2013-03-19 13:56:10 -0700 | [diff] [blame] | 600 | int i; |
| 601 | struct list_head *head; |
| 602 | hddTdlsPeer_t *tmp; |
| 603 | struct list_head *pos, *q; |
Gopichand Nakkala | 75e7b28 | 2013-03-15 18:37:13 -0700 | [diff] [blame] | 604 | tdlsCtx_t *pHddTdlsCtx; |
Madan Mohan Koyyalamudi | 263cec1 | 2013-10-07 10:57:50 +0530 | [diff] [blame] | 605 | hdd_context_t *pHddCtx; |
Mahesh A Saptasagar | 170b508 | 2015-02-16 18:50:54 +0530 | [diff] [blame] | 606 | v_CONTEXT_t pVosContext; |
Gopichand Nakkala | 75e7b28 | 2013-03-15 18:37:13 -0700 | [diff] [blame] | 607 | |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 608 | ENTER(); |
Mahesh A Saptasagar | 170b508 | 2015-02-16 18:50:54 +0530 | [diff] [blame] | 609 | pVosContext = vos_get_global_context(VOS_MODULE_ID_HDD, NULL); |
| 610 | if (NULL == pVosContext) |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 611 | { |
| 612 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Mahesh A Saptasagar | 170b508 | 2015-02-16 18:50:54 +0530 | [diff] [blame] | 613 | FL("pVosContext points to NULL")); |
Madan Mohan Koyyalamudi | 263cec1 | 2013-10-07 10:57:50 +0530 | [diff] [blame] | 614 | return; |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 615 | } |
Madan Mohan Koyyalamudi | 263cec1 | 2013-10-07 10:57:50 +0530 | [diff] [blame] | 616 | |
Mahesh A Saptasagar | 170b508 | 2015-02-16 18:50:54 +0530 | [diff] [blame] | 617 | pHddCtx = vos_get_context(VOS_MODULE_ID_HDD, pVosContext); |
| 618 | if (0 != (wlan_hdd_validate_context(pHddCtx))) |
Sushant Kaushik | 15c4c52 | 2014-08-14 12:24:49 +0530 | [diff] [blame] | 619 | { |
Madan Mohan Koyyalamudi | 263cec1 | 2013-10-07 10:57:50 +0530 | [diff] [blame] | 620 | return; |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 621 | } |
Madan Mohan Koyyalamudi | 263cec1 | 2013-10-07 10:57:50 +0530 | [diff] [blame] | 622 | |
Rajesh Chauhan | a34c6e6 | 2014-03-25 16:37:58 +0530 | [diff] [blame] | 623 | mutex_lock(&pHddCtx->tdls_lock); |
Gopichand Nakkala | ccd3a38 | 2013-03-19 13:56:10 -0700 | [diff] [blame] | 624 | |
Mahesh A Saptasagar | 170b508 | 2015-02-16 18:50:54 +0530 | [diff] [blame] | 625 | pHddTdlsCtx = (tdlsCtx_t *)userData; |
| 626 | if (0 != (wlan_hdd_validate_tdls_context(pHddCtx, pHddTdlsCtx))) |
| 627 | { |
| 628 | mutex_unlock(&pHddCtx->tdls_lock); |
| 629 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 630 | FL("Invalid pHddTdlsCtx context")); |
| 631 | return; |
| 632 | } |
| 633 | |
Gopichand Nakkala | ccd3a38 | 2013-03-19 13:56:10 -0700 | [diff] [blame] | 634 | for (i = 0; i < 256; i++) { |
| 635 | head = &pHddTdlsCtx->peer_list[i]; |
| 636 | list_for_each_safe (pos, q, head) { |
| 637 | tmp = list_entry(pos, hddTdlsPeer_t, node); |
| 638 | if (eTDLS_LINK_DISCOVERING == tmp->link_status) |
| 639 | { |
Masti, Narayanraddi | 34e0e56 | 2015-03-05 18:23:03 +0530 | [diff] [blame] | 640 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Gopichand Nakkala | ccd3a38 | 2013-03-19 13:56:10 -0700 | [diff] [blame] | 641 | "%s: " MAC_ADDRESS_STR " to idle state", __func__, |
| 642 | MAC_ADDR_ARRAY(tmp->peerMac)); |
Atul Mittal | 115287b | 2014-07-08 13:26:33 +0530 | [diff] [blame] | 643 | wlan_hdd_tdls_set_peer_link_status( |
| 644 | tmp, |
| 645 | eTDLS_LINK_IDLE, |
Atul Mittal | ad630e4 | 2014-10-07 19:19:14 +0530 | [diff] [blame] | 646 | eTDLS_LINK_NOT_SUPPORTED); |
Gopichand Nakkala | ccd3a38 | 2013-03-19 13:56:10 -0700 | [diff] [blame] | 647 | } |
| 648 | } |
| 649 | } |
Gopichand Nakkala | 75e7b28 | 2013-03-15 18:37:13 -0700 | [diff] [blame] | 650 | |
| 651 | pHddTdlsCtx->discovery_sent_cnt = 0; |
Gopichand Nakkala | 34d1b06 | 2013-03-19 15:28:33 -0700 | [diff] [blame] | 652 | wlan_hdd_tdls_check_power_save_prohibited(pHddTdlsCtx->pAdapter); |
Gopichand Nakkala | ccd3a38 | 2013-03-19 13:56:10 -0700 | [diff] [blame] | 653 | |
Madan Mohan Koyyalamudi | 263cec1 | 2013-10-07 10:57:50 +0530 | [diff] [blame] | 654 | mutex_unlock(&pHddCtx->tdls_lock); |
Gopichand Nakkala | ccd3a38 | 2013-03-19 13:56:10 -0700 | [diff] [blame] | 655 | |
Gopichand Nakkala | 75e7b28 | 2013-03-15 18:37:13 -0700 | [diff] [blame] | 656 | wlan_hdd_tdls_check_bmps(pHddTdlsCtx->pAdapter); |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 657 | EXIT(); |
Gopichand Nakkala | 75e7b28 | 2013-03-15 18:37:13 -0700 | [diff] [blame] | 658 | return; |
| 659 | } |
| 660 | |
Hoonki Lee | 1462135 | 2013-04-16 17:51:19 -0700 | [diff] [blame] | 661 | static v_VOID_t wlan_hdd_tdls_initiator_wait_cb( v_PVOID_t userData ) |
| 662 | { |
| 663 | hddTdlsPeer_t *curr_peer = (hddTdlsPeer_t *)userData; |
| 664 | tdlsCtx_t *pHddTdlsCtx; |
| 665 | |
Mahesh A Saptasagar | 4534e2b | 2015-03-05 20:45:41 +0530 | [diff] [blame] | 666 | ENTER(); |
Hoonki Lee | 1462135 | 2013-04-16 17:51:19 -0700 | [diff] [blame] | 667 | if ( NULL == curr_peer ) |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 668 | { |
| 669 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 670 | FL("curr_peer is NULL")); |
Hoonki Lee | 1462135 | 2013-04-16 17:51:19 -0700 | [diff] [blame] | 671 | return; |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 672 | } |
Hoonki Lee | 1462135 | 2013-04-16 17:51:19 -0700 | [diff] [blame] | 673 | |
| 674 | pHddTdlsCtx = curr_peer->pHddTdlsCtx; |
| 675 | |
| 676 | if ( NULL == pHddTdlsCtx ) |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 677 | { |
| 678 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 679 | FL("pHddTdlsCtx is NULL")); |
Hoonki Lee | 1462135 | 2013-04-16 17:51:19 -0700 | [diff] [blame] | 680 | return; |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 681 | } |
Mahesh A Saptasagar | 4534e2b | 2015-03-05 20:45:41 +0530 | [diff] [blame] | 682 | if (0 != (wlan_hdd_validate_context( |
| 683 | WLAN_HDD_GET_CTX(pHddTdlsCtx->pAdapter)))) |
| 684 | { |
| 685 | return; |
| 686 | } |
Hoonki Lee | 1462135 | 2013-04-16 17:51:19 -0700 | [diff] [blame] | 687 | WLANTL_ResumeDataTx( (WLAN_HDD_GET_CTX(pHddTdlsCtx->pAdapter))->pvosContext, |
| 688 | (v_U8_t *)&curr_peer->staId); |
Mahesh A Saptasagar | 4534e2b | 2015-03-05 20:45:41 +0530 | [diff] [blame] | 689 | EXIT(); |
Hoonki Lee | 1462135 | 2013-04-16 17:51:19 -0700 | [diff] [blame] | 690 | } |
| 691 | |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 692 | static void wlan_hdd_tdls_free_list(tdlsCtx_t *pHddTdlsCtx) |
Gopichand Nakkala | 91b0926 | 2013-02-10 14:27:02 -0800 | [diff] [blame] | 693 | { |
| 694 | int i; |
| 695 | struct list_head *head; |
| 696 | hddTdlsPeer_t *tmp; |
| 697 | struct list_head *pos, *q; |
| 698 | |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 699 | if (NULL == pHddTdlsCtx) |
| 700 | { |
| 701 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 702 | FL("pHddTdlsCtx is NULL")); |
| 703 | return; |
| 704 | } |
Gopichand Nakkala | 91b0926 | 2013-02-10 14:27:02 -0800 | [diff] [blame] | 705 | |
| 706 | for (i = 0; i < 256; i++) { |
| 707 | head = &pHddTdlsCtx->peer_list[i]; |
| 708 | list_for_each_safe (pos, q, head) { |
| 709 | tmp = list_entry(pos, hddTdlsPeer_t, node); |
| 710 | list_del(pos); |
| 711 | vos_mem_free(tmp); |
Srinivas Girigowda | 8d2348f | 2013-12-12 12:14:15 -0800 | [diff] [blame] | 712 | tmp = NULL; |
Gopichand Nakkala | 91b0926 | 2013-02-10 14:27:02 -0800 | [diff] [blame] | 713 | } |
| 714 | } |
Gopichand Nakkala | 91b0926 | 2013-02-10 14:27:02 -0800 | [diff] [blame] | 715 | } |
| 716 | |
Sameer Thalappil | bee426e | 2013-10-30 10:30:30 -0700 | [diff] [blame] | 717 | static void wlan_hdd_tdls_schedule_scan(struct work_struct *work) |
| 718 | { |
| 719 | tdls_scan_context_t *scan_ctx = |
| 720 | container_of(work, tdls_scan_context_t, tdls_scan_work.work); |
| 721 | |
| 722 | if (NULL == scan_ctx) |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 723 | { |
| 724 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 725 | FL("scan_ctx is NULL")); |
Sameer Thalappil | bee426e | 2013-10-30 10:30:30 -0700 | [diff] [blame] | 726 | return; |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 727 | } |
Sameer Thalappil | bee426e | 2013-10-30 10:30:30 -0700 | [diff] [blame] | 728 | |
| 729 | if (unlikely(TDLS_CTX_MAGIC != scan_ctx->magic)) |
| 730 | return; |
| 731 | |
| 732 | scan_ctx->attempt++; |
| 733 | |
| 734 | wlan_hdd_cfg80211_scan(scan_ctx->wiphy, |
| 735 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0)) |
| 736 | scan_ctx->dev, |
| 737 | #endif |
| 738 | scan_ctx->scan_request); |
| 739 | } |
| 740 | |
Pradeep Reddy POTTETI | f0569d7 | 2014-12-13 16:54:03 +0530 | [diff] [blame] | 741 | void wlan_hdd_tdls_btCoex_cb(void *data, int indType) |
| 742 | { |
| 743 | hdd_adapter_t *pAdapter; |
| 744 | hdd_context_t *pHddCtx; |
| 745 | u16 connectedTdlsPeers; |
| 746 | tdlsCtx_t *pHddTdlsCtx; |
| 747 | hddTdlsPeer_t *currPeer; |
| 748 | hdd_scaninfo_t *pScanInfo; |
| 749 | |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 750 | ENTER(); |
Pradeep Reddy POTTETI | f0569d7 | 2014-12-13 16:54:03 +0530 | [diff] [blame] | 751 | if ((NULL == data) || (indType < 0)) |
| 752 | { |
| 753 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 754 | FL("Invalid arguments")); |
| 755 | return; |
| 756 | } |
| 757 | |
| 758 | pHddCtx = (hdd_context_t *)data; |
| 759 | if (0 != (wlan_hdd_validate_context(pHddCtx))) |
| 760 | { |
Pradeep Reddy POTTETI | f0569d7 | 2014-12-13 16:54:03 +0530 | [diff] [blame] | 761 | return; |
| 762 | } |
| 763 | |
| 764 | /* if tdls is not enabled, then continue btCoex */ |
| 765 | if (eTDLS_SUPPORT_NOT_ENABLED == pHddCtx->tdls_mode) |
| 766 | { |
| 767 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 768 | FL("tdls is not enabled")); |
| 769 | return; |
| 770 | } |
| 771 | |
| 772 | /* get pAdapter context, do we need WLAN_HDD_P2P_CLIENT */ |
| 773 | pAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_INFRA_STATION); |
| 774 | if (NULL == pAdapter) |
| 775 | { |
| 776 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 777 | FL("pAdapter is not valid")); |
| 778 | return; |
| 779 | } |
| 780 | |
| 781 | pHddTdlsCtx = WLAN_HDD_GET_TDLS_CTX_PTR(pAdapter); |
| 782 | if (NULL == pHddTdlsCtx) |
| 783 | { |
| 784 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 785 | FL("pHddTdlsCtx is not valid")); |
| 786 | return; |
| 787 | } |
| 788 | |
| 789 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 790 | "%s: BtCoex notification type %d", __func__, indType); |
| 791 | /* BtCoex notification type enabled, Disable TDLS */ |
| 792 | if (indType == SIR_COEX_IND_TYPE_TDLS_DISABLE) |
| 793 | { |
Masti, Narayanraddi | 34e0e56 | 2015-03-05 18:23:03 +0530 | [diff] [blame] | 794 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Pradeep Reddy POTTETI | f0569d7 | 2014-12-13 16:54:03 +0530 | [diff] [blame] | 795 | FL("BtCoex notification, Disable TDLS")); |
| 796 | |
| 797 | pScanInfo = &pHddCtx->scan_info; |
| 798 | // Lets do abort scan if scan is pending |
| 799 | if ((pScanInfo != NULL) && pScanInfo->mScanPending) |
| 800 | { |
| 801 | hdd_abort_mac_scan(pHddCtx, pScanInfo->sessionId, |
| 802 | eCSR_SCAN_ABORT_DEFAULT); |
| 803 | } |
| 804 | |
| 805 | /* tdls is in progress */ |
Pradeep Reddy POTTETI | 9db32f0 | 2015-01-29 15:22:54 +0530 | [diff] [blame] | 806 | currPeer = wlan_hdd_tdls_is_progress(pHddCtx, NULL, 0, TRUE); |
Pradeep Reddy POTTETI | f0569d7 | 2014-12-13 16:54:03 +0530 | [diff] [blame] | 807 | if (NULL != currPeer) |
| 808 | { |
| 809 | wlan_hdd_tdls_set_peer_link_status (currPeer, |
| 810 | eTDLS_LINK_IDLE, |
| 811 | eTDLS_LINK_UNSPECIFIED); |
| 812 | } |
| 813 | |
| 814 | /* while tdls is up */ |
| 815 | if (eTDLS_SUPPORT_ENABLED == pHddCtx->tdls_mode || |
| 816 | eTDLS_SUPPORT_EXPLICIT_TRIGGER_ONLY == pHddCtx->tdls_mode) |
| 817 | { |
| 818 | connectedTdlsPeers = wlan_hdd_tdlsConnectedPeers(pAdapter); |
| 819 | /* disable implicit trigger logic & tdls operatoin */ |
| 820 | wlan_hdd_tdls_set_mode(pHddCtx, eTDLS_SUPPORT_DISABLED, FALSE); |
| 821 | pHddCtx->is_tdls_btc_enabled = FALSE; |
| 822 | |
| 823 | /* teardown the peers on the btcoex */ |
| 824 | if (connectedTdlsPeers) |
| 825 | { |
| 826 | tANI_U8 staIdx; |
| 827 | hddTdlsPeer_t *curr_peer; |
| 828 | |
| 829 | for (staIdx = 0; staIdx < HDD_MAX_NUM_TDLS_STA; staIdx++) |
| 830 | { |
| 831 | if (pHddCtx->tdlsConnInfo[staIdx].staId) |
| 832 | { |
Masti, Narayanraddi | 34e0e56 | 2015-03-05 18:23:03 +0530 | [diff] [blame] | 833 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 834 | ("%s: indicate TDLS teardown (staId %d)"), |
Pradeep Reddy POTTETI | f0569d7 | 2014-12-13 16:54:03 +0530 | [diff] [blame] | 835 | __func__,pHddCtx->tdlsConnInfo[staIdx].staId); |
| 836 | |
| 837 | #ifdef CONFIG_TDLS_IMPLICIT |
| 838 | curr_peer = wlan_hdd_tdls_find_all_peer(pHddCtx, |
| 839 | pHddCtx->tdlsConnInfo[staIdx].peerMac.bytes); |
| 840 | if(curr_peer) { |
| 841 | wlan_hdd_tdls_indicate_teardown( |
| 842 | curr_peer->pHddTdlsCtx->pAdapter, curr_peer, |
| 843 | eSIR_MAC_TDLS_TEARDOWN_UNSPEC_REASON); |
| 844 | } |
| 845 | #endif |
| 846 | } |
| 847 | } |
| 848 | } |
| 849 | } |
| 850 | } |
| 851 | /* BtCoex notification type enabled, Enable TDLS */ |
| 852 | else if (indType == SIR_COEX_IND_TYPE_TDLS_ENABLE) |
| 853 | { |
Masti, Narayanraddi | 34e0e56 | 2015-03-05 18:23:03 +0530 | [diff] [blame] | 854 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Pradeep Reddy POTTETI | f0569d7 | 2014-12-13 16:54:03 +0530 | [diff] [blame] | 855 | FL("BtCoex notification, Enable TDLS")); |
| 856 | /* if tdls was enabled before btCoex, re-enable tdls mode */ |
| 857 | if (eTDLS_SUPPORT_ENABLED == pHddCtx->tdls_mode_last || |
| 858 | eTDLS_SUPPORT_EXPLICIT_TRIGGER_ONLY == pHddCtx->tdls_mode_last) |
| 859 | { |
Masti, Narayanraddi | 34e0e56 | 2015-03-05 18:23:03 +0530 | [diff] [blame] | 860 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Pradeep Reddy POTTETI | f0569d7 | 2014-12-13 16:54:03 +0530 | [diff] [blame] | 861 | ("%s: revert tdls mode %d"), __func__, |
| 862 | pHddCtx->tdls_mode_last); |
| 863 | pHddCtx->is_tdls_btc_enabled = TRUE; |
| 864 | wlan_hdd_tdls_set_mode(pHddCtx, pHddCtx->tdls_mode_last, FALSE); |
| 865 | } |
| 866 | } |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 867 | EXIT(); |
Pradeep Reddy POTTETI | f0569d7 | 2014-12-13 16:54:03 +0530 | [diff] [blame] | 868 | return; |
| 869 | } |
| 870 | |
Agarwal Ashish | 4b87f92 | 2014-06-18 03:03:21 +0530 | [diff] [blame] | 871 | /* initialize TDLS global context */ |
| 872 | void wlan_hdd_tdls_init(hdd_context_t *pHddCtx ) |
| 873 | { |
| 874 | v_U8_t staIdx; |
Chandrasekaran, Manishekar | 0de84dc | 2015-03-10 15:12:34 +0530 | [diff] [blame] | 875 | eHalStatus status; |
Sameer Thalappil | bee426e | 2013-10-30 10:30:30 -0700 | [diff] [blame] | 876 | |
Agarwal Ashish | 4b87f92 | 2014-06-18 03:03:21 +0530 | [diff] [blame] | 877 | pHddCtx->connected_peer_count = 0; |
| 878 | |
| 879 | pHddCtx->tdls_scan_ctxt.magic = 0; |
| 880 | pHddCtx->tdls_scan_ctxt.attempt = 0; |
| 881 | pHddCtx->tdls_scan_ctxt.reject = 0; |
| 882 | pHddCtx->tdls_scan_ctxt.scan_request = NULL; |
| 883 | |
| 884 | for (staIdx = 0; staIdx < HDD_MAX_NUM_TDLS_STA; staIdx++) |
| 885 | { |
| 886 | pHddCtx->tdlsConnInfo[staIdx].staId = 0; |
| 887 | pHddCtx->tdlsConnInfo[staIdx].sessionId = 255; |
| 888 | vos_mem_zero(&pHddCtx->tdlsConnInfo[staIdx].peerMac, |
| 889 | sizeof(v_MACADDR_t)) ; |
| 890 | } |
Pradeep Reddy POTTETI | f0569d7 | 2014-12-13 16:54:03 +0530 | [diff] [blame] | 891 | pHddCtx->is_tdls_btc_enabled = TRUE; |
Chandrasekaran, Manishekar | 0de84dc | 2015-03-10 15:12:34 +0530 | [diff] [blame] | 892 | status = sme_RegisterBtCoexTDLSCallback(pHddCtx->hHal, |
| 893 | wlan_hdd_tdls_btCoex_cb); |
| 894 | if (status != eHAL_STATUS_SUCCESS) { |
| 895 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to register BT Coex TDLS callback")); |
| 896 | } |
Agarwal Ashish | 4b87f92 | 2014-06-18 03:03:21 +0530 | [diff] [blame] | 897 | |
| 898 | if (FALSE == pHddCtx->cfg_ini->fEnableTDLSImplicitTrigger) |
| 899 | { |
| 900 | pHddCtx->tdls_mode = eTDLS_SUPPORT_EXPLICIT_TRIGGER_ONLY; |
| 901 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s TDLS Implicit trigger not enabled!", __func__); |
| 902 | } |
| 903 | else |
| 904 | { |
| 905 | pHddCtx->tdls_mode = eTDLS_SUPPORT_ENABLED; |
| 906 | } |
| 907 | } |
| 908 | |
| 909 | int wlan_hdd_sta_tdls_init(hdd_adapter_t *pAdapter) |
Chilam Ng | 0112041 | 2013-02-19 18:32:21 -0800 | [diff] [blame] | 910 | { |
Chilam Ng | 0112041 | 2013-02-19 18:32:21 -0800 | [diff] [blame] | 911 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter ); |
Hoonki Lee | 2751190 | 2013-03-14 18:19:06 -0700 | [diff] [blame] | 912 | tdlsCtx_t *pHddTdlsCtx; |
Chilam Ng | 0112041 | 2013-02-19 18:32:21 -0800 | [diff] [blame] | 913 | int i; |
Sunil Dutt | 66485cb | 2013-12-19 19:05:03 +0530 | [diff] [blame] | 914 | if (NULL == pHddCtx) |
Mahesh A Saptasagar | 36cdc80 | 2015-01-07 18:41:17 +0530 | [diff] [blame] | 915 | { |
| 916 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s pHddCtx is NULL", __func__); |
Mahesh A Saptasagar | 170b508 | 2015-02-16 18:50:54 +0530 | [diff] [blame] | 917 | return -EINVAL; |
Mahesh A Saptasagar | 36cdc80 | 2015-01-07 18:41:17 +0530 | [diff] [blame] | 918 | } |
Sunil Dutt | 66485cb | 2013-12-19 19:05:03 +0530 | [diff] [blame] | 919 | |
Mahesh A Saptasagar | f5b8eff | 2015-01-31 01:07:07 +0530 | [diff] [blame] | 920 | if (test_bit(TDLS_INIT_DONE, &pAdapter->event_flags)) |
| 921 | { |
| 922 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Mahesh A Saptasagar | 170b508 | 2015-02-16 18:50:54 +0530 | [diff] [blame] | 923 | "%s: TDLS INIT DONE set to 1, no point in re-init", __func__); |
| 924 | return -EALREADY; |
Mahesh A Saptasagar | f5b8eff | 2015-01-31 01:07:07 +0530 | [diff] [blame] | 925 | } |
Sunil Dutt | 66485cb | 2013-12-19 19:05:03 +0530 | [diff] [blame] | 926 | |
Hoonki Lee | 2751190 | 2013-03-14 18:19:06 -0700 | [diff] [blame] | 927 | if ((FALSE == pHddCtx->cfg_ini->fEnableTDLSSupport) || |
| 928 | (FALSE == sme_IsFeatureSupportedByFW(TDLS))) |
| 929 | { |
| 930 | pHddCtx->tdls_mode = eTDLS_SUPPORT_NOT_ENABLED; |
| 931 | pAdapter->sessionCtx.station.pHddTdlsCtx = NULL; |
| 932 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s TDLS not enabled (%d) or FW doesn't support (%d)!", |
| 933 | __func__, pHddCtx->cfg_ini->fEnableTDLSSupport, |
| 934 | sme_IsFeatureSupportedByFW(TDLS)); |
Mahesh A Saptasagar | 170b508 | 2015-02-16 18:50:54 +0530 | [diff] [blame] | 935 | return -EINVAL; |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 936 | } |
Madan Mohan Koyyalamudi | 8174692 | 2013-07-17 14:38:51 +0530 | [diff] [blame] | 937 | /* TDLS is supported only in STA / P2P Client modes, |
| 938 | * hence the check for TDLS support in a specific Device mode. |
Madan Mohan Koyyalamudi | 8174692 | 2013-07-17 14:38:51 +0530 | [diff] [blame] | 939 | */ |
| 940 | if (0 == WLAN_HDD_IS_TDLS_SUPPORTED_ADAPTER(pAdapter)) |
| 941 | { |
Mahesh A Saptasagar | 36cdc80 | 2015-01-07 18:41:17 +0530 | [diff] [blame] | 942 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s TDLS is not supported in mode : %d", __func__, pAdapter->device_mode); |
Mahesh A Saptasagar | 170b508 | 2015-02-16 18:50:54 +0530 | [diff] [blame] | 943 | return -EINVAL; |
Madan Mohan Koyyalamudi | 8174692 | 2013-07-17 14:38:51 +0530 | [diff] [blame] | 944 | } |
| 945 | /* Check for the valid pHddTdlsCtx. If valid do not further |
| 946 | * allocate the memory, rather continue with the initialization. |
| 947 | * If tdls_initialization would get reinvoked without tdls_exit |
| 948 | * getting invoked (SSR) there is no point to further proceed |
| 949 | * with the memory allocations. |
| 950 | */ |
| 951 | if (NULL == pAdapter->sessionCtx.station.pHddTdlsCtx) |
| 952 | { |
| 953 | pHddTdlsCtx = vos_mem_malloc(sizeof(tdlsCtx_t)); |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 954 | |
Madan Mohan Koyyalamudi | 8174692 | 2013-07-17 14:38:51 +0530 | [diff] [blame] | 955 | if (NULL == pHddTdlsCtx) { |
| 956 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s malloc failed!", __func__); |
| 957 | pAdapter->sessionCtx.station.pHddTdlsCtx = NULL; |
Mahesh A Saptasagar | 170b508 | 2015-02-16 18:50:54 +0530 | [diff] [blame] | 958 | return -ENOMEM; |
Madan Mohan Koyyalamudi | 8174692 | 2013-07-17 14:38:51 +0530 | [diff] [blame] | 959 | } |
| 960 | /* initialize TDLS pAdater context */ |
| 961 | vos_mem_zero(pHddTdlsCtx, sizeof(tdlsCtx_t)); |
| 962 | #ifdef TDLS_USE_SEPARATE_DISCOVERY_TIMER |
| 963 | vos_timer_init(&pHddTdlsCtx->peerDiscoverTimer, |
| 964 | VOS_TIMER_TYPE_SW, |
| 965 | wlan_hdd_tdls_discover_peer_cb, |
| 966 | pHddTdlsCtx); |
| 967 | #endif |
Hoonki Lee | 2751190 | 2013-03-14 18:19:06 -0700 | [diff] [blame] | 968 | |
Madan Mohan Koyyalamudi | 8174692 | 2013-07-17 14:38:51 +0530 | [diff] [blame] | 969 | vos_timer_init(&pHddTdlsCtx->peerUpdateTimer, |
| 970 | VOS_TIMER_TYPE_SW, |
| 971 | wlan_hdd_tdls_update_peer_cb, |
| 972 | pHddTdlsCtx); |
| 973 | vos_timer_init(&pHddTdlsCtx->peerDiscoveryTimeoutTimer, |
| 974 | VOS_TIMER_TYPE_SW, |
| 975 | wlan_hdd_tdls_discovery_timeout_peer_cb, |
| 976 | pHddTdlsCtx); |
| 977 | |
| 978 | pAdapter->sessionCtx.station.pHddTdlsCtx = pHddTdlsCtx; |
Hoonki Lee | 2751190 | 2013-03-14 18:19:06 -0700 | [diff] [blame] | 979 | } |
| 980 | |
Madan Mohan Koyyalamudi | 8174692 | 2013-07-17 14:38:51 +0530 | [diff] [blame] | 981 | pHddTdlsCtx = pAdapter->sessionCtx.station.pHddTdlsCtx; |
Hoonki Lee | 2751190 | 2013-03-14 18:19:06 -0700 | [diff] [blame] | 982 | |
Gopichand Nakkala | ccd3a38 | 2013-03-19 13:56:10 -0700 | [diff] [blame] | 983 | sme_SetTdlsPowerSaveProhibited(WLAN_HDD_GET_HAL_CTX(pAdapter), 0); |
Hoonki Lee | 2751190 | 2013-03-14 18:19:06 -0700 | [diff] [blame] | 984 | |
Hoonki Lee | 2751190 | 2013-03-14 18:19:06 -0700 | [diff] [blame] | 985 | pHddTdlsCtx->pAdapter = pAdapter; |
| 986 | |
| 987 | for (i = 0; i < 256; i++) |
| 988 | { |
| 989 | INIT_LIST_HEAD(&pHddTdlsCtx->peer_list[i]); |
| 990 | } |
| 991 | |
Hoonki Lee | d37cbb3 | 2013-04-20 00:31:14 -0700 | [diff] [blame] | 992 | pHddTdlsCtx->curr_candidate = NULL; |
| 993 | pHddTdlsCtx->magic = 0; |
| 994 | |
Hoonki Lee | 2751190 | 2013-03-14 18:19:06 -0700 | [diff] [blame] | 995 | /* remember configuration even if it is not used right now. it could be used later */ |
| 996 | pHddTdlsCtx->threshold_config.tx_period_t = pHddCtx->cfg_ini->fTDLSTxStatsPeriod; |
| 997 | pHddTdlsCtx->threshold_config.tx_packet_n = pHddCtx->cfg_ini->fTDLSTxPacketThreshold; |
| 998 | pHddTdlsCtx->threshold_config.discovery_period_t = pHddCtx->cfg_ini->fTDLSDiscoveryPeriod; |
| 999 | pHddTdlsCtx->threshold_config.discovery_tries_n = pHddCtx->cfg_ini->fTDLSMaxDiscoveryAttempt; |
| 1000 | pHddTdlsCtx->threshold_config.idle_timeout_t = pHddCtx->cfg_ini->fTDLSIdleTimeout; |
| 1001 | pHddTdlsCtx->threshold_config.idle_packet_n = pHddCtx->cfg_ini->fTDLSIdlePacketThreshold; |
| 1002 | pHddTdlsCtx->threshold_config.rssi_hysteresis = pHddCtx->cfg_ini->fTDLSRSSIHysteresis; |
| 1003 | pHddTdlsCtx->threshold_config.rssi_trigger_threshold = pHddCtx->cfg_ini->fTDLSRSSITriggerThreshold; |
| 1004 | pHddTdlsCtx->threshold_config.rssi_teardown_threshold = pHddCtx->cfg_ini->fTDLSRSSITeardownThreshold; |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 1005 | |
Sameer Thalappil | bee426e | 2013-10-30 10:30:30 -0700 | [diff] [blame] | 1006 | INIT_DELAYED_WORK(&pHddCtx->tdls_scan_ctxt.tdls_scan_work, wlan_hdd_tdls_schedule_scan); |
Mahesh A Saptasagar | f5b8eff | 2015-01-31 01:07:07 +0530 | [diff] [blame] | 1007 | set_bit(TDLS_INIT_DONE, &pAdapter->event_flags); |
Hoonki Lee | 2751190 | 2013-03-14 18:19:06 -0700 | [diff] [blame] | 1008 | |
| 1009 | return 0; |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 1010 | } |
| 1011 | |
Pradeep Reddy POTTETI | 2d4d5c4 | 2015-03-03 14:34:19 +0530 | [diff] [blame] | 1012 | void wlan_hdd_tdls_exit(hdd_adapter_t *pAdapter, tANI_BOOLEAN mutexLock) |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 1013 | { |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 1014 | tdlsCtx_t *pHddTdlsCtx; |
Hoonki Lee | 93e67ff | 2013-03-19 15:49:25 -0700 | [diff] [blame] | 1015 | hdd_context_t *pHddCtx; |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 1016 | |
Chandrasekaran, Manishekar | 41b8e1f | 2015-03-10 13:30:28 +0530 | [diff] [blame] | 1017 | if (!pAdapter) { |
| 1018 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD adpater is NULL")); |
| 1019 | return; |
| 1020 | } |
| 1021 | |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 1022 | /* |
| 1023 | * NOTE: The Callers of this function should ensure to acquire the |
Mahesh A Saptasagar | f5b8eff | 2015-01-31 01:07:07 +0530 | [diff] [blame] | 1024 | * tdls_lock to avoid any concurrent access to the Adapter and logp |
| 1025 | * protection has to be ensured. |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 1026 | */ |
| 1027 | |
Madan Mohan Koyyalamudi | 263cec1 | 2013-10-07 10:57:50 +0530 | [diff] [blame] | 1028 | pHddCtx = WLAN_HDD_GET_CTX( pAdapter ); |
Agarwal Ashish | 9ffa5b9 | 2014-11-18 21:07:02 +0530 | [diff] [blame] | 1029 | |
| 1030 | if (NULL == pHddCtx || NULL == pHddCtx->cfg_ini) |
Madan Mohan Koyyalamudi | 263cec1 | 2013-10-07 10:57:50 +0530 | [diff] [blame] | 1031 | { |
Agarwal Ashish | 9ffa5b9 | 2014-11-18 21:07:02 +0530 | [diff] [blame] | 1032 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1033 | "%s: HDD context is Null", __func__); |
| 1034 | return ; |
| 1035 | } |
Mahesh A Saptasagar | f5b8eff | 2015-01-31 01:07:07 +0530 | [diff] [blame] | 1036 | if (!test_bit(TDLS_INIT_DONE, &pAdapter->event_flags)) |
Agarwal Ashish | 9ffa5b9 | 2014-11-18 21:07:02 +0530 | [diff] [blame] | 1037 | { |
Mahesh A Saptasagar | f5b8eff | 2015-01-31 01:07:07 +0530 | [diff] [blame] | 1038 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1039 | "%s: TDLS INIT DONE set to 0, no point in exit", __func__); |
| 1040 | return; |
Madan Mohan Koyyalamudi | 263cec1 | 2013-10-07 10:57:50 +0530 | [diff] [blame] | 1041 | } |
Mahesh A Saptasagar | f5b8eff | 2015-01-31 01:07:07 +0530 | [diff] [blame] | 1042 | clear_bit(TDLS_INIT_DONE, &pAdapter->event_flags); |
Madan Mohan Koyyalamudi | 263cec1 | 2013-10-07 10:57:50 +0530 | [diff] [blame] | 1043 | |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 1044 | pHddTdlsCtx = WLAN_HDD_GET_TDLS_CTX_PTR(pAdapter); |
Gopichand Nakkala | 91b0926 | 2013-02-10 14:27:02 -0800 | [diff] [blame] | 1045 | if (NULL == pHddTdlsCtx) |
| 1046 | { |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 1047 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1048 | FL("pHddTdlsCtx is NULL")); |
Hoonki Lee | bfee034 | 2013-01-21 16:43:45 -0800 | [diff] [blame] | 1049 | return; |
| 1050 | } |
Mahesh A Saptasagar | f5b8eff | 2015-01-31 01:07:07 +0530 | [diff] [blame] | 1051 | |
Anand N Sunkad | 860e5ea | 2015-03-30 14:41:51 +0530 | [diff] [blame] | 1052 | vos_flush_delayed_work(&pHddCtx->tdls_scan_ctxt.tdls_scan_work); |
Hoonki Lee | bfee034 | 2013-01-21 16:43:45 -0800 | [diff] [blame] | 1053 | |
Gopichand Nakkala | 91b0926 | 2013-02-10 14:27:02 -0800 | [diff] [blame] | 1054 | /* must stop timer here before freeing peer list, because peerIdleTimer is |
| 1055 | part of peer list structure. */ |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 1056 | wlan_hdd_tdls_timers_destroy(pHddTdlsCtx); |
| 1057 | wlan_hdd_tdls_free_list(pHddTdlsCtx); |
Chilam Ng | a75d8b6 | 2013-01-29 01:35:59 -0800 | [diff] [blame] | 1058 | |
Hoonki Lee | 93e67ff | 2013-03-19 15:49:25 -0700 | [diff] [blame] | 1059 | wlan_hdd_tdls_free_scan_request(&pHddCtx->tdls_scan_ctxt); |
Sushant Kaushik | 15c4c52 | 2014-08-14 12:24:49 +0530 | [diff] [blame] | 1060 | pHddTdlsCtx->magic = 0; |
| 1061 | pHddTdlsCtx->pAdapter = NULL; |
Chilam Ng | a75d8b6 | 2013-01-29 01:35:59 -0800 | [diff] [blame] | 1062 | vos_mem_free(pHddTdlsCtx); |
Pradeep Reddy POTTETI | 59c90d6 | 2014-03-24 19:45:47 +0530 | [diff] [blame] | 1063 | pAdapter->sessionCtx.station.pHddTdlsCtx = NULL; |
Chilam Ng | a75d8b6 | 2013-01-29 01:35:59 -0800 | [diff] [blame] | 1064 | pHddTdlsCtx = NULL; |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 1065 | } |
| 1066 | |
Madan Mohan Koyyalamudi | 693275b | 2013-07-22 19:14:09 +0530 | [diff] [blame] | 1067 | /* stop all monitoring timers per Adapter */ |
| 1068 | static void wlan_hdd_tdls_monitor_timers_stop(tdlsCtx_t *pHddTdlsCtx) |
Gopichand Nakkala | c369458 | 2013-02-13 20:51:22 -0800 | [diff] [blame] | 1069 | { |
Hoonki Lee | d37cbb3 | 2013-04-20 00:31:14 -0700 | [diff] [blame] | 1070 | #ifdef TDLS_USE_SEPARATE_DISCOVERY_TIMER |
Gopichand Nakkala | c369458 | 2013-02-13 20:51:22 -0800 | [diff] [blame] | 1071 | vos_timer_stop(&pHddTdlsCtx->peerDiscoverTimer); |
Hoonki Lee | d37cbb3 | 2013-04-20 00:31:14 -0700 | [diff] [blame] | 1072 | #endif |
Gopichand Nakkala | c369458 | 2013-02-13 20:51:22 -0800 | [diff] [blame] | 1073 | vos_timer_stop(&pHddTdlsCtx->peerUpdateTimer); |
Gopichand Nakkala | 75e7b28 | 2013-03-15 18:37:13 -0700 | [diff] [blame] | 1074 | vos_timer_stop(&pHddTdlsCtx->peerDiscoveryTimeoutTimer); |
Madan Mohan Koyyalamudi | 693275b | 2013-07-22 19:14:09 +0530 | [diff] [blame] | 1075 | } |
Gopichand Nakkala | c369458 | 2013-02-13 20:51:22 -0800 | [diff] [blame] | 1076 | |
Madan Mohan Koyyalamudi | 693275b | 2013-07-22 19:14:09 +0530 | [diff] [blame] | 1077 | /* stop all per peer timers */ |
| 1078 | static void wlan_hdd_tdls_peer_timers_stop(tdlsCtx_t *pHddTdlsCtx) |
| 1079 | { |
| 1080 | int i; |
| 1081 | struct list_head *head; |
| 1082 | struct list_head *pos; |
| 1083 | hddTdlsPeer_t *curr_peer; |
Gopichand Nakkala | c369458 | 2013-02-13 20:51:22 -0800 | [diff] [blame] | 1084 | for (i = 0; i < 256; i++) |
| 1085 | { |
| 1086 | head = &pHddTdlsCtx->peer_list[i]; |
Gopichand Nakkala | c369458 | 2013-02-13 20:51:22 -0800 | [diff] [blame] | 1087 | list_for_each (pos, head) { |
| 1088 | curr_peer = list_entry (pos, hddTdlsPeer_t, node); |
Masti, Narayanraddi | 34e0e56 | 2015-03-05 18:23:03 +0530 | [diff] [blame] | 1089 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Chilam Ng | 0112041 | 2013-02-19 18:32:21 -0800 | [diff] [blame] | 1090 | "%s: " MAC_ADDRESS_STR " -> stop idle timer", |
Gopichand Nakkala | c369458 | 2013-02-13 20:51:22 -0800 | [diff] [blame] | 1091 | __func__, |
Chilam Ng | 0112041 | 2013-02-19 18:32:21 -0800 | [diff] [blame] | 1092 | MAC_ADDR_ARRAY(curr_peer->peerMac)); |
Gopichand Nakkala | c369458 | 2013-02-13 20:51:22 -0800 | [diff] [blame] | 1093 | vos_timer_stop ( &curr_peer->peerIdleTimer ); |
Hoonki Lee | 1462135 | 2013-04-16 17:51:19 -0700 | [diff] [blame] | 1094 | vos_timer_stop( &curr_peer->initiatorWaitTimeoutTimer ); |
Gopichand Nakkala | c369458 | 2013-02-13 20:51:22 -0800 | [diff] [blame] | 1095 | } |
| 1096 | } |
Gopichand Nakkala | c369458 | 2013-02-13 20:51:22 -0800 | [diff] [blame] | 1097 | } |
| 1098 | |
Madan Mohan Koyyalamudi | 693275b | 2013-07-22 19:14:09 +0530 | [diff] [blame] | 1099 | /* stop all the tdls timers running */ |
| 1100 | static void wlan_hdd_tdls_timers_stop(tdlsCtx_t *pHddTdlsCtx) |
Gopichand Nakkala | 91b0926 | 2013-02-10 14:27:02 -0800 | [diff] [blame] | 1101 | { |
Madan Mohan Koyyalamudi | 693275b | 2013-07-22 19:14:09 +0530 | [diff] [blame] | 1102 | wlan_hdd_tdls_monitor_timers_stop(pHddTdlsCtx); |
| 1103 | wlan_hdd_tdls_peer_timers_stop(pHddTdlsCtx); |
| 1104 | } |
Gopichand Nakkala | 91b0926 | 2013-02-10 14:27:02 -0800 | [diff] [blame] | 1105 | |
Madan Mohan Koyyalamudi | 693275b | 2013-07-22 19:14:09 +0530 | [diff] [blame] | 1106 | static void wlan_hdd_tdls_monitor_timers_destroy(tdlsCtx_t *pHddTdlsCtx) |
| 1107 | { |
Hoonki Lee | d37cbb3 | 2013-04-20 00:31:14 -0700 | [diff] [blame] | 1108 | #ifdef TDLS_USE_SEPARATE_DISCOVERY_TIMER |
Gopichand Nakkala | 91b0926 | 2013-02-10 14:27:02 -0800 | [diff] [blame] | 1109 | vos_timer_stop(&pHddTdlsCtx->peerDiscoverTimer); |
| 1110 | vos_timer_destroy(&pHddTdlsCtx->peerDiscoverTimer); |
Hoonki Lee | d37cbb3 | 2013-04-20 00:31:14 -0700 | [diff] [blame] | 1111 | #endif |
Gopichand Nakkala | 91b0926 | 2013-02-10 14:27:02 -0800 | [diff] [blame] | 1112 | vos_timer_stop(&pHddTdlsCtx->peerUpdateTimer); |
| 1113 | vos_timer_destroy(&pHddTdlsCtx->peerUpdateTimer); |
Gopichand Nakkala | 75e7b28 | 2013-03-15 18:37:13 -0700 | [diff] [blame] | 1114 | vos_timer_stop(&pHddTdlsCtx->peerDiscoveryTimeoutTimer); |
| 1115 | vos_timer_destroy(&pHddTdlsCtx->peerDiscoveryTimeoutTimer); |
Madan Mohan Koyyalamudi | 693275b | 2013-07-22 19:14:09 +0530 | [diff] [blame] | 1116 | } |
| 1117 | /*Free all the timers related to the TDLS peer */ |
| 1118 | static void wlan_hdd_tdls_peer_timers_destroy(tdlsCtx_t *pHddTdlsCtx) |
| 1119 | { |
| 1120 | int i; |
| 1121 | struct list_head *head; |
| 1122 | struct list_head *pos; |
| 1123 | hddTdlsPeer_t *curr_peer; |
Gopichand Nakkala | 91b0926 | 2013-02-10 14:27:02 -0800 | [diff] [blame] | 1124 | for (i = 0; i < 256; i++) |
| 1125 | { |
| 1126 | head = &pHddTdlsCtx->peer_list[i]; |
| 1127 | |
| 1128 | list_for_each (pos, head) { |
| 1129 | curr_peer = list_entry (pos, hddTdlsPeer_t, node); |
| 1130 | |
Masti, Narayanraddi | 34e0e56 | 2015-03-05 18:23:03 +0530 | [diff] [blame] | 1131 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Chilam Ng | 0112041 | 2013-02-19 18:32:21 -0800 | [diff] [blame] | 1132 | "%s: " MAC_ADDRESS_STR " -> destroy idle timer", |
Gopichand Nakkala | 91b0926 | 2013-02-10 14:27:02 -0800 | [diff] [blame] | 1133 | __func__, |
Chilam Ng | 0112041 | 2013-02-19 18:32:21 -0800 | [diff] [blame] | 1134 | MAC_ADDR_ARRAY(curr_peer->peerMac)); |
Gopichand Nakkala | 91b0926 | 2013-02-10 14:27:02 -0800 | [diff] [blame] | 1135 | vos_timer_stop ( &curr_peer->peerIdleTimer ); |
| 1136 | vos_timer_destroy ( &curr_peer->peerIdleTimer ); |
Hoonki Lee | 1462135 | 2013-04-16 17:51:19 -0700 | [diff] [blame] | 1137 | vos_timer_stop(&curr_peer->initiatorWaitTimeoutTimer); |
| 1138 | vos_timer_destroy(&curr_peer->initiatorWaitTimeoutTimer); |
Gopichand Nakkala | 91b0926 | 2013-02-10 14:27:02 -0800 | [diff] [blame] | 1139 | } |
| 1140 | } |
Madan Mohan Koyyalamudi | 693275b | 2013-07-22 19:14:09 +0530 | [diff] [blame] | 1141 | |
| 1142 | } |
| 1143 | |
| 1144 | /* destroy all the tdls timers running */ |
| 1145 | static void wlan_hdd_tdls_timers_destroy(tdlsCtx_t *pHddTdlsCtx) |
| 1146 | { |
| 1147 | wlan_hdd_tdls_monitor_timers_destroy(pHddTdlsCtx); |
| 1148 | wlan_hdd_tdls_peer_timers_destroy(pHddTdlsCtx); |
Gopichand Nakkala | 91b0926 | 2013-02-10 14:27:02 -0800 | [diff] [blame] | 1149 | } |
| 1150 | |
Hoonki Lee | 387663d | 2013-02-05 18:08:43 -0800 | [diff] [blame] | 1151 | /* if mac address exist, return pointer |
| 1152 | if mac address doesn't exist, create a list and add, return pointer |
| 1153 | return NULL if fails to get new mac address |
| 1154 | */ |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 1155 | 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] | 1156 | { |
Hoonki Lee | 387663d | 2013-02-05 18:08:43 -0800 | [diff] [blame] | 1157 | struct list_head *head; |
| 1158 | hddTdlsPeer_t *peer; |
| 1159 | u8 key; |
Gopichand Nakkala | 4ddf019 | 2013-03-27 13:41:20 -0700 | [diff] [blame] | 1160 | tdlsCtx_t *pHddTdlsCtx; |
Chandrasekaran, Manishekar | 41b8e1f | 2015-03-10 13:30:28 +0530 | [diff] [blame] | 1161 | hdd_context_t *pHddCtx; |
Madan Mohan Koyyalamudi | 263cec1 | 2013-10-07 10:57:50 +0530 | [diff] [blame] | 1162 | |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 1163 | ENTER(); |
Chandrasekaran, Manishekar | 41b8e1f | 2015-03-10 13:30:28 +0530 | [diff] [blame] | 1164 | |
| 1165 | if (!pAdapter) { |
| 1166 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD adpater is NULL")); |
| 1167 | return NULL; |
| 1168 | } |
| 1169 | |
| 1170 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 1171 | if (0 != (wlan_hdd_validate_context(pHddCtx))) |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 1172 | { |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 1173 | return 0; |
| 1174 | } |
Hoonki Lee | bfee034 | 2013-01-21 16:43:45 -0800 | [diff] [blame] | 1175 | |
Hoonki Lee | 387663d | 2013-02-05 18:08:43 -0800 | [diff] [blame] | 1176 | /* if already there, just update */ |
Masti, Narayanraddi | 6dbcdbb | 2015-05-13 10:28:06 +0530 | [diff] [blame^] | 1177 | peer = wlan_hdd_tdls_find_peer(pAdapter, mac, FALSE); |
Hoonki Lee | 387663d | 2013-02-05 18:08:43 -0800 | [diff] [blame] | 1178 | if (peer != NULL) |
| 1179 | { |
| 1180 | return peer; |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 1181 | } |
| 1182 | |
Hoonki Lee | 387663d | 2013-02-05 18:08:43 -0800 | [diff] [blame] | 1183 | /* not found, allocate and add the list */ |
| 1184 | peer = vos_mem_malloc(sizeof(hddTdlsPeer_t)); |
| 1185 | if (NULL == peer) { |
| 1186 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s peer malloc failed!", __func__); |
| 1187 | return NULL; |
| 1188 | } |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 1189 | |
Gopichand Nakkala | 4ddf019 | 2013-03-27 13:41:20 -0700 | [diff] [blame] | 1190 | pHddTdlsCtx = WLAN_HDD_GET_TDLS_CTX_PTR(pAdapter); |
| 1191 | |
| 1192 | if (NULL == pHddTdlsCtx) |
| 1193 | { |
| 1194 | vos_mem_free(peer); |
Madan Mohan Koyyalamudi | 263cec1 | 2013-10-07 10:57:50 +0530 | [diff] [blame] | 1195 | mutex_unlock(&pHddCtx->tdls_lock); |
Hema Aparna Medicharla | 8bb6f78 | 2015-03-09 12:35:05 +0530 | [diff] [blame] | 1196 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 1197 | FL("pHddTdlsCtx is NULL")); |
Gopichand Nakkala | 4ddf019 | 2013-03-27 13:41:20 -0700 | [diff] [blame] | 1198 | return NULL; |
| 1199 | } |
| 1200 | |
| 1201 | key = wlan_hdd_tdls_hash_key(mac); |
| 1202 | head = &pHddTdlsCtx->peer_list[key]; |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 1203 | |
Hoonki Lee | 387663d | 2013-02-05 18:08:43 -0800 | [diff] [blame] | 1204 | vos_mem_zero(peer, sizeof(hddTdlsPeer_t)); |
| 1205 | vos_mem_copy(peer->peerMac, mac, sizeof(peer->peerMac)); |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 1206 | peer->pHddTdlsCtx = pHddTdlsCtx; |
Hoonki Lee | 387663d | 2013-02-05 18:08:43 -0800 | [diff] [blame] | 1207 | |
Gopichand Nakkala | 91b0926 | 2013-02-10 14:27:02 -0800 | [diff] [blame] | 1208 | vos_timer_init(&peer->peerIdleTimer, |
| 1209 | VOS_TIMER_TYPE_SW, |
| 1210 | wlan_hdd_tdls_idle_cb, |
| 1211 | peer); |
| 1212 | |
Hoonki Lee | 1462135 | 2013-04-16 17:51:19 -0700 | [diff] [blame] | 1213 | vos_timer_init(&peer->initiatorWaitTimeoutTimer, |
| 1214 | VOS_TIMER_TYPE_SW, |
| 1215 | wlan_hdd_tdls_initiator_wait_cb, |
| 1216 | peer); |
| 1217 | |
Hoonki Lee | 387663d | 2013-02-05 18:08:43 -0800 | [diff] [blame] | 1218 | list_add_tail(&peer->node, head); |
Hoonki Lee | 387663d | 2013-02-05 18:08:43 -0800 | [diff] [blame] | 1219 | |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 1220 | EXIT(); |
Hoonki Lee | 387663d | 2013-02-05 18:08:43 -0800 | [diff] [blame] | 1221 | return peer; |
| 1222 | } |
| 1223 | |
Gopichand Nakkala | 34d1b06 | 2013-03-19 15:28:33 -0700 | [diff] [blame] | 1224 | int wlan_hdd_tdls_set_cap(hdd_adapter_t *pAdapter, |
Hoonki Lee | 2751190 | 2013-03-14 18:19:06 -0700 | [diff] [blame] | 1225 | u8* mac, |
| 1226 | tTDLSCapType cap) |
| 1227 | { |
| 1228 | hddTdlsPeer_t *curr_peer; |
Masti, Narayanraddi | 6dbcdbb | 2015-05-13 10:28:06 +0530 | [diff] [blame^] | 1229 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
Hoonki Lee | 2751190 | 2013-03-14 18:19:06 -0700 | [diff] [blame] | 1230 | |
Masti, Narayanraddi | 6dbcdbb | 2015-05-13 10:28:06 +0530 | [diff] [blame^] | 1231 | if (0 != (wlan_hdd_validate_context(pHddCtx))) |
| 1232 | return -EINVAL; |
| 1233 | |
| 1234 | mutex_lock(&pHddCtx->tdls_lock); |
Gopichand Nakkala | 34d1b06 | 2013-03-19 15:28:33 -0700 | [diff] [blame] | 1235 | curr_peer = wlan_hdd_tdls_get_peer(pAdapter, mac); |
Hoonki Lee | 2751190 | 2013-03-14 18:19:06 -0700 | [diff] [blame] | 1236 | if (curr_peer == NULL) |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 1237 | { |
| 1238 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1239 | "%s: curr_peer is NULL", __func__); |
Masti, Narayanraddi | 6dbcdbb | 2015-05-13 10:28:06 +0530 | [diff] [blame^] | 1240 | mutex_unlock(&pHddCtx->tdls_lock); |
Gopichand Nakkala | 34d1b06 | 2013-03-19 15:28:33 -0700 | [diff] [blame] | 1241 | return -1; |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 1242 | } |
Hoonki Lee | 2751190 | 2013-03-14 18:19:06 -0700 | [diff] [blame] | 1243 | |
| 1244 | curr_peer->tdls_support = cap; |
| 1245 | |
Masti, Narayanraddi | 6dbcdbb | 2015-05-13 10:28:06 +0530 | [diff] [blame^] | 1246 | mutex_unlock(&pHddCtx->tdls_lock); |
Gopichand Nakkala | 34d1b06 | 2013-03-19 15:28:33 -0700 | [diff] [blame] | 1247 | return 0; |
Hoonki Lee | 2751190 | 2013-03-14 18:19:06 -0700 | [diff] [blame] | 1248 | } |
| 1249 | |
Atul Mittal | 115287b | 2014-07-08 13:26:33 +0530 | [diff] [blame] | 1250 | void wlan_hdd_tdls_set_peer_link_status(hddTdlsPeer_t *curr_peer, |
| 1251 | tTDLSLinkStatus status, |
| 1252 | tTDLSLinkReason reason) |
Hoonki Lee | 387663d | 2013-02-05 18:08:43 -0800 | [diff] [blame] | 1253 | { |
Atul Mittal | 115287b | 2014-07-08 13:26:33 +0530 | [diff] [blame] | 1254 | /*EXT TDLS*/ |
| 1255 | tANI_S32 state = 0; |
| 1256 | tANI_S32 res = 0; |
| 1257 | /*EXT TDLS*/ |
Hoonki Lee | 387663d | 2013-02-05 18:08:43 -0800 | [diff] [blame] | 1258 | if (curr_peer == NULL) |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 1259 | { |
| 1260 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1261 | "%s: curr_peer is NULL", __func__); |
Hoonki Lee | 387663d | 2013-02-05 18:08:43 -0800 | [diff] [blame] | 1262 | return; |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 1263 | } |
Hoonki Lee | 387663d | 2013-02-05 18:08:43 -0800 | [diff] [blame] | 1264 | |
Gopichand Nakkala | 8b00c63 | 2013-03-08 19:47:52 -0800 | [diff] [blame] | 1265 | 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] | 1266 | MAC_ADDR_ARRAY(curr_peer->peerMac), status); |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 1267 | |
| 1268 | curr_peer->link_status = status; |
| 1269 | |
Atul Mittal | 115287b | 2014-07-08 13:26:33 +0530 | [diff] [blame] | 1270 | /*EXT TDLS*/ |
| 1271 | if (curr_peer->isForcedPeer && curr_peer->state_change_notification) |
| 1272 | { |
| 1273 | /*save the reason for any further query*/ |
| 1274 | curr_peer->reason = reason; |
| 1275 | wlan_hdd_tdls_get_wifi_hal_state(curr_peer, &state, &res); |
| 1276 | |
| 1277 | (curr_peer->state_change_notification)( |
| 1278 | curr_peer->peerMac, |
| 1279 | state, |
| 1280 | res, |
| 1281 | curr_peer->pHddTdlsCtx->pAdapter); |
| 1282 | |
| 1283 | } |
| 1284 | /*EXT TDLS*/ |
| 1285 | |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 1286 | } |
| 1287 | |
Gopichand Nakkala | 8b00c63 | 2013-03-08 19:47:52 -0800 | [diff] [blame] | 1288 | void wlan_hdd_tdls_set_link_status(hdd_adapter_t *pAdapter, |
| 1289 | u8* mac, |
Atul Mittal | 115287b | 2014-07-08 13:26:33 +0530 | [diff] [blame] | 1290 | tTDLSLinkStatus linkStatus, |
| 1291 | tTDLSLinkReason reason) |
Gopichand Nakkala | 8b00c63 | 2013-03-08 19:47:52 -0800 | [diff] [blame] | 1292 | { |
Atul Mittal | 115287b | 2014-07-08 13:26:33 +0530 | [diff] [blame] | 1293 | |
| 1294 | /*EXT TDLS*/ |
| 1295 | tANI_S32 state = 0; |
| 1296 | tANI_S32 res = 0; |
| 1297 | /*EXT TDLS*/ |
Gopichand Nakkala | 8b00c63 | 2013-03-08 19:47:52 -0800 | [diff] [blame] | 1298 | hddTdlsPeer_t *curr_peer; |
| 1299 | |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 1300 | curr_peer = wlan_hdd_tdls_find_peer(pAdapter, mac, TRUE); |
Gopichand Nakkala | 8b00c63 | 2013-03-08 19:47:52 -0800 | [diff] [blame] | 1301 | if (curr_peer == NULL) |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 1302 | { |
| 1303 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1304 | "%s: curr_peer is NULL", __func__); |
Gopichand Nakkala | 8b00c63 | 2013-03-08 19:47:52 -0800 | [diff] [blame] | 1305 | return; |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 1306 | } |
Gopichand Nakkala | 8b00c63 | 2013-03-08 19:47:52 -0800 | [diff] [blame] | 1307 | |
| 1308 | curr_peer->link_status= linkStatus; |
| 1309 | |
Atul Mittal | 115287b | 2014-07-08 13:26:33 +0530 | [diff] [blame] | 1310 | /*EXT TDLS*/ |
| 1311 | |
| 1312 | if (curr_peer->isForcedPeer && curr_peer->state_change_notification) |
| 1313 | { |
| 1314 | /*save the reason for any further query*/ |
| 1315 | curr_peer->reason = reason; |
| 1316 | wlan_hdd_tdls_get_wifi_hal_state(curr_peer, &state, &res); |
| 1317 | |
| 1318 | (*curr_peer->state_change_notification)(mac, |
| 1319 | state, |
| 1320 | res, |
| 1321 | curr_peer->pHddTdlsCtx->pAdapter); |
| 1322 | |
| 1323 | } |
| 1324 | /*EXT TDLS*/ |
Gopichand Nakkala | 8b00c63 | 2013-03-08 19:47:52 -0800 | [diff] [blame] | 1325 | return; |
| 1326 | } |
| 1327 | |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 1328 | 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] | 1329 | { |
| 1330 | hddTdlsPeer_t *curr_peer; |
Gopichand Nakkala | 75e7b28 | 2013-03-15 18:37:13 -0700 | [diff] [blame] | 1331 | tdlsCtx_t *pHddTdlsCtx = WLAN_HDD_GET_TDLS_CTX_PTR(pAdapter); |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 1332 | hdd_context_t *pHddCtx; |
| 1333 | |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 1334 | ENTER(); |
| 1335 | |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 1336 | if ( NULL == pHddTdlsCtx ) |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 1337 | { |
| 1338 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Mahesh A Saptasagar | 36cdc80 | 2015-01-07 18:41:17 +0530 | [diff] [blame] | 1339 | FL("pHddTdlsCtx is NULL device mode = %d"), pAdapter->device_mode); |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 1340 | return -1; |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 1341 | } |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 1342 | |
| 1343 | pHddCtx = WLAN_HDD_GET_CTX(pHddTdlsCtx->pAdapter); |
| 1344 | |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 1345 | if(0 != (wlan_hdd_validate_context(pHddCtx))) |
| 1346 | { |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 1347 | return 0; |
| 1348 | } |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 1349 | |
Masti, Narayanraddi | 6dbcdbb | 2015-05-13 10:28:06 +0530 | [diff] [blame^] | 1350 | mutex_lock(&pHddCtx->tdls_lock); |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 1351 | curr_peer = wlan_hdd_tdls_get_peer(pAdapter, mac); |
Gopichand Nakkala | 75e7b28 | 2013-03-15 18:37:13 -0700 | [diff] [blame] | 1352 | |
| 1353 | if (NULL == curr_peer) |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 1354 | { |
| 1355 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1356 | FL("curr_peer is NULL")); |
Masti, Narayanraddi | 6dbcdbb | 2015-05-13 10:28:06 +0530 | [diff] [blame^] | 1357 | mutex_unlock(&pHddCtx->tdls_lock); |
Hoonki Lee | 387663d | 2013-02-05 18:08:43 -0800 | [diff] [blame] | 1358 | return -1; |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 1359 | } |
Masti, Narayanraddi | 6dbcdbb | 2015-05-13 10:28:06 +0530 | [diff] [blame^] | 1360 | mutex_unlock(&pHddCtx->tdls_lock); |
Gopichand Nakkala | 75e7b28 | 2013-03-15 18:37:13 -0700 | [diff] [blame] | 1361 | |
| 1362 | if (pHddTdlsCtx->discovery_sent_cnt) |
| 1363 | pHddTdlsCtx->discovery_sent_cnt--; |
| 1364 | |
Rajesh Chauhan | a34c6e6 | 2014-03-25 16:37:58 +0530 | [diff] [blame] | 1365 | mutex_lock(&pHddCtx->tdls_lock); |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 1366 | |
Gopichand Nakkala | 34d1b06 | 2013-03-19 15:28:33 -0700 | [diff] [blame] | 1367 | wlan_hdd_tdls_check_power_save_prohibited(pAdapter); |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 1368 | |
| 1369 | mutex_unlock(&pHddCtx->tdls_lock); |
Gopichand Nakkala | 75e7b28 | 2013-03-15 18:37:13 -0700 | [diff] [blame] | 1370 | if (0 == pHddTdlsCtx->discovery_sent_cnt) |
Gopichand Nakkala | ccd3a38 | 2013-03-19 13:56:10 -0700 | [diff] [blame] | 1371 | { |
Gopichand Nakkala | 75e7b28 | 2013-03-15 18:37:13 -0700 | [diff] [blame] | 1372 | vos_timer_stop(&pHddTdlsCtx->peerDiscoveryTimeoutTimer); |
Gopichand Nakkala | ccd3a38 | 2013-03-19 13:56:10 -0700 | [diff] [blame] | 1373 | } |
Gopichand Nakkala | 75e7b28 | 2013-03-15 18:37:13 -0700 | [diff] [blame] | 1374 | |
Masti, Narayanraddi | 34e0e56 | 2015-03-05 18:23:03 +0530 | [diff] [blame] | 1375 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Jeff Johnson | 0299d0a | 2013-10-30 12:37:43 -0700 | [diff] [blame] | 1376 | "Discovery(%u) Response from " MAC_ADDRESS_STR " link_status %d", |
Gopichand Nakkala | 75e7b28 | 2013-03-15 18:37:13 -0700 | [diff] [blame] | 1377 | pHddTdlsCtx->discovery_sent_cnt, MAC_ADDR_ARRAY(curr_peer->peerMac), |
| 1378 | curr_peer->link_status); |
| 1379 | |
Gopichand Nakkala | 8b00c63 | 2013-03-08 19:47:52 -0800 | [diff] [blame] | 1380 | if (eTDLS_LINK_DISCOVERING == curr_peer->link_status) |
Gopichand Nakkala | 901e892 | 2013-03-04 23:45:58 -0800 | [diff] [blame] | 1381 | { |
Shailender Karmuchi | 13c0d08 | 2013-03-26 14:41:39 -0700 | [diff] [blame] | 1382 | /* Since we are here, it means Throughput threshold is alredy met. Make sure RSSI |
| 1383 | threshold is also met before setting up TDLS link*/ |
| 1384 | if ((tANI_S32) curr_peer->rssi > (tANI_S32) pHddTdlsCtx->threshold_config.rssi_trigger_threshold) |
| 1385 | { |
Atul Mittal | 115287b | 2014-07-08 13:26:33 +0530 | [diff] [blame] | 1386 | wlan_hdd_tdls_set_peer_link_status(curr_peer, |
| 1387 | eTDLS_LINK_DISCOVERED, |
| 1388 | eTDLS_LINK_SUCCESS); |
Masti, Narayanraddi | 34e0e56 | 2015-03-05 18:23:03 +0530 | [diff] [blame] | 1389 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Shailender Karmuchi | 13c0d08 | 2013-03-26 14:41:39 -0700 | [diff] [blame] | 1390 | "Rssi Threshold met: "MAC_ADDRESS_STR" rssi = %d threshold= %d" , |
| 1391 | MAC_ADDR_ARRAY(curr_peer->peerMac), curr_peer->rssi, |
| 1392 | pHddTdlsCtx->threshold_config.rssi_trigger_threshold); |
| 1393 | cfg80211_tdls_oper_request(pAdapter->dev, curr_peer->peerMac, NL80211_TDLS_SETUP, FALSE, GFP_KERNEL); |
| 1394 | } |
| 1395 | else |
| 1396 | { |
Masti, Narayanraddi | 34e0e56 | 2015-03-05 18:23:03 +0530 | [diff] [blame] | 1397 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Shailender Karmuchi | 13c0d08 | 2013-03-26 14:41:39 -0700 | [diff] [blame] | 1398 | "Rssi Threshold not met: "MAC_ADDRESS_STR" rssi = %d threshold = %d ", |
| 1399 | MAC_ADDR_ARRAY(curr_peer->peerMac), curr_peer->rssi, |
| 1400 | pHddTdlsCtx->threshold_config.rssi_trigger_threshold); |
Sunil Dutt | b0d3924 | 2014-09-10 23:54:51 +0530 | [diff] [blame] | 1401 | |
| 1402 | /* if RSSI threshold is not met then allow further discovery |
| 1403 | * attempts by decrementing count for the last attempt |
| 1404 | */ |
| 1405 | if (curr_peer->discovery_attempt) |
| 1406 | curr_peer->discovery_attempt--; |
| 1407 | |
Atul Mittal | 115287b | 2014-07-08 13:26:33 +0530 | [diff] [blame] | 1408 | wlan_hdd_tdls_set_peer_link_status(curr_peer, |
| 1409 | eTDLS_LINK_IDLE, |
| 1410 | eTDLS_LINK_UNSPECIFIED); |
Shailender Karmuchi | 13c0d08 | 2013-03-26 14:41:39 -0700 | [diff] [blame] | 1411 | } |
Gopichand Nakkala | 901e892 | 2013-03-04 23:45:58 -0800 | [diff] [blame] | 1412 | } |
Gopichand Nakkala | ccd3a38 | 2013-03-19 13:56:10 -0700 | [diff] [blame] | 1413 | else |
| 1414 | { |
| 1415 | wlan_hdd_tdls_check_bmps(pAdapter); |
| 1416 | } |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 1417 | |
Gopichand Nakkala | 901e892 | 2013-03-04 23:45:58 -0800 | [diff] [blame] | 1418 | curr_peer->tdls_support = eTDLS_CAP_SUPPORTED; |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 1419 | EXIT(); |
Hoonki Lee | 387663d | 2013-02-05 18:08:43 -0800 | [diff] [blame] | 1420 | return 0; |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 1421 | } |
| 1422 | |
Gopichand Nakkala | 79ff85d | 2013-05-27 17:05:29 +0530 | [diff] [blame] | 1423 | int wlan_hdd_tdls_set_peer_caps(hdd_adapter_t *pAdapter, |
| 1424 | u8 *mac, |
Naresh Jayaram | 3180aa4 | 2014-02-12 21:47:26 +0530 | [diff] [blame] | 1425 | tCsrStaParams *StaParams, |
| 1426 | tANI_BOOLEAN isBufSta, |
| 1427 | tANI_BOOLEAN isOffChannelSupported) |
Gopichand Nakkala | 79ff85d | 2013-05-27 17:05:29 +0530 | [diff] [blame] | 1428 | { |
| 1429 | hddTdlsPeer_t *curr_peer; |
Masti, Narayanraddi | 6dbcdbb | 2015-05-13 10:28:06 +0530 | [diff] [blame^] | 1430 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
Gopichand Nakkala | 79ff85d | 2013-05-27 17:05:29 +0530 | [diff] [blame] | 1431 | |
Masti, Narayanraddi | 6dbcdbb | 2015-05-13 10:28:06 +0530 | [diff] [blame^] | 1432 | if (0 != (wlan_hdd_validate_context(pHddCtx))) |
| 1433 | return -EINVAL; |
| 1434 | |
| 1435 | mutex_lock(&pHddCtx->tdls_lock); |
Gopichand Nakkala | 79ff85d | 2013-05-27 17:05:29 +0530 | [diff] [blame] | 1436 | curr_peer = wlan_hdd_tdls_get_peer(pAdapter, mac); |
| 1437 | if (curr_peer == NULL) |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 1438 | { |
| 1439 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1440 | "%s: curr_peer is NULL", __func__); |
Masti, Narayanraddi | 6dbcdbb | 2015-05-13 10:28:06 +0530 | [diff] [blame^] | 1441 | mutex_unlock(&pHddCtx->tdls_lock); |
Gopichand Nakkala | 79ff85d | 2013-05-27 17:05:29 +0530 | [diff] [blame] | 1442 | return -1; |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 1443 | } |
Gopichand Nakkala | 79ff85d | 2013-05-27 17:05:29 +0530 | [diff] [blame] | 1444 | |
Naresh Jayaram | 3180aa4 | 2014-02-12 21:47:26 +0530 | [diff] [blame] | 1445 | curr_peer->uapsdQueues = StaParams->uapsd_queues; |
| 1446 | curr_peer->maxSp = StaParams->max_sp; |
Gopichand Nakkala | 79ff85d | 2013-05-27 17:05:29 +0530 | [diff] [blame] | 1447 | curr_peer->isBufSta = isBufSta; |
Naresh Jayaram | 3180aa4 | 2014-02-12 21:47:26 +0530 | [diff] [blame] | 1448 | curr_peer->isOffChannelSupported = isOffChannelSupported; |
| 1449 | |
| 1450 | vos_mem_copy(curr_peer->supported_channels, |
| 1451 | StaParams->supported_channels, |
| 1452 | StaParams->supported_channels_len); |
| 1453 | |
| 1454 | curr_peer->supported_channels_len = |
| 1455 | StaParams->supported_channels_len; |
| 1456 | |
| 1457 | vos_mem_copy(curr_peer->supported_oper_classes, |
| 1458 | StaParams->supported_oper_classes, |
| 1459 | StaParams->supported_oper_classes_len); |
| 1460 | |
| 1461 | curr_peer->supported_oper_classes_len = |
| 1462 | StaParams->supported_oper_classes_len; |
Agarwal Ashish | 16020c4 | 2014-12-29 22:01:11 +0530 | [diff] [blame] | 1463 | curr_peer->qos = StaParams->capability & CAPABILITIES_QOS_OFFSET; |
Masti, Narayanraddi | 6dbcdbb | 2015-05-13 10:28:06 +0530 | [diff] [blame^] | 1464 | |
| 1465 | mutex_unlock(&pHddCtx->tdls_lock); |
Gopichand Nakkala | 79ff85d | 2013-05-27 17:05:29 +0530 | [diff] [blame] | 1466 | return 0; |
| 1467 | } |
| 1468 | |
| 1469 | int wlan_hdd_tdls_get_link_establish_params(hdd_adapter_t *pAdapter, u8 *mac, |
| 1470 | tCsrTdlsLinkEstablishParams* tdlsLinkEstablishParams) |
| 1471 | { |
| 1472 | hddTdlsPeer_t *curr_peer; |
Masti, Narayanraddi | 6dbcdbb | 2015-05-13 10:28:06 +0530 | [diff] [blame^] | 1473 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
Gopichand Nakkala | 79ff85d | 2013-05-27 17:05:29 +0530 | [diff] [blame] | 1474 | |
Masti, Narayanraddi | 6dbcdbb | 2015-05-13 10:28:06 +0530 | [diff] [blame^] | 1475 | if (0 != (wlan_hdd_validate_context(pHddCtx))) |
| 1476 | return -EINVAL; |
| 1477 | |
| 1478 | mutex_lock(&pHddCtx->tdls_lock); |
Gopichand Nakkala | 79ff85d | 2013-05-27 17:05:29 +0530 | [diff] [blame] | 1479 | curr_peer = wlan_hdd_tdls_get_peer(pAdapter, mac); |
| 1480 | if (curr_peer == NULL) |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 1481 | { |
| 1482 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1483 | "%s: curr_peer is NULL", __func__); |
Masti, Narayanraddi | 6dbcdbb | 2015-05-13 10:28:06 +0530 | [diff] [blame^] | 1484 | mutex_unlock(&pHddCtx->tdls_lock); |
Gopichand Nakkala | 79ff85d | 2013-05-27 17:05:29 +0530 | [diff] [blame] | 1485 | return -1; |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 1486 | } |
Gopichand Nakkala | 79ff85d | 2013-05-27 17:05:29 +0530 | [diff] [blame] | 1487 | |
| 1488 | tdlsLinkEstablishParams->isResponder = curr_peer->is_responder; |
| 1489 | tdlsLinkEstablishParams->uapsdQueues = curr_peer->uapsdQueues; |
| 1490 | tdlsLinkEstablishParams->maxSp = curr_peer->maxSp; |
| 1491 | tdlsLinkEstablishParams->isBufSta = curr_peer->isBufSta; |
Naresh Jayaram | 3180aa4 | 2014-02-12 21:47:26 +0530 | [diff] [blame] | 1492 | tdlsLinkEstablishParams->isOffChannelSupported = |
| 1493 | curr_peer->isOffChannelSupported; |
| 1494 | |
| 1495 | vos_mem_copy(tdlsLinkEstablishParams->supportedChannels, |
| 1496 | curr_peer->supported_channels, |
| 1497 | curr_peer->supported_channels_len); |
| 1498 | |
| 1499 | tdlsLinkEstablishParams->supportedChannelsLen = |
| 1500 | curr_peer->supported_channels_len; |
| 1501 | |
| 1502 | vos_mem_copy(tdlsLinkEstablishParams->supportedOperClasses, |
| 1503 | curr_peer->supported_oper_classes, |
| 1504 | curr_peer->supported_oper_classes_len); |
| 1505 | |
| 1506 | tdlsLinkEstablishParams->supportedOperClassesLen = |
| 1507 | curr_peer->supported_oper_classes_len; |
Agarwal Ashish | 16020c4 | 2014-12-29 22:01:11 +0530 | [diff] [blame] | 1508 | tdlsLinkEstablishParams->qos = curr_peer->qos; |
| 1509 | |
Masti, Narayanraddi | 6dbcdbb | 2015-05-13 10:28:06 +0530 | [diff] [blame^] | 1510 | mutex_unlock(&pHddCtx->tdls_lock); |
Gopichand Nakkala | 79ff85d | 2013-05-27 17:05:29 +0530 | [diff] [blame] | 1511 | return 0; |
| 1512 | } |
| 1513 | |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 1514 | 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] | 1515 | { |
| 1516 | hddTdlsPeer_t *curr_peer; |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 1517 | |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 1518 | curr_peer = wlan_hdd_tdls_find_peer(pAdapter, mac, TRUE); |
Hoonki Lee | 387663d | 2013-02-05 18:08:43 -0800 | [diff] [blame] | 1519 | if (curr_peer == NULL) |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 1520 | { |
| 1521 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1522 | "%s: curr_peer is NULL", __func__); |
Hoonki Lee | 387663d | 2013-02-05 18:08:43 -0800 | [diff] [blame] | 1523 | return -1; |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 1524 | } |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 1525 | |
| 1526 | curr_peer->rssi = rxRssi; |
| 1527 | |
Hoonki Lee | 387663d | 2013-02-05 18:08:43 -0800 | [diff] [blame] | 1528 | return 0; |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 1529 | } |
| 1530 | |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 1531 | 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] | 1532 | { |
| 1533 | hddTdlsPeer_t *curr_peer; |
Masti, Narayanraddi | 6dbcdbb | 2015-05-13 10:28:06 +0530 | [diff] [blame^] | 1534 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
Hoonki Lee | a34dd89 | 2013-02-05 22:56:02 -0800 | [diff] [blame] | 1535 | |
Masti, Narayanraddi | 6dbcdbb | 2015-05-13 10:28:06 +0530 | [diff] [blame^] | 1536 | if (0 != (wlan_hdd_validate_context(pHddCtx))) |
| 1537 | return -EINVAL; |
| 1538 | |
| 1539 | mutex_lock(&pHddCtx->tdls_lock); |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 1540 | curr_peer = wlan_hdd_tdls_get_peer(pAdapter, mac); |
Gopichand Nakkala | 91b0926 | 2013-02-10 14:27:02 -0800 | [diff] [blame] | 1541 | if (curr_peer == NULL) |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 1542 | { |
| 1543 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1544 | "%s: curr_peer is NULL", __func__); |
Masti, Narayanraddi | 6dbcdbb | 2015-05-13 10:28:06 +0530 | [diff] [blame^] | 1545 | mutex_unlock(&pHddCtx->tdls_lock); |
Hoonki Lee | a34dd89 | 2013-02-05 22:56:02 -0800 | [diff] [blame] | 1546 | return -1; |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 1547 | } |
Hoonki Lee | a34dd89 | 2013-02-05 22:56:02 -0800 | [diff] [blame] | 1548 | |
| 1549 | curr_peer->is_responder = responder; |
| 1550 | |
Masti, Narayanraddi | 6dbcdbb | 2015-05-13 10:28:06 +0530 | [diff] [blame^] | 1551 | mutex_unlock(&pHddCtx->tdls_lock); |
Hoonki Lee | a34dd89 | 2013-02-05 22:56:02 -0800 | [diff] [blame] | 1552 | return 0; |
| 1553 | } |
| 1554 | |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 1555 | int wlan_hdd_tdls_get_responder(hdd_adapter_t *pAdapter, u8 *mac) |
Hoonki Lee | a34dd89 | 2013-02-05 22:56:02 -0800 | [diff] [blame] | 1556 | { |
| 1557 | hddTdlsPeer_t *curr_peer; |
| 1558 | |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 1559 | curr_peer = wlan_hdd_tdls_find_peer(pAdapter, mac, TRUE); |
Gopichand Nakkala | 91b0926 | 2013-02-10 14:27:02 -0800 | [diff] [blame] | 1560 | if (curr_peer == NULL) |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 1561 | { |
| 1562 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1563 | "%s: curr_peer is NULL", __func__); |
Hoonki Lee | a34dd89 | 2013-02-05 22:56:02 -0800 | [diff] [blame] | 1564 | return -1; |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 1565 | } |
Hoonki Lee | a34dd89 | 2013-02-05 22:56:02 -0800 | [diff] [blame] | 1566 | |
| 1567 | return (curr_peer->is_responder); |
| 1568 | } |
| 1569 | |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 1570 | 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] | 1571 | { |
| 1572 | hddTdlsPeer_t *curr_peer; |
Masti, Narayanraddi | 6dbcdbb | 2015-05-13 10:28:06 +0530 | [diff] [blame^] | 1573 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
Hoonki Lee | 11f7dda | 2013-02-14 16:55:44 -0800 | [diff] [blame] | 1574 | |
Masti, Narayanraddi | 6dbcdbb | 2015-05-13 10:28:06 +0530 | [diff] [blame^] | 1575 | if (0 != (wlan_hdd_validate_context(pHddCtx))) |
| 1576 | return -EINVAL; |
| 1577 | |
| 1578 | mutex_lock(&pHddCtx->tdls_lock); |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 1579 | curr_peer = wlan_hdd_tdls_get_peer(pAdapter, mac); |
Hoonki Lee | 11f7dda | 2013-02-14 16:55:44 -0800 | [diff] [blame] | 1580 | if (curr_peer == NULL) |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 1581 | { |
| 1582 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1583 | "%s: curr_peer is NULL", __func__); |
Masti, Narayanraddi | 6dbcdbb | 2015-05-13 10:28:06 +0530 | [diff] [blame^] | 1584 | mutex_unlock(&pHddCtx->tdls_lock); |
Hoonki Lee | 11f7dda | 2013-02-14 16:55:44 -0800 | [diff] [blame] | 1585 | return -1; |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 1586 | } |
Hoonki Lee | 11f7dda | 2013-02-14 16:55:44 -0800 | [diff] [blame] | 1587 | |
| 1588 | curr_peer->signature = uSignature; |
| 1589 | |
Masti, Narayanraddi | 6dbcdbb | 2015-05-13 10:28:06 +0530 | [diff] [blame^] | 1590 | mutex_unlock(&pHddCtx->tdls_lock); |
Hoonki Lee | 11f7dda | 2013-02-14 16:55:44 -0800 | [diff] [blame] | 1591 | return 0; |
| 1592 | } |
| 1593 | |
Hoonki Lee | a34dd89 | 2013-02-05 22:56:02 -0800 | [diff] [blame] | 1594 | |
Hoonki Lee | 387663d | 2013-02-05 18:08:43 -0800 | [diff] [blame] | 1595 | void wlan_hdd_tdls_extract_da(struct sk_buff *skb, u8 *mac) |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 1596 | { |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 1597 | memcpy(mac, skb->data, 6); |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 1598 | } |
| 1599 | |
Hoonki Lee | 387663d | 2013-02-05 18:08:43 -0800 | [diff] [blame] | 1600 | void wlan_hdd_tdls_extract_sa(struct sk_buff *skb, u8 *mac) |
Chilam Ng | 1279e23 | 2013-01-25 15:06:52 -0800 | [diff] [blame] | 1601 | { |
Chilam Ng | 1279e23 | 2013-01-25 15:06:52 -0800 | [diff] [blame] | 1602 | memcpy(mac, skb->data+6, 6); |
Chilam Ng | 1279e23 | 2013-01-25 15:06:52 -0800 | [diff] [blame] | 1603 | } |
| 1604 | |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 1605 | 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] | 1606 | { |
Hoonki Lee | 387663d | 2013-02-05 18:08:43 -0800 | [diff] [blame] | 1607 | hddTdlsPeer_t *curr_peer; |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 1608 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 1609 | |
Masti, Narayanraddi | 6dbcdbb | 2015-05-13 10:28:06 +0530 | [diff] [blame^] | 1610 | if (0 != (wlan_hdd_validate_context(pHddCtx))) |
| 1611 | return -EINVAL; |
| 1612 | |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 1613 | if (eTDLS_SUPPORT_ENABLED != pHddCtx->tdls_mode) |
| 1614 | return -1; |
Hoonki Lee | bfee034 | 2013-01-21 16:43:45 -0800 | [diff] [blame] | 1615 | |
Masti, Narayanraddi | 6dbcdbb | 2015-05-13 10:28:06 +0530 | [diff] [blame^] | 1616 | mutex_lock(&pHddCtx->tdls_lock); |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 1617 | curr_peer = wlan_hdd_tdls_get_peer(pAdapter, mac); |
Hoonki Lee | 387663d | 2013-02-05 18:08:43 -0800 | [diff] [blame] | 1618 | if (curr_peer == NULL) |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 1619 | { |
c_hpothu | e21931b | 2014-09-08 14:02:14 +0530 | [diff] [blame] | 1620 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 1621 | FL("curr_peer is NULL")); |
Masti, Narayanraddi | 6dbcdbb | 2015-05-13 10:28:06 +0530 | [diff] [blame^] | 1622 | mutex_unlock(&pHddCtx->tdls_lock); |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 1623 | return -1; |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 1624 | } |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 1625 | |
Chilam Ng | 1279e23 | 2013-01-25 15:06:52 -0800 | [diff] [blame] | 1626 | if (tx) |
| 1627 | curr_peer->tx_pkt++; |
| 1628 | else |
| 1629 | curr_peer->rx_pkt++; |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 1630 | |
Masti, Narayanraddi | 6dbcdbb | 2015-05-13 10:28:06 +0530 | [diff] [blame^] | 1631 | mutex_unlock(&pHddCtx->tdls_lock); |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 1632 | return 0; |
| 1633 | } |
| 1634 | |
Hoonki Lee | 2751190 | 2013-03-14 18:19:06 -0700 | [diff] [blame] | 1635 | static int wlan_hdd_tdls_check_config(tdls_config_params_t *config) |
| 1636 | { |
| 1637 | if (config->tdls > 2) |
| 1638 | { |
| 1639 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s invalid 1st argument %d. <0...2>", __func__, config->tdls); |
| 1640 | return -1; |
| 1641 | } |
| 1642 | if (config->tx_period_t < CFG_TDLS_TX_STATS_PERIOD_MIN || |
| 1643 | config->tx_period_t > CFG_TDLS_TX_STATS_PERIOD_MAX) |
| 1644 | { |
Jeff Johnson | 0299d0a | 2013-10-30 12:37:43 -0700 | [diff] [blame] | 1645 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s invalid 2nd argument %d. <%d...%ld>", __func__, config->tx_period_t, |
Hoonki Lee | 2751190 | 2013-03-14 18:19:06 -0700 | [diff] [blame] | 1646 | CFG_TDLS_TX_STATS_PERIOD_MIN, CFG_TDLS_TX_STATS_PERIOD_MAX); |
| 1647 | return -1; |
| 1648 | } |
| 1649 | if (config->tx_packet_n < CFG_TDLS_TX_PACKET_THRESHOLD_MIN || |
| 1650 | config->tx_packet_n > CFG_TDLS_TX_PACKET_THRESHOLD_MAX) |
| 1651 | { |
Jeff Johnson | 0299d0a | 2013-10-30 12:37:43 -0700 | [diff] [blame] | 1652 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s invalid 3rd argument %d. <%d...%ld>", __func__, config->tx_packet_n, |
Hoonki Lee | 2751190 | 2013-03-14 18:19:06 -0700 | [diff] [blame] | 1653 | CFG_TDLS_TX_PACKET_THRESHOLD_MIN, CFG_TDLS_TX_PACKET_THRESHOLD_MAX); |
| 1654 | return -1; |
| 1655 | } |
| 1656 | if (config->discovery_period_t < CFG_TDLS_DISCOVERY_PERIOD_MIN || |
| 1657 | config->discovery_period_t > CFG_TDLS_DISCOVERY_PERIOD_MAX) |
| 1658 | { |
Jeff Johnson | 0299d0a | 2013-10-30 12:37:43 -0700 | [diff] [blame] | 1659 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s invalid 4th argument %d. <%d...%ld>", __func__, config->discovery_period_t, |
Hoonki Lee | 2751190 | 2013-03-14 18:19:06 -0700 | [diff] [blame] | 1660 | CFG_TDLS_DISCOVERY_PERIOD_MIN, CFG_TDLS_DISCOVERY_PERIOD_MAX); |
| 1661 | return -1; |
| 1662 | } |
| 1663 | if (config->discovery_tries_n < CFG_TDLS_MAX_DISCOVERY_ATTEMPT_MIN || |
| 1664 | config->discovery_tries_n > CFG_TDLS_MAX_DISCOVERY_ATTEMPT_MAX) |
| 1665 | { |
| 1666 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s invalid 5th argument %d. <%d...%d>", __func__, config->discovery_tries_n, |
| 1667 | CFG_TDLS_MAX_DISCOVERY_ATTEMPT_MIN, CFG_TDLS_MAX_DISCOVERY_ATTEMPT_MAX); |
| 1668 | return -1; |
| 1669 | } |
| 1670 | if (config->idle_timeout_t < CFG_TDLS_IDLE_TIMEOUT_MIN || |
| 1671 | config->idle_timeout_t > CFG_TDLS_IDLE_TIMEOUT_MAX) |
| 1672 | { |
| 1673 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s invalid 6th argument %d. <%d...%d>", __func__, config->idle_timeout_t, |
| 1674 | CFG_TDLS_IDLE_TIMEOUT_MIN, CFG_TDLS_IDLE_TIMEOUT_MAX); |
| 1675 | return -1; |
| 1676 | } |
| 1677 | if (config->idle_packet_n < CFG_TDLS_IDLE_PACKET_THRESHOLD_MIN || |
| 1678 | config->idle_packet_n > CFG_TDLS_IDLE_PACKET_THRESHOLD_MAX) |
| 1679 | { |
| 1680 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s invalid 7th argument %d. <%d...%d>", __func__, config->idle_packet_n, |
| 1681 | CFG_TDLS_IDLE_PACKET_THRESHOLD_MIN, CFG_TDLS_IDLE_PACKET_THRESHOLD_MAX); |
| 1682 | return -1; |
| 1683 | } |
| 1684 | if (config->rssi_hysteresis < CFG_TDLS_RSSI_HYSTERESIS_MIN || |
| 1685 | config->rssi_hysteresis > CFG_TDLS_RSSI_HYSTERESIS_MAX) |
| 1686 | { |
| 1687 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s invalid 8th argument %d. <%d...%d>", __func__, config->rssi_hysteresis, |
| 1688 | CFG_TDLS_RSSI_HYSTERESIS_MIN, CFG_TDLS_RSSI_HYSTERESIS_MAX); |
| 1689 | return -1; |
| 1690 | } |
| 1691 | if (config->rssi_trigger_threshold < CFG_TDLS_RSSI_TRIGGER_THRESHOLD_MIN || |
| 1692 | config->rssi_trigger_threshold > CFG_TDLS_RSSI_TRIGGER_THRESHOLD_MAX) |
| 1693 | { |
| 1694 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s invalid 9th argument %d. <%d...%d>", __func__, config->rssi_trigger_threshold, |
| 1695 | CFG_TDLS_RSSI_TRIGGER_THRESHOLD_MIN, CFG_TDLS_RSSI_TRIGGER_THRESHOLD_MAX); |
| 1696 | return -1; |
| 1697 | } |
| 1698 | if (config->rssi_teardown_threshold < CFG_TDLS_RSSI_TEARDOWN_THRESHOLD_MIN || |
| 1699 | config->rssi_teardown_threshold > CFG_TDLS_RSSI_TEARDOWN_THRESHOLD_MAX) |
| 1700 | { |
| 1701 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s invalid 10th argument %d. <%d...%d>", __func__, config->rssi_teardown_threshold, |
| 1702 | CFG_TDLS_RSSI_TEARDOWN_THRESHOLD_MIN, CFG_TDLS_RSSI_TEARDOWN_THRESHOLD_MAX); |
| 1703 | return -1; |
| 1704 | } |
| 1705 | return 0; |
| 1706 | } |
| 1707 | |
Chilam Ng | 0112041 | 2013-02-19 18:32:21 -0800 | [diff] [blame] | 1708 | 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] | 1709 | { |
Chilam Ng | 0112041 | 2013-02-19 18:32:21 -0800 | [diff] [blame] | 1710 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 1711 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter ); |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 1712 | tdlsCtx_t *pHddTdlsCtx = WLAN_HDD_GET_TDLS_CTX_PTR(pAdapter); |
Hoonki Lee | 2751190 | 2013-03-14 18:19:06 -0700 | [diff] [blame] | 1713 | eTDLSSupportMode req_tdls_mode; |
Hoonki Lee | bfee034 | 2013-01-21 16:43:45 -0800 | [diff] [blame] | 1714 | |
Hoonki Lee | 2751190 | 2013-03-14 18:19:06 -0700 | [diff] [blame] | 1715 | if (NULL == pHddTdlsCtx) |
| 1716 | { |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 1717 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("TDLS not enabled!")); |
Hoonki Lee | 2751190 | 2013-03-14 18:19:06 -0700 | [diff] [blame] | 1718 | return -1; |
Chilam Ng | 0112041 | 2013-02-19 18:32:21 -0800 | [diff] [blame] | 1719 | } |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 1720 | |
Hoonki Lee | 2751190 | 2013-03-14 18:19:06 -0700 | [diff] [blame] | 1721 | if (wlan_hdd_tdls_check_config(config) != 0) |
| 1722 | { |
| 1723 | return -1; |
| 1724 | } |
| 1725 | |
| 1726 | /* config->tdls is mapped to 0->1, 1->2, 2->3 */ |
| 1727 | req_tdls_mode = config->tdls + 1; |
| 1728 | if (pHddCtx->tdls_mode == req_tdls_mode) |
| 1729 | { |
| 1730 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s already in mode %d", __func__, config->tdls); |
| 1731 | return -1; |
| 1732 | } |
| 1733 | |
| 1734 | /* copy the configuration only when given tdls mode is implicit trigger enable */ |
| 1735 | if (eTDLS_SUPPORT_ENABLED == req_tdls_mode) |
| 1736 | { |
Chilam Ng | 0112041 | 2013-02-19 18:32:21 -0800 | [diff] [blame] | 1737 | memcpy(&pHddTdlsCtx->threshold_config, config, sizeof(tdls_config_params_t)); |
| 1738 | } |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 1739 | |
Chilam Ng | 0112041 | 2013-02-19 18:32:21 -0800 | [diff] [blame] | 1740 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1741 | "iw set tdls params: %d %d %d %d %d %d %d %d %d %d", |
| 1742 | config->tdls, |
| 1743 | config->tx_period_t, |
| 1744 | config->tx_packet_n, |
| 1745 | config->discovery_period_t, |
| 1746 | config->discovery_tries_n, |
| 1747 | config->idle_timeout_t, |
| 1748 | config->idle_packet_n, |
| 1749 | config->rssi_hysteresis, |
| 1750 | config->rssi_trigger_threshold, |
| 1751 | config->rssi_teardown_threshold); |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 1752 | |
Gopichand Nakkala | dcbcf4e | 2013-03-23 14:32:39 -0700 | [diff] [blame] | 1753 | wlan_hdd_tdls_set_mode(pHddCtx, req_tdls_mode, TRUE); |
Chilam Ng | 0112041 | 2013-02-19 18:32:21 -0800 | [diff] [blame] | 1754 | |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 1755 | return 0; |
| 1756 | } |
| 1757 | |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 1758 | 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] | 1759 | { |
Hoonki Lee | 387663d | 2013-02-05 18:08:43 -0800 | [diff] [blame] | 1760 | hddTdlsPeer_t *curr_peer; |
Masti, Narayanraddi | 6dbcdbb | 2015-05-13 10:28:06 +0530 | [diff] [blame^] | 1761 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
Kiran V | 1ccee93 | 2012-12-12 14:49:46 -0800 | [diff] [blame] | 1762 | |
Masti, Narayanraddi | 6dbcdbb | 2015-05-13 10:28:06 +0530 | [diff] [blame^] | 1763 | if (0 != (wlan_hdd_validate_context(pHddCtx))) |
| 1764 | return -EINVAL; |
| 1765 | |
| 1766 | mutex_lock(&pHddCtx->tdls_lock); |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 1767 | curr_peer = wlan_hdd_tdls_get_peer(pAdapter, mac); |
Hoonki Lee | 387663d | 2013-02-05 18:08:43 -0800 | [diff] [blame] | 1768 | if (curr_peer == NULL) |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 1769 | { |
| 1770 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1771 | "%s: curr_peer is NULL", __func__); |
Masti, Narayanraddi | 6dbcdbb | 2015-05-13 10:28:06 +0530 | [diff] [blame^] | 1772 | mutex_unlock(&pHddCtx->tdls_lock); |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 1773 | return -1; |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 1774 | } |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 1775 | |
Hoonki Lee | 387663d | 2013-02-05 18:08:43 -0800 | [diff] [blame] | 1776 | curr_peer->staId = staId; |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 1777 | |
Masti, Narayanraddi | 6dbcdbb | 2015-05-13 10:28:06 +0530 | [diff] [blame^] | 1778 | mutex_unlock(&pHddCtx->tdls_lock); |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 1779 | return 0; |
Kiran V | 1ccee93 | 2012-12-12 14:49:46 -0800 | [diff] [blame] | 1780 | } |
| 1781 | |
Naresh Jayaram | 937abdf | 2013-11-26 19:50:25 +0530 | [diff] [blame] | 1782 | int wlan_hdd_tdls_set_force_peer(hdd_adapter_t *pAdapter, u8 *mac, |
| 1783 | tANI_BOOLEAN forcePeer) |
Sunil Dutt | 41de4e2 | 2013-11-14 18:09:02 +0530 | [diff] [blame] | 1784 | { |
Naresh Jayaram | 937abdf | 2013-11-26 19:50:25 +0530 | [diff] [blame] | 1785 | hddTdlsPeer_t *curr_peer; |
Sunil Dutt | 41de4e2 | 2013-11-14 18:09:02 +0530 | [diff] [blame] | 1786 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 1787 | |
| 1788 | if ((NULL == pHddCtx)) return -1; |
| 1789 | |
Rajesh Chauhan | a34c6e6 | 2014-03-25 16:37:58 +0530 | [diff] [blame] | 1790 | mutex_lock(&pHddCtx->tdls_lock); |
| 1791 | |
Naresh Jayaram | 937abdf | 2013-11-26 19:50:25 +0530 | [diff] [blame] | 1792 | curr_peer = wlan_hdd_tdls_find_peer(pAdapter, mac, FALSE); |
| 1793 | if (curr_peer == NULL) |
Sunil Dutt | 41de4e2 | 2013-11-14 18:09:02 +0530 | [diff] [blame] | 1794 | goto error; |
Naresh Jayaram | 937abdf | 2013-11-26 19:50:25 +0530 | [diff] [blame] | 1795 | curr_peer->isForcedPeer = forcePeer; |
Naresh Jayaram | ca7bc3a | 2014-02-04 23:03:04 +0530 | [diff] [blame] | 1796 | |
| 1797 | mutex_unlock(&pHddCtx->tdls_lock); |
| 1798 | return 0; |
Sunil Dutt | 41de4e2 | 2013-11-14 18:09:02 +0530 | [diff] [blame] | 1799 | error: |
| 1800 | mutex_unlock(&pHddCtx->tdls_lock); |
| 1801 | return -1; |
| 1802 | } |
| 1803 | |
Hoonki Lee | 387663d | 2013-02-05 18:08:43 -0800 | [diff] [blame] | 1804 | /* if peerMac is found, then it returns pointer to hddTdlsPeer_t |
| 1805 | otherwise, it returns NULL |
| 1806 | */ |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 1807 | hddTdlsPeer_t *wlan_hdd_tdls_find_peer(hdd_adapter_t *pAdapter, u8 *mac, |
| 1808 | tANI_BOOLEAN mutexLock) |
Kiran V | 1ccee93 | 2012-12-12 14:49:46 -0800 | [diff] [blame] | 1809 | { |
Hoonki Lee | 387663d | 2013-02-05 18:08:43 -0800 | [diff] [blame] | 1810 | u8 key; |
| 1811 | struct list_head *pos; |
| 1812 | struct list_head *head; |
| 1813 | hddTdlsPeer_t *curr_peer; |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 1814 | tdlsCtx_t *pHddTdlsCtx; |
Madan Mohan Koyyalamudi | 263cec1 | 2013-10-07 10:57:50 +0530 | [diff] [blame] | 1815 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
Hoonki Lee | 387663d | 2013-02-05 18:08:43 -0800 | [diff] [blame] | 1816 | |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 1817 | ENTER(); |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 1818 | if(0 != (wlan_hdd_validate_context(pHddCtx))) |
| 1819 | { |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 1820 | return 0; |
| 1821 | } |
Hoonki Lee | 387663d | 2013-02-05 18:08:43 -0800 | [diff] [blame] | 1822 | |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 1823 | if ( mutexLock ) |
Hoonki Lee | 387663d | 2013-02-05 18:08:43 -0800 | [diff] [blame] | 1824 | { |
Rajesh Chauhan | a34c6e6 | 2014-03-25 16:37:58 +0530 | [diff] [blame] | 1825 | mutex_lock(&pHddCtx->tdls_lock); |
Hoonki Lee | 387663d | 2013-02-05 18:08:43 -0800 | [diff] [blame] | 1826 | } |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 1827 | pHddTdlsCtx = WLAN_HDD_GET_TDLS_CTX_PTR(pAdapter); |
Gopichand Nakkala | eb69b60 | 2013-02-27 11:40:31 -0800 | [diff] [blame] | 1828 | if (NULL == pHddTdlsCtx) |
| 1829 | { |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 1830 | if ( mutexLock ) |
| 1831 | mutex_unlock(&pHddCtx->tdls_lock); |
Gopichand Nakkala | eb69b60 | 2013-02-27 11:40:31 -0800 | [diff] [blame] | 1832 | return NULL; |
| 1833 | } |
| 1834 | |
| 1835 | key = wlan_hdd_tdls_hash_key(mac); |
| 1836 | |
| 1837 | head = &pHddTdlsCtx->peer_list[key]; |
Hoonki Lee | 387663d | 2013-02-05 18:08:43 -0800 | [diff] [blame] | 1838 | |
| 1839 | list_for_each(pos, head) { |
| 1840 | curr_peer = list_entry (pos, hddTdlsPeer_t, node); |
| 1841 | if (!memcmp(mac, curr_peer->peerMac, 6)) { |
| 1842 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 1843 | "findTdlsPeer: found staId %d", curr_peer->staId); |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 1844 | if ( mutexLock ) |
| 1845 | mutex_unlock(&pHddCtx->tdls_lock); |
Hoonki Lee | 387663d | 2013-02-05 18:08:43 -0800 | [diff] [blame] | 1846 | return curr_peer; |
| 1847 | } |
| 1848 | } |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 1849 | if ( mutexLock ) |
| 1850 | mutex_unlock(&pHddCtx->tdls_lock); |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 1851 | |
| 1852 | EXIT(); |
Hoonki Lee | 387663d | 2013-02-05 18:08:43 -0800 | [diff] [blame] | 1853 | return NULL; |
| 1854 | } |
| 1855 | |
Hoonki Lee | a6d49be | 2013-04-05 09:43:25 -0700 | [diff] [blame] | 1856 | hddTdlsPeer_t *wlan_hdd_tdls_find_all_peer(hdd_context_t *pHddCtx, u8 *mac) |
| 1857 | { |
| 1858 | hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL; |
| 1859 | hdd_adapter_t *pAdapter = NULL; |
| 1860 | tdlsCtx_t *pHddTdlsCtx = NULL; |
| 1861 | hddTdlsPeer_t *curr_peer= NULL; |
| 1862 | VOS_STATUS status = 0; |
| 1863 | |
Rajesh Chauhan | a34c6e6 | 2014-03-25 16:37:58 +0530 | [diff] [blame] | 1864 | mutex_lock(&pHddCtx->tdls_lock); |
Hoonki Lee | a6d49be | 2013-04-05 09:43:25 -0700 | [diff] [blame] | 1865 | status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode ); |
| 1866 | while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status ) |
| 1867 | { |
| 1868 | pAdapter = pAdapterNode->pAdapter; |
| 1869 | |
| 1870 | pHddTdlsCtx = WLAN_HDD_GET_TDLS_CTX_PTR(pAdapter); |
| 1871 | if (NULL != pHddTdlsCtx) |
| 1872 | { |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 1873 | curr_peer = wlan_hdd_tdls_find_peer(pAdapter, mac, FALSE); |
Hoonki Lee | a6d49be | 2013-04-05 09:43:25 -0700 | [diff] [blame] | 1874 | if (curr_peer) |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 1875 | { |
| 1876 | mutex_unlock(&pHddCtx->tdls_lock); |
Hoonki Lee | a6d49be | 2013-04-05 09:43:25 -0700 | [diff] [blame] | 1877 | return curr_peer; |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 1878 | } |
Hoonki Lee | a6d49be | 2013-04-05 09:43:25 -0700 | [diff] [blame] | 1879 | } |
| 1880 | status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 1881 | pAdapterNode = pNext; |
| 1882 | } |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 1883 | mutex_unlock(&pHddCtx->tdls_lock); |
Hoonki Lee | a6d49be | 2013-04-05 09:43:25 -0700 | [diff] [blame] | 1884 | return curr_peer; |
| 1885 | } |
| 1886 | |
| 1887 | |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 1888 | int wlan_hdd_tdls_reset_peer(hdd_adapter_t *pAdapter, u8 *mac) |
Hoonki Lee | 387663d | 2013-02-05 18:08:43 -0800 | [diff] [blame] | 1889 | { |
Chilam Ng | 0112041 | 2013-02-19 18:32:21 -0800 | [diff] [blame] | 1890 | hdd_context_t *pHddCtx; |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 1891 | hddTdlsPeer_t *curr_peer; |
Kiran V | 1ccee93 | 2012-12-12 14:49:46 -0800 | [diff] [blame] | 1892 | |
Chilam Ng | 0112041 | 2013-02-19 18:32:21 -0800 | [diff] [blame] | 1893 | pHddCtx = WLAN_HDD_GET_CTX( pAdapter ); |
| 1894 | |
Masti, Narayanraddi | 6dbcdbb | 2015-05-13 10:28:06 +0530 | [diff] [blame^] | 1895 | if (0 != (wlan_hdd_validate_context(pHddCtx))) |
| 1896 | return -EINVAL; |
| 1897 | |
| 1898 | mutex_lock(&pHddCtx->tdls_lock); |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 1899 | curr_peer = wlan_hdd_tdls_get_peer(pAdapter, mac); |
Hoonki Lee | 387663d | 2013-02-05 18:08:43 -0800 | [diff] [blame] | 1900 | if (curr_peer == NULL) |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 1901 | { |
| 1902 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1903 | "%s: curr_peer is NULL", __func__); |
Masti, Narayanraddi | 6dbcdbb | 2015-05-13 10:28:06 +0530 | [diff] [blame^] | 1904 | mutex_unlock(&pHddCtx->tdls_lock); |
Hoonki Lee | 387663d | 2013-02-05 18:08:43 -0800 | [diff] [blame] | 1905 | return -1; |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 1906 | } |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 1907 | |
Atul Mittal | 115287b | 2014-07-08 13:26:33 +0530 | [diff] [blame] | 1908 | wlan_hdd_tdls_set_peer_link_status(curr_peer, |
| 1909 | eTDLS_LINK_IDLE, |
| 1910 | eTDLS_LINK_UNSPECIFIED); |
Hoonki Lee | cdd8e96 | 2013-01-20 00:45:46 -0800 | [diff] [blame] | 1911 | curr_peer->staId = 0; |
Hoonki Lee | 387663d | 2013-02-05 18:08:43 -0800 | [diff] [blame] | 1912 | |
Pradeep Reddy POTTETI | edaeb5f | 2014-05-22 23:34:41 +0530 | [diff] [blame] | 1913 | /* Throughput Monitor shall disable the split scan when |
| 1914 | * TDLS scan coexistance is disabled.At this point of time |
| 1915 | * since TDLS scan coexistance is not meeting the criteria |
| 1916 | * to be operational, explicitly make it false to enable |
| 1917 | * throughput monitor takes the control of split scan. |
| 1918 | */ |
| 1919 | if (pHddCtx->isTdlsScanCoexistence == TRUE) |
| 1920 | { |
| 1921 | pHddCtx->isTdlsScanCoexistence = FALSE; |
| 1922 | } |
| 1923 | |
Chilam Ng | 0112041 | 2013-02-19 18:32:21 -0800 | [diff] [blame] | 1924 | if(eTDLS_SUPPORT_ENABLED == pHddCtx->tdls_mode) { |
Chilam Ng | a75d8b6 | 2013-01-29 01:35:59 -0800 | [diff] [blame] | 1925 | vos_timer_stop( &curr_peer->peerIdleTimer ); |
Chilam Ng | a75d8b6 | 2013-01-29 01:35:59 -0800 | [diff] [blame] | 1926 | } |
Masti, Narayanraddi | 6dbcdbb | 2015-05-13 10:28:06 +0530 | [diff] [blame^] | 1927 | |
| 1928 | mutex_unlock(&pHddCtx->tdls_lock); |
Hoonki Lee | 387663d | 2013-02-05 18:08:43 -0800 | [diff] [blame] | 1929 | return 0; |
Hoonki Lee | cdd8e96 | 2013-01-20 00:45:46 -0800 | [diff] [blame] | 1930 | } |
| 1931 | |
Gopichand Nakkala | 638ebc7 | 2013-03-21 18:04:02 -0700 | [diff] [blame] | 1932 | /* Caller has to take the lock before calling this function */ |
Hoonki Lee | 2751190 | 2013-03-14 18:19:06 -0700 | [diff] [blame] | 1933 | static void wlan_tdd_tdls_reset_tx_rx(tdlsCtx_t *pHddTdlsCtx) |
| 1934 | { |
| 1935 | int i; |
| 1936 | struct list_head *head; |
| 1937 | hddTdlsPeer_t *tmp; |
| 1938 | struct list_head *pos, *q; |
| 1939 | |
Hoonki Lee | 2751190 | 2013-03-14 18:19:06 -0700 | [diff] [blame] | 1940 | for (i = 0; i < 256; i++) { |
| 1941 | head = &pHddTdlsCtx->peer_list[i]; |
| 1942 | list_for_each_safe (pos, q, head) { |
| 1943 | tmp = list_entry(pos, hddTdlsPeer_t, node); |
| 1944 | tmp->tx_pkt = 0; |
| 1945 | tmp->rx_pkt = 0; |
| 1946 | } |
| 1947 | } |
Hoonki Lee | 2751190 | 2013-03-14 18:19:06 -0700 | [diff] [blame] | 1948 | |
| 1949 | return ; |
| 1950 | } |
| 1951 | |
Gopichand Nakkala | 638ebc7 | 2013-03-21 18:04:02 -0700 | [diff] [blame] | 1952 | /* Caller has to take the lock before calling this function */ |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 1953 | 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] | 1954 | { |
| 1955 | int i; |
| 1956 | struct list_head *head; |
| 1957 | hddTdlsPeer_t *tmp; |
| 1958 | struct list_head *pos, *q; |
| 1959 | |
Gopichand Nakkala | c369458 | 2013-02-13 20:51:22 -0800 | [diff] [blame] | 1960 | pHddTdlsCtx->discovery_peer_cnt = 0; |
| 1961 | |
| 1962 | for (i = 0; i < 256; i++) { |
| 1963 | head = &pHddTdlsCtx->peer_list[i]; |
| 1964 | list_for_each_safe (pos, q, head) { |
| 1965 | tmp = list_entry(pos, hddTdlsPeer_t, node); |
| 1966 | tmp->discovery_processed = 0; |
| 1967 | } |
| 1968 | } |
Gopichand Nakkala | c369458 | 2013-02-13 20:51:22 -0800 | [diff] [blame] | 1969 | |
| 1970 | return 0; |
| 1971 | } |
| 1972 | |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 1973 | 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] | 1974 | { |
| 1975 | int i; |
| 1976 | struct list_head *head; |
| 1977 | struct list_head *pos, *q; |
| 1978 | int discovery_peer_cnt=0; |
| 1979 | hddTdlsPeer_t *tmp; |
| 1980 | |
Gopichand Nakkala | eb69b60 | 2013-02-27 11:40:31 -0800 | [diff] [blame] | 1981 | /* |
| 1982 | * This function expects the callers to acquire the Mutex. |
| 1983 | */ |
Gopichand Nakkala | c369458 | 2013-02-13 20:51:22 -0800 | [diff] [blame] | 1984 | |
| 1985 | for (i = 0; i < 256; i++) { |
| 1986 | head = &pHddTdlsCtx->peer_list[i]; |
| 1987 | list_for_each_safe (pos, q, head) { |
| 1988 | tmp = list_entry(pos, hddTdlsPeer_t, node); |
Masti, Narayanraddi | 34e0e56 | 2015-03-05 18:23:03 +0530 | [diff] [blame] | 1989 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Chilam Ng | 0112041 | 2013-02-19 18:32:21 -0800 | [diff] [blame] | 1990 | "%s, %d, " MAC_ADDRESS_STR, __func__, i, |
| 1991 | MAC_ADDR_ARRAY(tmp->peerMac)); |
Gopichand Nakkala | c369458 | 2013-02-13 20:51:22 -0800 | [diff] [blame] | 1992 | discovery_peer_cnt++; |
| 1993 | } |
| 1994 | } |
Gopichand Nakkala | c369458 | 2013-02-13 20:51:22 -0800 | [diff] [blame] | 1995 | return discovery_peer_cnt; |
| 1996 | } |
| 1997 | |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 1998 | tANI_U16 wlan_hdd_tdlsConnectedPeers(hdd_adapter_t *pAdapter) |
Lee Hoonki | c1262f2 | 2013-01-24 21:59:00 -0800 | [diff] [blame] | 1999 | { |
Hanumantha Reddy Pothula | da0fe36 | 2015-02-27 18:37:03 +0530 | [diff] [blame] | 2000 | hdd_context_t *pHddCtx = NULL; |
| 2001 | |
| 2002 | if ((NULL == pAdapter) || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic)) |
| 2003 | { |
| 2004 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2005 | FL("invalid pAdapter: %p"), pAdapter); |
| 2006 | return 0; |
| 2007 | } |
| 2008 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 2009 | |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 2010 | ENTER(); |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 2011 | if(0 != (wlan_hdd_validate_context(pHddCtx))) |
| 2012 | { |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 2013 | return 0; |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 2014 | } |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 2015 | EXIT(); |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 2016 | return pHddCtx->connected_peer_count; |
Lee Hoonki | c1262f2 | 2013-01-24 21:59:00 -0800 | [diff] [blame] | 2017 | } |
Chilam Ng | 16a2a1c | 2013-01-29 01:27:29 -0800 | [diff] [blame] | 2018 | |
Pradeep Reddy POTTETI | e309c15 | 2015-02-06 13:21:07 +0530 | [diff] [blame] | 2019 | hddTdlsPeer_t *wlan_hdd_tdls_get_connected_peer(hdd_adapter_t *pAdapter) |
Pradeep Reddy POTTETI | edaeb5f | 2014-05-22 23:34:41 +0530 | [diff] [blame] | 2020 | { |
| 2021 | int i; |
| 2022 | struct list_head *head; |
| 2023 | struct list_head *pos; |
| 2024 | hddTdlsPeer_t *curr_peer = NULL; |
| 2025 | tdlsCtx_t *pHddTdlsCtx; |
| 2026 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 2027 | |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 2028 | ENTER(); |
Pradeep Reddy POTTETI | edaeb5f | 2014-05-22 23:34:41 +0530 | [diff] [blame] | 2029 | if(0 != (wlan_hdd_validate_context(pHddCtx))) |
| 2030 | { |
Pradeep Reddy POTTETI | edaeb5f | 2014-05-22 23:34:41 +0530 | [diff] [blame] | 2031 | return NULL; |
| 2032 | } |
| 2033 | |
| 2034 | mutex_lock(&pHddCtx->tdls_lock); |
| 2035 | pHddTdlsCtx = WLAN_HDD_GET_TDLS_CTX_PTR(pAdapter); |
| 2036 | if (NULL == pHddTdlsCtx) { |
| 2037 | mutex_unlock(&pHddCtx->tdls_lock); |
| 2038 | return NULL; |
| 2039 | } |
| 2040 | for (i = 0; i < 256; i++) { |
| 2041 | head = &pHddTdlsCtx->peer_list[i]; |
| 2042 | |
| 2043 | list_for_each(pos, head) { |
| 2044 | curr_peer= list_entry (pos, hddTdlsPeer_t, node); |
Pradeep Reddy POTTETI | 8a62313 | 2014-06-26 16:07:06 +0530 | [diff] [blame] | 2045 | if (curr_peer && (curr_peer->link_status == eTDLS_LINK_CONNECTED)) |
Pradeep Reddy POTTETI | edaeb5f | 2014-05-22 23:34:41 +0530 | [diff] [blame] | 2046 | { |
| 2047 | mutex_unlock(&pHddCtx->tdls_lock); |
Masti, Narayanraddi | 34e0e56 | 2015-03-05 18:23:03 +0530 | [diff] [blame] | 2048 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Pradeep Reddy POTTETI | 8a62313 | 2014-06-26 16:07:06 +0530 | [diff] [blame] | 2049 | "%s: " MAC_ADDRESS_STR " eTDLS_LINK_CONNECTED", |
| 2050 | __func__, MAC_ADDR_ARRAY(curr_peer->peerMac)); |
Pradeep Reddy POTTETI | edaeb5f | 2014-05-22 23:34:41 +0530 | [diff] [blame] | 2051 | return curr_peer; |
| 2052 | } |
| 2053 | } |
| 2054 | } |
| 2055 | mutex_unlock(&pHddCtx->tdls_lock); |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 2056 | |
| 2057 | EXIT(); |
Pradeep Reddy POTTETI | edaeb5f | 2014-05-22 23:34:41 +0530 | [diff] [blame] | 2058 | return NULL; |
| 2059 | } |
| 2060 | |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 2061 | 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] | 2062 | { |
| 2063 | int i; |
| 2064 | int len, init_len; |
Hoonki Lee | 387663d | 2013-02-05 18:08:43 -0800 | [diff] [blame] | 2065 | struct list_head *head; |
| 2066 | struct list_head *pos; |
Chilam Ng | 16a2a1c | 2013-01-29 01:27:29 -0800 | [diff] [blame] | 2067 | hddTdlsPeer_t *curr_peer; |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 2068 | tdlsCtx_t *pHddTdlsCtx; |
Madan Mohan Koyyalamudi | 263cec1 | 2013-10-07 10:57:50 +0530 | [diff] [blame] | 2069 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 2070 | |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 2071 | ENTER(); |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 2072 | if(0 != (wlan_hdd_validate_context(pHddCtx))) |
| 2073 | { |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 2074 | return 0; |
Madan Mohan Koyyalamudi | 263cec1 | 2013-10-07 10:57:50 +0530 | [diff] [blame] | 2075 | } |
Chilam Ng | 16a2a1c | 2013-01-29 01:27:29 -0800 | [diff] [blame] | 2076 | |
Chilam Ng | 16a2a1c | 2013-01-29 01:27:29 -0800 | [diff] [blame] | 2077 | init_len = buflen; |
Sameer Thalappil | b0a3023 | 2013-09-27 15:37:48 -0700 | [diff] [blame] | 2078 | len = scnprintf(buf, buflen, "\n%-18s%-3s%-4s%-3s%-5s\n", |
| 2079 | "MAC", "Id", "cap", "up", "RSSI"); |
Chilam Ng | 16a2a1c | 2013-01-29 01:27:29 -0800 | [diff] [blame] | 2080 | buf += len; |
| 2081 | buflen -= len; |
| 2082 | /* 1234567890123456789012345678901234567 */ |
Sameer Thalappil | b0a3023 | 2013-09-27 15:37:48 -0700 | [diff] [blame] | 2083 | len = scnprintf(buf, buflen, "---------------------------------\n"); |
Chilam Ng | 16a2a1c | 2013-01-29 01:27:29 -0800 | [diff] [blame] | 2084 | buf += len; |
| 2085 | buflen -= len; |
| 2086 | |
Rajesh Chauhan | a34c6e6 | 2014-03-25 16:37:58 +0530 | [diff] [blame] | 2087 | mutex_lock(&pHddCtx->tdls_lock); |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 2088 | pHddTdlsCtx = WLAN_HDD_GET_TDLS_CTX_PTR(pAdapter); |
Gopichand Nakkala | eb69b60 | 2013-02-27 11:40:31 -0800 | [diff] [blame] | 2089 | if (NULL == pHddTdlsCtx) { |
Madan Mohan Koyyalamudi | 263cec1 | 2013-10-07 10:57:50 +0530 | [diff] [blame] | 2090 | mutex_unlock(&pHddCtx->tdls_lock); |
Sameer Thalappil | b0a3023 | 2013-09-27 15:37:48 -0700 | [diff] [blame] | 2091 | len = scnprintf(buf, buflen, "TDLS not enabled\n"); |
Gopichand Nakkala | eb69b60 | 2013-02-27 11:40:31 -0800 | [diff] [blame] | 2092 | return len; |
| 2093 | } |
Chilam Ng | 16a2a1c | 2013-01-29 01:27:29 -0800 | [diff] [blame] | 2094 | for (i = 0; i < 256; i++) { |
Hoonki Lee | 387663d | 2013-02-05 18:08:43 -0800 | [diff] [blame] | 2095 | head = &pHddTdlsCtx->peer_list[i]; |
Chilam Ng | 16a2a1c | 2013-01-29 01:27:29 -0800 | [diff] [blame] | 2096 | |
Hoonki Lee | 387663d | 2013-02-05 18:08:43 -0800 | [diff] [blame] | 2097 | list_for_each(pos, head) { |
| 2098 | curr_peer= list_entry (pos, hddTdlsPeer_t, node); |
Chilam Ng | 16a2a1c | 2013-01-29 01:27:29 -0800 | [diff] [blame] | 2099 | |
Hoonki Lee | 387663d | 2013-02-05 18:08:43 -0800 | [diff] [blame] | 2100 | if (buflen < 32+1) |
| 2101 | break; |
Sameer Thalappil | b0a3023 | 2013-09-27 15:37:48 -0700 | [diff] [blame] | 2102 | len = scnprintf(buf, buflen, |
Chilam Ng | 0112041 | 2013-02-19 18:32:21 -0800 | [diff] [blame] | 2103 | MAC_ADDRESS_STR"%3d%4s%3s%5d\n", |
| 2104 | MAC_ADDR_ARRAY(curr_peer->peerMac), |
Hoonki Lee | 387663d | 2013-02-05 18:08:43 -0800 | [diff] [blame] | 2105 | curr_peer->staId, |
| 2106 | (curr_peer->tdls_support == eTDLS_CAP_SUPPORTED) ? "Y":"N", |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 2107 | TDLS_IS_CONNECTED(curr_peer) ? "Y":"N", |
Hoonki Lee | 387663d | 2013-02-05 18:08:43 -0800 | [diff] [blame] | 2108 | curr_peer->rssi); |
| 2109 | buf += len; |
| 2110 | buflen -= len; |
Chilam Ng | 16a2a1c | 2013-01-29 01:27:29 -0800 | [diff] [blame] | 2111 | } |
| 2112 | } |
Madan Mohan Koyyalamudi | 263cec1 | 2013-10-07 10:57:50 +0530 | [diff] [blame] | 2113 | mutex_unlock(&pHddCtx->tdls_lock); |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 2114 | |
| 2115 | EXIT(); |
Chilam Ng | 16a2a1c | 2013-01-29 01:27:29 -0800 | [diff] [blame] | 2116 | return init_len-buflen; |
| 2117 | } |
Gopichand Nakkala | c369458 | 2013-02-13 20:51:22 -0800 | [diff] [blame] | 2118 | |
| 2119 | void wlan_hdd_tdls_connection_callback(hdd_adapter_t *pAdapter) |
| 2120 | { |
Mahesh A Saptasagar | 36cdc80 | 2015-01-07 18:41:17 +0530 | [diff] [blame] | 2121 | tdlsCtx_t *pHddTdlsCtx; |
Madan Mohan Koyyalamudi | 263cec1 | 2013-10-07 10:57:50 +0530 | [diff] [blame] | 2122 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
Gopichand Nakkala | 9d76a9b | 2013-02-28 15:38:37 -0800 | [diff] [blame] | 2123 | |
Mahesh A Saptasagar | 36cdc80 | 2015-01-07 18:41:17 +0530 | [diff] [blame] | 2124 | if ((NULL == pHddCtx)) |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 2125 | { |
Agarwal Ashish | bf98caf | 2014-03-25 13:29:11 +0530 | [diff] [blame] | 2126 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, |
| 2127 | FL("pHddCtx or pHddTdlsCtx points to NULL")); |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 2128 | return; |
| 2129 | } |
Madan Mohan Koyyalamudi | 263cec1 | 2013-10-07 10:57:50 +0530 | [diff] [blame] | 2130 | |
Rajesh Chauhan | a34c6e6 | 2014-03-25 16:37:58 +0530 | [diff] [blame] | 2131 | mutex_lock(&pHddCtx->tdls_lock); |
Gopichand Nakkala | 638ebc7 | 2013-03-21 18:04:02 -0700 | [diff] [blame] | 2132 | |
Mahesh A Saptasagar | 36cdc80 | 2015-01-07 18:41:17 +0530 | [diff] [blame] | 2133 | if (0 != wlan_hdd_sta_tdls_init(pAdapter)) |
| 2134 | { |
Mahesh A Saptasagar | 36cdc80 | 2015-01-07 18:41:17 +0530 | [diff] [blame] | 2135 | mutex_unlock(&pHddCtx->tdls_lock); |
Hema Aparna Medicharla | 8bb6f78 | 2015-03-09 12:35:05 +0530 | [diff] [blame] | 2136 | hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wlan_hdd_sta_tdls_init failed",__func__); |
Mahesh A Saptasagar | 36cdc80 | 2015-01-07 18:41:17 +0530 | [diff] [blame] | 2137 | return; |
| 2138 | } |
Mahesh A Saptasagar | 36cdc80 | 2015-01-07 18:41:17 +0530 | [diff] [blame] | 2139 | |
| 2140 | pHddTdlsCtx = WLAN_HDD_GET_TDLS_CTX_PTR(pAdapter); |
| 2141 | if ((NULL == pHddTdlsCtx)) |
| 2142 | { |
Hema Aparna Medicharla | 8bb6f78 | 2015-03-09 12:35:05 +0530 | [diff] [blame] | 2143 | mutex_unlock(&pHddCtx->tdls_lock); |
Mahesh A Saptasagar | 36cdc80 | 2015-01-07 18:41:17 +0530 | [diff] [blame] | 2144 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, |
| 2145 | FL("pHddCtx or pHddTdlsCtx points to NULL device mode = %d"), pAdapter->device_mode); |
Mahesh A Saptasagar | 36cdc80 | 2015-01-07 18:41:17 +0530 | [diff] [blame] | 2146 | return; |
| 2147 | } |
Masti, Narayanraddi | 34e0e56 | 2015-03-05 18:23:03 +0530 | [diff] [blame] | 2148 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Gopichand Nakkala | c369458 | 2013-02-13 20:51:22 -0800 | [diff] [blame] | 2149 | "%s, update %d discover %d", __func__, |
| 2150 | pHddTdlsCtx->threshold_config.tx_period_t, |
| 2151 | pHddTdlsCtx->threshold_config.discovery_period_t); |
| 2152 | |
Gopichand Nakkala | 9d76a9b | 2013-02-28 15:38:37 -0800 | [diff] [blame] | 2153 | if (eTDLS_SUPPORT_ENABLED == pHddCtx->tdls_mode) |
| 2154 | { |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 2155 | wlan_hdd_tdls_peer_reset_discovery_processed(pHddTdlsCtx); |
Gopichand Nakkala | 75e7b28 | 2013-03-15 18:37:13 -0700 | [diff] [blame] | 2156 | pHddTdlsCtx->discovery_sent_cnt = 0; |
Gopichand Nakkala | 34d1b06 | 2013-03-19 15:28:33 -0700 | [diff] [blame] | 2157 | wlan_hdd_tdls_check_power_save_prohibited(pHddTdlsCtx->pAdapter); |
Gopichand Nakkala | c369458 | 2013-02-13 20:51:22 -0800 | [diff] [blame] | 2158 | |
Gopichand Nakkala | 75e7b28 | 2013-03-15 18:37:13 -0700 | [diff] [blame] | 2159 | #ifdef FEATURE_WLAN_TDLS_INTERNAL |
Gopichand Nakkala | 3046fc9 | 2013-03-23 13:56:43 -0700 | [diff] [blame] | 2160 | wlan_hdd_tdls_timer_restart(pHddTdlsCtx->pAdapter, |
| 2161 | &pHddTdlsCtx->peerDiscoverTimer, |
| 2162 | pHddTdlsCtx->threshold_config.discovery_period_t); |
Gopichand Nakkala | 75e7b28 | 2013-03-15 18:37:13 -0700 | [diff] [blame] | 2163 | #endif |
Gopichand Nakkala | 3046fc9 | 2013-03-23 13:56:43 -0700 | [diff] [blame] | 2164 | wlan_hdd_tdls_timer_restart(pHddTdlsCtx->pAdapter, |
| 2165 | &pHddTdlsCtx->peerUpdateTimer, |
| 2166 | pHddTdlsCtx->threshold_config.tx_period_t); |
Gopichand Nakkala | 9d76a9b | 2013-02-28 15:38:37 -0800 | [diff] [blame] | 2167 | } |
Madan Mohan Koyyalamudi | 263cec1 | 2013-10-07 10:57:50 +0530 | [diff] [blame] | 2168 | mutex_unlock(&pHddCtx->tdls_lock); |
Gopichand Nakkala | c369458 | 2013-02-13 20:51:22 -0800 | [diff] [blame] | 2169 | |
| 2170 | } |
| 2171 | |
| 2172 | void wlan_hdd_tdls_disconnection_callback(hdd_adapter_t *pAdapter) |
| 2173 | { |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 2174 | tdlsCtx_t *pHddTdlsCtx = WLAN_HDD_GET_TDLS_CTX_PTR(pAdapter); |
Madan Mohan Koyyalamudi | 263cec1 | 2013-10-07 10:57:50 +0530 | [diff] [blame] | 2175 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 2176 | |
Deepthi Gowri | bfd1713 | 2014-11-14 17:59:04 +0530 | [diff] [blame] | 2177 | if (NULL == pHddCtx) |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 2178 | { |
| 2179 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Deepthi Gowri | bfd1713 | 2014-11-14 17:59:04 +0530 | [diff] [blame] | 2180 | FL(" pHddCtx points to NULL")); |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 2181 | return; |
| 2182 | } |
Gopichand Nakkala | c369458 | 2013-02-13 20:51:22 -0800 | [diff] [blame] | 2183 | |
Masti, Narayanraddi | 34e0e56 | 2015-03-05 18:23:03 +0530 | [diff] [blame] | 2184 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s", __func__); |
Gopichand Nakkala | c369458 | 2013-02-13 20:51:22 -0800 | [diff] [blame] | 2185 | |
Gopichand Nakkala | eb69b60 | 2013-02-27 11:40:31 -0800 | [diff] [blame] | 2186 | if (NULL == pHddTdlsCtx) |
| 2187 | { |
Hema Aparna Medicharla | 8bb6f78 | 2015-03-09 12:35:05 +0530 | [diff] [blame] | 2188 | mutex_unlock(&pHddCtx->tdls_lock); |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 2189 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2190 | FL("pHddTdlsCtx is NULL")); |
Gopichand Nakkala | eb69b60 | 2013-02-27 11:40:31 -0800 | [diff] [blame] | 2191 | return; |
| 2192 | } |
Masti, Narayanraddi | de96b99 | 2015-01-08 13:00:58 +0530 | [diff] [blame] | 2193 | |
Pradeep Reddy POTTETI | 2d4d5c4 | 2015-03-03 14:34:19 +0530 | [diff] [blame] | 2194 | mutex_lock(&pHddCtx->tdls_lock); |
Masti, Narayanraddi | de96b99 | 2015-01-08 13:00:58 +0530 | [diff] [blame] | 2195 | |
Gopichand Nakkala | ccd3a38 | 2013-03-19 13:56:10 -0700 | [diff] [blame] | 2196 | pHddTdlsCtx->discovery_sent_cnt = 0; |
Gopichand Nakkala | 34d1b06 | 2013-03-19 15:28:33 -0700 | [diff] [blame] | 2197 | wlan_hdd_tdls_check_power_save_prohibited(pHddTdlsCtx->pAdapter); |
Gopichand Nakkala | eb69b60 | 2013-02-27 11:40:31 -0800 | [diff] [blame] | 2198 | |
Pradeep Reddy POTTETI | 2d4d5c4 | 2015-03-03 14:34:19 +0530 | [diff] [blame] | 2199 | wlan_hdd_tdls_exit(pAdapter, TRUE); |
Gopichand Nakkala | eb69b60 | 2013-02-27 11:40:31 -0800 | [diff] [blame] | 2200 | |
Madan Mohan Koyyalamudi | 263cec1 | 2013-10-07 10:57:50 +0530 | [diff] [blame] | 2201 | mutex_unlock(&pHddCtx->tdls_lock); |
Gopichand Nakkala | c369458 | 2013-02-13 20:51:22 -0800 | [diff] [blame] | 2202 | } |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 2203 | |
| 2204 | void wlan_hdd_tdls_mgmt_completion_callback(hdd_adapter_t *pAdapter, tANI_U32 statusCode) |
| 2205 | { |
| 2206 | pAdapter->mgmtTxCompletionStatus = statusCode; |
Masti, Narayanraddi | 34e0e56 | 2015-03-05 18:23:03 +0530 | [diff] [blame] | 2207 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 2208 | "%s: Mgmt TX Completion %d",__func__, statusCode); |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 2209 | complete(&pAdapter->tdls_mgmt_comp); |
| 2210 | } |
| 2211 | |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 2212 | void wlan_hdd_tdls_increment_peer_count(hdd_adapter_t *pAdapter) |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 2213 | { |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 2214 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 2215 | |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 2216 | ENTER(); |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 2217 | if(0 != (wlan_hdd_validate_context(pHddCtx))) |
| 2218 | { |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 2219 | return; |
| 2220 | } |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 2221 | |
Rajesh Chauhan | a34c6e6 | 2014-03-25 16:37:58 +0530 | [diff] [blame] | 2222 | mutex_lock(&pHddCtx->tdls_lock); |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 2223 | |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 2224 | pHddCtx->connected_peer_count++; |
Gopichand Nakkala | 34d1b06 | 2013-03-19 15:28:33 -0700 | [diff] [blame] | 2225 | wlan_hdd_tdls_check_power_save_prohibited(pAdapter); |
Gopichand Nakkala | ccd3a38 | 2013-03-19 13:56:10 -0700 | [diff] [blame] | 2226 | |
Masti, Narayanraddi | 34e0e56 | 2015-03-05 18:23:03 +0530 | [diff] [blame] | 2227 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: %d", |
Gopichand Nakkala | ccd3a38 | 2013-03-19 13:56:10 -0700 | [diff] [blame] | 2228 | __func__, pHddCtx->connected_peer_count); |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 2229 | |
| 2230 | mutex_unlock(&pHddCtx->tdls_lock); |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 2231 | |
| 2232 | EXIT(); |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 2233 | } |
| 2234 | |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 2235 | void wlan_hdd_tdls_decrement_peer_count(hdd_adapter_t *pAdapter) |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 2236 | { |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 2237 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 2238 | |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 2239 | ENTER(); |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 2240 | if(0 != (wlan_hdd_validate_context(pHddCtx))) |
| 2241 | { |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 2242 | return; |
| 2243 | } |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 2244 | |
Rajesh Chauhan | a34c6e6 | 2014-03-25 16:37:58 +0530 | [diff] [blame] | 2245 | mutex_lock(&pHddCtx->tdls_lock); |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 2246 | |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 2247 | if (pHddCtx->connected_peer_count) |
| 2248 | pHddCtx->connected_peer_count--; |
Gopichand Nakkala | 34d1b06 | 2013-03-19 15:28:33 -0700 | [diff] [blame] | 2249 | wlan_hdd_tdls_check_power_save_prohibited(pAdapter); |
Gopichand Nakkala | ccd3a38 | 2013-03-19 13:56:10 -0700 | [diff] [blame] | 2250 | |
Masti, Narayanraddi | 34e0e56 | 2015-03-05 18:23:03 +0530 | [diff] [blame] | 2251 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: %d", |
Gopichand Nakkala | ccd3a38 | 2013-03-19 13:56:10 -0700 | [diff] [blame] | 2252 | __func__, pHddCtx->connected_peer_count); |
| 2253 | |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 2254 | mutex_unlock(&pHddCtx->tdls_lock); |
| 2255 | |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 2256 | EXIT(); |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 2257 | } |
| 2258 | |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 2259 | void wlan_hdd_tdls_check_bmps(hdd_adapter_t *pAdapter) |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 2260 | { |
Hanumantha Reddy Pothula | da0fe36 | 2015-02-27 18:37:03 +0530 | [diff] [blame] | 2261 | |
| 2262 | tdlsCtx_t *pHddTdlsCtx = NULL; |
| 2263 | hdd_context_t *pHddCtx = NULL; |
Hoonki Lee | 1462135 | 2013-04-16 17:51:19 -0700 | [diff] [blame] | 2264 | hddTdlsPeer_t *curr_peer; |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 2265 | |
Hanumantha Reddy Pothula | da0fe36 | 2015-02-27 18:37:03 +0530 | [diff] [blame] | 2266 | if ((NULL == pAdapter) || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic)) |
| 2267 | { |
| 2268 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2269 | FL("invalid pAdapter: %p"), pAdapter); |
| 2270 | return; |
| 2271 | } |
| 2272 | |
| 2273 | pHddTdlsCtx = WLAN_HDD_GET_TDLS_CTX_PTR(pAdapter); |
| 2274 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 2275 | |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 2276 | if ((NULL == pHddCtx) || (NULL == pHddTdlsCtx)) |
| 2277 | { |
Sushant Kaushik | 125ae69 | 2014-11-25 17:38:48 +0530 | [diff] [blame] | 2278 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 2279 | FL(" pHddCtx or pHddTdlsCtx points to NULL")); |
| 2280 | return; |
| 2281 | } |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 2282 | |
Pradeep Reddy POTTETI | 9db32f0 | 2015-01-29 15:22:54 +0530 | [diff] [blame] | 2283 | curr_peer = wlan_hdd_tdls_is_progress(pHddCtx, NULL, 0, TRUE); |
Hoonki Lee | 1462135 | 2013-04-16 17:51:19 -0700 | [diff] [blame] | 2284 | if (NULL != curr_peer) |
| 2285 | { |
Masti, Narayanraddi | 34e0e56 | 2015-03-05 18:23:03 +0530 | [diff] [blame] | 2286 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Hoonki Lee | 1462135 | 2013-04-16 17:51:19 -0700 | [diff] [blame] | 2287 | "%s: tdls in progress. Dont check for BMPS " MAC_ADDRESS_STR, |
| 2288 | __func__, MAC_ADDR_ARRAY (curr_peer->peerMac)); |
| 2289 | return; |
| 2290 | } |
| 2291 | |
Hoonki Lee | 93e67ff | 2013-03-19 15:49:25 -0700 | [diff] [blame] | 2292 | if ((TDLS_CTX_MAGIC != pHddCtx->tdls_scan_ctxt.magic) && |
| 2293 | (0 == pHddCtx->connected_peer_count) && |
Gopichand Nakkala | 75e7b28 | 2013-03-15 18:37:13 -0700 | [diff] [blame] | 2294 | (0 == pHddTdlsCtx->discovery_sent_cnt)) |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 2295 | { |
Gopichand Nakkala | 75e7b28 | 2013-03-15 18:37:13 -0700 | [diff] [blame] | 2296 | if (FALSE == sme_IsPmcBmps(WLAN_HDD_GET_HAL_CTX(pAdapter))) |
| 2297 | { |
Masti, Narayanraddi | 34e0e56 | 2015-03-05 18:23:03 +0530 | [diff] [blame] | 2298 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, |
Gopichand Nakkala | ccd3a38 | 2013-03-19 13:56:10 -0700 | [diff] [blame] | 2299 | "%s: No TDLS peer connected/discovery sent. Enable BMPS", |
| 2300 | __func__); |
Gopichand Nakkala | 75e7b28 | 2013-03-15 18:37:13 -0700 | [diff] [blame] | 2301 | hdd_enable_bmps_imps(pHddCtx); |
| 2302 | } |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 2303 | } |
Gopichand Nakkala | 75e7b28 | 2013-03-15 18:37:13 -0700 | [diff] [blame] | 2304 | else |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 2305 | { |
Gopichand Nakkala | 75e7b28 | 2013-03-15 18:37:13 -0700 | [diff] [blame] | 2306 | if (TRUE == sme_IsPmcBmps(WLAN_HDD_GET_HAL_CTX(pAdapter))) |
| 2307 | { |
Masti, Narayanraddi | 34e0e56 | 2015-03-05 18:23:03 +0530 | [diff] [blame] | 2308 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Gopichand Nakkala | ccd3a38 | 2013-03-19 13:56:10 -0700 | [diff] [blame] | 2309 | "%s: TDLS peer connected. Disable BMPS", __func__); |
Gopichand Nakkala | 75e7b28 | 2013-03-15 18:37:13 -0700 | [diff] [blame] | 2310 | hdd_disable_bmps_imps(pHddCtx, WLAN_HDD_INFRA_STATION); |
| 2311 | } |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 2312 | } |
| 2313 | return; |
| 2314 | } |
| 2315 | |
Gopichand Nakkala | 34d1b06 | 2013-03-19 15:28:33 -0700 | [diff] [blame] | 2316 | u8 wlan_hdd_tdls_is_peer_progress(hdd_adapter_t *pAdapter, u8 *mac) |
| 2317 | { |
| 2318 | hddTdlsPeer_t *curr_peer; |
| 2319 | |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 2320 | curr_peer = wlan_hdd_tdls_find_peer(pAdapter, mac, TRUE); |
Gopichand Nakkala | 34d1b06 | 2013-03-19 15:28:33 -0700 | [diff] [blame] | 2321 | if (curr_peer == NULL) |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 2322 | { |
| 2323 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2324 | "%s: curr_peer is NULL", __func__); |
Gopichand Nakkala | 34d1b06 | 2013-03-19 15:28:33 -0700 | [diff] [blame] | 2325 | return 0; |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 2326 | } |
Gopichand Nakkala | 34d1b06 | 2013-03-19 15:28:33 -0700 | [diff] [blame] | 2327 | |
| 2328 | return (eTDLS_LINK_CONNECTING == curr_peer->link_status); |
| 2329 | } |
| 2330 | |
Hoonki Lee | fb8df67 | 2013-04-10 18:20:34 -0700 | [diff] [blame] | 2331 | /* return pointer to hddTdlsPeer_t if TDLS is ongoing. Otherwise return NULL. |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 2332 | * mac - if NULL check for all the peer list, otherwise, skip this mac when skip_self is TRUE |
| 2333 | * skip_self - if TRUE, skip this mac. otherwise, check all the peer list. if |
| 2334 | mac is NULL, this argument is ignored, and check for all the peer list. |
| 2335 | */ |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 2336 | static hddTdlsPeer_t *wlan_hdd_tdls_find_progress_peer(hdd_adapter_t *pAdapter, u8 *mac, u8 skip_self) |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 2337 | { |
| 2338 | int i; |
| 2339 | struct list_head *head; |
| 2340 | hddTdlsPeer_t *curr_peer; |
| 2341 | struct list_head *pos; |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 2342 | tdlsCtx_t *pHddTdlsCtx = WLAN_HDD_GET_TDLS_CTX_PTR(pAdapter);; |
Madan Mohan Koyyalamudi | 263cec1 | 2013-10-07 10:57:50 +0530 | [diff] [blame] | 2343 | |
Madan Mohan Koyyalamudi | 263cec1 | 2013-10-07 10:57:50 +0530 | [diff] [blame] | 2344 | if (NULL == pHddTdlsCtx) |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 2345 | { |
| 2346 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2347 | FL("pHddTdlsCtx is NULL")); |
Madan Mohan Koyyalamudi | 263cec1 | 2013-10-07 10:57:50 +0530 | [diff] [blame] | 2348 | return NULL; |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 2349 | } |
Madan Mohan Koyyalamudi | 263cec1 | 2013-10-07 10:57:50 +0530 | [diff] [blame] | 2350 | |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 2351 | for (i = 0; i < 256; i++) { |
| 2352 | head = &pHddTdlsCtx->peer_list[i]; |
| 2353 | list_for_each(pos, head) { |
| 2354 | curr_peer = list_entry (pos, hddTdlsPeer_t, node); |
| 2355 | if (skip_self && mac && !memcmp(mac, curr_peer->peerMac, 6)) { |
| 2356 | continue; |
| 2357 | } |
| 2358 | else |
| 2359 | { |
Gopichand Nakkala | 8b00c63 | 2013-03-08 19:47:52 -0800 | [diff] [blame] | 2360 | if (eTDLS_LINK_CONNECTING == curr_peer->link_status) |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 2361 | { |
Masti, Narayanraddi | 34e0e56 | 2015-03-05 18:23:03 +0530 | [diff] [blame] | 2362 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Gopichand Nakkala | 34d1b06 | 2013-03-19 15:28:33 -0700 | [diff] [blame] | 2363 | "%s:" MAC_ADDRESS_STR " eTDLS_LINK_CONNECTING", |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 2364 | __func__, MAC_ADDR_ARRAY(curr_peer->peerMac)); |
Hoonki Lee | fb8df67 | 2013-04-10 18:20:34 -0700 | [diff] [blame] | 2365 | return curr_peer; |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 2366 | } |
| 2367 | } |
| 2368 | } |
| 2369 | } |
Hoonki Lee | fb8df67 | 2013-04-10 18:20:34 -0700 | [diff] [blame] | 2370 | return NULL; |
| 2371 | } |
| 2372 | |
Pradeep Reddy POTTETI | 9db32f0 | 2015-01-29 15:22:54 +0530 | [diff] [blame] | 2373 | hddTdlsPeer_t *wlan_hdd_tdls_is_progress(hdd_context_t *pHddCtx, u8 *mac, |
| 2374 | u8 skip_self, tANI_BOOLEAN mutexLock) |
Hoonki Lee | fb8df67 | 2013-04-10 18:20:34 -0700 | [diff] [blame] | 2375 | { |
| 2376 | hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL; |
| 2377 | hdd_adapter_t *pAdapter = NULL; |
| 2378 | tdlsCtx_t *pHddTdlsCtx = NULL; |
| 2379 | hddTdlsPeer_t *curr_peer= NULL; |
| 2380 | VOS_STATUS status = 0; |
| 2381 | |
Pradeep Reddy POTTETI | 9db32f0 | 2015-01-29 15:22:54 +0530 | [diff] [blame] | 2382 | if (mutexLock) |
| 2383 | { |
| 2384 | mutex_lock(&pHddCtx->tdls_lock); |
| 2385 | } |
Hoonki Lee | fb8df67 | 2013-04-10 18:20:34 -0700 | [diff] [blame] | 2386 | status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode ); |
| 2387 | while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status ) |
| 2388 | { |
| 2389 | pAdapter = pAdapterNode->pAdapter; |
| 2390 | |
| 2391 | pHddTdlsCtx = WLAN_HDD_GET_TDLS_CTX_PTR(pAdapter); |
| 2392 | if (NULL != pHddTdlsCtx) |
| 2393 | { |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 2394 | curr_peer = wlan_hdd_tdls_find_progress_peer(pAdapter, mac, skip_self); |
Hoonki Lee | fb8df67 | 2013-04-10 18:20:34 -0700 | [diff] [blame] | 2395 | if (curr_peer) |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 2396 | { |
Pradeep Reddy POTTETI | 9db32f0 | 2015-01-29 15:22:54 +0530 | [diff] [blame] | 2397 | if (mutexLock) |
| 2398 | mutex_unlock(&pHddCtx->tdls_lock); |
Hoonki Lee | fb8df67 | 2013-04-10 18:20:34 -0700 | [diff] [blame] | 2399 | return curr_peer; |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 2400 | } |
Hoonki Lee | fb8df67 | 2013-04-10 18:20:34 -0700 | [diff] [blame] | 2401 | } |
| 2402 | status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 2403 | pAdapterNode = pNext; |
| 2404 | } |
Pradeep Reddy POTTETI | 9db32f0 | 2015-01-29 15:22:54 +0530 | [diff] [blame] | 2405 | if (mutexLock) |
| 2406 | mutex_unlock(&pHddCtx->tdls_lock); |
Hoonki Lee | fb8df67 | 2013-04-10 18:20:34 -0700 | [diff] [blame] | 2407 | return NULL; |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 2408 | } |
Hoonki Lee | 2751190 | 2013-03-14 18:19:06 -0700 | [diff] [blame] | 2409 | |
| 2410 | static void wlan_hdd_tdls_implicit_disable(tdlsCtx_t *pHddTdlsCtx) |
| 2411 | { |
Hoonki Lee | 2751190 | 2013-03-14 18:19:06 -0700 | [diff] [blame] | 2412 | wlan_hdd_tdls_timers_stop(pHddTdlsCtx); |
Hoonki Lee | 2751190 | 2013-03-14 18:19:06 -0700 | [diff] [blame] | 2413 | } |
| 2414 | |
| 2415 | static void wlan_hdd_tdls_implicit_enable(tdlsCtx_t *pHddTdlsCtx) |
| 2416 | { |
| 2417 | wlan_hdd_tdls_peer_reset_discovery_processed(pHddTdlsCtx); |
Gopichand Nakkala | 75e7b28 | 2013-03-15 18:37:13 -0700 | [diff] [blame] | 2418 | pHddTdlsCtx->discovery_sent_cnt = 0; |
Hoonki Lee | 2751190 | 2013-03-14 18:19:06 -0700 | [diff] [blame] | 2419 | wlan_tdd_tdls_reset_tx_rx(pHddTdlsCtx); |
Gopichand Nakkala | 34d1b06 | 2013-03-19 15:28:33 -0700 | [diff] [blame] | 2420 | wlan_hdd_tdls_check_power_save_prohibited(pHddTdlsCtx->pAdapter); |
Gopichand Nakkala | ccd3a38 | 2013-03-19 13:56:10 -0700 | [diff] [blame] | 2421 | |
Hoonki Lee | 2751190 | 2013-03-14 18:19:06 -0700 | [diff] [blame] | 2422 | |
Gopichand Nakkala | 75e7b28 | 2013-03-15 18:37:13 -0700 | [diff] [blame] | 2423 | #ifdef FEATURE_WLAN_TDLS_INTERNAL |
Gopichand Nakkala | 3046fc9 | 2013-03-23 13:56:43 -0700 | [diff] [blame] | 2424 | wlan_hdd_tdls_timer_restart(pHddTdlsCtx->pAdapter, |
| 2425 | &pHddTdlsCtx->peerDiscoverTimer, |
| 2426 | pHddTdlsCtx->threshold_config.discovery_period_t); |
Gopichand Nakkala | 75e7b28 | 2013-03-15 18:37:13 -0700 | [diff] [blame] | 2427 | #endif |
Gopichand Nakkala | 3046fc9 | 2013-03-23 13:56:43 -0700 | [diff] [blame] | 2428 | wlan_hdd_tdls_timer_restart(pHddTdlsCtx->pAdapter, |
| 2429 | &pHddTdlsCtx->peerUpdateTimer, |
| 2430 | pHddTdlsCtx->threshold_config.tx_period_t); |
Hoonki Lee | 2751190 | 2013-03-14 18:19:06 -0700 | [diff] [blame] | 2431 | } |
| 2432 | |
Gopichand Nakkala | dcbcf4e | 2013-03-23 14:32:39 -0700 | [diff] [blame] | 2433 | void wlan_hdd_tdls_set_mode(hdd_context_t *pHddCtx, |
| 2434 | eTDLSSupportMode tdls_mode, |
| 2435 | v_BOOL_t bUpdateLast) |
Hoonki Lee | 2751190 | 2013-03-14 18:19:06 -0700 | [diff] [blame] | 2436 | { |
| 2437 | hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL; |
| 2438 | VOS_STATUS status; |
| 2439 | hdd_adapter_t *pAdapter; |
| 2440 | tdlsCtx_t *pHddTdlsCtx; |
| 2441 | |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 2442 | ENTER(); |
Masti, Narayanraddi | 34e0e56 | 2015-03-05 18:23:03 +0530 | [diff] [blame] | 2443 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 2444 | "%s mode %d", __func__, (int)tdls_mode); |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 2445 | |
| 2446 | if(0 != (wlan_hdd_validate_context(pHddCtx))) |
| 2447 | { |
Madan Mohan Koyyalamudi | 263cec1 | 2013-10-07 10:57:50 +0530 | [diff] [blame] | 2448 | return; |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 2449 | } |
Hoonki Lee | 2751190 | 2013-03-14 18:19:06 -0700 | [diff] [blame] | 2450 | |
Rajesh Chauhan | a34c6e6 | 2014-03-25 16:37:58 +0530 | [diff] [blame] | 2451 | mutex_lock(&pHddCtx->tdls_lock); |
Gopichand Nakkala | 638ebc7 | 2013-03-21 18:04:02 -0700 | [diff] [blame] | 2452 | |
Hoonki Lee | 93e67ff | 2013-03-19 15:49:25 -0700 | [diff] [blame] | 2453 | if (pHddCtx->tdls_mode == tdls_mode) |
| 2454 | { |
Hema Aparna Medicharla | 8bb6f78 | 2015-03-09 12:35:05 +0530 | [diff] [blame] | 2455 | mutex_unlock(&pHddCtx->tdls_lock); |
Masti, Narayanraddi | 34e0e56 | 2015-03-05 18:23:03 +0530 | [diff] [blame] | 2456 | hddLog(VOS_TRACE_LEVEL_INFO, "%s already in mode %d", __func__, |
| 2457 | (int)tdls_mode); |
Hoonki Lee | 93e67ff | 2013-03-19 15:49:25 -0700 | [diff] [blame] | 2458 | return; |
| 2459 | } |
| 2460 | |
Hoonki Lee | 2751190 | 2013-03-14 18:19:06 -0700 | [diff] [blame] | 2461 | status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode ); |
| 2462 | |
| 2463 | while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status ) |
| 2464 | { |
| 2465 | pAdapter = pAdapterNode->pAdapter; |
Hoonki Lee | a6d49be | 2013-04-05 09:43:25 -0700 | [diff] [blame] | 2466 | pHddTdlsCtx = WLAN_HDD_GET_TDLS_CTX_PTR(pAdapter); |
| 2467 | if (NULL != pHddTdlsCtx) |
Hoonki Lee | 2751190 | 2013-03-14 18:19:06 -0700 | [diff] [blame] | 2468 | { |
Hoonki Lee | a6d49be | 2013-04-05 09:43:25 -0700 | [diff] [blame] | 2469 | if(eTDLS_SUPPORT_ENABLED == tdls_mode) |
| 2470 | wlan_hdd_tdls_implicit_enable(pHddTdlsCtx); |
| 2471 | else if((eTDLS_SUPPORT_DISABLED == tdls_mode) || |
| 2472 | (eTDLS_SUPPORT_EXPLICIT_TRIGGER_ONLY == tdls_mode)) |
| 2473 | wlan_hdd_tdls_implicit_disable(pHddTdlsCtx); |
Hoonki Lee | 2751190 | 2013-03-14 18:19:06 -0700 | [diff] [blame] | 2474 | } |
| 2475 | status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 2476 | pAdapterNode = pNext; |
| 2477 | } |
Gopichand Nakkala | dcbcf4e | 2013-03-23 14:32:39 -0700 | [diff] [blame] | 2478 | if(bUpdateLast) |
| 2479 | { |
| 2480 | pHddCtx->tdls_mode_last = tdls_mode; |
| 2481 | } |
| 2482 | else |
| 2483 | { |
| 2484 | pHddCtx->tdls_mode_last = pHddCtx->tdls_mode; |
| 2485 | } |
Hoonki Lee | 2751190 | 2013-03-14 18:19:06 -0700 | [diff] [blame] | 2486 | pHddCtx->tdls_mode = tdls_mode; |
Gopichand Nakkala | dcbcf4e | 2013-03-23 14:32:39 -0700 | [diff] [blame] | 2487 | |
Madan Mohan Koyyalamudi | 263cec1 | 2013-10-07 10:57:50 +0530 | [diff] [blame] | 2488 | mutex_unlock(&pHddCtx->tdls_lock); |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 2489 | |
| 2490 | EXIT(); |
Hoonki Lee | 2751190 | 2013-03-14 18:19:06 -0700 | [diff] [blame] | 2491 | } |
Gopichand Nakkala | 75e7b28 | 2013-03-15 18:37:13 -0700 | [diff] [blame] | 2492 | |
Pradeep Reddy POTTETI | 9db32f0 | 2015-01-29 15:22:54 +0530 | [diff] [blame] | 2493 | static |
| 2494 | void wlan_hdd_tdls_implicit_send_discovery_request(tdlsCtx_t * pHddTdlsCtx) |
Gopichand Nakkala | 75e7b28 | 2013-03-15 18:37:13 -0700 | [diff] [blame] | 2495 | { |
Pradeep Reddy POTTETI | 9db32f0 | 2015-01-29 15:22:54 +0530 | [diff] [blame] | 2496 | hdd_context_t *pHddCtx = NULL; |
| 2497 | hddTdlsPeer_t *curr_peer = NULL, *temp_peer = NULL; |
Hoonki Lee | d37cbb3 | 2013-04-20 00:31:14 -0700 | [diff] [blame] | 2498 | |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 2499 | ENTER(); |
Hoonki Lee | d37cbb3 | 2013-04-20 00:31:14 -0700 | [diff] [blame] | 2500 | if (NULL == pHddTdlsCtx) |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 2501 | { |
| 2502 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2503 | FL("pHddTdlsCtx is NULL")); |
Hoonki Lee | d37cbb3 | 2013-04-20 00:31:14 -0700 | [diff] [blame] | 2504 | return; |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 2505 | } |
Hoonki Lee | d37cbb3 | 2013-04-20 00:31:14 -0700 | [diff] [blame] | 2506 | |
Hoonki Lee | d37cbb3 | 2013-04-20 00:31:14 -0700 | [diff] [blame] | 2507 | pHddCtx = WLAN_HDD_GET_CTX(pHddTdlsCtx->pAdapter); |
Hoonki Lee | fb8df67 | 2013-04-10 18:20:34 -0700 | [diff] [blame] | 2508 | |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 2509 | if(0 != (wlan_hdd_validate_context(pHddCtx))) |
| 2510 | { |
Hoonki Lee | fb8df67 | 2013-04-10 18:20:34 -0700 | [diff] [blame] | 2511 | return; |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 2512 | } |
Gopichand Nakkala | 75e7b28 | 2013-03-15 18:37:13 -0700 | [diff] [blame] | 2513 | |
Hoonki Lee | d37cbb3 | 2013-04-20 00:31:14 -0700 | [diff] [blame] | 2514 | curr_peer = pHddTdlsCtx->curr_candidate; |
Hoonki Lee | d37cbb3 | 2013-04-20 00:31:14 -0700 | [diff] [blame] | 2515 | if (NULL == curr_peer) |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 2516 | { |
| 2517 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2518 | FL("curr_peer is NULL")); |
| 2519 | |
Hoonki Lee | d37cbb3 | 2013-04-20 00:31:14 -0700 | [diff] [blame] | 2520 | return; |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 2521 | } |
Hoonki Lee | d37cbb3 | 2013-04-20 00:31:14 -0700 | [diff] [blame] | 2522 | |
Gopichand Nakkala | 75e7b28 | 2013-03-15 18:37:13 -0700 | [diff] [blame] | 2523 | if (TRUE == sme_IsPmcBmps(WLAN_HDD_GET_HAL_CTX(pHddTdlsCtx->pAdapter))) |
| 2524 | { |
Masti, Narayanraddi | 34e0e56 | 2015-03-05 18:23:03 +0530 | [diff] [blame] | 2525 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 2526 | "%s: Disable BMPS", __func__); |
Gopichand Nakkala | 75e7b28 | 2013-03-15 18:37:13 -0700 | [diff] [blame] | 2527 | hdd_disable_bmps_imps(pHddCtx, WLAN_HDD_INFRA_STATION); |
| 2528 | } |
Gopichand Nakkala | ccd3a38 | 2013-03-19 13:56:10 -0700 | [diff] [blame] | 2529 | |
Pradeep Reddy POTTETI | 9db32f0 | 2015-01-29 15:22:54 +0530 | [diff] [blame] | 2530 | /* This function is called in mutex_lock */ |
| 2531 | temp_peer = wlan_hdd_tdls_is_progress(pHddCtx, NULL, 0, FALSE); |
Hoonki Lee | fb8df67 | 2013-04-10 18:20:34 -0700 | [diff] [blame] | 2532 | if (NULL != temp_peer) |
| 2533 | { |
Pradeep Reddy POTTETI | 9db32f0 | 2015-01-29 15:22:54 +0530 | [diff] [blame] | 2534 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 2535 | "%s: " MAC_ADDRESS_STR " ongoing. pre_setup ignored", |
| 2536 | __func__, MAC_ADDR_ARRAY(temp_peer->peerMac)); |
Hoonki Lee | d37cbb3 | 2013-04-20 00:31:14 -0700 | [diff] [blame] | 2537 | goto done; |
Hoonki Lee | fb8df67 | 2013-04-10 18:20:34 -0700 | [diff] [blame] | 2538 | } |
| 2539 | |
Gopichand Nakkala | ccd3a38 | 2013-03-19 13:56:10 -0700 | [diff] [blame] | 2540 | if (eTDLS_CAP_UNKNOWN != curr_peer->tdls_support) |
Atul Mittal | 115287b | 2014-07-08 13:26:33 +0530 | [diff] [blame] | 2541 | wlan_hdd_tdls_set_peer_link_status(curr_peer, |
| 2542 | eTDLS_LINK_DISCOVERING, |
| 2543 | eTDLS_LINK_SUCCESS); |
Gopichand Nakkala | ccd3a38 | 2013-03-19 13:56:10 -0700 | [diff] [blame] | 2544 | |
Pradeep Reddy POTTETI | 9db32f0 | 2015-01-29 15:22:54 +0530 | [diff] [blame] | 2545 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 2546 | "%s: Implicit TDLS, Send Discovery request event", __func__); |
Hoonki Lee | d37cbb3 | 2013-04-20 00:31:14 -0700 | [diff] [blame] | 2547 | |
Pradeep Reddy POTTETI | 9db32f0 | 2015-01-29 15:22:54 +0530 | [diff] [blame] | 2548 | cfg80211_tdls_oper_request(pHddTdlsCtx->pAdapter->dev, |
| 2549 | curr_peer->peerMac, |
| 2550 | NL80211_TDLS_DISCOVERY_REQ, |
| 2551 | FALSE, |
| 2552 | GFP_KERNEL); |
Gopichand Nakkala | 75e7b28 | 2013-03-15 18:37:13 -0700 | [diff] [blame] | 2553 | pHddTdlsCtx->discovery_sent_cnt++; |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 2554 | |
Gopichand Nakkala | 34d1b06 | 2013-03-19 15:28:33 -0700 | [diff] [blame] | 2555 | wlan_hdd_tdls_check_power_save_prohibited(pHddTdlsCtx->pAdapter); |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 2556 | |
Pradeep Reddy POTTETI | 219ced3 | 2014-11-14 16:33:57 +0530 | [diff] [blame] | 2557 | wlan_hdd_tdls_timer_restart(pHddTdlsCtx->pAdapter, |
| 2558 | &pHddTdlsCtx->peerDiscoveryTimeoutTimer, |
| 2559 | pHddTdlsCtx->threshold_config.tx_period_t - TDLS_DISCOVERY_TIMEOUT_BEFORE_UPDATE); |
| 2560 | |
Pradeep Reddy POTTETI | 9db32f0 | 2015-01-29 15:22:54 +0530 | [diff] [blame] | 2561 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 2562 | "%s: discovery count %u timeout %u msec", |
| 2563 | __func__, pHddTdlsCtx->discovery_sent_cnt, |
| 2564 | pHddTdlsCtx->threshold_config.tx_period_t - TDLS_DISCOVERY_TIMEOUT_BEFORE_UPDATE); |
Gopichand Nakkala | 3046fc9 | 2013-03-23 13:56:43 -0700 | [diff] [blame] | 2565 | |
Hoonki Lee | d37cbb3 | 2013-04-20 00:31:14 -0700 | [diff] [blame] | 2566 | done: |
| 2567 | pHddTdlsCtx->curr_candidate = NULL; |
| 2568 | pHddTdlsCtx->magic = 0; |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 2569 | EXIT(); |
Gopichand Nakkala | 75e7b28 | 2013-03-15 18:37:13 -0700 | [diff] [blame] | 2570 | return; |
| 2571 | } |
Gopichand Nakkala | ccd3a38 | 2013-03-19 13:56:10 -0700 | [diff] [blame] | 2572 | |
| 2573 | tANI_U32 wlan_hdd_tdls_discovery_sent_cnt(hdd_context_t *pHddCtx) |
| 2574 | { |
| 2575 | hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL; |
| 2576 | hdd_adapter_t *pAdapter = NULL; |
| 2577 | tdlsCtx_t *pHddTdlsCtx = NULL; |
| 2578 | VOS_STATUS status = 0; |
| 2579 | tANI_U32 count = 0; |
| 2580 | |
| 2581 | status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode ); |
| 2582 | while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status ) |
| 2583 | { |
| 2584 | pAdapter = pAdapterNode->pAdapter; |
| 2585 | |
Hoonki Lee | a6d49be | 2013-04-05 09:43:25 -0700 | [diff] [blame] | 2586 | pHddTdlsCtx = WLAN_HDD_GET_TDLS_CTX_PTR(pAdapter); |
| 2587 | if (NULL != pHddTdlsCtx) |
Gopichand Nakkala | ccd3a38 | 2013-03-19 13:56:10 -0700 | [diff] [blame] | 2588 | { |
Hoonki Lee | a6d49be | 2013-04-05 09:43:25 -0700 | [diff] [blame] | 2589 | count = count + pHddTdlsCtx->discovery_sent_cnt; |
Gopichand Nakkala | ccd3a38 | 2013-03-19 13:56:10 -0700 | [diff] [blame] | 2590 | } |
| 2591 | status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 2592 | pAdapterNode = pNext; |
| 2593 | } |
| 2594 | return count; |
| 2595 | } |
| 2596 | |
Gopichand Nakkala | 34d1b06 | 2013-03-19 15:28:33 -0700 | [diff] [blame] | 2597 | void wlan_hdd_tdls_check_power_save_prohibited(hdd_adapter_t *pAdapter) |
Gopichand Nakkala | ccd3a38 | 2013-03-19 13:56:10 -0700 | [diff] [blame] | 2598 | { |
Hanumantha Reddy Pothula | da0fe36 | 2015-02-27 18:37:03 +0530 | [diff] [blame] | 2599 | tdlsCtx_t *pHddTdlsCtx = NULL; |
| 2600 | hdd_context_t *pHddCtx = NULL; |
Chandrasekaran, Manishekar | 41b8e1f | 2015-03-10 13:30:28 +0530 | [diff] [blame] | 2601 | |
Hanumantha Reddy Pothula | da0fe36 | 2015-02-27 18:37:03 +0530 | [diff] [blame] | 2602 | |
| 2603 | if ((NULL == pAdapter) || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic)) |
| 2604 | { |
| 2605 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2606 | FL("invalid pAdapter: %p"), pAdapter); |
Chandrasekaran, Manishekar | 41b8e1f | 2015-03-10 13:30:28 +0530 | [diff] [blame] | 2607 | return; |
| 2608 | } |
| 2609 | |
| 2610 | pHddTdlsCtx = WLAN_HDD_GET_TDLS_CTX_PTR(pAdapter); |
| 2611 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
Gopichand Nakkala | ccd3a38 | 2013-03-19 13:56:10 -0700 | [diff] [blame] | 2612 | |
| 2613 | if ((NULL == pHddTdlsCtx) || (NULL == pHddCtx)) |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 2614 | { |
| 2615 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2616 | FL(" pHddCtx or pHddTdlsCtx points to NULL")); |
Gopichand Nakkala | ccd3a38 | 2013-03-19 13:56:10 -0700 | [diff] [blame] | 2617 | return; |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 2618 | } |
Gopichand Nakkala | ccd3a38 | 2013-03-19 13:56:10 -0700 | [diff] [blame] | 2619 | |
| 2620 | if ((0 == pHddCtx->connected_peer_count) && |
| 2621 | (0 == wlan_hdd_tdls_discovery_sent_cnt(pHddCtx))) |
| 2622 | { |
| 2623 | sme_SetTdlsPowerSaveProhibited(WLAN_HDD_GET_HAL_CTX(pHddTdlsCtx->pAdapter), 0); |
| 2624 | return; |
| 2625 | } |
| 2626 | sme_SetTdlsPowerSaveProhibited(WLAN_HDD_GET_HAL_CTX(pHddTdlsCtx->pAdapter), 1); |
| 2627 | return; |
| 2628 | } |
Hoonki Lee | 93e67ff | 2013-03-19 15:49:25 -0700 | [diff] [blame] | 2629 | |
| 2630 | void wlan_hdd_tdls_free_scan_request (tdls_scan_context_t *tdls_scan_ctx) |
| 2631 | { |
| 2632 | if (NULL == tdls_scan_ctx) |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 2633 | { |
| 2634 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2635 | FL("tdls_scan_ctx is NULL")); |
Hoonki Lee | 93e67ff | 2013-03-19 15:49:25 -0700 | [diff] [blame] | 2636 | return; |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 2637 | } |
Hoonki Lee | 93e67ff | 2013-03-19 15:49:25 -0700 | [diff] [blame] | 2638 | |
Gopichand Nakkala | 3046fc9 | 2013-03-23 13:56:43 -0700 | [diff] [blame] | 2639 | tdls_scan_ctx->attempt = 0; |
Hoonki Lee | fb8df67 | 2013-04-10 18:20:34 -0700 | [diff] [blame] | 2640 | tdls_scan_ctx->reject = 0; |
Gopichand Nakkala | 3046fc9 | 2013-03-23 13:56:43 -0700 | [diff] [blame] | 2641 | tdls_scan_ctx->magic = 0; |
Hoonki Lee | 93e67ff | 2013-03-19 15:49:25 -0700 | [diff] [blame] | 2642 | tdls_scan_ctx->scan_request = NULL; |
| 2643 | return; |
| 2644 | } |
| 2645 | |
| 2646 | int wlan_hdd_tdls_copy_scan_context(hdd_context_t *pHddCtx, |
| 2647 | struct wiphy *wiphy, |
| 2648 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0)) |
| 2649 | struct net_device *dev, |
| 2650 | #endif |
| 2651 | struct cfg80211_scan_request *request) |
| 2652 | { |
| 2653 | tdls_scan_context_t *scan_ctx; |
| 2654 | |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 2655 | ENTER(); |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 2656 | if(0 != (wlan_hdd_validate_context(pHddCtx))) |
| 2657 | { |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 2658 | return 0; |
| 2659 | } |
Hoonki Lee | 93e67ff | 2013-03-19 15:49:25 -0700 | [diff] [blame] | 2660 | |
| 2661 | scan_ctx = &pHddCtx->tdls_scan_ctxt; |
| 2662 | |
| 2663 | scan_ctx->wiphy = wiphy; |
| 2664 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0)) |
| 2665 | scan_ctx->dev = dev; |
| 2666 | #endif |
| 2667 | |
| 2668 | scan_ctx->scan_request = request; |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 2669 | |
| 2670 | EXIT(); |
Hoonki Lee | 93e67ff | 2013-03-19 15:49:25 -0700 | [diff] [blame] | 2671 | return 0; |
| 2672 | } |
| 2673 | |
Hoonki Lee | 93e67ff | 2013-03-19 15:49:25 -0700 | [diff] [blame] | 2674 | static void wlan_hdd_tdls_scan_init_work(hdd_context_t *pHddCtx, |
| 2675 | struct wiphy *wiphy, |
| 2676 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0)) |
| 2677 | struct net_device *dev, |
| 2678 | #endif |
| 2679 | struct cfg80211_scan_request *request, |
| 2680 | unsigned long delay) |
| 2681 | { |
| 2682 | if (TDLS_CTX_MAGIC != pHddCtx->tdls_scan_ctxt.magic) |
| 2683 | { |
| 2684 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0)) |
| 2685 | wlan_hdd_tdls_copy_scan_context(pHddCtx, wiphy, dev, request); |
| 2686 | #else |
| 2687 | wlan_hdd_tdls_copy_scan_context(pHddCtx, wiphy, request); |
| 2688 | #endif |
| 2689 | pHddCtx->tdls_scan_ctxt.attempt = 0; |
| 2690 | pHddCtx->tdls_scan_ctxt.magic = TDLS_CTX_MAGIC; |
| 2691 | } |
Hoonki Lee | 93e67ff | 2013-03-19 15:49:25 -0700 | [diff] [blame] | 2692 | schedule_delayed_work(&pHddCtx->tdls_scan_ctxt.tdls_scan_work, delay); |
| 2693 | } |
| 2694 | |
| 2695 | /* return negative = caller should stop and return error code immediately |
| 2696 | return 0 = caller should stop and return success immediately |
| 2697 | return 1 = caller can continue to scan |
| 2698 | */ |
| 2699 | int wlan_hdd_tdls_scan_callback (hdd_adapter_t *pAdapter, |
| 2700 | struct wiphy *wiphy, |
| 2701 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0)) |
| 2702 | struct net_device *dev, |
| 2703 | #endif |
| 2704 | struct cfg80211_scan_request *request) |
| 2705 | { |
Hoonki Lee | 93e67ff | 2013-03-19 15:49:25 -0700 | [diff] [blame] | 2706 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 2707 | u16 connectedTdlsPeers; |
Pradeep Reddy POTTETI | edaeb5f | 2014-05-22 23:34:41 +0530 | [diff] [blame] | 2708 | hddTdlsPeer_t *curr_peer, *connected_peer; |
Hoonki Lee | 93e67ff | 2013-03-19 15:49:25 -0700 | [diff] [blame] | 2709 | unsigned long delay; |
Pradeep Reddy POTTETI | edaeb5f | 2014-05-22 23:34:41 +0530 | [diff] [blame] | 2710 | hdd_config_t *cfg_param = pHddCtx->cfg_ini; |
Hoonki Lee | 93e67ff | 2013-03-19 15:49:25 -0700 | [diff] [blame] | 2711 | |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 2712 | ENTER(); |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 2713 | if(0 != (wlan_hdd_validate_context(pHddCtx))) |
| 2714 | { |
Hoonki Lee | 93e67ff | 2013-03-19 15:49:25 -0700 | [diff] [blame] | 2715 | return 0; |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 2716 | } |
Hoonki Lee | 93e67ff | 2013-03-19 15:49:25 -0700 | [diff] [blame] | 2717 | |
| 2718 | /* if tdls is not enabled, then continue scan */ |
Pradeep Reddy POTTETI | f0569d7 | 2014-12-13 16:54:03 +0530 | [diff] [blame] | 2719 | if ((eTDLS_SUPPORT_NOT_ENABLED == pHddCtx->tdls_mode) || |
| 2720 | (pHddCtx->is_tdls_btc_enabled == FALSE)) |
Hoonki Lee | 93e67ff | 2013-03-19 15:49:25 -0700 | [diff] [blame] | 2721 | return 1; |
Pradeep Reddy POTTETI | 9db32f0 | 2015-01-29 15:22:54 +0530 | [diff] [blame] | 2722 | curr_peer = wlan_hdd_tdls_is_progress(pHddCtx, NULL, 0, TRUE); |
Hoonki Lee | fb8df67 | 2013-04-10 18:20:34 -0700 | [diff] [blame] | 2723 | if (NULL != curr_peer) |
Hoonki Lee | 93e67ff | 2013-03-19 15:49:25 -0700 | [diff] [blame] | 2724 | { |
Hoonki Lee | fb8df67 | 2013-04-10 18:20:34 -0700 | [diff] [blame] | 2725 | if (pHddCtx->tdls_scan_ctxt.reject++ >= TDLS_MAX_SCAN_REJECT) |
| 2726 | { |
| 2727 | pHddCtx->tdls_scan_ctxt.reject = 0; |
Masti, Narayanraddi | 34e0e56 | 2015-03-05 18:23:03 +0530 | [diff] [blame] | 2728 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Hoonki Lee | fb8df67 | 2013-04-10 18:20:34 -0700 | [diff] [blame] | 2729 | "%s: " MAC_ADDRESS_STR ". scan rejected %d. force it to idle", |
| 2730 | __func__, MAC_ADDR_ARRAY (curr_peer->peerMac), pHddCtx->tdls_scan_ctxt.reject); |
| 2731 | |
Atul Mittal | 115287b | 2014-07-08 13:26:33 +0530 | [diff] [blame] | 2732 | wlan_hdd_tdls_set_peer_link_status (curr_peer, |
| 2733 | eTDLS_LINK_IDLE, |
| 2734 | eTDLS_LINK_UNSPECIFIED); |
Hoonki Lee | fb8df67 | 2013-04-10 18:20:34 -0700 | [diff] [blame] | 2735 | return 1; |
| 2736 | } |
Masti, Narayanraddi | 34e0e56 | 2015-03-05 18:23:03 +0530 | [diff] [blame] | 2737 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Hoonki Lee | fb8df67 | 2013-04-10 18:20:34 -0700 | [diff] [blame] | 2738 | "%s: tdls in progress. scan rejected %d", |
| 2739 | __func__, pHddCtx->tdls_scan_ctxt.reject); |
Hoonki Lee | 93e67ff | 2013-03-19 15:49:25 -0700 | [diff] [blame] | 2740 | return -EBUSY; |
| 2741 | } |
| 2742 | |
| 2743 | /* tdls teardown is ongoing */ |
| 2744 | if (eTDLS_SUPPORT_DISABLED == pHddCtx->tdls_mode) |
| 2745 | { |
| 2746 | connectedTdlsPeers = wlan_hdd_tdlsConnectedPeers(pAdapter); |
| 2747 | if (connectedTdlsPeers && (pHddCtx->tdls_scan_ctxt.attempt < TDLS_MAX_SCAN_SCHEDULE)) |
| 2748 | { |
| 2749 | delay = (unsigned long)(TDLS_DELAY_SCAN_PER_CONNECTION*connectedTdlsPeers); |
Masti, Narayanraddi | 34e0e56 | 2015-03-05 18:23:03 +0530 | [diff] [blame] | 2750 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Hoonki Lee | 93e67ff | 2013-03-19 15:49:25 -0700 | [diff] [blame] | 2751 | "%s: tdls disabled, but still connected_peers %d attempt %d. schedule scan %lu msec", |
| 2752 | __func__, connectedTdlsPeers, pHddCtx->tdls_scan_ctxt.attempt, delay); |
| 2753 | |
| 2754 | wlan_hdd_tdls_scan_init_work (pHddCtx, wiphy, |
| 2755 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0)) |
| 2756 | dev, |
| 2757 | #endif |
| 2758 | request, |
| 2759 | msecs_to_jiffies(delay)); |
| 2760 | /* scan should not continue */ |
| 2761 | return 0; |
| 2762 | } |
| 2763 | /* no connected peer or max retry reached, scan continue */ |
Masti, Narayanraddi | 34e0e56 | 2015-03-05 18:23:03 +0530 | [diff] [blame] | 2764 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Hoonki Lee | 93e67ff | 2013-03-19 15:49:25 -0700 | [diff] [blame] | 2765 | "%s: tdls disabled. connected_peers %d attempt %d. scan allowed", |
| 2766 | __func__, connectedTdlsPeers, pHddCtx->tdls_scan_ctxt.attempt); |
| 2767 | return 1; |
| 2768 | } |
Agarwal Ashish | ef54a18 | 2014-12-16 15:07:31 +0530 | [diff] [blame] | 2769 | |
| 2770 | /* if fEnableTDLSScan flag is 1 ; driverwill allow scan even if |
| 2771 | * peer station is not buffer STA capable |
| 2772 | * |
| 2773 | * RX: If there is any RX activity, device will lose RX packets, |
| 2774 | * as peer will not be aware that device is off channel. |
| 2775 | * TX: TX is stopped whenever device initiate scan. |
| 2776 | */ |
| 2777 | if (pHddCtx->cfg_ini->fEnableTDLSScan == 1) |
| 2778 | { |
Masti, Narayanraddi | 34e0e56 | 2015-03-05 18:23:03 +0530 | [diff] [blame] | 2779 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Agarwal Ashish | ef54a18 | 2014-12-16 15:07:31 +0530 | [diff] [blame] | 2780 | FL("Allow SCAN in all TDLS cases")); |
| 2781 | return 1; |
| 2782 | } |
| 2783 | |
Hoonki Lee | 93e67ff | 2013-03-19 15:49:25 -0700 | [diff] [blame] | 2784 | /* while tdls is up, first time scan */ |
| 2785 | else if (eTDLS_SUPPORT_ENABLED == pHddCtx->tdls_mode || |
| 2786 | eTDLS_SUPPORT_EXPLICIT_TRIGGER_ONLY == pHddCtx->tdls_mode) |
| 2787 | { |
Hoonki Lee | 93e67ff | 2013-03-19 15:49:25 -0700 | [diff] [blame] | 2788 | connectedTdlsPeers = wlan_hdd_tdlsConnectedPeers(pAdapter); |
Pradeep Reddy POTTETI | edaeb5f | 2014-05-22 23:34:41 +0530 | [diff] [blame] | 2789 | |
| 2790 | /* check the TDLS link and Scan coexistance Capability */ |
| 2791 | if ( (TRUE == pHddCtx->cfg_ini->fEnableTDLSScanCoexSupport) && |
| 2792 | (TRUE == sme_IsFeatureSupportedByFW(TDLS_SCAN_COEXISTENCE)) && |
| 2793 | (connectedTdlsPeers == 1) ) |
| 2794 | { |
| 2795 | /* get connected peer information */ |
Pradeep Reddy POTTETI | e309c15 | 2015-02-06 13:21:07 +0530 | [diff] [blame] | 2796 | connected_peer = wlan_hdd_tdls_get_connected_peer(pAdapter); |
Pradeep Reddy POTTETI | edaeb5f | 2014-05-22 23:34:41 +0530 | [diff] [blame] | 2797 | if (NULL == connected_peer) { |
| 2798 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 2799 | "%s: Invalid connected_peer, Continue Scanning", __func__); |
| 2800 | /* scan should continue */ |
| 2801 | return 1; |
| 2802 | } |
Masti, Narayanraddi | 34e0e56 | 2015-03-05 18:23:03 +0530 | [diff] [blame] | 2803 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Pradeep Reddy POTTETI | edaeb5f | 2014-05-22 23:34:41 +0530 | [diff] [blame] | 2804 | ("%s: TDLS Scan Co-exist supported connectedTdlsPeers =%d buffersta =%d"), |
| 2805 | __func__,connectedTdlsPeers,connected_peer->isBufSta); |
| 2806 | |
| 2807 | if (connected_peer->isBufSta) |
| 2808 | { |
| 2809 | pHddCtx->isTdlsScanCoexistence = TRUE; |
| 2810 | if ((cfg_param->dynSplitscan) && (!pHddCtx->issplitscan_enabled)) |
| 2811 | { |
| 2812 | pHddCtx->issplitscan_enabled = TRUE; |
| 2813 | sme_enable_disable_split_scan( |
| 2814 | WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 2815 | cfg_param->nNumStaChanCombinedConc, |
| 2816 | cfg_param->nNumP2PChanCombinedConc); |
| 2817 | } |
Masti, Narayanraddi | 34e0e56 | 2015-03-05 18:23:03 +0530 | [diff] [blame] | 2818 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Pradeep Reddy POTTETI | edaeb5f | 2014-05-22 23:34:41 +0530 | [diff] [blame] | 2819 | ("%s:%d TDLS Scan Co-exist supported splitscan_enabled =%d "), |
| 2820 | __func__, __LINE__, pHddCtx->issplitscan_enabled); |
| 2821 | return 1; |
| 2822 | } |
| 2823 | |
| 2824 | } |
| 2825 | else |
| 2826 | { |
| 2827 | /* Throughput Monitor shall disable the split scan when |
| 2828 | * TDLS scan coexistance is disabled.At this point of time |
| 2829 | * since TDLS scan coexistance is not meeting the criteria |
| 2830 | * to be operational, explicitly make it false to enable |
| 2831 | * throughput monitor takes the control of split scan. |
| 2832 | */ |
| 2833 | pHddCtx->isTdlsScanCoexistence = FALSE; |
| 2834 | } |
Masti, Narayanraddi | 34e0e56 | 2015-03-05 18:23:03 +0530 | [diff] [blame] | 2835 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Pradeep Reddy POTTETI | edaeb5f | 2014-05-22 23:34:41 +0530 | [diff] [blame] | 2836 | ("%s: TDLS Scan Co-exist not supported connectedTdlsPeers =%d" |
| 2837 | " TDLSScanCoexSupport param =%d TDLS_SCAN_COEXISTENCE =%d"), |
| 2838 | __func__, connectedTdlsPeers, |
| 2839 | pHddCtx->cfg_ini->fEnableTDLSScanCoexSupport, |
| 2840 | sme_IsFeatureSupportedByFW(TDLS_SCAN_COEXISTENCE)); |
| 2841 | |
Atul Mittal | 5803b34 | 2014-09-04 15:31:19 +0530 | [diff] [blame] | 2842 | /* disable implicit trigger logic & tdls operatoin */ |
| 2843 | wlan_hdd_tdls_set_mode(pHddCtx, eTDLS_SUPPORT_DISABLED, FALSE); |
Pradeep Reddy POTTETI | edaeb5f | 2014-05-22 23:34:41 +0530 | [diff] [blame] | 2844 | /* fall back to the implementation of teardown the peers on the scan |
| 2845 | * when the number of connected peers are more than one. TDLS Scan |
| 2846 | * coexistance feature is exercised only when a single peer is |
| 2847 | * connected and the DUT shall not advertize the Buffer Sta capability, |
| 2848 | * so that the peer shall not go to the TDLS power save |
| 2849 | */ |
| 2850 | |
Hoonki Lee | 93e67ff | 2013-03-19 15:49:25 -0700 | [diff] [blame] | 2851 | if (connectedTdlsPeers) |
| 2852 | { |
| 2853 | tANI_U8 staIdx; |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 2854 | hddTdlsPeer_t *curr_peer; |
Hoonki Lee | 93e67ff | 2013-03-19 15:49:25 -0700 | [diff] [blame] | 2855 | |
| 2856 | for (staIdx = 0; staIdx < HDD_MAX_NUM_TDLS_STA; staIdx++) |
| 2857 | { |
| 2858 | if (pHddCtx->tdlsConnInfo[staIdx].staId) |
| 2859 | { |
Masti, Narayanraddi | 34e0e56 | 2015-03-05 18:23:03 +0530 | [diff] [blame] | 2860 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 2861 | ("%s: indicate TDLS teardown (staId %d)"), __func__, pHddCtx->tdlsConnInfo[staIdx].staId) ; |
Hoonki Lee | 93e67ff | 2013-03-19 15:49:25 -0700 | [diff] [blame] | 2862 | |
| 2863 | #ifdef CONFIG_TDLS_IMPLICIT |
Hoonki Lee | a6d49be | 2013-04-05 09:43:25 -0700 | [diff] [blame] | 2864 | curr_peer = wlan_hdd_tdls_find_all_peer(pHddCtx, pHddCtx->tdlsConnInfo[staIdx].peerMac.bytes); |
| 2865 | if(curr_peer) |
| 2866 | wlan_hdd_tdls_indicate_teardown(curr_peer->pHddTdlsCtx->pAdapter, curr_peer, eSIR_MAC_TDLS_TEARDOWN_UNSPEC_REASON); |
Hoonki Lee | 93e67ff | 2013-03-19 15:49:25 -0700 | [diff] [blame] | 2867 | #endif |
| 2868 | } |
| 2869 | } |
| 2870 | /* schedule scan */ |
| 2871 | delay = (unsigned long)(TDLS_DELAY_SCAN_PER_CONNECTION*connectedTdlsPeers); |
| 2872 | |
Masti, Narayanraddi | 34e0e56 | 2015-03-05 18:23:03 +0530 | [diff] [blame] | 2873 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Hoonki Lee | 93e67ff | 2013-03-19 15:49:25 -0700 | [diff] [blame] | 2874 | "%s: tdls enabled (mode %d), connected_peers %d. schedule scan %lu msec", |
| 2875 | __func__, pHddCtx->tdls_mode, wlan_hdd_tdlsConnectedPeers(pAdapter), |
| 2876 | delay); |
| 2877 | |
| 2878 | wlan_hdd_tdls_scan_init_work (pHddCtx, wiphy, |
| 2879 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0)) |
| 2880 | dev, |
| 2881 | #endif |
| 2882 | request, |
| 2883 | msecs_to_jiffies(delay)); |
| 2884 | /* scan should not continue */ |
| 2885 | return 0; |
| 2886 | } |
| 2887 | /* no connected peer, scan continue */ |
Masti, Narayanraddi | 34e0e56 | 2015-03-05 18:23:03 +0530 | [diff] [blame] | 2888 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Hoonki Lee | 93e67ff | 2013-03-19 15:49:25 -0700 | [diff] [blame] | 2889 | "%s: tdls_mode %d, and no tdls connection. scan allowed", |
| 2890 | __func__, pHddCtx->tdls_mode); |
| 2891 | } |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 2892 | EXIT(); |
Hoonki Lee | 93e67ff | 2013-03-19 15:49:25 -0700 | [diff] [blame] | 2893 | return 1; |
| 2894 | } |
| 2895 | |
| 2896 | void wlan_hdd_tdls_scan_done_callback(hdd_adapter_t *pAdapter) |
| 2897 | { |
| 2898 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
Hoonki Lee | 93e67ff | 2013-03-19 15:49:25 -0700 | [diff] [blame] | 2899 | |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 2900 | ENTER(); |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 2901 | if(0 != (wlan_hdd_validate_context(pHddCtx))) |
| 2902 | { |
Hoonki Lee | 93e67ff | 2013-03-19 15:49:25 -0700 | [diff] [blame] | 2903 | return; |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 2904 | } |
Hoonki Lee | 93e67ff | 2013-03-19 15:49:25 -0700 | [diff] [blame] | 2905 | |
Pradeep Reddy POTTETI | c7822df | 2015-02-19 20:15:41 +0530 | [diff] [blame] | 2906 | /* if tdls is not enabled or BtCoex is on then don't revert tdls mode */ |
| 2907 | if ((eTDLS_SUPPORT_NOT_ENABLED == pHddCtx->tdls_mode) || |
Chandrasekaran, Manishekar | 0de84dc | 2015-03-10 15:12:34 +0530 | [diff] [blame] | 2908 | (pHddCtx->is_tdls_btc_enabled == FALSE)) { |
| 2909 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to revert: Mode=%d, BTC enabled=%d"), |
| 2910 | pHddCtx->tdls_mode, pHddCtx->is_tdls_btc_enabled); |
Pradeep Reddy POTTETI | c7822df | 2015-02-19 20:15:41 +0530 | [diff] [blame] | 2911 | return; |
Chandrasekaran, Manishekar | 0de84dc | 2015-03-10 15:12:34 +0530 | [diff] [blame] | 2912 | } |
Sunil Dutt | 41de4e2 | 2013-11-14 18:09:02 +0530 | [diff] [blame] | 2913 | |
Hoonki Lee | 93e67ff | 2013-03-19 15:49:25 -0700 | [diff] [blame] | 2914 | /* free allocated memory at scan time */ |
Gopichand Nakkala | 3046fc9 | 2013-03-23 13:56:43 -0700 | [diff] [blame] | 2915 | wlan_hdd_tdls_free_scan_request (&pHddCtx->tdls_scan_ctxt); |
Hoonki Lee | 93e67ff | 2013-03-19 15:49:25 -0700 | [diff] [blame] | 2916 | |
| 2917 | /* if tdls was enabled before scan, re-enable tdls mode */ |
| 2918 | if(eTDLS_SUPPORT_ENABLED == pHddCtx->tdls_mode_last || |
| 2919 | eTDLS_SUPPORT_EXPLICIT_TRIGGER_ONLY == pHddCtx->tdls_mode_last) |
| 2920 | { |
Masti, Narayanraddi | 34e0e56 | 2015-03-05 18:23:03 +0530 | [diff] [blame] | 2921 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Hoonki Lee | 93e67ff | 2013-03-19 15:49:25 -0700 | [diff] [blame] | 2922 | ("%s: revert tdls mode %d"), __func__, pHddCtx->tdls_mode_last); |
| 2923 | |
Gopichand Nakkala | dcbcf4e | 2013-03-23 14:32:39 -0700 | [diff] [blame] | 2924 | wlan_hdd_tdls_set_mode(pHddCtx, pHddCtx->tdls_mode_last, FALSE); |
Hoonki Lee | 93e67ff | 2013-03-19 15:49:25 -0700 | [diff] [blame] | 2925 | } |
| 2926 | wlan_hdd_tdls_check_bmps(pAdapter); |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 2927 | |
| 2928 | EXIT(); |
Hoonki Lee | 93e67ff | 2013-03-19 15:49:25 -0700 | [diff] [blame] | 2929 | } |
Gopichand Nakkala | 3046fc9 | 2013-03-23 13:56:43 -0700 | [diff] [blame] | 2930 | |
| 2931 | void wlan_hdd_tdls_timer_restart(hdd_adapter_t *pAdapter, |
| 2932 | vos_timer_t *timer, |
| 2933 | v_U32_t expirationTime) |
| 2934 | { |
| 2935 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 2936 | |
| 2937 | if (NULL == pHddStaCtx) |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 2938 | { |
| 2939 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2940 | FL("pHddStaCtx is NULL")); |
Gopichand Nakkala | 3046fc9 | 2013-03-23 13:56:43 -0700 | [diff] [blame] | 2941 | return; |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 2942 | } |
Gopichand Nakkala | 3046fc9 | 2013-03-23 13:56:43 -0700 | [diff] [blame] | 2943 | |
| 2944 | /* Check whether driver load unload is in progress */ |
| 2945 | if(vos_is_load_unload_in_progress( VOS_MODULE_ID_VOSS, NULL)) |
| 2946 | { |
| 2947 | VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR, |
| 2948 | "%s: Driver load/unload is in progress.", __func__); |
| 2949 | return; |
| 2950 | } |
| 2951 | |
| 2952 | if (hdd_connIsConnected(pHddStaCtx)) |
| 2953 | { |
| 2954 | vos_timer_stop(timer); |
| 2955 | vos_timer_start(timer, expirationTime); |
| 2956 | } |
| 2957 | } |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 2958 | void wlan_hdd_tdls_indicate_teardown(hdd_adapter_t *pAdapter, |
| 2959 | hddTdlsPeer_t *curr_peer, |
| 2960 | tANI_U16 reason) |
| 2961 | { |
Pradeep Reddy POTTETI | 8a62313 | 2014-06-26 16:07:06 +0530 | [diff] [blame] | 2962 | hdd_context_t *pHddCtx; |
Pradeep Reddy POTTETI | edaeb5f | 2014-05-22 23:34:41 +0530 | [diff] [blame] | 2963 | |
Hanumantha Reddy Pothula | da0fe36 | 2015-02-27 18:37:03 +0530 | [diff] [blame] | 2964 | if ((NULL == pAdapter || WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic) || |
| 2965 | (NULL == curr_peer)) |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 2966 | { |
| 2967 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2968 | FL("parameters passed are invalid")); |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 2969 | return; |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 2970 | } |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 2971 | |
Pradeep Reddy POTTETI | 8a62313 | 2014-06-26 16:07:06 +0530 | [diff] [blame] | 2972 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 2973 | |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 2974 | if (eTDLS_LINK_CONNECTED != curr_peer->link_status) |
| 2975 | return; |
| 2976 | |
Pradeep Reddy POTTETI | edaeb5f | 2014-05-22 23:34:41 +0530 | [diff] [blame] | 2977 | /* Throughput Monitor shall disable the split scan when |
| 2978 | * TDLS scan coexistance is disabled.At this point of time |
| 2979 | * since TDLS scan coexistance is not meeting the criteria |
| 2980 | * to be operational, explicitly make it false to enable |
| 2981 | * throughput monitor takes the control of split scan. |
| 2982 | */ |
Pradeep Reddy POTTETI | 8a62313 | 2014-06-26 16:07:06 +0530 | [diff] [blame] | 2983 | if (pHddCtx && (pHddCtx->isTdlsScanCoexistence == TRUE)) |
Pradeep Reddy POTTETI | edaeb5f | 2014-05-22 23:34:41 +0530 | [diff] [blame] | 2984 | { |
| 2985 | pHddCtx->isTdlsScanCoexistence = FALSE; |
| 2986 | } |
| 2987 | |
Atul Mittal | 115287b | 2014-07-08 13:26:33 +0530 | [diff] [blame] | 2988 | wlan_hdd_tdls_set_peer_link_status(curr_peer, |
| 2989 | eTDLS_LINK_TEARING, |
Atul Mittal | 271a765 | 2014-09-12 13:18:22 +0530 | [diff] [blame] | 2990 | eTDLS_LINK_UNSPECIFIED); |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 2991 | cfg80211_tdls_oper_request(pAdapter->dev, |
| 2992 | curr_peer->peerMac, |
| 2993 | NL80211_TDLS_TEARDOWN, |
| 2994 | reason, |
| 2995 | GFP_KERNEL); |
| 2996 | } |
Atul Mittal | 115287b | 2014-07-08 13:26:33 +0530 | [diff] [blame] | 2997 | |
| 2998 | |
| 2999 | /*EXT TDLS*/ |
| 3000 | int wlan_hdd_set_callback(hddTdlsPeer_t *curr_peer, |
| 3001 | cfg80211_exttdls_callback callback) |
| 3002 | { |
| 3003 | |
| 3004 | hdd_context_t *pHddCtx; |
| 3005 | hdd_adapter_t *pAdapter; |
| 3006 | |
| 3007 | if (!curr_peer) return -1; |
| 3008 | |
| 3009 | pAdapter = curr_peer->pHddTdlsCtx->pAdapter; |
| 3010 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 3011 | if ((NULL == pHddCtx)) return -1; |
| 3012 | |
| 3013 | mutex_lock(&pHddCtx->tdls_lock); |
| 3014 | |
| 3015 | curr_peer->state_change_notification = callback; |
| 3016 | |
| 3017 | mutex_unlock(&pHddCtx->tdls_lock); |
| 3018 | return 0; |
| 3019 | |
| 3020 | |
| 3021 | } |
| 3022 | |
| 3023 | void wlan_hdd_tdls_get_wifi_hal_state(hddTdlsPeer_t *curr_peer, |
| 3024 | tANI_S32 *state, |
| 3025 | tANI_S32 *reason) |
| 3026 | { |
| 3027 | *reason = curr_peer->reason; |
| 3028 | |
| 3029 | switch(curr_peer->link_status) |
| 3030 | { |
| 3031 | case eTDLS_LINK_IDLE: |
Atul Mittal | 115287b | 2014-07-08 13:26:33 +0530 | [diff] [blame] | 3032 | case eTDLS_LINK_DISCOVERED: |
| 3033 | *state = WIFI_TDLS_ENABLED; |
| 3034 | break; |
Atul Mittal | ad630e4 | 2014-10-07 19:19:14 +0530 | [diff] [blame] | 3035 | case eTDLS_LINK_DISCOVERING: |
Atul Mittal | 115287b | 2014-07-08 13:26:33 +0530 | [diff] [blame] | 3036 | case eTDLS_LINK_CONNECTING: |
| 3037 | *state = WIFI_TDLS_TRYING; |
| 3038 | break; |
| 3039 | case eTDLS_LINK_CONNECTED: |
Pradeep Reddy POTTETI | f3148e8 | 2015-04-16 12:10:33 +0530 | [diff] [blame] | 3040 | if (TRUE == curr_peer->isOffChannelEstablished) |
Pradeep Reddy POTTETI | 16d8333 | 2015-03-26 18:28:13 +0530 | [diff] [blame] | 3041 | { |
| 3042 | *state = WIFI_TDLS_ESTABLISHED_OFF_CHANNEL; |
| 3043 | } |
| 3044 | else |
| 3045 | { |
| 3046 | *state = WIFI_TDLS_ESTABLISHED; |
| 3047 | } |
Atul Mittal | 115287b | 2014-07-08 13:26:33 +0530 | [diff] [blame] | 3048 | break; |
| 3049 | case eTDLS_LINK_TEARING: |
| 3050 | *state = WIFI_TDLS_DROPPED; |
| 3051 | break; |
| 3052 | } |
| 3053 | |
| 3054 | } |
| 3055 | |
| 3056 | int wlan_hdd_tdls_get_status(hdd_adapter_t *pAdapter, |
| 3057 | tANI_U8* mac, |
| 3058 | tANI_S32 *state, |
| 3059 | tANI_S32 *reason) |
| 3060 | { |
| 3061 | |
| 3062 | hddTdlsPeer_t *curr_peer; |
Atul Mittal | a75fced | 2014-10-06 13:59:07 +0530 | [diff] [blame] | 3063 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
Atul Mittal | 115287b | 2014-07-08 13:26:33 +0530 | [diff] [blame] | 3064 | curr_peer = wlan_hdd_tdls_find_peer(pAdapter, mac, TRUE); |
| 3065 | if (curr_peer == NULL) |
| 3066 | { |
Atul Mittal | a75fced | 2014-10-06 13:59:07 +0530 | [diff] [blame] | 3067 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Atul Mittal | 115287b | 2014-07-08 13:26:33 +0530 | [diff] [blame] | 3068 | FL("curr_peer is NULL")); |
Atul Mittal | 115287b | 2014-07-08 13:26:33 +0530 | [diff] [blame] | 3069 | |
Atul Mittal | a75fced | 2014-10-06 13:59:07 +0530 | [diff] [blame] | 3070 | *state = WIFI_TDLS_DISABLED; |
| 3071 | *reason = eTDLS_LINK_UNSPECIFIED; |
| 3072 | } |
| 3073 | else |
| 3074 | { |
| 3075 | if (pHddCtx->cfg_ini->fTDLSExternalControl && |
| 3076 | (FALSE == curr_peer->isForcedPeer)) |
| 3077 | { |
| 3078 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3079 | FL("curr_peer is not Forced")); |
| 3080 | *state = WIFI_TDLS_DISABLED; |
| 3081 | *reason = eTDLS_LINK_UNSPECIFIED; |
| 3082 | } |
| 3083 | else |
| 3084 | { |
| 3085 | wlan_hdd_tdls_get_wifi_hal_state(curr_peer, state, reason); |
| 3086 | } |
| 3087 | } |
Atul Mittal | 115287b | 2014-07-08 13:26:33 +0530 | [diff] [blame] | 3088 | return (0); |
| 3089 | } |
| 3090 | |
Agarwal Ashish | ef54a18 | 2014-12-16 15:07:31 +0530 | [diff] [blame] | 3091 | int hdd_set_tdls_scan_type(hdd_adapter_t *pAdapter, |
| 3092 | tANI_U8 *ptr) |
| 3093 | { |
| 3094 | int tdls_scan_type; |
Hema Aparna Medicharla | 26b9804 | 2015-01-21 15:02:01 +0530 | [diff] [blame] | 3095 | hdd_context_t *pHddCtx; |
Agarwal Ashish | ef54a18 | 2014-12-16 15:07:31 +0530 | [diff] [blame] | 3096 | if (NULL == pAdapter) |
| 3097 | { |
| 3098 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3099 | "%s: pAdapter is NULL", __func__); |
| 3100 | return -EINVAL; |
| 3101 | } |
Hema Aparna Medicharla | 26b9804 | 2015-01-21 15:02:01 +0530 | [diff] [blame] | 3102 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
Agarwal Ashish | ef54a18 | 2014-12-16 15:07:31 +0530 | [diff] [blame] | 3103 | tdls_scan_type = ptr[9] - '0'; |
| 3104 | |
| 3105 | if (tdls_scan_type <= 2) |
| 3106 | { |
| 3107 | pHddCtx->cfg_ini->fEnableTDLSScan = tdls_scan_type; |
| 3108 | return 0; |
| 3109 | } |
| 3110 | else |
| 3111 | { |
| 3112 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3113 | " Wrong value is given for tdls_scan_type " |
| 3114 | " Making fEnableTDLSScan as 0 "); |
| 3115 | pHddCtx->cfg_ini->fEnableTDLSScan = 0; |
| 3116 | return -EINVAL; |
| 3117 | } |
| 3118 | } |
Mahesh A Saptasagar | 170b508 | 2015-02-16 18:50:54 +0530 | [diff] [blame] | 3119 | int wlan_hdd_validate_tdls_context(hdd_context_t *pHddCtx, |
| 3120 | tdlsCtx_t *pHddTdlsCtx) |
| 3121 | { |
| 3122 | VOS_STATUS status; |
| 3123 | int found = 0; |
| 3124 | hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL; |
| 3125 | hdd_adapter_t *pAdapter; |
Agarwal Ashish | ef54a18 | 2014-12-16 15:07:31 +0530 | [diff] [blame] | 3126 | |
Mahesh A Saptasagar | 170b508 | 2015-02-16 18:50:54 +0530 | [diff] [blame] | 3127 | if (NULL == pHddTdlsCtx) |
| 3128 | { |
| 3129 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3130 | FL("TDLS context is NULL")); |
| 3131 | return -EINVAL; |
| 3132 | } |
| 3133 | status = hdd_get_front_adapter(pHddCtx, &pAdapterNode); |
| 3134 | while (NULL != pAdapterNode && VOS_STATUS_SUCCESS == status) |
| 3135 | { |
| 3136 | pAdapter = pAdapterNode->pAdapter; |
| 3137 | if (NULL != pAdapter) |
| 3138 | { |
| 3139 | if (pHddTdlsCtx == pAdapter->sessionCtx.station.pHddTdlsCtx && |
| 3140 | (NULL != pHddTdlsCtx->pAdapter) && |
| 3141 | (WLAN_HDD_ADAPTER_MAGIC == pHddTdlsCtx->pAdapter->magic)) |
| 3142 | { |
| 3143 | found = 1; |
| 3144 | break; |
| 3145 | } |
| 3146 | } |
| 3147 | status = hdd_get_next_adapter (pHddCtx, pAdapterNode, &pNext); |
| 3148 | pAdapterNode = pNext; |
| 3149 | } |
| 3150 | if (found == 1) |
| 3151 | { |
| 3152 | return 0; |
| 3153 | } |
| 3154 | else |
| 3155 | { |
| 3156 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3157 | FL("TDLS context doesnot belongs to valid adapter")); |
| 3158 | return -EINVAL; |
| 3159 | } |
| 3160 | } |
Atul Mittal | 115287b | 2014-07-08 13:26:33 +0530 | [diff] [blame] | 3161 | /*EXT TDLS*/ |
| 3162 | |