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