blob: 3dfc11b7977476aa680d2e41c20385b9e17e565e [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Kapil Gupta956c0c42017-06-16 19:24:31 +05302 * Copyright (c) 2011-2017 The Linux Foundation. All rights reserved.
Kiet Lam842dad02014-02-18 18:44:02 -08003 *
4 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
5 *
6 *
7 * Permission to use, copy, modify, and/or distribute this software for
8 * any purpose with or without fee is hereby granted, provided that the
9 * above copyright notice and this permission notice appear in all
10 * copies.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
13 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
14 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
15 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
16 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
17 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
18 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19 * PERFORMANCE OF THIS SOFTWARE.
20 */
21
22/*
Kiet Lama7f454d2014-07-24 12:04:06 -070023 * This file was originally distributed by Qualcomm Atheros, Inc.
24 * under proprietary terms before Copyright ownership was assigned
25 * to the Linux Foundation.
Jeff Johnson295189b2012-06-20 16:38:30 -070026 */
Kiet Lam842dad02014-02-18 18:44:02 -080027
28
Kiet Lama7f454d2014-07-24 12:04:06 -070029
30
Jeff Johnson295189b2012-06-20 16:38:30 -070031/**
32 * \file limSendManagementFrames.c
33 *
34 * \brief Code for preparing and sending 802.11 Management frames
35 *
Kiet Lam842dad02014-02-18 18:44:02 -080036
Jeff Johnson295189b2012-06-20 16:38:30 -070037 *
38 */
39
40#include "sirApi.h"
41#include "aniGlobal.h"
42#include "sirMacProtDef.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070043#include "cfgApi.h"
44#include "utilsApi.h"
45#include "limTypes.h"
46#include "limUtils.h"
47#include "limSecurityUtils.h"
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -070048#include "limPropExtsUtils.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070049#include "dot11f.h"
50#include "limStaHashApi.h"
51#include "schApi.h"
52#include "limSendMessages.h"
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -080053#include "limAssocUtils.h"
54#include "limFT.h"
Chet Lanctot8cecea22014-02-11 19:09:36 -080055#ifdef WLAN_FEATURE_11W
Satyanarayana Dash6f438272015-03-03 18:01:06 +053056#include "wniCfg.h"
Chet Lanctot8cecea22014-02-11 19:09:36 -080057#endif
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -080058
Jeff Johnson295189b2012-06-20 16:38:30 -070059#if defined WLAN_FEATURE_VOWIFI
60#include "rrmApi.h"
61#endif
62
Jeff Johnson295189b2012-06-20 16:38:30 -070063#include "wlan_qct_wda.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070064
Masti, Narayanraddi67ea5912015-01-08 12:34:05 +053065#define IS_BROADCAST_MAC(x) (((x[0] & x[1] & x[2] & x[3] & x[4] & x[5]) == 0xff) ? 1 : 0)
Jeff Johnson295189b2012-06-20 16:38:30 -070066////////////////////////////////////////////////////////////////////////
67
Kalikinkar dhara205da782014-03-21 15:49:32 -070068tSirRetStatus limStripOffExtCapIE(tpAniSirGlobal pMac,
69 tANI_U8 *addIE,
70 tANI_U16 *addnIELen,
71 tANI_U8 *pExtractedExtCapIEBuf )
72{
73 tANI_U8* tempbuf = NULL;
74 tANI_U16 tempLen = 0;
75 int left = *addnIELen;
76 tANI_U8 *ptr = addIE;
77 tANI_U8 elem_id, elem_len;
78
79 if (NULL == addIE)
80 {
81 PELOGE(limLog(pMac, LOG1, FL("NULL addIE pointer"));)
82 return eSIR_IGNORE_IE ;
83 }
84
85 tempbuf = vos_mem_malloc(left);
86 if ( NULL == tempbuf )
87 {
88 PELOGE(limLog(pMac, LOGE,
89 FL("Unable to allocate memory to store addn IE"));)
90 return eSIR_MEM_ALLOC_FAILED;
91 }
92
93 while(left >= 2)
94 {
95 elem_id = ptr[0];
96 elem_len = ptr[1];
97 left -= 2;
98 if (elem_len > left)
99 {
100 limLog( pMac, LOGE,
101 FL("Invalid IEs eid = %d elem_len=%d left=%d"),
102 elem_id,elem_len,left);
103 vos_mem_free(tempbuf);
104 return eSIR_FAILURE;
105 }
106 if ( !(DOT11F_EID_EXTCAP == elem_id) )
107 {
108 vos_mem_copy (tempbuf + tempLen, &ptr[0], elem_len + 2);
109 tempLen += (elem_len + 2);
110 }
111 else
Hu Wangc12631c2016-08-11 09:57:03 +0800112 {
Kalikinkar dhara205da782014-03-21 15:49:32 -0700113 if ( NULL != pExtractedExtCapIEBuf )
114 {
115 vos_mem_set(pExtractedExtCapIEBuf,
116 DOT11F_IE_EXTCAP_MAX_LEN + 2, 0);
117 if (elem_len <= DOT11F_IE_EXTCAP_MAX_LEN )
118 {
119 vos_mem_copy (pExtractedExtCapIEBuf, &ptr[0],
120 elem_len + 2);
121 }
122 }
123 }
124 left -= elem_len;
125 ptr += (elem_len + 2);
126 }
127 vos_mem_copy (addIE, tempbuf, tempLen);
128 *addnIELen = tempLen;
129 vos_mem_free(tempbuf);
130 return eSIR_SUCCESS;
131}
132
133void limUpdateExtCapIEtoStruct(tpAniSirGlobal pMac,
134 tANI_U8 *pBuf,
135 tDot11fIEExtCap *pDst)
136{
137 tANI_U8 pOut[DOT11F_IE_EXTCAP_MAX_LEN];
Hu Wangc12631c2016-08-11 09:57:03 +0800138 tANI_U8 tag, len, *val;
Kalikinkar dhara205da782014-03-21 15:49:32 -0700139
140 if ( NULL == pBuf )
141 {
142 limLog( pMac, LOGE,
143 FL("Invalid Buffer Address"));
144 return;
145 }
146 if(NULL == pDst)
147 {
148 PELOGE(limLog(pMac, LOGE,
149 FL("NULL pDst pointer"));)
150 return ;
151 }
152
Hu Wangc12631c2016-08-11 09:57:03 +0800153 /* Get tlv */
154 tag = pBuf[0];
155 len = pBuf[1];
156 val = &pBuf[2];
157
158 if ( DOT11F_EID_EXTCAP != tag ||
159 len > DOT11F_IE_EXTCAP_MAX_LEN )
Kalikinkar dhara205da782014-03-21 15:49:32 -0700160 {
Mahesh A Saptasagare00ff532014-10-17 19:05:14 +0530161 limLog( pMac, LOG1,
Hu Wangc12631c2016-08-11 09:57:03 +0800162 FL("Invalid IEs eid = %d elem_len=%d "), tag, len);
Kalikinkar dhara205da782014-03-21 15:49:32 -0700163 return;
164 }
Kalikinkar dhara205da782014-03-21 15:49:32 -0700165
Hu Wangc12631c2016-08-11 09:57:03 +0800166 vos_mem_zero(pOut, DOT11F_IE_EXTCAP_MAX_LEN);
167 vos_mem_copy(pOut, val, len);
Kalikinkar dhara205da782014-03-21 15:49:32 -0700168 if ( DOT11F_PARSE_SUCCESS != dot11fUnpackIeExtCap( pMac,
Hu Wangc12631c2016-08-11 09:57:03 +0800169 pOut, len, pDst) )
Kalikinkar dhara205da782014-03-21 15:49:32 -0700170 {
171 limLog( pMac, LOGE,
172 FL("dot11fUnpackIeExtCap Parse Error "));
173 }
174}
175
176tSirRetStatus limStripOffExtCapIEAndUpdateStruct(tpAniSirGlobal pMac,
177 tANI_U8* addIE,
178 tANI_U16 *addnIELen,
179 tDot11fIEExtCap * pDst )
180{
181 tANI_U8 pExtractedExtCapIEBuf[DOT11F_IE_EXTCAP_MAX_LEN + 2];
182 tSirRetStatus nSirStatus;
183
184 vos_mem_set(( tANI_U8* )&pExtractedExtCapIEBuf[0],
185 DOT11F_IE_EXTCAP_MAX_LEN + 2, 0);
186 nSirStatus = limStripOffExtCapIE(pMac, addIE, addnIELen,
187 pExtractedExtCapIEBuf);
188 if ( eSIR_SUCCESS != nSirStatus )
189 {
190 limLog( pMac, LOG1, FL("Failed to strip off in"
191 "limStripOffExtCapIE status = (%d)."),
192 nSirStatus );
193 return nSirStatus;
194 }
195 /* update the extracted ExtCap to struct*/
196 limUpdateExtCapIEtoStruct(pMac, pExtractedExtCapIEBuf, pDst);
197 return nSirStatus;
198}
199
200void limMergeExtCapIEStruct(tDot11fIEExtCap *pDst,
Hu Wang5193b572016-08-11 10:04:47 +0800201 tDot11fIEExtCap *pSrc,
202 bool add)
Kalikinkar dhara205da782014-03-21 15:49:32 -0700203{
Hu Wang5193b572016-08-11 10:04:47 +0800204 tANI_U8 *tempDst = (tANI_U8 *)pDst->bytes;
205 tANI_U8 *tempSrc = (tANI_U8 *)pSrc->bytes;
206 tANI_U8 structlen = DOT11F_IE_EXTCAP_MAX_LEN;
Kalikinkar dhara205da782014-03-21 15:49:32 -0700207
Hu Wang5193b572016-08-11 10:04:47 +0800208 // if src is not present, nothing to do
209 if(!pSrc->present) {
210 return;
211 }
212
213 // if dst is not present, and add=false, nothing to do
214 if (!pDst->present && !add) {
215 return;
216 }
217
218 // in other cases, need to merge the bits
219 pDst->present = 1;
Kalikinkar dhara205da782014-03-21 15:49:32 -0700220 while(tempDst && tempSrc && structlen--)
221 {
Hu Wang5193b572016-08-11 10:04:47 +0800222 if (add) {
223 *tempDst |= *tempSrc;
224 } else {
225 *tempDst &= *tempSrc;
226 }
Kalikinkar dhara205da782014-03-21 15:49:32 -0700227 tempDst++;
228 tempSrc++;
229 }
Hu Wangc12631c2016-08-11 09:57:03 +0800230 pDst->num_bytes = lim_compute_ext_cap_ie_length(pDst);
Hu Wang5193b572016-08-11 10:04:47 +0800231
232 // if all bits are zero, it means it is not prsent.
233 if (pDst->num_bytes == 0) {
234 pDst->present = 0;
235 }
Kalikinkar dhara205da782014-03-21 15:49:32 -0700236}
Jeff Johnson295189b2012-06-20 16:38:30 -0700237
238/**
239 *
240 * \brief This function is called by various LIM modules to prepare the
241 * 802.11 frame MAC header
242 *
243 *
244 * \param pMac Pointer to Global MAC structure
245 *
246 * \param pBD Pointer to the frame buffer that needs to be populate
247 *
248 * \param type Type of the frame
249 *
250 * \param subType Subtype of the frame
251 *
252 * \return eHalStatus
253 *
254 *
255 * The pFrameBuf argument points to the beginning of the frame buffer to
256 * which - a) The 802.11 MAC header is set b) Following this MAC header
257 * will be the MGMT frame payload The payload itself is populated by the
258 * caller API
259 *
260 *
261 */
262
263tSirRetStatus limPopulateMacHeader( tpAniSirGlobal pMac,
264 tANI_U8* pBD,
265 tANI_U8 type,
266 tANI_U8 subType,
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530267 tSirMacAddr peerAddr, tSirMacAddr selfMacAddr)
Jeff Johnson295189b2012-06-20 16:38:30 -0700268{
269 tSirRetStatus statusCode = eSIR_SUCCESS;
270 tpSirMacMgmtHdr pMacHdr;
271
272 /// Prepare MAC management header
273 pMacHdr = (tpSirMacMgmtHdr) (pBD);
274
275 // Prepare FC
276 pMacHdr->fc.protVer = SIR_MAC_PROTOCOL_VERSION;
277 pMacHdr->fc.type = type;
278 pMacHdr->fc.subType = subType;
279
280 // Prepare Address 1
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530281 vos_mem_copy( (tANI_U8 *) pMacHdr->da,
Jeff Johnson295189b2012-06-20 16:38:30 -0700282 (tANI_U8 *) peerAddr,
283 sizeof( tSirMacAddr ));
284
285 // Prepare Address 2
Jeff Johnson295189b2012-06-20 16:38:30 -0700286 sirCopyMacAddr(pMacHdr->sa,selfMacAddr);
287
288 // Prepare Address 3
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530289 vos_mem_copy( (tANI_U8 *) pMacHdr->bssId,
Jeff Johnson295189b2012-06-20 16:38:30 -0700290 (tANI_U8 *) peerAddr,
291 sizeof( tSirMacAddr ));
292 return statusCode;
293} /*** end limPopulateMacHeader() ***/
294
295/**
296 * \brief limSendProbeReqMgmtFrame
297 *
298 *
299 * \param pMac Pointer to Global MAC structure
300 *
301 * \param pSsid SSID to be sent in Probe Request frame
302 *
303 * \param bssid BSSID to be sent in Probe Request frame
304 *
305 * \param nProbeDelay probe delay to be used before sending Probe Request
306 * frame
307 *
308 * \param nChannelNum Channel # on which the Probe Request is going out
309 *
310 * \param nAdditionalIELen if non-zero, include pAdditionalIE in the Probe Request frame
311 *
312 * \param pAdditionalIE if nAdditionalIELen is non zero, include this field in the Probe Request frame
313 *
314 * This function is called by various LIM modules to send Probe Request frame
315 * during active scan/learn phase.
316 * Probe request is sent out in the following scenarios:
317 * --heartbeat failure: session needed
318 * --join req: session needed
319 * --foreground scan: no session
320 * --background scan: no session
321 * --schBeaconProcessing: to get EDCA parameters: session needed
322 *
323 *
324 */
325tSirRetStatus
326limSendProbeReqMgmtFrame(tpAniSirGlobal pMac,
327 tSirMacSSid *pSsid,
328 tSirMacAddr bssid,
329 tANI_U8 nChannelNum,
330 tSirMacAddr SelfMacAddr,
331 tANI_U32 dot11mode,
332 tANI_U32 nAdditionalIELen,
333 tANI_U8 *pAdditionalIE)
334{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +0530335 tDot11fProbeRequest pr;
336 tANI_U32 nStatus, nBytes, nPayload;
337 tSirRetStatus nSirStatus;
338 tANI_U8 *pFrame;
339 void *pPacket;
340 eHalStatus halstatus;
341 tpPESession psessionEntry;
342 tANI_U8 sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -0700343 tANI_U8 *p2pIe = NULL;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +0530344 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700345
346#ifndef GEN4_SCAN
347 return eSIR_FAILURE;
348#endif
349
350#if defined ( ANI_DVT_DEBUG )
351 return eSIR_FAILURE;
352#endif
353
Abhishek Singh4beed422014-02-03 16:47:17 +0530354 /* The probe req should not send 11ac capabilieties if band is 2.4GHz,
355 * unless enableVhtFor24GHz is enabled in INI. So if enableVhtFor24GHz
356 * is false and dot11mode is 11ac set it to 11n.
357 */
358 if ( nChannelNum <= SIR_11B_CHANNEL_END &&
359 ( FALSE == pMac->roam.configParam.enableVhtFor24GHz ) &&
360 ( WNI_CFG_DOT11_MODE_11AC == dot11mode ||
361 WNI_CFG_DOT11_MODE_11AC_ONLY == dot11mode ) )
362 dot11mode = WNI_CFG_DOT11_MODE_11N;
Jeff Johnson295189b2012-06-20 16:38:30 -0700363 /*
364 * session context may or may not be present, when probe request needs to be sent out.
365 * following cases exist:
366 * --heartbeat failure: session needed
367 * --join req: session needed
368 * --foreground scan: no session
369 * --background scan: no session
370 * --schBeaconProcessing: to get EDCA parameters: session needed
371 * If session context does not exist, some IEs will be populated from CFGs,
372 * e.g. Supported and Extended rate set IEs
373 */
374 psessionEntry = peFindSessionByBssid(pMac,bssid,&sessionId);
375
376 // The scheme here is to fill out a 'tDot11fProbeRequest' structure
377 // and then hand it off to 'dot11fPackProbeRequest' (for
378 // serialization). We start by zero-initializing the structure:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530379 vos_mem_set(( tANI_U8* )&pr, sizeof( pr ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700380
381 // & delegating to assorted helpers:
382 PopulateDot11fSSID( pMac, pSsid, &pr.SSID );
383
Jeff Johnson295189b2012-06-20 16:38:30 -0700384 if( nAdditionalIELen && pAdditionalIE )
385 {
386 p2pIe = limGetP2pIEPtr(pMac, pAdditionalIE, nAdditionalIELen);
387 }
Jeff Johnsone7245742012-09-05 17:12:55 -0700388 /* Don't include 11b rate only when device is doing P2P Search */
389 if( ( WNI_CFG_DOT11_MODE_11B != dot11mode ) &&
390 ( p2pIe != NULL ) &&
391 /* Don't include 11b rate if it is a P2P serach or probe request is sent by P2P Client */
392 ( ( ( pMac->lim.gpLimMlmScanReq != NULL ) &&
393 pMac->lim.gpLimMlmScanReq->p2pSearch ) ||
394 ( ( psessionEntry != NULL ) &&
395 ( VOS_P2P_CLIENT_MODE == psessionEntry->pePersona ) )
396 )
397 )
Jeff Johnson295189b2012-06-20 16:38:30 -0700398 {
399 /* In the below API pass channel number > 14, do that it fills only
400 * 11a rates in supported rates */
401 PopulateDot11fSuppRates( pMac, 15, &pr.SuppRates,psessionEntry);
402 }
403 else
404 {
Jeff Johnson295189b2012-06-20 16:38:30 -0700405 PopulateDot11fSuppRates( pMac, nChannelNum,
406 &pr.SuppRates,psessionEntry);
407
408 if ( WNI_CFG_DOT11_MODE_11B != dot11mode )
409 {
410 PopulateDot11fExtSuppRates1( pMac, nChannelNum, &pr.ExtSuppRates );
411 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700412 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700413
414#if defined WLAN_FEATURE_VOWIFI
415 //Table 7-14 in IEEE Std. 802.11k-2008 says
416 //DS params "can" be present in RRM is disabled and "is" present if
417 //RRM is enabled. It should be ok even if we add it into probe req when
418 //RRM is not enabled.
419 PopulateDot11fDSParams( pMac, &pr.DSParams, nChannelNum, psessionEntry );
420 //Call RRM module to get the tx power for management used.
421 {
422 tANI_U8 txPower = (tANI_U8) rrmGetMgmtTxPower( pMac, psessionEntry );
423 PopulateDot11fWFATPC( pMac, &pr.WFATPC, txPower, 0 );
424 }
425#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700426
427 if (psessionEntry != NULL ) {
Jeff Johnsone7245742012-09-05 17:12:55 -0700428 psessionEntry->htCapability = IS_DOT11_MODE_HT(dot11mode);
Jeff Johnson295189b2012-06-20 16:38:30 -0700429 //Include HT Capability IE
Jeff Johnsone7245742012-09-05 17:12:55 -0700430 if (psessionEntry->htCapability)
Jeff Johnson295189b2012-06-20 16:38:30 -0700431 {
Jeff Johnsone7245742012-09-05 17:12:55 -0700432 PopulateDot11fHTCaps( pMac, psessionEntry, &pr.HTCaps );
Jeff Johnson295189b2012-06-20 16:38:30 -0700433 }
Jeff Johnsone7245742012-09-05 17:12:55 -0700434 } else { //psessionEntry == NULL
435 if (IS_DOT11_MODE_HT(dot11mode))
Jeff Johnson295189b2012-06-20 16:38:30 -0700436 {
Jeff Johnsone7245742012-09-05 17:12:55 -0700437 PopulateDot11fHTCaps( pMac, psessionEntry, &pr.HTCaps );
Jeff Johnson295189b2012-06-20 16:38:30 -0700438 }
439 }
Gopichand Nakkala40bc6502012-12-20 16:55:36 -0800440
Hardik Kantilal Patelbca5b002015-01-19 15:30:18 +0530441 if((nChannelNum <= SIR_11B_CHANNEL_END)
442 && (!IS_HT40_OBSS_SCAN_FEATURE_ENABLE)
443 && (!pMac->roam.configParam.channelBondingMode24GHz))
Gopichand Nakkala40bc6502012-12-20 16:55:36 -0800444 {
445 pr.HTCaps.supportedChannelWidthSet = eHT_CHANNEL_WIDTH_20MHZ;
446 pr.HTCaps.shortGI40MHz = 0;
447 }
Jeff Johnsone7245742012-09-05 17:12:55 -0700448#ifdef WLAN_FEATURE_11AC
449 if (psessionEntry != NULL ) {
450 psessionEntry->vhtCapability = IS_DOT11_MODE_VHT(dot11mode);
451 //Include HT Capability IE
452 if (psessionEntry->vhtCapability)
453 {
Abhishek Singh33f76ea2015-06-04 12:27:30 +0530454 PopulateDot11fVHTCaps( pMac, &pr.VHTCaps,
455 psessionEntry->currentOperChannel , eSIR_FALSE );
Jeff Johnsone7245742012-09-05 17:12:55 -0700456 }
457 } else {
458 if (IS_DOT11_MODE_VHT(dot11mode))
459 {
Abhishek Singh33f76ea2015-06-04 12:27:30 +0530460 PopulateDot11fVHTCaps( pMac, &pr.VHTCaps, nChannelNum, eSIR_FALSE );
Jeff Johnsone7245742012-09-05 17:12:55 -0700461 }
462 }
463#endif
464
Jeff Johnson295189b2012-06-20 16:38:30 -0700465
466 // That's it-- now we pack it. First, how much space are we going to
467 // need?
468 nStatus = dot11fGetPackedProbeRequestSize( pMac, &pr, &nPayload );
469 if ( DOT11F_FAILED( nStatus ) )
470 {
471 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700472 "or a Probe Request (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -0700473 // We'll fall back on the worst case scenario:
474 nPayload = sizeof( tDot11fProbeRequest );
475 }
476 else if ( DOT11F_WARNED( nStatus ) )
477 {
478 limLog( pMac, LOGW, FL("There were warnings while calculating"
479 "the packed size for a Probe Request ("
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700480 "0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -0700481 }
482
483 nBytes = nPayload + sizeof( tSirMacMgmtHdr ) + nAdditionalIELen;
484
485 // Ok-- try to allocate some memory:
486 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
487 ( tANI_U16 )nBytes, ( void** ) &pFrame,
488 ( void** ) &pPacket );
489 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
490 {
491 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Pro"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700492 "be Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -0700493 return eSIR_MEM_ALLOC_FAILED;
494 }
495
496 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530497 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -0700498
499 // Next, we fill out the buffer descriptor:
500 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530501 SIR_MAC_MGMT_PROBE_REQ, bssid, SelfMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -0700502 if ( eSIR_SUCCESS != nSirStatus )
503 {
504 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700505 "tor for a Probe Request (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -0700506 nSirStatus );
507 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
508 ( void* ) pFrame, ( void* ) pPacket );
509 return nSirStatus; // allocated!
510 }
511
512 // That done, pack the Probe Request:
513 nStatus = dot11fPackProbeRequest( pMac, &pr, pFrame +
514 sizeof( tSirMacMgmtHdr ),
515 nPayload, &nPayload );
516 if ( DOT11F_FAILED( nStatus ) )
517 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700518 limLog( pMac, LOGE, FL("Failed to pack a Probe Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -0700519 nStatus );
520 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
521 return eSIR_FAILURE; // allocated!
522 }
523 else if ( DOT11F_WARNED( nStatus ) )
524 {
525 limLog( pMac, LOGW, FL("There were warnings while packing a P"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -0800526 "robe Request (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -0700527 }
528
529 // Append any AddIE if present.
530 if( nAdditionalIELen )
531 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530532 vos_mem_copy( pFrame+sizeof(tSirMacMgmtHdr)+nPayload,
Jeff Johnson295189b2012-06-20 16:38:30 -0700533 pAdditionalIE, nAdditionalIELen );
534 nPayload += nAdditionalIELen;
535 }
536
537 /* If this probe request is sent during P2P Search State, then we need
538 * to send it at OFDM rate.
539 */
540 if( ( SIR_BAND_5_GHZ == limGetRFBand(nChannelNum))
Jeff Johnson295189b2012-06-20 16:38:30 -0700541 || (( pMac->lim.gpLimMlmScanReq != NULL) &&
542 pMac->lim.gpLimMlmScanReq->p2pSearch )
Gopichand Nakkala67967212013-02-15 17:31:15 +0530543 /* For unicast probe req mgmt from Join function
544 we don't set above variables. So we need to add
545 one more check whether it is pePersona is P2P_CLIENT or not */
546 || ( ( psessionEntry != NULL ) &&
547 ( VOS_P2P_CLIENT_MODE == psessionEntry->pePersona ) )
Jeff Johnson295189b2012-06-20 16:38:30 -0700548 )
549 {
550 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
551 }
552
Masti, Narayanraddi67ea5912015-01-08 12:34:05 +0530553 if( ( psessionEntry != NULL ) && ( psessionEntry->is11Gonly == true ) &&
554 ( !IS_BROADCAST_MAC(bssid) ) ){
555 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
556 }
557
Jeff Johnson295189b2012-06-20 16:38:30 -0700558 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) sizeof(tSirMacMgmtHdr) + nPayload,
559 HAL_TXRX_FRM_802_11_MGMT,
560 ANI_TXDIR_TODS,
561 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
562 limTxComplete, pFrame, txFlag );
563 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
564 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700565 limLog( pMac, LOGE, FL("could not send Probe Request frame!" ));
Jeff Johnson295189b2012-06-20 16:38:30 -0700566 //Pkt will be freed up by the callback
567 return eSIR_FAILURE;
568 }
569
570 return eSIR_SUCCESS;
571} // End limSendProbeReqMgmtFrame.
572
Jeff Johnson295189b2012-06-20 16:38:30 -0700573tSirRetStatus limGetAddnIeForProbeResp(tpAniSirGlobal pMac,
574 tANI_U8* addIE, tANI_U16 *addnIELen,
575 tANI_U8 probeReqP2pIe)
576{
577 /* If Probe request doesn't have P2P IE, then take out P2P IE
578 from additional IE */
579 if(!probeReqP2pIe)
580 {
581 tANI_U8* tempbuf = NULL;
582 tANI_U16 tempLen = 0;
583 int left = *addnIELen;
584 v_U8_t *ptr = addIE;
585 v_U8_t elem_id, elem_len;
586
587 if(NULL == addIE)
588 {
589 PELOGE(limLog(pMac, LOGE,
590 FL(" NULL addIE pointer"));)
591 return eSIR_FAILURE;
592 }
593
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530594 tempbuf = vos_mem_malloc(left);
595 if ( NULL == tempbuf )
Jeff Johnson295189b2012-06-20 16:38:30 -0700596 {
597 PELOGE(limLog(pMac, LOGE,
598 FL("Unable to allocate memory to store addn IE"));)
599 return eSIR_MEM_ALLOC_FAILED;
600 }
601
602 while(left >= 2)
603 {
604 elem_id = ptr[0];
605 elem_len = ptr[1];
606 left -= 2;
607 if(elem_len > left)
608 {
609 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700610 FL("****Invalid IEs eid = %d elem_len=%d left=%d*****"),
Jeff Johnson295189b2012-06-20 16:38:30 -0700611 elem_id,elem_len,left);
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530612 vos_mem_free(tempbuf);
Jeff Johnson295189b2012-06-20 16:38:30 -0700613 return eSIR_FAILURE;
614 }
615 if ( !( (SIR_MAC_EID_VENDOR == elem_id) &&
616 (memcmp(&ptr[2], SIR_MAC_P2P_OUI, SIR_MAC_P2P_OUI_SIZE)==0) ) )
617 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530618 vos_mem_copy (tempbuf + tempLen, &ptr[0], elem_len + 2);
Jeff Johnson295189b2012-06-20 16:38:30 -0700619 tempLen += (elem_len + 2);
620 }
621 left -= elem_len;
622 ptr += (elem_len + 2);
623 }
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530624 vos_mem_copy (addIE, tempbuf, tempLen);
Jeff Johnson295189b2012-06-20 16:38:30 -0700625 *addnIELen = tempLen;
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530626 vos_mem_free(tempbuf);
Jeff Johnson295189b2012-06-20 16:38:30 -0700627 }
628 return eSIR_SUCCESS;
629}
Jeff Johnson295189b2012-06-20 16:38:30 -0700630
631void
632limSendProbeRspMgmtFrame(tpAniSirGlobal pMac,
633 tSirMacAddr peerMacAddr,
634 tpAniSSID pSsid,
635 short nStaId,
636 tANI_U8 nKeepAlive,
637 tpPESession psessionEntry,
638 tANI_U8 probeReqP2pIe)
639{
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700640 tDot11fProbeResponse *pFrm;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +0530641 tSirRetStatus nSirStatus;
c_hpothubcd78652014-04-28 22:31:08 +0530642 tANI_U32 cfg, nPayload, nStatus;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +0530643 tpSirMacMgmtHdr pMacHdr;
644 tANI_U8 *pFrame;
645 void *pPacket;
646 eHalStatus halstatus;
647 tANI_U32 addnIEPresent;
648 tANI_U32 addnIE1Len=0;
649 tANI_U32 addnIE2Len=0;
650 tANI_U32 addnIE3Len=0;
651 tANI_U16 totalAddnIeLen = 0;
652 tANI_U32 wpsApEnable=0, tmp;
653 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700654 tANI_U8 *addIE = NULL;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +0530655 tANI_U8 *pP2pIe = NULL;
656 tANI_U8 noaLen = 0;
657 tANI_U8 total_noaLen = 0;
658 tANI_U8 noaStream[SIR_MAX_NOA_ATTR_LEN
Jeff Johnson295189b2012-06-20 16:38:30 -0700659 + SIR_P2P_IE_HEADER_LEN];
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +0530660 tANI_U8 noaIe[SIR_MAX_NOA_ATTR_LEN + SIR_P2P_IE_HEADER_LEN];
Kalikinkar dhara205da782014-03-21 15:49:32 -0700661 tDot11fIEExtCap extractedExtCap;
662 tANI_BOOLEAN extractedExtCapFlag = eANI_BOOLEAN_TRUE;
c_hpothubcd78652014-04-28 22:31:08 +0530663 tANI_U32 nBytes = 0;
664
Jeff Johnson295189b2012-06-20 16:38:30 -0700665 if(pMac->gDriverType == eDRIVER_TYPE_MFG) // We don't answer requests
666 {
667 return; // in this case.
668 }
669
670 if(NULL == psessionEntry)
671 {
672 return;
673 }
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530674
675 pFrm = vos_mem_malloc(sizeof(tDot11fProbeResponse));
676 if ( NULL == pFrm )
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700677 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530678 limLog(pMac, LOGE, FL("Unable to allocate memory in limSendProbeRspMgmtFrame") );
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700679 return;
680 }
681
Girish Gowli0e826792014-05-17 17:56:44 +0530682 vos_mem_set(( tANI_U8* )&extractedExtCap, sizeof( tDot11fIEExtCap ), 0);
683
Jeff Johnson295189b2012-06-20 16:38:30 -0700684 // Fill out 'frm', after which we'll just hand the struct off to
685 // 'dot11fPackProbeResponse'.
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530686 vos_mem_set(( tANI_U8* )pFrm, sizeof( tDot11fProbeResponse ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700687
688 // Timestamp to be updated by TFP, below.
689
690 // Beacon Interval:
Jeff Johnson295189b2012-06-20 16:38:30 -0700691 if(psessionEntry->limSystemRole == eLIM_AP_ROLE)
692 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700693 pFrm->BeaconInterval.interval = pMac->sch.schObject.gSchBeaconInterval;
Jeff Johnson295189b2012-06-20 16:38:30 -0700694 }
695 else
696 {
Jeff Johnson3c3e1782013-02-27 10:48:42 -0800697 nSirStatus = wlan_cfgGetInt( pMac, WNI_CFG_BEACON_INTERVAL, &cfg);
698 if (eSIR_SUCCESS != nSirStatus)
699 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700700 limLog( pMac, LOGP, FL("Failed to retrieve WNI_CFG_BEACON_INTERVAL from CFG (%d)."),
Jeff Johnson3c3e1782013-02-27 10:48:42 -0800701 nSirStatus );
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530702 vos_mem_free(pFrm);
Jeff Johnson3c3e1782013-02-27 10:48:42 -0800703 return;
704 }
705 pFrm->BeaconInterval.interval = ( tANI_U16 ) cfg;
Madan Mohan Koyyalamudic0d1b3f2012-11-13 10:41:07 -0800706 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700707
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700708 PopulateDot11fCapabilities( pMac, &pFrm->Capabilities, psessionEntry );
709 PopulateDot11fSSID( pMac, ( tSirMacSSid* )pSsid, &pFrm->SSID );
Jeff Johnson295189b2012-06-20 16:38:30 -0700710 PopulateDot11fSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700711 &pFrm->SuppRates,psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -0700712
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700713 PopulateDot11fDSParams( pMac, &pFrm->DSParams, psessionEntry->currentOperChannel,psessionEntry);
714 PopulateDot11fIBSSParams( pMac, &pFrm->IBSSParams, psessionEntry );
Jeff Johnson295189b2012-06-20 16:38:30 -0700715
Jeff Johnson295189b2012-06-20 16:38:30 -0700716
Jeff Johnson295189b2012-06-20 16:38:30 -0700717 if(psessionEntry->limSystemRole == eLIM_AP_ROLE)
718 {
719 if(psessionEntry->wps_state != SAP_WPS_DISABLED)
720 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700721 PopulateDot11fProbeResWPSIEs(pMac, &pFrm->WscProbeRes, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -0700722 }
723 }
724 else
725 {
Jeff Johnson3c3e1782013-02-27 10:48:42 -0800726 if (wlan_cfgGetInt(pMac, (tANI_U16) WNI_CFG_WPS_ENABLE, &tmp) != eSIR_SUCCESS)
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700727 limLog(pMac, LOGP,"Failed to cfg get id %d", WNI_CFG_WPS_ENABLE );
Jeff Johnson295189b2012-06-20 16:38:30 -0700728
Jeff Johnson3c3e1782013-02-27 10:48:42 -0800729 wpsApEnable = tmp & WNI_CFG_WPS_ENABLE_AP;
Jeff Johnson295189b2012-06-20 16:38:30 -0700730
Jeff Johnson3c3e1782013-02-27 10:48:42 -0800731 if (wpsApEnable)
732 {
733 PopulateDot11fWscInProbeRes(pMac, &pFrm->WscProbeRes);
734 }
735
736 if (pMac->lim.wscIeInfo.probeRespWscEnrollmentState == eLIM_WSC_ENROLL_BEGIN)
737 {
738 PopulateDot11fWscRegistrarInfoInProbeRes(pMac, &pFrm->WscProbeRes);
739 pMac->lim.wscIeInfo.probeRespWscEnrollmentState = eLIM_WSC_ENROLL_IN_PROGRESS;
740 }
741
742 if (pMac->lim.wscIeInfo.wscEnrollmentState == eLIM_WSC_ENROLL_END)
743 {
744 DePopulateDot11fWscRegistrarInfoInProbeRes(pMac, &pFrm->WscProbeRes);
745 pMac->lim.wscIeInfo.probeRespWscEnrollmentState = eLIM_WSC_ENROLL_NOOP;
746 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700747 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700748
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700749 PopulateDot11fCountry( pMac, &pFrm->Country, psessionEntry);
750 PopulateDot11fEDCAParamSet( pMac, &pFrm->EDCAParamSet, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -0700751
Jeff Johnson295189b2012-06-20 16:38:30 -0700752
753 if (psessionEntry->dot11mode != WNI_CFG_DOT11_MODE_11B)
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700754 PopulateDot11fERPInfo( pMac, &pFrm->ERPInfo, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -0700755
756
757 // N.B. In earlier implementations, the RSN IE would be placed in
758 // the frame here, before the WPA IE, if 'RSN_BEFORE_WPA' was defined.
759 PopulateDot11fExtSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700760 &pFrm->ExtSuppRates, psessionEntry );
Jeff Johnson295189b2012-06-20 16:38:30 -0700761
762 //Populate HT IEs, when operating in 11n or Taurus modes.
Jeff Johnsone7245742012-09-05 17:12:55 -0700763 if ( psessionEntry->htCapability )
Jeff Johnson295189b2012-06-20 16:38:30 -0700764 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700765 PopulateDot11fHTCaps( pMac, psessionEntry, &pFrm->HTCaps );
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700766 PopulateDot11fHTInfo( pMac, &pFrm->HTInfo, psessionEntry );
Jeff Johnson295189b2012-06-20 16:38:30 -0700767 }
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +0530768
769#ifdef WLAN_FEATURE_AP_HT40_24G
770 /* Populate Overlapping BSS Scan Parameters IEs,
771 * when operating in HT40 in 2.4GHz.
772 */
Hardik Kantilal Patel3c235242015-01-02 17:56:18 +0530773 if ((pMac->roam.configParam.apHT40_24GEnabled)
774 && (IS_DOT11_MODE_HT(psessionEntry->dot11mode)))
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +0530775 {
776 PopulateDot11fOBSSScanParameters( pMac, &pFrm->OBSSScanParameters,
777 psessionEntry);
Hardik Kantilal Patelee5874c2015-01-14 15:23:28 +0530778 /* 10.15.8 Support of DSSS/CCK in 40 MHz, An associated HT STA in
779 * a 20/40 MHz BSS may generate DSSS/CCK transmissions.Set DSSS/CCK
780 * Mode in 40 MHz bit in HT capablity.
781 */
782 pFrm->HTCaps.dsssCckMode40MHz = 1;
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +0530783 }
784#endif
785
786 PopulateDot11fExtCap( pMac, &pFrm->ExtCap, psessionEntry);
787
Jeff Johnsone7245742012-09-05 17:12:55 -0700788#ifdef WLAN_FEATURE_11AC
789 if(psessionEntry->vhtCapability)
790 {
Chet Lanctotf19c1f62013-12-13 13:56:21 -0800791 limLog( pMac, LOG1, FL("Populate VHT IE in Probe Response"));
Abhishek Singh33f76ea2015-06-04 12:27:30 +0530792 PopulateDot11fVHTCaps( pMac, &pFrm->VHTCaps,
793 psessionEntry->currentOperChannel, eSIR_TRUE );
794 PopulateDot11fVHTOperation( pMac, &pFrm->VHTOperation ,
795 psessionEntry->currentOperChannel);
Jeff Johnsone7245742012-09-05 17:12:55 -0700796 // we do not support multi users yet
797 //PopulateDot11fVHTExtBssLoad( pMac, &frm.VHTExtBssLoad );
798 }
799#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700800
Sandeep Puligilla60342762014-01-30 21:05:37 +0530801
Hardik Kantilal Patelee5874c2015-01-14 15:23:28 +0530802 if ( psessionEntry->pLimStartBssReq )
Jeff Johnson295189b2012-06-20 16:38:30 -0700803 {
804 PopulateDot11fWPA( pMac, &( psessionEntry->pLimStartBssReq->rsnIE ),
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700805 &pFrm->WPA );
Chet Lanctot4b9abd72013-06-27 11:14:56 -0700806 PopulateDot11fRSNOpaque( pMac, &( psessionEntry->pLimStartBssReq->rsnIE ),
807 &pFrm->RSNOpaque );
Jeff Johnson295189b2012-06-20 16:38:30 -0700808 }
809
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700810 PopulateDot11fWMM( pMac, &pFrm->WMMInfoAp, &pFrm->WMMParams, &pFrm->WMMCaps, psessionEntry );
Jeff Johnson295189b2012-06-20 16:38:30 -0700811
812#if defined(FEATURE_WLAN_WAPI)
813 if( psessionEntry->pLimStartBssReq )
814 {
815 PopulateDot11fWAPI( pMac, &( psessionEntry->pLimStartBssReq->rsnIE ),
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700816 &pFrm->WAPI );
Jeff Johnson295189b2012-06-20 16:38:30 -0700817 }
818
819#endif // defined(FEATURE_WLAN_WAPI)
820
Jeff Johnson295189b2012-06-20 16:38:30 -0700821 addnIEPresent = false;
Jeff Johnson295189b2012-06-20 16:38:30 -0700822 if( pMac->lim.gpLimRemainOnChanReq )
823 {
824 nBytes += (pMac->lim.gpLimRemainOnChanReq->length - sizeof( tSirRemainOnChnReq ) );
825 }
826 //Only use CFG for non-listen mode. This CFG is not working for concurrency
827 //In listening mode, probe rsp IEs is passed in the message from SME to PE
828 else
Jeff Johnson295189b2012-06-20 16:38:30 -0700829 {
830
831 if (wlan_cfgGetInt(pMac, WNI_CFG_PROBE_RSP_ADDNIE_FLAG,
832 &addnIEPresent) != eSIR_SUCCESS)
833 {
834 limLog(pMac, LOGP, FL("Unable to get WNI_CFG_PROBE_RSP_ADDNIE_FLAG"));
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530835 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700836 return;
837 }
838 }
839
840 if (addnIEPresent)
841 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530842
843 addIE = vos_mem_malloc(WNI_CFG_PROBE_RSP_ADDNIE_DATA1_LEN*3);
844 if ( NULL == addIE )
Jeff Johnson295189b2012-06-20 16:38:30 -0700845 {
846 PELOGE(limLog(pMac, LOGE,
847 FL("Unable to allocate memory to store addn IE"));)
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530848 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700849 return;
850 }
851
852 //Probe rsp IE available
853 if ( eSIR_SUCCESS != wlan_cfgGetStrLen(pMac,
854 WNI_CFG_PROBE_RSP_ADDNIE_DATA1, &addnIE1Len) )
855 {
856 limLog(pMac, LOGP, FL("Unable to get WNI_CFG_PROBE_RSP_ADDNIE_DATA1 length"));
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530857 vos_mem_free(addIE);
858 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700859 return;
860 }
861 if (addnIE1Len <= WNI_CFG_PROBE_RSP_ADDNIE_DATA1_LEN && addnIE1Len &&
862 (nBytes + addnIE1Len) <= SIR_MAX_PACKET_SIZE)
863 {
864 if ( eSIR_SUCCESS != wlan_cfgGetStr(pMac,
865 WNI_CFG_PROBE_RSP_ADDNIE_DATA1, &addIE[0],
866 &addnIE1Len) )
867 {
868 limLog(pMac, LOGP,
869 FL("Unable to get WNI_CFG_PROBE_RSP_ADDNIE_DATA1 String"));
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530870 vos_mem_free(addIE);
871 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700872 return;
873 }
874 }
875
876 //Probe rsp IE available
877 if ( eSIR_SUCCESS != wlan_cfgGetStrLen(pMac,
878 WNI_CFG_PROBE_RSP_ADDNIE_DATA2, &addnIE2Len) )
879 {
880 limLog(pMac, LOGP, FL("Unable to get WNI_CFG_PROBE_RSP_ADDNIE_DATA2 length"));
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530881 vos_mem_free(addIE);
882 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700883 return;
884 }
885 if (addnIE2Len <= WNI_CFG_PROBE_RSP_ADDNIE_DATA2_LEN && addnIE2Len &&
886 (nBytes + addnIE2Len) <= SIR_MAX_PACKET_SIZE)
887 {
888 if ( eSIR_SUCCESS != wlan_cfgGetStr(pMac,
889 WNI_CFG_PROBE_RSP_ADDNIE_DATA2, &addIE[addnIE1Len],
890 &addnIE2Len) )
891 {
892 limLog(pMac, LOGP,
893 FL("Unable to get WNI_CFG_PROBE_RSP_ADDNIE_DATA2 String"));
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530894 vos_mem_free(addIE);
895 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700896 return;
897 }
898 }
899
900 //Probe rsp IE available
901 if ( eSIR_SUCCESS != wlan_cfgGetStrLen(pMac,
902 WNI_CFG_PROBE_RSP_ADDNIE_DATA3, &addnIE3Len) )
903 {
904 limLog(pMac, LOGP, FL("Unable to get WNI_CFG_PROBE_RSP_ADDNIE_DATA3 length"));
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530905 vos_mem_free(addIE);
906 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700907 return;
908 }
909 if (addnIE3Len <= WNI_CFG_PROBE_RSP_ADDNIE_DATA3_LEN && addnIE3Len &&
910 (nBytes + addnIE3Len) <= SIR_MAX_PACKET_SIZE)
911 {
912 if ( eSIR_SUCCESS != wlan_cfgGetStr(pMac,
913 WNI_CFG_PROBE_RSP_ADDNIE_DATA3,
914 &addIE[addnIE1Len + addnIE2Len],
915 &addnIE3Len) )
916 {
917 limLog(pMac, LOGP,
918 FL("Unable to get WNI_CFG_PROBE_RSP_ADDNIE_DATA3 String"));
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530919 vos_mem_free(addIE);
920 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700921 return;
922 }
923 }
924 totalAddnIeLen = addnIE1Len + addnIE2Len + addnIE3Len;
925
Jeff Johnson295189b2012-06-20 16:38:30 -0700926 if(eSIR_SUCCESS != limGetAddnIeForProbeResp(pMac, addIE, &totalAddnIeLen, probeReqP2pIe))
927 {
928 limLog(pMac, LOGP,
929 FL("Unable to get final Additional IE for Probe Req"));
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530930 vos_mem_free(addIE);
931 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700932 return;
933 }
Kalikinkar dhara205da782014-03-21 15:49:32 -0700934
Kalikinkar dhara205da782014-03-21 15:49:32 -0700935 nSirStatus = limStripOffExtCapIEAndUpdateStruct(pMac,
936 addIE,
937 &totalAddnIeLen,
938 &extractedExtCap );
939 if(eSIR_SUCCESS != nSirStatus )
940 {
941 extractedExtCapFlag = eANI_BOOLEAN_FALSE;
942 limLog(pMac, LOG1,
943 FL("Unable to Stripoff ExtCap IE from Probe Rsp"));
944 }
945
Jeff Johnson295189b2012-06-20 16:38:30 -0700946 nBytes = nBytes + totalAddnIeLen;
Kaushik, Sushanta5ee77a2014-07-30 19:35:25 +0530947 limLog(pMac, LOG1,
948 FL("probe rsp packet size is %d "), nBytes);
Jeff Johnson295189b2012-06-20 16:38:30 -0700949 if (probeReqP2pIe)
950 {
951 pP2pIe = limGetP2pIEPtr(pMac, &addIE[0], totalAddnIeLen);
952 if (pP2pIe != NULL)
953 {
954 //get NoA attribute stream P2P IE
955 noaLen = limGetNoaAttrStream(pMac, noaStream, psessionEntry);
956 if (noaLen != 0)
957 {
958 total_noaLen = limBuildP2pIe(pMac, &noaIe[0],
959 &noaStream[0], noaLen);
960 nBytes = nBytes + total_noaLen;
Kaushik, Sushanta5ee77a2014-07-30 19:35:25 +0530961 limLog(pMac, LOG1,
962 FL("p2p probe rsp packet size is %d, noalength is %d"),
963 nBytes, total_noaLen);
Jeff Johnson295189b2012-06-20 16:38:30 -0700964 }
965 }
966 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700967 }
968
c_hpothubcd78652014-04-28 22:31:08 +0530969 /*merge ExtCap IE*/
970 if (extractedExtCapFlag && extractedExtCap.present)
971 {
Hu Wang5193b572016-08-11 10:04:47 +0800972 limMergeExtCapIEStruct(&pFrm->ExtCap, &extractedExtCap, true);
c_hpothubcd78652014-04-28 22:31:08 +0530973 }
974
975 nStatus = dot11fGetPackedProbeResponseSize( pMac, pFrm, &nPayload );
976 if ( DOT11F_FAILED( nStatus ) )
977 {
978 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
979 "or a Probe Response (0x%08x)."),
980 nStatus );
981 // We'll fall back on the worst case scenario:
982 nPayload = sizeof( tDot11fProbeResponse );
983 }
984 else if ( DOT11F_WARNED( nStatus ) )
985 {
986 limLog( pMac, LOGW, FL("There were warnings while calculating"
987 "the packed size for a Probe Response "
988 "(0x%08x)."), nStatus );
989 }
990
991 nBytes += nPayload + sizeof( tSirMacMgmtHdr );
992
Jeff Johnson295189b2012-06-20 16:38:30 -0700993 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
994 ( tANI_U16 )nBytes, ( void** ) &pFrame,
995 ( void** ) &pPacket );
996 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
997 {
998 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Pro"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700999 "be Response."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07001000 if ( addIE != NULL )
1001 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301002 vos_mem_free(addIE);
Jeff Johnson295189b2012-06-20 16:38:30 -07001003 }
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301004 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -07001005 return;
1006 }
1007
1008 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301009 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07001010
1011 // Next, we fill out the buffer descriptor:
1012 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
1013 SIR_MAC_MGMT_PROBE_RSP, peerMacAddr,psessionEntry->selfMacAddr);
1014 if ( eSIR_SUCCESS != nSirStatus )
1015 {
1016 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001017 "tor for a Probe Response (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001018 nSirStatus );
1019 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1020 ( void* ) pFrame, ( void* ) pPacket );
1021 if ( addIE != NULL )
1022 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301023 vos_mem_free(addIE);
Jeff Johnson295189b2012-06-20 16:38:30 -07001024 }
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301025 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -07001026 return;
1027 }
1028
1029 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
1030
1031 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
1032
1033 // That done, pack the Probe Response:
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07001034 nStatus = dot11fPackProbeResponse( pMac, pFrm, pFrame + sizeof(tSirMacMgmtHdr),
Jeff Johnson295189b2012-06-20 16:38:30 -07001035 nPayload, &nPayload );
1036 if ( DOT11F_FAILED( nStatus ) )
1037 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001038 limLog( pMac, LOGE, FL("Failed to pack a Probe Response (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001039 nStatus );
1040 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1041 if ( addIE != NULL )
1042 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301043 vos_mem_free(addIE);
Jeff Johnson295189b2012-06-20 16:38:30 -07001044 }
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301045 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -07001046 return; // allocated!
1047 }
1048 else if ( DOT11F_WARNED( nStatus ) )
1049 {
1050 limLog( pMac, LOGW, FL("There were warnings while packing a P"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001051 "robe Response (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001052 }
1053
1054 PELOG3(limLog( pMac, LOG3, FL("Sending Probe Response frame to ") );
1055 limPrintMacAddr( pMac, peerMacAddr, LOG3 );)
1056
1057 pMac->sys.probeRespond++;
1058
Jeff Johnson295189b2012-06-20 16:38:30 -07001059 if( pMac->lim.gpLimRemainOnChanReq )
1060 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301061 vos_mem_copy ( pFrame+sizeof(tSirMacMgmtHdr)+nPayload,
Jeff Johnson295189b2012-06-20 16:38:30 -07001062 pMac->lim.gpLimRemainOnChanReq->probeRspIe, (pMac->lim.gpLimRemainOnChanReq->length - sizeof( tSirRemainOnChnReq )) );
1063 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001064
1065 if ( addnIEPresent )
1066 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301067 vos_mem_copy(pFrame+sizeof(tSirMacMgmtHdr)+nPayload, &addIE[0], totalAddnIeLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07001068 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001069 if (noaLen != 0)
1070 {
Krunal Soni81b24262013-05-15 17:46:41 -07001071 if (total_noaLen > (SIR_MAX_NOA_ATTR_LEN + SIR_P2P_IE_HEADER_LEN))
Jeff Johnson295189b2012-06-20 16:38:30 -07001072 {
1073 limLog(pMac, LOGE,
Kaushik, Sushant96ac9d72013-12-11 19:28:10 +05301074 FL("Not able to insert NoA because of length constraint."
1075 "Total Length is :%d"),total_noaLen);
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301076 vos_mem_free(addIE);
1077 vos_mem_free(pFrm);
Krunal Soni81b24262013-05-15 17:46:41 -07001078 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1079 ( void* ) pFrame, ( void* ) pPacket );
1080 return;
1081 }
1082 else
1083 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301084 vos_mem_copy( &pFrame[nBytes - (total_noaLen)],
Krunal Soni81b24262013-05-15 17:46:41 -07001085 &noaIe[0], total_noaLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07001086 }
1087 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001088
1089 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07001090 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
1091 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07001092 )
1093 {
1094 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
1095 }
1096
1097 // Queue Probe Response frame in high priority WQ
1098 halstatus = halTxFrame( ( tHalHandle ) pMac, pPacket,
1099 ( tANI_U16 ) nBytes,
1100 HAL_TXRX_FRM_802_11_MGMT,
1101 ANI_TXDIR_TODS,
1102 7,//SMAC_SWBD_TX_TID_MGMT_LOW,
1103 limTxComplete, pFrame, txFlag );
1104 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1105 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001106 limLog( pMac, LOGE, FL("Could not send Probe Response.") );
Jeff Johnson295189b2012-06-20 16:38:30 -07001107 //Pkt will be freed up by the callback
1108 }
1109
1110 if ( addIE != NULL )
1111 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301112 vos_mem_free(addIE);
Jeff Johnson295189b2012-06-20 16:38:30 -07001113 }
1114
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301115 vos_mem_free(pFrm);
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07001116 return;
1117
1118
Jeff Johnson295189b2012-06-20 16:38:30 -07001119} // End limSendProbeRspMgmtFrame.
1120
1121void
1122limSendAddtsReqActionFrame(tpAniSirGlobal pMac,
1123 tSirMacAddr peerMacAddr,
1124 tSirAddtsReqInfo *pAddTS,
1125 tpPESession psessionEntry)
1126{
1127 tANI_U16 i;
1128 tANI_U8 *pFrame;
1129 tSirRetStatus nSirStatus;
1130 tDot11fAddTSRequest AddTSReq;
1131 tDot11fWMMAddTSRequest WMMAddTSReq;
1132 tANI_U32 nPayload, nBytes, nStatus;
1133 tpSirMacMgmtHdr pMacHdr;
1134 void *pPacket;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001135#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07001136 tANI_U32 phyMode;
1137#endif
1138 eHalStatus halstatus;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05301139 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001140
1141 if(NULL == psessionEntry)
1142 {
1143 return;
1144 }
1145
1146 if ( ! pAddTS->wmeTspecPresent )
1147 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301148 vos_mem_set(( tANI_U8* )&AddTSReq, sizeof( AddTSReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001149
1150 AddTSReq.Action.action = SIR_MAC_QOS_ADD_TS_REQ;
1151 AddTSReq.DialogToken.token = pAddTS->dialogToken;
1152 AddTSReq.Category.category = SIR_MAC_ACTION_QOS_MGMT;
1153 if ( pAddTS->lleTspecPresent )
1154 {
1155 PopulateDot11fTSPEC( &pAddTS->tspec, &AddTSReq.TSPEC );
1156 }
1157 else
1158 {
1159 PopulateDot11fWMMTSPEC( &pAddTS->tspec, &AddTSReq.WMMTSPEC );
1160 }
1161
1162 if ( pAddTS->lleTspecPresent )
1163 {
1164 AddTSReq.num_WMMTCLAS = 0;
1165 AddTSReq.num_TCLAS = pAddTS->numTclas;
1166 for ( i = 0; i < pAddTS->numTclas; ++i)
1167 {
1168 PopulateDot11fTCLAS( pMac, &pAddTS->tclasInfo[i],
1169 &AddTSReq.TCLAS[i] );
1170 }
1171 }
1172 else
1173 {
1174 AddTSReq.num_TCLAS = 0;
1175 AddTSReq.num_WMMTCLAS = pAddTS->numTclas;
1176 for ( i = 0; i < pAddTS->numTclas; ++i)
1177 {
1178 PopulateDot11fWMMTCLAS( pMac, &pAddTS->tclasInfo[i],
1179 &AddTSReq.WMMTCLAS[i] );
1180 }
1181 }
1182
1183 if ( pAddTS->tclasProcPresent )
1184 {
1185 if ( pAddTS->lleTspecPresent )
1186 {
1187 AddTSReq.TCLASSPROC.processing = pAddTS->tclasProc;
1188 AddTSReq.TCLASSPROC.present = 1;
1189 }
1190 else
1191 {
1192 AddTSReq.WMMTCLASPROC.version = 1;
1193 AddTSReq.WMMTCLASPROC.processing = pAddTS->tclasProc;
1194 AddTSReq.WMMTCLASPROC.present = 1;
1195 }
1196 }
1197
1198 nStatus = dot11fGetPackedAddTSRequestSize( pMac, &AddTSReq, &nPayload );
1199 if ( DOT11F_FAILED( nStatus ) )
1200 {
1201 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001202 "or an Add TS Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001203 nStatus );
1204 // We'll fall back on the worst case scenario:
1205 nPayload = sizeof( tDot11fAddTSRequest );
1206 }
1207 else if ( DOT11F_WARNED( nStatus ) )
1208 {
1209 limLog( pMac, LOGW, FL("There were warnings while calculating"
1210 "the packed size for an Add TS Request"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001211 " (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001212 }
1213 }
1214 else
1215 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301216 vos_mem_set(( tANI_U8* )&WMMAddTSReq, sizeof( WMMAddTSReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001217
1218 WMMAddTSReq.Action.action = SIR_MAC_QOS_ADD_TS_REQ;
1219 WMMAddTSReq.DialogToken.token = pAddTS->dialogToken;
1220 WMMAddTSReq.Category.category = SIR_MAC_ACTION_WME;
1221
1222 // WMM spec 2.2.10 - status code is only filled in for ADDTS response
1223 WMMAddTSReq.StatusCode.statusCode = 0;
1224
1225 PopulateDot11fWMMTSPEC( &pAddTS->tspec, &WMMAddTSReq.WMMTSPEC );
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001226#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07001227 limGetPhyMode(pMac, &phyMode, psessionEntry);
1228
1229 if( phyMode == WNI_CFG_PHY_MODE_11G || phyMode == WNI_CFG_PHY_MODE_11A)
1230 {
1231 pAddTS->tsrsIE.rates[0] = TSRS_11AG_RATE_6MBPS;
1232 }
1233 else
1234 {
1235 pAddTS->tsrsIE.rates[0] = TSRS_11B_RATE_5_5MBPS;
1236 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001237 PopulateDot11TSRSIE(pMac,&pAddTS->tsrsIE, &WMMAddTSReq.ESETrafStrmRateSet,sizeof(tANI_U8));
Jeff Johnson295189b2012-06-20 16:38:30 -07001238#endif
1239 // fillWmeTspecIE
1240
1241 nStatus = dot11fGetPackedWMMAddTSRequestSize( pMac, &WMMAddTSReq, &nPayload );
1242 if ( DOT11F_FAILED( nStatus ) )
1243 {
1244 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001245 "or a WMM Add TS Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001246 nStatus );
1247 // We'll fall back on the worst case scenario:
1248 nPayload = sizeof( tDot11fAddTSRequest );
1249 }
1250 else if ( DOT11F_WARNED( nStatus ) )
1251 {
1252 limLog( pMac, LOGW, FL("There were warnings while calculating"
1253 "the packed size for a WMM Add TS Requ"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001254 "est (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001255 }
1256 }
1257
1258 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
1259
1260 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1261 ( tANI_U16 )nBytes, ( void** ) &pFrame,
1262 ( void** ) &pPacket );
1263 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1264 {
1265 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for an Ad"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001266 "d TS Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07001267 return;
1268 }
1269
1270 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301271 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07001272
1273 // Next, we fill out the buffer descriptor:
1274 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
1275 SIR_MAC_MGMT_ACTION, peerMacAddr,psessionEntry->selfMacAddr);
1276 if ( eSIR_SUCCESS != nSirStatus )
1277 {
1278 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001279 "tor for an Add TS Request (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001280 nSirStatus );
1281 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1282 ( void* ) pFrame, ( void* ) pPacket );
1283 return;
1284 }
1285
1286 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
1287
1288 #if 0
1289 cfgLen = SIR_MAC_ADDR_LENGTH;
1290 if ( eSIR_SUCCESS != wlan_cfgGetStr( pMac, WNI_CFG_BSSID,
1291 ( tANI_U8* )pMacHdr->bssId, &cfgLen ) )
1292 {
1293 limLog( pMac, LOGP, FL("Failed to retrieve WNI_CFG_BSSID whil"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001294 "e sending an Add TS Request.") );
Jeff Johnson295189b2012-06-20 16:38:30 -07001295 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1296 ( void* ) pFrame, ( void* ) pPacket );
1297 return;
1298 }
1299 #endif //TO SUPPORT BT-AMP
1300
1301 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
1302
Chet Lanctot186b5732013-03-18 10:26:30 -07001303#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07001304 limSetProtectedBit(pMac, psessionEntry, peerMacAddr, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07001305#endif
1306
Jeff Johnson295189b2012-06-20 16:38:30 -07001307 // That done, pack the struct:
1308 if ( ! pAddTS->wmeTspecPresent )
1309 {
1310 nStatus = dot11fPackAddTSRequest( pMac, &AddTSReq,
1311 pFrame + sizeof(tSirMacMgmtHdr),
1312 nPayload, &nPayload );
1313 if ( DOT11F_FAILED( nStatus ) )
1314 {
1315 limLog( pMac, LOGE, FL("Failed to pack an Add TS Request "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001316 "(0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001317 nStatus );
1318 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1319 return; // allocated!
1320 }
1321 else if ( DOT11F_WARNED( nStatus ) )
1322 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001323 limLog( pMac, LOGW, FL("There were warnings while packing "
1324 "an Add TS Request (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001325 }
1326 }
1327 else
1328 {
1329 nStatus = dot11fPackWMMAddTSRequest( pMac, &WMMAddTSReq,
1330 pFrame + sizeof(tSirMacMgmtHdr),
1331 nPayload, &nPayload );
1332 if ( DOT11F_FAILED( nStatus ) )
1333 {
1334 limLog( pMac, LOGE, FL("Failed to pack a WMM Add TS Reque"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001335 "st (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001336 nStatus );
1337 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1338 return; // allocated!
1339 }
1340 else if ( DOT11F_WARNED( nStatus ) )
1341 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001342 limLog( pMac, LOGW, FL("There were warnings while packing "
1343 "a WMM Add TS Request (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001344 }
1345 }
1346
Abhishek Singh127a8442014-12-15 17:31:27 +05301347 limLog( pMac, LOG1, FL("Sending an Add TS Request frame to ") );
1348 limPrintMacAddr( pMac, peerMacAddr, LOG1 );
Jeff Johnson295189b2012-06-20 16:38:30 -07001349
1350 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07001351 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
1352 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07001353 )
1354 {
1355 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
1356 }
1357
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05301358 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
1359 psessionEntry->peSessionId,
1360 pMacHdr->fc.subType));
Jeff Johnson295189b2012-06-20 16:38:30 -07001361 // Queue Addts Response frame in high priority WQ
1362 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
1363 HAL_TXRX_FRM_802_11_MGMT,
1364 ANI_TXDIR_TODS,
1365 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
1366 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05301367 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
1368 psessionEntry->peSessionId,
1369 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07001370 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1371 {
1372 limLog( pMac, LOGE, FL( "*** Could not send an Add TS Request"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001373 " (%X) ***" ), halstatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001374 //Pkt will be freed up by the callback
1375 }
1376
1377} // End limSendAddtsReqActionFrame.
1378
Jeff Johnson295189b2012-06-20 16:38:30 -07001379
1380
1381void
1382limSendAssocRspMgmtFrame(tpAniSirGlobal pMac,
1383 tANI_U16 statusCode,
1384 tANI_U16 aid,
1385 tSirMacAddr peerMacAddr,
1386 tANI_U8 subType,
Kapil Gupta956c0c42017-06-16 19:24:31 +05301387 tpDphHashNode pSta,tpPESession psessionEntry,
1388 assoc_rsp_tx_context *tx_complete_context)
Jeff Johnson295189b2012-06-20 16:38:30 -07001389{
1390 static tDot11fAssocResponse frm;
1391 tANI_U8 *pFrame, *macAddr;
1392 tpSirMacMgmtHdr pMacHdr;
1393 tSirRetStatus nSirStatus;
1394 tANI_U8 lleMode = 0, fAddTS, edcaInclude = 0;
1395 tHalBitVal qosMode, wmeMode;
c_hpothubcd78652014-04-28 22:31:08 +05301396 tANI_U32 nPayload, nStatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07001397 void *pPacket;
1398 eHalStatus halstatus;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05301399 tUpdateBeaconParams beaconParams;
1400 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001401 tANI_U32 addnIEPresent = false;
1402 tANI_U32 addnIELen=0;
1403 tANI_U8 addIE[WNI_CFG_ASSOC_RSP_ADDNIE_DATA_LEN];
1404 tpSirAssocReq pAssocReq = NULL;
Mahesh A Saptasagar38c177e2014-10-17 18:55:48 +05301405 tANI_U16 addStripoffIELen = 0;
1406 tDot11fIEExtCap extractedExtCap;
1407 tANI_BOOLEAN extractedExtCapFlag = eANI_BOOLEAN_FALSE;
c_hpothubcd78652014-04-28 22:31:08 +05301408 tANI_U32 nBytes = 0;
Kalikinkar dhara205da782014-03-21 15:49:32 -07001409
Chet Lanctot8cecea22014-02-11 19:09:36 -08001410#ifdef WLAN_FEATURE_11W
1411 tANI_U32 retryInterval;
1412 tANI_U32 maxRetries;
1413#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001414
1415 if(NULL == psessionEntry)
1416 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05301417 limLog( pMac, LOGE, FL("psessionEntry is NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001418 return;
1419 }
1420
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301421 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07001422
1423 limGetQosMode(psessionEntry, &qosMode);
1424 limGetWmeMode(psessionEntry, &wmeMode);
1425
1426 // An Add TS IE is added only if the AP supports it and the requesting
1427 // STA sent a traffic spec.
1428 fAddTS = ( qosMode && pSta && pSta->qos.addtsPresent ) ? 1 : 0;
1429
1430 PopulateDot11fCapabilities( pMac, &frm.Capabilities, psessionEntry );
1431
1432 frm.Status.status = statusCode;
1433
1434 frm.AID.associd = aid | LIM_AID_MASK;
1435
1436 if ( NULL == pSta )
1437 {
1438 PopulateDot11fSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL, &frm.SuppRates,psessionEntry);
1439 PopulateDot11fExtSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL, &frm.ExtSuppRates, psessionEntry );
1440 }
1441 else
1442 {
1443 PopulateDot11fAssocRspRates( pMac, &frm.SuppRates, &frm.ExtSuppRates,
1444 pSta->supportedRates.llbRates, pSta->supportedRates.llaRates );
1445 }
1446
Jeff Johnson295189b2012-06-20 16:38:30 -07001447 if(psessionEntry->limSystemRole == eLIM_AP_ROLE)
1448 {
1449 if( pSta != NULL && eSIR_SUCCESS == statusCode )
1450 {
1451 pAssocReq =
1452 (tpSirAssocReq) psessionEntry->parsedAssocReq[pSta->assocId];
Jeff Johnson295189b2012-06-20 16:38:30 -07001453 /* populate P2P IE in AssocRsp when assocReq from the peer includes P2P IE */
1454 if( pAssocReq != NULL && pAssocReq->addIEPresent ) {
1455 PopulateDot11AssocResP2PIE(pMac, &frm.P2PAssocRes, pAssocReq);
1456 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001457 }
1458 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001459
1460 if ( NULL != pSta )
1461 {
1462 if ( eHAL_SET == qosMode )
1463 {
1464 if ( pSta->lleEnabled )
1465 {
1466 lleMode = 1;
1467 if ( ( ! pSta->aniPeer ) || ( ! PROP_CAPABILITY_GET( 11EQOS, pSta->propCapability ) ) )
1468 {
1469 PopulateDot11fEDCAParamSet( pMac, &frm.EDCAParamSet, psessionEntry);
1470
1471// FramesToDo:...
1472// if ( fAddTS )
1473// {
1474// tANI_U8 *pAf = pBody;
1475// *pAf++ = SIR_MAC_QOS_ACTION_EID;
1476// tANI_U32 tlen;
1477// status = sirAddtsRspFill(pMac, pAf, statusCode, &pSta->qos.addts, NULL,
1478// &tlen, bufLen - frameLen);
1479// } // End if on Add TS.
1480 }
1481 } // End if on .11e enabled in 'pSta'.
1482 } // End if on QOS Mode on.
1483
1484 if ( ( ! lleMode ) && ( eHAL_SET == wmeMode ) && pSta->wmeEnabled )
1485 {
1486 if ( ( ! pSta->aniPeer ) || ( ! PROP_CAPABILITY_GET( WME, pSta->propCapability ) ) )
1487 {
1488
Jeff Johnson295189b2012-06-20 16:38:30 -07001489 PopulateDot11fWMMParams( pMac, &frm.WMMParams, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07001490
1491 if ( pSta->wsmEnabled )
1492 {
1493 PopulateDot11fWMMCaps(&frm.WMMCaps );
1494 }
1495 }
1496 }
1497
1498 if ( pSta->aniPeer )
1499 {
1500 if ( ( lleMode && PROP_CAPABILITY_GET( 11EQOS, pSta->propCapability ) ) ||
1501 ( pSta->wmeEnabled && PROP_CAPABILITY_GET( WME, pSta->propCapability ) ) )
1502 {
1503 edcaInclude = 1;
1504 }
1505
1506 } // End if on Airgo peer.
1507
1508 if ( pSta->mlmStaContext.htCapability &&
Jeff Johnsone7245742012-09-05 17:12:55 -07001509 psessionEntry->htCapability )
Jeff Johnson295189b2012-06-20 16:38:30 -07001510 {
Krishna Kumaar Natarajan025a8602015-08-04 16:31:36 +05301511 limLog(pMac, LOG1, FL("Populate HT IEs in Assoc Response"));
Jeff Johnsone7245742012-09-05 17:12:55 -07001512 PopulateDot11fHTCaps( pMac, psessionEntry, &frm.HTCaps );
Sachin Ahujac3a26232014-09-23 22:27:30 +05301513 /*
1514 *Check the STA capability and update the HTCaps accordingly
1515 */
1516 frm.HTCaps.supportedChannelWidthSet =
1517 (pSta->htSupportedChannelWidthSet < psessionEntry->htSupportedChannelWidthSet) ?
1518 pSta->htSupportedChannelWidthSet : psessionEntry->htSupportedChannelWidthSet ;
1519
1520 if (!frm.HTCaps.supportedChannelWidthSet)
1521 frm.HTCaps.shortGI40MHz = 0;
1522
Jeff Johnson295189b2012-06-20 16:38:30 -07001523 PopulateDot11fHTInfo( pMac, &frm.HTInfo, psessionEntry );
Jeff Johnson295189b2012-06-20 16:38:30 -07001524 }
Agrawal Ashishb10d0392015-08-06 16:18:20 +05301525 limLog(pMac, LOG1, FL("SupportedChnlWidth: %d, mimoPS: %d, GF: %d,"
1526 "shortGI20:%d, shortGI40: %d, dsssCck: %d, AMPDU Param: %x"),
1527 frm.HTCaps.supportedChannelWidthSet, frm.HTCaps.mimoPowerSave,
1528 frm.HTCaps.greenField, frm.HTCaps.shortGI20MHz, frm.HTCaps.shortGI40MHz,
1529 frm.HTCaps.dsssCckMode40MHz, frm.HTCaps.maxRxAMPDUFactor);
1530
1531
Jeff Johnsone7245742012-09-05 17:12:55 -07001532
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301533#ifdef WLAN_FEATURE_AP_HT40_24G
1534 /* Populate Overlapping BSS Scan Parameters IEs,
1535 * when operating in HT40 in 2.4GHz.
1536 */
Hardik Kantilal Patel3c235242015-01-02 17:56:18 +05301537 if ((pMac->roam.configParam.apHT40_24GEnabled)
1538 && (IS_DOT11_MODE_HT(psessionEntry->dot11mode)))
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301539 {
1540 PopulateDot11fOBSSScanParameters( pMac, &frm.OBSSScanParameters,
1541 psessionEntry);
Hardik Kantilal Patelee5874c2015-01-14 15:23:28 +05301542 /* 10.15.8 Support of DSSS/CCK in 40 MHz, An associated HT STA in
1543 * a 20/40 MHz BSS may generate DSSS/CCK transmissions.Set DSSS/CCK
1544 * Mode in 40 MHz bit in HT capablity.
1545 */
1546 frm.HTCaps.dsssCckMode40MHz = 1;
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301547 }
1548#endif
1549
1550 PopulateDot11fExtCap( pMac, &frm.ExtCap, psessionEntry);
Jeff Johnsone7245742012-09-05 17:12:55 -07001551#ifdef WLAN_FEATURE_11AC
1552 if( pSta->mlmStaContext.vhtCapability &&
1553 psessionEntry->vhtCapability )
1554 {
Chet Lanctotf19c1f62013-12-13 13:56:21 -08001555 limLog( pMac, LOG1, FL("Populate VHT IEs in Assoc Response"));
Abhishek Singh33f76ea2015-06-04 12:27:30 +05301556 PopulateDot11fVHTCaps( pMac, &frm.VHTCaps,
1557 psessionEntry->currentOperChannel, eSIR_TRUE );
1558 PopulateDot11fVHTOperation( pMac, &frm.VHTOperation,
1559 psessionEntry->currentOperChannel);
Jeff Johnsone7245742012-09-05 17:12:55 -07001560 }
1561#endif
1562
Chet Lanctot8cecea22014-02-11 19:09:36 -08001563#ifdef WLAN_FEATURE_11W
Dino Myclea7f18452014-04-24 08:55:31 +05301564 if( eSIR_MAC_TRY_AGAIN_LATER == statusCode )
1565 {
Chet Lanctotfadc8e32014-04-24 14:50:52 -07001566 if ( wlan_cfgGetInt(pMac, WNI_CFG_PMF_SA_QUERY_MAX_RETRIES,
1567 &maxRetries ) != eSIR_SUCCESS )
1568 limLog( pMac, LOGE,
1569 FL("Could not retrieve PMF SA Query maximum retries value") );
1570 else
1571 if ( wlan_cfgGetInt(pMac, WNI_CFG_PMF_SA_QUERY_RETRY_INTERVAL,
1572 &retryInterval ) != eSIR_SUCCESS)
1573 limLog( pMac, LOGE,
1574 FL("Could not retrieve PMF SA Query timer interval value") );
Dino Myclea7f18452014-04-24 08:55:31 +05301575 else
Chet Lanctotfadc8e32014-04-24 14:50:52 -07001576 PopulateDot11fTimeoutInterval(
1577 pMac, &frm.TimeoutInterval, SIR_MAC_TI_TYPE_ASSOC_COMEBACK,
1578 (maxRetries - pSta->pmfSaQueryRetryCount) * retryInterval );
Dino Myclea7f18452014-04-24 08:55:31 +05301579 }
Chet Lanctot8cecea22014-02-11 19:09:36 -08001580#endif
Dino Myclea7f18452014-04-24 08:55:31 +05301581 } // End if on non-NULL 'pSta'.
Jeff Johnson295189b2012-06-20 16:38:30 -07001582
Chet Lanctot8cecea22014-02-11 19:09:36 -08001583 vos_mem_set(( tANI_U8* )&beaconParams, sizeof( tUpdateBeaconParams), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001584
Jeff Johnson295189b2012-06-20 16:38:30 -07001585 if( psessionEntry->limSystemRole == eLIM_AP_ROLE ){
1586 if(psessionEntry->gLimProtectionControl != WNI_CFG_FORCE_POLICY_PROTECTION_DISABLE)
1587 limDecideApProtection(pMac, peerMacAddr, &beaconParams,psessionEntry);
1588 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001589
1590 limUpdateShortPreamble(pMac, peerMacAddr, &beaconParams, psessionEntry);
1591 limUpdateShortSlotTime(pMac, peerMacAddr, &beaconParams, psessionEntry);
1592
1593 beaconParams.bssIdx = psessionEntry->bssIdx;
1594
1595 //Send message to HAL about beacon parameter change.
1596 if(beaconParams.paramChangeBitmap)
1597 {
1598 schSetFixedBeaconFields(pMac,psessionEntry);
1599 limSendBeaconParams(pMac, &beaconParams, psessionEntry );
1600 }
1601
Jeff Johnson295189b2012-06-20 16:38:30 -07001602 if ( pAssocReq != NULL )
1603 {
1604 if (wlan_cfgGetInt(pMac, WNI_CFG_ASSOC_RSP_ADDNIE_FLAG,
1605 &addnIEPresent) != eSIR_SUCCESS)
1606 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05301607 limLog(pMac, LOGP, FL("Unable to get "
1608 "WNI_CFG_ASSOC_RSP_ADDNIE_FLAG"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001609 return;
1610 }
1611
1612 if (addnIEPresent)
1613 {
1614 //Assoc rsp IE available
1615 if (wlan_cfgGetStrLen(pMac, WNI_CFG_ASSOC_RSP_ADDNIE_DATA,
1616 &addnIELen) != eSIR_SUCCESS)
1617 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05301618 limLog(pMac, LOGP, FL("Unable to get "
1619 "WNI_CFG_ASSOC_RSP_ADDNIE_DATA length"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001620 return;
1621 }
1622
1623 if (addnIELen <= WNI_CFG_ASSOC_RSP_ADDNIE_DATA_LEN && addnIELen &&
1624 (nBytes + addnIELen) <= SIR_MAX_PACKET_SIZE)
1625 {
1626 if (wlan_cfgGetStr(pMac, WNI_CFG_ASSOC_RSP_ADDNIE_DATA,
1627 &addIE[0], &addnIELen) == eSIR_SUCCESS)
1628 {
Mahesh A Saptasagar38c177e2014-10-17 18:55:48 +05301629
1630 vos_mem_set(( tANI_U8* )&extractedExtCap,
1631 sizeof( tDot11fIEExtCap ), 0);
Mahesh A Saptasagare00ff532014-10-17 19:05:14 +05301632 addStripoffIELen = addnIELen;
Mahesh A Saptasagar38c177e2014-10-17 18:55:48 +05301633 nSirStatus = limStripOffExtCapIEAndUpdateStruct(pMac,
1634 &addIE[0],
1635 &addStripoffIELen,
1636 &extractedExtCap );
1637 if(eSIR_SUCCESS != nSirStatus)
1638 {
1639 limLog(pMac, LOG1,
1640 FL("Unable to Stripoff ExtCap IE from Assoc Rsp"));
1641 }
1642 else
1643 {
1644 addnIELen = addStripoffIELen;
1645 extractedExtCapFlag = eANI_BOOLEAN_TRUE;
1646 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001647 nBytes = nBytes + addnIELen;
1648 }
1649 }
1650 }
1651 }
1652
Mahesh A Saptasagar38c177e2014-10-17 18:55:48 +05301653 /* merge the ExtCap struct*/
1654 if (extractedExtCapFlag && extractedExtCap.present)
1655 {
Hu Wang5193b572016-08-11 10:04:47 +08001656 limMergeExtCapIEStruct(&(frm.ExtCap), &extractedExtCap, true);
Mahesh A Saptasagar38c177e2014-10-17 18:55:48 +05301657 }
1658
c_hpothubcd78652014-04-28 22:31:08 +05301659 nStatus = dot11fGetPackedAssocResponseSize( pMac, &frm, &nPayload );
1660 if ( DOT11F_FAILED( nStatus ) )
1661 {
1662 limLog( pMac, LOGE, FL("Failed to calculate the packed size f"
1663 "or an Association Response (0x%08x)."),
1664 nStatus );
1665 return;
1666 }
1667 else if ( DOT11F_WARNED( nStatus ) )
1668 {
1669 limLog( pMac, LOGW, FL("There were warnings while calculating "
1670 "the packed size for an Association Re"
1671 "sponse (0x%08x)."), nStatus );
1672 }
1673
1674 nBytes += sizeof( tSirMacMgmtHdr ) + nPayload;
1675
Jeff Johnson295189b2012-06-20 16:38:30 -07001676 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1677 ( tANI_U16 )nBytes, ( void** ) &pFrame,
1678 ( void** ) &pPacket );
1679 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1680 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001681 limLog(pMac, LOGP, FL("Call to bufAlloc failed for RE/ASSOC RSP."));
Jeff Johnson295189b2012-06-20 16:38:30 -07001682 return;
1683 }
1684
1685 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301686 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07001687
1688 // Next, we fill out the buffer descriptor:
1689 nSirStatus = limPopulateMacHeader( pMac,
1690 pFrame,
1691 SIR_MAC_MGMT_FRAME,
1692 ( LIM_ASSOC == subType ) ?
1693 SIR_MAC_MGMT_ASSOC_RSP :
1694 SIR_MAC_MGMT_REASSOC_RSP,
1695 peerMacAddr,psessionEntry->selfMacAddr);
1696 if ( eSIR_SUCCESS != nSirStatus )
1697 {
1698 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001699 "tor for an Association Response (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001700 nSirStatus );
1701 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1702 ( void* ) pFrame, ( void* ) pPacket );
1703 return;
1704 }
1705
1706 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
1707
Jeff Johnson295189b2012-06-20 16:38:30 -07001708 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
1709
1710 nStatus = dot11fPackAssocResponse( pMac, &frm,
1711 pFrame + sizeof( tSirMacMgmtHdr ),
1712 nPayload, &nPayload );
1713 if ( DOT11F_FAILED( nStatus ) )
1714 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05301715 limLog( pMac, LOGE, FL("Failed to pack an Association Response"
1716 " (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001717 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1718 ( void* ) pFrame, ( void* ) pPacket );
1719 return; // allocated!
1720 }
1721 else if ( DOT11F_WARNED( nStatus ) )
1722 {
1723 limLog( pMac, LOGW, FL("There were warnings while packing an "
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001724 "Association Response (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001725 }
1726
1727 macAddr = pMacHdr->da;
1728
1729 if (subType == LIM_ASSOC)
1730 {
Abhishek Singh3cbf6052014-12-15 16:46:42 +05301731 limLog(pMac, LOG1,
Jeff Johnson295189b2012-06-20 16:38:30 -07001732 FL("*** Sending Assoc Resp status %d aid %d to "),
Abhishek Singh3cbf6052014-12-15 16:46:42 +05301733 statusCode, aid);
Jeff Johnson295189b2012-06-20 16:38:30 -07001734 }
1735 else{
Abhishek Singh3cbf6052014-12-15 16:46:42 +05301736 limLog(pMac, LOG1,
Jeff Johnson295189b2012-06-20 16:38:30 -07001737 FL("*** Sending ReAssoc Resp status %d aid %d to "),
Abhishek Singh3cbf6052014-12-15 16:46:42 +05301738 statusCode, aid);
Jeff Johnson295189b2012-06-20 16:38:30 -07001739 }
Abhishek Singh3cbf6052014-12-15 16:46:42 +05301740 limPrintMacAddr(pMac, pMacHdr->da, LOG1);
Jeff Johnson295189b2012-06-20 16:38:30 -07001741
1742 if ( addnIEPresent )
1743 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301744 vos_mem_copy ( pFrame+sizeof(tSirMacMgmtHdr)+nPayload, &addIE[0], addnIELen ) ;
Jeff Johnson295189b2012-06-20 16:38:30 -07001745 }
1746
1747 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07001748 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
1749 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07001750 )
1751 {
1752 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
1753 }
1754
Agarwal Ashisha8e81f52014-04-02 01:59:52 +05301755 limLog( pMac, LOG1, FL("Sending Assoc resp over WQ5 to "MAC_ADDRESS_STR
1756 " From " MAC_ADDRESS_STR),MAC_ADDR_ARRAY(pMacHdr->da),
1757 MAC_ADDR_ARRAY(psessionEntry->selfMacAddr));
1758
1759 txFlag |= HAL_USE_FW_IN_TX_PATH;
1760
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05301761 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
1762 psessionEntry->peSessionId,
1763 pMacHdr->fc.subType));
Ganesh Kondabattiniffc00b12015-03-18 13:11:33 +05301764
1765 if (IS_FEATURE_SUPPORTED_BY_FW(ENHANCED_TXBD_COMPLETION))
1766 {
Kapil Gupta956c0c42017-06-16 19:24:31 +05301767 limLog(pMac, LOG1, FL("Re/AssocRsp - txBdToken %u"),
1768 pMac->lim.txBdToken);
Ganesh Kondabattiniffc00b12015-03-18 13:11:33 +05301769 /// Queue Association Response frame in high priority WQ
Kapil Gupta956c0c42017-06-16 19:24:31 +05301770 if (tx_complete_context)
1771 {
1772 tx_complete_context->txBdToken = pMac->lim.txBdToken;
1773 halstatus = halTxFrameWithTxComplete(pMac, pPacket,
1774 (tANI_U16) nBytes,
1775 HAL_TXRX_FRM_802_11_MGMT,
1776 ANI_TXDIR_TODS,
1777 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
1778 limTxComplete, pFrame, limAssocRspTxCompleteCnf,
1779 txFlag, pMac->lim.txBdToken);
1780 }
1781 else
1782 halstatus = halTxFrameWithTxComplete(pMac, pPacket,
1783 (tANI_U16) nBytes,
Ganesh Kondabattiniffc00b12015-03-18 13:11:33 +05301784 HAL_TXRX_FRM_802_11_MGMT,
1785 ANI_TXDIR_TODS,
1786 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
1787 limTxComplete, pFrame, limTxBdComplete,
Kapil Gupta956c0c42017-06-16 19:24:31 +05301788 txFlag, pMac->lim.txBdToken);
1789
Ganesh Kondabattiniffc00b12015-03-18 13:11:33 +05301790 pMac->lim.txBdToken++;
1791 }
1792 else
1793 {
1794 /// Queue Association Response frame in high priority WQ
1795 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
1796 HAL_TXRX_FRM_802_11_MGMT,
1797 ANI_TXDIR_TODS,
1798 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
1799 limTxComplete, pFrame, txFlag );
1800 }
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05301801 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
1802 psessionEntry->peSessionId,
1803 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07001804 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1805 {
1806 limLog(pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001807 FL("*** Could not Send Re/AssocRsp, retCode=%X ***"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001808 nSirStatus);
1809
1810 //Pkt will be freed up by the callback
1811 }
1812
1813 // update the ANI peer station count
1814 //FIXME_PROTECTION : take care of different type of station
1815 // counter inside this function.
1816 limUtilCountStaAdd(pMac, pSta, psessionEntry);
1817
1818} // End limSendAssocRspMgmtFrame.
1819
1820
1821
1822void
1823limSendAddtsRspActionFrame(tpAniSirGlobal pMac,
1824 tSirMacAddr peer,
1825 tANI_U16 nStatusCode,
1826 tSirAddtsReqInfo *pAddTS,
1827 tSirMacScheduleIE *pSchedule,
1828 tpPESession psessionEntry)
1829{
1830 tANI_U8 *pFrame;
1831 tpSirMacMgmtHdr pMacHdr;
1832 tDot11fAddTSResponse AddTSRsp;
1833 tDot11fWMMAddTSResponse WMMAddTSRsp;
1834 tSirRetStatus nSirStatus;
1835 tANI_U32 i, nBytes, nPayload, nStatus;
1836 void *pPacket;
1837 eHalStatus halstatus;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05301838 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001839
1840 if(NULL == psessionEntry)
1841 {
1842 return;
1843 }
1844
1845 if ( ! pAddTS->wmeTspecPresent )
1846 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301847 vos_mem_set( ( tANI_U8* )&AddTSRsp, sizeof( AddTSRsp ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07001848
1849 AddTSRsp.Category.category = SIR_MAC_ACTION_QOS_MGMT;
1850 AddTSRsp.Action.action = SIR_MAC_QOS_ADD_TS_RSP;
1851 AddTSRsp.DialogToken.token = pAddTS->dialogToken;
1852 AddTSRsp.Status.status = nStatusCode;
1853
1854 // The TsDelay information element is only filled in for a specific
1855 // status code:
1856 if ( eSIR_MAC_TS_NOT_CREATED_STATUS == nStatusCode )
1857 {
1858 if ( pAddTS->wsmTspecPresent )
1859 {
1860 AddTSRsp.WMMTSDelay.version = 1;
1861 AddTSRsp.WMMTSDelay.delay = 10;
1862 AddTSRsp.WMMTSDelay.present = 1;
1863 }
1864 else
1865 {
1866 AddTSRsp.TSDelay.delay = 10;
1867 AddTSRsp.TSDelay.present = 1;
1868 }
1869 }
1870
1871 if ( pAddTS->wsmTspecPresent )
1872 {
1873 PopulateDot11fWMMTSPEC( &pAddTS->tspec, &AddTSRsp.WMMTSPEC );
1874 }
1875 else
1876 {
1877 PopulateDot11fTSPEC( &pAddTS->tspec, &AddTSRsp.TSPEC );
1878 }
1879
1880 if ( pAddTS->wsmTspecPresent )
1881 {
1882 AddTSRsp.num_WMMTCLAS = 0;
1883 AddTSRsp.num_TCLAS = pAddTS->numTclas;
1884 for ( i = 0; i < AddTSRsp.num_TCLAS; ++i)
1885 {
1886 PopulateDot11fTCLAS( pMac, &pAddTS->tclasInfo[i],
1887 &AddTSRsp.TCLAS[i] );
1888 }
1889 }
1890 else
1891 {
1892 AddTSRsp.num_TCLAS = 0;
1893 AddTSRsp.num_WMMTCLAS = pAddTS->numTclas;
1894 for ( i = 0; i < AddTSRsp.num_WMMTCLAS; ++i)
1895 {
1896 PopulateDot11fWMMTCLAS( pMac, &pAddTS->tclasInfo[i],
1897 &AddTSRsp.WMMTCLAS[i] );
1898 }
1899 }
1900
1901 if ( pAddTS->tclasProcPresent )
1902 {
1903 if ( pAddTS->wsmTspecPresent )
1904 {
1905 AddTSRsp.WMMTCLASPROC.version = 1;
1906 AddTSRsp.WMMTCLASPROC.processing = pAddTS->tclasProc;
1907 AddTSRsp.WMMTCLASPROC.present = 1;
1908 }
1909 else
1910 {
1911 AddTSRsp.TCLASSPROC.processing = pAddTS->tclasProc;
1912 AddTSRsp.TCLASSPROC.present = 1;
1913 }
1914 }
1915
1916 // schedule element is included only if requested in the tspec and we are
1917 // using hcca (or both edca and hcca)
1918 // 11e-D8.0 is inconsistent on whether the schedule element is included
1919 // based on tspec schedule bit or not. Sec 7.4.2.2. says one thing but
1920 // pg 46, line 17-18 says something else. So just include it and let the
1921 // sta figure it out
1922 if ((pSchedule != NULL) &&
1923 ((pAddTS->tspec.tsinfo.traffic.accessPolicy == SIR_MAC_ACCESSPOLICY_HCCA) ||
1924 (pAddTS->tspec.tsinfo.traffic.accessPolicy == SIR_MAC_ACCESSPOLICY_BOTH)))
1925 {
1926 if ( pAddTS->wsmTspecPresent )
1927 {
1928 PopulateDot11fWMMSchedule( pSchedule, &AddTSRsp.WMMSchedule );
1929 }
1930 else
1931 {
1932 PopulateDot11fSchedule( pSchedule, &AddTSRsp.Schedule );
1933 }
1934 }
1935
1936 nStatus = dot11fGetPackedAddTSResponseSize( pMac, &AddTSRsp, &nPayload );
1937 if ( DOT11F_FAILED( nStatus ) )
1938 {
1939 limLog( pMac, LOGP, FL("Failed to calculate the packed si"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001940 "ze for an Add TS Response (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001941 nStatus );
1942 // We'll fall back on the worst case scenario:
1943 nPayload = sizeof( tDot11fAddTSResponse );
1944 }
1945 else if ( DOT11F_WARNED( nStatus ) )
1946 {
1947 limLog( pMac, LOGW, FL("There were warnings while calcula"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001948 "ting the packed size for an Add TS"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001949 " Response (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001950 }
1951 }
1952 else
1953 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301954 vos_mem_set( ( tANI_U8* )&WMMAddTSRsp, sizeof( WMMAddTSRsp ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07001955
1956 WMMAddTSRsp.Category.category = SIR_MAC_ACTION_WME;
1957 WMMAddTSRsp.Action.action = SIR_MAC_QOS_ADD_TS_RSP;
1958 WMMAddTSRsp.DialogToken.token = pAddTS->dialogToken;
1959 WMMAddTSRsp.StatusCode.statusCode = (tANI_U8)nStatusCode;
1960
1961 PopulateDot11fWMMTSPEC( &pAddTS->tspec, &WMMAddTSRsp.WMMTSPEC );
1962
1963 nStatus = dot11fGetPackedWMMAddTSResponseSize( pMac, &WMMAddTSRsp, &nPayload );
1964 if ( DOT11F_FAILED( nStatus ) )
1965 {
1966 limLog( pMac, LOGP, FL("Failed to calculate the packed si"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001967 "ze for a WMM Add TS Response (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001968 nStatus );
1969 // We'll fall back on the worst case scenario:
1970 nPayload = sizeof( tDot11fWMMAddTSResponse );
1971 }
1972 else if ( DOT11F_WARNED( nStatus ) )
1973 {
1974 limLog( pMac, LOGW, FL("There were warnings while calcula"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001975 "ting the packed size for a WMM Add"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001976 "TS Response (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001977 }
1978 }
1979
1980 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
1981
1982 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
1983 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1984 {
1985 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for an Ad"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001986 "d TS Response."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07001987 return;
1988 }
1989
1990 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301991 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07001992
1993 // Next, we fill out the buffer descriptor:
1994 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
1995 SIR_MAC_MGMT_ACTION, peer,psessionEntry->selfMacAddr);
1996 if ( eSIR_SUCCESS != nSirStatus )
1997 {
1998 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001999 "tor for an Add TS Response (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002000 nSirStatus );
2001 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
2002 return; // allocated!
2003 }
2004
2005 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
2006
2007
2008 #if 0
2009 if ( eSIR_SUCCESS != wlan_cfgGetStr( pMac, WNI_CFG_BSSID,
2010 ( tANI_U8* )pMacHdr->bssId, &cfgLen ) )
2011 {
2012 limLog( pMac, LOGP, FL("Failed to retrieve WNI_CFG_BSSID whil"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002013 "e sending an Add TS Response.") );
Jeff Johnson295189b2012-06-20 16:38:30 -07002014 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
2015 return; // allocated!
2016 }
2017 #endif //TO SUPPORT BT-AMP
2018 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
2019
Chet Lanctot186b5732013-03-18 10:26:30 -07002020#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07002021 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07002022#endif
2023
Jeff Johnson295189b2012-06-20 16:38:30 -07002024 // That done, pack the struct:
2025 if ( ! pAddTS->wmeTspecPresent )
2026 {
2027 nStatus = dot11fPackAddTSResponse( pMac, &AddTSRsp,
2028 pFrame + sizeof( tSirMacMgmtHdr ),
2029 nPayload, &nPayload );
2030 if ( DOT11F_FAILED( nStatus ) )
2031 {
2032 limLog( pMac, LOGE, FL("Failed to pack an Add TS Response "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002033 "(0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002034 nStatus );
2035 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
2036 return;
2037 }
2038 else if ( DOT11F_WARNED( nStatus ) )
2039 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08002040 limLog( pMac, LOGW, FL("There were warnings while packing "
2041 "an Add TS Response (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07002042 }
2043 }
2044 else
2045 {
2046 nStatus = dot11fPackWMMAddTSResponse( pMac, &WMMAddTSRsp,
2047 pFrame + sizeof( tSirMacMgmtHdr ),
2048 nPayload, &nPayload );
2049 if ( DOT11F_FAILED( nStatus ) )
2050 {
2051 limLog( pMac, LOGE, FL("Failed to pack a WMM Add TS Response "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002052 "(0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002053 nStatus );
2054 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
2055 return;
2056 }
2057 else if ( DOT11F_WARNED( nStatus ) )
2058 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08002059 limLog( pMac, LOGW, FL("There were warnings while packing "
2060 "a WMM Add TS Response (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07002061 }
2062 }
2063
Abhishek Singh3cbf6052014-12-15 16:46:42 +05302064 limLog( pMac, LOG1, FL("Sending an Add TS Response (status %d) to "),
Jeff Johnson295189b2012-06-20 16:38:30 -07002065 nStatusCode );
Abhishek Singh3cbf6052014-12-15 16:46:42 +05302066 limPrintMacAddr( pMac, pMacHdr->da, LOG1 );
Jeff Johnson295189b2012-06-20 16:38:30 -07002067
2068 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07002069 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
2070 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07002071 )
2072 {
2073 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
2074 }
2075
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05302076 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
2077 psessionEntry->peSessionId,
2078 pMacHdr->fc.subType));
Jeff Johnson295189b2012-06-20 16:38:30 -07002079 // Queue the frame in high priority WQ:
2080 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
2081 HAL_TXRX_FRM_802_11_MGMT,
2082 ANI_TXDIR_TODS,
2083 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
2084 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05302085 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
2086 psessionEntry->peSessionId,
2087 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07002088 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
2089 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002090 limLog( pMac, LOGE, FL("Failed to send Add TS Response (%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002091 nSirStatus );
2092 //Pkt will be freed up by the callback
2093 }
2094
2095} // End limSendAddtsRspActionFrame.
2096
2097void
2098limSendDeltsReqActionFrame(tpAniSirGlobal pMac,
2099 tSirMacAddr peer,
2100 tANI_U8 wmmTspecPresent,
2101 tSirMacTSInfo *pTsinfo,
2102 tSirMacTspecIE *pTspecIe,
2103 tpPESession psessionEntry)
2104{
2105 tANI_U8 *pFrame;
2106 tpSirMacMgmtHdr pMacHdr;
2107 tDot11fDelTS DelTS;
2108 tDot11fWMMDelTS WMMDelTS;
2109 tSirRetStatus nSirStatus;
2110 tANI_U32 nBytes, nPayload, nStatus;
2111 void *pPacket;
2112 eHalStatus halstatus;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05302113 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002114
2115 if(NULL == psessionEntry)
2116 {
2117 return;
2118 }
2119
2120 if ( ! wmmTspecPresent )
2121 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302122 vos_mem_set( ( tANI_U8* )&DelTS, sizeof( DelTS ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07002123
2124 DelTS.Category.category = SIR_MAC_ACTION_QOS_MGMT;
2125 DelTS.Action.action = SIR_MAC_QOS_DEL_TS_REQ;
2126 PopulateDot11fTSInfo( pTsinfo, &DelTS.TSInfo );
2127
2128 nStatus = dot11fGetPackedDelTSSize( pMac, &DelTS, &nPayload );
2129 if ( DOT11F_FAILED( nStatus ) )
2130 {
2131 limLog( pMac, LOGP, FL("Failed to calculate the packed si"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002132 "ze for a Del TS (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002133 nStatus );
2134 // We'll fall back on the worst case scenario:
2135 nPayload = sizeof( tDot11fDelTS );
2136 }
2137 else if ( DOT11F_WARNED( nStatus ) )
2138 {
2139 limLog( pMac, LOGW, FL("There were warnings while calcula"
2140 "ting the packed size for a Del TS"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002141 " (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07002142 }
2143 }
2144 else
2145 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302146 vos_mem_set( ( tANI_U8* )&WMMDelTS, sizeof( WMMDelTS ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07002147
2148 WMMDelTS.Category.category = SIR_MAC_ACTION_WME;
2149 WMMDelTS.Action.action = SIR_MAC_QOS_DEL_TS_REQ;
2150 WMMDelTS.DialogToken.token = 0;
2151 WMMDelTS.StatusCode.statusCode = 0;
2152 PopulateDot11fWMMTSPEC( pTspecIe, &WMMDelTS.WMMTSPEC );
2153 nStatus = dot11fGetPackedWMMDelTSSize( pMac, &WMMDelTS, &nPayload );
2154 if ( DOT11F_FAILED( nStatus ) )
2155 {
2156 limLog( pMac, LOGP, FL("Failed to calculate the packed si"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002157 "ze for a WMM Del TS (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002158 nStatus );
2159 // We'll fall back on the worst case scenario:
2160 nPayload = sizeof( tDot11fDelTS );
2161 }
2162 else if ( DOT11F_WARNED( nStatus ) )
2163 {
2164 limLog( pMac, LOGW, FL("There were warnings while calcula"
2165 "ting the packed size for a WMM De"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002166 "l TS (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07002167 }
2168 }
2169
2170 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
2171
2172 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
2173 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
2174 {
2175 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for an Ad"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002176 "d TS Response."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07002177 return;
2178 }
2179
2180 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302181 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07002182
2183 // Next, we fill out the buffer descriptor:
2184 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
2185 SIR_MAC_MGMT_ACTION, peer,
2186 psessionEntry->selfMacAddr);
2187 if ( eSIR_SUCCESS != nSirStatus )
2188 {
2189 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002190 "tor for an Add TS Response (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002191 nSirStatus );
2192 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
2193 return; // allocated!
2194 }
2195
2196 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
2197
2198 #if 0
2199
2200 cfgLen = SIR_MAC_ADDR_LENGTH;
2201 if ( eSIR_SUCCESS != wlan_cfgGetStr( pMac, WNI_CFG_BSSID,
2202 ( tANI_U8* )pMacHdr->bssId, &cfgLen ) )
2203 {
2204 limLog( pMac, LOGP, FL("Failed to retrieve WNI_CFG_BSSID whil"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002205 "e sending an Add TS Response.") );
Jeff Johnson295189b2012-06-20 16:38:30 -07002206 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
2207 return; // allocated!
2208 }
2209 #endif //TO SUPPORT BT-AMP
2210 sirCopyMacAddr(pMacHdr->bssId, psessionEntry->bssId);
2211
Chet Lanctot186b5732013-03-18 10:26:30 -07002212#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07002213 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07002214#endif
2215
Jeff Johnson295189b2012-06-20 16:38:30 -07002216 // That done, pack the struct:
2217 if ( !wmmTspecPresent )
2218 {
2219 nStatus = dot11fPackDelTS( pMac, &DelTS,
2220 pFrame + sizeof( tSirMacMgmtHdr ),
2221 nPayload, &nPayload );
2222 if ( DOT11F_FAILED( nStatus ) )
2223 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002224 limLog( pMac, LOGE, FL("Failed to pack a Del TS frame (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002225 nStatus );
2226 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
2227 return; // allocated!
2228 }
2229 else if ( DOT11F_WARNED( nStatus ) )
2230 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08002231 limLog( pMac, LOGW, FL("There were warnings while packing "
2232 "a Del TS frame (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07002233 }
2234 }
2235 else
2236 {
2237 nStatus = dot11fPackWMMDelTS( pMac, &WMMDelTS,
2238 pFrame + sizeof( tSirMacMgmtHdr ),
2239 nPayload, &nPayload );
2240 if ( DOT11F_FAILED( nStatus ) )
2241 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002242 limLog( pMac, LOGE, FL("Failed to pack a WMM Del TS frame (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002243 nStatus );
2244 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
2245 return; // allocated!
2246 }
2247 else if ( DOT11F_WARNED( nStatus ) )
2248 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08002249 limLog( pMac, LOGW, FL("There were warnings while packing "
2250 "a WMM Del TS frame (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07002251 }
2252 }
2253
Abhishek Singh3cbf6052014-12-15 16:46:42 +05302254 limLog(pMac, LOG1, FL("Sending DELTS REQ (size %d) to "), nBytes);
2255 limPrintMacAddr(pMac, pMacHdr->da, LOG1);
Jeff Johnson295189b2012-06-20 16:38:30 -07002256
2257 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07002258 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
2259 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07002260 )
2261 {
2262 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
2263 }
2264
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05302265 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
2266 psessionEntry->peSessionId,
2267 pMacHdr->fc.subType));
Jeff Johnson295189b2012-06-20 16:38:30 -07002268 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
2269 HAL_TXRX_FRM_802_11_MGMT,
2270 ANI_TXDIR_TODS,
2271 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
2272 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05302273 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
2274 psessionEntry->peSessionId,
2275 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07002276 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
2277 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002278 limLog( pMac, LOGE, FL("Failed to send Del TS (%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002279 nSirStatus );
2280 //Pkt will be freed up by the callback
2281 }
2282
2283} // End limSendDeltsReqActionFrame.
2284
2285void
2286limSendAssocReqMgmtFrame(tpAniSirGlobal pMac,
2287 tLimMlmAssocReq *pMlmAssocReq,
2288 tpPESession psessionEntry)
2289{
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002290 tDot11fAssocRequest *pFrm;
Jeff Johnson295189b2012-06-20 16:38:30 -07002291 tANI_U16 caps;
2292 tANI_U8 *pFrame;
Agrawal Ashish5ac89da2015-10-26 19:08:47 +05302293 tSirRetStatus nSirStatus = eSIR_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07002294 tLimMlmAssocCnf mlmAssocCnf;
c_hpothubcd78652014-04-28 22:31:08 +05302295 tANI_U32 nPayload, nStatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07002296 tANI_U8 fQosEnabled, fWmeEnabled, fWsmEnabled;
2297 void *pPacket;
2298 eHalStatus halstatus;
2299 tANI_U16 nAddIELen;
2300 tANI_U8 *pAddIE;
2301 tANI_U8 *wpsIe = NULL;
2302#if defined WLAN_FEATURE_VOWIFI
2303 tANI_U8 PowerCapsPopulated = FALSE;
2304#endif
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05302305 tANI_U32 txFlag = 0;
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05302306 tpSirMacMgmtHdr pMacHdr;
Kalikinkar dhara205da782014-03-21 15:49:32 -07002307 tDot11fIEExtCap extractedExtCap;
2308 tANI_BOOLEAN extractedExtCapFlag = eANI_BOOLEAN_TRUE;
c_hpothubcd78652014-04-28 22:31:08 +05302309 tANI_U32 nBytes = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002310
2311 if(NULL == psessionEntry)
2312 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05302313 limLog(pMac, LOGE, FL("psessionEntry is NULL") );
Jeff Johnson295189b2012-06-20 16:38:30 -07002314 return;
2315 }
2316
Jeff Johnson295189b2012-06-20 16:38:30 -07002317 /* check this early to avoid unncessary operation */
2318 if(NULL == psessionEntry->pLimJoinReq)
2319 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05302320 limLog(pMac, LOGE, FL("psessionEntry->pLimJoinReq is NULL") );
Jeff Johnson295189b2012-06-20 16:38:30 -07002321 return;
2322 }
2323 nAddIELen = psessionEntry->pLimJoinReq->addIEAssoc.length;
2324 pAddIE = psessionEntry->pLimJoinReq->addIEAssoc.addIEdata;
2325
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302326 pFrm = vos_mem_malloc(sizeof(tDot11fAssocRequest));
2327 if ( NULL == pFrm )
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002328 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05302329 limLog(pMac, LOGE, FL("Unable to allocate memory") );
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002330 return;
2331 }
2332
2333
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302334 vos_mem_set( ( tANI_U8* )pFrm, sizeof( tDot11fAssocRequest ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07002335
Kalikinkar dhara205da782014-03-21 15:49:32 -07002336 vos_mem_set(( tANI_U8* )&extractedExtCap, sizeof( tDot11fIEExtCap ), 0);
Hu Wang5193b572016-08-11 10:04:47 +08002337 if (psessionEntry->ExtCap.present)
Agrawal Ashish5ac89da2015-10-26 19:08:47 +05302338 {
2339 nSirStatus = limStripOffExtCapIEAndUpdateStruct(pMac, pAddIE,
Kalikinkar dhara205da782014-03-21 15:49:32 -07002340 &nAddIELen,
2341 &extractedExtCap );
Agrawal Ashish5ac89da2015-10-26 19:08:47 +05302342 }
Kalikinkar dhara205da782014-03-21 15:49:32 -07002343 if(eSIR_SUCCESS != nSirStatus )
2344 {
2345 extractedExtCapFlag = eANI_BOOLEAN_FALSE;
2346 limLog(pMac, LOG1,
2347 FL("Unable to Stripoff ExtCap IE from Assoc Req"));
2348 }
Leela Venkata Kiran Kumar Reddy Chirala2f9b5712014-05-06 00:09:42 -07002349 /* TODO:remove this code once driver provides the call back function
2350 * to supplicant for set_qos_map
2351 */
2352 else
2353 {
Hu Wangc12631c2016-08-11 09:57:03 +08002354 struct s_ext_cap *p_ext_cap = (struct s_ext_cap *)extractedExtCap.bytes;
2355 if (p_ext_cap->interworkingService) {
2356 p_ext_cap->qosMap = 1;
2357 }
2358 extractedExtCap.num_bytes = lim_compute_ext_cap_ie_length(&extractedExtCap);
2359 extractedExtCapFlag = (extractedExtCap.num_bytes > 0);
Leela Venkata Kiran Kumar Reddy Chirala2f9b5712014-05-06 00:09:42 -07002360 }
Kalikinkar dhara205da782014-03-21 15:49:32 -07002361
Jeff Johnson295189b2012-06-20 16:38:30 -07002362 caps = pMlmAssocReq->capabilityInfo;
2363 if ( PROP_CAPABILITY_GET( 11EQOS, psessionEntry->limCurrentBssPropCap ) )
2364 ((tSirMacCapabilityInfo *) &caps)->qos = 0;
2365#if defined(FEATURE_WLAN_WAPI)
2366 /* CR: 262463 :
2367 According to WAPI standard:
2368 7.3.1.4 Capability Information field
2369 In WAPI, non-AP STAs within an ESS set the Privacy subfield to 0 in transmitted
2370 Association or Reassociation management frames. APs ignore the Privacy subfield within received Association and
2371 Reassociation management frames. */
2372 if ( psessionEntry->encryptType == eSIR_ED_WPI)
2373 ((tSirMacCapabilityInfo *) &caps)->privacy = 0;
2374#endif
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002375 swapBitField16(caps, ( tANI_U16* )&pFrm->Capabilities );
Jeff Johnson295189b2012-06-20 16:38:30 -07002376
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002377 pFrm->ListenInterval.interval = pMlmAssocReq->listenInterval;
2378 PopulateDot11fSSID2( pMac, &pFrm->SSID );
Jeff Johnson295189b2012-06-20 16:38:30 -07002379 PopulateDot11fSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002380 &pFrm->SuppRates,psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07002381
2382 fQosEnabled = ( psessionEntry->limQosEnabled) &&
2383 SIR_MAC_GET_QOS( psessionEntry->limCurrentBssCaps );
2384
2385 fWmeEnabled = ( psessionEntry->limWmeEnabled ) &&
2386 LIM_BSS_CAPS_GET( WME, psessionEntry->limCurrentBssQosCaps );
2387
2388 // We prefer .11e asociations:
2389 if ( fQosEnabled ) fWmeEnabled = false;
2390
2391 fWsmEnabled = ( psessionEntry->limWsmEnabled ) && fWmeEnabled &&
2392 LIM_BSS_CAPS_GET( WSM, psessionEntry->limCurrentBssQosCaps );
2393
2394 if ( psessionEntry->lim11hEnable &&
2395 psessionEntry->pLimJoinReq->spectrumMgtIndicator == eSIR_TRUE )
2396 {
2397#if defined WLAN_FEATURE_VOWIFI
2398 PowerCapsPopulated = TRUE;
2399
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002400 PopulateDot11fPowerCaps( pMac, &pFrm->PowerCaps, LIM_ASSOC,psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07002401#endif
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002402 PopulateDot11fSuppChannels( pMac, &pFrm->SuppChannels, LIM_ASSOC,psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07002403
2404 }
2405
2406#if defined WLAN_FEATURE_VOWIFI
2407 if( pMac->rrm.rrmPEContext.rrmEnable &&
2408 SIR_MAC_GET_RRM( psessionEntry->limCurrentBssCaps ) )
2409 {
2410 if (PowerCapsPopulated == FALSE)
2411 {
2412 PowerCapsPopulated = TRUE;
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002413 PopulateDot11fPowerCaps(pMac, &pFrm->PowerCaps, LIM_ASSOC, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07002414 }
2415 }
2416#endif
2417
2418 if ( fQosEnabled &&
2419 ( ! PROP_CAPABILITY_GET(11EQOS, psessionEntry->limCurrentBssPropCap)))
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002420 PopulateDot11fQOSCapsStation( pMac, &pFrm->QOSCapsStation );
Jeff Johnson295189b2012-06-20 16:38:30 -07002421
2422 PopulateDot11fExtSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002423 &pFrm->ExtSuppRates, psessionEntry );
Jeff Johnson295189b2012-06-20 16:38:30 -07002424
2425#if defined WLAN_FEATURE_VOWIFI
2426 if( pMac->rrm.rrmPEContext.rrmEnable &&
2427 SIR_MAC_GET_RRM( psessionEntry->limCurrentBssCaps ) )
2428 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002429 PopulateDot11fRRMIe( pMac, &pFrm->RRMEnabledCap, psessionEntry );
Jeff Johnson295189b2012-06-20 16:38:30 -07002430 }
2431#endif
2432 // The join request *should* contain zero or one of the WPA and RSN
2433 // IEs. The payload send along with the request is a
2434 // 'tSirSmeJoinReq'; the IE portion is held inside a 'tSirRSNie':
2435
2436 // typedef struct sSirRSNie
2437 // {
2438 // tANI_U16 length;
2439 // tANI_U8 rsnIEdata[SIR_MAC_MAX_IE_LENGTH+2];
2440 // } tSirRSNie, *tpSirRSNie;
2441
2442 // So, we should be able to make the following two calls harmlessly,
2443 // since they do nothing if they don't find the given IE in the
2444 // bytestream with which they're provided.
2445
2446 // The net effect of this will be to faithfully transmit whatever
2447 // security IE is in the join request.
2448
2449 // *However*, if we're associating for the purpose of WPS
2450 // enrollment, and we've been configured to indicate that by
2451 // eliding the WPA or RSN IE, we just skip this:
2452 if( nAddIELen && pAddIE )
2453 {
2454 wpsIe = limGetWscIEPtr (pMac, pAddIE, nAddIELen);
2455 }
2456 if ( NULL == wpsIe )
2457 {
2458 PopulateDot11fRSNOpaque( pMac, &( psessionEntry->pLimJoinReq->rsnIE ),
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002459 &pFrm->RSNOpaque );
Jeff Johnson295189b2012-06-20 16:38:30 -07002460 PopulateDot11fWPAOpaque( pMac, &( psessionEntry->pLimJoinReq->rsnIE ),
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002461 &pFrm->WPAOpaque );
Jeff Johnson295189b2012-06-20 16:38:30 -07002462#if defined(FEATURE_WLAN_WAPI)
2463 PopulateDot11fWAPIOpaque( pMac, &( psessionEntry->pLimJoinReq->rsnIE ),
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002464 &pFrm->WAPIOpaque );
Jeff Johnson295189b2012-06-20 16:38:30 -07002465#endif // defined(FEATURE_WLAN_WAPI)
2466 }
2467
2468 // include WME EDCA IE as well
2469 if ( fWmeEnabled )
2470 {
2471 if ( ! PROP_CAPABILITY_GET( WME, psessionEntry->limCurrentBssPropCap ) )
2472 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002473 PopulateDot11fWMMInfoStation( pMac, &pFrm->WMMInfoStation );
Jeff Johnson295189b2012-06-20 16:38:30 -07002474 }
2475
2476 if ( fWsmEnabled &&
2477 ( ! PROP_CAPABILITY_GET(WSM, psessionEntry->limCurrentBssPropCap )))
2478 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002479 PopulateDot11fWMMCaps( &pFrm->WMMCaps );
Jeff Johnson295189b2012-06-20 16:38:30 -07002480 }
2481 }
2482
2483 //Populate HT IEs, when operating in 11n or Taurus modes AND
2484 //when AP is also operating in 11n mode.
Jeff Johnsone7245742012-09-05 17:12:55 -07002485 if ( psessionEntry->htCapability &&
Jeff Johnson295189b2012-06-20 16:38:30 -07002486 pMac->lim.htCapabilityPresentInBeacon)
2487 {
Krishna Kumaar Natarajan025a8602015-08-04 16:31:36 +05302488 limLog(pMac, LOG1, FL("Populate HT IEs in Assoc Request"));
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002489 PopulateDot11fHTCaps( pMac, psessionEntry, &pFrm->HTCaps );
Jeff Johnson295189b2012-06-20 16:38:30 -07002490#ifdef DISABLE_GF_FOR_INTEROP
2491
2492 /*
2493 * To resolve the interop problem with Broadcom AP,
2494 * where TQ STA could not pass traffic with GF enabled,
2495 * TQ STA will do Greenfield only with TQ AP, for
2496 * everybody else it will be turned off.
2497 */
2498
2499 if( (psessionEntry->pLimJoinReq != NULL) && (!psessionEntry->pLimJoinReq->bssDescription.aniIndicator))
2500 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05302501 limLog( pMac, LOG1, FL("Sending Assoc Req to Non-TQ AP,"
2502 " Turning off Greenfield"));
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002503 pFrm->HTCaps.greenField = WNI_CFG_GREENFIELD_CAPABILITY_DISABLE;
Jeff Johnson295189b2012-06-20 16:38:30 -07002504 }
2505#endif
2506
2507 }
Agrawal Ashishb10d0392015-08-06 16:18:20 +05302508
2509 limLog(pMac, LOG1, FL("SupportedChnlWidth: %d, mimoPS: %d, GF: %d,"
2510 "shortGI20:%d, shortGI40: %d, dsssCck: %d, AMPDU Param: %x"),
2511 pFrm->HTCaps.supportedChannelWidthSet, pFrm->HTCaps.mimoPowerSave,
2512 pFrm->HTCaps.greenField, pFrm->HTCaps.shortGI20MHz, pFrm->HTCaps.shortGI40MHz,
2513 pFrm->HTCaps.dsssCckMode40MHz, pFrm->HTCaps.maxRxAMPDUFactor);
2514
2515
Jeff Johnsone7245742012-09-05 17:12:55 -07002516#ifdef WLAN_FEATURE_11AC
2517 if ( psessionEntry->vhtCapability &&
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07002518 psessionEntry->vhtCapabilityPresentInBeacon)
Jeff Johnsone7245742012-09-05 17:12:55 -07002519 {
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07002520 limLog( pMac, LOG1, FL("Populate VHT IEs in Assoc Request"));
Abhishek Singh33f76ea2015-06-04 12:27:30 +05302521 PopulateDot11fVHTCaps( pMac, &pFrm->VHTCaps,
2522 psessionEntry->currentOperChannel, eSIR_FALSE );
Abhishek Singhe038dc62015-05-22 11:36:45 +05302523
Jeff Johnsone7245742012-09-05 17:12:55 -07002524 }
2525#endif
Hu Wang5193b572016-08-11 10:04:47 +08002526 if (psessionEntry->ExtCap.present)
Agrawal Ashish5ac89da2015-10-26 19:08:47 +05302527 PopulateDot11fExtCap( pMac, &pFrm->ExtCap, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07002528
2529#if defined WLAN_FEATURE_VOWIFI_11R
2530 if (psessionEntry->pLimJoinReq->is11Rconnection)
2531 {
2532#if defined WLAN_FEATURE_VOWIFI_11R_DEBUG
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002533 limLog( pMac, LOG1, FL("mdie = %02x %02x %02x"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002534 (unsigned int)psessionEntry->pLimJoinReq->bssDescription.mdie[0],
2535 (unsigned int)psessionEntry->pLimJoinReq->bssDescription.mdie[1],
2536 (unsigned int)psessionEntry->pLimJoinReq->bssDescription.mdie[2]);
2537#endif
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302538 PopulateMDIE( pMac, &pFrm->MobilityDomain,
2539 psessionEntry->pLimJoinReq->bssDescription.mdie);
Jeff Johnson295189b2012-06-20 16:38:30 -07002540 }
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302541 else
Jeff Johnson295189b2012-06-20 16:38:30 -07002542 {
2543 // No 11r IEs dont send any MDIE
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302544 limLog( pMac, LOG1, FL("MDIE not present"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002545 }
2546#endif
2547
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002548#ifdef FEATURE_WLAN_ESE
2549 /* For ESE Associations fill the ESE IEs */
2550 if (psessionEntry->isESEconnection &&
2551 psessionEntry->pLimJoinReq->isESEFeatureIniEnabled)
Jeff Johnson295189b2012-06-20 16:38:30 -07002552 {
Varun Reddy Yeturu30779b42013-04-09 09:57:16 -07002553#ifndef FEATURE_DISABLE_RM
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002554 PopulateDot11fESERadMgmtCap(&pFrm->ESERadMgmtCap);
Varun Reddy Yeturu30779b42013-04-09 09:57:16 -07002555#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002556 PopulateDot11fESEVersion(&pFrm->ESEVersion);
Jeff Johnson295189b2012-06-20 16:38:30 -07002557 }
2558#endif
2559
c_hpothubcd78652014-04-28 22:31:08 +05302560 /* merge the ExtCap struct*/
2561 if (extractedExtCapFlag && extractedExtCap.present)
2562 {
Hu Wang5193b572016-08-11 10:04:47 +08002563 limMergeExtCapIEStruct(&pFrm->ExtCap, &extractedExtCap, true);
2564 }
2565
2566 if (pFrm->ExtCap.present && psessionEntry->ExtCap.present) {
2567 limMergeExtCapIEStruct(&pFrm->ExtCap, &psessionEntry->ExtCap, false);
2568 limLog(pMac, LOG1,
2569 FL("Clear the bits in EXTCAP IE that AP don't support to avoid IoT issues."));
c_hpothubcd78652014-04-28 22:31:08 +05302570 }
2571
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002572 nStatus = dot11fGetPackedAssocRequestSize( pMac, pFrm, &nPayload );
Jeff Johnson295189b2012-06-20 16:38:30 -07002573 if ( DOT11F_FAILED( nStatus ) )
2574 {
2575 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002576 "or an Association Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002577 nStatus );
2578 // We'll fall back on the worst case scenario:
2579 nPayload = sizeof( tDot11fAssocRequest );
2580 }
2581 else if ( DOT11F_WARNED( nStatus ) )
2582 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08002583 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07002584 "the packed size for an Association Re "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002585 "quest(0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07002586 }
2587
2588 nBytes = nPayload + sizeof( tSirMacMgmtHdr ) + nAddIELen;
2589
2590 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
2591 ( tANI_U16 )nBytes, ( void** ) &pFrame,
2592 ( void** ) &pPacket );
2593 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
2594 {
2595 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for an As"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002596 "sociation Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07002597
2598 psessionEntry->limMlmState = psessionEntry->limPrevMlmState;
Jeff Johnsone7245742012-09-05 17:12:55 -07002599 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07002600
2601
2602 /* Update PE session id*/
2603 mlmAssocCnf.sessionId = psessionEntry->peSessionId;
2604
2605 mlmAssocCnf.resultCode = eSIR_SME_RESOURCES_UNAVAILABLE;
2606
2607 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
2608 ( void* ) pFrame, ( void* ) pPacket );
2609
2610 limPostSmeMessage( pMac, LIM_MLM_ASSOC_CNF,
2611 ( tANI_U32* ) &mlmAssocCnf);
2612
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302613 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -07002614 return;
2615 }
2616
2617 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302618 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07002619
2620 // Next, we fill out the buffer descriptor:
2621 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
2622 SIR_MAC_MGMT_ASSOC_REQ, psessionEntry->bssId,psessionEntry->selfMacAddr);
2623 if ( eSIR_SUCCESS != nSirStatus )
2624 {
2625 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002626 "tor for an Association Request (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002627 nSirStatus );
2628 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302629 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -07002630 return;
2631 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002632
Abhishek Singh57aebef2014-02-03 18:47:44 +05302633 // That done, pack the Assoc Request:
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002634 nStatus = dot11fPackAssocRequest( pMac, pFrm, pFrame +
Jeff Johnson295189b2012-06-20 16:38:30 -07002635 sizeof(tSirMacMgmtHdr),
2636 nPayload, &nPayload );
2637 if ( DOT11F_FAILED( nStatus ) )
2638 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05302639 limLog( pMac, LOGE, FL("Failed to pack a Assoc Request (0x%0"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002640 "8x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002641 nStatus );
2642 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
2643 ( void* ) pFrame, ( void* ) pPacket );
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302644 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -07002645 return;
2646 }
2647 else if ( DOT11F_WARNED( nStatus ) )
2648 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05302649 limLog( pMac, LOGW, FL("There were warnings while packing a Assoc"
2650 "Request (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07002651 }
2652
2653 PELOG1(limLog( pMac, LOG1, FL("*** Sending Association Request length %d"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002654 "to "),
Jeff Johnson295189b2012-06-20 16:38:30 -07002655 nBytes );)
2656 // limPrintMacAddr( pMac, bssid, LOG1 );
2657
2658 if( psessionEntry->assocReq != NULL )
2659 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302660 vos_mem_free(psessionEntry->assocReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07002661 psessionEntry->assocReq = NULL;
2662 }
2663
2664 if( nAddIELen )
2665 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302666 vos_mem_copy( pFrame + sizeof(tSirMacMgmtHdr) + nPayload,
2667 pAddIE,
2668 nAddIELen );
Jeff Johnson295189b2012-06-20 16:38:30 -07002669 nPayload += nAddIELen;
2670 }
2671
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302672 psessionEntry->assocReq = vos_mem_malloc(nPayload);
2673 if ( NULL == psessionEntry->assocReq )
Jeff Johnson295189b2012-06-20 16:38:30 -07002674 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05302675 PELOGE(limLog(pMac, LOGE, FL("Unable to allocate memory to store "
2676 "assoc request"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07002677 }
2678 else
2679 {
2680 //Store the Assoc request. This is sent to csr/hdd in join cnf response.
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302681 vos_mem_copy( psessionEntry->assocReq, pFrame + sizeof(tSirMacMgmtHdr), nPayload);
Jeff Johnson295189b2012-06-20 16:38:30 -07002682 psessionEntry->assocReqLen = nPayload;
2683 }
2684
2685 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07002686 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
2687 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07002688 )
2689 {
2690 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
2691 }
2692
Sushant Kaushike8681d22015-04-21 12:08:25 +05302693 if(psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ||
2694 psessionEntry->pePersona == VOS_STA_MODE)
Ganesh K08bce952012-12-13 15:04:41 -08002695 {
2696 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
2697 }
Deepthi Gowri639d5042015-11-16 20:23:39 +05302698#ifdef FEATURE_WLAN_DIAG_SUPPORT
2699 limDiagEventReport(pMac, WLAN_PE_DIAG_ASSOC_START_EVENT, psessionEntry,
2700 eSIR_SUCCESS, eSIR_SUCCESS);
2701#endif
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05302702 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
Agarwal Ashisha8e81f52014-04-02 01:59:52 +05302703 limLog( pMac, LOG1, FL("Sending Assoc req over WQ5 to "MAC_ADDRESS_STR
2704 " From " MAC_ADDRESS_STR),MAC_ADDR_ARRAY(pMacHdr->da),
2705 MAC_ADDR_ARRAY(psessionEntry->selfMacAddr));
2706 txFlag |= HAL_USE_FW_IN_TX_PATH;
2707
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05302708 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
2709 psessionEntry->peSessionId,
2710 pMacHdr->fc.subType));
Katya Nigam63902932014-06-26 19:04:23 +05302711
Masti, Narayanraddi67ea5912015-01-08 12:34:05 +05302712 if( ( psessionEntry->is11Gonly == true ) &&
2713 ( !IS_BROADCAST_MAC(pMlmAssocReq->peerMacAddr) ) ){
2714 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
2715 }
Ganesh Kondabattiniffc00b12015-03-18 13:11:33 +05302716 if (IS_FEATURE_SUPPORTED_BY_FW(ENHANCED_TXBD_COMPLETION))
2717 {
2718 limLog(pMac, LOG1, FL("Assoc Req - txBdToken %u"), pMac->lim.txBdToken);
2719 halstatus = halTxFrameWithTxComplete( pMac, pPacket,
2720 ( tANI_U16 ) (sizeof(tSirMacMgmtHdr) + nPayload),
2721 HAL_TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS,
2722 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
2723 limTxComplete, pFrame, limTxBdComplete, txFlag,
2724 pMac->lim.txBdToken);
2725 pMac->lim.txBdToken++;
2726 }
2727 else
2728 {
2729 halstatus = halTxFrame( pMac, pPacket,
2730 ( tANI_U16 ) (sizeof(tSirMacMgmtHdr) + nPayload),
2731 HAL_TXRX_FRM_802_11_MGMT,
2732 ANI_TXDIR_TODS,
2733 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
2734 limTxComplete, pFrame, txFlag );
2735 }
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05302736 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
2737 psessionEntry->peSessionId,
2738 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07002739 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
2740 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002741 limLog( pMac, LOGE, FL("Failed to send Association Request (%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002742 halstatus );
2743 //Pkt will be freed up by the callback
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302744 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -07002745 return;
2746 }
2747
Katya Nigamccaeda72015-04-20 18:51:22 +05302748 //Enable caching only if Assoc Request is successfully submitted to the h/w
2749 WLANTL_EnableCaching(psessionEntry->staId);
2750
Jeff Johnson295189b2012-06-20 16:38:30 -07002751 // Free up buffer allocated for mlmAssocReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302752 vos_mem_free(pMlmAssocReq);
Leela Venkata Kiran Kumar Reddy Chiralad6c0fe22013-12-11 19:10:50 -08002753 pMlmAssocReq = NULL;
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302754 vos_mem_free(pFrm);
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002755 return;
Jeff Johnson295189b2012-06-20 16:38:30 -07002756} // End limSendAssocReqMgmtFrame
2757
2758
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002759#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07002760/*------------------------------------------------------------------------------------
2761 *
2762 * Send Reassoc Req with FTIEs.
2763 *
2764 *-----------------------------------------------------------------------------------
2765 */
2766void
2767limSendReassocReqWithFTIEsMgmtFrame(tpAniSirGlobal pMac,
2768 tLimMlmReassocReq *pMlmReassocReq,tpPESession psessionEntry)
2769{
2770 static tDot11fReAssocRequest frm;
2771 tANI_U16 caps;
2772 tANI_U8 *pFrame;
2773 tSirRetStatus nSirStatus;
2774 tANI_U32 nBytes, nPayload, nStatus;
2775 tANI_U8 fQosEnabled, fWmeEnabled, fWsmEnabled;
2776 void *pPacket;
2777 eHalStatus halstatus;
2778#if defined WLAN_FEATURE_VOWIFI
2779 tANI_U8 PowerCapsPopulated = FALSE;
2780#endif
2781 tANI_U16 ft_ies_length = 0;
2782 tANI_U8 *pBody;
2783 tANI_U16 nAddIELen;
2784 tANI_U8 *pAddIE;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002785#if defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07002786 tANI_U8 *wpsIe = NULL;
2787#endif
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05302788 tANI_U32 txFlag = 0;
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05302789 tpSirMacMgmtHdr pMacHdr;
Jeff Johnson295189b2012-06-20 16:38:30 -07002790
2791 if (NULL == psessionEntry)
2792 {
2793 return;
2794 }
2795
Jeff Johnson295189b2012-06-20 16:38:30 -07002796 /* check this early to avoid unncessary operation */
2797 if(NULL == psessionEntry->pLimReAssocReq)
2798 {
2799 return;
2800 }
2801 nAddIELen = psessionEntry->pLimReAssocReq->addIEAssoc.length;
2802 pAddIE = psessionEntry->pLimReAssocReq->addIEAssoc.addIEdata;
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08002803 limLog( pMac, LOG1, FL("limSendReassocReqWithFTIEsMgmtFrame received in "
2804 "state (%d)."), psessionEntry->limMlmState);
Jeff Johnson295189b2012-06-20 16:38:30 -07002805
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302806 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07002807
2808 caps = pMlmReassocReq->capabilityInfo;
2809 if (PROP_CAPABILITY_GET(11EQOS, psessionEntry->limReassocBssPropCap))
2810 ((tSirMacCapabilityInfo *) &caps)->qos = 0;
2811#if defined(FEATURE_WLAN_WAPI)
2812 /* CR: 262463 :
2813 According to WAPI standard:
2814 7.3.1.4 Capability Information field
2815 In WAPI, non-AP STAs within an ESS set the Privacy subfield to 0 in transmitted
2816 Association or Reassociation management frames. APs ignore the Privacy subfield within received Association and
2817 Reassociation management frames. */
2818 if ( psessionEntry->encryptType == eSIR_ED_WPI)
2819 ((tSirMacCapabilityInfo *) &caps)->privacy = 0;
2820#endif
2821 swapBitField16(caps, ( tANI_U16* )&frm.Capabilities );
2822
2823 frm.ListenInterval.interval = pMlmReassocReq->listenInterval;
2824
2825 // Get the old bssid of the older AP.
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302826 vos_mem_copy( ( tANI_U8* )frm.CurrentAPAddress.mac,
Jeff Johnson295189b2012-06-20 16:38:30 -07002827 pMac->ft.ftPEContext.pFTPreAuthReq->currbssId, 6);
2828
2829 PopulateDot11fSSID2( pMac, &frm.SSID );
2830 PopulateDot11fSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
2831 &frm.SuppRates,psessionEntry);
2832
2833 fQosEnabled = ( psessionEntry->limQosEnabled) &&
2834 SIR_MAC_GET_QOS( psessionEntry->limReassocBssCaps );
2835
2836 fWmeEnabled = ( psessionEntry->limWmeEnabled ) &&
2837 LIM_BSS_CAPS_GET( WME, psessionEntry->limReassocBssQosCaps );
2838
2839 fWsmEnabled = ( psessionEntry->limWsmEnabled ) && fWmeEnabled &&
2840 LIM_BSS_CAPS_GET( WSM, psessionEntry->limReassocBssQosCaps );
2841
2842 if ( psessionEntry->lim11hEnable &&
2843 psessionEntry->pLimReAssocReq->spectrumMgtIndicator == eSIR_TRUE )
2844 {
2845#if defined WLAN_FEATURE_VOWIFI
2846 PowerCapsPopulated = TRUE;
2847
2848 PopulateDot11fPowerCaps( pMac, &frm.PowerCaps, LIM_REASSOC,psessionEntry);
2849 PopulateDot11fSuppChannels( pMac, &frm.SuppChannels, LIM_REASSOC,psessionEntry);
2850#endif
2851 }
2852
2853#if defined WLAN_FEATURE_VOWIFI
2854 if( pMac->rrm.rrmPEContext.rrmEnable &&
2855 SIR_MAC_GET_RRM( psessionEntry->limCurrentBssCaps ) )
2856 {
2857 if (PowerCapsPopulated == FALSE)
2858 {
2859 PowerCapsPopulated = TRUE;
2860 PopulateDot11fPowerCaps(pMac, &frm.PowerCaps, LIM_REASSOC, psessionEntry);
2861 }
2862 }
2863#endif
2864
2865 if ( fQosEnabled &&
2866 ( ! PROP_CAPABILITY_GET(11EQOS, psessionEntry->limReassocBssPropCap ) ))
2867 {
2868 PopulateDot11fQOSCapsStation( pMac, &frm.QOSCapsStation );
2869 }
2870
2871 PopulateDot11fExtSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
2872 &frm.ExtSuppRates, psessionEntry );
2873
2874#if defined WLAN_FEATURE_VOWIFI
2875 if( pMac->rrm.rrmPEContext.rrmEnable &&
2876 SIR_MAC_GET_RRM( psessionEntry->limReassocBssCaps ) )
2877 {
2878 PopulateDot11fRRMIe( pMac, &frm.RRMEnabledCap, psessionEntry );
2879 }
2880#endif
2881
2882 // Ideally this should be enabled for 11r also. But 11r does
2883 // not follow the usual norm of using the Opaque object
2884 // for rsnie and fties. Instead we just add
2885 // the rsnie and fties at the end of the pack routine for 11r.
2886 // This should ideally! be fixed.
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002887#if defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07002888 //
2889 // The join request *should* contain zero or one of the WPA and RSN
2890 // IEs. The payload send along with the request is a
2891 // 'tSirSmeJoinReq'; the IE portion is held inside a 'tSirRSNie':
2892
2893 // typedef struct sSirRSNie
2894 // {
2895 // tANI_U16 length;
2896 // tANI_U8 rsnIEdata[SIR_MAC_MAX_IE_LENGTH+2];
2897 // } tSirRSNie, *tpSirRSNie;
2898
2899 // So, we should be able to make the following two calls harmlessly,
2900 // since they do nothing if they don't find the given IE in the
2901 // bytestream with which they're provided.
2902
2903 // The net effect of this will be to faithfully transmit whatever
2904 // security IE is in the join request.
2905
2906 // *However*, if we're associating for the purpose of WPS
2907 // enrollment, and we've been configured to indicate that by
2908 // eliding the WPA or RSN IE, we just skip this:
2909 if (!psessionEntry->is11Rconnection)
2910 {
2911 if( nAddIELen && pAddIE )
2912 {
2913 wpsIe = limGetWscIEPtr(pMac, pAddIE, nAddIELen);
2914 }
2915 if ( NULL == wpsIe )
2916 {
2917 PopulateDot11fRSNOpaque( pMac, &( psessionEntry->pLimReAssocReq->rsnIE ),
2918 &frm.RSNOpaque );
2919 PopulateDot11fWPAOpaque( pMac, &( psessionEntry->pLimReAssocReq->rsnIE ),
2920 &frm.WPAOpaque );
2921 }
2922
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002923#ifdef FEATURE_WLAN_ESE
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302924 if (psessionEntry->pLimReAssocReq->cckmIE.length)
Jeff Johnson295189b2012-06-20 16:38:30 -07002925 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002926 PopulateDot11fESECckmOpaque( pMac, &( psessionEntry->pLimReAssocReq->cckmIE ),
2927 &frm.ESECckmOpaque );
Jeff Johnson295189b2012-06-20 16:38:30 -07002928 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002929#endif //FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07002930 }
2931
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002932#ifdef FEATURE_WLAN_ESE
2933 // For ESE Associations fill the ESE IEs
2934 if (psessionEntry->isESEconnection &&
2935 psessionEntry->pLimReAssocReq->isESEFeatureIniEnabled)
Jeff Johnson295189b2012-06-20 16:38:30 -07002936 {
Varun Reddy Yeturu30779b42013-04-09 09:57:16 -07002937#ifndef FEATURE_DISABLE_RM
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002938 PopulateDot11fESERadMgmtCap(&frm.ESERadMgmtCap);
Varun Reddy Yeturu30779b42013-04-09 09:57:16 -07002939#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002940 PopulateDot11fESEVersion(&frm.ESEVersion);
Jeff Johnson295189b2012-06-20 16:38:30 -07002941 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002942#endif //FEATURE_WLAN_ESE
2943#endif //FEATURE_WLAN_ESE || FEATURE_WLAN_LFR
Jeff Johnson295189b2012-06-20 16:38:30 -07002944
2945 // include WME EDCA IE as well
2946 if ( fWmeEnabled )
2947 {
2948 if ( ! PROP_CAPABILITY_GET( WME, psessionEntry->limReassocBssPropCap ) )
2949 {
2950 PopulateDot11fWMMInfoStation( pMac, &frm.WMMInfoStation );
2951 }
2952
2953 if ( fWsmEnabled &&
2954 ( ! PROP_CAPABILITY_GET(WSM, psessionEntry->limReassocBssPropCap )))
2955 {
2956 PopulateDot11fWMMCaps( &frm.WMMCaps );
2957 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002958#ifdef FEATURE_WLAN_ESE
2959 if (psessionEntry->isESEconnection)
Jeff Johnson295189b2012-06-20 16:38:30 -07002960 {
2961 PopulateDot11fReAssocTspec(pMac, &frm, psessionEntry);
2962
2963 // Populate the TSRS IE if TSPEC is included in the reassoc request
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002964 if (psessionEntry->pLimReAssocReq->eseTspecInfo.numTspecs)
Jeff Johnson295189b2012-06-20 16:38:30 -07002965 {
2966 tANI_U32 phyMode;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002967 tSirMacESETSRSIE tsrsIE;
Jeff Johnson295189b2012-06-20 16:38:30 -07002968 limGetPhyMode(pMac, &phyMode, psessionEntry);
2969
2970 tsrsIE.tsid = 0;
2971 if( phyMode == WNI_CFG_PHY_MODE_11G || phyMode == WNI_CFG_PHY_MODE_11A)
2972 {
2973 tsrsIE.rates[0] = TSRS_11AG_RATE_6MBPS;
2974 }
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302975 else
Jeff Johnson295189b2012-06-20 16:38:30 -07002976 {
2977 tsrsIE.rates[0] = TSRS_11B_RATE_5_5MBPS;
2978 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002979 PopulateDot11TSRSIE(pMac,&tsrsIE, &frm.ESETrafStrmRateSet, sizeof(tANI_U8));
Jeff Johnson295189b2012-06-20 16:38:30 -07002980 }
2981 }
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302982#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002983 }
2984
Jeff Johnsone7245742012-09-05 17:12:55 -07002985 if ( psessionEntry->htCapability &&
Jeff Johnson295189b2012-06-20 16:38:30 -07002986 pMac->lim.htCapabilityPresentInBeacon)
2987 {
Jeff Johnsone7245742012-09-05 17:12:55 -07002988 PopulateDot11fHTCaps( pMac, psessionEntry, &frm.HTCaps );
Jeff Johnson295189b2012-06-20 16:38:30 -07002989 }
Agrawal Ashishb10d0392015-08-06 16:18:20 +05302990 limLog(pMac, LOG1, FL("SupportedChnlWidth: %d, mimoPS: %d, GF: %d,"
2991 "shortGI20:%d, shortGI40: %d, dsssCck: %d, AMPDU Param: %x"),
2992 frm.HTCaps.supportedChannelWidthSet, frm.HTCaps.mimoPowerSave,
2993 frm.HTCaps.greenField, frm.HTCaps.shortGI20MHz, frm.HTCaps.shortGI40MHz,
2994 frm.HTCaps.dsssCckMode40MHz, frm.HTCaps.maxRxAMPDUFactor);
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08002995#if defined WLAN_FEATURE_VOWIFI_11R
Kanchanapally, Vidyullatha4f84f682014-04-29 20:40:34 +05302996 if ( psessionEntry->pLimReAssocReq->bssDescription.mdiePresent &&
2997 (pMac->ft.ftSmeContext.addMDIE == TRUE)
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002998#if defined FEATURE_WLAN_ESE
2999 && !psessionEntry->isESEconnection
Gopichand Nakkala0ac55062013-04-08 14:43:07 +05303000#endif
3001 )
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08003002 {
3003 PopulateMDIE( pMac, &frm.MobilityDomain, psessionEntry->pLimReAssocReq->bssDescription.mdie);
3004 }
3005#endif
3006
Chet Lanctotf19c1f62013-12-13 13:56:21 -08003007#ifdef WLAN_FEATURE_11AC
3008 if ( psessionEntry->vhtCapability &&
3009 psessionEntry->vhtCapabilityPresentInBeacon)
3010 {
3011 limLog( pMac, LOG1, FL("Populate VHT IEs in Re-Assoc Request"));
Abhishek Singh33f76ea2015-06-04 12:27:30 +05303012 PopulateDot11fVHTCaps( pMac, &frm.VHTCaps,
3013 psessionEntry->currentOperChannel, eSIR_FALSE );
Abhishek Singhe038dc62015-05-22 11:36:45 +05303014
Chet Lanctotf19c1f62013-12-13 13:56:21 -08003015 }
3016#endif
Hu Wang5193b572016-08-11 10:04:47 +08003017 if (psessionEntry->ExtCap.present)
Agrawal Ashish5ac89da2015-10-26 19:08:47 +05303018 PopulateDot11fExtCap( pMac, &frm.ExtCap, psessionEntry);
Chet Lanctotf19c1f62013-12-13 13:56:21 -08003019
Jeff Johnson295189b2012-06-20 16:38:30 -07003020 nStatus = dot11fGetPackedReAssocRequestSize( pMac, &frm, &nPayload );
3021 if ( DOT11F_FAILED( nStatus ) )
3022 {
3023 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003024 "or a Re-Association Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003025 nStatus );
3026 // We'll fall back on the worst case scenario:
3027 nPayload = sizeof( tDot11fReAssocRequest );
3028 }
3029 else if ( DOT11F_WARNED( nStatus ) )
3030 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08003031 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07003032 "the packed size for a Re-Association Re "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003033 "quest(0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07003034 }
3035
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07003036 nBytes = nPayload + sizeof( tSirMacMgmtHdr ) + nAddIELen;
Jeff Johnson295189b2012-06-20 16:38:30 -07003037
3038#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08003039 limLog( pMac, LOG1, FL("FT IE Reassoc Req (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003040 pMac->ft.ftSmeContext.reassoc_ft_ies_length);
3041#endif
3042
3043#if defined WLAN_FEATURE_VOWIFI_11R
3044 if (psessionEntry->is11Rconnection)
3045 {
3046 ft_ies_length = pMac->ft.ftSmeContext.reassoc_ft_ies_length;
3047 }
3048#endif
3049
3050 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
3051 ( tANI_U16 )nBytes+ft_ies_length, ( void** ) &pFrame,
3052 ( void** ) &pPacket );
3053 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3054 {
3055 psessionEntry->limMlmState = psessionEntry->limPrevMlmState;
Jeff Johnsone7245742012-09-05 17:12:55 -07003056 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07003057 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Re-As"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003058 "sociation Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07003059 goto end;
3060 }
3061
3062 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303063 vos_mem_set( pFrame, nBytes + ft_ies_length, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07003064
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003065#if defined WLAN_FEATURE_VOWIFI_11R_DEBUG || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08003066 limPrintMacAddr(pMac, psessionEntry->limReAssocbssId, LOG1);
Jeff Johnson295189b2012-06-20 16:38:30 -07003067#endif
3068 // Next, we fill out the buffer descriptor:
3069 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
3070 SIR_MAC_MGMT_REASSOC_REQ,
3071 psessionEntry->limReAssocbssId,psessionEntry->selfMacAddr);
3072 if ( eSIR_SUCCESS != nSirStatus )
3073 {
3074 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003075 "tor for an Association Request (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003076 nSirStatus );
3077 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
3078 goto end;
3079 }
3080
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05303081 pMacHdr = (tpSirMacMgmtHdr) pFrame;
Jeff Johnson295189b2012-06-20 16:38:30 -07003082 // That done, pack the ReAssoc Request:
3083 nStatus = dot11fPackReAssocRequest( pMac, &frm, pFrame +
3084 sizeof(tSirMacMgmtHdr),
3085 nPayload, &nPayload );
3086 if ( DOT11F_FAILED( nStatus ) )
3087 {
3088 limLog( pMac, LOGE, FL("Failed to pack a Re-Association Reque"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003089 "st (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003090 nStatus );
3091 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
3092 goto end;
3093 }
3094 else if ( DOT11F_WARNED( nStatus ) )
3095 {
3096 limLog( pMac, LOGW, FL("There were warnings while packing a R"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08003097 "e-Association Request (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07003098 }
3099
3100 PELOG3(limLog( pMac, LOG3,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003101 FL("*** Sending Re-Association Request length %d %d to "),
Jeff Johnson295189b2012-06-20 16:38:30 -07003102 nBytes, nPayload );)
3103 if( psessionEntry->assocReq != NULL )
3104 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303105 vos_mem_free(psessionEntry->assocReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07003106 psessionEntry->assocReq = NULL;
3107 }
3108
3109 if( nAddIELen )
3110 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303111 vos_mem_copy( pFrame + sizeof(tSirMacMgmtHdr) + nPayload,
3112 pAddIE,
3113 nAddIELen );
Jeff Johnson295189b2012-06-20 16:38:30 -07003114 nPayload += nAddIELen;
3115 }
3116
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303117 psessionEntry->assocReq = vos_mem_malloc(nPayload);
3118 if ( NULL == psessionEntry->assocReq )
Jeff Johnson295189b2012-06-20 16:38:30 -07003119 {
3120 PELOGE(limLog(pMac, LOGE, FL("Unable to allocate memory to store assoc request"));)
Jeff Johnson43971f52012-07-17 12:26:56 -07003121 }
3122 else
3123 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003124 //Store the Assoc request. This is sent to csr/hdd in join cnf response.
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303125 vos_mem_copy( psessionEntry->assocReq, pFrame + sizeof(tSirMacMgmtHdr), nPayload);
Jeff Johnson295189b2012-06-20 16:38:30 -07003126 psessionEntry->assocReqLen = nPayload;
Jeff Johnson43971f52012-07-17 12:26:56 -07003127 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003128
3129 if (psessionEntry->is11Rconnection)
3130 {
3131 {
3132 int i = 0;
3133
3134 pBody = pFrame + nBytes;
3135 for (i=0; i<ft_ies_length; i++)
3136 {
3137 *pBody = pMac->ft.ftSmeContext.reassoc_ft_ies[i];
3138 pBody++;
3139 }
3140 }
3141 }
3142
3143#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08003144 PELOGE(limLog(pMac, LOG1, FL("Re-assoc Req Frame is: "));
3145 sirDumpBuf(pMac, SIR_LIM_MODULE_ID, LOG1,
Jeff Johnson295189b2012-06-20 16:38:30 -07003146 (tANI_U8 *)pFrame,
3147 (nBytes + ft_ies_length));)
3148#endif
3149
3150
3151 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07003152 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
3153 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07003154 )
3155 {
3156 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
3157 }
3158
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07003159 if( NULL != psessionEntry->assocReq )
3160 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303161 vos_mem_free(psessionEntry->assocReq);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07003162 psessionEntry->assocReq = NULL;
3163 }
Agrawal Ashishad64dc22016-02-04 11:32:15 +05303164 if (ft_ies_length)
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07003165 {
Agrawal Ashishad64dc22016-02-04 11:32:15 +05303166 psessionEntry->assocReq = vos_mem_malloc(ft_ies_length);
3167 if (NULL == psessionEntry->assocReq)
3168 {
3169 limLog(pMac, LOGE,
3170 FL("Unable to allocate memory for FT IEs"));
3171 psessionEntry->assocReqLen = 0;
3172 }
3173 else
3174 {
3175 /* Store the FT IEs. This is sent to csr/hdd in join cnf response.*/
3176 vos_mem_copy(psessionEntry->assocReq,
3177 pMac->ft.ftSmeContext.reassoc_ft_ies,
3178 (ft_ies_length));
3179 psessionEntry->assocReqLen = ft_ies_length;
3180 }
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07003181 }
3182 else
3183 {
Agrawal Ashishad64dc22016-02-04 11:32:15 +05303184 limLog(pMac, LOG1, FL("FT IEs not present"));
3185 psessionEntry->assocReqLen = 0;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07003186 }
Deepthi Gowri639d5042015-11-16 20:23:39 +05303187#ifdef FEATURE_WLAN_DIAG_SUPPORT
3188 limDiagEventReport(pMac, WLAN_PE_DIAG_REASSOC_START_EVENT, psessionEntry,
3189 eSIR_SUCCESS, eSIR_SUCCESS);
3190#endif
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05303191 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
3192 psessionEntry->peSessionId,
3193 pMacHdr->fc.subType));
Ganesh Kondabattiniffc00b12015-03-18 13:11:33 +05303194 if (IS_FEATURE_SUPPORTED_BY_FW(ENHANCED_TXBD_COMPLETION))
3195 {
3196 limLog( pMac, LOG1, FL("Reassoc req - txBdToken %u"), pMac->lim.txBdToken);
3197 halstatus = halTxFrameWithTxComplete( pMac, pPacket,
3198 ( tANI_U16 ) (nBytes + ft_ies_length),
3199 HAL_TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS,
3200 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
3201 limTxComplete, pFrame, limTxBdComplete, txFlag,
3202 pMac->lim.txBdToken);
3203 pMac->lim.txBdToken++;
3204 }
3205 else
3206 {
3207 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) (nBytes + ft_ies_length),
3208 HAL_TXRX_FRM_802_11_MGMT,
3209 ANI_TXDIR_TODS,
3210 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
3211 limTxComplete, pFrame, txFlag );
3212 }
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05303213 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
3214 psessionEntry->peSessionId,
3215 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07003216 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3217 {
3218 limLog( pMac, LOGE, FL("Failed to send Re-Association Request"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003219 "(%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07003220 nSirStatus );
3221 //Pkt will be freed up by the callback
3222 goto end;
3223 }
3224
Katya Nigamccaeda72015-04-20 18:51:22 +05303225 // Enable TL cahching in case of roaming
3226 WLANTL_EnableCaching(psessionEntry->staId);
3227
Jeff Johnson295189b2012-06-20 16:38:30 -07003228end:
3229 // Free up buffer allocated for mlmAssocReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303230 vos_mem_free( pMlmReassocReq );
Jeff Johnson295189b2012-06-20 16:38:30 -07003231 psessionEntry->pLimMlmReassocReq = NULL;
3232
3233}
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -07003234
3235void limSendRetryReassocReqFrame(tpAniSirGlobal pMac,
3236 tLimMlmReassocReq *pMlmReassocReq,
3237 tpPESession psessionEntry)
3238{
3239 tLimMlmReassocCnf mlmReassocCnf; // keep sme
3240 tLimMlmReassocReq *pTmpMlmReassocReq = NULL;
Sachin Ahuja07a43012015-01-30 17:04:38 +05303241#ifdef FEATURE_WLAN_ESE
3242 tANI_U32 val=0;
3243#endif
3244 if (pMlmReassocReq == NULL)
3245 {
3246 limLog(pMac, LOGE,
3247 FL("Invalid pMlmReassocReq"));
3248 goto end;
3249 }
Hema Aparna Medicharla43d0f7b2015-02-12 17:07:59 +05303250
3251 pTmpMlmReassocReq = vos_mem_malloc(sizeof(tLimMlmReassocReq));
3252 if ( NULL == pTmpMlmReassocReq ) goto end;
3253 vos_mem_set( pTmpMlmReassocReq, sizeof(tLimMlmReassocReq), 0);
3254 vos_mem_copy( pTmpMlmReassocReq, pMlmReassocReq, sizeof(tLimMlmReassocReq));
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -07003255
3256 // Prepare and send Reassociation request frame
3257 // start reassoc timer.
Sachin Ahuja07a43012015-01-30 17:04:38 +05303258#ifdef FEATURE_WLAN_ESE
3259 /*
3260 * In case of Ese Reassociation, change the reassoc timer
3261 * value.
3262 */
3263 val = pMlmReassocReq->reassocFailureTimeout;
3264 if (psessionEntry->isESEconnection)
3265 {
3266 val = val/LIM_MAX_REASSOC_RETRY_LIMIT;
3267 }
3268 if (tx_timer_deactivate(&pMac->lim.limTimers.gLimReassocFailureTimer) !=
3269 TX_SUCCESS)
3270 {
3271 limLog(pMac, LOGP,
3272 FL("unable to deactivate Reassoc failure timer"));
3273 }
3274 val = SYS_MS_TO_TICKS(val);
3275 if (tx_timer_change(&pMac->lim.limTimers.gLimReassocFailureTimer,
3276 val, 0) != TX_SUCCESS)
3277 {
3278 limLog(pMac, LOGP,
3279 FL("unable to change Reassociation failure timer"));
3280 }
3281#endif
3282
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -07003283 pMac->lim.limTimers.gLimReassocFailureTimer.sessionId = psessionEntry->peSessionId;
3284 // Start reassociation failure timer
Leela V Kiran Kumar Reddy Chiralac3b9d382013-01-31 20:49:53 -08003285 MTRACE(macTrace(pMac, TRACE_CODE_TIMER_ACTIVATE, psessionEntry->peSessionId, eLIM_REASSOC_FAIL_TIMER));
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -07003286 if (tx_timer_activate(&pMac->lim.limTimers.gLimReassocFailureTimer)
3287 != TX_SUCCESS)
3288 {
3289 // Could not start reassoc failure timer.
3290 // Log error
3291 limLog(pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003292 FL("could not start Reassociation failure timer"));
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -07003293 // Return Reassoc confirm with
3294 // Resources Unavailable
3295 mlmReassocCnf.resultCode = eSIR_SME_RESOURCES_UNAVAILABLE;
3296 mlmReassocCnf.protStatusCode = eSIR_MAC_UNSPEC_FAILURE_STATUS;
3297 goto end;
3298 }
3299
3300 limSendReassocReqWithFTIEsMgmtFrame(pMac, pTmpMlmReassocReq, psessionEntry);
3301 return;
3302
3303end:
3304 // Free up buffer allocated for reassocReq
3305 if (pMlmReassocReq != NULL)
3306 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303307 vos_mem_free(pMlmReassocReq);
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -07003308 pMlmReassocReq = NULL;
3309 }
3310 if (pTmpMlmReassocReq != NULL)
3311 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303312 vos_mem_free(pTmpMlmReassocReq);
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -07003313 pTmpMlmReassocReq = NULL;
3314 }
3315 mlmReassocCnf.resultCode = eSIR_SME_FT_REASSOC_FAILURE;
3316 mlmReassocCnf.protStatusCode = eSIR_MAC_UNSPEC_FAILURE_STATUS;
3317 /* Update PE sessio Id*/
3318 mlmReassocCnf.sessionId = psessionEntry->peSessionId;
3319
3320 limPostSmeMessage(pMac, LIM_MLM_REASSOC_CNF, (tANI_U32 *) &mlmReassocCnf);
3321}
3322
Jeff Johnson295189b2012-06-20 16:38:30 -07003323#endif /* WLAN_FEATURE_VOWIFI_11R */
3324
3325
3326void
3327limSendReassocReqMgmtFrame(tpAniSirGlobal pMac,
3328 tLimMlmReassocReq *pMlmReassocReq,tpPESession psessionEntry)
3329{
3330 static tDot11fReAssocRequest frm;
3331 tANI_U16 caps;
3332 tANI_U8 *pFrame;
3333 tSirRetStatus nSirStatus;
3334 tANI_U32 nBytes, nPayload, nStatus;
3335 tANI_U8 fQosEnabled, fWmeEnabled, fWsmEnabled;
3336 void *pPacket;
3337 eHalStatus halstatus;
3338 tANI_U16 nAddIELen;
3339 tANI_U8 *pAddIE;
3340 tANI_U8 *wpsIe = NULL;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05303341 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003342#if defined WLAN_FEATURE_VOWIFI
3343 tANI_U8 PowerCapsPopulated = FALSE;
3344#endif
Ganesh Kondabattiniffc00b12015-03-18 13:11:33 +05303345 tpSirMacMgmtHdr pMacHdr;
Jeff Johnson295189b2012-06-20 16:38:30 -07003346
3347 if(NULL == psessionEntry)
3348 {
3349 return;
3350 }
3351
3352 /* check this early to avoid unncessary operation */
3353 if(NULL == psessionEntry->pLimReAssocReq)
3354 {
3355 return;
3356 }
3357 nAddIELen = psessionEntry->pLimReAssocReq->addIEAssoc.length;
3358 pAddIE = psessionEntry->pLimReAssocReq->addIEAssoc.addIEdata;
3359
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303360 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07003361
3362 caps = pMlmReassocReq->capabilityInfo;
3363 if (PROP_CAPABILITY_GET(11EQOS, psessionEntry->limReassocBssPropCap))
3364 ((tSirMacCapabilityInfo *) &caps)->qos = 0;
3365#if defined(FEATURE_WLAN_WAPI)
3366 /* CR: 262463 :
3367 According to WAPI standard:
3368 7.3.1.4 Capability Information field
3369 In WAPI, non-AP STAs within an ESS set the Privacy subfield to 0 in transmitted
3370 Association or Reassociation management frames. APs ignore the Privacy subfield within received Association and
3371 Reassociation management frames. */
3372 if ( psessionEntry->encryptType == eSIR_ED_WPI)
3373 ((tSirMacCapabilityInfo *) &caps)->privacy = 0;
3374#endif
3375 swapBitField16(caps, ( tANI_U16* )&frm.Capabilities );
3376
3377 frm.ListenInterval.interval = pMlmReassocReq->listenInterval;
3378
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303379 vos_mem_copy(( tANI_U8* )frm.CurrentAPAddress.mac,
3380 ( tANI_U8* )psessionEntry->bssId, 6 );
Jeff Johnson295189b2012-06-20 16:38:30 -07003381
3382 PopulateDot11fSSID2( pMac, &frm.SSID );
3383 PopulateDot11fSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
3384 &frm.SuppRates,psessionEntry);
3385
3386 fQosEnabled = ( psessionEntry->limQosEnabled ) &&
3387 SIR_MAC_GET_QOS( psessionEntry->limReassocBssCaps );
3388
3389 fWmeEnabled = ( psessionEntry->limWmeEnabled ) &&
3390 LIM_BSS_CAPS_GET( WME, psessionEntry->limReassocBssQosCaps );
3391
3392 fWsmEnabled = ( psessionEntry->limWsmEnabled ) && fWmeEnabled &&
3393 LIM_BSS_CAPS_GET( WSM, psessionEntry->limReassocBssQosCaps );
3394
3395
3396 if ( psessionEntry->lim11hEnable &&
3397 psessionEntry->pLimReAssocReq->spectrumMgtIndicator == eSIR_TRUE )
3398 {
3399#if defined WLAN_FEATURE_VOWIFI
3400 PowerCapsPopulated = TRUE;
3401 PopulateDot11fPowerCaps( pMac, &frm.PowerCaps, LIM_REASSOC,psessionEntry);
3402 PopulateDot11fSuppChannels( pMac, &frm.SuppChannels, LIM_REASSOC,psessionEntry);
3403#endif
3404 }
3405
3406#if defined WLAN_FEATURE_VOWIFI
3407 if( pMac->rrm.rrmPEContext.rrmEnable &&
3408 SIR_MAC_GET_RRM( psessionEntry->limCurrentBssCaps ) )
3409 {
3410 if (PowerCapsPopulated == FALSE)
3411 {
3412 PowerCapsPopulated = TRUE;
3413 PopulateDot11fPowerCaps(pMac, &frm.PowerCaps, LIM_REASSOC, psessionEntry);
3414 }
3415 }
3416#endif
3417
3418 if ( fQosEnabled &&
3419 ( ! PROP_CAPABILITY_GET(11EQOS, psessionEntry->limReassocBssPropCap ) ))
3420 {
3421 PopulateDot11fQOSCapsStation( pMac, &frm.QOSCapsStation );
3422 }
3423
3424 PopulateDot11fExtSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
3425 &frm.ExtSuppRates, psessionEntry );
3426
3427#if defined WLAN_FEATURE_VOWIFI
3428 if( pMac->rrm.rrmPEContext.rrmEnable &&
3429 SIR_MAC_GET_RRM( psessionEntry->limReassocBssCaps ) )
3430 {
3431 PopulateDot11fRRMIe( pMac, &frm.RRMEnabledCap, psessionEntry );
3432 }
3433#endif
3434 // The join request *should* contain zero or one of the WPA and RSN
3435 // IEs. The payload send along with the request is a
3436 // 'tSirSmeJoinReq'; the IE portion is held inside a 'tSirRSNie':
3437
3438 // typedef struct sSirRSNie
3439 // {
3440 // tANI_U16 length;
3441 // tANI_U8 rsnIEdata[SIR_MAC_MAX_IE_LENGTH+2];
3442 // } tSirRSNie, *tpSirRSNie;
3443
3444 // So, we should be able to make the following two calls harmlessly,
3445 // since they do nothing if they don't find the given IE in the
3446 // bytestream with which they're provided.
3447
3448 // The net effect of this will be to faithfully transmit whatever
3449 // security IE is in the join request.
3450
3451 // *However*, if we're associating for the purpose of WPS
3452 // enrollment, and we've been configured to indicate that by
3453 // eliding the WPA or RSN IE, we just skip this:
3454 if( nAddIELen && pAddIE )
3455 {
3456 wpsIe = limGetWscIEPtr(pMac, pAddIE, nAddIELen);
3457 }
3458 if ( NULL == wpsIe )
3459 {
3460 PopulateDot11fRSNOpaque( pMac, &( psessionEntry->pLimReAssocReq->rsnIE ),
3461 &frm.RSNOpaque );
3462 PopulateDot11fWPAOpaque( pMac, &( psessionEntry->pLimReAssocReq->rsnIE ),
3463 &frm.WPAOpaque );
3464#if defined(FEATURE_WLAN_WAPI)
3465 PopulateDot11fWAPIOpaque( pMac, &( psessionEntry->pLimReAssocReq->rsnIE ),
3466 &frm.WAPIOpaque );
3467#endif // defined(FEATURE_WLAN_WAPI)
3468 }
3469
3470 // include WME EDCA IE as well
3471 if ( fWmeEnabled )
3472 {
3473 if ( ! PROP_CAPABILITY_GET( WME, psessionEntry->limReassocBssPropCap ) )
3474 {
3475 PopulateDot11fWMMInfoStation( pMac, &frm.WMMInfoStation );
3476 }
3477
3478 if ( fWsmEnabled &&
3479 ( ! PROP_CAPABILITY_GET(WSM, psessionEntry->limReassocBssPropCap )))
3480 {
3481 PopulateDot11fWMMCaps( &frm.WMMCaps );
3482 }
3483 }
3484
Jeff Johnsone7245742012-09-05 17:12:55 -07003485 if ( psessionEntry->htCapability &&
Jeff Johnson295189b2012-06-20 16:38:30 -07003486 pMac->lim.htCapabilityPresentInBeacon)
3487 {
Jeff Johnsone7245742012-09-05 17:12:55 -07003488 PopulateDot11fHTCaps( pMac, psessionEntry, &frm.HTCaps );
Jeff Johnson295189b2012-06-20 16:38:30 -07003489 }
Agrawal Ashishb10d0392015-08-06 16:18:20 +05303490 limLog(pMac, LOG1, FL("SupportedChnlWidth: %d, mimoPS: %d, GF: %d,"
3491 "shortGI20:%d, shortGI40: %d, dsssCck: %d, AMPDU Param: %x"),
3492 frm.HTCaps.supportedChannelWidthSet, frm.HTCaps.mimoPowerSave,
3493 frm.HTCaps.greenField, frm.HTCaps.shortGI20MHz, frm.HTCaps.shortGI40MHz,
3494 frm.HTCaps.dsssCckMode40MHz, frm.HTCaps.maxRxAMPDUFactor);
Jeff Johnsone7245742012-09-05 17:12:55 -07003495#ifdef WLAN_FEATURE_11AC
3496 if ( psessionEntry->vhtCapability &&
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07003497 psessionEntry->vhtCapabilityPresentInBeacon)
Jeff Johnsone7245742012-09-05 17:12:55 -07003498 {
Chet Lanctotf19c1f62013-12-13 13:56:21 -08003499 limLog( pMac, LOG1, FL("Populate VHT IEs in Re-Assoc Request"));
Abhishek Singh33f76ea2015-06-04 12:27:30 +05303500 PopulateDot11fVHTCaps( pMac, &frm.VHTCaps,
3501 psessionEntry->currentOperChannel, eSIR_FALSE );
Hu Wang5193b572016-08-11 10:04:47 +08003502 if (psessionEntry->ExtCap.present)
Agrawal Ashish5ac89da2015-10-26 19:08:47 +05303503 PopulateDot11fExtCap( pMac, &frm.ExtCap, psessionEntry);
Jeff Johnsone7245742012-09-05 17:12:55 -07003504 }
3505#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003506
3507 nStatus = dot11fGetPackedReAssocRequestSize( pMac, &frm, &nPayload );
3508 if ( DOT11F_FAILED( nStatus ) )
3509 {
3510 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003511 "or a Re-Association Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003512 nStatus );
3513 // We'll fall back on the worst case scenario:
3514 nPayload = sizeof( tDot11fReAssocRequest );
3515 }
3516 else if ( DOT11F_WARNED( nStatus ) )
3517 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08003518 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07003519 "the packed size for a Re-Association Re "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003520 "quest(0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07003521 }
3522
3523 nBytes = nPayload + sizeof( tSirMacMgmtHdr ) + nAddIELen;
3524
3525 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
3526 ( tANI_U16 )nBytes, ( void** ) &pFrame,
3527 ( void** ) &pPacket );
3528 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3529 {
3530 psessionEntry->limMlmState = psessionEntry->limPrevMlmState;
Jeff Johnsone7245742012-09-05 17:12:55 -07003531 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07003532 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Re-As"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003533 "sociation Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07003534 goto end;
3535 }
3536
3537 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303538 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07003539
3540 // Next, we fill out the buffer descriptor:
3541 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
3542 SIR_MAC_MGMT_REASSOC_REQ,
3543 psessionEntry->limReAssocbssId,psessionEntry->selfMacAddr);
3544 if ( eSIR_SUCCESS != nSirStatus )
3545 {
3546 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003547 "tor for an Association Request (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003548 nSirStatus );
3549 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
3550 goto end;
3551 }
3552
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05303553 pMacHdr = (tpSirMacMgmtHdr) pFrame;
Jeff Johnson295189b2012-06-20 16:38:30 -07003554 // That done, pack the Probe Request:
3555 nStatus = dot11fPackReAssocRequest( pMac, &frm, pFrame +
3556 sizeof(tSirMacMgmtHdr),
3557 nPayload, &nPayload );
3558 if ( DOT11F_FAILED( nStatus ) )
3559 {
3560 limLog( pMac, LOGE, FL("Failed to pack a Re-Association Reque"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003561 "st (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003562 nStatus );
3563 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
3564 goto end;
3565 }
3566 else if ( DOT11F_WARNED( nStatus ) )
3567 {
3568 limLog( pMac, LOGW, FL("There were warnings while packing a R"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08003569 "e-Association Request (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07003570 }
3571
3572 PELOG1(limLog( pMac, LOG1, FL("*** Sending Re-Association Request length %d"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003573 "to "),
Jeff Johnson295189b2012-06-20 16:38:30 -07003574 nBytes );)
3575
3576 if( psessionEntry->assocReq != NULL )
3577 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303578 vos_mem_free(psessionEntry->assocReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07003579 psessionEntry->assocReq = NULL;
3580 }
3581
3582 if( nAddIELen )
3583 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303584 vos_mem_copy( pFrame + sizeof(tSirMacMgmtHdr) + nPayload,
3585 pAddIE,
3586 nAddIELen );
Jeff Johnson295189b2012-06-20 16:38:30 -07003587 nPayload += nAddIELen;
3588 }
3589
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303590 psessionEntry->assocReq = vos_mem_malloc(nPayload);
3591 if ( NULL == psessionEntry->assocReq )
Jeff Johnson295189b2012-06-20 16:38:30 -07003592 {
3593 PELOGE(limLog(pMac, LOGE, FL("Unable to allocate memory to store assoc request"));)
Jeff Johnson43971f52012-07-17 12:26:56 -07003594 }
3595 else
3596 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003597 //Store the Assoc request. This is sent to csr/hdd in join cnf response.
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303598 vos_mem_copy(psessionEntry->assocReq, pFrame + sizeof(tSirMacMgmtHdr), nPayload);
Jeff Johnson295189b2012-06-20 16:38:30 -07003599 psessionEntry->assocReqLen = nPayload;
Jeff Johnson43971f52012-07-17 12:26:56 -07003600 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003601
3602 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07003603 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
3604 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07003605 )
3606 {
3607 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
3608 }
3609
Sushant Kaushike8681d22015-04-21 12:08:25 +05303610 if(psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ||
3611 psessionEntry->pePersona == VOS_STA_MODE)
Ganesh K08bce952012-12-13 15:04:41 -08003612 {
3613 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
3614 }
Deepthi Gowri639d5042015-11-16 20:23:39 +05303615#ifdef FEATURE_WLAN_DIAG_SUPPORT
3616 limDiagEventReport(pMac, WLAN_PE_DIAG_REASSOC_START_EVENT, psessionEntry,
3617 eSIR_SUCCESS, eSIR_SUCCESS);
3618#endif
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08003619
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05303620 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
3621 psessionEntry->peSessionId,
3622 pMacHdr->fc.subType));
Katya Nigam63902932014-06-26 19:04:23 +05303623
Ganesh Kondabattiniffc00b12015-03-18 13:11:33 +05303624 if (IS_FEATURE_SUPPORTED_BY_FW(ENHANCED_TXBD_COMPLETION))
3625 {
3626 limLog(pMac, LOG1, FL("Reassoc req - txBdToken %u"), pMac->lim.txBdToken);
3627 halstatus = halTxFrameWithTxComplete( pMac, pPacket,
3628 ( tANI_U16 ) (sizeof(tSirMacMgmtHdr) + nPayload),
3629 HAL_TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS,
3630 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
3631 limTxComplete, pFrame, limTxBdComplete,
3632 txFlag, pMac->lim.txBdToken );
3633 pMac->lim.txBdToken++;
3634 }
3635 else
3636 {
3637 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) (sizeof(tSirMacMgmtHdr) + nPayload),
3638 HAL_TXRX_FRM_802_11_MGMT,
3639 ANI_TXDIR_TODS,
3640 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
3641 limTxComplete, pFrame, txFlag );
3642 }
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05303643 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
3644 psessionEntry->peSessionId,
3645 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07003646 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3647 {
3648 limLog( pMac, LOGE, FL("Failed to send Re-Association Request"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003649 "(%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07003650 nSirStatus );
3651 //Pkt will be freed up by the callback
3652 goto end;
3653 }
3654
Katya Nigamccaeda72015-04-20 18:51:22 +05303655 // enable caching
3656 WLANTL_EnableCaching(psessionEntry->staId);
3657
Jeff Johnson295189b2012-06-20 16:38:30 -07003658end:
3659 // Free up buffer allocated for mlmAssocReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303660 vos_mem_free( pMlmReassocReq );
Jeff Johnson295189b2012-06-20 16:38:30 -07003661 psessionEntry->pLimMlmReassocReq = NULL;
3662
3663} // limSendReassocReqMgmtFrame
3664
Sushant Kaushik9e923872015-04-02 17:09:31 +05303665eHalStatus limAuthTxCompleteCnf(tpAniSirGlobal pMac, void *pData)
Ganesh Kondabattiniffc00b12015-03-18 13:11:33 +05303666{
Sushant Kaushik9e923872015-04-02 17:09:31 +05303667 tANI_U32 txCompleteSuccess;
Ganesh Kondabattiniffc00b12015-03-18 13:11:33 +05303668 tpSirTxBdStatus pTxBdStatus;
Sushant Kaushik9e923872015-04-02 17:09:31 +05303669
3670 if (!pData)
3671 {
3672 limLog(pMac, LOG1,
3673 FL(" pData is NULL"));
3674 return eHAL_STATUS_FAILURE;
3675 }
Sushant Kaushik9e923872015-04-02 17:09:31 +05303676
Ganesh Kondabattiniffc00b12015-03-18 13:11:33 +05303677 if (IS_FEATURE_SUPPORTED_BY_FW(ENHANCED_TXBD_COMPLETION))
3678 {
3679 pTxBdStatus = (tpSirTxBdStatus) pData;
3680 txCompleteSuccess = pTxBdStatus->txCompleteStatus;
3681 limLog(pMac, LOG1, FL("txCompleteStatus %u, txBdToken %u"),
3682 pTxBdStatus->txCompleteStatus, pTxBdStatus->txBdToken);
3683 }
3684 else
3685 {
3686 txCompleteSuccess = *((tANI_U32*) pData);
3687 limLog(pMac, LOG1,
3688 FL("txCompleteSuccess= %d"), txCompleteSuccess);
3689 }
3690
Sushant Kaushik9e923872015-04-02 17:09:31 +05303691 if(txCompleteSuccess)
3692 {
3693 pMac->authAckStatus = LIM_AUTH_ACK_RCD_SUCCESS;
3694 // 'Change' timer for future activations
3695 limDeactivateAndChangeTimer(pMac, eLIM_AUTH_RETRY_TIMER);
3696 }
3697 else
3698 pMac->authAckStatus = LIM_AUTH_ACK_RCD_FAILURE;
Sushant Kaushikb97a0082015-08-31 12:36:45 +05303699#ifdef FEATURE_WLAN_DIAG_SUPPORT
Deepthi Gowri639d5042015-11-16 20:23:39 +05303700 limDiagEventReport(pMac, WLAN_PE_DIAG_AUTH_START_EVENT, NULL,
Sushant Kaushikb97a0082015-08-31 12:36:45 +05303701 pMac->authAckStatus, eSIR_SUCCESS);
3702#endif
3703
Sushant Kaushik9e923872015-04-02 17:09:31 +05303704 return eHAL_STATUS_SUCCESS;
3705}
3706
Jeff Johnson295189b2012-06-20 16:38:30 -07003707/**
3708 * \brief Send an Authentication frame
3709 *
3710 *
3711 * \param pMac Pointer to Global MAC structure
3712 *
3713 * \param pAuthFrameBody Pointer to Authentication frame structure that need
3714 * to be sent
3715 *
3716 * \param peerMacAddr MAC address of the peer entity to which Authentication
3717 * frame is destined
3718 *
3719 * \param wepBit Indicates whether wep bit to be set in FC while sending
3720 * Authentication frame3
3721 *
3722 *
3723 * This function is called by limProcessMlmMessages(). Authentication frame
3724 * is formatted and sent when this function is called.
3725 *
3726 *
3727 */
3728
3729void
3730limSendAuthMgmtFrame(tpAniSirGlobal pMac,
3731 tpSirMacAuthFrameBody pAuthFrameBody,
3732 tSirMacAddr peerMacAddr,
3733 tANI_U8 wepBit,
Sushant Kaushik9e923872015-04-02 17:09:31 +05303734 tpPESession psessionEntry,
3735 tAniBool waitForAck
Jeff Johnson295189b2012-06-20 16:38:30 -07003736 )
3737{
3738 tANI_U8 *pFrame, *pBody;
3739 tANI_U32 frameLen = 0, bodyLen = 0;
3740 tpSirMacMgmtHdr pMacHdr;
3741 tANI_U16 i;
3742 void *pPacket;
3743 eHalStatus halstatus;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05303744 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003745
3746 if(NULL == psessionEntry)
3747 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05303748 limLog(pMac, LOGE, FL("Error: psession Entry is NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003749 return;
3750 }
Abhishek Singh57aebef2014-02-03 18:47:44 +05303751
3752 limLog(pMac, LOG1,
3753 FL("Sending Auth seq# %d status %d (%d) to "MAC_ADDRESS_STR),
3754 pAuthFrameBody->authTransactionSeqNumber,
3755 pAuthFrameBody->authStatusCode,
3756 (pAuthFrameBody->authStatusCode == eSIR_MAC_SUCCESS_STATUS),
3757 MAC_ADDR_ARRAY(peerMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07003758 if (wepBit == LIM_WEP_IN_FC)
3759 {
3760 /// Auth frame3 to be sent with encrypted framebody
3761 /**
3762 * Allocate buffer for Authenticaton frame of size equal
3763 * to management frame header length plus 2 bytes each for
3764 * auth algorithm number, transaction number, status code,
3765 * 128 bytes for challenge text and 4 bytes each for
3766 * IV & ICV.
3767 */
3768
3769 frameLen = sizeof(tSirMacMgmtHdr) + LIM_ENCR_AUTH_BODY_LEN;
3770
3771 bodyLen = LIM_ENCR_AUTH_BODY_LEN;
3772 } // if (wepBit == LIM_WEP_IN_FC)
3773 else
3774 {
3775 switch (pAuthFrameBody->authTransactionSeqNumber)
3776 {
3777 case SIR_MAC_AUTH_FRAME_1:
3778 /**
3779 * Allocate buffer for Authenticaton frame of size
3780 * equal to management frame header length plus 2 bytes
3781 * each for auth algorithm number, transaction number
3782 * and status code.
3783 */
3784
3785 frameLen = sizeof(tSirMacMgmtHdr) +
3786 SIR_MAC_AUTH_CHALLENGE_OFFSET;
3787 bodyLen = SIR_MAC_AUTH_CHALLENGE_OFFSET;
3788
3789#if defined WLAN_FEATURE_VOWIFI_11R
Madan Mohan Koyyalamudi6a00a802012-11-28 16:12:11 -08003790 if (pAuthFrameBody->authAlgoNumber == eSIR_FT_AUTH)
3791 {
3792 if (0 != pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length)
Jeff Johnson295189b2012-06-20 16:38:30 -07003793 {
Madan Mohan Koyyalamudi6a00a802012-11-28 16:12:11 -08003794 frameLen += pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length;
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003795 limLog(pMac, LOG3, FL("Auth frame, FTIES length added=%d"),
Madan Mohan Koyyalamudi6a00a802012-11-28 16:12:11 -08003796 pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length);
Jeff Johnson295189b2012-06-20 16:38:30 -07003797 }
Madan Mohan Koyyalamudi6a00a802012-11-28 16:12:11 -08003798 else
3799 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05303800 limLog(pMac, LOG3, FL("Auth frame, Does not contain "
3801 "FTIES!!!"));
Madan Mohan Koyyalamudi6a00a802012-11-28 16:12:11 -08003802 frameLen += (2+SIR_MDIE_SIZE);
3803 }
3804 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003805#endif
3806 break;
3807
3808 case SIR_MAC_AUTH_FRAME_2:
3809 if ((pAuthFrameBody->authAlgoNumber == eSIR_OPEN_SYSTEM) ||
3810 ((pAuthFrameBody->authAlgoNumber == eSIR_SHARED_KEY) &&
3811 (pAuthFrameBody->authStatusCode != eSIR_MAC_SUCCESS_STATUS)))
3812 {
3813 /**
3814 * Allocate buffer for Authenticaton frame of size
3815 * equal to management frame header length plus
3816 * 2 bytes each for auth algorithm number,
3817 * transaction number and status code.
3818 */
3819
3820 frameLen = sizeof(tSirMacMgmtHdr) +
3821 SIR_MAC_AUTH_CHALLENGE_OFFSET;
3822 bodyLen = SIR_MAC_AUTH_CHALLENGE_OFFSET;
3823 }
3824 else
3825 {
3826 // Shared Key algorithm with challenge text
3827 // to be sent
3828 /**
3829 * Allocate buffer for Authenticaton frame of size
3830 * equal to management frame header length plus
3831 * 2 bytes each for auth algorithm number,
3832 * transaction number, status code and 128 bytes
3833 * for challenge text.
3834 */
3835
3836 frameLen = sizeof(tSirMacMgmtHdr) +
3837 sizeof(tSirMacAuthFrame);
3838 bodyLen = sizeof(tSirMacAuthFrameBody);
3839 }
3840
3841 break;
3842
3843 case SIR_MAC_AUTH_FRAME_3:
3844 /// Auth frame3 to be sent without encrypted framebody
3845 /**
3846 * Allocate buffer for Authenticaton frame of size equal
3847 * to management frame header length plus 2 bytes each
3848 * for auth algorithm number, transaction number and
3849 * status code.
3850 */
3851
3852 frameLen = sizeof(tSirMacMgmtHdr) +
3853 SIR_MAC_AUTH_CHALLENGE_OFFSET;
3854 bodyLen = SIR_MAC_AUTH_CHALLENGE_OFFSET;
3855
3856 break;
3857
3858 case SIR_MAC_AUTH_FRAME_4:
3859 /**
3860 * Allocate buffer for Authenticaton frame of size equal
3861 * to management frame header length plus 2 bytes each
3862 * for auth algorithm number, transaction number and
3863 * status code.
3864 */
3865
3866 frameLen = sizeof(tSirMacMgmtHdr) +
3867 SIR_MAC_AUTH_CHALLENGE_OFFSET;
3868 bodyLen = SIR_MAC_AUTH_CHALLENGE_OFFSET;
3869
3870 break;
3871 } // switch (pAuthFrameBody->authTransactionSeqNumber)
3872 } // end if (wepBit == LIM_WEP_IN_FC)
3873
3874
3875 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )frameLen, ( void** ) &pFrame, ( void** ) &pPacket );
3876
3877 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3878 {
3879 // Log error
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003880 limLog(pMac, LOGP, FL("call to bufAlloc failed for AUTH frame"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003881
3882 return;
3883 }
3884
3885 for (i = 0; i < frameLen; i++)
3886 pFrame[i] = 0;
3887
3888 // Prepare BD
3889 if (limPopulateMacHeader(pMac, pFrame, SIR_MAC_MGMT_FRAME,
3890 SIR_MAC_MGMT_AUTH, peerMacAddr,psessionEntry->selfMacAddr) != eSIR_SUCCESS)
3891 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05303892 limLog(pMac, LOGE, FL("call to limPopulateMacHeader failed for "
3893 "AUTH frame"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003894 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
3895 return;
3896 }
3897
3898 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
3899 pMacHdr->fc.wep = wepBit;
3900
3901 // Prepare BSSId
3902 if( (psessionEntry->limSystemRole == eLIM_AP_ROLE)|| (psessionEntry->limSystemRole == eLIM_BT_AMP_AP_ROLE) )
3903 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303904 vos_mem_copy( (tANI_U8 *) pMacHdr->bssId,
3905 (tANI_U8 *) psessionEntry->bssId,
3906 sizeof( tSirMacAddr ));
Jeff Johnson295189b2012-06-20 16:38:30 -07003907 }
3908
3909 /// Prepare Authentication frame body
3910 pBody = pFrame + sizeof(tSirMacMgmtHdr);
3911
3912 if (wepBit == LIM_WEP_IN_FC)
3913 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303914 vos_mem_copy(pBody, (tANI_U8 *) pAuthFrameBody, bodyLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07003915
Abhishek Singh3cbf6052014-12-15 16:46:42 +05303916 limLog(pMac, LOG1,
Abhishek Singh57aebef2014-02-03 18:47:44 +05303917 FL("*** Sending Auth seq# 3 status %d (%d) to"MAC_ADDRESS_STR),
Jeff Johnson295189b2012-06-20 16:38:30 -07003918 pAuthFrameBody->authStatusCode,
Abhishek Singh57aebef2014-02-03 18:47:44 +05303919 (pAuthFrameBody->authStatusCode == eSIR_MAC_SUCCESS_STATUS),
Abhishek Singh3cbf6052014-12-15 16:46:42 +05303920 MAC_ADDR_ARRAY(pMacHdr->da));
Jeff Johnson295189b2012-06-20 16:38:30 -07003921
Jeff Johnson295189b2012-06-20 16:38:30 -07003922 }
3923 else
3924 {
3925 *((tANI_U16 *)(pBody)) = sirSwapU16ifNeeded(pAuthFrameBody->authAlgoNumber);
3926 pBody += sizeof(tANI_U16);
3927 bodyLen -= sizeof(tANI_U16);
3928
3929 *((tANI_U16 *)(pBody)) = sirSwapU16ifNeeded(pAuthFrameBody->authTransactionSeqNumber);
3930 pBody += sizeof(tANI_U16);
3931 bodyLen -= sizeof(tANI_U16);
3932
3933 *((tANI_U16 *)(pBody)) = sirSwapU16ifNeeded(pAuthFrameBody->authStatusCode);
3934 pBody += sizeof(tANI_U16);
3935 bodyLen -= sizeof(tANI_U16);
Leela Venkata Kiran Kumar Reddy Chirala7d3fa552013-08-28 10:52:21 -07003936 if ( bodyLen <= (sizeof (pAuthFrameBody->type) +
3937 sizeof (pAuthFrameBody->length) +
3938 sizeof (pAuthFrameBody->challengeText)))
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303939 vos_mem_copy(pBody, (tANI_U8 *) &pAuthFrameBody->type, bodyLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07003940
3941#if defined WLAN_FEATURE_VOWIFI_11R
3942 if ((pAuthFrameBody->authAlgoNumber == eSIR_FT_AUTH) &&
3943 (pAuthFrameBody->authTransactionSeqNumber == SIR_MAC_AUTH_FRAME_1))
3944 {
3945
3946 {
3947 int i = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003948 if (pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length)
3949 {
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08003950#if defined WLAN_FEATURE_VOWIFI_11R_DEBUG
Srinivas Girigowdad63eb492014-02-06 12:21:47 -08003951 PELOG2(limLog(pMac, LOG2, FL("Auth1 Frame FTIE is: "));
3952 sirDumpBuf(pMac, SIR_LIM_MODULE_ID, LOG2,
Jeff Johnson295189b2012-06-20 16:38:30 -07003953 (tANI_U8 *)pBody,
3954 (pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length));)
Jeff Johnson295189b2012-06-20 16:38:30 -07003955#endif
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08003956 for (i=0; i<pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length; i++)
3957 {
Madan Mohan Koyyalamudi6a00a802012-11-28 16:12:11 -08003958 *pBody = pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies[i];
3959 pBody++;
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08003960 }
3961 }
3962 else
3963 {
3964 /* MDID attr is 54*/
3965 *pBody = 54;
Jeff Johnson295189b2012-06-20 16:38:30 -07003966 pBody++;
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08003967 *pBody = SIR_MDIE_SIZE;
3968 pBody++;
3969 for(i=0;i<SIR_MDIE_SIZE;i++)
3970 {
3971 *pBody = pMac->ft.ftPEContext.pFTPreAuthReq->pbssDescription->mdie[i];
3972 pBody++;
3973 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003974 }
3975 }
3976 }
3977#endif
3978
Abhishek Singh3cbf6052014-12-15 16:46:42 +05303979 limLog(pMac, LOG1,
Abhishek Singh57aebef2014-02-03 18:47:44 +05303980 FL("*** Sending Auth seq# %d status %d (%d) to "MAC_ADDRESS_STR),
Jeff Johnson295189b2012-06-20 16:38:30 -07003981 pAuthFrameBody->authTransactionSeqNumber,
3982 pAuthFrameBody->authStatusCode,
Abhishek Singh57aebef2014-02-03 18:47:44 +05303983 (pAuthFrameBody->authStatusCode == eSIR_MAC_SUCCESS_STATUS),
Abhishek Singh3cbf6052014-12-15 16:46:42 +05303984 MAC_ADDR_ARRAY(pMacHdr->da));
Jeff Johnson295189b2012-06-20 16:38:30 -07003985 }
3986 PELOG2(sirDumpBuf(pMac, SIR_LIM_MODULE_ID, LOG2, pFrame, frameLen);)
3987
3988 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07003989 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
3990 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003991#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05303992 || ((NULL != pMac->ft.ftPEContext.pFTPreAuthReq)
Jeff Johnsone7245742012-09-05 17:12:55 -07003993 && ( SIR_BAND_5_GHZ == limGetRFBand(pMac->ft.ftPEContext.pFTPreAuthReq->preAuthchannelNum)))
3994#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003995 )
3996 {
3997 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
3998 }
3999
Sushant Kaushike8681d22015-04-21 12:08:25 +05304000 if(psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ||
4001 psessionEntry->pePersona == VOS_STA_MODE)
Ganesh K08bce952012-12-13 15:04:41 -08004002 {
4003 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
4004 }
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08004005
Sushant Kaushik9e923872015-04-02 17:09:31 +05304006 limLog( pMac, LOG1,
4007 FL("Sending Auth Frame over WQ5 with waitForAck %d to "MAC_ADDRESS_STR
4008 " From " MAC_ADDRESS_STR), waitForAck, MAC_ADDR_ARRAY(pMacHdr->da),
Agarwal Ashisha8e81f52014-04-02 01:59:52 +05304009 MAC_ADDR_ARRAY(psessionEntry->selfMacAddr));
4010
4011 txFlag |= HAL_USE_FW_IN_TX_PATH;
4012
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304013 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
4014 psessionEntry->peSessionId,
4015 pMacHdr->fc.subType));
Masti, Narayanraddi67ea5912015-01-08 12:34:05 +05304016
4017 if( ( psessionEntry->is11Gonly == true ) &&
4018 ( !IS_BROADCAST_MAC(peerMacAddr) ) ){
4019 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
4020 }
Sushant Kaushik9e923872015-04-02 17:09:31 +05304021 if(eSIR_TRUE == waitForAck)
4022 {
4023 pMac->authAckStatus = LIM_AUTH_ACK_NOT_RCD;
Sushant Kaushik0b343422015-05-25 17:15:55 +05304024 limLog(pMac, LOG1, FL("Auth frame - txBdToken %u"),
Ganesh Kondabattiniffc00b12015-03-18 13:11:33 +05304025 pMac->lim.txBdToken);
Sushant Kaushik9e923872015-04-02 17:09:31 +05304026 halstatus = halTxFrameWithTxComplete( pMac, pPacket,
4027 ( tANI_U16 ) frameLen,
4028 HAL_TXRX_FRM_802_11_MGMT,
4029 ANI_TXDIR_TODS,
4030 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
Ganesh Kondabattiniffc00b12015-03-18 13:11:33 +05304031 limTxComplete, pFrame, limAuthTxCompleteCnf, txFlag,
4032 pMac->lim.txBdToken);
4033 pMac->lim.txBdToken++;
Sushant Kaushik9e923872015-04-02 17:09:31 +05304034 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
4035 psessionEntry->peSessionId,
4036 halstatus));
4037 if (!HAL_STATUS_SUCCESS(halstatus))
4038 {
4039 limLog( pMac, LOGE,
4040 FL("Could not send Auth frame, retCode=%X "),
4041 halstatus );
4042 pMac->authAckStatus = LIM_AUTH_ACK_RCD_FAILURE;
4043 //Pkt will be freed up by the callback
4044 }
4045 }
4046 else
4047 {
4048 /// Queue Authentication frame in high priority WQ
4049 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) frameLen,
Jeff Johnson295189b2012-06-20 16:38:30 -07004050 HAL_TXRX_FRM_802_11_MGMT,
4051 ANI_TXDIR_TODS,
4052 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4053 limTxComplete, pFrame, txFlag );
Sushant Kaushik9e923872015-04-02 17:09:31 +05304054 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304055 psessionEntry->peSessionId,
4056 halstatus));
Sushant Kaushik9e923872015-04-02 17:09:31 +05304057 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4058 {
Jeff Johnson295189b2012-06-20 16:38:30 -07004059 limLog(pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004060 FL("*** Could not send Auth frame, retCode=%X ***"),
Jeff Johnson295189b2012-06-20 16:38:30 -07004061 halstatus);
4062
4063 //Pkt will be freed up by the callback
Sushant Kaushik9e923872015-04-02 17:09:31 +05304064 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004065 }
4066
4067 return;
4068} /*** end limSendAuthMgmtFrame() ***/
4069
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004070eHalStatus limSendDeauthCnf(tpAniSirGlobal pMac)
4071{
4072 tANI_U16 aid;
4073 tpDphHashNode pStaDs;
4074 tLimMlmDeauthReq *pMlmDeauthReq;
4075 tLimMlmDeauthCnf mlmDeauthCnf;
4076 tpPESession psessionEntry;
4077
4078 pMlmDeauthReq = pMac->lim.limDisassocDeauthCnfReq.pMlmDeauthReq;
4079 if (pMlmDeauthReq)
4080 {
4081 if (tx_timer_running(&pMac->lim.limTimers.gLimDeauthAckTimer))
4082 {
4083 limDeactivateAndChangeTimer(pMac, eLIM_DEAUTH_ACK_TIMER);
4084 }
4085
4086 if((psessionEntry = peFindSessionBySessionId(pMac, pMlmDeauthReq->sessionId))== NULL)
4087 {
4088
4089 PELOGE(limLog(pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004090 FL("session does not exist for given sessionId"));)
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004091 mlmDeauthCnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
4092 goto end;
4093 }
4094
4095 pStaDs = dphLookupHashEntry(pMac, pMlmDeauthReq->peerMacAddr, &aid, &psessionEntry->dph.dphHashTable);
4096 if (pStaDs == NULL)
4097 {
4098 mlmDeauthCnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
4099 goto end;
4100 }
4101
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004102 /// Receive path cleanup with dummy packet
4103 limCleanupRxPath(pMac, pStaDs,psessionEntry);
Abhishek Singhcf4590b2014-04-16 18:58:08 +05304104
4105#ifdef WLAN_FEATURE_VOWIFI_11R
Mukul Sharma0820d0e2014-11-11 19:49:02 +05304106 if ( psessionEntry->limSystemRole == eLIM_STA_ROLE )
Abhishek Singhcf4590b2014-04-16 18:58:08 +05304107 {
Mukul Sharma0820d0e2014-11-11 19:49:02 +05304108 PELOGE(limLog(pMac, LOG1,
4109 FL("FT Preauth SessionId %d Cleanup"
Abhishek Singhcf4590b2014-04-16 18:58:08 +05304110#ifdef FEATURE_WLAN_ESE
4111 " isESE %d"
4112#endif
4113#ifdef FEATURE_WLAN_LFR
4114 " isLFR %d"
4115#endif
4116 " is11r %d, Deauth reason %d Trigger = %d"),
Mukul Sharma0820d0e2014-11-11 19:49:02 +05304117 psessionEntry->peSessionId,
Abhishek Singhcf4590b2014-04-16 18:58:08 +05304118#ifdef FEATURE_WLAN_ESE
4119 psessionEntry->isESEconnection,
4120#endif
4121#ifdef FEATURE_WLAN_LFR
4122 psessionEntry->isFastRoamIniFeatureEnabled,
4123#endif
4124 psessionEntry->is11Rconnection,
4125 pMlmDeauthReq->reasonCode,
4126 pMlmDeauthReq->deauthTrigger););
Mukul Sharma0820d0e2014-11-11 19:49:02 +05304127
4128 limFTCleanup(pMac);
Abhishek Singhcf4590b2014-04-16 18:58:08 +05304129 }
4130#endif
4131
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004132 /// Free up buffer allocated for mlmDeauthReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304133 vos_mem_free(pMlmDeauthReq);
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004134 pMac->lim.limDisassocDeauthCnfReq.pMlmDeauthReq = NULL;
4135 }
4136 return eHAL_STATUS_SUCCESS;
4137end:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304138 vos_mem_copy( (tANI_U8 *) &mlmDeauthCnf.peerMacAddr,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004139 (tANI_U8 *) pMlmDeauthReq->peerMacAddr,
4140 sizeof(tSirMacAddr));
4141 mlmDeauthCnf.deauthTrigger = pMlmDeauthReq->deauthTrigger;
4142 mlmDeauthCnf.aid = pMlmDeauthReq->aid;
4143 mlmDeauthCnf.sessionId = pMlmDeauthReq->sessionId;
4144
4145 // Free up buffer allocated
4146 // for mlmDeauthReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304147 vos_mem_free(pMlmDeauthReq);
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004148
4149 limPostSmeMessage(pMac,
4150 LIM_MLM_DEAUTH_CNF,
4151 (tANI_U32 *) &mlmDeauthCnf);
4152 return eHAL_STATUS_SUCCESS;
4153}
4154
4155eHalStatus limSendDisassocCnf(tpAniSirGlobal pMac)
4156{
4157 tANI_U16 aid;
4158 tpDphHashNode pStaDs;
4159 tLimMlmDisassocCnf mlmDisassocCnf;
4160 tpPESession psessionEntry;
4161 tLimMlmDisassocReq *pMlmDisassocReq;
4162
4163 pMlmDisassocReq = pMac->lim.limDisassocDeauthCnfReq.pMlmDisassocReq;
4164 if (pMlmDisassocReq)
4165 {
4166 if (tx_timer_running(&pMac->lim.limTimers.gLimDisassocAckTimer))
4167 {
4168 limDeactivateAndChangeTimer(pMac, eLIM_DISASSOC_ACK_TIMER);
4169 }
4170
4171 if((psessionEntry = peFindSessionBySessionId(pMac, pMlmDisassocReq->sessionId))== NULL)
4172 {
4173
4174 PELOGE(limLog(pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004175 FL("session does not exist for given sessionId"));)
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004176 mlmDisassocCnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
4177 goto end;
4178 }
4179
4180 pStaDs = dphLookupHashEntry(pMac, pMlmDisassocReq->peerMacAddr, &aid, &psessionEntry->dph.dphHashTable);
4181 if (pStaDs == NULL)
4182 {
Sachin Ahuja2fea3d12014-12-18 17:31:31 +05304183 limLog(pMac, LOGE,
4184 FL("StaDs Null"));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004185 mlmDisassocCnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
4186 goto end;
4187 }
4188
4189 /// Receive path cleanup with dummy packet
4190 if(eSIR_SUCCESS != limCleanupRxPath(pMac, pStaDs, psessionEntry))
4191 {
4192 mlmDisassocCnf.resultCode = eSIR_SME_RESOURCES_UNAVAILABLE;
Sachin Ahuja2fea3d12014-12-18 17:31:31 +05304193 limLog(pMac, LOGE,
4194 FL("CleanupRxPath error"));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004195 goto end;
4196 }
4197
4198#ifdef WLAN_FEATURE_VOWIFI_11R
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08004199 if ( (psessionEntry->limSystemRole == eLIM_STA_ROLE ) &&
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05304200 (pMlmDisassocReq->reasonCode !=
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08004201 eSIR_MAC_DISASSOC_DUE_TO_FTHANDOFF_REASON))
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004202 {
Mukul Sharma0820d0e2014-11-11 19:49:02 +05304203 PELOGE(limLog(pMac, LOG1,
4204 FL("FT Preauth SessionId %d Cleanup"
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004205#ifdef FEATURE_WLAN_ESE
4206 " isESE %d"
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08004207#endif
4208#ifdef FEATURE_WLAN_LFR
4209 " isLFR %d"
4210#endif
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004211 " is11r %d reason %d"),
Mukul Sharma0820d0e2014-11-11 19:49:02 +05304212 psessionEntry->peSessionId,
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004213#ifdef FEATURE_WLAN_ESE
4214 psessionEntry->isESEconnection,
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08004215#endif
4216#ifdef FEATURE_WLAN_LFR
4217 psessionEntry->isFastRoamIniFeatureEnabled,
4218#endif
4219 psessionEntry->is11Rconnection,
4220 pMlmDisassocReq->reasonCode););
Mukul Sharma0820d0e2014-11-11 19:49:02 +05304221 limFTCleanup(pMac);
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004222 }
4223#endif
4224
4225 /// Free up buffer allocated for mlmDisassocReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304226 vos_mem_free(pMlmDisassocReq);
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004227 pMac->lim.limDisassocDeauthCnfReq.pMlmDisassocReq = NULL;
4228 return eHAL_STATUS_SUCCESS;
4229 }
4230 else
4231 {
4232 return eHAL_STATUS_SUCCESS;
4233 }
4234end:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304235 vos_mem_copy( (tANI_U8 *) &mlmDisassocCnf.peerMacAddr,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004236 (tANI_U8 *) pMlmDisassocReq->peerMacAddr,
4237 sizeof(tSirMacAddr));
4238 mlmDisassocCnf.aid = pMlmDisassocReq->aid;
4239 mlmDisassocCnf.disassocTrigger = pMlmDisassocReq->disassocTrigger;
4240
4241 /* Update PE session ID*/
4242 mlmDisassocCnf.sessionId = pMlmDisassocReq->sessionId;
4243
Madan Mohan Koyyalamudib7f5a672012-11-29 11:17:46 -08004244 if(pMlmDisassocReq != NULL)
4245 {
4246 /// Free up buffer allocated for mlmDisassocReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304247 vos_mem_free(pMlmDisassocReq);
Madan Mohan Koyyalamudib7f5a672012-11-29 11:17:46 -08004248 pMac->lim.limDisassocDeauthCnfReq.pMlmDisassocReq = NULL;
4249 }
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004250
4251 limPostSmeMessage(pMac,
4252 LIM_MLM_DISASSOC_CNF,
4253 (tANI_U32 *) &mlmDisassocCnf);
4254 return eHAL_STATUS_SUCCESS;
4255}
4256
Ganesh Kondabattini358fc9b2015-03-11 16:14:25 +05304257eHalStatus limDisassocTxCompleteCnf(tpAniSirGlobal pMac, void *pData)
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004258{
Ganesh Kondabattinib18b3292015-03-16 16:59:26 +05304259 if (pData && IS_FEATURE_SUPPORTED_BY_FW(ENHANCED_TXBD_COMPLETION))
4260 {
4261 tpSirTxBdStatus pTxBdStatus;
4262 pTxBdStatus = (tpSirTxBdStatus) pData;
4263 limLog(pMac, LOG1, FL("txCompleteStatus %u, txBdToken %u"),
4264 pTxBdStatus->txCompleteStatus, pTxBdStatus->txBdToken);
4265 }
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004266 return limSendDisassocCnf(pMac);
4267}
4268
Ganesh Kondabattini358fc9b2015-03-11 16:14:25 +05304269eHalStatus limDeauthTxCompleteCnf(tpAniSirGlobal pMac, void *pData)
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004270{
Ganesh Kondabattinib18b3292015-03-16 16:59:26 +05304271 if (pData && IS_FEATURE_SUPPORTED_BY_FW(ENHANCED_TXBD_COMPLETION))
4272 {
4273 tpSirTxBdStatus pTxBdStatus;
4274 pTxBdStatus = (tpSirTxBdStatus) pData;
4275 limLog(pMac, LOG1, FL("txCompleteStatus %u, txBdToken %u"),
4276 pTxBdStatus->txCompleteStatus, pTxBdStatus->txBdToken);
4277 }
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004278 return limSendDeauthCnf(pMac);
4279}
4280
Jeff Johnson295189b2012-06-20 16:38:30 -07004281/**
4282 * \brief This function is called to send Disassociate frame.
4283 *
4284 *
4285 * \param pMac Pointer to Global MAC structure
4286 *
4287 * \param nReason Indicates the reason that need to be sent in
4288 * Disassociation frame
4289 *
4290 * \param peerMacAddr MAC address of the STA to which Disassociation frame is
4291 * sent
4292 *
4293 *
4294 */
4295
4296void
4297limSendDisassocMgmtFrame(tpAniSirGlobal pMac,
4298 tANI_U16 nReason,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004299 tSirMacAddr peer,
4300 tpPESession psessionEntry,
4301 tANI_BOOLEAN waitForAck)
Jeff Johnson295189b2012-06-20 16:38:30 -07004302{
4303 tDot11fDisassociation frm;
4304 tANI_U8 *pFrame;
4305 tSirRetStatus nSirStatus;
4306 tpSirMacMgmtHdr pMacHdr;
4307 tANI_U32 nBytes, nPayload, nStatus;
4308 void *pPacket;
4309 eHalStatus halstatus;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304310 tANI_U32 txFlag = 0;
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004311 tANI_U32 val = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004312 if(NULL == psessionEntry)
4313 {
4314 return;
4315 }
4316
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304317 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004318
4319 frm.Reason.code = nReason;
4320
4321 nStatus = dot11fGetPackedDisassociationSize( pMac, &frm, &nPayload );
4322 if ( DOT11F_FAILED( nStatus ) )
4323 {
4324 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004325 "or a Disassociation (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004326 nStatus );
4327 // We'll fall back on the worst case scenario:
4328 nPayload = sizeof( tDot11fDisassociation );
4329 }
4330 else if ( DOT11F_WARNED( nStatus ) )
4331 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004332 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07004333 "the packed size for a Disassociation "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004334 "(0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004335 }
4336
4337 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4338
4339 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
4340 ( tANI_U16 )nBytes, ( void** ) &pFrame,
4341 ( void** ) &pPacket );
4342 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4343 {
4344 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Dis"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004345 "association."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07004346 return;
4347 }
4348
4349 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304350 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004351
4352 // Next, we fill out the buffer descriptor:
4353 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
4354 SIR_MAC_MGMT_DISASSOC, peer,psessionEntry->selfMacAddr);
4355 if ( eSIR_SUCCESS != nSirStatus )
4356 {
4357 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004358 "tor for a Disassociation (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004359 nSirStatus );
4360 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
4361 ( void* ) pFrame, ( void* ) pPacket );
4362 return; // just allocated...
4363 }
4364
4365 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
4366
4367 // Prepare the BSSID
4368 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
4369
Chet Lanctot186b5732013-03-18 10:26:30 -07004370#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07004371 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07004372#endif
4373
Jeff Johnson295189b2012-06-20 16:38:30 -07004374 nStatus = dot11fPackDisassociation( pMac, &frm, pFrame +
4375 sizeof(tSirMacMgmtHdr),
4376 nPayload, &nPayload );
4377 if ( DOT11F_FAILED( nStatus ) )
4378 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004379 limLog( pMac, LOGE, FL("Failed to pack a Disassociation (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004380 nStatus );
4381 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
4382 ( void* ) pFrame, ( void* ) pPacket );
4383 return; // allocated!
4384 }
4385 else if ( DOT11F_WARNED( nStatus ) )
4386 {
4387 limLog( pMac, LOGW, FL("There were warnings while packing a D"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004388 "isassociation (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004389 }
4390
Abhishek Singhcd09b562013-12-24 16:02:20 +05304391 limLog( pMac, LOG1, FL("***Sessionid %d Sending Disassociation frame with "
4392 "reason %u and waitForAck %d to "MAC_ADDRESS_STR" ,From "
4393 MAC_ADDRESS_STR), psessionEntry->peSessionId, nReason, waitForAck,
4394 MAC_ADDR_ARRAY(pMacHdr->da),
4395 MAC_ADDR_ARRAY(psessionEntry->selfMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07004396
4397 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07004398 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
4399 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07004400 )
4401 {
4402 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
4403 }
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08004404
Sushant Kaushike8681d22015-04-21 12:08:25 +05304405 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08004406
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304407 if( IS_FW_IN_TX_PATH_FEATURE_ENABLE )
4408 {
4409 /* This frame will be sent on air by firmware,
4410 which will ensure that this frame goes out
4411 even though DEL_STA is sent immediately */
4412 /* Without this for DEL_STA command there is
4413 risk of flushing frame in BTQM queue without
4414 sending on air */
Agarwal Ashisha8e81f52014-04-02 01:59:52 +05304415 limLog( pMac, LOG1, FL("Sending Disassoc Frame over WQ5 to "MAC_ADDRESS_STR
4416 " From " MAC_ADDRESS_STR),MAC_ADDR_ARRAY(pMacHdr->da),
4417 MAC_ADDR_ARRAY(psessionEntry->selfMacAddr));
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304418 txFlag |= HAL_USE_FW_IN_TX_PATH;
4419 }
4420
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004421 if (waitForAck)
Jeff Johnson295189b2012-06-20 16:38:30 -07004422 {
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304423 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
4424 psessionEntry->peSessionId,
4425 pMacHdr->fc.subType));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004426 // Queue Disassociation frame in high priority WQ
4427 /* get the duration from the request */
4428 halstatus = halTxFrameWithTxComplete( pMac, pPacket, ( tANI_U16 ) nBytes,
4429 HAL_TXRX_FRM_802_11_MGMT,
4430 ANI_TXDIR_TODS,
4431 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4432 limTxComplete, pFrame, limDisassocTxCompleteCnf,
Ganesh Kondabattini10e67352015-03-16 17:41:57 +05304433 txFlag,
4434 pMac->lim.txBdToken++);
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304435 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
4436 psessionEntry->peSessionId,
4437 halstatus));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004438 val = SYS_MS_TO_TICKS(LIM_DISASSOC_DEAUTH_ACK_TIMEOUT);
Jeff Johnson295189b2012-06-20 16:38:30 -07004439
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004440 if (tx_timer_change(
4441 &pMac->lim.limTimers.gLimDisassocAckTimer, val, 0)
4442 != TX_SUCCESS)
4443 {
4444 limLog(pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004445 FL("Unable to change Disassoc ack Timer val"));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004446 return;
4447 }
4448 else if(TX_SUCCESS != tx_timer_activate(
4449 &pMac->lim.limTimers.gLimDisassocAckTimer))
4450 {
4451 limLog(pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004452 FL("Unable to activate Disassoc ack Timer"));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004453 limDeactivateAndChangeTimer(pMac, eLIM_DISASSOC_ACK_TIMER);
4454 return;
4455 }
4456 }
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08004457 else
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004458 {
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304459 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
4460 psessionEntry->peSessionId,
4461 pMacHdr->fc.subType));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004462 // Queue Disassociation frame in high priority WQ
4463 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4464 HAL_TXRX_FRM_802_11_MGMT,
4465 ANI_TXDIR_TODS,
4466 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4467 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304468 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
4469 psessionEntry->peSessionId,
4470 halstatus));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004471 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4472 {
4473 limLog( pMac, LOGE, FL("Failed to send Disassociation "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004474 "(%X)!"),
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004475 nSirStatus );
4476 //Pkt will be freed up by the callback
4477 return;
4478 }
4479 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004480} // End limSendDisassocMgmtFrame.
4481
4482/**
4483 * \brief This function is called to send a Deauthenticate frame
4484 *
4485 *
4486 * \param pMac Pointer to global MAC structure
4487 *
4488 * \param nReason Indicates the reason that need to be sent in the
4489 * Deauthenticate frame
4490 *
4491 * \param peeer address of the STA to which the frame is to be sent
4492 *
4493 *
4494 */
4495
4496void
4497limSendDeauthMgmtFrame(tpAniSirGlobal pMac,
4498 tANI_U16 nReason,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004499 tSirMacAddr peer,
4500 tpPESession psessionEntry,
4501 tANI_BOOLEAN waitForAck)
Jeff Johnson295189b2012-06-20 16:38:30 -07004502{
4503 tDot11fDeAuth frm;
4504 tANI_U8 *pFrame;
4505 tSirRetStatus nSirStatus;
4506 tpSirMacMgmtHdr pMacHdr;
4507 tANI_U32 nBytes, nPayload, nStatus;
4508 void *pPacket;
4509 eHalStatus halstatus;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304510 tANI_U32 txFlag = 0;
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004511 tANI_U32 val = 0;
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08004512#ifdef FEATURE_WLAN_TDLS
4513 tANI_U16 aid;
4514 tpDphHashNode pStaDs;
4515#endif
4516
Jeff Johnson295189b2012-06-20 16:38:30 -07004517 if(NULL == psessionEntry)
4518 {
4519 return;
4520 }
4521
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304522 vos_mem_set( ( tANI_U8* ) &frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004523
4524 frm.Reason.code = nReason;
4525
4526 nStatus = dot11fGetPackedDeAuthSize( pMac, &frm, &nPayload );
4527 if ( DOT11F_FAILED( nStatus ) )
4528 {
4529 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004530 "or a De-Authentication (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004531 nStatus );
4532 // We'll fall back on the worst case scenario:
4533 nPayload = sizeof( tDot11fDeAuth );
4534 }
4535 else if ( DOT11F_WARNED( nStatus ) )
4536 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004537 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07004538 "the packed size for a De-Authentication "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004539 "(0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004540 }
4541
4542 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4543
4544 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
4545 ( tANI_U16 )nBytes, ( void** ) &pFrame,
4546 ( void** ) &pPacket );
4547 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4548 {
4549 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a De-"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004550 "Authentication."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07004551 return;
4552 }
4553
4554 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304555 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004556
4557 // Next, we fill out the buffer descriptor:
4558 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
4559 SIR_MAC_MGMT_DEAUTH, peer,psessionEntry->selfMacAddr);
4560 if ( eSIR_SUCCESS != nSirStatus )
4561 {
4562 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004563 "tor for a De-Authentication (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004564 nSirStatus );
4565 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
4566 ( void* ) pFrame, ( void* ) pPacket );
4567 return; // just allocated...
4568 }
4569
4570 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
4571
4572 // Prepare the BSSID
4573 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
4574
Chet Lanctot186b5732013-03-18 10:26:30 -07004575#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07004576 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07004577#endif
4578
Jeff Johnson295189b2012-06-20 16:38:30 -07004579 nStatus = dot11fPackDeAuth( pMac, &frm, pFrame +
4580 sizeof(tSirMacMgmtHdr),
4581 nPayload, &nPayload );
4582 if ( DOT11F_FAILED( nStatus ) )
4583 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004584 limLog( pMac, LOGE, FL("Failed to pack a DeAuthentication (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004585 nStatus );
4586 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
4587 ( void* ) pFrame, ( void* ) pPacket );
4588 return;
4589 }
4590 else if ( DOT11F_WARNED( nStatus ) )
4591 {
4592 limLog( pMac, LOGW, FL("There were warnings while packing a D"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004593 "e-Authentication (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004594 }
Abhishek Singhcd09b562013-12-24 16:02:20 +05304595 limLog( pMac, LOG1, FL("***Sessionid %d Sending Deauth frame with "
4596 "reason %u and waitForAck %d to "MAC_ADDRESS_STR" ,From "
4597 MAC_ADDRESS_STR), psessionEntry->peSessionId, nReason, waitForAck,
4598 MAC_ADDR_ARRAY(pMacHdr->da),
4599 MAC_ADDR_ARRAY(psessionEntry->selfMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07004600
4601 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07004602 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
4603 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07004604 )
4605 {
4606 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
4607 }
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08004608
Sushant Kaushike8681d22015-04-21 12:08:25 +05304609 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08004610
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304611 if( IS_FW_IN_TX_PATH_FEATURE_ENABLE )
4612 {
4613 /* This frame will be sent on air by firmware,
4614 which will ensure that this frame goes out
4615 even though DEL_STA is sent immediately */
4616 /* Without this for DEL_STA command there is
4617 risk of flushing frame in BTQM queue without
4618 sending on air */
Agarwal Ashisha8e81f52014-04-02 01:59:52 +05304619 limLog( pMac, LOG1, FL("Sending Deauth Frame over WQ5 to "MAC_ADDRESS_STR
4620 " From " MAC_ADDRESS_STR),MAC_ADDR_ARRAY(pMacHdr->da),
4621 MAC_ADDR_ARRAY(psessionEntry->selfMacAddr));
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304622 txFlag |= HAL_USE_FW_IN_TX_PATH;
4623 }
4624
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08004625#ifdef FEATURE_WLAN_TDLS
4626 pStaDs = dphLookupHashEntry(pMac, peer, &aid, &psessionEntry->dph.dphHashTable);
4627#endif
4628
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004629 if (waitForAck)
Jeff Johnson295189b2012-06-20 16:38:30 -07004630 {
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304631 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
4632 psessionEntry->peSessionId,
4633 pMacHdr->fc.subType));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004634 // Queue Disassociation frame in high priority WQ
4635 halstatus = halTxFrameWithTxComplete( pMac, pPacket, ( tANI_U16 ) nBytes,
4636 HAL_TXRX_FRM_802_11_MGMT,
4637 ANI_TXDIR_TODS,
4638 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
Ganesh Kondabattini10e67352015-03-16 17:41:57 +05304639 limTxComplete, pFrame, limDeauthTxCompleteCnf, txFlag,
4640 pMac->lim.txBdToken++);
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304641 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
4642 psessionEntry->peSessionId,
4643 halstatus));
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304644 if (!HAL_STATUS_SUCCESS(halstatus))
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004645 {
4646 limLog( pMac, LOGE, FL("Failed to send De-Authentication "
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304647 "(%X)!"),
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004648 nSirStatus );
Gopichand Nakkala4261ea52012-12-31 16:43:00 -08004649 //Pkt will be freed up by the callback limTxComplete
4650
4651 /*Call limProcessDeauthAckTimeout which will send
4652 * DeauthCnf for this frame
4653 */
4654 limProcessDeauthAckTimeout(pMac);
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004655 return;
4656 }
4657
4658 val = SYS_MS_TO_TICKS(LIM_DISASSOC_DEAUTH_ACK_TIMEOUT);
4659
4660 if (tx_timer_change(
4661 &pMac->lim.limTimers.gLimDeauthAckTimer, val, 0)
4662 != TX_SUCCESS)
4663 {
4664 limLog(pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004665 FL("Unable to change Deauth ack Timer val"));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004666 return;
4667 }
4668 else if(TX_SUCCESS != tx_timer_activate(
4669 &pMac->lim.limTimers.gLimDeauthAckTimer))
4670 {
4671 limLog(pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004672 FL("Unable to activate Deauth ack Timer"));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004673 limDeactivateAndChangeTimer(pMac, eLIM_DEAUTH_ACK_TIMER);
4674 return;
4675 }
4676 }
4677 else
4678 {
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304679 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
4680 psessionEntry->peSessionId,
4681 pMacHdr->fc.subType));
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08004682#ifdef FEATURE_WLAN_TDLS
4683 if ((NULL != pStaDs) && (STA_ENTRY_TDLS_PEER == pStaDs->staType))
4684 {
4685 // Queue Disassociation frame in high priority WQ
4686 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004687 HAL_TXRX_FRM_802_11_MGMT,
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08004688 ANI_TXDIR_IBSS,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004689 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4690 limTxComplete, pFrame, txFlag );
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08004691 }
4692 else
4693 {
4694#endif
4695 // Queue Disassociation frame in high priority WQ
4696 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4697 HAL_TXRX_FRM_802_11_MGMT,
4698 ANI_TXDIR_TODS,
4699 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4700 limTxComplete, pFrame, txFlag );
4701#ifdef FEATURE_WLAN_TDLS
4702 }
4703#endif
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304704 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
4705 psessionEntry->peSessionId,
4706 halstatus));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004707 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4708 {
4709 limLog( pMac, LOGE, FL("Failed to send De-Authentication "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004710 "(%X)!"),
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004711 nSirStatus );
4712 //Pkt will be freed up by the callback
4713 return;
4714 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004715 }
4716
4717} // End limSendDeauthMgmtFrame.
4718
4719
4720#ifdef ANI_SUPPORT_11H
4721/**
4722 * \brief Send a Measurement Report Action frame
4723 *
4724 *
4725 * \param pMac Pointer to the global MAC structure
4726 *
4727 * \param pMeasReqFrame Address of a tSirMacMeasReqActionFrame
4728 *
4729 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
4730 *
4731 *
4732 */
4733
4734tSirRetStatus
4735limSendMeasReportFrame(tpAniSirGlobal pMac,
4736 tpSirMacMeasReqActionFrame pMeasReqFrame,
4737 tSirMacAddr peer)
4738{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304739 tDot11fMeasurementReport frm;
4740 tANI_U8 *pFrame;
4741 tSirRetStatus nSirStatus;
4742 tpSirMacMgmtHdr pMacHdr;
4743 tANI_U32 nBytes, nPayload, nStatus, nCfg;
4744 void *pPacket;
4745 eHalStatus halstatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07004746
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304747 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004748
4749 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
4750 frm.Action.action = SIR_MAC_ACTION_MEASURE_REPORT_ID;
4751 frm.DialogToken.token = pMeasReqFrame->actionHeader.dialogToken;
4752
4753 switch ( pMeasReqFrame->measReqIE.measType )
4754 {
4755 case SIR_MAC_BASIC_MEASUREMENT_TYPE:
4756 nSirStatus =
4757 PopulateDot11fMeasurementReport0( pMac, pMeasReqFrame,
4758 &frm.MeasurementReport );
4759 break;
4760 case SIR_MAC_CCA_MEASUREMENT_TYPE:
4761 nSirStatus =
4762 PopulateDot11fMeasurementReport1( pMac, pMeasReqFrame,
4763 &frm.MeasurementReport );
4764 break;
4765 case SIR_MAC_RPI_MEASUREMENT_TYPE:
4766 nSirStatus =
4767 PopulateDot11fMeasurementReport2( pMac, pMeasReqFrame,
4768 &frm.MeasurementReport );
4769 break;
4770 default:
4771 limLog( pMac, LOGE, FL("Unknown measurement type %d in limSen"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004772 "dMeasReportFrame."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004773 pMeasReqFrame->measReqIE.measType );
4774 return eSIR_FAILURE;
4775 }
4776
4777 if ( eSIR_SUCCESS != nSirStatus ) return eSIR_FAILURE;
4778
4779 nStatus = dot11fGetPackedMeasurementReportSize( pMac, &frm, &nPayload );
4780 if ( DOT11F_FAILED( nStatus ) )
4781 {
4782 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004783 "or a Measurement Report (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004784 nStatus );
4785 // We'll fall back on the worst case scenario:
4786 nPayload = sizeof( tDot11fMeasurementReport );
4787 }
4788 else if ( DOT11F_WARNED( nStatus ) )
4789 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004790 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07004791 "the packed size for a Measurement Rep"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004792 "ort (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004793 }
4794
4795 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4796
4797 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
4798 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4799 {
4800 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a De-"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004801 "Authentication."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07004802 return eSIR_FAILURE;
4803 }
4804
4805 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304806 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004807
4808 // Next, we fill out the buffer descriptor:
4809 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
4810 SIR_MAC_MGMT_ACTION, peer);
4811 if ( eSIR_SUCCESS != nSirStatus )
4812 {
4813 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004814 "tor for a Measurement Report (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004815 nSirStatus );
4816 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4817 return eSIR_FAILURE; // just allocated...
4818 }
4819
4820 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
4821
4822 nCfg = 6;
4823 nSirStatus = wlan_cfgGetStr( pMac, WNI_CFG_BSSID, pMacHdr->bssId, &nCfg );
4824 if ( eSIR_SUCCESS != nSirStatus )
4825 {
4826 limLog( pMac, LOGE, FL("Failed to retrieve WNI_CFG_BSSID from"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004827 " CFG (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004828 nSirStatus );
4829 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4830 return eSIR_FAILURE; // just allocated...
4831 }
4832
Chet Lanctot186b5732013-03-18 10:26:30 -07004833#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07004834 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07004835#endif
4836
Jeff Johnson295189b2012-06-20 16:38:30 -07004837 nStatus = dot11fPackMeasurementReport( pMac, &frm, pFrame +
4838 sizeof(tSirMacMgmtHdr),
4839 nPayload, &nPayload );
4840 if ( DOT11F_FAILED( nStatus ) )
4841 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004842 limLog( pMac, LOGE, FL("Failed to pack a Measurement Report (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004843 nStatus );
4844 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4845 return eSIR_FAILURE; // allocated!
4846 }
4847 else if ( DOT11F_WARNED( nStatus ) )
4848 {
4849 limLog( pMac, LOGW, FL("There were warnings while packing a M"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004850 "easurement Report (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004851 }
4852
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304853 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
4854 ((psessionEntry)? psessionEntry->peSessionId : NO_SESSION),
4855 pMacHdr->fc.subType));
Jeff Johnson295189b2012-06-20 16:38:30 -07004856 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4857 HAL_TXRX_FRM_802_11_MGMT,
4858 ANI_TXDIR_TODS,
4859 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4860 limTxComplete, pFrame, 0 );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304861 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
4862 ((psessionEntry)? psessionEntry->peSessionId : NO_SESSION),
4863 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07004864 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4865 {
4866 limLog( pMac, LOGE, FL("Failed to send a Measurement Report "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004867 "(%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07004868 nSirStatus );
4869 //Pkt will be freed up by the callback
4870 return eSIR_FAILURE; // just allocated...
4871 }
4872
4873 return eSIR_SUCCESS;
4874
4875} // End limSendMeasReportFrame.
4876
4877
4878/**
4879 * \brief Send a TPC Request Action frame
4880 *
4881 *
4882 * \param pMac Pointer to the global MAC datastructure
4883 *
4884 * \param peer MAC address to which the frame should be sent
4885 *
4886 *
4887 */
4888
4889void
4890limSendTpcRequestFrame(tpAniSirGlobal pMac,
4891 tSirMacAddr peer)
4892{
4893 tDot11fTPCRequest frm;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304894 tANI_U8 *pFrame;
Jeff Johnson295189b2012-06-20 16:38:30 -07004895 tSirRetStatus nSirStatus;
4896 tpSirMacMgmtHdr pMacHdr;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304897 tANI_U32 nBytes, nPayload, nStatus, nCfg;
4898 void *pPacket;
4899 eHalStatus halstatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07004900
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304901 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004902
4903 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
4904 frm.Action.action = SIR_MAC_ACTION_TPC_REQUEST_ID;
4905 frm.DialogToken.token = 1;
4906 frm.TPCRequest.present = 1;
4907
4908 nStatus = dot11fGetPackedTPCRequestSize( pMac, &frm, &nPayload );
4909 if ( DOT11F_FAILED( nStatus ) )
4910 {
4911 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004912 "or a TPC Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004913 nStatus );
4914 // We'll fall back on the worst case scenario:
4915 nPayload = sizeof( tDot11fTPCRequest );
4916 }
4917 else if ( DOT11F_WARNED( nStatus ) )
4918 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004919 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07004920 "the packed size for a TPC Request (0x"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004921 "%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004922 }
4923
4924 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4925
4926 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
4927 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4928 {
4929 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a TPC"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004930 " Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07004931 return;
4932 }
4933
4934 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304935 vos_mem_set(pFrame, nBytes,0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004936
4937 // Next, we fill out the buffer descriptor:
4938 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
4939 SIR_MAC_MGMT_ACTION, peer);
4940 if ( eSIR_SUCCESS != nSirStatus )
4941 {
4942 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004943 "tor for a TPC Request (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004944 nSirStatus );
4945 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4946 return; // just allocated...
4947 }
4948
4949 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
4950
4951 nCfg = 6;
4952 nSirStatus = wlan_cfgGetStr( pMac, WNI_CFG_BSSID, pMacHdr->bssId, &nCfg );
4953 if ( eSIR_SUCCESS != nSirStatus )
4954 {
4955 limLog( pMac, LOGE, FL("Failed to retrieve WNI_CFG_BSSID from"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004956 " CFG (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004957 nSirStatus );
4958 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4959 return; // just allocated...
4960 }
4961
Chet Lanctot186b5732013-03-18 10:26:30 -07004962#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07004963 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07004964#endif
4965
Jeff Johnson295189b2012-06-20 16:38:30 -07004966 nStatus = dot11fPackTPCRequest( pMac, &frm, pFrame +
4967 sizeof(tSirMacMgmtHdr),
4968 nPayload, &nPayload );
4969 if ( DOT11F_FAILED( nStatus ) )
4970 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004971 limLog( pMac, LOGE, FL("Failed to pack a TPC Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004972 nStatus );
4973 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4974 return; // allocated!
4975 }
4976 else if ( DOT11F_WARNED( nStatus ) )
4977 {
4978 limLog( pMac, LOGW, FL("There were warnings while packing a T"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004979 "PC Request (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004980 }
4981
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304982 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
4983 ((psessionEntry)? psessionEntry->peSessionId : NO_SESSION),
4984 pMacHdr->fc.subType));
Jeff Johnson295189b2012-06-20 16:38:30 -07004985 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4986 HAL_TXRX_FRM_802_11_MGMT,
4987 ANI_TXDIR_TODS,
4988 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4989 limTxComplete, pFrame, 0 );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304990 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
4991 ((psessionEntry)? psessionEntry->peSessionId : NO_SESSION),
4992 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07004993 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4994 {
4995 limLog( pMac, LOGE, FL("Failed to send a TPC Request "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004996 "(%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07004997 nSirStatus );
4998 //Pkt will be freed up by the callback
4999 return;
5000 }
5001
5002} // End limSendTpcRequestFrame.
5003
5004
5005/**
5006 * \brief Send a TPC Report Action frame
5007 *
5008 *
5009 * \param pMac Pointer to the global MAC datastructure
5010 *
5011 * \param pTpcReqFrame Pointer to the received TPC Request
5012 *
5013 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
5014 *
5015 *
5016 */
5017
5018tSirRetStatus
5019limSendTpcReportFrame(tpAniSirGlobal pMac,
5020 tpSirMacTpcReqActionFrame pTpcReqFrame,
5021 tSirMacAddr peer)
5022{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05305023 tDot11fTPCReport frm;
5024 tANI_U8 *pFrame;
5025 tSirRetStatus nSirStatus;
5026 tpSirMacMgmtHdr pMacHdr;
5027 tANI_U32 nBytes, nPayload, nStatus, nCfg;
5028 void *pPacket;
5029 eHalStatus halstatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07005030
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305031 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005032
5033 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
5034 frm.Action.action = SIR_MAC_ACTION_TPC_REPORT_ID;
5035 frm.DialogToken.token = pTpcReqFrame->actionHeader.dialogToken;
5036
5037 // FramesToDo: On the Gen4_TVM branch, there was a comment:
5038 // "misplaced this function, need to replace:
5039 // txPower = halGetRateToPwrValue(pMac, staid,
5040 // pMac->lim.gLimCurrentChannelId, 0);
5041 frm.TPCReport.tx_power = 0;
5042 frm.TPCReport.link_margin = 0;
5043 frm.TPCReport.present = 1;
5044
5045 nStatus = dot11fGetPackedTPCReportSize( pMac, &frm, &nPayload );
5046 if ( DOT11F_FAILED( nStatus ) )
5047 {
5048 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005049 "or a TPC Report (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005050 nStatus );
5051 // We'll fall back on the worst case scenario:
5052 nPayload = sizeof( tDot11fTPCReport );
5053 }
5054 else if ( DOT11F_WARNED( nStatus ) )
5055 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005056 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07005057 "the packed size for a TPC Report (0x"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005058 "%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07005059 }
5060
5061 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
5062
5063 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
5064 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
5065 {
5066 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a TPC"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005067 " Report."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07005068 return eSIR_FAILURE;
5069 }
5070
5071 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305072 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005073
5074 // Next, we fill out the buffer descriptor:
5075 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
5076 SIR_MAC_MGMT_ACTION, peer);
5077 if ( eSIR_SUCCESS != nSirStatus )
5078 {
5079 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005080 "tor for a TPC Report (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005081 nSirStatus );
5082 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
5083 return eSIR_FAILURE; // just allocated...
5084 }
5085
5086 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
5087
5088 nCfg = 6;
5089 nSirStatus = wlan_cfgGetStr( pMac, WNI_CFG_BSSID, pMacHdr->bssId, &nCfg );
5090 if ( eSIR_SUCCESS != nSirStatus )
5091 {
5092 limLog( pMac, LOGE, FL("Failed to retrieve WNI_CFG_BSSID from"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005093 " CFG (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005094 nSirStatus );
5095 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
5096 return eSIR_FAILURE; // just allocated...
5097 }
5098
Chet Lanctot186b5732013-03-18 10:26:30 -07005099#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07005100 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07005101#endif
5102
Jeff Johnson295189b2012-06-20 16:38:30 -07005103 nStatus = dot11fPackTPCReport( pMac, &frm, pFrame +
5104 sizeof(tSirMacMgmtHdr),
5105 nPayload, &nPayload );
5106 if ( DOT11F_FAILED( nStatus ) )
5107 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005108 limLog( pMac, LOGE, FL("Failed to pack a TPC Report (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005109 nStatus );
5110 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
5111 return eSIR_FAILURE; // allocated!
5112 }
5113 else if ( DOT11F_WARNED( nStatus ) )
5114 {
5115 limLog( pMac, LOGW, FL("There were warnings while packing a T"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005116 "PC Report (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07005117 }
5118
5119
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05305120 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
5121 ((psessionEntry)? psessionEntry->peSessionId : NO_SESSION),
5122 pMacHdr->fc.subType));
Jeff Johnson295189b2012-06-20 16:38:30 -07005123 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
5124 HAL_TXRX_FRM_802_11_MGMT,
5125 ANI_TXDIR_TODS,
5126 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
5127 limTxComplete, pFrame, 0 );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05305128 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
5129 ((psessionEntry)? psessionEntry->peSessionId : NO_SESSION),
5130 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07005131 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
5132 {
5133 limLog( pMac, LOGE, FL("Failed to send a TPC Report "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005134 "(%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07005135 nSirStatus );
5136 //Pkt will be freed up by the callback
5137 return eSIR_FAILURE; // just allocated...
5138 }
5139
5140 return eSIR_SUCCESS;
5141
5142} // End limSendTpcReportFrame.
5143#endif //ANI_SUPPORT_11H
5144
5145
Jeff Johnson295189b2012-06-20 16:38:30 -07005146/**
5147 * \brief Send a Channel Switch Announcement
5148 *
5149 *
5150 * \param pMac Pointer to the global MAC datastructure
5151 *
5152 * \param peer MAC address to which this frame will be sent
5153 *
5154 * \param nMode
5155 *
5156 * \param nNewChannel
5157 *
5158 * \param nCount
5159 *
5160 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
5161 *
5162 *
5163 */
5164
5165tSirRetStatus
5166limSendChannelSwitchMgmtFrame(tpAniSirGlobal pMac,
5167 tSirMacAddr peer,
Jeff Johnsone7245742012-09-05 17:12:55 -07005168 tANI_U8 nMode,
5169 tANI_U8 nNewChannel,
5170 tANI_U8 nCount,
5171 tpPESession psessionEntry )
Jeff Johnson295189b2012-06-20 16:38:30 -07005172{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05305173 tDot11fChannelSwitch frm;
5174 tANI_U8 *pFrame;
5175 tSirRetStatus nSirStatus;
5176 tpSirMacMgmtHdr pMacHdr;
5177 tANI_U32 nBytes, nPayload, nStatus;//, nCfg;
5178 void *pPacket;
5179 eHalStatus halstatus;
5180 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005181
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305182 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005183
5184 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
5185 frm.Action.action = SIR_MAC_ACTION_CHANNEL_SWITCH_ID;
5186 frm.ChanSwitchAnn.switchMode = nMode;
5187 frm.ChanSwitchAnn.newChannel = nNewChannel;
5188 frm.ChanSwitchAnn.switchCount = nCount;
5189 frm.ChanSwitchAnn.present = 1;
5190
5191 nStatus = dot11fGetPackedChannelSwitchSize( pMac, &frm, &nPayload );
5192 if ( DOT11F_FAILED( nStatus ) )
5193 {
5194 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005195 "or a Channel Switch (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005196 nStatus );
5197 // We'll fall back on the worst case scenario:
5198 nPayload = sizeof( tDot11fChannelSwitch );
5199 }
5200 else if ( DOT11F_WARNED( nStatus ) )
5201 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005202 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07005203 "the packed size for a Channel Switch (0x"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005204 "%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07005205 }
5206
5207 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
5208
5209 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
5210 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
5211 {
5212 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a TPC"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005213 " Report."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07005214 return eSIR_FAILURE;
5215 }
5216
5217 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305218 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005219
5220 // Next, we fill out the buffer descriptor:
5221 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
Jeff Johnsone7245742012-09-05 17:12:55 -07005222 SIR_MAC_MGMT_ACTION, peer, psessionEntry->selfMacAddr);
5223 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305224 vos_mem_copy( (tANI_U8 *) pMacHdr->bssId,
5225 (tANI_U8 *) psessionEntry->bssId,
5226 sizeof( tSirMacAddr ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005227 if ( eSIR_SUCCESS != nSirStatus )
5228 {
5229 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005230 "tor for a Channel Switch (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005231 nSirStatus );
5232 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
5233 return eSIR_FAILURE; // just allocated...
5234 }
5235
Jeff Johnsone7245742012-09-05 17:12:55 -07005236#if 0
Jeff Johnson295189b2012-06-20 16:38:30 -07005237 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
5238
5239 nCfg = 6;
5240 nSirStatus = wlan_cfgGetStr( pMac, WNI_CFG_BSSID, pMacHdr->bssId, &nCfg );
5241 if ( eSIR_SUCCESS != nSirStatus )
5242 {
5243 limLog( pMac, LOGE, FL("Failed to retrieve WNI_CFG_BSSID from"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005244 " CFG (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005245 nSirStatus );
5246 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
5247 return eSIR_FAILURE; // just allocated...
5248 }
Jeff Johnsone7245742012-09-05 17:12:55 -07005249#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07005250
5251#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07005252 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07005253#endif
5254
Jeff Johnson295189b2012-06-20 16:38:30 -07005255 nStatus = dot11fPackChannelSwitch( pMac, &frm, pFrame +
5256 sizeof(tSirMacMgmtHdr),
5257 nPayload, &nPayload );
5258 if ( DOT11F_FAILED( nStatus ) )
5259 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005260 limLog( pMac, LOGE, FL("Failed to pack a Channel Switch (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005261 nStatus );
5262 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
5263 return eSIR_FAILURE; // allocated!
5264 }
5265 else if ( DOT11F_WARNED( nStatus ) )
5266 {
5267 limLog( pMac, LOGW, FL("There were warnings while packing a C"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005268 "hannel Switch (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07005269 }
5270
Jeff Johnsone7245742012-09-05 17:12:55 -07005271 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnsone7245742012-09-05 17:12:55 -07005272 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
5273 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnsone7245742012-09-05 17:12:55 -07005274 )
5275 {
5276 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
5277 }
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05305278
5279 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
5280 psessionEntry->peSessionId,
5281 pMacHdr->fc.subType));
Jeff Johnson295189b2012-06-20 16:38:30 -07005282 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
5283 HAL_TXRX_FRM_802_11_MGMT,
5284 ANI_TXDIR_TODS,
5285 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
Jeff Johnsone7245742012-09-05 17:12:55 -07005286 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05305287 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
5288 psessionEntry->peSessionId,
5289 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07005290 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
5291 {
5292 limLog( pMac, LOGE, FL("Failed to send a Channel Switch "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005293 "(%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07005294 nSirStatus );
5295 //Pkt will be freed up by the callback
5296 return eSIR_FAILURE;
5297 }
5298
5299 return eSIR_SUCCESS;
5300
5301} // End limSendChannelSwitchMgmtFrame.
5302
Jeff Johnson295189b2012-06-20 16:38:30 -07005303
5304
Mohit Khanna4a70d262012-09-11 16:30:12 -07005305#ifdef WLAN_FEATURE_11AC
5306tSirRetStatus
5307limSendVHTOpmodeNotificationFrame(tpAniSirGlobal pMac,
5308 tSirMacAddr peer,
5309 tANI_U8 nMode,
5310 tpPESession psessionEntry )
5311{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05305312 tDot11fOperatingMode frm;
5313 tANI_U8 *pFrame;
5314 tSirRetStatus nSirStatus;
5315 tpSirMacMgmtHdr pMacHdr;
5316 tANI_U32 nBytes, nPayload = 0, nStatus;//, nCfg;
5317 void *pPacket;
5318 eHalStatus halstatus;
5319 tANI_U32 txFlag = 0;
Mohit Khanna4a70d262012-09-11 16:30:12 -07005320
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305321 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Mohit Khanna4a70d262012-09-11 16:30:12 -07005322
5323 frm.Category.category = SIR_MAC_ACTION_VHT;
5324 frm.Action.action = SIR_MAC_VHT_OPMODE_NOTIFICATION;
5325 frm.OperatingMode.chanWidth = nMode;
5326 frm.OperatingMode.rxNSS = 0;
5327 frm.OperatingMode.rxNSSType = 0;
5328
5329 nStatus = dot11fGetPackedOperatingModeSize( pMac, &frm, &nPayload );
5330 if ( DOT11F_FAILED( nStatus ) )
5331 {
5332 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005333 "or a Operating Mode (0x%08x)."),
Mohit Khanna4a70d262012-09-11 16:30:12 -07005334 nStatus );
5335 // We'll fall back on the worst case scenario:
5336 nPayload = sizeof( tDot11fOperatingMode);
5337 }
5338 else if ( DOT11F_WARNED( nStatus ) )
5339 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005340 limLog( pMac, LOGW, FL("There were warnings while calculating "
Mohit Khanna4a70d262012-09-11 16:30:12 -07005341 "the packed size for a Operating Mode (0x"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005342 "%08x)."), nStatus );
Mohit Khanna4a70d262012-09-11 16:30:12 -07005343 }
5344
5345 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
5346
5347 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
5348 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
5349 {
5350 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Operating Mode"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005351 " Report."), nBytes );
Mohit Khanna4a70d262012-09-11 16:30:12 -07005352 return eSIR_FAILURE;
5353 }
5354
5355 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305356 vos_mem_set( pFrame, nBytes, 0 );
Mohit Khanna4a70d262012-09-11 16:30:12 -07005357
5358
5359 // Next, we fill out the buffer descriptor:
5360 if(psessionEntry->pePersona == VOS_STA_SAP_MODE) {
5361 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
5362 SIR_MAC_MGMT_ACTION, peer, psessionEntry->selfMacAddr);
5363 } else
5364 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
5365 SIR_MAC_MGMT_ACTION, psessionEntry->bssId, psessionEntry->selfMacAddr);
5366 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305367 vos_mem_copy( (tANI_U8 *) pMacHdr->bssId,
5368 (tANI_U8 *) psessionEntry->bssId,
5369 sizeof( tSirMacAddr ));
Mohit Khanna4a70d262012-09-11 16:30:12 -07005370 if ( eSIR_SUCCESS != nSirStatus )
5371 {
5372 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005373 "tor for a Operating Mode (%d)."),
Mohit Khanna4a70d262012-09-11 16:30:12 -07005374 nSirStatus );
5375 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
5376 return eSIR_FAILURE; // just allocated...
5377 }
5378 nStatus = dot11fPackOperatingMode( pMac, &frm, pFrame +
5379 sizeof(tSirMacMgmtHdr),
5380 nPayload, &nPayload );
5381 if ( DOT11F_FAILED( nStatus ) )
5382 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005383 limLog( pMac, LOGE, FL("Failed to pack a Operating Mode (0x%08x)."),
Mohit Khanna4a70d262012-09-11 16:30:12 -07005384 nStatus );
5385 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
5386 return eSIR_FAILURE; // allocated!
5387 }
5388 else if ( DOT11F_WARNED( nStatus ) )
5389 {
5390 limLog( pMac, LOGW, FL("There were warnings while packing a Operating Mode"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005391 " (0x%08x)."), nStatus );
Mohit Khanna4a70d262012-09-11 16:30:12 -07005392 }
5393 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Mohit Khanna4a70d262012-09-11 16:30:12 -07005394 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
5395 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Mohit Khanna4a70d262012-09-11 16:30:12 -07005396 )
5397 {
5398 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
5399 }
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05305400
5401 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
5402 psessionEntry->peSessionId,
5403 pMacHdr->fc.subType));
Mohit Khanna4a70d262012-09-11 16:30:12 -07005404 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
5405 HAL_TXRX_FRM_802_11_MGMT,
5406 ANI_TXDIR_TODS,
5407 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
5408 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05305409 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
5410 psessionEntry->peSessionId,
5411 halstatus));
Mohit Khanna4a70d262012-09-11 16:30:12 -07005412 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
5413 {
5414 limLog( pMac, LOGE, FL("Failed to send a Channel Switch "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005415 "(%X)!"),
Mohit Khanna4a70d262012-09-11 16:30:12 -07005416 nSirStatus );
5417 //Pkt will be freed up by the callback
5418 return eSIR_FAILURE;
5419 }
5420
5421 return eSIR_SUCCESS;
5422}
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005423
5424/**
5425 * \brief Send a VHT Channel Switch Announcement
5426 *
5427 *
5428 * \param pMac Pointer to the global MAC datastructure
5429 *
5430 * \param peer MAC address to which this frame will be sent
5431 *
5432 * \param nChanWidth
5433 *
5434 * \param nNewChannel
5435 *
5436 *
5437 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
5438 *
5439 *
5440 */
5441
5442tSirRetStatus
5443limSendVHTChannelSwitchMgmtFrame(tpAniSirGlobal pMac,
5444 tSirMacAddr peer,
5445 tANI_U8 nChanWidth,
5446 tANI_U8 nNewChannel,
5447 tANI_U8 ncbMode,
5448 tpPESession psessionEntry )
5449{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05305450 tDot11fChannelSwitch frm;
5451 tANI_U8 *pFrame;
5452 tSirRetStatus nSirStatus;
5453 tpSirMacMgmtHdr pMacHdr;
5454 tANI_U32 nBytes, nPayload, nStatus;//, nCfg;
5455 void *pPacket;
5456 eHalStatus halstatus;
5457 tANI_U32 txFlag = 0;
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005458
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305459 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005460
5461
5462 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
5463 frm.Action.action = SIR_MAC_ACTION_CHANNEL_SWITCH_ID;
5464 frm.ChanSwitchAnn.switchMode = 1;
5465 frm.ChanSwitchAnn.newChannel = nNewChannel;
5466 frm.ChanSwitchAnn.switchCount = 1;
5467 frm.ExtChanSwitchAnn.secondaryChannelOffset = limGetHTCBState(ncbMode);
5468 frm.ExtChanSwitchAnn.present = 1;
5469 frm.WiderBWChanSwitchAnn.newChanWidth = nChanWidth;
5470 frm.WiderBWChanSwitchAnn.newCenterChanFreq0 = limGetCenterChannel(pMac,nNewChannel,ncbMode,nChanWidth);
5471 frm.WiderBWChanSwitchAnn.newCenterChanFreq1 = 0;
5472 frm.ChanSwitchAnn.present = 1;
5473 frm.WiderBWChanSwitchAnn.present = 1;
5474
5475 nStatus = dot11fGetPackedChannelSwitchSize( pMac, &frm, &nPayload );
5476 if ( DOT11F_FAILED( nStatus ) )
5477 {
5478 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005479 "or a Channel Switch (0x%08x)."),
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005480 nStatus );
5481 // We'll fall back on the worst case scenario:
5482 nPayload = sizeof( tDot11fChannelSwitch );
5483 }
5484 else if ( DOT11F_WARNED( nStatus ) )
5485 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005486 limLog( pMac, LOGW, FL("There were warnings while calculating "
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005487 "the packed size for a Channel Switch (0x"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005488 "%08x)."), nStatus );
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005489 }
5490
5491 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
5492
5493 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
5494 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
5495 {
5496 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a TPC"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005497 " Report."), nBytes );
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005498 return eSIR_FAILURE;
5499 }
5500 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305501 vos_mem_set( pFrame, nBytes, 0 );
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005502
5503 // Next, we fill out the buffer descriptor:
5504 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
5505 SIR_MAC_MGMT_ACTION, peer, psessionEntry->selfMacAddr);
5506 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305507 vos_mem_copy( (tANI_U8 *) pMacHdr->bssId,
5508 (tANI_U8 *) psessionEntry->bssId,
5509 sizeof( tSirMacAddr ));
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005510 if ( eSIR_SUCCESS != nSirStatus )
5511 {
5512 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005513 "tor for a Channel Switch (%d)."),
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005514 nSirStatus );
5515 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
5516 return eSIR_FAILURE; // just allocated...
5517 }
5518 nStatus = dot11fPackChannelSwitch( pMac, &frm, pFrame +
5519 sizeof(tSirMacMgmtHdr),
5520 nPayload, &nPayload );
5521 if ( DOT11F_FAILED( nStatus ) )
5522 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005523 limLog( pMac, LOGE, FL("Failed to pack a Channel Switch (0x%08x)."),
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005524 nStatus );
5525 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
5526 return eSIR_FAILURE; // allocated!
5527 }
5528 else if ( DOT11F_WARNED( nStatus ) )
5529 {
5530 limLog( pMac, LOGW, FL("There were warnings while packing a C"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005531 "hannel Switch (0x%08x)."), nStatus );
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005532 }
5533
5534 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005535 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
5536 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005537 )
5538 {
5539 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
5540 }
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05305541
5542 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
5543 psessionEntry->peSessionId,
5544 pMacHdr->fc.subType));
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005545 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
5546 HAL_TXRX_FRM_802_11_MGMT,
5547 ANI_TXDIR_TODS,
5548 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
5549 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05305550 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
5551 psessionEntry->peSessionId,
5552 halstatus));
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005553 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
5554 {
5555 limLog( pMac, LOGE, FL("Failed to send a Channel Switch "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005556 "(%X)!"),
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005557 nSirStatus );
5558 //Pkt will be freed up by the callback
5559 return eSIR_FAILURE;
5560 }
5561
5562 return eSIR_SUCCESS;
5563
5564} // End limSendVHTChannelSwitchMgmtFrame.
5565
5566
5567
Mohit Khanna4a70d262012-09-11 16:30:12 -07005568#endif
5569
Jeff Johnson295189b2012-06-20 16:38:30 -07005570/**
5571 * \brief Send an ADDBA Req Action Frame to peer
5572 *
5573 * \sa limSendAddBAReq
5574 *
5575 * \param pMac The global tpAniSirGlobal object
5576 *
5577 * \param pMlmAddBAReq A pointer to tLimMlmAddBAReq. This contains
5578 * the necessary parameters reqd by PE send the ADDBA Req Action
5579 * Frame to the peer
5580 *
5581 * \return eSIR_SUCCESS if setup completes successfully
5582 * eSIR_FAILURE is some problem is encountered
5583 */
5584tSirRetStatus limSendAddBAReq( tpAniSirGlobal pMac,
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305585 tpLimMlmAddBAReq pMlmAddBAReq, tpPESession psessionEntry)
Jeff Johnson295189b2012-06-20 16:38:30 -07005586{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05305587 tDot11fAddBAReq frmAddBAReq;
5588 tANI_U8 *pAddBAReqBuffer = NULL;
5589 tpSirMacMgmtHdr pMacHdr;
5590 tANI_U32 frameLen = 0, nStatus, nPayload;
5591 tSirRetStatus statusCode;
5592 eHalStatus halStatus;
5593 void *pPacket;
5594 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005595
5596 if(NULL == psessionEntry)
5597 {
5598 return eSIR_FAILURE;
5599 }
5600
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305601 vos_mem_set( (void *) &frmAddBAReq, sizeof( frmAddBAReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005602
5603 // Category - 3 (BA)
5604 frmAddBAReq.Category.category = SIR_MAC_ACTION_BLKACK;
5605
5606 // Action - 0 (ADDBA Req)
5607 frmAddBAReq.Action.action = SIR_MAC_BLKACK_ADD_REQ;
5608
5609 // FIXME - Dialog Token, generalize this...
5610 frmAddBAReq.DialogToken.token = pMlmAddBAReq->baDialogToken;
5611
5612 // Fill the ADDBA Parameter Set
5613 frmAddBAReq.AddBAParameterSet.tid = pMlmAddBAReq->baTID;
5614 frmAddBAReq.AddBAParameterSet.policy = pMlmAddBAReq->baPolicy;
5615 frmAddBAReq.AddBAParameterSet.bufferSize = pMlmAddBAReq->baBufferSize;
5616
5617 // BA timeout
5618 // 0 - indicates no BA timeout
5619 frmAddBAReq.BATimeout.timeout = pMlmAddBAReq->baTimeout;
5620
Abhishek Singh1f6e6532014-06-05 17:35:08 +05305621 /* Send SSN whatever we get from FW.
5622 */
5623 frmAddBAReq.BAStartingSequenceControl.ssn = pMlmAddBAReq->baSSN;
Jeff Johnson295189b2012-06-20 16:38:30 -07005624
5625 nStatus = dot11fGetPackedAddBAReqSize( pMac, &frmAddBAReq, &nPayload );
5626
5627 if( DOT11F_FAILED( nStatus ))
5628 {
5629 limLog( pMac, LOGW,
5630 FL( "Failed to calculate the packed size for "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005631 "an ADDBA Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005632 nStatus );
5633
5634 // We'll fall back on the worst case scenario:
5635 nPayload = sizeof( tDot11fAddBAReq );
5636 }
5637 else if( DOT11F_WARNED( nStatus ))
5638 {
5639 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005640 FL( "There were warnings while calculating "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005641 "the packed size for an ADDBA Req (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005642 nStatus );
5643 }
5644
5645 // Add the MGMT header to frame length
5646 frameLen = nPayload + sizeof( tSirMacMgmtHdr );
5647
5648 // Need to allocate a buffer for ADDBA AF
5649 if( eHAL_STATUS_SUCCESS !=
5650 (halStatus = palPktAlloc( pMac->hHdd,
5651 HAL_TXRX_FRM_802_11_MGMT,
5652 (tANI_U16) frameLen,
5653 (void **) &pAddBAReqBuffer,
5654 (void **) &pPacket )))
5655 {
5656 // Log error
5657 limLog( pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005658 FL("palPktAlloc FAILED! Length [%d], Status [%d]"),
Jeff Johnson295189b2012-06-20 16:38:30 -07005659 frameLen,
5660 halStatus );
5661
5662 statusCode = eSIR_MEM_ALLOC_FAILED;
5663 goto returnAfterError;
5664 }
5665
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305666 vos_mem_set( (void *) pAddBAReqBuffer, frameLen, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005667
5668 // Copy necessary info to BD
5669 if( eSIR_SUCCESS !=
5670 (statusCode = limPopulateMacHeader( pMac,
5671 pAddBAReqBuffer,
5672 SIR_MAC_MGMT_FRAME,
5673 SIR_MAC_MGMT_ACTION,
5674 pMlmAddBAReq->peerMacAddr,psessionEntry->selfMacAddr)))
5675 goto returnAfterError;
5676
5677 // Update A3 with the BSSID
5678 pMacHdr = ( tpSirMacMgmtHdr ) pAddBAReqBuffer;
5679
5680 #if 0
5681 cfgLen = SIR_MAC_ADDR_LENGTH;
5682 if( eSIR_SUCCESS != cfgGetStr( pMac,
5683 WNI_CFG_BSSID,
5684 (tANI_U8 *) pMacHdr->bssId,
5685 &cfgLen ))
5686 {
5687 limLog( pMac, LOGP,
5688 FL( "Failed to retrieve WNI_CFG_BSSID while"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005689 "sending an ACTION Frame" ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005690
5691 // FIXME - Need to convert to tSirRetStatus
5692 statusCode = eSIR_FAILURE;
5693 goto returnAfterError;
5694 }
5695 #endif//TO SUPPORT BT-AMP
5696 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
5697
Chet Lanctot186b5732013-03-18 10:26:30 -07005698#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07005699 limSetProtectedBit(pMac, psessionEntry, pMlmAddBAReq->peerMacAddr, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07005700#endif
5701
Jeff Johnson295189b2012-06-20 16:38:30 -07005702 // Now, we're ready to "pack" the frames
5703 nStatus = dot11fPackAddBAReq( pMac,
5704 &frmAddBAReq,
5705 pAddBAReqBuffer + sizeof( tSirMacMgmtHdr ),
5706 nPayload,
5707 &nPayload );
5708
5709 if( DOT11F_FAILED( nStatus ))
5710 {
5711 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005712 FL( "Failed to pack an ADDBA Req (0x%08x)." ),
Jeff Johnson295189b2012-06-20 16:38:30 -07005713 nStatus );
5714
5715 // FIXME - Need to convert to tSirRetStatus
5716 statusCode = eSIR_FAILURE;
5717 goto returnAfterError;
5718 }
5719 else if( DOT11F_WARNED( nStatus ))
5720 {
5721 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005722 FL( "There were warnings while packing an ADDBA Req (0x%08x)."),
5723 nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07005724 }
5725
Abhishek Singh02d9f6c2014-05-12 14:07:53 +05305726 limLog( pMac, LOG1, FL( "Sending an ADDBA REQ to "MAC_ADDRESS_STR " with"
5727 " tid = %d policy = %d buffsize = %d "
5728 " amsduSupported = %d"),
5729 MAC_ADDR_ARRAY(pMlmAddBAReq->peerMacAddr),
5730 frmAddBAReq.AddBAParameterSet.tid,
5731 frmAddBAReq.AddBAParameterSet.policy,
5732 frmAddBAReq.AddBAParameterSet.bufferSize,
5733 frmAddBAReq.AddBAParameterSet.amsduSupported);
Jeff Johnson295189b2012-06-20 16:38:30 -07005734
Abhishek Singh1f6e6532014-06-05 17:35:08 +05305735 limLog( pMac, LOG1, FL( "ssn = %d fragNum = %d" ),
5736 frmAddBAReq.BAStartingSequenceControl.ssn,
5737 frmAddBAReq.BAStartingSequenceControl.fragNumber);
5738
Jeff Johnson295189b2012-06-20 16:38:30 -07005739 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07005740 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
5741 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07005742 )
5743 {
5744 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
5745 }
5746
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05305747 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
5748 psessionEntry->peSessionId,
5749 pMacHdr->fc.subType));
5750 halStatus = halTxFrame( pMac,
5751 pPacket,
5752 (tANI_U16) frameLen,
5753 HAL_TXRX_FRM_802_11_MGMT,
5754 ANI_TXDIR_TODS,
5755 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
5756 limTxComplete,
5757 pAddBAReqBuffer, txFlag );
5758 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
5759 psessionEntry->peSessionId,
5760 halStatus));
5761 if( eHAL_STATUS_SUCCESS != halStatus )
Jeff Johnson295189b2012-06-20 16:38:30 -07005762 {
5763 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005764 FL( "halTxFrame FAILED! Status [%d]"),
Jeff Johnson295189b2012-06-20 16:38:30 -07005765 halStatus );
5766
5767 // FIXME - Need to convert eHalStatus to tSirRetStatus
5768 statusCode = eSIR_FAILURE;
5769 //Pkt will be freed up by the callback
5770 return statusCode;
5771 }
5772 else
5773 return eSIR_SUCCESS;
5774
5775returnAfterError:
5776
5777 // Release buffer, if allocated
5778 if( NULL != pAddBAReqBuffer )
5779 palPktFree( pMac->hHdd,
5780 HAL_TXRX_FRM_802_11_MGMT,
5781 (void *) pAddBAReqBuffer,
5782 (void *) pPacket );
5783
5784 return statusCode;
5785}
5786
5787/**
5788 * \brief Send an ADDBA Rsp Action Frame to peer
5789 *
5790 * \sa limSendAddBARsp
5791 *
5792 * \param pMac The global tpAniSirGlobal object
5793 *
5794 * \param pMlmAddBARsp A pointer to tLimMlmAddBARsp. This contains
5795 * the necessary parameters reqd by PE send the ADDBA Rsp Action
5796 * Frame to the peer
5797 *
5798 * \return eSIR_SUCCESS if setup completes successfully
5799 * eSIR_FAILURE is some problem is encountered
5800 */
5801tSirRetStatus limSendAddBARsp( tpAniSirGlobal pMac,
5802 tpLimMlmAddBARsp pMlmAddBARsp,
5803 tpPESession psessionEntry)
5804{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05305805 tDot11fAddBARsp frmAddBARsp;
5806 tANI_U8 *pAddBARspBuffer = NULL;
5807 tpSirMacMgmtHdr pMacHdr;
5808 tANI_U32 frameLen = 0, nStatus, nPayload;
5809 tSirRetStatus statusCode;
5810 eHalStatus halStatus;
5811 void *pPacket;
5812 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005813
5814 if(NULL == psessionEntry)
5815 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005816 PELOGE(limLog(pMac, LOGE, FL("Session entry is NULL!!!"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07005817 return eSIR_FAILURE;
5818 }
5819
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305820 vos_mem_set( (void *) &frmAddBARsp, sizeof( frmAddBARsp ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005821
5822 // Category - 3 (BA)
5823 frmAddBARsp.Category.category = SIR_MAC_ACTION_BLKACK;
5824 // Action - 1 (ADDBA Rsp)
5825 frmAddBARsp.Action.action = SIR_MAC_BLKACK_ADD_RSP;
5826
5827 // Should be same as the one we received in the ADDBA Req
5828 frmAddBARsp.DialogToken.token = pMlmAddBARsp->baDialogToken;
5829
5830 // ADDBA Req status
5831 frmAddBARsp.Status.status = pMlmAddBARsp->addBAResultCode;
5832
5833 // Fill the ADDBA Parameter Set as provided by caller
5834 frmAddBARsp.AddBAParameterSet.tid = pMlmAddBARsp->baTID;
5835 frmAddBARsp.AddBAParameterSet.policy = pMlmAddBARsp->baPolicy;
5836 frmAddBARsp.AddBAParameterSet.bufferSize = pMlmAddBARsp->baBufferSize;
krunal soni5afa96c2013-09-06 22:19:02 -07005837
5838 if(psessionEntry->isAmsduSupportInAMPDU)
5839 {
5840 frmAddBARsp.AddBAParameterSet.amsduSupported =
5841 psessionEntry->amsduSupportedInBA;
5842 }
5843 else
5844 {
5845 frmAddBARsp.AddBAParameterSet.amsduSupported = 0;
5846 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005847
5848 // BA timeout
5849 // 0 - indicates no BA timeout
5850 frmAddBARsp.BATimeout.timeout = pMlmAddBARsp->baTimeout;
5851
5852 nStatus = dot11fGetPackedAddBARspSize( pMac, &frmAddBARsp, &nPayload );
5853
5854 if( DOT11F_FAILED( nStatus ))
5855 {
5856 limLog( pMac, LOGW,
5857 FL( "Failed to calculate the packed size for "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005858 "an ADDBA Response (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005859 nStatus );
5860
5861 // We'll fall back on the worst case scenario:
5862 nPayload = sizeof( tDot11fAddBARsp );
5863 }
5864 else if( DOT11F_WARNED( nStatus ))
5865 {
5866 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005867 FL( "There were warnings while calculating "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005868 "the packed size for an ADDBA Rsp (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005869 nStatus );
5870 }
5871
5872 // Need to allocate a buffer for ADDBA AF
5873 frameLen = nPayload + sizeof( tSirMacMgmtHdr );
5874
5875 // Allocate shared memory
5876 if( eHAL_STATUS_SUCCESS !=
5877 (halStatus = palPktAlloc( pMac->hHdd,
5878 HAL_TXRX_FRM_802_11_MGMT,
5879 (tANI_U16) frameLen,
5880 (void **) &pAddBARspBuffer,
5881 (void **) &pPacket )))
5882 {
5883 // Log error
5884 limLog( pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005885 FL("palPktAlloc FAILED! Length [%d], Status [%d]"),
Jeff Johnson295189b2012-06-20 16:38:30 -07005886 frameLen,
5887 halStatus );
5888
5889 statusCode = eSIR_MEM_ALLOC_FAILED;
5890 goto returnAfterError;
5891 }
5892
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305893 vos_mem_set( (void *) pAddBARspBuffer, frameLen, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005894
5895 // Copy necessary info to BD
5896 if( eSIR_SUCCESS !=
5897 (statusCode = limPopulateMacHeader( pMac,
5898 pAddBARspBuffer,
5899 SIR_MAC_MGMT_FRAME,
5900 SIR_MAC_MGMT_ACTION,
5901 pMlmAddBARsp->peerMacAddr,psessionEntry->selfMacAddr)))
5902 goto returnAfterError;
5903
5904 // Update A3 with the BSSID
5905
5906 pMacHdr = ( tpSirMacMgmtHdr ) pAddBARspBuffer;
5907
5908 #if 0
5909 cfgLen = SIR_MAC_ADDR_LENGTH;
5910 if( eSIR_SUCCESS != wlan_cfgGetStr( pMac,
5911 WNI_CFG_BSSID,
5912 (tANI_U8 *) pMacHdr->bssId,
5913 &cfgLen ))
5914 {
5915 limLog( pMac, LOGP,
5916 FL( "Failed to retrieve WNI_CFG_BSSID while"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005917 "sending an ACTION Frame" ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005918
5919 // FIXME - Need to convert to tSirRetStatus
5920 statusCode = eSIR_FAILURE;
5921 goto returnAfterError;
5922 }
5923 #endif // TO SUPPORT BT-AMP
5924 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
5925
Chet Lanctot186b5732013-03-18 10:26:30 -07005926#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07005927 limSetProtectedBit(pMac, psessionEntry, pMlmAddBARsp->peerMacAddr, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07005928#endif
5929
Jeff Johnson295189b2012-06-20 16:38:30 -07005930 // Now, we're ready to "pack" the frames
5931 nStatus = dot11fPackAddBARsp( pMac,
5932 &frmAddBARsp,
5933 pAddBARspBuffer + sizeof( tSirMacMgmtHdr ),
5934 nPayload,
5935 &nPayload );
5936
5937 if( DOT11F_FAILED( nStatus ))
5938 {
5939 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005940 FL( "Failed to pack an ADDBA Rsp (0x%08x)." ),
Jeff Johnson295189b2012-06-20 16:38:30 -07005941 nStatus );
5942
5943 // FIXME - Need to convert to tSirRetStatus
5944 statusCode = eSIR_FAILURE;
5945 goto returnAfterError;
5946 }
5947 else if( DOT11F_WARNED( nStatus ))
5948 {
5949 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005950 FL( "There were warnings while packing an ADDBA Rsp (0x%08x)." ),
5951 nStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07005952 }
5953
Abhishek Singh02d9f6c2014-05-12 14:07:53 +05305954 limLog( pMac, LOG1, FL( "Sending an ADDBA RSP to "MAC_ADDRESS_STR " with"
5955 " tid = %d policy = %d buffsize = %d"
5956 " amsduSupported = %d status %d"),
5957 MAC_ADDR_ARRAY(pMlmAddBARsp->peerMacAddr),
5958 frmAddBARsp.AddBAParameterSet.tid,
5959 frmAddBARsp.AddBAParameterSet.policy,
5960 frmAddBARsp.AddBAParameterSet.bufferSize,
5961 frmAddBARsp.AddBAParameterSet.amsduSupported,
5962 frmAddBARsp.Status.status);
5963
Jeff Johnson295189b2012-06-20 16:38:30 -07005964
5965 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07005966 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
5967 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07005968 )
5969 {
5970 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
5971 }
5972
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05305973 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
5974 psessionEntry->peSessionId,
5975 pMacHdr->fc.subType));
5976 halStatus = halTxFrame( pMac,
5977 pPacket,
5978 (tANI_U16) frameLen,
5979 HAL_TXRX_FRM_802_11_MGMT,
5980 ANI_TXDIR_TODS,
5981 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
5982 limTxComplete,
5983 pAddBARspBuffer, txFlag );
5984 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
5985 psessionEntry->peSessionId,
5986 halStatus));
5987 if( eHAL_STATUS_SUCCESS != halStatus )
5988 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005989 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005990 FL( "halTxFrame FAILED! Status [%d]" ),
Jeff Johnson295189b2012-06-20 16:38:30 -07005991 halStatus );
5992
5993 // FIXME - HAL error codes are different from PE error
5994 // codes!! And, this routine is returning tSirRetStatus
5995 statusCode = eSIR_FAILURE;
5996 //Pkt will be freed up by the callback
5997 return statusCode;
5998 }
5999 else
6000 return eSIR_SUCCESS;
6001
6002 returnAfterError:
Jeff Johnson295189b2012-06-20 16:38:30 -07006003 // Release buffer, if allocated
6004 if( NULL != pAddBARspBuffer )
6005 palPktFree( pMac->hHdd,
6006 HAL_TXRX_FRM_802_11_MGMT,
6007 (void *) pAddBARspBuffer,
6008 (void *) pPacket );
6009
6010 return statusCode;
6011}
6012
6013/**
6014 * \brief Send a DELBA Indication Action Frame to peer
6015 *
6016 * \sa limSendDelBAInd
6017 *
6018 * \param pMac The global tpAniSirGlobal object
6019 *
6020 * \param peerMacAddr MAC Address of peer
6021 *
6022 * \param reasonCode Reason for the DELBA notification
6023 *
6024 * \param pBAParameterSet The DELBA Parameter Set.
6025 * This identifies the TID for which the BA session is
6026 * being deleted.
6027 *
6028 * \return eSIR_SUCCESS if setup completes successfully
6029 * eSIR_FAILURE is some problem is encountered
6030 */
6031tSirRetStatus limSendDelBAInd( tpAniSirGlobal pMac,
6032 tpLimMlmDelBAReq pMlmDelBAReq,tpPESession psessionEntry)
6033{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05306034 tDot11fDelBAInd frmDelBAInd;
6035 tANI_U8 *pDelBAIndBuffer = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07006036 //tANI_U32 val;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05306037 tpSirMacMgmtHdr pMacHdr;
6038 tANI_U32 frameLen = 0, nStatus, nPayload;
6039 tSirRetStatus statusCode;
6040 eHalStatus halStatus;
6041 void *pPacket;
6042 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07006043
6044 if(NULL == psessionEntry)
6045 {
6046 return eSIR_FAILURE;
6047 }
6048
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05306049 vos_mem_set( (void *) &frmDelBAInd, sizeof( frmDelBAInd ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07006050
6051 // Category - 3 (BA)
6052 frmDelBAInd.Category.category = SIR_MAC_ACTION_BLKACK;
6053 // Action - 2 (DELBA)
6054 frmDelBAInd.Action.action = SIR_MAC_BLKACK_DEL;
6055
6056 // Fill the DELBA Parameter Set as provided by caller
6057 frmDelBAInd.DelBAParameterSet.tid = pMlmDelBAReq->baTID;
6058 frmDelBAInd.DelBAParameterSet.initiator = pMlmDelBAReq->baDirection;
6059
6060 // BA Starting Sequence Number
6061 // Fragment number will always be zero
6062 frmDelBAInd.Reason.code = pMlmDelBAReq->delBAReasonCode;
6063
6064 nStatus = dot11fGetPackedDelBAIndSize( pMac, &frmDelBAInd, &nPayload );
6065
6066 if( DOT11F_FAILED( nStatus ))
6067 {
6068 limLog( pMac, LOGW,
6069 FL( "Failed to calculate the packed size for "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006070 "an DELBA Indication (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07006071 nStatus );
6072
6073 // We'll fall back on the worst case scenario:
6074 nPayload = sizeof( tDot11fDelBAInd );
6075 }
6076 else if( DOT11F_WARNED( nStatus ))
6077 {
6078 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08006079 FL( "There were warnings while calculating "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006080 "the packed size for an DELBA Ind (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07006081 nStatus );
6082 }
6083
6084 // Add the MGMT header to frame length
6085 frameLen = nPayload + sizeof( tSirMacMgmtHdr );
6086
6087 // Allocate shared memory
6088 if( eHAL_STATUS_SUCCESS !=
6089 (halStatus = palPktAlloc( pMac->hHdd,
6090 HAL_TXRX_FRM_802_11_MGMT,
6091 (tANI_U16) frameLen,
6092 (void **) &pDelBAIndBuffer,
6093 (void **) &pPacket )))
6094 {
6095 // Log error
6096 limLog( pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006097 FL("palPktAlloc FAILED! Length [%d], Status [%d]"),
Jeff Johnson295189b2012-06-20 16:38:30 -07006098 frameLen,
6099 halStatus );
6100
6101 statusCode = eSIR_MEM_ALLOC_FAILED;
6102 goto returnAfterError;
6103 }
6104
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05306105 vos_mem_set( (void *) pDelBAIndBuffer, frameLen, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07006106
6107 // Copy necessary info to BD
6108 if( eSIR_SUCCESS !=
6109 (statusCode = limPopulateMacHeader( pMac,
6110 pDelBAIndBuffer,
6111 SIR_MAC_MGMT_FRAME,
6112 SIR_MAC_MGMT_ACTION,
6113 pMlmDelBAReq->peerMacAddr,psessionEntry->selfMacAddr)))
6114 goto returnAfterError;
6115
6116 // Update A3 with the BSSID
6117 pMacHdr = ( tpSirMacMgmtHdr ) pDelBAIndBuffer;
6118
6119 #if 0
6120 cfgLen = SIR_MAC_ADDR_LENGTH;
6121 if( eSIR_SUCCESS != cfgGetStr( pMac,
6122 WNI_CFG_BSSID,
6123 (tANI_U8 *) pMacHdr->bssId,
6124 &cfgLen ))
6125 {
6126 limLog( pMac, LOGP,
6127 FL( "Failed to retrieve WNI_CFG_BSSID while"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006128 "sending an ACTION Frame" ));
Jeff Johnson295189b2012-06-20 16:38:30 -07006129
6130 // FIXME - Need to convert to tSirRetStatus
6131 statusCode = eSIR_FAILURE;
6132 goto returnAfterError;
6133 }
6134 #endif //TO SUPPORT BT-AMP
6135 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
6136
Chet Lanctot186b5732013-03-18 10:26:30 -07006137#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07006138 limSetProtectedBit(pMac, psessionEntry, pMlmDelBAReq->peerMacAddr, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07006139#endif
6140
Jeff Johnson295189b2012-06-20 16:38:30 -07006141 // Now, we're ready to "pack" the frames
6142 nStatus = dot11fPackDelBAInd( pMac,
6143 &frmDelBAInd,
6144 pDelBAIndBuffer + sizeof( tSirMacMgmtHdr ),
6145 nPayload,
6146 &nPayload );
6147
6148 if( DOT11F_FAILED( nStatus ))
6149 {
6150 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006151 FL( "Failed to pack an DELBA Ind (0x%08x)." ),
Jeff Johnson295189b2012-06-20 16:38:30 -07006152 nStatus );
6153
6154 // FIXME - Need to convert to tSirRetStatus
6155 statusCode = eSIR_FAILURE;
6156 goto returnAfterError;
6157 }
6158 else if( DOT11F_WARNED( nStatus ))
6159 {
6160 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08006161 FL( "There were warnings while packing an DELBA Ind (0x%08x)." ),
6162 nStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07006163 }
6164
Abhishek Singh1f6e6532014-06-05 17:35:08 +05306165 limLog( pMac, LOG1,
6166 FL( "Sending a DELBA IND to: "MAC_ADDRESS_STR" with Tid = %d"
6167 " initiator = %d reason = %d" ),
6168 MAC_ADDR_ARRAY(pMlmDelBAReq->peerMacAddr),
6169 frmDelBAInd.DelBAParameterSet.tid,
6170 frmDelBAInd.DelBAParameterSet.initiator,
6171 frmDelBAInd.Reason.code);
6172
Jeff Johnson295189b2012-06-20 16:38:30 -07006173
6174 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07006175 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
6176 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07006177 )
6178 {
6179 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
6180 }
6181
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05306182 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
6183 psessionEntry->peSessionId,
6184 pMacHdr->fc.subType));
6185 halStatus = halTxFrame( pMac,
6186 pPacket,
6187 (tANI_U16) frameLen,
6188 HAL_TXRX_FRM_802_11_MGMT,
6189 ANI_TXDIR_TODS,
6190 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
6191 limTxComplete,
6192 pDelBAIndBuffer, txFlag );
6193 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
6194 psessionEntry->peSessionId,
6195 halStatus));
6196 if( eHAL_STATUS_SUCCESS != halStatus )
Jeff Johnson295189b2012-06-20 16:38:30 -07006197 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006198 PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]" ), halStatus );)
Jeff Johnson295189b2012-06-20 16:38:30 -07006199 statusCode = eSIR_FAILURE;
6200 //Pkt will be freed up by the callback
6201 return statusCode;
6202 }
6203 else
6204 return eSIR_SUCCESS;
6205
6206 returnAfterError:
6207
6208 // Release buffer, if allocated
6209 if( NULL != pDelBAIndBuffer )
6210 palPktFree( pMac->hHdd,
6211 HAL_TXRX_FRM_802_11_MGMT,
6212 (void *) pDelBAIndBuffer,
6213 (void *) pPacket );
6214
6215 return statusCode;
6216}
6217
6218#if defined WLAN_FEATURE_VOWIFI
6219
6220/**
6221 * \brief Send a Neighbor Report Request Action frame
6222 *
6223 *
6224 * \param pMac Pointer to the global MAC structure
6225 *
6226 * \param pNeighborReq Address of a tSirMacNeighborReportReq
6227 *
6228 * \param peer mac address of peer station.
6229 *
6230 * \param psessionEntry address of session entry.
6231 *
6232 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
6233 *
6234 *
6235 */
6236
6237tSirRetStatus
6238limSendNeighborReportRequestFrame(tpAniSirGlobal pMac,
6239 tpSirMacNeighborReportReq pNeighborReq,
6240 tSirMacAddr peer,
6241 tpPESession psessionEntry
6242 )
6243{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05306244 tSirRetStatus statusCode = eSIR_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006245 tDot11fNeighborReportRequest frm;
6246 tANI_U8 *pFrame;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05306247 tpSirMacMgmtHdr pMacHdr;
6248 tANI_U32 nBytes, nPayload, nStatus;
6249 void *pPacket;
6250 eHalStatus halstatus;
6251 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07006252
6253 if ( psessionEntry == NULL )
6254 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006255 limLog( pMac, LOGE, FL("(psession == NULL) in Request to send Neighbor Report request action frame") );
Jeff Johnson295189b2012-06-20 16:38:30 -07006256 return eSIR_FAILURE;
6257 }
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05306258 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07006259
6260 frm.Category.category = SIR_MAC_ACTION_RRM;
6261 frm.Action.action = SIR_MAC_RRM_NEIGHBOR_REQ;
6262 frm.DialogToken.token = pNeighborReq->dialogToken;
6263
6264
6265 if( pNeighborReq->ssid_present )
6266 {
6267 PopulateDot11fSSID( pMac, &pNeighborReq->ssid, &frm.SSID );
6268 }
6269
6270 nStatus = dot11fGetPackedNeighborReportRequestSize( pMac, &frm, &nPayload );
6271 if ( DOT11F_FAILED( nStatus ) )
6272 {
6273 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006274 "or a Neighbor Report Request(0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07006275 nStatus );
6276 // We'll fall back on the worst case scenario:
6277 nPayload = sizeof( tDot11fNeighborReportRequest );
6278 }
6279 else if ( DOT11F_WARNED( nStatus ) )
6280 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08006281 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07006282 "the packed size for a Neighbor Rep"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006283 "ort Request(0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07006284 }
6285
6286 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
6287
6288 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
6289 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
6290 {
6291 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Neighbor "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006292 "Report Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07006293 return eSIR_FAILURE;
6294 }
6295
6296 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05306297 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07006298
6299 // Copy necessary info to BD
6300 if( eSIR_SUCCESS !=
6301 (statusCode = limPopulateMacHeader( pMac,
6302 pFrame,
6303 SIR_MAC_MGMT_FRAME,
6304 SIR_MAC_MGMT_ACTION,
6305 peer, psessionEntry->selfMacAddr)))
6306 goto returnAfterError;
6307
6308 // Update A3 with the BSSID
6309 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
6310
6311 sirCopyMacAddr( pMacHdr->bssId, psessionEntry->bssId );
6312
Chet Lanctot186b5732013-03-18 10:26:30 -07006313#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07006314 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07006315#endif
6316
Jeff Johnson295189b2012-06-20 16:38:30 -07006317 // Now, we're ready to "pack" the frames
6318 nStatus = dot11fPackNeighborReportRequest( pMac,
6319 &frm,
6320 pFrame + sizeof( tSirMacMgmtHdr ),
6321 nPayload,
6322 &nPayload );
6323
6324 if( DOT11F_FAILED( nStatus ))
6325 {
6326 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006327 FL( "Failed to pack an Neighbor Report Request (0x%08x)." ),
Jeff Johnson295189b2012-06-20 16:38:30 -07006328 nStatus );
6329
6330 // FIXME - Need to convert to tSirRetStatus
6331 statusCode = eSIR_FAILURE;
6332 goto returnAfterError;
6333 }
6334 else if( DOT11F_WARNED( nStatus ))
6335 {
6336 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08006337 FL( "There were warnings while packing Neighbor Report "
6338 "Request (0x%08x)." ), nStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07006339 }
6340
6341 limLog( pMac, LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006342 FL( "Sending a Neighbor Report Request to " ));
Jeff Johnson295189b2012-06-20 16:38:30 -07006343 limPrintMacAddr( pMac, peer, LOGW );
6344
6345 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07006346 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
6347 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07006348 )
6349 {
6350 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
6351 }
6352
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05306353 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
6354 psessionEntry->peSessionId,
6355 pMacHdr->fc.subType));
6356 halstatus = halTxFrame( pMac,
6357 pPacket,
6358 (tANI_U16) nBytes,
6359 HAL_TXRX_FRM_802_11_MGMT,
6360 ANI_TXDIR_TODS,
6361 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
6362 limTxComplete,
6363 pFrame, txFlag );
6364 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
6365 psessionEntry->peSessionId,
6366 halstatus));
6367 if( eHAL_STATUS_SUCCESS != halstatus )
Jeff Johnson295189b2012-06-20 16:38:30 -07006368 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006369 PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]" ), halstatus );)
Jeff Johnson295189b2012-06-20 16:38:30 -07006370 statusCode = eSIR_FAILURE;
6371 //Pkt will be freed up by the callback
6372 return statusCode;
6373 }
6374 else
6375 return eSIR_SUCCESS;
6376
6377returnAfterError:
6378 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
6379
6380 return statusCode;
6381} // End limSendNeighborReportRequestFrame.
6382
6383/**
6384 * \brief Send a Link Report Action frame
6385 *
6386 *
6387 * \param pMac Pointer to the global MAC structure
6388 *
6389 * \param pLinkReport Address of a tSirMacLinkReport
6390 *
6391 * \param peer mac address of peer station.
6392 *
6393 * \param psessionEntry address of session entry.
6394 *
6395 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
6396 *
6397 *
6398 */
6399
6400tSirRetStatus
6401limSendLinkReportActionFrame(tpAniSirGlobal pMac,
6402 tpSirMacLinkReport pLinkReport,
6403 tSirMacAddr peer,
6404 tpPESession psessionEntry
6405 )
6406{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05306407 tSirRetStatus statusCode = eSIR_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006408 tDot11fLinkMeasurementReport frm;
6409 tANI_U8 *pFrame;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05306410 tpSirMacMgmtHdr pMacHdr;
6411 tANI_U32 nBytes, nPayload, nStatus;
6412 void *pPacket;
6413 eHalStatus halstatus;
6414 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07006415
6416
6417 if ( psessionEntry == NULL )
6418 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006419 limLog( pMac, LOGE, FL("(psession == NULL) in Request to send Link Report action frame") );
Jeff Johnson295189b2012-06-20 16:38:30 -07006420 return eSIR_FAILURE;
6421 }
6422
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05306423 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07006424
6425 frm.Category.category = SIR_MAC_ACTION_RRM;
6426 frm.Action.action = SIR_MAC_RRM_LINK_MEASUREMENT_RPT;
6427 frm.DialogToken.token = pLinkReport->dialogToken;
6428
6429
6430 //IEEE Std. 802.11 7.3.2.18. for the report element.
6431 //Even though TPC report an IE, it is represented using fixed fields since it is positioned
6432 //in the middle of other fixed fields in the link report frame(IEEE Std. 802.11k section7.4.6.4
6433 //and frame parser always expects IEs to come after all fixed fields. It is easier to handle
6434 //such case this way than changing the frame parser.
6435 frm.TPCEleID.TPCId = SIR_MAC_TPC_RPT_EID;
6436 frm.TPCEleLen.TPCLen = 2;
6437 frm.TxPower.txPower = pLinkReport->txPower;
6438 frm.LinkMargin.linkMargin = 0;
6439
6440 frm.RxAntennaId.antennaId = pLinkReport->rxAntenna;
6441 frm.TxAntennaId.antennaId = pLinkReport->txAntenna;
6442 frm.RCPI.rcpi = pLinkReport->rcpi;
6443 frm.RSNI.rsni = pLinkReport->rsni;
6444
6445 nStatus = dot11fGetPackedLinkMeasurementReportSize( pMac, &frm, &nPayload );
6446 if ( DOT11F_FAILED( nStatus ) )
6447 {
6448 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006449 "or a Link Report (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07006450 nStatus );
6451 // We'll fall back on the worst case scenario:
6452 nPayload = sizeof( tDot11fLinkMeasurementReport );
6453 }
6454 else if ( DOT11F_WARNED( nStatus ) )
6455 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08006456 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07006457 "the packed size for a Link Rep"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006458 "ort (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07006459 }
6460
6461 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
6462
6463 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
6464 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
6465 {
6466 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Link "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006467 "Report."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07006468 return eSIR_FAILURE;
6469 }
6470
6471 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05306472 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07006473
6474 // Copy necessary info to BD
6475 if( eSIR_SUCCESS !=
6476 (statusCode = limPopulateMacHeader( pMac,
6477 pFrame,
6478 SIR_MAC_MGMT_FRAME,
6479 SIR_MAC_MGMT_ACTION,
6480 peer, psessionEntry->selfMacAddr)))
6481 goto returnAfterError;
6482
6483 // Update A3 with the BSSID
6484 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
6485
6486 sirCopyMacAddr( pMacHdr->bssId, psessionEntry->bssId );
6487
Chet Lanctot186b5732013-03-18 10:26:30 -07006488#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07006489 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07006490#endif
6491
Jeff Johnson295189b2012-06-20 16:38:30 -07006492 // Now, we're ready to "pack" the frames
6493 nStatus = dot11fPackLinkMeasurementReport( pMac,
6494 &frm,
6495 pFrame + sizeof( tSirMacMgmtHdr ),
6496 nPayload,
6497 &nPayload );
6498
6499 if( DOT11F_FAILED( nStatus ))
6500 {
6501 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006502 FL( "Failed to pack an Link Report (0x%08x)." ),
Jeff Johnson295189b2012-06-20 16:38:30 -07006503 nStatus );
6504
6505 // FIXME - Need to convert to tSirRetStatus
6506 statusCode = eSIR_FAILURE;
6507 goto returnAfterError;
6508 }
6509 else if( DOT11F_WARNED( nStatus ))
6510 {
6511 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08006512 FL( "There were warnings while packing Link Report (0x%08x)." ),
6513 nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07006514 }
6515
6516 limLog( pMac, LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006517 FL( "Sending a Link Report to " ));
Jeff Johnson295189b2012-06-20 16:38:30 -07006518 limPrintMacAddr( pMac, peer, LOGW );
6519
6520 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07006521 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
6522 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07006523 )
6524 {
6525 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
6526 }
6527
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05306528 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
6529 psessionEntry->peSessionId,
6530 pMacHdr->fc.subType));
6531 halstatus = halTxFrame( pMac,
6532 pPacket,
6533 (tANI_U16) nBytes,
6534 HAL_TXRX_FRM_802_11_MGMT,
6535 ANI_TXDIR_TODS,
6536 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
6537 limTxComplete,
6538 pFrame, txFlag );
6539 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
6540 psessionEntry->peSessionId,
6541 halstatus));
6542 if( eHAL_STATUS_SUCCESS != halstatus )
Jeff Johnson295189b2012-06-20 16:38:30 -07006543 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006544 PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]" ), halstatus );)
Jeff Johnson295189b2012-06-20 16:38:30 -07006545 statusCode = eSIR_FAILURE;
6546 //Pkt will be freed up by the callback
6547 return statusCode;
6548 }
6549 else
6550 return eSIR_SUCCESS;
6551
6552returnAfterError:
6553 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
6554
6555 return statusCode;
6556} // End limSendLinkReportActionFrame.
6557
6558/**
6559 * \brief Send a Beacon Report Action frame
6560 *
6561 *
6562 * \param pMac Pointer to the global MAC structure
6563 *
6564 * \param dialog_token dialog token to be used in the action frame.
6565 *
6566 * \param num_report number of reports in pRRMReport.
6567 *
6568 * \param pRRMReport Address of a tSirMacRadioMeasureReport.
6569 *
6570 * \param peer mac address of peer station.
6571 *
6572 * \param psessionEntry address of session entry.
6573 *
6574 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
6575 *
6576 *
6577 */
6578
6579tSirRetStatus
6580limSendRadioMeasureReportActionFrame(tpAniSirGlobal pMac,
6581 tANI_U8 dialog_token,
6582 tANI_U8 num_report,
6583 tpSirMacRadioMeasureReport pRRMReport,
6584 tSirMacAddr peer,
6585 tpPESession psessionEntry
6586 )
6587{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05306588 tSirRetStatus statusCode = eSIR_SUCCESS;
6589 tANI_U8 *pFrame;
6590 tpSirMacMgmtHdr pMacHdr;
6591 tANI_U32 nBytes, nPayload, nStatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07006592 void *pPacket;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05306593 eHalStatus halstatus;
6594 tANI_U8 i;
6595 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07006596
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006597 tDot11fRadioMeasurementReport *frm =
6598 vos_mem_malloc(sizeof(tDot11fRadioMeasurementReport));
6599 if (!frm) {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006600 limLog( pMac, LOGE, FL("Not enough memory to allocate tDot11fRadioMeasurementReport") );
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006601 return eSIR_FAILURE;
6602 }
6603
Jeff Johnson295189b2012-06-20 16:38:30 -07006604 if ( psessionEntry == NULL )
6605 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006606 limLog( pMac, LOGE, FL("(psession == NULL) in Request to send Beacon Report action frame") );
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006607 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07006608 return eSIR_FAILURE;
6609 }
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05306610 vos_mem_set( ( tANI_U8* )frm, sizeof( *frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07006611
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006612 frm->Category.category = SIR_MAC_ACTION_RRM;
6613 frm->Action.action = SIR_MAC_RRM_RADIO_MEASURE_RPT;
6614 frm->DialogToken.token = dialog_token;
Jeff Johnson295189b2012-06-20 16:38:30 -07006615
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006616 frm->num_MeasurementReport = (num_report > RADIO_REPORTS_MAX_IN_A_FRAME ) ? RADIO_REPORTS_MAX_IN_A_FRAME : num_report;
Jeff Johnson295189b2012-06-20 16:38:30 -07006617
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006618 for( i = 0 ; i < frm->num_MeasurementReport ; i++ )
Jeff Johnson295189b2012-06-20 16:38:30 -07006619 {
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006620 frm->MeasurementReport[i].type = pRRMReport[i].type;
6621 frm->MeasurementReport[i].token = pRRMReport[i].token;
6622 frm->MeasurementReport[i].late = 0; //IEEE 802.11k section 7.3.22. (always zero in rrm)
Jeff Johnson295189b2012-06-20 16:38:30 -07006623 switch( pRRMReport[i].type )
6624 {
6625 case SIR_MAC_RRM_BEACON_TYPE:
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006626 PopulateDot11fBeaconReport( pMac, &frm->MeasurementReport[i], &pRRMReport[i].report.beaconReport );
6627 frm->MeasurementReport[i].incapable = pRRMReport[i].incapable;
6628 frm->MeasurementReport[i].refused = pRRMReport[i].refused;
6629 frm->MeasurementReport[i].present = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07006630 break;
6631 default:
Gopichand Nakkala72717fd2013-02-08 12:23:45 +05306632 frm->MeasurementReport[i].incapable = pRRMReport[i].incapable;
6633 frm->MeasurementReport[i].refused = pRRMReport[i].refused;
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006634 frm->MeasurementReport[i].present = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07006635 break;
6636 }
6637 }
6638
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006639 nStatus = dot11fGetPackedRadioMeasurementReportSize( pMac, frm, &nPayload );
Jeff Johnson295189b2012-06-20 16:38:30 -07006640 if ( DOT11F_FAILED( nStatus ) )
6641 {
6642 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006643 "or a Radio Measure Report (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07006644 nStatus );
6645 // We'll fall back on the worst case scenario:
6646 nPayload = sizeof( tDot11fLinkMeasurementReport );
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006647 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07006648 return eSIR_FAILURE;
6649 }
6650 else if ( DOT11F_WARNED( nStatus ) )
6651 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08006652 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07006653 "the packed size for a Radio Measure Rep"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006654 "ort (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07006655 }
6656
6657 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
6658
6659 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
6660 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
6661 {
6662 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Radio Measure "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006663 "Report."), nBytes );
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006664 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07006665 return eSIR_FAILURE;
6666 }
6667
6668 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05306669 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07006670
6671 // Copy necessary info to BD
6672 if( eSIR_SUCCESS !=
6673 (statusCode = limPopulateMacHeader( pMac,
6674 pFrame,
6675 SIR_MAC_MGMT_FRAME,
6676 SIR_MAC_MGMT_ACTION,
6677 peer, psessionEntry->selfMacAddr)))
6678 goto returnAfterError;
6679
6680 // Update A3 with the BSSID
6681 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
6682
6683 sirCopyMacAddr( pMacHdr->bssId, psessionEntry->bssId );
6684
Chet Lanctot186b5732013-03-18 10:26:30 -07006685#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07006686 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07006687#endif
6688
Jeff Johnson295189b2012-06-20 16:38:30 -07006689 // Now, we're ready to "pack" the frames
6690 nStatus = dot11fPackRadioMeasurementReport( pMac,
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006691 frm,
Jeff Johnson295189b2012-06-20 16:38:30 -07006692 pFrame + sizeof( tSirMacMgmtHdr ),
6693 nPayload,
6694 &nPayload );
6695
6696 if( DOT11F_FAILED( nStatus ))
6697 {
6698 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006699 FL( "Failed to pack an Radio Measure Report (0x%08x)." ),
Jeff Johnson295189b2012-06-20 16:38:30 -07006700 nStatus );
6701
6702 // FIXME - Need to convert to tSirRetStatus
6703 statusCode = eSIR_FAILURE;
6704 goto returnAfterError;
6705 }
6706 else if( DOT11F_WARNED( nStatus ))
6707 {
6708 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08006709 FL( "There were warnings while packing Radio "
6710 "Measure Report (0x%08x)." ), nStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07006711 }
6712
6713 limLog( pMac, LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006714 FL( "Sending a Radio Measure Report to " ));
Jeff Johnson295189b2012-06-20 16:38:30 -07006715 limPrintMacAddr( pMac, peer, LOGW );
6716
6717 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07006718 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
6719 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07006720 )
6721 {
6722 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
6723 }
6724
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05306725 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
6726 psessionEntry->peSessionId,
6727 pMacHdr->fc.subType));
6728 halstatus = halTxFrame( pMac,
6729 pPacket,
6730 (tANI_U16) nBytes,
6731 HAL_TXRX_FRM_802_11_MGMT,
6732 ANI_TXDIR_TODS,
6733 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
6734 limTxComplete,
6735 pFrame, txFlag );
6736 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
6737 psessionEntry->peSessionId,
6738 halstatus));
6739 if( eHAL_STATUS_SUCCESS != halstatus )
Jeff Johnson295189b2012-06-20 16:38:30 -07006740 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006741 PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]" ), halstatus );)
Jeff Johnson295189b2012-06-20 16:38:30 -07006742 statusCode = eSIR_FAILURE;
6743 //Pkt will be freed up by the callback
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006744 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07006745 return statusCode;
6746 }
Madan Mohan Koyyalamudieeb56b12012-10-31 15:10:04 -07006747 else {
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006748 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07006749 return eSIR_SUCCESS;
Madan Mohan Koyyalamudieeb56b12012-10-31 15:10:04 -07006750 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006751
6752returnAfterError:
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006753 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07006754 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
Jeff Johnson295189b2012-06-20 16:38:30 -07006755 return statusCode;
6756} // End limSendBeaconReportActionFrame.
6757
6758#endif
6759
6760#ifdef WLAN_FEATURE_11W
6761/**
Chet Lanctot8cecea22014-02-11 19:09:36 -08006762 * \brief Send SA query request action frame to peer
6763 *
6764 * \sa limSendSaQueryRequestFrame
6765 *
6766 *
6767 * \param pMac The global tpAniSirGlobal object
6768 *
6769 * \param transId Transaction identifier
6770 *
6771 * \param peer The Mac address of the station to which this action frame is addressed
6772 *
6773 * \param psessionEntry The PE session entry
6774 *
6775 * \return eSIR_SUCCESS if setup completes successfully
6776 * eSIR_FAILURE is some problem is encountered
6777 */
6778
6779tSirRetStatus limSendSaQueryRequestFrame( tpAniSirGlobal pMac, tANI_U8 *transId,
6780 tSirMacAddr peer, tpPESession psessionEntry )
6781{
6782
6783 tDot11fSaQueryReq frm; // SA query request action frame
6784 tANI_U8 *pFrame;
6785 tSirRetStatus nSirStatus;
6786 tpSirMacMgmtHdr pMacHdr;
6787 tANI_U32 nBytes, nPayload, nStatus;
6788 void *pPacket;
6789 eHalStatus halstatus;
6790 tANI_U8 txFlag = 0;
6791
6792 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
6793 frm.Category.category = SIR_MAC_ACTION_SA_QUERY;
6794 /* 11w action field is :
6795 action: 0 --> SA Query Request action frame
6796 action: 1 --> SA Query Response action frame */
6797 frm.Action.action = SIR_MAC_SA_QUERY_REQ;
6798 /* 11w SA Query Request transId */
6799 vos_mem_copy( &frm.TransactionId.transId[0], &transId[0], 2 );
6800
6801 nStatus = dot11fGetPackedSaQueryReqSize(pMac, &frm, &nPayload);
6802 if ( DOT11F_FAILED( nStatus ) )
6803 {
6804 limLog( pMac, LOGP, FL("Failed to calculate the packed size "
6805 "for an SA Query Request (0x%08x)."),
6806 nStatus );
6807 // We'll fall back on the worst case scenario:
6808 nPayload = sizeof( tDot11fSaQueryReq );
6809 }
6810 else if ( DOT11F_WARNED( nStatus ) )
6811 {
6812 limLog( pMac, LOGW, FL("There were warnings while calculating "
6813 "the packed size for an SA Query Request"
6814 " (0x%08x)."), nStatus );
6815 }
6816
6817 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
6818 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
6819 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
6820 {
6821 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a SA Query Request "
6822 "action frame"), nBytes );
6823 return eSIR_FAILURE;
6824 }
6825
6826 // Paranoia:
6827 vos_mem_set( pFrame, nBytes, 0 );
6828
6829 // Copy necessary info to BD
6830 nSirStatus = limPopulateMacHeader( pMac,
6831 pFrame,
6832 SIR_MAC_MGMT_FRAME,
6833 SIR_MAC_MGMT_ACTION,
6834 peer, psessionEntry->selfMacAddr );
6835 if ( eSIR_SUCCESS != nSirStatus )
6836 goto returnAfterError;
6837
6838 // Update A3 with the BSSID
6839 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
6840
6841 sirCopyMacAddr( pMacHdr->bssId, psessionEntry->bssId );
6842
6843 // Since this is a SA Query Request, set the "protect" (aka WEP) bit
6844 // in the FC
6845 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
6846
6847 // Pack 11w SA Query Request frame
6848 nStatus = dot11fPackSaQueryReq( pMac,
6849 &frm,
6850 pFrame + sizeof( tSirMacMgmtHdr ),
6851 nPayload,
6852 &nPayload );
6853
6854 if ( DOT11F_FAILED( nStatus ))
6855 {
6856 limLog( pMac, LOGE,
6857 FL( "Failed to pack an SA Query Request (0x%08x)." ),
6858 nStatus );
6859 // FIXME - Need to convert to tSirRetStatus
6860 nSirStatus = eSIR_FAILURE;
6861 goto returnAfterError;
6862 }
6863 else if ( DOT11F_WARNED( nStatus ))
6864 {
6865 limLog( pMac, LOGW,
6866 FL( "There were warnings while packing SA Query Request (0x%08x)." ),
6867 nStatus);
6868 }
6869
6870 limLog( pMac, LOG1,
6871 FL( "Sending an SA Query Request to " ));
6872 limPrintMacAddr( pMac, peer, LOG1 );
6873 limPrintMacAddr( pMac, peer, LOGE );
6874 limLog( pMac, LOGE,
6875 FL( "Sending an SA Query Request from " ));
6876 limPrintMacAddr( pMac, psessionEntry->selfMacAddr, LOGE );
6877
6878 if ( ( SIR_BAND_5_GHZ == limGetRFBand( psessionEntry->currentOperChannel ) )
6879#ifdef WLAN_FEATURE_P2P
6880 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
6881 ( psessionEntry->pePersona == VOS_P2P_GO_MODE )
6882#endif
6883 )
6884 {
6885 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
6886 }
6887
6888 halstatus = halTxFrame( pMac,
6889 pPacket,
6890 (tANI_U16) nBytes,
6891 HAL_TXRX_FRM_802_11_MGMT,
6892 ANI_TXDIR_TODS,
6893 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
6894 limTxComplete,
6895 pFrame, txFlag );
6896 if ( eHAL_STATUS_SUCCESS != halstatus )
6897 {
6898 PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]" ), halstatus );)
6899 nSirStatus = eSIR_FAILURE;
6900 //Pkt will be freed up by the callback
6901 return nSirStatus;
6902 }
6903 else {
6904 return eSIR_SUCCESS;
6905 }
6906
6907returnAfterError:
6908 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
6909 return nSirStatus;
6910} // End limSendSaQueryRequestFrame
6911
6912/**
Jeff Johnson295189b2012-06-20 16:38:30 -07006913 * \brief Send SA query response action frame to peer
6914 *
6915 * \sa limSendSaQueryResponseFrame
6916 *
6917 *
6918 * \param pMac The global tpAniSirGlobal object
6919 *
Chet Lanctot186b5732013-03-18 10:26:30 -07006920 * \param transId Transaction identifier received in SA query request action frame
Jeff Johnson295189b2012-06-20 16:38:30 -07006921 *
Chet Lanctot186b5732013-03-18 10:26:30 -07006922 * \param peer The Mac address of the AP to which this action frame is addressed
6923 *
6924 * \param psessionEntry The PE session entry
Jeff Johnson295189b2012-06-20 16:38:30 -07006925 *
6926 * \return eSIR_SUCCESS if setup completes successfully
6927 * eSIR_FAILURE is some problem is encountered
6928 */
6929
Chet Lanctot186b5732013-03-18 10:26:30 -07006930tSirRetStatus limSendSaQueryResponseFrame( tpAniSirGlobal pMac, tANI_U8 *transId,
Jeff Johnson295189b2012-06-20 16:38:30 -07006931tSirMacAddr peer,tpPESession psessionEntry)
6932{
6933
Chet Lanctot186b5732013-03-18 10:26:30 -07006934 tDot11fSaQueryRsp frm; // SA query reponse action frame
Jeff Johnson295189b2012-06-20 16:38:30 -07006935 tANI_U8 *pFrame;
6936 tSirRetStatus nSirStatus;
6937 tpSirMacMgmtHdr pMacHdr;
Chet Lanctot186b5732013-03-18 10:26:30 -07006938 tANI_U32 nBytes, nPayload, nStatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07006939 void *pPacket;
6940 eHalStatus halstatus;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05306941 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07006942
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05306943 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Chet Lanctot186b5732013-03-18 10:26:30 -07006944 frm.Category.category = SIR_MAC_ACTION_SA_QUERY;
6945 /*11w action field is :
Jeff Johnson295189b2012-06-20 16:38:30 -07006946 action: 0 --> SA query request action frame
6947 action: 1 --> SA query response action frame */
Chet Lanctot186b5732013-03-18 10:26:30 -07006948 frm.Action.action = SIR_MAC_SA_QUERY_RSP;
6949 /*11w SA query response transId is same as
Jeff Johnson295189b2012-06-20 16:38:30 -07006950 SA query request transId*/
Chet Lanctot186b5732013-03-18 10:26:30 -07006951 vos_mem_copy( &frm.TransactionId.transId[0], &transId[0], 2 );
Jeff Johnson295189b2012-06-20 16:38:30 -07006952
Chet Lanctot186b5732013-03-18 10:26:30 -07006953 nStatus = dot11fGetPackedSaQueryRspSize(pMac, &frm, &nPayload);
6954 if ( DOT11F_FAILED( nStatus ) )
6955 {
6956 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
6957 "or a SA Query Response (0x%08x)."),
6958 nStatus );
6959 // We'll fall back on the worst case scenario:
6960 nPayload = sizeof( tDot11fSaQueryRsp );
6961 }
6962 else if ( DOT11F_WARNED( nStatus ) )
6963 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08006964 limLog( pMac, LOGW, FL("There were warnings while calculating "
Chet Lanctot186b5732013-03-18 10:26:30 -07006965 "the packed size for an SA Query Response"
6966 " (0x%08x)."), nStatus );
6967 }
6968
Jeff Johnson295189b2012-06-20 16:38:30 -07006969 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
6970 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
6971 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
6972 {
6973 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a SA query response"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006974 " action frame"), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07006975 return eSIR_FAILURE;
6976 }
6977
6978 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05306979 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07006980
Chet Lanctot186b5732013-03-18 10:26:30 -07006981 // Copy necessary info to BD
Chet Lanctotb2b0d552013-03-22 16:58:44 -07006982 nSirStatus = limPopulateMacHeader( pMac,
Chet Lanctot186b5732013-03-18 10:26:30 -07006983 pFrame,
6984 SIR_MAC_MGMT_FRAME,
6985 SIR_MAC_MGMT_ACTION,
Chet Lanctotb2b0d552013-03-22 16:58:44 -07006986 peer, psessionEntry->selfMacAddr );
6987 if ( eSIR_SUCCESS != nSirStatus )
Chet Lanctot186b5732013-03-18 10:26:30 -07006988 goto returnAfterError;
Jeff Johnson295189b2012-06-20 16:38:30 -07006989
Chet Lanctot186b5732013-03-18 10:26:30 -07006990 // Update A3 with the BSSID
Jeff Johnson295189b2012-06-20 16:38:30 -07006991 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
6992
Chet Lanctot186b5732013-03-18 10:26:30 -07006993 sirCopyMacAddr( pMacHdr->bssId, psessionEntry->bssId );
Jeff Johnson295189b2012-06-20 16:38:30 -07006994
Chet Lanctot186b5732013-03-18 10:26:30 -07006995 // Since this is a SA Query Response, set the "protect" (aka WEP) bit
6996 // in the FC
Chet Lanctot8cecea22014-02-11 19:09:36 -08006997 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Jeff Johnson295189b2012-06-20 16:38:30 -07006998
Chet Lanctot186b5732013-03-18 10:26:30 -07006999 // Pack 11w SA query response frame
7000 nStatus = dot11fPackSaQueryRsp( pMac,
7001 &frm,
7002 pFrame + sizeof( tSirMacMgmtHdr ),
7003 nPayload,
7004 &nPayload );
7005
7006 if ( DOT11F_FAILED( nStatus ))
7007 {
7008 limLog( pMac, LOGE,
7009 FL( "Failed to pack an SA Query Response (0x%08x)." ),
7010 nStatus );
7011 // FIXME - Need to convert to tSirRetStatus
7012 nSirStatus = eSIR_FAILURE;
7013 goto returnAfterError;
7014 }
7015 else if ( DOT11F_WARNED( nStatus ))
7016 {
7017 limLog( pMac, LOGW,
7018 FL( "There were warnings while packing SA Query Response (0x%08x)." ),
7019 nStatus);
7020 }
7021
7022 limLog( pMac, LOG1,
7023 FL( "Sending a SA Query Response to " ));
7024 limPrintMacAddr( pMac, peer, LOGW );
7025
Chet Lanctotb2b0d552013-03-22 16:58:44 -07007026 if ( ( SIR_BAND_5_GHZ == limGetRFBand( psessionEntry->currentOperChannel ) )
Chet Lanctot186b5732013-03-18 10:26:30 -07007027#ifdef WLAN_FEATURE_P2P
Chet Lanctotb2b0d552013-03-22 16:58:44 -07007028 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
7029 ( psessionEntry->pePersona == VOS_P2P_GO_MODE )
Chet Lanctot186b5732013-03-18 10:26:30 -07007030#endif
Chet Lanctotb2b0d552013-03-22 16:58:44 -07007031 )
7032 {
7033 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
7034 }
Chet Lanctot186b5732013-03-18 10:26:30 -07007035
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05307036 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
7037 psessionEntry->peSessionId,
7038 pMacHdr->fc.subType));
Chet Lanctotb2b0d552013-03-22 16:58:44 -07007039 halstatus = halTxFrame( pMac,
7040 pPacket,
7041 (tANI_U16) nBytes,
7042 HAL_TXRX_FRM_802_11_MGMT,
7043 ANI_TXDIR_TODS,
7044 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
7045 limTxComplete,
7046 pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05307047 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
7048 psessionEntry->peSessionId,
7049 halstatus));
Chet Lanctotb2b0d552013-03-22 16:58:44 -07007050 if ( eHAL_STATUS_SUCCESS != halstatus )
Chet Lanctot186b5732013-03-18 10:26:30 -07007051 {
7052 PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]" ), halstatus );)
7053 nSirStatus = eSIR_FAILURE;
7054 //Pkt will be freed up by the callback
7055 return nSirStatus;
7056 }
7057 else {
7058 return eSIR_SUCCESS;
7059 }
7060
7061returnAfterError:
7062 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
7063 return nSirStatus;
7064} // End limSendSaQueryResponseFrame
Jeff Johnson295189b2012-06-20 16:38:30 -07007065#endif
Abhishek Singh00b71972016-01-07 10:51:04 +05307066
7067#ifdef WLAN_FEATURE_RMC
7068tSirRetStatus
7069limSendRMCActionFrame(tpAniSirGlobal pMac,
7070 tSirMacAddr peerMacAddr,
7071 tSirRMCInfo *pRMC,
7072 tpPESession psessionEntry)
7073{
7074 tSirRetStatus nSirStatus;
7075 tANI_U8 *pFrame;
7076 tDot11fRMC RMC;
7077 tANI_U32 nPayload, nBytes, nStatus;
7078 tpSirMacMgmtHdr pMacHdr;
7079 void *pPacket;
7080 eHalStatus halstatus;
7081 tANI_U8 txFlag = 0;
7082 tANI_U8 MagicCode[] = { 0x4f, 0x58, 0x59, 0x47, 0x45, 0x4e };
7083
7084 if (NULL == psessionEntry)
7085 {
7086 return eSIR_FAILURE;
7087 }
7088
7089 vos_mem_set(( tANI_U8* )&RMC, sizeof( RMC ), 0);
7090
7091 RMC.Action.action = pRMC->action;
7092 RMC.RMCDialogToken.token = pRMC->dialogToken;
7093 RMC.Category.category = SIR_MAC_ACTION_VENDOR_SPECIFIC_CATEGORY;
7094 RMC.RMCVersion.version = SIR_MAC_RMC_VER;
7095
7096 vos_mem_copy(&RMC.RMCOUI.oui, SIR_MAC_RMC_OUI, SIR_MAC_RMC_OUI_SIZE);
7097 vos_mem_copy(&RMC.MagicCode.magic, MagicCode, sizeof(MagicCode));
7098
7099 vos_mem_copy(&RMC.Ruler.mac, pRMC->mcastRuler, sizeof(tSirMacAddr));
7100
7101 nStatus = dot11fGetPackedRMCSize( pMac, &RMC, &nPayload );
7102 if ( DOT11F_FAILED( nStatus ) )
7103 {
7104 limLog( pMac, LOGE, FL("Failed to calculate the packed size for "
7105 "an RMC (0x%08x)."),
7106 nStatus );
7107 // We'll fall back on the worst case scenario:
7108 nPayload = sizeof( tDot11fRMC );
7109 }
7110 else if ( DOT11F_WARNED( nStatus ) )
7111 {
7112 limLog( pMac, LOGW, FL("There were warnings while calculating "
7113 "the packed size for an RMC Action Frame"
7114 " (0x%08x)."), nStatus );
7115 }
7116
7117 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
7118
7119 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
7120 ( tANI_U16 )nBytes, ( void** ) &pFrame,
7121 ( void** ) &pPacket );
7122 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
7123 {
7124 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for an RMC "
7125 "Action Frame."), nBytes );
7126 return eSIR_FAILURE;
7127 }
7128
7129 // Paranoia:
7130 vos_mem_set( pFrame, nBytes, 0 );
7131
7132 // Next, we fill out the buffer descriptor:
7133 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
7134 SIR_MAC_MGMT_ACTION, peerMacAddr,
7135 psessionEntry->selfMacAddr);
7136 if ( eSIR_SUCCESS != nSirStatus )
7137 {
7138 limLog( pMac, LOGE, FL("Failed to populate the buffer descriptor "
7139 "for an RMC Action Frame (%d)."),
7140 nSirStatus );
7141 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
7142 ( void* ) pFrame, ( void* ) pPacket );
7143 return nSirStatus;
7144 }
7145
7146 // Update A3 with the BSSID
7147 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
7148 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
7149
7150 // That done, pack the struct:
7151 nStatus = dot11fPackRMC( pMac, &RMC,
7152 pFrame + sizeof(tSirMacMgmtHdr),
7153 nPayload, &nPayload );
7154 if ( DOT11F_FAILED( nStatus ) )
7155 {
7156 limLog( pMac, LOGE, FL("Failed to pack an RMC "
7157 "(0x%08x)."),
7158 nStatus );
7159 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame,
7160 ( void* ) pPacket );
7161 return eSIR_FAILURE;
7162 }
7163 else if ( DOT11F_WARNED( nStatus ) )
7164 {
7165 limLog( pMac, LOGW, FL("There were warnings while packing "
7166 "an RMC (0x%08x)."), nStatus );
7167 }
7168
7169 limLog( pMac, LOG1, FL("Sending an RMC Action frame to "
7170 MAC_ADDRESS_STR), MAC_ADDR_ARRAY(peerMacAddr));
7171
7172 /*
7173 * With this masking, RMC action frames will be sent
7174 * at self-sta rates for both 2G and 5G bands.
7175 */
7176 txFlag |= HAL_USE_SELF_STA_REQUESTED_MASK;
7177
7178 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
7179 psessionEntry->peSessionId,
7180 pMacHdr->fc.subType));
7181 // Queue RMC Action frame in high priority WQ
7182 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
7183 HAL_TXRX_FRM_802_11_MGMT,
7184 ANI_TXDIR_TODS,
7185 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
7186 limTxComplete, pFrame, txFlag );
7187 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
7188 psessionEntry->peSessionId,
7189 halstatus));
7190 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
7191 {
7192 limLog( pMac, LOGE, FL( "*** Could not send an RMC Action frame"
7193 " (%X) ***" ), halstatus );
7194 //Pkt will be freed up by the callback
7195 return eSIR_FAILURE;
7196 }
7197
7198 return eSIR_SUCCESS;
7199
7200} // End limSendRMCActionFrame.
7201
7202#endif /* WLAN_FEATURE_RMC */