blob: ca63678fb7c735043f6d49774c3b70dcc8fc9235 [file] [log] [blame]
Kiran V1ccee932012-12-12 14:49:46 -08001/*
Pradeep Reddy POTTETIc7822df2015-02-19 20:15:41 +05302 * Copyright (c) 2012-2015 The Linux Foundation. All rights reserved.
Kiet Lam842dad02014-02-18 18:44:02 -08003 *
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 Nakkala0c1331e2013-01-07 22:49:07 -080020 */
Kiet Lam842dad02014-02-18 18:44:02 -080021
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 V1ccee932012-12-12 14:49:46 -080028/**========================================================================
29
30 \file wlan_hdd_tdls.c
31
Chilam NG571c65a2013-01-19 12:27:36 +053032 \brief WLAN Host Device Driver implementation for TDLS
Kiran V1ccee932012-12-12 14:49:46 -080033
Kiran V1ccee932012-12-12 14:49:46 -080034 ========================================================================*/
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 NG571c65a2013-01-19 12:27:36 +053041#include <linux/list.h>
Kiran V1ccee932012-12-12 14:49:46 -080042#include <linux/etherdevice.h>
43#include <net/ieee80211_radiotap.h>
44#include "wlan_hdd_tdls.h"
Chilam NG571c65a2013-01-19 12:27:36 +053045#include "wlan_hdd_cfg80211.h"
Masti, Narayanraddi1fb32a92015-06-29 13:14:06 +053046#include "wlan_hdd_assoc.h"
47#include "sme_Api.h"
Mahesh A Saptasagar8b231b32014-08-11 11:58:15 +053048#include "vos_sched.h"
Chilam NG571c65a2013-01-19 12:27:36 +053049
Gopichand Nakkala4327a152013-03-04 23:22:42 -080050static tANI_S32 wlan_hdd_get_tdls_discovery_peer_cnt(tdlsCtx_t *pHddTdlsCtx);
51static tANI_S32 wlan_hdd_tdls_peer_reset_discovery_processed(tdlsCtx_t *pHddTdlsCtx);
52static void wlan_hdd_tdls_timers_destroy(tdlsCtx_t *pHddTdlsCtx);
Madan Mohan Koyyalamudi693275b2013-07-22 19:14:09 +053053static void wlan_hdd_tdls_peer_timers_destroy(tdlsCtx_t *pHddTdlsCtx);
Sunil Dutt41de4e22013-11-14 18:09:02 +053054int wpa_tdls_is_allowed_force_peer(tdlsCtx_t *pHddTdlsCtx, u8 *mac);
Hoonki Leed37cbb32013-04-20 00:31:14 -070055#ifdef CONFIG_TDLS_IMPLICIT
Pradeep Reddy POTTETI9db32f02015-01-29 15:22:54 +053056static void wlan_hdd_tdls_implicit_send_discovery_request(tdlsCtx_t *pHddTdlsCtx);
Hoonki Leed37cbb32013-04-20 00:31:14 -070057#endif
Chilam NG571c65a2013-01-19 12:27:36 +053058
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053059static u8 wlan_hdd_tdls_hash_key (
60#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
61 const u8 *mac
62#else
63 u8 *mac
64#endif
65 )
Hoonki Leef63df0d2013-01-16 19:29:14 -080066{
67 int i;
Hoonki Lee387663d2013-02-05 18:08:43 -080068 u8 key = 0;
69
70 for (i = 0; i < 6; i++)
71 key ^= mac[i];
72
73 return key;
74}
75
Masti, Narayanraddifdde4d02015-04-16 14:41:51 +053076/**
77 * wlan_hdd_tdls_disable_offchan_and_teardown_links - Disable offchannel
78 * and teardown TDLS links
79 * @hddCtx : pointer to hdd context
80 *
81 * Return: None
82 */
83void wlan_hdd_tdls_disable_offchan_and_teardown_links(hdd_context_t *hddctx)
84{
85 u16 connected_tdls_peers = 0;
Masti, Narayanraddi1fb32a92015-06-29 13:14:06 +053086 u8 staIdx;
Masti, Narayanraddi471e9382015-07-23 18:51:29 +053087 hddTdlsPeer_t *curr_peer = NULL;
Masti, Narayanraddifdde4d02015-04-16 14:41:51 +053088 hdd_adapter_t *adapter = NULL;
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053089 bool tdls_unlock = FALSE;
Masti, Narayanraddifdde4d02015-04-16 14:41:51 +053090
91 if (eTDLS_SUPPORT_NOT_ENABLED == hddctx->tdls_mode) {
92 hddLog(LOG1, FL("TDLS mode is disabled OR not enabled in FW"));
93 return ;
94 }
95
96 adapter = hdd_get_adapter(hddctx, WLAN_HDD_INFRA_STATION);
97
98 if (adapter == NULL) {
99 hddLog(LOGE, FL("Station Adapter Not Found"));
Masti, Narayanraddi70e5b472015-08-04 12:54:16 +0530100 goto done;
Masti, Narayanraddifdde4d02015-04-16 14:41:51 +0530101 }
102
103 connected_tdls_peers = wlan_hdd_tdlsConnectedPeers(adapter);
Masti, Narayanraddi1fb32a92015-06-29 13:14:06 +0530104 if (!connected_tdls_peers) {
Masti, Narayanraddi70e5b472015-08-04 12:54:16 +0530105 hddLog(LOG1, FL("No TDLS connected peers to delete TDLS peers"));
106 goto done;
Masti, Narayanraddi1fb32a92015-06-29 13:14:06 +0530107 }
Masti, Narayanraddifdde4d02015-04-16 14:41:51 +0530108
Masti, Narayanraddi471e9382015-07-23 18:51:29 +0530109 /* TDLS is not supported in case of concurrency
110 * Disable TDLS Offchannel to avoid more than two concurrent channels.
111 */
112 if (connected_tdls_peers == 1) {
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +0530113 tSirMacAddr peer_mac;
114 int32_t channel;
115
116 mutex_lock(&hddctx->tdls_lock);
Masti, Narayanraddi471e9382015-07-23 18:51:29 +0530117 curr_peer = wlan_hdd_tdls_get_connected_peer(adapter);
118 if (curr_peer && (curr_peer->isOffChannelConfigured == TRUE)) {
119 hddLog(LOG1, FL("%s: Concurrency detected, Disable "
120 "TDLS channel switch"), __func__);
121 curr_peer->isOffChannelEstablished = FALSE;
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +0530122 channel = curr_peer->peerParams.channel;
123 vos_mem_copy(peer_mac, curr_peer->peerMac, sizeof(tSirMacAddr));
124 mutex_unlock(&hddctx->tdls_lock);
125
Masti, Narayanraddi471e9382015-07-23 18:51:29 +0530126 sme_SendTdlsChanSwitchReq(WLAN_HDD_GET_HAL_CTX(adapter),
127 adapter->sessionId,
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +0530128 peer_mac,
129 channel,
Masti, Narayanraddi471e9382015-07-23 18:51:29 +0530130 TDLS_OFF_CHANNEL_BW_OFFSET,
131 TDLS_CHANNEL_SWITCH_DISABLE);
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +0530132 tdls_unlock = TRUE;
Masti, Narayanraddifdde4d02015-04-16 14:41:51 +0530133 }
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +0530134 if (tdls_unlock == FALSE)
135 mutex_unlock(&hddctx->tdls_lock);
Masti, Narayanraddifdde4d02015-04-16 14:41:51 +0530136 }
Masti, Narayanraddi471e9382015-07-23 18:51:29 +0530137
138 /* Send Msg to PE for sending deauth and deleting all the TDLS peers */
139 sme_DeleteAllTDLSPeers(hddctx->hHal, adapter->sessionId);
140
141 /* As mentioned above TDLS is not supported in case of concurrency
142 * Find the connected peer and generate TDLS teardown indication to
143 * supplicant.
144 */
145 for (staIdx = 0; staIdx < HDD_MAX_NUM_TDLS_STA; staIdx++) {
146 if (!hddctx->tdlsConnInfo[staIdx].staId)
147 continue;
148
149 curr_peer = wlan_hdd_tdls_find_all_peer(hddctx,
150 hddctx->tdlsConnInfo[staIdx].peerMac.bytes);
151
152 if (!curr_peer)
153 continue;
154
155 /* Del Sta happened already as part of sme_DeleteAllTDLSPeers
156 * Hence clear hdd data structure.
157 */
158 hdd_roamDeregisterTDLSSTA(adapter,
159 hddctx->tdlsConnInfo[staIdx].staId);
160 wlan_hdd_tdls_decrement_peer_count(adapter);
161 wlan_hdd_tdls_reset_peer(adapter, curr_peer->peerMac);
162
163 hddctx->tdlsConnInfo[staIdx].staId = 0 ;
164 hddctx->tdlsConnInfo[staIdx].sessionId = 255;
165 vos_mem_zero(&hddctx->tdlsConnInfo[staIdx].peerMac,
166 sizeof(v_MACADDR_t)) ;
167 wlan_hdd_tdls_check_bmps(adapter);
168
169 hddLog(LOG1, FL("indicate TDLS teardown (staId %d)"),
170 curr_peer->staId);
171
172 /* Indicate teardown to supplicant */
173 wlan_hdd_tdls_indicate_teardown(
174 curr_peer->pHddTdlsCtx->pAdapter,
175 curr_peer,
176 eSIR_MAC_TDLS_TEARDOWN_UNSPEC_REASON);
177 }
178
Masti, Narayanraddi70e5b472015-08-04 12:54:16 +0530179done:
Masti, Narayanraddifdde4d02015-04-16 14:41:51 +0530180 wlan_hdd_tdls_set_mode(hddctx, eTDLS_SUPPORT_DISABLED, FALSE);
181 hddLog(LOG1, FL("TDLS Support Disabled"));
182}
183
184/**
185 * hdd_tdls_notify_mode_change - Notify mode change
186 * @adapter: pointer to hdd adapter
187 * @hddCtx : pointer to hdd context
188 *
189 * Return: None
190 */
191void hdd_tdls_notify_mode_change(hdd_adapter_t *adapter, hdd_context_t *hddctx)
192{
Masti, Narayanraddifdde4d02015-04-16 14:41:51 +0530193 wlan_hdd_tdls_disable_offchan_and_teardown_links(hddctx);
194}
195
Gopichand Nakkala4327a152013-03-04 23:22:42 -0800196static v_VOID_t wlan_hdd_tdls_start_peer_discover_timer(tdlsCtx_t *pHddTdlsCtx,
197 tANI_BOOLEAN mutexLock,
198 v_U32_t discoveryExpiry)
Gopichand Nakkalaeb69b602013-02-27 11:40:31 -0800199{
Gopichand Nakkalaeb69b602013-02-27 11:40:31 -0800200 hdd_station_ctx_t *pHddStaCtx;
Madan Mohan Koyyalamudi263cec12013-10-07 10:57:50 +0530201 hdd_context_t *pHddCtx;
202
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +0530203 ENTER();
204
c_hpothu7f63e882013-10-02 19:13:35 +0530205 if ((NULL == pHddTdlsCtx) || (NULL == pHddTdlsCtx->pAdapter) )
206 {
207 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
208 FL(" pHddTdlsCtx or pAdapter points to NULL"));
Madan Mohan Koyyalamudi263cec12013-10-07 10:57:50 +0530209 return;
c_hpothu7f63e882013-10-02 19:13:35 +0530210 }
Madan Mohan Koyyalamudi263cec12013-10-07 10:57:50 +0530211
212 pHddCtx = WLAN_HDD_GET_CTX( pHddTdlsCtx->pAdapter );
213
c_hpothu7f63e882013-10-02 19:13:35 +0530214 if(0 != (wlan_hdd_validate_context(pHddCtx)))
215 {
Madan Mohan Koyyalamudi263cec12013-10-07 10:57:50 +0530216 return;
c_hpothu7f63e882013-10-02 19:13:35 +0530217 }
Gopichand Nakkalaeb69b602013-02-27 11:40:31 -0800218
Gopichand Nakkalaeb69b602013-02-27 11:40:31 -0800219 if ( mutexLock )
220 {
Rajesh Chauhana34c6e62014-03-25 16:37:58 +0530221 mutex_lock(&pHddCtx->tdls_lock);
Gopichand Nakkalaeb69b602013-02-27 11:40:31 -0800222 }
Gopichand Nakkalaeb69b602013-02-27 11:40:31 -0800223
Gopichand Nakkala4327a152013-03-04 23:22:42 -0800224 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pHddTdlsCtx->pAdapter);
Deepthi Gowri681c9432015-05-14 11:51:11 +0530225
Gopichand Nakkala3046fc92013-03-23 13:56:43 -0700226 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "beacon rssi: %d",
227 pHddTdlsCtx->ap_rssi);
228
Gopichand Nakkalaeb69b602013-02-27 11:40:31 -0800229 if ( mutexLock )
Madan Mohan Koyyalamudi263cec12013-10-07 10:57:50 +0530230 mutex_unlock(&pHddCtx->tdls_lock);
Gopichand Nakkalaeb69b602013-02-27 11:40:31 -0800231
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +0530232 EXIT();
Gopichand Nakkalaeb69b602013-02-27 11:40:31 -0800233 return;
234}
235
Hoonki Leed37cbb32013-04-20 00:31:14 -0700236#ifdef TDLS_USE_SEPARATE_DISCOVERY_TIMER
Hoonki Lee387663d2013-02-05 18:08:43 -0800237static v_VOID_t wlan_hdd_tdls_discover_peer_cb( v_PVOID_t userData )
238{
239 int i;
240 struct list_head *head;
241 struct list_head *pos;
Chilam NG571c65a2013-01-19 12:27:36 +0530242 hddTdlsPeer_t *curr_peer;
Madan Mohan Koyyalamudi263cec12013-10-07 10:57:50 +0530243 hdd_context_t *pHddCtx;
Mahesh A Saptasagar170b5082015-02-16 18:50:54 +0530244 tdlsCtx_t *pHddTdlsCtx;
Gopichand Nakkalac3694582013-02-13 20:51:22 -0800245 int discover_req_sent = 0;
246 v_U32_t discover_expiry = TDLS_SUB_DISCOVERY_PERIOD;
Gopichand Nakkalaeb69b602013-02-27 11:40:31 -0800247 tANI_BOOLEAN doMutexLock = eANI_BOOLEAN_TRUE;
Mahesh A Saptasagar170b5082015-02-16 18:50:54 +0530248 v_CONTEXT_t pVosContext;
Gopichand Nakkalac3694582013-02-13 20:51:22 -0800249
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +0530250 ENTER();
251
Mahesh A Saptasagar170b5082015-02-16 18:50:54 +0530252 pVosContext = vos_get_global_context(VOS_MODULE_ID_HDD, NULL);
253 if (NULL == pVosContext)
c_hpothu7f63e882013-10-02 19:13:35 +0530254 {
255 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Mahesh A Saptasagar170b5082015-02-16 18:50:54 +0530256 FL("pVosContext points to NULL"));
Madan Mohan Koyyalamudi263cec12013-10-07 10:57:50 +0530257 return;
c_hpothu7f63e882013-10-02 19:13:35 +0530258 }
Madan Mohan Koyyalamudi263cec12013-10-07 10:57:50 +0530259
Mahesh A Saptasagar170b5082015-02-16 18:50:54 +0530260 pHddCtx = vos_get_context(VOS_MODULE_ID_HDD, pVosContext);
261 if (0 != (wlan_hdd_validate_context(pHddCtx)))
Sushant Kaushik15c4c522014-08-14 12:24:49 +0530262 {
Madan Mohan Koyyalamudi263cec12013-10-07 10:57:50 +0530263 return;
c_hpothu7f63e882013-10-02 19:13:35 +0530264 }
Madan Mohan Koyyalamudi263cec12013-10-07 10:57:50 +0530265
Rajesh Chauhana34c6e62014-03-25 16:37:58 +0530266 mutex_lock(&pHddCtx->tdls_lock);
Mahesh A Saptasagar170b5082015-02-16 18:50:54 +0530267 pHddTdlsCtx = (tdlsCtx_t *)userData;
268 if (0 != (wlan_hdd_validate_tdls_context(pHddCtx, pHddTdlsCtx)))
269 {
270 mutex_unlock(&pHddCtx->tdls_lock);
271 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
272 FL("Invalid pHddTdlsCtx context"));
273 return;
274 }
Hoonki Leebfee0342013-01-21 16:43:45 -0800275
Hoonki Lee387663d2013-02-05 18:08:43 -0800276 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: ", __func__);
277
Gopichand Nakkalac3694582013-02-13 20:51:22 -0800278 if (0 == pHddTdlsCtx->discovery_peer_cnt)
Gopichand Nakkala4327a152013-03-04 23:22:42 -0800279 pHddTdlsCtx->discovery_peer_cnt = wlan_hdd_get_tdls_discovery_peer_cnt(pHddTdlsCtx);
Gopichand Nakkalac3694582013-02-13 20:51:22 -0800280
Chilam NG571c65a2013-01-19 12:27:36 +0530281 for (i = 0; i < 256; i++) {
Hoonki Lee387663d2013-02-05 18:08:43 -0800282 head = &pHddTdlsCtx->peer_list[i];
Chilam NG571c65a2013-01-19 12:27:36 +0530283
Hoonki Lee387663d2013-02-05 18:08:43 -0800284 list_for_each (pos, head) {
285 curr_peer = list_entry (pos, hddTdlsPeer_t, node);
Chilam NG571c65a2013-01-19 12:27:36 +0530286
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +0530287 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Chilam Ng01120412013-02-19 18:32:21 -0800288 "%d " MAC_ADDRESS_STR " %d %d, %d %d %d %d", i,
289 MAC_ADDR_ARRAY(curr_peer->peerMac),
Gopichand Nakkalac3694582013-02-13 20:51:22 -0800290 curr_peer->discovery_processed,
291 discover_req_sent,
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -0800292 curr_peer->tdls_support,
293 curr_peer->link_status,
294 curr_peer->discovery_attempt,
295 pHddTdlsCtx->threshold_config.discovery_tries_n);
Hoonki Lee387663d2013-02-05 18:08:43 -0800296
Gopichand Nakkalac3694582013-02-13 20:51:22 -0800297 if (discover_req_sent < TDLS_MAX_DISCOVER_REQS_PER_TIMER) {
298 if (!curr_peer->discovery_processed) {
Chilam NG571c65a2013-01-19 12:27:36 +0530299
Gopichand Nakkalac3694582013-02-13 20:51:22 -0800300 curr_peer->discovery_processed = 1;
301 discover_req_sent++;
302 pHddTdlsCtx->discovery_peer_cnt--;
303
304 if ((eTDLS_CAP_UNKNOWN == curr_peer->tdls_support) &&
Gopichand Nakkala901e8922013-03-04 23:45:58 -0800305 (eTDLS_LINK_IDLE == curr_peer->link_status) &&
Gopichand Nakkalab88f6772013-02-27 18:12:56 -0800306 (curr_peer->tx_pkt >=
307 pHddTdlsCtx->threshold_config.tx_packet_n)) {
Gopichand Nakkala273d5a02013-02-19 15:15:09 -0800308
309 if (curr_peer->discovery_attempt <
310 pHddTdlsCtx->threshold_config.discovery_tries_n) {
Pradeep Reddy POTTETI9db32f02015-01-29 15:22:54 +0530311 cfg80211_tdls_oper_request(
312 pHddTdlsCtx->pAdapter->dev,
313 curr_peer->peerMac,
314 NL80211_TDLS_DISCOVERY_REQ,
315 FALSE,
316 GFP_KERNEL);
Gopichand Nakkala273d5a02013-02-19 15:15:09 -0800317 curr_peer->discovery_attempt++;
318 }
319 else
320 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +0530321 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Gopichand Nakkala273d5a02013-02-19 15:15:09 -0800322 "%s: Maximum Discovery retries reached", __func__);
323 curr_peer->tdls_support = eTDLS_CAP_NOT_SUPPORTED;
324 }
Gopichand Nakkalac3694582013-02-13 20:51:22 -0800325
326 }
327 }
Chilam NG571c65a2013-01-19 12:27:36 +0530328 }
Gopichand Nakkalac3694582013-02-13 20:51:22 -0800329 else
330 goto exit_loop;
Hoonki Lee387663d2013-02-05 18:08:43 -0800331 }
Hoonki Leef63df0d2013-01-16 19:29:14 -0800332 }
Gopichand Nakkalac3694582013-02-13 20:51:22 -0800333exit_loop:
Hoonki Leef63df0d2013-01-16 19:29:14 -0800334
Gopichand Nakkalac3694582013-02-13 20:51:22 -0800335 if (0 != pHddTdlsCtx->discovery_peer_cnt) {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +0530336 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalac3694582013-02-13 20:51:22 -0800337 "discovery_peer_cnt is %d , Starting SUB_DISCOVERY_TIMER",
338 pHddTdlsCtx->discovery_peer_cnt);
339 discover_expiry = TDLS_SUB_DISCOVERY_PERIOD;
Gopichand Nakkalaeb69b602013-02-27 11:40:31 -0800340 doMutexLock = eANI_BOOLEAN_FALSE;
Gopichand Nakkalac3694582013-02-13 20:51:22 -0800341 goto done;
342 }
Gopichand Nakkalac3694582013-02-13 20:51:22 -0800343 discover_expiry = pHddTdlsCtx->threshold_config.discovery_period_t;
344
Gopichand Nakkala4327a152013-03-04 23:22:42 -0800345 wlan_hdd_tdls_peer_reset_discovery_processed(pHddTdlsCtx);
Chilam NG571c65a2013-01-19 12:27:36 +0530346
Madan Mohan Koyyalamudi263cec12013-10-07 10:57:50 +0530347 mutex_unlock(&pHddCtx->tdls_lock);
Gopichand Nakkala638ebc72013-03-21 18:04:02 -0700348
Gopichand Nakkalaeb69b602013-02-27 11:40:31 -0800349 /* Commenting out the following function as it was introducing
350 * a race condition when pHddTdlsCtx is deleted. Also , this
351 * function is consuming more time in the timer callback.
352 * RSSI based trigger needs to revisit this part of the code.
353 */
354
355 /*
356 * wlan_hdd_get_rssi(pAdapter, &pHddTdlsCtx->ap_rssi);
357 */
Chilam NG571c65a2013-01-19 12:27:36 +0530358
Gopichand Nakkalac3694582013-02-13 20:51:22 -0800359done:
Gopichand Nakkala4327a152013-03-04 23:22:42 -0800360 wlan_hdd_tdls_start_peer_discover_timer(pHddTdlsCtx, doMutexLock, discover_expiry);
Gopichand Nakkala91b09262013-02-10 14:27:02 -0800361
Gopichand Nakkalaeb69b602013-02-27 11:40:31 -0800362 if ( !doMutexLock )
Madan Mohan Koyyalamudi263cec12013-10-07 10:57:50 +0530363 mutex_unlock(&pHddCtx->tdls_lock);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +0530364 EXIT();
Gopichand Nakkalaeb69b602013-02-27 11:40:31 -0800365 return;
Hoonki Leef63df0d2013-01-16 19:29:14 -0800366}
Hoonki Leed37cbb32013-04-20 00:31:14 -0700367#endif
Chilam NG571c65a2013-01-19 12:27:36 +0530368
Hoonki Lee387663d2013-02-05 18:08:43 -0800369static v_VOID_t wlan_hdd_tdls_update_peer_cb( v_PVOID_t userData )
Chilam NG571c65a2013-01-19 12:27:36 +0530370{
371 int i;
Hoonki Lee387663d2013-02-05 18:08:43 -0800372 struct list_head *head;
373 struct list_head *pos;
Chilam NG571c65a2013-01-19 12:27:36 +0530374 hddTdlsPeer_t *curr_peer;
Mahesh A Saptasagar170b5082015-02-16 18:50:54 +0530375 tdlsCtx_t *pHddTdlsCtx;
Madan Mohan Koyyalamudi263cec12013-10-07 10:57:50 +0530376 hdd_context_t *pHddCtx;
Mahesh A Saptasagar170b5082015-02-16 18:50:54 +0530377 v_CONTEXT_t pVosContext;
Hoonki Leebfee0342013-01-21 16:43:45 -0800378
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +0530379 ENTER();
Mahesh A Saptasagar170b5082015-02-16 18:50:54 +0530380 pVosContext = vos_get_global_context(VOS_MODULE_ID_HDD, NULL);
381 if (NULL == pVosContext)
c_hpothu7f63e882013-10-02 19:13:35 +0530382 {
383 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Mahesh A Saptasagar170b5082015-02-16 18:50:54 +0530384 FL("pVosContext points to NULL"));
Madan Mohan Koyyalamudi263cec12013-10-07 10:57:50 +0530385 return;
c_hpothu7f63e882013-10-02 19:13:35 +0530386 }
Mahesh A Saptasagar170b5082015-02-16 18:50:54 +0530387 pHddCtx = vos_get_context(VOS_MODULE_ID_HDD, pVosContext);
388 if (0 != (wlan_hdd_validate_context(pHddCtx)))
Sushant Kaushik15c4c522014-08-14 12:24:49 +0530389 {
Madan Mohan Koyyalamudi263cec12013-10-07 10:57:50 +0530390 return;
c_hpothu7f63e882013-10-02 19:13:35 +0530391 }
Rajesh Chauhana34c6e62014-03-25 16:37:58 +0530392 mutex_lock(&pHddCtx->tdls_lock);
Mahesh A Saptasagar170b5082015-02-16 18:50:54 +0530393 pHddTdlsCtx = (tdlsCtx_t *)userData;
394 if (0 != (wlan_hdd_validate_tdls_context(pHddCtx, pHddTdlsCtx)))
395 {
396 mutex_unlock(&pHddCtx->tdls_lock);
397 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
398 FL("Invalid pHddTdlsCtx context"));
399 return;
400 }
Chilam NG571c65a2013-01-19 12:27:36 +0530401 for (i = 0; i < 256; i++) {
Hoonki Lee387663d2013-02-05 18:08:43 -0800402 head = &pHddTdlsCtx->peer_list[i];
Chilam NG571c65a2013-01-19 12:27:36 +0530403
Hoonki Lee387663d2013-02-05 18:08:43 -0800404 list_for_each (pos, head) {
405 curr_peer = list_entry (pos, hddTdlsPeer_t, node);
Chilam NG571c65a2013-01-19 12:27:36 +0530406
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +0530407 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Hoonki Lee66b75f32013-04-16 18:30:07 -0700408 "%s: " MAC_ADDRESS_STR " link_status %d"
409 " tdls_support %d", __func__, MAC_ADDR_ARRAY(curr_peer->peerMac),
Gopichand Nakkala34d1b062013-03-19 15:28:33 -0700410 curr_peer->link_status, curr_peer->tdls_support);
Hoonki Lee387663d2013-02-05 18:08:43 -0800411
Chilam NG571c65a2013-01-19 12:27:36 +0530412 if (eTDLS_CAP_SUPPORTED == curr_peer->tdls_support) {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +0530413 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Hoonki Lee66b75f32013-04-16 18:30:07 -0700414 "tx %d, rx %d (thr.pkt %d/idle %d), rssi %d (thr.trig %d/hys %d/tear %d)",
415 curr_peer->tx_pkt, curr_peer->rx_pkt,
Hoonki Lee5a4b2172013-01-29 01:45:53 -0800416 pHddTdlsCtx->threshold_config.tx_packet_n,
Hoonki Lee66b75f32013-04-16 18:30:07 -0700417 pHddTdlsCtx->threshold_config.idle_packet_n,
418 curr_peer->rssi,
419 pHddTdlsCtx->threshold_config.rssi_trigger_threshold,
420 pHddTdlsCtx->threshold_config.rssi_hysteresis,
421 pHddTdlsCtx->threshold_config.rssi_teardown_threshold);
Chilam Ng01120412013-02-19 18:32:21 -0800422
Gopichand Nakkala901e8922013-03-04 23:45:58 -0800423 if ((eTDLS_LINK_IDLE == curr_peer->link_status) ||
424 (eTDLS_LINK_DISCOVERING == curr_peer->link_status)){
Sunil Dutt961ecbd2013-11-28 20:04:07 +0530425
426 if (pHddCtx->cfg_ini->fTDLSExternalControl &&
427 (FALSE == curr_peer->isForcedPeer)) {
Ganesh Kondabattini2d7b6a42015-09-01 18:45:18 +0530428 goto next_peer;
Sunil Dutt961ecbd2013-11-28 20:04:07 +0530429 }
430
Chilam NG571c65a2013-01-19 12:27:36 +0530431 if (curr_peer->tx_pkt >=
432 pHddTdlsCtx->threshold_config.tx_packet_n) {
Hoonki Lee5a4b2172013-01-29 01:45:53 -0800433
Gopichand Nakkala8b00c632013-03-08 19:47:52 -0800434 if (HDD_MAX_NUM_TDLS_STA > wlan_hdd_tdlsConnectedPeers(pHddTdlsCtx->pAdapter))
Gopichand Nakkalab977a972013-02-18 19:15:09 -0800435 {
436
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +0530437 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
438 "Tput trigger TDLS pre-setup");
Chilam NG571c65a2013-01-19 12:27:36 +0530439#ifdef CONFIG_TDLS_IMPLICIT
Pradeep Reddy POTTETI9db32f02015-01-29 15:22:54 +0530440 pHddTdlsCtx->curr_candidate = curr_peer;
441 wlan_hdd_tdls_implicit_send_discovery_request(pHddTdlsCtx);
Chilam NG571c65a2013-01-19 12:27:36 +0530442#endif
Gopichand Nakkalab977a972013-02-18 19:15:09 -0800443 }
444 else
445 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +0530446 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkala8b00c632013-03-08 19:47:52 -0800447 "%s: Maximum peer connected already! %d",
448 __func__, wlan_hdd_tdlsConnectedPeers(pHddTdlsCtx->pAdapter) );
Gopichand Nakkalab977a972013-02-18 19:15:09 -0800449 }
Hoonki Leecdd8e962013-01-20 00:45:46 -0800450 goto next_peer;
Chilam NG571c65a2013-01-19 12:27:36 +0530451 }
Hoonki Leefb8df672013-04-10 18:20:34 -0700452 }
453 else if (eTDLS_LINK_CONNECTED == curr_peer->link_status) {
Chilam Ng01120412013-02-19 18:32:21 -0800454 if ((tANI_S32)curr_peer->rssi <
455 (tANI_S32)pHddTdlsCtx->threshold_config.rssi_teardown_threshold) {
Hoonki Lee5a4b2172013-01-29 01:45:53 -0800456
Chilam Ng01120412013-02-19 18:32:21 -0800457 VOS_TRACE( VOS_MODULE_ID_HDD,
458 VOS_TRACE_LEVEL_WARN,
459 "Tear down - low RSSI: " MAC_ADDRESS_STR "!",
460 MAC_ADDR_ARRAY(curr_peer->peerMac));
461#ifdef CONFIG_TDLS_IMPLICIT
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -0700462 wlan_hdd_tdls_indicate_teardown(pHddTdlsCtx->pAdapter,
463 curr_peer,
464 eSIR_MAC_TDLS_TEARDOWN_UNSPEC_REASON);
Chilam Ng01120412013-02-19 18:32:21 -0800465#endif
Hoonki Leecdd8e962013-01-20 00:45:46 -0800466 goto next_peer;
Chilam NG571c65a2013-01-19 12:27:36 +0530467 }
Chilam Ng01120412013-02-19 18:32:21 -0800468
Naresh Jayaramdb4514b2013-11-25 18:08:10 +0530469 /* Only teardown based on non zero idle packet threshold, to address a use
470 * case where this threshold does not get consider for TEAR DOWN.
471 */
472
473 if (( 0 != pHddTdlsCtx->threshold_config.idle_packet_n ) &&
474 ((curr_peer->tx_pkt <
Chilam Ng01120412013-02-19 18:32:21 -0800475 pHddTdlsCtx->threshold_config.idle_packet_n) &&
476 (curr_peer->rx_pkt <
Naresh Jayaramdb4514b2013-11-25 18:08:10 +0530477 pHddTdlsCtx->threshold_config.idle_packet_n))) {
Chilam Ng01120412013-02-19 18:32:21 -0800478 if (VOS_TIMER_STATE_RUNNING !=
479 vos_timer_getCurrentState(&curr_peer->peerIdleTimer)) {
480 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
481 "Tx/Rx Idle timer start: " MAC_ADDRESS_STR "!",
482 MAC_ADDR_ARRAY(curr_peer->peerMac));
Gopichand Nakkala3046fc92013-03-23 13:56:43 -0700483 wlan_hdd_tdls_timer_restart(pHddTdlsCtx->pAdapter,
484 &curr_peer->peerIdleTimer,
485 pHddTdlsCtx->threshold_config.idle_timeout_t);
Chilam Ng01120412013-02-19 18:32:21 -0800486 }
487 } else {
Hoonki Lee5a4b2172013-01-29 01:45:53 -0800488 if (VOS_TIMER_STATE_RUNNING ==
489 vos_timer_getCurrentState(&curr_peer->peerIdleTimer)) {
Chilam Ng01120412013-02-19 18:32:21 -0800490 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
491 "Tx/Rx Idle timer stop: " MAC_ADDRESS_STR "!",
492 MAC_ADDR_ARRAY(curr_peer->peerMac));
493 vos_timer_stop( &curr_peer->peerIdleTimer);
Hoonki Lee5a4b2172013-01-29 01:45:53 -0800494 }
Hoonki Lee5a4b2172013-01-29 01:45:53 -0800495 }
Chilam Ng01120412013-02-19 18:32:21 -0800496
Hoonki Leecdd8e962013-01-20 00:45:46 -0800497// if (curr_peer->rssi <
498// (pHddTdlsCtx->threshold_config.rssi_hysteresis +
499// pHddTdlsCtx->ap_rssi)) {
500//
501//#ifdef CONFIG_TDLS_IMPLICIT
502// cfg80211_tdls_oper_request(pHddTdlsCtx->dev,
503// curr_peer->peerMac,
504// NL80211_TDLS_TEARDOWN, FALSE,
505// GFP_KERNEL);
506//#endif
507// }
Chilam NG571c65a2013-01-19 12:27:36 +0530508 }
Chilam Ng01120412013-02-19 18:32:21 -0800509 } else if (eTDLS_CAP_UNKNOWN == curr_peer->tdls_support) {
Sunil Dutt961ecbd2013-11-28 20:04:07 +0530510
511 if (pHddCtx->cfg_ini->fTDLSExternalControl &&
512 (FALSE == curr_peer->isForcedPeer)) {
Ganesh Kondabattini2d7b6a42015-09-01 18:45:18 +0530513 goto next_peer;
Sunil Dutt961ecbd2013-11-28 20:04:07 +0530514 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -0700515 if (!TDLS_IS_CONNECTED(curr_peer)) {
Chilam Ng01120412013-02-19 18:32:21 -0800516 if (curr_peer->tx_pkt >=
517 pHddTdlsCtx->threshold_config.tx_packet_n) {
Chilam Ng01120412013-02-19 18:32:21 -0800518
Sunil Duttb0d39242014-09-10 23:54:51 +0530519 /* Ignore discovery attempt if External Control is enabled, that
520 * is, peer is forced. In that case, continue discovery attempt
521 * regardless attempt count
522 */
523 if (curr_peer->isForcedPeer || curr_peer->discovery_attempt++ <
Chilam Ng01120412013-02-19 18:32:21 -0800524 pHddTdlsCtx->threshold_config.discovery_tries_n) {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +0530525 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
526 "TDLS UNKNOWN discover ");
Hoonki Leed37cbb32013-04-20 00:31:14 -0700527#ifdef CONFIG_TDLS_IMPLICIT
Pradeep Reddy POTTETI9db32f02015-01-29 15:22:54 +0530528 pHddTdlsCtx->curr_candidate = curr_peer;
529 wlan_hdd_tdls_implicit_send_discovery_request(pHddTdlsCtx);
Hoonki Leed37cbb32013-04-20 00:31:14 -0700530#endif
Chilam Ng01120412013-02-19 18:32:21 -0800531 }
Gopichand Nakkala901e8922013-03-04 23:45:58 -0800532 else
Gopichand Nakkala8b00c632013-03-08 19:47:52 -0800533 {
Gopichand Nakkala901e8922013-03-04 23:45:58 -0800534 curr_peer->tdls_support = eTDLS_CAP_NOT_SUPPORTED;
Atul Mittal115287b2014-07-08 13:26:33 +0530535 wlan_hdd_tdls_set_peer_link_status(
536 curr_peer,
537 eTDLS_LINK_IDLE,
538 eTDLS_LINK_NOT_SUPPORTED);
539
Gopichand Nakkala8b00c632013-03-08 19:47:52 -0800540 }
Chilam Ng01120412013-02-19 18:32:21 -0800541 }
542 }
Chilam NG571c65a2013-01-19 12:27:36 +0530543 }
544
Hoonki Leecdd8e962013-01-20 00:45:46 -0800545next_peer:
Chilam NG571c65a2013-01-19 12:27:36 +0530546 curr_peer->tx_pkt = 0;
Chilam Ng1279e232013-01-25 15:06:52 -0800547 curr_peer->rx_pkt = 0;
Hoonki Lee387663d2013-02-05 18:08:43 -0800548 }
Chilam NG571c65a2013-01-19 12:27:36 +0530549 }
550
Gopichand Nakkala3046fc92013-03-23 13:56:43 -0700551 wlan_hdd_tdls_timer_restart(pHddTdlsCtx->pAdapter,
552 &pHddTdlsCtx->peerUpdateTimer,
553 pHddTdlsCtx->threshold_config.tx_period_t);
Madan Mohan Koyyalamudi263cec12013-10-07 10:57:50 +0530554 mutex_unlock(&pHddCtx->tdls_lock);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +0530555 EXIT();
Chilam NG571c65a2013-01-19 12:27:36 +0530556}
557
Chilam Ng1279e232013-01-25 15:06:52 -0800558static v_VOID_t wlan_hdd_tdls_idle_cb( v_PVOID_t userData )
559{
Lee Hoonkic1262f22013-01-24 21:59:00 -0800560#ifdef CONFIG_TDLS_IMPLICIT
Mahesh A Saptasagar170b5082015-02-16 18:50:54 +0530561 hddTdlsPeer_t *curr_peer;
Madan Mohan Koyyalamudi263cec12013-10-07 10:57:50 +0530562 tdlsCtx_t *pHddTdlsCtx;
563 hdd_context_t *pHddCtx;
Mahesh A Saptasagar170b5082015-02-16 18:50:54 +0530564 v_CONTEXT_t pVosContext;
Chilam Ng1279e232013-01-25 15:06:52 -0800565
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +0530566 ENTER();
567
Mahesh A Saptasagar170b5082015-02-16 18:50:54 +0530568 pVosContext = vos_get_global_context(VOS_MODULE_ID_HDD, NULL);
569 if (NULL == pVosContext)
570 {
571 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
572 FL("pVosContext points to NULL"));
573 return;
574 }
575 pHddCtx = vos_get_context(VOS_MODULE_ID_HDD, pVosContext);
576 if (0 != (wlan_hdd_validate_context(pHddCtx)))
577 {
Mahesh A Saptasagar170b5082015-02-16 18:50:54 +0530578 return;
579 }
580
581 mutex_lock(&pHddCtx->tdls_lock);
582
583 curr_peer = (hddTdlsPeer_t *)userData;
Rajesh Chauhan1ace6002013-04-18 18:08:21 -0700584 if (NULL == curr_peer)
585 {
Mahesh A Saptasagar170b5082015-02-16 18:50:54 +0530586 mutex_unlock(&pHddCtx->tdls_lock);
Rajesh Chauhan1ace6002013-04-18 18:08:21 -0700587 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
c_hpothu7f63e882013-10-02 19:13:35 +0530588 FL("Invalid tdls idle timer expired"));
Rajesh Chauhan1ace6002013-04-18 18:08:21 -0700589 return;
590 }
Mahesh A Saptasagar170b5082015-02-16 18:50:54 +0530591
Madan Mohan Koyyalamudi263cec12013-10-07 10:57:50 +0530592 pHddTdlsCtx = curr_peer->pHddTdlsCtx;
Mahesh A Saptasagar170b5082015-02-16 18:50:54 +0530593 if (0 != (wlan_hdd_validate_tdls_context(pHddCtx, pHddTdlsCtx)))
c_hpothu7f63e882013-10-02 19:13:35 +0530594 {
Mahesh A Saptasagar170b5082015-02-16 18:50:54 +0530595 mutex_unlock(&pHddCtx->tdls_lock);
c_hpothu7f63e882013-10-02 19:13:35 +0530596 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Mahesh A Saptasagar170b5082015-02-16 18:50:54 +0530597 FL("Invalid pHddTdlsCtx context"));
Madan Mohan Koyyalamudi263cec12013-10-07 10:57:50 +0530598 return;
c_hpothu7f63e882013-10-02 19:13:35 +0530599 }
Rajesh Chauhan1ace6002013-04-18 18:08:21 -0700600
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +0530601 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -0800602 "%s: Tx/Rx Idle " MAC_ADDRESS_STR " tx_pkt: %d, rx_pkt: %d, idle_packet_n: %d",
Rajesh Chauhan1ace6002013-04-18 18:08:21 -0700603 __func__, MAC_ADDR_ARRAY(curr_peer->peerMac),
604 curr_peer->tx_pkt,
605 curr_peer->rx_pkt,
606 curr_peer->pHddTdlsCtx->threshold_config.idle_packet_n);
607
Rajesh Chauhan1ace6002013-04-18 18:08:21 -0700608 /* Check tx/rx statistics on this tdls link for recent activities and
609 * then decide whether to tear down the link or keep it.
610 */
611 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))
612 {
613 /* this tdls link got back to normal, so keep it */
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +0530614 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Rajesh Chauhan1ace6002013-04-18 18:08:21 -0700615 "%s: tdls link to " MAC_ADDRESS_STR " back to normal, will stay",
616 __func__, MAC_ADDR_ARRAY(curr_peer->peerMac));
617 }
618 else
619 {
620 /* this tdls link needs to get torn down */
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +0530621 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Rajesh Chauhan1ace6002013-04-18 18:08:21 -0700622 "%s: trigger tdls link to " MAC_ADDRESS_STR " down",
623 __func__, MAC_ADDR_ARRAY(curr_peer->peerMac));
624
625 wlan_hdd_tdls_indicate_teardown(curr_peer->pHddTdlsCtx->pAdapter,
626 curr_peer,
627 eSIR_MAC_TDLS_TEARDOWN_UNSPEC_REASON);
628 }
Madan Mohan Koyyalamudi263cec12013-10-07 10:57:50 +0530629 mutex_unlock(&pHddCtx->tdls_lock);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +0530630 EXIT();
Chilam Ng1279e232013-01-25 15:06:52 -0800631#endif
632}
633
Gopichand Nakkala75e7b282013-03-15 18:37:13 -0700634static v_VOID_t wlan_hdd_tdls_discovery_timeout_peer_cb(v_PVOID_t userData)
635{
Gopichand Nakkalaccd3a382013-03-19 13:56:10 -0700636 int i;
637 struct list_head *head;
638 hddTdlsPeer_t *tmp;
639 struct list_head *pos, *q;
Gopichand Nakkala75e7b282013-03-15 18:37:13 -0700640 tdlsCtx_t *pHddTdlsCtx;
Madan Mohan Koyyalamudi263cec12013-10-07 10:57:50 +0530641 hdd_context_t *pHddCtx;
Mahesh A Saptasagar170b5082015-02-16 18:50:54 +0530642 v_CONTEXT_t pVosContext;
Gopichand Nakkala75e7b282013-03-15 18:37:13 -0700643
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +0530644 ENTER();
Mahesh A Saptasagar170b5082015-02-16 18:50:54 +0530645 pVosContext = vos_get_global_context(VOS_MODULE_ID_HDD, NULL);
646 if (NULL == pVosContext)
c_hpothu7f63e882013-10-02 19:13:35 +0530647 {
648 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Mahesh A Saptasagar170b5082015-02-16 18:50:54 +0530649 FL("pVosContext points to NULL"));
Madan Mohan Koyyalamudi263cec12013-10-07 10:57:50 +0530650 return;
c_hpothu7f63e882013-10-02 19:13:35 +0530651 }
Madan Mohan Koyyalamudi263cec12013-10-07 10:57:50 +0530652
Mahesh A Saptasagar170b5082015-02-16 18:50:54 +0530653 pHddCtx = vos_get_context(VOS_MODULE_ID_HDD, pVosContext);
654 if (0 != (wlan_hdd_validate_context(pHddCtx)))
Sushant Kaushik15c4c522014-08-14 12:24:49 +0530655 {
Madan Mohan Koyyalamudi263cec12013-10-07 10:57:50 +0530656 return;
c_hpothu7f63e882013-10-02 19:13:35 +0530657 }
Madan Mohan Koyyalamudi263cec12013-10-07 10:57:50 +0530658
Rajesh Chauhana34c6e62014-03-25 16:37:58 +0530659 mutex_lock(&pHddCtx->tdls_lock);
Gopichand Nakkalaccd3a382013-03-19 13:56:10 -0700660
Mahesh A Saptasagar170b5082015-02-16 18:50:54 +0530661 pHddTdlsCtx = (tdlsCtx_t *)userData;
662 if (0 != (wlan_hdd_validate_tdls_context(pHddCtx, pHddTdlsCtx)))
663 {
664 mutex_unlock(&pHddCtx->tdls_lock);
665 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
666 FL("Invalid pHddTdlsCtx context"));
667 return;
668 }
669
Gopichand Nakkalaccd3a382013-03-19 13:56:10 -0700670 for (i = 0; i < 256; i++) {
671 head = &pHddTdlsCtx->peer_list[i];
672 list_for_each_safe (pos, q, head) {
673 tmp = list_entry(pos, hddTdlsPeer_t, node);
674 if (eTDLS_LINK_DISCOVERING == tmp->link_status)
675 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +0530676 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalaccd3a382013-03-19 13:56:10 -0700677 "%s: " MAC_ADDRESS_STR " to idle state", __func__,
678 MAC_ADDR_ARRAY(tmp->peerMac));
Atul Mittal115287b2014-07-08 13:26:33 +0530679 wlan_hdd_tdls_set_peer_link_status(
680 tmp,
681 eTDLS_LINK_IDLE,
Atul Mittalad630e42014-10-07 19:19:14 +0530682 eTDLS_LINK_NOT_SUPPORTED);
Gopichand Nakkalaccd3a382013-03-19 13:56:10 -0700683 }
684 }
685 }
Gopichand Nakkala75e7b282013-03-15 18:37:13 -0700686
687 pHddTdlsCtx->discovery_sent_cnt = 0;
Gopichand Nakkala34d1b062013-03-19 15:28:33 -0700688 wlan_hdd_tdls_check_power_save_prohibited(pHddTdlsCtx->pAdapter);
Gopichand Nakkalaccd3a382013-03-19 13:56:10 -0700689
Madan Mohan Koyyalamudi263cec12013-10-07 10:57:50 +0530690 mutex_unlock(&pHddCtx->tdls_lock);
Gopichand Nakkalaccd3a382013-03-19 13:56:10 -0700691
Gopichand Nakkala75e7b282013-03-15 18:37:13 -0700692 wlan_hdd_tdls_check_bmps(pHddTdlsCtx->pAdapter);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +0530693 EXIT();
Gopichand Nakkala75e7b282013-03-15 18:37:13 -0700694 return;
695}
696
Ganesh Kondabattinicbfdc392015-09-11 19:12:59 +0530697v_VOID_t wlan_hdd_tdls_initiator_wait_cb( v_PVOID_t userData )
Hoonki Lee14621352013-04-16 17:51:19 -0700698{
Ganesh Kondabattinicbfdc392015-09-11 19:12:59 +0530699 tdlsConnInfo_t *tdlsInfo = (tdlsConnInfo_t *) userData;
Hoonki Lee14621352013-04-16 17:51:19 -0700700 tdlsCtx_t *pHddTdlsCtx;
Ganesh Kondabattinicbfdc392015-09-11 19:12:59 +0530701 hdd_context_t *pHddCtx = NULL;
702 hdd_adapter_t *pAdapter = NULL;
703 v_CONTEXT_t pVosContext = vos_get_global_context(VOS_MODULE_ID_HDD, NULL);
704 hddTdlsPeer_t *curr_peer = NULL;
Hoonki Lee14621352013-04-16 17:51:19 -0700705
Mahesh A Saptasagar4534e2b2015-03-05 20:45:41 +0530706 ENTER();
Ganesh Kondabattinicbfdc392015-09-11 19:12:59 +0530707
708 if (!tdlsInfo->staId)
c_hpothu7f63e882013-10-02 19:13:35 +0530709 {
710 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Ganesh Kondabattinicbfdc392015-09-11 19:12:59 +0530711 FL("peer (staidx %u) doesn't exists"), tdlsInfo->staId);
712 return;
713 }
714 if (!pVosContext)
715 {
716 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
717 FL("pVosContext is NULL"));
Hoonki Lee14621352013-04-16 17:51:19 -0700718 return;
c_hpothu7f63e882013-10-02 19:13:35 +0530719 }
Hoonki Lee14621352013-04-16 17:51:19 -0700720
Ganesh Kondabattinicbfdc392015-09-11 19:12:59 +0530721 pHddCtx = vos_get_context( VOS_MODULE_ID_HDD, pVosContext);
722 if (!pHddCtx)
723 {
724 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
725 FL("pHddCtx is NULL"));
726 return;
727 }
728
729 pAdapter = hdd_get_adapter_by_sme_session_id(pHddCtx, tdlsInfo->sessionId);
730
731 if (!pAdapter)
732 {
733 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
734 FL("pAdapter is NULL"));
735 return;
736 }
737
738 mutex_lock(&pHddCtx->tdls_lock);
739 curr_peer = wlan_hdd_tdls_find_peer(pAdapter,
740 (u8 *) &tdlsInfo->peerMac.bytes[0], FALSE);
741 if (curr_peer == NULL)
742 {
743 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
744 FL("peer doesn't exists"));
745 mutex_unlock(&pHddCtx->tdls_lock);
746 return;
747 }
Hoonki Lee14621352013-04-16 17:51:19 -0700748 pHddTdlsCtx = curr_peer->pHddTdlsCtx;
749
750 if ( NULL == pHddTdlsCtx )
c_hpothu7f63e882013-10-02 19:13:35 +0530751 {
Ratheesh S P36dbc932015-08-07 14:28:57 +0530752 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
c_hpothu7f63e882013-10-02 19:13:35 +0530753 FL("pHddTdlsCtx is NULL"));
Hoonki Lee14621352013-04-16 17:51:19 -0700754 return;
c_hpothu7f63e882013-10-02 19:13:35 +0530755 }
Mahesh A Saptasagar4534e2b2015-03-05 20:45:41 +0530756 if (0 != (wlan_hdd_validate_context(
757 WLAN_HDD_GET_CTX(pHddTdlsCtx->pAdapter))))
758 {
759 return;
760 }
Hoonki Lee14621352013-04-16 17:51:19 -0700761 WLANTL_ResumeDataTx( (WLAN_HDD_GET_CTX(pHddTdlsCtx->pAdapter))->pvosContext,
762 (v_U8_t *)&curr_peer->staId);
Ganesh Kondabattinicbfdc392015-09-11 19:12:59 +0530763 mutex_unlock(&pHddCtx->tdls_lock);
Mahesh A Saptasagar4534e2b2015-03-05 20:45:41 +0530764 EXIT();
Hoonki Lee14621352013-04-16 17:51:19 -0700765}
766
Gopichand Nakkala4327a152013-03-04 23:22:42 -0800767static void wlan_hdd_tdls_free_list(tdlsCtx_t *pHddTdlsCtx)
Gopichand Nakkala91b09262013-02-10 14:27:02 -0800768{
769 int i;
770 struct list_head *head;
771 hddTdlsPeer_t *tmp;
772 struct list_head *pos, *q;
773
c_hpothu7f63e882013-10-02 19:13:35 +0530774 if (NULL == pHddTdlsCtx)
775 {
Ratheesh S P36dbc932015-08-07 14:28:57 +0530776 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
c_hpothu7f63e882013-10-02 19:13:35 +0530777 FL("pHddTdlsCtx is NULL"));
778 return;
779 }
Gopichand Nakkala91b09262013-02-10 14:27:02 -0800780
781 for (i = 0; i < 256; i++) {
782 head = &pHddTdlsCtx->peer_list[i];
783 list_for_each_safe (pos, q, head) {
784 tmp = list_entry(pos, hddTdlsPeer_t, node);
785 list_del(pos);
786 vos_mem_free(tmp);
Srinivas Girigowda8d2348f2013-12-12 12:14:15 -0800787 tmp = NULL;
Gopichand Nakkala91b09262013-02-10 14:27:02 -0800788 }
789 }
Gopichand Nakkala91b09262013-02-10 14:27:02 -0800790}
791
Sameer Thalappilbee426e2013-10-30 10:30:30 -0700792static void wlan_hdd_tdls_schedule_scan(struct work_struct *work)
793{
794 tdls_scan_context_t *scan_ctx =
795 container_of(work, tdls_scan_context_t, tdls_scan_work.work);
796
797 if (NULL == scan_ctx)
c_hpothu7f63e882013-10-02 19:13:35 +0530798 {
799 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
800 FL("scan_ctx is NULL"));
Sameer Thalappilbee426e2013-10-30 10:30:30 -0700801 return;
c_hpothu7f63e882013-10-02 19:13:35 +0530802 }
Sameer Thalappilbee426e2013-10-30 10:30:30 -0700803
804 if (unlikely(TDLS_CTX_MAGIC != scan_ctx->magic))
805 return;
806
807 scan_ctx->attempt++;
808
809 wlan_hdd_cfg80211_scan(scan_ctx->wiphy,
810#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
811 scan_ctx->dev,
812#endif
813 scan_ctx->scan_request);
814}
815
Pradeep Reddy POTTETIf0569d72014-12-13 16:54:03 +0530816void wlan_hdd_tdls_btCoex_cb(void *data, int indType)
817{
818 hdd_adapter_t *pAdapter;
819 hdd_context_t *pHddCtx;
820 u16 connectedTdlsPeers;
821 tdlsCtx_t *pHddTdlsCtx;
822 hddTdlsPeer_t *currPeer;
Pradeep Reddy POTTETIf0569d72014-12-13 16:54:03 +0530823
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +0530824 ENTER();
Pradeep Reddy POTTETIf0569d72014-12-13 16:54:03 +0530825 if ((NULL == data) || (indType < 0))
826 {
827 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
828 FL("Invalid arguments"));
829 return;
830 }
831
832 pHddCtx = (hdd_context_t *)data;
833 if (0 != (wlan_hdd_validate_context(pHddCtx)))
834 {
Pradeep Reddy POTTETIf0569d72014-12-13 16:54:03 +0530835 return;
836 }
837
838 /* if tdls is not enabled, then continue btCoex */
839 if (eTDLS_SUPPORT_NOT_ENABLED == pHddCtx->tdls_mode)
840 {
841 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
842 FL("tdls is not enabled"));
843 return;
844 }
845
846 /* get pAdapter context, do we need WLAN_HDD_P2P_CLIENT */
847 pAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_INFRA_STATION);
848 if (NULL == pAdapter)
849 {
850 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
851 FL("pAdapter is not valid"));
852 return;
853 }
854
855 pHddTdlsCtx = WLAN_HDD_GET_TDLS_CTX_PTR(pAdapter);
856 if (NULL == pHddTdlsCtx)
857 {
858 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
859 FL("pHddTdlsCtx is not valid"));
860 return;
861 }
862
863 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
864 "%s: BtCoex notification type %d", __func__, indType);
865 /* BtCoex notification type enabled, Disable TDLS */
866 if (indType == SIR_COEX_IND_TYPE_TDLS_DISABLE)
867 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +0530868 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Pradeep Reddy POTTETIf0569d72014-12-13 16:54:03 +0530869 FL("BtCoex notification, Disable TDLS"));
870
Pradeep Reddy POTTETIf0569d72014-12-13 16:54:03 +0530871 /* tdls is in progress */
Pradeep Reddy POTTETI9db32f02015-01-29 15:22:54 +0530872 currPeer = wlan_hdd_tdls_is_progress(pHddCtx, NULL, 0, TRUE);
Pradeep Reddy POTTETIf0569d72014-12-13 16:54:03 +0530873 if (NULL != currPeer)
874 {
875 wlan_hdd_tdls_set_peer_link_status (currPeer,
876 eTDLS_LINK_IDLE,
877 eTDLS_LINK_UNSPECIFIED);
878 }
879
880 /* while tdls is up */
881 if (eTDLS_SUPPORT_ENABLED == pHddCtx->tdls_mode ||
882 eTDLS_SUPPORT_EXPLICIT_TRIGGER_ONLY == pHddCtx->tdls_mode)
883 {
884 connectedTdlsPeers = wlan_hdd_tdlsConnectedPeers(pAdapter);
885 /* disable implicit trigger logic & tdls operatoin */
886 wlan_hdd_tdls_set_mode(pHddCtx, eTDLS_SUPPORT_DISABLED, FALSE);
887 pHddCtx->is_tdls_btc_enabled = FALSE;
888
889 /* teardown the peers on the btcoex */
890 if (connectedTdlsPeers)
891 {
892 tANI_U8 staIdx;
893 hddTdlsPeer_t *curr_peer;
894
895 for (staIdx = 0; staIdx < HDD_MAX_NUM_TDLS_STA; staIdx++)
896 {
897 if (pHddCtx->tdlsConnInfo[staIdx].staId)
898 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +0530899 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
900 ("%s: indicate TDLS teardown (staId %d)"),
Pradeep Reddy POTTETIf0569d72014-12-13 16:54:03 +0530901 __func__,pHddCtx->tdlsConnInfo[staIdx].staId);
902
903 #ifdef CONFIG_TDLS_IMPLICIT
904 curr_peer = wlan_hdd_tdls_find_all_peer(pHddCtx,
905 pHddCtx->tdlsConnInfo[staIdx].peerMac.bytes);
906 if(curr_peer) {
907 wlan_hdd_tdls_indicate_teardown(
908 curr_peer->pHddTdlsCtx->pAdapter, curr_peer,
909 eSIR_MAC_TDLS_TEARDOWN_UNSPEC_REASON);
910 }
911 #endif
912 }
913 }
914 }
915 }
916 }
917 /* BtCoex notification type enabled, Enable TDLS */
918 else if (indType == SIR_COEX_IND_TYPE_TDLS_ENABLE)
919 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +0530920 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Pradeep Reddy POTTETIf0569d72014-12-13 16:54:03 +0530921 FL("BtCoex notification, Enable TDLS"));
922 /* if tdls was enabled before btCoex, re-enable tdls mode */
923 if (eTDLS_SUPPORT_ENABLED == pHddCtx->tdls_mode_last ||
924 eTDLS_SUPPORT_EXPLICIT_TRIGGER_ONLY == pHddCtx->tdls_mode_last)
925 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +0530926 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Pradeep Reddy POTTETIf0569d72014-12-13 16:54:03 +0530927 ("%s: revert tdls mode %d"), __func__,
928 pHddCtx->tdls_mode_last);
929 pHddCtx->is_tdls_btc_enabled = TRUE;
930 wlan_hdd_tdls_set_mode(pHddCtx, pHddCtx->tdls_mode_last, FALSE);
931 }
932 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +0530933 EXIT();
Pradeep Reddy POTTETIf0569d72014-12-13 16:54:03 +0530934 return;
935}
936
Agarwal Ashish4b87f922014-06-18 03:03:21 +0530937/* initialize TDLS global context */
938void wlan_hdd_tdls_init(hdd_context_t *pHddCtx )
939{
940 v_U8_t staIdx;
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +0530941 eHalStatus status;
Sameer Thalappilbee426e2013-10-30 10:30:30 -0700942
Agarwal Ashish4b87f922014-06-18 03:03:21 +0530943 pHddCtx->connected_peer_count = 0;
944
945 pHddCtx->tdls_scan_ctxt.magic = 0;
946 pHddCtx->tdls_scan_ctxt.attempt = 0;
947 pHddCtx->tdls_scan_ctxt.reject = 0;
948 pHddCtx->tdls_scan_ctxt.scan_request = NULL;
949
950 for (staIdx = 0; staIdx < HDD_MAX_NUM_TDLS_STA; staIdx++)
951 {
952 pHddCtx->tdlsConnInfo[staIdx].staId = 0;
953 pHddCtx->tdlsConnInfo[staIdx].sessionId = 255;
954 vos_mem_zero(&pHddCtx->tdlsConnInfo[staIdx].peerMac,
955 sizeof(v_MACADDR_t)) ;
956 }
Pradeep Reddy POTTETIf0569d72014-12-13 16:54:03 +0530957 pHddCtx->is_tdls_btc_enabled = TRUE;
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +0530958 status = sme_RegisterBtCoexTDLSCallback(pHddCtx->hHal,
959 wlan_hdd_tdls_btCoex_cb);
960 if (status != eHAL_STATUS_SUCCESS) {
961 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to register BT Coex TDLS callback"));
962 }
Agarwal Ashish4b87f922014-06-18 03:03:21 +0530963
964 if (FALSE == pHddCtx->cfg_ini->fEnableTDLSImplicitTrigger)
965 {
966 pHddCtx->tdls_mode = eTDLS_SUPPORT_EXPLICIT_TRIGGER_ONLY;
Ratheesh S P36dbc932015-08-07 14:28:57 +0530967 hddLog(VOS_TRACE_LEVEL_INFO, "%s TDLS Implicit trigger not enabled!", __func__);
Agarwal Ashish4b87f922014-06-18 03:03:21 +0530968 }
969 else
970 {
971 pHddCtx->tdls_mode = eTDLS_SUPPORT_ENABLED;
972 }
973}
974
975int wlan_hdd_sta_tdls_init(hdd_adapter_t *pAdapter)
Chilam Ng01120412013-02-19 18:32:21 -0800976{
Chilam Ng01120412013-02-19 18:32:21 -0800977 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
Hoonki Lee27511902013-03-14 18:19:06 -0700978 tdlsCtx_t *pHddTdlsCtx;
Chilam Ng01120412013-02-19 18:32:21 -0800979 int i;
Sunil Dutt66485cb2013-12-19 19:05:03 +0530980 if (NULL == pHddCtx)
Mahesh A Saptasagar36cdc802015-01-07 18:41:17 +0530981 {
982 hddLog(VOS_TRACE_LEVEL_ERROR, "%s pHddCtx is NULL", __func__);
Mahesh A Saptasagar170b5082015-02-16 18:50:54 +0530983 return -EINVAL;
Mahesh A Saptasagar36cdc802015-01-07 18:41:17 +0530984 }
Sunil Dutt66485cb2013-12-19 19:05:03 +0530985
Mahesh A Saptasagarf5b8eff2015-01-31 01:07:07 +0530986 if (test_bit(TDLS_INIT_DONE, &pAdapter->event_flags))
987 {
988 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Mahesh A Saptasagar170b5082015-02-16 18:50:54 +0530989 "%s: TDLS INIT DONE set to 1, no point in re-init", __func__);
990 return -EALREADY;
Mahesh A Saptasagarf5b8eff2015-01-31 01:07:07 +0530991 }
Sunil Dutt66485cb2013-12-19 19:05:03 +0530992
Hoonki Lee27511902013-03-14 18:19:06 -0700993 if ((FALSE == pHddCtx->cfg_ini->fEnableTDLSSupport) ||
994 (FALSE == sme_IsFeatureSupportedByFW(TDLS)))
995 {
996 pHddCtx->tdls_mode = eTDLS_SUPPORT_NOT_ENABLED;
997 pAdapter->sessionCtx.station.pHddTdlsCtx = NULL;
Ratheesh S P36dbc932015-08-07 14:28:57 +0530998 hddLog(VOS_TRACE_LEVEL_INFO, "%s TDLS not enabled (%d) or FW doesn't support (%d)!",
Hoonki Lee27511902013-03-14 18:19:06 -0700999 __func__, pHddCtx->cfg_ini->fEnableTDLSSupport,
1000 sme_IsFeatureSupportedByFW(TDLS));
Mahesh A Saptasagar170b5082015-02-16 18:50:54 +05301001 return -EINVAL;
Gopichand Nakkala4327a152013-03-04 23:22:42 -08001002 }
Madan Mohan Koyyalamudi81746922013-07-17 14:38:51 +05301003 /* TDLS is supported only in STA / P2P Client modes,
1004 * hence the check for TDLS support in a specific Device mode.
Madan Mohan Koyyalamudi81746922013-07-17 14:38:51 +05301005 */
1006 if (0 == WLAN_HDD_IS_TDLS_SUPPORTED_ADAPTER(pAdapter))
1007 {
Mahesh A Saptasagar36cdc802015-01-07 18:41:17 +05301008 hddLog(VOS_TRACE_LEVEL_ERROR, "%s TDLS is not supported in mode : %d", __func__, pAdapter->device_mode);
Mahesh A Saptasagar170b5082015-02-16 18:50:54 +05301009 return -EINVAL;
Madan Mohan Koyyalamudi81746922013-07-17 14:38:51 +05301010 }
1011 /* Check for the valid pHddTdlsCtx. If valid do not further
1012 * allocate the memory, rather continue with the initialization.
1013 * If tdls_initialization would get reinvoked without tdls_exit
1014 * getting invoked (SSR) there is no point to further proceed
1015 * with the memory allocations.
1016 */
1017 if (NULL == pAdapter->sessionCtx.station.pHddTdlsCtx)
1018 {
1019 pHddTdlsCtx = vos_mem_malloc(sizeof(tdlsCtx_t));
Gopichand Nakkala4327a152013-03-04 23:22:42 -08001020
Madan Mohan Koyyalamudi81746922013-07-17 14:38:51 +05301021 if (NULL == pHddTdlsCtx) {
1022 hddLog(VOS_TRACE_LEVEL_ERROR, "%s malloc failed!", __func__);
1023 pAdapter->sessionCtx.station.pHddTdlsCtx = NULL;
Mahesh A Saptasagar170b5082015-02-16 18:50:54 +05301024 return -ENOMEM;
Madan Mohan Koyyalamudi81746922013-07-17 14:38:51 +05301025 }
1026 /* initialize TDLS pAdater context */
1027 vos_mem_zero(pHddTdlsCtx, sizeof(tdlsCtx_t));
1028#ifdef TDLS_USE_SEPARATE_DISCOVERY_TIMER
1029 vos_timer_init(&pHddTdlsCtx->peerDiscoverTimer,
1030 VOS_TIMER_TYPE_SW,
1031 wlan_hdd_tdls_discover_peer_cb,
1032 pHddTdlsCtx);
1033#endif
Hoonki Lee27511902013-03-14 18:19:06 -07001034
Madan Mohan Koyyalamudi81746922013-07-17 14:38:51 +05301035 vos_timer_init(&pHddTdlsCtx->peerUpdateTimer,
1036 VOS_TIMER_TYPE_SW,
1037 wlan_hdd_tdls_update_peer_cb,
1038 pHddTdlsCtx);
1039 vos_timer_init(&pHddTdlsCtx->peerDiscoveryTimeoutTimer,
1040 VOS_TIMER_TYPE_SW,
1041 wlan_hdd_tdls_discovery_timeout_peer_cb,
1042 pHddTdlsCtx);
1043
1044 pAdapter->sessionCtx.station.pHddTdlsCtx = pHddTdlsCtx;
Hoonki Lee27511902013-03-14 18:19:06 -07001045 }
1046
Madan Mohan Koyyalamudi81746922013-07-17 14:38:51 +05301047 pHddTdlsCtx = pAdapter->sessionCtx.station.pHddTdlsCtx;
Hoonki Lee27511902013-03-14 18:19:06 -07001048
Gopichand Nakkalaccd3a382013-03-19 13:56:10 -07001049 sme_SetTdlsPowerSaveProhibited(WLAN_HDD_GET_HAL_CTX(pAdapter), 0);
Hoonki Lee27511902013-03-14 18:19:06 -07001050
Hoonki Lee27511902013-03-14 18:19:06 -07001051 pHddTdlsCtx->pAdapter = pAdapter;
1052
1053 for (i = 0; i < 256; i++)
1054 {
1055 INIT_LIST_HEAD(&pHddTdlsCtx->peer_list[i]);
1056 }
1057
Hoonki Leed37cbb32013-04-20 00:31:14 -07001058 pHddTdlsCtx->curr_candidate = NULL;
1059 pHddTdlsCtx->magic = 0;
1060
Hoonki Lee27511902013-03-14 18:19:06 -07001061 /* remember configuration even if it is not used right now. it could be used later */
1062 pHddTdlsCtx->threshold_config.tx_period_t = pHddCtx->cfg_ini->fTDLSTxStatsPeriod;
1063 pHddTdlsCtx->threshold_config.tx_packet_n = pHddCtx->cfg_ini->fTDLSTxPacketThreshold;
1064 pHddTdlsCtx->threshold_config.discovery_period_t = pHddCtx->cfg_ini->fTDLSDiscoveryPeriod;
1065 pHddTdlsCtx->threshold_config.discovery_tries_n = pHddCtx->cfg_ini->fTDLSMaxDiscoveryAttempt;
1066 pHddTdlsCtx->threshold_config.idle_timeout_t = pHddCtx->cfg_ini->fTDLSIdleTimeout;
1067 pHddTdlsCtx->threshold_config.idle_packet_n = pHddCtx->cfg_ini->fTDLSIdlePacketThreshold;
1068 pHddTdlsCtx->threshold_config.rssi_hysteresis = pHddCtx->cfg_ini->fTDLSRSSIHysteresis;
1069 pHddTdlsCtx->threshold_config.rssi_trigger_threshold = pHddCtx->cfg_ini->fTDLSRSSITriggerThreshold;
1070 pHddTdlsCtx->threshold_config.rssi_teardown_threshold = pHddCtx->cfg_ini->fTDLSRSSITeardownThreshold;
Chilam NG571c65a2013-01-19 12:27:36 +05301071
Anand N Sunkaddc63c792015-06-03 14:33:24 +05301072 vos_init_delayed_work(&pHddCtx->tdls_scan_ctxt.tdls_scan_work,
1073 wlan_hdd_tdls_schedule_scan);
1074 set_bit(TDLS_INIT_DONE, &pAdapter->event_flags);
Hoonki Lee27511902013-03-14 18:19:06 -07001075
1076 return 0;
Chilam NG571c65a2013-01-19 12:27:36 +05301077}
1078
Pradeep Reddy POTTETI2d4d5c42015-03-03 14:34:19 +05301079void wlan_hdd_tdls_exit(hdd_adapter_t *pAdapter, tANI_BOOLEAN mutexLock)
Chilam NG571c65a2013-01-19 12:27:36 +05301080{
Gopichand Nakkala4327a152013-03-04 23:22:42 -08001081 tdlsCtx_t *pHddTdlsCtx;
Hoonki Lee93e67ff2013-03-19 15:49:25 -07001082 hdd_context_t *pHddCtx;
Gopichand Nakkala4327a152013-03-04 23:22:42 -08001083
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +05301084 if (!pAdapter) {
1085 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD adpater is NULL"));
1086 return;
1087 }
1088
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05301089 /*
1090 * NOTE: The Callers of this function should ensure to acquire the
Mahesh A Saptasagarf5b8eff2015-01-31 01:07:07 +05301091 * tdls_lock to avoid any concurrent access to the Adapter and logp
1092 * protection has to be ensured.
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05301093 */
1094
Madan Mohan Koyyalamudi263cec12013-10-07 10:57:50 +05301095 pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
Agarwal Ashish9ffa5b92014-11-18 21:07:02 +05301096
1097 if (NULL == pHddCtx || NULL == pHddCtx->cfg_ini)
Madan Mohan Koyyalamudi263cec12013-10-07 10:57:50 +05301098 {
Agarwal Ashish9ffa5b92014-11-18 21:07:02 +05301099 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1100 "%s: HDD context is Null", __func__);
1101 return ;
1102 }
Mahesh A Saptasagarf5b8eff2015-01-31 01:07:07 +05301103 if (!test_bit(TDLS_INIT_DONE, &pAdapter->event_flags))
Agarwal Ashish9ffa5b92014-11-18 21:07:02 +05301104 {
Ratheesh S P36dbc932015-08-07 14:28:57 +05301105 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Mahesh A Saptasagarf5b8eff2015-01-31 01:07:07 +05301106 "%s: TDLS INIT DONE set to 0, no point in exit", __func__);
1107 return;
Madan Mohan Koyyalamudi263cec12013-10-07 10:57:50 +05301108 }
Mahesh A Saptasagarf5b8eff2015-01-31 01:07:07 +05301109 clear_bit(TDLS_INIT_DONE, &pAdapter->event_flags);
Madan Mohan Koyyalamudi263cec12013-10-07 10:57:50 +05301110
Gopichand Nakkala4327a152013-03-04 23:22:42 -08001111 pHddTdlsCtx = WLAN_HDD_GET_TDLS_CTX_PTR(pAdapter);
Gopichand Nakkala91b09262013-02-10 14:27:02 -08001112 if (NULL == pHddTdlsCtx)
1113 {
Ratheesh S P36dbc932015-08-07 14:28:57 +05301114 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
c_hpothu7f63e882013-10-02 19:13:35 +05301115 FL("pHddTdlsCtx is NULL"));
Hoonki Leebfee0342013-01-21 16:43:45 -08001116 return;
1117 }
Mahesh A Saptasagarf5b8eff2015-01-31 01:07:07 +05301118
Anand N Sunkad860e5ea2015-03-30 14:41:51 +05301119 vos_flush_delayed_work(&pHddCtx->tdls_scan_ctxt.tdls_scan_work);
Hoonki Leebfee0342013-01-21 16:43:45 -08001120
Gopichand Nakkala91b09262013-02-10 14:27:02 -08001121 /* must stop timer here before freeing peer list, because peerIdleTimer is
1122 part of peer list structure. */
Gopichand Nakkala4327a152013-03-04 23:22:42 -08001123 wlan_hdd_tdls_timers_destroy(pHddTdlsCtx);
1124 wlan_hdd_tdls_free_list(pHddTdlsCtx);
Chilam Nga75d8b62013-01-29 01:35:59 -08001125
Hoonki Lee93e67ff2013-03-19 15:49:25 -07001126 wlan_hdd_tdls_free_scan_request(&pHddCtx->tdls_scan_ctxt);
Sushant Kaushik15c4c522014-08-14 12:24:49 +05301127 pHddTdlsCtx->magic = 0;
1128 pHddTdlsCtx->pAdapter = NULL;
Chilam Nga75d8b62013-01-29 01:35:59 -08001129 vos_mem_free(pHddTdlsCtx);
Pradeep Reddy POTTETI59c90d62014-03-24 19:45:47 +05301130 pAdapter->sessionCtx.station.pHddTdlsCtx = NULL;
Chilam Nga75d8b62013-01-29 01:35:59 -08001131 pHddTdlsCtx = NULL;
Chilam NG571c65a2013-01-19 12:27:36 +05301132}
1133
Madan Mohan Koyyalamudi693275b2013-07-22 19:14:09 +05301134/* stop all monitoring timers per Adapter */
1135static void wlan_hdd_tdls_monitor_timers_stop(tdlsCtx_t *pHddTdlsCtx)
Gopichand Nakkalac3694582013-02-13 20:51:22 -08001136{
Hoonki Leed37cbb32013-04-20 00:31:14 -07001137#ifdef TDLS_USE_SEPARATE_DISCOVERY_TIMER
Gopichand Nakkalac3694582013-02-13 20:51:22 -08001138 vos_timer_stop(&pHddTdlsCtx->peerDiscoverTimer);
Hoonki Leed37cbb32013-04-20 00:31:14 -07001139#endif
Gopichand Nakkalac3694582013-02-13 20:51:22 -08001140 vos_timer_stop(&pHddTdlsCtx->peerUpdateTimer);
Gopichand Nakkala75e7b282013-03-15 18:37:13 -07001141 vos_timer_stop(&pHddTdlsCtx->peerDiscoveryTimeoutTimer);
Madan Mohan Koyyalamudi693275b2013-07-22 19:14:09 +05301142}
Gopichand Nakkalac3694582013-02-13 20:51:22 -08001143
Madan Mohan Koyyalamudi693275b2013-07-22 19:14:09 +05301144/* stop all per peer timers */
1145static void wlan_hdd_tdls_peer_timers_stop(tdlsCtx_t *pHddTdlsCtx)
1146{
1147 int i;
1148 struct list_head *head;
1149 struct list_head *pos;
1150 hddTdlsPeer_t *curr_peer;
Gopichand Nakkalac3694582013-02-13 20:51:22 -08001151 for (i = 0; i < 256; i++)
1152 {
1153 head = &pHddTdlsCtx->peer_list[i];
Gopichand Nakkalac3694582013-02-13 20:51:22 -08001154 list_for_each (pos, head) {
1155 curr_peer = list_entry (pos, hddTdlsPeer_t, node);
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +05301156 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Chilam Ng01120412013-02-19 18:32:21 -08001157 "%s: " MAC_ADDRESS_STR " -> stop idle timer",
Gopichand Nakkalac3694582013-02-13 20:51:22 -08001158 __func__,
Chilam Ng01120412013-02-19 18:32:21 -08001159 MAC_ADDR_ARRAY(curr_peer->peerMac));
Gopichand Nakkalac3694582013-02-13 20:51:22 -08001160 vos_timer_stop ( &curr_peer->peerIdleTimer );
Ganesh Kondabattinicbfdc392015-09-11 19:12:59 +05301161 if (vos_timer_is_initialized(&curr_peer->initiatorWaitTimeoutTimer))
1162 vos_timer_stop( &curr_peer->initiatorWaitTimeoutTimer );
Gopichand Nakkalac3694582013-02-13 20:51:22 -08001163 }
1164 }
Gopichand Nakkalac3694582013-02-13 20:51:22 -08001165}
1166
Madan Mohan Koyyalamudi693275b2013-07-22 19:14:09 +05301167/* stop all the tdls timers running */
1168static void wlan_hdd_tdls_timers_stop(tdlsCtx_t *pHddTdlsCtx)
Gopichand Nakkala91b09262013-02-10 14:27:02 -08001169{
Madan Mohan Koyyalamudi693275b2013-07-22 19:14:09 +05301170 wlan_hdd_tdls_monitor_timers_stop(pHddTdlsCtx);
1171 wlan_hdd_tdls_peer_timers_stop(pHddTdlsCtx);
1172}
Gopichand Nakkala91b09262013-02-10 14:27:02 -08001173
Madan Mohan Koyyalamudi693275b2013-07-22 19:14:09 +05301174static void wlan_hdd_tdls_monitor_timers_destroy(tdlsCtx_t *pHddTdlsCtx)
1175{
Hoonki Leed37cbb32013-04-20 00:31:14 -07001176#ifdef TDLS_USE_SEPARATE_DISCOVERY_TIMER
Gopichand Nakkala91b09262013-02-10 14:27:02 -08001177 vos_timer_stop(&pHddTdlsCtx->peerDiscoverTimer);
1178 vos_timer_destroy(&pHddTdlsCtx->peerDiscoverTimer);
Hoonki Leed37cbb32013-04-20 00:31:14 -07001179#endif
Gopichand Nakkala91b09262013-02-10 14:27:02 -08001180 vos_timer_stop(&pHddTdlsCtx->peerUpdateTimer);
1181 vos_timer_destroy(&pHddTdlsCtx->peerUpdateTimer);
Gopichand Nakkala75e7b282013-03-15 18:37:13 -07001182 vos_timer_stop(&pHddTdlsCtx->peerDiscoveryTimeoutTimer);
1183 vos_timer_destroy(&pHddTdlsCtx->peerDiscoveryTimeoutTimer);
Madan Mohan Koyyalamudi693275b2013-07-22 19:14:09 +05301184}
1185/*Free all the timers related to the TDLS peer */
1186static void wlan_hdd_tdls_peer_timers_destroy(tdlsCtx_t *pHddTdlsCtx)
1187{
1188 int i;
1189 struct list_head *head;
1190 struct list_head *pos;
1191 hddTdlsPeer_t *curr_peer;
Gopichand Nakkala91b09262013-02-10 14:27:02 -08001192 for (i = 0; i < 256; i++)
1193 {
1194 head = &pHddTdlsCtx->peer_list[i];
1195
1196 list_for_each (pos, head) {
1197 curr_peer = list_entry (pos, hddTdlsPeer_t, node);
1198
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +05301199 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Chilam Ng01120412013-02-19 18:32:21 -08001200 "%s: " MAC_ADDRESS_STR " -> destroy idle timer",
Gopichand Nakkala91b09262013-02-10 14:27:02 -08001201 __func__,
Chilam Ng01120412013-02-19 18:32:21 -08001202 MAC_ADDR_ARRAY(curr_peer->peerMac));
Gopichand Nakkala91b09262013-02-10 14:27:02 -08001203 vos_timer_stop ( &curr_peer->peerIdleTimer );
1204 vos_timer_destroy ( &curr_peer->peerIdleTimer );
Ganesh Kondabattinicbfdc392015-09-11 19:12:59 +05301205 if (vos_timer_is_initialized(&curr_peer->initiatorWaitTimeoutTimer))
1206 {
1207 vos_timer_stop(&curr_peer->initiatorWaitTimeoutTimer);
1208 vos_timer_destroy(&curr_peer->initiatorWaitTimeoutTimer);
1209 }
Gopichand Nakkala91b09262013-02-10 14:27:02 -08001210 }
1211 }
Madan Mohan Koyyalamudi693275b2013-07-22 19:14:09 +05301212
1213}
1214
1215/* destroy all the tdls timers running */
1216static void wlan_hdd_tdls_timers_destroy(tdlsCtx_t *pHddTdlsCtx)
1217{
1218 wlan_hdd_tdls_monitor_timers_destroy(pHddTdlsCtx);
1219 wlan_hdd_tdls_peer_timers_destroy(pHddTdlsCtx);
Gopichand Nakkala91b09262013-02-10 14:27:02 -08001220}
1221
Hoonki Lee387663d2013-02-05 18:08:43 -08001222/* if mac address exist, return pointer
1223 if mac address doesn't exist, create a list and add, return pointer
1224 return NULL if fails to get new mac address
1225*/
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +05301226hddTdlsPeer_t *wlan_hdd_tdls_get_peer(hdd_adapter_t *pAdapter,
1227#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
1228 const u8 *mac
1229#else
1230 u8 *mac
1231#endif
1232 )
Chilam NG571c65a2013-01-19 12:27:36 +05301233{
Hoonki Lee387663d2013-02-05 18:08:43 -08001234 struct list_head *head;
1235 hddTdlsPeer_t *peer;
1236 u8 key;
Gopichand Nakkala4ddf0192013-03-27 13:41:20 -07001237 tdlsCtx_t *pHddTdlsCtx;
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +05301238 hdd_context_t *pHddCtx;
Madan Mohan Koyyalamudi263cec12013-10-07 10:57:50 +05301239
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +05301240
1241 if (!pAdapter) {
1242 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD adpater is NULL"));
1243 return NULL;
1244 }
1245
1246 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1247 if (0 != (wlan_hdd_validate_context(pHddCtx)))
c_hpothu7f63e882013-10-02 19:13:35 +05301248 {
c_hpothu7f63e882013-10-02 19:13:35 +05301249 return 0;
1250 }
Hoonki Leebfee0342013-01-21 16:43:45 -08001251
Hoonki Lee387663d2013-02-05 18:08:43 -08001252 /* if already there, just update */
Masti, Narayanraddi6dbcdbb2015-05-13 10:28:06 +05301253 peer = wlan_hdd_tdls_find_peer(pAdapter, mac, FALSE);
Hoonki Lee387663d2013-02-05 18:08:43 -08001254 if (peer != NULL)
1255 {
1256 return peer;
Chilam NG571c65a2013-01-19 12:27:36 +05301257 }
1258
Hoonki Lee387663d2013-02-05 18:08:43 -08001259 /* not found, allocate and add the list */
1260 peer = vos_mem_malloc(sizeof(hddTdlsPeer_t));
1261 if (NULL == peer) {
1262 hddLog(VOS_TRACE_LEVEL_ERROR, "%s peer malloc failed!", __func__);
1263 return NULL;
1264 }
Chilam NG571c65a2013-01-19 12:27:36 +05301265
Gopichand Nakkala4ddf0192013-03-27 13:41:20 -07001266 pHddTdlsCtx = WLAN_HDD_GET_TDLS_CTX_PTR(pAdapter);
1267
1268 if (NULL == pHddTdlsCtx)
1269 {
1270 vos_mem_free(peer);
Hema Aparna Medicharla8bb6f782015-03-09 12:35:05 +05301271 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1272 FL("pHddTdlsCtx is NULL"));
Gopichand Nakkala4ddf0192013-03-27 13:41:20 -07001273 return NULL;
1274 }
1275
1276 key = wlan_hdd_tdls_hash_key(mac);
1277 head = &pHddTdlsCtx->peer_list[key];
Chilam NG571c65a2013-01-19 12:27:36 +05301278
Hoonki Lee387663d2013-02-05 18:08:43 -08001279 vos_mem_zero(peer, sizeof(hddTdlsPeer_t));
1280 vos_mem_copy(peer->peerMac, mac, sizeof(peer->peerMac));
Gopichand Nakkala4327a152013-03-04 23:22:42 -08001281 peer->pHddTdlsCtx = pHddTdlsCtx;
Hoonki Lee387663d2013-02-05 18:08:43 -08001282
Gopichand Nakkala91b09262013-02-10 14:27:02 -08001283 vos_timer_init(&peer->peerIdleTimer,
1284 VOS_TIMER_TYPE_SW,
1285 wlan_hdd_tdls_idle_cb,
1286 peer);
Hoonki Lee387663d2013-02-05 18:08:43 -08001287 list_add_tail(&peer->node, head);
Hoonki Lee387663d2013-02-05 18:08:43 -08001288
1289 return peer;
1290}
1291
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07001292int wlan_hdd_tdls_set_cap(hdd_adapter_t *pAdapter,
Anand N Sunkad9bfc2622015-07-30 15:18:54 +05301293#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
1294 const u8* mac,
1295#else
Hoonki Lee27511902013-03-14 18:19:06 -07001296 u8* mac,
Anand N Sunkad9bfc2622015-07-30 15:18:54 +05301297#endif
Hoonki Lee27511902013-03-14 18:19:06 -07001298 tTDLSCapType cap)
1299{
1300 hddTdlsPeer_t *curr_peer;
Masti, Narayanraddi6dbcdbb2015-05-13 10:28:06 +05301301 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Hoonki Lee27511902013-03-14 18:19:06 -07001302
Masti, Narayanraddi6dbcdbb2015-05-13 10:28:06 +05301303 if (0 != (wlan_hdd_validate_context(pHddCtx)))
1304 return -EINVAL;
1305
1306 mutex_lock(&pHddCtx->tdls_lock);
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07001307 curr_peer = wlan_hdd_tdls_get_peer(pAdapter, mac);
Hoonki Lee27511902013-03-14 18:19:06 -07001308 if (curr_peer == NULL)
c_hpothu7f63e882013-10-02 19:13:35 +05301309 {
1310 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1311 "%s: curr_peer is NULL", __func__);
Masti, Narayanraddi6dbcdbb2015-05-13 10:28:06 +05301312 mutex_unlock(&pHddCtx->tdls_lock);
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07001313 return -1;
c_hpothu7f63e882013-10-02 19:13:35 +05301314 }
Hoonki Lee27511902013-03-14 18:19:06 -07001315
1316 curr_peer->tdls_support = cap;
1317
Masti, Narayanraddi6dbcdbb2015-05-13 10:28:06 +05301318 mutex_unlock(&pHddCtx->tdls_lock);
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07001319 return 0;
Hoonki Lee27511902013-03-14 18:19:06 -07001320}
1321
Atul Mittal115287b2014-07-08 13:26:33 +05301322void wlan_hdd_tdls_set_peer_link_status(hddTdlsPeer_t *curr_peer,
1323 tTDLSLinkStatus status,
1324 tTDLSLinkReason reason)
Hoonki Lee387663d2013-02-05 18:08:43 -08001325{
Atul Mittal115287b2014-07-08 13:26:33 +05301326 /*EXT TDLS*/
1327 tANI_S32 state = 0;
1328 tANI_S32 res = 0;
1329 /*EXT TDLS*/
Hoonki Lee387663d2013-02-05 18:08:43 -08001330 if (curr_peer == NULL)
c_hpothu7f63e882013-10-02 19:13:35 +05301331 {
1332 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1333 "%s: curr_peer is NULL", __func__);
Hoonki Lee387663d2013-02-05 18:08:43 -08001334 return;
c_hpothu7f63e882013-10-02 19:13:35 +05301335 }
Hoonki Lee387663d2013-02-05 18:08:43 -08001336
Gopichand Nakkala8b00c632013-03-08 19:47:52 -08001337 hddLog(VOS_TRACE_LEVEL_WARN, "tdls set peer " MAC_ADDRESS_STR " link status to %u",
Chilam Ng01120412013-02-19 18:32:21 -08001338 MAC_ADDR_ARRAY(curr_peer->peerMac), status);
Chilam NG571c65a2013-01-19 12:27:36 +05301339
1340 curr_peer->link_status = status;
1341
Atul Mittal115287b2014-07-08 13:26:33 +05301342 /*EXT TDLS*/
1343 if (curr_peer->isForcedPeer && curr_peer->state_change_notification)
1344 {
1345 /*save the reason for any further query*/
1346 curr_peer->reason = reason;
1347 wlan_hdd_tdls_get_wifi_hal_state(curr_peer, &state, &res);
1348
1349 (curr_peer->state_change_notification)(
1350 curr_peer->peerMac,
1351 state,
1352 res,
1353 curr_peer->pHddTdlsCtx->pAdapter);
1354
1355 }
1356 /*EXT TDLS*/
1357
Chilam NG571c65a2013-01-19 12:27:36 +05301358}
1359
Gopichand Nakkala8b00c632013-03-08 19:47:52 -08001360void wlan_hdd_tdls_set_link_status(hdd_adapter_t *pAdapter,
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +05301361#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
1362 const u8 *mac,
1363#else
1364 u8 *mac,
1365#endif
Atul Mittal115287b2014-07-08 13:26:33 +05301366 tTDLSLinkStatus linkStatus,
1367 tTDLSLinkReason reason)
Gopichand Nakkala8b00c632013-03-08 19:47:52 -08001368{
Atul Mittal115287b2014-07-08 13:26:33 +05301369
1370 /*EXT TDLS*/
1371 tANI_S32 state = 0;
1372 tANI_S32 res = 0;
1373 /*EXT TDLS*/
Gopichand Nakkala8b00c632013-03-08 19:47:52 -08001374 hddTdlsPeer_t *curr_peer;
1375
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05301376 curr_peer = wlan_hdd_tdls_find_peer(pAdapter, mac, TRUE);
Gopichand Nakkala8b00c632013-03-08 19:47:52 -08001377 if (curr_peer == NULL)
c_hpothu7f63e882013-10-02 19:13:35 +05301378 {
1379 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1380 "%s: curr_peer is NULL", __func__);
Gopichand Nakkala8b00c632013-03-08 19:47:52 -08001381 return;
c_hpothu7f63e882013-10-02 19:13:35 +05301382 }
Gopichand Nakkala8b00c632013-03-08 19:47:52 -08001383
1384 curr_peer->link_status= linkStatus;
1385
Atul Mittal115287b2014-07-08 13:26:33 +05301386 /*EXT TDLS*/
1387
1388 if (curr_peer->isForcedPeer && curr_peer->state_change_notification)
1389 {
1390 /*save the reason for any further query*/
1391 curr_peer->reason = reason;
1392 wlan_hdd_tdls_get_wifi_hal_state(curr_peer, &state, &res);
1393
1394 (*curr_peer->state_change_notification)(mac,
1395 state,
1396 res,
1397 curr_peer->pHddTdlsCtx->pAdapter);
1398
1399 }
1400 /*EXT TDLS*/
Gopichand Nakkala8b00c632013-03-08 19:47:52 -08001401 return;
1402}
1403
Gopichand Nakkala4327a152013-03-04 23:22:42 -08001404int wlan_hdd_tdls_recv_discovery_resp(hdd_adapter_t *pAdapter, u8 *mac)
Chilam NG571c65a2013-01-19 12:27:36 +05301405{
1406 hddTdlsPeer_t *curr_peer;
Gopichand Nakkala75e7b282013-03-15 18:37:13 -07001407 tdlsCtx_t *pHddTdlsCtx = WLAN_HDD_GET_TDLS_CTX_PTR(pAdapter);
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05301408 hdd_context_t *pHddCtx;
1409
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301410 ENTER();
1411
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05301412 if ( NULL == pHddTdlsCtx )
c_hpothu7f63e882013-10-02 19:13:35 +05301413 {
1414 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Mahesh A Saptasagar36cdc802015-01-07 18:41:17 +05301415 FL("pHddTdlsCtx is NULL device mode = %d"), pAdapter->device_mode);
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05301416 return -1;
c_hpothu7f63e882013-10-02 19:13:35 +05301417 }
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05301418
1419 pHddCtx = WLAN_HDD_GET_CTX(pHddTdlsCtx->pAdapter);
1420
c_hpothu7f63e882013-10-02 19:13:35 +05301421 if(0 != (wlan_hdd_validate_context(pHddCtx)))
1422 {
c_hpothu7f63e882013-10-02 19:13:35 +05301423 return 0;
1424 }
Chilam NG571c65a2013-01-19 12:27:36 +05301425
Masti, Narayanraddi6dbcdbb2015-05-13 10:28:06 +05301426 mutex_lock(&pHddCtx->tdls_lock);
Gopichand Nakkala4327a152013-03-04 23:22:42 -08001427 curr_peer = wlan_hdd_tdls_get_peer(pAdapter, mac);
Gopichand Nakkala75e7b282013-03-15 18:37:13 -07001428
1429 if (NULL == curr_peer)
c_hpothu7f63e882013-10-02 19:13:35 +05301430 {
1431 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1432 FL("curr_peer is NULL"));
Masti, Narayanraddi6dbcdbb2015-05-13 10:28:06 +05301433 mutex_unlock(&pHddCtx->tdls_lock);
Hoonki Lee387663d2013-02-05 18:08:43 -08001434 return -1;
c_hpothu7f63e882013-10-02 19:13:35 +05301435 }
Masti, Narayanraddi6dbcdbb2015-05-13 10:28:06 +05301436 mutex_unlock(&pHddCtx->tdls_lock);
Gopichand Nakkala75e7b282013-03-15 18:37:13 -07001437
1438 if (pHddTdlsCtx->discovery_sent_cnt)
1439 pHddTdlsCtx->discovery_sent_cnt--;
1440
Rajesh Chauhana34c6e62014-03-25 16:37:58 +05301441 mutex_lock(&pHddCtx->tdls_lock);
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05301442
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07001443 wlan_hdd_tdls_check_power_save_prohibited(pAdapter);
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05301444
1445 mutex_unlock(&pHddCtx->tdls_lock);
Gopichand Nakkala75e7b282013-03-15 18:37:13 -07001446 if (0 == pHddTdlsCtx->discovery_sent_cnt)
Gopichand Nakkalaccd3a382013-03-19 13:56:10 -07001447 {
Gopichand Nakkala75e7b282013-03-15 18:37:13 -07001448 vos_timer_stop(&pHddTdlsCtx->peerDiscoveryTimeoutTimer);
Gopichand Nakkalaccd3a382013-03-19 13:56:10 -07001449 }
Gopichand Nakkala75e7b282013-03-15 18:37:13 -07001450
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +05301451 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07001452 "Discovery(%u) Response from " MAC_ADDRESS_STR " link_status %d",
Gopichand Nakkala75e7b282013-03-15 18:37:13 -07001453 pHddTdlsCtx->discovery_sent_cnt, MAC_ADDR_ARRAY(curr_peer->peerMac),
1454 curr_peer->link_status);
1455
Gopichand Nakkala8b00c632013-03-08 19:47:52 -08001456 if (eTDLS_LINK_DISCOVERING == curr_peer->link_status)
Gopichand Nakkala901e8922013-03-04 23:45:58 -08001457 {
Shailender Karmuchi13c0d082013-03-26 14:41:39 -07001458 /* Since we are here, it means Throughput threshold is alredy met. Make sure RSSI
1459 threshold is also met before setting up TDLS link*/
1460 if ((tANI_S32) curr_peer->rssi > (tANI_S32) pHddTdlsCtx->threshold_config.rssi_trigger_threshold)
1461 {
Atul Mittal115287b2014-07-08 13:26:33 +05301462 wlan_hdd_tdls_set_peer_link_status(curr_peer,
1463 eTDLS_LINK_DISCOVERED,
1464 eTDLS_LINK_SUCCESS);
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +05301465 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Shailender Karmuchi13c0d082013-03-26 14:41:39 -07001466 "Rssi Threshold met: "MAC_ADDRESS_STR" rssi = %d threshold= %d" ,
1467 MAC_ADDR_ARRAY(curr_peer->peerMac), curr_peer->rssi,
1468 pHddTdlsCtx->threshold_config.rssi_trigger_threshold);
1469 cfg80211_tdls_oper_request(pAdapter->dev, curr_peer->peerMac, NL80211_TDLS_SETUP, FALSE, GFP_KERNEL);
1470 }
1471 else
1472 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +05301473 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Shailender Karmuchi13c0d082013-03-26 14:41:39 -07001474 "Rssi Threshold not met: "MAC_ADDRESS_STR" rssi = %d threshold = %d ",
1475 MAC_ADDR_ARRAY(curr_peer->peerMac), curr_peer->rssi,
1476 pHddTdlsCtx->threshold_config.rssi_trigger_threshold);
Sunil Duttb0d39242014-09-10 23:54:51 +05301477
1478 /* if RSSI threshold is not met then allow further discovery
1479 * attempts by decrementing count for the last attempt
1480 */
1481 if (curr_peer->discovery_attempt)
1482 curr_peer->discovery_attempt--;
1483
Atul Mittal115287b2014-07-08 13:26:33 +05301484 wlan_hdd_tdls_set_peer_link_status(curr_peer,
1485 eTDLS_LINK_IDLE,
1486 eTDLS_LINK_UNSPECIFIED);
Shailender Karmuchi13c0d082013-03-26 14:41:39 -07001487 }
Gopichand Nakkala901e8922013-03-04 23:45:58 -08001488 }
Gopichand Nakkalaccd3a382013-03-19 13:56:10 -07001489 else
1490 {
1491 wlan_hdd_tdls_check_bmps(pAdapter);
1492 }
Chilam NG571c65a2013-01-19 12:27:36 +05301493
Gopichand Nakkala901e8922013-03-04 23:45:58 -08001494 curr_peer->tdls_support = eTDLS_CAP_SUPPORTED;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301495 EXIT();
Hoonki Lee387663d2013-02-05 18:08:43 -08001496 return 0;
Chilam NG571c65a2013-01-19 12:27:36 +05301497}
1498
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05301499int wlan_hdd_tdls_set_peer_caps(hdd_adapter_t *pAdapter,
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +05301500#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
1501 const u8 *mac,
1502#else
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05301503 u8 *mac,
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +05301504#endif
Naresh Jayaram3180aa42014-02-12 21:47:26 +05301505 tCsrStaParams *StaParams,
1506 tANI_BOOLEAN isBufSta,
1507 tANI_BOOLEAN isOffChannelSupported)
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05301508{
1509 hddTdlsPeer_t *curr_peer;
Masti, Narayanraddi6dbcdbb2015-05-13 10:28:06 +05301510 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05301511
Masti, Narayanraddi6dbcdbb2015-05-13 10:28:06 +05301512 if (0 != (wlan_hdd_validate_context(pHddCtx)))
1513 return -EINVAL;
1514
1515 mutex_lock(&pHddCtx->tdls_lock);
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05301516 curr_peer = wlan_hdd_tdls_get_peer(pAdapter, mac);
1517 if (curr_peer == NULL)
c_hpothu7f63e882013-10-02 19:13:35 +05301518 {
1519 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1520 "%s: curr_peer is NULL", __func__);
Masti, Narayanraddi6dbcdbb2015-05-13 10:28:06 +05301521 mutex_unlock(&pHddCtx->tdls_lock);
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05301522 return -1;
c_hpothu7f63e882013-10-02 19:13:35 +05301523 }
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05301524
Naresh Jayaram3180aa42014-02-12 21:47:26 +05301525 curr_peer->uapsdQueues = StaParams->uapsd_queues;
1526 curr_peer->maxSp = StaParams->max_sp;
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05301527 curr_peer->isBufSta = isBufSta;
Naresh Jayaram3180aa42014-02-12 21:47:26 +05301528 curr_peer->isOffChannelSupported = isOffChannelSupported;
1529
1530 vos_mem_copy(curr_peer->supported_channels,
1531 StaParams->supported_channels,
1532 StaParams->supported_channels_len);
1533
1534 curr_peer->supported_channels_len =
1535 StaParams->supported_channels_len;
1536
1537 vos_mem_copy(curr_peer->supported_oper_classes,
1538 StaParams->supported_oper_classes,
1539 StaParams->supported_oper_classes_len);
1540
1541 curr_peer->supported_oper_classes_len =
1542 StaParams->supported_oper_classes_len;
Agarwal Ashish16020c42014-12-29 22:01:11 +05301543 curr_peer->qos = StaParams->capability & CAPABILITIES_QOS_OFFSET;
Masti, Narayanraddi6dbcdbb2015-05-13 10:28:06 +05301544
1545 mutex_unlock(&pHddCtx->tdls_lock);
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05301546 return 0;
1547}
1548
Anand N Sunkad9bfc2622015-07-30 15:18:54 +05301549int wlan_hdd_tdls_get_link_establish_params(hdd_adapter_t *pAdapter,
1550#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
1551 const u8 *mac,
1552#else
1553 u8 *mac,
1554#endif
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05301555 tCsrTdlsLinkEstablishParams* tdlsLinkEstablishParams)
1556{
1557 hddTdlsPeer_t *curr_peer;
Masti, Narayanraddi6dbcdbb2015-05-13 10:28:06 +05301558 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05301559
Masti, Narayanraddi6dbcdbb2015-05-13 10:28:06 +05301560 if (0 != (wlan_hdd_validate_context(pHddCtx)))
1561 return -EINVAL;
1562
1563 mutex_lock(&pHddCtx->tdls_lock);
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05301564 curr_peer = wlan_hdd_tdls_get_peer(pAdapter, mac);
1565 if (curr_peer == NULL)
c_hpothu7f63e882013-10-02 19:13:35 +05301566 {
1567 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1568 "%s: curr_peer is NULL", __func__);
Masti, Narayanraddi6dbcdbb2015-05-13 10:28:06 +05301569 mutex_unlock(&pHddCtx->tdls_lock);
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05301570 return -1;
c_hpothu7f63e882013-10-02 19:13:35 +05301571 }
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05301572
1573 tdlsLinkEstablishParams->isResponder = curr_peer->is_responder;
1574 tdlsLinkEstablishParams->uapsdQueues = curr_peer->uapsdQueues;
1575 tdlsLinkEstablishParams->maxSp = curr_peer->maxSp;
1576 tdlsLinkEstablishParams->isBufSta = curr_peer->isBufSta;
Naresh Jayaram3180aa42014-02-12 21:47:26 +05301577 tdlsLinkEstablishParams->isOffChannelSupported =
1578 curr_peer->isOffChannelSupported;
1579
1580 vos_mem_copy(tdlsLinkEstablishParams->supportedChannels,
1581 curr_peer->supported_channels,
1582 curr_peer->supported_channels_len);
1583
1584 tdlsLinkEstablishParams->supportedChannelsLen =
1585 curr_peer->supported_channels_len;
1586
1587 vos_mem_copy(tdlsLinkEstablishParams->supportedOperClasses,
1588 curr_peer->supported_oper_classes,
1589 curr_peer->supported_oper_classes_len);
1590
1591 tdlsLinkEstablishParams->supportedOperClassesLen =
1592 curr_peer->supported_oper_classes_len;
Agarwal Ashish16020c42014-12-29 22:01:11 +05301593 tdlsLinkEstablishParams->qos = curr_peer->qos;
1594
Masti, Narayanraddi6dbcdbb2015-05-13 10:28:06 +05301595 mutex_unlock(&pHddCtx->tdls_lock);
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05301596 return 0;
1597}
1598
Anand N Sunkad9bfc2622015-07-30 15:18:54 +05301599int wlan_hdd_tdls_set_rssi(hdd_adapter_t *pAdapter,
1600#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
1601 const u8 *mac,
1602#else
1603 u8 *mac,
1604#endif
1605 tANI_S8 rxRssi)
Chilam NG571c65a2013-01-19 12:27:36 +05301606{
1607 hddTdlsPeer_t *curr_peer;
Chilam NG571c65a2013-01-19 12:27:36 +05301608
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05301609 curr_peer = wlan_hdd_tdls_find_peer(pAdapter, mac, TRUE);
Hoonki Lee387663d2013-02-05 18:08:43 -08001610 if (curr_peer == NULL)
c_hpothu7f63e882013-10-02 19:13:35 +05301611 {
1612 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1613 "%s: curr_peer is NULL", __func__);
Hoonki Lee387663d2013-02-05 18:08:43 -08001614 return -1;
c_hpothu7f63e882013-10-02 19:13:35 +05301615 }
Chilam NG571c65a2013-01-19 12:27:36 +05301616
1617 curr_peer->rssi = rxRssi;
1618
Hoonki Lee387663d2013-02-05 18:08:43 -08001619 return 0;
Chilam NG571c65a2013-01-19 12:27:36 +05301620}
1621
Anand N Sunkad9bfc2622015-07-30 15:18:54 +05301622int wlan_hdd_tdls_set_responder(hdd_adapter_t *pAdapter,
1623#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
1624 const u8 *mac,
1625#else
1626 u8 *mac,
1627#endif
1628 tANI_U8 responder)
Hoonki Leea34dd892013-02-05 22:56:02 -08001629{
1630 hddTdlsPeer_t *curr_peer;
Masti, Narayanraddi6dbcdbb2015-05-13 10:28:06 +05301631 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Hoonki Leea34dd892013-02-05 22:56:02 -08001632
Masti, Narayanraddi6dbcdbb2015-05-13 10:28:06 +05301633 if (0 != (wlan_hdd_validate_context(pHddCtx)))
1634 return -EINVAL;
1635
1636 mutex_lock(&pHddCtx->tdls_lock);
Gopichand Nakkala4327a152013-03-04 23:22:42 -08001637 curr_peer = wlan_hdd_tdls_get_peer(pAdapter, mac);
Gopichand Nakkala91b09262013-02-10 14:27:02 -08001638 if (curr_peer == NULL)
c_hpothu7f63e882013-10-02 19:13:35 +05301639 {
1640 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1641 "%s: curr_peer is NULL", __func__);
Masti, Narayanraddi6dbcdbb2015-05-13 10:28:06 +05301642 mutex_unlock(&pHddCtx->tdls_lock);
Hoonki Leea34dd892013-02-05 22:56:02 -08001643 return -1;
c_hpothu7f63e882013-10-02 19:13:35 +05301644 }
Hoonki Leea34dd892013-02-05 22:56:02 -08001645
1646 curr_peer->is_responder = responder;
1647
Masti, Narayanraddi6dbcdbb2015-05-13 10:28:06 +05301648 mutex_unlock(&pHddCtx->tdls_lock);
Hoonki Leea34dd892013-02-05 22:56:02 -08001649 return 0;
1650}
1651
Gopichand Nakkala4327a152013-03-04 23:22:42 -08001652int wlan_hdd_tdls_get_responder(hdd_adapter_t *pAdapter, u8 *mac)
Hoonki Leea34dd892013-02-05 22:56:02 -08001653{
1654 hddTdlsPeer_t *curr_peer;
1655
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05301656 curr_peer = wlan_hdd_tdls_find_peer(pAdapter, mac, TRUE);
Gopichand Nakkala91b09262013-02-10 14:27:02 -08001657 if (curr_peer == NULL)
c_hpothu7f63e882013-10-02 19:13:35 +05301658 {
1659 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1660 "%s: curr_peer is NULL", __func__);
Hoonki Leea34dd892013-02-05 22:56:02 -08001661 return -1;
c_hpothu7f63e882013-10-02 19:13:35 +05301662 }
Hoonki Leea34dd892013-02-05 22:56:02 -08001663
1664 return (curr_peer->is_responder);
1665}
1666
Anand N Sunkad9bfc2622015-07-30 15:18:54 +05301667int wlan_hdd_tdls_set_signature(hdd_adapter_t *pAdapter,
1668#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
1669 const u8 *mac,
1670#else
1671 u8 *mac,
1672#endif
1673 tANI_U8 uSignature)
Hoonki Lee11f7dda2013-02-14 16:55:44 -08001674{
1675 hddTdlsPeer_t *curr_peer;
Masti, Narayanraddi6dbcdbb2015-05-13 10:28:06 +05301676 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Hoonki Lee11f7dda2013-02-14 16:55:44 -08001677
Masti, Narayanraddi6dbcdbb2015-05-13 10:28:06 +05301678 if (0 != (wlan_hdd_validate_context(pHddCtx)))
1679 return -EINVAL;
1680
1681 mutex_lock(&pHddCtx->tdls_lock);
Gopichand Nakkala4327a152013-03-04 23:22:42 -08001682 curr_peer = wlan_hdd_tdls_get_peer(pAdapter, mac);
Hoonki Lee11f7dda2013-02-14 16:55:44 -08001683 if (curr_peer == NULL)
c_hpothu7f63e882013-10-02 19:13:35 +05301684 {
1685 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1686 "%s: curr_peer is NULL", __func__);
Masti, Narayanraddi6dbcdbb2015-05-13 10:28:06 +05301687 mutex_unlock(&pHddCtx->tdls_lock);
Hoonki Lee11f7dda2013-02-14 16:55:44 -08001688 return -1;
c_hpothu7f63e882013-10-02 19:13:35 +05301689 }
Hoonki Lee11f7dda2013-02-14 16:55:44 -08001690
1691 curr_peer->signature = uSignature;
1692
Masti, Narayanraddi6dbcdbb2015-05-13 10:28:06 +05301693 mutex_unlock(&pHddCtx->tdls_lock);
Hoonki Lee11f7dda2013-02-14 16:55:44 -08001694 return 0;
1695}
1696
Hoonki Leea34dd892013-02-05 22:56:02 -08001697
Hoonki Lee387663d2013-02-05 18:08:43 -08001698void wlan_hdd_tdls_extract_da(struct sk_buff *skb, u8 *mac)
Chilam NG571c65a2013-01-19 12:27:36 +05301699{
Chilam NG571c65a2013-01-19 12:27:36 +05301700 memcpy(mac, skb->data, 6);
Chilam NG571c65a2013-01-19 12:27:36 +05301701}
1702
Hoonki Lee387663d2013-02-05 18:08:43 -08001703void wlan_hdd_tdls_extract_sa(struct sk_buff *skb, u8 *mac)
Chilam Ng1279e232013-01-25 15:06:52 -08001704{
Chilam Ng1279e232013-01-25 15:06:52 -08001705 memcpy(mac, skb->data+6, 6);
Chilam Ng1279e232013-01-25 15:06:52 -08001706}
1707
Anand N Sunkad9bfc2622015-07-30 15:18:54 +05301708int wlan_hdd_tdls_increment_pkt_count(hdd_adapter_t *pAdapter,
1709#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
1710 const u8 *mac,
1711#else
1712 u8 *mac,
1713#endif
1714 u8 tx)
Chilam NG571c65a2013-01-19 12:27:36 +05301715{
Hoonki Lee387663d2013-02-05 18:08:43 -08001716 hddTdlsPeer_t *curr_peer;
Gopichand Nakkala4327a152013-03-04 23:22:42 -08001717 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Chilam NG571c65a2013-01-19 12:27:36 +05301718
Masti, Narayanraddi6dbcdbb2015-05-13 10:28:06 +05301719 if (0 != (wlan_hdd_validate_context(pHddCtx)))
1720 return -EINVAL;
1721
Gopichand Nakkala4327a152013-03-04 23:22:42 -08001722 if (eTDLS_SUPPORT_ENABLED != pHddCtx->tdls_mode)
1723 return -1;
Hoonki Leebfee0342013-01-21 16:43:45 -08001724
Masti, Narayanraddi6dbcdbb2015-05-13 10:28:06 +05301725 mutex_lock(&pHddCtx->tdls_lock);
Gopichand Nakkala4327a152013-03-04 23:22:42 -08001726 curr_peer = wlan_hdd_tdls_get_peer(pAdapter, mac);
Hoonki Lee387663d2013-02-05 18:08:43 -08001727 if (curr_peer == NULL)
c_hpothu7f63e882013-10-02 19:13:35 +05301728 {
c_hpothue21931b2014-09-08 14:02:14 +05301729 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1730 FL("curr_peer is NULL"));
Masti, Narayanraddi6dbcdbb2015-05-13 10:28:06 +05301731 mutex_unlock(&pHddCtx->tdls_lock);
Chilam NG571c65a2013-01-19 12:27:36 +05301732 return -1;
c_hpothu7f63e882013-10-02 19:13:35 +05301733 }
Chilam NG571c65a2013-01-19 12:27:36 +05301734
Chilam Ng1279e232013-01-25 15:06:52 -08001735 if (tx)
1736 curr_peer->tx_pkt++;
1737 else
1738 curr_peer->rx_pkt++;
Chilam NG571c65a2013-01-19 12:27:36 +05301739
Masti, Narayanraddi6dbcdbb2015-05-13 10:28:06 +05301740 mutex_unlock(&pHddCtx->tdls_lock);
Chilam NG571c65a2013-01-19 12:27:36 +05301741 return 0;
1742}
1743
Hoonki Lee27511902013-03-14 18:19:06 -07001744static int wlan_hdd_tdls_check_config(tdls_config_params_t *config)
1745{
1746 if (config->tdls > 2)
1747 {
1748 hddLog(VOS_TRACE_LEVEL_ERROR, "%s invalid 1st argument %d. <0...2>", __func__, config->tdls);
1749 return -1;
1750 }
1751 if (config->tx_period_t < CFG_TDLS_TX_STATS_PERIOD_MIN ||
1752 config->tx_period_t > CFG_TDLS_TX_STATS_PERIOD_MAX)
1753 {
Jeff Johnson0299d0a2013-10-30 12:37:43 -07001754 hddLog(VOS_TRACE_LEVEL_ERROR, "%s invalid 2nd argument %d. <%d...%ld>", __func__, config->tx_period_t,
Hoonki Lee27511902013-03-14 18:19:06 -07001755 CFG_TDLS_TX_STATS_PERIOD_MIN, CFG_TDLS_TX_STATS_PERIOD_MAX);
1756 return -1;
1757 }
1758 if (config->tx_packet_n < CFG_TDLS_TX_PACKET_THRESHOLD_MIN ||
1759 config->tx_packet_n > CFG_TDLS_TX_PACKET_THRESHOLD_MAX)
1760 {
Jeff Johnson0299d0a2013-10-30 12:37:43 -07001761 hddLog(VOS_TRACE_LEVEL_ERROR, "%s invalid 3rd argument %d. <%d...%ld>", __func__, config->tx_packet_n,
Hoonki Lee27511902013-03-14 18:19:06 -07001762 CFG_TDLS_TX_PACKET_THRESHOLD_MIN, CFG_TDLS_TX_PACKET_THRESHOLD_MAX);
1763 return -1;
1764 }
1765 if (config->discovery_period_t < CFG_TDLS_DISCOVERY_PERIOD_MIN ||
1766 config->discovery_period_t > CFG_TDLS_DISCOVERY_PERIOD_MAX)
1767 {
Jeff Johnson0299d0a2013-10-30 12:37:43 -07001768 hddLog(VOS_TRACE_LEVEL_ERROR, "%s invalid 4th argument %d. <%d...%ld>", __func__, config->discovery_period_t,
Hoonki Lee27511902013-03-14 18:19:06 -07001769 CFG_TDLS_DISCOVERY_PERIOD_MIN, CFG_TDLS_DISCOVERY_PERIOD_MAX);
1770 return -1;
1771 }
1772 if (config->discovery_tries_n < CFG_TDLS_MAX_DISCOVERY_ATTEMPT_MIN ||
1773 config->discovery_tries_n > CFG_TDLS_MAX_DISCOVERY_ATTEMPT_MAX)
1774 {
1775 hddLog(VOS_TRACE_LEVEL_ERROR, "%s invalid 5th argument %d. <%d...%d>", __func__, config->discovery_tries_n,
1776 CFG_TDLS_MAX_DISCOVERY_ATTEMPT_MIN, CFG_TDLS_MAX_DISCOVERY_ATTEMPT_MAX);
1777 return -1;
1778 }
1779 if (config->idle_timeout_t < CFG_TDLS_IDLE_TIMEOUT_MIN ||
1780 config->idle_timeout_t > CFG_TDLS_IDLE_TIMEOUT_MAX)
1781 {
1782 hddLog(VOS_TRACE_LEVEL_ERROR, "%s invalid 6th argument %d. <%d...%d>", __func__, config->idle_timeout_t,
1783 CFG_TDLS_IDLE_TIMEOUT_MIN, CFG_TDLS_IDLE_TIMEOUT_MAX);
1784 return -1;
1785 }
1786 if (config->idle_packet_n < CFG_TDLS_IDLE_PACKET_THRESHOLD_MIN ||
1787 config->idle_packet_n > CFG_TDLS_IDLE_PACKET_THRESHOLD_MAX)
1788 {
1789 hddLog(VOS_TRACE_LEVEL_ERROR, "%s invalid 7th argument %d. <%d...%d>", __func__, config->idle_packet_n,
1790 CFG_TDLS_IDLE_PACKET_THRESHOLD_MIN, CFG_TDLS_IDLE_PACKET_THRESHOLD_MAX);
1791 return -1;
1792 }
1793 if (config->rssi_hysteresis < CFG_TDLS_RSSI_HYSTERESIS_MIN ||
1794 config->rssi_hysteresis > CFG_TDLS_RSSI_HYSTERESIS_MAX)
1795 {
1796 hddLog(VOS_TRACE_LEVEL_ERROR, "%s invalid 8th argument %d. <%d...%d>", __func__, config->rssi_hysteresis,
1797 CFG_TDLS_RSSI_HYSTERESIS_MIN, CFG_TDLS_RSSI_HYSTERESIS_MAX);
1798 return -1;
1799 }
1800 if (config->rssi_trigger_threshold < CFG_TDLS_RSSI_TRIGGER_THRESHOLD_MIN ||
1801 config->rssi_trigger_threshold > CFG_TDLS_RSSI_TRIGGER_THRESHOLD_MAX)
1802 {
1803 hddLog(VOS_TRACE_LEVEL_ERROR, "%s invalid 9th argument %d. <%d...%d>", __func__, config->rssi_trigger_threshold,
1804 CFG_TDLS_RSSI_TRIGGER_THRESHOLD_MIN, CFG_TDLS_RSSI_TRIGGER_THRESHOLD_MAX);
1805 return -1;
1806 }
1807 if (config->rssi_teardown_threshold < CFG_TDLS_RSSI_TEARDOWN_THRESHOLD_MIN ||
1808 config->rssi_teardown_threshold > CFG_TDLS_RSSI_TEARDOWN_THRESHOLD_MAX)
1809 {
1810 hddLog(VOS_TRACE_LEVEL_ERROR, "%s invalid 10th argument %d. <%d...%d>", __func__, config->rssi_teardown_threshold,
1811 CFG_TDLS_RSSI_TEARDOWN_THRESHOLD_MIN, CFG_TDLS_RSSI_TEARDOWN_THRESHOLD_MAX);
1812 return -1;
1813 }
1814 return 0;
1815}
1816
Chilam Ng01120412013-02-19 18:32:21 -08001817int wlan_hdd_tdls_set_params(struct net_device *dev, tdls_config_params_t *config)
Chilam NG571c65a2013-01-19 12:27:36 +05301818{
Chilam Ng01120412013-02-19 18:32:21 -08001819 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1820 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
Gopichand Nakkala4327a152013-03-04 23:22:42 -08001821 tdlsCtx_t *pHddTdlsCtx = WLAN_HDD_GET_TDLS_CTX_PTR(pAdapter);
Hoonki Lee27511902013-03-14 18:19:06 -07001822 eTDLSSupportMode req_tdls_mode;
Hoonki Leebfee0342013-01-21 16:43:45 -08001823
Hoonki Lee27511902013-03-14 18:19:06 -07001824 if (NULL == pHddTdlsCtx)
1825 {
c_hpothu7f63e882013-10-02 19:13:35 +05301826 hddLog(VOS_TRACE_LEVEL_ERROR, FL("TDLS not enabled!"));
Hoonki Lee27511902013-03-14 18:19:06 -07001827 return -1;
Chilam Ng01120412013-02-19 18:32:21 -08001828 }
Chilam NG571c65a2013-01-19 12:27:36 +05301829
Hoonki Lee27511902013-03-14 18:19:06 -07001830 if (wlan_hdd_tdls_check_config(config) != 0)
1831 {
1832 return -1;
1833 }
1834
1835 /* config->tdls is mapped to 0->1, 1->2, 2->3 */
1836 req_tdls_mode = config->tdls + 1;
1837 if (pHddCtx->tdls_mode == req_tdls_mode)
1838 {
1839 hddLog(VOS_TRACE_LEVEL_ERROR, "%s already in mode %d", __func__, config->tdls);
1840 return -1;
1841 }
1842
1843 /* copy the configuration only when given tdls mode is implicit trigger enable */
1844 if (eTDLS_SUPPORT_ENABLED == req_tdls_mode)
1845 {
Chilam Ng01120412013-02-19 18:32:21 -08001846 memcpy(&pHddTdlsCtx->threshold_config, config, sizeof(tdls_config_params_t));
1847 }
Chilam NG571c65a2013-01-19 12:27:36 +05301848
Chilam Ng01120412013-02-19 18:32:21 -08001849 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1850 "iw set tdls params: %d %d %d %d %d %d %d %d %d %d",
1851 config->tdls,
1852 config->tx_period_t,
1853 config->tx_packet_n,
1854 config->discovery_period_t,
1855 config->discovery_tries_n,
1856 config->idle_timeout_t,
1857 config->idle_packet_n,
1858 config->rssi_hysteresis,
1859 config->rssi_trigger_threshold,
1860 config->rssi_teardown_threshold);
Chilam NG571c65a2013-01-19 12:27:36 +05301861
Gopichand Nakkaladcbcf4e2013-03-23 14:32:39 -07001862 wlan_hdd_tdls_set_mode(pHddCtx, req_tdls_mode, TRUE);
Chilam Ng01120412013-02-19 18:32:21 -08001863
Chilam NG571c65a2013-01-19 12:27:36 +05301864 return 0;
1865}
1866
Anand N Sunkad9bfc2622015-07-30 15:18:54 +05301867int wlan_hdd_tdls_set_sta_id(hdd_adapter_t *pAdapter,
1868#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
1869 const u8 *mac,
1870#else
1871 u8 *mac,
1872#endif
1873 u8 staId)
Kiran V1ccee932012-12-12 14:49:46 -08001874{
Hoonki Lee387663d2013-02-05 18:08:43 -08001875 hddTdlsPeer_t *curr_peer;
Masti, Narayanraddi6dbcdbb2015-05-13 10:28:06 +05301876 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Kiran V1ccee932012-12-12 14:49:46 -08001877
Masti, Narayanraddi6dbcdbb2015-05-13 10:28:06 +05301878 if (0 != (wlan_hdd_validate_context(pHddCtx)))
1879 return -EINVAL;
1880
1881 mutex_lock(&pHddCtx->tdls_lock);
Gopichand Nakkala4327a152013-03-04 23:22:42 -08001882 curr_peer = wlan_hdd_tdls_get_peer(pAdapter, mac);
Hoonki Lee387663d2013-02-05 18:08:43 -08001883 if (curr_peer == NULL)
c_hpothu7f63e882013-10-02 19:13:35 +05301884 {
1885 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1886 "%s: curr_peer is NULL", __func__);
Masti, Narayanraddi6dbcdbb2015-05-13 10:28:06 +05301887 mutex_unlock(&pHddCtx->tdls_lock);
Chilam NG571c65a2013-01-19 12:27:36 +05301888 return -1;
c_hpothu7f63e882013-10-02 19:13:35 +05301889 }
Chilam NG571c65a2013-01-19 12:27:36 +05301890
Hoonki Lee387663d2013-02-05 18:08:43 -08001891 curr_peer->staId = staId;
Chilam NG571c65a2013-01-19 12:27:36 +05301892
Masti, Narayanraddi6dbcdbb2015-05-13 10:28:06 +05301893 mutex_unlock(&pHddCtx->tdls_lock);
Chilam NG571c65a2013-01-19 12:27:36 +05301894 return 0;
Kiran V1ccee932012-12-12 14:49:46 -08001895}
1896
Anand N Sunkad9bfc2622015-07-30 15:18:54 +05301897int wlan_hdd_tdls_set_force_peer(hdd_adapter_t *pAdapter,
1898#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
1899 const u8 *mac,
1900#else
1901 u8 *mac,
1902#endif
Naresh Jayaram937abdf2013-11-26 19:50:25 +05301903 tANI_BOOLEAN forcePeer)
Sunil Dutt41de4e22013-11-14 18:09:02 +05301904{
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +05301905 /* NOTE:
1906 * Hold mutex tdls_lock before calling this function
1907 */
Naresh Jayaram937abdf2013-11-26 19:50:25 +05301908 hddTdlsPeer_t *curr_peer;
Sunil Dutt41de4e22013-11-14 18:09:02 +05301909 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1910
1911 if ((NULL == pHddCtx)) return -1;
1912
Naresh Jayaram937abdf2013-11-26 19:50:25 +05301913 curr_peer = wlan_hdd_tdls_find_peer(pAdapter, mac, FALSE);
1914 if (curr_peer == NULL)
Sunil Dutt41de4e22013-11-14 18:09:02 +05301915 goto error;
Naresh Jayaram937abdf2013-11-26 19:50:25 +05301916 curr_peer->isForcedPeer = forcePeer;
Naresh Jayaramca7bc3a2014-02-04 23:03:04 +05301917
Naresh Jayaramca7bc3a2014-02-04 23:03:04 +05301918 return 0;
Sunil Dutt41de4e22013-11-14 18:09:02 +05301919error:
Sunil Dutt41de4e22013-11-14 18:09:02 +05301920 return -1;
1921}
1922
Hoonki Lee387663d2013-02-05 18:08:43 -08001923/* if peerMac is found, then it returns pointer to hddTdlsPeer_t
1924 otherwise, it returns NULL
1925*/
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +05301926hddTdlsPeer_t *wlan_hdd_tdls_find_peer(hdd_adapter_t *pAdapter,
1927#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
1928 const u8 *mac,
1929#else
1930 u8 *mac,
1931#endif
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05301932 tANI_BOOLEAN mutexLock)
Kiran V1ccee932012-12-12 14:49:46 -08001933{
Hoonki Lee387663d2013-02-05 18:08:43 -08001934 u8 key;
1935 struct list_head *pos;
1936 struct list_head *head;
1937 hddTdlsPeer_t *curr_peer;
Gopichand Nakkala4327a152013-03-04 23:22:42 -08001938 tdlsCtx_t *pHddTdlsCtx;
Madan Mohan Koyyalamudi263cec12013-10-07 10:57:50 +05301939 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Hoonki Lee387663d2013-02-05 18:08:43 -08001940
c_hpothu7f63e882013-10-02 19:13:35 +05301941 if(0 != (wlan_hdd_validate_context(pHddCtx)))
1942 {
c_hpothu7f63e882013-10-02 19:13:35 +05301943 return 0;
1944 }
Hoonki Lee387663d2013-02-05 18:08:43 -08001945
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05301946 if ( mutexLock )
Hoonki Lee387663d2013-02-05 18:08:43 -08001947 {
Rajesh Chauhana34c6e62014-03-25 16:37:58 +05301948 mutex_lock(&pHddCtx->tdls_lock);
Hoonki Lee387663d2013-02-05 18:08:43 -08001949 }
Gopichand Nakkala4327a152013-03-04 23:22:42 -08001950 pHddTdlsCtx = WLAN_HDD_GET_TDLS_CTX_PTR(pAdapter);
Gopichand Nakkalaeb69b602013-02-27 11:40:31 -08001951 if (NULL == pHddTdlsCtx)
1952 {
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05301953 if ( mutexLock )
1954 mutex_unlock(&pHddCtx->tdls_lock);
Gopichand Nakkalaeb69b602013-02-27 11:40:31 -08001955 return NULL;
1956 }
1957
1958 key = wlan_hdd_tdls_hash_key(mac);
1959
1960 head = &pHddTdlsCtx->peer_list[key];
Hoonki Lee387663d2013-02-05 18:08:43 -08001961
1962 list_for_each(pos, head) {
1963 curr_peer = list_entry (pos, hddTdlsPeer_t, node);
1964 if (!memcmp(mac, curr_peer->peerMac, 6)) {
1965 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1966 "findTdlsPeer: found staId %d", curr_peer->staId);
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05301967 if ( mutexLock )
1968 mutex_unlock(&pHddCtx->tdls_lock);
Hoonki Lee387663d2013-02-05 18:08:43 -08001969 return curr_peer;
1970 }
1971 }
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05301972 if ( mutexLock )
1973 mutex_unlock(&pHddCtx->tdls_lock);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301974
Hoonki Lee387663d2013-02-05 18:08:43 -08001975 return NULL;
1976}
1977
Anand N Sunkad9bfc2622015-07-30 15:18:54 +05301978hddTdlsPeer_t *wlan_hdd_tdls_find_all_peer(hdd_context_t *pHddCtx,
1979#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
1980 const u8 *mac
1981#else
1982 u8 *mac
1983#endif
1984)
Hoonki Leea6d49be2013-04-05 09:43:25 -07001985{
1986 hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL;
1987 hdd_adapter_t *pAdapter = NULL;
1988 tdlsCtx_t *pHddTdlsCtx = NULL;
1989 hddTdlsPeer_t *curr_peer= NULL;
1990 VOS_STATUS status = 0;
1991
Rajesh Chauhana34c6e62014-03-25 16:37:58 +05301992 mutex_lock(&pHddCtx->tdls_lock);
Hoonki Leea6d49be2013-04-05 09:43:25 -07001993 status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
1994 while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status )
1995 {
1996 pAdapter = pAdapterNode->pAdapter;
1997
1998 pHddTdlsCtx = WLAN_HDD_GET_TDLS_CTX_PTR(pAdapter);
1999 if (NULL != pHddTdlsCtx)
2000 {
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05302001 curr_peer = wlan_hdd_tdls_find_peer(pAdapter, mac, FALSE);
Hoonki Leea6d49be2013-04-05 09:43:25 -07002002 if (curr_peer)
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05302003 {
2004 mutex_unlock(&pHddCtx->tdls_lock);
Hoonki Leea6d49be2013-04-05 09:43:25 -07002005 return curr_peer;
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05302006 }
Hoonki Leea6d49be2013-04-05 09:43:25 -07002007 }
2008 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
2009 pAdapterNode = pNext;
2010 }
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05302011 mutex_unlock(&pHddCtx->tdls_lock);
Hoonki Leea6d49be2013-04-05 09:43:25 -07002012 return curr_peer;
2013}
2014
2015
Anand N Sunkad9bfc2622015-07-30 15:18:54 +05302016int wlan_hdd_tdls_reset_peer(hdd_adapter_t *pAdapter,
2017#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
2018 const u8 *mac
2019#else
2020 u8 *mac
2021#endif
2022)
Hoonki Lee387663d2013-02-05 18:08:43 -08002023{
Chilam Ng01120412013-02-19 18:32:21 -08002024 hdd_context_t *pHddCtx;
Chilam NG571c65a2013-01-19 12:27:36 +05302025 hddTdlsPeer_t *curr_peer;
Kiran V1ccee932012-12-12 14:49:46 -08002026
Chilam Ng01120412013-02-19 18:32:21 -08002027 pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
2028
Masti, Narayanraddi6dbcdbb2015-05-13 10:28:06 +05302029 if (0 != (wlan_hdd_validate_context(pHddCtx)))
2030 return -EINVAL;
2031
2032 mutex_lock(&pHddCtx->tdls_lock);
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002033 curr_peer = wlan_hdd_tdls_get_peer(pAdapter, mac);
Hoonki Lee387663d2013-02-05 18:08:43 -08002034 if (curr_peer == NULL)
c_hpothu7f63e882013-10-02 19:13:35 +05302035 {
2036 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2037 "%s: curr_peer is NULL", __func__);
Masti, Narayanraddi6dbcdbb2015-05-13 10:28:06 +05302038 mutex_unlock(&pHddCtx->tdls_lock);
Hoonki Lee387663d2013-02-05 18:08:43 -08002039 return -1;
c_hpothu7f63e882013-10-02 19:13:35 +05302040 }
Chilam NG571c65a2013-01-19 12:27:36 +05302041
Atul Mittal115287b2014-07-08 13:26:33 +05302042 wlan_hdd_tdls_set_peer_link_status(curr_peer,
2043 eTDLS_LINK_IDLE,
2044 eTDLS_LINK_UNSPECIFIED);
Hoonki Leecdd8e962013-01-20 00:45:46 -08002045 curr_peer->staId = 0;
Hoonki Lee387663d2013-02-05 18:08:43 -08002046
Pradeep Reddy POTTETIedaeb5f2014-05-22 23:34:41 +05302047 /* Throughput Monitor shall disable the split scan when
2048 * TDLS scan coexistance is disabled.At this point of time
2049 * since TDLS scan coexistance is not meeting the criteria
2050 * to be operational, explicitly make it false to enable
2051 * throughput monitor takes the control of split scan.
2052 */
2053 if (pHddCtx->isTdlsScanCoexistence == TRUE)
2054 {
2055 pHddCtx->isTdlsScanCoexistence = FALSE;
2056 }
2057
Chilam Ng01120412013-02-19 18:32:21 -08002058 if(eTDLS_SUPPORT_ENABLED == pHddCtx->tdls_mode) {
Chilam Nga75d8b62013-01-29 01:35:59 -08002059 vos_timer_stop( &curr_peer->peerIdleTimer );
Chilam Nga75d8b62013-01-29 01:35:59 -08002060 }
Masti, Narayanraddi6dbcdbb2015-05-13 10:28:06 +05302061
2062 mutex_unlock(&pHddCtx->tdls_lock);
Hoonki Lee387663d2013-02-05 18:08:43 -08002063 return 0;
Hoonki Leecdd8e962013-01-20 00:45:46 -08002064}
2065
Gopichand Nakkala638ebc72013-03-21 18:04:02 -07002066/* Caller has to take the lock before calling this function */
Hoonki Lee27511902013-03-14 18:19:06 -07002067static void wlan_tdd_tdls_reset_tx_rx(tdlsCtx_t *pHddTdlsCtx)
2068{
2069 int i;
2070 struct list_head *head;
2071 hddTdlsPeer_t *tmp;
2072 struct list_head *pos, *q;
2073
Hoonki Lee27511902013-03-14 18:19:06 -07002074 for (i = 0; i < 256; i++) {
2075 head = &pHddTdlsCtx->peer_list[i];
2076 list_for_each_safe (pos, q, head) {
2077 tmp = list_entry(pos, hddTdlsPeer_t, node);
2078 tmp->tx_pkt = 0;
2079 tmp->rx_pkt = 0;
2080 }
2081 }
Hoonki Lee27511902013-03-14 18:19:06 -07002082
2083 return ;
2084}
2085
Gopichand Nakkala638ebc72013-03-21 18:04:02 -07002086/* Caller has to take the lock before calling this function */
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002087static tANI_S32 wlan_hdd_tdls_peer_reset_discovery_processed(tdlsCtx_t *pHddTdlsCtx)
Gopichand Nakkalac3694582013-02-13 20:51:22 -08002088{
2089 int i;
2090 struct list_head *head;
2091 hddTdlsPeer_t *tmp;
2092 struct list_head *pos, *q;
2093
Gopichand Nakkalac3694582013-02-13 20:51:22 -08002094 pHddTdlsCtx->discovery_peer_cnt = 0;
2095
2096 for (i = 0; i < 256; i++) {
2097 head = &pHddTdlsCtx->peer_list[i];
2098 list_for_each_safe (pos, q, head) {
2099 tmp = list_entry(pos, hddTdlsPeer_t, node);
2100 tmp->discovery_processed = 0;
2101 }
2102 }
Gopichand Nakkalac3694582013-02-13 20:51:22 -08002103
2104 return 0;
2105}
2106
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002107static tANI_S32 wlan_hdd_get_tdls_discovery_peer_cnt(tdlsCtx_t *pHddTdlsCtx)
Gopichand Nakkalac3694582013-02-13 20:51:22 -08002108{
2109 int i;
2110 struct list_head *head;
2111 struct list_head *pos, *q;
2112 int discovery_peer_cnt=0;
2113 hddTdlsPeer_t *tmp;
2114
Gopichand Nakkalaeb69b602013-02-27 11:40:31 -08002115 /*
2116 * This function expects the callers to acquire the Mutex.
2117 */
Gopichand Nakkalac3694582013-02-13 20:51:22 -08002118
2119 for (i = 0; i < 256; i++) {
2120 head = &pHddTdlsCtx->peer_list[i];
2121 list_for_each_safe (pos, q, head) {
2122 tmp = list_entry(pos, hddTdlsPeer_t, node);
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +05302123 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Chilam Ng01120412013-02-19 18:32:21 -08002124 "%s, %d, " MAC_ADDRESS_STR, __func__, i,
2125 MAC_ADDR_ARRAY(tmp->peerMac));
Gopichand Nakkalac3694582013-02-13 20:51:22 -08002126 discovery_peer_cnt++;
2127 }
2128 }
Gopichand Nakkalac3694582013-02-13 20:51:22 -08002129 return discovery_peer_cnt;
2130}
2131
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002132tANI_U16 wlan_hdd_tdlsConnectedPeers(hdd_adapter_t *pAdapter)
Lee Hoonkic1262f22013-01-24 21:59:00 -08002133{
Hanumantha Reddy Pothulada0fe362015-02-27 18:37:03 +05302134 hdd_context_t *pHddCtx = NULL;
2135
2136 if ((NULL == pAdapter) || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic))
2137 {
2138 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2139 FL("invalid pAdapter: %p"), pAdapter);
2140 return 0;
2141 }
2142 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002143
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302144 ENTER();
c_hpothu7f63e882013-10-02 19:13:35 +05302145 if(0 != (wlan_hdd_validate_context(pHddCtx)))
2146 {
Gopichand Nakkalab977a972013-02-18 19:15:09 -08002147 return 0;
c_hpothu7f63e882013-10-02 19:13:35 +05302148 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302149 EXIT();
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002150 return pHddCtx->connected_peer_count;
Lee Hoonkic1262f22013-01-24 21:59:00 -08002151}
Chilam Ng16a2a1c2013-01-29 01:27:29 -08002152
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +05302153hddTdlsPeer_t *wlan_hdd_tdls_get_connected_peer(hdd_adapter_t *pAdapter)
Pradeep Reddy POTTETIedaeb5f2014-05-22 23:34:41 +05302154{
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +05302155 /* NOTE:
2156 * Hold mutext tdls_lock before calling this function
2157 */
Pradeep Reddy POTTETIedaeb5f2014-05-22 23:34:41 +05302158 int i;
2159 struct list_head *head;
2160 struct list_head *pos;
2161 hddTdlsPeer_t *curr_peer = NULL;
2162 tdlsCtx_t *pHddTdlsCtx;
2163 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2164
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302165 ENTER();
Pradeep Reddy POTTETIedaeb5f2014-05-22 23:34:41 +05302166 if(0 != (wlan_hdd_validate_context(pHddCtx)))
2167 {
Pradeep Reddy POTTETIedaeb5f2014-05-22 23:34:41 +05302168 return NULL;
2169 }
2170
Pradeep Reddy POTTETIedaeb5f2014-05-22 23:34:41 +05302171 pHddTdlsCtx = WLAN_HDD_GET_TDLS_CTX_PTR(pAdapter);
2172 if (NULL == pHddTdlsCtx) {
Pradeep Reddy POTTETIedaeb5f2014-05-22 23:34:41 +05302173 return NULL;
2174 }
2175 for (i = 0; i < 256; i++) {
2176 head = &pHddTdlsCtx->peer_list[i];
2177
2178 list_for_each(pos, head) {
2179 curr_peer= list_entry (pos, hddTdlsPeer_t, node);
Pradeep Reddy POTTETI8a623132014-06-26 16:07:06 +05302180 if (curr_peer && (curr_peer->link_status == eTDLS_LINK_CONNECTED))
Pradeep Reddy POTTETIedaeb5f2014-05-22 23:34:41 +05302181 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +05302182 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Pradeep Reddy POTTETI8a623132014-06-26 16:07:06 +05302183 "%s: " MAC_ADDRESS_STR " eTDLS_LINK_CONNECTED",
2184 __func__, MAC_ADDR_ARRAY(curr_peer->peerMac));
Pradeep Reddy POTTETIedaeb5f2014-05-22 23:34:41 +05302185 return curr_peer;
2186 }
2187 }
2188 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302189
2190 EXIT();
Pradeep Reddy POTTETIedaeb5f2014-05-22 23:34:41 +05302191 return NULL;
2192}
2193
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002194int wlan_hdd_tdls_get_all_peers(hdd_adapter_t *pAdapter, char *buf, int buflen)
Chilam Ng16a2a1c2013-01-29 01:27:29 -08002195{
2196 int i;
2197 int len, init_len;
Hoonki Lee387663d2013-02-05 18:08:43 -08002198 struct list_head *head;
2199 struct list_head *pos;
Chilam Ng16a2a1c2013-01-29 01:27:29 -08002200 hddTdlsPeer_t *curr_peer;
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002201 tdlsCtx_t *pHddTdlsCtx;
Madan Mohan Koyyalamudi263cec12013-10-07 10:57:50 +05302202 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2203
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302204 ENTER();
c_hpothu7f63e882013-10-02 19:13:35 +05302205 if(0 != (wlan_hdd_validate_context(pHddCtx)))
2206 {
c_hpothu7f63e882013-10-02 19:13:35 +05302207 return 0;
Madan Mohan Koyyalamudi263cec12013-10-07 10:57:50 +05302208 }
Chilam Ng16a2a1c2013-01-29 01:27:29 -08002209
Chilam Ng16a2a1c2013-01-29 01:27:29 -08002210 init_len = buflen;
Sameer Thalappilb0a30232013-09-27 15:37:48 -07002211 len = scnprintf(buf, buflen, "\n%-18s%-3s%-4s%-3s%-5s\n",
2212 "MAC", "Id", "cap", "up", "RSSI");
Chilam Ng16a2a1c2013-01-29 01:27:29 -08002213 buf += len;
2214 buflen -= len;
2215 /* 1234567890123456789012345678901234567 */
Sameer Thalappilb0a30232013-09-27 15:37:48 -07002216 len = scnprintf(buf, buflen, "---------------------------------\n");
Chilam Ng16a2a1c2013-01-29 01:27:29 -08002217 buf += len;
2218 buflen -= len;
2219
Rajesh Chauhana34c6e62014-03-25 16:37:58 +05302220 mutex_lock(&pHddCtx->tdls_lock);
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002221 pHddTdlsCtx = WLAN_HDD_GET_TDLS_CTX_PTR(pAdapter);
Gopichand Nakkalaeb69b602013-02-27 11:40:31 -08002222 if (NULL == pHddTdlsCtx) {
Madan Mohan Koyyalamudi263cec12013-10-07 10:57:50 +05302223 mutex_unlock(&pHddCtx->tdls_lock);
Sameer Thalappilb0a30232013-09-27 15:37:48 -07002224 len = scnprintf(buf, buflen, "TDLS not enabled\n");
Gopichand Nakkalaeb69b602013-02-27 11:40:31 -08002225 return len;
2226 }
Chilam Ng16a2a1c2013-01-29 01:27:29 -08002227 for (i = 0; i < 256; i++) {
Hoonki Lee387663d2013-02-05 18:08:43 -08002228 head = &pHddTdlsCtx->peer_list[i];
Chilam Ng16a2a1c2013-01-29 01:27:29 -08002229
Hoonki Lee387663d2013-02-05 18:08:43 -08002230 list_for_each(pos, head) {
2231 curr_peer= list_entry (pos, hddTdlsPeer_t, node);
Chilam Ng16a2a1c2013-01-29 01:27:29 -08002232
Hoonki Lee387663d2013-02-05 18:08:43 -08002233 if (buflen < 32+1)
2234 break;
Sameer Thalappilb0a30232013-09-27 15:37:48 -07002235 len = scnprintf(buf, buflen,
Chilam Ng01120412013-02-19 18:32:21 -08002236 MAC_ADDRESS_STR"%3d%4s%3s%5d\n",
2237 MAC_ADDR_ARRAY(curr_peer->peerMac),
Hoonki Lee387663d2013-02-05 18:08:43 -08002238 curr_peer->staId,
2239 (curr_peer->tdls_support == eTDLS_CAP_SUPPORTED) ? "Y":"N",
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07002240 TDLS_IS_CONNECTED(curr_peer) ? "Y":"N",
Hoonki Lee387663d2013-02-05 18:08:43 -08002241 curr_peer->rssi);
2242 buf += len;
2243 buflen -= len;
Chilam Ng16a2a1c2013-01-29 01:27:29 -08002244 }
2245 }
Madan Mohan Koyyalamudi263cec12013-10-07 10:57:50 +05302246 mutex_unlock(&pHddCtx->tdls_lock);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302247
2248 EXIT();
Chilam Ng16a2a1c2013-01-29 01:27:29 -08002249 return init_len-buflen;
2250}
Gopichand Nakkalac3694582013-02-13 20:51:22 -08002251
2252void wlan_hdd_tdls_connection_callback(hdd_adapter_t *pAdapter)
2253{
Mahesh A Saptasagar36cdc802015-01-07 18:41:17 +05302254 tdlsCtx_t *pHddTdlsCtx;
Madan Mohan Koyyalamudi263cec12013-10-07 10:57:50 +05302255 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkala9d76a9b2013-02-28 15:38:37 -08002256
Mahesh A Saptasagar36cdc802015-01-07 18:41:17 +05302257 if ((NULL == pHddCtx))
c_hpothu7f63e882013-10-02 19:13:35 +05302258 {
Agarwal Ashishbf98caf2014-03-25 13:29:11 +05302259 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
2260 FL("pHddCtx or pHddTdlsCtx points to NULL"));
c_hpothu7f63e882013-10-02 19:13:35 +05302261 return;
2262 }
Madan Mohan Koyyalamudi263cec12013-10-07 10:57:50 +05302263
Rajesh Chauhana34c6e62014-03-25 16:37:58 +05302264 mutex_lock(&pHddCtx->tdls_lock);
Gopichand Nakkala638ebc72013-03-21 18:04:02 -07002265
Mahesh A Saptasagar36cdc802015-01-07 18:41:17 +05302266 if (0 != wlan_hdd_sta_tdls_init(pAdapter))
2267 {
Mahesh A Saptasagar36cdc802015-01-07 18:41:17 +05302268 mutex_unlock(&pHddCtx->tdls_lock);
Hema Aparna Medicharla8bb6f782015-03-09 12:35:05 +05302269 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wlan_hdd_sta_tdls_init failed",__func__);
Mahesh A Saptasagar36cdc802015-01-07 18:41:17 +05302270 return;
2271 }
Mahesh A Saptasagar36cdc802015-01-07 18:41:17 +05302272
2273 pHddTdlsCtx = WLAN_HDD_GET_TDLS_CTX_PTR(pAdapter);
2274 if ((NULL == pHddTdlsCtx))
2275 {
Hema Aparna Medicharla8bb6f782015-03-09 12:35:05 +05302276 mutex_unlock(&pHddCtx->tdls_lock);
Mahesh A Saptasagar36cdc802015-01-07 18:41:17 +05302277 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
2278 FL("pHddCtx or pHddTdlsCtx points to NULL device mode = %d"), pAdapter->device_mode);
Mahesh A Saptasagar36cdc802015-01-07 18:41:17 +05302279 return;
2280 }
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +05302281 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalac3694582013-02-13 20:51:22 -08002282 "%s, update %d discover %d", __func__,
2283 pHddTdlsCtx->threshold_config.tx_period_t,
2284 pHddTdlsCtx->threshold_config.discovery_period_t);
2285
Gopichand Nakkala9d76a9b2013-02-28 15:38:37 -08002286 if (eTDLS_SUPPORT_ENABLED == pHddCtx->tdls_mode)
2287 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002288 wlan_hdd_tdls_peer_reset_discovery_processed(pHddTdlsCtx);
Gopichand Nakkala75e7b282013-03-15 18:37:13 -07002289 pHddTdlsCtx->discovery_sent_cnt = 0;
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07002290 wlan_hdd_tdls_check_power_save_prohibited(pHddTdlsCtx->pAdapter);
Gopichand Nakkalac3694582013-02-13 20:51:22 -08002291
Gopichand Nakkala3046fc92013-03-23 13:56:43 -07002292 wlan_hdd_tdls_timer_restart(pHddTdlsCtx->pAdapter,
2293 &pHddTdlsCtx->peerUpdateTimer,
2294 pHddTdlsCtx->threshold_config.tx_period_t);
Gopichand Nakkala9d76a9b2013-02-28 15:38:37 -08002295 }
Madan Mohan Koyyalamudi263cec12013-10-07 10:57:50 +05302296 mutex_unlock(&pHddCtx->tdls_lock);
Gopichand Nakkalac3694582013-02-13 20:51:22 -08002297
2298}
2299
2300void wlan_hdd_tdls_disconnection_callback(hdd_adapter_t *pAdapter)
2301{
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002302 tdlsCtx_t *pHddTdlsCtx = WLAN_HDD_GET_TDLS_CTX_PTR(pAdapter);
Madan Mohan Koyyalamudi263cec12013-10-07 10:57:50 +05302303 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2304
Deepthi Gowribfd17132014-11-14 17:59:04 +05302305 if (NULL == pHddCtx)
c_hpothu7f63e882013-10-02 19:13:35 +05302306 {
2307 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Deepthi Gowribfd17132014-11-14 17:59:04 +05302308 FL(" pHddCtx points to NULL"));
c_hpothu7f63e882013-10-02 19:13:35 +05302309 return;
2310 }
Gopichand Nakkalac3694582013-02-13 20:51:22 -08002311
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +05302312 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s", __func__);
Gopichand Nakkalac3694582013-02-13 20:51:22 -08002313
Gopichand Nakkalaeb69b602013-02-27 11:40:31 -08002314 if (NULL == pHddTdlsCtx)
2315 {
Hema Aparna Medicharla8bb6f782015-03-09 12:35:05 +05302316 mutex_unlock(&pHddCtx->tdls_lock);
Ratheesh S P36dbc932015-08-07 14:28:57 +05302317 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
c_hpothu7f63e882013-10-02 19:13:35 +05302318 FL("pHddTdlsCtx is NULL"));
Gopichand Nakkalaeb69b602013-02-27 11:40:31 -08002319 return;
2320 }
Masti, Narayanraddide96b992015-01-08 13:00:58 +05302321
Pradeep Reddy POTTETI2d4d5c42015-03-03 14:34:19 +05302322 mutex_lock(&pHddCtx->tdls_lock);
Masti, Narayanraddide96b992015-01-08 13:00:58 +05302323
Gopichand Nakkalaccd3a382013-03-19 13:56:10 -07002324 pHddTdlsCtx->discovery_sent_cnt = 0;
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07002325 wlan_hdd_tdls_check_power_save_prohibited(pHddTdlsCtx->pAdapter);
Gopichand Nakkalaeb69b602013-02-27 11:40:31 -08002326
Pradeep Reddy POTTETI2d4d5c42015-03-03 14:34:19 +05302327 wlan_hdd_tdls_exit(pAdapter, TRUE);
Gopichand Nakkalaeb69b602013-02-27 11:40:31 -08002328
Madan Mohan Koyyalamudi263cec12013-10-07 10:57:50 +05302329 mutex_unlock(&pHddCtx->tdls_lock);
Gopichand Nakkalac3694582013-02-13 20:51:22 -08002330}
Gopichand Nakkalab977a972013-02-18 19:15:09 -08002331
2332void wlan_hdd_tdls_mgmt_completion_callback(hdd_adapter_t *pAdapter, tANI_U32 statusCode)
2333{
2334 pAdapter->mgmtTxCompletionStatus = statusCode;
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +05302335 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2336 "%s: Mgmt TX Completion %d",__func__, statusCode);
Gopichand Nakkalab977a972013-02-18 19:15:09 -08002337 complete(&pAdapter->tdls_mgmt_comp);
2338}
2339
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002340void wlan_hdd_tdls_increment_peer_count(hdd_adapter_t *pAdapter)
Gopichand Nakkalab977a972013-02-18 19:15:09 -08002341{
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002342 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkalab977a972013-02-18 19:15:09 -08002343
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302344 ENTER();
c_hpothu7f63e882013-10-02 19:13:35 +05302345 if(0 != (wlan_hdd_validate_context(pHddCtx)))
2346 {
c_hpothu7f63e882013-10-02 19:13:35 +05302347 return;
2348 }
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002349
Rajesh Chauhana34c6e62014-03-25 16:37:58 +05302350 mutex_lock(&pHddCtx->tdls_lock);
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05302351
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002352 pHddCtx->connected_peer_count++;
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07002353 wlan_hdd_tdls_check_power_save_prohibited(pAdapter);
Gopichand Nakkalaccd3a382013-03-19 13:56:10 -07002354
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +05302355 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: %d",
Gopichand Nakkalaccd3a382013-03-19 13:56:10 -07002356 __func__, pHddCtx->connected_peer_count);
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05302357
2358 mutex_unlock(&pHddCtx->tdls_lock);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302359
2360 EXIT();
Gopichand Nakkalab977a972013-02-18 19:15:09 -08002361}
2362
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002363void wlan_hdd_tdls_decrement_peer_count(hdd_adapter_t *pAdapter)
Gopichand Nakkalab977a972013-02-18 19:15:09 -08002364{
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002365 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkalab977a972013-02-18 19:15:09 -08002366
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302367 ENTER();
c_hpothu7f63e882013-10-02 19:13:35 +05302368 if(0 != (wlan_hdd_validate_context(pHddCtx)))
2369 {
c_hpothu7f63e882013-10-02 19:13:35 +05302370 return;
2371 }
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002372
Rajesh Chauhana34c6e62014-03-25 16:37:58 +05302373 mutex_lock(&pHddCtx->tdls_lock);
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05302374
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002375 if (pHddCtx->connected_peer_count)
2376 pHddCtx->connected_peer_count--;
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07002377 wlan_hdd_tdls_check_power_save_prohibited(pAdapter);
Gopichand Nakkalaccd3a382013-03-19 13:56:10 -07002378
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +05302379 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: %d",
Gopichand Nakkalaccd3a382013-03-19 13:56:10 -07002380 __func__, pHddCtx->connected_peer_count);
2381
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05302382 mutex_unlock(&pHddCtx->tdls_lock);
2383
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302384 EXIT();
Gopichand Nakkalab977a972013-02-18 19:15:09 -08002385}
2386
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002387void wlan_hdd_tdls_check_bmps(hdd_adapter_t *pAdapter)
Gopichand Nakkalab977a972013-02-18 19:15:09 -08002388{
Hanumantha Reddy Pothulada0fe362015-02-27 18:37:03 +05302389
2390 tdlsCtx_t *pHddTdlsCtx = NULL;
2391 hdd_context_t *pHddCtx = NULL;
Hoonki Lee14621352013-04-16 17:51:19 -07002392 hddTdlsPeer_t *curr_peer;
Gopichand Nakkalab977a972013-02-18 19:15:09 -08002393
Hanumantha Reddy Pothulada0fe362015-02-27 18:37:03 +05302394 if ((NULL == pAdapter) || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic))
2395 {
2396 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2397 FL("invalid pAdapter: %p"), pAdapter);
2398 return;
2399 }
2400
2401 pHddTdlsCtx = WLAN_HDD_GET_TDLS_CTX_PTR(pAdapter);
2402 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2403
c_hpothu7f63e882013-10-02 19:13:35 +05302404 if ((NULL == pHddCtx) || (NULL == pHddTdlsCtx))
2405 {
Sushant Kaushik125ae692014-11-25 17:38:48 +05302406 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
c_hpothu7f63e882013-10-02 19:13:35 +05302407 FL(" pHddCtx or pHddTdlsCtx points to NULL"));
2408 return;
2409 }
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002410
Pradeep Reddy POTTETI9db32f02015-01-29 15:22:54 +05302411 curr_peer = wlan_hdd_tdls_is_progress(pHddCtx, NULL, 0, TRUE);
Hoonki Lee14621352013-04-16 17:51:19 -07002412 if (NULL != curr_peer)
2413 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +05302414 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Hoonki Lee14621352013-04-16 17:51:19 -07002415 "%s: tdls in progress. Dont check for BMPS " MAC_ADDRESS_STR,
2416 __func__, MAC_ADDR_ARRAY (curr_peer->peerMac));
2417 return;
2418 }
2419
Hoonki Lee93e67ff2013-03-19 15:49:25 -07002420 if ((TDLS_CTX_MAGIC != pHddCtx->tdls_scan_ctxt.magic) &&
2421 (0 == pHddCtx->connected_peer_count) &&
Gopichand Nakkala75e7b282013-03-15 18:37:13 -07002422 (0 == pHddTdlsCtx->discovery_sent_cnt))
Gopichand Nakkalab977a972013-02-18 19:15:09 -08002423 {
Gopichand Nakkala75e7b282013-03-15 18:37:13 -07002424 if (FALSE == sme_IsPmcBmps(WLAN_HDD_GET_HAL_CTX(pAdapter)))
2425 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +05302426 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Gopichand Nakkalaccd3a382013-03-19 13:56:10 -07002427 "%s: No TDLS peer connected/discovery sent. Enable BMPS",
2428 __func__);
Gopichand Nakkala75e7b282013-03-15 18:37:13 -07002429 hdd_enable_bmps_imps(pHddCtx);
2430 }
Gopichand Nakkalab977a972013-02-18 19:15:09 -08002431 }
Gopichand Nakkala75e7b282013-03-15 18:37:13 -07002432 else
Gopichand Nakkalab977a972013-02-18 19:15:09 -08002433 {
Gopichand Nakkala75e7b282013-03-15 18:37:13 -07002434 if (TRUE == sme_IsPmcBmps(WLAN_HDD_GET_HAL_CTX(pAdapter)))
2435 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +05302436 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalaccd3a382013-03-19 13:56:10 -07002437 "%s: TDLS peer connected. Disable BMPS", __func__);
Gopichand Nakkala75e7b282013-03-15 18:37:13 -07002438 hdd_disable_bmps_imps(pHddCtx, WLAN_HDD_INFRA_STATION);
2439 }
Gopichand Nakkalab977a972013-02-18 19:15:09 -08002440 }
2441 return;
2442}
2443
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07002444u8 wlan_hdd_tdls_is_peer_progress(hdd_adapter_t *pAdapter, u8 *mac)
2445{
2446 hddTdlsPeer_t *curr_peer;
2447
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05302448 curr_peer = wlan_hdd_tdls_find_peer(pAdapter, mac, TRUE);
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07002449 if (curr_peer == NULL)
c_hpothu7f63e882013-10-02 19:13:35 +05302450 {
2451 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2452 "%s: curr_peer is NULL", __func__);
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07002453 return 0;
c_hpothu7f63e882013-10-02 19:13:35 +05302454 }
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07002455
2456 return (eTDLS_LINK_CONNECTING == curr_peer->link_status);
2457}
2458
Hoonki Leefb8df672013-04-10 18:20:34 -07002459/* return pointer to hddTdlsPeer_t if TDLS is ongoing. Otherwise return NULL.
Gopichand Nakkalab977a972013-02-18 19:15:09 -08002460 * mac - if NULL check for all the peer list, otherwise, skip this mac when skip_self is TRUE
2461 * skip_self - if TRUE, skip this mac. otherwise, check all the peer list. if
2462 mac is NULL, this argument is ignored, and check for all the peer list.
2463 */
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +05302464static hddTdlsPeer_t *wlan_hdd_tdls_find_progress_peer(hdd_adapter_t *pAdapter,
2465#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
2466 const u8 *mac,
2467#else
2468 u8 *mac,
2469#endif
2470 u8 skip_self)
Gopichand Nakkalab977a972013-02-18 19:15:09 -08002471{
2472 int i;
2473 struct list_head *head;
2474 hddTdlsPeer_t *curr_peer;
2475 struct list_head *pos;
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05302476 tdlsCtx_t *pHddTdlsCtx = WLAN_HDD_GET_TDLS_CTX_PTR(pAdapter);;
Madan Mohan Koyyalamudi263cec12013-10-07 10:57:50 +05302477
Madan Mohan Koyyalamudi263cec12013-10-07 10:57:50 +05302478 if (NULL == pHddTdlsCtx)
c_hpothu7f63e882013-10-02 19:13:35 +05302479 {
Ratheesh S P36dbc932015-08-07 14:28:57 +05302480 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
c_hpothu7f63e882013-10-02 19:13:35 +05302481 FL("pHddTdlsCtx is NULL"));
Madan Mohan Koyyalamudi263cec12013-10-07 10:57:50 +05302482 return NULL;
c_hpothu7f63e882013-10-02 19:13:35 +05302483 }
Madan Mohan Koyyalamudi263cec12013-10-07 10:57:50 +05302484
Gopichand Nakkalab977a972013-02-18 19:15:09 -08002485 for (i = 0; i < 256; i++) {
2486 head = &pHddTdlsCtx->peer_list[i];
2487 list_for_each(pos, head) {
2488 curr_peer = list_entry (pos, hddTdlsPeer_t, node);
2489 if (skip_self && mac && !memcmp(mac, curr_peer->peerMac, 6)) {
2490 continue;
2491 }
2492 else
2493 {
Gopichand Nakkala8b00c632013-03-08 19:47:52 -08002494 if (eTDLS_LINK_CONNECTING == curr_peer->link_status)
Gopichand Nakkalab977a972013-02-18 19:15:09 -08002495 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +05302496 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07002497 "%s:" MAC_ADDRESS_STR " eTDLS_LINK_CONNECTING",
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07002498 __func__, MAC_ADDR_ARRAY(curr_peer->peerMac));
Hoonki Leefb8df672013-04-10 18:20:34 -07002499 return curr_peer;
Gopichand Nakkalab977a972013-02-18 19:15:09 -08002500 }
2501 }
2502 }
2503 }
Hoonki Leefb8df672013-04-10 18:20:34 -07002504 return NULL;
2505}
2506
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +05302507hddTdlsPeer_t *wlan_hdd_tdls_is_progress(hdd_context_t *pHddCtx,
2508#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
2509 const u8 *mac,
2510#else
2511 u8 *mac,
2512#endif
Pradeep Reddy POTTETI9db32f02015-01-29 15:22:54 +05302513 u8 skip_self, tANI_BOOLEAN mutexLock)
Hoonki Leefb8df672013-04-10 18:20:34 -07002514{
2515 hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL;
2516 hdd_adapter_t *pAdapter = NULL;
2517 tdlsCtx_t *pHddTdlsCtx = NULL;
2518 hddTdlsPeer_t *curr_peer= NULL;
2519 VOS_STATUS status = 0;
2520
Pradeep Reddy POTTETI9db32f02015-01-29 15:22:54 +05302521 if (mutexLock)
2522 {
2523 mutex_lock(&pHddCtx->tdls_lock);
2524 }
Hoonki Leefb8df672013-04-10 18:20:34 -07002525 status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
2526 while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status )
2527 {
2528 pAdapter = pAdapterNode->pAdapter;
2529
2530 pHddTdlsCtx = WLAN_HDD_GET_TDLS_CTX_PTR(pAdapter);
2531 if (NULL != pHddTdlsCtx)
2532 {
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05302533 curr_peer = wlan_hdd_tdls_find_progress_peer(pAdapter, mac, skip_self);
Hoonki Leefb8df672013-04-10 18:20:34 -07002534 if (curr_peer)
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05302535 {
Pradeep Reddy POTTETI9db32f02015-01-29 15:22:54 +05302536 if (mutexLock)
2537 mutex_unlock(&pHddCtx->tdls_lock);
Hoonki Leefb8df672013-04-10 18:20:34 -07002538 return curr_peer;
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05302539 }
Hoonki Leefb8df672013-04-10 18:20:34 -07002540 }
2541 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
2542 pAdapterNode = pNext;
2543 }
Pradeep Reddy POTTETI9db32f02015-01-29 15:22:54 +05302544 if (mutexLock)
2545 mutex_unlock(&pHddCtx->tdls_lock);
Hoonki Leefb8df672013-04-10 18:20:34 -07002546 return NULL;
Gopichand Nakkalab977a972013-02-18 19:15:09 -08002547}
Hoonki Lee27511902013-03-14 18:19:06 -07002548
2549static void wlan_hdd_tdls_implicit_disable(tdlsCtx_t *pHddTdlsCtx)
2550{
Hoonki Lee27511902013-03-14 18:19:06 -07002551 wlan_hdd_tdls_timers_stop(pHddTdlsCtx);
Hoonki Lee27511902013-03-14 18:19:06 -07002552}
2553
2554static void wlan_hdd_tdls_implicit_enable(tdlsCtx_t *pHddTdlsCtx)
2555{
2556 wlan_hdd_tdls_peer_reset_discovery_processed(pHddTdlsCtx);
Gopichand Nakkala75e7b282013-03-15 18:37:13 -07002557 pHddTdlsCtx->discovery_sent_cnt = 0;
Hoonki Lee27511902013-03-14 18:19:06 -07002558 wlan_tdd_tdls_reset_tx_rx(pHddTdlsCtx);
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07002559 wlan_hdd_tdls_check_power_save_prohibited(pHddTdlsCtx->pAdapter);
Gopichand Nakkalaccd3a382013-03-19 13:56:10 -07002560
Hoonki Lee27511902013-03-14 18:19:06 -07002561
Gopichand Nakkala3046fc92013-03-23 13:56:43 -07002562 wlan_hdd_tdls_timer_restart(pHddTdlsCtx->pAdapter,
2563 &pHddTdlsCtx->peerUpdateTimer,
2564 pHddTdlsCtx->threshold_config.tx_period_t);
Hoonki Lee27511902013-03-14 18:19:06 -07002565}
2566
Gopichand Nakkaladcbcf4e2013-03-23 14:32:39 -07002567void wlan_hdd_tdls_set_mode(hdd_context_t *pHddCtx,
2568 eTDLSSupportMode tdls_mode,
2569 v_BOOL_t bUpdateLast)
Hoonki Lee27511902013-03-14 18:19:06 -07002570{
2571 hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL;
2572 VOS_STATUS status;
2573 hdd_adapter_t *pAdapter;
2574 tdlsCtx_t *pHddTdlsCtx;
2575
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +05302576 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2577 "%s mode %d", __func__, (int)tdls_mode);
c_hpothu7f63e882013-10-02 19:13:35 +05302578
2579 if(0 != (wlan_hdd_validate_context(pHddCtx)))
2580 {
Madan Mohan Koyyalamudi263cec12013-10-07 10:57:50 +05302581 return;
c_hpothu7f63e882013-10-02 19:13:35 +05302582 }
Hoonki Lee27511902013-03-14 18:19:06 -07002583
Rajesh Chauhana34c6e62014-03-25 16:37:58 +05302584 mutex_lock(&pHddCtx->tdls_lock);
Gopichand Nakkala638ebc72013-03-21 18:04:02 -07002585
Hoonki Lee93e67ff2013-03-19 15:49:25 -07002586 if (pHddCtx->tdls_mode == tdls_mode)
2587 {
Hema Aparna Medicharla8bb6f782015-03-09 12:35:05 +05302588 mutex_unlock(&pHddCtx->tdls_lock);
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +05302589 hddLog(VOS_TRACE_LEVEL_INFO, "%s already in mode %d", __func__,
2590 (int)tdls_mode);
Hoonki Lee93e67ff2013-03-19 15:49:25 -07002591 return;
2592 }
2593
Hoonki Lee27511902013-03-14 18:19:06 -07002594 status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
2595
2596 while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status )
2597 {
2598 pAdapter = pAdapterNode->pAdapter;
Hoonki Leea6d49be2013-04-05 09:43:25 -07002599 pHddTdlsCtx = WLAN_HDD_GET_TDLS_CTX_PTR(pAdapter);
2600 if (NULL != pHddTdlsCtx)
Hoonki Lee27511902013-03-14 18:19:06 -07002601 {
Hoonki Leea6d49be2013-04-05 09:43:25 -07002602 if(eTDLS_SUPPORT_ENABLED == tdls_mode)
2603 wlan_hdd_tdls_implicit_enable(pHddTdlsCtx);
2604 else if((eTDLS_SUPPORT_DISABLED == tdls_mode) ||
2605 (eTDLS_SUPPORT_EXPLICIT_TRIGGER_ONLY == tdls_mode))
2606 wlan_hdd_tdls_implicit_disable(pHddTdlsCtx);
Hoonki Lee27511902013-03-14 18:19:06 -07002607 }
2608 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
2609 pAdapterNode = pNext;
2610 }
Gopichand Nakkaladcbcf4e2013-03-23 14:32:39 -07002611 if(bUpdateLast)
2612 {
2613 pHddCtx->tdls_mode_last = tdls_mode;
2614 }
2615 else
2616 {
2617 pHddCtx->tdls_mode_last = pHddCtx->tdls_mode;
2618 }
Hoonki Lee27511902013-03-14 18:19:06 -07002619 pHddCtx->tdls_mode = tdls_mode;
Gopichand Nakkaladcbcf4e2013-03-23 14:32:39 -07002620
Madan Mohan Koyyalamudi263cec12013-10-07 10:57:50 +05302621 mutex_unlock(&pHddCtx->tdls_lock);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302622
Hoonki Lee27511902013-03-14 18:19:06 -07002623}
Gopichand Nakkala75e7b282013-03-15 18:37:13 -07002624
Pradeep Reddy POTTETI9db32f02015-01-29 15:22:54 +05302625static
2626void wlan_hdd_tdls_implicit_send_discovery_request(tdlsCtx_t * pHddTdlsCtx)
Gopichand Nakkala75e7b282013-03-15 18:37:13 -07002627{
Pradeep Reddy POTTETI9db32f02015-01-29 15:22:54 +05302628 hdd_context_t *pHddCtx = NULL;
2629 hddTdlsPeer_t *curr_peer = NULL, *temp_peer = NULL;
Hoonki Leed37cbb32013-04-20 00:31:14 -07002630
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302631 ENTER();
Hoonki Leed37cbb32013-04-20 00:31:14 -07002632 if (NULL == pHddTdlsCtx)
c_hpothu7f63e882013-10-02 19:13:35 +05302633 {
Ratheesh S P36dbc932015-08-07 14:28:57 +05302634 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
c_hpothu7f63e882013-10-02 19:13:35 +05302635 FL("pHddTdlsCtx is NULL"));
Hoonki Leed37cbb32013-04-20 00:31:14 -07002636 return;
c_hpothu7f63e882013-10-02 19:13:35 +05302637 }
Hoonki Leed37cbb32013-04-20 00:31:14 -07002638
Hoonki Leed37cbb32013-04-20 00:31:14 -07002639 pHddCtx = WLAN_HDD_GET_CTX(pHddTdlsCtx->pAdapter);
Hoonki Leefb8df672013-04-10 18:20:34 -07002640
c_hpothu7f63e882013-10-02 19:13:35 +05302641 if(0 != (wlan_hdd_validate_context(pHddCtx)))
2642 {
Hoonki Leefb8df672013-04-10 18:20:34 -07002643 return;
c_hpothu7f63e882013-10-02 19:13:35 +05302644 }
Gopichand Nakkala75e7b282013-03-15 18:37:13 -07002645
Hoonki Leed37cbb32013-04-20 00:31:14 -07002646 curr_peer = pHddTdlsCtx->curr_candidate;
Hoonki Leed37cbb32013-04-20 00:31:14 -07002647 if (NULL == curr_peer)
c_hpothu7f63e882013-10-02 19:13:35 +05302648 {
2649 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2650 FL("curr_peer is NULL"));
2651
Hoonki Leed37cbb32013-04-20 00:31:14 -07002652 return;
c_hpothu7f63e882013-10-02 19:13:35 +05302653 }
Hoonki Leed37cbb32013-04-20 00:31:14 -07002654
Gopichand Nakkala75e7b282013-03-15 18:37:13 -07002655 if (TRUE == sme_IsPmcBmps(WLAN_HDD_GET_HAL_CTX(pHddTdlsCtx->pAdapter)))
2656 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +05302657 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2658 "%s: Disable BMPS", __func__);
Gopichand Nakkala75e7b282013-03-15 18:37:13 -07002659 hdd_disable_bmps_imps(pHddCtx, WLAN_HDD_INFRA_STATION);
2660 }
Gopichand Nakkalaccd3a382013-03-19 13:56:10 -07002661
Pradeep Reddy POTTETI9db32f02015-01-29 15:22:54 +05302662 /* This function is called in mutex_lock */
2663 temp_peer = wlan_hdd_tdls_is_progress(pHddCtx, NULL, 0, FALSE);
Hoonki Leefb8df672013-04-10 18:20:34 -07002664 if (NULL != temp_peer)
2665 {
Pradeep Reddy POTTETI9db32f02015-01-29 15:22:54 +05302666 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2667 "%s: " MAC_ADDRESS_STR " ongoing. pre_setup ignored",
2668 __func__, MAC_ADDR_ARRAY(temp_peer->peerMac));
Hoonki Leed37cbb32013-04-20 00:31:14 -07002669 goto done;
Hoonki Leefb8df672013-04-10 18:20:34 -07002670 }
2671
Gopichand Nakkalaccd3a382013-03-19 13:56:10 -07002672 if (eTDLS_CAP_UNKNOWN != curr_peer->tdls_support)
Atul Mittal115287b2014-07-08 13:26:33 +05302673 wlan_hdd_tdls_set_peer_link_status(curr_peer,
2674 eTDLS_LINK_DISCOVERING,
2675 eTDLS_LINK_SUCCESS);
Gopichand Nakkalaccd3a382013-03-19 13:56:10 -07002676
Pradeep Reddy POTTETI9db32f02015-01-29 15:22:54 +05302677 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2678 "%s: Implicit TDLS, Send Discovery request event", __func__);
Hoonki Leed37cbb32013-04-20 00:31:14 -07002679
Pradeep Reddy POTTETI9db32f02015-01-29 15:22:54 +05302680 cfg80211_tdls_oper_request(pHddTdlsCtx->pAdapter->dev,
2681 curr_peer->peerMac,
2682 NL80211_TDLS_DISCOVERY_REQ,
2683 FALSE,
2684 GFP_KERNEL);
Gopichand Nakkala75e7b282013-03-15 18:37:13 -07002685 pHddTdlsCtx->discovery_sent_cnt++;
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05302686
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07002687 wlan_hdd_tdls_check_power_save_prohibited(pHddTdlsCtx->pAdapter);
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05302688
Pradeep Reddy POTTETI219ced32014-11-14 16:33:57 +05302689 wlan_hdd_tdls_timer_restart(pHddTdlsCtx->pAdapter,
2690 &pHddTdlsCtx->peerDiscoveryTimeoutTimer,
2691 pHddTdlsCtx->threshold_config.tx_period_t - TDLS_DISCOVERY_TIMEOUT_BEFORE_UPDATE);
2692
Pradeep Reddy POTTETI9db32f02015-01-29 15:22:54 +05302693 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2694 "%s: discovery count %u timeout %u msec",
2695 __func__, pHddTdlsCtx->discovery_sent_cnt,
2696 pHddTdlsCtx->threshold_config.tx_period_t - TDLS_DISCOVERY_TIMEOUT_BEFORE_UPDATE);
Gopichand Nakkala3046fc92013-03-23 13:56:43 -07002697
Hoonki Leed37cbb32013-04-20 00:31:14 -07002698done:
2699 pHddTdlsCtx->curr_candidate = NULL;
2700 pHddTdlsCtx->magic = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302701 EXIT();
Gopichand Nakkala75e7b282013-03-15 18:37:13 -07002702 return;
2703}
Gopichand Nakkalaccd3a382013-03-19 13:56:10 -07002704
2705tANI_U32 wlan_hdd_tdls_discovery_sent_cnt(hdd_context_t *pHddCtx)
2706{
2707 hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL;
2708 hdd_adapter_t *pAdapter = NULL;
2709 tdlsCtx_t *pHddTdlsCtx = NULL;
2710 VOS_STATUS status = 0;
2711 tANI_U32 count = 0;
2712
2713 status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
2714 while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status )
2715 {
2716 pAdapter = pAdapterNode->pAdapter;
2717
Hoonki Leea6d49be2013-04-05 09:43:25 -07002718 pHddTdlsCtx = WLAN_HDD_GET_TDLS_CTX_PTR(pAdapter);
2719 if (NULL != pHddTdlsCtx)
Gopichand Nakkalaccd3a382013-03-19 13:56:10 -07002720 {
Hoonki Leea6d49be2013-04-05 09:43:25 -07002721 count = count + pHddTdlsCtx->discovery_sent_cnt;
Gopichand Nakkalaccd3a382013-03-19 13:56:10 -07002722 }
2723 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
2724 pAdapterNode = pNext;
2725 }
2726 return count;
2727}
2728
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07002729void wlan_hdd_tdls_check_power_save_prohibited(hdd_adapter_t *pAdapter)
Gopichand Nakkalaccd3a382013-03-19 13:56:10 -07002730{
Hanumantha Reddy Pothulada0fe362015-02-27 18:37:03 +05302731 tdlsCtx_t *pHddTdlsCtx = NULL;
2732 hdd_context_t *pHddCtx = NULL;
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +05302733
Hanumantha Reddy Pothulada0fe362015-02-27 18:37:03 +05302734
2735 if ((NULL == pAdapter) || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic))
2736 {
2737 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2738 FL("invalid pAdapter: %p"), pAdapter);
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +05302739 return;
2740 }
2741
2742 pHddTdlsCtx = WLAN_HDD_GET_TDLS_CTX_PTR(pAdapter);
2743 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkalaccd3a382013-03-19 13:56:10 -07002744
2745 if ((NULL == pHddTdlsCtx) || (NULL == pHddCtx))
c_hpothu7f63e882013-10-02 19:13:35 +05302746 {
2747 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2748 FL(" pHddCtx or pHddTdlsCtx points to NULL"));
Gopichand Nakkalaccd3a382013-03-19 13:56:10 -07002749 return;
c_hpothu7f63e882013-10-02 19:13:35 +05302750 }
Gopichand Nakkalaccd3a382013-03-19 13:56:10 -07002751
2752 if ((0 == pHddCtx->connected_peer_count) &&
2753 (0 == wlan_hdd_tdls_discovery_sent_cnt(pHddCtx)))
2754 {
2755 sme_SetTdlsPowerSaveProhibited(WLAN_HDD_GET_HAL_CTX(pHddTdlsCtx->pAdapter), 0);
2756 return;
2757 }
2758 sme_SetTdlsPowerSaveProhibited(WLAN_HDD_GET_HAL_CTX(pHddTdlsCtx->pAdapter), 1);
2759 return;
2760}
Hoonki Lee93e67ff2013-03-19 15:49:25 -07002761
2762void wlan_hdd_tdls_free_scan_request (tdls_scan_context_t *tdls_scan_ctx)
2763{
2764 if (NULL == tdls_scan_ctx)
c_hpothu7f63e882013-10-02 19:13:35 +05302765 {
2766 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2767 FL("tdls_scan_ctx is NULL"));
Hoonki Lee93e67ff2013-03-19 15:49:25 -07002768 return;
c_hpothu7f63e882013-10-02 19:13:35 +05302769 }
Hoonki Lee93e67ff2013-03-19 15:49:25 -07002770
Gopichand Nakkala3046fc92013-03-23 13:56:43 -07002771 tdls_scan_ctx->attempt = 0;
Hoonki Leefb8df672013-04-10 18:20:34 -07002772 tdls_scan_ctx->reject = 0;
Gopichand Nakkala3046fc92013-03-23 13:56:43 -07002773 tdls_scan_ctx->magic = 0;
Hoonki Lee93e67ff2013-03-19 15:49:25 -07002774 tdls_scan_ctx->scan_request = NULL;
2775 return;
2776}
2777
2778int wlan_hdd_tdls_copy_scan_context(hdd_context_t *pHddCtx,
2779 struct wiphy *wiphy,
2780#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
2781 struct net_device *dev,
2782#endif
2783 struct cfg80211_scan_request *request)
2784{
2785 tdls_scan_context_t *scan_ctx;
2786
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302787 ENTER();
c_hpothu7f63e882013-10-02 19:13:35 +05302788 if(0 != (wlan_hdd_validate_context(pHddCtx)))
2789 {
c_hpothu7f63e882013-10-02 19:13:35 +05302790 return 0;
2791 }
Hoonki Lee93e67ff2013-03-19 15:49:25 -07002792
2793 scan_ctx = &pHddCtx->tdls_scan_ctxt;
2794
2795 scan_ctx->wiphy = wiphy;
2796#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
2797 scan_ctx->dev = dev;
2798#endif
2799
2800 scan_ctx->scan_request = request;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302801
2802 EXIT();
Hoonki Lee93e67ff2013-03-19 15:49:25 -07002803 return 0;
2804}
2805
Hoonki Lee93e67ff2013-03-19 15:49:25 -07002806static void wlan_hdd_tdls_scan_init_work(hdd_context_t *pHddCtx,
2807 struct wiphy *wiphy,
2808#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
2809 struct net_device *dev,
2810#endif
2811 struct cfg80211_scan_request *request,
2812 unsigned long delay)
2813{
2814 if (TDLS_CTX_MAGIC != pHddCtx->tdls_scan_ctxt.magic)
2815 {
2816#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
2817 wlan_hdd_tdls_copy_scan_context(pHddCtx, wiphy, dev, request);
2818#else
2819 wlan_hdd_tdls_copy_scan_context(pHddCtx, wiphy, request);
2820#endif
2821 pHddCtx->tdls_scan_ctxt.attempt = 0;
2822 pHddCtx->tdls_scan_ctxt.magic = TDLS_CTX_MAGIC;
2823 }
Hoonki Lee93e67ff2013-03-19 15:49:25 -07002824 schedule_delayed_work(&pHddCtx->tdls_scan_ctxt.tdls_scan_work, delay);
2825}
2826
2827/* return negative = caller should stop and return error code immediately
2828 return 0 = caller should stop and return success immediately
2829 return 1 = caller can continue to scan
2830 */
2831int wlan_hdd_tdls_scan_callback (hdd_adapter_t *pAdapter,
2832 struct wiphy *wiphy,
2833#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
2834 struct net_device *dev,
2835#endif
2836 struct cfg80211_scan_request *request)
2837{
Hoonki Lee93e67ff2013-03-19 15:49:25 -07002838 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2839 u16 connectedTdlsPeers;
Pradeep Reddy POTTETIedaeb5f2014-05-22 23:34:41 +05302840 hddTdlsPeer_t *curr_peer, *connected_peer;
Hoonki Lee93e67ff2013-03-19 15:49:25 -07002841 unsigned long delay;
Pradeep Reddy POTTETIedaeb5f2014-05-22 23:34:41 +05302842 hdd_config_t *cfg_param = pHddCtx->cfg_ini;
Hoonki Lee93e67ff2013-03-19 15:49:25 -07002843
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302844 ENTER();
c_hpothu7f63e882013-10-02 19:13:35 +05302845 if(0 != (wlan_hdd_validate_context(pHddCtx)))
2846 {
Hoonki Lee93e67ff2013-03-19 15:49:25 -07002847 return 0;
c_hpothu7f63e882013-10-02 19:13:35 +05302848 }
Hoonki Lee93e67ff2013-03-19 15:49:25 -07002849
2850 /* if tdls is not enabled, then continue scan */
Pradeep Reddy POTTETIf0569d72014-12-13 16:54:03 +05302851 if ((eTDLS_SUPPORT_NOT_ENABLED == pHddCtx->tdls_mode) ||
2852 (pHddCtx->is_tdls_btc_enabled == FALSE))
Hoonki Lee93e67ff2013-03-19 15:49:25 -07002853 return 1;
Pradeep Reddy POTTETI9db32f02015-01-29 15:22:54 +05302854 curr_peer = wlan_hdd_tdls_is_progress(pHddCtx, NULL, 0, TRUE);
Hoonki Leefb8df672013-04-10 18:20:34 -07002855 if (NULL != curr_peer)
Hoonki Lee93e67ff2013-03-19 15:49:25 -07002856 {
Hoonki Leefb8df672013-04-10 18:20:34 -07002857 if (pHddCtx->tdls_scan_ctxt.reject++ >= TDLS_MAX_SCAN_REJECT)
2858 {
2859 pHddCtx->tdls_scan_ctxt.reject = 0;
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +05302860 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Hoonki Leefb8df672013-04-10 18:20:34 -07002861 "%s: " MAC_ADDRESS_STR ". scan rejected %d. force it to idle",
2862 __func__, MAC_ADDR_ARRAY (curr_peer->peerMac), pHddCtx->tdls_scan_ctxt.reject);
2863
Atul Mittal115287b2014-07-08 13:26:33 +05302864 wlan_hdd_tdls_set_peer_link_status (curr_peer,
2865 eTDLS_LINK_IDLE,
2866 eTDLS_LINK_UNSPECIFIED);
Hoonki Leefb8df672013-04-10 18:20:34 -07002867 return 1;
2868 }
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +05302869 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Hoonki Leefb8df672013-04-10 18:20:34 -07002870 "%s: tdls in progress. scan rejected %d",
2871 __func__, pHddCtx->tdls_scan_ctxt.reject);
Hoonki Lee93e67ff2013-03-19 15:49:25 -07002872 return -EBUSY;
2873 }
2874
2875 /* tdls teardown is ongoing */
2876 if (eTDLS_SUPPORT_DISABLED == pHddCtx->tdls_mode)
2877 {
2878 connectedTdlsPeers = wlan_hdd_tdlsConnectedPeers(pAdapter);
2879 if (connectedTdlsPeers && (pHddCtx->tdls_scan_ctxt.attempt < TDLS_MAX_SCAN_SCHEDULE))
2880 {
2881 delay = (unsigned long)(TDLS_DELAY_SCAN_PER_CONNECTION*connectedTdlsPeers);
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +05302882 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Hoonki Lee93e67ff2013-03-19 15:49:25 -07002883 "%s: tdls disabled, but still connected_peers %d attempt %d. schedule scan %lu msec",
2884 __func__, connectedTdlsPeers, pHddCtx->tdls_scan_ctxt.attempt, delay);
2885
2886 wlan_hdd_tdls_scan_init_work (pHddCtx, wiphy,
2887#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
2888 dev,
2889#endif
2890 request,
2891 msecs_to_jiffies(delay));
2892 /* scan should not continue */
2893 return 0;
2894 }
2895 /* no connected peer or max retry reached, scan continue */
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +05302896 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Hoonki Lee93e67ff2013-03-19 15:49:25 -07002897 "%s: tdls disabled. connected_peers %d attempt %d. scan allowed",
2898 __func__, connectedTdlsPeers, pHddCtx->tdls_scan_ctxt.attempt);
2899 return 1;
2900 }
Agarwal Ashishef54a182014-12-16 15:07:31 +05302901
2902 /* if fEnableTDLSScan flag is 1 ; driverwill allow scan even if
2903 * peer station is not buffer STA capable
2904 *
2905 * RX: If there is any RX activity, device will lose RX packets,
2906 * as peer will not be aware that device is off channel.
2907 * TX: TX is stopped whenever device initiate scan.
2908 */
2909 if (pHddCtx->cfg_ini->fEnableTDLSScan == 1)
2910 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +05302911 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Agarwal Ashishef54a182014-12-16 15:07:31 +05302912 FL("Allow SCAN in all TDLS cases"));
2913 return 1;
2914 }
2915
Hoonki Lee93e67ff2013-03-19 15:49:25 -07002916 /* while tdls is up, first time scan */
2917 else if (eTDLS_SUPPORT_ENABLED == pHddCtx->tdls_mode ||
2918 eTDLS_SUPPORT_EXPLICIT_TRIGGER_ONLY == pHddCtx->tdls_mode)
2919 {
Hoonki Lee93e67ff2013-03-19 15:49:25 -07002920 connectedTdlsPeers = wlan_hdd_tdlsConnectedPeers(pAdapter);
Pradeep Reddy POTTETIedaeb5f2014-05-22 23:34:41 +05302921
2922 /* check the TDLS link and Scan coexistance Capability */
2923 if ( (TRUE == pHddCtx->cfg_ini->fEnableTDLSScanCoexSupport) &&
2924 (TRUE == sme_IsFeatureSupportedByFW(TDLS_SCAN_COEXISTENCE)) &&
2925 (connectedTdlsPeers == 1) )
2926 {
2927 /* get connected peer information */
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +05302928 connected_peer = wlan_hdd_tdls_get_connected_peer(pAdapter);
Pradeep Reddy POTTETIedaeb5f2014-05-22 23:34:41 +05302929 if (NULL == connected_peer) {
2930 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
2931 "%s: Invalid connected_peer, Continue Scanning", __func__);
2932 /* scan should continue */
2933 return 1;
2934 }
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +05302935 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Pradeep Reddy POTTETIedaeb5f2014-05-22 23:34:41 +05302936 ("%s: TDLS Scan Co-exist supported connectedTdlsPeers =%d buffersta =%d"),
2937 __func__,connectedTdlsPeers,connected_peer->isBufSta);
2938
2939 if (connected_peer->isBufSta)
2940 {
2941 pHddCtx->isTdlsScanCoexistence = TRUE;
2942 if ((cfg_param->dynSplitscan) && (!pHddCtx->issplitscan_enabled))
2943 {
2944 pHddCtx->issplitscan_enabled = TRUE;
2945 sme_enable_disable_split_scan(
2946 WLAN_HDD_GET_HAL_CTX(pAdapter),
2947 cfg_param->nNumStaChanCombinedConc,
2948 cfg_param->nNumP2PChanCombinedConc);
2949 }
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +05302950 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Pradeep Reddy POTTETIedaeb5f2014-05-22 23:34:41 +05302951 ("%s:%d TDLS Scan Co-exist supported splitscan_enabled =%d "),
2952 __func__, __LINE__, pHddCtx->issplitscan_enabled);
2953 return 1;
2954 }
2955
2956 }
2957 else
2958 {
2959 /* Throughput Monitor shall disable the split scan when
2960 * TDLS scan coexistance is disabled.At this point of time
2961 * since TDLS scan coexistance is not meeting the criteria
2962 * to be operational, explicitly make it false to enable
2963 * throughput monitor takes the control of split scan.
2964 */
2965 pHddCtx->isTdlsScanCoexistence = FALSE;
2966 }
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +05302967 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Pradeep Reddy POTTETIedaeb5f2014-05-22 23:34:41 +05302968 ("%s: TDLS Scan Co-exist not supported connectedTdlsPeers =%d"
2969 " TDLSScanCoexSupport param =%d TDLS_SCAN_COEXISTENCE =%d"),
2970 __func__, connectedTdlsPeers,
2971 pHddCtx->cfg_ini->fEnableTDLSScanCoexSupport,
2972 sme_IsFeatureSupportedByFW(TDLS_SCAN_COEXISTENCE));
2973
Atul Mittal5803b342014-09-04 15:31:19 +05302974 /* disable implicit trigger logic & tdls operatoin */
2975 wlan_hdd_tdls_set_mode(pHddCtx, eTDLS_SUPPORT_DISABLED, FALSE);
Pradeep Reddy POTTETIedaeb5f2014-05-22 23:34:41 +05302976 /* fall back to the implementation of teardown the peers on the scan
2977 * when the number of connected peers are more than one. TDLS Scan
2978 * coexistance feature is exercised only when a single peer is
2979 * connected and the DUT shall not advertize the Buffer Sta capability,
2980 * so that the peer shall not go to the TDLS power save
2981 */
2982
Hoonki Lee93e67ff2013-03-19 15:49:25 -07002983 if (connectedTdlsPeers)
2984 {
2985 tANI_U8 staIdx;
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07002986 hddTdlsPeer_t *curr_peer;
Hoonki Lee93e67ff2013-03-19 15:49:25 -07002987
2988 for (staIdx = 0; staIdx < HDD_MAX_NUM_TDLS_STA; staIdx++)
2989 {
2990 if (pHddCtx->tdlsConnInfo[staIdx].staId)
2991 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +05302992 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2993 ("%s: indicate TDLS teardown (staId %d)"), __func__, pHddCtx->tdlsConnInfo[staIdx].staId) ;
Hoonki Lee93e67ff2013-03-19 15:49:25 -07002994
2995#ifdef CONFIG_TDLS_IMPLICIT
Hoonki Leea6d49be2013-04-05 09:43:25 -07002996 curr_peer = wlan_hdd_tdls_find_all_peer(pHddCtx, pHddCtx->tdlsConnInfo[staIdx].peerMac.bytes);
2997 if(curr_peer)
2998 wlan_hdd_tdls_indicate_teardown(curr_peer->pHddTdlsCtx->pAdapter, curr_peer, eSIR_MAC_TDLS_TEARDOWN_UNSPEC_REASON);
Hoonki Lee93e67ff2013-03-19 15:49:25 -07002999#endif
3000 }
3001 }
3002 /* schedule scan */
3003 delay = (unsigned long)(TDLS_DELAY_SCAN_PER_CONNECTION*connectedTdlsPeers);
3004
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +05303005 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Hoonki Lee93e67ff2013-03-19 15:49:25 -07003006 "%s: tdls enabled (mode %d), connected_peers %d. schedule scan %lu msec",
3007 __func__, pHddCtx->tdls_mode, wlan_hdd_tdlsConnectedPeers(pAdapter),
3008 delay);
3009
3010 wlan_hdd_tdls_scan_init_work (pHddCtx, wiphy,
3011#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
3012 dev,
3013#endif
3014 request,
3015 msecs_to_jiffies(delay));
3016 /* scan should not continue */
3017 return 0;
3018 }
3019 /* no connected peer, scan continue */
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +05303020 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Hoonki Lee93e67ff2013-03-19 15:49:25 -07003021 "%s: tdls_mode %d, and no tdls connection. scan allowed",
3022 __func__, pHddCtx->tdls_mode);
3023 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303024 EXIT();
Hoonki Lee93e67ff2013-03-19 15:49:25 -07003025 return 1;
3026}
3027
3028void wlan_hdd_tdls_scan_done_callback(hdd_adapter_t *pAdapter)
3029{
3030 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Hoonki Lee93e67ff2013-03-19 15:49:25 -07003031
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303032 ENTER();
c_hpothu7f63e882013-10-02 19:13:35 +05303033 if(0 != (wlan_hdd_validate_context(pHddCtx)))
3034 {
Hoonki Lee93e67ff2013-03-19 15:49:25 -07003035 return;
c_hpothu7f63e882013-10-02 19:13:35 +05303036 }
Hoonki Lee93e67ff2013-03-19 15:49:25 -07003037
Pradeep Reddy POTTETIc7822df2015-02-19 20:15:41 +05303038 /* if tdls is not enabled or BtCoex is on then don't revert tdls mode */
3039 if ((eTDLS_SUPPORT_NOT_ENABLED == pHddCtx->tdls_mode) ||
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05303040 (pHddCtx->is_tdls_btc_enabled == FALSE)) {
3041 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to revert: Mode=%d, BTC enabled=%d"),
3042 pHddCtx->tdls_mode, pHddCtx->is_tdls_btc_enabled);
Pradeep Reddy POTTETIc7822df2015-02-19 20:15:41 +05303043 return;
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05303044 }
Sunil Dutt41de4e22013-11-14 18:09:02 +05303045
Hoonki Lee93e67ff2013-03-19 15:49:25 -07003046 /* free allocated memory at scan time */
Gopichand Nakkala3046fc92013-03-23 13:56:43 -07003047 wlan_hdd_tdls_free_scan_request (&pHddCtx->tdls_scan_ctxt);
Hoonki Lee93e67ff2013-03-19 15:49:25 -07003048
3049 /* if tdls was enabled before scan, re-enable tdls mode */
3050 if(eTDLS_SUPPORT_ENABLED == pHddCtx->tdls_mode_last ||
3051 eTDLS_SUPPORT_EXPLICIT_TRIGGER_ONLY == pHddCtx->tdls_mode_last)
3052 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +05303053 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Hoonki Lee93e67ff2013-03-19 15:49:25 -07003054 ("%s: revert tdls mode %d"), __func__, pHddCtx->tdls_mode_last);
3055
Gopichand Nakkaladcbcf4e2013-03-23 14:32:39 -07003056 wlan_hdd_tdls_set_mode(pHddCtx, pHddCtx->tdls_mode_last, FALSE);
Hoonki Lee93e67ff2013-03-19 15:49:25 -07003057 }
3058 wlan_hdd_tdls_check_bmps(pAdapter);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303059
3060 EXIT();
Hoonki Lee93e67ff2013-03-19 15:49:25 -07003061}
Gopichand Nakkala3046fc92013-03-23 13:56:43 -07003062
3063void wlan_hdd_tdls_timer_restart(hdd_adapter_t *pAdapter,
3064 vos_timer_t *timer,
3065 v_U32_t expirationTime)
3066{
3067 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3068
3069 if (NULL == pHddStaCtx)
c_hpothu7f63e882013-10-02 19:13:35 +05303070 {
3071 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3072 FL("pHddStaCtx is NULL"));
Gopichand Nakkala3046fc92013-03-23 13:56:43 -07003073 return;
c_hpothu7f63e882013-10-02 19:13:35 +05303074 }
Gopichand Nakkala3046fc92013-03-23 13:56:43 -07003075
3076 /* Check whether driver load unload is in progress */
3077 if(vos_is_load_unload_in_progress( VOS_MODULE_ID_VOSS, NULL))
3078 {
3079 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
3080 "%s: Driver load/unload is in progress.", __func__);
3081 return;
3082 }
3083
3084 if (hdd_connIsConnected(pHddStaCtx))
3085 {
3086 vos_timer_stop(timer);
3087 vos_timer_start(timer, expirationTime);
3088 }
3089}
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003090void wlan_hdd_tdls_indicate_teardown(hdd_adapter_t *pAdapter,
3091 hddTdlsPeer_t *curr_peer,
3092 tANI_U16 reason)
3093{
Pradeep Reddy POTTETI8a623132014-06-26 16:07:06 +05303094 hdd_context_t *pHddCtx;
Pradeep Reddy POTTETIedaeb5f2014-05-22 23:34:41 +05303095
Hanumantha Reddy Pothulada0fe362015-02-27 18:37:03 +05303096 if ((NULL == pAdapter || WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic) ||
3097 (NULL == curr_peer))
c_hpothu7f63e882013-10-02 19:13:35 +05303098 {
3099 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3100 FL("parameters passed are invalid"));
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003101 return;
c_hpothu7f63e882013-10-02 19:13:35 +05303102 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003103
Pradeep Reddy POTTETI8a623132014-06-26 16:07:06 +05303104 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3105
Masti, Narayanraddi9d275662015-08-26 13:15:12 +05303106 if ((eTDLS_LINK_CONNECTED != curr_peer->link_status) &&
3107 (eTDLS_LINK_CONNECTING != curr_peer->link_status))
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003108 return;
3109
Pradeep Reddy POTTETIedaeb5f2014-05-22 23:34:41 +05303110 /* Throughput Monitor shall disable the split scan when
3111 * TDLS scan coexistance is disabled.At this point of time
3112 * since TDLS scan coexistance is not meeting the criteria
3113 * to be operational, explicitly make it false to enable
3114 * throughput monitor takes the control of split scan.
3115 */
Pradeep Reddy POTTETI8a623132014-06-26 16:07:06 +05303116 if (pHddCtx && (pHddCtx->isTdlsScanCoexistence == TRUE))
Pradeep Reddy POTTETIedaeb5f2014-05-22 23:34:41 +05303117 {
3118 pHddCtx->isTdlsScanCoexistence = FALSE;
3119 }
3120
Atul Mittal115287b2014-07-08 13:26:33 +05303121 wlan_hdd_tdls_set_peer_link_status(curr_peer,
3122 eTDLS_LINK_TEARING,
Atul Mittal271a7652014-09-12 13:18:22 +05303123 eTDLS_LINK_UNSPECIFIED);
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +05303124 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3125 FL("Setting NL80211_TDLS_TEARDOWN, reason %d"), reason);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003126 cfg80211_tdls_oper_request(pAdapter->dev,
3127 curr_peer->peerMac,
3128 NL80211_TDLS_TEARDOWN,
3129 reason,
3130 GFP_KERNEL);
3131}
Atul Mittal115287b2014-07-08 13:26:33 +05303132
3133
3134/*EXT TDLS*/
3135int wlan_hdd_set_callback(hddTdlsPeer_t *curr_peer,
3136 cfg80211_exttdls_callback callback)
3137{
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +05303138 /* NOTE:
3139 * Hold mutex tdls_lock before calling this function
3140 */
Atul Mittal115287b2014-07-08 13:26:33 +05303141
3142 hdd_context_t *pHddCtx;
3143 hdd_adapter_t *pAdapter;
3144
3145 if (!curr_peer) return -1;
3146
3147 pAdapter = curr_peer->pHddTdlsCtx->pAdapter;
3148 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3149 if ((NULL == pHddCtx)) return -1;
3150
Atul Mittal115287b2014-07-08 13:26:33 +05303151 curr_peer->state_change_notification = callback;
3152
Atul Mittal115287b2014-07-08 13:26:33 +05303153 return 0;
Atul Mittal115287b2014-07-08 13:26:33 +05303154}
3155
3156void wlan_hdd_tdls_get_wifi_hal_state(hddTdlsPeer_t *curr_peer,
3157 tANI_S32 *state,
3158 tANI_S32 *reason)
3159{
3160 *reason = curr_peer->reason;
3161
3162 switch(curr_peer->link_status)
3163 {
3164 case eTDLS_LINK_IDLE:
Atul Mittal115287b2014-07-08 13:26:33 +05303165 case eTDLS_LINK_DISCOVERED:
3166 *state = WIFI_TDLS_ENABLED;
3167 break;
Atul Mittalad630e42014-10-07 19:19:14 +05303168 case eTDLS_LINK_DISCOVERING:
Atul Mittal115287b2014-07-08 13:26:33 +05303169 case eTDLS_LINK_CONNECTING:
3170 *state = WIFI_TDLS_TRYING;
3171 break;
3172 case eTDLS_LINK_CONNECTED:
Pradeep Reddy POTTETIf3148e82015-04-16 12:10:33 +05303173 if (TRUE == curr_peer->isOffChannelEstablished)
Pradeep Reddy POTTETI16d83332015-03-26 18:28:13 +05303174 {
3175 *state = WIFI_TDLS_ESTABLISHED_OFF_CHANNEL;
3176 }
3177 else
3178 {
3179 *state = WIFI_TDLS_ESTABLISHED;
3180 }
Atul Mittal115287b2014-07-08 13:26:33 +05303181 break;
3182 case eTDLS_LINK_TEARING:
3183 *state = WIFI_TDLS_DROPPED;
3184 break;
3185 }
3186
3187}
3188
3189int wlan_hdd_tdls_get_status(hdd_adapter_t *pAdapter,
Anand N Sunkad9bfc2622015-07-30 15:18:54 +05303190#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
3191 const tANI_U8* mac,
3192#else
Atul Mittal115287b2014-07-08 13:26:33 +05303193 tANI_U8* mac,
Anand N Sunkad9bfc2622015-07-30 15:18:54 +05303194#endif
Atul Mittal115287b2014-07-08 13:26:33 +05303195 tANI_S32 *state,
3196 tANI_S32 *reason)
3197{
3198
3199 hddTdlsPeer_t *curr_peer;
Atul Mittala75fced2014-10-06 13:59:07 +05303200 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Atul Mittal115287b2014-07-08 13:26:33 +05303201 curr_peer = wlan_hdd_tdls_find_peer(pAdapter, mac, TRUE);
3202 if (curr_peer == NULL)
3203 {
Atul Mittala75fced2014-10-06 13:59:07 +05303204 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Atul Mittal115287b2014-07-08 13:26:33 +05303205 FL("curr_peer is NULL"));
Atul Mittal115287b2014-07-08 13:26:33 +05303206
Atul Mittala75fced2014-10-06 13:59:07 +05303207 *state = WIFI_TDLS_DISABLED;
3208 *reason = eTDLS_LINK_UNSPECIFIED;
3209 }
3210 else
3211 {
3212 if (pHddCtx->cfg_ini->fTDLSExternalControl &&
3213 (FALSE == curr_peer->isForcedPeer))
3214 {
3215 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3216 FL("curr_peer is not Forced"));
3217 *state = WIFI_TDLS_DISABLED;
3218 *reason = eTDLS_LINK_UNSPECIFIED;
3219 }
3220 else
3221 {
3222 wlan_hdd_tdls_get_wifi_hal_state(curr_peer, state, reason);
3223 }
3224 }
Atul Mittal115287b2014-07-08 13:26:33 +05303225 return (0);
3226}
3227
Agarwal Ashishef54a182014-12-16 15:07:31 +05303228int hdd_set_tdls_scan_type(hdd_adapter_t *pAdapter,
3229 tANI_U8 *ptr)
3230{
3231 int tdls_scan_type;
Hema Aparna Medicharla26b98042015-01-21 15:02:01 +05303232 hdd_context_t *pHddCtx;
Agarwal Ashishef54a182014-12-16 15:07:31 +05303233 if (NULL == pAdapter)
3234 {
3235 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3236 "%s: pAdapter is NULL", __func__);
3237 return -EINVAL;
3238 }
Hema Aparna Medicharla26b98042015-01-21 15:02:01 +05303239 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Agarwal Ashishef54a182014-12-16 15:07:31 +05303240 tdls_scan_type = ptr[9] - '0';
3241
3242 if (tdls_scan_type <= 2)
3243 {
3244 pHddCtx->cfg_ini->fEnableTDLSScan = tdls_scan_type;
3245 return 0;
3246 }
3247 else
3248 {
3249 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3250 " Wrong value is given for tdls_scan_type "
3251 " Making fEnableTDLSScan as 0 ");
3252 pHddCtx->cfg_ini->fEnableTDLSScan = 0;
3253 return -EINVAL;
3254 }
3255}
Mahesh A Saptasagar170b5082015-02-16 18:50:54 +05303256int wlan_hdd_validate_tdls_context(hdd_context_t *pHddCtx,
3257 tdlsCtx_t *pHddTdlsCtx)
3258{
3259 VOS_STATUS status;
3260 int found = 0;
3261 hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL;
3262 hdd_adapter_t *pAdapter;
Agarwal Ashishef54a182014-12-16 15:07:31 +05303263
Mahesh A Saptasagar170b5082015-02-16 18:50:54 +05303264 if (NULL == pHddTdlsCtx)
3265 {
3266 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3267 FL("TDLS context is NULL"));
3268 return -EINVAL;
3269 }
3270 status = hdd_get_front_adapter(pHddCtx, &pAdapterNode);
3271 while (NULL != pAdapterNode && VOS_STATUS_SUCCESS == status)
3272 {
3273 pAdapter = pAdapterNode->pAdapter;
3274 if (NULL != pAdapter)
3275 {
3276 if (pHddTdlsCtx == pAdapter->sessionCtx.station.pHddTdlsCtx &&
3277 (NULL != pHddTdlsCtx->pAdapter) &&
3278 (WLAN_HDD_ADAPTER_MAGIC == pHddTdlsCtx->pAdapter->magic))
3279 {
3280 found = 1;
3281 break;
3282 }
3283 }
3284 status = hdd_get_next_adapter (pHddCtx, pAdapterNode, &pNext);
3285 pAdapterNode = pNext;
3286 }
3287 if (found == 1)
3288 {
3289 return 0;
3290 }
3291 else
3292 {
3293 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3294 FL("TDLS context doesnot belongs to valid adapter"));
3295 return -EINVAL;
3296 }
3297}
Ganesh Kondabattinif3ba0972015-08-07 15:58:04 +05303298
3299
3300void wlan_hdd_tdls_update_rx_pkt_cnt_n_rssi(hdd_adapter_t *pAdapter,
3301 u8 *mac, v_S7_t rssiAvg)
3302{
3303 hddTdlsPeer_t *curr_peer;
3304 hdd_context_t *pHddCtx = NULL;
3305 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3306 mutex_lock(&pHddCtx->tdls_lock);
3307 curr_peer = wlan_hdd_tdls_find_peer(pAdapter, mac, FALSE);
3308 if ((NULL != curr_peer) &&
3309 (eTDLS_LINK_CONNECTED == curr_peer->link_status))
3310 {
3311 curr_peer->rx_pkt++;
3312 curr_peer->rssi = rssiAvg;
3313 }
3314 mutex_unlock(&pHddCtx->tdls_lock);
3315 VOS_TRACE( VOS_MODULE_ID_HDD_DATA, VOS_TRACE_LEVEL_INFO,
3316 "mac : " MAC_ADDRESS_STR "rssi is %d",
3317 MAC_ADDR_ARRAY(mac), rssiAvg);
3318}
Atul Mittal115287b2014-07-08 13:26:33 +05303319
Masti, Narayanraddi575ccc72015-08-17 18:04:57 +05303320/**
3321 * wlan_hdd_tdls_reenable() - Re-Enable TDLS
3322 * @hddctx: pointer to hdd context
3323 *
3324 * Function re-enable's TDLS which might be disabled during concurrency
3325 *
3326 * Return: None
3327 */
3328void wlan_hdd_tdls_reenable(hdd_context_t *pHddCtx)
3329{
3330
3331 if ((TRUE != pHddCtx->cfg_ini->fEnableTDLSSupport) ||
3332 (TRUE != sme_IsFeatureSupportedByFW(TDLS))) {
3333 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3334 FL("tdls support not enabled"));
3335 return;
3336 }
3337
3338 /* if tdls is not enabled or BtCoex is on then don't revert tdls mode */
3339 if ((eTDLS_SUPPORT_NOT_ENABLED == pHddCtx->tdls_mode) ||
3340 (pHddCtx->is_tdls_btc_enabled == FALSE)) {
3341 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3342 FL("btc disable tdls so no need to enable: Mode=%d, BTC enabled=%d"),
3343 pHddCtx->tdls_mode, pHddCtx->is_tdls_btc_enabled);
3344 return;
3345 }
3346
3347 if (eTDLS_SUPPORT_ENABLED == pHddCtx->tdls_mode_last ||
3348 eTDLS_SUPPORT_EXPLICIT_TRIGGER_ONLY ==
3349 pHddCtx->tdls_mode_last) {
3350 /* Enable TDLS support Once P2P session ends since
3351 * upond detection of concurrency TDLS might be disabled
3352 */
3353 hddLog(LOG1, FL("TDLS mode set to %d"), pHddCtx->tdls_mode_last);
3354 wlan_hdd_tdls_set_mode(pHddCtx, pHddCtx->tdls_mode_last,
3355 FALSE);
3356 }
3357}
Ganesh Kondabattinicbfdc392015-09-11 19:12:59 +05303358
3359tdlsConnInfo_t *wlan_hdd_get_conn_info(hdd_context_t *pHddCtx,
3360 tANI_U8 idx)
3361{
3362 tANI_U8 staIdx;
3363
3364 /* check if there is available index for this new TDLS STA */
3365 for ( staIdx = 0; staIdx < HDD_MAX_NUM_TDLS_STA; staIdx++ )
3366 {
3367 if (idx == pHddCtx->tdlsConnInfo[staIdx].staId )
3368 {
3369 hddLog(LOG1, FL("tdls peer with staIdx %u exists"), idx );
3370 return (&pHddCtx->tdlsConnInfo[staIdx]);
3371 }
3372 }
3373 hddLog(LOGE, FL("tdls peer with staIdx %u not exists"), idx );
3374 return NULL;
3375}
Masti, Narayanraddi575ccc72015-08-17 18:04:57 +05303376/*EXT TDLS*/