blob: 1799c447e3b1ab0e4084b97408d4d3e2798ba2e7 [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Abhishek Singhc601a472016-01-20 11:08:32 +05302 * Copyright (c) 2011-2016 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,
1387 tpDphHashNode pSta,tpPESession psessionEntry)
1388{
1389 static tDot11fAssocResponse frm;
1390 tANI_U8 *pFrame, *macAddr;
1391 tpSirMacMgmtHdr pMacHdr;
1392 tSirRetStatus nSirStatus;
1393 tANI_U8 lleMode = 0, fAddTS, edcaInclude = 0;
1394 tHalBitVal qosMode, wmeMode;
c_hpothubcd78652014-04-28 22:31:08 +05301395 tANI_U32 nPayload, nStatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07001396 void *pPacket;
1397 eHalStatus halstatus;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05301398 tUpdateBeaconParams beaconParams;
1399 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001400 tANI_U32 addnIEPresent = false;
1401 tANI_U32 addnIELen=0;
1402 tANI_U8 addIE[WNI_CFG_ASSOC_RSP_ADDNIE_DATA_LEN];
1403 tpSirAssocReq pAssocReq = NULL;
Mahesh A Saptasagar38c177e2014-10-17 18:55:48 +05301404 tANI_U16 addStripoffIELen = 0;
1405 tDot11fIEExtCap extractedExtCap;
1406 tANI_BOOLEAN extractedExtCapFlag = eANI_BOOLEAN_FALSE;
c_hpothubcd78652014-04-28 22:31:08 +05301407 tANI_U32 nBytes = 0;
Kalikinkar dhara205da782014-03-21 15:49:32 -07001408
Chet Lanctot8cecea22014-02-11 19:09:36 -08001409#ifdef WLAN_FEATURE_11W
1410 tANI_U32 retryInterval;
1411 tANI_U32 maxRetries;
1412#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001413
1414 if(NULL == psessionEntry)
1415 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05301416 limLog( pMac, LOGE, FL("psessionEntry is NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001417 return;
1418 }
1419
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301420 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07001421
1422 limGetQosMode(psessionEntry, &qosMode);
1423 limGetWmeMode(psessionEntry, &wmeMode);
1424
1425 // An Add TS IE is added only if the AP supports it and the requesting
1426 // STA sent a traffic spec.
1427 fAddTS = ( qosMode && pSta && pSta->qos.addtsPresent ) ? 1 : 0;
1428
1429 PopulateDot11fCapabilities( pMac, &frm.Capabilities, psessionEntry );
1430
1431 frm.Status.status = statusCode;
1432
1433 frm.AID.associd = aid | LIM_AID_MASK;
1434
1435 if ( NULL == pSta )
1436 {
1437 PopulateDot11fSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL, &frm.SuppRates,psessionEntry);
1438 PopulateDot11fExtSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL, &frm.ExtSuppRates, psessionEntry );
1439 }
1440 else
1441 {
1442 PopulateDot11fAssocRspRates( pMac, &frm.SuppRates, &frm.ExtSuppRates,
1443 pSta->supportedRates.llbRates, pSta->supportedRates.llaRates );
1444 }
1445
Jeff Johnson295189b2012-06-20 16:38:30 -07001446 if(psessionEntry->limSystemRole == eLIM_AP_ROLE)
1447 {
1448 if( pSta != NULL && eSIR_SUCCESS == statusCode )
1449 {
1450 pAssocReq =
1451 (tpSirAssocReq) psessionEntry->parsedAssocReq[pSta->assocId];
Jeff Johnson295189b2012-06-20 16:38:30 -07001452 /* populate P2P IE in AssocRsp when assocReq from the peer includes P2P IE */
1453 if( pAssocReq != NULL && pAssocReq->addIEPresent ) {
1454 PopulateDot11AssocResP2PIE(pMac, &frm.P2PAssocRes, pAssocReq);
1455 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001456 }
1457 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001458
1459 if ( NULL != pSta )
1460 {
1461 if ( eHAL_SET == qosMode )
1462 {
1463 if ( pSta->lleEnabled )
1464 {
1465 lleMode = 1;
1466 if ( ( ! pSta->aniPeer ) || ( ! PROP_CAPABILITY_GET( 11EQOS, pSta->propCapability ) ) )
1467 {
1468 PopulateDot11fEDCAParamSet( pMac, &frm.EDCAParamSet, psessionEntry);
1469
1470// FramesToDo:...
1471// if ( fAddTS )
1472// {
1473// tANI_U8 *pAf = pBody;
1474// *pAf++ = SIR_MAC_QOS_ACTION_EID;
1475// tANI_U32 tlen;
1476// status = sirAddtsRspFill(pMac, pAf, statusCode, &pSta->qos.addts, NULL,
1477// &tlen, bufLen - frameLen);
1478// } // End if on Add TS.
1479 }
1480 } // End if on .11e enabled in 'pSta'.
1481 } // End if on QOS Mode on.
1482
1483 if ( ( ! lleMode ) && ( eHAL_SET == wmeMode ) && pSta->wmeEnabled )
1484 {
1485 if ( ( ! pSta->aniPeer ) || ( ! PROP_CAPABILITY_GET( WME, pSta->propCapability ) ) )
1486 {
1487
Jeff Johnson295189b2012-06-20 16:38:30 -07001488 PopulateDot11fWMMParams( pMac, &frm.WMMParams, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07001489
1490 if ( pSta->wsmEnabled )
1491 {
1492 PopulateDot11fWMMCaps(&frm.WMMCaps );
1493 }
1494 }
1495 }
1496
1497 if ( pSta->aniPeer )
1498 {
1499 if ( ( lleMode && PROP_CAPABILITY_GET( 11EQOS, pSta->propCapability ) ) ||
1500 ( pSta->wmeEnabled && PROP_CAPABILITY_GET( WME, pSta->propCapability ) ) )
1501 {
1502 edcaInclude = 1;
1503 }
1504
1505 } // End if on Airgo peer.
1506
1507 if ( pSta->mlmStaContext.htCapability &&
Jeff Johnsone7245742012-09-05 17:12:55 -07001508 psessionEntry->htCapability )
Jeff Johnson295189b2012-06-20 16:38:30 -07001509 {
Krishna Kumaar Natarajan025a8602015-08-04 16:31:36 +05301510 limLog(pMac, LOG1, FL("Populate HT IEs in Assoc Response"));
Jeff Johnsone7245742012-09-05 17:12:55 -07001511 PopulateDot11fHTCaps( pMac, psessionEntry, &frm.HTCaps );
Sachin Ahujac3a26232014-09-23 22:27:30 +05301512 /*
1513 *Check the STA capability and update the HTCaps accordingly
1514 */
1515 frm.HTCaps.supportedChannelWidthSet =
1516 (pSta->htSupportedChannelWidthSet < psessionEntry->htSupportedChannelWidthSet) ?
1517 pSta->htSupportedChannelWidthSet : psessionEntry->htSupportedChannelWidthSet ;
1518
1519 if (!frm.HTCaps.supportedChannelWidthSet)
1520 frm.HTCaps.shortGI40MHz = 0;
1521
Jeff Johnson295189b2012-06-20 16:38:30 -07001522 PopulateDot11fHTInfo( pMac, &frm.HTInfo, psessionEntry );
Jeff Johnson295189b2012-06-20 16:38:30 -07001523 }
Agrawal Ashishb10d0392015-08-06 16:18:20 +05301524 limLog(pMac, LOG1, FL("SupportedChnlWidth: %d, mimoPS: %d, GF: %d,"
1525 "shortGI20:%d, shortGI40: %d, dsssCck: %d, AMPDU Param: %x"),
1526 frm.HTCaps.supportedChannelWidthSet, frm.HTCaps.mimoPowerSave,
1527 frm.HTCaps.greenField, frm.HTCaps.shortGI20MHz, frm.HTCaps.shortGI40MHz,
1528 frm.HTCaps.dsssCckMode40MHz, frm.HTCaps.maxRxAMPDUFactor);
1529
1530
Jeff Johnsone7245742012-09-05 17:12:55 -07001531
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301532#ifdef WLAN_FEATURE_AP_HT40_24G
1533 /* Populate Overlapping BSS Scan Parameters IEs,
1534 * when operating in HT40 in 2.4GHz.
1535 */
Hardik Kantilal Patel3c235242015-01-02 17:56:18 +05301536 if ((pMac->roam.configParam.apHT40_24GEnabled)
1537 && (IS_DOT11_MODE_HT(psessionEntry->dot11mode)))
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301538 {
1539 PopulateDot11fOBSSScanParameters( pMac, &frm.OBSSScanParameters,
1540 psessionEntry);
Hardik Kantilal Patelee5874c2015-01-14 15:23:28 +05301541 /* 10.15.8 Support of DSSS/CCK in 40 MHz, An associated HT STA in
1542 * a 20/40 MHz BSS may generate DSSS/CCK transmissions.Set DSSS/CCK
1543 * Mode in 40 MHz bit in HT capablity.
1544 */
1545 frm.HTCaps.dsssCckMode40MHz = 1;
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301546 }
1547#endif
1548
1549 PopulateDot11fExtCap( pMac, &frm.ExtCap, psessionEntry);
Jeff Johnsone7245742012-09-05 17:12:55 -07001550#ifdef WLAN_FEATURE_11AC
1551 if( pSta->mlmStaContext.vhtCapability &&
1552 psessionEntry->vhtCapability )
1553 {
Chet Lanctotf19c1f62013-12-13 13:56:21 -08001554 limLog( pMac, LOG1, FL("Populate VHT IEs in Assoc Response"));
Abhishek Singh33f76ea2015-06-04 12:27:30 +05301555 PopulateDot11fVHTCaps( pMac, &frm.VHTCaps,
1556 psessionEntry->currentOperChannel, eSIR_TRUE );
1557 PopulateDot11fVHTOperation( pMac, &frm.VHTOperation,
1558 psessionEntry->currentOperChannel);
Jeff Johnsone7245742012-09-05 17:12:55 -07001559 }
1560#endif
1561
Chet Lanctot8cecea22014-02-11 19:09:36 -08001562#ifdef WLAN_FEATURE_11W
Dino Myclea7f18452014-04-24 08:55:31 +05301563 if( eSIR_MAC_TRY_AGAIN_LATER == statusCode )
1564 {
Chet Lanctotfadc8e32014-04-24 14:50:52 -07001565 if ( wlan_cfgGetInt(pMac, WNI_CFG_PMF_SA_QUERY_MAX_RETRIES,
1566 &maxRetries ) != eSIR_SUCCESS )
1567 limLog( pMac, LOGE,
1568 FL("Could not retrieve PMF SA Query maximum retries value") );
1569 else
1570 if ( wlan_cfgGetInt(pMac, WNI_CFG_PMF_SA_QUERY_RETRY_INTERVAL,
1571 &retryInterval ) != eSIR_SUCCESS)
1572 limLog( pMac, LOGE,
1573 FL("Could not retrieve PMF SA Query timer interval value") );
Dino Myclea7f18452014-04-24 08:55:31 +05301574 else
Chet Lanctotfadc8e32014-04-24 14:50:52 -07001575 PopulateDot11fTimeoutInterval(
1576 pMac, &frm.TimeoutInterval, SIR_MAC_TI_TYPE_ASSOC_COMEBACK,
1577 (maxRetries - pSta->pmfSaQueryRetryCount) * retryInterval );
Dino Myclea7f18452014-04-24 08:55:31 +05301578 }
Chet Lanctot8cecea22014-02-11 19:09:36 -08001579#endif
Dino Myclea7f18452014-04-24 08:55:31 +05301580 } // End if on non-NULL 'pSta'.
Jeff Johnson295189b2012-06-20 16:38:30 -07001581
Chet Lanctot8cecea22014-02-11 19:09:36 -08001582 vos_mem_set(( tANI_U8* )&beaconParams, sizeof( tUpdateBeaconParams), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001583
Jeff Johnson295189b2012-06-20 16:38:30 -07001584 if( psessionEntry->limSystemRole == eLIM_AP_ROLE ){
1585 if(psessionEntry->gLimProtectionControl != WNI_CFG_FORCE_POLICY_PROTECTION_DISABLE)
1586 limDecideApProtection(pMac, peerMacAddr, &beaconParams,psessionEntry);
1587 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001588
1589 limUpdateShortPreamble(pMac, peerMacAddr, &beaconParams, psessionEntry);
1590 limUpdateShortSlotTime(pMac, peerMacAddr, &beaconParams, psessionEntry);
1591
1592 beaconParams.bssIdx = psessionEntry->bssIdx;
1593
1594 //Send message to HAL about beacon parameter change.
1595 if(beaconParams.paramChangeBitmap)
1596 {
1597 schSetFixedBeaconFields(pMac,psessionEntry);
1598 limSendBeaconParams(pMac, &beaconParams, psessionEntry );
1599 }
1600
Jeff Johnson295189b2012-06-20 16:38:30 -07001601 if ( pAssocReq != NULL )
1602 {
1603 if (wlan_cfgGetInt(pMac, WNI_CFG_ASSOC_RSP_ADDNIE_FLAG,
1604 &addnIEPresent) != eSIR_SUCCESS)
1605 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05301606 limLog(pMac, LOGP, FL("Unable to get "
1607 "WNI_CFG_ASSOC_RSP_ADDNIE_FLAG"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001608 return;
1609 }
1610
1611 if (addnIEPresent)
1612 {
1613 //Assoc rsp IE available
1614 if (wlan_cfgGetStrLen(pMac, WNI_CFG_ASSOC_RSP_ADDNIE_DATA,
1615 &addnIELen) != eSIR_SUCCESS)
1616 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05301617 limLog(pMac, LOGP, FL("Unable to get "
1618 "WNI_CFG_ASSOC_RSP_ADDNIE_DATA length"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001619 return;
1620 }
1621
1622 if (addnIELen <= WNI_CFG_ASSOC_RSP_ADDNIE_DATA_LEN && addnIELen &&
1623 (nBytes + addnIELen) <= SIR_MAX_PACKET_SIZE)
1624 {
1625 if (wlan_cfgGetStr(pMac, WNI_CFG_ASSOC_RSP_ADDNIE_DATA,
1626 &addIE[0], &addnIELen) == eSIR_SUCCESS)
1627 {
Mahesh A Saptasagar38c177e2014-10-17 18:55:48 +05301628
1629 vos_mem_set(( tANI_U8* )&extractedExtCap,
1630 sizeof( tDot11fIEExtCap ), 0);
Mahesh A Saptasagare00ff532014-10-17 19:05:14 +05301631 addStripoffIELen = addnIELen;
Mahesh A Saptasagar38c177e2014-10-17 18:55:48 +05301632 nSirStatus = limStripOffExtCapIEAndUpdateStruct(pMac,
1633 &addIE[0],
1634 &addStripoffIELen,
1635 &extractedExtCap );
1636 if(eSIR_SUCCESS != nSirStatus)
1637 {
1638 limLog(pMac, LOG1,
1639 FL("Unable to Stripoff ExtCap IE from Assoc Rsp"));
1640 }
1641 else
1642 {
1643 addnIELen = addStripoffIELen;
1644 extractedExtCapFlag = eANI_BOOLEAN_TRUE;
1645 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001646 nBytes = nBytes + addnIELen;
1647 }
1648 }
1649 }
1650 }
1651
Mahesh A Saptasagar38c177e2014-10-17 18:55:48 +05301652 /* merge the ExtCap struct*/
1653 if (extractedExtCapFlag && extractedExtCap.present)
1654 {
Hu Wang5193b572016-08-11 10:04:47 +08001655 limMergeExtCapIEStruct(&(frm.ExtCap), &extractedExtCap, true);
Mahesh A Saptasagar38c177e2014-10-17 18:55:48 +05301656 }
1657
c_hpothubcd78652014-04-28 22:31:08 +05301658 nStatus = dot11fGetPackedAssocResponseSize( pMac, &frm, &nPayload );
1659 if ( DOT11F_FAILED( nStatus ) )
1660 {
1661 limLog( pMac, LOGE, FL("Failed to calculate the packed size f"
1662 "or an Association Response (0x%08x)."),
1663 nStatus );
1664 return;
1665 }
1666 else if ( DOT11F_WARNED( nStatus ) )
1667 {
1668 limLog( pMac, LOGW, FL("There were warnings while calculating "
1669 "the packed size for an Association Re"
1670 "sponse (0x%08x)."), nStatus );
1671 }
1672
1673 nBytes += sizeof( tSirMacMgmtHdr ) + nPayload;
1674
Jeff Johnson295189b2012-06-20 16:38:30 -07001675 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1676 ( tANI_U16 )nBytes, ( void** ) &pFrame,
1677 ( void** ) &pPacket );
1678 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1679 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001680 limLog(pMac, LOGP, FL("Call to bufAlloc failed for RE/ASSOC RSP."));
Jeff Johnson295189b2012-06-20 16:38:30 -07001681 return;
1682 }
1683
1684 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301685 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07001686
1687 // Next, we fill out the buffer descriptor:
1688 nSirStatus = limPopulateMacHeader( pMac,
1689 pFrame,
1690 SIR_MAC_MGMT_FRAME,
1691 ( LIM_ASSOC == subType ) ?
1692 SIR_MAC_MGMT_ASSOC_RSP :
1693 SIR_MAC_MGMT_REASSOC_RSP,
1694 peerMacAddr,psessionEntry->selfMacAddr);
1695 if ( eSIR_SUCCESS != nSirStatus )
1696 {
1697 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001698 "tor for an Association Response (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001699 nSirStatus );
1700 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1701 ( void* ) pFrame, ( void* ) pPacket );
1702 return;
1703 }
1704
1705 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
1706
Jeff Johnson295189b2012-06-20 16:38:30 -07001707 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
1708
1709 nStatus = dot11fPackAssocResponse( pMac, &frm,
1710 pFrame + sizeof( tSirMacMgmtHdr ),
1711 nPayload, &nPayload );
1712 if ( DOT11F_FAILED( nStatus ) )
1713 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05301714 limLog( pMac, LOGE, FL("Failed to pack an Association Response"
1715 " (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001716 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1717 ( void* ) pFrame, ( void* ) pPacket );
1718 return; // allocated!
1719 }
1720 else if ( DOT11F_WARNED( nStatus ) )
1721 {
1722 limLog( pMac, LOGW, FL("There were warnings while packing an "
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001723 "Association Response (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001724 }
1725
1726 macAddr = pMacHdr->da;
1727
1728 if (subType == LIM_ASSOC)
1729 {
Abhishek Singh3cbf6052014-12-15 16:46:42 +05301730 limLog(pMac, LOG1,
Jeff Johnson295189b2012-06-20 16:38:30 -07001731 FL("*** Sending Assoc Resp status %d aid %d to "),
Abhishek Singh3cbf6052014-12-15 16:46:42 +05301732 statusCode, aid);
Jeff Johnson295189b2012-06-20 16:38:30 -07001733 }
1734 else{
Abhishek Singh3cbf6052014-12-15 16:46:42 +05301735 limLog(pMac, LOG1,
Jeff Johnson295189b2012-06-20 16:38:30 -07001736 FL("*** Sending ReAssoc Resp status %d aid %d to "),
Abhishek Singh3cbf6052014-12-15 16:46:42 +05301737 statusCode, aid);
Jeff Johnson295189b2012-06-20 16:38:30 -07001738 }
Abhishek Singh3cbf6052014-12-15 16:46:42 +05301739 limPrintMacAddr(pMac, pMacHdr->da, LOG1);
Jeff Johnson295189b2012-06-20 16:38:30 -07001740
1741 if ( addnIEPresent )
1742 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301743 vos_mem_copy ( pFrame+sizeof(tSirMacMgmtHdr)+nPayload, &addIE[0], addnIELen ) ;
Jeff Johnson295189b2012-06-20 16:38:30 -07001744 }
1745
1746 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07001747 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
1748 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07001749 )
1750 {
1751 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
1752 }
1753
Agarwal Ashisha8e81f52014-04-02 01:59:52 +05301754 limLog( pMac, LOG1, FL("Sending Assoc resp over WQ5 to "MAC_ADDRESS_STR
1755 " From " MAC_ADDRESS_STR),MAC_ADDR_ARRAY(pMacHdr->da),
1756 MAC_ADDR_ARRAY(psessionEntry->selfMacAddr));
1757
1758 txFlag |= HAL_USE_FW_IN_TX_PATH;
1759
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05301760 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
1761 psessionEntry->peSessionId,
1762 pMacHdr->fc.subType));
Ganesh Kondabattiniffc00b12015-03-18 13:11:33 +05301763
1764 if (IS_FEATURE_SUPPORTED_BY_FW(ENHANCED_TXBD_COMPLETION))
1765 {
1766 limLog(pMac, LOG1, FL("Re/AssocRsp - txBdToken %u"), pMac->lim.txBdToken);
1767 /// Queue Association Response frame in high priority WQ
1768 halstatus = halTxFrameWithTxComplete( pMac, pPacket, ( tANI_U16 ) nBytes,
1769 HAL_TXRX_FRM_802_11_MGMT,
1770 ANI_TXDIR_TODS,
1771 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
1772 limTxComplete, pFrame, limTxBdComplete,
1773 txFlag, pMac->lim.txBdToken );
1774 pMac->lim.txBdToken++;
1775 }
1776 else
1777 {
1778 /// Queue Association Response frame in high priority WQ
1779 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
1780 HAL_TXRX_FRM_802_11_MGMT,
1781 ANI_TXDIR_TODS,
1782 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
1783 limTxComplete, pFrame, txFlag );
1784 }
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05301785 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
1786 psessionEntry->peSessionId,
1787 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07001788 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1789 {
1790 limLog(pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001791 FL("*** Could not Send Re/AssocRsp, retCode=%X ***"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001792 nSirStatus);
1793
1794 //Pkt will be freed up by the callback
1795 }
1796
1797 // update the ANI peer station count
1798 //FIXME_PROTECTION : take care of different type of station
1799 // counter inside this function.
1800 limUtilCountStaAdd(pMac, pSta, psessionEntry);
1801
1802} // End limSendAssocRspMgmtFrame.
1803
1804
1805
1806void
1807limSendAddtsRspActionFrame(tpAniSirGlobal pMac,
1808 tSirMacAddr peer,
1809 tANI_U16 nStatusCode,
1810 tSirAddtsReqInfo *pAddTS,
1811 tSirMacScheduleIE *pSchedule,
1812 tpPESession psessionEntry)
1813{
1814 tANI_U8 *pFrame;
1815 tpSirMacMgmtHdr pMacHdr;
1816 tDot11fAddTSResponse AddTSRsp;
1817 tDot11fWMMAddTSResponse WMMAddTSRsp;
1818 tSirRetStatus nSirStatus;
1819 tANI_U32 i, nBytes, nPayload, nStatus;
1820 void *pPacket;
1821 eHalStatus halstatus;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05301822 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001823
1824 if(NULL == psessionEntry)
1825 {
1826 return;
1827 }
1828
1829 if ( ! pAddTS->wmeTspecPresent )
1830 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301831 vos_mem_set( ( tANI_U8* )&AddTSRsp, sizeof( AddTSRsp ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07001832
1833 AddTSRsp.Category.category = SIR_MAC_ACTION_QOS_MGMT;
1834 AddTSRsp.Action.action = SIR_MAC_QOS_ADD_TS_RSP;
1835 AddTSRsp.DialogToken.token = pAddTS->dialogToken;
1836 AddTSRsp.Status.status = nStatusCode;
1837
1838 // The TsDelay information element is only filled in for a specific
1839 // status code:
1840 if ( eSIR_MAC_TS_NOT_CREATED_STATUS == nStatusCode )
1841 {
1842 if ( pAddTS->wsmTspecPresent )
1843 {
1844 AddTSRsp.WMMTSDelay.version = 1;
1845 AddTSRsp.WMMTSDelay.delay = 10;
1846 AddTSRsp.WMMTSDelay.present = 1;
1847 }
1848 else
1849 {
1850 AddTSRsp.TSDelay.delay = 10;
1851 AddTSRsp.TSDelay.present = 1;
1852 }
1853 }
1854
1855 if ( pAddTS->wsmTspecPresent )
1856 {
1857 PopulateDot11fWMMTSPEC( &pAddTS->tspec, &AddTSRsp.WMMTSPEC );
1858 }
1859 else
1860 {
1861 PopulateDot11fTSPEC( &pAddTS->tspec, &AddTSRsp.TSPEC );
1862 }
1863
1864 if ( pAddTS->wsmTspecPresent )
1865 {
1866 AddTSRsp.num_WMMTCLAS = 0;
1867 AddTSRsp.num_TCLAS = pAddTS->numTclas;
1868 for ( i = 0; i < AddTSRsp.num_TCLAS; ++i)
1869 {
1870 PopulateDot11fTCLAS( pMac, &pAddTS->tclasInfo[i],
1871 &AddTSRsp.TCLAS[i] );
1872 }
1873 }
1874 else
1875 {
1876 AddTSRsp.num_TCLAS = 0;
1877 AddTSRsp.num_WMMTCLAS = pAddTS->numTclas;
1878 for ( i = 0; i < AddTSRsp.num_WMMTCLAS; ++i)
1879 {
1880 PopulateDot11fWMMTCLAS( pMac, &pAddTS->tclasInfo[i],
1881 &AddTSRsp.WMMTCLAS[i] );
1882 }
1883 }
1884
1885 if ( pAddTS->tclasProcPresent )
1886 {
1887 if ( pAddTS->wsmTspecPresent )
1888 {
1889 AddTSRsp.WMMTCLASPROC.version = 1;
1890 AddTSRsp.WMMTCLASPROC.processing = pAddTS->tclasProc;
1891 AddTSRsp.WMMTCLASPROC.present = 1;
1892 }
1893 else
1894 {
1895 AddTSRsp.TCLASSPROC.processing = pAddTS->tclasProc;
1896 AddTSRsp.TCLASSPROC.present = 1;
1897 }
1898 }
1899
1900 // schedule element is included only if requested in the tspec and we are
1901 // using hcca (or both edca and hcca)
1902 // 11e-D8.0 is inconsistent on whether the schedule element is included
1903 // based on tspec schedule bit or not. Sec 7.4.2.2. says one thing but
1904 // pg 46, line 17-18 says something else. So just include it and let the
1905 // sta figure it out
1906 if ((pSchedule != NULL) &&
1907 ((pAddTS->tspec.tsinfo.traffic.accessPolicy == SIR_MAC_ACCESSPOLICY_HCCA) ||
1908 (pAddTS->tspec.tsinfo.traffic.accessPolicy == SIR_MAC_ACCESSPOLICY_BOTH)))
1909 {
1910 if ( pAddTS->wsmTspecPresent )
1911 {
1912 PopulateDot11fWMMSchedule( pSchedule, &AddTSRsp.WMMSchedule );
1913 }
1914 else
1915 {
1916 PopulateDot11fSchedule( pSchedule, &AddTSRsp.Schedule );
1917 }
1918 }
1919
1920 nStatus = dot11fGetPackedAddTSResponseSize( pMac, &AddTSRsp, &nPayload );
1921 if ( DOT11F_FAILED( nStatus ) )
1922 {
1923 limLog( pMac, LOGP, FL("Failed to calculate the packed si"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001924 "ze for an Add TS Response (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001925 nStatus );
1926 // We'll fall back on the worst case scenario:
1927 nPayload = sizeof( tDot11fAddTSResponse );
1928 }
1929 else if ( DOT11F_WARNED( nStatus ) )
1930 {
1931 limLog( pMac, LOGW, FL("There were warnings while calcula"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001932 "ting the packed size for an Add TS"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001933 " Response (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001934 }
1935 }
1936 else
1937 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301938 vos_mem_set( ( tANI_U8* )&WMMAddTSRsp, sizeof( WMMAddTSRsp ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07001939
1940 WMMAddTSRsp.Category.category = SIR_MAC_ACTION_WME;
1941 WMMAddTSRsp.Action.action = SIR_MAC_QOS_ADD_TS_RSP;
1942 WMMAddTSRsp.DialogToken.token = pAddTS->dialogToken;
1943 WMMAddTSRsp.StatusCode.statusCode = (tANI_U8)nStatusCode;
1944
1945 PopulateDot11fWMMTSPEC( &pAddTS->tspec, &WMMAddTSRsp.WMMTSPEC );
1946
1947 nStatus = dot11fGetPackedWMMAddTSResponseSize( pMac, &WMMAddTSRsp, &nPayload );
1948 if ( DOT11F_FAILED( nStatus ) )
1949 {
1950 limLog( pMac, LOGP, FL("Failed to calculate the packed si"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001951 "ze for a WMM Add TS Response (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001952 nStatus );
1953 // We'll fall back on the worst case scenario:
1954 nPayload = sizeof( tDot11fWMMAddTSResponse );
1955 }
1956 else if ( DOT11F_WARNED( nStatus ) )
1957 {
1958 limLog( pMac, LOGW, FL("There were warnings while calcula"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001959 "ting the packed size for a WMM Add"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001960 "TS Response (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001961 }
1962 }
1963
1964 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
1965
1966 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
1967 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1968 {
1969 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for an Ad"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001970 "d TS Response."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07001971 return;
1972 }
1973
1974 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301975 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07001976
1977 // Next, we fill out the buffer descriptor:
1978 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
1979 SIR_MAC_MGMT_ACTION, peer,psessionEntry->selfMacAddr);
1980 if ( eSIR_SUCCESS != nSirStatus )
1981 {
1982 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001983 "tor for an Add TS Response (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001984 nSirStatus );
1985 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1986 return; // allocated!
1987 }
1988
1989 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
1990
1991
1992 #if 0
1993 if ( eSIR_SUCCESS != wlan_cfgGetStr( pMac, WNI_CFG_BSSID,
1994 ( tANI_U8* )pMacHdr->bssId, &cfgLen ) )
1995 {
1996 limLog( pMac, LOGP, FL("Failed to retrieve WNI_CFG_BSSID whil"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001997 "e sending an Add TS Response.") );
Jeff Johnson295189b2012-06-20 16:38:30 -07001998 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1999 return; // allocated!
2000 }
2001 #endif //TO SUPPORT BT-AMP
2002 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
2003
Chet Lanctot186b5732013-03-18 10:26:30 -07002004#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07002005 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07002006#endif
2007
Jeff Johnson295189b2012-06-20 16:38:30 -07002008 // That done, pack the struct:
2009 if ( ! pAddTS->wmeTspecPresent )
2010 {
2011 nStatus = dot11fPackAddTSResponse( pMac, &AddTSRsp,
2012 pFrame + sizeof( tSirMacMgmtHdr ),
2013 nPayload, &nPayload );
2014 if ( DOT11F_FAILED( nStatus ) )
2015 {
2016 limLog( pMac, LOGE, FL("Failed to pack an Add TS Response "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002017 "(0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002018 nStatus );
2019 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
2020 return;
2021 }
2022 else if ( DOT11F_WARNED( nStatus ) )
2023 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08002024 limLog( pMac, LOGW, FL("There were warnings while packing "
2025 "an Add TS Response (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07002026 }
2027 }
2028 else
2029 {
2030 nStatus = dot11fPackWMMAddTSResponse( pMac, &WMMAddTSRsp,
2031 pFrame + sizeof( tSirMacMgmtHdr ),
2032 nPayload, &nPayload );
2033 if ( DOT11F_FAILED( nStatus ) )
2034 {
2035 limLog( pMac, LOGE, FL("Failed to pack a WMM Add TS Response "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002036 "(0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002037 nStatus );
2038 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
2039 return;
2040 }
2041 else if ( DOT11F_WARNED( nStatus ) )
2042 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08002043 limLog( pMac, LOGW, FL("There were warnings while packing "
2044 "a WMM Add TS Response (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07002045 }
2046 }
2047
Abhishek Singh3cbf6052014-12-15 16:46:42 +05302048 limLog( pMac, LOG1, FL("Sending an Add TS Response (status %d) to "),
Jeff Johnson295189b2012-06-20 16:38:30 -07002049 nStatusCode );
Abhishek Singh3cbf6052014-12-15 16:46:42 +05302050 limPrintMacAddr( pMac, pMacHdr->da, LOG1 );
Jeff Johnson295189b2012-06-20 16:38:30 -07002051
2052 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07002053 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
2054 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07002055 )
2056 {
2057 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
2058 }
2059
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05302060 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
2061 psessionEntry->peSessionId,
2062 pMacHdr->fc.subType));
Jeff Johnson295189b2012-06-20 16:38:30 -07002063 // Queue the frame in high priority WQ:
2064 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
2065 HAL_TXRX_FRM_802_11_MGMT,
2066 ANI_TXDIR_TODS,
2067 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
2068 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05302069 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
2070 psessionEntry->peSessionId,
2071 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07002072 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
2073 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002074 limLog( pMac, LOGE, FL("Failed to send Add TS Response (%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002075 nSirStatus );
2076 //Pkt will be freed up by the callback
2077 }
2078
2079} // End limSendAddtsRspActionFrame.
2080
2081void
2082limSendDeltsReqActionFrame(tpAniSirGlobal pMac,
2083 tSirMacAddr peer,
2084 tANI_U8 wmmTspecPresent,
2085 tSirMacTSInfo *pTsinfo,
2086 tSirMacTspecIE *pTspecIe,
2087 tpPESession psessionEntry)
2088{
2089 tANI_U8 *pFrame;
2090 tpSirMacMgmtHdr pMacHdr;
2091 tDot11fDelTS DelTS;
2092 tDot11fWMMDelTS WMMDelTS;
2093 tSirRetStatus nSirStatus;
2094 tANI_U32 nBytes, nPayload, nStatus;
2095 void *pPacket;
2096 eHalStatus halstatus;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05302097 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002098
2099 if(NULL == psessionEntry)
2100 {
2101 return;
2102 }
2103
2104 if ( ! wmmTspecPresent )
2105 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302106 vos_mem_set( ( tANI_U8* )&DelTS, sizeof( DelTS ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07002107
2108 DelTS.Category.category = SIR_MAC_ACTION_QOS_MGMT;
2109 DelTS.Action.action = SIR_MAC_QOS_DEL_TS_REQ;
2110 PopulateDot11fTSInfo( pTsinfo, &DelTS.TSInfo );
2111
2112 nStatus = dot11fGetPackedDelTSSize( pMac, &DelTS, &nPayload );
2113 if ( DOT11F_FAILED( nStatus ) )
2114 {
2115 limLog( pMac, LOGP, FL("Failed to calculate the packed si"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002116 "ze for a Del TS (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002117 nStatus );
2118 // We'll fall back on the worst case scenario:
2119 nPayload = sizeof( tDot11fDelTS );
2120 }
2121 else if ( DOT11F_WARNED( nStatus ) )
2122 {
2123 limLog( pMac, LOGW, FL("There were warnings while calcula"
2124 "ting the packed size for a Del TS"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002125 " (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07002126 }
2127 }
2128 else
2129 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302130 vos_mem_set( ( tANI_U8* )&WMMDelTS, sizeof( WMMDelTS ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07002131
2132 WMMDelTS.Category.category = SIR_MAC_ACTION_WME;
2133 WMMDelTS.Action.action = SIR_MAC_QOS_DEL_TS_REQ;
2134 WMMDelTS.DialogToken.token = 0;
2135 WMMDelTS.StatusCode.statusCode = 0;
2136 PopulateDot11fWMMTSPEC( pTspecIe, &WMMDelTS.WMMTSPEC );
2137 nStatus = dot11fGetPackedWMMDelTSSize( pMac, &WMMDelTS, &nPayload );
2138 if ( DOT11F_FAILED( nStatus ) )
2139 {
2140 limLog( pMac, LOGP, FL("Failed to calculate the packed si"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002141 "ze for a WMM Del TS (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002142 nStatus );
2143 // We'll fall back on the worst case scenario:
2144 nPayload = sizeof( tDot11fDelTS );
2145 }
2146 else if ( DOT11F_WARNED( nStatus ) )
2147 {
2148 limLog( pMac, LOGW, FL("There were warnings while calcula"
2149 "ting the packed size for a WMM De"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002150 "l TS (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07002151 }
2152 }
2153
2154 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
2155
2156 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
2157 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
2158 {
2159 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for an Ad"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002160 "d TS Response."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07002161 return;
2162 }
2163
2164 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302165 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07002166
2167 // Next, we fill out the buffer descriptor:
2168 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
2169 SIR_MAC_MGMT_ACTION, peer,
2170 psessionEntry->selfMacAddr);
2171 if ( eSIR_SUCCESS != nSirStatus )
2172 {
2173 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002174 "tor for an Add TS Response (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002175 nSirStatus );
2176 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
2177 return; // allocated!
2178 }
2179
2180 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
2181
2182 #if 0
2183
2184 cfgLen = SIR_MAC_ADDR_LENGTH;
2185 if ( eSIR_SUCCESS != wlan_cfgGetStr( pMac, WNI_CFG_BSSID,
2186 ( tANI_U8* )pMacHdr->bssId, &cfgLen ) )
2187 {
2188 limLog( pMac, LOGP, FL("Failed to retrieve WNI_CFG_BSSID whil"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002189 "e sending an Add TS Response.") );
Jeff Johnson295189b2012-06-20 16:38:30 -07002190 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
2191 return; // allocated!
2192 }
2193 #endif //TO SUPPORT BT-AMP
2194 sirCopyMacAddr(pMacHdr->bssId, psessionEntry->bssId);
2195
Chet Lanctot186b5732013-03-18 10:26:30 -07002196#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07002197 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07002198#endif
2199
Jeff Johnson295189b2012-06-20 16:38:30 -07002200 // That done, pack the struct:
2201 if ( !wmmTspecPresent )
2202 {
2203 nStatus = dot11fPackDelTS( pMac, &DelTS,
2204 pFrame + sizeof( tSirMacMgmtHdr ),
2205 nPayload, &nPayload );
2206 if ( DOT11F_FAILED( nStatus ) )
2207 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002208 limLog( pMac, LOGE, FL("Failed to pack a Del TS frame (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002209 nStatus );
2210 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
2211 return; // allocated!
2212 }
2213 else if ( DOT11F_WARNED( nStatus ) )
2214 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08002215 limLog( pMac, LOGW, FL("There were warnings while packing "
2216 "a Del TS frame (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07002217 }
2218 }
2219 else
2220 {
2221 nStatus = dot11fPackWMMDelTS( pMac, &WMMDelTS,
2222 pFrame + sizeof( tSirMacMgmtHdr ),
2223 nPayload, &nPayload );
2224 if ( DOT11F_FAILED( nStatus ) )
2225 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002226 limLog( pMac, LOGE, FL("Failed to pack a WMM Del TS frame (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002227 nStatus );
2228 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
2229 return; // allocated!
2230 }
2231 else if ( DOT11F_WARNED( nStatus ) )
2232 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08002233 limLog( pMac, LOGW, FL("There were warnings while packing "
2234 "a WMM Del TS frame (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07002235 }
2236 }
2237
Abhishek Singh3cbf6052014-12-15 16:46:42 +05302238 limLog(pMac, LOG1, FL("Sending DELTS REQ (size %d) to "), nBytes);
2239 limPrintMacAddr(pMac, pMacHdr->da, LOG1);
Jeff Johnson295189b2012-06-20 16:38:30 -07002240
2241 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07002242 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
2243 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07002244 )
2245 {
2246 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
2247 }
2248
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05302249 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
2250 psessionEntry->peSessionId,
2251 pMacHdr->fc.subType));
Jeff Johnson295189b2012-06-20 16:38:30 -07002252 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
2253 HAL_TXRX_FRM_802_11_MGMT,
2254 ANI_TXDIR_TODS,
2255 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
2256 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05302257 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
2258 psessionEntry->peSessionId,
2259 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07002260 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
2261 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002262 limLog( pMac, LOGE, FL("Failed to send Del TS (%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002263 nSirStatus );
2264 //Pkt will be freed up by the callback
2265 }
2266
2267} // End limSendDeltsReqActionFrame.
2268
2269void
2270limSendAssocReqMgmtFrame(tpAniSirGlobal pMac,
2271 tLimMlmAssocReq *pMlmAssocReq,
2272 tpPESession psessionEntry)
2273{
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002274 tDot11fAssocRequest *pFrm;
Jeff Johnson295189b2012-06-20 16:38:30 -07002275 tANI_U16 caps;
2276 tANI_U8 *pFrame;
Agrawal Ashish5ac89da2015-10-26 19:08:47 +05302277 tSirRetStatus nSirStatus = eSIR_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07002278 tLimMlmAssocCnf mlmAssocCnf;
c_hpothubcd78652014-04-28 22:31:08 +05302279 tANI_U32 nPayload, nStatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07002280 tANI_U8 fQosEnabled, fWmeEnabled, fWsmEnabled;
2281 void *pPacket;
2282 eHalStatus halstatus;
2283 tANI_U16 nAddIELen;
2284 tANI_U8 *pAddIE;
2285 tANI_U8 *wpsIe = NULL;
2286#if defined WLAN_FEATURE_VOWIFI
2287 tANI_U8 PowerCapsPopulated = FALSE;
2288#endif
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05302289 tANI_U32 txFlag = 0;
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05302290 tpSirMacMgmtHdr pMacHdr;
Kalikinkar dhara205da782014-03-21 15:49:32 -07002291 tDot11fIEExtCap extractedExtCap;
2292 tANI_BOOLEAN extractedExtCapFlag = eANI_BOOLEAN_TRUE;
c_hpothubcd78652014-04-28 22:31:08 +05302293 tANI_U32 nBytes = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002294
2295 if(NULL == psessionEntry)
2296 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05302297 limLog(pMac, LOGE, FL("psessionEntry is NULL") );
Jeff Johnson295189b2012-06-20 16:38:30 -07002298 return;
2299 }
2300
Jeff Johnson295189b2012-06-20 16:38:30 -07002301 /* check this early to avoid unncessary operation */
2302 if(NULL == psessionEntry->pLimJoinReq)
2303 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05302304 limLog(pMac, LOGE, FL("psessionEntry->pLimJoinReq is NULL") );
Jeff Johnson295189b2012-06-20 16:38:30 -07002305 return;
2306 }
2307 nAddIELen = psessionEntry->pLimJoinReq->addIEAssoc.length;
2308 pAddIE = psessionEntry->pLimJoinReq->addIEAssoc.addIEdata;
2309
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302310 pFrm = vos_mem_malloc(sizeof(tDot11fAssocRequest));
2311 if ( NULL == pFrm )
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002312 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05302313 limLog(pMac, LOGE, FL("Unable to allocate memory") );
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002314 return;
2315 }
2316
2317
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302318 vos_mem_set( ( tANI_U8* )pFrm, sizeof( tDot11fAssocRequest ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07002319
Kalikinkar dhara205da782014-03-21 15:49:32 -07002320 vos_mem_set(( tANI_U8* )&extractedExtCap, sizeof( tDot11fIEExtCap ), 0);
Hu Wang5193b572016-08-11 10:04:47 +08002321 if (psessionEntry->ExtCap.present)
Agrawal Ashish5ac89da2015-10-26 19:08:47 +05302322 {
2323 nSirStatus = limStripOffExtCapIEAndUpdateStruct(pMac, pAddIE,
Kalikinkar dhara205da782014-03-21 15:49:32 -07002324 &nAddIELen,
2325 &extractedExtCap );
Agrawal Ashish5ac89da2015-10-26 19:08:47 +05302326 }
Kalikinkar dhara205da782014-03-21 15:49:32 -07002327 if(eSIR_SUCCESS != nSirStatus )
2328 {
2329 extractedExtCapFlag = eANI_BOOLEAN_FALSE;
2330 limLog(pMac, LOG1,
2331 FL("Unable to Stripoff ExtCap IE from Assoc Req"));
2332 }
Leela Venkata Kiran Kumar Reddy Chirala2f9b5712014-05-06 00:09:42 -07002333 /* TODO:remove this code once driver provides the call back function
2334 * to supplicant for set_qos_map
2335 */
2336 else
2337 {
Hu Wangc12631c2016-08-11 09:57:03 +08002338 struct s_ext_cap *p_ext_cap = (struct s_ext_cap *)extractedExtCap.bytes;
2339 if (p_ext_cap->interworkingService) {
2340 p_ext_cap->qosMap = 1;
2341 }
2342 extractedExtCap.num_bytes = lim_compute_ext_cap_ie_length(&extractedExtCap);
2343 extractedExtCapFlag = (extractedExtCap.num_bytes > 0);
Leela Venkata Kiran Kumar Reddy Chirala2f9b5712014-05-06 00:09:42 -07002344 }
Kalikinkar dhara205da782014-03-21 15:49:32 -07002345
Jeff Johnson295189b2012-06-20 16:38:30 -07002346 caps = pMlmAssocReq->capabilityInfo;
2347 if ( PROP_CAPABILITY_GET( 11EQOS, psessionEntry->limCurrentBssPropCap ) )
2348 ((tSirMacCapabilityInfo *) &caps)->qos = 0;
2349#if defined(FEATURE_WLAN_WAPI)
2350 /* CR: 262463 :
2351 According to WAPI standard:
2352 7.3.1.4 Capability Information field
2353 In WAPI, non-AP STAs within an ESS set the Privacy subfield to 0 in transmitted
2354 Association or Reassociation management frames. APs ignore the Privacy subfield within received Association and
2355 Reassociation management frames. */
2356 if ( psessionEntry->encryptType == eSIR_ED_WPI)
2357 ((tSirMacCapabilityInfo *) &caps)->privacy = 0;
2358#endif
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002359 swapBitField16(caps, ( tANI_U16* )&pFrm->Capabilities );
Jeff Johnson295189b2012-06-20 16:38:30 -07002360
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002361 pFrm->ListenInterval.interval = pMlmAssocReq->listenInterval;
2362 PopulateDot11fSSID2( pMac, &pFrm->SSID );
Jeff Johnson295189b2012-06-20 16:38:30 -07002363 PopulateDot11fSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002364 &pFrm->SuppRates,psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07002365
2366 fQosEnabled = ( psessionEntry->limQosEnabled) &&
2367 SIR_MAC_GET_QOS( psessionEntry->limCurrentBssCaps );
2368
2369 fWmeEnabled = ( psessionEntry->limWmeEnabled ) &&
2370 LIM_BSS_CAPS_GET( WME, psessionEntry->limCurrentBssQosCaps );
2371
2372 // We prefer .11e asociations:
2373 if ( fQosEnabled ) fWmeEnabled = false;
2374
2375 fWsmEnabled = ( psessionEntry->limWsmEnabled ) && fWmeEnabled &&
2376 LIM_BSS_CAPS_GET( WSM, psessionEntry->limCurrentBssQosCaps );
2377
2378 if ( psessionEntry->lim11hEnable &&
2379 psessionEntry->pLimJoinReq->spectrumMgtIndicator == eSIR_TRUE )
2380 {
2381#if defined WLAN_FEATURE_VOWIFI
2382 PowerCapsPopulated = TRUE;
2383
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002384 PopulateDot11fPowerCaps( pMac, &pFrm->PowerCaps, LIM_ASSOC,psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07002385#endif
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002386 PopulateDot11fSuppChannels( pMac, &pFrm->SuppChannels, LIM_ASSOC,psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07002387
2388 }
2389
2390#if defined WLAN_FEATURE_VOWIFI
2391 if( pMac->rrm.rrmPEContext.rrmEnable &&
2392 SIR_MAC_GET_RRM( psessionEntry->limCurrentBssCaps ) )
2393 {
2394 if (PowerCapsPopulated == FALSE)
2395 {
2396 PowerCapsPopulated = TRUE;
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002397 PopulateDot11fPowerCaps(pMac, &pFrm->PowerCaps, LIM_ASSOC, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07002398 }
2399 }
2400#endif
2401
2402 if ( fQosEnabled &&
2403 ( ! PROP_CAPABILITY_GET(11EQOS, psessionEntry->limCurrentBssPropCap)))
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002404 PopulateDot11fQOSCapsStation( pMac, &pFrm->QOSCapsStation );
Jeff Johnson295189b2012-06-20 16:38:30 -07002405
2406 PopulateDot11fExtSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002407 &pFrm->ExtSuppRates, psessionEntry );
Jeff Johnson295189b2012-06-20 16:38:30 -07002408
2409#if defined WLAN_FEATURE_VOWIFI
2410 if( pMac->rrm.rrmPEContext.rrmEnable &&
2411 SIR_MAC_GET_RRM( psessionEntry->limCurrentBssCaps ) )
2412 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002413 PopulateDot11fRRMIe( pMac, &pFrm->RRMEnabledCap, psessionEntry );
Jeff Johnson295189b2012-06-20 16:38:30 -07002414 }
2415#endif
2416 // The join request *should* contain zero or one of the WPA and RSN
2417 // IEs. The payload send along with the request is a
2418 // 'tSirSmeJoinReq'; the IE portion is held inside a 'tSirRSNie':
2419
2420 // typedef struct sSirRSNie
2421 // {
2422 // tANI_U16 length;
2423 // tANI_U8 rsnIEdata[SIR_MAC_MAX_IE_LENGTH+2];
2424 // } tSirRSNie, *tpSirRSNie;
2425
2426 // So, we should be able to make the following two calls harmlessly,
2427 // since they do nothing if they don't find the given IE in the
2428 // bytestream with which they're provided.
2429
2430 // The net effect of this will be to faithfully transmit whatever
2431 // security IE is in the join request.
2432
2433 // *However*, if we're associating for the purpose of WPS
2434 // enrollment, and we've been configured to indicate that by
2435 // eliding the WPA or RSN IE, we just skip this:
2436 if( nAddIELen && pAddIE )
2437 {
2438 wpsIe = limGetWscIEPtr (pMac, pAddIE, nAddIELen);
2439 }
2440 if ( NULL == wpsIe )
2441 {
2442 PopulateDot11fRSNOpaque( pMac, &( psessionEntry->pLimJoinReq->rsnIE ),
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002443 &pFrm->RSNOpaque );
Jeff Johnson295189b2012-06-20 16:38:30 -07002444 PopulateDot11fWPAOpaque( pMac, &( psessionEntry->pLimJoinReq->rsnIE ),
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002445 &pFrm->WPAOpaque );
Jeff Johnson295189b2012-06-20 16:38:30 -07002446#if defined(FEATURE_WLAN_WAPI)
2447 PopulateDot11fWAPIOpaque( pMac, &( psessionEntry->pLimJoinReq->rsnIE ),
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002448 &pFrm->WAPIOpaque );
Jeff Johnson295189b2012-06-20 16:38:30 -07002449#endif // defined(FEATURE_WLAN_WAPI)
2450 }
2451
2452 // include WME EDCA IE as well
2453 if ( fWmeEnabled )
2454 {
2455 if ( ! PROP_CAPABILITY_GET( WME, psessionEntry->limCurrentBssPropCap ) )
2456 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002457 PopulateDot11fWMMInfoStation( pMac, &pFrm->WMMInfoStation );
Jeff Johnson295189b2012-06-20 16:38:30 -07002458 }
2459
2460 if ( fWsmEnabled &&
2461 ( ! PROP_CAPABILITY_GET(WSM, psessionEntry->limCurrentBssPropCap )))
2462 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002463 PopulateDot11fWMMCaps( &pFrm->WMMCaps );
Jeff Johnson295189b2012-06-20 16:38:30 -07002464 }
2465 }
2466
2467 //Populate HT IEs, when operating in 11n or Taurus modes AND
2468 //when AP is also operating in 11n mode.
Jeff Johnsone7245742012-09-05 17:12:55 -07002469 if ( psessionEntry->htCapability &&
Jeff Johnson295189b2012-06-20 16:38:30 -07002470 pMac->lim.htCapabilityPresentInBeacon)
2471 {
Krishna Kumaar Natarajan025a8602015-08-04 16:31:36 +05302472 limLog(pMac, LOG1, FL("Populate HT IEs in Assoc Request"));
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002473 PopulateDot11fHTCaps( pMac, psessionEntry, &pFrm->HTCaps );
Jeff Johnson295189b2012-06-20 16:38:30 -07002474#ifdef DISABLE_GF_FOR_INTEROP
2475
2476 /*
2477 * To resolve the interop problem with Broadcom AP,
2478 * where TQ STA could not pass traffic with GF enabled,
2479 * TQ STA will do Greenfield only with TQ AP, for
2480 * everybody else it will be turned off.
2481 */
2482
2483 if( (psessionEntry->pLimJoinReq != NULL) && (!psessionEntry->pLimJoinReq->bssDescription.aniIndicator))
2484 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05302485 limLog( pMac, LOG1, FL("Sending Assoc Req to Non-TQ AP,"
2486 " Turning off Greenfield"));
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002487 pFrm->HTCaps.greenField = WNI_CFG_GREENFIELD_CAPABILITY_DISABLE;
Jeff Johnson295189b2012-06-20 16:38:30 -07002488 }
2489#endif
2490
2491 }
Agrawal Ashishb10d0392015-08-06 16:18:20 +05302492
2493 limLog(pMac, LOG1, FL("SupportedChnlWidth: %d, mimoPS: %d, GF: %d,"
2494 "shortGI20:%d, shortGI40: %d, dsssCck: %d, AMPDU Param: %x"),
2495 pFrm->HTCaps.supportedChannelWidthSet, pFrm->HTCaps.mimoPowerSave,
2496 pFrm->HTCaps.greenField, pFrm->HTCaps.shortGI20MHz, pFrm->HTCaps.shortGI40MHz,
2497 pFrm->HTCaps.dsssCckMode40MHz, pFrm->HTCaps.maxRxAMPDUFactor);
2498
2499
Jeff Johnsone7245742012-09-05 17:12:55 -07002500#ifdef WLAN_FEATURE_11AC
2501 if ( psessionEntry->vhtCapability &&
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07002502 psessionEntry->vhtCapabilityPresentInBeacon)
Jeff Johnsone7245742012-09-05 17:12:55 -07002503 {
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07002504 limLog( pMac, LOG1, FL("Populate VHT IEs in Assoc Request"));
Abhishek Singh33f76ea2015-06-04 12:27:30 +05302505 PopulateDot11fVHTCaps( pMac, &pFrm->VHTCaps,
2506 psessionEntry->currentOperChannel, eSIR_FALSE );
Abhishek Singhe038dc62015-05-22 11:36:45 +05302507
Jeff Johnsone7245742012-09-05 17:12:55 -07002508 }
2509#endif
Hu Wang5193b572016-08-11 10:04:47 +08002510 if (psessionEntry->ExtCap.present)
Agrawal Ashish5ac89da2015-10-26 19:08:47 +05302511 PopulateDot11fExtCap( pMac, &pFrm->ExtCap, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07002512
2513#if defined WLAN_FEATURE_VOWIFI_11R
2514 if (psessionEntry->pLimJoinReq->is11Rconnection)
2515 {
2516#if defined WLAN_FEATURE_VOWIFI_11R_DEBUG
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002517 limLog( pMac, LOG1, FL("mdie = %02x %02x %02x"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002518 (unsigned int)psessionEntry->pLimJoinReq->bssDescription.mdie[0],
2519 (unsigned int)psessionEntry->pLimJoinReq->bssDescription.mdie[1],
2520 (unsigned int)psessionEntry->pLimJoinReq->bssDescription.mdie[2]);
2521#endif
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302522 PopulateMDIE( pMac, &pFrm->MobilityDomain,
2523 psessionEntry->pLimJoinReq->bssDescription.mdie);
Jeff Johnson295189b2012-06-20 16:38:30 -07002524 }
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302525 else
Jeff Johnson295189b2012-06-20 16:38:30 -07002526 {
2527 // No 11r IEs dont send any MDIE
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302528 limLog( pMac, LOG1, FL("MDIE not present"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002529 }
2530#endif
2531
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002532#ifdef FEATURE_WLAN_ESE
2533 /* For ESE Associations fill the ESE IEs */
2534 if (psessionEntry->isESEconnection &&
2535 psessionEntry->pLimJoinReq->isESEFeatureIniEnabled)
Jeff Johnson295189b2012-06-20 16:38:30 -07002536 {
Varun Reddy Yeturu30779b42013-04-09 09:57:16 -07002537#ifndef FEATURE_DISABLE_RM
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002538 PopulateDot11fESERadMgmtCap(&pFrm->ESERadMgmtCap);
Varun Reddy Yeturu30779b42013-04-09 09:57:16 -07002539#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002540 PopulateDot11fESEVersion(&pFrm->ESEVersion);
Jeff Johnson295189b2012-06-20 16:38:30 -07002541 }
2542#endif
2543
c_hpothubcd78652014-04-28 22:31:08 +05302544 /* merge the ExtCap struct*/
2545 if (extractedExtCapFlag && extractedExtCap.present)
2546 {
Hu Wang5193b572016-08-11 10:04:47 +08002547 limMergeExtCapIEStruct(&pFrm->ExtCap, &extractedExtCap, true);
2548 }
2549
2550 if (pFrm->ExtCap.present && psessionEntry->ExtCap.present) {
2551 limMergeExtCapIEStruct(&pFrm->ExtCap, &psessionEntry->ExtCap, false);
2552 limLog(pMac, LOG1,
2553 FL("Clear the bits in EXTCAP IE that AP don't support to avoid IoT issues."));
c_hpothubcd78652014-04-28 22:31:08 +05302554 }
2555
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002556 nStatus = dot11fGetPackedAssocRequestSize( pMac, pFrm, &nPayload );
Jeff Johnson295189b2012-06-20 16:38:30 -07002557 if ( DOT11F_FAILED( nStatus ) )
2558 {
2559 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002560 "or an Association Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002561 nStatus );
2562 // We'll fall back on the worst case scenario:
2563 nPayload = sizeof( tDot11fAssocRequest );
2564 }
2565 else if ( DOT11F_WARNED( nStatus ) )
2566 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08002567 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07002568 "the packed size for an Association Re "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002569 "quest(0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07002570 }
2571
2572 nBytes = nPayload + sizeof( tSirMacMgmtHdr ) + nAddIELen;
2573
2574 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
2575 ( tANI_U16 )nBytes, ( void** ) &pFrame,
2576 ( void** ) &pPacket );
2577 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
2578 {
2579 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for an As"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002580 "sociation Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07002581
2582 psessionEntry->limMlmState = psessionEntry->limPrevMlmState;
Jeff Johnsone7245742012-09-05 17:12:55 -07002583 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07002584
2585
2586 /* Update PE session id*/
2587 mlmAssocCnf.sessionId = psessionEntry->peSessionId;
2588
2589 mlmAssocCnf.resultCode = eSIR_SME_RESOURCES_UNAVAILABLE;
2590
2591 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
2592 ( void* ) pFrame, ( void* ) pPacket );
2593
2594 limPostSmeMessage( pMac, LIM_MLM_ASSOC_CNF,
2595 ( tANI_U32* ) &mlmAssocCnf);
2596
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302597 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -07002598 return;
2599 }
2600
2601 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302602 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07002603
2604 // Next, we fill out the buffer descriptor:
2605 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
2606 SIR_MAC_MGMT_ASSOC_REQ, psessionEntry->bssId,psessionEntry->selfMacAddr);
2607 if ( eSIR_SUCCESS != nSirStatus )
2608 {
2609 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002610 "tor for an Association Request (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002611 nSirStatus );
2612 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302613 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -07002614 return;
2615 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002616
Abhishek Singh57aebef2014-02-03 18:47:44 +05302617 // That done, pack the Assoc Request:
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002618 nStatus = dot11fPackAssocRequest( pMac, pFrm, pFrame +
Jeff Johnson295189b2012-06-20 16:38:30 -07002619 sizeof(tSirMacMgmtHdr),
2620 nPayload, &nPayload );
2621 if ( DOT11F_FAILED( nStatus ) )
2622 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05302623 limLog( pMac, LOGE, FL("Failed to pack a Assoc Request (0x%0"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002624 "8x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002625 nStatus );
2626 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
2627 ( void* ) pFrame, ( void* ) pPacket );
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302628 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -07002629 return;
2630 }
2631 else if ( DOT11F_WARNED( nStatus ) )
2632 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05302633 limLog( pMac, LOGW, FL("There were warnings while packing a Assoc"
2634 "Request (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07002635 }
2636
2637 PELOG1(limLog( pMac, LOG1, FL("*** Sending Association Request length %d"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002638 "to "),
Jeff Johnson295189b2012-06-20 16:38:30 -07002639 nBytes );)
2640 // limPrintMacAddr( pMac, bssid, LOG1 );
2641
2642 if( psessionEntry->assocReq != NULL )
2643 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302644 vos_mem_free(psessionEntry->assocReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07002645 psessionEntry->assocReq = NULL;
2646 }
2647
2648 if( nAddIELen )
2649 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302650 vos_mem_copy( pFrame + sizeof(tSirMacMgmtHdr) + nPayload,
2651 pAddIE,
2652 nAddIELen );
Jeff Johnson295189b2012-06-20 16:38:30 -07002653 nPayload += nAddIELen;
2654 }
2655
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302656 psessionEntry->assocReq = vos_mem_malloc(nPayload);
2657 if ( NULL == psessionEntry->assocReq )
Jeff Johnson295189b2012-06-20 16:38:30 -07002658 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05302659 PELOGE(limLog(pMac, LOGE, FL("Unable to allocate memory to store "
2660 "assoc request"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07002661 }
2662 else
2663 {
2664 //Store the Assoc request. This is sent to csr/hdd in join cnf response.
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302665 vos_mem_copy( psessionEntry->assocReq, pFrame + sizeof(tSirMacMgmtHdr), nPayload);
Jeff Johnson295189b2012-06-20 16:38:30 -07002666 psessionEntry->assocReqLen = nPayload;
2667 }
2668
2669 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07002670 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
2671 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07002672 )
2673 {
2674 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
2675 }
2676
Sushant Kaushike8681d22015-04-21 12:08:25 +05302677 if(psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ||
2678 psessionEntry->pePersona == VOS_STA_MODE)
Ganesh K08bce952012-12-13 15:04:41 -08002679 {
2680 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
2681 }
Deepthi Gowri639d5042015-11-16 20:23:39 +05302682#ifdef FEATURE_WLAN_DIAG_SUPPORT
2683 limDiagEventReport(pMac, WLAN_PE_DIAG_ASSOC_START_EVENT, psessionEntry,
2684 eSIR_SUCCESS, eSIR_SUCCESS);
2685#endif
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05302686 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
Agarwal Ashisha8e81f52014-04-02 01:59:52 +05302687 limLog( pMac, LOG1, FL("Sending Assoc req over WQ5 to "MAC_ADDRESS_STR
2688 " From " MAC_ADDRESS_STR),MAC_ADDR_ARRAY(pMacHdr->da),
2689 MAC_ADDR_ARRAY(psessionEntry->selfMacAddr));
2690 txFlag |= HAL_USE_FW_IN_TX_PATH;
2691
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05302692 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
2693 psessionEntry->peSessionId,
2694 pMacHdr->fc.subType));
Katya Nigam63902932014-06-26 19:04:23 +05302695
Masti, Narayanraddi67ea5912015-01-08 12:34:05 +05302696 if( ( psessionEntry->is11Gonly == true ) &&
2697 ( !IS_BROADCAST_MAC(pMlmAssocReq->peerMacAddr) ) ){
2698 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
2699 }
Ganesh Kondabattiniffc00b12015-03-18 13:11:33 +05302700 if (IS_FEATURE_SUPPORTED_BY_FW(ENHANCED_TXBD_COMPLETION))
2701 {
2702 limLog(pMac, LOG1, FL("Assoc Req - txBdToken %u"), pMac->lim.txBdToken);
2703 halstatus = halTxFrameWithTxComplete( pMac, pPacket,
2704 ( tANI_U16 ) (sizeof(tSirMacMgmtHdr) + nPayload),
2705 HAL_TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS,
2706 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
2707 limTxComplete, pFrame, limTxBdComplete, txFlag,
2708 pMac->lim.txBdToken);
2709 pMac->lim.txBdToken++;
2710 }
2711 else
2712 {
2713 halstatus = halTxFrame( pMac, pPacket,
2714 ( tANI_U16 ) (sizeof(tSirMacMgmtHdr) + nPayload),
2715 HAL_TXRX_FRM_802_11_MGMT,
2716 ANI_TXDIR_TODS,
2717 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
2718 limTxComplete, pFrame, txFlag );
2719 }
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05302720 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
2721 psessionEntry->peSessionId,
2722 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07002723 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
2724 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002725 limLog( pMac, LOGE, FL("Failed to send Association Request (%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002726 halstatus );
2727 //Pkt will be freed up by the callback
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302728 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -07002729 return;
2730 }
2731
Katya Nigamccaeda72015-04-20 18:51:22 +05302732 //Enable caching only if Assoc Request is successfully submitted to the h/w
2733 WLANTL_EnableCaching(psessionEntry->staId);
2734
Jeff Johnson295189b2012-06-20 16:38:30 -07002735 // Free up buffer allocated for mlmAssocReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302736 vos_mem_free(pMlmAssocReq);
Leela Venkata Kiran Kumar Reddy Chiralad6c0fe22013-12-11 19:10:50 -08002737 pMlmAssocReq = NULL;
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302738 vos_mem_free(pFrm);
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002739 return;
Jeff Johnson295189b2012-06-20 16:38:30 -07002740} // End limSendAssocReqMgmtFrame
2741
2742
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002743#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07002744/*------------------------------------------------------------------------------------
2745 *
2746 * Send Reassoc Req with FTIEs.
2747 *
2748 *-----------------------------------------------------------------------------------
2749 */
2750void
2751limSendReassocReqWithFTIEsMgmtFrame(tpAniSirGlobal pMac,
2752 tLimMlmReassocReq *pMlmReassocReq,tpPESession psessionEntry)
2753{
2754 static tDot11fReAssocRequest frm;
2755 tANI_U16 caps;
2756 tANI_U8 *pFrame;
2757 tSirRetStatus nSirStatus;
2758 tANI_U32 nBytes, nPayload, nStatus;
2759 tANI_U8 fQosEnabled, fWmeEnabled, fWsmEnabled;
2760 void *pPacket;
2761 eHalStatus halstatus;
2762#if defined WLAN_FEATURE_VOWIFI
2763 tANI_U8 PowerCapsPopulated = FALSE;
2764#endif
2765 tANI_U16 ft_ies_length = 0;
2766 tANI_U8 *pBody;
2767 tANI_U16 nAddIELen;
2768 tANI_U8 *pAddIE;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002769#if defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07002770 tANI_U8 *wpsIe = NULL;
2771#endif
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05302772 tANI_U32 txFlag = 0;
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05302773 tpSirMacMgmtHdr pMacHdr;
Jeff Johnson295189b2012-06-20 16:38:30 -07002774
2775 if (NULL == psessionEntry)
2776 {
2777 return;
2778 }
2779
Jeff Johnson295189b2012-06-20 16:38:30 -07002780 /* check this early to avoid unncessary operation */
2781 if(NULL == psessionEntry->pLimReAssocReq)
2782 {
2783 return;
2784 }
2785 nAddIELen = psessionEntry->pLimReAssocReq->addIEAssoc.length;
2786 pAddIE = psessionEntry->pLimReAssocReq->addIEAssoc.addIEdata;
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08002787 limLog( pMac, LOG1, FL("limSendReassocReqWithFTIEsMgmtFrame received in "
2788 "state (%d)."), psessionEntry->limMlmState);
Jeff Johnson295189b2012-06-20 16:38:30 -07002789
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302790 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07002791
2792 caps = pMlmReassocReq->capabilityInfo;
2793 if (PROP_CAPABILITY_GET(11EQOS, psessionEntry->limReassocBssPropCap))
2794 ((tSirMacCapabilityInfo *) &caps)->qos = 0;
2795#if defined(FEATURE_WLAN_WAPI)
2796 /* CR: 262463 :
2797 According to WAPI standard:
2798 7.3.1.4 Capability Information field
2799 In WAPI, non-AP STAs within an ESS set the Privacy subfield to 0 in transmitted
2800 Association or Reassociation management frames. APs ignore the Privacy subfield within received Association and
2801 Reassociation management frames. */
2802 if ( psessionEntry->encryptType == eSIR_ED_WPI)
2803 ((tSirMacCapabilityInfo *) &caps)->privacy = 0;
2804#endif
2805 swapBitField16(caps, ( tANI_U16* )&frm.Capabilities );
2806
2807 frm.ListenInterval.interval = pMlmReassocReq->listenInterval;
2808
2809 // Get the old bssid of the older AP.
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302810 vos_mem_copy( ( tANI_U8* )frm.CurrentAPAddress.mac,
Jeff Johnson295189b2012-06-20 16:38:30 -07002811 pMac->ft.ftPEContext.pFTPreAuthReq->currbssId, 6);
2812
2813 PopulateDot11fSSID2( pMac, &frm.SSID );
2814 PopulateDot11fSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
2815 &frm.SuppRates,psessionEntry);
2816
2817 fQosEnabled = ( psessionEntry->limQosEnabled) &&
2818 SIR_MAC_GET_QOS( psessionEntry->limReassocBssCaps );
2819
2820 fWmeEnabled = ( psessionEntry->limWmeEnabled ) &&
2821 LIM_BSS_CAPS_GET( WME, psessionEntry->limReassocBssQosCaps );
2822
2823 fWsmEnabled = ( psessionEntry->limWsmEnabled ) && fWmeEnabled &&
2824 LIM_BSS_CAPS_GET( WSM, psessionEntry->limReassocBssQosCaps );
2825
2826 if ( psessionEntry->lim11hEnable &&
2827 psessionEntry->pLimReAssocReq->spectrumMgtIndicator == eSIR_TRUE )
2828 {
2829#if defined WLAN_FEATURE_VOWIFI
2830 PowerCapsPopulated = TRUE;
2831
2832 PopulateDot11fPowerCaps( pMac, &frm.PowerCaps, LIM_REASSOC,psessionEntry);
2833 PopulateDot11fSuppChannels( pMac, &frm.SuppChannels, LIM_REASSOC,psessionEntry);
2834#endif
2835 }
2836
2837#if defined WLAN_FEATURE_VOWIFI
2838 if( pMac->rrm.rrmPEContext.rrmEnable &&
2839 SIR_MAC_GET_RRM( psessionEntry->limCurrentBssCaps ) )
2840 {
2841 if (PowerCapsPopulated == FALSE)
2842 {
2843 PowerCapsPopulated = TRUE;
2844 PopulateDot11fPowerCaps(pMac, &frm.PowerCaps, LIM_REASSOC, psessionEntry);
2845 }
2846 }
2847#endif
2848
2849 if ( fQosEnabled &&
2850 ( ! PROP_CAPABILITY_GET(11EQOS, psessionEntry->limReassocBssPropCap ) ))
2851 {
2852 PopulateDot11fQOSCapsStation( pMac, &frm.QOSCapsStation );
2853 }
2854
2855 PopulateDot11fExtSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
2856 &frm.ExtSuppRates, psessionEntry );
2857
2858#if defined WLAN_FEATURE_VOWIFI
2859 if( pMac->rrm.rrmPEContext.rrmEnable &&
2860 SIR_MAC_GET_RRM( psessionEntry->limReassocBssCaps ) )
2861 {
2862 PopulateDot11fRRMIe( pMac, &frm.RRMEnabledCap, psessionEntry );
2863 }
2864#endif
2865
2866 // Ideally this should be enabled for 11r also. But 11r does
2867 // not follow the usual norm of using the Opaque object
2868 // for rsnie and fties. Instead we just add
2869 // the rsnie and fties at the end of the pack routine for 11r.
2870 // This should ideally! be fixed.
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002871#if defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07002872 //
2873 // The join request *should* contain zero or one of the WPA and RSN
2874 // IEs. The payload send along with the request is a
2875 // 'tSirSmeJoinReq'; the IE portion is held inside a 'tSirRSNie':
2876
2877 // typedef struct sSirRSNie
2878 // {
2879 // tANI_U16 length;
2880 // tANI_U8 rsnIEdata[SIR_MAC_MAX_IE_LENGTH+2];
2881 // } tSirRSNie, *tpSirRSNie;
2882
2883 // So, we should be able to make the following two calls harmlessly,
2884 // since they do nothing if they don't find the given IE in the
2885 // bytestream with which they're provided.
2886
2887 // The net effect of this will be to faithfully transmit whatever
2888 // security IE is in the join request.
2889
2890 // *However*, if we're associating for the purpose of WPS
2891 // enrollment, and we've been configured to indicate that by
2892 // eliding the WPA or RSN IE, we just skip this:
2893 if (!psessionEntry->is11Rconnection)
2894 {
2895 if( nAddIELen && pAddIE )
2896 {
2897 wpsIe = limGetWscIEPtr(pMac, pAddIE, nAddIELen);
2898 }
2899 if ( NULL == wpsIe )
2900 {
2901 PopulateDot11fRSNOpaque( pMac, &( psessionEntry->pLimReAssocReq->rsnIE ),
2902 &frm.RSNOpaque );
2903 PopulateDot11fWPAOpaque( pMac, &( psessionEntry->pLimReAssocReq->rsnIE ),
2904 &frm.WPAOpaque );
2905 }
2906
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002907#ifdef FEATURE_WLAN_ESE
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302908 if (psessionEntry->pLimReAssocReq->cckmIE.length)
Jeff Johnson295189b2012-06-20 16:38:30 -07002909 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002910 PopulateDot11fESECckmOpaque( pMac, &( psessionEntry->pLimReAssocReq->cckmIE ),
2911 &frm.ESECckmOpaque );
Jeff Johnson295189b2012-06-20 16:38:30 -07002912 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002913#endif //FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07002914 }
2915
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002916#ifdef FEATURE_WLAN_ESE
2917 // For ESE Associations fill the ESE IEs
2918 if (psessionEntry->isESEconnection &&
2919 psessionEntry->pLimReAssocReq->isESEFeatureIniEnabled)
Jeff Johnson295189b2012-06-20 16:38:30 -07002920 {
Varun Reddy Yeturu30779b42013-04-09 09:57:16 -07002921#ifndef FEATURE_DISABLE_RM
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002922 PopulateDot11fESERadMgmtCap(&frm.ESERadMgmtCap);
Varun Reddy Yeturu30779b42013-04-09 09:57:16 -07002923#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002924 PopulateDot11fESEVersion(&frm.ESEVersion);
Jeff Johnson295189b2012-06-20 16:38:30 -07002925 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002926#endif //FEATURE_WLAN_ESE
2927#endif //FEATURE_WLAN_ESE || FEATURE_WLAN_LFR
Jeff Johnson295189b2012-06-20 16:38:30 -07002928
2929 // include WME EDCA IE as well
2930 if ( fWmeEnabled )
2931 {
2932 if ( ! PROP_CAPABILITY_GET( WME, psessionEntry->limReassocBssPropCap ) )
2933 {
2934 PopulateDot11fWMMInfoStation( pMac, &frm.WMMInfoStation );
2935 }
2936
2937 if ( fWsmEnabled &&
2938 ( ! PROP_CAPABILITY_GET(WSM, psessionEntry->limReassocBssPropCap )))
2939 {
2940 PopulateDot11fWMMCaps( &frm.WMMCaps );
2941 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002942#ifdef FEATURE_WLAN_ESE
2943 if (psessionEntry->isESEconnection)
Jeff Johnson295189b2012-06-20 16:38:30 -07002944 {
2945 PopulateDot11fReAssocTspec(pMac, &frm, psessionEntry);
2946
2947 // Populate the TSRS IE if TSPEC is included in the reassoc request
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002948 if (psessionEntry->pLimReAssocReq->eseTspecInfo.numTspecs)
Jeff Johnson295189b2012-06-20 16:38:30 -07002949 {
2950 tANI_U32 phyMode;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002951 tSirMacESETSRSIE tsrsIE;
Jeff Johnson295189b2012-06-20 16:38:30 -07002952 limGetPhyMode(pMac, &phyMode, psessionEntry);
2953
2954 tsrsIE.tsid = 0;
2955 if( phyMode == WNI_CFG_PHY_MODE_11G || phyMode == WNI_CFG_PHY_MODE_11A)
2956 {
2957 tsrsIE.rates[0] = TSRS_11AG_RATE_6MBPS;
2958 }
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302959 else
Jeff Johnson295189b2012-06-20 16:38:30 -07002960 {
2961 tsrsIE.rates[0] = TSRS_11B_RATE_5_5MBPS;
2962 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002963 PopulateDot11TSRSIE(pMac,&tsrsIE, &frm.ESETrafStrmRateSet, sizeof(tANI_U8));
Jeff Johnson295189b2012-06-20 16:38:30 -07002964 }
2965 }
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302966#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002967 }
2968
Jeff Johnsone7245742012-09-05 17:12:55 -07002969 if ( psessionEntry->htCapability &&
Jeff Johnson295189b2012-06-20 16:38:30 -07002970 pMac->lim.htCapabilityPresentInBeacon)
2971 {
Jeff Johnsone7245742012-09-05 17:12:55 -07002972 PopulateDot11fHTCaps( pMac, psessionEntry, &frm.HTCaps );
Jeff Johnson295189b2012-06-20 16:38:30 -07002973 }
Agrawal Ashishb10d0392015-08-06 16:18:20 +05302974 limLog(pMac, LOG1, FL("SupportedChnlWidth: %d, mimoPS: %d, GF: %d,"
2975 "shortGI20:%d, shortGI40: %d, dsssCck: %d, AMPDU Param: %x"),
2976 frm.HTCaps.supportedChannelWidthSet, frm.HTCaps.mimoPowerSave,
2977 frm.HTCaps.greenField, frm.HTCaps.shortGI20MHz, frm.HTCaps.shortGI40MHz,
2978 frm.HTCaps.dsssCckMode40MHz, frm.HTCaps.maxRxAMPDUFactor);
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08002979#if defined WLAN_FEATURE_VOWIFI_11R
Kanchanapally, Vidyullatha4f84f682014-04-29 20:40:34 +05302980 if ( psessionEntry->pLimReAssocReq->bssDescription.mdiePresent &&
2981 (pMac->ft.ftSmeContext.addMDIE == TRUE)
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002982#if defined FEATURE_WLAN_ESE
2983 && !psessionEntry->isESEconnection
Gopichand Nakkala0ac55062013-04-08 14:43:07 +05302984#endif
2985 )
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08002986 {
2987 PopulateMDIE( pMac, &frm.MobilityDomain, psessionEntry->pLimReAssocReq->bssDescription.mdie);
2988 }
2989#endif
2990
Chet Lanctotf19c1f62013-12-13 13:56:21 -08002991#ifdef WLAN_FEATURE_11AC
2992 if ( psessionEntry->vhtCapability &&
2993 psessionEntry->vhtCapabilityPresentInBeacon)
2994 {
2995 limLog( pMac, LOG1, FL("Populate VHT IEs in Re-Assoc Request"));
Abhishek Singh33f76ea2015-06-04 12:27:30 +05302996 PopulateDot11fVHTCaps( pMac, &frm.VHTCaps,
2997 psessionEntry->currentOperChannel, eSIR_FALSE );
Abhishek Singhe038dc62015-05-22 11:36:45 +05302998
Chet Lanctotf19c1f62013-12-13 13:56:21 -08002999 }
3000#endif
Hu Wang5193b572016-08-11 10:04:47 +08003001 if (psessionEntry->ExtCap.present)
Agrawal Ashish5ac89da2015-10-26 19:08:47 +05303002 PopulateDot11fExtCap( pMac, &frm.ExtCap, psessionEntry);
Chet Lanctotf19c1f62013-12-13 13:56:21 -08003003
Jeff Johnson295189b2012-06-20 16:38:30 -07003004 nStatus = dot11fGetPackedReAssocRequestSize( pMac, &frm, &nPayload );
3005 if ( DOT11F_FAILED( nStatus ) )
3006 {
3007 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003008 "or a Re-Association Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003009 nStatus );
3010 // We'll fall back on the worst case scenario:
3011 nPayload = sizeof( tDot11fReAssocRequest );
3012 }
3013 else if ( DOT11F_WARNED( nStatus ) )
3014 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08003015 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07003016 "the packed size for a Re-Association Re "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003017 "quest(0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07003018 }
3019
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07003020 nBytes = nPayload + sizeof( tSirMacMgmtHdr ) + nAddIELen;
Jeff Johnson295189b2012-06-20 16:38:30 -07003021
3022#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08003023 limLog( pMac, LOG1, FL("FT IE Reassoc Req (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003024 pMac->ft.ftSmeContext.reassoc_ft_ies_length);
3025#endif
3026
3027#if defined WLAN_FEATURE_VOWIFI_11R
3028 if (psessionEntry->is11Rconnection)
3029 {
3030 ft_ies_length = pMac->ft.ftSmeContext.reassoc_ft_ies_length;
3031 }
3032#endif
3033
3034 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
3035 ( tANI_U16 )nBytes+ft_ies_length, ( void** ) &pFrame,
3036 ( void** ) &pPacket );
3037 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3038 {
3039 psessionEntry->limMlmState = psessionEntry->limPrevMlmState;
Jeff Johnsone7245742012-09-05 17:12:55 -07003040 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07003041 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Re-As"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003042 "sociation Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07003043 goto end;
3044 }
3045
3046 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303047 vos_mem_set( pFrame, nBytes + ft_ies_length, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07003048
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003049#if defined WLAN_FEATURE_VOWIFI_11R_DEBUG || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08003050 limPrintMacAddr(pMac, psessionEntry->limReAssocbssId, LOG1);
Jeff Johnson295189b2012-06-20 16:38:30 -07003051#endif
3052 // Next, we fill out the buffer descriptor:
3053 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
3054 SIR_MAC_MGMT_REASSOC_REQ,
3055 psessionEntry->limReAssocbssId,psessionEntry->selfMacAddr);
3056 if ( eSIR_SUCCESS != nSirStatus )
3057 {
3058 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003059 "tor for an Association Request (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003060 nSirStatus );
3061 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
3062 goto end;
3063 }
3064
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05303065 pMacHdr = (tpSirMacMgmtHdr) pFrame;
Jeff Johnson295189b2012-06-20 16:38:30 -07003066 // That done, pack the ReAssoc Request:
3067 nStatus = dot11fPackReAssocRequest( pMac, &frm, pFrame +
3068 sizeof(tSirMacMgmtHdr),
3069 nPayload, &nPayload );
3070 if ( DOT11F_FAILED( nStatus ) )
3071 {
3072 limLog( pMac, LOGE, FL("Failed to pack a Re-Association Reque"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003073 "st (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003074 nStatus );
3075 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
3076 goto end;
3077 }
3078 else if ( DOT11F_WARNED( nStatus ) )
3079 {
3080 limLog( pMac, LOGW, FL("There were warnings while packing a R"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08003081 "e-Association Request (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07003082 }
3083
3084 PELOG3(limLog( pMac, LOG3,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003085 FL("*** Sending Re-Association Request length %d %d to "),
Jeff Johnson295189b2012-06-20 16:38:30 -07003086 nBytes, nPayload );)
3087 if( psessionEntry->assocReq != NULL )
3088 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303089 vos_mem_free(psessionEntry->assocReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07003090 psessionEntry->assocReq = NULL;
3091 }
3092
3093 if( nAddIELen )
3094 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303095 vos_mem_copy( pFrame + sizeof(tSirMacMgmtHdr) + nPayload,
3096 pAddIE,
3097 nAddIELen );
Jeff Johnson295189b2012-06-20 16:38:30 -07003098 nPayload += nAddIELen;
3099 }
3100
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303101 psessionEntry->assocReq = vos_mem_malloc(nPayload);
3102 if ( NULL == psessionEntry->assocReq )
Jeff Johnson295189b2012-06-20 16:38:30 -07003103 {
3104 PELOGE(limLog(pMac, LOGE, FL("Unable to allocate memory to store assoc request"));)
Jeff Johnson43971f52012-07-17 12:26:56 -07003105 }
3106 else
3107 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003108 //Store the Assoc request. This is sent to csr/hdd in join cnf response.
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303109 vos_mem_copy( psessionEntry->assocReq, pFrame + sizeof(tSirMacMgmtHdr), nPayload);
Jeff Johnson295189b2012-06-20 16:38:30 -07003110 psessionEntry->assocReqLen = nPayload;
Jeff Johnson43971f52012-07-17 12:26:56 -07003111 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003112
3113 if (psessionEntry->is11Rconnection)
3114 {
3115 {
3116 int i = 0;
3117
3118 pBody = pFrame + nBytes;
3119 for (i=0; i<ft_ies_length; i++)
3120 {
3121 *pBody = pMac->ft.ftSmeContext.reassoc_ft_ies[i];
3122 pBody++;
3123 }
3124 }
3125 }
3126
3127#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08003128 PELOGE(limLog(pMac, LOG1, FL("Re-assoc Req Frame is: "));
3129 sirDumpBuf(pMac, SIR_LIM_MODULE_ID, LOG1,
Jeff Johnson295189b2012-06-20 16:38:30 -07003130 (tANI_U8 *)pFrame,
3131 (nBytes + ft_ies_length));)
3132#endif
3133
3134
3135 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07003136 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
3137 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07003138 )
3139 {
3140 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
3141 }
3142
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07003143 if( NULL != psessionEntry->assocReq )
3144 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303145 vos_mem_free(psessionEntry->assocReq);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07003146 psessionEntry->assocReq = NULL;
3147 }
Agrawal Ashishad64dc22016-02-04 11:32:15 +05303148 if (ft_ies_length)
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07003149 {
Agrawal Ashishad64dc22016-02-04 11:32:15 +05303150 psessionEntry->assocReq = vos_mem_malloc(ft_ies_length);
3151 if (NULL == psessionEntry->assocReq)
3152 {
3153 limLog(pMac, LOGE,
3154 FL("Unable to allocate memory for FT IEs"));
3155 psessionEntry->assocReqLen = 0;
3156 }
3157 else
3158 {
3159 /* Store the FT IEs. This is sent to csr/hdd in join cnf response.*/
3160 vos_mem_copy(psessionEntry->assocReq,
3161 pMac->ft.ftSmeContext.reassoc_ft_ies,
3162 (ft_ies_length));
3163 psessionEntry->assocReqLen = ft_ies_length;
3164 }
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07003165 }
3166 else
3167 {
Agrawal Ashishad64dc22016-02-04 11:32:15 +05303168 limLog(pMac, LOG1, FL("FT IEs not present"));
3169 psessionEntry->assocReqLen = 0;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07003170 }
Deepthi Gowri639d5042015-11-16 20:23:39 +05303171#ifdef FEATURE_WLAN_DIAG_SUPPORT
3172 limDiagEventReport(pMac, WLAN_PE_DIAG_REASSOC_START_EVENT, psessionEntry,
3173 eSIR_SUCCESS, eSIR_SUCCESS);
3174#endif
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05303175 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
3176 psessionEntry->peSessionId,
3177 pMacHdr->fc.subType));
Ganesh Kondabattiniffc00b12015-03-18 13:11:33 +05303178 if (IS_FEATURE_SUPPORTED_BY_FW(ENHANCED_TXBD_COMPLETION))
3179 {
3180 limLog( pMac, LOG1, FL("Reassoc req - txBdToken %u"), pMac->lim.txBdToken);
3181 halstatus = halTxFrameWithTxComplete( pMac, pPacket,
3182 ( tANI_U16 ) (nBytes + ft_ies_length),
3183 HAL_TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS,
3184 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
3185 limTxComplete, pFrame, limTxBdComplete, txFlag,
3186 pMac->lim.txBdToken);
3187 pMac->lim.txBdToken++;
3188 }
3189 else
3190 {
3191 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) (nBytes + ft_ies_length),
3192 HAL_TXRX_FRM_802_11_MGMT,
3193 ANI_TXDIR_TODS,
3194 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
3195 limTxComplete, pFrame, txFlag );
3196 }
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05303197 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
3198 psessionEntry->peSessionId,
3199 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07003200 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3201 {
3202 limLog( pMac, LOGE, FL("Failed to send Re-Association Request"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003203 "(%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07003204 nSirStatus );
3205 //Pkt will be freed up by the callback
3206 goto end;
3207 }
3208
Katya Nigamccaeda72015-04-20 18:51:22 +05303209 // Enable TL cahching in case of roaming
3210 WLANTL_EnableCaching(psessionEntry->staId);
3211
Jeff Johnson295189b2012-06-20 16:38:30 -07003212end:
3213 // Free up buffer allocated for mlmAssocReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303214 vos_mem_free( pMlmReassocReq );
Jeff Johnson295189b2012-06-20 16:38:30 -07003215 psessionEntry->pLimMlmReassocReq = NULL;
3216
3217}
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -07003218
3219void limSendRetryReassocReqFrame(tpAniSirGlobal pMac,
3220 tLimMlmReassocReq *pMlmReassocReq,
3221 tpPESession psessionEntry)
3222{
3223 tLimMlmReassocCnf mlmReassocCnf; // keep sme
3224 tLimMlmReassocReq *pTmpMlmReassocReq = NULL;
Sachin Ahuja07a43012015-01-30 17:04:38 +05303225#ifdef FEATURE_WLAN_ESE
3226 tANI_U32 val=0;
3227#endif
3228 if (pMlmReassocReq == NULL)
3229 {
3230 limLog(pMac, LOGE,
3231 FL("Invalid pMlmReassocReq"));
3232 goto end;
3233 }
Hema Aparna Medicharla43d0f7b2015-02-12 17:07:59 +05303234
3235 pTmpMlmReassocReq = vos_mem_malloc(sizeof(tLimMlmReassocReq));
3236 if ( NULL == pTmpMlmReassocReq ) goto end;
3237 vos_mem_set( pTmpMlmReassocReq, sizeof(tLimMlmReassocReq), 0);
3238 vos_mem_copy( pTmpMlmReassocReq, pMlmReassocReq, sizeof(tLimMlmReassocReq));
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -07003239
3240 // Prepare and send Reassociation request frame
3241 // start reassoc timer.
Sachin Ahuja07a43012015-01-30 17:04:38 +05303242#ifdef FEATURE_WLAN_ESE
3243 /*
3244 * In case of Ese Reassociation, change the reassoc timer
3245 * value.
3246 */
3247 val = pMlmReassocReq->reassocFailureTimeout;
3248 if (psessionEntry->isESEconnection)
3249 {
3250 val = val/LIM_MAX_REASSOC_RETRY_LIMIT;
3251 }
3252 if (tx_timer_deactivate(&pMac->lim.limTimers.gLimReassocFailureTimer) !=
3253 TX_SUCCESS)
3254 {
3255 limLog(pMac, LOGP,
3256 FL("unable to deactivate Reassoc failure timer"));
3257 }
3258 val = SYS_MS_TO_TICKS(val);
3259 if (tx_timer_change(&pMac->lim.limTimers.gLimReassocFailureTimer,
3260 val, 0) != TX_SUCCESS)
3261 {
3262 limLog(pMac, LOGP,
3263 FL("unable to change Reassociation failure timer"));
3264 }
3265#endif
3266
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -07003267 pMac->lim.limTimers.gLimReassocFailureTimer.sessionId = psessionEntry->peSessionId;
3268 // Start reassociation failure timer
Leela V Kiran Kumar Reddy Chiralac3b9d382013-01-31 20:49:53 -08003269 MTRACE(macTrace(pMac, TRACE_CODE_TIMER_ACTIVATE, psessionEntry->peSessionId, eLIM_REASSOC_FAIL_TIMER));
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -07003270 if (tx_timer_activate(&pMac->lim.limTimers.gLimReassocFailureTimer)
3271 != TX_SUCCESS)
3272 {
3273 // Could not start reassoc failure timer.
3274 // Log error
3275 limLog(pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003276 FL("could not start Reassociation failure timer"));
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -07003277 // Return Reassoc confirm with
3278 // Resources Unavailable
3279 mlmReassocCnf.resultCode = eSIR_SME_RESOURCES_UNAVAILABLE;
3280 mlmReassocCnf.protStatusCode = eSIR_MAC_UNSPEC_FAILURE_STATUS;
3281 goto end;
3282 }
3283
3284 limSendReassocReqWithFTIEsMgmtFrame(pMac, pTmpMlmReassocReq, psessionEntry);
3285 return;
3286
3287end:
3288 // Free up buffer allocated for reassocReq
3289 if (pMlmReassocReq != NULL)
3290 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303291 vos_mem_free(pMlmReassocReq);
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -07003292 pMlmReassocReq = NULL;
3293 }
3294 if (pTmpMlmReassocReq != NULL)
3295 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303296 vos_mem_free(pTmpMlmReassocReq);
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -07003297 pTmpMlmReassocReq = NULL;
3298 }
3299 mlmReassocCnf.resultCode = eSIR_SME_FT_REASSOC_FAILURE;
3300 mlmReassocCnf.protStatusCode = eSIR_MAC_UNSPEC_FAILURE_STATUS;
3301 /* Update PE sessio Id*/
3302 mlmReassocCnf.sessionId = psessionEntry->peSessionId;
3303
3304 limPostSmeMessage(pMac, LIM_MLM_REASSOC_CNF, (tANI_U32 *) &mlmReassocCnf);
3305}
3306
Jeff Johnson295189b2012-06-20 16:38:30 -07003307#endif /* WLAN_FEATURE_VOWIFI_11R */
3308
3309
3310void
3311limSendReassocReqMgmtFrame(tpAniSirGlobal pMac,
3312 tLimMlmReassocReq *pMlmReassocReq,tpPESession psessionEntry)
3313{
3314 static tDot11fReAssocRequest frm;
3315 tANI_U16 caps;
3316 tANI_U8 *pFrame;
3317 tSirRetStatus nSirStatus;
3318 tANI_U32 nBytes, nPayload, nStatus;
3319 tANI_U8 fQosEnabled, fWmeEnabled, fWsmEnabled;
3320 void *pPacket;
3321 eHalStatus halstatus;
3322 tANI_U16 nAddIELen;
3323 tANI_U8 *pAddIE;
3324 tANI_U8 *wpsIe = NULL;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05303325 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003326#if defined WLAN_FEATURE_VOWIFI
3327 tANI_U8 PowerCapsPopulated = FALSE;
3328#endif
Ganesh Kondabattiniffc00b12015-03-18 13:11:33 +05303329 tpSirMacMgmtHdr pMacHdr;
Jeff Johnson295189b2012-06-20 16:38:30 -07003330
3331 if(NULL == psessionEntry)
3332 {
3333 return;
3334 }
3335
3336 /* check this early to avoid unncessary operation */
3337 if(NULL == psessionEntry->pLimReAssocReq)
3338 {
3339 return;
3340 }
3341 nAddIELen = psessionEntry->pLimReAssocReq->addIEAssoc.length;
3342 pAddIE = psessionEntry->pLimReAssocReq->addIEAssoc.addIEdata;
3343
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303344 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07003345
3346 caps = pMlmReassocReq->capabilityInfo;
3347 if (PROP_CAPABILITY_GET(11EQOS, psessionEntry->limReassocBssPropCap))
3348 ((tSirMacCapabilityInfo *) &caps)->qos = 0;
3349#if defined(FEATURE_WLAN_WAPI)
3350 /* CR: 262463 :
3351 According to WAPI standard:
3352 7.3.1.4 Capability Information field
3353 In WAPI, non-AP STAs within an ESS set the Privacy subfield to 0 in transmitted
3354 Association or Reassociation management frames. APs ignore the Privacy subfield within received Association and
3355 Reassociation management frames. */
3356 if ( psessionEntry->encryptType == eSIR_ED_WPI)
3357 ((tSirMacCapabilityInfo *) &caps)->privacy = 0;
3358#endif
3359 swapBitField16(caps, ( tANI_U16* )&frm.Capabilities );
3360
3361 frm.ListenInterval.interval = pMlmReassocReq->listenInterval;
3362
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303363 vos_mem_copy(( tANI_U8* )frm.CurrentAPAddress.mac,
3364 ( tANI_U8* )psessionEntry->bssId, 6 );
Jeff Johnson295189b2012-06-20 16:38:30 -07003365
3366 PopulateDot11fSSID2( pMac, &frm.SSID );
3367 PopulateDot11fSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
3368 &frm.SuppRates,psessionEntry);
3369
3370 fQosEnabled = ( psessionEntry->limQosEnabled ) &&
3371 SIR_MAC_GET_QOS( psessionEntry->limReassocBssCaps );
3372
3373 fWmeEnabled = ( psessionEntry->limWmeEnabled ) &&
3374 LIM_BSS_CAPS_GET( WME, psessionEntry->limReassocBssQosCaps );
3375
3376 fWsmEnabled = ( psessionEntry->limWsmEnabled ) && fWmeEnabled &&
3377 LIM_BSS_CAPS_GET( WSM, psessionEntry->limReassocBssQosCaps );
3378
3379
3380 if ( psessionEntry->lim11hEnable &&
3381 psessionEntry->pLimReAssocReq->spectrumMgtIndicator == eSIR_TRUE )
3382 {
3383#if defined WLAN_FEATURE_VOWIFI
3384 PowerCapsPopulated = TRUE;
3385 PopulateDot11fPowerCaps( pMac, &frm.PowerCaps, LIM_REASSOC,psessionEntry);
3386 PopulateDot11fSuppChannels( pMac, &frm.SuppChannels, LIM_REASSOC,psessionEntry);
3387#endif
3388 }
3389
3390#if defined WLAN_FEATURE_VOWIFI
3391 if( pMac->rrm.rrmPEContext.rrmEnable &&
3392 SIR_MAC_GET_RRM( psessionEntry->limCurrentBssCaps ) )
3393 {
3394 if (PowerCapsPopulated == FALSE)
3395 {
3396 PowerCapsPopulated = TRUE;
3397 PopulateDot11fPowerCaps(pMac, &frm.PowerCaps, LIM_REASSOC, psessionEntry);
3398 }
3399 }
3400#endif
3401
3402 if ( fQosEnabled &&
3403 ( ! PROP_CAPABILITY_GET(11EQOS, psessionEntry->limReassocBssPropCap ) ))
3404 {
3405 PopulateDot11fQOSCapsStation( pMac, &frm.QOSCapsStation );
3406 }
3407
3408 PopulateDot11fExtSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
3409 &frm.ExtSuppRates, psessionEntry );
3410
3411#if defined WLAN_FEATURE_VOWIFI
3412 if( pMac->rrm.rrmPEContext.rrmEnable &&
3413 SIR_MAC_GET_RRM( psessionEntry->limReassocBssCaps ) )
3414 {
3415 PopulateDot11fRRMIe( pMac, &frm.RRMEnabledCap, psessionEntry );
3416 }
3417#endif
3418 // The join request *should* contain zero or one of the WPA and RSN
3419 // IEs. The payload send along with the request is a
3420 // 'tSirSmeJoinReq'; the IE portion is held inside a 'tSirRSNie':
3421
3422 // typedef struct sSirRSNie
3423 // {
3424 // tANI_U16 length;
3425 // tANI_U8 rsnIEdata[SIR_MAC_MAX_IE_LENGTH+2];
3426 // } tSirRSNie, *tpSirRSNie;
3427
3428 // So, we should be able to make the following two calls harmlessly,
3429 // since they do nothing if they don't find the given IE in the
3430 // bytestream with which they're provided.
3431
3432 // The net effect of this will be to faithfully transmit whatever
3433 // security IE is in the join request.
3434
3435 // *However*, if we're associating for the purpose of WPS
3436 // enrollment, and we've been configured to indicate that by
3437 // eliding the WPA or RSN IE, we just skip this:
3438 if( nAddIELen && pAddIE )
3439 {
3440 wpsIe = limGetWscIEPtr(pMac, pAddIE, nAddIELen);
3441 }
3442 if ( NULL == wpsIe )
3443 {
3444 PopulateDot11fRSNOpaque( pMac, &( psessionEntry->pLimReAssocReq->rsnIE ),
3445 &frm.RSNOpaque );
3446 PopulateDot11fWPAOpaque( pMac, &( psessionEntry->pLimReAssocReq->rsnIE ),
3447 &frm.WPAOpaque );
3448#if defined(FEATURE_WLAN_WAPI)
3449 PopulateDot11fWAPIOpaque( pMac, &( psessionEntry->pLimReAssocReq->rsnIE ),
3450 &frm.WAPIOpaque );
3451#endif // defined(FEATURE_WLAN_WAPI)
3452 }
3453
3454 // include WME EDCA IE as well
3455 if ( fWmeEnabled )
3456 {
3457 if ( ! PROP_CAPABILITY_GET( WME, psessionEntry->limReassocBssPropCap ) )
3458 {
3459 PopulateDot11fWMMInfoStation( pMac, &frm.WMMInfoStation );
3460 }
3461
3462 if ( fWsmEnabled &&
3463 ( ! PROP_CAPABILITY_GET(WSM, psessionEntry->limReassocBssPropCap )))
3464 {
3465 PopulateDot11fWMMCaps( &frm.WMMCaps );
3466 }
3467 }
3468
Jeff Johnsone7245742012-09-05 17:12:55 -07003469 if ( psessionEntry->htCapability &&
Jeff Johnson295189b2012-06-20 16:38:30 -07003470 pMac->lim.htCapabilityPresentInBeacon)
3471 {
Jeff Johnsone7245742012-09-05 17:12:55 -07003472 PopulateDot11fHTCaps( pMac, psessionEntry, &frm.HTCaps );
Jeff Johnson295189b2012-06-20 16:38:30 -07003473 }
Agrawal Ashishb10d0392015-08-06 16:18:20 +05303474 limLog(pMac, LOG1, FL("SupportedChnlWidth: %d, mimoPS: %d, GF: %d,"
3475 "shortGI20:%d, shortGI40: %d, dsssCck: %d, AMPDU Param: %x"),
3476 frm.HTCaps.supportedChannelWidthSet, frm.HTCaps.mimoPowerSave,
3477 frm.HTCaps.greenField, frm.HTCaps.shortGI20MHz, frm.HTCaps.shortGI40MHz,
3478 frm.HTCaps.dsssCckMode40MHz, frm.HTCaps.maxRxAMPDUFactor);
Jeff Johnsone7245742012-09-05 17:12:55 -07003479#ifdef WLAN_FEATURE_11AC
3480 if ( psessionEntry->vhtCapability &&
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07003481 psessionEntry->vhtCapabilityPresentInBeacon)
Jeff Johnsone7245742012-09-05 17:12:55 -07003482 {
Chet Lanctotf19c1f62013-12-13 13:56:21 -08003483 limLog( pMac, LOG1, FL("Populate VHT IEs in Re-Assoc Request"));
Abhishek Singh33f76ea2015-06-04 12:27:30 +05303484 PopulateDot11fVHTCaps( pMac, &frm.VHTCaps,
3485 psessionEntry->currentOperChannel, eSIR_FALSE );
Hu Wang5193b572016-08-11 10:04:47 +08003486 if (psessionEntry->ExtCap.present)
Agrawal Ashish5ac89da2015-10-26 19:08:47 +05303487 PopulateDot11fExtCap( pMac, &frm.ExtCap, psessionEntry);
Jeff Johnsone7245742012-09-05 17:12:55 -07003488 }
3489#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003490
3491 nStatus = dot11fGetPackedReAssocRequestSize( pMac, &frm, &nPayload );
3492 if ( DOT11F_FAILED( nStatus ) )
3493 {
3494 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003495 "or a Re-Association Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003496 nStatus );
3497 // We'll fall back on the worst case scenario:
3498 nPayload = sizeof( tDot11fReAssocRequest );
3499 }
3500 else if ( DOT11F_WARNED( nStatus ) )
3501 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08003502 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07003503 "the packed size for a Re-Association Re "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003504 "quest(0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07003505 }
3506
3507 nBytes = nPayload + sizeof( tSirMacMgmtHdr ) + nAddIELen;
3508
3509 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
3510 ( tANI_U16 )nBytes, ( void** ) &pFrame,
3511 ( void** ) &pPacket );
3512 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3513 {
3514 psessionEntry->limMlmState = psessionEntry->limPrevMlmState;
Jeff Johnsone7245742012-09-05 17:12:55 -07003515 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07003516 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Re-As"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003517 "sociation Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07003518 goto end;
3519 }
3520
3521 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303522 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07003523
3524 // Next, we fill out the buffer descriptor:
3525 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
3526 SIR_MAC_MGMT_REASSOC_REQ,
3527 psessionEntry->limReAssocbssId,psessionEntry->selfMacAddr);
3528 if ( eSIR_SUCCESS != nSirStatus )
3529 {
3530 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003531 "tor for an Association Request (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003532 nSirStatus );
3533 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
3534 goto end;
3535 }
3536
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05303537 pMacHdr = (tpSirMacMgmtHdr) pFrame;
Jeff Johnson295189b2012-06-20 16:38:30 -07003538 // That done, pack the Probe Request:
3539 nStatus = dot11fPackReAssocRequest( pMac, &frm, pFrame +
3540 sizeof(tSirMacMgmtHdr),
3541 nPayload, &nPayload );
3542 if ( DOT11F_FAILED( nStatus ) )
3543 {
3544 limLog( pMac, LOGE, FL("Failed to pack a Re-Association Reque"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003545 "st (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003546 nStatus );
3547 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
3548 goto end;
3549 }
3550 else if ( DOT11F_WARNED( nStatus ) )
3551 {
3552 limLog( pMac, LOGW, FL("There were warnings while packing a R"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08003553 "e-Association Request (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07003554 }
3555
3556 PELOG1(limLog( pMac, LOG1, FL("*** Sending Re-Association Request length %d"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003557 "to "),
Jeff Johnson295189b2012-06-20 16:38:30 -07003558 nBytes );)
3559
3560 if( psessionEntry->assocReq != NULL )
3561 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303562 vos_mem_free(psessionEntry->assocReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07003563 psessionEntry->assocReq = NULL;
3564 }
3565
3566 if( nAddIELen )
3567 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303568 vos_mem_copy( pFrame + sizeof(tSirMacMgmtHdr) + nPayload,
3569 pAddIE,
3570 nAddIELen );
Jeff Johnson295189b2012-06-20 16:38:30 -07003571 nPayload += nAddIELen;
3572 }
3573
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303574 psessionEntry->assocReq = vos_mem_malloc(nPayload);
3575 if ( NULL == psessionEntry->assocReq )
Jeff Johnson295189b2012-06-20 16:38:30 -07003576 {
3577 PELOGE(limLog(pMac, LOGE, FL("Unable to allocate memory to store assoc request"));)
Jeff Johnson43971f52012-07-17 12:26:56 -07003578 }
3579 else
3580 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003581 //Store the Assoc request. This is sent to csr/hdd in join cnf response.
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303582 vos_mem_copy(psessionEntry->assocReq, pFrame + sizeof(tSirMacMgmtHdr), nPayload);
Jeff Johnson295189b2012-06-20 16:38:30 -07003583 psessionEntry->assocReqLen = nPayload;
Jeff Johnson43971f52012-07-17 12:26:56 -07003584 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003585
3586 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07003587 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
3588 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07003589 )
3590 {
3591 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
3592 }
3593
Sushant Kaushike8681d22015-04-21 12:08:25 +05303594 if(psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ||
3595 psessionEntry->pePersona == VOS_STA_MODE)
Ganesh K08bce952012-12-13 15:04:41 -08003596 {
3597 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
3598 }
Deepthi Gowri639d5042015-11-16 20:23:39 +05303599#ifdef FEATURE_WLAN_DIAG_SUPPORT
3600 limDiagEventReport(pMac, WLAN_PE_DIAG_REASSOC_START_EVENT, psessionEntry,
3601 eSIR_SUCCESS, eSIR_SUCCESS);
3602#endif
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08003603
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05303604 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
3605 psessionEntry->peSessionId,
3606 pMacHdr->fc.subType));
Katya Nigam63902932014-06-26 19:04:23 +05303607
Ganesh Kondabattiniffc00b12015-03-18 13:11:33 +05303608 if (IS_FEATURE_SUPPORTED_BY_FW(ENHANCED_TXBD_COMPLETION))
3609 {
3610 limLog(pMac, LOG1, FL("Reassoc req - txBdToken %u"), pMac->lim.txBdToken);
3611 halstatus = halTxFrameWithTxComplete( pMac, pPacket,
3612 ( tANI_U16 ) (sizeof(tSirMacMgmtHdr) + nPayload),
3613 HAL_TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS,
3614 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
3615 limTxComplete, pFrame, limTxBdComplete,
3616 txFlag, pMac->lim.txBdToken );
3617 pMac->lim.txBdToken++;
3618 }
3619 else
3620 {
3621 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) (sizeof(tSirMacMgmtHdr) + nPayload),
3622 HAL_TXRX_FRM_802_11_MGMT,
3623 ANI_TXDIR_TODS,
3624 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
3625 limTxComplete, pFrame, txFlag );
3626 }
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05303627 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
3628 psessionEntry->peSessionId,
3629 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07003630 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3631 {
3632 limLog( pMac, LOGE, FL("Failed to send Re-Association Request"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003633 "(%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07003634 nSirStatus );
3635 //Pkt will be freed up by the callback
3636 goto end;
3637 }
3638
Katya Nigamccaeda72015-04-20 18:51:22 +05303639 // enable caching
3640 WLANTL_EnableCaching(psessionEntry->staId);
3641
Jeff Johnson295189b2012-06-20 16:38:30 -07003642end:
3643 // Free up buffer allocated for mlmAssocReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303644 vos_mem_free( pMlmReassocReq );
Jeff Johnson295189b2012-06-20 16:38:30 -07003645 psessionEntry->pLimMlmReassocReq = NULL;
3646
3647} // limSendReassocReqMgmtFrame
3648
Sushant Kaushik9e923872015-04-02 17:09:31 +05303649eHalStatus limAuthTxCompleteCnf(tpAniSirGlobal pMac, void *pData)
Ganesh Kondabattiniffc00b12015-03-18 13:11:33 +05303650{
Sushant Kaushik9e923872015-04-02 17:09:31 +05303651 tANI_U32 txCompleteSuccess;
Ganesh Kondabattiniffc00b12015-03-18 13:11:33 +05303652 tpSirTxBdStatus pTxBdStatus;
Sushant Kaushik9e923872015-04-02 17:09:31 +05303653
3654 if (!pData)
3655 {
3656 limLog(pMac, LOG1,
3657 FL(" pData is NULL"));
3658 return eHAL_STATUS_FAILURE;
3659 }
Sushant Kaushik9e923872015-04-02 17:09:31 +05303660
Ganesh Kondabattiniffc00b12015-03-18 13:11:33 +05303661 if (IS_FEATURE_SUPPORTED_BY_FW(ENHANCED_TXBD_COMPLETION))
3662 {
3663 pTxBdStatus = (tpSirTxBdStatus) pData;
3664 txCompleteSuccess = pTxBdStatus->txCompleteStatus;
3665 limLog(pMac, LOG1, FL("txCompleteStatus %u, txBdToken %u"),
3666 pTxBdStatus->txCompleteStatus, pTxBdStatus->txBdToken);
3667 }
3668 else
3669 {
3670 txCompleteSuccess = *((tANI_U32*) pData);
3671 limLog(pMac, LOG1,
3672 FL("txCompleteSuccess= %d"), txCompleteSuccess);
3673 }
3674
Sushant Kaushik9e923872015-04-02 17:09:31 +05303675 if(txCompleteSuccess)
3676 {
3677 pMac->authAckStatus = LIM_AUTH_ACK_RCD_SUCCESS;
3678 // 'Change' timer for future activations
3679 limDeactivateAndChangeTimer(pMac, eLIM_AUTH_RETRY_TIMER);
3680 }
3681 else
3682 pMac->authAckStatus = LIM_AUTH_ACK_RCD_FAILURE;
Sushant Kaushikb97a0082015-08-31 12:36:45 +05303683#ifdef FEATURE_WLAN_DIAG_SUPPORT
Deepthi Gowri639d5042015-11-16 20:23:39 +05303684 limDiagEventReport(pMac, WLAN_PE_DIAG_AUTH_START_EVENT, NULL,
Sushant Kaushikb97a0082015-08-31 12:36:45 +05303685 pMac->authAckStatus, eSIR_SUCCESS);
3686#endif
3687
Sushant Kaushik9e923872015-04-02 17:09:31 +05303688 return eHAL_STATUS_SUCCESS;
3689}
3690
Jeff Johnson295189b2012-06-20 16:38:30 -07003691/**
3692 * \brief Send an Authentication frame
3693 *
3694 *
3695 * \param pMac Pointer to Global MAC structure
3696 *
3697 * \param pAuthFrameBody Pointer to Authentication frame structure that need
3698 * to be sent
3699 *
3700 * \param peerMacAddr MAC address of the peer entity to which Authentication
3701 * frame is destined
3702 *
3703 * \param wepBit Indicates whether wep bit to be set in FC while sending
3704 * Authentication frame3
3705 *
3706 *
3707 * This function is called by limProcessMlmMessages(). Authentication frame
3708 * is formatted and sent when this function is called.
3709 *
3710 *
3711 */
3712
3713void
3714limSendAuthMgmtFrame(tpAniSirGlobal pMac,
3715 tpSirMacAuthFrameBody pAuthFrameBody,
3716 tSirMacAddr peerMacAddr,
3717 tANI_U8 wepBit,
Sushant Kaushik9e923872015-04-02 17:09:31 +05303718 tpPESession psessionEntry,
3719 tAniBool waitForAck
Jeff Johnson295189b2012-06-20 16:38:30 -07003720 )
3721{
3722 tANI_U8 *pFrame, *pBody;
3723 tANI_U32 frameLen = 0, bodyLen = 0;
3724 tpSirMacMgmtHdr pMacHdr;
3725 tANI_U16 i;
3726 void *pPacket;
3727 eHalStatus halstatus;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05303728 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003729
3730 if(NULL == psessionEntry)
3731 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05303732 limLog(pMac, LOGE, FL("Error: psession Entry is NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003733 return;
3734 }
Abhishek Singh57aebef2014-02-03 18:47:44 +05303735
3736 limLog(pMac, LOG1,
3737 FL("Sending Auth seq# %d status %d (%d) to "MAC_ADDRESS_STR),
3738 pAuthFrameBody->authTransactionSeqNumber,
3739 pAuthFrameBody->authStatusCode,
3740 (pAuthFrameBody->authStatusCode == eSIR_MAC_SUCCESS_STATUS),
3741 MAC_ADDR_ARRAY(peerMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07003742 if (wepBit == LIM_WEP_IN_FC)
3743 {
3744 /// Auth frame3 to be sent with encrypted framebody
3745 /**
3746 * Allocate buffer for Authenticaton frame of size equal
3747 * to management frame header length plus 2 bytes each for
3748 * auth algorithm number, transaction number, status code,
3749 * 128 bytes for challenge text and 4 bytes each for
3750 * IV & ICV.
3751 */
3752
3753 frameLen = sizeof(tSirMacMgmtHdr) + LIM_ENCR_AUTH_BODY_LEN;
3754
3755 bodyLen = LIM_ENCR_AUTH_BODY_LEN;
3756 } // if (wepBit == LIM_WEP_IN_FC)
3757 else
3758 {
3759 switch (pAuthFrameBody->authTransactionSeqNumber)
3760 {
3761 case SIR_MAC_AUTH_FRAME_1:
3762 /**
3763 * Allocate buffer for Authenticaton frame of size
3764 * equal to management frame header length plus 2 bytes
3765 * each for auth algorithm number, transaction number
3766 * and status code.
3767 */
3768
3769 frameLen = sizeof(tSirMacMgmtHdr) +
3770 SIR_MAC_AUTH_CHALLENGE_OFFSET;
3771 bodyLen = SIR_MAC_AUTH_CHALLENGE_OFFSET;
3772
3773#if defined WLAN_FEATURE_VOWIFI_11R
Madan Mohan Koyyalamudi6a00a802012-11-28 16:12:11 -08003774 if (pAuthFrameBody->authAlgoNumber == eSIR_FT_AUTH)
3775 {
3776 if (0 != pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length)
Jeff Johnson295189b2012-06-20 16:38:30 -07003777 {
Madan Mohan Koyyalamudi6a00a802012-11-28 16:12:11 -08003778 frameLen += pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length;
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003779 limLog(pMac, LOG3, FL("Auth frame, FTIES length added=%d"),
Madan Mohan Koyyalamudi6a00a802012-11-28 16:12:11 -08003780 pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length);
Jeff Johnson295189b2012-06-20 16:38:30 -07003781 }
Madan Mohan Koyyalamudi6a00a802012-11-28 16:12:11 -08003782 else
3783 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05303784 limLog(pMac, LOG3, FL("Auth frame, Does not contain "
3785 "FTIES!!!"));
Madan Mohan Koyyalamudi6a00a802012-11-28 16:12:11 -08003786 frameLen += (2+SIR_MDIE_SIZE);
3787 }
3788 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003789#endif
3790 break;
3791
3792 case SIR_MAC_AUTH_FRAME_2:
3793 if ((pAuthFrameBody->authAlgoNumber == eSIR_OPEN_SYSTEM) ||
3794 ((pAuthFrameBody->authAlgoNumber == eSIR_SHARED_KEY) &&
3795 (pAuthFrameBody->authStatusCode != eSIR_MAC_SUCCESS_STATUS)))
3796 {
3797 /**
3798 * Allocate buffer for Authenticaton frame of size
3799 * equal to management frame header length plus
3800 * 2 bytes each for auth algorithm number,
3801 * transaction number and status code.
3802 */
3803
3804 frameLen = sizeof(tSirMacMgmtHdr) +
3805 SIR_MAC_AUTH_CHALLENGE_OFFSET;
3806 bodyLen = SIR_MAC_AUTH_CHALLENGE_OFFSET;
3807 }
3808 else
3809 {
3810 // Shared Key algorithm with challenge text
3811 // to be sent
3812 /**
3813 * Allocate buffer for Authenticaton frame of size
3814 * equal to management frame header length plus
3815 * 2 bytes each for auth algorithm number,
3816 * transaction number, status code and 128 bytes
3817 * for challenge text.
3818 */
3819
3820 frameLen = sizeof(tSirMacMgmtHdr) +
3821 sizeof(tSirMacAuthFrame);
3822 bodyLen = sizeof(tSirMacAuthFrameBody);
3823 }
3824
3825 break;
3826
3827 case SIR_MAC_AUTH_FRAME_3:
3828 /// Auth frame3 to be sent without encrypted framebody
3829 /**
3830 * Allocate buffer for Authenticaton frame of size equal
3831 * to management frame header length plus 2 bytes each
3832 * for auth algorithm number, transaction number and
3833 * status code.
3834 */
3835
3836 frameLen = sizeof(tSirMacMgmtHdr) +
3837 SIR_MAC_AUTH_CHALLENGE_OFFSET;
3838 bodyLen = SIR_MAC_AUTH_CHALLENGE_OFFSET;
3839
3840 break;
3841
3842 case SIR_MAC_AUTH_FRAME_4:
3843 /**
3844 * Allocate buffer for Authenticaton frame of size equal
3845 * to management frame header length plus 2 bytes each
3846 * for auth algorithm number, transaction number and
3847 * status code.
3848 */
3849
3850 frameLen = sizeof(tSirMacMgmtHdr) +
3851 SIR_MAC_AUTH_CHALLENGE_OFFSET;
3852 bodyLen = SIR_MAC_AUTH_CHALLENGE_OFFSET;
3853
3854 break;
3855 } // switch (pAuthFrameBody->authTransactionSeqNumber)
3856 } // end if (wepBit == LIM_WEP_IN_FC)
3857
3858
3859 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )frameLen, ( void** ) &pFrame, ( void** ) &pPacket );
3860
3861 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3862 {
3863 // Log error
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003864 limLog(pMac, LOGP, FL("call to bufAlloc failed for AUTH frame"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003865
3866 return;
3867 }
3868
3869 for (i = 0; i < frameLen; i++)
3870 pFrame[i] = 0;
3871
3872 // Prepare BD
3873 if (limPopulateMacHeader(pMac, pFrame, SIR_MAC_MGMT_FRAME,
3874 SIR_MAC_MGMT_AUTH, peerMacAddr,psessionEntry->selfMacAddr) != eSIR_SUCCESS)
3875 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05303876 limLog(pMac, LOGE, FL("call to limPopulateMacHeader failed for "
3877 "AUTH frame"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003878 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
3879 return;
3880 }
3881
3882 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
3883 pMacHdr->fc.wep = wepBit;
3884
3885 // Prepare BSSId
3886 if( (psessionEntry->limSystemRole == eLIM_AP_ROLE)|| (psessionEntry->limSystemRole == eLIM_BT_AMP_AP_ROLE) )
3887 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303888 vos_mem_copy( (tANI_U8 *) pMacHdr->bssId,
3889 (tANI_U8 *) psessionEntry->bssId,
3890 sizeof( tSirMacAddr ));
Jeff Johnson295189b2012-06-20 16:38:30 -07003891 }
3892
3893 /// Prepare Authentication frame body
3894 pBody = pFrame + sizeof(tSirMacMgmtHdr);
3895
3896 if (wepBit == LIM_WEP_IN_FC)
3897 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303898 vos_mem_copy(pBody, (tANI_U8 *) pAuthFrameBody, bodyLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07003899
Abhishek Singh3cbf6052014-12-15 16:46:42 +05303900 limLog(pMac, LOG1,
Abhishek Singh57aebef2014-02-03 18:47:44 +05303901 FL("*** Sending Auth seq# 3 status %d (%d) to"MAC_ADDRESS_STR),
Jeff Johnson295189b2012-06-20 16:38:30 -07003902 pAuthFrameBody->authStatusCode,
Abhishek Singh57aebef2014-02-03 18:47:44 +05303903 (pAuthFrameBody->authStatusCode == eSIR_MAC_SUCCESS_STATUS),
Abhishek Singh3cbf6052014-12-15 16:46:42 +05303904 MAC_ADDR_ARRAY(pMacHdr->da));
Jeff Johnson295189b2012-06-20 16:38:30 -07003905
Jeff Johnson295189b2012-06-20 16:38:30 -07003906 }
3907 else
3908 {
3909 *((tANI_U16 *)(pBody)) = sirSwapU16ifNeeded(pAuthFrameBody->authAlgoNumber);
3910 pBody += sizeof(tANI_U16);
3911 bodyLen -= sizeof(tANI_U16);
3912
3913 *((tANI_U16 *)(pBody)) = sirSwapU16ifNeeded(pAuthFrameBody->authTransactionSeqNumber);
3914 pBody += sizeof(tANI_U16);
3915 bodyLen -= sizeof(tANI_U16);
3916
3917 *((tANI_U16 *)(pBody)) = sirSwapU16ifNeeded(pAuthFrameBody->authStatusCode);
3918 pBody += sizeof(tANI_U16);
3919 bodyLen -= sizeof(tANI_U16);
Leela Venkata Kiran Kumar Reddy Chirala7d3fa552013-08-28 10:52:21 -07003920 if ( bodyLen <= (sizeof (pAuthFrameBody->type) +
3921 sizeof (pAuthFrameBody->length) +
3922 sizeof (pAuthFrameBody->challengeText)))
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303923 vos_mem_copy(pBody, (tANI_U8 *) &pAuthFrameBody->type, bodyLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07003924
3925#if defined WLAN_FEATURE_VOWIFI_11R
3926 if ((pAuthFrameBody->authAlgoNumber == eSIR_FT_AUTH) &&
3927 (pAuthFrameBody->authTransactionSeqNumber == SIR_MAC_AUTH_FRAME_1))
3928 {
3929
3930 {
3931 int i = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003932 if (pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length)
3933 {
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08003934#if defined WLAN_FEATURE_VOWIFI_11R_DEBUG
Srinivas Girigowdad63eb492014-02-06 12:21:47 -08003935 PELOG2(limLog(pMac, LOG2, FL("Auth1 Frame FTIE is: "));
3936 sirDumpBuf(pMac, SIR_LIM_MODULE_ID, LOG2,
Jeff Johnson295189b2012-06-20 16:38:30 -07003937 (tANI_U8 *)pBody,
3938 (pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length));)
Jeff Johnson295189b2012-06-20 16:38:30 -07003939#endif
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08003940 for (i=0; i<pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length; i++)
3941 {
Madan Mohan Koyyalamudi6a00a802012-11-28 16:12:11 -08003942 *pBody = pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies[i];
3943 pBody++;
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08003944 }
3945 }
3946 else
3947 {
3948 /* MDID attr is 54*/
3949 *pBody = 54;
Jeff Johnson295189b2012-06-20 16:38:30 -07003950 pBody++;
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08003951 *pBody = SIR_MDIE_SIZE;
3952 pBody++;
3953 for(i=0;i<SIR_MDIE_SIZE;i++)
3954 {
3955 *pBody = pMac->ft.ftPEContext.pFTPreAuthReq->pbssDescription->mdie[i];
3956 pBody++;
3957 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003958 }
3959 }
3960 }
3961#endif
3962
Abhishek Singh3cbf6052014-12-15 16:46:42 +05303963 limLog(pMac, LOG1,
Abhishek Singh57aebef2014-02-03 18:47:44 +05303964 FL("*** Sending Auth seq# %d status %d (%d) to "MAC_ADDRESS_STR),
Jeff Johnson295189b2012-06-20 16:38:30 -07003965 pAuthFrameBody->authTransactionSeqNumber,
3966 pAuthFrameBody->authStatusCode,
Abhishek Singh57aebef2014-02-03 18:47:44 +05303967 (pAuthFrameBody->authStatusCode == eSIR_MAC_SUCCESS_STATUS),
Abhishek Singh3cbf6052014-12-15 16:46:42 +05303968 MAC_ADDR_ARRAY(pMacHdr->da));
Jeff Johnson295189b2012-06-20 16:38:30 -07003969 }
3970 PELOG2(sirDumpBuf(pMac, SIR_LIM_MODULE_ID, LOG2, pFrame, frameLen);)
3971
3972 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07003973 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
3974 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003975#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05303976 || ((NULL != pMac->ft.ftPEContext.pFTPreAuthReq)
Jeff Johnsone7245742012-09-05 17:12:55 -07003977 && ( SIR_BAND_5_GHZ == limGetRFBand(pMac->ft.ftPEContext.pFTPreAuthReq->preAuthchannelNum)))
3978#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003979 )
3980 {
3981 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
3982 }
3983
Sushant Kaushike8681d22015-04-21 12:08:25 +05303984 if(psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ||
3985 psessionEntry->pePersona == VOS_STA_MODE)
Ganesh K08bce952012-12-13 15:04:41 -08003986 {
3987 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
3988 }
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08003989
Sushant Kaushik9e923872015-04-02 17:09:31 +05303990 limLog( pMac, LOG1,
3991 FL("Sending Auth Frame over WQ5 with waitForAck %d to "MAC_ADDRESS_STR
3992 " From " MAC_ADDRESS_STR), waitForAck, MAC_ADDR_ARRAY(pMacHdr->da),
Agarwal Ashisha8e81f52014-04-02 01:59:52 +05303993 MAC_ADDR_ARRAY(psessionEntry->selfMacAddr));
3994
3995 txFlag |= HAL_USE_FW_IN_TX_PATH;
3996
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05303997 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
3998 psessionEntry->peSessionId,
3999 pMacHdr->fc.subType));
Masti, Narayanraddi67ea5912015-01-08 12:34:05 +05304000
4001 if( ( psessionEntry->is11Gonly == true ) &&
4002 ( !IS_BROADCAST_MAC(peerMacAddr) ) ){
4003 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
4004 }
Sushant Kaushik9e923872015-04-02 17:09:31 +05304005 if(eSIR_TRUE == waitForAck)
4006 {
4007 pMac->authAckStatus = LIM_AUTH_ACK_NOT_RCD;
Sushant Kaushik0b343422015-05-25 17:15:55 +05304008 limLog(pMac, LOG1, FL("Auth frame - txBdToken %u"),
Ganesh Kondabattiniffc00b12015-03-18 13:11:33 +05304009 pMac->lim.txBdToken);
Sushant Kaushik9e923872015-04-02 17:09:31 +05304010 halstatus = halTxFrameWithTxComplete( pMac, pPacket,
4011 ( tANI_U16 ) frameLen,
4012 HAL_TXRX_FRM_802_11_MGMT,
4013 ANI_TXDIR_TODS,
4014 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
Ganesh Kondabattiniffc00b12015-03-18 13:11:33 +05304015 limTxComplete, pFrame, limAuthTxCompleteCnf, txFlag,
4016 pMac->lim.txBdToken);
4017 pMac->lim.txBdToken++;
Sushant Kaushik9e923872015-04-02 17:09:31 +05304018 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
4019 psessionEntry->peSessionId,
4020 halstatus));
4021 if (!HAL_STATUS_SUCCESS(halstatus))
4022 {
4023 limLog( pMac, LOGE,
4024 FL("Could not send Auth frame, retCode=%X "),
4025 halstatus );
4026 pMac->authAckStatus = LIM_AUTH_ACK_RCD_FAILURE;
4027 //Pkt will be freed up by the callback
4028 }
4029 }
4030 else
4031 {
4032 /// Queue Authentication frame in high priority WQ
4033 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) frameLen,
Jeff Johnson295189b2012-06-20 16:38:30 -07004034 HAL_TXRX_FRM_802_11_MGMT,
4035 ANI_TXDIR_TODS,
4036 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4037 limTxComplete, pFrame, txFlag );
Sushant Kaushik9e923872015-04-02 17:09:31 +05304038 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304039 psessionEntry->peSessionId,
4040 halstatus));
Sushant Kaushik9e923872015-04-02 17:09:31 +05304041 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4042 {
Jeff Johnson295189b2012-06-20 16:38:30 -07004043 limLog(pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004044 FL("*** Could not send Auth frame, retCode=%X ***"),
Jeff Johnson295189b2012-06-20 16:38:30 -07004045 halstatus);
4046
4047 //Pkt will be freed up by the callback
Sushant Kaushik9e923872015-04-02 17:09:31 +05304048 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004049 }
4050
4051 return;
4052} /*** end limSendAuthMgmtFrame() ***/
4053
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004054eHalStatus limSendDeauthCnf(tpAniSirGlobal pMac)
4055{
4056 tANI_U16 aid;
4057 tpDphHashNode pStaDs;
4058 tLimMlmDeauthReq *pMlmDeauthReq;
4059 tLimMlmDeauthCnf mlmDeauthCnf;
4060 tpPESession psessionEntry;
4061
4062 pMlmDeauthReq = pMac->lim.limDisassocDeauthCnfReq.pMlmDeauthReq;
4063 if (pMlmDeauthReq)
4064 {
4065 if (tx_timer_running(&pMac->lim.limTimers.gLimDeauthAckTimer))
4066 {
4067 limDeactivateAndChangeTimer(pMac, eLIM_DEAUTH_ACK_TIMER);
4068 }
4069
4070 if((psessionEntry = peFindSessionBySessionId(pMac, pMlmDeauthReq->sessionId))== NULL)
4071 {
4072
4073 PELOGE(limLog(pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004074 FL("session does not exist for given sessionId"));)
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004075 mlmDeauthCnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
4076 goto end;
4077 }
4078
4079 pStaDs = dphLookupHashEntry(pMac, pMlmDeauthReq->peerMacAddr, &aid, &psessionEntry->dph.dphHashTable);
4080 if (pStaDs == NULL)
4081 {
4082 mlmDeauthCnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
4083 goto end;
4084 }
4085
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004086 /// Receive path cleanup with dummy packet
4087 limCleanupRxPath(pMac, pStaDs,psessionEntry);
Abhishek Singhcf4590b2014-04-16 18:58:08 +05304088
4089#ifdef WLAN_FEATURE_VOWIFI_11R
Mukul Sharma0820d0e2014-11-11 19:49:02 +05304090 if ( psessionEntry->limSystemRole == eLIM_STA_ROLE )
Abhishek Singhcf4590b2014-04-16 18:58:08 +05304091 {
Mukul Sharma0820d0e2014-11-11 19:49:02 +05304092 PELOGE(limLog(pMac, LOG1,
4093 FL("FT Preauth SessionId %d Cleanup"
Abhishek Singhcf4590b2014-04-16 18:58:08 +05304094#ifdef FEATURE_WLAN_ESE
4095 " isESE %d"
4096#endif
4097#ifdef FEATURE_WLAN_LFR
4098 " isLFR %d"
4099#endif
4100 " is11r %d, Deauth reason %d Trigger = %d"),
Mukul Sharma0820d0e2014-11-11 19:49:02 +05304101 psessionEntry->peSessionId,
Abhishek Singhcf4590b2014-04-16 18:58:08 +05304102#ifdef FEATURE_WLAN_ESE
4103 psessionEntry->isESEconnection,
4104#endif
4105#ifdef FEATURE_WLAN_LFR
4106 psessionEntry->isFastRoamIniFeatureEnabled,
4107#endif
4108 psessionEntry->is11Rconnection,
4109 pMlmDeauthReq->reasonCode,
4110 pMlmDeauthReq->deauthTrigger););
Mukul Sharma0820d0e2014-11-11 19:49:02 +05304111
4112 limFTCleanup(pMac);
Abhishek Singhcf4590b2014-04-16 18:58:08 +05304113 }
4114#endif
4115
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004116 /// Free up buffer allocated for mlmDeauthReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304117 vos_mem_free(pMlmDeauthReq);
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004118 pMac->lim.limDisassocDeauthCnfReq.pMlmDeauthReq = NULL;
4119 }
4120 return eHAL_STATUS_SUCCESS;
4121end:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304122 vos_mem_copy( (tANI_U8 *) &mlmDeauthCnf.peerMacAddr,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004123 (tANI_U8 *) pMlmDeauthReq->peerMacAddr,
4124 sizeof(tSirMacAddr));
4125 mlmDeauthCnf.deauthTrigger = pMlmDeauthReq->deauthTrigger;
4126 mlmDeauthCnf.aid = pMlmDeauthReq->aid;
4127 mlmDeauthCnf.sessionId = pMlmDeauthReq->sessionId;
4128
4129 // Free up buffer allocated
4130 // for mlmDeauthReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304131 vos_mem_free(pMlmDeauthReq);
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004132
4133 limPostSmeMessage(pMac,
4134 LIM_MLM_DEAUTH_CNF,
4135 (tANI_U32 *) &mlmDeauthCnf);
4136 return eHAL_STATUS_SUCCESS;
4137}
4138
4139eHalStatus limSendDisassocCnf(tpAniSirGlobal pMac)
4140{
4141 tANI_U16 aid;
4142 tpDphHashNode pStaDs;
4143 tLimMlmDisassocCnf mlmDisassocCnf;
4144 tpPESession psessionEntry;
4145 tLimMlmDisassocReq *pMlmDisassocReq;
4146
4147 pMlmDisassocReq = pMac->lim.limDisassocDeauthCnfReq.pMlmDisassocReq;
4148 if (pMlmDisassocReq)
4149 {
4150 if (tx_timer_running(&pMac->lim.limTimers.gLimDisassocAckTimer))
4151 {
4152 limDeactivateAndChangeTimer(pMac, eLIM_DISASSOC_ACK_TIMER);
4153 }
4154
4155 if((psessionEntry = peFindSessionBySessionId(pMac, pMlmDisassocReq->sessionId))== NULL)
4156 {
4157
4158 PELOGE(limLog(pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004159 FL("session does not exist for given sessionId"));)
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004160 mlmDisassocCnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
4161 goto end;
4162 }
4163
4164 pStaDs = dphLookupHashEntry(pMac, pMlmDisassocReq->peerMacAddr, &aid, &psessionEntry->dph.dphHashTable);
4165 if (pStaDs == NULL)
4166 {
Sachin Ahuja2fea3d12014-12-18 17:31:31 +05304167 limLog(pMac, LOGE,
4168 FL("StaDs Null"));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004169 mlmDisassocCnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
4170 goto end;
4171 }
4172
4173 /// Receive path cleanup with dummy packet
4174 if(eSIR_SUCCESS != limCleanupRxPath(pMac, pStaDs, psessionEntry))
4175 {
4176 mlmDisassocCnf.resultCode = eSIR_SME_RESOURCES_UNAVAILABLE;
Sachin Ahuja2fea3d12014-12-18 17:31:31 +05304177 limLog(pMac, LOGE,
4178 FL("CleanupRxPath error"));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004179 goto end;
4180 }
4181
4182#ifdef WLAN_FEATURE_VOWIFI_11R
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08004183 if ( (psessionEntry->limSystemRole == eLIM_STA_ROLE ) &&
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05304184 (pMlmDisassocReq->reasonCode !=
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08004185 eSIR_MAC_DISASSOC_DUE_TO_FTHANDOFF_REASON))
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004186 {
Mukul Sharma0820d0e2014-11-11 19:49:02 +05304187 PELOGE(limLog(pMac, LOG1,
4188 FL("FT Preauth SessionId %d Cleanup"
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004189#ifdef FEATURE_WLAN_ESE
4190 " isESE %d"
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08004191#endif
4192#ifdef FEATURE_WLAN_LFR
4193 " isLFR %d"
4194#endif
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004195 " is11r %d reason %d"),
Mukul Sharma0820d0e2014-11-11 19:49:02 +05304196 psessionEntry->peSessionId,
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004197#ifdef FEATURE_WLAN_ESE
4198 psessionEntry->isESEconnection,
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08004199#endif
4200#ifdef FEATURE_WLAN_LFR
4201 psessionEntry->isFastRoamIniFeatureEnabled,
4202#endif
4203 psessionEntry->is11Rconnection,
4204 pMlmDisassocReq->reasonCode););
Mukul Sharma0820d0e2014-11-11 19:49:02 +05304205 limFTCleanup(pMac);
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004206 }
4207#endif
4208
4209 /// Free up buffer allocated for mlmDisassocReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304210 vos_mem_free(pMlmDisassocReq);
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004211 pMac->lim.limDisassocDeauthCnfReq.pMlmDisassocReq = NULL;
4212 return eHAL_STATUS_SUCCESS;
4213 }
4214 else
4215 {
4216 return eHAL_STATUS_SUCCESS;
4217 }
4218end:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304219 vos_mem_copy( (tANI_U8 *) &mlmDisassocCnf.peerMacAddr,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004220 (tANI_U8 *) pMlmDisassocReq->peerMacAddr,
4221 sizeof(tSirMacAddr));
4222 mlmDisassocCnf.aid = pMlmDisassocReq->aid;
4223 mlmDisassocCnf.disassocTrigger = pMlmDisassocReq->disassocTrigger;
4224
4225 /* Update PE session ID*/
4226 mlmDisassocCnf.sessionId = pMlmDisassocReq->sessionId;
4227
Madan Mohan Koyyalamudib7f5a672012-11-29 11:17:46 -08004228 if(pMlmDisassocReq != NULL)
4229 {
4230 /// Free up buffer allocated for mlmDisassocReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304231 vos_mem_free(pMlmDisassocReq);
Madan Mohan Koyyalamudib7f5a672012-11-29 11:17:46 -08004232 pMac->lim.limDisassocDeauthCnfReq.pMlmDisassocReq = NULL;
4233 }
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004234
4235 limPostSmeMessage(pMac,
4236 LIM_MLM_DISASSOC_CNF,
4237 (tANI_U32 *) &mlmDisassocCnf);
4238 return eHAL_STATUS_SUCCESS;
4239}
4240
Ganesh Kondabattini358fc9b2015-03-11 16:14:25 +05304241eHalStatus limDisassocTxCompleteCnf(tpAniSirGlobal pMac, void *pData)
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004242{
Ganesh Kondabattinib18b3292015-03-16 16:59:26 +05304243 if (pData && IS_FEATURE_SUPPORTED_BY_FW(ENHANCED_TXBD_COMPLETION))
4244 {
4245 tpSirTxBdStatus pTxBdStatus;
4246 pTxBdStatus = (tpSirTxBdStatus) pData;
4247 limLog(pMac, LOG1, FL("txCompleteStatus %u, txBdToken %u"),
4248 pTxBdStatus->txCompleteStatus, pTxBdStatus->txBdToken);
4249 }
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004250 return limSendDisassocCnf(pMac);
4251}
4252
Ganesh Kondabattini358fc9b2015-03-11 16:14:25 +05304253eHalStatus limDeauthTxCompleteCnf(tpAniSirGlobal pMac, void *pData)
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004254{
Ganesh Kondabattinib18b3292015-03-16 16:59:26 +05304255 if (pData && IS_FEATURE_SUPPORTED_BY_FW(ENHANCED_TXBD_COMPLETION))
4256 {
4257 tpSirTxBdStatus pTxBdStatus;
4258 pTxBdStatus = (tpSirTxBdStatus) pData;
4259 limLog(pMac, LOG1, FL("txCompleteStatus %u, txBdToken %u"),
4260 pTxBdStatus->txCompleteStatus, pTxBdStatus->txBdToken);
4261 }
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004262 return limSendDeauthCnf(pMac);
4263}
4264
Jeff Johnson295189b2012-06-20 16:38:30 -07004265/**
4266 * \brief This function is called to send Disassociate frame.
4267 *
4268 *
4269 * \param pMac Pointer to Global MAC structure
4270 *
4271 * \param nReason Indicates the reason that need to be sent in
4272 * Disassociation frame
4273 *
4274 * \param peerMacAddr MAC address of the STA to which Disassociation frame is
4275 * sent
4276 *
4277 *
4278 */
4279
4280void
4281limSendDisassocMgmtFrame(tpAniSirGlobal pMac,
4282 tANI_U16 nReason,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004283 tSirMacAddr peer,
4284 tpPESession psessionEntry,
4285 tANI_BOOLEAN waitForAck)
Jeff Johnson295189b2012-06-20 16:38:30 -07004286{
4287 tDot11fDisassociation frm;
4288 tANI_U8 *pFrame;
4289 tSirRetStatus nSirStatus;
4290 tpSirMacMgmtHdr pMacHdr;
4291 tANI_U32 nBytes, nPayload, nStatus;
4292 void *pPacket;
4293 eHalStatus halstatus;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304294 tANI_U32 txFlag = 0;
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004295 tANI_U32 val = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004296 if(NULL == psessionEntry)
4297 {
4298 return;
4299 }
4300
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304301 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004302
4303 frm.Reason.code = nReason;
4304
4305 nStatus = dot11fGetPackedDisassociationSize( pMac, &frm, &nPayload );
4306 if ( DOT11F_FAILED( nStatus ) )
4307 {
4308 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004309 "or a Disassociation (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004310 nStatus );
4311 // We'll fall back on the worst case scenario:
4312 nPayload = sizeof( tDot11fDisassociation );
4313 }
4314 else if ( DOT11F_WARNED( nStatus ) )
4315 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004316 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07004317 "the packed size for a Disassociation "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004318 "(0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004319 }
4320
4321 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4322
4323 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
4324 ( tANI_U16 )nBytes, ( void** ) &pFrame,
4325 ( void** ) &pPacket );
4326 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4327 {
4328 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Dis"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004329 "association."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07004330 return;
4331 }
4332
4333 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304334 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004335
4336 // Next, we fill out the buffer descriptor:
4337 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
4338 SIR_MAC_MGMT_DISASSOC, peer,psessionEntry->selfMacAddr);
4339 if ( eSIR_SUCCESS != nSirStatus )
4340 {
4341 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004342 "tor for a Disassociation (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004343 nSirStatus );
4344 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
4345 ( void* ) pFrame, ( void* ) pPacket );
4346 return; // just allocated...
4347 }
4348
4349 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
4350
4351 // Prepare the BSSID
4352 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
4353
Chet Lanctot186b5732013-03-18 10:26:30 -07004354#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07004355 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07004356#endif
4357
Jeff Johnson295189b2012-06-20 16:38:30 -07004358 nStatus = dot11fPackDisassociation( pMac, &frm, pFrame +
4359 sizeof(tSirMacMgmtHdr),
4360 nPayload, &nPayload );
4361 if ( DOT11F_FAILED( nStatus ) )
4362 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004363 limLog( pMac, LOGE, FL("Failed to pack a Disassociation (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004364 nStatus );
4365 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
4366 ( void* ) pFrame, ( void* ) pPacket );
4367 return; // allocated!
4368 }
4369 else if ( DOT11F_WARNED( nStatus ) )
4370 {
4371 limLog( pMac, LOGW, FL("There were warnings while packing a D"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004372 "isassociation (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004373 }
4374
Abhishek Singhcd09b562013-12-24 16:02:20 +05304375 limLog( pMac, LOG1, FL("***Sessionid %d Sending Disassociation frame with "
4376 "reason %u and waitForAck %d to "MAC_ADDRESS_STR" ,From "
4377 MAC_ADDRESS_STR), psessionEntry->peSessionId, nReason, waitForAck,
4378 MAC_ADDR_ARRAY(pMacHdr->da),
4379 MAC_ADDR_ARRAY(psessionEntry->selfMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07004380
4381 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07004382 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
4383 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07004384 )
4385 {
4386 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
4387 }
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08004388
Sushant Kaushike8681d22015-04-21 12:08:25 +05304389 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08004390
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304391 if( IS_FW_IN_TX_PATH_FEATURE_ENABLE )
4392 {
4393 /* This frame will be sent on air by firmware,
4394 which will ensure that this frame goes out
4395 even though DEL_STA is sent immediately */
4396 /* Without this for DEL_STA command there is
4397 risk of flushing frame in BTQM queue without
4398 sending on air */
Agarwal Ashisha8e81f52014-04-02 01:59:52 +05304399 limLog( pMac, LOG1, FL("Sending Disassoc Frame over WQ5 to "MAC_ADDRESS_STR
4400 " From " MAC_ADDRESS_STR),MAC_ADDR_ARRAY(pMacHdr->da),
4401 MAC_ADDR_ARRAY(psessionEntry->selfMacAddr));
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304402 txFlag |= HAL_USE_FW_IN_TX_PATH;
4403 }
4404
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004405 if (waitForAck)
Jeff Johnson295189b2012-06-20 16:38:30 -07004406 {
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304407 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
4408 psessionEntry->peSessionId,
4409 pMacHdr->fc.subType));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004410 // Queue Disassociation frame in high priority WQ
4411 /* get the duration from the request */
4412 halstatus = halTxFrameWithTxComplete( pMac, pPacket, ( tANI_U16 ) nBytes,
4413 HAL_TXRX_FRM_802_11_MGMT,
4414 ANI_TXDIR_TODS,
4415 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4416 limTxComplete, pFrame, limDisassocTxCompleteCnf,
Ganesh Kondabattini10e67352015-03-16 17:41:57 +05304417 txFlag,
4418 pMac->lim.txBdToken++);
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304419 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
4420 psessionEntry->peSessionId,
4421 halstatus));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004422 val = SYS_MS_TO_TICKS(LIM_DISASSOC_DEAUTH_ACK_TIMEOUT);
Jeff Johnson295189b2012-06-20 16:38:30 -07004423
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004424 if (tx_timer_change(
4425 &pMac->lim.limTimers.gLimDisassocAckTimer, val, 0)
4426 != TX_SUCCESS)
4427 {
4428 limLog(pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004429 FL("Unable to change Disassoc ack Timer val"));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004430 return;
4431 }
4432 else if(TX_SUCCESS != tx_timer_activate(
4433 &pMac->lim.limTimers.gLimDisassocAckTimer))
4434 {
4435 limLog(pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004436 FL("Unable to activate Disassoc ack Timer"));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004437 limDeactivateAndChangeTimer(pMac, eLIM_DISASSOC_ACK_TIMER);
4438 return;
4439 }
4440 }
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08004441 else
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004442 {
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304443 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
4444 psessionEntry->peSessionId,
4445 pMacHdr->fc.subType));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004446 // Queue Disassociation frame in high priority WQ
4447 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4448 HAL_TXRX_FRM_802_11_MGMT,
4449 ANI_TXDIR_TODS,
4450 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4451 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304452 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
4453 psessionEntry->peSessionId,
4454 halstatus));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004455 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4456 {
4457 limLog( pMac, LOGE, FL("Failed to send Disassociation "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004458 "(%X)!"),
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004459 nSirStatus );
4460 //Pkt will be freed up by the callback
4461 return;
4462 }
4463 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004464} // End limSendDisassocMgmtFrame.
4465
4466/**
4467 * \brief This function is called to send a Deauthenticate frame
4468 *
4469 *
4470 * \param pMac Pointer to global MAC structure
4471 *
4472 * \param nReason Indicates the reason that need to be sent in the
4473 * Deauthenticate frame
4474 *
4475 * \param peeer address of the STA to which the frame is to be sent
4476 *
4477 *
4478 */
4479
4480void
4481limSendDeauthMgmtFrame(tpAniSirGlobal pMac,
4482 tANI_U16 nReason,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004483 tSirMacAddr peer,
4484 tpPESession psessionEntry,
4485 tANI_BOOLEAN waitForAck)
Jeff Johnson295189b2012-06-20 16:38:30 -07004486{
4487 tDot11fDeAuth frm;
4488 tANI_U8 *pFrame;
4489 tSirRetStatus nSirStatus;
4490 tpSirMacMgmtHdr pMacHdr;
4491 tANI_U32 nBytes, nPayload, nStatus;
4492 void *pPacket;
4493 eHalStatus halstatus;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304494 tANI_U32 txFlag = 0;
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004495 tANI_U32 val = 0;
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08004496#ifdef FEATURE_WLAN_TDLS
4497 tANI_U16 aid;
4498 tpDphHashNode pStaDs;
4499#endif
4500
Jeff Johnson295189b2012-06-20 16:38:30 -07004501 if(NULL == psessionEntry)
4502 {
4503 return;
4504 }
4505
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304506 vos_mem_set( ( tANI_U8* ) &frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004507
4508 frm.Reason.code = nReason;
4509
4510 nStatus = dot11fGetPackedDeAuthSize( pMac, &frm, &nPayload );
4511 if ( DOT11F_FAILED( nStatus ) )
4512 {
4513 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004514 "or a De-Authentication (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004515 nStatus );
4516 // We'll fall back on the worst case scenario:
4517 nPayload = sizeof( tDot11fDeAuth );
4518 }
4519 else if ( DOT11F_WARNED( nStatus ) )
4520 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004521 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07004522 "the packed size for a De-Authentication "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004523 "(0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004524 }
4525
4526 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4527
4528 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
4529 ( tANI_U16 )nBytes, ( void** ) &pFrame,
4530 ( void** ) &pPacket );
4531 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4532 {
4533 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a De-"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004534 "Authentication."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07004535 return;
4536 }
4537
4538 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304539 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004540
4541 // Next, we fill out the buffer descriptor:
4542 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
4543 SIR_MAC_MGMT_DEAUTH, peer,psessionEntry->selfMacAddr);
4544 if ( eSIR_SUCCESS != nSirStatus )
4545 {
4546 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004547 "tor for a De-Authentication (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004548 nSirStatus );
4549 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
4550 ( void* ) pFrame, ( void* ) pPacket );
4551 return; // just allocated...
4552 }
4553
4554 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
4555
4556 // Prepare the BSSID
4557 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
4558
Chet Lanctot186b5732013-03-18 10:26:30 -07004559#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07004560 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07004561#endif
4562
Jeff Johnson295189b2012-06-20 16:38:30 -07004563 nStatus = dot11fPackDeAuth( pMac, &frm, pFrame +
4564 sizeof(tSirMacMgmtHdr),
4565 nPayload, &nPayload );
4566 if ( DOT11F_FAILED( nStatus ) )
4567 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004568 limLog( pMac, LOGE, FL("Failed to pack a DeAuthentication (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004569 nStatus );
4570 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
4571 ( void* ) pFrame, ( void* ) pPacket );
4572 return;
4573 }
4574 else if ( DOT11F_WARNED( nStatus ) )
4575 {
4576 limLog( pMac, LOGW, FL("There were warnings while packing a D"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004577 "e-Authentication (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004578 }
Abhishek Singhcd09b562013-12-24 16:02:20 +05304579 limLog( pMac, LOG1, FL("***Sessionid %d Sending Deauth frame with "
4580 "reason %u and waitForAck %d to "MAC_ADDRESS_STR" ,From "
4581 MAC_ADDRESS_STR), psessionEntry->peSessionId, nReason, waitForAck,
4582 MAC_ADDR_ARRAY(pMacHdr->da),
4583 MAC_ADDR_ARRAY(psessionEntry->selfMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07004584
4585 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07004586 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
4587 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07004588 )
4589 {
4590 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
4591 }
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08004592
Sushant Kaushike8681d22015-04-21 12:08:25 +05304593 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08004594
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304595 if( IS_FW_IN_TX_PATH_FEATURE_ENABLE )
4596 {
4597 /* This frame will be sent on air by firmware,
4598 which will ensure that this frame goes out
4599 even though DEL_STA is sent immediately */
4600 /* Without this for DEL_STA command there is
4601 risk of flushing frame in BTQM queue without
4602 sending on air */
Agarwal Ashisha8e81f52014-04-02 01:59:52 +05304603 limLog( pMac, LOG1, FL("Sending Deauth Frame over WQ5 to "MAC_ADDRESS_STR
4604 " From " MAC_ADDRESS_STR),MAC_ADDR_ARRAY(pMacHdr->da),
4605 MAC_ADDR_ARRAY(psessionEntry->selfMacAddr));
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304606 txFlag |= HAL_USE_FW_IN_TX_PATH;
4607 }
4608
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08004609#ifdef FEATURE_WLAN_TDLS
4610 pStaDs = dphLookupHashEntry(pMac, peer, &aid, &psessionEntry->dph.dphHashTable);
4611#endif
4612
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004613 if (waitForAck)
Jeff Johnson295189b2012-06-20 16:38:30 -07004614 {
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304615 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
4616 psessionEntry->peSessionId,
4617 pMacHdr->fc.subType));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004618 // Queue Disassociation frame in high priority WQ
4619 halstatus = halTxFrameWithTxComplete( pMac, pPacket, ( tANI_U16 ) nBytes,
4620 HAL_TXRX_FRM_802_11_MGMT,
4621 ANI_TXDIR_TODS,
4622 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
Ganesh Kondabattini10e67352015-03-16 17:41:57 +05304623 limTxComplete, pFrame, limDeauthTxCompleteCnf, txFlag,
4624 pMac->lim.txBdToken++);
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304625 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
4626 psessionEntry->peSessionId,
4627 halstatus));
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304628 if (!HAL_STATUS_SUCCESS(halstatus))
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004629 {
4630 limLog( pMac, LOGE, FL("Failed to send De-Authentication "
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304631 "(%X)!"),
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004632 nSirStatus );
Gopichand Nakkala4261ea52012-12-31 16:43:00 -08004633 //Pkt will be freed up by the callback limTxComplete
4634
4635 /*Call limProcessDeauthAckTimeout which will send
4636 * DeauthCnf for this frame
4637 */
4638 limProcessDeauthAckTimeout(pMac);
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004639 return;
4640 }
4641
4642 val = SYS_MS_TO_TICKS(LIM_DISASSOC_DEAUTH_ACK_TIMEOUT);
4643
4644 if (tx_timer_change(
4645 &pMac->lim.limTimers.gLimDeauthAckTimer, val, 0)
4646 != TX_SUCCESS)
4647 {
4648 limLog(pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004649 FL("Unable to change Deauth ack Timer val"));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004650 return;
4651 }
4652 else if(TX_SUCCESS != tx_timer_activate(
4653 &pMac->lim.limTimers.gLimDeauthAckTimer))
4654 {
4655 limLog(pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004656 FL("Unable to activate Deauth ack Timer"));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004657 limDeactivateAndChangeTimer(pMac, eLIM_DEAUTH_ACK_TIMER);
4658 return;
4659 }
4660 }
4661 else
4662 {
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304663 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
4664 psessionEntry->peSessionId,
4665 pMacHdr->fc.subType));
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08004666#ifdef FEATURE_WLAN_TDLS
4667 if ((NULL != pStaDs) && (STA_ENTRY_TDLS_PEER == pStaDs->staType))
4668 {
4669 // Queue Disassociation frame in high priority WQ
4670 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004671 HAL_TXRX_FRM_802_11_MGMT,
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08004672 ANI_TXDIR_IBSS,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004673 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4674 limTxComplete, pFrame, txFlag );
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08004675 }
4676 else
4677 {
4678#endif
4679 // Queue Disassociation frame in high priority WQ
4680 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4681 HAL_TXRX_FRM_802_11_MGMT,
4682 ANI_TXDIR_TODS,
4683 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4684 limTxComplete, pFrame, txFlag );
4685#ifdef FEATURE_WLAN_TDLS
4686 }
4687#endif
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304688 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
4689 psessionEntry->peSessionId,
4690 halstatus));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004691 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4692 {
4693 limLog( pMac, LOGE, FL("Failed to send De-Authentication "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004694 "(%X)!"),
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004695 nSirStatus );
4696 //Pkt will be freed up by the callback
4697 return;
4698 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004699 }
4700
4701} // End limSendDeauthMgmtFrame.
4702
4703
4704#ifdef ANI_SUPPORT_11H
4705/**
4706 * \brief Send a Measurement Report Action frame
4707 *
4708 *
4709 * \param pMac Pointer to the global MAC structure
4710 *
4711 * \param pMeasReqFrame Address of a tSirMacMeasReqActionFrame
4712 *
4713 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
4714 *
4715 *
4716 */
4717
4718tSirRetStatus
4719limSendMeasReportFrame(tpAniSirGlobal pMac,
4720 tpSirMacMeasReqActionFrame pMeasReqFrame,
4721 tSirMacAddr peer)
4722{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304723 tDot11fMeasurementReport frm;
4724 tANI_U8 *pFrame;
4725 tSirRetStatus nSirStatus;
4726 tpSirMacMgmtHdr pMacHdr;
4727 tANI_U32 nBytes, nPayload, nStatus, nCfg;
4728 void *pPacket;
4729 eHalStatus halstatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07004730
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304731 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004732
4733 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
4734 frm.Action.action = SIR_MAC_ACTION_MEASURE_REPORT_ID;
4735 frm.DialogToken.token = pMeasReqFrame->actionHeader.dialogToken;
4736
4737 switch ( pMeasReqFrame->measReqIE.measType )
4738 {
4739 case SIR_MAC_BASIC_MEASUREMENT_TYPE:
4740 nSirStatus =
4741 PopulateDot11fMeasurementReport0( pMac, pMeasReqFrame,
4742 &frm.MeasurementReport );
4743 break;
4744 case SIR_MAC_CCA_MEASUREMENT_TYPE:
4745 nSirStatus =
4746 PopulateDot11fMeasurementReport1( pMac, pMeasReqFrame,
4747 &frm.MeasurementReport );
4748 break;
4749 case SIR_MAC_RPI_MEASUREMENT_TYPE:
4750 nSirStatus =
4751 PopulateDot11fMeasurementReport2( pMac, pMeasReqFrame,
4752 &frm.MeasurementReport );
4753 break;
4754 default:
4755 limLog( pMac, LOGE, FL("Unknown measurement type %d in limSen"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004756 "dMeasReportFrame."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004757 pMeasReqFrame->measReqIE.measType );
4758 return eSIR_FAILURE;
4759 }
4760
4761 if ( eSIR_SUCCESS != nSirStatus ) return eSIR_FAILURE;
4762
4763 nStatus = dot11fGetPackedMeasurementReportSize( pMac, &frm, &nPayload );
4764 if ( DOT11F_FAILED( nStatus ) )
4765 {
4766 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004767 "or a Measurement Report (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004768 nStatus );
4769 // We'll fall back on the worst case scenario:
4770 nPayload = sizeof( tDot11fMeasurementReport );
4771 }
4772 else if ( DOT11F_WARNED( nStatus ) )
4773 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004774 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07004775 "the packed size for a Measurement Rep"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004776 "ort (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004777 }
4778
4779 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4780
4781 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
4782 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4783 {
4784 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a De-"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004785 "Authentication."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07004786 return eSIR_FAILURE;
4787 }
4788
4789 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304790 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004791
4792 // Next, we fill out the buffer descriptor:
4793 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
4794 SIR_MAC_MGMT_ACTION, peer);
4795 if ( eSIR_SUCCESS != nSirStatus )
4796 {
4797 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004798 "tor for a Measurement Report (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004799 nSirStatus );
4800 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4801 return eSIR_FAILURE; // just allocated...
4802 }
4803
4804 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
4805
4806 nCfg = 6;
4807 nSirStatus = wlan_cfgGetStr( pMac, WNI_CFG_BSSID, pMacHdr->bssId, &nCfg );
4808 if ( eSIR_SUCCESS != nSirStatus )
4809 {
4810 limLog( pMac, LOGE, FL("Failed to retrieve WNI_CFG_BSSID from"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004811 " CFG (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004812 nSirStatus );
4813 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4814 return eSIR_FAILURE; // just allocated...
4815 }
4816
Chet Lanctot186b5732013-03-18 10:26:30 -07004817#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07004818 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07004819#endif
4820
Jeff Johnson295189b2012-06-20 16:38:30 -07004821 nStatus = dot11fPackMeasurementReport( pMac, &frm, pFrame +
4822 sizeof(tSirMacMgmtHdr),
4823 nPayload, &nPayload );
4824 if ( DOT11F_FAILED( nStatus ) )
4825 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004826 limLog( pMac, LOGE, FL("Failed to pack a Measurement Report (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004827 nStatus );
4828 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4829 return eSIR_FAILURE; // allocated!
4830 }
4831 else if ( DOT11F_WARNED( nStatus ) )
4832 {
4833 limLog( pMac, LOGW, FL("There were warnings while packing a M"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004834 "easurement Report (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004835 }
4836
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304837 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
4838 ((psessionEntry)? psessionEntry->peSessionId : NO_SESSION),
4839 pMacHdr->fc.subType));
Jeff Johnson295189b2012-06-20 16:38:30 -07004840 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4841 HAL_TXRX_FRM_802_11_MGMT,
4842 ANI_TXDIR_TODS,
4843 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4844 limTxComplete, pFrame, 0 );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304845 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
4846 ((psessionEntry)? psessionEntry->peSessionId : NO_SESSION),
4847 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07004848 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4849 {
4850 limLog( pMac, LOGE, FL("Failed to send a Measurement Report "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004851 "(%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07004852 nSirStatus );
4853 //Pkt will be freed up by the callback
4854 return eSIR_FAILURE; // just allocated...
4855 }
4856
4857 return eSIR_SUCCESS;
4858
4859} // End limSendMeasReportFrame.
4860
4861
4862/**
4863 * \brief Send a TPC Request Action frame
4864 *
4865 *
4866 * \param pMac Pointer to the global MAC datastructure
4867 *
4868 * \param peer MAC address to which the frame should be sent
4869 *
4870 *
4871 */
4872
4873void
4874limSendTpcRequestFrame(tpAniSirGlobal pMac,
4875 tSirMacAddr peer)
4876{
4877 tDot11fTPCRequest frm;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304878 tANI_U8 *pFrame;
Jeff Johnson295189b2012-06-20 16:38:30 -07004879 tSirRetStatus nSirStatus;
4880 tpSirMacMgmtHdr pMacHdr;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304881 tANI_U32 nBytes, nPayload, nStatus, nCfg;
4882 void *pPacket;
4883 eHalStatus halstatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07004884
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304885 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004886
4887 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
4888 frm.Action.action = SIR_MAC_ACTION_TPC_REQUEST_ID;
4889 frm.DialogToken.token = 1;
4890 frm.TPCRequest.present = 1;
4891
4892 nStatus = dot11fGetPackedTPCRequestSize( pMac, &frm, &nPayload );
4893 if ( DOT11F_FAILED( nStatus ) )
4894 {
4895 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004896 "or a TPC Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004897 nStatus );
4898 // We'll fall back on the worst case scenario:
4899 nPayload = sizeof( tDot11fTPCRequest );
4900 }
4901 else if ( DOT11F_WARNED( nStatus ) )
4902 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004903 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07004904 "the packed size for a TPC Request (0x"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004905 "%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004906 }
4907
4908 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4909
4910 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
4911 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4912 {
4913 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a TPC"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004914 " Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07004915 return;
4916 }
4917
4918 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304919 vos_mem_set(pFrame, nBytes,0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004920
4921 // Next, we fill out the buffer descriptor:
4922 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
4923 SIR_MAC_MGMT_ACTION, peer);
4924 if ( eSIR_SUCCESS != nSirStatus )
4925 {
4926 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004927 "tor for a TPC Request (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004928 nSirStatus );
4929 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4930 return; // just allocated...
4931 }
4932
4933 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
4934
4935 nCfg = 6;
4936 nSirStatus = wlan_cfgGetStr( pMac, WNI_CFG_BSSID, pMacHdr->bssId, &nCfg );
4937 if ( eSIR_SUCCESS != nSirStatus )
4938 {
4939 limLog( pMac, LOGE, FL("Failed to retrieve WNI_CFG_BSSID from"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004940 " CFG (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004941 nSirStatus );
4942 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4943 return; // just allocated...
4944 }
4945
Chet Lanctot186b5732013-03-18 10:26:30 -07004946#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07004947 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07004948#endif
4949
Jeff Johnson295189b2012-06-20 16:38:30 -07004950 nStatus = dot11fPackTPCRequest( pMac, &frm, pFrame +
4951 sizeof(tSirMacMgmtHdr),
4952 nPayload, &nPayload );
4953 if ( DOT11F_FAILED( nStatus ) )
4954 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004955 limLog( pMac, LOGE, FL("Failed to pack a TPC Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004956 nStatus );
4957 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4958 return; // allocated!
4959 }
4960 else if ( DOT11F_WARNED( nStatus ) )
4961 {
4962 limLog( pMac, LOGW, FL("There were warnings while packing a T"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004963 "PC Request (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004964 }
4965
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304966 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
4967 ((psessionEntry)? psessionEntry->peSessionId : NO_SESSION),
4968 pMacHdr->fc.subType));
Jeff Johnson295189b2012-06-20 16:38:30 -07004969 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4970 HAL_TXRX_FRM_802_11_MGMT,
4971 ANI_TXDIR_TODS,
4972 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4973 limTxComplete, pFrame, 0 );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304974 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
4975 ((psessionEntry)? psessionEntry->peSessionId : NO_SESSION),
4976 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07004977 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4978 {
4979 limLog( pMac, LOGE, FL("Failed to send a TPC Request "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004980 "(%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07004981 nSirStatus );
4982 //Pkt will be freed up by the callback
4983 return;
4984 }
4985
4986} // End limSendTpcRequestFrame.
4987
4988
4989/**
4990 * \brief Send a TPC Report Action frame
4991 *
4992 *
4993 * \param pMac Pointer to the global MAC datastructure
4994 *
4995 * \param pTpcReqFrame Pointer to the received TPC Request
4996 *
4997 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
4998 *
4999 *
5000 */
5001
5002tSirRetStatus
5003limSendTpcReportFrame(tpAniSirGlobal pMac,
5004 tpSirMacTpcReqActionFrame pTpcReqFrame,
5005 tSirMacAddr peer)
5006{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05305007 tDot11fTPCReport frm;
5008 tANI_U8 *pFrame;
5009 tSirRetStatus nSirStatus;
5010 tpSirMacMgmtHdr pMacHdr;
5011 tANI_U32 nBytes, nPayload, nStatus, nCfg;
5012 void *pPacket;
5013 eHalStatus halstatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07005014
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305015 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005016
5017 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
5018 frm.Action.action = SIR_MAC_ACTION_TPC_REPORT_ID;
5019 frm.DialogToken.token = pTpcReqFrame->actionHeader.dialogToken;
5020
5021 // FramesToDo: On the Gen4_TVM branch, there was a comment:
5022 // "misplaced this function, need to replace:
5023 // txPower = halGetRateToPwrValue(pMac, staid,
5024 // pMac->lim.gLimCurrentChannelId, 0);
5025 frm.TPCReport.tx_power = 0;
5026 frm.TPCReport.link_margin = 0;
5027 frm.TPCReport.present = 1;
5028
5029 nStatus = dot11fGetPackedTPCReportSize( pMac, &frm, &nPayload );
5030 if ( DOT11F_FAILED( nStatus ) )
5031 {
5032 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005033 "or a TPC Report (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005034 nStatus );
5035 // We'll fall back on the worst case scenario:
5036 nPayload = sizeof( tDot11fTPCReport );
5037 }
5038 else if ( DOT11F_WARNED( nStatus ) )
5039 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005040 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07005041 "the packed size for a TPC Report (0x"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005042 "%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07005043 }
5044
5045 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
5046
5047 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
5048 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
5049 {
5050 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a TPC"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005051 " Report."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07005052 return eSIR_FAILURE;
5053 }
5054
5055 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305056 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005057
5058 // Next, we fill out the buffer descriptor:
5059 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
5060 SIR_MAC_MGMT_ACTION, peer);
5061 if ( eSIR_SUCCESS != nSirStatus )
5062 {
5063 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005064 "tor for a TPC Report (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005065 nSirStatus );
5066 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
5067 return eSIR_FAILURE; // just allocated...
5068 }
5069
5070 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
5071
5072 nCfg = 6;
5073 nSirStatus = wlan_cfgGetStr( pMac, WNI_CFG_BSSID, pMacHdr->bssId, &nCfg );
5074 if ( eSIR_SUCCESS != nSirStatus )
5075 {
5076 limLog( pMac, LOGE, FL("Failed to retrieve WNI_CFG_BSSID from"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005077 " CFG (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005078 nSirStatus );
5079 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
5080 return eSIR_FAILURE; // just allocated...
5081 }
5082
Chet Lanctot186b5732013-03-18 10:26:30 -07005083#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07005084 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07005085#endif
5086
Jeff Johnson295189b2012-06-20 16:38:30 -07005087 nStatus = dot11fPackTPCReport( pMac, &frm, pFrame +
5088 sizeof(tSirMacMgmtHdr),
5089 nPayload, &nPayload );
5090 if ( DOT11F_FAILED( nStatus ) )
5091 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005092 limLog( pMac, LOGE, FL("Failed to pack a TPC Report (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005093 nStatus );
5094 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
5095 return eSIR_FAILURE; // allocated!
5096 }
5097 else if ( DOT11F_WARNED( nStatus ) )
5098 {
5099 limLog( pMac, LOGW, FL("There were warnings while packing a T"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005100 "PC Report (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07005101 }
5102
5103
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05305104 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
5105 ((psessionEntry)? psessionEntry->peSessionId : NO_SESSION),
5106 pMacHdr->fc.subType));
Jeff Johnson295189b2012-06-20 16:38:30 -07005107 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
5108 HAL_TXRX_FRM_802_11_MGMT,
5109 ANI_TXDIR_TODS,
5110 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
5111 limTxComplete, pFrame, 0 );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05305112 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
5113 ((psessionEntry)? psessionEntry->peSessionId : NO_SESSION),
5114 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07005115 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
5116 {
5117 limLog( pMac, LOGE, FL("Failed to send a TPC Report "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005118 "(%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07005119 nSirStatus );
5120 //Pkt will be freed up by the callback
5121 return eSIR_FAILURE; // just allocated...
5122 }
5123
5124 return eSIR_SUCCESS;
5125
5126} // End limSendTpcReportFrame.
5127#endif //ANI_SUPPORT_11H
5128
5129
Jeff Johnson295189b2012-06-20 16:38:30 -07005130/**
5131 * \brief Send a Channel Switch Announcement
5132 *
5133 *
5134 * \param pMac Pointer to the global MAC datastructure
5135 *
5136 * \param peer MAC address to which this frame will be sent
5137 *
5138 * \param nMode
5139 *
5140 * \param nNewChannel
5141 *
5142 * \param nCount
5143 *
5144 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
5145 *
5146 *
5147 */
5148
5149tSirRetStatus
5150limSendChannelSwitchMgmtFrame(tpAniSirGlobal pMac,
5151 tSirMacAddr peer,
Jeff Johnsone7245742012-09-05 17:12:55 -07005152 tANI_U8 nMode,
5153 tANI_U8 nNewChannel,
5154 tANI_U8 nCount,
5155 tpPESession psessionEntry )
Jeff Johnson295189b2012-06-20 16:38:30 -07005156{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05305157 tDot11fChannelSwitch frm;
5158 tANI_U8 *pFrame;
5159 tSirRetStatus nSirStatus;
5160 tpSirMacMgmtHdr pMacHdr;
5161 tANI_U32 nBytes, nPayload, nStatus;//, nCfg;
5162 void *pPacket;
5163 eHalStatus halstatus;
5164 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005165
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305166 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005167
5168 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
5169 frm.Action.action = SIR_MAC_ACTION_CHANNEL_SWITCH_ID;
5170 frm.ChanSwitchAnn.switchMode = nMode;
5171 frm.ChanSwitchAnn.newChannel = nNewChannel;
5172 frm.ChanSwitchAnn.switchCount = nCount;
5173 frm.ChanSwitchAnn.present = 1;
5174
5175 nStatus = dot11fGetPackedChannelSwitchSize( pMac, &frm, &nPayload );
5176 if ( DOT11F_FAILED( nStatus ) )
5177 {
5178 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005179 "or a Channel Switch (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005180 nStatus );
5181 // We'll fall back on the worst case scenario:
5182 nPayload = sizeof( tDot11fChannelSwitch );
5183 }
5184 else if ( DOT11F_WARNED( nStatus ) )
5185 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005186 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07005187 "the packed size for a Channel Switch (0x"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005188 "%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07005189 }
5190
5191 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
5192
5193 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
5194 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
5195 {
5196 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a TPC"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005197 " Report."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07005198 return eSIR_FAILURE;
5199 }
5200
5201 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305202 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005203
5204 // Next, we fill out the buffer descriptor:
5205 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
Jeff Johnsone7245742012-09-05 17:12:55 -07005206 SIR_MAC_MGMT_ACTION, peer, psessionEntry->selfMacAddr);
5207 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305208 vos_mem_copy( (tANI_U8 *) pMacHdr->bssId,
5209 (tANI_U8 *) psessionEntry->bssId,
5210 sizeof( tSirMacAddr ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005211 if ( eSIR_SUCCESS != nSirStatus )
5212 {
5213 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005214 "tor for a Channel Switch (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005215 nSirStatus );
5216 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
5217 return eSIR_FAILURE; // just allocated...
5218 }
5219
Jeff Johnsone7245742012-09-05 17:12:55 -07005220#if 0
Jeff Johnson295189b2012-06-20 16:38:30 -07005221 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
5222
5223 nCfg = 6;
5224 nSirStatus = wlan_cfgGetStr( pMac, WNI_CFG_BSSID, pMacHdr->bssId, &nCfg );
5225 if ( eSIR_SUCCESS != nSirStatus )
5226 {
5227 limLog( pMac, LOGE, FL("Failed to retrieve WNI_CFG_BSSID from"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005228 " CFG (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005229 nSirStatus );
5230 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
5231 return eSIR_FAILURE; // just allocated...
5232 }
Jeff Johnsone7245742012-09-05 17:12:55 -07005233#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07005234
5235#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07005236 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07005237#endif
5238
Jeff Johnson295189b2012-06-20 16:38:30 -07005239 nStatus = dot11fPackChannelSwitch( pMac, &frm, pFrame +
5240 sizeof(tSirMacMgmtHdr),
5241 nPayload, &nPayload );
5242 if ( DOT11F_FAILED( nStatus ) )
5243 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005244 limLog( pMac, LOGE, FL("Failed to pack a Channel Switch (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005245 nStatus );
5246 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
5247 return eSIR_FAILURE; // allocated!
5248 }
5249 else if ( DOT11F_WARNED( nStatus ) )
5250 {
5251 limLog( pMac, LOGW, FL("There were warnings while packing a C"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005252 "hannel Switch (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07005253 }
5254
Jeff Johnsone7245742012-09-05 17:12:55 -07005255 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnsone7245742012-09-05 17:12:55 -07005256 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
5257 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnsone7245742012-09-05 17:12:55 -07005258 )
5259 {
5260 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
5261 }
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05305262
5263 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
5264 psessionEntry->peSessionId,
5265 pMacHdr->fc.subType));
Jeff Johnson295189b2012-06-20 16:38:30 -07005266 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
5267 HAL_TXRX_FRM_802_11_MGMT,
5268 ANI_TXDIR_TODS,
5269 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
Jeff Johnsone7245742012-09-05 17:12:55 -07005270 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05305271 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
5272 psessionEntry->peSessionId,
5273 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07005274 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
5275 {
5276 limLog( pMac, LOGE, FL("Failed to send a Channel Switch "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005277 "(%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07005278 nSirStatus );
5279 //Pkt will be freed up by the callback
5280 return eSIR_FAILURE;
5281 }
5282
5283 return eSIR_SUCCESS;
5284
5285} // End limSendChannelSwitchMgmtFrame.
5286
Jeff Johnson295189b2012-06-20 16:38:30 -07005287
5288
Mohit Khanna4a70d262012-09-11 16:30:12 -07005289#ifdef WLAN_FEATURE_11AC
5290tSirRetStatus
5291limSendVHTOpmodeNotificationFrame(tpAniSirGlobal pMac,
5292 tSirMacAddr peer,
5293 tANI_U8 nMode,
5294 tpPESession psessionEntry )
5295{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05305296 tDot11fOperatingMode frm;
5297 tANI_U8 *pFrame;
5298 tSirRetStatus nSirStatus;
5299 tpSirMacMgmtHdr pMacHdr;
5300 tANI_U32 nBytes, nPayload = 0, nStatus;//, nCfg;
5301 void *pPacket;
5302 eHalStatus halstatus;
5303 tANI_U32 txFlag = 0;
Mohit Khanna4a70d262012-09-11 16:30:12 -07005304
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305305 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Mohit Khanna4a70d262012-09-11 16:30:12 -07005306
5307 frm.Category.category = SIR_MAC_ACTION_VHT;
5308 frm.Action.action = SIR_MAC_VHT_OPMODE_NOTIFICATION;
5309 frm.OperatingMode.chanWidth = nMode;
5310 frm.OperatingMode.rxNSS = 0;
5311 frm.OperatingMode.rxNSSType = 0;
5312
5313 nStatus = dot11fGetPackedOperatingModeSize( pMac, &frm, &nPayload );
5314 if ( DOT11F_FAILED( nStatus ) )
5315 {
5316 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005317 "or a Operating Mode (0x%08x)."),
Mohit Khanna4a70d262012-09-11 16:30:12 -07005318 nStatus );
5319 // We'll fall back on the worst case scenario:
5320 nPayload = sizeof( tDot11fOperatingMode);
5321 }
5322 else if ( DOT11F_WARNED( nStatus ) )
5323 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005324 limLog( pMac, LOGW, FL("There were warnings while calculating "
Mohit Khanna4a70d262012-09-11 16:30:12 -07005325 "the packed size for a Operating Mode (0x"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005326 "%08x)."), nStatus );
Mohit Khanna4a70d262012-09-11 16:30:12 -07005327 }
5328
5329 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
5330
5331 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
5332 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
5333 {
5334 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Operating Mode"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005335 " Report."), nBytes );
Mohit Khanna4a70d262012-09-11 16:30:12 -07005336 return eSIR_FAILURE;
5337 }
5338
5339 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305340 vos_mem_set( pFrame, nBytes, 0 );
Mohit Khanna4a70d262012-09-11 16:30:12 -07005341
5342
5343 // Next, we fill out the buffer descriptor:
5344 if(psessionEntry->pePersona == VOS_STA_SAP_MODE) {
5345 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
5346 SIR_MAC_MGMT_ACTION, peer, psessionEntry->selfMacAddr);
5347 } else
5348 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
5349 SIR_MAC_MGMT_ACTION, psessionEntry->bssId, psessionEntry->selfMacAddr);
5350 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305351 vos_mem_copy( (tANI_U8 *) pMacHdr->bssId,
5352 (tANI_U8 *) psessionEntry->bssId,
5353 sizeof( tSirMacAddr ));
Mohit Khanna4a70d262012-09-11 16:30:12 -07005354 if ( eSIR_SUCCESS != nSirStatus )
5355 {
5356 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005357 "tor for a Operating Mode (%d)."),
Mohit Khanna4a70d262012-09-11 16:30:12 -07005358 nSirStatus );
5359 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
5360 return eSIR_FAILURE; // just allocated...
5361 }
5362 nStatus = dot11fPackOperatingMode( pMac, &frm, pFrame +
5363 sizeof(tSirMacMgmtHdr),
5364 nPayload, &nPayload );
5365 if ( DOT11F_FAILED( nStatus ) )
5366 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005367 limLog( pMac, LOGE, FL("Failed to pack a Operating Mode (0x%08x)."),
Mohit Khanna4a70d262012-09-11 16:30:12 -07005368 nStatus );
5369 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
5370 return eSIR_FAILURE; // allocated!
5371 }
5372 else if ( DOT11F_WARNED( nStatus ) )
5373 {
5374 limLog( pMac, LOGW, FL("There were warnings while packing a Operating Mode"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005375 " (0x%08x)."), nStatus );
Mohit Khanna4a70d262012-09-11 16:30:12 -07005376 }
5377 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Mohit Khanna4a70d262012-09-11 16:30:12 -07005378 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
5379 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Mohit Khanna4a70d262012-09-11 16:30:12 -07005380 )
5381 {
5382 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
5383 }
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05305384
5385 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
5386 psessionEntry->peSessionId,
5387 pMacHdr->fc.subType));
Mohit Khanna4a70d262012-09-11 16:30:12 -07005388 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
5389 HAL_TXRX_FRM_802_11_MGMT,
5390 ANI_TXDIR_TODS,
5391 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
5392 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05305393 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
5394 psessionEntry->peSessionId,
5395 halstatus));
Mohit Khanna4a70d262012-09-11 16:30:12 -07005396 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
5397 {
5398 limLog( pMac, LOGE, FL("Failed to send a Channel Switch "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005399 "(%X)!"),
Mohit Khanna4a70d262012-09-11 16:30:12 -07005400 nSirStatus );
5401 //Pkt will be freed up by the callback
5402 return eSIR_FAILURE;
5403 }
5404
5405 return eSIR_SUCCESS;
5406}
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005407
5408/**
5409 * \brief Send a VHT Channel Switch Announcement
5410 *
5411 *
5412 * \param pMac Pointer to the global MAC datastructure
5413 *
5414 * \param peer MAC address to which this frame will be sent
5415 *
5416 * \param nChanWidth
5417 *
5418 * \param nNewChannel
5419 *
5420 *
5421 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
5422 *
5423 *
5424 */
5425
5426tSirRetStatus
5427limSendVHTChannelSwitchMgmtFrame(tpAniSirGlobal pMac,
5428 tSirMacAddr peer,
5429 tANI_U8 nChanWidth,
5430 tANI_U8 nNewChannel,
5431 tANI_U8 ncbMode,
5432 tpPESession psessionEntry )
5433{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05305434 tDot11fChannelSwitch frm;
5435 tANI_U8 *pFrame;
5436 tSirRetStatus nSirStatus;
5437 tpSirMacMgmtHdr pMacHdr;
5438 tANI_U32 nBytes, nPayload, nStatus;//, nCfg;
5439 void *pPacket;
5440 eHalStatus halstatus;
5441 tANI_U32 txFlag = 0;
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005442
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305443 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005444
5445
5446 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
5447 frm.Action.action = SIR_MAC_ACTION_CHANNEL_SWITCH_ID;
5448 frm.ChanSwitchAnn.switchMode = 1;
5449 frm.ChanSwitchAnn.newChannel = nNewChannel;
5450 frm.ChanSwitchAnn.switchCount = 1;
5451 frm.ExtChanSwitchAnn.secondaryChannelOffset = limGetHTCBState(ncbMode);
5452 frm.ExtChanSwitchAnn.present = 1;
5453 frm.WiderBWChanSwitchAnn.newChanWidth = nChanWidth;
5454 frm.WiderBWChanSwitchAnn.newCenterChanFreq0 = limGetCenterChannel(pMac,nNewChannel,ncbMode,nChanWidth);
5455 frm.WiderBWChanSwitchAnn.newCenterChanFreq1 = 0;
5456 frm.ChanSwitchAnn.present = 1;
5457 frm.WiderBWChanSwitchAnn.present = 1;
5458
5459 nStatus = dot11fGetPackedChannelSwitchSize( pMac, &frm, &nPayload );
5460 if ( DOT11F_FAILED( nStatus ) )
5461 {
5462 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005463 "or a Channel Switch (0x%08x)."),
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005464 nStatus );
5465 // We'll fall back on the worst case scenario:
5466 nPayload = sizeof( tDot11fChannelSwitch );
5467 }
5468 else if ( DOT11F_WARNED( nStatus ) )
5469 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005470 limLog( pMac, LOGW, FL("There were warnings while calculating "
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005471 "the packed size for a Channel Switch (0x"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005472 "%08x)."), nStatus );
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005473 }
5474
5475 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
5476
5477 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
5478 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
5479 {
5480 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a TPC"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005481 " Report."), nBytes );
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005482 return eSIR_FAILURE;
5483 }
5484 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305485 vos_mem_set( pFrame, nBytes, 0 );
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005486
5487 // Next, we fill out the buffer descriptor:
5488 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
5489 SIR_MAC_MGMT_ACTION, peer, psessionEntry->selfMacAddr);
5490 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305491 vos_mem_copy( (tANI_U8 *) pMacHdr->bssId,
5492 (tANI_U8 *) psessionEntry->bssId,
5493 sizeof( tSirMacAddr ));
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005494 if ( eSIR_SUCCESS != nSirStatus )
5495 {
5496 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005497 "tor for a Channel Switch (%d)."),
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005498 nSirStatus );
5499 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
5500 return eSIR_FAILURE; // just allocated...
5501 }
5502 nStatus = dot11fPackChannelSwitch( pMac, &frm, pFrame +
5503 sizeof(tSirMacMgmtHdr),
5504 nPayload, &nPayload );
5505 if ( DOT11F_FAILED( nStatus ) )
5506 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005507 limLog( pMac, LOGE, FL("Failed to pack a Channel Switch (0x%08x)."),
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005508 nStatus );
5509 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
5510 return eSIR_FAILURE; // allocated!
5511 }
5512 else if ( DOT11F_WARNED( nStatus ) )
5513 {
5514 limLog( pMac, LOGW, FL("There were warnings while packing a C"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005515 "hannel Switch (0x%08x)."), nStatus );
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005516 }
5517
5518 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005519 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
5520 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005521 )
5522 {
5523 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
5524 }
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05305525
5526 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
5527 psessionEntry->peSessionId,
5528 pMacHdr->fc.subType));
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005529 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
5530 HAL_TXRX_FRM_802_11_MGMT,
5531 ANI_TXDIR_TODS,
5532 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
5533 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05305534 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
5535 psessionEntry->peSessionId,
5536 halstatus));
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005537 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
5538 {
5539 limLog( pMac, LOGE, FL("Failed to send a Channel Switch "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005540 "(%X)!"),
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005541 nSirStatus );
5542 //Pkt will be freed up by the callback
5543 return eSIR_FAILURE;
5544 }
5545
5546 return eSIR_SUCCESS;
5547
5548} // End limSendVHTChannelSwitchMgmtFrame.
5549
5550
5551
Mohit Khanna4a70d262012-09-11 16:30:12 -07005552#endif
5553
Jeff Johnson295189b2012-06-20 16:38:30 -07005554/**
5555 * \brief Send an ADDBA Req Action Frame to peer
5556 *
5557 * \sa limSendAddBAReq
5558 *
5559 * \param pMac The global tpAniSirGlobal object
5560 *
5561 * \param pMlmAddBAReq A pointer to tLimMlmAddBAReq. This contains
5562 * the necessary parameters reqd by PE send the ADDBA Req Action
5563 * Frame to the peer
5564 *
5565 * \return eSIR_SUCCESS if setup completes successfully
5566 * eSIR_FAILURE is some problem is encountered
5567 */
5568tSirRetStatus limSendAddBAReq( tpAniSirGlobal pMac,
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305569 tpLimMlmAddBAReq pMlmAddBAReq, tpPESession psessionEntry)
Jeff Johnson295189b2012-06-20 16:38:30 -07005570{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05305571 tDot11fAddBAReq frmAddBAReq;
5572 tANI_U8 *pAddBAReqBuffer = NULL;
5573 tpSirMacMgmtHdr pMacHdr;
5574 tANI_U32 frameLen = 0, nStatus, nPayload;
5575 tSirRetStatus statusCode;
5576 eHalStatus halStatus;
5577 void *pPacket;
5578 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005579
5580 if(NULL == psessionEntry)
5581 {
5582 return eSIR_FAILURE;
5583 }
5584
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305585 vos_mem_set( (void *) &frmAddBAReq, sizeof( frmAddBAReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005586
5587 // Category - 3 (BA)
5588 frmAddBAReq.Category.category = SIR_MAC_ACTION_BLKACK;
5589
5590 // Action - 0 (ADDBA Req)
5591 frmAddBAReq.Action.action = SIR_MAC_BLKACK_ADD_REQ;
5592
5593 // FIXME - Dialog Token, generalize this...
5594 frmAddBAReq.DialogToken.token = pMlmAddBAReq->baDialogToken;
5595
5596 // Fill the ADDBA Parameter Set
5597 frmAddBAReq.AddBAParameterSet.tid = pMlmAddBAReq->baTID;
5598 frmAddBAReq.AddBAParameterSet.policy = pMlmAddBAReq->baPolicy;
5599 frmAddBAReq.AddBAParameterSet.bufferSize = pMlmAddBAReq->baBufferSize;
5600
5601 // BA timeout
5602 // 0 - indicates no BA timeout
5603 frmAddBAReq.BATimeout.timeout = pMlmAddBAReq->baTimeout;
5604
Abhishek Singh1f6e6532014-06-05 17:35:08 +05305605 /* Send SSN whatever we get from FW.
5606 */
5607 frmAddBAReq.BAStartingSequenceControl.ssn = pMlmAddBAReq->baSSN;
Jeff Johnson295189b2012-06-20 16:38:30 -07005608
5609 nStatus = dot11fGetPackedAddBAReqSize( pMac, &frmAddBAReq, &nPayload );
5610
5611 if( DOT11F_FAILED( nStatus ))
5612 {
5613 limLog( pMac, LOGW,
5614 FL( "Failed to calculate the packed size for "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005615 "an ADDBA Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005616 nStatus );
5617
5618 // We'll fall back on the worst case scenario:
5619 nPayload = sizeof( tDot11fAddBAReq );
5620 }
5621 else if( DOT11F_WARNED( nStatus ))
5622 {
5623 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005624 FL( "There were warnings while calculating "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005625 "the packed size for an ADDBA Req (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005626 nStatus );
5627 }
5628
5629 // Add the MGMT header to frame length
5630 frameLen = nPayload + sizeof( tSirMacMgmtHdr );
5631
5632 // Need to allocate a buffer for ADDBA AF
5633 if( eHAL_STATUS_SUCCESS !=
5634 (halStatus = palPktAlloc( pMac->hHdd,
5635 HAL_TXRX_FRM_802_11_MGMT,
5636 (tANI_U16) frameLen,
5637 (void **) &pAddBAReqBuffer,
5638 (void **) &pPacket )))
5639 {
5640 // Log error
5641 limLog( pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005642 FL("palPktAlloc FAILED! Length [%d], Status [%d]"),
Jeff Johnson295189b2012-06-20 16:38:30 -07005643 frameLen,
5644 halStatus );
5645
5646 statusCode = eSIR_MEM_ALLOC_FAILED;
5647 goto returnAfterError;
5648 }
5649
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305650 vos_mem_set( (void *) pAddBAReqBuffer, frameLen, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005651
5652 // Copy necessary info to BD
5653 if( eSIR_SUCCESS !=
5654 (statusCode = limPopulateMacHeader( pMac,
5655 pAddBAReqBuffer,
5656 SIR_MAC_MGMT_FRAME,
5657 SIR_MAC_MGMT_ACTION,
5658 pMlmAddBAReq->peerMacAddr,psessionEntry->selfMacAddr)))
5659 goto returnAfterError;
5660
5661 // Update A3 with the BSSID
5662 pMacHdr = ( tpSirMacMgmtHdr ) pAddBAReqBuffer;
5663
5664 #if 0
5665 cfgLen = SIR_MAC_ADDR_LENGTH;
5666 if( eSIR_SUCCESS != cfgGetStr( pMac,
5667 WNI_CFG_BSSID,
5668 (tANI_U8 *) pMacHdr->bssId,
5669 &cfgLen ))
5670 {
5671 limLog( pMac, LOGP,
5672 FL( "Failed to retrieve WNI_CFG_BSSID while"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005673 "sending an ACTION Frame" ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005674
5675 // FIXME - Need to convert to tSirRetStatus
5676 statusCode = eSIR_FAILURE;
5677 goto returnAfterError;
5678 }
5679 #endif//TO SUPPORT BT-AMP
5680 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
5681
Chet Lanctot186b5732013-03-18 10:26:30 -07005682#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07005683 limSetProtectedBit(pMac, psessionEntry, pMlmAddBAReq->peerMacAddr, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07005684#endif
5685
Jeff Johnson295189b2012-06-20 16:38:30 -07005686 // Now, we're ready to "pack" the frames
5687 nStatus = dot11fPackAddBAReq( pMac,
5688 &frmAddBAReq,
5689 pAddBAReqBuffer + sizeof( tSirMacMgmtHdr ),
5690 nPayload,
5691 &nPayload );
5692
5693 if( DOT11F_FAILED( nStatus ))
5694 {
5695 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005696 FL( "Failed to pack an ADDBA Req (0x%08x)." ),
Jeff Johnson295189b2012-06-20 16:38:30 -07005697 nStatus );
5698
5699 // FIXME - Need to convert to tSirRetStatus
5700 statusCode = eSIR_FAILURE;
5701 goto returnAfterError;
5702 }
5703 else if( DOT11F_WARNED( nStatus ))
5704 {
5705 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005706 FL( "There were warnings while packing an ADDBA Req (0x%08x)."),
5707 nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07005708 }
5709
Abhishek Singh02d9f6c2014-05-12 14:07:53 +05305710 limLog( pMac, LOG1, FL( "Sending an ADDBA REQ to "MAC_ADDRESS_STR " with"
5711 " tid = %d policy = %d buffsize = %d "
5712 " amsduSupported = %d"),
5713 MAC_ADDR_ARRAY(pMlmAddBAReq->peerMacAddr),
5714 frmAddBAReq.AddBAParameterSet.tid,
5715 frmAddBAReq.AddBAParameterSet.policy,
5716 frmAddBAReq.AddBAParameterSet.bufferSize,
5717 frmAddBAReq.AddBAParameterSet.amsduSupported);
Jeff Johnson295189b2012-06-20 16:38:30 -07005718
Abhishek Singh1f6e6532014-06-05 17:35:08 +05305719 limLog( pMac, LOG1, FL( "ssn = %d fragNum = %d" ),
5720 frmAddBAReq.BAStartingSequenceControl.ssn,
5721 frmAddBAReq.BAStartingSequenceControl.fragNumber);
5722
Jeff Johnson295189b2012-06-20 16:38:30 -07005723 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07005724 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
5725 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07005726 )
5727 {
5728 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
5729 }
5730
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05305731 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
5732 psessionEntry->peSessionId,
5733 pMacHdr->fc.subType));
5734 halStatus = halTxFrame( pMac,
5735 pPacket,
5736 (tANI_U16) frameLen,
5737 HAL_TXRX_FRM_802_11_MGMT,
5738 ANI_TXDIR_TODS,
5739 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
5740 limTxComplete,
5741 pAddBAReqBuffer, txFlag );
5742 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
5743 psessionEntry->peSessionId,
5744 halStatus));
5745 if( eHAL_STATUS_SUCCESS != halStatus )
Jeff Johnson295189b2012-06-20 16:38:30 -07005746 {
5747 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005748 FL( "halTxFrame FAILED! Status [%d]"),
Jeff Johnson295189b2012-06-20 16:38:30 -07005749 halStatus );
5750
5751 // FIXME - Need to convert eHalStatus to tSirRetStatus
5752 statusCode = eSIR_FAILURE;
5753 //Pkt will be freed up by the callback
5754 return statusCode;
5755 }
5756 else
5757 return eSIR_SUCCESS;
5758
5759returnAfterError:
5760
5761 // Release buffer, if allocated
5762 if( NULL != pAddBAReqBuffer )
5763 palPktFree( pMac->hHdd,
5764 HAL_TXRX_FRM_802_11_MGMT,
5765 (void *) pAddBAReqBuffer,
5766 (void *) pPacket );
5767
5768 return statusCode;
5769}
5770
5771/**
5772 * \brief Send an ADDBA Rsp Action Frame to peer
5773 *
5774 * \sa limSendAddBARsp
5775 *
5776 * \param pMac The global tpAniSirGlobal object
5777 *
5778 * \param pMlmAddBARsp A pointer to tLimMlmAddBARsp. This contains
5779 * the necessary parameters reqd by PE send the ADDBA Rsp Action
5780 * Frame to the peer
5781 *
5782 * \return eSIR_SUCCESS if setup completes successfully
5783 * eSIR_FAILURE is some problem is encountered
5784 */
5785tSirRetStatus limSendAddBARsp( tpAniSirGlobal pMac,
5786 tpLimMlmAddBARsp pMlmAddBARsp,
5787 tpPESession psessionEntry)
5788{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05305789 tDot11fAddBARsp frmAddBARsp;
5790 tANI_U8 *pAddBARspBuffer = NULL;
5791 tpSirMacMgmtHdr pMacHdr;
5792 tANI_U32 frameLen = 0, nStatus, nPayload;
5793 tSirRetStatus statusCode;
5794 eHalStatus halStatus;
5795 void *pPacket;
5796 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005797
5798 if(NULL == psessionEntry)
5799 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005800 PELOGE(limLog(pMac, LOGE, FL("Session entry is NULL!!!"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07005801 return eSIR_FAILURE;
5802 }
5803
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305804 vos_mem_set( (void *) &frmAddBARsp, sizeof( frmAddBARsp ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005805
5806 // Category - 3 (BA)
5807 frmAddBARsp.Category.category = SIR_MAC_ACTION_BLKACK;
5808 // Action - 1 (ADDBA Rsp)
5809 frmAddBARsp.Action.action = SIR_MAC_BLKACK_ADD_RSP;
5810
5811 // Should be same as the one we received in the ADDBA Req
5812 frmAddBARsp.DialogToken.token = pMlmAddBARsp->baDialogToken;
5813
5814 // ADDBA Req status
5815 frmAddBARsp.Status.status = pMlmAddBARsp->addBAResultCode;
5816
5817 // Fill the ADDBA Parameter Set as provided by caller
5818 frmAddBARsp.AddBAParameterSet.tid = pMlmAddBARsp->baTID;
5819 frmAddBARsp.AddBAParameterSet.policy = pMlmAddBARsp->baPolicy;
5820 frmAddBARsp.AddBAParameterSet.bufferSize = pMlmAddBARsp->baBufferSize;
krunal soni5afa96c2013-09-06 22:19:02 -07005821
5822 if(psessionEntry->isAmsduSupportInAMPDU)
5823 {
5824 frmAddBARsp.AddBAParameterSet.amsduSupported =
5825 psessionEntry->amsduSupportedInBA;
5826 }
5827 else
5828 {
5829 frmAddBARsp.AddBAParameterSet.amsduSupported = 0;
5830 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005831
5832 // BA timeout
5833 // 0 - indicates no BA timeout
5834 frmAddBARsp.BATimeout.timeout = pMlmAddBARsp->baTimeout;
5835
5836 nStatus = dot11fGetPackedAddBARspSize( pMac, &frmAddBARsp, &nPayload );
5837
5838 if( DOT11F_FAILED( nStatus ))
5839 {
5840 limLog( pMac, LOGW,
5841 FL( "Failed to calculate the packed size for "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005842 "an ADDBA Response (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005843 nStatus );
5844
5845 // We'll fall back on the worst case scenario:
5846 nPayload = sizeof( tDot11fAddBARsp );
5847 }
5848 else if( DOT11F_WARNED( nStatus ))
5849 {
5850 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005851 FL( "There were warnings while calculating "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005852 "the packed size for an ADDBA Rsp (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005853 nStatus );
5854 }
5855
5856 // Need to allocate a buffer for ADDBA AF
5857 frameLen = nPayload + sizeof( tSirMacMgmtHdr );
5858
5859 // Allocate shared memory
5860 if( eHAL_STATUS_SUCCESS !=
5861 (halStatus = palPktAlloc( pMac->hHdd,
5862 HAL_TXRX_FRM_802_11_MGMT,
5863 (tANI_U16) frameLen,
5864 (void **) &pAddBARspBuffer,
5865 (void **) &pPacket )))
5866 {
5867 // Log error
5868 limLog( pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005869 FL("palPktAlloc FAILED! Length [%d], Status [%d]"),
Jeff Johnson295189b2012-06-20 16:38:30 -07005870 frameLen,
5871 halStatus );
5872
5873 statusCode = eSIR_MEM_ALLOC_FAILED;
5874 goto returnAfterError;
5875 }
5876
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305877 vos_mem_set( (void *) pAddBARspBuffer, frameLen, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005878
5879 // Copy necessary info to BD
5880 if( eSIR_SUCCESS !=
5881 (statusCode = limPopulateMacHeader( pMac,
5882 pAddBARspBuffer,
5883 SIR_MAC_MGMT_FRAME,
5884 SIR_MAC_MGMT_ACTION,
5885 pMlmAddBARsp->peerMacAddr,psessionEntry->selfMacAddr)))
5886 goto returnAfterError;
5887
5888 // Update A3 with the BSSID
5889
5890 pMacHdr = ( tpSirMacMgmtHdr ) pAddBARspBuffer;
5891
5892 #if 0
5893 cfgLen = SIR_MAC_ADDR_LENGTH;
5894 if( eSIR_SUCCESS != wlan_cfgGetStr( pMac,
5895 WNI_CFG_BSSID,
5896 (tANI_U8 *) pMacHdr->bssId,
5897 &cfgLen ))
5898 {
5899 limLog( pMac, LOGP,
5900 FL( "Failed to retrieve WNI_CFG_BSSID while"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005901 "sending an ACTION Frame" ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005902
5903 // FIXME - Need to convert to tSirRetStatus
5904 statusCode = eSIR_FAILURE;
5905 goto returnAfterError;
5906 }
5907 #endif // TO SUPPORT BT-AMP
5908 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
5909
Chet Lanctot186b5732013-03-18 10:26:30 -07005910#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07005911 limSetProtectedBit(pMac, psessionEntry, pMlmAddBARsp->peerMacAddr, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07005912#endif
5913
Jeff Johnson295189b2012-06-20 16:38:30 -07005914 // Now, we're ready to "pack" the frames
5915 nStatus = dot11fPackAddBARsp( pMac,
5916 &frmAddBARsp,
5917 pAddBARspBuffer + sizeof( tSirMacMgmtHdr ),
5918 nPayload,
5919 &nPayload );
5920
5921 if( DOT11F_FAILED( nStatus ))
5922 {
5923 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005924 FL( "Failed to pack an ADDBA Rsp (0x%08x)." ),
Jeff Johnson295189b2012-06-20 16:38:30 -07005925 nStatus );
5926
5927 // FIXME - Need to convert to tSirRetStatus
5928 statusCode = eSIR_FAILURE;
5929 goto returnAfterError;
5930 }
5931 else if( DOT11F_WARNED( nStatus ))
5932 {
5933 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005934 FL( "There were warnings while packing an ADDBA Rsp (0x%08x)." ),
5935 nStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07005936 }
5937
Abhishek Singh02d9f6c2014-05-12 14:07:53 +05305938 limLog( pMac, LOG1, FL( "Sending an ADDBA RSP to "MAC_ADDRESS_STR " with"
5939 " tid = %d policy = %d buffsize = %d"
5940 " amsduSupported = %d status %d"),
5941 MAC_ADDR_ARRAY(pMlmAddBARsp->peerMacAddr),
5942 frmAddBARsp.AddBAParameterSet.tid,
5943 frmAddBARsp.AddBAParameterSet.policy,
5944 frmAddBARsp.AddBAParameterSet.bufferSize,
5945 frmAddBARsp.AddBAParameterSet.amsduSupported,
5946 frmAddBARsp.Status.status);
5947
Jeff Johnson295189b2012-06-20 16:38:30 -07005948
5949 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07005950 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
5951 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07005952 )
5953 {
5954 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
5955 }
5956
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05305957 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
5958 psessionEntry->peSessionId,
5959 pMacHdr->fc.subType));
5960 halStatus = halTxFrame( pMac,
5961 pPacket,
5962 (tANI_U16) frameLen,
5963 HAL_TXRX_FRM_802_11_MGMT,
5964 ANI_TXDIR_TODS,
5965 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
5966 limTxComplete,
5967 pAddBARspBuffer, txFlag );
5968 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
5969 psessionEntry->peSessionId,
5970 halStatus));
5971 if( eHAL_STATUS_SUCCESS != halStatus )
5972 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005973 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005974 FL( "halTxFrame FAILED! Status [%d]" ),
Jeff Johnson295189b2012-06-20 16:38:30 -07005975 halStatus );
5976
5977 // FIXME - HAL error codes are different from PE error
5978 // codes!! And, this routine is returning tSirRetStatus
5979 statusCode = eSIR_FAILURE;
5980 //Pkt will be freed up by the callback
5981 return statusCode;
5982 }
5983 else
5984 return eSIR_SUCCESS;
5985
5986 returnAfterError:
Jeff Johnson295189b2012-06-20 16:38:30 -07005987 // Release buffer, if allocated
5988 if( NULL != pAddBARspBuffer )
5989 palPktFree( pMac->hHdd,
5990 HAL_TXRX_FRM_802_11_MGMT,
5991 (void *) pAddBARspBuffer,
5992 (void *) pPacket );
5993
5994 return statusCode;
5995}
5996
5997/**
5998 * \brief Send a DELBA Indication Action Frame to peer
5999 *
6000 * \sa limSendDelBAInd
6001 *
6002 * \param pMac The global tpAniSirGlobal object
6003 *
6004 * \param peerMacAddr MAC Address of peer
6005 *
6006 * \param reasonCode Reason for the DELBA notification
6007 *
6008 * \param pBAParameterSet The DELBA Parameter Set.
6009 * This identifies the TID for which the BA session is
6010 * being deleted.
6011 *
6012 * \return eSIR_SUCCESS if setup completes successfully
6013 * eSIR_FAILURE is some problem is encountered
6014 */
6015tSirRetStatus limSendDelBAInd( tpAniSirGlobal pMac,
6016 tpLimMlmDelBAReq pMlmDelBAReq,tpPESession psessionEntry)
6017{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05306018 tDot11fDelBAInd frmDelBAInd;
6019 tANI_U8 *pDelBAIndBuffer = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07006020 //tANI_U32 val;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05306021 tpSirMacMgmtHdr pMacHdr;
6022 tANI_U32 frameLen = 0, nStatus, nPayload;
6023 tSirRetStatus statusCode;
6024 eHalStatus halStatus;
6025 void *pPacket;
6026 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07006027
6028 if(NULL == psessionEntry)
6029 {
6030 return eSIR_FAILURE;
6031 }
6032
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05306033 vos_mem_set( (void *) &frmDelBAInd, sizeof( frmDelBAInd ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07006034
6035 // Category - 3 (BA)
6036 frmDelBAInd.Category.category = SIR_MAC_ACTION_BLKACK;
6037 // Action - 2 (DELBA)
6038 frmDelBAInd.Action.action = SIR_MAC_BLKACK_DEL;
6039
6040 // Fill the DELBA Parameter Set as provided by caller
6041 frmDelBAInd.DelBAParameterSet.tid = pMlmDelBAReq->baTID;
6042 frmDelBAInd.DelBAParameterSet.initiator = pMlmDelBAReq->baDirection;
6043
6044 // BA Starting Sequence Number
6045 // Fragment number will always be zero
6046 frmDelBAInd.Reason.code = pMlmDelBAReq->delBAReasonCode;
6047
6048 nStatus = dot11fGetPackedDelBAIndSize( pMac, &frmDelBAInd, &nPayload );
6049
6050 if( DOT11F_FAILED( nStatus ))
6051 {
6052 limLog( pMac, LOGW,
6053 FL( "Failed to calculate the packed size for "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006054 "an DELBA Indication (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07006055 nStatus );
6056
6057 // We'll fall back on the worst case scenario:
6058 nPayload = sizeof( tDot11fDelBAInd );
6059 }
6060 else if( DOT11F_WARNED( nStatus ))
6061 {
6062 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08006063 FL( "There were warnings while calculating "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006064 "the packed size for an DELBA Ind (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07006065 nStatus );
6066 }
6067
6068 // Add the MGMT header to frame length
6069 frameLen = nPayload + sizeof( tSirMacMgmtHdr );
6070
6071 // Allocate shared memory
6072 if( eHAL_STATUS_SUCCESS !=
6073 (halStatus = palPktAlloc( pMac->hHdd,
6074 HAL_TXRX_FRM_802_11_MGMT,
6075 (tANI_U16) frameLen,
6076 (void **) &pDelBAIndBuffer,
6077 (void **) &pPacket )))
6078 {
6079 // Log error
6080 limLog( pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006081 FL("palPktAlloc FAILED! Length [%d], Status [%d]"),
Jeff Johnson295189b2012-06-20 16:38:30 -07006082 frameLen,
6083 halStatus );
6084
6085 statusCode = eSIR_MEM_ALLOC_FAILED;
6086 goto returnAfterError;
6087 }
6088
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05306089 vos_mem_set( (void *) pDelBAIndBuffer, frameLen, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07006090
6091 // Copy necessary info to BD
6092 if( eSIR_SUCCESS !=
6093 (statusCode = limPopulateMacHeader( pMac,
6094 pDelBAIndBuffer,
6095 SIR_MAC_MGMT_FRAME,
6096 SIR_MAC_MGMT_ACTION,
6097 pMlmDelBAReq->peerMacAddr,psessionEntry->selfMacAddr)))
6098 goto returnAfterError;
6099
6100 // Update A3 with the BSSID
6101 pMacHdr = ( tpSirMacMgmtHdr ) pDelBAIndBuffer;
6102
6103 #if 0
6104 cfgLen = SIR_MAC_ADDR_LENGTH;
6105 if( eSIR_SUCCESS != cfgGetStr( pMac,
6106 WNI_CFG_BSSID,
6107 (tANI_U8 *) pMacHdr->bssId,
6108 &cfgLen ))
6109 {
6110 limLog( pMac, LOGP,
6111 FL( "Failed to retrieve WNI_CFG_BSSID while"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006112 "sending an ACTION Frame" ));
Jeff Johnson295189b2012-06-20 16:38:30 -07006113
6114 // FIXME - Need to convert to tSirRetStatus
6115 statusCode = eSIR_FAILURE;
6116 goto returnAfterError;
6117 }
6118 #endif //TO SUPPORT BT-AMP
6119 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
6120
Chet Lanctot186b5732013-03-18 10:26:30 -07006121#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07006122 limSetProtectedBit(pMac, psessionEntry, pMlmDelBAReq->peerMacAddr, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07006123#endif
6124
Jeff Johnson295189b2012-06-20 16:38:30 -07006125 // Now, we're ready to "pack" the frames
6126 nStatus = dot11fPackDelBAInd( pMac,
6127 &frmDelBAInd,
6128 pDelBAIndBuffer + sizeof( tSirMacMgmtHdr ),
6129 nPayload,
6130 &nPayload );
6131
6132 if( DOT11F_FAILED( nStatus ))
6133 {
6134 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006135 FL( "Failed to pack an DELBA Ind (0x%08x)." ),
Jeff Johnson295189b2012-06-20 16:38:30 -07006136 nStatus );
6137
6138 // FIXME - Need to convert to tSirRetStatus
6139 statusCode = eSIR_FAILURE;
6140 goto returnAfterError;
6141 }
6142 else if( DOT11F_WARNED( nStatus ))
6143 {
6144 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08006145 FL( "There were warnings while packing an DELBA Ind (0x%08x)." ),
6146 nStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07006147 }
6148
Abhishek Singh1f6e6532014-06-05 17:35:08 +05306149 limLog( pMac, LOG1,
6150 FL( "Sending a DELBA IND to: "MAC_ADDRESS_STR" with Tid = %d"
6151 " initiator = %d reason = %d" ),
6152 MAC_ADDR_ARRAY(pMlmDelBAReq->peerMacAddr),
6153 frmDelBAInd.DelBAParameterSet.tid,
6154 frmDelBAInd.DelBAParameterSet.initiator,
6155 frmDelBAInd.Reason.code);
6156
Jeff Johnson295189b2012-06-20 16:38:30 -07006157
6158 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07006159 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
6160 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07006161 )
6162 {
6163 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
6164 }
6165
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05306166 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
6167 psessionEntry->peSessionId,
6168 pMacHdr->fc.subType));
6169 halStatus = halTxFrame( pMac,
6170 pPacket,
6171 (tANI_U16) frameLen,
6172 HAL_TXRX_FRM_802_11_MGMT,
6173 ANI_TXDIR_TODS,
6174 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
6175 limTxComplete,
6176 pDelBAIndBuffer, txFlag );
6177 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
6178 psessionEntry->peSessionId,
6179 halStatus));
6180 if( eHAL_STATUS_SUCCESS != halStatus )
Jeff Johnson295189b2012-06-20 16:38:30 -07006181 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006182 PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]" ), halStatus );)
Jeff Johnson295189b2012-06-20 16:38:30 -07006183 statusCode = eSIR_FAILURE;
6184 //Pkt will be freed up by the callback
6185 return statusCode;
6186 }
6187 else
6188 return eSIR_SUCCESS;
6189
6190 returnAfterError:
6191
6192 // Release buffer, if allocated
6193 if( NULL != pDelBAIndBuffer )
6194 palPktFree( pMac->hHdd,
6195 HAL_TXRX_FRM_802_11_MGMT,
6196 (void *) pDelBAIndBuffer,
6197 (void *) pPacket );
6198
6199 return statusCode;
6200}
6201
6202#if defined WLAN_FEATURE_VOWIFI
6203
6204/**
6205 * \brief Send a Neighbor Report Request Action frame
6206 *
6207 *
6208 * \param pMac Pointer to the global MAC structure
6209 *
6210 * \param pNeighborReq Address of a tSirMacNeighborReportReq
6211 *
6212 * \param peer mac address of peer station.
6213 *
6214 * \param psessionEntry address of session entry.
6215 *
6216 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
6217 *
6218 *
6219 */
6220
6221tSirRetStatus
6222limSendNeighborReportRequestFrame(tpAniSirGlobal pMac,
6223 tpSirMacNeighborReportReq pNeighborReq,
6224 tSirMacAddr peer,
6225 tpPESession psessionEntry
6226 )
6227{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05306228 tSirRetStatus statusCode = eSIR_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006229 tDot11fNeighborReportRequest frm;
6230 tANI_U8 *pFrame;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05306231 tpSirMacMgmtHdr pMacHdr;
6232 tANI_U32 nBytes, nPayload, nStatus;
6233 void *pPacket;
6234 eHalStatus halstatus;
6235 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07006236
6237 if ( psessionEntry == NULL )
6238 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006239 limLog( pMac, LOGE, FL("(psession == NULL) in Request to send Neighbor Report request action frame") );
Jeff Johnson295189b2012-06-20 16:38:30 -07006240 return eSIR_FAILURE;
6241 }
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05306242 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07006243
6244 frm.Category.category = SIR_MAC_ACTION_RRM;
6245 frm.Action.action = SIR_MAC_RRM_NEIGHBOR_REQ;
6246 frm.DialogToken.token = pNeighborReq->dialogToken;
6247
6248
6249 if( pNeighborReq->ssid_present )
6250 {
6251 PopulateDot11fSSID( pMac, &pNeighborReq->ssid, &frm.SSID );
6252 }
6253
6254 nStatus = dot11fGetPackedNeighborReportRequestSize( pMac, &frm, &nPayload );
6255 if ( DOT11F_FAILED( nStatus ) )
6256 {
6257 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006258 "or a Neighbor Report Request(0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07006259 nStatus );
6260 // We'll fall back on the worst case scenario:
6261 nPayload = sizeof( tDot11fNeighborReportRequest );
6262 }
6263 else if ( DOT11F_WARNED( nStatus ) )
6264 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08006265 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07006266 "the packed size for a Neighbor Rep"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006267 "ort Request(0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07006268 }
6269
6270 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
6271
6272 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
6273 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
6274 {
6275 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Neighbor "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006276 "Report Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07006277 return eSIR_FAILURE;
6278 }
6279
6280 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05306281 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07006282
6283 // Copy necessary info to BD
6284 if( eSIR_SUCCESS !=
6285 (statusCode = limPopulateMacHeader( pMac,
6286 pFrame,
6287 SIR_MAC_MGMT_FRAME,
6288 SIR_MAC_MGMT_ACTION,
6289 peer, psessionEntry->selfMacAddr)))
6290 goto returnAfterError;
6291
6292 // Update A3 with the BSSID
6293 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
6294
6295 sirCopyMacAddr( pMacHdr->bssId, psessionEntry->bssId );
6296
Chet Lanctot186b5732013-03-18 10:26:30 -07006297#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07006298 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07006299#endif
6300
Jeff Johnson295189b2012-06-20 16:38:30 -07006301 // Now, we're ready to "pack" the frames
6302 nStatus = dot11fPackNeighborReportRequest( pMac,
6303 &frm,
6304 pFrame + sizeof( tSirMacMgmtHdr ),
6305 nPayload,
6306 &nPayload );
6307
6308 if( DOT11F_FAILED( nStatus ))
6309 {
6310 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006311 FL( "Failed to pack an Neighbor Report Request (0x%08x)." ),
Jeff Johnson295189b2012-06-20 16:38:30 -07006312 nStatus );
6313
6314 // FIXME - Need to convert to tSirRetStatus
6315 statusCode = eSIR_FAILURE;
6316 goto returnAfterError;
6317 }
6318 else if( DOT11F_WARNED( nStatus ))
6319 {
6320 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08006321 FL( "There were warnings while packing Neighbor Report "
6322 "Request (0x%08x)." ), nStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07006323 }
6324
6325 limLog( pMac, LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006326 FL( "Sending a Neighbor Report Request to " ));
Jeff Johnson295189b2012-06-20 16:38:30 -07006327 limPrintMacAddr( pMac, peer, LOGW );
6328
6329 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07006330 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
6331 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07006332 )
6333 {
6334 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
6335 }
6336
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05306337 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
6338 psessionEntry->peSessionId,
6339 pMacHdr->fc.subType));
6340 halstatus = halTxFrame( pMac,
6341 pPacket,
6342 (tANI_U16) nBytes,
6343 HAL_TXRX_FRM_802_11_MGMT,
6344 ANI_TXDIR_TODS,
6345 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
6346 limTxComplete,
6347 pFrame, txFlag );
6348 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
6349 psessionEntry->peSessionId,
6350 halstatus));
6351 if( eHAL_STATUS_SUCCESS != halstatus )
Jeff Johnson295189b2012-06-20 16:38:30 -07006352 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006353 PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]" ), halstatus );)
Jeff Johnson295189b2012-06-20 16:38:30 -07006354 statusCode = eSIR_FAILURE;
6355 //Pkt will be freed up by the callback
6356 return statusCode;
6357 }
6358 else
6359 return eSIR_SUCCESS;
6360
6361returnAfterError:
6362 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
6363
6364 return statusCode;
6365} // End limSendNeighborReportRequestFrame.
6366
6367/**
6368 * \brief Send a Link Report Action frame
6369 *
6370 *
6371 * \param pMac Pointer to the global MAC structure
6372 *
6373 * \param pLinkReport Address of a tSirMacLinkReport
6374 *
6375 * \param peer mac address of peer station.
6376 *
6377 * \param psessionEntry address of session entry.
6378 *
6379 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
6380 *
6381 *
6382 */
6383
6384tSirRetStatus
6385limSendLinkReportActionFrame(tpAniSirGlobal pMac,
6386 tpSirMacLinkReport pLinkReport,
6387 tSirMacAddr peer,
6388 tpPESession psessionEntry
6389 )
6390{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05306391 tSirRetStatus statusCode = eSIR_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006392 tDot11fLinkMeasurementReport frm;
6393 tANI_U8 *pFrame;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05306394 tpSirMacMgmtHdr pMacHdr;
6395 tANI_U32 nBytes, nPayload, nStatus;
6396 void *pPacket;
6397 eHalStatus halstatus;
6398 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07006399
6400
6401 if ( psessionEntry == NULL )
6402 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006403 limLog( pMac, LOGE, FL("(psession == NULL) in Request to send Link Report action frame") );
Jeff Johnson295189b2012-06-20 16:38:30 -07006404 return eSIR_FAILURE;
6405 }
6406
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05306407 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07006408
6409 frm.Category.category = SIR_MAC_ACTION_RRM;
6410 frm.Action.action = SIR_MAC_RRM_LINK_MEASUREMENT_RPT;
6411 frm.DialogToken.token = pLinkReport->dialogToken;
6412
6413
6414 //IEEE Std. 802.11 7.3.2.18. for the report element.
6415 //Even though TPC report an IE, it is represented using fixed fields since it is positioned
6416 //in the middle of other fixed fields in the link report frame(IEEE Std. 802.11k section7.4.6.4
6417 //and frame parser always expects IEs to come after all fixed fields. It is easier to handle
6418 //such case this way than changing the frame parser.
6419 frm.TPCEleID.TPCId = SIR_MAC_TPC_RPT_EID;
6420 frm.TPCEleLen.TPCLen = 2;
6421 frm.TxPower.txPower = pLinkReport->txPower;
6422 frm.LinkMargin.linkMargin = 0;
6423
6424 frm.RxAntennaId.antennaId = pLinkReport->rxAntenna;
6425 frm.TxAntennaId.antennaId = pLinkReport->txAntenna;
6426 frm.RCPI.rcpi = pLinkReport->rcpi;
6427 frm.RSNI.rsni = pLinkReport->rsni;
6428
6429 nStatus = dot11fGetPackedLinkMeasurementReportSize( pMac, &frm, &nPayload );
6430 if ( DOT11F_FAILED( nStatus ) )
6431 {
6432 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006433 "or a Link Report (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07006434 nStatus );
6435 // We'll fall back on the worst case scenario:
6436 nPayload = sizeof( tDot11fLinkMeasurementReport );
6437 }
6438 else if ( DOT11F_WARNED( nStatus ) )
6439 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08006440 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07006441 "the packed size for a Link Rep"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006442 "ort (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07006443 }
6444
6445 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
6446
6447 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
6448 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
6449 {
6450 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Link "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006451 "Report."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07006452 return eSIR_FAILURE;
6453 }
6454
6455 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05306456 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07006457
6458 // Copy necessary info to BD
6459 if( eSIR_SUCCESS !=
6460 (statusCode = limPopulateMacHeader( pMac,
6461 pFrame,
6462 SIR_MAC_MGMT_FRAME,
6463 SIR_MAC_MGMT_ACTION,
6464 peer, psessionEntry->selfMacAddr)))
6465 goto returnAfterError;
6466
6467 // Update A3 with the BSSID
6468 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
6469
6470 sirCopyMacAddr( pMacHdr->bssId, psessionEntry->bssId );
6471
Chet Lanctot186b5732013-03-18 10:26:30 -07006472#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07006473 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07006474#endif
6475
Jeff Johnson295189b2012-06-20 16:38:30 -07006476 // Now, we're ready to "pack" the frames
6477 nStatus = dot11fPackLinkMeasurementReport( pMac,
6478 &frm,
6479 pFrame + sizeof( tSirMacMgmtHdr ),
6480 nPayload,
6481 &nPayload );
6482
6483 if( DOT11F_FAILED( nStatus ))
6484 {
6485 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006486 FL( "Failed to pack an Link Report (0x%08x)." ),
Jeff Johnson295189b2012-06-20 16:38:30 -07006487 nStatus );
6488
6489 // FIXME - Need to convert to tSirRetStatus
6490 statusCode = eSIR_FAILURE;
6491 goto returnAfterError;
6492 }
6493 else if( DOT11F_WARNED( nStatus ))
6494 {
6495 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08006496 FL( "There were warnings while packing Link Report (0x%08x)." ),
6497 nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07006498 }
6499
6500 limLog( pMac, LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006501 FL( "Sending a Link Report to " ));
Jeff Johnson295189b2012-06-20 16:38:30 -07006502 limPrintMacAddr( pMac, peer, LOGW );
6503
6504 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07006505 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
6506 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07006507 )
6508 {
6509 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
6510 }
6511
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05306512 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
6513 psessionEntry->peSessionId,
6514 pMacHdr->fc.subType));
6515 halstatus = halTxFrame( pMac,
6516 pPacket,
6517 (tANI_U16) nBytes,
6518 HAL_TXRX_FRM_802_11_MGMT,
6519 ANI_TXDIR_TODS,
6520 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
6521 limTxComplete,
6522 pFrame, txFlag );
6523 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
6524 psessionEntry->peSessionId,
6525 halstatus));
6526 if( eHAL_STATUS_SUCCESS != halstatus )
Jeff Johnson295189b2012-06-20 16:38:30 -07006527 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006528 PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]" ), halstatus );)
Jeff Johnson295189b2012-06-20 16:38:30 -07006529 statusCode = eSIR_FAILURE;
6530 //Pkt will be freed up by the callback
6531 return statusCode;
6532 }
6533 else
6534 return eSIR_SUCCESS;
6535
6536returnAfterError:
6537 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
6538
6539 return statusCode;
6540} // End limSendLinkReportActionFrame.
6541
6542/**
6543 * \brief Send a Beacon Report Action frame
6544 *
6545 *
6546 * \param pMac Pointer to the global MAC structure
6547 *
6548 * \param dialog_token dialog token to be used in the action frame.
6549 *
6550 * \param num_report number of reports in pRRMReport.
6551 *
6552 * \param pRRMReport Address of a tSirMacRadioMeasureReport.
6553 *
6554 * \param peer mac address of peer station.
6555 *
6556 * \param psessionEntry address of session entry.
6557 *
6558 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
6559 *
6560 *
6561 */
6562
6563tSirRetStatus
6564limSendRadioMeasureReportActionFrame(tpAniSirGlobal pMac,
6565 tANI_U8 dialog_token,
6566 tANI_U8 num_report,
6567 tpSirMacRadioMeasureReport pRRMReport,
6568 tSirMacAddr peer,
6569 tpPESession psessionEntry
6570 )
6571{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05306572 tSirRetStatus statusCode = eSIR_SUCCESS;
6573 tANI_U8 *pFrame;
6574 tpSirMacMgmtHdr pMacHdr;
6575 tANI_U32 nBytes, nPayload, nStatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07006576 void *pPacket;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05306577 eHalStatus halstatus;
6578 tANI_U8 i;
6579 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07006580
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006581 tDot11fRadioMeasurementReport *frm =
6582 vos_mem_malloc(sizeof(tDot11fRadioMeasurementReport));
6583 if (!frm) {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006584 limLog( pMac, LOGE, FL("Not enough memory to allocate tDot11fRadioMeasurementReport") );
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006585 return eSIR_FAILURE;
6586 }
6587
Jeff Johnson295189b2012-06-20 16:38:30 -07006588 if ( psessionEntry == NULL )
6589 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006590 limLog( pMac, LOGE, FL("(psession == NULL) in Request to send Beacon Report action frame") );
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006591 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07006592 return eSIR_FAILURE;
6593 }
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05306594 vos_mem_set( ( tANI_U8* )frm, sizeof( *frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07006595
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006596 frm->Category.category = SIR_MAC_ACTION_RRM;
6597 frm->Action.action = SIR_MAC_RRM_RADIO_MEASURE_RPT;
6598 frm->DialogToken.token = dialog_token;
Jeff Johnson295189b2012-06-20 16:38:30 -07006599
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006600 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 -07006601
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006602 for( i = 0 ; i < frm->num_MeasurementReport ; i++ )
Jeff Johnson295189b2012-06-20 16:38:30 -07006603 {
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006604 frm->MeasurementReport[i].type = pRRMReport[i].type;
6605 frm->MeasurementReport[i].token = pRRMReport[i].token;
6606 frm->MeasurementReport[i].late = 0; //IEEE 802.11k section 7.3.22. (always zero in rrm)
Jeff Johnson295189b2012-06-20 16:38:30 -07006607 switch( pRRMReport[i].type )
6608 {
6609 case SIR_MAC_RRM_BEACON_TYPE:
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006610 PopulateDot11fBeaconReport( pMac, &frm->MeasurementReport[i], &pRRMReport[i].report.beaconReport );
6611 frm->MeasurementReport[i].incapable = pRRMReport[i].incapable;
6612 frm->MeasurementReport[i].refused = pRRMReport[i].refused;
6613 frm->MeasurementReport[i].present = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07006614 break;
6615 default:
Gopichand Nakkala72717fd2013-02-08 12:23:45 +05306616 frm->MeasurementReport[i].incapable = pRRMReport[i].incapable;
6617 frm->MeasurementReport[i].refused = pRRMReport[i].refused;
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006618 frm->MeasurementReport[i].present = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07006619 break;
6620 }
6621 }
6622
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006623 nStatus = dot11fGetPackedRadioMeasurementReportSize( pMac, frm, &nPayload );
Jeff Johnson295189b2012-06-20 16:38:30 -07006624 if ( DOT11F_FAILED( nStatus ) )
6625 {
6626 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006627 "or a Radio Measure Report (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07006628 nStatus );
6629 // We'll fall back on the worst case scenario:
6630 nPayload = sizeof( tDot11fLinkMeasurementReport );
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006631 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07006632 return eSIR_FAILURE;
6633 }
6634 else if ( DOT11F_WARNED( nStatus ) )
6635 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08006636 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07006637 "the packed size for a Radio Measure Rep"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006638 "ort (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07006639 }
6640
6641 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
6642
6643 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
6644 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
6645 {
6646 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Radio Measure "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006647 "Report."), nBytes );
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006648 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07006649 return eSIR_FAILURE;
6650 }
6651
6652 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05306653 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07006654
6655 // Copy necessary info to BD
6656 if( eSIR_SUCCESS !=
6657 (statusCode = limPopulateMacHeader( pMac,
6658 pFrame,
6659 SIR_MAC_MGMT_FRAME,
6660 SIR_MAC_MGMT_ACTION,
6661 peer, psessionEntry->selfMacAddr)))
6662 goto returnAfterError;
6663
6664 // Update A3 with the BSSID
6665 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
6666
6667 sirCopyMacAddr( pMacHdr->bssId, psessionEntry->bssId );
6668
Chet Lanctot186b5732013-03-18 10:26:30 -07006669#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07006670 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07006671#endif
6672
Jeff Johnson295189b2012-06-20 16:38:30 -07006673 // Now, we're ready to "pack" the frames
6674 nStatus = dot11fPackRadioMeasurementReport( pMac,
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006675 frm,
Jeff Johnson295189b2012-06-20 16:38:30 -07006676 pFrame + sizeof( tSirMacMgmtHdr ),
6677 nPayload,
6678 &nPayload );
6679
6680 if( DOT11F_FAILED( nStatus ))
6681 {
6682 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006683 FL( "Failed to pack an Radio Measure Report (0x%08x)." ),
Jeff Johnson295189b2012-06-20 16:38:30 -07006684 nStatus );
6685
6686 // FIXME - Need to convert to tSirRetStatus
6687 statusCode = eSIR_FAILURE;
6688 goto returnAfterError;
6689 }
6690 else if( DOT11F_WARNED( nStatus ))
6691 {
6692 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08006693 FL( "There were warnings while packing Radio "
6694 "Measure Report (0x%08x)." ), nStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07006695 }
6696
6697 limLog( pMac, LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006698 FL( "Sending a Radio Measure Report to " ));
Jeff Johnson295189b2012-06-20 16:38:30 -07006699 limPrintMacAddr( pMac, peer, LOGW );
6700
6701 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07006702 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
6703 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07006704 )
6705 {
6706 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
6707 }
6708
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05306709 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
6710 psessionEntry->peSessionId,
6711 pMacHdr->fc.subType));
6712 halstatus = halTxFrame( pMac,
6713 pPacket,
6714 (tANI_U16) nBytes,
6715 HAL_TXRX_FRM_802_11_MGMT,
6716 ANI_TXDIR_TODS,
6717 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
6718 limTxComplete,
6719 pFrame, txFlag );
6720 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
6721 psessionEntry->peSessionId,
6722 halstatus));
6723 if( eHAL_STATUS_SUCCESS != halstatus )
Jeff Johnson295189b2012-06-20 16:38:30 -07006724 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006725 PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]" ), halstatus );)
Jeff Johnson295189b2012-06-20 16:38:30 -07006726 statusCode = eSIR_FAILURE;
6727 //Pkt will be freed up by the callback
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006728 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07006729 return statusCode;
6730 }
Madan Mohan Koyyalamudieeb56b12012-10-31 15:10:04 -07006731 else {
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006732 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07006733 return eSIR_SUCCESS;
Madan Mohan Koyyalamudieeb56b12012-10-31 15:10:04 -07006734 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006735
6736returnAfterError:
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006737 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07006738 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
Jeff Johnson295189b2012-06-20 16:38:30 -07006739 return statusCode;
6740} // End limSendBeaconReportActionFrame.
6741
6742#endif
6743
6744#ifdef WLAN_FEATURE_11W
6745/**
Chet Lanctot8cecea22014-02-11 19:09:36 -08006746 * \brief Send SA query request action frame to peer
6747 *
6748 * \sa limSendSaQueryRequestFrame
6749 *
6750 *
6751 * \param pMac The global tpAniSirGlobal object
6752 *
6753 * \param transId Transaction identifier
6754 *
6755 * \param peer The Mac address of the station to which this action frame is addressed
6756 *
6757 * \param psessionEntry The PE session entry
6758 *
6759 * \return eSIR_SUCCESS if setup completes successfully
6760 * eSIR_FAILURE is some problem is encountered
6761 */
6762
6763tSirRetStatus limSendSaQueryRequestFrame( tpAniSirGlobal pMac, tANI_U8 *transId,
6764 tSirMacAddr peer, tpPESession psessionEntry )
6765{
6766
6767 tDot11fSaQueryReq frm; // SA query request action frame
6768 tANI_U8 *pFrame;
6769 tSirRetStatus nSirStatus;
6770 tpSirMacMgmtHdr pMacHdr;
6771 tANI_U32 nBytes, nPayload, nStatus;
6772 void *pPacket;
6773 eHalStatus halstatus;
6774 tANI_U8 txFlag = 0;
6775
6776 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
6777 frm.Category.category = SIR_MAC_ACTION_SA_QUERY;
6778 /* 11w action field is :
6779 action: 0 --> SA Query Request action frame
6780 action: 1 --> SA Query Response action frame */
6781 frm.Action.action = SIR_MAC_SA_QUERY_REQ;
6782 /* 11w SA Query Request transId */
6783 vos_mem_copy( &frm.TransactionId.transId[0], &transId[0], 2 );
6784
6785 nStatus = dot11fGetPackedSaQueryReqSize(pMac, &frm, &nPayload);
6786 if ( DOT11F_FAILED( nStatus ) )
6787 {
6788 limLog( pMac, LOGP, FL("Failed to calculate the packed size "
6789 "for an SA Query Request (0x%08x)."),
6790 nStatus );
6791 // We'll fall back on the worst case scenario:
6792 nPayload = sizeof( tDot11fSaQueryReq );
6793 }
6794 else if ( DOT11F_WARNED( nStatus ) )
6795 {
6796 limLog( pMac, LOGW, FL("There were warnings while calculating "
6797 "the packed size for an SA Query Request"
6798 " (0x%08x)."), nStatus );
6799 }
6800
6801 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
6802 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
6803 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
6804 {
6805 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a SA Query Request "
6806 "action frame"), nBytes );
6807 return eSIR_FAILURE;
6808 }
6809
6810 // Paranoia:
6811 vos_mem_set( pFrame, nBytes, 0 );
6812
6813 // Copy necessary info to BD
6814 nSirStatus = limPopulateMacHeader( pMac,
6815 pFrame,
6816 SIR_MAC_MGMT_FRAME,
6817 SIR_MAC_MGMT_ACTION,
6818 peer, psessionEntry->selfMacAddr );
6819 if ( eSIR_SUCCESS != nSirStatus )
6820 goto returnAfterError;
6821
6822 // Update A3 with the BSSID
6823 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
6824
6825 sirCopyMacAddr( pMacHdr->bssId, psessionEntry->bssId );
6826
6827 // Since this is a SA Query Request, set the "protect" (aka WEP) bit
6828 // in the FC
6829 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
6830
6831 // Pack 11w SA Query Request frame
6832 nStatus = dot11fPackSaQueryReq( pMac,
6833 &frm,
6834 pFrame + sizeof( tSirMacMgmtHdr ),
6835 nPayload,
6836 &nPayload );
6837
6838 if ( DOT11F_FAILED( nStatus ))
6839 {
6840 limLog( pMac, LOGE,
6841 FL( "Failed to pack an SA Query Request (0x%08x)." ),
6842 nStatus );
6843 // FIXME - Need to convert to tSirRetStatus
6844 nSirStatus = eSIR_FAILURE;
6845 goto returnAfterError;
6846 }
6847 else if ( DOT11F_WARNED( nStatus ))
6848 {
6849 limLog( pMac, LOGW,
6850 FL( "There were warnings while packing SA Query Request (0x%08x)." ),
6851 nStatus);
6852 }
6853
6854 limLog( pMac, LOG1,
6855 FL( "Sending an SA Query Request to " ));
6856 limPrintMacAddr( pMac, peer, LOG1 );
6857 limPrintMacAddr( pMac, peer, LOGE );
6858 limLog( pMac, LOGE,
6859 FL( "Sending an SA Query Request from " ));
6860 limPrintMacAddr( pMac, psessionEntry->selfMacAddr, LOGE );
6861
6862 if ( ( SIR_BAND_5_GHZ == limGetRFBand( psessionEntry->currentOperChannel ) )
6863#ifdef WLAN_FEATURE_P2P
6864 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
6865 ( psessionEntry->pePersona == VOS_P2P_GO_MODE )
6866#endif
6867 )
6868 {
6869 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
6870 }
6871
6872 halstatus = halTxFrame( pMac,
6873 pPacket,
6874 (tANI_U16) nBytes,
6875 HAL_TXRX_FRM_802_11_MGMT,
6876 ANI_TXDIR_TODS,
6877 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
6878 limTxComplete,
6879 pFrame, txFlag );
6880 if ( eHAL_STATUS_SUCCESS != halstatus )
6881 {
6882 PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]" ), halstatus );)
6883 nSirStatus = eSIR_FAILURE;
6884 //Pkt will be freed up by the callback
6885 return nSirStatus;
6886 }
6887 else {
6888 return eSIR_SUCCESS;
6889 }
6890
6891returnAfterError:
6892 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
6893 return nSirStatus;
6894} // End limSendSaQueryRequestFrame
6895
6896/**
Jeff Johnson295189b2012-06-20 16:38:30 -07006897 * \brief Send SA query response action frame to peer
6898 *
6899 * \sa limSendSaQueryResponseFrame
6900 *
6901 *
6902 * \param pMac The global tpAniSirGlobal object
6903 *
Chet Lanctot186b5732013-03-18 10:26:30 -07006904 * \param transId Transaction identifier received in SA query request action frame
Jeff Johnson295189b2012-06-20 16:38:30 -07006905 *
Chet Lanctot186b5732013-03-18 10:26:30 -07006906 * \param peer The Mac address of the AP to which this action frame is addressed
6907 *
6908 * \param psessionEntry The PE session entry
Jeff Johnson295189b2012-06-20 16:38:30 -07006909 *
6910 * \return eSIR_SUCCESS if setup completes successfully
6911 * eSIR_FAILURE is some problem is encountered
6912 */
6913
Chet Lanctot186b5732013-03-18 10:26:30 -07006914tSirRetStatus limSendSaQueryResponseFrame( tpAniSirGlobal pMac, tANI_U8 *transId,
Jeff Johnson295189b2012-06-20 16:38:30 -07006915tSirMacAddr peer,tpPESession psessionEntry)
6916{
6917
Chet Lanctot186b5732013-03-18 10:26:30 -07006918 tDot11fSaQueryRsp frm; // SA query reponse action frame
Jeff Johnson295189b2012-06-20 16:38:30 -07006919 tANI_U8 *pFrame;
6920 tSirRetStatus nSirStatus;
6921 tpSirMacMgmtHdr pMacHdr;
Chet Lanctot186b5732013-03-18 10:26:30 -07006922 tANI_U32 nBytes, nPayload, nStatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07006923 void *pPacket;
6924 eHalStatus halstatus;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05306925 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07006926
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05306927 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Chet Lanctot186b5732013-03-18 10:26:30 -07006928 frm.Category.category = SIR_MAC_ACTION_SA_QUERY;
6929 /*11w action field is :
Jeff Johnson295189b2012-06-20 16:38:30 -07006930 action: 0 --> SA query request action frame
6931 action: 1 --> SA query response action frame */
Chet Lanctot186b5732013-03-18 10:26:30 -07006932 frm.Action.action = SIR_MAC_SA_QUERY_RSP;
6933 /*11w SA query response transId is same as
Jeff Johnson295189b2012-06-20 16:38:30 -07006934 SA query request transId*/
Chet Lanctot186b5732013-03-18 10:26:30 -07006935 vos_mem_copy( &frm.TransactionId.transId[0], &transId[0], 2 );
Jeff Johnson295189b2012-06-20 16:38:30 -07006936
Chet Lanctot186b5732013-03-18 10:26:30 -07006937 nStatus = dot11fGetPackedSaQueryRspSize(pMac, &frm, &nPayload);
6938 if ( DOT11F_FAILED( nStatus ) )
6939 {
6940 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
6941 "or a SA Query Response (0x%08x)."),
6942 nStatus );
6943 // We'll fall back on the worst case scenario:
6944 nPayload = sizeof( tDot11fSaQueryRsp );
6945 }
6946 else if ( DOT11F_WARNED( nStatus ) )
6947 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08006948 limLog( pMac, LOGW, FL("There were warnings while calculating "
Chet Lanctot186b5732013-03-18 10:26:30 -07006949 "the packed size for an SA Query Response"
6950 " (0x%08x)."), nStatus );
6951 }
6952
Jeff Johnson295189b2012-06-20 16:38:30 -07006953 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
6954 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
6955 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
6956 {
6957 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a SA query response"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006958 " action frame"), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07006959 return eSIR_FAILURE;
6960 }
6961
6962 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05306963 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07006964
Chet Lanctot186b5732013-03-18 10:26:30 -07006965 // Copy necessary info to BD
Chet Lanctotb2b0d552013-03-22 16:58:44 -07006966 nSirStatus = limPopulateMacHeader( pMac,
Chet Lanctot186b5732013-03-18 10:26:30 -07006967 pFrame,
6968 SIR_MAC_MGMT_FRAME,
6969 SIR_MAC_MGMT_ACTION,
Chet Lanctotb2b0d552013-03-22 16:58:44 -07006970 peer, psessionEntry->selfMacAddr );
6971 if ( eSIR_SUCCESS != nSirStatus )
Chet Lanctot186b5732013-03-18 10:26:30 -07006972 goto returnAfterError;
Jeff Johnson295189b2012-06-20 16:38:30 -07006973
Chet Lanctot186b5732013-03-18 10:26:30 -07006974 // Update A3 with the BSSID
Jeff Johnson295189b2012-06-20 16:38:30 -07006975 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
6976
Chet Lanctot186b5732013-03-18 10:26:30 -07006977 sirCopyMacAddr( pMacHdr->bssId, psessionEntry->bssId );
Jeff Johnson295189b2012-06-20 16:38:30 -07006978
Chet Lanctot186b5732013-03-18 10:26:30 -07006979 // Since this is a SA Query Response, set the "protect" (aka WEP) bit
6980 // in the FC
Chet Lanctot8cecea22014-02-11 19:09:36 -08006981 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Jeff Johnson295189b2012-06-20 16:38:30 -07006982
Chet Lanctot186b5732013-03-18 10:26:30 -07006983 // Pack 11w SA query response frame
6984 nStatus = dot11fPackSaQueryRsp( pMac,
6985 &frm,
6986 pFrame + sizeof( tSirMacMgmtHdr ),
6987 nPayload,
6988 &nPayload );
6989
6990 if ( DOT11F_FAILED( nStatus ))
6991 {
6992 limLog( pMac, LOGE,
6993 FL( "Failed to pack an SA Query Response (0x%08x)." ),
6994 nStatus );
6995 // FIXME - Need to convert to tSirRetStatus
6996 nSirStatus = eSIR_FAILURE;
6997 goto returnAfterError;
6998 }
6999 else if ( DOT11F_WARNED( nStatus ))
7000 {
7001 limLog( pMac, LOGW,
7002 FL( "There were warnings while packing SA Query Response (0x%08x)." ),
7003 nStatus);
7004 }
7005
7006 limLog( pMac, LOG1,
7007 FL( "Sending a SA Query Response to " ));
7008 limPrintMacAddr( pMac, peer, LOGW );
7009
Chet Lanctotb2b0d552013-03-22 16:58:44 -07007010 if ( ( SIR_BAND_5_GHZ == limGetRFBand( psessionEntry->currentOperChannel ) )
Chet Lanctot186b5732013-03-18 10:26:30 -07007011#ifdef WLAN_FEATURE_P2P
Chet Lanctotb2b0d552013-03-22 16:58:44 -07007012 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
7013 ( psessionEntry->pePersona == VOS_P2P_GO_MODE )
Chet Lanctot186b5732013-03-18 10:26:30 -07007014#endif
Chet Lanctotb2b0d552013-03-22 16:58:44 -07007015 )
7016 {
7017 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
7018 }
Chet Lanctot186b5732013-03-18 10:26:30 -07007019
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05307020 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
7021 psessionEntry->peSessionId,
7022 pMacHdr->fc.subType));
Chet Lanctotb2b0d552013-03-22 16:58:44 -07007023 halstatus = halTxFrame( pMac,
7024 pPacket,
7025 (tANI_U16) nBytes,
7026 HAL_TXRX_FRM_802_11_MGMT,
7027 ANI_TXDIR_TODS,
7028 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
7029 limTxComplete,
7030 pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05307031 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
7032 psessionEntry->peSessionId,
7033 halstatus));
Chet Lanctotb2b0d552013-03-22 16:58:44 -07007034 if ( eHAL_STATUS_SUCCESS != halstatus )
Chet Lanctot186b5732013-03-18 10:26:30 -07007035 {
7036 PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]" ), halstatus );)
7037 nSirStatus = eSIR_FAILURE;
7038 //Pkt will be freed up by the callback
7039 return nSirStatus;
7040 }
7041 else {
7042 return eSIR_SUCCESS;
7043 }
7044
7045returnAfterError:
7046 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
7047 return nSirStatus;
7048} // End limSendSaQueryResponseFrame
Jeff Johnson295189b2012-06-20 16:38:30 -07007049#endif
Abhishek Singh00b71972016-01-07 10:51:04 +05307050
7051#ifdef WLAN_FEATURE_RMC
7052tSirRetStatus
7053limSendRMCActionFrame(tpAniSirGlobal pMac,
7054 tSirMacAddr peerMacAddr,
7055 tSirRMCInfo *pRMC,
7056 tpPESession psessionEntry)
7057{
7058 tSirRetStatus nSirStatus;
7059 tANI_U8 *pFrame;
7060 tDot11fRMC RMC;
7061 tANI_U32 nPayload, nBytes, nStatus;
7062 tpSirMacMgmtHdr pMacHdr;
7063 void *pPacket;
7064 eHalStatus halstatus;
7065 tANI_U8 txFlag = 0;
7066 tANI_U8 MagicCode[] = { 0x4f, 0x58, 0x59, 0x47, 0x45, 0x4e };
7067
7068 if (NULL == psessionEntry)
7069 {
7070 return eSIR_FAILURE;
7071 }
7072
7073 vos_mem_set(( tANI_U8* )&RMC, sizeof( RMC ), 0);
7074
7075 RMC.Action.action = pRMC->action;
7076 RMC.RMCDialogToken.token = pRMC->dialogToken;
7077 RMC.Category.category = SIR_MAC_ACTION_VENDOR_SPECIFIC_CATEGORY;
7078 RMC.RMCVersion.version = SIR_MAC_RMC_VER;
7079
7080 vos_mem_copy(&RMC.RMCOUI.oui, SIR_MAC_RMC_OUI, SIR_MAC_RMC_OUI_SIZE);
7081 vos_mem_copy(&RMC.MagicCode.magic, MagicCode, sizeof(MagicCode));
7082
7083 vos_mem_copy(&RMC.Ruler.mac, pRMC->mcastRuler, sizeof(tSirMacAddr));
7084
7085 nStatus = dot11fGetPackedRMCSize( pMac, &RMC, &nPayload );
7086 if ( DOT11F_FAILED( nStatus ) )
7087 {
7088 limLog( pMac, LOGE, FL("Failed to calculate the packed size for "
7089 "an RMC (0x%08x)."),
7090 nStatus );
7091 // We'll fall back on the worst case scenario:
7092 nPayload = sizeof( tDot11fRMC );
7093 }
7094 else if ( DOT11F_WARNED( nStatus ) )
7095 {
7096 limLog( pMac, LOGW, FL("There were warnings while calculating "
7097 "the packed size for an RMC Action Frame"
7098 " (0x%08x)."), nStatus );
7099 }
7100
7101 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
7102
7103 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
7104 ( tANI_U16 )nBytes, ( void** ) &pFrame,
7105 ( void** ) &pPacket );
7106 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
7107 {
7108 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for an RMC "
7109 "Action Frame."), nBytes );
7110 return eSIR_FAILURE;
7111 }
7112
7113 // Paranoia:
7114 vos_mem_set( pFrame, nBytes, 0 );
7115
7116 // Next, we fill out the buffer descriptor:
7117 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
7118 SIR_MAC_MGMT_ACTION, peerMacAddr,
7119 psessionEntry->selfMacAddr);
7120 if ( eSIR_SUCCESS != nSirStatus )
7121 {
7122 limLog( pMac, LOGE, FL("Failed to populate the buffer descriptor "
7123 "for an RMC Action Frame (%d)."),
7124 nSirStatus );
7125 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
7126 ( void* ) pFrame, ( void* ) pPacket );
7127 return nSirStatus;
7128 }
7129
7130 // Update A3 with the BSSID
7131 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
7132 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
7133
7134 // That done, pack the struct:
7135 nStatus = dot11fPackRMC( pMac, &RMC,
7136 pFrame + sizeof(tSirMacMgmtHdr),
7137 nPayload, &nPayload );
7138 if ( DOT11F_FAILED( nStatus ) )
7139 {
7140 limLog( pMac, LOGE, FL("Failed to pack an RMC "
7141 "(0x%08x)."),
7142 nStatus );
7143 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame,
7144 ( void* ) pPacket );
7145 return eSIR_FAILURE;
7146 }
7147 else if ( DOT11F_WARNED( nStatus ) )
7148 {
7149 limLog( pMac, LOGW, FL("There were warnings while packing "
7150 "an RMC (0x%08x)."), nStatus );
7151 }
7152
7153 limLog( pMac, LOG1, FL("Sending an RMC Action frame to "
7154 MAC_ADDRESS_STR), MAC_ADDR_ARRAY(peerMacAddr));
7155
7156 /*
7157 * With this masking, RMC action frames will be sent
7158 * at self-sta rates for both 2G and 5G bands.
7159 */
7160 txFlag |= HAL_USE_SELF_STA_REQUESTED_MASK;
7161
7162 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
7163 psessionEntry->peSessionId,
7164 pMacHdr->fc.subType));
7165 // Queue RMC Action frame in high priority WQ
7166 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
7167 HAL_TXRX_FRM_802_11_MGMT,
7168 ANI_TXDIR_TODS,
7169 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
7170 limTxComplete, pFrame, txFlag );
7171 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
7172 psessionEntry->peSessionId,
7173 halstatus));
7174 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
7175 {
7176 limLog( pMac, LOGE, FL( "*** Could not send an RMC Action frame"
7177 " (%X) ***" ), halstatus );
7178 //Pkt will be freed up by the callback
7179 return eSIR_FAILURE;
7180 }
7181
7182 return eSIR_SUCCESS;
7183
7184} // End limSendRMCActionFrame.
7185
7186#endif /* WLAN_FEATURE_RMC */