Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1 | /* |
Rajeev Kumar Sirasanagandla | 5b21a9c | 2018-01-08 17:05:11 +0530 | [diff] [blame] | 2 | * Copyright (c) 2012-2018 The Linux Foundation. All rights reserved. |
Kiet Lam | 842dad0 | 2014-02-18 18:44:02 -0800 | [diff] [blame] | 3 | * |
| 4 | * Previously licensed under the ISC license by Qualcomm Atheros, Inc. |
| 5 | * |
| 6 | * |
| 7 | * Permission to use, copy, modify, and/or distribute this software for |
| 8 | * any purpose with or without fee is hereby granted, provided that the |
| 9 | * above copyright notice and this permission notice appear in all |
| 10 | * copies. |
| 11 | * |
| 12 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL |
| 13 | * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED |
| 14 | * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE |
| 15 | * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL |
| 16 | * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR |
| 17 | * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER |
| 18 | * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR |
| 19 | * PERFORMANCE OF THIS SOFTWARE. |
Gopichand Nakkala | 92f07d8 | 2013-01-08 21:16:34 -0800 | [diff] [blame] | 20 | */ |
Kiet Lam | 842dad0 | 2014-02-18 18:44:02 -0800 | [diff] [blame] | 21 | |
| 22 | /* |
| 23 | * This file was originally distributed by Qualcomm Atheros, Inc. |
| 24 | * under proprietary terms before Copyright ownership was assigned |
| 25 | * to the Linux Foundation. |
| 26 | */ |
| 27 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 28 | /**======================================================================== |
| 29 | |
| 30 | \file wlan_hdd_p2p.c |
| 31 | |
| 32 | \brief WLAN Host Device Driver implementation for P2P commands interface |
| 33 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 34 | |
| 35 | ========================================================================*/ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 36 | |
| 37 | #include <wlan_hdd_includes.h> |
| 38 | #include <wlan_hdd_hostapd.h> |
| 39 | #include <net/cfg80211.h> |
| 40 | #include "sme_Api.h" |
Leela Venkata Kiran Kumar Reddy Chirala | 8e69fbc | 2013-10-30 18:51:13 -0700 | [diff] [blame] | 41 | #include "sme_QosApi.h" |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 42 | #include "wlan_hdd_p2p.h" |
| 43 | #include "sapApi.h" |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 44 | #include "wlan_hdd_main.h" |
Daram Sudha | 1f7e0e9 | 2013-12-17 07:52:31 +0530 | [diff] [blame] | 45 | #include "vos_trace.h" |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 46 | #include <linux/netdevice.h> |
| 47 | #include <linux/skbuff.h> |
| 48 | #include <linux/etherdevice.h> |
| 49 | #include <net/ieee80211_radiotap.h> |
Hoonki Lee | 1090c6a | 2013-01-16 17:40:54 -0800 | [diff] [blame] | 50 | #ifdef FEATURE_WLAN_TDLS |
| 51 | #include "wlan_hdd_tdls.h" |
| 52 | #endif |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 53 | #include "wlan_hdd_trace.h" |
| 54 | #include "vos_types.h" |
| 55 | #include "vos_trace.h" |
Mahesh A Saptasagar | 65570ad | 2014-06-23 21:05:38 +0530 | [diff] [blame] | 56 | #include "vos_sched.h" |
| 57 | |
Madan Mohan Koyyalamudi | 4b63eee | 2012-11-06 18:47:56 -0800 | [diff] [blame] | 58 | //Ms to Micro Sec |
| 59 | #define MS_TO_MUS(x) ((x)*1000); |
Daram Sudha | 1f7e0e9 | 2013-12-17 07:52:31 +0530 | [diff] [blame] | 60 | tANI_U8* hdd_getActionString( tANI_U16 MsgType ) |
| 61 | { |
| 62 | switch (MsgType) |
| 63 | { |
| 64 | CASE_RETURN_STRING(SIR_MAC_ACTION_SPECTRUM_MGMT); |
| 65 | CASE_RETURN_STRING(SIR_MAC_ACTION_QOS_MGMT); |
| 66 | CASE_RETURN_STRING(SIR_MAC_ACTION_DLP); |
| 67 | CASE_RETURN_STRING(SIR_MAC_ACTION_BLKACK); |
| 68 | CASE_RETURN_STRING(SIR_MAC_ACTION_PUBLIC_USAGE); |
| 69 | CASE_RETURN_STRING(SIR_MAC_ACTION_RRM); |
| 70 | CASE_RETURN_STRING(SIR_MAC_ACTION_FAST_BSS_TRNST); |
| 71 | CASE_RETURN_STRING(SIR_MAC_ACTION_HT); |
| 72 | CASE_RETURN_STRING(SIR_MAC_ACTION_SA_QUERY); |
| 73 | CASE_RETURN_STRING(SIR_MAC_ACTION_PROT_DUAL_PUB); |
| 74 | CASE_RETURN_STRING(SIR_MAC_ACTION_WNM); |
| 75 | CASE_RETURN_STRING(SIR_MAC_ACTION_UNPROT_WNM); |
| 76 | CASE_RETURN_STRING(SIR_MAC_ACTION_TDLS); |
| 77 | CASE_RETURN_STRING(SIR_MAC_ACITON_MESH); |
Abhishek Singh | 09d4e4a | 2016-01-12 11:20:22 +0530 | [diff] [blame] | 78 | CASE_RETURN_STRING(SIR_MAC_ACTION_MHF); |
Daram Sudha | 1f7e0e9 | 2013-12-17 07:52:31 +0530 | [diff] [blame] | 79 | CASE_RETURN_STRING(SIR_MAC_SELF_PROTECTED); |
| 80 | CASE_RETURN_STRING(SIR_MAC_ACTION_WME); |
| 81 | CASE_RETURN_STRING(SIR_MAC_ACTION_VHT); |
| 82 | default: |
| 83 | return ("UNKNOWN"); |
| 84 | } |
| 85 | } |
| 86 | |
| 87 | |
Madan Mohan Koyyalamudi | 26bd714 | 2012-10-30 18:14:19 -0700 | [diff] [blame] | 88 | #ifdef WLAN_FEATURE_P2P_DEBUG |
| 89 | #define MAX_P2P_ACTION_FRAME_TYPE 9 |
| 90 | const char *p2p_action_frame_type[]={"GO Negotiation Request", |
| 91 | "GO Negotiation Response", |
| 92 | "GO Negotiation Confirmation", |
| 93 | "P2P Invitation Request", |
| 94 | "P2P Invitation Response", |
| 95 | "Device Discoverability Request", |
| 96 | "Device Discoverability Response", |
| 97 | "Provision Discovery Request", |
| 98 | "Provision Discovery Response"}; |
| 99 | |
| 100 | /* We no need to protect this variable since |
| 101 | * there is no chance of race to condition |
| 102 | * and also not make any complicating the code |
| 103 | * just for debugging log |
| 104 | */ |
| 105 | tP2PConnectionStatus globalP2PConnectionStatus = P2P_NOT_ACTIVE; |
| 106 | |
| 107 | #endif |
Hoonki Lee | 1090c6a | 2013-01-16 17:40:54 -0800 | [diff] [blame] | 108 | #define MAX_TDLS_ACTION_FRAME_TYPE 11 |
| 109 | const char *tdls_action_frame_type[] = {"TDLS Setup Request", |
| 110 | "TDLS Setup Response", |
| 111 | "TDLS Setup Confirm", |
| 112 | "TDLS Teardown", |
| 113 | "TDLS Peer Traffic Indication", |
| 114 | "TDLS Channel Switch Request", |
| 115 | "TDLS Channel Switch Response", |
| 116 | "TDLS Peer PSM Request", |
| 117 | "TDLS Peer PSM Response", |
| 118 | "TDLS Peer Traffic Response", |
| 119 | "TDLS Discovery Request" }; |
Madan Mohan Koyyalamudi | 26bd714 | 2012-10-30 18:14:19 -0700 | [diff] [blame] | 120 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 121 | extern struct net_device_ops net_ops_struct; |
| 122 | |
| 123 | static int hdd_wlan_add_rx_radiotap_hdr( struct sk_buff *skb, |
| 124 | int rtap_len, int flag ); |
| 125 | |
| 126 | static void hdd_wlan_tx_complete( hdd_adapter_t* pAdapter, |
| 127 | hdd_cfg80211_state_t* cfgState, |
| 128 | tANI_BOOLEAN actionSendSuccess ); |
| 129 | |
| 130 | static void hdd_sendMgmtFrameOverMonitorIface( hdd_adapter_t *pMonAdapter, |
Rashmi Ramanna | c774453 | 2013-10-06 16:49:08 +0530 | [diff] [blame] | 131 | tANI_U32 nFrameLength, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 132 | tANI_U8* pbFrames, |
| 133 | tANI_U8 frameType ); |
vamsi | 9bd92b7 | 2013-12-26 14:11:29 +0530 | [diff] [blame] | 134 | |
Rajeev Kumar Sirasanagandla | ac6345d | 2017-08-30 23:09:08 +0530 | [diff] [blame] | 135 | static v_BOOL_t wlan_hdd_is_type_p2p_action( const u8 *buf, uint32_t len ) |
Edhar, Mahesh Kumar | 9b223db | 2013-11-28 11:30:01 +0530 | [diff] [blame] | 136 | { |
vamsi | 9bd92b7 | 2013-12-26 14:11:29 +0530 | [diff] [blame] | 137 | const u8 *ouiPtr; |
| 138 | |
Rajeev Kumar Sirasanagandla | ac6345d | 2017-08-30 23:09:08 +0530 | [diff] [blame] | 139 | if (len < WLAN_HDD_PUBLIC_ACTION_FRAME_SUB_TYPE_OFFSET + 1) { |
| 140 | return VOS_FALSE; |
| 141 | } |
| 142 | |
vamsi | 9bd92b7 | 2013-12-26 14:11:29 +0530 | [diff] [blame] | 143 | if ( buf[WLAN_HDD_PUBLIC_ACTION_FRAME_CATEGORY_OFFSET] != |
| 144 | WLAN_HDD_PUBLIC_ACTION_FRAME ) { |
| 145 | return VOS_FALSE; |
| 146 | } |
| 147 | |
| 148 | if ( buf[WLAN_HDD_PUBLIC_ACTION_FRAME_ACTION_OFFSET] != |
| 149 | WLAN_HDD_VENDOR_SPECIFIC_ACTION ) { |
| 150 | return VOS_FALSE; |
| 151 | } |
| 152 | |
| 153 | ouiPtr = &buf[WLAN_HDD_PUBLIC_ACTION_FRAME_OUI_OFFSET]; |
| 154 | |
| 155 | if ( WPA_GET_BE24(ouiPtr) != WLAN_HDD_WFA_OUI ) { |
| 156 | return VOS_FALSE; |
| 157 | } |
| 158 | |
| 159 | if ( buf[WLAN_HDD_PUBLIC_ACTION_FRAME_OUI_TYPE_OFFSET] != |
| 160 | WLAN_HDD_WFA_P2P_OUI_TYPE ) { |
| 161 | return VOS_FALSE; |
| 162 | } |
| 163 | |
Edhar, Mahesh Kumar | 11cf197 | 2017-03-20 17:07:33 +0530 | [diff] [blame] | 164 | return VOS_TRUE; |
| 165 | } |
| 166 | |
Rajeev Kumar Sirasanagandla | ac6345d | 2017-08-30 23:09:08 +0530 | [diff] [blame] | 167 | static bool hdd_p2p_is_action_type_rsp( const u8 *buf, uint32_t len ) |
Edhar, Mahesh Kumar | 11cf197 | 2017-03-20 17:07:33 +0530 | [diff] [blame] | 168 | { |
| 169 | tActionFrmType actionFrmType; |
| 170 | |
Rajeev Kumar Sirasanagandla | ac6345d | 2017-08-30 23:09:08 +0530 | [diff] [blame] | 171 | if ( wlan_hdd_is_type_p2p_action(buf, len) ) |
Edhar, Mahesh Kumar | 11cf197 | 2017-03-20 17:07:33 +0530 | [diff] [blame] | 172 | { |
| 173 | actionFrmType = buf[WLAN_HDD_PUBLIC_ACTION_FRAME_SUB_TYPE_OFFSET]; |
| 174 | if ( actionFrmType != WLAN_HDD_INVITATION_REQ && |
| 175 | actionFrmType != WLAN_HDD_GO_NEG_REQ && |
| 176 | actionFrmType != WLAN_HDD_DEV_DIS_REQ && |
| 177 | actionFrmType != WLAN_HDD_PROV_DIS_REQ ) |
| 178 | return VOS_TRUE; |
| 179 | } |
| 180 | return VOS_FALSE; |
Edhar, Mahesh Kumar | 9b223db | 2013-11-28 11:30:01 +0530 | [diff] [blame] | 181 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 182 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 183 | eHalStatus wlan_hdd_remain_on_channel_callback( tHalHandle hHal, void* pCtx, |
| 184 | eHalStatus status ) |
| 185 | { |
| 186 | hdd_adapter_t *pAdapter = (hdd_adapter_t*) pCtx; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 187 | hdd_cfg80211_state_t *cfgState = WLAN_HDD_GET_CFG_STATE_PTR( pAdapter ); |
Deepthi Gowri | 8a76bdb | 2015-08-21 15:17:28 +0530 | [diff] [blame] | 188 | hdd_remain_on_chan_ctx_t *pRemainChanCtx = NULL; |
Mahesh A Saptasagar | 6062794 | 2014-10-13 13:55:14 +0530 | [diff] [blame] | 189 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
Deepthi Gowri | 8a76bdb | 2015-08-21 15:17:28 +0530 | [diff] [blame] | 190 | rem_on_channel_request_type_t req_type; |
| 191 | |
Mahesh A Saptasagar | 6062794 | 2014-10-13 13:55:14 +0530 | [diff] [blame] | 192 | if (pHddCtx == NULL) |
| 193 | { |
| 194 | hddLog(LOGE, "%s: Hdd Context is NULL", __func__); |
| 195 | return eHAL_STATUS_FAILURE; |
| 196 | } |
Mahesh A Saptasagar | 6062794 | 2014-10-13 13:55:14 +0530 | [diff] [blame] | 197 | |
| 198 | mutex_lock(&pHddCtx->roc_lock); |
Deepthi Gowri | 8a76bdb | 2015-08-21 15:17:28 +0530 | [diff] [blame] | 199 | |
| 200 | pRemainChanCtx = cfgState->remain_on_chan_ctx; |
| 201 | if (pRemainChanCtx == NULL) |
| 202 | { |
| 203 | hddLog( LOGW, |
| 204 | "%s: No Rem on channel pending for which Rsp is received", __func__); |
| 205 | mutex_unlock(&pHddCtx->roc_lock); |
| 206 | return eHAL_STATUS_SUCCESS; |
| 207 | } |
| 208 | |
Rashmi Ramanna | c774453 | 2013-10-06 16:49:08 +0530 | [diff] [blame] | 209 | hddLog( VOS_TRACE_LEVEL_INFO, |
| 210 | "Received ROC rsp (request type %d, channel %d, cookie %llu", |
| 211 | pRemainChanCtx->rem_on_chan_request, |
| 212 | pRemainChanCtx->chan.center_freq, |
| 213 | pRemainChanCtx->cookie); |
Deepthi Gowri | f41ac8f | 2016-05-12 16:36:00 +0530 | [diff] [blame] | 214 | if(!VOS_IS_STATUS_SUCCESS(vos_timer_stop( |
| 215 | &pRemainChanCtx->hdd_remain_on_chan_timer))) |
| 216 | { |
| 217 | hddLog( LOGE, FL("Failed to stop hdd_remain_on_chan_timer")); |
| 218 | } |
| 219 | if(!VOS_IS_STATUS_SUCCESS(vos_timer_destroy( |
| 220 | &pRemainChanCtx->hdd_remain_on_chan_timer))) |
| 221 | { |
| 222 | hddLog( LOGE, FL("Failed to destroy hdd_remain_on_chan_timer")); |
| 223 | } |
Kaushik, Sushant | 7005e37 | 2014-04-08 11:36:54 +0530 | [diff] [blame] | 224 | if ( REMAIN_ON_CHANNEL_REQUEST == pRemainChanCtx->rem_on_chan_request ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 225 | { |
| 226 | if( cfgState->buf ) |
| 227 | { |
Agrawal Ashish | b10d039 | 2015-08-06 16:18:20 +0530 | [diff] [blame] | 228 | hddLog( LOG1, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 229 | "%s: We need to receive yet an ack from one of tx packet", |
| 230 | __func__); |
| 231 | } |
Jeff Johnson | 3bbe4bf | 2013-01-18 17:05:29 -0800 | [diff] [blame] | 232 | cfg80211_remain_on_channel_expired( |
| 233 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0)) |
| 234 | pRemainChanCtx->dev->ieee80211_ptr, |
| 235 | #else |
| 236 | pRemainChanCtx->dev, |
| 237 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 238 | pRemainChanCtx->cookie, |
| 239 | &pRemainChanCtx->chan, |
Yue Ma | f49ba87 | 2013-08-19 12:04:25 -0700 | [diff] [blame] | 240 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,8,0)) |
| 241 | pRemainChanCtx->chan_type, |
| 242 | #endif |
| 243 | GFP_KERNEL); |
Ganesh Kondabattini | babfb49 | 2014-12-17 20:25:29 +0530 | [diff] [blame] | 244 | pAdapter->lastRocTs = vos_timer_get_system_time(); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 245 | } |
| 246 | |
Deepthi Gowri | 8a76bdb | 2015-08-21 15:17:28 +0530 | [diff] [blame] | 247 | req_type = pRemainChanCtx->rem_on_chan_request; |
| 248 | mutex_unlock(&pHddCtx->roc_lock); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 249 | |
| 250 | if ( ( WLAN_HDD_INFRA_STATION == pAdapter->device_mode ) || |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 251 | ( WLAN_HDD_P2P_CLIENT == pAdapter->device_mode ) || |
| 252 | ( WLAN_HDD_P2P_DEVICE == pAdapter->device_mode ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 253 | ) |
| 254 | { |
| 255 | tANI_U8 sessionId = pAdapter->sessionId; |
Deepthi Gowri | 8a76bdb | 2015-08-21 15:17:28 +0530 | [diff] [blame] | 256 | if( REMAIN_ON_CHANNEL_REQUEST == req_type ) |
Madan Mohan Koyyalamudi | 3588591 | 2012-11-30 15:05:42 -0800 | [diff] [blame] | 257 | { |
| 258 | sme_DeregisterMgmtFrame( |
| 259 | hHal, sessionId, |
| 260 | (SIR_MAC_MGMT_FRAME << 2) | ( SIR_MAC_MGMT_PROBE_REQ << 4), |
| 261 | NULL, 0 ); |
| 262 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 263 | } |
Abhishek Singh | 36b7c53 | 2015-03-13 15:50:54 +0530 | [diff] [blame] | 264 | else if (WLAN_HDD_P2P_GO == pAdapter->device_mode) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 265 | { |
| 266 | WLANSAP_DeRegisterMgmtFrame( |
| 267 | (WLAN_HDD_GET_CTX(pAdapter))->pvosContext, |
| 268 | (SIR_MAC_MGMT_FRAME << 2) | ( SIR_MAC_MGMT_PROBE_REQ << 4), |
| 269 | NULL, 0 ); |
| 270 | } |
Deepthi Gowri | 200d15a | 2015-08-10 16:02:49 +0530 | [diff] [blame] | 271 | mutex_lock(&pHddCtx->roc_lock); |
Deepthi Gowri | ddda7a4 | 2016-08-16 17:05:13 +0530 | [diff] [blame] | 272 | pRemainChanCtx = cfgState->remain_on_chan_ctx; |
Deepthi Gowri | 8a76bdb | 2015-08-21 15:17:28 +0530 | [diff] [blame] | 273 | if ( pRemainChanCtx ) |
| 274 | { |
Deepthi Gowri | 7566465 | 2016-09-08 17:44:35 +0530 | [diff] [blame] | 275 | /* Trigger kernel panic if ROC timer state is not set to unused state |
| 276 | * before freeing the ROC ctx. |
| 277 | */ |
| 278 | if (VOS_TIMER_STATE_UNUSED != vos_timer_getCurrentState( |
| 279 | &pRemainChanCtx->hdd_remain_on_chan_timer)) |
| 280 | VOS_BUG(0); |
| 281 | |
Deepthi Gowri | 8a76bdb | 2015-08-21 15:17:28 +0530 | [diff] [blame] | 282 | if (pRemainChanCtx->action_pkt_buff.frame_ptr != NULL |
| 283 | && pRemainChanCtx->action_pkt_buff.frame_length != 0) |
| 284 | { |
| 285 | vos_mem_free(pRemainChanCtx->action_pkt_buff.frame_ptr); |
| 286 | } |
Deepthi Gowri | ddda7a4 | 2016-08-16 17:05:13 +0530 | [diff] [blame] | 287 | hddLog( LOG1, FL( |
Jeff Johnson | c135a9a | 2017-09-19 08:37:24 -0700 | [diff] [blame] | 288 | "Freeing ROC ctx cfgState->remain_on_chan_ctx=%pK"), |
Deepthi Gowri | ddda7a4 | 2016-08-16 17:05:13 +0530 | [diff] [blame] | 289 | cfgState->remain_on_chan_ctx); |
| 290 | vos_mem_free( pRemainChanCtx ); |
| 291 | pRemainChanCtx = NULL; |
| 292 | cfgState->remain_on_chan_ctx = NULL; |
Deepthi Gowri | 8a76bdb | 2015-08-21 15:17:28 +0530 | [diff] [blame] | 293 | } |
Deepthi Gowri | 200d15a | 2015-08-10 16:02:49 +0530 | [diff] [blame] | 294 | mutex_unlock(&pHddCtx->roc_lock); |
Deepthi Gowri | 3e672f0 | 2015-01-30 17:04:08 +0530 | [diff] [blame] | 295 | if (eHAL_STATUS_SUCCESS != status) |
| 296 | complete(&pAdapter->rem_on_chan_ready_event); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 297 | complete(&pAdapter->cancel_rem_on_chan_var); |
Kaushik, Sushant | 7005e37 | 2014-04-08 11:36:54 +0530 | [diff] [blame] | 298 | pAdapter->is_roc_inprogress = FALSE; |
Sushant Kaushik | 83392fa | 2015-05-05 17:44:40 +0530 | [diff] [blame] | 299 | hdd_allow_suspend(WIFI_POWER_EVENT_WAKELOCK_ROC); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 300 | return eHAL_STATUS_SUCCESS; |
| 301 | } |
| 302 | |
Sushant Kaushik | 5ad9b7b | 2014-05-21 21:09:43 +0530 | [diff] [blame] | 303 | VOS_STATUS wlan_hdd_cancel_existing_remain_on_channel(hdd_adapter_t *pAdapter) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 304 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 305 | hdd_cfg80211_state_t *cfgState = WLAN_HDD_GET_CFG_STATE_PTR( pAdapter ); |
Deepthi Gowri | 7374e28 | 2015-08-26 19:22:58 +0530 | [diff] [blame] | 306 | hdd_remain_on_chan_ctx_t *pRemainChanCtx = NULL; |
Mahesh A Saptasagar | 6062794 | 2014-10-13 13:55:14 +0530 | [diff] [blame] | 307 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 308 | int status = 0; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 309 | |
Mahesh A Saptasagar | 6062794 | 2014-10-13 13:55:14 +0530 | [diff] [blame] | 310 | if (NULL == pHddCtx) |
| 311 | { |
| 312 | hddLog(LOGE, "%s: HddCtx is NULL", __func__); |
| 313 | return VOS_STATUS_E_FAILURE; |
| 314 | } |
| 315 | |
| 316 | mutex_lock(&pHddCtx->roc_lock); |
Deepthi Gowri | 7374e28 | 2015-08-26 19:22:58 +0530 | [diff] [blame] | 317 | pRemainChanCtx = cfgState->remain_on_chan_ctx; |
| 318 | if(pRemainChanCtx != NULL) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 319 | { |
Ganesh Kondabattini | babfb49 | 2014-12-17 20:25:29 +0530 | [diff] [blame] | 320 | if(VOS_TIMER_STATE_RUNNING == vos_timer_getCurrentState( |
Deepthi Gowri | 7374e28 | 2015-08-26 19:22:58 +0530 | [diff] [blame] | 321 | &pRemainChanCtx->hdd_remain_on_chan_timer)) |
Ganesh Kondabattini | babfb49 | 2014-12-17 20:25:29 +0530 | [diff] [blame] | 322 | { |
| 323 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 324 | "Cancel Existing ROC (cookie=%llu)", |
Deepthi Gowri | 7374e28 | 2015-08-26 19:22:58 +0530 | [diff] [blame] | 325 | pRemainChanCtx->cookie); |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 326 | |
Deepthi Gowri | f41ac8f | 2016-05-12 16:36:00 +0530 | [diff] [blame] | 327 | if(!VOS_IS_STATUS_SUCCESS(vos_timer_stop( |
| 328 | &pRemainChanCtx->hdd_remain_on_chan_timer))) |
| 329 | { |
| 330 | hddLog( LOGE, FL("Failed to stop hdd_remain_on_chan_timer")); |
| 331 | } |
Ganesh Kondabattini | babfb49 | 2014-12-17 20:25:29 +0530 | [diff] [blame] | 332 | } |
Daram Sudha | 1f7e0e9 | 2013-12-17 07:52:31 +0530 | [diff] [blame] | 333 | /* Wait till remain on channel ready indication before issuing cancel |
| 334 | * remain on channel request, otherwise if remain on channel not |
| 335 | * received and if the driver issues cancel remain on channel then lim |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 336 | * will be in unknown state. |
| 337 | */ |
Mahesh A Saptasagar | 6062794 | 2014-10-13 13:55:14 +0530 | [diff] [blame] | 338 | if (pRemainChanCtx->hdd_remain_on_chan_cancel_in_progress != TRUE) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 339 | { |
Deepthi Gowri | ef88a5f | 2015-04-06 14:41:46 +0530 | [diff] [blame] | 340 | mutex_unlock(&pHddCtx->roc_lock); |
Mahesh A Saptasagar | 6062794 | 2014-10-13 13:55:14 +0530 | [diff] [blame] | 341 | status = wait_for_completion_interruptible_timeout( |
| 342 | &pAdapter->rem_on_chan_ready_event, |
| 343 | msecs_to_jiffies(WAIT_REM_CHAN_READY)); |
| 344 | if (0 >= status) |
| 345 | { |
Deepthi Gowri | 7374e28 | 2015-08-26 19:22:58 +0530 | [diff] [blame] | 346 | mutex_lock(&pHddCtx->roc_lock); |
| 347 | pRemainChanCtx = cfgState->remain_on_chan_ctx; |
| 348 | if (pRemainChanCtx) |
| 349 | pRemainChanCtx->is_pending_roc_cancelled = TRUE; |
| 350 | mutex_unlock(&pHddCtx->roc_lock); |
Mahesh A Saptasagar | 6062794 | 2014-10-13 13:55:14 +0530 | [diff] [blame] | 351 | hddLog( LOGE, |
Deepthi Gowri | 7374e28 | 2015-08-26 19:22:58 +0530 | [diff] [blame] | 352 | "%s: timeout waiting for remain on channel" |
| 353 | " ready indication %d", |
Mahesh A Saptasagar | 6062794 | 2014-10-13 13:55:14 +0530 | [diff] [blame] | 354 | __func__, status); |
Abhishek Singh | 837adf2 | 2015-10-01 17:37:37 +0530 | [diff] [blame] | 355 | vos_fatal_event_logs_req(WLAN_LOG_TYPE_FATAL, |
| 356 | WLAN_LOG_INDICATOR_HOST_DRIVER, |
| 357 | WLAN_LOG_REASON_HDD_TIME_OUT, |
| 358 | FALSE, TRUE); |
Mahesh A Saptasagar | 6062794 | 2014-10-13 13:55:14 +0530 | [diff] [blame] | 359 | return VOS_STATUS_E_FAILURE; |
| 360 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 361 | |
Deepthi Gowri | ef88a5f | 2015-04-06 14:41:46 +0530 | [diff] [blame] | 362 | mutex_lock(&pHddCtx->roc_lock); |
Deepthi Gowri | 7374e28 | 2015-08-26 19:22:58 +0530 | [diff] [blame] | 363 | pRemainChanCtx = cfgState->remain_on_chan_ctx; |
| 364 | if (NULL == pRemainChanCtx) |
| 365 | { |
| 366 | mutex_unlock(&pHddCtx->roc_lock); |
| 367 | hddLog( LOGE, |
| 368 | "%s-%d: pRemainChanCtx is NULL", |
| 369 | __func__, __LINE__); |
| 370 | return VOS_STATUS_E_FAILURE; |
| 371 | } |
Abhishek Singh | f81dfd0 | 2015-08-10 14:15:08 +0530 | [diff] [blame] | 372 | /* Check again if cancel remain on channel is started. |
| 373 | * If its started wait for its completiona and return. |
| 374 | */ |
| 375 | if (TRUE == pRemainChanCtx->hdd_remain_on_chan_cancel_in_progress) |
| 376 | { |
| 377 | mutex_unlock(&pHddCtx->roc_lock); |
| 378 | hddLog( LOG1, |
| 379 | "ROC timer cancellation in progress," |
| 380 | " wait for completion"); |
| 381 | status = wait_for_completion_interruptible_timeout( |
| 382 | &pAdapter->cancel_rem_on_chan_var, |
| 383 | msecs_to_jiffies(WAIT_CANCEL_REM_CHAN)); |
| 384 | if (0 >= status) |
| 385 | { |
| 386 | hddLog( LOGE, |
| 387 | "%s:wait on cancel_rem_on_chan_var failed %d", |
| 388 | __func__, status); |
| 389 | return VOS_STATUS_E_FAILURE; |
| 390 | } |
| 391 | return VOS_STATUS_SUCCESS; |
| 392 | } |
| 393 | else |
| 394 | pRemainChanCtx->hdd_remain_on_chan_cancel_in_progress = TRUE; |
Abhishek Singh | f81dfd0 | 2015-08-10 14:15:08 +0530 | [diff] [blame] | 395 | INIT_COMPLETION(pAdapter->cancel_rem_on_chan_var); |
Abhishek Singh | 4892e96 | 2015-12-30 11:18:58 +0530 | [diff] [blame] | 396 | mutex_unlock(&pHddCtx->roc_lock); |
Abhishek Singh | f81dfd0 | 2015-08-10 14:15:08 +0530 | [diff] [blame] | 397 | |
| 398 | /* Issue abort remain on chan request to sme. |
| 399 | * The remain on channel callback will make sure the remain_on_chan |
| 400 | * expired event is sent. |
| 401 | */ |
| 402 | if ( ( WLAN_HDD_INFRA_STATION == pAdapter->device_mode ) || |
Abhishek Singh | 36b7c53 | 2015-03-13 15:50:54 +0530 | [diff] [blame] | 403 | ( WLAN_HDD_P2P_CLIENT == pAdapter->device_mode ) || |
| 404 | ( WLAN_HDD_P2P_DEVICE == pAdapter->device_mode )) |
Abhishek Singh | f81dfd0 | 2015-08-10 14:15:08 +0530 | [diff] [blame] | 405 | { |
| 406 | if (eHAL_STATUS_SUCCESS != |
| 407 | sme_CancelRemainOnChannel( WLAN_HDD_GET_HAL_CTX( pAdapter ), |
Deepthi Gowri | 7049825 | 2015-01-20 15:56:45 +0530 | [diff] [blame] | 408 | pAdapter->sessionId )) |
Abhishek Singh | f81dfd0 | 2015-08-10 14:15:08 +0530 | [diff] [blame] | 409 | { |
| 410 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 411 | FL("Failed to Cancel Remain on Channel")); |
| 412 | } |
| 413 | } |
| 414 | else if (WLAN_HDD_P2P_GO == pAdapter->device_mode) |
| 415 | { |
| 416 | WLANSAP_CancelRemainOnChannel( |
| 417 | (WLAN_HDD_GET_CTX(pAdapter))->pvosContext); |
| 418 | } |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 419 | |
Abhishek Singh | f81dfd0 | 2015-08-10 14:15:08 +0530 | [diff] [blame] | 420 | status = wait_for_completion_interruptible_timeout( |
| 421 | &pAdapter->cancel_rem_on_chan_var, |
| 422 | msecs_to_jiffies(WAIT_CANCEL_REM_CHAN)); |
Abhishek Singh | 9afcc84 | 2016-03-24 10:34:12 +0530 | [diff] [blame] | 423 | hdd_allow_suspend(WIFI_POWER_EVENT_WAKELOCK_ROC); |
Abhishek Singh | f81dfd0 | 2015-08-10 14:15:08 +0530 | [diff] [blame] | 424 | if (0 >= status) |
| 425 | { |
Abhishek Singh | 9afcc84 | 2016-03-24 10:34:12 +0530 | [diff] [blame] | 426 | hddLog(LOGE, |
| 427 | FL("Timeout waiting for cancel remain on channel ready indication %d"), |
| 428 | status); |
| 429 | return VOS_STATUS_E_FAILURE; |
Abhishek Singh | f81dfd0 | 2015-08-10 14:15:08 +0530 | [diff] [blame] | 430 | } |
Mahesh A Saptasagar | 6062794 | 2014-10-13 13:55:14 +0530 | [diff] [blame] | 431 | } |
| 432 | else |
| 433 | { |
| 434 | hddLog( LOG1, |
| 435 | "ROC timer cancellation in progress," |
| 436 | " wait for completion"); |
| 437 | mutex_unlock(&pHddCtx->roc_lock); |
| 438 | status = wait_for_completion_interruptible_timeout( |
| 439 | &pAdapter->cancel_rem_on_chan_var, |
| 440 | msecs_to_jiffies(WAIT_CANCEL_REM_CHAN)); |
| 441 | if (0 >= status) |
| 442 | { |
| 443 | hddLog( LOGE, |
| 444 | "%s:wait on cancel_rem_on_chan_var failed %d", |
| 445 | __func__, status); |
| 446 | return VOS_STATUS_E_FAILURE; |
| 447 | } |
| 448 | return VOS_STATUS_SUCCESS; |
| 449 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 450 | } |
Mahesh A Saptasagar | 6062794 | 2014-10-13 13:55:14 +0530 | [diff] [blame] | 451 | else |
| 452 | { |
| 453 | hddLog(LOG1, |
| 454 | "%s: remain_on_chan_ctx is NULL", __func__); |
| 455 | mutex_unlock(&pHddCtx->roc_lock); |
| 456 | } |
| 457 | return VOS_STATUS_SUCCESS; |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 458 | } |
| 459 | |
| 460 | int wlan_hdd_check_remain_on_channel(hdd_adapter_t *pAdapter) |
| 461 | { |
| 462 | int status = 0; |
| 463 | hdd_cfg80211_state_t *cfgState = WLAN_HDD_GET_CFG_STATE_PTR( pAdapter ); |
| 464 | |
| 465 | if(WLAN_HDD_P2P_GO != pAdapter->device_mode) |
| 466 | { |
| 467 | //Cancel Existing Remain On Channel |
| 468 | //If no action frame is pending |
| 469 | if( cfgState->remain_on_chan_ctx != NULL) |
| 470 | { |
| 471 | //Check whether Action Frame is pending or not |
| 472 | if( cfgState->buf == NULL) |
| 473 | { |
| 474 | wlan_hdd_cancel_existing_remain_on_channel(pAdapter); |
| 475 | } |
| 476 | else |
| 477 | { |
Rashmi Ramanna | c774453 | 2013-10-06 16:49:08 +0530 | [diff] [blame] | 478 | hddLog(VOS_TRACE_LEVEL_DEBUG, |
| 479 | "Cannot Cancel Existing Remain on Channel"); |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 480 | status = -EBUSY; |
| 481 | } |
| 482 | } |
| 483 | } |
| 484 | return status; |
| 485 | } |
Kaushik, Sushant | 7005e37 | 2014-04-08 11:36:54 +0530 | [diff] [blame] | 486 | void wlan_hdd_remain_on_chan_timeout(void *data) |
| 487 | { |
| 488 | hdd_adapter_t *pAdapter = (hdd_adapter_t *)data; |
Deepthi Gowri | 8a76bdb | 2015-08-21 15:17:28 +0530 | [diff] [blame] | 489 | hdd_remain_on_chan_ctx_t *pRemainChanCtx = NULL; |
Kaushik, Sushant | 7005e37 | 2014-04-08 11:36:54 +0530 | [diff] [blame] | 490 | hdd_cfg80211_state_t *cfgState; |
Abhishek Singh | bd3041e | 2015-07-30 14:36:25 +0530 | [diff] [blame] | 491 | hdd_context_t *pHddCtx; |
Hanumantha Reddy Pothula | da0fe36 | 2015-02-27 18:37:03 +0530 | [diff] [blame] | 492 | |
| 493 | if ((NULL == pAdapter) || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic)) |
Kaushik, Sushant | 7005e37 | 2014-04-08 11:36:54 +0530 | [diff] [blame] | 494 | { |
Jeff Johnson | c135a9a | 2017-09-19 08:37:24 -0700 | [diff] [blame] | 495 | hddLog( LOGE, FL("pAdapter is invalid %pK !!!"), pAdapter); |
Kaushik, Sushant | 7005e37 | 2014-04-08 11:36:54 +0530 | [diff] [blame] | 496 | return; |
| 497 | } |
Abhishek Singh | bd3041e | 2015-07-30 14:36:25 +0530 | [diff] [blame] | 498 | pHddCtx = WLAN_HDD_GET_CTX( pAdapter ); |
Kaushik, Sushant | 7005e37 | 2014-04-08 11:36:54 +0530 | [diff] [blame] | 499 | cfgState = WLAN_HDD_GET_CFG_STATE_PTR( pAdapter ); |
Deepthi Gowri | 8a76bdb | 2015-08-21 15:17:28 +0530 | [diff] [blame] | 500 | mutex_lock(&pHddCtx->roc_lock); |
Kaushik, Sushant | 7005e37 | 2014-04-08 11:36:54 +0530 | [diff] [blame] | 501 | pRemainChanCtx = cfgState->remain_on_chan_ctx; |
Deepthi Gowri | 8a76bdb | 2015-08-21 15:17:28 +0530 | [diff] [blame] | 502 | |
Kaushik, Sushant | 7005e37 | 2014-04-08 11:36:54 +0530 | [diff] [blame] | 503 | if (NULL == pRemainChanCtx) |
| 504 | { |
| 505 | hddLog( LOGE, FL("No Remain on channel is pending")); |
Deepthi Gowri | 8a76bdb | 2015-08-21 15:17:28 +0530 | [diff] [blame] | 506 | mutex_unlock(&pHddCtx->roc_lock); |
Kaushik, Sushant | 7005e37 | 2014-04-08 11:36:54 +0530 | [diff] [blame] | 507 | return; |
| 508 | } |
Deepthi Gowri | 8a76bdb | 2015-08-21 15:17:28 +0530 | [diff] [blame] | 509 | |
Kaushik, Sushant | 7005e37 | 2014-04-08 11:36:54 +0530 | [diff] [blame] | 510 | if ( TRUE == pRemainChanCtx->hdd_remain_on_chan_cancel_in_progress ) |
| 511 | { |
Abhishek Singh | bd3041e | 2015-07-30 14:36:25 +0530 | [diff] [blame] | 512 | mutex_unlock(&pHddCtx->roc_lock); |
Kaushik, Sushant | 7005e37 | 2014-04-08 11:36:54 +0530 | [diff] [blame] | 513 | hddLog( LOGE, FL("Cancellation already in progress")); |
| 514 | return; |
| 515 | } |
| 516 | |
| 517 | pRemainChanCtx->hdd_remain_on_chan_cancel_in_progress = TRUE; |
| 518 | INIT_COMPLETION(pAdapter->cancel_rem_on_chan_var); |
Abhishek Singh | 4892e96 | 2015-12-30 11:18:58 +0530 | [diff] [blame] | 519 | mutex_unlock(&pHddCtx->roc_lock); |
Kaushik, Sushant | 7005e37 | 2014-04-08 11:36:54 +0530 | [diff] [blame] | 520 | hddLog( LOG1,"%s: Cancel Remain on Channel on timeout", __func__); |
Abhishek Singh | 36b7c53 | 2015-03-13 15:50:54 +0530 | [diff] [blame] | 521 | if ( ( WLAN_HDD_INFRA_STATION == pAdapter->device_mode ) || |
| 522 | ( WLAN_HDD_P2P_CLIENT == pAdapter->device_mode ) || |
Kaushik, Sushant | 7005e37 | 2014-04-08 11:36:54 +0530 | [diff] [blame] | 523 | ( WLAN_HDD_P2P_DEVICE == pAdapter->device_mode ) |
| 524 | ) |
| 525 | { |
Deepthi Gowri | 7049825 | 2015-01-20 15:56:45 +0530 | [diff] [blame] | 526 | if (eHAL_STATUS_SUCCESS != |
| 527 | sme_CancelRemainOnChannel( WLAN_HDD_GET_HAL_CTX( pAdapter), |
| 528 | pAdapter->sessionId )) |
| 529 | { |
| 530 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 531 | FL("Failed to Cancel Remain on Channel")); |
| 532 | } |
Kaushik, Sushant | 7005e37 | 2014-04-08 11:36:54 +0530 | [diff] [blame] | 533 | } |
Abhishek Singh | 36b7c53 | 2015-03-13 15:50:54 +0530 | [diff] [blame] | 534 | else if (WLAN_HDD_P2P_GO == pAdapter->device_mode) |
Kaushik, Sushant | 7005e37 | 2014-04-08 11:36:54 +0530 | [diff] [blame] | 535 | { |
Deepthi Gowri | 7049825 | 2015-01-20 15:56:45 +0530 | [diff] [blame] | 536 | WLANSAP_CancelRemainOnChannel( |
| 537 | (WLAN_HDD_GET_CTX(pAdapter))->pvosContext); |
Kaushik, Sushant | 7005e37 | 2014-04-08 11:36:54 +0530 | [diff] [blame] | 538 | } |
Masti, Narayanraddi | 44b0db0 | 2015-12-22 11:54:35 +0530 | [diff] [blame] | 539 | |
| 540 | wlan_hdd_start_stop_tdls_source_timer(pHddCtx, eTDLS_SUPPORT_ENABLED); |
| 541 | |
Sushant Kaushik | 83392fa | 2015-05-05 17:44:40 +0530 | [diff] [blame] | 542 | hdd_allow_suspend(WIFI_POWER_EVENT_WAKELOCK_ROC); |
Kaushik, Sushant | 7005e37 | 2014-04-08 11:36:54 +0530 | [diff] [blame] | 543 | } |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 544 | |
Ganesh Kondabattini | babfb49 | 2014-12-17 20:25:29 +0530 | [diff] [blame] | 545 | static int wlan_hdd_p2p_start_remain_on_channel( |
| 546 | hdd_adapter_t *pAdapter) |
| 547 | { |
| 548 | VOS_STATUS status = VOS_STATUS_SUCCESS; |
| 549 | hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL; |
| 550 | hdd_adapter_t *pAdapter_temp; |
| 551 | v_BOOL_t isGoPresent = VOS_FALSE; |
Mahesh A Saptasagar | e5440c7 | 2015-01-28 21:21:07 +0530 | [diff] [blame] | 552 | hdd_context_t *pHddCtx; |
| 553 | hdd_cfg80211_state_t *cfgState; |
Deepthi Gowri | 6ccb1d4 | 2015-08-21 19:43:53 +0530 | [diff] [blame] | 554 | hdd_remain_on_chan_ctx_t *pRemainChanCtx = NULL; |
Mahesh A Saptasagar | e5440c7 | 2015-01-28 21:21:07 +0530 | [diff] [blame] | 555 | rem_on_channel_request_type_t request_type; |
Deepthi Gowri | 6ccb1d4 | 2015-08-21 19:43:53 +0530 | [diff] [blame] | 556 | unsigned int duration; |
| 557 | v_U16_t hw_value; |
| 558 | |
Mahesh A Saptasagar | e5440c7 | 2015-01-28 21:21:07 +0530 | [diff] [blame] | 559 | int ret = 0; |
Ganesh Kondabattini | babfb49 | 2014-12-17 20:25:29 +0530 | [diff] [blame] | 560 | |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 561 | ENTER(); |
Mahesh A Saptasagar | e5440c7 | 2015-01-28 21:21:07 +0530 | [diff] [blame] | 562 | if (NULL == pAdapter) |
| 563 | { |
| 564 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 565 | "%s: Adapter is NULL",__func__); |
| 566 | return -EINVAL; |
| 567 | } |
| 568 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 569 | ret = wlan_hdd_validate_context(pHddCtx); |
| 570 | if (0 != ret) |
| 571 | { |
Mahesh A Saptasagar | e5440c7 | 2015-01-28 21:21:07 +0530 | [diff] [blame] | 572 | return ret; |
| 573 | } |
| 574 | cfgState = WLAN_HDD_GET_CFG_STATE_PTR( pAdapter ); |
| 575 | if (NULL == cfgState) |
| 576 | { |
| 577 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 578 | "%s: cfgState is not valid ",__func__); |
| 579 | return -EINVAL; |
| 580 | } |
Deepthi Gowri | 6ccb1d4 | 2015-08-21 19:43:53 +0530 | [diff] [blame] | 581 | mutex_lock(&pHddCtx->roc_lock); |
Mahesh A Saptasagar | e5440c7 | 2015-01-28 21:21:07 +0530 | [diff] [blame] | 582 | pRemainChanCtx = cfgState->remain_on_chan_ctx; |
Deepthi Gowri | 6ccb1d4 | 2015-08-21 19:43:53 +0530 | [diff] [blame] | 583 | if ( pRemainChanCtx == NULL) |
| 584 | { |
| 585 | mutex_unlock(&pHddCtx->roc_lock); |
| 586 | hddLog( LOGE, |
| 587 | "%s-%d: pRemainChanCtx is NULL", |
| 588 | __func__, __LINE__); |
| 589 | return ret; |
| 590 | } |
Mahesh A Saptasagar | e5440c7 | 2015-01-28 21:21:07 +0530 | [diff] [blame] | 591 | request_type = pRemainChanCtx->rem_on_chan_request; |
Ganesh Kondabattini | babfb49 | 2014-12-17 20:25:29 +0530 | [diff] [blame] | 592 | /* Initialize Remain on chan timer */ |
| 593 | status = vos_timer_init(&pRemainChanCtx->hdd_remain_on_chan_timer, |
| 594 | VOS_TIMER_TYPE_SW, |
| 595 | wlan_hdd_remain_on_chan_timeout, |
| 596 | pAdapter); |
| 597 | if (status != VOS_STATUS_SUCCESS) |
| 598 | { |
| 599 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Ganesh Kondabattini | 02795ae | 2015-02-02 17:45:19 +0530 | [diff] [blame] | 600 | FL("Not able to initalize remain_on_chan timer")); |
Deepthi Gowri | f41ac8f | 2016-05-12 16:36:00 +0530 | [diff] [blame] | 601 | hddLog( LOG1, FL( |
Jeff Johnson | c135a9a | 2017-09-19 08:37:24 -0700 | [diff] [blame] | 602 | "Freeing ROC ctx cfgState->remain_on_chan_ctx=%pK"), |
Deepthi Gowri | f41ac8f | 2016-05-12 16:36:00 +0530 | [diff] [blame] | 603 | cfgState->remain_on_chan_ctx); |
Ganesh Kondabattini | 02795ae | 2015-02-02 17:45:19 +0530 | [diff] [blame] | 604 | cfgState->remain_on_chan_ctx = NULL; |
| 605 | vos_mem_free(pRemainChanCtx); |
Deepthi Gowri | 6ccb1d4 | 2015-08-21 19:43:53 +0530 | [diff] [blame] | 606 | mutex_unlock(&pHddCtx->roc_lock); |
Ganesh Kondabattini | 02795ae | 2015-02-02 17:45:19 +0530 | [diff] [blame] | 607 | return -EINVAL; |
Ganesh Kondabattini | babfb49 | 2014-12-17 20:25:29 +0530 | [diff] [blame] | 608 | } |
Ganesh Kondabattini | 02795ae | 2015-02-02 17:45:19 +0530 | [diff] [blame] | 609 | |
Deepthi Gowri | 6ccb1d4 | 2015-08-21 19:43:53 +0530 | [diff] [blame] | 610 | duration = pRemainChanCtx->duration; |
| 611 | hw_value = pRemainChanCtx->chan.hw_value; |
| 612 | mutex_unlock(&pHddCtx->roc_lock); |
| 613 | |
Ganesh Kondabattini | babfb49 | 2014-12-17 20:25:29 +0530 | [diff] [blame] | 614 | status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode ); |
| 615 | while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status ) |
| 616 | { |
| 617 | pAdapter_temp = pAdapterNode->pAdapter; |
| 618 | if (WLAN_HDD_P2P_GO == pAdapter_temp->device_mode) |
| 619 | { |
| 620 | isGoPresent = VOS_TRUE; |
| 621 | } |
| 622 | status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 623 | pAdapterNode = pNext; |
| 624 | } |
Sushant Kaushik | 83392fa | 2015-05-05 17:44:40 +0530 | [diff] [blame] | 625 | hdd_prevent_suspend(WIFI_POWER_EVENT_WAKELOCK_ROC); |
Ganesh Kondabattini | babfb49 | 2014-12-17 20:25:29 +0530 | [diff] [blame] | 626 | //call sme API to start remain on channel. |
| 627 | if ( ( WLAN_HDD_INFRA_STATION == pAdapter->device_mode ) || |
| 628 | ( WLAN_HDD_P2P_CLIENT == pAdapter->device_mode ) || |
| 629 | ( WLAN_HDD_P2P_DEVICE == pAdapter->device_mode ) |
| 630 | ) |
| 631 | { |
| 632 | tANI_U8 sessionId = pAdapter->sessionId; |
| 633 | //call sme API to start remain on channel. |
| 634 | if (eHAL_STATUS_SUCCESS != sme_RemainOnChannel( |
| 635 | WLAN_HDD_GET_HAL_CTX(pAdapter), sessionId, |
Deepthi Gowri | 6ccb1d4 | 2015-08-21 19:43:53 +0530 | [diff] [blame] | 636 | hw_value, duration, |
Ganesh Kondabattini | babfb49 | 2014-12-17 20:25:29 +0530 | [diff] [blame] | 637 | wlan_hdd_remain_on_channel_callback, pAdapter, |
| 638 | (tANI_U8)(request_type == REMAIN_ON_CHANNEL_REQUEST)? TRUE:FALSE)) |
| 639 | { |
| 640 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 641 | FL(" RemainOnChannel returned fail")); |
Deepthi Gowri | 6ccb1d4 | 2015-08-21 19:43:53 +0530 | [diff] [blame] | 642 | |
| 643 | mutex_lock(&pHddCtx->roc_lock); |
Deepthi Gowri | f41ac8f | 2016-05-12 16:36:00 +0530 | [diff] [blame] | 644 | pRemainChanCtx = cfgState->remain_on_chan_ctx; |
| 645 | hddLog( LOG1, FL( |
Jeff Johnson | c135a9a | 2017-09-19 08:37:24 -0700 | [diff] [blame] | 646 | "Freeing ROC ctx cfgState->remain_on_chan_ctx=%pK"), |
Deepthi Gowri | f41ac8f | 2016-05-12 16:36:00 +0530 | [diff] [blame] | 647 | cfgState->remain_on_chan_ctx); |
| 648 | if (pRemainChanCtx) |
| 649 | { |
| 650 | if(!VOS_IS_STATUS_SUCCESS(vos_timer_destroy |
| 651 | (&pRemainChanCtx->hdd_remain_on_chan_timer))) |
| 652 | { |
| 653 | hddLog( LOGE, FL( |
| 654 | "Failed to destroy hdd_remain_on_chan_timer")); |
| 655 | } |
| 656 | vos_mem_free(pRemainChanCtx); |
| 657 | cfgState->remain_on_chan_ctx = NULL; |
| 658 | } |
Deepthi Gowri | 6ccb1d4 | 2015-08-21 19:43:53 +0530 | [diff] [blame] | 659 | mutex_unlock(&pHddCtx->roc_lock); |
Sushant Kaushik | 83392fa | 2015-05-05 17:44:40 +0530 | [diff] [blame] | 660 | hdd_allow_suspend(WIFI_POWER_EVENT_WAKELOCK_ROC); |
Ganesh Kondabattini | babfb49 | 2014-12-17 20:25:29 +0530 | [diff] [blame] | 661 | return -EINVAL; |
| 662 | } |
| 663 | |
| 664 | if( REMAIN_ON_CHANNEL_REQUEST == request_type) |
| 665 | { |
| 666 | if( eHAL_STATUS_SUCCESS != sme_RegisterMgmtFrame( |
| 667 | WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 668 | sessionId, (SIR_MAC_MGMT_FRAME << 2) | |
| 669 | (SIR_MAC_MGMT_PROBE_REQ << 4), NULL, 0 )) |
| 670 | { |
| 671 | hddLog(VOS_TRACE_LEVEL_ERROR, "sme_RegisterMgmtFrame returned fail"); |
| 672 | } |
| 673 | } |
| 674 | |
| 675 | } |
Abhishek Singh | 36b7c53 | 2015-03-13 15:50:54 +0530 | [diff] [blame] | 676 | else if (WLAN_HDD_P2P_GO == pAdapter->device_mode) |
Ganesh Kondabattini | babfb49 | 2014-12-17 20:25:29 +0530 | [diff] [blame] | 677 | { |
| 678 | //call sme API to start remain on channel. |
| 679 | if (VOS_STATUS_SUCCESS != WLANSAP_RemainOnChannel( |
| 680 | (WLAN_HDD_GET_CTX(pAdapter))->pvosContext, |
Deepthi Gowri | 6ccb1d4 | 2015-08-21 19:43:53 +0530 | [diff] [blame] | 681 | hw_value, duration, |
Ganesh Kondabattini | babfb49 | 2014-12-17 20:25:29 +0530 | [diff] [blame] | 682 | wlan_hdd_remain_on_channel_callback, pAdapter )) |
| 683 | |
| 684 | { |
| 685 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 686 | "%s: WLANSAP_RemainOnChannel returned fail", __func__); |
Deepthi Gowri | 6ccb1d4 | 2015-08-21 19:43:53 +0530 | [diff] [blame] | 687 | mutex_lock(&pHddCtx->roc_lock); |
Deepthi Gowri | f41ac8f | 2016-05-12 16:36:00 +0530 | [diff] [blame] | 688 | pRemainChanCtx = cfgState->remain_on_chan_ctx; |
| 689 | hddLog( LOG1, FL( |
Jeff Johnson | c135a9a | 2017-09-19 08:37:24 -0700 | [diff] [blame] | 690 | "Freeing ROC ctx cfgState->remain_on_chan_ctx=%pK"), |
Deepthi Gowri | f41ac8f | 2016-05-12 16:36:00 +0530 | [diff] [blame] | 691 | cfgState->remain_on_chan_ctx); |
| 692 | if (pRemainChanCtx) |
| 693 | { |
| 694 | if(!VOS_IS_STATUS_SUCCESS(vos_timer_destroy |
| 695 | (&pRemainChanCtx->hdd_remain_on_chan_timer))) |
| 696 | { |
| 697 | hddLog( LOGE, FL( |
| 698 | "Failed to destroy hdd_remain_on_chan_timer")); |
| 699 | } |
| 700 | vos_mem_free (pRemainChanCtx); |
| 701 | cfgState->remain_on_chan_ctx = NULL; |
| 702 | } |
Deepthi Gowri | 6ccb1d4 | 2015-08-21 19:43:53 +0530 | [diff] [blame] | 703 | mutex_unlock(&pHddCtx->roc_lock); |
Sushant Kaushik | 83392fa | 2015-05-05 17:44:40 +0530 | [diff] [blame] | 704 | hdd_allow_suspend(WIFI_POWER_EVENT_WAKELOCK_ROC); |
Ganesh Kondabattini | babfb49 | 2014-12-17 20:25:29 +0530 | [diff] [blame] | 705 | return -EINVAL; |
| 706 | } |
| 707 | |
| 708 | |
| 709 | if (VOS_STATUS_SUCCESS != WLANSAP_RegisterMgmtFrame( |
| 710 | (WLAN_HDD_GET_CTX(pAdapter))->pvosContext, |
| 711 | (SIR_MAC_MGMT_FRAME << 2) | ( SIR_MAC_MGMT_PROBE_REQ << 4), |
| 712 | NULL, 0 )) |
| 713 | { |
| 714 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 715 | "%s: WLANSAP_RegisterMgmtFrame returned fail", __func__); |
| 716 | WLANSAP_CancelRemainOnChannel( |
| 717 | (WLAN_HDD_GET_CTX(pAdapter))->pvosContext); |
Sushant Kaushik | 83392fa | 2015-05-05 17:44:40 +0530 | [diff] [blame] | 718 | hdd_allow_suspend(WIFI_POWER_EVENT_WAKELOCK_ROC); |
Ganesh Kondabattini | babfb49 | 2014-12-17 20:25:29 +0530 | [diff] [blame] | 719 | return -EINVAL; |
| 720 | } |
| 721 | |
| 722 | } |
| 723 | |
Masti, Narayanraddi | 44b0db0 | 2015-12-22 11:54:35 +0530 | [diff] [blame] | 724 | wlan_hdd_start_stop_tdls_source_timer(pHddCtx, eTDLS_SUPPORT_DISABLED); |
| 725 | |
Ganesh Kondabattini | babfb49 | 2014-12-17 20:25:29 +0530 | [diff] [blame] | 726 | pAdapter->is_roc_inprogress = TRUE; |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 727 | EXIT(); |
Ganesh Kondabattini | babfb49 | 2014-12-17 20:25:29 +0530 | [diff] [blame] | 728 | return 0; |
| 729 | } |
| 730 | |
| 731 | |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 732 | static int wlan_hdd_request_remain_on_channel( struct wiphy *wiphy, |
| 733 | struct net_device *dev, |
| 734 | struct ieee80211_channel *chan, |
Yue Ma | f49ba87 | 2013-08-19 12:04:25 -0700 | [diff] [blame] | 735 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,8,0)) |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 736 | enum nl80211_channel_type channel_type, |
Yue Ma | f49ba87 | 2013-08-19 12:04:25 -0700 | [diff] [blame] | 737 | #endif |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 738 | unsigned int duration, u64 *cookie, |
| 739 | rem_on_channel_request_type_t request_type ) |
| 740 | { |
| 741 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 742 | hdd_remain_on_chan_ctx_t *pRemainChanCtx; |
| 743 | hdd_cfg80211_state_t *cfgState = WLAN_HDD_GET_CFG_STATE_PTR( pAdapter ); |
Masti, Narayanraddi | c80e2bf | 2015-01-27 16:39:00 +0530 | [diff] [blame] | 744 | hdd_context_t *pHddCtx = NULL; |
Sushant Kaushik | 5ad9b7b | 2014-05-21 21:09:43 +0530 | [diff] [blame] | 745 | VOS_STATUS checkReadyInd; |
Ganesh Kondabattini | babfb49 | 2014-12-17 20:25:29 +0530 | [diff] [blame] | 746 | hdd_adapter_t *pStaAdapter; |
Masti, Narayanraddi | c80e2bf | 2015-01-27 16:39:00 +0530 | [diff] [blame] | 747 | int status = 0; |
| 748 | |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 749 | ENTER(); |
Masti, Narayanraddi | c80e2bf | 2015-01-27 16:39:00 +0530 | [diff] [blame] | 750 | if (NULL == pAdapter) |
| 751 | { |
| 752 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 753 | "%s: HDD adapter is Null", __func__); |
| 754 | return -ENODEV; |
| 755 | } |
| 756 | |
| 757 | pHddCtx = WLAN_HDD_GET_CTX( pAdapter ); |
| 758 | status = wlan_hdd_validate_context(pHddCtx); |
Masti, Narayanraddi | c80e2bf | 2015-01-27 16:39:00 +0530 | [diff] [blame] | 759 | if (0 != status) |
| 760 | { |
Masti, Narayanraddi | c80e2bf | 2015-01-27 16:39:00 +0530 | [diff] [blame] | 761 | return status; |
| 762 | } |
Ganesh Kondabattini | babfb49 | 2014-12-17 20:25:29 +0530 | [diff] [blame] | 763 | |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 764 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d", |
| 765 | __func__,pAdapter->device_mode); |
Yue Ma | f49ba87 | 2013-08-19 12:04:25 -0700 | [diff] [blame] | 766 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,8,0)) |
Rashmi Ramanna | c774453 | 2013-10-06 16:49:08 +0530 | [diff] [blame] | 767 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 768 | "chan(hw_val)0x%x chan(centerfreq) %d chan type 0x%x, dur %d," |
| 769 | " request type %d, cookie %llu", |
| 770 | chan->hw_value, chan->center_freq, channel_type, duration, |
| 771 | request_type, *cookie); |
Yue Ma | f49ba87 | 2013-08-19 12:04:25 -0700 | [diff] [blame] | 772 | #else |
Rashmi Ramanna | c774453 | 2013-10-06 16:49:08 +0530 | [diff] [blame] | 773 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 774 | "chan(hw_val)0x%x chan(centerfreq) %d, duration %d" |
| 775 | " reuest type %d, cookie %llu", chan->hw_value, chan->center_freq, |
| 776 | duration, request_type, *cookie ); |
Yue Ma | f49ba87 | 2013-08-19 12:04:25 -0700 | [diff] [blame] | 777 | #endif |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 778 | //Cancel existing remain On Channel if any |
Sushant Kaushik | 5ad9b7b | 2014-05-21 21:09:43 +0530 | [diff] [blame] | 779 | checkReadyInd = wlan_hdd_cancel_existing_remain_on_channel(pAdapter); |
| 780 | if (VOS_STATUS_SUCCESS != checkReadyInd) |
| 781 | { |
| 782 | hddLog( LOGE, FL("Cancel Roc in progress")); |
| 783 | return -EBUSY; |
| 784 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 785 | |
Hanumanth Reddy Pothula | 80e3f8c | 2016-09-14 19:04:26 +0530 | [diff] [blame] | 786 | if (TRUE == pHddCtx->btCoexModeSet) |
| 787 | { |
| 788 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 789 | FL("BTCoex Mode operation in progress")); |
| 790 | return -EBUSY; |
| 791 | } |
| 792 | |
Sreelakshmi Konamki | 20ebed9 | 2016-10-27 12:13:30 +0530 | [diff] [blame] | 793 | if(hdd_isConnectionInProgress((hdd_context_t *)pAdapter->pHddCtx, NULL, |
| 794 | NULL)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 795 | { |
| 796 | hddLog( LOGE, |
Masti, Narayanraddi | c80e2bf | 2015-01-27 16:39:00 +0530 | [diff] [blame] | 797 | "%s: Connection is in progress", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 798 | return -EBUSY; |
| 799 | } |
| 800 | |
Ganesh Kondabattini | bdb415e | 2015-09-16 12:37:14 +0530 | [diff] [blame] | 801 | mutex_lock(&pHddCtx->roc_lock); |
| 802 | |
Deepthi Gowri | 7566465 | 2016-09-08 17:44:35 +0530 | [diff] [blame] | 803 | if (cfgState->remain_on_chan_ctx) |
| 804 | VOS_BUG(0); |
| 805 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 806 | pRemainChanCtx = vos_mem_malloc( sizeof(hdd_remain_on_chan_ctx_t) ); |
| 807 | if( NULL == pRemainChanCtx ) |
| 808 | { |
| 809 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 810 | "%s: Not able to allocate memory for Channel context", |
| 811 | __func__); |
Ganesh Kondabattini | bdb415e | 2015-09-16 12:37:14 +0530 | [diff] [blame] | 812 | mutex_unlock(&pHddCtx->roc_lock); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 813 | return -ENOMEM; |
| 814 | } |
| 815 | |
Ganesh Kondabattini | 8ae1a07 | 2015-02-02 17:49:50 +0530 | [diff] [blame] | 816 | vos_mem_zero(pRemainChanCtx, sizeof (hdd_remain_on_chan_ctx_t)); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 817 | vos_mem_copy( &pRemainChanCtx->chan, chan, |
| 818 | sizeof(struct ieee80211_channel) ); |
| 819 | |
Yue Ma | f49ba87 | 2013-08-19 12:04:25 -0700 | [diff] [blame] | 820 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,8,0)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 821 | pRemainChanCtx->chan_type = channel_type; |
Yue Ma | f49ba87 | 2013-08-19 12:04:25 -0700 | [diff] [blame] | 822 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 823 | pRemainChanCtx->duration = duration; |
| 824 | pRemainChanCtx->dev = dev; |
Jeff Johnson | f67dca9 | 2013-11-08 17:07:40 -0800 | [diff] [blame] | 825 | *cookie = (uintptr_t) pRemainChanCtx; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 826 | pRemainChanCtx->cookie = *cookie; |
| 827 | pRemainChanCtx->rem_on_chan_request = request_type; |
| 828 | cfgState->remain_on_chan_ctx = pRemainChanCtx; |
| 829 | cfgState->current_freq = chan->center_freq; |
Kaushik, Sushant | 7005e37 | 2014-04-08 11:36:54 +0530 | [diff] [blame] | 830 | pRemainChanCtx->action_pkt_buff.freq = 0; |
| 831 | pRemainChanCtx->action_pkt_buff.frame_ptr = NULL; |
| 832 | pRemainChanCtx->action_pkt_buff.frame_length = 0; |
| 833 | pRemainChanCtx->hdd_remain_on_chan_cancel_in_progress = FALSE; |
Sushant Kaushik | 5ad9b7b | 2014-05-21 21:09:43 +0530 | [diff] [blame] | 834 | pRemainChanCtx->is_pending_roc_cancelled = FALSE; |
Ganesh Kondabattini | babfb49 | 2014-12-17 20:25:29 +0530 | [diff] [blame] | 835 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 836 | INIT_COMPLETION(pAdapter->rem_on_chan_ready_event); |
| 837 | |
Ganesh Kondabattini | babfb49 | 2014-12-17 20:25:29 +0530 | [diff] [blame] | 838 | if (REMAIN_ON_CHANNEL_REQUEST == request_type) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 839 | { |
Ganesh Kondabattini | babfb49 | 2014-12-17 20:25:29 +0530 | [diff] [blame] | 840 | pStaAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_INFRA_STATION); |
| 841 | if((NULL != pStaAdapter)&& |
| 842 | hdd_connIsConnected( WLAN_HDD_GET_STATION_CTX_PTR(pStaAdapter))) |
Sushant Kaushik | 298a859 | 2014-12-09 17:34:07 +0530 | [diff] [blame] | 843 | { |
Ganesh Kondabattini | babfb49 | 2014-12-17 20:25:29 +0530 | [diff] [blame] | 844 | if (pAdapter->lastRocTs !=0 && |
| 845 | ((vos_timer_get_system_time() - pAdapter->lastRocTs ) |
| 846 | < pHddCtx->cfg_ini->gP2PListenDeferInterval)) |
Rashmi Ramanna | c774453 | 2013-10-06 16:49:08 +0530 | [diff] [blame] | 847 | { |
Ganesh Kondabattini | babfb49 | 2014-12-17 20:25:29 +0530 | [diff] [blame] | 848 | if (pRemainChanCtx->duration > HDD_P2P_MAX_ROC_DURATION) |
| 849 | pRemainChanCtx->duration = HDD_P2P_MAX_ROC_DURATION; |
Ganesh Kondabattini | bdb415e | 2015-09-16 12:37:14 +0530 | [diff] [blame] | 850 | |
| 851 | mutex_unlock(&pHddCtx->roc_lock); |
| 852 | |
Ganesh Kondabattini | babfb49 | 2014-12-17 20:25:29 +0530 | [diff] [blame] | 853 | schedule_delayed_work(&pAdapter->roc_work, |
| 854 | msecs_to_jiffies(pHddCtx->cfg_ini->gP2PListenDeferInterval)); |
Jeff Johnson | c135a9a | 2017-09-19 08:37:24 -0700 | [diff] [blame] | 855 | hddLog(VOS_TRACE_LEVEL_INFO, "Defer interval is %hu, pAdapter %pK", |
Ganesh Kondabattini | babfb49 | 2014-12-17 20:25:29 +0530 | [diff] [blame] | 856 | pHddCtx->cfg_ini->gP2PListenDeferInterval, pAdapter); |
| 857 | return 0; |
Rashmi Ramanna | c774453 | 2013-10-06 16:49:08 +0530 | [diff] [blame] | 858 | } |
Madan Mohan Koyyalamudi | 3588591 | 2012-11-30 15:05:42 -0800 | [diff] [blame] | 859 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 860 | } |
Nirav Shah | 87cd0cb | 2013-12-28 21:22:09 +0530 | [diff] [blame] | 861 | |
Ganesh Kondabattini | bdb415e | 2015-09-16 12:37:14 +0530 | [diff] [blame] | 862 | mutex_unlock(&pHddCtx->roc_lock); |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 863 | status = wlan_hdd_p2p_start_remain_on_channel(pAdapter); |
| 864 | |
| 865 | EXIT(); |
| 866 | return status; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 867 | } |
| 868 | |
Mahesh A Saptasagar | 65570ad | 2014-06-23 21:05:38 +0530 | [diff] [blame] | 869 | int __wlan_hdd_cfg80211_remain_on_channel( struct wiphy *wiphy, |
Jeff Johnson | 3bbe4bf | 2013-01-18 17:05:29 -0800 | [diff] [blame] | 870 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0)) |
| 871 | struct wireless_dev *wdev, |
| 872 | #else |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 873 | struct net_device *dev, |
Jeff Johnson | 3bbe4bf | 2013-01-18 17:05:29 -0800 | [diff] [blame] | 874 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 875 | struct ieee80211_channel *chan, |
Yue Ma | f49ba87 | 2013-08-19 12:04:25 -0700 | [diff] [blame] | 876 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,8,0)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 877 | enum nl80211_channel_type channel_type, |
Yue Ma | f49ba87 | 2013-08-19 12:04:25 -0700 | [diff] [blame] | 878 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 879 | unsigned int duration, u64 *cookie ) |
| 880 | { |
Jeff Johnson | 3bbe4bf | 2013-01-18 17:05:29 -0800 | [diff] [blame] | 881 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0)) |
| 882 | struct net_device *dev = wdev->netdev; |
| 883 | #endif |
Mahesh A Saptasagar | 7408839 | 2015-02-05 17:22:09 +0530 | [diff] [blame] | 884 | hdd_adapter_t *pAdapter; |
| 885 | hdd_context_t *pHddCtx; |
| 886 | int ret = 0; |
| 887 | |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 888 | ENTER(); |
Mahesh A Saptasagar | 7408839 | 2015-02-05 17:22:09 +0530 | [diff] [blame] | 889 | pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 890 | if (NULL == pAdapter) |
| 891 | { |
| 892 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 893 | "%s: Adapter is NULL",__func__); |
| 894 | return -EINVAL; |
| 895 | } |
| 896 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 897 | ret = wlan_hdd_validate_context(pHddCtx); |
| 898 | if (0 != ret) |
| 899 | { |
Mahesh A Saptasagar | 7408839 | 2015-02-05 17:22:09 +0530 | [diff] [blame] | 900 | return ret; |
| 901 | } |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 902 | |
| 903 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
| 904 | TRACE_CODE_HDD_REMAIN_ON_CHANNEL, |
| 905 | pAdapter->sessionId, REMAIN_ON_CHANNEL_REQUEST)); |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 906 | ret = wlan_hdd_request_remain_on_channel(wiphy, dev, |
Yue Ma | f49ba87 | 2013-08-19 12:04:25 -0700 | [diff] [blame] | 907 | chan, |
| 908 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,8,0)) |
| 909 | channel_type, |
| 910 | #endif |
| 911 | duration, cookie, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 912 | REMAIN_ON_CHANNEL_REQUEST); |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 913 | EXIT(); |
| 914 | return ret; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 915 | } |
| 916 | |
Mahesh A Saptasagar | 65570ad | 2014-06-23 21:05:38 +0530 | [diff] [blame] | 917 | int wlan_hdd_cfg80211_remain_on_channel( struct wiphy *wiphy, |
| 918 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0)) |
| 919 | struct wireless_dev *wdev, |
| 920 | #else |
| 921 | struct net_device *dev, |
| 922 | #endif |
| 923 | struct ieee80211_channel *chan, |
| 924 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,8,0)) |
| 925 | enum nl80211_channel_type channel_type, |
| 926 | #endif |
| 927 | unsigned int duration, u64 *cookie ) |
| 928 | { |
| 929 | int ret; |
| 930 | |
| 931 | vos_ssr_protect(__func__); |
| 932 | ret = __wlan_hdd_cfg80211_remain_on_channel(wiphy, |
| 933 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0)) |
| 934 | wdev, |
| 935 | #else |
| 936 | dev, |
| 937 | #endif |
| 938 | chan, |
| 939 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,8,0)) |
| 940 | channel_type, |
| 941 | #endif |
| 942 | duration, cookie); |
| 943 | vos_ssr_unprotect(__func__); |
| 944 | |
| 945 | return ret; |
| 946 | } |
| 947 | |
| 948 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 949 | void hdd_remainChanReadyHandler( hdd_adapter_t *pAdapter ) |
| 950 | { |
Kaushik, Sushant | 2640261 | 2014-05-03 16:56:06 +0530 | [diff] [blame] | 951 | hdd_cfg80211_state_t *cfgState = NULL; |
| 952 | hdd_remain_on_chan_ctx_t* pRemainChanCtx = NULL; |
Deepthi Gowri | 3124dcd | 2015-08-28 19:34:27 +0530 | [diff] [blame] | 953 | hdd_context_t *pHddCtx; |
Kaushik, Sushant | 7005e37 | 2014-04-08 11:36:54 +0530 | [diff] [blame] | 954 | VOS_STATUS status; |
Kaushik, Sushant | 2640261 | 2014-05-03 16:56:06 +0530 | [diff] [blame] | 955 | if (NULL == pAdapter) |
| 956 | { |
| 957 | hddLog(LOGE, FL("pAdapter is NULL")); |
| 958 | return; |
| 959 | } |
Deepthi Gowri | 3124dcd | 2015-08-28 19:34:27 +0530 | [diff] [blame] | 960 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 961 | if (NULL == pHddCtx) |
| 962 | { |
| 963 | hddLog(LOGE, FL("pHddCtx is NULL")); |
| 964 | return; |
| 965 | } |
Kaushik, Sushant | 2640261 | 2014-05-03 16:56:06 +0530 | [diff] [blame] | 966 | cfgState = WLAN_HDD_GET_CFG_STATE_PTR( pAdapter ); |
Deepthi Gowri | 22d0875 | 2015-02-05 15:07:40 +0530 | [diff] [blame] | 967 | pAdapter->startRocTs = vos_timer_get_system_time(); |
Deepthi Gowri | 3124dcd | 2015-08-28 19:34:27 +0530 | [diff] [blame] | 968 | mutex_lock(&pHddCtx->roc_lock); |
| 969 | pRemainChanCtx = cfgState->remain_on_chan_ctx; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 970 | if( pRemainChanCtx != NULL ) |
| 971 | { |
Kaushik, Sushant | 78c3efe | 2014-05-13 10:29:34 +0530 | [diff] [blame] | 972 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
| 973 | TRACE_CODE_HDD_REMAINCHANREADYHANDLER, |
| 974 | pAdapter->sessionId, pRemainChanCtx->duration)); |
Kaushik, Sushant | 7005e37 | 2014-04-08 11:36:54 +0530 | [diff] [blame] | 975 | //start timer for actual duration |
| 976 | status = vos_timer_start(&pRemainChanCtx->hdd_remain_on_chan_timer, |
| 977 | (pRemainChanCtx->duration)); |
| 978 | if (VOS_STATUS_SUCCESS!=status) |
| 979 | { |
| 980 | hddLog( LOGE, FL("Remain on Channel timer start failed")); |
| 981 | } |
| 982 | if( REMAIN_ON_CHANNEL_REQUEST == pRemainChanCtx->rem_on_chan_request) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 983 | { |
Jeff Johnson | 3bbe4bf | 2013-01-18 17:05:29 -0800 | [diff] [blame] | 984 | cfg80211_ready_on_channel( |
| 985 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0)) |
| 986 | pAdapter->dev->ieee80211_ptr, |
| 987 | #else |
| 988 | pAdapter->dev, |
| 989 | #endif |
Jeff Johnson | f67dca9 | 2013-11-08 17:07:40 -0800 | [diff] [blame] | 990 | (uintptr_t)pRemainChanCtx, |
Yue Ma | f49ba87 | 2013-08-19 12:04:25 -0700 | [diff] [blame] | 991 | &pRemainChanCtx->chan, |
| 992 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,8,0)) |
| 993 | pRemainChanCtx->chan_type, |
| 994 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 995 | pRemainChanCtx->duration, GFP_KERNEL ); |
| 996 | } |
| 997 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)) |
Kaushik, Sushant | 7005e37 | 2014-04-08 11:36:54 +0530 | [diff] [blame] | 998 | else if( OFF_CHANNEL_ACTION_TX == pRemainChanCtx->rem_on_chan_request) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 999 | { |
| 1000 | complete(&pAdapter->offchannel_tx_event); |
| 1001 | } |
| 1002 | #endif |
Kaushik, Sushant | 7005e37 | 2014-04-08 11:36:54 +0530 | [diff] [blame] | 1003 | // Check for cached action frame |
| 1004 | if ( pRemainChanCtx->action_pkt_buff.frame_length != 0 ) |
| 1005 | { |
Anand N Sunkad | 7bfc8e4 | 2015-07-29 09:59:45 +0530 | [diff] [blame] | 1006 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0)) |
| 1007 | cfg80211_rx_mgmt(pAdapter->dev->ieee80211_ptr, |
| 1008 | pRemainChanCtx->action_pkt_buff.freq, 0, |
| 1009 | pRemainChanCtx->action_pkt_buff.frame_ptr, |
| 1010 | pRemainChanCtx->action_pkt_buff.frame_length, |
| 1011 | NL80211_RXMGMT_FLAG_ANSWERED); |
| 1012 | #elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3,12,0)) |
Anand N Sunkad | e9adb1b | 2015-07-29 09:56:45 +0530 | [diff] [blame] | 1013 | cfg80211_rx_mgmt(pAdapter->dev->ieee80211_ptr, |
| 1014 | pRemainChanCtx->action_pkt_buff.freq, 0, |
| 1015 | pRemainChanCtx->action_pkt_buff.frame_ptr, |
| 1016 | pRemainChanCtx->action_pkt_buff.frame_length, |
| 1017 | NL80211_RXMGMT_FLAG_ANSWERED, GFP_ATOMIC); |
| 1018 | #elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0)) |
Kaushik, Sushant | 7005e37 | 2014-04-08 11:36:54 +0530 | [diff] [blame] | 1019 | cfg80211_rx_mgmt( pAdapter->dev->ieee80211_ptr, |
| 1020 | pRemainChanCtx->action_pkt_buff.freq, 0, |
| 1021 | pRemainChanCtx->action_pkt_buff.frame_ptr, |
| 1022 | pRemainChanCtx->action_pkt_buff.frame_length, |
| 1023 | GFP_ATOMIC ); |
| 1024 | #elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0)) |
| 1025 | cfg80211_rx_mgmt( pAdapter->dev, |
| 1026 | pRemainChanCtx->action_pkt_buff.freq, 0, |
| 1027 | pRemainChanCtx->action_pkt_buff.frame_ptr, |
| 1028 | pRemainChanCtx->action_pkt_buff.frame_length, |
| 1029 | GFP_ATOMIC ); |
| 1030 | #else |
| 1031 | cfg80211_rx_mgmt( pAdapter->dev, |
| 1032 | pRemainChanCtx->action_pkt_buff.freq, |
| 1033 | pRemainChanCtx->action_pkt_buff.frame_ptr, |
| 1034 | pRemainChanCtx->action_pkt_buff.frame_length, |
| 1035 | GFP_ATOMIC ); |
| 1036 | #endif //LINUX_VERSION_CODE |
| 1037 | hddLog( LOGE, "%s: Sent cached action frame to supplicant", __func__); |
| 1038 | vos_mem_free(pRemainChanCtx->action_pkt_buff.frame_ptr); |
| 1039 | pRemainChanCtx->action_pkt_buff.frame_length = 0; |
| 1040 | pRemainChanCtx->action_pkt_buff.freq = 0; |
| 1041 | pRemainChanCtx->action_pkt_buff.frame_ptr = NULL; |
| 1042 | } |
Rashmi Ramanna | c774453 | 2013-10-06 16:49:08 +0530 | [diff] [blame] | 1043 | hddLog( VOS_TRACE_LEVEL_INFO, "Ready on chan ind (cookie=%llu)", |
| 1044 | pRemainChanCtx->cookie); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1045 | complete(&pAdapter->rem_on_chan_ready_event); |
Sushant Kaushik | 5ad9b7b | 2014-05-21 21:09:43 +0530 | [diff] [blame] | 1046 | if (TRUE == pRemainChanCtx->is_pending_roc_cancelled) |
| 1047 | { |
Deepthi Gowri | 3124dcd | 2015-08-28 19:34:27 +0530 | [diff] [blame] | 1048 | mutex_unlock(&pHddCtx->roc_lock); |
Sushant Kaushik | 5ad9b7b | 2014-05-21 21:09:43 +0530 | [diff] [blame] | 1049 | /* since pRemainChanCtx->is_pending_roc_cancelled is |
| 1050 | * set, it means Cancel Reamain on channel command is |
| 1051 | * pending because remain on channel event was not |
| 1052 | * ready when cancel ROC was issued.So issue |
| 1053 | * cancel ROC now. |
| 1054 | */ |
| 1055 | wlan_hdd_cancel_existing_remain_on_channel(pAdapter); |
| 1056 | } |
Deepthi Gowri | 3124dcd | 2015-08-28 19:34:27 +0530 | [diff] [blame] | 1057 | else |
| 1058 | { |
| 1059 | mutex_unlock(&pHddCtx->roc_lock); |
| 1060 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1061 | } |
| 1062 | else |
| 1063 | { |
Deepthi Gowri | 3124dcd | 2015-08-28 19:34:27 +0530 | [diff] [blame] | 1064 | mutex_unlock(&pHddCtx->roc_lock); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1065 | hddLog( LOGW, "%s: No Pending Remain on channel Request", __func__); |
| 1066 | } |
| 1067 | return; |
| 1068 | } |
| 1069 | |
Mahesh A Saptasagar | 65570ad | 2014-06-23 21:05:38 +0530 | [diff] [blame] | 1070 | int __wlan_hdd_cfg80211_cancel_remain_on_channel( struct wiphy *wiphy, |
Jeff Johnson | 3bbe4bf | 2013-01-18 17:05:29 -0800 | [diff] [blame] | 1071 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0)) |
| 1072 | struct wireless_dev *wdev, |
| 1073 | #else |
| 1074 | struct net_device *dev, |
| 1075 | #endif |
| 1076 | u64 cookie ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1077 | { |
Jeff Johnson | 3bbe4bf | 2013-01-18 17:05:29 -0800 | [diff] [blame] | 1078 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0)) |
| 1079 | struct net_device *dev = wdev->netdev; |
| 1080 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1081 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1082 | hdd_cfg80211_state_t *cfgState = WLAN_HDD_GET_CFG_STATE_PTR( pAdapter ); |
Deepthi Gowri | 8a76bdb | 2015-08-21 15:17:28 +0530 | [diff] [blame] | 1083 | hdd_remain_on_chan_ctx_t *pRemainChanCtx = NULL; |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 1084 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter ); |
| 1085 | int status; |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 1086 | u64 cookie_dummy; |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 1087 | |
| 1088 | ENTER(); |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 1089 | cookie_dummy = cookie << 32; |
| 1090 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
| 1091 | TRACE_CODE_HDD_CFG80211_CANCEL_REMAIN_ON_CHANNEL, |
| 1092 | pAdapter->sessionId, cookie_dummy)); |
| 1093 | hddLog( LOG1, "Cancel remain on channel req"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1094 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 1095 | status = wlan_hdd_validate_context(pHddCtx); |
| 1096 | |
| 1097 | if (0 != status) |
Madan Mohan Koyyalamudi | b2c3689 | 2012-10-18 20:52:38 -0700 | [diff] [blame] | 1098 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 1099 | return status; |
Madan Mohan Koyyalamudi | b2c3689 | 2012-10-18 20:52:38 -0700 | [diff] [blame] | 1100 | } |
Rashmi Ramanna | c774453 | 2013-10-06 16:49:08 +0530 | [diff] [blame] | 1101 | hddLog( LOG1, "Cancel remain on channel req (cookie = %llu)", cookie); |
| 1102 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1103 | /* FIXME cancel currently running remain on chan. |
| 1104 | * Need to check cookie and cancel accordingly |
| 1105 | */ |
Deepthi Gowri | 8f3c88f | 2014-12-22 14:38:14 +0530 | [diff] [blame] | 1106 | mutex_lock(&pHddCtx->roc_lock); |
Deepthi Gowri | 8a76bdb | 2015-08-21 15:17:28 +0530 | [diff] [blame] | 1107 | pRemainChanCtx = cfgState->remain_on_chan_ctx; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1108 | if( (cfgState->remain_on_chan_ctx == NULL) || |
| 1109 | (cfgState->remain_on_chan_ctx->cookie != cookie) ) |
| 1110 | { |
Hema Aparna Medicharla | 8bb6f78 | 2015-03-09 12:35:05 +0530 | [diff] [blame] | 1111 | mutex_unlock(&pHddCtx->roc_lock); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1112 | hddLog( LOGE, |
| 1113 | "%s: No Remain on channel pending with specified cookie value", |
| 1114 | __func__); |
| 1115 | return -EINVAL; |
| 1116 | } |
Sushant Kaushik | 5ad9b7b | 2014-05-21 21:09:43 +0530 | [diff] [blame] | 1117 | if (TRUE != pRemainChanCtx->is_pending_roc_cancelled) |
| 1118 | { |
Deepthi Gowri | 0e5c5d3 | 2015-03-30 13:52:53 +0530 | [diff] [blame] | 1119 | mutex_unlock(&pHddCtx->roc_lock); |
Sushant Kaushik | 5ad9b7b | 2014-05-21 21:09:43 +0530 | [diff] [blame] | 1120 | /* wait until remain on channel ready event received |
| 1121 | * for already issued remain on channel request */ |
| 1122 | status = wait_for_completion_interruptible_timeout(&pAdapter->rem_on_chan_ready_event, |
| 1123 | msecs_to_jiffies(WAIT_REM_CHAN_READY)); |
| 1124 | if (0 >= status) |
| 1125 | { |
| 1126 | hddLog( LOGE, |
| 1127 | "%s: timeout waiting for remain on channel ready indication %d", |
| 1128 | __func__, status); |
Swaroop Golti | 05f6340 | 2015-07-22 11:59:59 +0530 | [diff] [blame] | 1129 | mutex_lock(&pHddCtx->roc_lock); |
| 1130 | if (cfgState->remain_on_chan_ctx) |
| 1131 | cfgState->remain_on_chan_ctx->is_pending_roc_cancelled = TRUE; |
| 1132 | mutex_unlock(&pHddCtx->roc_lock); |
Abhishek Singh | 837adf2 | 2015-10-01 17:37:37 +0530 | [diff] [blame] | 1133 | vos_fatal_event_logs_req(WLAN_LOG_TYPE_FATAL, |
| 1134 | WLAN_LOG_INDICATOR_HOST_DRIVER, |
| 1135 | WLAN_LOG_REASON_HDD_TIME_OUT, |
| 1136 | FALSE, TRUE); |
Sushant Kaushik | 5ad9b7b | 2014-05-21 21:09:43 +0530 | [diff] [blame] | 1137 | return 0; |
| 1138 | |
| 1139 | } |
Deepthi Gowri | 0e5c5d3 | 2015-03-30 13:52:53 +0530 | [diff] [blame] | 1140 | mutex_lock(&pHddCtx->roc_lock); |
Sushant Kaushik | 5ad9b7b | 2014-05-21 21:09:43 +0530 | [diff] [blame] | 1141 | } |
| 1142 | else |
| 1143 | { |
| 1144 | hddLog( LOG1, FL("Cancel ROC event is already pending, " |
| 1145 | "waiting for ready on channel indication.") ); |
Deepthi Gowri | 8f3c88f | 2014-12-22 14:38:14 +0530 | [diff] [blame] | 1146 | mutex_unlock(&pHddCtx->roc_lock); |
Sushant Kaushik | 5ad9b7b | 2014-05-21 21:09:43 +0530 | [diff] [blame] | 1147 | return 0; |
| 1148 | } |
Kaushik, Sushant | 7005e37 | 2014-04-08 11:36:54 +0530 | [diff] [blame] | 1149 | if (NULL != cfgState->remain_on_chan_ctx) |
| 1150 | { |
Deepthi Gowri | f41ac8f | 2016-05-12 16:36:00 +0530 | [diff] [blame] | 1151 | if(!VOS_IS_STATUS_SUCCESS(vos_timer_stop( |
| 1152 | &cfgState->remain_on_chan_ctx->hdd_remain_on_chan_timer))) |
| 1153 | { |
| 1154 | hddLog( LOGE, FL("Failed to stop hdd_remain_on_chan_timer")); |
| 1155 | } |
Kaushik, Sushant | 7005e37 | 2014-04-08 11:36:54 +0530 | [diff] [blame] | 1156 | if (TRUE == pRemainChanCtx->hdd_remain_on_chan_cancel_in_progress) |
| 1157 | { |
Deepthi Gowri | 0e5c5d3 | 2015-03-30 13:52:53 +0530 | [diff] [blame] | 1158 | mutex_unlock(&pHddCtx->roc_lock); |
Kaushik, Sushant | 7005e37 | 2014-04-08 11:36:54 +0530 | [diff] [blame] | 1159 | hddLog( LOG1, |
| 1160 | FL("ROC timer cancellation in progress," |
| 1161 | " wait for completion")); |
| 1162 | status = wait_for_completion_interruptible_timeout( |
| 1163 | &pAdapter->cancel_rem_on_chan_var, |
| 1164 | msecs_to_jiffies(WAIT_CANCEL_REM_CHAN)); |
| 1165 | if (0 >= status) |
| 1166 | { |
| 1167 | hddLog( LOGE, |
| 1168 | "%s:wait on cancel_rem_on_chan_var failed %d", |
| 1169 | __func__, status); |
| 1170 | } |
| 1171 | return 0; |
| 1172 | } |
| 1173 | else |
| 1174 | pRemainChanCtx->hdd_remain_on_chan_cancel_in_progress = TRUE; |
| 1175 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1176 | INIT_COMPLETION(pAdapter->cancel_rem_on_chan_var); |
Abhishek Singh | 4892e96 | 2015-12-30 11:18:58 +0530 | [diff] [blame] | 1177 | mutex_unlock(&pHddCtx->roc_lock); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1178 | /* Issue abort remain on chan request to sme. |
| 1179 | * The remain on channel callback will make sure the remain_on_chan |
| 1180 | * expired event is sent. |
| 1181 | */ |
Abhishek Singh | 36b7c53 | 2015-03-13 15:50:54 +0530 | [diff] [blame] | 1182 | if ( ( WLAN_HDD_INFRA_STATION == pAdapter->device_mode ) || |
| 1183 | ( WLAN_HDD_P2P_CLIENT == pAdapter->device_mode ) || |
Deepthi Gowri | 7049825 | 2015-01-20 15:56:45 +0530 | [diff] [blame] | 1184 | ( WLAN_HDD_P2P_DEVICE == pAdapter->device_mode )) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1185 | { |
Daram Sudha | 1f7e0e9 | 2013-12-17 07:52:31 +0530 | [diff] [blame] | 1186 | tANI_U8 sessionId = pAdapter->sessionId; |
Deepthi Gowri | 7049825 | 2015-01-20 15:56:45 +0530 | [diff] [blame] | 1187 | if (eHAL_STATUS_SUCCESS != |
| 1188 | sme_CancelRemainOnChannel( WLAN_HDD_GET_HAL_CTX( pAdapter ), |
| 1189 | sessionId )) |
| 1190 | { |
| 1191 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1192 | FL("Failed to Cancel Remain on Channel")); |
| 1193 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1194 | } |
Deepthi Gowri | 7049825 | 2015-01-20 15:56:45 +0530 | [diff] [blame] | 1195 | else if (WLAN_HDD_P2P_GO == pAdapter->device_mode) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1196 | { |
| 1197 | WLANSAP_CancelRemainOnChannel( |
Deepthi Gowri | 7049825 | 2015-01-20 15:56:45 +0530 | [diff] [blame] | 1198 | (WLAN_HDD_GET_CTX(pAdapter))->pvosContext); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1199 | } |
Daram Sudha | 1f7e0e9 | 2013-12-17 07:52:31 +0530 | [diff] [blame] | 1200 | else |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1201 | { |
| 1202 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid device_mode = %d", |
| 1203 | __func__, pAdapter->device_mode); |
| 1204 | return -EIO; |
| 1205 | } |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 1206 | status = wait_for_completion_interruptible_timeout(&pAdapter->cancel_rem_on_chan_var, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1207 | msecs_to_jiffies(WAIT_CANCEL_REM_CHAN)); |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 1208 | if (0 >= status) |
| 1209 | { |
| 1210 | hddLog( LOGE, |
| 1211 | "%s:wait on cancel_rem_on_chan_var failed %d", __func__, status); |
| 1212 | } |
Sushant Kaushik | 83392fa | 2015-05-05 17:44:40 +0530 | [diff] [blame] | 1213 | hdd_allow_suspend(WIFI_POWER_EVENT_WAKELOCK_ROC); |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 1214 | |
| 1215 | EXIT(); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1216 | return 0; |
| 1217 | } |
| 1218 | |
Mahesh A Saptasagar | 65570ad | 2014-06-23 21:05:38 +0530 | [diff] [blame] | 1219 | int wlan_hdd_cfg80211_cancel_remain_on_channel( struct wiphy *wiphy, |
Jeff Johnson | 3bbe4bf | 2013-01-18 17:05:29 -0800 | [diff] [blame] | 1220 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0)) |
Mahesh A Saptasagar | 65570ad | 2014-06-23 21:05:38 +0530 | [diff] [blame] | 1221 | struct wireless_dev *wdev, |
| 1222 | #else |
| 1223 | struct net_device *dev, |
| 1224 | #endif |
| 1225 | u64 cookie ) |
| 1226 | { |
| 1227 | int ret; |
| 1228 | |
| 1229 | vos_ssr_protect(__func__); |
| 1230 | ret = __wlan_hdd_cfg80211_cancel_remain_on_channel(wiphy, |
| 1231 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0)) |
| 1232 | wdev, |
| 1233 | #else |
| 1234 | dev, |
| 1235 | #endif |
| 1236 | cookie); |
| 1237 | vos_ssr_unprotect(__func__); |
| 1238 | |
| 1239 | return ret; |
| 1240 | } |
| 1241 | |
| 1242 | |
| 1243 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0)) |
| 1244 | int __wlan_hdd_mgmt_tx( struct wiphy *wiphy, struct wireless_dev *wdev, |
Jeff Johnson | 3bbe4bf | 2013-01-18 17:05:29 -0800 | [diff] [blame] | 1245 | struct ieee80211_channel *chan, bool offchan, |
Yue Ma | f49ba87 | 2013-08-19 12:04:25 -0700 | [diff] [blame] | 1246 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,8,0)) |
Jeff Johnson | 3bbe4bf | 2013-01-18 17:05:29 -0800 | [diff] [blame] | 1247 | enum nl80211_channel_type channel_type, |
Yue Ma | f49ba87 | 2013-08-19 12:04:25 -0700 | [diff] [blame] | 1248 | bool channel_type_valid, |
| 1249 | #endif |
| 1250 | unsigned int wait, |
Jeff Johnson | 3bbe4bf | 2013-01-18 17:05:29 -0800 | [diff] [blame] | 1251 | const u8 *buf, size_t len, bool no_cck, |
| 1252 | bool dont_wait_for_ack, u64 *cookie ) |
| 1253 | #elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3,3,0)) |
Mahesh A Saptasagar | 65570ad | 2014-06-23 21:05:38 +0530 | [diff] [blame] | 1254 | int __wlan_hdd_mgmt_tx( struct wiphy *wiphy, struct net_device *dev, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1255 | struct ieee80211_channel *chan, bool offchan, |
| 1256 | enum nl80211_channel_type channel_type, |
| 1257 | bool channel_type_valid, unsigned int wait, |
| 1258 | const u8 *buf, size_t len, bool no_cck, |
| 1259 | bool dont_wait_for_ack, u64 *cookie ) |
| 1260 | #elif (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)) |
Mahesh A Saptasagar | 65570ad | 2014-06-23 21:05:38 +0530 | [diff] [blame] | 1261 | int __wlan_hdd_mgmt_tx( struct wiphy *wiphy, struct net_device *dev, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1262 | struct ieee80211_channel *chan, bool offchan, |
| 1263 | enum nl80211_channel_type channel_type, |
| 1264 | bool channel_type_valid, unsigned int wait, |
| 1265 | const u8 *buf, size_t len, u64 *cookie ) |
| 1266 | #else |
Mahesh A Saptasagar | 65570ad | 2014-06-23 21:05:38 +0530 | [diff] [blame] | 1267 | int __wlan_hdd_mgmt_tx( struct wiphy *wiphy, struct net_device *dev, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1268 | struct ieee80211_channel *chan, |
| 1269 | enum nl80211_channel_type channel_type, |
| 1270 | bool channel_type_valid, |
| 1271 | const u8 *buf, size_t len, u64 *cookie ) |
| 1272 | #endif //LINUX_VERSION_CODE |
| 1273 | { |
Jeff Johnson | 3bbe4bf | 2013-01-18 17:05:29 -0800 | [diff] [blame] | 1274 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0)) |
| 1275 | struct net_device *dev = wdev->netdev; |
| 1276 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1277 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev ); |
Nachiket Kukade | 78386c1 | 2018-03-28 15:06:47 +0530 | [diff] [blame] | 1278 | hdd_adapter_t *pGoAdapter; |
Kaushik, Sushant | b1ed0f4 | 2014-07-01 18:26:31 +0530 | [diff] [blame] | 1279 | hdd_cfg80211_state_t *cfgState = WLAN_HDD_GET_CFG_STATE_PTR( pAdapter ); |
Deepthi Gowri | 7374e28 | 2015-08-26 19:22:58 +0530 | [diff] [blame] | 1280 | hdd_remain_on_chan_ctx_t *pRemainChanCtx = NULL; |
Kaushik, Sushant | b1ed0f4 | 2014-07-01 18:26:31 +0530 | [diff] [blame] | 1281 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter ); |
Rajeev Kumar Sirasanagandla | ac6345d | 2017-08-30 23:09:08 +0530 | [diff] [blame] | 1282 | tANI_U8 type; |
| 1283 | tANI_U8 subType; |
Mukul Sharma | 1e5d0b7 | 2014-07-01 19:22:21 +0530 | [diff] [blame] | 1284 | tActionFrmType actionFrmType = WLAN_HDD_ACTION_FRM_TYPE_MAX; |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 1285 | bool noack = 0; |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 1286 | int status; |
Rajeev Kumar Sirasanagandla | ac6345d | 2017-08-30 23:09:08 +0530 | [diff] [blame] | 1287 | uint32_t mgmt_hdr_len = sizeof(struct ieee80211_hdr_3addr); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 1288 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1289 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)) |
Deepthi Gowri | e4c9803 | 2016-06-17 15:24:57 +0530 | [diff] [blame] | 1290 | uint8_t home_ch = 0; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1291 | #endif |
Kaushik, Sushant | b1ed0f4 | 2014-07-01 18:26:31 +0530 | [diff] [blame] | 1292 | |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 1293 | ENTER(); |
Rajeev Kumar Sirasanagandla | ac6345d | 2017-08-30 23:09:08 +0530 | [diff] [blame] | 1294 | |
| 1295 | if (len < mgmt_hdr_len + 1) { |
| 1296 | hddLog(VOS_TRACE_LEVEL_ERROR,"Invalid Length"); |
| 1297 | return -EINVAL; |
| 1298 | } |
| 1299 | |
| 1300 | type = WLAN_HDD_GET_TYPE_FRM_FC(buf[0]); |
| 1301 | subType = WLAN_HDD_GET_SUBTYPE_FRM_FC(buf[0]); |
| 1302 | |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 1303 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 1304 | TRACE_CODE_HDD_ACTION, pAdapter->sessionId, |
| 1305 | pAdapter->device_mode )); |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 1306 | status = wlan_hdd_validate_context(pHddCtx); |
| 1307 | |
| 1308 | if (0 != status) |
Sameer Thalappil | 75ea31a | 2013-02-21 19:38:16 -0800 | [diff] [blame] | 1309 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 1310 | return status; |
Sameer Thalappil | 75ea31a | 2013-02-21 19:38:16 -0800 | [diff] [blame] | 1311 | } |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 1312 | |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 1313 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d type: %d", |
| 1314 | __func__, pAdapter->device_mode, type); |
| 1315 | |
| 1316 | |
Madan Mohan Koyyalamudi | 26bd714 | 2012-10-30 18:14:19 -0700 | [diff] [blame] | 1317 | if ((type == SIR_MAC_MGMT_FRAME) && |
| 1318 | (subType == SIR_MAC_MGMT_ACTION) && |
Rajeev Kumar Sirasanagandla | ac6345d | 2017-08-30 23:09:08 +0530 | [diff] [blame] | 1319 | wlan_hdd_is_type_p2p_action( |
| 1320 | &buf[WLAN_HDD_PUBLIC_ACTION_FRAME_BODY_OFFSET], len - mgmt_hdr_len)) |
Madan Mohan Koyyalamudi | 26bd714 | 2012-10-30 18:14:19 -0700 | [diff] [blame] | 1321 | { |
| 1322 | actionFrmType = buf[WLAN_HDD_PUBLIC_ACTION_FRAME_TYPE_OFFSET]; |
Kaushik, Sushant | 731e894 | 2014-09-08 11:59:19 +0530 | [diff] [blame] | 1323 | #ifdef WLAN_FEATURE_P2P_DEBUG |
Hoonki Lee | 1090c6a | 2013-01-16 17:40:54 -0800 | [diff] [blame] | 1324 | if(actionFrmType >= MAX_P2P_ACTION_FRAME_TYPE) |
Madan Mohan Koyyalamudi | 26bd714 | 2012-10-30 18:14:19 -0700 | [diff] [blame] | 1325 | { |
| 1326 | hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P] unknown[%d] ---> OTA", |
| 1327 | actionFrmType); |
| 1328 | } |
| 1329 | else |
| 1330 | { |
| 1331 | hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P] %s ---> OTA", |
| 1332 | p2p_action_frame_type[actionFrmType]); |
| 1333 | if( (actionFrmType == WLAN_HDD_PROV_DIS_REQ) && |
| 1334 | (globalP2PConnectionStatus == P2P_NOT_ACTIVE) ) |
| 1335 | { |
| 1336 | globalP2PConnectionStatus = P2P_GO_NEG_PROCESS; |
| 1337 | hddLog(LOGE,"[P2P State]Inactive state to " |
Jeff Johnson | 1250df4 | 2012-12-10 14:31:52 -0800 | [diff] [blame] | 1338 | "GO negotiation progress state"); |
Madan Mohan Koyyalamudi | 26bd714 | 2012-10-30 18:14:19 -0700 | [diff] [blame] | 1339 | } |
| 1340 | else if( (actionFrmType == WLAN_HDD_GO_NEG_CNF) && |
| 1341 | (globalP2PConnectionStatus == P2P_GO_NEG_PROCESS) ) |
| 1342 | { |
| 1343 | globalP2PConnectionStatus = P2P_GO_NEG_COMPLETED; |
| 1344 | hddLog(LOGE,"[P2P State]GO nego progress to GO nego" |
| 1345 | " completed state"); |
| 1346 | } |
| 1347 | } |
Madan Mohan Koyyalamudi | 26bd714 | 2012-10-30 18:14:19 -0700 | [diff] [blame] | 1348 | #endif |
Kaushik, Sushant | 731e894 | 2014-09-08 11:59:19 +0530 | [diff] [blame] | 1349 | } |
Madan Mohan Koyyalamudi | 26bd714 | 2012-10-30 18:14:19 -0700 | [diff] [blame] | 1350 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 1351 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,3,0)) |
| 1352 | noack = dont_wait_for_ack; |
| 1353 | #endif |
| 1354 | |
Deepthi Gowri | 7374e28 | 2015-08-26 19:22:58 +0530 | [diff] [blame] | 1355 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 1356 | //If the wait is coming as 0 with off channel set |
| 1357 | //then set the wait to 200 ms |
| 1358 | if (offchan && !wait) |
Deepthi Gowri | 22d0875 | 2015-02-05 15:07:40 +0530 | [diff] [blame] | 1359 | { |
Ganesh Kondabattini | 7f6049c | 2015-02-20 20:39:05 +0530 | [diff] [blame] | 1360 | wait = ACTION_FRAME_DEFAULT_WAIT; |
Deepthi Gowri | 7374e28 | 2015-08-26 19:22:58 +0530 | [diff] [blame] | 1361 | mutex_lock(&pHddCtx->roc_lock); |
| 1362 | pRemainChanCtx = cfgState->remain_on_chan_ctx; |
Ganesh Kondabattini | 7f6049c | 2015-02-20 20:39:05 +0530 | [diff] [blame] | 1363 | if (pRemainChanCtx) |
| 1364 | { |
| 1365 | tANI_U32 current_time = vos_timer_get_system_time(); |
| 1366 | int remaining_roc_time = ((int) pRemainChanCtx->duration - |
| 1367 | (current_time - pAdapter->startRocTs)); |
| 1368 | if ( remaining_roc_time > ACTION_FRAME_DEFAULT_WAIT) |
| 1369 | wait = remaining_roc_time; |
| 1370 | } |
Deepthi Gowri | 7374e28 | 2015-08-26 19:22:58 +0530 | [diff] [blame] | 1371 | mutex_unlock(&pHddCtx->roc_lock); |
Deepthi Gowri | 22d0875 | 2015-02-05 15:07:40 +0530 | [diff] [blame] | 1372 | } |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 1373 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1374 | //Call sme API to send out a action frame. |
| 1375 | // OR can we send it directly through data path?? |
| 1376 | // After tx completion send tx status back. |
| 1377 | if ( ( WLAN_HDD_SOFTAP == pAdapter->device_mode ) || |
| 1378 | ( WLAN_HDD_P2P_GO == pAdapter->device_mode ) |
| 1379 | ) |
| 1380 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1381 | if (type == SIR_MAC_MGMT_FRAME) |
| 1382 | { |
| 1383 | if (subType == SIR_MAC_MGMT_PROBE_RSP) |
| 1384 | { |
Daram Sudha | 1f7e0e9 | 2013-12-17 07:52:31 +0530 | [diff] [blame] | 1385 | /* Drop Probe response recieved from supplicant, as for GO and |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1386 | SAP PE itself sends probe response |
Daram Sudha | 1f7e0e9 | 2013-12-17 07:52:31 +0530 | [diff] [blame] | 1387 | */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1388 | goto err_rem_channel; |
| 1389 | } |
| 1390 | else if ((subType == SIR_MAC_MGMT_DISASSOC) || |
| 1391 | (subType == SIR_MAC_MGMT_DEAUTH)) |
| 1392 | { |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 1393 | /* During EAP failure or P2P Group Remove supplicant |
| 1394 | * is sending del_station command to driver. From |
| 1395 | * del_station function, Driver will send deauth frame to |
| 1396 | * p2p client. No need to send disassoc frame from here. |
| 1397 | * so Drop the frame here and send tx indication back to |
| 1398 | * supplicant. |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1399 | */ |
| 1400 | tANI_U8 dstMac[ETH_ALEN] = {0}; |
| 1401 | memcpy(&dstMac, &buf[WLAN_HDD_80211_FRM_DA_OFFSET], ETH_ALEN); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 1402 | hddLog(VOS_TRACE_LEVEL_INFO, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1403 | "%s: Deauth/Disassoc received for STA:" |
Arif Hussain | 24bafea | 2013-11-15 15:10:03 -0800 | [diff] [blame] | 1404 | MAC_ADDRESS_STR, |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 1405 | __func__, |
Arif Hussain | 24bafea | 2013-11-15 15:10:03 -0800 | [diff] [blame] | 1406 | MAC_ADDR_ARRAY(dstMac)); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1407 | goto err_rem_channel; |
| 1408 | } |
| 1409 | } |
| 1410 | } |
| 1411 | |
| 1412 | if( NULL != cfgState->buf ) |
Sudhir Sattayappa Kohalli | 8ee532d | 2013-02-15 13:16:26 -0800 | [diff] [blame] | 1413 | { |
| 1414 | if ( !noack ) |
| 1415 | { |
| 1416 | hddLog( LOGE, "(%s):Previous P2P Action frame packet pending", |
| 1417 | __func__); |
| 1418 | hdd_cleanup_actionframe(pAdapter->pHddCtx, pAdapter); |
| 1419 | } |
| 1420 | else |
| 1421 | { |
| 1422 | hddLog( LOGE, "(%s):Pending Action frame packet return EBUSY", |
| 1423 | __func__); |
| 1424 | return -EBUSY; |
| 1425 | } |
| 1426 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1427 | |
Daram Sudha | 1f7e0e9 | 2013-12-17 07:52:31 +0530 | [diff] [blame] | 1428 | if( subType == SIR_MAC_MGMT_ACTION) |
| 1429 | { |
| 1430 | hddLog( LOG1, "Action frame tx request : %s", |
| 1431 | hdd_getActionString(buf[WLAN_HDD_PUBLIC_ACTION_FRAME_OFFSET])); |
| 1432 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1433 | |
| 1434 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)) |
Deepthi Gowri | e4c9803 | 2016-06-17 15:24:57 +0530 | [diff] [blame] | 1435 | if ( (( WLAN_HDD_SOFTAP == pAdapter->device_mode ) || |
| 1436 | ( WLAN_HDD_P2P_GO == pAdapter->device_mode )) && |
| 1437 | (test_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags))) |
| 1438 | { |
| 1439 | home_ch = pAdapter->sessionCtx.ap.operatingChannel; |
| 1440 | } |
| 1441 | else if ((pAdapter->device_mode == WLAN_HDD_INFRA_STATION) && |
| 1442 | (pAdapter->sessionCtx.station.conn_info.connState == |
| 1443 | eConnectionState_Associated)) |
| 1444 | { |
| 1445 | home_ch = pAdapter->sessionCtx.station.conn_info.operationChannel; |
| 1446 | } |
Nachiket Kukade | 78386c1 | 2018-03-28 15:06:47 +0530 | [diff] [blame] | 1447 | else |
| 1448 | { |
| 1449 | pGoAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_P2P_GO); |
| 1450 | if (pGoAdapter && test_bit(SOFTAP_BSS_STARTED, |
| 1451 | &pGoAdapter->event_flags)) |
| 1452 | home_ch = pGoAdapter->sessionCtx.ap.operatingChannel; |
| 1453 | } |
| 1454 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1455 | //If GO adapter exists and operating on same frequency |
| 1456 | //then we will not request remain on channel |
Deepthi Gowri | e4c9803 | 2016-06-17 15:24:57 +0530 | [diff] [blame] | 1457 | if (ieee80211_frequency_to_channel(chan->center_freq) == home_ch) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1458 | { |
Kaushik, Sushant | 39bdbe2 | 2014-05-23 10:39:15 +0530 | [diff] [blame] | 1459 | /* if GO exist and is not off channel |
| 1460 | * wait time should be zero. |
| 1461 | */ |
| 1462 | wait = 0; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1463 | goto send_frame; |
| 1464 | } |
| 1465 | #endif |
| 1466 | |
| 1467 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)) |
| 1468 | if( offchan && wait) |
| 1469 | { |
| 1470 | int status; |
Agarwal Ashish | 7875e7c | 2014-03-11 12:54:57 +0530 | [diff] [blame] | 1471 | rem_on_channel_request_type_t req_type = OFF_CHANNEL_ACTION_TX; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1472 | // In case of P2P Client mode if we are already |
| 1473 | // on the same channel then send the frame directly |
Mahesh A Saptasagar | 5c03204 | 2015-01-08 14:56:33 +0530 | [diff] [blame] | 1474 | mutex_lock(&pHddCtx->roc_lock); |
Deepthi Gowri | 7374e28 | 2015-08-26 19:22:58 +0530 | [diff] [blame] | 1475 | pRemainChanCtx = cfgState->remain_on_chan_ctx; |
| 1476 | if( (pRemainChanCtx != NULL) && |
Kaushik, Sushant | 7005e37 | 2014-04-08 11:36:54 +0530 | [diff] [blame] | 1477 | (cfgState->current_freq == chan->center_freq) |
| 1478 | ) |
| 1479 | { |
| 1480 | if ( VOS_TIMER_STATE_RUNNING == vos_timer_getCurrentState( |
Deepthi Gowri | 7374e28 | 2015-08-26 19:22:58 +0530 | [diff] [blame] | 1481 | &pRemainChanCtx->hdd_remain_on_chan_timer) ) |
vamsi | da0e5ab | 2013-12-26 14:33:27 +0530 | [diff] [blame] | 1482 | { |
Sushant Kaushik | 22257d6 | 2014-05-20 19:27:07 +0530 | [diff] [blame] | 1483 | /* Some times FW is taking almost 500 msec for |
| 1484 | * full 15 retries, which leads to ROC expiration |
| 1485 | * by the time peer gets response from other peer. |
| 1486 | * Therefore as part of temporary fix , in host |
| 1487 | * ROC time is extended. For frames where we are |
| 1488 | * expecting response from peer , its extended by |
| 1489 | * 500 msec to make ROC wait time as 1 sec and |
| 1490 | * in other cases its extended by 300 msec to make |
| 1491 | * total ROC wait as 500 msec. |
| 1492 | * TODO: FW needs to fix as why 15 retry is taking |
| 1493 | * such long time. |
| 1494 | */ |
| 1495 | if ( actionFrmType == WLAN_HDD_INVITATION_REQ || |
| 1496 | actionFrmType == WLAN_HDD_GO_NEG_REQ || |
| 1497 | actionFrmType == WLAN_HDD_GO_NEG_RESP ) |
| 1498 | wait = wait + ACTION_FRAME_RSP_WAIT; |
| 1499 | else if ( actionFrmType == WLAN_HDD_GO_NEG_CNF || |
| 1500 | actionFrmType == WLAN_HDD_INVITATION_RESP ) |
| 1501 | wait = wait + ACTION_FRAME_ACK_WAIT; |
Deepthi Gowri | f41ac8f | 2016-05-12 16:36:00 +0530 | [diff] [blame] | 1502 | |
| 1503 | if (!VOS_IS_STATUS_SUCCESS(vos_timer_stop( |
| 1504 | &pRemainChanCtx->hdd_remain_on_chan_timer))) |
| 1505 | { |
| 1506 | hddLog( LOGE, FL("Failed to stop hdd_remain_on_chan_timer")); |
| 1507 | } |
Kaushik, Sushant | 7005e37 | 2014-04-08 11:36:54 +0530 | [diff] [blame] | 1508 | status = vos_timer_start( |
Deepthi Gowri | 7374e28 | 2015-08-26 19:22:58 +0530 | [diff] [blame] | 1509 | &pRemainChanCtx->hdd_remain_on_chan_timer, |
Kaushik, Sushant | 7005e37 | 2014-04-08 11:36:54 +0530 | [diff] [blame] | 1510 | wait); |
Hema Aparna Medicharla | 8bb6f78 | 2015-03-09 12:35:05 +0530 | [diff] [blame] | 1511 | |
| 1512 | mutex_unlock(&pHddCtx->roc_lock); |
Kaushik, Sushant | 7005e37 | 2014-04-08 11:36:54 +0530 | [diff] [blame] | 1513 | |
| 1514 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 1515 | "action frame: extending the wait time %u", |
| 1516 | wait); |
Hema Aparna Medicharla | 8bb6f78 | 2015-03-09 12:35:05 +0530 | [diff] [blame] | 1517 | |
| 1518 | if ( status != VOS_STATUS_SUCCESS ) |
| 1519 | { |
| 1520 | hddLog( LOGE, "Remain on Channel timer start failed"); |
| 1521 | } |
Kaushik, Sushant | 7005e37 | 2014-04-08 11:36:54 +0530 | [diff] [blame] | 1522 | goto send_frame; |
| 1523 | } |
| 1524 | else |
| 1525 | { |
| 1526 | if ( TRUE == |
| 1527 | pRemainChanCtx->hdd_remain_on_chan_cancel_in_progress ) |
| 1528 | { |
Mahesh A Saptasagar | 5c03204 | 2015-01-08 14:56:33 +0530 | [diff] [blame] | 1529 | mutex_unlock(&pHddCtx->roc_lock); |
Kaushik, Sushant | 7005e37 | 2014-04-08 11:36:54 +0530 | [diff] [blame] | 1530 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 1531 | "action frame tx: waiting for completion of ROC "); |
| 1532 | |
| 1533 | status = wait_for_completion_interruptible_timeout( |
| 1534 | &pAdapter->cancel_rem_on_chan_var, |
| 1535 | msecs_to_jiffies(WAIT_CANCEL_REM_CHAN)); |
| 1536 | if (0 >= status) |
| 1537 | { |
| 1538 | hddLog( LOGE, |
| 1539 | "%s:wait on cancel_rem_on_chan_var failed %d", |
| 1540 | __func__, status); |
| 1541 | } |
Mahesh A Saptasagar | 5c03204 | 2015-01-08 14:56:33 +0530 | [diff] [blame] | 1542 | goto bypass_lock; |
vamsi | da0e5ab | 2013-12-26 14:33:27 +0530 | [diff] [blame] | 1543 | } |
| 1544 | } |
Edhar, Mahesh Kumar | 9b223db | 2013-11-28 11:30:01 +0530 | [diff] [blame] | 1545 | } |
Mahesh A Saptasagar | 5c03204 | 2015-01-08 14:56:33 +0530 | [diff] [blame] | 1546 | mutex_unlock(&pHddCtx->roc_lock); |
| 1547 | bypass_lock: |
Rashmi Ramanna | c774453 | 2013-10-06 16:49:08 +0530 | [diff] [blame] | 1548 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 1549 | "action frame: Request ROC for wait time %u", wait); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1550 | INIT_COMPLETION(pAdapter->offchannel_tx_event); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1551 | status = wlan_hdd_request_remain_on_channel(wiphy, dev, |
Yue Ma | f49ba87 | 2013-08-19 12:04:25 -0700 | [diff] [blame] | 1552 | chan, |
| 1553 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,8,0)) |
| 1554 | channel_type, |
| 1555 | #endif |
| 1556 | wait, cookie, |
Agarwal Ashish | 7875e7c | 2014-03-11 12:54:57 +0530 | [diff] [blame] | 1557 | req_type); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1558 | |
| 1559 | if(0 != status) |
| 1560 | { |
| 1561 | if( (-EBUSY == status) && |
| 1562 | (cfgState->current_freq == chan->center_freq) ) |
| 1563 | { |
| 1564 | goto send_frame; |
| 1565 | } |
| 1566 | goto err_rem_channel; |
| 1567 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1568 | /* Wait for driver to be ready on the requested channel */ |
| 1569 | status = wait_for_completion_interruptible_timeout( |
| 1570 | &pAdapter->offchannel_tx_event, |
| 1571 | msecs_to_jiffies(WAIT_CHANGE_CHANNEL_FOR_OFFCHANNEL_TX)); |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 1572 | if(0 >= status) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1573 | { |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 1574 | hddLog( LOGE, "wait on offchannel_tx_event failed %d", status); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1575 | goto err_rem_channel; |
| 1576 | } |
| 1577 | } |
| 1578 | else if ( offchan ) |
| 1579 | { |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 1580 | /* Check before sending action frame |
| 1581 | whether we already remain on channel */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1582 | if(NULL == cfgState->remain_on_chan_ctx) |
| 1583 | { |
| 1584 | goto err_rem_channel; |
| 1585 | } |
| 1586 | } |
| 1587 | send_frame: |
| 1588 | #endif |
| 1589 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 1590 | if(!noack) |
| 1591 | { |
| 1592 | cfgState->buf = vos_mem_malloc( len ); //buf; |
| 1593 | if( cfgState->buf == NULL ) |
| 1594 | return -ENOMEM; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1595 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 1596 | cfgState->len = len; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1597 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 1598 | vos_mem_copy( cfgState->buf, buf, len); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1599 | |
Ganesh Kondabattini | cdacf81 | 2015-09-01 12:36:09 +0530 | [diff] [blame] | 1600 | mutex_lock(&pHddCtx->roc_lock); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1601 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)) |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 1602 | if( cfgState->remain_on_chan_ctx ) |
| 1603 | { |
| 1604 | cfgState->action_cookie = cfgState->remain_on_chan_ctx->cookie; |
| 1605 | *cookie = cfgState->action_cookie; |
| 1606 | } |
| 1607 | else |
| 1608 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1609 | #endif |
Jeff Johnson | f67dca9 | 2013-11-08 17:07:40 -0800 | [diff] [blame] | 1610 | *cookie = (uintptr_t) cfgState->buf; |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 1611 | cfgState->action_cookie = *cookie; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1612 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)) |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 1613 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1614 | #endif |
Ganesh Kondabattini | cdacf81 | 2015-09-01 12:36:09 +0530 | [diff] [blame] | 1615 | mutex_unlock(&pHddCtx->roc_lock); |
Daram Sudha | 1f7e0e9 | 2013-12-17 07:52:31 +0530 | [diff] [blame] | 1616 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1617 | |
| 1618 | if ( (WLAN_HDD_INFRA_STATION == pAdapter->device_mode) || |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 1619 | (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) || |
| 1620 | ( WLAN_HDD_P2P_DEVICE == pAdapter->device_mode ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1621 | ) |
| 1622 | { |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 1623 | tANI_U8 sessionId = pAdapter->sessionId; |
Hoonki Lee | 1090c6a | 2013-01-16 17:40:54 -0800 | [diff] [blame] | 1624 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 1625 | if ((type == SIR_MAC_MGMT_FRAME) && |
| 1626 | (subType == SIR_MAC_MGMT_ACTION) && |
Rajeev Kumar Sirasanagandla | ac6345d | 2017-08-30 23:09:08 +0530 | [diff] [blame] | 1627 | wlan_hdd_is_type_p2p_action( |
| 1628 | &buf[WLAN_HDD_PUBLIC_ACTION_FRAME_BODY_OFFSET], |
| 1629 | len - mgmt_hdr_len)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1630 | { |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 1631 | actionFrmType = buf[WLAN_HDD_PUBLIC_ACTION_FRAME_TYPE_OFFSET]; |
Rashmi Ramanna | c774453 | 2013-10-06 16:49:08 +0530 | [diff] [blame] | 1632 | hddLog(LOG1, "Tx Action Frame %u.", actionFrmType); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 1633 | if (actionFrmType == WLAN_HDD_PROV_DIS_REQ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1634 | { |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 1635 | cfgState->actionFrmState = HDD_PD_REQ_ACK_PENDING; |
Rashmi Ramanna | c774453 | 2013-10-06 16:49:08 +0530 | [diff] [blame] | 1636 | hddLog(LOG1, "%s: HDD_PD_REQ_ACK_PENDING.", __func__); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 1637 | } |
| 1638 | else if (actionFrmType == WLAN_HDD_GO_NEG_REQ) |
| 1639 | { |
| 1640 | cfgState->actionFrmState = HDD_GO_NEG_REQ_ACK_PENDING; |
Rashmi Ramanna | c774453 | 2013-10-06 16:49:08 +0530 | [diff] [blame] | 1641 | hddLog(LOG1, "%s: HDD_GO_NEG_REQ_ACK_PENDING.", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1642 | } |
| 1643 | } |
Abhishek Singh | 0ebac9c | 2014-06-25 13:34:12 +0530 | [diff] [blame] | 1644 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1645 | if (eHAL_STATUS_SUCCESS != |
| 1646 | sme_sendAction( WLAN_HDD_GET_HAL_CTX(pAdapter), |
Kaushik, Sushant | 7005e37 | 2014-04-08 11:36:54 +0530 | [diff] [blame] | 1647 | sessionId, buf, len, wait, noack)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1648 | { |
| 1649 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1650 | "%s: sme_sendAction returned fail", __func__); |
| 1651 | goto err; |
| 1652 | } |
| 1653 | } |
Deepthi Gowri | e4c9803 | 2016-06-17 15:24:57 +0530 | [diff] [blame] | 1654 | else if( ( WLAN_HDD_SOFTAP== pAdapter->device_mode ) || |
| 1655 | ( WLAN_HDD_P2P_GO == pAdapter->device_mode ) |
| 1656 | ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1657 | { |
Jeff Johnson | 43971f5 | 2012-07-17 12:26:56 -0700 | [diff] [blame] | 1658 | if( VOS_STATUS_SUCCESS != |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1659 | WLANSAP_SendAction( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext, |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 1660 | buf, len, 0 ) ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1661 | { |
| 1662 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1663 | "%s: WLANSAP_SendAction returned fail", __func__); |
| 1664 | goto err; |
| 1665 | } |
| 1666 | } |
| 1667 | |
| 1668 | return 0; |
| 1669 | err: |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 1670 | if(!noack) |
| 1671 | { |
| 1672 | hdd_sendActionCnf( pAdapter, FALSE ); |
| 1673 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1674 | return 0; |
| 1675 | err_rem_channel: |
Jeff Johnson | f67dca9 | 2013-11-08 17:07:40 -0800 | [diff] [blame] | 1676 | *cookie = (uintptr_t)cfgState; |
Jeff Johnson | 3bbe4bf | 2013-01-18 17:05:29 -0800 | [diff] [blame] | 1677 | cfg80211_mgmt_tx_status( |
| 1678 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0)) |
| 1679 | pAdapter->dev->ieee80211_ptr, |
| 1680 | #else |
| 1681 | pAdapter->dev, |
| 1682 | #endif |
| 1683 | *cookie, buf, len, FALSE, GFP_KERNEL ); |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 1684 | EXIT(); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1685 | return 0; |
| 1686 | } |
| 1687 | |
Anand N Sunkad | e9adb1b | 2015-07-29 09:56:45 +0530 | [diff] [blame] | 1688 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0)) |
| 1689 | int wlan_hdd_mgmt_tx(struct wiphy *wiphy, struct wireless_dev *wdev, |
| 1690 | struct cfg80211_mgmt_tx_params *params, u64 *cookie) |
| 1691 | #elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0)) |
Mahesh A Saptasagar | 65570ad | 2014-06-23 21:05:38 +0530 | [diff] [blame] | 1692 | int wlan_hdd_mgmt_tx( struct wiphy *wiphy, struct wireless_dev *wdev, |
| 1693 | struct ieee80211_channel *chan, bool offchan, |
| 1694 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,8,0)) |
| 1695 | enum nl80211_channel_type channel_type, |
| 1696 | bool channel_type_valid, |
| 1697 | #endif |
| 1698 | unsigned int wait, |
| 1699 | const u8 *buf, size_t len, bool no_cck, |
| 1700 | bool dont_wait_for_ack, u64 *cookie ) |
| 1701 | #elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3,3,0)) |
| 1702 | int wlan_hdd_mgmt_tx( struct wiphy *wiphy, struct net_device *dev, |
| 1703 | struct ieee80211_channel *chan, bool offchan, |
| 1704 | enum nl80211_channel_type channel_type, |
| 1705 | bool channel_type_valid, unsigned int wait, |
| 1706 | const u8 *buf, size_t len, bool no_cck, |
| 1707 | bool dont_wait_for_ack, u64 *cookie ) |
| 1708 | #elif (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)) |
| 1709 | int wlan_hdd_mgmt_tx( struct wiphy *wiphy, struct net_device *dev, |
| 1710 | struct ieee80211_channel *chan, bool offchan, |
| 1711 | enum nl80211_channel_type channel_type, |
| 1712 | bool channel_type_valid, unsigned int wait, |
| 1713 | const u8 *buf, size_t len, u64 *cookie ) |
| 1714 | #else |
| 1715 | int wlan_hdd_mgmt_tx( struct wiphy *wiphy, struct net_device *dev, |
| 1716 | struct ieee80211_channel *chan, |
| 1717 | enum nl80211_channel_type channel_type, |
| 1718 | bool channel_type_valid, |
| 1719 | const u8 *buf, size_t len, u64 *cookie ) |
| 1720 | #endif //LINUX_VERSION_CODE |
| 1721 | { |
| 1722 | int ret; |
| 1723 | |
| 1724 | vos_ssr_protect(__func__); |
Anand N Sunkad | e9adb1b | 2015-07-29 09:56:45 +0530 | [diff] [blame] | 1725 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0)) |
| 1726 | ret = __wlan_hdd_mgmt_tx(wiphy, wdev, params->chan, params->offchan, |
| 1727 | params->wait, params->buf, params->len, |
| 1728 | params->no_cck, params->dont_wait_for_ack, |
| 1729 | cookie); |
| 1730 | #elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0)) |
Mahesh A Saptasagar | 65570ad | 2014-06-23 21:05:38 +0530 | [diff] [blame] | 1731 | ret = __wlan_hdd_mgmt_tx(wiphy, wdev, |
| 1732 | chan, offchan, |
| 1733 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,8,0)) |
| 1734 | channel_type, |
| 1735 | channel_type_valid, |
| 1736 | #endif |
| 1737 | wait, |
| 1738 | buf, len, no_cck, |
| 1739 | dont_wait_for_ack, cookie); |
| 1740 | #elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3,3,0)) |
| 1741 | ret = __wlan_hdd_mgmt_tx(wiphy, dev, chan, offchan, |
| 1742 | channel_type, channel_type_valid, wait, |
| 1743 | buf, len, no_cck, |
| 1744 | dont_wait_for_ack, cookie); |
| 1745 | #elif (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)) |
| 1746 | ret = __wlan_hdd_mgmt_tx(wiphy, dev, chan, offchan, |
| 1747 | channel_type, channel_type_valid, wait, |
| 1748 | buf, len, cookie); |
| 1749 | #else |
| 1750 | ret = __wlan_hdd_mgmt_tx(wiphy, dev, chan, channel_type, |
| 1751 | channel_type_valid, buf, len, cookie); |
| 1752 | #endif //LINUX_VERSION_CODE |
| 1753 | vos_ssr_unprotect(__func__); |
| 1754 | |
| 1755 | return ret; |
| 1756 | } |
| 1757 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1758 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)) |
Jeff Johnson | 3bbe4bf | 2013-01-18 17:05:29 -0800 | [diff] [blame] | 1759 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0)) |
Mahesh A Saptasagar | 65570ad | 2014-06-23 21:05:38 +0530 | [diff] [blame] | 1760 | int __wlan_hdd_cfg80211_mgmt_tx_cancel_wait(struct wiphy *wiphy, |
Jeff Johnson | 3bbe4bf | 2013-01-18 17:05:29 -0800 | [diff] [blame] | 1761 | struct wireless_dev *wdev, |
| 1762 | u64 cookie) |
| 1763 | { |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 1764 | u64 cookie_dummy; |
| 1765 | cookie_dummy = cookie << 32; |
| 1766 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
| 1767 | TRACE_CODE_HDD_MGMT_TX_CANCEL_WAIT, NO_SESSION, cookie_dummy)); |
Jeff Johnson | 3bbe4bf | 2013-01-18 17:05:29 -0800 | [diff] [blame] | 1768 | return wlan_hdd_cfg80211_cancel_remain_on_channel( wiphy, wdev, cookie ); |
| 1769 | } |
| 1770 | #else |
Mahesh A Saptasagar | 65570ad | 2014-06-23 21:05:38 +0530 | [diff] [blame] | 1771 | int __wlan_hdd_cfg80211_mgmt_tx_cancel_wait(struct wiphy *wiphy, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1772 | struct net_device *dev, |
| 1773 | u64 cookie) |
| 1774 | { |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 1775 | u64 cookie_dummy; |
| 1776 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev ); |
| 1777 | cookie_dummy = cookie << 32; |
| 1778 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
| 1779 | TRACE_CODE_HDD_MGMT_TX_CANCEL_WAIT, |
| 1780 | pAdapter->sessionId, cookie_dummy)); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1781 | return wlan_hdd_cfg80211_cancel_remain_on_channel( wiphy, dev, cookie ); |
| 1782 | } |
| 1783 | #endif |
Jeff Johnson | 3bbe4bf | 2013-01-18 17:05:29 -0800 | [diff] [blame] | 1784 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1785 | |
Mahesh A Saptasagar | 65570ad | 2014-06-23 21:05:38 +0530 | [diff] [blame] | 1786 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)) |
| 1787 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0)) |
| 1788 | int wlan_hdd_cfg80211_mgmt_tx_cancel_wait(struct wiphy *wiphy, |
| 1789 | struct wireless_dev *wdev, |
| 1790 | u64 cookie) |
| 1791 | { |
| 1792 | int ret; |
| 1793 | |
| 1794 | vos_ssr_protect(__func__); |
| 1795 | ret = __wlan_hdd_cfg80211_mgmt_tx_cancel_wait(wiphy, wdev, cookie); |
| 1796 | vos_ssr_unprotect(__func__); |
| 1797 | |
| 1798 | return ret; |
| 1799 | } |
| 1800 | #else |
| 1801 | int wlan_hdd_cfg80211_mgmt_tx_cancel_wait(struct wiphy *wiphy, |
| 1802 | struct net_device *dev, |
| 1803 | u64 cookie) |
| 1804 | { |
| 1805 | int ret; |
| 1806 | |
| 1807 | vos_ssr_protect(__func__); |
| 1808 | ret = __wlan_hdd_cfg80211_mgmt_tx_cancel_wait(wiphy, dev, cookie); |
| 1809 | vos_ssr_unprotect(__func__); |
| 1810 | |
| 1811 | return ret; |
| 1812 | } |
| 1813 | #endif |
| 1814 | #endif |
| 1815 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1816 | void hdd_sendActionCnf( hdd_adapter_t *pAdapter, tANI_BOOLEAN actionSendSuccess ) |
| 1817 | { |
| 1818 | hdd_cfg80211_state_t *cfgState = WLAN_HDD_GET_CFG_STATE_PTR( pAdapter ); |
| 1819 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 1820 | cfgState->actionFrmState = HDD_IDLE; |
| 1821 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1822 | if( NULL == cfgState->buf ) |
| 1823 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1824 | return; |
| 1825 | } |
Deepthi Gowri | 108809c | 2016-06-16 18:04:24 +0530 | [diff] [blame] | 1826 | if (cfgState->is_go_neg_ack_received) |
| 1827 | { |
| 1828 | cfgState->is_go_neg_ack_received = 0; |
| 1829 | /* Sometimes its possible that host may receive the ack for GO |
| 1830 | * negotiation req after sending go negotaition confirmation, |
| 1831 | * in such case drop the ack received for the go negotiation |
| 1832 | * request, so that supplicant waits for the confirmation ack |
| 1833 | * from firmware. |
| 1834 | */ |
| 1835 | hddLog( LOG1, FL("Drop the pending ack received in cfgState->actionFrmState %d"), |
| 1836 | cfgState->actionFrmState); |
| 1837 | return; |
| 1838 | } |
| 1839 | |
| 1840 | hddLog( LOG1, "Send Action cnf, actionSendSuccess %d", actionSendSuccess); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1841 | |
| 1842 | /* If skb is NULL it means this packet was received on CFG80211 interface |
| 1843 | * else it was received on Monitor interface */ |
| 1844 | if( cfgState->skb == NULL ) |
| 1845 | { |
| 1846 | /* |
| 1847 | * buf is the same pointer it passed us to send. Since we are sending |
| 1848 | * it through control path, we use different buffers. |
| 1849 | * In case of mac80211, they just push it to the skb and pass the same |
| 1850 | * data while sending tx ack status. |
| 1851 | * */ |
Jeff Johnson | 3bbe4bf | 2013-01-18 17:05:29 -0800 | [diff] [blame] | 1852 | cfg80211_mgmt_tx_status( |
| 1853 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0)) |
| 1854 | pAdapter->dev->ieee80211_ptr, |
| 1855 | #else |
| 1856 | pAdapter->dev, |
| 1857 | #endif |
| 1858 | cfgState->action_cookie, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1859 | cfgState->buf, cfgState->len, actionSendSuccess, GFP_KERNEL ); |
| 1860 | vos_mem_free( cfgState->buf ); |
| 1861 | cfgState->buf = NULL; |
| 1862 | } |
| 1863 | else |
| 1864 | { |
| 1865 | hdd_adapter_t* pMonAdapter = |
| 1866 | hdd_get_adapter( pAdapter->pHddCtx, WLAN_HDD_MONITOR ); |
| 1867 | if( pMonAdapter == NULL ) |
| 1868 | { |
| 1869 | hddLog( LOGE, "Not able to get Monitor Adapter"); |
| 1870 | cfgState->skb = NULL; |
| 1871 | vos_mem_free( cfgState->buf ); |
| 1872 | cfgState->buf = NULL; |
| 1873 | complete(&pAdapter->tx_action_cnf_event); |
| 1874 | return; |
| 1875 | } |
| 1876 | /* Send TX completion feedback over monitor interface. */ |
| 1877 | hdd_wlan_tx_complete( pMonAdapter, cfgState, actionSendSuccess ); |
| 1878 | cfgState->skb = NULL; |
| 1879 | vos_mem_free( cfgState->buf ); |
| 1880 | cfgState->buf = NULL; |
| 1881 | /* Look for the next Mgmt packet to TX */ |
| 1882 | hdd_mon_tx_mgmt_pkt(pAdapter); |
| 1883 | } |
| 1884 | complete(&pAdapter->tx_action_cnf_event); |
| 1885 | } |
| 1886 | |
| 1887 | /** |
| 1888 | * hdd_setP2pNoa |
| 1889 | * |
| 1890 | *FUNCTION: |
Daram Sudha | 1f7e0e9 | 2013-12-17 07:52:31 +0530 | [diff] [blame] | 1891 | * This function is called from hdd_hostapd_ioctl function when Driver |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1892 | * get P2P_SET_NOA comand from wpa_supplicant using private ioctl |
| 1893 | * |
| 1894 | *LOGIC: |
Daram Sudha | 1f7e0e9 | 2013-12-17 07:52:31 +0530 | [diff] [blame] | 1895 | * Fill NoA Struct According to P2P Power save Option and Pass it to SME layer |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1896 | * |
| 1897 | *ASSUMPTIONS: |
| 1898 | * |
| 1899 | * |
| 1900 | *NOTE: |
| 1901 | * |
| 1902 | * @param dev Pointer to net device structure |
Daram Sudha | 1f7e0e9 | 2013-12-17 07:52:31 +0530 | [diff] [blame] | 1903 | * @param command Pointer to command |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1904 | * |
| 1905 | * @return Status |
| 1906 | */ |
| 1907 | |
| 1908 | int hdd_setP2pNoa( struct net_device *dev, tANI_U8 *command ) |
| 1909 | { |
| 1910 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 1911 | tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter); |
| 1912 | VOS_STATUS status = VOS_STATUS_SUCCESS; |
| 1913 | tP2pPsConfig NoA; |
Madan Mohan Koyyalamudi | 4b63eee | 2012-11-06 18:47:56 -0800 | [diff] [blame] | 1914 | int count, duration, start_time; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1915 | char *param; |
kalikinkar dhara | 19d7718 | 2013-11-12 14:29:46 -0800 | [diff] [blame] | 1916 | tANI_U8 ret = 0; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1917 | |
Madan Mohan Koyyalamudi | d8ac866 | 2012-11-06 19:04:56 -0800 | [diff] [blame] | 1918 | param = strnchr(command, strlen(command), ' '); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1919 | if (param == NULL) |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 1920 | { |
| 1921 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1922 | "%s: strnchr failed to find delimeter",__func__); |
| 1923 | return -EINVAL; |
| 1924 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1925 | param++; |
kalikinkar dhara | 19d7718 | 2013-11-12 14:29:46 -0800 | [diff] [blame] | 1926 | ret = sscanf(param, "%d %d %d", &count, &start_time, &duration); |
| 1927 | if (ret < 3) |
| 1928 | { |
| 1929 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1930 | "%s: P2P_SET GO NoA: fail to read param " |
Sushant Kaushik | 8778797 | 2015-09-11 16:05:00 +0530 | [diff] [blame] | 1931 | "count=%d duration=%d interval=%d ", |
kalikinkar dhara | 19d7718 | 2013-11-12 14:29:46 -0800 | [diff] [blame] | 1932 | __func__, count, start_time, duration); |
| 1933 | return -EINVAL; |
| 1934 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1935 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 1936 | "%s: P2P_SET GO NoA: count=%d duration=%d interval=%d", |
Madan Mohan Koyyalamudi | 4b63eee | 2012-11-06 18:47:56 -0800 | [diff] [blame] | 1937 | __func__, count, start_time, duration); |
| 1938 | duration = MS_TO_MUS(duration); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1939 | /* PS Selection |
| 1940 | * Periodic NoA (2) |
| 1941 | * Single NOA (4) |
| 1942 | */ |
| 1943 | NoA.opp_ps = 0; |
| 1944 | NoA.ctWindow = 0; |
| 1945 | if (count == 1) |
| 1946 | { |
| 1947 | NoA.duration = 0; |
| 1948 | NoA.single_noa_duration = duration; |
| 1949 | NoA.psSelection = P2P_POWER_SAVE_TYPE_SINGLE_NOA; |
| 1950 | } |
| 1951 | else |
| 1952 | { |
| 1953 | NoA.duration = duration; |
| 1954 | NoA.single_noa_duration = 0; |
| 1955 | NoA.psSelection = P2P_POWER_SAVE_TYPE_PERIODIC_NOA; |
| 1956 | } |
Madan Mohan Koyyalamudi | 4b63eee | 2012-11-06 18:47:56 -0800 | [diff] [blame] | 1957 | NoA.interval = MS_TO_MUS(100); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1958 | NoA.count = count; |
| 1959 | NoA.sessionid = pAdapter->sessionId; |
| 1960 | |
| 1961 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 1962 | "%s: P2P_PS_ATTR:oppPS %d ctWindow %d duration %d " |
| 1963 | "interval %d count %d single noa duration %d " |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 1964 | "PsSelection %x", __func__, NoA.opp_ps, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1965 | NoA.ctWindow, NoA.duration, NoA.interval, |
| 1966 | NoA.count, NoA.single_noa_duration, |
| 1967 | NoA.psSelection); |
| 1968 | |
| 1969 | sme_p2pSetPs(hHal, &NoA); |
| 1970 | return status; |
| 1971 | } |
| 1972 | |
| 1973 | /** |
| 1974 | * hdd_setP2pOpps |
| 1975 | * |
| 1976 | *FUNCTION: |
| 1977 | * This function is called from hdd_hostapd_ioctl function when Driver |
| 1978 | * get P2P_SET_PS comand from wpa_supplicant using private ioctl |
| 1979 | * |
| 1980 | *LOGIC: |
| 1981 | * Fill NoA Struct According to P2P Power save Option and Pass it to SME layer |
| 1982 | * |
| 1983 | *ASSUMPTIONS: |
| 1984 | * |
| 1985 | * |
| 1986 | *NOTE: |
| 1987 | * |
| 1988 | * @param dev Pointer to net device structure |
| 1989 | * @param command Pointer to command |
| 1990 | * |
| 1991 | * @return Status |
| 1992 | */ |
| 1993 | |
| 1994 | int hdd_setP2pOpps( struct net_device *dev, tANI_U8 *command ) |
| 1995 | { |
| 1996 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 1997 | tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter); |
| 1998 | VOS_STATUS status = VOS_STATUS_SUCCESS; |
| 1999 | tP2pPsConfig NoA; |
| 2000 | char *param; |
| 2001 | int legacy_ps, opp_ps, ctwindow; |
kalikinkar dhara | 19d7718 | 2013-11-12 14:29:46 -0800 | [diff] [blame] | 2002 | tANI_U8 ret = 0; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2003 | |
Madan Mohan Koyyalamudi | d8ac866 | 2012-11-06 19:04:56 -0800 | [diff] [blame] | 2004 | param = strnchr(command, strlen(command), ' '); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2005 | if (param == NULL) |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 2006 | { |
| 2007 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2008 | "%s: strnchr failed to find delimeter",__func__); |
Madan Mohan Koyyalamudi | cae253a | 2012-11-06 19:10:35 -0800 | [diff] [blame] | 2009 | return -EINVAL; |
c_hpothu | 7f63e88 | 2013-10-02 19:13:35 +0530 | [diff] [blame] | 2010 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2011 | param++; |
kalikinkar dhara | 19d7718 | 2013-11-12 14:29:46 -0800 | [diff] [blame] | 2012 | ret = sscanf(param, "%d %d %d", &legacy_ps, &opp_ps, &ctwindow); |
| 2013 | if (ret < 3) |
| 2014 | { |
| 2015 | VOS_TRACE (VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2016 | "%s: P2P_SET GO PS: fail to read param " |
Sushant Kaushik | 8778797 | 2015-09-11 16:05:00 +0530 | [diff] [blame] | 2017 | " legacy_ps=%d opp_ps=%d ctwindow=%d ", |
kalikinkar dhara | 19d7718 | 2013-11-12 14:29:46 -0800 | [diff] [blame] | 2018 | __func__, legacy_ps, opp_ps, ctwindow); |
| 2019 | return -EINVAL; |
| 2020 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2021 | VOS_TRACE (VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 2022 | "%s: P2P_SET GO PS: legacy_ps=%d opp_ps=%d ctwindow=%d", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2023 | __func__, legacy_ps, opp_ps, ctwindow); |
| 2024 | |
| 2025 | /* PS Selection |
| 2026 | * Opportunistic Power Save (1) |
| 2027 | */ |
| 2028 | |
| 2029 | /* From wpa_cli user need to use separate command to set ctWindow and Opps |
| 2030 | * When user want to set ctWindow during that time other parameters |
Daram Sudha | 1f7e0e9 | 2013-12-17 07:52:31 +0530 | [diff] [blame] | 2031 | * values are coming from wpa_supplicant as -1. |
| 2032 | * Example : User want to set ctWindow with 30 then wpa_cli command : |
| 2033 | * P2P_SET ctwindow 30 |
| 2034 | * Command Received at hdd_hostapd_ioctl is as below: |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2035 | * P2P_SET_PS -1 -1 30 (legacy_ps = -1, opp_ps = -1, ctwindow = 30) |
Daram Sudha | 1f7e0e9 | 2013-12-17 07:52:31 +0530 | [diff] [blame] | 2036 | */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2037 | if (ctwindow != -1) |
| 2038 | { |
| 2039 | |
| 2040 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 2041 | "Opportunistic Power Save is %s", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2042 | (TRUE == pAdapter->ops) ? "Enable" : "Disable" ); |
| 2043 | |
| 2044 | if (ctwindow != pAdapter->ctw) |
| 2045 | { |
| 2046 | pAdapter->ctw = ctwindow; |
Daram Sudha | 1f7e0e9 | 2013-12-17 07:52:31 +0530 | [diff] [blame] | 2047 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2048 | if(pAdapter->ops) |
| 2049 | { |
| 2050 | NoA.opp_ps = pAdapter->ops; |
| 2051 | NoA.ctWindow = pAdapter->ctw; |
| 2052 | NoA.duration = 0; |
| 2053 | NoA.single_noa_duration = 0; |
| 2054 | NoA.interval = 0; |
| 2055 | NoA.count = 0; |
| 2056 | NoA.psSelection = P2P_POWER_SAVE_TYPE_OPPORTUNISTIC; |
| 2057 | NoA.sessionid = pAdapter->sessionId; |
Daram Sudha | 1f7e0e9 | 2013-12-17 07:52:31 +0530 | [diff] [blame] | 2058 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2059 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 2060 | "%s: P2P_PS_ATTR:oppPS %d ctWindow %d duration %d " |
| 2061 | "interval %d count %d single noa duration %d " |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 2062 | "PsSelection %x", __func__, NoA.opp_ps, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2063 | NoA.ctWindow, NoA.duration, NoA.interval, |
| 2064 | NoA.count, NoA.single_noa_duration, |
| 2065 | NoA.psSelection); |
| 2066 | |
| 2067 | sme_p2pSetPs(hHal, &NoA); |
| 2068 | } |
| 2069 | return 0; |
| 2070 | } |
| 2071 | } |
| 2072 | |
| 2073 | if (opp_ps != -1) |
| 2074 | { |
| 2075 | pAdapter->ops = opp_ps; |
| 2076 | |
Daram Sudha | 1f7e0e9 | 2013-12-17 07:52:31 +0530 | [diff] [blame] | 2077 | if ((opp_ps != -1) && (pAdapter->ctw)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2078 | { |
| 2079 | NoA.opp_ps = opp_ps; |
| 2080 | NoA.ctWindow = pAdapter->ctw; |
| 2081 | NoA.duration = 0; |
| 2082 | NoA.single_noa_duration = 0; |
| 2083 | NoA.interval = 0; |
| 2084 | NoA.count = 0; |
| 2085 | NoA.psSelection = P2P_POWER_SAVE_TYPE_OPPORTUNISTIC; |
| 2086 | NoA.sessionid = pAdapter->sessionId; |
| 2087 | |
| 2088 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 2089 | "%s: P2P_PS_ATTR:oppPS %d ctWindow %d duration %d " |
| 2090 | "interval %d count %d single noa duration %d " |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 2091 | "PsSelection %x", __func__, NoA.opp_ps, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2092 | NoA.ctWindow, NoA.duration, NoA.interval, |
| 2093 | NoA.count, NoA.single_noa_duration, |
| 2094 | NoA.psSelection); |
| 2095 | |
| 2096 | sme_p2pSetPs(hHal, &NoA); |
| 2097 | } |
| 2098 | } |
| 2099 | return status; |
| 2100 | } |
| 2101 | |
| 2102 | int hdd_setP2pPs( struct net_device *dev, void *msgData ) |
| 2103 | { |
| 2104 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 2105 | tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter); |
| 2106 | VOS_STATUS status = VOS_STATUS_SUCCESS; |
| 2107 | tP2pPsConfig NoA; |
| 2108 | p2p_app_setP2pPs_t *pappNoA = (p2p_app_setP2pPs_t *) msgData; |
| 2109 | |
| 2110 | NoA.opp_ps = pappNoA->opp_ps; |
| 2111 | NoA.ctWindow = pappNoA->ctWindow; |
| 2112 | NoA.duration = pappNoA->duration; |
| 2113 | NoA.interval = pappNoA->interval; |
| 2114 | NoA.count = pappNoA->count; |
| 2115 | NoA.single_noa_duration = pappNoA->single_noa_duration; |
| 2116 | NoA.psSelection = pappNoA->psSelection; |
| 2117 | NoA.sessionid = pAdapter->sessionId; |
| 2118 | |
| 2119 | sme_p2pSetPs(hHal, &NoA); |
| 2120 | return status; |
| 2121 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2122 | |
| 2123 | static tANI_U8 wlan_hdd_get_session_type( enum nl80211_iftype type ) |
| 2124 | { |
| 2125 | tANI_U8 sessionType; |
| 2126 | |
| 2127 | switch( type ) |
| 2128 | { |
| 2129 | case NL80211_IFTYPE_AP: |
| 2130 | sessionType = WLAN_HDD_SOFTAP; |
| 2131 | break; |
| 2132 | case NL80211_IFTYPE_P2P_GO: |
| 2133 | sessionType = WLAN_HDD_P2P_GO; |
| 2134 | break; |
| 2135 | case NL80211_IFTYPE_P2P_CLIENT: |
| 2136 | sessionType = WLAN_HDD_P2P_CLIENT; |
| 2137 | break; |
| 2138 | case NL80211_IFTYPE_STATION: |
| 2139 | sessionType = WLAN_HDD_INFRA_STATION; |
| 2140 | break; |
| 2141 | case NL80211_IFTYPE_MONITOR: |
| 2142 | sessionType = WLAN_HDD_MONITOR; |
| 2143 | break; |
| 2144 | default: |
| 2145 | sessionType = WLAN_HDD_INFRA_STATION; |
| 2146 | break; |
| 2147 | } |
| 2148 | |
| 2149 | return sessionType; |
| 2150 | } |
| 2151 | |
Rajeev Kumar Sirasanagandla | 8f11d54 | 2017-11-14 17:56:55 +0530 | [diff] [blame] | 2152 | /** |
| 2153 | * hdd_close_all_adapters_per_mode() - close all adapters per mode |
| 2154 | * @hdd_ctx: pointer to hdd context |
| 2155 | * @mode: all adapters to be deleted in this mode |
| 2156 | * |
| 2157 | * Return: None |
| 2158 | */ |
| 2159 | static void |
| 2160 | hdd_close_all_adapters_per_mode(hdd_context_t *hdd_ctx, |
| 2161 | uint32_t mode) |
| 2162 | { |
| 2163 | hdd_adapter_t *adapter = hdd_get_adapter(hdd_ctx, mode); |
| 2164 | |
| 2165 | while (adapter) { |
| 2166 | hdd_stop_adapter(hdd_ctx, adapter, VOS_TRUE); |
| 2167 | hdd_deinit_adapter(hdd_ctx, adapter, TRUE); |
| 2168 | hdd_close_adapter(hdd_ctx, adapter, VOS_TRUE); |
| 2169 | |
| 2170 | adapter = hdd_get_adapter(hdd_ctx, mode); |
| 2171 | } |
| 2172 | } |
| 2173 | |
| 2174 | static void wlan_hdd_create_p2p_adapter(hdd_context_t *hdd_ctx, |
| 2175 | tANI_U8 rtnl_held) |
| 2176 | { |
| 2177 | hdd_adapter_t *p2p_adapter; |
| 2178 | |
| 2179 | p2p_adapter = hdd_open_adapter(hdd_ctx, WLAN_HDD_P2P_DEVICE, "p2p%d", |
| 2180 | &hdd_ctx->p2pDeviceAddress.bytes[0], |
| 2181 | rtnl_held); |
| 2182 | if (!p2p_adapter) |
| 2183 | hddLog(LOGE, |
| 2184 | FL("Failed to do hdd_open_adapter for P2P Device Interface")); |
| 2185 | } |
| 2186 | |
| 2187 | /** |
| 2188 | * wlan_hdd_add_monitor_check() - check for monitor intf and add if needed |
| 2189 | * @hdd_ctx: pointer to hdd context |
| 2190 | * @adapter: output pointer to hold created monitor adapter |
| 2191 | * @type: type of the interface |
| 2192 | * @name: name of the interface |
| 2193 | * |
| 2194 | * Return: 0 - on success |
| 2195 | * 1 - on failure |
| 2196 | */ |
| 2197 | static int |
| 2198 | wlan_hdd_add_monitor_check(hdd_context_t *hdd_ctx, hdd_adapter_t **adapter, |
| 2199 | enum nl80211_iftype type, const char *name) |
| 2200 | { |
| 2201 | hdd_adapter_t *sta_adapter; |
| 2202 | hdd_adapter_t *mon_adapter; |
| 2203 | uint32_t i; |
| 2204 | |
| 2205 | *adapter = NULL; |
| 2206 | |
| 2207 | /* |
| 2208 | * If add interface request is for monitor mode, then it can run in |
| 2209 | * parallel with only one station interface. |
| 2210 | * If there is no existing station interface return error |
| 2211 | */ |
| 2212 | if (type != NL80211_IFTYPE_MONITOR) |
| 2213 | return 0; |
| 2214 | |
| 2215 | if (!sme_IsFeatureSupportedByFW(STA_MONITOR_SCC)) { |
| 2216 | hddLog(LOGE, FL("No FW support for STA + MON SCC")); |
| 2217 | return -EINVAL; |
| 2218 | } |
| 2219 | |
| 2220 | if (hdd_ctx->no_of_open_sessions[VOS_MONITOR_MODE]) { |
| 2221 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 2222 | "%s: monitor mode already exists, only one is possible", |
| 2223 | __func__); |
| 2224 | |
| 2225 | return -EBUSY; |
| 2226 | } |
| 2227 | |
| 2228 | /* Ensure there is only one station interface */ |
| 2229 | if (hdd_ctx->no_of_open_sessions[VOS_STA_MODE] != 1) { |
| 2230 | hddLog(LOGE, |
| 2231 | FL("cannot add monitor mode, due to %u sta interfaces"), |
| 2232 | hdd_ctx->no_of_open_sessions[VOS_STA_MODE]); |
| 2233 | |
| 2234 | return -EINVAL; |
| 2235 | } |
| 2236 | |
| 2237 | sta_adapter = hdd_get_adapter(hdd_ctx, WLAN_HDD_INFRA_STATION); |
| 2238 | if (!sta_adapter) { |
| 2239 | hddLog(LOGE, FL("No station adapter")); |
| 2240 | return -EINVAL; |
| 2241 | } |
| 2242 | |
| 2243 | /* delete all the other interfaces */ |
| 2244 | for (i = VOS_STA_SAP_MODE; i <= VOS_P2P_DEVICE; i++) { |
| 2245 | if (i == VOS_FTM_MODE || i == VOS_MONITOR_MODE) |
| 2246 | continue; |
| 2247 | |
| 2248 | hdd_close_all_adapters_per_mode(hdd_ctx, i); |
| 2249 | } |
| 2250 | |
| 2251 | mon_adapter = hdd_open_adapter(hdd_ctx, WLAN_HDD_MONITOR, name, |
| 2252 | wlan_hdd_get_intf_addr(hdd_ctx), |
| 2253 | VOS_TRUE); |
| 2254 | if (!mon_adapter) { |
| 2255 | hddLog(VOS_TRACE_LEVEL_ERROR,"%s: hdd_open_adapter failed", |
| 2256 | __func__); |
| 2257 | wlan_hdd_create_p2p_adapter(hdd_ctx, TRUE); |
| 2258 | return -EINVAL; |
| 2259 | } |
| 2260 | |
| 2261 | *adapter = mon_adapter; |
| 2262 | return 0; |
| 2263 | } |
| 2264 | |
Rajeev Kumar Sirasanagandla | 5b21a9c | 2018-01-08 17:05:11 +0530 | [diff] [blame] | 2265 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0)) |
| 2266 | static struct wireless_dev * |
| 2267 | __wlan_hdd_add_virtual_intf(struct wiphy *wiphy, |
| 2268 | const char *name, |
| 2269 | unsigned char name_assign_type, |
| 2270 | enum nl80211_iftype type, |
| 2271 | u32 *flags, |
| 2272 | struct vif_params *params) |
Jeff Johnson | 3bbe4bf | 2013-01-18 17:05:29 -0800 | [diff] [blame] | 2273 | #elif (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)) |
Rajeev Kumar Sirasanagandla | 5b21a9c | 2018-01-08 17:05:11 +0530 | [diff] [blame] | 2274 | static struct net_device * |
| 2275 | __wlan_hdd_add_virtual_intf(struct wiphy *wiphy, |
| 2276 | const char *name, |
| 2277 | unsigned char name_assign_type, |
| 2278 | enum nl80211_iftype type, |
| 2279 | u32 *flags, |
| 2280 | struct vif_params *params) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2281 | #else |
Rajeev Kumar Sirasanagandla | 5b21a9c | 2018-01-08 17:05:11 +0530 | [diff] [blame] | 2282 | static int |
| 2283 | __wlan_hdd_add_virtual_intf(struct wiphy *wiphy, |
| 2284 | const char *name, |
| 2285 | unsigned char name_assign_type, |
| 2286 | enum nl80211_iftype type, |
| 2287 | u32 *flags, |
| 2288 | struct vif_params *params) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2289 | #endif |
| 2290 | { |
| 2291 | hdd_context_t *pHddCtx = (hdd_context_t*) wiphy_priv(wiphy); |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 2292 | hdd_adapter_t *pAdapter = NULL; |
Rashmi Ramanna | 8f122ce | 2014-05-28 22:42:12 +0530 | [diff] [blame] | 2293 | hdd_scaninfo_t *pScanInfo = NULL; |
Masti, Narayanraddi | c80e2bf | 2015-01-27 16:39:00 +0530 | [diff] [blame] | 2294 | int ret = 0; |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 2295 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2296 | ENTER(); |
| 2297 | |
Masti, Narayanraddi | c80e2bf | 2015-01-27 16:39:00 +0530 | [diff] [blame] | 2298 | ret = wlan_hdd_validate_context(pHddCtx); |
| 2299 | if (0 != ret) |
| 2300 | { |
Masti, Narayanraddi | c80e2bf | 2015-01-27 16:39:00 +0530 | [diff] [blame] | 2301 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)) |
| 2302 | return ERR_PTR(-EINVAL); |
| 2303 | #else |
| 2304 | return -EAGAIN; |
| 2305 | #endif |
| 2306 | } |
| 2307 | |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 2308 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
| 2309 | TRACE_CODE_HDD_ADD_VIRTUAL_INTF, NO_SESSION, type)); |
Agarwal Ashish | 4cfa1e5 | 2014-05-09 20:25:11 +0530 | [diff] [blame] | 2310 | if (WLAN_HDD_P2P_CLIENT != wlan_hdd_get_session_type(type) && |
| 2311 | WLAN_HDD_INFRA_STATION != wlan_hdd_get_session_type(type) && |
| 2312 | hdd_get_adapter(pHddCtx, wlan_hdd_get_session_type(type)) != NULL) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2313 | { |
Jeff Johnson | d13512a | 2012-07-17 11:42:19 -0700 | [diff] [blame] | 2314 | hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Interface type %d already exists. Two" |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2315 | "interfaces of same type are not supported currently.",__func__, type); |
c_hpothu | 471fc96 | 2014-06-24 16:06:53 +0530 | [diff] [blame] | 2316 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)) |
| 2317 | return ERR_PTR(-EINVAL); |
| 2318 | #else |
| 2319 | return -EAGAIN; |
| 2320 | #endif |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2321 | } |
| 2322 | |
Rajeev Kumar Sirasanagandla | 8f11d54 | 2017-11-14 17:56:55 +0530 | [diff] [blame] | 2323 | if (pHddCtx->concurrency_mode == VOS_STA_MON) { |
| 2324 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 2325 | "%s: STA + MONITOR mode is in progress, cannot add new interface", |
| 2326 | __func__); |
| 2327 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)) |
| 2328 | return ERR_PTR(-EINVAL); |
| 2329 | #else |
| 2330 | return -EBUSY; |
| 2331 | #endif |
| 2332 | } |
| 2333 | |
Rashmi Ramanna | 8f122ce | 2014-05-28 22:42:12 +0530 | [diff] [blame] | 2334 | pAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_INFRA_STATION); |
| 2335 | pScanInfo = &pHddCtx->scan_info; |
| 2336 | if ((pScanInfo != NULL) && (pAdapter != NULL) && |
| 2337 | (pHddCtx->scan_info.mScanPending)) |
| 2338 | { |
| 2339 | hdd_abort_mac_scan(pHddCtx, pAdapter->sessionId, |
| 2340 | eCSR_SCAN_ABORT_DEFAULT); |
| 2341 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 2342 | "%s: Abort Scan while adding virtual interface",__func__); |
| 2343 | } |
| 2344 | |
Rajeev Kumar Sirasanagandla | 8f11d54 | 2017-11-14 17:56:55 +0530 | [diff] [blame] | 2345 | ret = wlan_hdd_add_monitor_check(pHddCtx, &pAdapter, type, name); |
| 2346 | if (ret) { |
| 2347 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)) |
| 2348 | return ERR_PTR(-EINVAL); |
| 2349 | #else |
| 2350 | return ret; |
| 2351 | #endif |
| 2352 | } |
| 2353 | |
| 2354 | if (pAdapter) |
| 2355 | goto return_adapter; |
| 2356 | |
Rashmi Ramanna | 8f122ce | 2014-05-28 22:42:12 +0530 | [diff] [blame] | 2357 | pAdapter = NULL; |
Kiet Lam | 04e2691 | 2013-10-18 20:13:38 +0530 | [diff] [blame] | 2358 | if (pHddCtx->cfg_ini->isP2pDeviceAddrAdministrated && |
| 2359 | ((NL80211_IFTYPE_P2P_GO == type) || |
| 2360 | (NL80211_IFTYPE_P2P_CLIENT == type))) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2361 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2362 | /* Generate the P2P Interface Address. this address must be |
| 2363 | * different from the P2P Device Address. |
| 2364 | */ |
| 2365 | v_MACADDR_t p2pDeviceAddress = pHddCtx->p2pDeviceAddress; |
| 2366 | p2pDeviceAddress.bytes[4] ^= 0x80; |
Daram Sudha | 1f7e0e9 | 2013-12-17 07:52:31 +0530 | [diff] [blame] | 2367 | pAdapter = hdd_open_adapter( pHddCtx, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2368 | wlan_hdd_get_session_type(type), |
| 2369 | name, p2pDeviceAddress.bytes, |
| 2370 | VOS_TRUE ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2371 | } |
| 2372 | else |
| 2373 | { |
| 2374 | pAdapter = hdd_open_adapter( pHddCtx, wlan_hdd_get_session_type(type), |
| 2375 | name, wlan_hdd_get_intf_addr(pHddCtx), VOS_TRUE ); |
| 2376 | } |
| 2377 | |
| 2378 | if( NULL == pAdapter) |
| 2379 | { |
| 2380 | hddLog(VOS_TRACE_LEVEL_ERROR,"%s: hdd_open_adapter failed",__func__); |
| 2381 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)) |
c_hpothu | 471fc96 | 2014-06-24 16:06:53 +0530 | [diff] [blame] | 2382 | return ERR_PTR(-EINVAL); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2383 | #else |
| 2384 | return -EINVAL; |
| 2385 | #endif |
| 2386 | } |
Masti, Narayanraddi | 41d82f0 | 2015-06-12 14:04:11 +0530 | [diff] [blame] | 2387 | |
Bala Venkatesh | 5c06a25 | 2018-07-12 16:08:04 +0530 | [diff] [blame] | 2388 | if (type == NL80211_IFTYPE_P2P_CLIENT || type == NL80211_IFTYPE_P2P_GO || |
| 2389 | type == NL80211_IFTYPE_AP) |
Masti, Narayanraddi | 575ccc7 | 2015-08-17 18:04:57 +0530 | [diff] [blame] | 2390 | { |
| 2391 | /* Below function Notifies Mode change and |
| 2392 | * If p2p session is detected then invokes functionality to |
| 2393 | * Teardown TDLS links and disable offchannel if any. Since |
| 2394 | * TDLS is not supported in case of concurrency. |
| 2395 | */ |
| 2396 | hddLog(LOG1, FL("Interface type = %d"), type); |
| 2397 | hdd_tdls_notify_mode_change(pAdapter, pHddCtx); |
| 2398 | } |
Masti, Narayanraddi | 41d82f0 | 2015-06-12 14:04:11 +0530 | [diff] [blame] | 2399 | |
Rajeev Kumar Sirasanagandla | 8f11d54 | 2017-11-14 17:56:55 +0530 | [diff] [blame] | 2400 | return_adapter: |
| 2401 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2402 | EXIT(); |
Jeff Johnson | 3bbe4bf | 2013-01-18 17:05:29 -0800 | [diff] [blame] | 2403 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0)) |
| 2404 | return pAdapter->dev->ieee80211_ptr; |
| 2405 | #elif (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2406 | return pAdapter->dev; |
| 2407 | #else |
| 2408 | return 0; |
| 2409 | #endif |
| 2410 | } |
| 2411 | |
Rajeev Kumar Sirasanagandla | 5b21a9c | 2018-01-08 17:05:11 +0530 | [diff] [blame] | 2412 | #if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 12, 0) |
| 2413 | struct wireless_dev *wlan_hdd_add_virtual_intf(struct wiphy *wiphy, |
| 2414 | const char *name, |
| 2415 | unsigned char name_assign_type, |
| 2416 | enum nl80211_iftype type, |
| 2417 | struct vif_params *params) |
| 2418 | { |
| 2419 | struct wireless_dev *wdev; |
| 2420 | |
| 2421 | vos_ssr_protect(__func__); |
| 2422 | wdev = __wlan_hdd_add_virtual_intf(wiphy, name, name_assign_type, |
| 2423 | type, ¶ms->flags, params); |
| 2424 | vos_ssr_unprotect(__func__); |
| 2425 | |
| 2426 | return wdev; |
| 2427 | } |
| 2428 | #elif (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 1, 0)) || \ |
| 2429 | defined(WITH_BACKPORTS) |
| 2430 | /** |
| 2431 | * wlan_hdd_add_virtual_intf() - Add virtual interface wrapper |
| 2432 | * @wiphy: wiphy pointer |
| 2433 | * @name: User-visible name of the interface |
| 2434 | * @name_assign_type: the name of assign type of the netdev |
| 2435 | * @nl80211_iftype: (virtual) interface types |
| 2436 | * @flags: monitor mode configuration flags (not used) |
| 2437 | * @vif_params: virtual interface parameters (not used) |
| 2438 | * |
| 2439 | * Return: the pointer of wireless dev, otherwise ERR_PTR. |
| 2440 | */ |
| 2441 | struct wireless_dev *wlan_hdd_add_virtual_intf(struct wiphy *wiphy, |
| 2442 | const char *name, |
| 2443 | unsigned char name_assign_type, |
| 2444 | enum nl80211_iftype type, |
| 2445 | u32 *flags, |
| 2446 | struct vif_params *params) |
| 2447 | { |
| 2448 | struct wireless_dev *wdev; |
| 2449 | |
| 2450 | vos_ssr_protect(__func__); |
| 2451 | wdev = __wlan_hdd_add_virtual_intf(wiphy, name, name_assign_type, |
| 2452 | type, flags, params); |
| 2453 | vos_ssr_unprotect(__func__); |
| 2454 | return wdev; |
| 2455 | |
| 2456 | } |
| 2457 | #elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3,7,0)) |
| 2458 | /** |
| 2459 | * wlan_hdd_add_virtual_intf() - Add virtual interface wrapper |
| 2460 | * @wiphy: wiphy pointer |
| 2461 | * @name: User-visible name of the interface |
| 2462 | * @nl80211_iftype: (virtual) interface types |
| 2463 | * @flags: monitor mode configuration flags (not used) |
| 2464 | * @vif_params: virtual interface parameters (not used) |
| 2465 | * |
| 2466 | * Return: the pointer of wireless dev, otherwise ERR_PTR. |
| 2467 | */ |
| 2468 | struct wireless_dev *wlan_hdd_add_virtual_intf(struct wiphy *wiphy, |
| 2469 | const char *name, |
| 2470 | enum nl80211_iftype type, |
| 2471 | u32 *flags, |
| 2472 | struct vif_params *params) |
| 2473 | { |
| 2474 | struct wireless_dev *wdev; |
| 2475 | unsigned char name_assign_type = 0; |
| 2476 | |
| 2477 | vos_ssr_protect(__func__); |
| 2478 | wdev = __wlan_hdd_add_virtual_intf(wiphy, name, name_assign_type, |
| 2479 | type, flags, params); |
| 2480 | vos_ssr_unprotect(__func__); |
| 2481 | return wdev; |
| 2482 | |
| 2483 | } |
| 2484 | |
Mahesh A Saptasagar | 65570ad | 2014-06-23 21:05:38 +0530 | [diff] [blame] | 2485 | #elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0)) |
| 2486 | struct wireless_dev* wlan_hdd_add_virtual_intf( |
| 2487 | struct wiphy *wiphy, char *name, enum nl80211_iftype type, |
| 2488 | u32 *flags, struct vif_params *params ) |
Mahesh A Saptasagar | 65570ad | 2014-06-23 21:05:38 +0530 | [diff] [blame] | 2489 | { |
Rajeev Kumar Sirasanagandla | 5b21a9c | 2018-01-08 17:05:11 +0530 | [diff] [blame] | 2490 | struct wireless_dev *wdev; |
| 2491 | unsigned char name_assign_type = 0; |
| 2492 | |
| 2493 | vos_ssr_protect(__func__); |
| 2494 | wdev = __wlan_hdd_add_virtual_intf(wiphy, (const char *)name, |
| 2495 | name_assign_type, |
| 2496 | type, flags, params); |
| 2497 | vos_ssr_unprotect(__func__); |
| 2498 | return wdev; |
| 2499 | |
Mahesh A Saptasagar | 65570ad | 2014-06-23 21:05:38 +0530 | [diff] [blame] | 2500 | } |
| 2501 | |
Rajeev Kumar Sirasanagandla | 5b21a9c | 2018-01-08 17:05:11 +0530 | [diff] [blame] | 2502 | #elif (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)) |
| 2503 | struct net_device* wlan_hdd_add_virtual_intf(struct wiphy *wiphy, |
| 2504 | char *name, |
| 2505 | enum nl80211_iftype type, |
| 2506 | u32 *flags, |
| 2507 | struct vif_params *params) |
| 2508 | { |
| 2509 | struct net_device *ndev; |
| 2510 | unsigned char name_assign_type = 0; |
| 2511 | |
| 2512 | vos_ssr_protect(__func__); |
| 2513 | ndev = __wlan_hdd_add_virtual_intf(wiphy, (const char *)name, name_assign_type, |
| 2514 | type, flags, params); |
| 2515 | vos_ssr_unprotect(__func__); |
| 2516 | return wdev; |
| 2517 | |
| 2518 | } |
| 2519 | #else |
| 2520 | int wlan_hdd_add_virtual_intf(struct wiphy *wiphy, char *name, |
| 2521 | enum nl80211_iftype type, |
| 2522 | u32 *flags, struct vif_params *params) |
| 2523 | { |
| 2524 | int ret; |
| 2525 | unsigned char name_assign_type = 0; |
| 2526 | |
| 2527 | vos_ssr_protect(__func__); |
| 2528 | ret = __wlan_hdd_add_virtual_intf(wiphy, (const char *)name, name_assign_type, |
| 2529 | type, flags, params); |
| 2530 | vos_ssr_unprotect(__func__); |
| 2531 | |
| 2532 | return ret; |
| 2533 | } |
| 2534 | #endif |
| 2535 | |
Rajeev Kumar Sirasanagandla | 8f11d54 | 2017-11-14 17:56:55 +0530 | [diff] [blame] | 2536 | /** |
| 2537 | * hdd_delete_adapter() - stop and close adapter |
| 2538 | * @hdd_ctx: pointer to hdd context |
| 2539 | * @adapter: adapter to be deleted |
| 2540 | * @rtnl_held: rtnl lock held |
| 2541 | * |
| 2542 | * Rerurn: None |
| 2543 | */ |
| 2544 | static void |
| 2545 | hdd_delete_adapter(hdd_context_t *hdd_ctx, hdd_adapter_t *adapter, |
| 2546 | tANI_U8 rtnl_held) |
| 2547 | { |
| 2548 | wlan_hdd_release_intf_addr(hdd_ctx, adapter->macAddressCurrent.bytes); |
| 2549 | hdd_stop_adapter(hdd_ctx, adapter, VOS_TRUE); |
Sourav Mohapatra | 47b07a0 | 2019-08-22 10:23:18 +0530 | [diff] [blame] | 2550 | hdd_deinit_adapter(hdd_ctx, adapter, TRUE); |
Rajeev Kumar Sirasanagandla | 8f11d54 | 2017-11-14 17:56:55 +0530 | [diff] [blame] | 2551 | hdd_close_adapter(hdd_ctx, adapter, rtnl_held); |
| 2552 | } |
| 2553 | |
| 2554 | /** |
| 2555 | * wlan_hdd_del_monitor() - delete monitor interface |
| 2556 | * @hdd_ctx: pointer to hdd context |
| 2557 | * @adapter: adapter to be deleted |
| 2558 | * @rtnl_held: rtnl lock held |
| 2559 | * |
| 2560 | * This function is invoked to delete monitor interface and also |
| 2561 | * station interface if needed. |
| 2562 | * |
| 2563 | * Return: None |
| 2564 | */ |
| 2565 | static void |
| 2566 | wlan_hdd_del_monitor(hdd_context_t *hdd_ctx, hdd_adapter_t *adapter, |
| 2567 | tANI_U8 rtnl_held) |
| 2568 | { |
| 2569 | hdd_adapter_t *monitor_adapter; |
| 2570 | bool delete_station = false; |
| 2571 | |
| 2572 | monitor_adapter = hdd_get_adapter(hdd_ctx, WLAN_HDD_MONITOR); |
| 2573 | if (monitor_adapter != adapter) |
| 2574 | delete_station = true; |
| 2575 | |
| 2576 | /* delete the monitor adapter and re-create the p2p-dev adapter */ |
| 2577 | hdd_delete_adapter(hdd_ctx, monitor_adapter, rtnl_held); |
| 2578 | |
| 2579 | wlan_hdd_create_p2p_adapter(hdd_ctx, rtnl_held); |
| 2580 | |
| 2581 | if (delete_station) |
| 2582 | hdd_delete_adapter(hdd_ctx, adapter, rtnl_held); |
| 2583 | } |
| 2584 | |
Mahesh A Saptasagar | 65570ad | 2014-06-23 21:05:38 +0530 | [diff] [blame] | 2585 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0)) |
| 2586 | int __wlan_hdd_del_virtual_intf( struct wiphy *wiphy, struct wireless_dev *wdev ) |
| 2587 | #else |
| 2588 | int __wlan_hdd_del_virtual_intf( struct wiphy *wiphy, struct net_device *dev ) |
Jeff Johnson | 3bbe4bf | 2013-01-18 17:05:29 -0800 | [diff] [blame] | 2589 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2590 | { |
Jeff Johnson | 3bbe4bf | 2013-01-18 17:05:29 -0800 | [diff] [blame] | 2591 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0)) |
| 2592 | struct net_device *dev = wdev->netdev; |
| 2593 | #endif |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 2594 | hdd_context_t *pHddCtx = (hdd_context_t*) wiphy_priv(wiphy); |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 2595 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev ); |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 2596 | int status; |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 2597 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 2598 | ENTER(); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2599 | |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 2600 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
| 2601 | TRACE_CODE_HDD_DEL_VIRTUAL_INTF, |
| 2602 | pAdapter->sessionId, pAdapter->device_mode)); |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 2603 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d", |
Rajeev Kumar Sirasanagandla | 8f11d54 | 2017-11-14 17:56:55 +0530 | [diff] [blame] | 2604 | __func__,pAdapter->device_mode); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2605 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 2606 | status = wlan_hdd_validate_context(pHddCtx); |
| 2607 | |
| 2608 | if (0 != status) |
| 2609 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 2610 | return status; |
| 2611 | } |
| 2612 | |
Rajeev Kumar Sirasanagandla | 8f11d54 | 2017-11-14 17:56:55 +0530 | [diff] [blame] | 2613 | if (pHddCtx->concurrency_mode == VOS_STA_MON) |
| 2614 | wlan_hdd_del_monitor(pHddCtx, pAdapter, TRUE); |
| 2615 | else |
| 2616 | hdd_delete_adapter(pHddCtx, pAdapter, TRUE); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2617 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 2618 | EXIT(); |
| 2619 | return 0; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2620 | } |
| 2621 | |
Mahesh A Saptasagar | 65570ad | 2014-06-23 21:05:38 +0530 | [diff] [blame] | 2622 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0)) |
| 2623 | int wlan_hdd_del_virtual_intf( struct wiphy *wiphy, struct wireless_dev *wdev ) |
| 2624 | #else |
| 2625 | int wlan_hdd_del_virtual_intf( struct wiphy *wiphy, struct net_device *dev ) |
| 2626 | #endif |
| 2627 | { |
| 2628 | int ret; |
| 2629 | |
| 2630 | vos_ssr_protect(__func__); |
| 2631 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0)) |
| 2632 | ret = __wlan_hdd_del_virtual_intf(wiphy, wdev); |
| 2633 | #else |
| 2634 | ret = __wlan_hdd_del_virtual_intf(wiphy, dev); |
| 2635 | #endif |
| 2636 | vos_ssr_unprotect(__func__); |
| 2637 | |
| 2638 | return ret; |
| 2639 | } |
| 2640 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2641 | void hdd_sendMgmtFrameOverMonitorIface( hdd_adapter_t *pMonAdapter, |
Jeff Johnson | c9ca373 | 2013-03-27 11:31:03 -0700 | [diff] [blame] | 2642 | tANI_U32 nFrameLength, |
| 2643 | tANI_U8* pbFrames, |
Daram Sudha | 1f7e0e9 | 2013-12-17 07:52:31 +0530 | [diff] [blame] | 2644 | tANI_U8 frameType ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2645 | { |
| 2646 | //Indicate a Frame over Monitor Intf. |
| 2647 | int rxstat; |
| 2648 | struct sk_buff *skb = NULL; |
| 2649 | int needed_headroom = 0; |
| 2650 | int flag = HDD_RX_FLAG_IV_STRIPPED | HDD_RX_FLAG_DECRYPTED | |
| 2651 | HDD_RX_FLAG_MMIC_STRIPPED; |
Sameer Thalappil | 50dc009 | 2013-02-19 17:23:33 -0800 | [diff] [blame] | 2652 | #ifdef WLAN_OPEN_SOURCE |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 2653 | #ifdef WLAN_FEATURE_HOLD_RX_WAKELOCK |
| 2654 | hdd_context_t* pHddCtx = (hdd_context_t*)(pMonAdapter->pHddCtx); |
| 2655 | #endif |
Sameer Thalappil | 50dc009 | 2013-02-19 17:23:33 -0800 | [diff] [blame] | 2656 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2657 | hddLog( LOG1, FL("Indicate Frame over Monitor Intf")); |
| 2658 | |
Jeff Johnson | c9ca373 | 2013-03-27 11:31:03 -0700 | [diff] [blame] | 2659 | if (NULL == pbFrames) |
| 2660 | { |
| 2661 | hddLog(LOGE, FL("NULL frame pointer")); |
| 2662 | return; |
| 2663 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2664 | |
| 2665 | /* room for the radiotap header based on driver features |
| 2666 | * 1 Byte for RADIO TAP Flag, 1 Byte padding and 2 Byte for |
| 2667 | * RX flags. |
| 2668 | * */ |
| 2669 | needed_headroom = sizeof(struct ieee80211_radiotap_header) + 4; |
| 2670 | |
| 2671 | //alloc skb here |
| 2672 | skb = alloc_skb(VPKT_SIZE_BUFFER, GFP_ATOMIC); |
| 2673 | if (unlikely(NULL == skb)) |
| 2674 | { |
| 2675 | hddLog( LOGW, FL("Unable to allocate skb")); |
| 2676 | return; |
| 2677 | } |
| 2678 | skb_reserve(skb, VPKT_SIZE_BUFFER); |
| 2679 | if (unlikely(skb_headroom(skb) < nFrameLength)) |
| 2680 | { |
| 2681 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 2682 | "HDD [%d]: Insufficient headroom, " |
Jeff Johnson | c135a9a | 2017-09-19 08:37:24 -0700 | [diff] [blame] | 2683 | "head[%pK], data[%pK], req[%d]", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2684 | __LINE__, skb->head, skb->data, nFrameLength); |
| 2685 | kfree_skb(skb); |
| 2686 | return ; |
| 2687 | } |
| 2688 | // actually push the data |
| 2689 | memcpy(skb_push(skb, nFrameLength), pbFrames, nFrameLength); |
| 2690 | /* prepend radiotap information */ |
| 2691 | if( 0 != hdd_wlan_add_rx_radiotap_hdr( skb, needed_headroom, flag ) ) |
| 2692 | { |
| 2693 | hddLog( LOGE, FL("Not Able Add Radio Tap")); |
| 2694 | //free skb |
| 2695 | kfree_skb(skb); |
| 2696 | return ; |
| 2697 | } |
| 2698 | |
| 2699 | skb_reset_mac_header( skb ); |
| 2700 | skb->dev = pMonAdapter->dev; |
| 2701 | skb->protocol = eth_type_trans( skb, skb->dev ); |
Madan Mohan Koyyalamudi | f91902f | 2012-10-25 11:59:19 -0700 | [diff] [blame] | 2702 | skb->ip_summed = CHECKSUM_NONE; |
Sameer Thalappil | 50dc009 | 2013-02-19 17:23:33 -0800 | [diff] [blame] | 2703 | #ifdef WLAN_OPEN_SOURCE |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 2704 | #ifdef WLAN_FEATURE_HOLD_RX_WAKELOCK |
Sushant Kaushik | 83392fa | 2015-05-05 17:44:40 +0530 | [diff] [blame] | 2705 | vos_wake_lock_timeout_release(&pHddCtx->rx_wake_lock, |
| 2706 | HDD_WAKE_LOCK_DURATION, |
| 2707 | WIFI_POWER_EVENT_WAKELOCK_HOLD_RX); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 2708 | #endif |
Sameer Thalappil | 50dc009 | 2013-02-19 17:23:33 -0800 | [diff] [blame] | 2709 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2710 | rxstat = netif_rx_ni(skb); |
| 2711 | if( NET_RX_SUCCESS == rxstat ) |
| 2712 | { |
| 2713 | hddLog( LOG1, FL("Success")); |
| 2714 | } |
| 2715 | else |
Rashmi Ramanna | dae90e0 | 2013-12-30 21:49:48 +0530 | [diff] [blame] | 2716 | hddLog( LOGE, FL("Failed %d"), rxstat); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2717 | |
| 2718 | return ; |
| 2719 | } |
| 2720 | |
Abhishek Singh | 7d624e1 | 2015-11-30 14:29:27 +0530 | [diff] [blame] | 2721 | void __hdd_indicate_mgmt_frame(hdd_adapter_t *pAdapter, |
Daram Sudha | 1f7e0e9 | 2013-12-17 07:52:31 +0530 | [diff] [blame] | 2722 | tANI_U32 nFrameLength, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2723 | tANI_U8* pbFrames, |
| 2724 | tANI_U8 frameType, |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 2725 | tANI_U32 rxChan, |
Abhishek Singh | 7d624e1 | 2015-11-30 14:29:27 +0530 | [diff] [blame] | 2726 | tANI_S8 rxRssi) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2727 | { |
| 2728 | tANI_U16 freq; |
Kaushik, Sushant | 7005e37 | 2014-04-08 11:36:54 +0530 | [diff] [blame] | 2729 | tANI_U16 extend_time; |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 2730 | tANI_U8 type = 0; |
Madan Mohan Koyyalamudi | c537df2 | 2012-10-22 15:07:08 -0700 | [diff] [blame] | 2731 | tANI_U8 subType = 0; |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 2732 | tActionFrmType actionFrmType; |
| 2733 | hdd_cfg80211_state_t *cfgState = NULL; |
Rashmi Ramanna | dae90e0 | 2013-12-30 21:49:48 +0530 | [diff] [blame] | 2734 | hdd_scaninfo_t *pScanInfo = NULL; |
Kaushik, Sushant | 13a287c | 2014-05-03 12:26:27 +0530 | [diff] [blame] | 2735 | hdd_context_t *pHddCtx = NULL; |
Kaushik, Sushant | 7005e37 | 2014-04-08 11:36:54 +0530 | [diff] [blame] | 2736 | VOS_STATUS status; |
| 2737 | hdd_remain_on_chan_ctx_t* pRemainChanCtx = NULL; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2738 | |
Agarwal Ashish | ae800dd | 2015-06-24 12:44:48 +0530 | [diff] [blame] | 2739 | hddLog(VOS_TRACE_LEVEL_INFO, FL("Frame Type = %d Frame Length = %d"), |
| 2740 | frameType, nFrameLength); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2741 | |
| 2742 | if (NULL == pAdapter) |
| 2743 | { |
Jeff Johnson | c9ca373 | 2013-03-27 11:31:03 -0700 | [diff] [blame] | 2744 | hddLog(LOGE, FL("pAdapter is NULL")); |
| 2745 | return; |
| 2746 | } |
| 2747 | |
| 2748 | if (0 == nFrameLength) |
| 2749 | { |
| 2750 | hddLog(LOGE, FL("Frame Length is Invalid ZERO")); |
| 2751 | return; |
| 2752 | } |
| 2753 | |
| 2754 | if (NULL == pbFrames) |
| 2755 | { |
| 2756 | hddLog(LOGE, FL("pbFrames is NULL")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2757 | return; |
| 2758 | } |
| 2759 | |
Madan Mohan Koyyalamudi | c537df2 | 2012-10-22 15:07:08 -0700 | [diff] [blame] | 2760 | type = WLAN_HDD_GET_TYPE_FRM_FC(pbFrames[0]); |
| 2761 | subType = WLAN_HDD_GET_SUBTYPE_FRM_FC(pbFrames[0]); |
| 2762 | |
| 2763 | /* Get pAdapter from Destination mac address of the frame */ |
| 2764 | if ((type == SIR_MAC_MGMT_FRAME) && |
Sreelakshmi Konamki | 14dccd2 | 2017-05-11 12:17:22 +0530 | [diff] [blame] | 2765 | (subType != SIR_MAC_MGMT_PROBE_REQ) && |
Wu Gao | 6518a29 | 2019-04-02 13:31:41 +0800 | [diff] [blame] | 2766 | (nFrameLength > WLAN_HDD_80211_FRM_DA_OFFSET + VOS_MAC_ADDR_SIZE) && |
Sreelakshmi Konamki | 14dccd2 | 2017-05-11 12:17:22 +0530 | [diff] [blame] | 2767 | !vos_is_macaddr_broadcast( |
| 2768 | (v_MACADDR_t *)&pbFrames[WLAN_HDD_80211_FRM_DA_OFFSET])) |
Madan Mohan Koyyalamudi | c537df2 | 2012-10-22 15:07:08 -0700 | [diff] [blame] | 2769 | { |
| 2770 | pAdapter = hdd_get_adapter_by_macaddr( WLAN_HDD_GET_CTX(pAdapter), |
| 2771 | &pbFrames[WLAN_HDD_80211_FRM_DA_OFFSET]); |
| 2772 | if (NULL == pAdapter) |
| 2773 | { |
| 2774 | /* Under assumtion that we don't receive any action frame |
| 2775 | * with BCST as destination we dropping action frame |
| 2776 | */ |
Madan Mohan Koyyalamudi | 051ff0b | 2012-12-03 16:55:26 -0800 | [diff] [blame] | 2777 | hddLog(VOS_TRACE_LEVEL_FATAL,"pAdapter for action frame is NULL Macaddr = " |
| 2778 | MAC_ADDRESS_STR , |
| 2779 | MAC_ADDR_ARRAY(&pbFrames[WLAN_HDD_80211_FRM_DA_OFFSET])); |
| 2780 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Frame Type = %d Frame Length = %d" |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 2781 | " subType = %d",__func__,frameType,nFrameLength,subType); |
Madan Mohan Koyyalamudi | c537df2 | 2012-10-22 15:07:08 -0700 | [diff] [blame] | 2782 | return; |
| 2783 | } |
| 2784 | } |
| 2785 | |
Jeff Johnson | c9ca373 | 2013-03-27 11:31:03 -0700 | [diff] [blame] | 2786 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2787 | if (NULL == pAdapter->dev) |
| 2788 | { |
| 2789 | hddLog( LOGE, FL("pAdapter->dev is NULL")); |
| 2790 | return; |
| 2791 | } |
| 2792 | |
| 2793 | if (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic) |
| 2794 | { |
| 2795 | hddLog( LOGE, FL("pAdapter has invalid magic")); |
| 2796 | return; |
| 2797 | } |
| 2798 | |
Rashmi Ramanna | dae90e0 | 2013-12-30 21:49:48 +0530 | [diff] [blame] | 2799 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 2800 | if (NULL == pHddCtx) |
| 2801 | { |
| 2802 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: HDD Context Null Pointer", __func__); |
| 2803 | return; |
| 2804 | } |
| 2805 | |
Jeff Johnson | c9ca373 | 2013-03-27 11:31:03 -0700 | [diff] [blame] | 2806 | if ((WLAN_HDD_SOFTAP == pAdapter->device_mode) || |
| 2807 | (WLAN_HDD_P2P_GO == pAdapter->device_mode )) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2808 | { |
| 2809 | hdd_adapter_t *pMonAdapter = |
| 2810 | hdd_get_mon_adapter( WLAN_HDD_GET_CTX(pAdapter) ); |
| 2811 | |
Jeff Johnson | c9ca373 | 2013-03-27 11:31:03 -0700 | [diff] [blame] | 2812 | if (NULL != pMonAdapter) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2813 | { |
| 2814 | hddLog( LOG1, FL("Indicate Frame over Monitor Interface")); |
| 2815 | hdd_sendMgmtFrameOverMonitorIface( pMonAdapter, nFrameLength, |
| 2816 | pbFrames, frameType); |
| 2817 | return; |
| 2818 | } |
| 2819 | } |
| 2820 | |
| 2821 | //Channel indicated may be wrong. TODO |
| 2822 | //Indicate an action frame. |
| 2823 | if( rxChan <= MAX_NO_OF_2_4_CHANNELS ) |
| 2824 | { |
| 2825 | freq = ieee80211_channel_to_frequency( rxChan, |
Rajeev Kumar Sirasanagandla | 5b21a9c | 2018-01-08 17:05:11 +0530 | [diff] [blame] | 2826 | HDD_NL80211_BAND_2GHZ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2827 | } |
| 2828 | else |
| 2829 | { |
| 2830 | freq = ieee80211_channel_to_frequency( rxChan, |
Rajeev Kumar Sirasanagandla | 5b21a9c | 2018-01-08 17:05:11 +0530 | [diff] [blame] | 2831 | HDD_NL80211_BAND_5GHZ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2832 | } |
| 2833 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 2834 | cfgState = WLAN_HDD_GET_CFG_STATE_PTR( pAdapter ); |
Daram Sudha | 1f7e0e9 | 2013-12-17 07:52:31 +0530 | [diff] [blame] | 2835 | |
| 2836 | if ((type == SIR_MAC_MGMT_FRAME) && |
Wu Gao | 6518a29 | 2019-04-02 13:31:41 +0800 | [diff] [blame] | 2837 | (subType == SIR_MAC_MGMT_ACTION) && |
| 2838 | (nFrameLength > WLAN_HDD_PUBLIC_ACTION_FRAME_OFFSET + 1)) |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 2839 | { |
Hoonki Lee | 1090c6a | 2013-01-16 17:40:54 -0800 | [diff] [blame] | 2840 | if(pbFrames[WLAN_HDD_PUBLIC_ACTION_FRAME_OFFSET] == WLAN_HDD_PUBLIC_ACTION_FRAME) |
| 2841 | { |
| 2842 | // public action frame |
Wu Gao | 6518a29 | 2019-04-02 13:31:41 +0800 | [diff] [blame] | 2843 | if((WLAN_HDD_PUBLIC_ACTION_FRAME_OFFSET + SIR_MAC_P2P_OUI_SIZE + 2 < |
| 2844 | nFrameLength) && |
| 2845 | (pbFrames[WLAN_HDD_PUBLIC_ACTION_FRAME_OFFSET+1] == |
| 2846 | SIR_MAC_ACTION_VENDOR_SPECIFIC) && |
Sudhir Sattayappa Kohalli | c823980 | 2013-02-22 18:46:44 -0800 | [diff] [blame] | 2847 | vos_mem_compare(&pbFrames[WLAN_HDD_PUBLIC_ACTION_FRAME_OFFSET+2], SIR_MAC_P2P_OUI, SIR_MAC_P2P_OUI_SIZE)) |
Hoonki Lee | 1090c6a | 2013-01-16 17:40:54 -0800 | [diff] [blame] | 2848 | // P2P action frames |
| 2849 | { |
| 2850 | actionFrmType = pbFrames[WLAN_HDD_PUBLIC_ACTION_FRAME_TYPE_OFFSET]; |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 2851 | hddLog(LOG1, "Rx Action Frame %u", actionFrmType); |
Madan Mohan Koyyalamudi | 26bd714 | 2012-10-30 18:14:19 -0700 | [diff] [blame] | 2852 | #ifdef WLAN_FEATURE_P2P_DEBUG |
Hoonki Lee | 1090c6a | 2013-01-16 17:40:54 -0800 | [diff] [blame] | 2853 | if(actionFrmType >= MAX_P2P_ACTION_FRAME_TYPE) |
| 2854 | { |
| 2855 | hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P] unknown[%d] <--- OTA", |
| 2856 | actionFrmType); |
| 2857 | } |
| 2858 | else |
| 2859 | { |
| 2860 | hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P] %s <--- OTA", |
| 2861 | p2p_action_frame_type[actionFrmType]); |
| 2862 | if( (actionFrmType == WLAN_HDD_PROV_DIS_REQ) && |
| 2863 | (globalP2PConnectionStatus == P2P_NOT_ACTIVE) ) |
| 2864 | { |
| 2865 | globalP2PConnectionStatus = P2P_GO_NEG_PROCESS; |
| 2866 | hddLog(LOGE,"[P2P State]Inactive state to " |
Jeff Johnson | 1250df4 | 2012-12-10 14:31:52 -0800 | [diff] [blame] | 2867 | "GO negotiation progress state"); |
Hoonki Lee | 1090c6a | 2013-01-16 17:40:54 -0800 | [diff] [blame] | 2868 | } |
| 2869 | else if( (actionFrmType == WLAN_HDD_GO_NEG_CNF) && |
| 2870 | (globalP2PConnectionStatus == P2P_GO_NEG_PROCESS) ) |
| 2871 | { |
| 2872 | globalP2PConnectionStatus = P2P_GO_NEG_COMPLETED; |
Jeff Johnson | 1250df4 | 2012-12-10 14:31:52 -0800 | [diff] [blame] | 2873 | hddLog(LOGE,"[P2P State]GO negotiation progress to " |
| 2874 | "GO negotiation completed state"); |
Hoonki Lee | 1090c6a | 2013-01-16 17:40:54 -0800 | [diff] [blame] | 2875 | } |
| 2876 | else if( (actionFrmType == WLAN_HDD_INVITATION_REQ) && |
| 2877 | (globalP2PConnectionStatus == P2P_NOT_ACTIVE) ) |
| 2878 | { |
| 2879 | globalP2PConnectionStatus = P2P_GO_NEG_COMPLETED; |
| 2880 | hddLog(LOGE,"[P2P State]Inactive state to GO negotiation" |
| 2881 | " completed state Autonomous GO formation"); |
| 2882 | } |
| 2883 | } |
| 2884 | #endif |
Deepthi Gowri | 0637d59 | 2015-09-16 12:34:02 +0530 | [diff] [blame] | 2885 | mutex_lock(&pHddCtx->roc_lock); |
| 2886 | pRemainChanCtx = cfgState->remain_on_chan_ctx; |
| 2887 | |
Kaushik, Sushant | 7005e37 | 2014-04-08 11:36:54 +0530 | [diff] [blame] | 2888 | if (pRemainChanCtx != NULL && VOS_TIMER_STATE_RUNNING |
| 2889 | == vos_timer_getCurrentState(&pRemainChanCtx->hdd_remain_on_chan_timer)) |
| 2890 | { |
| 2891 | if ( actionFrmType == WLAN_HDD_GO_NEG_REQ || |
| 2892 | actionFrmType == WLAN_HDD_GO_NEG_RESP || |
| 2893 | actionFrmType == WLAN_HDD_INVITATION_REQ || |
| 2894 | actionFrmType == WLAN_HDD_DEV_DIS_REQ || |
| 2895 | actionFrmType == WLAN_HDD_PROV_DIS_REQ ) |
| 2896 | { |
| 2897 | hddLog( LOG1, "Extend RoC timer on reception of" |
| 2898 | " Action Frame"); |
| 2899 | if ((actionFrmType == WLAN_HDD_GO_NEG_REQ) |
| 2900 | || (actionFrmType == WLAN_HDD_GO_NEG_RESP)) |
| 2901 | extend_time = 2 * ACTION_FRAME_DEFAULT_WAIT; |
| 2902 | else |
| 2903 | extend_time = ACTION_FRAME_DEFAULT_WAIT; |
| 2904 | if (completion_done(&pAdapter->rem_on_chan_ready_event)) |
| 2905 | { |
Deepthi Gowri | f41ac8f | 2016-05-12 16:36:00 +0530 | [diff] [blame] | 2906 | if(!VOS_IS_STATUS_SUCCESS(vos_timer_stop( |
| 2907 | &pRemainChanCtx->hdd_remain_on_chan_timer))) |
| 2908 | { |
| 2909 | hddLog( LOGE, FL( |
| 2910 | "Failed to stop hdd_remain_on_chan_timer")); |
| 2911 | } |
Kaushik, Sushant | 7005e37 | 2014-04-08 11:36:54 +0530 | [diff] [blame] | 2912 | status = vos_timer_start( |
| 2913 | &pRemainChanCtx->hdd_remain_on_chan_timer, |
| 2914 | extend_time); |
| 2915 | if (status != VOS_STATUS_SUCCESS) |
| 2916 | { |
| 2917 | hddLog( LOGE, "ROC timer start failed"); |
| 2918 | } |
| 2919 | } |
| 2920 | else |
| 2921 | { |
| 2922 | // Buffer Packet |
| 2923 | if (pRemainChanCtx->action_pkt_buff.frame_length == 0) |
| 2924 | { |
| 2925 | pRemainChanCtx->action_pkt_buff.frame_length = |
| 2926 | nFrameLength; |
| 2927 | pRemainChanCtx->action_pkt_buff.freq = freq; |
| 2928 | pRemainChanCtx->action_pkt_buff.frame_ptr |
| 2929 | = vos_mem_malloc(nFrameLength); |
| 2930 | vos_mem_copy( |
| 2931 | pRemainChanCtx->action_pkt_buff.frame_ptr, |
| 2932 | pbFrames, nFrameLength); |
| 2933 | hddLog( LOGE,"%s:" |
| 2934 | "Action Pkt Cached successfully !!!", __func__); |
| 2935 | } |
| 2936 | else |
| 2937 | { |
| 2938 | hddLog( LOGE,"%s:" |
| 2939 | "Frames are pending. dropping frame !!!", |
| 2940 | __func__); |
| 2941 | } |
Deepthi Gowri | 0637d59 | 2015-09-16 12:34:02 +0530 | [diff] [blame] | 2942 | mutex_unlock(&pHddCtx->roc_lock); |
Kaushik, Sushant | 7005e37 | 2014-04-08 11:36:54 +0530 | [diff] [blame] | 2943 | return; |
| 2944 | } |
| 2945 | } |
| 2946 | } |
| 2947 | if (pRemainChanCtx != NULL && |
Deepthi Gowri | 12e2dae | 2015-12-07 17:32:09 +0530 | [diff] [blame] | 2948 | vos_timer_is_initialized( |
| 2949 | &cfgState->remain_on_chan_ctx->hdd_remain_on_chan_timer) && |
Kaushik, Sushant | 7005e37 | 2014-04-08 11:36:54 +0530 | [diff] [blame] | 2950 | VOS_TIMER_STATE_RUNNING != vos_timer_getCurrentState( |
| 2951 | &cfgState->remain_on_chan_ctx->hdd_remain_on_chan_timer)) |
| 2952 | hddLog( LOG1, "%s:" |
| 2953 | "Rcvd action frame after timer expired ", __func__); |
| 2954 | |
Deepthi Gowri | 0637d59 | 2015-09-16 12:34:02 +0530 | [diff] [blame] | 2955 | mutex_unlock(&pHddCtx->roc_lock); |
| 2956 | |
Kaushik, Sushant | 7005e37 | 2014-04-08 11:36:54 +0530 | [diff] [blame] | 2957 | if (((actionFrmType == WLAN_HDD_PROV_DIS_RESP) && |
| 2958 | (cfgState->actionFrmState == HDD_PD_REQ_ACK_PENDING)) || |
| 2959 | ((actionFrmType == WLAN_HDD_GO_NEG_RESP) && |
| 2960 | (cfgState->actionFrmState == HDD_GO_NEG_REQ_ACK_PENDING))) |
| 2961 | { |
Deepthi Gowri | 0637d59 | 2015-09-16 12:34:02 +0530 | [diff] [blame] | 2962 | hddLog(LOG1, "%s: ACK_PENDING and But received RESP for Action frame ", |
Kaushik, Sushant | 7005e37 | 2014-04-08 11:36:54 +0530 | [diff] [blame] | 2963 | __func__); |
Deepthi Gowri | 108809c | 2016-06-16 18:04:24 +0530 | [diff] [blame] | 2964 | cfgState->is_go_neg_ack_received = 1; |
| 2965 | |
Deepthi Gowri | 0637d59 | 2015-09-16 12:34:02 +0530 | [diff] [blame] | 2966 | hdd_sendActionCnf(pAdapter, TRUE); |
| 2967 | } |
Madan Mohan Koyyalamudi | 26bd714 | 2012-10-30 18:14:19 -0700 | [diff] [blame] | 2968 | } |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 2969 | #ifdef FEATURE_WLAN_TDLS |
Hoonki Lee | 1090c6a | 2013-01-16 17:40:54 -0800 | [diff] [blame] | 2970 | else if(pbFrames[WLAN_HDD_PUBLIC_ACTION_FRAME_OFFSET+1] == WLAN_HDD_PUBLIC_ACTION_TDLS_DISC_RESP) |
Madan Mohan Koyyalamudi | 26bd714 | 2012-10-30 18:14:19 -0700 | [diff] [blame] | 2971 | { |
Shailender Karmuchi | 13c0d08 | 2013-03-26 14:41:39 -0700 | [diff] [blame] | 2972 | u8 *mac = &pbFrames[WLAN_HDD_80211_FRM_DA_OFFSET+6]; |
Masti, Narayanraddi | 34e0e56 | 2015-03-05 18:23:03 +0530 | [diff] [blame] | 2973 | hddLog(VOS_TRACE_LEVEL_INFO,"[TDLS] TDLS Discovery Response," MAC_ADDRESS_STR " RSSI[%d] <--- OTA", |
Shailender Karmuchi | 13c0d08 | 2013-03-26 14:41:39 -0700 | [diff] [blame] | 2974 | MAC_ADDR_ARRAY(mac),rxRssi); |
Masti, Narayanraddi | 34e0e56 | 2015-03-05 18:23:03 +0530 | [diff] [blame] | 2975 | |
Shailender Karmuchi | 13c0d08 | 2013-03-26 14:41:39 -0700 | [diff] [blame] | 2976 | wlan_hdd_tdls_set_rssi(pAdapter, mac, rxRssi); |
| 2977 | wlan_hdd_tdls_recv_discovery_resp(pAdapter, mac); |
Hoonki Lee | 1090c6a | 2013-01-16 17:40:54 -0800 | [diff] [blame] | 2978 | } |
| 2979 | #endif |
| 2980 | } |
Kaushik, Sushant | 507a861 | 2014-10-21 17:00:55 +0530 | [diff] [blame] | 2981 | |
| 2982 | pScanInfo = &pHddCtx->scan_info; |
| 2983 | if ((pScanInfo != NULL) && (pHddCtx->scan_info.mScanPending)) |
| 2984 | { |
| 2985 | hddLog(LOGE,"Action frame received when Scanning is in" |
| 2986 | " progress. Abort Scan."); |
| 2987 | hdd_abort_mac_scan(pAdapter->pHddCtx, |
| 2988 | pScanInfo->sessionId, |
| 2989 | eCSR_SCAN_ABORT_DEFAULT); |
| 2990 | } |
Masti, Narayanraddi | 34e0e56 | 2015-03-05 18:23:03 +0530 | [diff] [blame] | 2991 | |
Hoonki Lee | 1090c6a | 2013-01-16 17:40:54 -0800 | [diff] [blame] | 2992 | if(pbFrames[WLAN_HDD_PUBLIC_ACTION_FRAME_OFFSET] == WLAN_HDD_TDLS_ACTION_FRAME) |
| 2993 | { |
| 2994 | actionFrmType = pbFrames[WLAN_HDD_PUBLIC_ACTION_FRAME_OFFSET+1]; |
| 2995 | if(actionFrmType >= MAX_TDLS_ACTION_FRAME_TYPE) |
| 2996 | { |
Masti, Narayanraddi | 34e0e56 | 2015-03-05 18:23:03 +0530 | [diff] [blame] | 2997 | hddLog(VOS_TRACE_LEVEL_INFO,"[TDLS] Action type[%d] <--- OTA", |
Hoonki Lee | 1090c6a | 2013-01-16 17:40:54 -0800 | [diff] [blame] | 2998 | actionFrmType); |
| 2999 | } |
| 3000 | else |
| 3001 | { |
Masti, Narayanraddi | 34e0e56 | 2015-03-05 18:23:03 +0530 | [diff] [blame] | 3002 | hddLog(VOS_TRACE_LEVEL_INFO,"[TDLS] %s <--- OTA", |
Hoonki Lee | 1090c6a | 2013-01-16 17:40:54 -0800 | [diff] [blame] | 3003 | tdls_action_frame_type[actionFrmType]); |
Madan Mohan Koyyalamudi | 26bd714 | 2012-10-30 18:14:19 -0700 | [diff] [blame] | 3004 | } |
Abhishek Singh | 888420b | 2016-01-06 12:28:03 +0530 | [diff] [blame] | 3005 | vos_tdls_tx_rx_mgmt_event(SIR_MAC_ACTION_TDLS, |
| 3006 | SIR_MAC_ACTION_RX, SIR_MAC_MGMT_ACTION, |
| 3007 | actionFrmType, &pbFrames[WLAN_HDD_80211_FRM_DA_OFFSET+6]); |
Madan Mohan Koyyalamudi | 26bd714 | 2012-10-30 18:14:19 -0700 | [diff] [blame] | 3008 | } |
Masti, Narayanraddi | 34e0e56 | 2015-03-05 18:23:03 +0530 | [diff] [blame] | 3009 | |
Leela Venkata Kiran Kumar Reddy Chirala | 8e69fbc | 2013-10-30 18:51:13 -0700 | [diff] [blame] | 3010 | if((pbFrames[WLAN_HDD_PUBLIC_ACTION_FRAME_OFFSET] == WLAN_HDD_QOS_ACTION_FRAME)&& |
| 3011 | (pbFrames[WLAN_HDD_PUBLIC_ACTION_FRAME_OFFSET+1] == WLAN_HDD_QOS_MAP_CONFIGURE) ) |
| 3012 | { |
Kumar Anand | 82c009f | 2014-05-29 00:29:42 -0700 | [diff] [blame] | 3013 | sme_UpdateDSCPtoUPMapping(pHddCtx->hHal, |
| 3014 | pAdapter->hddWmmDscpToUpMap, pAdapter->sessionId); |
Leela Venkata Kiran Kumar Reddy Chirala | 8e69fbc | 2013-10-30 18:51:13 -0700 | [diff] [blame] | 3015 | } |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 3016 | } |
| 3017 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3018 | //Indicate Frame Over Normal Interface |
| 3019 | hddLog( LOG1, FL("Indicate Frame over NL80211 Interface")); |
Anand N Sunkad | 7bfc8e4 | 2015-07-29 09:59:45 +0530 | [diff] [blame] | 3020 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0)) |
yeshwanth sriram guntuka | bbdd77c | 2017-05-02 12:49:53 +0530 | [diff] [blame] | 3021 | cfg80211_rx_mgmt(pAdapter->dev->ieee80211_ptr, freq, rxRssi * 100, pbFrames, |
Anand N Sunkad | 7bfc8e4 | 2015-07-29 09:59:45 +0530 | [diff] [blame] | 3022 | nFrameLength, NL80211_RXMGMT_FLAG_ANSWERED); |
| 3023 | #elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3,12,0)) |
yeshwanth sriram guntuka | bbdd77c | 2017-05-02 12:49:53 +0530 | [diff] [blame] | 3024 | cfg80211_rx_mgmt(pAdapter->dev->ieee80211_ptr, freq, rxRssi * 100, pbFrames, |
Anand N Sunkad | e9adb1b | 2015-07-29 09:56:45 +0530 | [diff] [blame] | 3025 | nFrameLength, NL80211_RXMGMT_FLAG_ANSWERED, GFP_ATOMIC); |
| 3026 | #elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0)) |
yeshwanth sriram guntuka | bbdd77c | 2017-05-02 12:49:53 +0530 | [diff] [blame] | 3027 | cfg80211_rx_mgmt( pAdapter->dev->ieee80211_ptr, freq, rxRssi * 100, |
Jeff Johnson | 3bbe4bf | 2013-01-18 17:05:29 -0800 | [diff] [blame] | 3028 | pbFrames, nFrameLength, |
| 3029 | GFP_ATOMIC ); |
| 3030 | #elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0)) |
yeshwanth sriram guntuka | bbdd77c | 2017-05-02 12:49:53 +0530 | [diff] [blame] | 3031 | cfg80211_rx_mgmt( pAdapter->dev, freq, rxRssi * 100, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3032 | pbFrames, nFrameLength, |
| 3033 | GFP_ATOMIC ); |
| 3034 | #else |
| 3035 | cfg80211_rx_mgmt( pAdapter->dev, freq, |
| 3036 | pbFrames, nFrameLength, |
| 3037 | GFP_ATOMIC ); |
| 3038 | #endif //LINUX_VERSION_CODE |
| 3039 | } |
| 3040 | |
| 3041 | /* |
| 3042 | * ieee80211_add_rx_radiotap_header - add radiotap header |
| 3043 | */ |
| 3044 | static int hdd_wlan_add_rx_radiotap_hdr ( |
| 3045 | struct sk_buff *skb, int rtap_len, int flag ) |
| 3046 | { |
| 3047 | u8 rtap_temp[20] = {0}; |
| 3048 | struct ieee80211_radiotap_header *rthdr; |
| 3049 | unsigned char *pos; |
| 3050 | u16 rx_flags = 0; |
| 3051 | |
| 3052 | rthdr = (struct ieee80211_radiotap_header *)(&rtap_temp[0]); |
| 3053 | |
| 3054 | /* radiotap header, set always present flags */ |
| 3055 | rthdr->it_present = cpu_to_le32((1 << IEEE80211_RADIOTAP_FLAGS) | |
| 3056 | (1 << IEEE80211_RADIOTAP_RX_FLAGS)); |
| 3057 | rthdr->it_len = cpu_to_le16(rtap_len); |
| 3058 | |
| 3059 | pos = (unsigned char *) (rthdr + 1); |
| 3060 | |
| 3061 | /* the order of the following fields is important */ |
| 3062 | |
| 3063 | /* IEEE80211_RADIOTAP_FLAGS */ |
| 3064 | *pos = 0; |
| 3065 | pos++; |
| 3066 | |
| 3067 | /* IEEE80211_RADIOTAP_RX_FLAGS: Length 2 Bytes */ |
| 3068 | /* ensure 2 byte alignment for the 2 byte field as required */ |
| 3069 | if ((pos - (u8 *)rthdr) & 1) |
| 3070 | pos++; |
| 3071 | put_unaligned_le16(rx_flags, pos); |
| 3072 | pos += 2; |
Daram Sudha | 1f7e0e9 | 2013-12-17 07:52:31 +0530 | [diff] [blame] | 3073 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3074 | // actually push the data |
| 3075 | memcpy(skb_push(skb, rtap_len), &rtap_temp[0], rtap_len); |
| 3076 | |
| 3077 | return 0; |
| 3078 | } |
| 3079 | |
| 3080 | static void hdd_wlan_tx_complete( hdd_adapter_t* pAdapter, |
| 3081 | hdd_cfg80211_state_t* cfgState, |
| 3082 | tANI_BOOLEAN actionSendSuccess ) |
| 3083 | { |
| 3084 | struct ieee80211_radiotap_header *rthdr; |
| 3085 | unsigned char *pos; |
| 3086 | struct sk_buff *skb = cfgState->skb; |
Sameer Thalappil | 50dc009 | 2013-02-19 17:23:33 -0800 | [diff] [blame] | 3087 | #ifdef WLAN_OPEN_SOURCE |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 3088 | #ifdef WLAN_FEATURE_HOLD_RX_WAKELOCK |
| 3089 | hdd_context_t *pHddCtx = (hdd_context_t*)(pAdapter->pHddCtx); |
| 3090 | #endif |
Sameer Thalappil | 50dc009 | 2013-02-19 17:23:33 -0800 | [diff] [blame] | 3091 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3092 | |
| 3093 | /* 2 Byte for TX flags and 1 Byte for Retry count */ |
| 3094 | u32 rtHdrLen = sizeof(*rthdr) + 3; |
| 3095 | |
| 3096 | u8 *data; |
| 3097 | |
| 3098 | /* We have to return skb with Data starting with MAC header. We have |
| 3099 | * copied SKB data starting with MAC header to cfgState->buf. We will pull |
| 3100 | * entire skb->len from skb and then we will push cfgState->buf to skb |
| 3101 | * */ |
| 3102 | if( NULL == skb_pull(skb, skb->len) ) |
| 3103 | { |
| 3104 | hddLog( LOGE, FL("Not Able to Pull %d byte from skb"), skb->len); |
| 3105 | kfree_skb(cfgState->skb); |
| 3106 | return; |
| 3107 | } |
| 3108 | |
| 3109 | data = skb_push( skb, cfgState->len ); |
| 3110 | |
| 3111 | if (data == NULL) |
| 3112 | { |
Jeff Johnson | 59a121e | 2013-11-30 09:46:08 -0800 | [diff] [blame] | 3113 | hddLog( LOGE, FL("Not Able to Push %zu byte to skb"), cfgState->len); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3114 | kfree_skb( cfgState->skb ); |
| 3115 | return; |
| 3116 | } |
| 3117 | |
| 3118 | memcpy( data, cfgState->buf, cfgState->len ); |
| 3119 | |
| 3120 | /* send frame to monitor interfaces now */ |
| 3121 | if( skb_headroom(skb) < rtHdrLen ) |
| 3122 | { |
| 3123 | hddLog( LOGE, FL("No headroom for rtap header")); |
| 3124 | kfree_skb(cfgState->skb); |
| 3125 | return; |
| 3126 | } |
| 3127 | |
| 3128 | rthdr = (struct ieee80211_radiotap_header*) skb_push( skb, rtHdrLen ); |
| 3129 | |
| 3130 | memset( rthdr, 0, rtHdrLen ); |
| 3131 | rthdr->it_len = cpu_to_le16( rtHdrLen ); |
| 3132 | rthdr->it_present = cpu_to_le32((1 << IEEE80211_RADIOTAP_TX_FLAGS) | |
| 3133 | (1 << IEEE80211_RADIOTAP_DATA_RETRIES) |
| 3134 | ); |
| 3135 | |
| 3136 | pos = (unsigned char *)( rthdr+1 ); |
| 3137 | |
| 3138 | // Fill TX flags |
| 3139 | *pos = actionSendSuccess; |
| 3140 | pos += 2; |
| 3141 | |
| 3142 | // Fill retry count |
| 3143 | *pos = 0; |
| 3144 | pos++; |
| 3145 | |
| 3146 | skb_set_mac_header( skb, 0 ); |
Madan Mohan Koyyalamudi | f91902f | 2012-10-25 11:59:19 -0700 | [diff] [blame] | 3147 | skb->ip_summed = CHECKSUM_NONE; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3148 | skb->pkt_type = PACKET_OTHERHOST; |
| 3149 | skb->protocol = htons(ETH_P_802_2); |
| 3150 | memset( skb->cb, 0, sizeof( skb->cb ) ); |
Sameer Thalappil | 50dc009 | 2013-02-19 17:23:33 -0800 | [diff] [blame] | 3151 | #ifdef WLAN_OPEN_SOURCE |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 3152 | #ifdef WLAN_FEATURE_HOLD_RX_WAKELOCK |
Sushant Kaushik | 83392fa | 2015-05-05 17:44:40 +0530 | [diff] [blame] | 3153 | vos_wake_lock_timeout_release(&pHddCtx->rx_wake_lock, |
| 3154 | HDD_WAKE_LOCK_DURATION, |
| 3155 | WIFI_POWER_EVENT_WAKELOCK_HOLD_RX); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 3156 | #endif |
Sameer Thalappil | 50dc009 | 2013-02-19 17:23:33 -0800 | [diff] [blame] | 3157 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3158 | if (in_interrupt()) |
| 3159 | netif_rx( skb ); |
| 3160 | else |
| 3161 | netif_rx_ni( skb ); |
| 3162 | |
| 3163 | /* Enable Queues which we have disabled earlier */ |
Padma, Santhosh Kumar | 9dacb5c | 2014-12-17 19:22:56 +0530 | [diff] [blame] | 3164 | hddLog(VOS_TRACE_LEVEL_INFO, FL("Enabling queues")); |
Gopichand Nakkala | 8c0386c | 2013-07-09 23:31:37 +0530 | [diff] [blame] | 3165 | netif_tx_start_all_queues( pAdapter->dev ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3166 | |
| 3167 | } |
Gopichand Nakkala | 8c0386c | 2013-07-09 23:31:37 +0530 | [diff] [blame] | 3168 | |
Mahesh A Saptasagar | e5440c7 | 2015-01-28 21:21:07 +0530 | [diff] [blame] | 3169 | void __hdd_p2p_roc_work_queue(struct work_struct *work) |
Ganesh Kondabattini | babfb49 | 2014-12-17 20:25:29 +0530 | [diff] [blame] | 3170 | { |
| 3171 | hdd_adapter_t *pAdapter = container_of(to_delayed_work(work), hdd_adapter_t, roc_work); |
| 3172 | hddLog( VOS_TRACE_LEVEL_INFO, FL("%s: "), __func__); |
| 3173 | wlan_hdd_p2p_start_remain_on_channel(pAdapter); |
| 3174 | return; |
| 3175 | } |
| 3176 | |
Mahesh A Saptasagar | e5440c7 | 2015-01-28 21:21:07 +0530 | [diff] [blame] | 3177 | void hdd_p2p_roc_work_queue(struct work_struct *work) |
| 3178 | { |
| 3179 | vos_ssr_protect(__func__); |
| 3180 | __hdd_p2p_roc_work_queue(work); |
| 3181 | vos_ssr_unprotect(__func__); |
| 3182 | return; |
| 3183 | } |