blob: ac90ef6632a43f83cd18c54d53b8a31f4f692f40 [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Abhinav Kumar8eed0362019-08-05 14:26:07 +05302 * Copyright (c) 2011-2019 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
Abhishek Singh02605092017-10-25 14:06:12 +0530801 if (LIM_IS_AP_ROLE(psessionEntry) && psessionEntry->include_ecsa_ie) {
802 populate_dot11f_ext_chann_switch_ann(pMac, &pFrm->ext_chan_switch_ann,
803 psessionEntry);
804 if (psessionEntry->lim11hEnable) {
805 PopulateDot11fChanSwitchAnn(pMac,
806 &pFrm->ChanSwitchAnn, psessionEntry);
807 if (psessionEntry->include_wide_ch_bw_ie)
808 PopulateDot11fWiderBWChanSwitchAnn(pMac,
809 &pFrm->WiderBWChanSwitchAnn, psessionEntry);
810 }
811 }
812
Sandeep Puligilla60342762014-01-30 21:05:37 +0530813
Hardik Kantilal Patelee5874c2015-01-14 15:23:28 +0530814 if ( psessionEntry->pLimStartBssReq )
Jeff Johnson295189b2012-06-20 16:38:30 -0700815 {
816 PopulateDot11fWPA( pMac, &( psessionEntry->pLimStartBssReq->rsnIE ),
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700817 &pFrm->WPA );
Chet Lanctot4b9abd72013-06-27 11:14:56 -0700818 PopulateDot11fRSNOpaque( pMac, &( psessionEntry->pLimStartBssReq->rsnIE ),
819 &pFrm->RSNOpaque );
Jeff Johnson295189b2012-06-20 16:38:30 -0700820 }
821
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700822 PopulateDot11fWMM( pMac, &pFrm->WMMInfoAp, &pFrm->WMMParams, &pFrm->WMMCaps, psessionEntry );
Jeff Johnson295189b2012-06-20 16:38:30 -0700823
824#if defined(FEATURE_WLAN_WAPI)
825 if( psessionEntry->pLimStartBssReq )
826 {
827 PopulateDot11fWAPI( pMac, &( psessionEntry->pLimStartBssReq->rsnIE ),
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700828 &pFrm->WAPI );
Jeff Johnson295189b2012-06-20 16:38:30 -0700829 }
830
831#endif // defined(FEATURE_WLAN_WAPI)
832
Jeff Johnson295189b2012-06-20 16:38:30 -0700833 addnIEPresent = false;
Jeff Johnson295189b2012-06-20 16:38:30 -0700834 if( pMac->lim.gpLimRemainOnChanReq )
835 {
836 nBytes += (pMac->lim.gpLimRemainOnChanReq->length - sizeof( tSirRemainOnChnReq ) );
837 }
838 //Only use CFG for non-listen mode. This CFG is not working for concurrency
839 //In listening mode, probe rsp IEs is passed in the message from SME to PE
840 else
Jeff Johnson295189b2012-06-20 16:38:30 -0700841 {
842
843 if (wlan_cfgGetInt(pMac, WNI_CFG_PROBE_RSP_ADDNIE_FLAG,
844 &addnIEPresent) != eSIR_SUCCESS)
845 {
846 limLog(pMac, LOGP, FL("Unable to get WNI_CFG_PROBE_RSP_ADDNIE_FLAG"));
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530847 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700848 return;
849 }
850 }
851
852 if (addnIEPresent)
853 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530854
855 addIE = vos_mem_malloc(WNI_CFG_PROBE_RSP_ADDNIE_DATA1_LEN*3);
856 if ( NULL == addIE )
Jeff Johnson295189b2012-06-20 16:38:30 -0700857 {
858 PELOGE(limLog(pMac, LOGE,
859 FL("Unable to allocate memory to store addn IE"));)
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530860 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700861 return;
862 }
863
864 //Probe rsp IE available
865 if ( eSIR_SUCCESS != wlan_cfgGetStrLen(pMac,
866 WNI_CFG_PROBE_RSP_ADDNIE_DATA1, &addnIE1Len) )
867 {
868 limLog(pMac, LOGP, FL("Unable to get WNI_CFG_PROBE_RSP_ADDNIE_DATA1 length"));
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530869 vos_mem_free(addIE);
870 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700871 return;
872 }
873 if (addnIE1Len <= WNI_CFG_PROBE_RSP_ADDNIE_DATA1_LEN && addnIE1Len &&
Abhishek Singhafb46052018-02-09 14:10:04 +0530874 (nBytes + addnIE1Len) <= SCH_MAX_PROBE_RESP_SIZE)
Jeff Johnson295189b2012-06-20 16:38:30 -0700875 {
876 if ( eSIR_SUCCESS != wlan_cfgGetStr(pMac,
877 WNI_CFG_PROBE_RSP_ADDNIE_DATA1, &addIE[0],
878 &addnIE1Len) )
879 {
880 limLog(pMac, LOGP,
881 FL("Unable to get WNI_CFG_PROBE_RSP_ADDNIE_DATA1 String"));
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530882 vos_mem_free(addIE);
883 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700884 return;
885 }
886 }
887
888 //Probe rsp IE available
889 if ( eSIR_SUCCESS != wlan_cfgGetStrLen(pMac,
890 WNI_CFG_PROBE_RSP_ADDNIE_DATA2, &addnIE2Len) )
891 {
892 limLog(pMac, LOGP, FL("Unable to get WNI_CFG_PROBE_RSP_ADDNIE_DATA2 length"));
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530893 vos_mem_free(addIE);
894 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700895 return;
896 }
897 if (addnIE2Len <= WNI_CFG_PROBE_RSP_ADDNIE_DATA2_LEN && addnIE2Len &&
Abhishek Singhafb46052018-02-09 14:10:04 +0530898 (nBytes + addnIE2Len) <= SCH_MAX_PROBE_RESP_SIZE)
Jeff Johnson295189b2012-06-20 16:38:30 -0700899 {
900 if ( eSIR_SUCCESS != wlan_cfgGetStr(pMac,
901 WNI_CFG_PROBE_RSP_ADDNIE_DATA2, &addIE[addnIE1Len],
902 &addnIE2Len) )
903 {
904 limLog(pMac, LOGP,
905 FL("Unable to get WNI_CFG_PROBE_RSP_ADDNIE_DATA2 String"));
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530906 vos_mem_free(addIE);
907 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700908 return;
909 }
910 }
911
912 //Probe rsp IE available
913 if ( eSIR_SUCCESS != wlan_cfgGetStrLen(pMac,
914 WNI_CFG_PROBE_RSP_ADDNIE_DATA3, &addnIE3Len) )
915 {
916 limLog(pMac, LOGP, FL("Unable to get WNI_CFG_PROBE_RSP_ADDNIE_DATA3 length"));
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530917 vos_mem_free(addIE);
918 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700919 return;
920 }
921 if (addnIE3Len <= WNI_CFG_PROBE_RSP_ADDNIE_DATA3_LEN && addnIE3Len &&
Abhishek Singhafb46052018-02-09 14:10:04 +0530922 (nBytes + addnIE3Len) <= SCH_MAX_PROBE_RESP_SIZE)
Jeff Johnson295189b2012-06-20 16:38:30 -0700923 {
924 if ( eSIR_SUCCESS != wlan_cfgGetStr(pMac,
925 WNI_CFG_PROBE_RSP_ADDNIE_DATA3,
926 &addIE[addnIE1Len + addnIE2Len],
927 &addnIE3Len) )
928 {
929 limLog(pMac, LOGP,
930 FL("Unable to get WNI_CFG_PROBE_RSP_ADDNIE_DATA3 String"));
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530931 vos_mem_free(addIE);
932 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700933 return;
934 }
935 }
936 totalAddnIeLen = addnIE1Len + addnIE2Len + addnIE3Len;
937
Jeff Johnson295189b2012-06-20 16:38:30 -0700938 if(eSIR_SUCCESS != limGetAddnIeForProbeResp(pMac, addIE, &totalAddnIeLen, probeReqP2pIe))
939 {
940 limLog(pMac, LOGP,
941 FL("Unable to get final Additional IE for Probe Req"));
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530942 vos_mem_free(addIE);
943 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700944 return;
945 }
Kalikinkar dhara205da782014-03-21 15:49:32 -0700946
Kalikinkar dhara205da782014-03-21 15:49:32 -0700947 nSirStatus = limStripOffExtCapIEAndUpdateStruct(pMac,
948 addIE,
949 &totalAddnIeLen,
950 &extractedExtCap );
951 if(eSIR_SUCCESS != nSirStatus )
952 {
953 extractedExtCapFlag = eANI_BOOLEAN_FALSE;
954 limLog(pMac, LOG1,
955 FL("Unable to Stripoff ExtCap IE from Probe Rsp"));
956 }
957
Jeff Johnson295189b2012-06-20 16:38:30 -0700958 nBytes = nBytes + totalAddnIeLen;
Kaushik, Sushanta5ee77a2014-07-30 19:35:25 +0530959 limLog(pMac, LOG1,
960 FL("probe rsp packet size is %d "), nBytes);
Jeff Johnson295189b2012-06-20 16:38:30 -0700961 if (probeReqP2pIe)
962 {
963 pP2pIe = limGetP2pIEPtr(pMac, &addIE[0], totalAddnIeLen);
964 if (pP2pIe != NULL)
965 {
966 //get NoA attribute stream P2P IE
967 noaLen = limGetNoaAttrStream(pMac, noaStream, psessionEntry);
968 if (noaLen != 0)
969 {
970 total_noaLen = limBuildP2pIe(pMac, &noaIe[0],
971 &noaStream[0], noaLen);
972 nBytes = nBytes + total_noaLen;
Kaushik, Sushanta5ee77a2014-07-30 19:35:25 +0530973 limLog(pMac, LOG1,
974 FL("p2p probe rsp packet size is %d, noalength is %d"),
975 nBytes, total_noaLen);
Jeff Johnson295189b2012-06-20 16:38:30 -0700976 }
977 }
978 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700979 }
980
c_hpothubcd78652014-04-28 22:31:08 +0530981 /*merge ExtCap IE*/
982 if (extractedExtCapFlag && extractedExtCap.present)
983 {
Hu Wang5193b572016-08-11 10:04:47 +0800984 limMergeExtCapIEStruct(&pFrm->ExtCap, &extractedExtCap, true);
c_hpothubcd78652014-04-28 22:31:08 +0530985 }
986
987 nStatus = dot11fGetPackedProbeResponseSize( pMac, pFrm, &nPayload );
988 if ( DOT11F_FAILED( nStatus ) )
989 {
990 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
991 "or a Probe Response (0x%08x)."),
992 nStatus );
993 // We'll fall back on the worst case scenario:
994 nPayload = sizeof( tDot11fProbeResponse );
995 }
996 else if ( DOT11F_WARNED( nStatus ) )
997 {
998 limLog( pMac, LOGW, FL("There were warnings while calculating"
999 "the packed size for a Probe Response "
1000 "(0x%08x)."), nStatus );
1001 }
1002
1003 nBytes += nPayload + sizeof( tSirMacMgmtHdr );
1004
Jeff Johnson295189b2012-06-20 16:38:30 -07001005 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1006 ( tANI_U16 )nBytes, ( void** ) &pFrame,
1007 ( void** ) &pPacket );
1008 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1009 {
1010 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Pro"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001011 "be Response."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07001012 if ( addIE != NULL )
1013 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301014 vos_mem_free(addIE);
Jeff Johnson295189b2012-06-20 16:38:30 -07001015 }
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301016 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -07001017 return;
1018 }
1019
1020 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301021 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07001022
1023 // Next, we fill out the buffer descriptor:
1024 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
1025 SIR_MAC_MGMT_PROBE_RSP, peerMacAddr,psessionEntry->selfMacAddr);
1026 if ( eSIR_SUCCESS != nSirStatus )
1027 {
1028 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001029 "tor for a Probe Response (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001030 nSirStatus );
1031 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1032 ( void* ) pFrame, ( void* ) pPacket );
1033 if ( addIE != NULL )
1034 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301035 vos_mem_free(addIE);
Jeff Johnson295189b2012-06-20 16:38:30 -07001036 }
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301037 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -07001038 return;
1039 }
1040
1041 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
1042
1043 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
1044
1045 // That done, pack the Probe Response:
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07001046 nStatus = dot11fPackProbeResponse( pMac, pFrm, pFrame + sizeof(tSirMacMgmtHdr),
Jeff Johnson295189b2012-06-20 16:38:30 -07001047 nPayload, &nPayload );
1048 if ( DOT11F_FAILED( nStatus ) )
1049 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001050 limLog( pMac, LOGE, FL("Failed to pack a Probe Response (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001051 nStatus );
1052 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1053 if ( addIE != NULL )
1054 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301055 vos_mem_free(addIE);
Jeff Johnson295189b2012-06-20 16:38:30 -07001056 }
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301057 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -07001058 return; // allocated!
1059 }
1060 else if ( DOT11F_WARNED( nStatus ) )
1061 {
1062 limLog( pMac, LOGW, FL("There were warnings while packing a P"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001063 "robe Response (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001064 }
1065
1066 PELOG3(limLog( pMac, LOG3, FL("Sending Probe Response frame to ") );
1067 limPrintMacAddr( pMac, peerMacAddr, LOG3 );)
1068
1069 pMac->sys.probeRespond++;
1070
Jeff Johnson295189b2012-06-20 16:38:30 -07001071 if( pMac->lim.gpLimRemainOnChanReq )
1072 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301073 vos_mem_copy ( pFrame+sizeof(tSirMacMgmtHdr)+nPayload,
Jeff Johnson295189b2012-06-20 16:38:30 -07001074 pMac->lim.gpLimRemainOnChanReq->probeRspIe, (pMac->lim.gpLimRemainOnChanReq->length - sizeof( tSirRemainOnChnReq )) );
1075 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001076
1077 if ( addnIEPresent )
1078 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301079 vos_mem_copy(pFrame+sizeof(tSirMacMgmtHdr)+nPayload, &addIE[0], totalAddnIeLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07001080 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001081 if (noaLen != 0)
1082 {
Krunal Soni81b24262013-05-15 17:46:41 -07001083 if (total_noaLen > (SIR_MAX_NOA_ATTR_LEN + SIR_P2P_IE_HEADER_LEN))
Jeff Johnson295189b2012-06-20 16:38:30 -07001084 {
1085 limLog(pMac, LOGE,
Kaushik, Sushant96ac9d72013-12-11 19:28:10 +05301086 FL("Not able to insert NoA because of length constraint."
1087 "Total Length is :%d"),total_noaLen);
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301088 vos_mem_free(addIE);
1089 vos_mem_free(pFrm);
Krunal Soni81b24262013-05-15 17:46:41 -07001090 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1091 ( void* ) pFrame, ( void* ) pPacket );
1092 return;
1093 }
1094 else
1095 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301096 vos_mem_copy( &pFrame[nBytes - (total_noaLen)],
Krunal Soni81b24262013-05-15 17:46:41 -07001097 &noaIe[0], total_noaLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07001098 }
1099 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001100
1101 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07001102 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
1103 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07001104 )
1105 {
1106 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
1107 }
1108
1109 // Queue Probe Response frame in high priority WQ
1110 halstatus = halTxFrame( ( tHalHandle ) pMac, pPacket,
1111 ( tANI_U16 ) nBytes,
1112 HAL_TXRX_FRM_802_11_MGMT,
1113 ANI_TXDIR_TODS,
1114 7,//SMAC_SWBD_TX_TID_MGMT_LOW,
1115 limTxComplete, pFrame, txFlag );
1116 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1117 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001118 limLog( pMac, LOGE, FL("Could not send Probe Response.") );
Jeff Johnson295189b2012-06-20 16:38:30 -07001119 //Pkt will be freed up by the callback
1120 }
1121
1122 if ( addIE != NULL )
1123 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301124 vos_mem_free(addIE);
Jeff Johnson295189b2012-06-20 16:38:30 -07001125 }
1126
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301127 vos_mem_free(pFrm);
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07001128 return;
1129
1130
Jeff Johnson295189b2012-06-20 16:38:30 -07001131} // End limSendProbeRspMgmtFrame.
1132
1133void
1134limSendAddtsReqActionFrame(tpAniSirGlobal pMac,
1135 tSirMacAddr peerMacAddr,
1136 tSirAddtsReqInfo *pAddTS,
1137 tpPESession psessionEntry)
1138{
1139 tANI_U16 i;
1140 tANI_U8 *pFrame;
1141 tSirRetStatus nSirStatus;
1142 tDot11fAddTSRequest AddTSReq;
1143 tDot11fWMMAddTSRequest WMMAddTSReq;
1144 tANI_U32 nPayload, nBytes, nStatus;
1145 tpSirMacMgmtHdr pMacHdr;
1146 void *pPacket;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001147#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07001148 tANI_U32 phyMode;
1149#endif
1150 eHalStatus halstatus;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05301151 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001152
1153 if(NULL == psessionEntry)
1154 {
1155 return;
1156 }
1157
1158 if ( ! pAddTS->wmeTspecPresent )
1159 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301160 vos_mem_set(( tANI_U8* )&AddTSReq, sizeof( AddTSReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001161
1162 AddTSReq.Action.action = SIR_MAC_QOS_ADD_TS_REQ;
1163 AddTSReq.DialogToken.token = pAddTS->dialogToken;
1164 AddTSReq.Category.category = SIR_MAC_ACTION_QOS_MGMT;
1165 if ( pAddTS->lleTspecPresent )
1166 {
1167 PopulateDot11fTSPEC( &pAddTS->tspec, &AddTSReq.TSPEC );
1168 }
1169 else
1170 {
1171 PopulateDot11fWMMTSPEC( &pAddTS->tspec, &AddTSReq.WMMTSPEC );
1172 }
1173
1174 if ( pAddTS->lleTspecPresent )
1175 {
1176 AddTSReq.num_WMMTCLAS = 0;
1177 AddTSReq.num_TCLAS = pAddTS->numTclas;
1178 for ( i = 0; i < pAddTS->numTclas; ++i)
1179 {
1180 PopulateDot11fTCLAS( pMac, &pAddTS->tclasInfo[i],
1181 &AddTSReq.TCLAS[i] );
1182 }
1183 }
1184 else
1185 {
1186 AddTSReq.num_TCLAS = 0;
1187 AddTSReq.num_WMMTCLAS = pAddTS->numTclas;
1188 for ( i = 0; i < pAddTS->numTclas; ++i)
1189 {
1190 PopulateDot11fWMMTCLAS( pMac, &pAddTS->tclasInfo[i],
1191 &AddTSReq.WMMTCLAS[i] );
1192 }
1193 }
1194
1195 if ( pAddTS->tclasProcPresent )
1196 {
1197 if ( pAddTS->lleTspecPresent )
1198 {
1199 AddTSReq.TCLASSPROC.processing = pAddTS->tclasProc;
1200 AddTSReq.TCLASSPROC.present = 1;
1201 }
1202 else
1203 {
1204 AddTSReq.WMMTCLASPROC.version = 1;
1205 AddTSReq.WMMTCLASPROC.processing = pAddTS->tclasProc;
1206 AddTSReq.WMMTCLASPROC.present = 1;
1207 }
1208 }
1209
1210 nStatus = dot11fGetPackedAddTSRequestSize( pMac, &AddTSReq, &nPayload );
1211 if ( DOT11F_FAILED( nStatus ) )
1212 {
1213 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001214 "or an Add TS Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001215 nStatus );
1216 // We'll fall back on the worst case scenario:
1217 nPayload = sizeof( tDot11fAddTSRequest );
1218 }
1219 else if ( DOT11F_WARNED( nStatus ) )
1220 {
1221 limLog( pMac, LOGW, FL("There were warnings while calculating"
1222 "the packed size for an Add TS Request"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001223 " (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001224 }
1225 }
1226 else
1227 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301228 vos_mem_set(( tANI_U8* )&WMMAddTSReq, sizeof( WMMAddTSReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001229
1230 WMMAddTSReq.Action.action = SIR_MAC_QOS_ADD_TS_REQ;
1231 WMMAddTSReq.DialogToken.token = pAddTS->dialogToken;
1232 WMMAddTSReq.Category.category = SIR_MAC_ACTION_WME;
1233
1234 // WMM spec 2.2.10 - status code is only filled in for ADDTS response
1235 WMMAddTSReq.StatusCode.statusCode = 0;
1236
1237 PopulateDot11fWMMTSPEC( &pAddTS->tspec, &WMMAddTSReq.WMMTSPEC );
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001238#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07001239 limGetPhyMode(pMac, &phyMode, psessionEntry);
1240
1241 if( phyMode == WNI_CFG_PHY_MODE_11G || phyMode == WNI_CFG_PHY_MODE_11A)
1242 {
1243 pAddTS->tsrsIE.rates[0] = TSRS_11AG_RATE_6MBPS;
1244 }
1245 else
1246 {
1247 pAddTS->tsrsIE.rates[0] = TSRS_11B_RATE_5_5MBPS;
1248 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001249 PopulateDot11TSRSIE(pMac,&pAddTS->tsrsIE, &WMMAddTSReq.ESETrafStrmRateSet,sizeof(tANI_U8));
Jeff Johnson295189b2012-06-20 16:38:30 -07001250#endif
1251 // fillWmeTspecIE
1252
1253 nStatus = dot11fGetPackedWMMAddTSRequestSize( pMac, &WMMAddTSReq, &nPayload );
1254 if ( DOT11F_FAILED( nStatus ) )
1255 {
1256 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001257 "or a WMM Add TS Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001258 nStatus );
1259 // We'll fall back on the worst case scenario:
1260 nPayload = sizeof( tDot11fAddTSRequest );
1261 }
1262 else if ( DOT11F_WARNED( nStatus ) )
1263 {
1264 limLog( pMac, LOGW, FL("There were warnings while calculating"
1265 "the packed size for a WMM Add TS Requ"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001266 "est (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001267 }
1268 }
1269
1270 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
1271
1272 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1273 ( tANI_U16 )nBytes, ( void** ) &pFrame,
1274 ( void** ) &pPacket );
1275 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1276 {
1277 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for an Ad"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001278 "d TS Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07001279 return;
1280 }
1281
1282 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301283 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07001284
1285 // Next, we fill out the buffer descriptor:
1286 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
1287 SIR_MAC_MGMT_ACTION, peerMacAddr,psessionEntry->selfMacAddr);
1288 if ( eSIR_SUCCESS != nSirStatus )
1289 {
1290 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001291 "tor for an Add TS Request (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001292 nSirStatus );
1293 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1294 ( void* ) pFrame, ( void* ) pPacket );
1295 return;
1296 }
1297
1298 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
1299
1300 #if 0
1301 cfgLen = SIR_MAC_ADDR_LENGTH;
1302 if ( eSIR_SUCCESS != wlan_cfgGetStr( pMac, WNI_CFG_BSSID,
1303 ( tANI_U8* )pMacHdr->bssId, &cfgLen ) )
1304 {
1305 limLog( pMac, LOGP, FL("Failed to retrieve WNI_CFG_BSSID whil"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001306 "e sending an Add TS Request.") );
Jeff Johnson295189b2012-06-20 16:38:30 -07001307 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1308 ( void* ) pFrame, ( void* ) pPacket );
1309 return;
1310 }
1311 #endif //TO SUPPORT BT-AMP
1312
1313 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
1314
Chet Lanctot186b5732013-03-18 10:26:30 -07001315#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07001316 limSetProtectedBit(pMac, psessionEntry, peerMacAddr, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07001317#endif
1318
Jeff Johnson295189b2012-06-20 16:38:30 -07001319 // That done, pack the struct:
1320 if ( ! pAddTS->wmeTspecPresent )
1321 {
1322 nStatus = dot11fPackAddTSRequest( pMac, &AddTSReq,
1323 pFrame + sizeof(tSirMacMgmtHdr),
1324 nPayload, &nPayload );
1325 if ( DOT11F_FAILED( nStatus ) )
1326 {
1327 limLog( pMac, LOGE, FL("Failed to pack an Add TS Request "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001328 "(0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001329 nStatus );
1330 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1331 return; // allocated!
1332 }
1333 else if ( DOT11F_WARNED( nStatus ) )
1334 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001335 limLog( pMac, LOGW, FL("There were warnings while packing "
1336 "an Add TS Request (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001337 }
1338 }
1339 else
1340 {
1341 nStatus = dot11fPackWMMAddTSRequest( pMac, &WMMAddTSReq,
1342 pFrame + sizeof(tSirMacMgmtHdr),
1343 nPayload, &nPayload );
1344 if ( DOT11F_FAILED( nStatus ) )
1345 {
1346 limLog( pMac, LOGE, FL("Failed to pack a WMM Add TS Reque"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001347 "st (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001348 nStatus );
1349 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1350 return; // allocated!
1351 }
1352 else if ( DOT11F_WARNED( nStatus ) )
1353 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001354 limLog( pMac, LOGW, FL("There were warnings while packing "
1355 "a WMM Add TS Request (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001356 }
1357 }
1358
Abhishek Singh127a8442014-12-15 17:31:27 +05301359 limLog( pMac, LOG1, FL("Sending an Add TS Request frame to ") );
1360 limPrintMacAddr( pMac, peerMacAddr, LOG1 );
Jeff Johnson295189b2012-06-20 16:38:30 -07001361
1362 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07001363 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
1364 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07001365 )
1366 {
1367 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
1368 }
1369
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05301370 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
1371 psessionEntry->peSessionId,
1372 pMacHdr->fc.subType));
Jeff Johnson295189b2012-06-20 16:38:30 -07001373 // Queue Addts Response frame in high priority WQ
1374 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
1375 HAL_TXRX_FRM_802_11_MGMT,
1376 ANI_TXDIR_TODS,
1377 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
1378 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05301379 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
1380 psessionEntry->peSessionId,
1381 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07001382 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1383 {
1384 limLog( pMac, LOGE, FL( "*** Could not send an Add TS Request"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001385 " (%X) ***" ), halstatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001386 //Pkt will be freed up by the callback
1387 }
1388
1389} // End limSendAddtsReqActionFrame.
1390
Jeff Johnson295189b2012-06-20 16:38:30 -07001391
1392
1393void
1394limSendAssocRspMgmtFrame(tpAniSirGlobal pMac,
1395 tANI_U16 statusCode,
1396 tANI_U16 aid,
1397 tSirMacAddr peerMacAddr,
1398 tANI_U8 subType,
Kapil Gupta956c0c42017-06-16 19:24:31 +05301399 tpDphHashNode pSta,tpPESession psessionEntry,
1400 assoc_rsp_tx_context *tx_complete_context)
Jeff Johnson295189b2012-06-20 16:38:30 -07001401{
1402 static tDot11fAssocResponse frm;
1403 tANI_U8 *pFrame, *macAddr;
1404 tpSirMacMgmtHdr pMacHdr;
1405 tSirRetStatus nSirStatus;
1406 tANI_U8 lleMode = 0, fAddTS, edcaInclude = 0;
1407 tHalBitVal qosMode, wmeMode;
c_hpothubcd78652014-04-28 22:31:08 +05301408 tANI_U32 nPayload, nStatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07001409 void *pPacket;
1410 eHalStatus halstatus;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05301411 tUpdateBeaconParams beaconParams;
1412 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001413 tANI_U32 addnIEPresent = false;
1414 tANI_U32 addnIELen=0;
1415 tANI_U8 addIE[WNI_CFG_ASSOC_RSP_ADDNIE_DATA_LEN];
1416 tpSirAssocReq pAssocReq = NULL;
Mahesh A Saptasagar38c177e2014-10-17 18:55:48 +05301417 tANI_U16 addStripoffIELen = 0;
1418 tDot11fIEExtCap extractedExtCap;
1419 tANI_BOOLEAN extractedExtCapFlag = eANI_BOOLEAN_FALSE;
c_hpothubcd78652014-04-28 22:31:08 +05301420 tANI_U32 nBytes = 0;
Kalikinkar dhara205da782014-03-21 15:49:32 -07001421
Chet Lanctot8cecea22014-02-11 19:09:36 -08001422#ifdef WLAN_FEATURE_11W
1423 tANI_U32 retryInterval;
1424 tANI_U32 maxRetries;
1425#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001426
1427 if(NULL == psessionEntry)
1428 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05301429 limLog( pMac, LOGE, FL("psessionEntry is NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001430 return;
1431 }
1432
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301433 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07001434
1435 limGetQosMode(psessionEntry, &qosMode);
1436 limGetWmeMode(psessionEntry, &wmeMode);
1437
1438 // An Add TS IE is added only if the AP supports it and the requesting
1439 // STA sent a traffic spec.
1440 fAddTS = ( qosMode && pSta && pSta->qos.addtsPresent ) ? 1 : 0;
1441
1442 PopulateDot11fCapabilities( pMac, &frm.Capabilities, psessionEntry );
1443
1444 frm.Status.status = statusCode;
1445
1446 frm.AID.associd = aid | LIM_AID_MASK;
1447
1448 if ( NULL == pSta )
1449 {
1450 PopulateDot11fSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL, &frm.SuppRates,psessionEntry);
1451 PopulateDot11fExtSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL, &frm.ExtSuppRates, psessionEntry );
1452 }
1453 else
1454 {
1455 PopulateDot11fAssocRspRates( pMac, &frm.SuppRates, &frm.ExtSuppRates,
1456 pSta->supportedRates.llbRates, pSta->supportedRates.llaRates );
1457 }
1458
Jeff Johnson295189b2012-06-20 16:38:30 -07001459 if(psessionEntry->limSystemRole == eLIM_AP_ROLE)
1460 {
1461 if( pSta != NULL && eSIR_SUCCESS == statusCode )
1462 {
1463 pAssocReq =
1464 (tpSirAssocReq) psessionEntry->parsedAssocReq[pSta->assocId];
Jeff Johnson295189b2012-06-20 16:38:30 -07001465 /* populate P2P IE in AssocRsp when assocReq from the peer includes P2P IE */
1466 if( pAssocReq != NULL && pAssocReq->addIEPresent ) {
1467 PopulateDot11AssocResP2PIE(pMac, &frm.P2PAssocRes, pAssocReq);
1468 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001469 }
1470 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001471
1472 if ( NULL != pSta )
1473 {
1474 if ( eHAL_SET == qosMode )
1475 {
1476 if ( pSta->lleEnabled )
1477 {
1478 lleMode = 1;
1479 if ( ( ! pSta->aniPeer ) || ( ! PROP_CAPABILITY_GET( 11EQOS, pSta->propCapability ) ) )
1480 {
1481 PopulateDot11fEDCAParamSet( pMac, &frm.EDCAParamSet, psessionEntry);
1482
1483// FramesToDo:...
1484// if ( fAddTS )
1485// {
1486// tANI_U8 *pAf = pBody;
1487// *pAf++ = SIR_MAC_QOS_ACTION_EID;
1488// tANI_U32 tlen;
1489// status = sirAddtsRspFill(pMac, pAf, statusCode, &pSta->qos.addts, NULL,
1490// &tlen, bufLen - frameLen);
1491// } // End if on Add TS.
1492 }
1493 } // End if on .11e enabled in 'pSta'.
1494 } // End if on QOS Mode on.
1495
1496 if ( ( ! lleMode ) && ( eHAL_SET == wmeMode ) && pSta->wmeEnabled )
1497 {
1498 if ( ( ! pSta->aniPeer ) || ( ! PROP_CAPABILITY_GET( WME, pSta->propCapability ) ) )
1499 {
1500
Jeff Johnson295189b2012-06-20 16:38:30 -07001501 PopulateDot11fWMMParams( pMac, &frm.WMMParams, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07001502
1503 if ( pSta->wsmEnabled )
1504 {
1505 PopulateDot11fWMMCaps(&frm.WMMCaps );
1506 }
1507 }
1508 }
1509
1510 if ( pSta->aniPeer )
1511 {
1512 if ( ( lleMode && PROP_CAPABILITY_GET( 11EQOS, pSta->propCapability ) ) ||
1513 ( pSta->wmeEnabled && PROP_CAPABILITY_GET( WME, pSta->propCapability ) ) )
1514 {
1515 edcaInclude = 1;
1516 }
1517
1518 } // End if on Airgo peer.
1519
1520 if ( pSta->mlmStaContext.htCapability &&
Jeff Johnsone7245742012-09-05 17:12:55 -07001521 psessionEntry->htCapability )
Jeff Johnson295189b2012-06-20 16:38:30 -07001522 {
Krishna Kumaar Natarajan025a8602015-08-04 16:31:36 +05301523 limLog(pMac, LOG1, FL("Populate HT IEs in Assoc Response"));
Jeff Johnsone7245742012-09-05 17:12:55 -07001524 PopulateDot11fHTCaps( pMac, psessionEntry, &frm.HTCaps );
Sachin Ahujac3a26232014-09-23 22:27:30 +05301525 /*
1526 *Check the STA capability and update the HTCaps accordingly
1527 */
1528 frm.HTCaps.supportedChannelWidthSet =
1529 (pSta->htSupportedChannelWidthSet < psessionEntry->htSupportedChannelWidthSet) ?
1530 pSta->htSupportedChannelWidthSet : psessionEntry->htSupportedChannelWidthSet ;
1531
1532 if (!frm.HTCaps.supportedChannelWidthSet)
1533 frm.HTCaps.shortGI40MHz = 0;
1534
Jeff Johnson295189b2012-06-20 16:38:30 -07001535 PopulateDot11fHTInfo( pMac, &frm.HTInfo, psessionEntry );
Jeff Johnson295189b2012-06-20 16:38:30 -07001536 }
Agrawal Ashishb10d0392015-08-06 16:18:20 +05301537 limLog(pMac, LOG1, FL("SupportedChnlWidth: %d, mimoPS: %d, GF: %d,"
1538 "shortGI20:%d, shortGI40: %d, dsssCck: %d, AMPDU Param: %x"),
1539 frm.HTCaps.supportedChannelWidthSet, frm.HTCaps.mimoPowerSave,
1540 frm.HTCaps.greenField, frm.HTCaps.shortGI20MHz, frm.HTCaps.shortGI40MHz,
1541 frm.HTCaps.dsssCckMode40MHz, frm.HTCaps.maxRxAMPDUFactor);
1542
1543
Jeff Johnsone7245742012-09-05 17:12:55 -07001544
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301545#ifdef WLAN_FEATURE_AP_HT40_24G
1546 /* Populate Overlapping BSS Scan Parameters IEs,
1547 * when operating in HT40 in 2.4GHz.
1548 */
Hardik Kantilal Patel3c235242015-01-02 17:56:18 +05301549 if ((pMac->roam.configParam.apHT40_24GEnabled)
1550 && (IS_DOT11_MODE_HT(psessionEntry->dot11mode)))
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301551 {
1552 PopulateDot11fOBSSScanParameters( pMac, &frm.OBSSScanParameters,
1553 psessionEntry);
Hardik Kantilal Patelee5874c2015-01-14 15:23:28 +05301554 /* 10.15.8 Support of DSSS/CCK in 40 MHz, An associated HT STA in
1555 * a 20/40 MHz BSS may generate DSSS/CCK transmissions.Set DSSS/CCK
1556 * Mode in 40 MHz bit in HT capablity.
1557 */
1558 frm.HTCaps.dsssCckMode40MHz = 1;
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301559 }
1560#endif
1561
1562 PopulateDot11fExtCap( pMac, &frm.ExtCap, psessionEntry);
Jeff Johnsone7245742012-09-05 17:12:55 -07001563#ifdef WLAN_FEATURE_11AC
1564 if( pSta->mlmStaContext.vhtCapability &&
1565 psessionEntry->vhtCapability )
1566 {
Chet Lanctotf19c1f62013-12-13 13:56:21 -08001567 limLog( pMac, LOG1, FL("Populate VHT IEs in Assoc Response"));
Abhishek Singh33f76ea2015-06-04 12:27:30 +05301568 PopulateDot11fVHTCaps( pMac, &frm.VHTCaps,
1569 psessionEntry->currentOperChannel, eSIR_TRUE );
1570 PopulateDot11fVHTOperation( pMac, &frm.VHTOperation,
1571 psessionEntry->currentOperChannel);
Jeff Johnsone7245742012-09-05 17:12:55 -07001572 }
1573#endif
1574
Chet Lanctot8cecea22014-02-11 19:09:36 -08001575#ifdef WLAN_FEATURE_11W
Dino Myclea7f18452014-04-24 08:55:31 +05301576 if( eSIR_MAC_TRY_AGAIN_LATER == statusCode )
1577 {
Chet Lanctotfadc8e32014-04-24 14:50:52 -07001578 if ( wlan_cfgGetInt(pMac, WNI_CFG_PMF_SA_QUERY_MAX_RETRIES,
1579 &maxRetries ) != eSIR_SUCCESS )
1580 limLog( pMac, LOGE,
1581 FL("Could not retrieve PMF SA Query maximum retries value") );
1582 else
1583 if ( wlan_cfgGetInt(pMac, WNI_CFG_PMF_SA_QUERY_RETRY_INTERVAL,
1584 &retryInterval ) != eSIR_SUCCESS)
1585 limLog( pMac, LOGE,
1586 FL("Could not retrieve PMF SA Query timer interval value") );
Dino Myclea7f18452014-04-24 08:55:31 +05301587 else
Chet Lanctotfadc8e32014-04-24 14:50:52 -07001588 PopulateDot11fTimeoutInterval(
1589 pMac, &frm.TimeoutInterval, SIR_MAC_TI_TYPE_ASSOC_COMEBACK,
1590 (maxRetries - pSta->pmfSaQueryRetryCount) * retryInterval );
Dino Myclea7f18452014-04-24 08:55:31 +05301591 }
Chet Lanctot8cecea22014-02-11 19:09:36 -08001592#endif
Dino Myclea7f18452014-04-24 08:55:31 +05301593 } // End if on non-NULL 'pSta'.
Jeff Johnson295189b2012-06-20 16:38:30 -07001594
Chet Lanctot8cecea22014-02-11 19:09:36 -08001595 vos_mem_set(( tANI_U8* )&beaconParams, sizeof( tUpdateBeaconParams), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001596
Jeff Johnson295189b2012-06-20 16:38:30 -07001597 if( psessionEntry->limSystemRole == eLIM_AP_ROLE ){
1598 if(psessionEntry->gLimProtectionControl != WNI_CFG_FORCE_POLICY_PROTECTION_DISABLE)
1599 limDecideApProtection(pMac, peerMacAddr, &beaconParams,psessionEntry);
1600 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001601
1602 limUpdateShortPreamble(pMac, peerMacAddr, &beaconParams, psessionEntry);
1603 limUpdateShortSlotTime(pMac, peerMacAddr, &beaconParams, psessionEntry);
1604
1605 beaconParams.bssIdx = psessionEntry->bssIdx;
1606
1607 //Send message to HAL about beacon parameter change.
1608 if(beaconParams.paramChangeBitmap)
1609 {
1610 schSetFixedBeaconFields(pMac,psessionEntry);
1611 limSendBeaconParams(pMac, &beaconParams, psessionEntry );
1612 }
1613
Jeff Johnson295189b2012-06-20 16:38:30 -07001614 if ( pAssocReq != NULL )
1615 {
1616 if (wlan_cfgGetInt(pMac, WNI_CFG_ASSOC_RSP_ADDNIE_FLAG,
1617 &addnIEPresent) != eSIR_SUCCESS)
1618 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05301619 limLog(pMac, LOGP, FL("Unable to get "
1620 "WNI_CFG_ASSOC_RSP_ADDNIE_FLAG"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001621 return;
1622 }
1623
1624 if (addnIEPresent)
1625 {
1626 //Assoc rsp IE available
1627 if (wlan_cfgGetStrLen(pMac, WNI_CFG_ASSOC_RSP_ADDNIE_DATA,
1628 &addnIELen) != eSIR_SUCCESS)
1629 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05301630 limLog(pMac, LOGP, FL("Unable to get "
1631 "WNI_CFG_ASSOC_RSP_ADDNIE_DATA length"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001632 return;
1633 }
1634
1635 if (addnIELen <= WNI_CFG_ASSOC_RSP_ADDNIE_DATA_LEN && addnIELen &&
1636 (nBytes + addnIELen) <= SIR_MAX_PACKET_SIZE)
1637 {
1638 if (wlan_cfgGetStr(pMac, WNI_CFG_ASSOC_RSP_ADDNIE_DATA,
1639 &addIE[0], &addnIELen) == eSIR_SUCCESS)
1640 {
Mahesh A Saptasagar38c177e2014-10-17 18:55:48 +05301641
1642 vos_mem_set(( tANI_U8* )&extractedExtCap,
1643 sizeof( tDot11fIEExtCap ), 0);
Mahesh A Saptasagare00ff532014-10-17 19:05:14 +05301644 addStripoffIELen = addnIELen;
Mahesh A Saptasagar38c177e2014-10-17 18:55:48 +05301645 nSirStatus = limStripOffExtCapIEAndUpdateStruct(pMac,
1646 &addIE[0],
1647 &addStripoffIELen,
1648 &extractedExtCap );
1649 if(eSIR_SUCCESS != nSirStatus)
1650 {
1651 limLog(pMac, LOG1,
1652 FL("Unable to Stripoff ExtCap IE from Assoc Rsp"));
1653 }
1654 else
1655 {
1656 addnIELen = addStripoffIELen;
1657 extractedExtCapFlag = eANI_BOOLEAN_TRUE;
1658 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001659 nBytes = nBytes + addnIELen;
1660 }
1661 }
1662 }
1663 }
1664
Mahesh A Saptasagar38c177e2014-10-17 18:55:48 +05301665 /* merge the ExtCap struct*/
1666 if (extractedExtCapFlag && extractedExtCap.present)
1667 {
Hu Wang5193b572016-08-11 10:04:47 +08001668 limMergeExtCapIEStruct(&(frm.ExtCap), &extractedExtCap, true);
Mahesh A Saptasagar38c177e2014-10-17 18:55:48 +05301669 }
1670
c_hpothubcd78652014-04-28 22:31:08 +05301671 nStatus = dot11fGetPackedAssocResponseSize( pMac, &frm, &nPayload );
1672 if ( DOT11F_FAILED( nStatus ) )
1673 {
1674 limLog( pMac, LOGE, FL("Failed to calculate the packed size f"
1675 "or an Association Response (0x%08x)."),
1676 nStatus );
1677 return;
1678 }
1679 else if ( DOT11F_WARNED( nStatus ) )
1680 {
1681 limLog( pMac, LOGW, FL("There were warnings while calculating "
1682 "the packed size for an Association Re"
1683 "sponse (0x%08x)."), nStatus );
1684 }
1685
1686 nBytes += sizeof( tSirMacMgmtHdr ) + nPayload;
1687
Jeff Johnson295189b2012-06-20 16:38:30 -07001688 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1689 ( tANI_U16 )nBytes, ( void** ) &pFrame,
1690 ( void** ) &pPacket );
1691 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1692 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001693 limLog(pMac, LOGP, FL("Call to bufAlloc failed for RE/ASSOC RSP."));
Jeff Johnson295189b2012-06-20 16:38:30 -07001694 return;
1695 }
1696
1697 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301698 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07001699
1700 // Next, we fill out the buffer descriptor:
1701 nSirStatus = limPopulateMacHeader( pMac,
1702 pFrame,
1703 SIR_MAC_MGMT_FRAME,
1704 ( LIM_ASSOC == subType ) ?
1705 SIR_MAC_MGMT_ASSOC_RSP :
1706 SIR_MAC_MGMT_REASSOC_RSP,
1707 peerMacAddr,psessionEntry->selfMacAddr);
1708 if ( eSIR_SUCCESS != nSirStatus )
1709 {
1710 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001711 "tor for an Association Response (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001712 nSirStatus );
1713 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1714 ( void* ) pFrame, ( void* ) pPacket );
1715 return;
1716 }
1717
1718 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
1719
Jeff Johnson295189b2012-06-20 16:38:30 -07001720 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
1721
1722 nStatus = dot11fPackAssocResponse( pMac, &frm,
1723 pFrame + sizeof( tSirMacMgmtHdr ),
1724 nPayload, &nPayload );
1725 if ( DOT11F_FAILED( nStatus ) )
1726 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05301727 limLog( pMac, LOGE, FL("Failed to pack an Association Response"
1728 " (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001729 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1730 ( void* ) pFrame, ( void* ) pPacket );
1731 return; // allocated!
1732 }
1733 else if ( DOT11F_WARNED( nStatus ) )
1734 {
1735 limLog( pMac, LOGW, FL("There were warnings while packing an "
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001736 "Association Response (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001737 }
1738
1739 macAddr = pMacHdr->da;
1740
1741 if (subType == LIM_ASSOC)
1742 {
Abhishek Singh3cbf6052014-12-15 16:46:42 +05301743 limLog(pMac, LOG1,
Jeff Johnson295189b2012-06-20 16:38:30 -07001744 FL("*** Sending Assoc Resp status %d aid %d to "),
Abhishek Singh3cbf6052014-12-15 16:46:42 +05301745 statusCode, aid);
Jeff Johnson295189b2012-06-20 16:38:30 -07001746 }
1747 else{
Abhishek Singh3cbf6052014-12-15 16:46:42 +05301748 limLog(pMac, LOG1,
Jeff Johnson295189b2012-06-20 16:38:30 -07001749 FL("*** Sending ReAssoc Resp status %d aid %d to "),
Abhishek Singh3cbf6052014-12-15 16:46:42 +05301750 statusCode, aid);
Jeff Johnson295189b2012-06-20 16:38:30 -07001751 }
Abhishek Singh3cbf6052014-12-15 16:46:42 +05301752 limPrintMacAddr(pMac, pMacHdr->da, LOG1);
Jeff Johnson295189b2012-06-20 16:38:30 -07001753
1754 if ( addnIEPresent )
1755 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301756 vos_mem_copy ( pFrame+sizeof(tSirMacMgmtHdr)+nPayload, &addIE[0], addnIELen ) ;
Jeff Johnson295189b2012-06-20 16:38:30 -07001757 }
1758
1759 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07001760 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
1761 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07001762 )
1763 {
1764 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
1765 }
1766
Agarwal Ashisha8e81f52014-04-02 01:59:52 +05301767 limLog( pMac, LOG1, FL("Sending Assoc resp over WQ5 to "MAC_ADDRESS_STR
1768 " From " MAC_ADDRESS_STR),MAC_ADDR_ARRAY(pMacHdr->da),
1769 MAC_ADDR_ARRAY(psessionEntry->selfMacAddr));
1770
1771 txFlag |= HAL_USE_FW_IN_TX_PATH;
1772
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05301773 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
1774 psessionEntry->peSessionId,
1775 pMacHdr->fc.subType));
Ganesh Kondabattiniffc00b12015-03-18 13:11:33 +05301776
1777 if (IS_FEATURE_SUPPORTED_BY_FW(ENHANCED_TXBD_COMPLETION))
1778 {
Kapil Gupta956c0c42017-06-16 19:24:31 +05301779 limLog(pMac, LOG1, FL("Re/AssocRsp - txBdToken %u"),
1780 pMac->lim.txBdToken);
Ganesh Kondabattiniffc00b12015-03-18 13:11:33 +05301781 /// Queue Association Response frame in high priority WQ
Kapil Gupta956c0c42017-06-16 19:24:31 +05301782 if (tx_complete_context)
1783 {
1784 tx_complete_context->txBdToken = pMac->lim.txBdToken;
1785 halstatus = halTxFrameWithTxComplete(pMac, pPacket,
1786 (tANI_U16) nBytes,
1787 HAL_TXRX_FRM_802_11_MGMT,
1788 ANI_TXDIR_TODS,
1789 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
1790 limTxComplete, pFrame, limAssocRspTxCompleteCnf,
1791 txFlag, pMac->lim.txBdToken);
1792 }
1793 else
1794 halstatus = halTxFrameWithTxComplete(pMac, pPacket,
1795 (tANI_U16) nBytes,
Ganesh Kondabattiniffc00b12015-03-18 13:11:33 +05301796 HAL_TXRX_FRM_802_11_MGMT,
1797 ANI_TXDIR_TODS,
1798 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
1799 limTxComplete, pFrame, limTxBdComplete,
Kapil Gupta956c0c42017-06-16 19:24:31 +05301800 txFlag, pMac->lim.txBdToken);
1801
Ganesh Kondabattiniffc00b12015-03-18 13:11:33 +05301802 pMac->lim.txBdToken++;
1803 }
1804 else
1805 {
1806 /// Queue Association Response frame in high priority WQ
1807 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
1808 HAL_TXRX_FRM_802_11_MGMT,
1809 ANI_TXDIR_TODS,
1810 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
1811 limTxComplete, pFrame, txFlag );
1812 }
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05301813 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
1814 psessionEntry->peSessionId,
1815 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07001816 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1817 {
1818 limLog(pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001819 FL("*** Could not Send Re/AssocRsp, retCode=%X ***"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001820 nSirStatus);
1821
1822 //Pkt will be freed up by the callback
1823 }
1824
1825 // update the ANI peer station count
1826 //FIXME_PROTECTION : take care of different type of station
1827 // counter inside this function.
1828 limUtilCountStaAdd(pMac, pSta, psessionEntry);
1829
1830} // End limSendAssocRspMgmtFrame.
1831
1832
1833
1834void
1835limSendAddtsRspActionFrame(tpAniSirGlobal pMac,
1836 tSirMacAddr peer,
1837 tANI_U16 nStatusCode,
1838 tSirAddtsReqInfo *pAddTS,
1839 tSirMacScheduleIE *pSchedule,
1840 tpPESession psessionEntry)
1841{
1842 tANI_U8 *pFrame;
1843 tpSirMacMgmtHdr pMacHdr;
1844 tDot11fAddTSResponse AddTSRsp;
1845 tDot11fWMMAddTSResponse WMMAddTSRsp;
1846 tSirRetStatus nSirStatus;
1847 tANI_U32 i, nBytes, nPayload, nStatus;
1848 void *pPacket;
1849 eHalStatus halstatus;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05301850 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001851
1852 if(NULL == psessionEntry)
1853 {
1854 return;
1855 }
1856
1857 if ( ! pAddTS->wmeTspecPresent )
1858 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301859 vos_mem_set( ( tANI_U8* )&AddTSRsp, sizeof( AddTSRsp ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07001860
1861 AddTSRsp.Category.category = SIR_MAC_ACTION_QOS_MGMT;
1862 AddTSRsp.Action.action = SIR_MAC_QOS_ADD_TS_RSP;
1863 AddTSRsp.DialogToken.token = pAddTS->dialogToken;
1864 AddTSRsp.Status.status = nStatusCode;
1865
1866 // The TsDelay information element is only filled in for a specific
1867 // status code:
1868 if ( eSIR_MAC_TS_NOT_CREATED_STATUS == nStatusCode )
1869 {
1870 if ( pAddTS->wsmTspecPresent )
1871 {
1872 AddTSRsp.WMMTSDelay.version = 1;
1873 AddTSRsp.WMMTSDelay.delay = 10;
1874 AddTSRsp.WMMTSDelay.present = 1;
1875 }
1876 else
1877 {
1878 AddTSRsp.TSDelay.delay = 10;
1879 AddTSRsp.TSDelay.present = 1;
1880 }
1881 }
1882
1883 if ( pAddTS->wsmTspecPresent )
1884 {
1885 PopulateDot11fWMMTSPEC( &pAddTS->tspec, &AddTSRsp.WMMTSPEC );
1886 }
1887 else
1888 {
1889 PopulateDot11fTSPEC( &pAddTS->tspec, &AddTSRsp.TSPEC );
1890 }
1891
1892 if ( pAddTS->wsmTspecPresent )
1893 {
1894 AddTSRsp.num_WMMTCLAS = 0;
1895 AddTSRsp.num_TCLAS = pAddTS->numTclas;
1896 for ( i = 0; i < AddTSRsp.num_TCLAS; ++i)
1897 {
1898 PopulateDot11fTCLAS( pMac, &pAddTS->tclasInfo[i],
1899 &AddTSRsp.TCLAS[i] );
1900 }
1901 }
1902 else
1903 {
1904 AddTSRsp.num_TCLAS = 0;
1905 AddTSRsp.num_WMMTCLAS = pAddTS->numTclas;
1906 for ( i = 0; i < AddTSRsp.num_WMMTCLAS; ++i)
1907 {
1908 PopulateDot11fWMMTCLAS( pMac, &pAddTS->tclasInfo[i],
1909 &AddTSRsp.WMMTCLAS[i] );
1910 }
1911 }
1912
1913 if ( pAddTS->tclasProcPresent )
1914 {
1915 if ( pAddTS->wsmTspecPresent )
1916 {
1917 AddTSRsp.WMMTCLASPROC.version = 1;
1918 AddTSRsp.WMMTCLASPROC.processing = pAddTS->tclasProc;
1919 AddTSRsp.WMMTCLASPROC.present = 1;
1920 }
1921 else
1922 {
1923 AddTSRsp.TCLASSPROC.processing = pAddTS->tclasProc;
1924 AddTSRsp.TCLASSPROC.present = 1;
1925 }
1926 }
1927
1928 // schedule element is included only if requested in the tspec and we are
1929 // using hcca (or both edca and hcca)
1930 // 11e-D8.0 is inconsistent on whether the schedule element is included
1931 // based on tspec schedule bit or not. Sec 7.4.2.2. says one thing but
1932 // pg 46, line 17-18 says something else. So just include it and let the
1933 // sta figure it out
1934 if ((pSchedule != NULL) &&
1935 ((pAddTS->tspec.tsinfo.traffic.accessPolicy == SIR_MAC_ACCESSPOLICY_HCCA) ||
1936 (pAddTS->tspec.tsinfo.traffic.accessPolicy == SIR_MAC_ACCESSPOLICY_BOTH)))
1937 {
1938 if ( pAddTS->wsmTspecPresent )
1939 {
1940 PopulateDot11fWMMSchedule( pSchedule, &AddTSRsp.WMMSchedule );
1941 }
1942 else
1943 {
1944 PopulateDot11fSchedule( pSchedule, &AddTSRsp.Schedule );
1945 }
1946 }
1947
1948 nStatus = dot11fGetPackedAddTSResponseSize( pMac, &AddTSRsp, &nPayload );
1949 if ( DOT11F_FAILED( nStatus ) )
1950 {
1951 limLog( pMac, LOGP, FL("Failed to calculate the packed si"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001952 "ze for an Add TS Response (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001953 nStatus );
1954 // We'll fall back on the worst case scenario:
1955 nPayload = sizeof( tDot11fAddTSResponse );
1956 }
1957 else if ( DOT11F_WARNED( nStatus ) )
1958 {
1959 limLog( pMac, LOGW, FL("There were warnings while calcula"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001960 "ting the packed size for an Add TS"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001961 " Response (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001962 }
1963 }
1964 else
1965 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301966 vos_mem_set( ( tANI_U8* )&WMMAddTSRsp, sizeof( WMMAddTSRsp ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07001967
1968 WMMAddTSRsp.Category.category = SIR_MAC_ACTION_WME;
1969 WMMAddTSRsp.Action.action = SIR_MAC_QOS_ADD_TS_RSP;
1970 WMMAddTSRsp.DialogToken.token = pAddTS->dialogToken;
1971 WMMAddTSRsp.StatusCode.statusCode = (tANI_U8)nStatusCode;
1972
1973 PopulateDot11fWMMTSPEC( &pAddTS->tspec, &WMMAddTSRsp.WMMTSPEC );
1974
1975 nStatus = dot11fGetPackedWMMAddTSResponseSize( pMac, &WMMAddTSRsp, &nPayload );
1976 if ( DOT11F_FAILED( nStatus ) )
1977 {
1978 limLog( pMac, LOGP, FL("Failed to calculate the packed si"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001979 "ze for a WMM Add TS Response (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001980 nStatus );
1981 // We'll fall back on the worst case scenario:
1982 nPayload = sizeof( tDot11fWMMAddTSResponse );
1983 }
1984 else if ( DOT11F_WARNED( nStatus ) )
1985 {
1986 limLog( pMac, LOGW, FL("There were warnings while calcula"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001987 "ting the packed size for a WMM Add"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001988 "TS Response (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001989 }
1990 }
1991
1992 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
1993
1994 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
1995 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1996 {
1997 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for an Ad"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001998 "d TS Response."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07001999 return;
2000 }
2001
2002 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302003 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07002004
2005 // Next, we fill out the buffer descriptor:
2006 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
2007 SIR_MAC_MGMT_ACTION, peer,psessionEntry->selfMacAddr);
2008 if ( eSIR_SUCCESS != nSirStatus )
2009 {
2010 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002011 "tor for an Add TS Response (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002012 nSirStatus );
2013 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
2014 return; // allocated!
2015 }
2016
2017 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
2018
2019
2020 #if 0
2021 if ( eSIR_SUCCESS != wlan_cfgGetStr( pMac, WNI_CFG_BSSID,
2022 ( tANI_U8* )pMacHdr->bssId, &cfgLen ) )
2023 {
2024 limLog( pMac, LOGP, FL("Failed to retrieve WNI_CFG_BSSID whil"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002025 "e sending an Add TS Response.") );
Jeff Johnson295189b2012-06-20 16:38:30 -07002026 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
2027 return; // allocated!
2028 }
2029 #endif //TO SUPPORT BT-AMP
2030 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
2031
Chet Lanctot186b5732013-03-18 10:26:30 -07002032#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07002033 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07002034#endif
2035
Jeff Johnson295189b2012-06-20 16:38:30 -07002036 // That done, pack the struct:
2037 if ( ! pAddTS->wmeTspecPresent )
2038 {
2039 nStatus = dot11fPackAddTSResponse( pMac, &AddTSRsp,
2040 pFrame + sizeof( tSirMacMgmtHdr ),
2041 nPayload, &nPayload );
2042 if ( DOT11F_FAILED( nStatus ) )
2043 {
2044 limLog( pMac, LOGE, FL("Failed to pack an Add TS Response "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002045 "(0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002046 nStatus );
2047 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
2048 return;
2049 }
2050 else if ( DOT11F_WARNED( nStatus ) )
2051 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08002052 limLog( pMac, LOGW, FL("There were warnings while packing "
2053 "an Add TS Response (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07002054 }
2055 }
2056 else
2057 {
2058 nStatus = dot11fPackWMMAddTSResponse( pMac, &WMMAddTSRsp,
2059 pFrame + sizeof( tSirMacMgmtHdr ),
2060 nPayload, &nPayload );
2061 if ( DOT11F_FAILED( nStatus ) )
2062 {
2063 limLog( pMac, LOGE, FL("Failed to pack a WMM Add TS Response "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002064 "(0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002065 nStatus );
2066 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
2067 return;
2068 }
2069 else if ( DOT11F_WARNED( nStatus ) )
2070 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08002071 limLog( pMac, LOGW, FL("There were warnings while packing "
2072 "a WMM Add TS Response (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07002073 }
2074 }
2075
Abhishek Singh3cbf6052014-12-15 16:46:42 +05302076 limLog( pMac, LOG1, FL("Sending an Add TS Response (status %d) to "),
Jeff Johnson295189b2012-06-20 16:38:30 -07002077 nStatusCode );
Abhishek Singh3cbf6052014-12-15 16:46:42 +05302078 limPrintMacAddr( pMac, pMacHdr->da, LOG1 );
Jeff Johnson295189b2012-06-20 16:38:30 -07002079
2080 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07002081 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
2082 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07002083 )
2084 {
2085 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
2086 }
2087
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05302088 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
2089 psessionEntry->peSessionId,
2090 pMacHdr->fc.subType));
Jeff Johnson295189b2012-06-20 16:38:30 -07002091 // Queue the frame in high priority WQ:
2092 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
2093 HAL_TXRX_FRM_802_11_MGMT,
2094 ANI_TXDIR_TODS,
2095 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
2096 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05302097 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
2098 psessionEntry->peSessionId,
2099 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07002100 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
2101 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002102 limLog( pMac, LOGE, FL("Failed to send Add TS Response (%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002103 nSirStatus );
2104 //Pkt will be freed up by the callback
2105 }
2106
2107} // End limSendAddtsRspActionFrame.
2108
2109void
2110limSendDeltsReqActionFrame(tpAniSirGlobal pMac,
2111 tSirMacAddr peer,
2112 tANI_U8 wmmTspecPresent,
2113 tSirMacTSInfo *pTsinfo,
2114 tSirMacTspecIE *pTspecIe,
2115 tpPESession psessionEntry)
2116{
2117 tANI_U8 *pFrame;
2118 tpSirMacMgmtHdr pMacHdr;
2119 tDot11fDelTS DelTS;
2120 tDot11fWMMDelTS WMMDelTS;
2121 tSirRetStatus nSirStatus;
2122 tANI_U32 nBytes, nPayload, nStatus;
2123 void *pPacket;
2124 eHalStatus halstatus;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05302125 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002126
2127 if(NULL == psessionEntry)
2128 {
2129 return;
2130 }
2131
2132 if ( ! wmmTspecPresent )
2133 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302134 vos_mem_set( ( tANI_U8* )&DelTS, sizeof( DelTS ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07002135
2136 DelTS.Category.category = SIR_MAC_ACTION_QOS_MGMT;
2137 DelTS.Action.action = SIR_MAC_QOS_DEL_TS_REQ;
2138 PopulateDot11fTSInfo( pTsinfo, &DelTS.TSInfo );
2139
2140 nStatus = dot11fGetPackedDelTSSize( pMac, &DelTS, &nPayload );
2141 if ( DOT11F_FAILED( nStatus ) )
2142 {
2143 limLog( pMac, LOGP, FL("Failed to calculate the packed si"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002144 "ze for a Del TS (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002145 nStatus );
2146 // We'll fall back on the worst case scenario:
2147 nPayload = sizeof( tDot11fDelTS );
2148 }
2149 else if ( DOT11F_WARNED( nStatus ) )
2150 {
2151 limLog( pMac, LOGW, FL("There were warnings while calcula"
2152 "ting the packed size for a Del TS"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002153 " (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07002154 }
2155 }
2156 else
2157 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302158 vos_mem_set( ( tANI_U8* )&WMMDelTS, sizeof( WMMDelTS ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07002159
2160 WMMDelTS.Category.category = SIR_MAC_ACTION_WME;
2161 WMMDelTS.Action.action = SIR_MAC_QOS_DEL_TS_REQ;
2162 WMMDelTS.DialogToken.token = 0;
2163 WMMDelTS.StatusCode.statusCode = 0;
2164 PopulateDot11fWMMTSPEC( pTspecIe, &WMMDelTS.WMMTSPEC );
2165 nStatus = dot11fGetPackedWMMDelTSSize( pMac, &WMMDelTS, &nPayload );
2166 if ( DOT11F_FAILED( nStatus ) )
2167 {
2168 limLog( pMac, LOGP, FL("Failed to calculate the packed si"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002169 "ze for a WMM Del TS (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002170 nStatus );
2171 // We'll fall back on the worst case scenario:
2172 nPayload = sizeof( tDot11fDelTS );
2173 }
2174 else if ( DOT11F_WARNED( nStatus ) )
2175 {
2176 limLog( pMac, LOGW, FL("There were warnings while calcula"
2177 "ting the packed size for a WMM De"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002178 "l TS (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07002179 }
2180 }
2181
2182 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
2183
2184 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
2185 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
2186 {
2187 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for an Ad"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002188 "d TS Response."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07002189 return;
2190 }
2191
2192 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302193 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07002194
2195 // Next, we fill out the buffer descriptor:
2196 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
2197 SIR_MAC_MGMT_ACTION, peer,
2198 psessionEntry->selfMacAddr);
2199 if ( eSIR_SUCCESS != nSirStatus )
2200 {
2201 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002202 "tor for an Add TS Response (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002203 nSirStatus );
2204 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
2205 return; // allocated!
2206 }
2207
2208 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
2209
2210 #if 0
2211
2212 cfgLen = SIR_MAC_ADDR_LENGTH;
2213 if ( eSIR_SUCCESS != wlan_cfgGetStr( pMac, WNI_CFG_BSSID,
2214 ( tANI_U8* )pMacHdr->bssId, &cfgLen ) )
2215 {
2216 limLog( pMac, LOGP, FL("Failed to retrieve WNI_CFG_BSSID whil"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002217 "e sending an Add TS Response.") );
Jeff Johnson295189b2012-06-20 16:38:30 -07002218 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
2219 return; // allocated!
2220 }
2221 #endif //TO SUPPORT BT-AMP
2222 sirCopyMacAddr(pMacHdr->bssId, psessionEntry->bssId);
2223
Chet Lanctot186b5732013-03-18 10:26:30 -07002224#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07002225 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07002226#endif
2227
Jeff Johnson295189b2012-06-20 16:38:30 -07002228 // That done, pack the struct:
2229 if ( !wmmTspecPresent )
2230 {
2231 nStatus = dot11fPackDelTS( pMac, &DelTS,
2232 pFrame + sizeof( tSirMacMgmtHdr ),
2233 nPayload, &nPayload );
2234 if ( DOT11F_FAILED( nStatus ) )
2235 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002236 limLog( pMac, LOGE, FL("Failed to pack a Del TS frame (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002237 nStatus );
2238 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
2239 return; // allocated!
2240 }
2241 else if ( DOT11F_WARNED( nStatus ) )
2242 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08002243 limLog( pMac, LOGW, FL("There were warnings while packing "
2244 "a Del TS frame (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07002245 }
2246 }
2247 else
2248 {
2249 nStatus = dot11fPackWMMDelTS( pMac, &WMMDelTS,
2250 pFrame + sizeof( tSirMacMgmtHdr ),
2251 nPayload, &nPayload );
2252 if ( DOT11F_FAILED( nStatus ) )
2253 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002254 limLog( pMac, LOGE, FL("Failed to pack a WMM Del TS frame (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002255 nStatus );
2256 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
2257 return; // allocated!
2258 }
2259 else if ( DOT11F_WARNED( nStatus ) )
2260 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08002261 limLog( pMac, LOGW, FL("There were warnings while packing "
2262 "a WMM Del TS frame (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07002263 }
2264 }
2265
Abhishek Singh3cbf6052014-12-15 16:46:42 +05302266 limLog(pMac, LOG1, FL("Sending DELTS REQ (size %d) to "), nBytes);
2267 limPrintMacAddr(pMac, pMacHdr->da, LOG1);
Jeff Johnson295189b2012-06-20 16:38:30 -07002268
2269 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07002270 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
2271 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07002272 )
2273 {
2274 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
2275 }
2276
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05302277 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
2278 psessionEntry->peSessionId,
2279 pMacHdr->fc.subType));
Jeff Johnson295189b2012-06-20 16:38:30 -07002280 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
2281 HAL_TXRX_FRM_802_11_MGMT,
2282 ANI_TXDIR_TODS,
2283 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
2284 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05302285 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
2286 psessionEntry->peSessionId,
2287 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07002288 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
2289 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002290 limLog( pMac, LOGE, FL("Failed to send Del TS (%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002291 nSirStatus );
2292 //Pkt will be freed up by the callback
2293 }
2294
2295} // End limSendDeltsReqActionFrame.
2296
2297void
2298limSendAssocReqMgmtFrame(tpAniSirGlobal pMac,
2299 tLimMlmAssocReq *pMlmAssocReq,
2300 tpPESession psessionEntry)
2301{
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002302 tDot11fAssocRequest *pFrm;
Jeff Johnson295189b2012-06-20 16:38:30 -07002303 tANI_U16 caps;
2304 tANI_U8 *pFrame;
Agrawal Ashish5ac89da2015-10-26 19:08:47 +05302305 tSirRetStatus nSirStatus = eSIR_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07002306 tLimMlmAssocCnf mlmAssocCnf;
c_hpothubcd78652014-04-28 22:31:08 +05302307 tANI_U32 nPayload, nStatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07002308 tANI_U8 fQosEnabled, fWmeEnabled, fWsmEnabled;
2309 void *pPacket;
2310 eHalStatus halstatus;
2311 tANI_U16 nAddIELen;
2312 tANI_U8 *pAddIE;
2313 tANI_U8 *wpsIe = NULL;
2314#if defined WLAN_FEATURE_VOWIFI
2315 tANI_U8 PowerCapsPopulated = FALSE;
2316#endif
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05302317 tANI_U32 txFlag = 0;
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05302318 tpSirMacMgmtHdr pMacHdr;
Kalikinkar dhara205da782014-03-21 15:49:32 -07002319 tDot11fIEExtCap extractedExtCap;
2320 tANI_BOOLEAN extractedExtCapFlag = eANI_BOOLEAN_TRUE;
c_hpothubcd78652014-04-28 22:31:08 +05302321 tANI_U32 nBytes = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002322
2323 if(NULL == psessionEntry)
2324 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05302325 limLog(pMac, LOGE, FL("psessionEntry is NULL") );
Jeff Johnson295189b2012-06-20 16:38:30 -07002326 return;
2327 }
2328
Jeff Johnson295189b2012-06-20 16:38:30 -07002329 /* check this early to avoid unncessary operation */
2330 if(NULL == psessionEntry->pLimJoinReq)
2331 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05302332 limLog(pMac, LOGE, FL("psessionEntry->pLimJoinReq is NULL") );
Jeff Johnson295189b2012-06-20 16:38:30 -07002333 return;
2334 }
2335 nAddIELen = psessionEntry->pLimJoinReq->addIEAssoc.length;
2336 pAddIE = psessionEntry->pLimJoinReq->addIEAssoc.addIEdata;
2337
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302338 pFrm = vos_mem_malloc(sizeof(tDot11fAssocRequest));
2339 if ( NULL == pFrm )
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002340 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05302341 limLog(pMac, LOGE, FL("Unable to allocate memory") );
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002342 return;
2343 }
2344
2345
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302346 vos_mem_set( ( tANI_U8* )pFrm, sizeof( tDot11fAssocRequest ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07002347
Kalikinkar dhara205da782014-03-21 15:49:32 -07002348 vos_mem_set(( tANI_U8* )&extractedExtCap, sizeof( tDot11fIEExtCap ), 0);
Hu Wang5193b572016-08-11 10:04:47 +08002349 if (psessionEntry->ExtCap.present)
Agrawal Ashish5ac89da2015-10-26 19:08:47 +05302350 {
2351 nSirStatus = limStripOffExtCapIEAndUpdateStruct(pMac, pAddIE,
Kalikinkar dhara205da782014-03-21 15:49:32 -07002352 &nAddIELen,
2353 &extractedExtCap );
Agrawal Ashish5ac89da2015-10-26 19:08:47 +05302354 }
Kalikinkar dhara205da782014-03-21 15:49:32 -07002355 if(eSIR_SUCCESS != nSirStatus )
2356 {
2357 extractedExtCapFlag = eANI_BOOLEAN_FALSE;
2358 limLog(pMac, LOG1,
2359 FL("Unable to Stripoff ExtCap IE from Assoc Req"));
2360 }
Leela Venkata Kiran Kumar Reddy Chirala2f9b5712014-05-06 00:09:42 -07002361 /* TODO:remove this code once driver provides the call back function
2362 * to supplicant for set_qos_map
2363 */
2364 else
2365 {
Hu Wangc12631c2016-08-11 09:57:03 +08002366 struct s_ext_cap *p_ext_cap = (struct s_ext_cap *)extractedExtCap.bytes;
2367 if (p_ext_cap->interworkingService) {
2368 p_ext_cap->qosMap = 1;
2369 }
2370 extractedExtCap.num_bytes = lim_compute_ext_cap_ie_length(&extractedExtCap);
2371 extractedExtCapFlag = (extractedExtCap.num_bytes > 0);
Leela Venkata Kiran Kumar Reddy Chirala2f9b5712014-05-06 00:09:42 -07002372 }
Kalikinkar dhara205da782014-03-21 15:49:32 -07002373
Jeff Johnson295189b2012-06-20 16:38:30 -07002374 caps = pMlmAssocReq->capabilityInfo;
2375 if ( PROP_CAPABILITY_GET( 11EQOS, psessionEntry->limCurrentBssPropCap ) )
2376 ((tSirMacCapabilityInfo *) &caps)->qos = 0;
2377#if defined(FEATURE_WLAN_WAPI)
2378 /* CR: 262463 :
2379 According to WAPI standard:
2380 7.3.1.4 Capability Information field
2381 In WAPI, non-AP STAs within an ESS set the Privacy subfield to 0 in transmitted
2382 Association or Reassociation management frames. APs ignore the Privacy subfield within received Association and
2383 Reassociation management frames. */
2384 if ( psessionEntry->encryptType == eSIR_ED_WPI)
2385 ((tSirMacCapabilityInfo *) &caps)->privacy = 0;
2386#endif
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002387 swapBitField16(caps, ( tANI_U16* )&pFrm->Capabilities );
Jeff Johnson295189b2012-06-20 16:38:30 -07002388
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002389 pFrm->ListenInterval.interval = pMlmAssocReq->listenInterval;
2390 PopulateDot11fSSID2( pMac, &pFrm->SSID );
Jeff Johnson295189b2012-06-20 16:38:30 -07002391 PopulateDot11fSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002392 &pFrm->SuppRates,psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07002393
2394 fQosEnabled = ( psessionEntry->limQosEnabled) &&
2395 SIR_MAC_GET_QOS( psessionEntry->limCurrentBssCaps );
2396
2397 fWmeEnabled = ( psessionEntry->limWmeEnabled ) &&
2398 LIM_BSS_CAPS_GET( WME, psessionEntry->limCurrentBssQosCaps );
2399
2400 // We prefer .11e asociations:
2401 if ( fQosEnabled ) fWmeEnabled = false;
2402
2403 fWsmEnabled = ( psessionEntry->limWsmEnabled ) && fWmeEnabled &&
2404 LIM_BSS_CAPS_GET( WSM, psessionEntry->limCurrentBssQosCaps );
2405
2406 if ( psessionEntry->lim11hEnable &&
2407 psessionEntry->pLimJoinReq->spectrumMgtIndicator == eSIR_TRUE )
2408 {
2409#if defined WLAN_FEATURE_VOWIFI
2410 PowerCapsPopulated = TRUE;
2411
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002412 PopulateDot11fPowerCaps( pMac, &pFrm->PowerCaps, LIM_ASSOC,psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07002413#endif
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002414 PopulateDot11fSuppChannels( pMac, &pFrm->SuppChannels, LIM_ASSOC,psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07002415
2416 }
2417
2418#if defined WLAN_FEATURE_VOWIFI
2419 if( pMac->rrm.rrmPEContext.rrmEnable &&
2420 SIR_MAC_GET_RRM( psessionEntry->limCurrentBssCaps ) )
2421 {
2422 if (PowerCapsPopulated == FALSE)
2423 {
2424 PowerCapsPopulated = TRUE;
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002425 PopulateDot11fPowerCaps(pMac, &pFrm->PowerCaps, LIM_ASSOC, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07002426 }
2427 }
2428#endif
2429
2430 if ( fQosEnabled &&
2431 ( ! PROP_CAPABILITY_GET(11EQOS, psessionEntry->limCurrentBssPropCap)))
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002432 PopulateDot11fQOSCapsStation( pMac, &pFrm->QOSCapsStation );
Jeff Johnson295189b2012-06-20 16:38:30 -07002433
2434 PopulateDot11fExtSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002435 &pFrm->ExtSuppRates, psessionEntry );
Jeff Johnson295189b2012-06-20 16:38:30 -07002436
2437#if defined WLAN_FEATURE_VOWIFI
2438 if( pMac->rrm.rrmPEContext.rrmEnable &&
2439 SIR_MAC_GET_RRM( psessionEntry->limCurrentBssCaps ) )
2440 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002441 PopulateDot11fRRMIe( pMac, &pFrm->RRMEnabledCap, psessionEntry );
Jeff Johnson295189b2012-06-20 16:38:30 -07002442 }
2443#endif
2444 // The join request *should* contain zero or one of the WPA and RSN
2445 // IEs. The payload send along with the request is a
2446 // 'tSirSmeJoinReq'; the IE portion is held inside a 'tSirRSNie':
2447
2448 // typedef struct sSirRSNie
2449 // {
2450 // tANI_U16 length;
2451 // tANI_U8 rsnIEdata[SIR_MAC_MAX_IE_LENGTH+2];
2452 // } tSirRSNie, *tpSirRSNie;
2453
2454 // So, we should be able to make the following two calls harmlessly,
2455 // since they do nothing if they don't find the given IE in the
2456 // bytestream with which they're provided.
2457
2458 // The net effect of this will be to faithfully transmit whatever
2459 // security IE is in the join request.
2460
2461 // *However*, if we're associating for the purpose of WPS
2462 // enrollment, and we've been configured to indicate that by
2463 // eliding the WPA or RSN IE, we just skip this:
2464 if( nAddIELen && pAddIE )
2465 {
2466 wpsIe = limGetWscIEPtr (pMac, pAddIE, nAddIELen);
2467 }
2468 if ( NULL == wpsIe )
2469 {
2470 PopulateDot11fRSNOpaque( pMac, &( psessionEntry->pLimJoinReq->rsnIE ),
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002471 &pFrm->RSNOpaque );
Jeff Johnson295189b2012-06-20 16:38:30 -07002472 PopulateDot11fWPAOpaque( pMac, &( psessionEntry->pLimJoinReq->rsnIE ),
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002473 &pFrm->WPAOpaque );
Jeff Johnson295189b2012-06-20 16:38:30 -07002474#if defined(FEATURE_WLAN_WAPI)
2475 PopulateDot11fWAPIOpaque( pMac, &( psessionEntry->pLimJoinReq->rsnIE ),
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002476 &pFrm->WAPIOpaque );
Jeff Johnson295189b2012-06-20 16:38:30 -07002477#endif // defined(FEATURE_WLAN_WAPI)
2478 }
2479
2480 // include WME EDCA IE as well
2481 if ( fWmeEnabled )
2482 {
2483 if ( ! PROP_CAPABILITY_GET( WME, psessionEntry->limCurrentBssPropCap ) )
2484 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002485 PopulateDot11fWMMInfoStation( pMac, &pFrm->WMMInfoStation );
Jeff Johnson295189b2012-06-20 16:38:30 -07002486 }
2487
2488 if ( fWsmEnabled &&
2489 ( ! PROP_CAPABILITY_GET(WSM, psessionEntry->limCurrentBssPropCap )))
2490 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002491 PopulateDot11fWMMCaps( &pFrm->WMMCaps );
Jeff Johnson295189b2012-06-20 16:38:30 -07002492 }
2493 }
2494
2495 //Populate HT IEs, when operating in 11n or Taurus modes AND
2496 //when AP is also operating in 11n mode.
Jeff Johnsone7245742012-09-05 17:12:55 -07002497 if ( psessionEntry->htCapability &&
Jeff Johnson295189b2012-06-20 16:38:30 -07002498 pMac->lim.htCapabilityPresentInBeacon)
2499 {
Krishna Kumaar Natarajan025a8602015-08-04 16:31:36 +05302500 limLog(pMac, LOG1, FL("Populate HT IEs in Assoc Request"));
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002501 PopulateDot11fHTCaps( pMac, psessionEntry, &pFrm->HTCaps );
Jeff Johnson295189b2012-06-20 16:38:30 -07002502#ifdef DISABLE_GF_FOR_INTEROP
2503
2504 /*
2505 * To resolve the interop problem with Broadcom AP,
2506 * where TQ STA could not pass traffic with GF enabled,
2507 * TQ STA will do Greenfield only with TQ AP, for
2508 * everybody else it will be turned off.
2509 */
2510
2511 if( (psessionEntry->pLimJoinReq != NULL) && (!psessionEntry->pLimJoinReq->bssDescription.aniIndicator))
2512 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05302513 limLog( pMac, LOG1, FL("Sending Assoc Req to Non-TQ AP,"
2514 " Turning off Greenfield"));
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002515 pFrm->HTCaps.greenField = WNI_CFG_GREENFIELD_CAPABILITY_DISABLE;
Jeff Johnson295189b2012-06-20 16:38:30 -07002516 }
2517#endif
2518
2519 }
Agrawal Ashishb10d0392015-08-06 16:18:20 +05302520
2521 limLog(pMac, LOG1, FL("SupportedChnlWidth: %d, mimoPS: %d, GF: %d,"
2522 "shortGI20:%d, shortGI40: %d, dsssCck: %d, AMPDU Param: %x"),
2523 pFrm->HTCaps.supportedChannelWidthSet, pFrm->HTCaps.mimoPowerSave,
2524 pFrm->HTCaps.greenField, pFrm->HTCaps.shortGI20MHz, pFrm->HTCaps.shortGI40MHz,
2525 pFrm->HTCaps.dsssCckMode40MHz, pFrm->HTCaps.maxRxAMPDUFactor);
2526
2527
Jeff Johnsone7245742012-09-05 17:12:55 -07002528#ifdef WLAN_FEATURE_11AC
2529 if ( psessionEntry->vhtCapability &&
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07002530 psessionEntry->vhtCapabilityPresentInBeacon)
Jeff Johnsone7245742012-09-05 17:12:55 -07002531 {
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07002532 limLog( pMac, LOG1, FL("Populate VHT IEs in Assoc Request"));
Abhishek Singh33f76ea2015-06-04 12:27:30 +05302533 PopulateDot11fVHTCaps( pMac, &pFrm->VHTCaps,
2534 psessionEntry->currentOperChannel, eSIR_FALSE );
Abhishek Singhe038dc62015-05-22 11:36:45 +05302535
Jeff Johnsone7245742012-09-05 17:12:55 -07002536 }
2537#endif
Hu Wang5193b572016-08-11 10:04:47 +08002538 if (psessionEntry->ExtCap.present)
Agrawal Ashish5ac89da2015-10-26 19:08:47 +05302539 PopulateDot11fExtCap( pMac, &pFrm->ExtCap, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07002540
2541#if defined WLAN_FEATURE_VOWIFI_11R
2542 if (psessionEntry->pLimJoinReq->is11Rconnection)
2543 {
2544#if defined WLAN_FEATURE_VOWIFI_11R_DEBUG
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002545 limLog( pMac, LOG1, FL("mdie = %02x %02x %02x"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002546 (unsigned int)psessionEntry->pLimJoinReq->bssDescription.mdie[0],
2547 (unsigned int)psessionEntry->pLimJoinReq->bssDescription.mdie[1],
2548 (unsigned int)psessionEntry->pLimJoinReq->bssDescription.mdie[2]);
2549#endif
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302550 PopulateMDIE( pMac, &pFrm->MobilityDomain,
2551 psessionEntry->pLimJoinReq->bssDescription.mdie);
Jeff Johnson295189b2012-06-20 16:38:30 -07002552 }
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302553 else
Jeff Johnson295189b2012-06-20 16:38:30 -07002554 {
2555 // No 11r IEs dont send any MDIE
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302556 limLog( pMac, LOG1, FL("MDIE not present"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002557 }
2558#endif
2559
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002560#ifdef FEATURE_WLAN_ESE
2561 /* For ESE Associations fill the ESE IEs */
2562 if (psessionEntry->isESEconnection &&
2563 psessionEntry->pLimJoinReq->isESEFeatureIniEnabled)
Jeff Johnson295189b2012-06-20 16:38:30 -07002564 {
Varun Reddy Yeturu30779b42013-04-09 09:57:16 -07002565#ifndef FEATURE_DISABLE_RM
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002566 PopulateDot11fESERadMgmtCap(&pFrm->ESERadMgmtCap);
Varun Reddy Yeturu30779b42013-04-09 09:57:16 -07002567#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002568 PopulateDot11fESEVersion(&pFrm->ESEVersion);
Jeff Johnson295189b2012-06-20 16:38:30 -07002569 }
2570#endif
2571
c_hpothubcd78652014-04-28 22:31:08 +05302572 /* merge the ExtCap struct*/
2573 if (extractedExtCapFlag && extractedExtCap.present)
2574 {
Hu Wang5193b572016-08-11 10:04:47 +08002575 limMergeExtCapIEStruct(&pFrm->ExtCap, &extractedExtCap, true);
2576 }
2577
2578 if (pFrm->ExtCap.present && psessionEntry->ExtCap.present) {
2579 limMergeExtCapIEStruct(&pFrm->ExtCap, &psessionEntry->ExtCap, false);
2580 limLog(pMac, LOG1,
2581 FL("Clear the bits in EXTCAP IE that AP don't support to avoid IoT issues."));
c_hpothubcd78652014-04-28 22:31:08 +05302582 }
2583
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002584 nStatus = dot11fGetPackedAssocRequestSize( pMac, pFrm, &nPayload );
Jeff Johnson295189b2012-06-20 16:38:30 -07002585 if ( DOT11F_FAILED( nStatus ) )
2586 {
2587 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002588 "or an Association Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002589 nStatus );
2590 // We'll fall back on the worst case scenario:
2591 nPayload = sizeof( tDot11fAssocRequest );
2592 }
2593 else if ( DOT11F_WARNED( nStatus ) )
2594 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08002595 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07002596 "the packed size for an Association Re "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002597 "quest(0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07002598 }
2599
2600 nBytes = nPayload + sizeof( tSirMacMgmtHdr ) + nAddIELen;
2601
2602 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
2603 ( tANI_U16 )nBytes, ( void** ) &pFrame,
2604 ( void** ) &pPacket );
2605 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
2606 {
2607 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for an As"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002608 "sociation Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07002609
2610 psessionEntry->limMlmState = psessionEntry->limPrevMlmState;
Jeff Johnsone7245742012-09-05 17:12:55 -07002611 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07002612
2613
2614 /* Update PE session id*/
2615 mlmAssocCnf.sessionId = psessionEntry->peSessionId;
2616
2617 mlmAssocCnf.resultCode = eSIR_SME_RESOURCES_UNAVAILABLE;
2618
Jeff Johnson295189b2012-06-20 16:38:30 -07002619 limPostSmeMessage( pMac, LIM_MLM_ASSOC_CNF,
2620 ( tANI_U32* ) &mlmAssocCnf);
2621
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302622 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -07002623 return;
2624 }
2625
2626 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302627 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07002628
2629 // Next, we fill out the buffer descriptor:
2630 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
2631 SIR_MAC_MGMT_ASSOC_REQ, psessionEntry->bssId,psessionEntry->selfMacAddr);
2632 if ( eSIR_SUCCESS != nSirStatus )
2633 {
2634 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002635 "tor for an Association Request (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002636 nSirStatus );
2637 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302638 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -07002639 return;
2640 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002641
Abhishek Singh57aebef2014-02-03 18:47:44 +05302642 // That done, pack the Assoc Request:
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002643 nStatus = dot11fPackAssocRequest( pMac, pFrm, pFrame +
Jeff Johnson295189b2012-06-20 16:38:30 -07002644 sizeof(tSirMacMgmtHdr),
2645 nPayload, &nPayload );
2646 if ( DOT11F_FAILED( nStatus ) )
2647 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05302648 limLog( pMac, LOGE, FL("Failed to pack a Assoc Request (0x%0"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002649 "8x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002650 nStatus );
2651 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
2652 ( void* ) pFrame, ( void* ) pPacket );
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302653 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -07002654 return;
2655 }
2656 else if ( DOT11F_WARNED( nStatus ) )
2657 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05302658 limLog( pMac, LOGW, FL("There were warnings while packing a Assoc"
2659 "Request (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07002660 }
2661
2662 PELOG1(limLog( pMac, LOG1, FL("*** Sending Association Request length %d"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002663 "to "),
Jeff Johnson295189b2012-06-20 16:38:30 -07002664 nBytes );)
2665 // limPrintMacAddr( pMac, bssid, LOG1 );
2666
2667 if( psessionEntry->assocReq != NULL )
2668 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302669 vos_mem_free(psessionEntry->assocReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07002670 psessionEntry->assocReq = NULL;
2671 }
2672
2673 if( nAddIELen )
2674 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302675 vos_mem_copy( pFrame + sizeof(tSirMacMgmtHdr) + nPayload,
2676 pAddIE,
2677 nAddIELen );
Jeff Johnson295189b2012-06-20 16:38:30 -07002678 nPayload += nAddIELen;
2679 }
2680
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302681 psessionEntry->assocReq = vos_mem_malloc(nPayload);
2682 if ( NULL == psessionEntry->assocReq )
Jeff Johnson295189b2012-06-20 16:38:30 -07002683 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05302684 PELOGE(limLog(pMac, LOGE, FL("Unable to allocate memory to store "
2685 "assoc request"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07002686 }
2687 else
2688 {
2689 //Store the Assoc request. This is sent to csr/hdd in join cnf response.
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302690 vos_mem_copy( psessionEntry->assocReq, pFrame + sizeof(tSirMacMgmtHdr), nPayload);
Jeff Johnson295189b2012-06-20 16:38:30 -07002691 psessionEntry->assocReqLen = nPayload;
2692 }
2693
2694 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07002695 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
2696 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07002697 )
2698 {
2699 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
2700 }
2701
Sushant Kaushike8681d22015-04-21 12:08:25 +05302702 if(psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ||
2703 psessionEntry->pePersona == VOS_STA_MODE)
Ganesh K08bce952012-12-13 15:04:41 -08002704 {
2705 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
2706 }
Deepthi Gowri639d5042015-11-16 20:23:39 +05302707#ifdef FEATURE_WLAN_DIAG_SUPPORT
2708 limDiagEventReport(pMac, WLAN_PE_DIAG_ASSOC_START_EVENT, psessionEntry,
2709 eSIR_SUCCESS, eSIR_SUCCESS);
2710#endif
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05302711 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
Agarwal Ashisha8e81f52014-04-02 01:59:52 +05302712 limLog( pMac, LOG1, FL("Sending Assoc req over WQ5 to "MAC_ADDRESS_STR
2713 " From " MAC_ADDRESS_STR),MAC_ADDR_ARRAY(pMacHdr->da),
2714 MAC_ADDR_ARRAY(psessionEntry->selfMacAddr));
2715 txFlag |= HAL_USE_FW_IN_TX_PATH;
2716
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05302717 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
2718 psessionEntry->peSessionId,
2719 pMacHdr->fc.subType));
Katya Nigam63902932014-06-26 19:04:23 +05302720
Masti, Narayanraddi67ea5912015-01-08 12:34:05 +05302721 if( ( psessionEntry->is11Gonly == true ) &&
2722 ( !IS_BROADCAST_MAC(pMlmAssocReq->peerMacAddr) ) ){
2723 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
2724 }
Ganesh Kondabattiniffc00b12015-03-18 13:11:33 +05302725 if (IS_FEATURE_SUPPORTED_BY_FW(ENHANCED_TXBD_COMPLETION))
2726 {
2727 limLog(pMac, LOG1, FL("Assoc Req - txBdToken %u"), pMac->lim.txBdToken);
2728 halstatus = halTxFrameWithTxComplete( pMac, pPacket,
2729 ( tANI_U16 ) (sizeof(tSirMacMgmtHdr) + nPayload),
2730 HAL_TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS,
2731 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
2732 limTxComplete, pFrame, limTxBdComplete, txFlag,
2733 pMac->lim.txBdToken);
2734 pMac->lim.txBdToken++;
2735 }
2736 else
2737 {
2738 halstatus = halTxFrame( pMac, pPacket,
2739 ( tANI_U16 ) (sizeof(tSirMacMgmtHdr) + nPayload),
2740 HAL_TXRX_FRM_802_11_MGMT,
2741 ANI_TXDIR_TODS,
2742 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
2743 limTxComplete, pFrame, txFlag );
2744 }
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05302745 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
2746 psessionEntry->peSessionId,
2747 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07002748 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
2749 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002750 limLog( pMac, LOGE, FL("Failed to send Association Request (%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002751 halstatus );
2752 //Pkt will be freed up by the callback
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302753 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -07002754 return;
2755 }
2756
Katya Nigamccaeda72015-04-20 18:51:22 +05302757 //Enable caching only if Assoc Request is successfully submitted to the h/w
2758 WLANTL_EnableCaching(psessionEntry->staId);
2759
Jeff Johnson295189b2012-06-20 16:38:30 -07002760 // Free up buffer allocated for mlmAssocReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302761 vos_mem_free(pMlmAssocReq);
Leela Venkata Kiran Kumar Reddy Chiralad6c0fe22013-12-11 19:10:50 -08002762 pMlmAssocReq = NULL;
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302763 vos_mem_free(pFrm);
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002764 return;
Jeff Johnson295189b2012-06-20 16:38:30 -07002765} // End limSendAssocReqMgmtFrame
2766
2767
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002768#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07002769/*------------------------------------------------------------------------------------
2770 *
2771 * Send Reassoc Req with FTIEs.
2772 *
2773 *-----------------------------------------------------------------------------------
2774 */
2775void
2776limSendReassocReqWithFTIEsMgmtFrame(tpAniSirGlobal pMac,
2777 tLimMlmReassocReq *pMlmReassocReq,tpPESession psessionEntry)
2778{
2779 static tDot11fReAssocRequest frm;
2780 tANI_U16 caps;
2781 tANI_U8 *pFrame;
2782 tSirRetStatus nSirStatus;
2783 tANI_U32 nBytes, nPayload, nStatus;
2784 tANI_U8 fQosEnabled, fWmeEnabled, fWsmEnabled;
2785 void *pPacket;
2786 eHalStatus halstatus;
2787#if defined WLAN_FEATURE_VOWIFI
2788 tANI_U8 PowerCapsPopulated = FALSE;
2789#endif
2790 tANI_U16 ft_ies_length = 0;
2791 tANI_U8 *pBody;
2792 tANI_U16 nAddIELen;
2793 tANI_U8 *pAddIE;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002794#if defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07002795 tANI_U8 *wpsIe = NULL;
2796#endif
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05302797 tANI_U32 txFlag = 0;
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05302798 tpSirMacMgmtHdr pMacHdr;
Jeff Johnson295189b2012-06-20 16:38:30 -07002799
2800 if (NULL == psessionEntry)
2801 {
2802 return;
2803 }
2804
Jeff Johnson295189b2012-06-20 16:38:30 -07002805 /* check this early to avoid unncessary operation */
2806 if(NULL == psessionEntry->pLimReAssocReq)
2807 {
2808 return;
2809 }
2810 nAddIELen = psessionEntry->pLimReAssocReq->addIEAssoc.length;
2811 pAddIE = psessionEntry->pLimReAssocReq->addIEAssoc.addIEdata;
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08002812 limLog( pMac, LOG1, FL("limSendReassocReqWithFTIEsMgmtFrame received in "
2813 "state (%d)."), psessionEntry->limMlmState);
Jeff Johnson295189b2012-06-20 16:38:30 -07002814
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302815 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07002816
2817 caps = pMlmReassocReq->capabilityInfo;
2818 if (PROP_CAPABILITY_GET(11EQOS, psessionEntry->limReassocBssPropCap))
2819 ((tSirMacCapabilityInfo *) &caps)->qos = 0;
2820#if defined(FEATURE_WLAN_WAPI)
2821 /* CR: 262463 :
2822 According to WAPI standard:
2823 7.3.1.4 Capability Information field
2824 In WAPI, non-AP STAs within an ESS set the Privacy subfield to 0 in transmitted
2825 Association or Reassociation management frames. APs ignore the Privacy subfield within received Association and
2826 Reassociation management frames. */
2827 if ( psessionEntry->encryptType == eSIR_ED_WPI)
2828 ((tSirMacCapabilityInfo *) &caps)->privacy = 0;
2829#endif
2830 swapBitField16(caps, ( tANI_U16* )&frm.Capabilities );
2831
2832 frm.ListenInterval.interval = pMlmReassocReq->listenInterval;
2833
2834 // Get the old bssid of the older AP.
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302835 vos_mem_copy( ( tANI_U8* )frm.CurrentAPAddress.mac,
Jeff Johnson295189b2012-06-20 16:38:30 -07002836 pMac->ft.ftPEContext.pFTPreAuthReq->currbssId, 6);
2837
2838 PopulateDot11fSSID2( pMac, &frm.SSID );
2839 PopulateDot11fSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
2840 &frm.SuppRates,psessionEntry);
2841
2842 fQosEnabled = ( psessionEntry->limQosEnabled) &&
2843 SIR_MAC_GET_QOS( psessionEntry->limReassocBssCaps );
2844
2845 fWmeEnabled = ( psessionEntry->limWmeEnabled ) &&
2846 LIM_BSS_CAPS_GET( WME, psessionEntry->limReassocBssQosCaps );
2847
2848 fWsmEnabled = ( psessionEntry->limWsmEnabled ) && fWmeEnabled &&
2849 LIM_BSS_CAPS_GET( WSM, psessionEntry->limReassocBssQosCaps );
2850
2851 if ( psessionEntry->lim11hEnable &&
2852 psessionEntry->pLimReAssocReq->spectrumMgtIndicator == eSIR_TRUE )
2853 {
2854#if defined WLAN_FEATURE_VOWIFI
2855 PowerCapsPopulated = TRUE;
2856
2857 PopulateDot11fPowerCaps( pMac, &frm.PowerCaps, LIM_REASSOC,psessionEntry);
2858 PopulateDot11fSuppChannels( pMac, &frm.SuppChannels, LIM_REASSOC,psessionEntry);
2859#endif
2860 }
2861
2862#if defined WLAN_FEATURE_VOWIFI
2863 if( pMac->rrm.rrmPEContext.rrmEnable &&
2864 SIR_MAC_GET_RRM( psessionEntry->limCurrentBssCaps ) )
2865 {
2866 if (PowerCapsPopulated == FALSE)
2867 {
2868 PowerCapsPopulated = TRUE;
2869 PopulateDot11fPowerCaps(pMac, &frm.PowerCaps, LIM_REASSOC, psessionEntry);
2870 }
2871 }
2872#endif
2873
2874 if ( fQosEnabled &&
2875 ( ! PROP_CAPABILITY_GET(11EQOS, psessionEntry->limReassocBssPropCap ) ))
2876 {
2877 PopulateDot11fQOSCapsStation( pMac, &frm.QOSCapsStation );
2878 }
2879
2880 PopulateDot11fExtSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
2881 &frm.ExtSuppRates, psessionEntry );
2882
2883#if defined WLAN_FEATURE_VOWIFI
2884 if( pMac->rrm.rrmPEContext.rrmEnable &&
2885 SIR_MAC_GET_RRM( psessionEntry->limReassocBssCaps ) )
2886 {
2887 PopulateDot11fRRMIe( pMac, &frm.RRMEnabledCap, psessionEntry );
2888 }
2889#endif
2890
2891 // Ideally this should be enabled for 11r also. But 11r does
2892 // not follow the usual norm of using the Opaque object
2893 // for rsnie and fties. Instead we just add
2894 // the rsnie and fties at the end of the pack routine for 11r.
2895 // This should ideally! be fixed.
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002896#if defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07002897 //
2898 // The join request *should* contain zero or one of the WPA and RSN
2899 // IEs. The payload send along with the request is a
2900 // 'tSirSmeJoinReq'; the IE portion is held inside a 'tSirRSNie':
2901
2902 // typedef struct sSirRSNie
2903 // {
2904 // tANI_U16 length;
2905 // tANI_U8 rsnIEdata[SIR_MAC_MAX_IE_LENGTH+2];
2906 // } tSirRSNie, *tpSirRSNie;
2907
2908 // So, we should be able to make the following two calls harmlessly,
2909 // since they do nothing if they don't find the given IE in the
2910 // bytestream with which they're provided.
2911
2912 // The net effect of this will be to faithfully transmit whatever
2913 // security IE is in the join request.
2914
2915 // *However*, if we're associating for the purpose of WPS
2916 // enrollment, and we've been configured to indicate that by
2917 // eliding the WPA or RSN IE, we just skip this:
2918 if (!psessionEntry->is11Rconnection)
2919 {
2920 if( nAddIELen && pAddIE )
2921 {
2922 wpsIe = limGetWscIEPtr(pMac, pAddIE, nAddIELen);
2923 }
2924 if ( NULL == wpsIe )
2925 {
2926 PopulateDot11fRSNOpaque( pMac, &( psessionEntry->pLimReAssocReq->rsnIE ),
2927 &frm.RSNOpaque );
2928 PopulateDot11fWPAOpaque( pMac, &( psessionEntry->pLimReAssocReq->rsnIE ),
2929 &frm.WPAOpaque );
2930 }
2931
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002932#ifdef FEATURE_WLAN_ESE
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302933 if (psessionEntry->pLimReAssocReq->cckmIE.length)
Jeff Johnson295189b2012-06-20 16:38:30 -07002934 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002935 PopulateDot11fESECckmOpaque( pMac, &( psessionEntry->pLimReAssocReq->cckmIE ),
2936 &frm.ESECckmOpaque );
Jeff Johnson295189b2012-06-20 16:38:30 -07002937 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002938#endif //FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07002939 }
2940
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002941#ifdef FEATURE_WLAN_ESE
2942 // For ESE Associations fill the ESE IEs
2943 if (psessionEntry->isESEconnection &&
2944 psessionEntry->pLimReAssocReq->isESEFeatureIniEnabled)
Jeff Johnson295189b2012-06-20 16:38:30 -07002945 {
Varun Reddy Yeturu30779b42013-04-09 09:57:16 -07002946#ifndef FEATURE_DISABLE_RM
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002947 PopulateDot11fESERadMgmtCap(&frm.ESERadMgmtCap);
Varun Reddy Yeturu30779b42013-04-09 09:57:16 -07002948#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002949 PopulateDot11fESEVersion(&frm.ESEVersion);
Jeff Johnson295189b2012-06-20 16:38:30 -07002950 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002951#endif //FEATURE_WLAN_ESE
2952#endif //FEATURE_WLAN_ESE || FEATURE_WLAN_LFR
Jeff Johnson295189b2012-06-20 16:38:30 -07002953
2954 // include WME EDCA IE as well
2955 if ( fWmeEnabled )
2956 {
2957 if ( ! PROP_CAPABILITY_GET( WME, psessionEntry->limReassocBssPropCap ) )
2958 {
2959 PopulateDot11fWMMInfoStation( pMac, &frm.WMMInfoStation );
2960 }
2961
2962 if ( fWsmEnabled &&
2963 ( ! PROP_CAPABILITY_GET(WSM, psessionEntry->limReassocBssPropCap )))
2964 {
2965 PopulateDot11fWMMCaps( &frm.WMMCaps );
2966 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002967#ifdef FEATURE_WLAN_ESE
2968 if (psessionEntry->isESEconnection)
Jeff Johnson295189b2012-06-20 16:38:30 -07002969 {
2970 PopulateDot11fReAssocTspec(pMac, &frm, psessionEntry);
2971
2972 // Populate the TSRS IE if TSPEC is included in the reassoc request
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002973 if (psessionEntry->pLimReAssocReq->eseTspecInfo.numTspecs)
Jeff Johnson295189b2012-06-20 16:38:30 -07002974 {
2975 tANI_U32 phyMode;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002976 tSirMacESETSRSIE tsrsIE;
Jeff Johnson295189b2012-06-20 16:38:30 -07002977 limGetPhyMode(pMac, &phyMode, psessionEntry);
2978
2979 tsrsIE.tsid = 0;
2980 if( phyMode == WNI_CFG_PHY_MODE_11G || phyMode == WNI_CFG_PHY_MODE_11A)
2981 {
2982 tsrsIE.rates[0] = TSRS_11AG_RATE_6MBPS;
2983 }
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302984 else
Jeff Johnson295189b2012-06-20 16:38:30 -07002985 {
2986 tsrsIE.rates[0] = TSRS_11B_RATE_5_5MBPS;
2987 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002988 PopulateDot11TSRSIE(pMac,&tsrsIE, &frm.ESETrafStrmRateSet, sizeof(tANI_U8));
Jeff Johnson295189b2012-06-20 16:38:30 -07002989 }
2990 }
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302991#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002992 }
2993
Jeff Johnsone7245742012-09-05 17:12:55 -07002994 if ( psessionEntry->htCapability &&
Jeff Johnson295189b2012-06-20 16:38:30 -07002995 pMac->lim.htCapabilityPresentInBeacon)
2996 {
Jeff Johnsone7245742012-09-05 17:12:55 -07002997 PopulateDot11fHTCaps( pMac, psessionEntry, &frm.HTCaps );
Jeff Johnson295189b2012-06-20 16:38:30 -07002998 }
Agrawal Ashishb10d0392015-08-06 16:18:20 +05302999 limLog(pMac, LOG1, FL("SupportedChnlWidth: %d, mimoPS: %d, GF: %d,"
3000 "shortGI20:%d, shortGI40: %d, dsssCck: %d, AMPDU Param: %x"),
3001 frm.HTCaps.supportedChannelWidthSet, frm.HTCaps.mimoPowerSave,
3002 frm.HTCaps.greenField, frm.HTCaps.shortGI20MHz, frm.HTCaps.shortGI40MHz,
3003 frm.HTCaps.dsssCckMode40MHz, frm.HTCaps.maxRxAMPDUFactor);
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08003004#if defined WLAN_FEATURE_VOWIFI_11R
Kanchanapally, Vidyullatha4f84f682014-04-29 20:40:34 +05303005 if ( psessionEntry->pLimReAssocReq->bssDescription.mdiePresent &&
3006 (pMac->ft.ftSmeContext.addMDIE == TRUE)
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003007#if defined FEATURE_WLAN_ESE
3008 && !psessionEntry->isESEconnection
Gopichand Nakkala0ac55062013-04-08 14:43:07 +05303009#endif
3010 )
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08003011 {
3012 PopulateMDIE( pMac, &frm.MobilityDomain, psessionEntry->pLimReAssocReq->bssDescription.mdie);
3013 }
3014#endif
3015
Chet Lanctotf19c1f62013-12-13 13:56:21 -08003016#ifdef WLAN_FEATURE_11AC
3017 if ( psessionEntry->vhtCapability &&
3018 psessionEntry->vhtCapabilityPresentInBeacon)
3019 {
3020 limLog( pMac, LOG1, FL("Populate VHT IEs in Re-Assoc Request"));
Abhishek Singh33f76ea2015-06-04 12:27:30 +05303021 PopulateDot11fVHTCaps( pMac, &frm.VHTCaps,
3022 psessionEntry->currentOperChannel, eSIR_FALSE );
Abhishek Singhe038dc62015-05-22 11:36:45 +05303023
Chet Lanctotf19c1f62013-12-13 13:56:21 -08003024 }
3025#endif
Hu Wang5193b572016-08-11 10:04:47 +08003026 if (psessionEntry->ExtCap.present)
Agrawal Ashish5ac89da2015-10-26 19:08:47 +05303027 PopulateDot11fExtCap( pMac, &frm.ExtCap, psessionEntry);
Chet Lanctotf19c1f62013-12-13 13:56:21 -08003028
Jeff Johnson295189b2012-06-20 16:38:30 -07003029 nStatus = dot11fGetPackedReAssocRequestSize( pMac, &frm, &nPayload );
3030 if ( DOT11F_FAILED( nStatus ) )
3031 {
3032 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003033 "or a Re-Association Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003034 nStatus );
3035 // We'll fall back on the worst case scenario:
3036 nPayload = sizeof( tDot11fReAssocRequest );
3037 }
3038 else if ( DOT11F_WARNED( nStatus ) )
3039 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08003040 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07003041 "the packed size for a Re-Association Re "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003042 "quest(0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07003043 }
3044
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07003045 nBytes = nPayload + sizeof( tSirMacMgmtHdr ) + nAddIELen;
Jeff Johnson295189b2012-06-20 16:38:30 -07003046
3047#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08003048 limLog( pMac, LOG1, FL("FT IE Reassoc Req (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003049 pMac->ft.ftSmeContext.reassoc_ft_ies_length);
3050#endif
3051
3052#if defined WLAN_FEATURE_VOWIFI_11R
3053 if (psessionEntry->is11Rconnection)
3054 {
3055 ft_ies_length = pMac->ft.ftSmeContext.reassoc_ft_ies_length;
3056 }
3057#endif
3058
3059 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
3060 ( tANI_U16 )nBytes+ft_ies_length, ( void** ) &pFrame,
3061 ( void** ) &pPacket );
3062 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3063 {
3064 psessionEntry->limMlmState = psessionEntry->limPrevMlmState;
Jeff Johnsone7245742012-09-05 17:12:55 -07003065 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07003066 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Re-As"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003067 "sociation Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07003068 goto end;
3069 }
3070
3071 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303072 vos_mem_set( pFrame, nBytes + ft_ies_length, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07003073
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003074#if defined WLAN_FEATURE_VOWIFI_11R_DEBUG || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08003075 limPrintMacAddr(pMac, psessionEntry->limReAssocbssId, LOG1);
Jeff Johnson295189b2012-06-20 16:38:30 -07003076#endif
3077 // Next, we fill out the buffer descriptor:
3078 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
3079 SIR_MAC_MGMT_REASSOC_REQ,
3080 psessionEntry->limReAssocbssId,psessionEntry->selfMacAddr);
3081 if ( eSIR_SUCCESS != nSirStatus )
3082 {
3083 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003084 "tor for an Association Request (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003085 nSirStatus );
3086 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
3087 goto end;
3088 }
3089
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05303090 pMacHdr = (tpSirMacMgmtHdr) pFrame;
Jeff Johnson295189b2012-06-20 16:38:30 -07003091 // That done, pack the ReAssoc Request:
3092 nStatus = dot11fPackReAssocRequest( pMac, &frm, pFrame +
3093 sizeof(tSirMacMgmtHdr),
3094 nPayload, &nPayload );
3095 if ( DOT11F_FAILED( nStatus ) )
3096 {
3097 limLog( pMac, LOGE, FL("Failed to pack a Re-Association Reque"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003098 "st (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003099 nStatus );
3100 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
3101 goto end;
3102 }
3103 else if ( DOT11F_WARNED( nStatus ) )
3104 {
3105 limLog( pMac, LOGW, FL("There were warnings while packing a R"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08003106 "e-Association Request (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07003107 }
3108
3109 PELOG3(limLog( pMac, LOG3,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003110 FL("*** Sending Re-Association Request length %d %d to "),
Jeff Johnson295189b2012-06-20 16:38:30 -07003111 nBytes, nPayload );)
3112 if( psessionEntry->assocReq != NULL )
3113 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303114 vos_mem_free(psessionEntry->assocReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07003115 psessionEntry->assocReq = NULL;
3116 }
3117
3118 if( nAddIELen )
3119 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303120 vos_mem_copy( pFrame + sizeof(tSirMacMgmtHdr) + nPayload,
3121 pAddIE,
3122 nAddIELen );
Jeff Johnson295189b2012-06-20 16:38:30 -07003123 nPayload += nAddIELen;
3124 }
3125
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303126 psessionEntry->assocReq = vos_mem_malloc(nPayload);
3127 if ( NULL == psessionEntry->assocReq )
Jeff Johnson295189b2012-06-20 16:38:30 -07003128 {
3129 PELOGE(limLog(pMac, LOGE, FL("Unable to allocate memory to store assoc request"));)
Jeff Johnson43971f52012-07-17 12:26:56 -07003130 }
3131 else
3132 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003133 //Store the Assoc request. This is sent to csr/hdd in join cnf response.
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303134 vos_mem_copy( psessionEntry->assocReq, pFrame + sizeof(tSirMacMgmtHdr), nPayload);
Jeff Johnson295189b2012-06-20 16:38:30 -07003135 psessionEntry->assocReqLen = nPayload;
Jeff Johnson43971f52012-07-17 12:26:56 -07003136 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003137
3138 if (psessionEntry->is11Rconnection)
3139 {
3140 {
3141 int i = 0;
3142
3143 pBody = pFrame + nBytes;
3144 for (i=0; i<ft_ies_length; i++)
3145 {
3146 *pBody = pMac->ft.ftSmeContext.reassoc_ft_ies[i];
3147 pBody++;
3148 }
3149 }
3150 }
3151
3152#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08003153 PELOGE(limLog(pMac, LOG1, FL("Re-assoc Req Frame is: "));
3154 sirDumpBuf(pMac, SIR_LIM_MODULE_ID, LOG1,
Jeff Johnson295189b2012-06-20 16:38:30 -07003155 (tANI_U8 *)pFrame,
3156 (nBytes + ft_ies_length));)
3157#endif
3158
3159
3160 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07003161 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
3162 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07003163 )
3164 {
3165 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
3166 }
3167
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07003168 if( NULL != psessionEntry->assocReq )
3169 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303170 vos_mem_free(psessionEntry->assocReq);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07003171 psessionEntry->assocReq = NULL;
3172 }
Agrawal Ashishad64dc22016-02-04 11:32:15 +05303173 if (ft_ies_length)
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07003174 {
Agrawal Ashishad64dc22016-02-04 11:32:15 +05303175 psessionEntry->assocReq = vos_mem_malloc(ft_ies_length);
3176 if (NULL == psessionEntry->assocReq)
3177 {
3178 limLog(pMac, LOGE,
3179 FL("Unable to allocate memory for FT IEs"));
3180 psessionEntry->assocReqLen = 0;
3181 }
3182 else
3183 {
3184 /* Store the FT IEs. This is sent to csr/hdd in join cnf response.*/
3185 vos_mem_copy(psessionEntry->assocReq,
3186 pMac->ft.ftSmeContext.reassoc_ft_ies,
3187 (ft_ies_length));
3188 psessionEntry->assocReqLen = ft_ies_length;
3189 }
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07003190 }
3191 else
3192 {
Agrawal Ashishad64dc22016-02-04 11:32:15 +05303193 limLog(pMac, LOG1, FL("FT IEs not present"));
3194 psessionEntry->assocReqLen = 0;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07003195 }
Deepthi Gowri639d5042015-11-16 20:23:39 +05303196#ifdef FEATURE_WLAN_DIAG_SUPPORT
3197 limDiagEventReport(pMac, WLAN_PE_DIAG_REASSOC_START_EVENT, psessionEntry,
3198 eSIR_SUCCESS, eSIR_SUCCESS);
3199#endif
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05303200 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
3201 psessionEntry->peSessionId,
3202 pMacHdr->fc.subType));
Ganesh Kondabattiniffc00b12015-03-18 13:11:33 +05303203 if (IS_FEATURE_SUPPORTED_BY_FW(ENHANCED_TXBD_COMPLETION))
3204 {
3205 limLog( pMac, LOG1, FL("Reassoc req - txBdToken %u"), pMac->lim.txBdToken);
3206 halstatus = halTxFrameWithTxComplete( pMac, pPacket,
3207 ( tANI_U16 ) (nBytes + ft_ies_length),
3208 HAL_TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS,
3209 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
3210 limTxComplete, pFrame, limTxBdComplete, txFlag,
3211 pMac->lim.txBdToken);
3212 pMac->lim.txBdToken++;
3213 }
3214 else
3215 {
3216 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) (nBytes + ft_ies_length),
3217 HAL_TXRX_FRM_802_11_MGMT,
3218 ANI_TXDIR_TODS,
3219 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
3220 limTxComplete, pFrame, txFlag );
3221 }
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05303222 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
3223 psessionEntry->peSessionId,
3224 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07003225 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3226 {
3227 limLog( pMac, LOGE, FL("Failed to send Re-Association Request"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003228 "(%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07003229 nSirStatus );
3230 //Pkt will be freed up by the callback
3231 goto end;
3232 }
3233
Katya Nigamccaeda72015-04-20 18:51:22 +05303234 // Enable TL cahching in case of roaming
3235 WLANTL_EnableCaching(psessionEntry->staId);
3236
Jeff Johnson295189b2012-06-20 16:38:30 -07003237end:
3238 // Free up buffer allocated for mlmAssocReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303239 vos_mem_free( pMlmReassocReq );
Jeff Johnson295189b2012-06-20 16:38:30 -07003240 psessionEntry->pLimMlmReassocReq = NULL;
3241
3242}
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -07003243
3244void limSendRetryReassocReqFrame(tpAniSirGlobal pMac,
3245 tLimMlmReassocReq *pMlmReassocReq,
3246 tpPESession psessionEntry)
3247{
3248 tLimMlmReassocCnf mlmReassocCnf; // keep sme
3249 tLimMlmReassocReq *pTmpMlmReassocReq = NULL;
Sachin Ahuja07a43012015-01-30 17:04:38 +05303250#ifdef FEATURE_WLAN_ESE
3251 tANI_U32 val=0;
3252#endif
3253 if (pMlmReassocReq == NULL)
3254 {
3255 limLog(pMac, LOGE,
3256 FL("Invalid pMlmReassocReq"));
3257 goto end;
3258 }
Hema Aparna Medicharla43d0f7b2015-02-12 17:07:59 +05303259
3260 pTmpMlmReassocReq = vos_mem_malloc(sizeof(tLimMlmReassocReq));
3261 if ( NULL == pTmpMlmReassocReq ) goto end;
3262 vos_mem_set( pTmpMlmReassocReq, sizeof(tLimMlmReassocReq), 0);
3263 vos_mem_copy( pTmpMlmReassocReq, pMlmReassocReq, sizeof(tLimMlmReassocReq));
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -07003264
3265 // Prepare and send Reassociation request frame
3266 // start reassoc timer.
Sachin Ahuja07a43012015-01-30 17:04:38 +05303267#ifdef FEATURE_WLAN_ESE
3268 /*
3269 * In case of Ese Reassociation, change the reassoc timer
3270 * value.
3271 */
3272 val = pMlmReassocReq->reassocFailureTimeout;
3273 if (psessionEntry->isESEconnection)
3274 {
3275 val = val/LIM_MAX_REASSOC_RETRY_LIMIT;
3276 }
3277 if (tx_timer_deactivate(&pMac->lim.limTimers.gLimReassocFailureTimer) !=
3278 TX_SUCCESS)
3279 {
3280 limLog(pMac, LOGP,
3281 FL("unable to deactivate Reassoc failure timer"));
3282 }
3283 val = SYS_MS_TO_TICKS(val);
3284 if (tx_timer_change(&pMac->lim.limTimers.gLimReassocFailureTimer,
3285 val, 0) != TX_SUCCESS)
3286 {
3287 limLog(pMac, LOGP,
3288 FL("unable to change Reassociation failure timer"));
3289 }
3290#endif
3291
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -07003292 pMac->lim.limTimers.gLimReassocFailureTimer.sessionId = psessionEntry->peSessionId;
3293 // Start reassociation failure timer
Leela V Kiran Kumar Reddy Chiralac3b9d382013-01-31 20:49:53 -08003294 MTRACE(macTrace(pMac, TRACE_CODE_TIMER_ACTIVATE, psessionEntry->peSessionId, eLIM_REASSOC_FAIL_TIMER));
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -07003295 if (tx_timer_activate(&pMac->lim.limTimers.gLimReassocFailureTimer)
3296 != TX_SUCCESS)
3297 {
3298 // Could not start reassoc failure timer.
3299 // Log error
3300 limLog(pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003301 FL("could not start Reassociation failure timer"));
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -07003302 // Return Reassoc confirm with
3303 // Resources Unavailable
3304 mlmReassocCnf.resultCode = eSIR_SME_RESOURCES_UNAVAILABLE;
3305 mlmReassocCnf.protStatusCode = eSIR_MAC_UNSPEC_FAILURE_STATUS;
3306 goto end;
3307 }
3308
3309 limSendReassocReqWithFTIEsMgmtFrame(pMac, pTmpMlmReassocReq, psessionEntry);
3310 return;
3311
3312end:
3313 // Free up buffer allocated for reassocReq
3314 if (pMlmReassocReq != NULL)
3315 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303316 vos_mem_free(pMlmReassocReq);
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -07003317 pMlmReassocReq = NULL;
3318 }
3319 if (pTmpMlmReassocReq != NULL)
3320 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303321 vos_mem_free(pTmpMlmReassocReq);
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -07003322 pTmpMlmReassocReq = NULL;
3323 }
3324 mlmReassocCnf.resultCode = eSIR_SME_FT_REASSOC_FAILURE;
3325 mlmReassocCnf.protStatusCode = eSIR_MAC_UNSPEC_FAILURE_STATUS;
3326 /* Update PE sessio Id*/
3327 mlmReassocCnf.sessionId = psessionEntry->peSessionId;
3328
3329 limPostSmeMessage(pMac, LIM_MLM_REASSOC_CNF, (tANI_U32 *) &mlmReassocCnf);
3330}
3331
Jeff Johnson295189b2012-06-20 16:38:30 -07003332#endif /* WLAN_FEATURE_VOWIFI_11R */
3333
3334
3335void
3336limSendReassocReqMgmtFrame(tpAniSirGlobal pMac,
3337 tLimMlmReassocReq *pMlmReassocReq,tpPESession psessionEntry)
3338{
3339 static tDot11fReAssocRequest frm;
3340 tANI_U16 caps;
3341 tANI_U8 *pFrame;
3342 tSirRetStatus nSirStatus;
3343 tANI_U32 nBytes, nPayload, nStatus;
3344 tANI_U8 fQosEnabled, fWmeEnabled, fWsmEnabled;
3345 void *pPacket;
3346 eHalStatus halstatus;
3347 tANI_U16 nAddIELen;
3348 tANI_U8 *pAddIE;
3349 tANI_U8 *wpsIe = NULL;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05303350 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003351#if defined WLAN_FEATURE_VOWIFI
3352 tANI_U8 PowerCapsPopulated = FALSE;
3353#endif
Ganesh Kondabattiniffc00b12015-03-18 13:11:33 +05303354 tpSirMacMgmtHdr pMacHdr;
Jeff Johnson295189b2012-06-20 16:38:30 -07003355
3356 if(NULL == psessionEntry)
3357 {
3358 return;
3359 }
3360
3361 /* check this early to avoid unncessary operation */
3362 if(NULL == psessionEntry->pLimReAssocReq)
3363 {
3364 return;
3365 }
3366 nAddIELen = psessionEntry->pLimReAssocReq->addIEAssoc.length;
3367 pAddIE = psessionEntry->pLimReAssocReq->addIEAssoc.addIEdata;
3368
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303369 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07003370
3371 caps = pMlmReassocReq->capabilityInfo;
3372 if (PROP_CAPABILITY_GET(11EQOS, psessionEntry->limReassocBssPropCap))
3373 ((tSirMacCapabilityInfo *) &caps)->qos = 0;
3374#if defined(FEATURE_WLAN_WAPI)
3375 /* CR: 262463 :
3376 According to WAPI standard:
3377 7.3.1.4 Capability Information field
3378 In WAPI, non-AP STAs within an ESS set the Privacy subfield to 0 in transmitted
3379 Association or Reassociation management frames. APs ignore the Privacy subfield within received Association and
3380 Reassociation management frames. */
3381 if ( psessionEntry->encryptType == eSIR_ED_WPI)
3382 ((tSirMacCapabilityInfo *) &caps)->privacy = 0;
3383#endif
3384 swapBitField16(caps, ( tANI_U16* )&frm.Capabilities );
3385
3386 frm.ListenInterval.interval = pMlmReassocReq->listenInterval;
3387
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303388 vos_mem_copy(( tANI_U8* )frm.CurrentAPAddress.mac,
3389 ( tANI_U8* )psessionEntry->bssId, 6 );
Jeff Johnson295189b2012-06-20 16:38:30 -07003390
3391 PopulateDot11fSSID2( pMac, &frm.SSID );
3392 PopulateDot11fSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
3393 &frm.SuppRates,psessionEntry);
3394
3395 fQosEnabled = ( psessionEntry->limQosEnabled ) &&
3396 SIR_MAC_GET_QOS( psessionEntry->limReassocBssCaps );
3397
3398 fWmeEnabled = ( psessionEntry->limWmeEnabled ) &&
3399 LIM_BSS_CAPS_GET( WME, psessionEntry->limReassocBssQosCaps );
3400
3401 fWsmEnabled = ( psessionEntry->limWsmEnabled ) && fWmeEnabled &&
3402 LIM_BSS_CAPS_GET( WSM, psessionEntry->limReassocBssQosCaps );
3403
3404
3405 if ( psessionEntry->lim11hEnable &&
3406 psessionEntry->pLimReAssocReq->spectrumMgtIndicator == eSIR_TRUE )
3407 {
3408#if defined WLAN_FEATURE_VOWIFI
3409 PowerCapsPopulated = TRUE;
3410 PopulateDot11fPowerCaps( pMac, &frm.PowerCaps, LIM_REASSOC,psessionEntry);
3411 PopulateDot11fSuppChannels( pMac, &frm.SuppChannels, LIM_REASSOC,psessionEntry);
3412#endif
3413 }
3414
3415#if defined WLAN_FEATURE_VOWIFI
3416 if( pMac->rrm.rrmPEContext.rrmEnable &&
3417 SIR_MAC_GET_RRM( psessionEntry->limCurrentBssCaps ) )
3418 {
3419 if (PowerCapsPopulated == FALSE)
3420 {
3421 PowerCapsPopulated = TRUE;
3422 PopulateDot11fPowerCaps(pMac, &frm.PowerCaps, LIM_REASSOC, psessionEntry);
3423 }
3424 }
3425#endif
3426
3427 if ( fQosEnabled &&
3428 ( ! PROP_CAPABILITY_GET(11EQOS, psessionEntry->limReassocBssPropCap ) ))
3429 {
3430 PopulateDot11fQOSCapsStation( pMac, &frm.QOSCapsStation );
3431 }
3432
3433 PopulateDot11fExtSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
3434 &frm.ExtSuppRates, psessionEntry );
3435
3436#if defined WLAN_FEATURE_VOWIFI
3437 if( pMac->rrm.rrmPEContext.rrmEnable &&
3438 SIR_MAC_GET_RRM( psessionEntry->limReassocBssCaps ) )
3439 {
3440 PopulateDot11fRRMIe( pMac, &frm.RRMEnabledCap, psessionEntry );
3441 }
3442#endif
3443 // The join request *should* contain zero or one of the WPA and RSN
3444 // IEs. The payload send along with the request is a
3445 // 'tSirSmeJoinReq'; the IE portion is held inside a 'tSirRSNie':
3446
3447 // typedef struct sSirRSNie
3448 // {
3449 // tANI_U16 length;
3450 // tANI_U8 rsnIEdata[SIR_MAC_MAX_IE_LENGTH+2];
3451 // } tSirRSNie, *tpSirRSNie;
3452
3453 // So, we should be able to make the following two calls harmlessly,
3454 // since they do nothing if they don't find the given IE in the
3455 // bytestream with which they're provided.
3456
3457 // The net effect of this will be to faithfully transmit whatever
3458 // security IE is in the join request.
3459
3460 // *However*, if we're associating for the purpose of WPS
3461 // enrollment, and we've been configured to indicate that by
3462 // eliding the WPA or RSN IE, we just skip this:
3463 if( nAddIELen && pAddIE )
3464 {
3465 wpsIe = limGetWscIEPtr(pMac, pAddIE, nAddIELen);
3466 }
3467 if ( NULL == wpsIe )
3468 {
3469 PopulateDot11fRSNOpaque( pMac, &( psessionEntry->pLimReAssocReq->rsnIE ),
3470 &frm.RSNOpaque );
3471 PopulateDot11fWPAOpaque( pMac, &( psessionEntry->pLimReAssocReq->rsnIE ),
3472 &frm.WPAOpaque );
3473#if defined(FEATURE_WLAN_WAPI)
3474 PopulateDot11fWAPIOpaque( pMac, &( psessionEntry->pLimReAssocReq->rsnIE ),
3475 &frm.WAPIOpaque );
3476#endif // defined(FEATURE_WLAN_WAPI)
3477 }
3478
3479 // include WME EDCA IE as well
3480 if ( fWmeEnabled )
3481 {
3482 if ( ! PROP_CAPABILITY_GET( WME, psessionEntry->limReassocBssPropCap ) )
3483 {
3484 PopulateDot11fWMMInfoStation( pMac, &frm.WMMInfoStation );
3485 }
3486
3487 if ( fWsmEnabled &&
3488 ( ! PROP_CAPABILITY_GET(WSM, psessionEntry->limReassocBssPropCap )))
3489 {
3490 PopulateDot11fWMMCaps( &frm.WMMCaps );
3491 }
3492 }
3493
Jeff Johnsone7245742012-09-05 17:12:55 -07003494 if ( psessionEntry->htCapability &&
Jeff Johnson295189b2012-06-20 16:38:30 -07003495 pMac->lim.htCapabilityPresentInBeacon)
3496 {
Jeff Johnsone7245742012-09-05 17:12:55 -07003497 PopulateDot11fHTCaps( pMac, psessionEntry, &frm.HTCaps );
Jeff Johnson295189b2012-06-20 16:38:30 -07003498 }
Agrawal Ashishb10d0392015-08-06 16:18:20 +05303499 limLog(pMac, LOG1, FL("SupportedChnlWidth: %d, mimoPS: %d, GF: %d,"
3500 "shortGI20:%d, shortGI40: %d, dsssCck: %d, AMPDU Param: %x"),
3501 frm.HTCaps.supportedChannelWidthSet, frm.HTCaps.mimoPowerSave,
3502 frm.HTCaps.greenField, frm.HTCaps.shortGI20MHz, frm.HTCaps.shortGI40MHz,
3503 frm.HTCaps.dsssCckMode40MHz, frm.HTCaps.maxRxAMPDUFactor);
Jeff Johnsone7245742012-09-05 17:12:55 -07003504#ifdef WLAN_FEATURE_11AC
3505 if ( psessionEntry->vhtCapability &&
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07003506 psessionEntry->vhtCapabilityPresentInBeacon)
Jeff Johnsone7245742012-09-05 17:12:55 -07003507 {
Chet Lanctotf19c1f62013-12-13 13:56:21 -08003508 limLog( pMac, LOG1, FL("Populate VHT IEs in Re-Assoc Request"));
Abhishek Singh33f76ea2015-06-04 12:27:30 +05303509 PopulateDot11fVHTCaps( pMac, &frm.VHTCaps,
3510 psessionEntry->currentOperChannel, eSIR_FALSE );
Hu Wang5193b572016-08-11 10:04:47 +08003511 if (psessionEntry->ExtCap.present)
Agrawal Ashish5ac89da2015-10-26 19:08:47 +05303512 PopulateDot11fExtCap( pMac, &frm.ExtCap, psessionEntry);
Jeff Johnsone7245742012-09-05 17:12:55 -07003513 }
3514#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003515
3516 nStatus = dot11fGetPackedReAssocRequestSize( pMac, &frm, &nPayload );
3517 if ( DOT11F_FAILED( nStatus ) )
3518 {
3519 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003520 "or a Re-Association Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003521 nStatus );
3522 // We'll fall back on the worst case scenario:
3523 nPayload = sizeof( tDot11fReAssocRequest );
3524 }
3525 else if ( DOT11F_WARNED( nStatus ) )
3526 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08003527 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07003528 "the packed size for a Re-Association Re "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003529 "quest(0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07003530 }
3531
3532 nBytes = nPayload + sizeof( tSirMacMgmtHdr ) + nAddIELen;
3533
3534 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
3535 ( tANI_U16 )nBytes, ( void** ) &pFrame,
3536 ( void** ) &pPacket );
3537 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3538 {
3539 psessionEntry->limMlmState = psessionEntry->limPrevMlmState;
Jeff Johnsone7245742012-09-05 17:12:55 -07003540 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07003541 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Re-As"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003542 "sociation Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07003543 goto end;
3544 }
3545
3546 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303547 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07003548
3549 // Next, we fill out the buffer descriptor:
3550 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
3551 SIR_MAC_MGMT_REASSOC_REQ,
3552 psessionEntry->limReAssocbssId,psessionEntry->selfMacAddr);
3553 if ( eSIR_SUCCESS != nSirStatus )
3554 {
3555 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003556 "tor for an Association Request (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003557 nSirStatus );
3558 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
3559 goto end;
3560 }
3561
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05303562 pMacHdr = (tpSirMacMgmtHdr) pFrame;
Jeff Johnson295189b2012-06-20 16:38:30 -07003563 // That done, pack the Probe Request:
3564 nStatus = dot11fPackReAssocRequest( pMac, &frm, pFrame +
3565 sizeof(tSirMacMgmtHdr),
3566 nPayload, &nPayload );
3567 if ( DOT11F_FAILED( nStatus ) )
3568 {
3569 limLog( pMac, LOGE, FL("Failed to pack a Re-Association Reque"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003570 "st (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003571 nStatus );
3572 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
3573 goto end;
3574 }
3575 else if ( DOT11F_WARNED( nStatus ) )
3576 {
3577 limLog( pMac, LOGW, FL("There were warnings while packing a R"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08003578 "e-Association Request (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07003579 }
3580
3581 PELOG1(limLog( pMac, LOG1, FL("*** Sending Re-Association Request length %d"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003582 "to "),
Jeff Johnson295189b2012-06-20 16:38:30 -07003583 nBytes );)
3584
3585 if( psessionEntry->assocReq != NULL )
3586 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303587 vos_mem_free(psessionEntry->assocReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07003588 psessionEntry->assocReq = NULL;
3589 }
3590
3591 if( nAddIELen )
3592 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303593 vos_mem_copy( pFrame + sizeof(tSirMacMgmtHdr) + nPayload,
3594 pAddIE,
3595 nAddIELen );
Jeff Johnson295189b2012-06-20 16:38:30 -07003596 nPayload += nAddIELen;
3597 }
3598
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303599 psessionEntry->assocReq = vos_mem_malloc(nPayload);
3600 if ( NULL == psessionEntry->assocReq )
Jeff Johnson295189b2012-06-20 16:38:30 -07003601 {
3602 PELOGE(limLog(pMac, LOGE, FL("Unable to allocate memory to store assoc request"));)
Jeff Johnson43971f52012-07-17 12:26:56 -07003603 }
3604 else
3605 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003606 //Store the Assoc request. This is sent to csr/hdd in join cnf response.
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303607 vos_mem_copy(psessionEntry->assocReq, pFrame + sizeof(tSirMacMgmtHdr), nPayload);
Jeff Johnson295189b2012-06-20 16:38:30 -07003608 psessionEntry->assocReqLen = nPayload;
Jeff Johnson43971f52012-07-17 12:26:56 -07003609 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003610
3611 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07003612 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
3613 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07003614 )
3615 {
3616 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
3617 }
3618
Sushant Kaushike8681d22015-04-21 12:08:25 +05303619 if(psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ||
3620 psessionEntry->pePersona == VOS_STA_MODE)
Ganesh K08bce952012-12-13 15:04:41 -08003621 {
3622 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
3623 }
Deepthi Gowri639d5042015-11-16 20:23:39 +05303624#ifdef FEATURE_WLAN_DIAG_SUPPORT
3625 limDiagEventReport(pMac, WLAN_PE_DIAG_REASSOC_START_EVENT, psessionEntry,
3626 eSIR_SUCCESS, eSIR_SUCCESS);
3627#endif
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08003628
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05303629 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
3630 psessionEntry->peSessionId,
3631 pMacHdr->fc.subType));
Katya Nigam63902932014-06-26 19:04:23 +05303632
Ganesh Kondabattiniffc00b12015-03-18 13:11:33 +05303633 if (IS_FEATURE_SUPPORTED_BY_FW(ENHANCED_TXBD_COMPLETION))
3634 {
3635 limLog(pMac, LOG1, FL("Reassoc req - txBdToken %u"), pMac->lim.txBdToken);
3636 halstatus = halTxFrameWithTxComplete( pMac, pPacket,
3637 ( tANI_U16 ) (sizeof(tSirMacMgmtHdr) + nPayload),
3638 HAL_TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS,
3639 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
3640 limTxComplete, pFrame, limTxBdComplete,
3641 txFlag, pMac->lim.txBdToken );
3642 pMac->lim.txBdToken++;
3643 }
3644 else
3645 {
3646 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) (sizeof(tSirMacMgmtHdr) + nPayload),
3647 HAL_TXRX_FRM_802_11_MGMT,
3648 ANI_TXDIR_TODS,
3649 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
3650 limTxComplete, pFrame, txFlag );
3651 }
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05303652 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
3653 psessionEntry->peSessionId,
3654 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07003655 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3656 {
3657 limLog( pMac, LOGE, FL("Failed to send Re-Association Request"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003658 "(%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07003659 nSirStatus );
3660 //Pkt will be freed up by the callback
3661 goto end;
3662 }
3663
Katya Nigamccaeda72015-04-20 18:51:22 +05303664 // enable caching
3665 WLANTL_EnableCaching(psessionEntry->staId);
3666
Jeff Johnson295189b2012-06-20 16:38:30 -07003667end:
3668 // Free up buffer allocated for mlmAssocReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303669 vos_mem_free( pMlmReassocReq );
Jeff Johnson295189b2012-06-20 16:38:30 -07003670 psessionEntry->pLimMlmReassocReq = NULL;
3671
3672} // limSendReassocReqMgmtFrame
3673
Sushant Kaushik9e923872015-04-02 17:09:31 +05303674eHalStatus limAuthTxCompleteCnf(tpAniSirGlobal pMac, void *pData)
Ganesh Kondabattiniffc00b12015-03-18 13:11:33 +05303675{
Sushant Kaushik9e923872015-04-02 17:09:31 +05303676 tANI_U32 txCompleteSuccess;
Ganesh Kondabattiniffc00b12015-03-18 13:11:33 +05303677 tpSirTxBdStatus pTxBdStatus;
Sushant Kaushik9e923872015-04-02 17:09:31 +05303678
3679 if (!pData)
3680 {
3681 limLog(pMac, LOG1,
3682 FL(" pData is NULL"));
3683 return eHAL_STATUS_FAILURE;
3684 }
Sushant Kaushik9e923872015-04-02 17:09:31 +05303685
Ganesh Kondabattiniffc00b12015-03-18 13:11:33 +05303686 if (IS_FEATURE_SUPPORTED_BY_FW(ENHANCED_TXBD_COMPLETION))
3687 {
3688 pTxBdStatus = (tpSirTxBdStatus) pData;
3689 txCompleteSuccess = pTxBdStatus->txCompleteStatus;
3690 limLog(pMac, LOG1, FL("txCompleteStatus %u, txBdToken %u"),
3691 pTxBdStatus->txCompleteStatus, pTxBdStatus->txBdToken);
3692 }
3693 else
3694 {
3695 txCompleteSuccess = *((tANI_U32*) pData);
3696 limLog(pMac, LOG1,
3697 FL("txCompleteSuccess= %d"), txCompleteSuccess);
3698 }
3699
Sushant Kaushik9e923872015-04-02 17:09:31 +05303700 if(txCompleteSuccess)
3701 {
3702 pMac->authAckStatus = LIM_AUTH_ACK_RCD_SUCCESS;
3703 // 'Change' timer for future activations
3704 limDeactivateAndChangeTimer(pMac, eLIM_AUTH_RETRY_TIMER);
3705 }
3706 else
3707 pMac->authAckStatus = LIM_AUTH_ACK_RCD_FAILURE;
Sushant Kaushikb97a0082015-08-31 12:36:45 +05303708#ifdef FEATURE_WLAN_DIAG_SUPPORT
Deepthi Gowri639d5042015-11-16 20:23:39 +05303709 limDiagEventReport(pMac, WLAN_PE_DIAG_AUTH_START_EVENT, NULL,
Sushant Kaushikb97a0082015-08-31 12:36:45 +05303710 pMac->authAckStatus, eSIR_SUCCESS);
3711#endif
3712
Sushant Kaushik9e923872015-04-02 17:09:31 +05303713 return eHAL_STATUS_SUCCESS;
3714}
3715
Jeff Johnson295189b2012-06-20 16:38:30 -07003716/**
3717 * \brief Send an Authentication frame
3718 *
3719 *
3720 * \param pMac Pointer to Global MAC structure
3721 *
3722 * \param pAuthFrameBody Pointer to Authentication frame structure that need
3723 * to be sent
3724 *
3725 * \param peerMacAddr MAC address of the peer entity to which Authentication
3726 * frame is destined
3727 *
3728 * \param wepBit Indicates whether wep bit to be set in FC while sending
3729 * Authentication frame3
3730 *
3731 *
3732 * This function is called by limProcessMlmMessages(). Authentication frame
3733 * is formatted and sent when this function is called.
3734 *
3735 *
3736 */
3737
3738void
3739limSendAuthMgmtFrame(tpAniSirGlobal pMac,
3740 tpSirMacAuthFrameBody pAuthFrameBody,
3741 tSirMacAddr peerMacAddr,
yeshwanth sriram guntukaccf694b2017-08-14 13:30:56 +05303742 tANI_U8 wep_challenge_len,
Sushant Kaushik9e923872015-04-02 17:09:31 +05303743 tpPESession psessionEntry,
3744 tAniBool waitForAck
Jeff Johnson295189b2012-06-20 16:38:30 -07003745 )
3746{
3747 tANI_U8 *pFrame, *pBody;
3748 tANI_U32 frameLen = 0, bodyLen = 0;
3749 tpSirMacMgmtHdr pMacHdr;
3750 tANI_U16 i;
3751 void *pPacket;
3752 eHalStatus halstatus;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05303753 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003754
3755 if(NULL == psessionEntry)
3756 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05303757 limLog(pMac, LOGE, FL("Error: psession Entry is NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003758 return;
3759 }
Abhishek Singh57aebef2014-02-03 18:47:44 +05303760
3761 limLog(pMac, LOG1,
3762 FL("Sending Auth seq# %d status %d (%d) to "MAC_ADDRESS_STR),
3763 pAuthFrameBody->authTransactionSeqNumber,
3764 pAuthFrameBody->authStatusCode,
3765 (pAuthFrameBody->authStatusCode == eSIR_MAC_SUCCESS_STATUS),
3766 MAC_ADDR_ARRAY(peerMacAddr));
yeshwanth sriram guntukaccf694b2017-08-14 13:30:56 +05303767 if (wep_challenge_len)
Jeff Johnson295189b2012-06-20 16:38:30 -07003768 {
3769 /// Auth frame3 to be sent with encrypted framebody
3770 /**
3771 * Allocate buffer for Authenticaton frame of size equal
3772 * to management frame header length plus 2 bytes each for
3773 * auth algorithm number, transaction number, status code,
3774 * 128 bytes for challenge text and 4 bytes each for
3775 * IV & ICV.
3776 */
yeshwanth sriram guntukaccf694b2017-08-14 13:30:56 +05303777 bodyLen = wep_challenge_len + LIM_ENCR_AUTH_INFO_LEN;
3778 frameLen = sizeof(tSirMacMgmtHdr) + bodyLen;
Jeff Johnson295189b2012-06-20 16:38:30 -07003779 } // if (wepBit == LIM_WEP_IN_FC)
3780 else
3781 {
3782 switch (pAuthFrameBody->authTransactionSeqNumber)
3783 {
3784 case SIR_MAC_AUTH_FRAME_1:
3785 /**
3786 * Allocate buffer for Authenticaton frame of size
3787 * equal to management frame header length plus 2 bytes
3788 * each for auth algorithm number, transaction number
3789 * and status code.
3790 */
3791
3792 frameLen = sizeof(tSirMacMgmtHdr) +
3793 SIR_MAC_AUTH_CHALLENGE_OFFSET;
3794 bodyLen = SIR_MAC_AUTH_CHALLENGE_OFFSET;
3795
3796#if defined WLAN_FEATURE_VOWIFI_11R
Madan Mohan Koyyalamudi6a00a802012-11-28 16:12:11 -08003797 if (pAuthFrameBody->authAlgoNumber == eSIR_FT_AUTH)
3798 {
3799 if (0 != pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length)
Jeff Johnson295189b2012-06-20 16:38:30 -07003800 {
Madan Mohan Koyyalamudi6a00a802012-11-28 16:12:11 -08003801 frameLen += pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length;
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003802 limLog(pMac, LOG3, FL("Auth frame, FTIES length added=%d"),
Madan Mohan Koyyalamudi6a00a802012-11-28 16:12:11 -08003803 pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length);
Jeff Johnson295189b2012-06-20 16:38:30 -07003804 }
Madan Mohan Koyyalamudi6a00a802012-11-28 16:12:11 -08003805 else
3806 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05303807 limLog(pMac, LOG3, FL("Auth frame, Does not contain "
3808 "FTIES!!!"));
Madan Mohan Koyyalamudi6a00a802012-11-28 16:12:11 -08003809 frameLen += (2+SIR_MDIE_SIZE);
3810 }
3811 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003812#endif
3813 break;
3814
3815 case SIR_MAC_AUTH_FRAME_2:
3816 if ((pAuthFrameBody->authAlgoNumber == eSIR_OPEN_SYSTEM) ||
3817 ((pAuthFrameBody->authAlgoNumber == eSIR_SHARED_KEY) &&
3818 (pAuthFrameBody->authStatusCode != eSIR_MAC_SUCCESS_STATUS)))
3819 {
3820 /**
3821 * Allocate buffer for Authenticaton frame of size
3822 * equal to management frame header length plus
3823 * 2 bytes each for auth algorithm number,
3824 * transaction number and status code.
3825 */
3826
3827 frameLen = sizeof(tSirMacMgmtHdr) +
3828 SIR_MAC_AUTH_CHALLENGE_OFFSET;
3829 bodyLen = SIR_MAC_AUTH_CHALLENGE_OFFSET;
3830 }
3831 else
3832 {
3833 // Shared Key algorithm with challenge text
3834 // to be sent
3835 /**
3836 * Allocate buffer for Authenticaton frame of size
3837 * equal to management frame header length plus
3838 * 2 bytes each for auth algorithm number,
3839 * transaction number, status code and 128 bytes
3840 * for challenge text.
3841 */
3842
yeshwanth sriram guntuka97711052017-09-08 12:16:08 +05303843 bodyLen = SIR_MAC_AUTH_FRAME_INFO_LEN +
3844 SIR_MAC_SAP_AUTH_CHALLENGE_LENGTH +
3845 SIR_MAC_CHALLENGE_ID_LEN;
Jeff Johnson295189b2012-06-20 16:38:30 -07003846 frameLen = sizeof(tSirMacMgmtHdr) +
yeshwanth sriram guntuka97711052017-09-08 12:16:08 +05303847 bodyLen;
Jeff Johnson295189b2012-06-20 16:38:30 -07003848 }
3849
3850 break;
3851
3852 case SIR_MAC_AUTH_FRAME_3:
3853 /// Auth frame3 to be sent without encrypted framebody
3854 /**
3855 * Allocate buffer for Authenticaton frame of size equal
3856 * to management frame header length plus 2 bytes each
3857 * for auth algorithm number, transaction number and
3858 * status code.
3859 */
3860
3861 frameLen = sizeof(tSirMacMgmtHdr) +
3862 SIR_MAC_AUTH_CHALLENGE_OFFSET;
3863 bodyLen = SIR_MAC_AUTH_CHALLENGE_OFFSET;
3864
3865 break;
3866
3867 case SIR_MAC_AUTH_FRAME_4:
3868 /**
3869 * Allocate buffer for Authenticaton frame of size equal
3870 * to management frame header length plus 2 bytes each
3871 * for auth algorithm number, transaction number and
3872 * status code.
3873 */
3874
3875 frameLen = sizeof(tSirMacMgmtHdr) +
3876 SIR_MAC_AUTH_CHALLENGE_OFFSET;
3877 bodyLen = SIR_MAC_AUTH_CHALLENGE_OFFSET;
3878
3879 break;
3880 } // switch (pAuthFrameBody->authTransactionSeqNumber)
3881 } // end if (wepBit == LIM_WEP_IN_FC)
3882
3883
3884 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )frameLen, ( void** ) &pFrame, ( void** ) &pPacket );
3885
3886 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3887 {
3888 // Log error
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003889 limLog(pMac, LOGP, FL("call to bufAlloc failed for AUTH frame"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003890
3891 return;
3892 }
3893
3894 for (i = 0; i < frameLen; i++)
3895 pFrame[i] = 0;
3896
3897 // Prepare BD
3898 if (limPopulateMacHeader(pMac, pFrame, SIR_MAC_MGMT_FRAME,
3899 SIR_MAC_MGMT_AUTH, peerMacAddr,psessionEntry->selfMacAddr) != eSIR_SUCCESS)
3900 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05303901 limLog(pMac, LOGE, FL("call to limPopulateMacHeader failed for "
3902 "AUTH frame"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003903 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
3904 return;
3905 }
3906
3907 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
yeshwanth sriram guntukaccf694b2017-08-14 13:30:56 +05303908 if (wep_challenge_len)
3909 pMacHdr->fc.wep = LIM_WEP_IN_FC;
3910 else
3911 pMacHdr->fc.wep = LIM_NO_WEP_IN_FC;
Jeff Johnson295189b2012-06-20 16:38:30 -07003912
3913 // Prepare BSSId
3914 if( (psessionEntry->limSystemRole == eLIM_AP_ROLE)|| (psessionEntry->limSystemRole == eLIM_BT_AMP_AP_ROLE) )
3915 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303916 vos_mem_copy( (tANI_U8 *) pMacHdr->bssId,
3917 (tANI_U8 *) psessionEntry->bssId,
3918 sizeof( tSirMacAddr ));
Jeff Johnson295189b2012-06-20 16:38:30 -07003919 }
3920
3921 /// Prepare Authentication frame body
3922 pBody = pFrame + sizeof(tSirMacMgmtHdr);
3923
yeshwanth sriram guntukaccf694b2017-08-14 13:30:56 +05303924 if (wep_challenge_len)
Jeff Johnson295189b2012-06-20 16:38:30 -07003925 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303926 vos_mem_copy(pBody, (tANI_U8 *) pAuthFrameBody, bodyLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07003927
Abhishek Singh3cbf6052014-12-15 16:46:42 +05303928 limLog(pMac, LOG1,
Abhishek Singh57aebef2014-02-03 18:47:44 +05303929 FL("*** Sending Auth seq# 3 status %d (%d) to"MAC_ADDRESS_STR),
Jeff Johnson295189b2012-06-20 16:38:30 -07003930 pAuthFrameBody->authStatusCode,
Abhishek Singh57aebef2014-02-03 18:47:44 +05303931 (pAuthFrameBody->authStatusCode == eSIR_MAC_SUCCESS_STATUS),
Abhishek Singh3cbf6052014-12-15 16:46:42 +05303932 MAC_ADDR_ARRAY(pMacHdr->da));
Jeff Johnson295189b2012-06-20 16:38:30 -07003933
Jeff Johnson295189b2012-06-20 16:38:30 -07003934 }
3935 else
3936 {
3937 *((tANI_U16 *)(pBody)) = sirSwapU16ifNeeded(pAuthFrameBody->authAlgoNumber);
3938 pBody += sizeof(tANI_U16);
3939 bodyLen -= sizeof(tANI_U16);
3940
3941 *((tANI_U16 *)(pBody)) = sirSwapU16ifNeeded(pAuthFrameBody->authTransactionSeqNumber);
3942 pBody += sizeof(tANI_U16);
3943 bodyLen -= sizeof(tANI_U16);
3944
3945 *((tANI_U16 *)(pBody)) = sirSwapU16ifNeeded(pAuthFrameBody->authStatusCode);
3946 pBody += sizeof(tANI_U16);
3947 bodyLen -= sizeof(tANI_U16);
Leela Venkata Kiran Kumar Reddy Chirala7d3fa552013-08-28 10:52:21 -07003948 if ( bodyLen <= (sizeof (pAuthFrameBody->type) +
3949 sizeof (pAuthFrameBody->length) +
3950 sizeof (pAuthFrameBody->challengeText)))
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303951 vos_mem_copy(pBody, (tANI_U8 *) &pAuthFrameBody->type, bodyLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07003952
3953#if defined WLAN_FEATURE_VOWIFI_11R
3954 if ((pAuthFrameBody->authAlgoNumber == eSIR_FT_AUTH) &&
3955 (pAuthFrameBody->authTransactionSeqNumber == SIR_MAC_AUTH_FRAME_1))
3956 {
3957
3958 {
3959 int i = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003960 if (pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length)
3961 {
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08003962#if defined WLAN_FEATURE_VOWIFI_11R_DEBUG
Srinivas Girigowdad63eb492014-02-06 12:21:47 -08003963 PELOG2(limLog(pMac, LOG2, FL("Auth1 Frame FTIE is: "));
3964 sirDumpBuf(pMac, SIR_LIM_MODULE_ID, LOG2,
Jeff Johnson295189b2012-06-20 16:38:30 -07003965 (tANI_U8 *)pBody,
3966 (pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length));)
Jeff Johnson295189b2012-06-20 16:38:30 -07003967#endif
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08003968 for (i=0; i<pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length; i++)
3969 {
Madan Mohan Koyyalamudi6a00a802012-11-28 16:12:11 -08003970 *pBody = pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies[i];
3971 pBody++;
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08003972 }
3973 }
3974 else
3975 {
3976 /* MDID attr is 54*/
3977 *pBody = 54;
Jeff Johnson295189b2012-06-20 16:38:30 -07003978 pBody++;
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08003979 *pBody = SIR_MDIE_SIZE;
3980 pBody++;
3981 for(i=0;i<SIR_MDIE_SIZE;i++)
3982 {
3983 *pBody = pMac->ft.ftPEContext.pFTPreAuthReq->pbssDescription->mdie[i];
3984 pBody++;
3985 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003986 }
3987 }
3988 }
3989#endif
3990
Abhishek Singh3cbf6052014-12-15 16:46:42 +05303991 limLog(pMac, LOG1,
Abhishek Singh57aebef2014-02-03 18:47:44 +05303992 FL("*** Sending Auth seq# %d status %d (%d) to "MAC_ADDRESS_STR),
Jeff Johnson295189b2012-06-20 16:38:30 -07003993 pAuthFrameBody->authTransactionSeqNumber,
3994 pAuthFrameBody->authStatusCode,
Abhishek Singh57aebef2014-02-03 18:47:44 +05303995 (pAuthFrameBody->authStatusCode == eSIR_MAC_SUCCESS_STATUS),
Abhishek Singh3cbf6052014-12-15 16:46:42 +05303996 MAC_ADDR_ARRAY(pMacHdr->da));
Jeff Johnson295189b2012-06-20 16:38:30 -07003997 }
3998 PELOG2(sirDumpBuf(pMac, SIR_LIM_MODULE_ID, LOG2, pFrame, frameLen);)
3999
4000 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07004001 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
4002 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004003#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05304004 || ((NULL != pMac->ft.ftPEContext.pFTPreAuthReq)
Jeff Johnsone7245742012-09-05 17:12:55 -07004005 && ( SIR_BAND_5_GHZ == limGetRFBand(pMac->ft.ftPEContext.pFTPreAuthReq->preAuthchannelNum)))
4006#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004007 )
4008 {
4009 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
4010 }
4011
Sushant Kaushike8681d22015-04-21 12:08:25 +05304012 if(psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ||
4013 psessionEntry->pePersona == VOS_STA_MODE)
Ganesh K08bce952012-12-13 15:04:41 -08004014 {
4015 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
4016 }
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08004017
Sushant Kaushik9e923872015-04-02 17:09:31 +05304018 limLog( pMac, LOG1,
4019 FL("Sending Auth Frame over WQ5 with waitForAck %d to "MAC_ADDRESS_STR
4020 " From " MAC_ADDRESS_STR), waitForAck, MAC_ADDR_ARRAY(pMacHdr->da),
Agarwal Ashisha8e81f52014-04-02 01:59:52 +05304021 MAC_ADDR_ARRAY(psessionEntry->selfMacAddr));
4022
4023 txFlag |= HAL_USE_FW_IN_TX_PATH;
4024
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304025 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
4026 psessionEntry->peSessionId,
4027 pMacHdr->fc.subType));
Masti, Narayanraddi67ea5912015-01-08 12:34:05 +05304028
4029 if( ( psessionEntry->is11Gonly == true ) &&
4030 ( !IS_BROADCAST_MAC(peerMacAddr) ) ){
4031 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
4032 }
Sushant Kaushik9e923872015-04-02 17:09:31 +05304033 if(eSIR_TRUE == waitForAck)
4034 {
4035 pMac->authAckStatus = LIM_AUTH_ACK_NOT_RCD;
Sushant Kaushik0b343422015-05-25 17:15:55 +05304036 limLog(pMac, LOG1, FL("Auth frame - txBdToken %u"),
Ganesh Kondabattiniffc00b12015-03-18 13:11:33 +05304037 pMac->lim.txBdToken);
Sushant Kaushik9e923872015-04-02 17:09:31 +05304038 halstatus = halTxFrameWithTxComplete( pMac, pPacket,
4039 ( tANI_U16 ) frameLen,
4040 HAL_TXRX_FRM_802_11_MGMT,
4041 ANI_TXDIR_TODS,
4042 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
Ganesh Kondabattiniffc00b12015-03-18 13:11:33 +05304043 limTxComplete, pFrame, limAuthTxCompleteCnf, txFlag,
4044 pMac->lim.txBdToken);
4045 pMac->lim.txBdToken++;
Sushant Kaushik9e923872015-04-02 17:09:31 +05304046 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
4047 psessionEntry->peSessionId,
4048 halstatus));
4049 if (!HAL_STATUS_SUCCESS(halstatus))
4050 {
4051 limLog( pMac, LOGE,
4052 FL("Could not send Auth frame, retCode=%X "),
4053 halstatus );
4054 pMac->authAckStatus = LIM_AUTH_ACK_RCD_FAILURE;
4055 //Pkt will be freed up by the callback
4056 }
4057 }
4058 else
4059 {
4060 /// Queue Authentication frame in high priority WQ
4061 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) frameLen,
Jeff Johnson295189b2012-06-20 16:38:30 -07004062 HAL_TXRX_FRM_802_11_MGMT,
4063 ANI_TXDIR_TODS,
4064 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4065 limTxComplete, pFrame, txFlag );
Sushant Kaushik9e923872015-04-02 17:09:31 +05304066 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304067 psessionEntry->peSessionId,
4068 halstatus));
Sushant Kaushik9e923872015-04-02 17:09:31 +05304069 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4070 {
Jeff Johnson295189b2012-06-20 16:38:30 -07004071 limLog(pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004072 FL("*** Could not send Auth frame, retCode=%X ***"),
Jeff Johnson295189b2012-06-20 16:38:30 -07004073 halstatus);
4074
4075 //Pkt will be freed up by the callback
Sushant Kaushik9e923872015-04-02 17:09:31 +05304076 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004077 }
4078
4079 return;
4080} /*** end limSendAuthMgmtFrame() ***/
4081
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004082eHalStatus limSendDeauthCnf(tpAniSirGlobal pMac)
4083{
4084 tANI_U16 aid;
4085 tpDphHashNode pStaDs;
4086 tLimMlmDeauthReq *pMlmDeauthReq;
4087 tLimMlmDeauthCnf mlmDeauthCnf;
4088 tpPESession psessionEntry;
4089
4090 pMlmDeauthReq = pMac->lim.limDisassocDeauthCnfReq.pMlmDeauthReq;
4091 if (pMlmDeauthReq)
4092 {
4093 if (tx_timer_running(&pMac->lim.limTimers.gLimDeauthAckTimer))
4094 {
4095 limDeactivateAndChangeTimer(pMac, eLIM_DEAUTH_ACK_TIMER);
4096 }
4097
4098 if((psessionEntry = peFindSessionBySessionId(pMac, pMlmDeauthReq->sessionId))== NULL)
4099 {
4100
4101 PELOGE(limLog(pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004102 FL("session does not exist for given sessionId"));)
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004103 mlmDeauthCnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
4104 goto end;
4105 }
4106
4107 pStaDs = dphLookupHashEntry(pMac, pMlmDeauthReq->peerMacAddr, &aid, &psessionEntry->dph.dphHashTable);
4108 if (pStaDs == NULL)
4109 {
4110 mlmDeauthCnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
4111 goto end;
4112 }
4113
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004114 /// Receive path cleanup with dummy packet
4115 limCleanupRxPath(pMac, pStaDs,psessionEntry);
Abhishek Singhcf4590b2014-04-16 18:58:08 +05304116
4117#ifdef WLAN_FEATURE_VOWIFI_11R
Mukul Sharma0820d0e2014-11-11 19:49:02 +05304118 if ( psessionEntry->limSystemRole == eLIM_STA_ROLE )
Abhishek Singhcf4590b2014-04-16 18:58:08 +05304119 {
Mukul Sharma0820d0e2014-11-11 19:49:02 +05304120 PELOGE(limLog(pMac, LOG1,
4121 FL("FT Preauth SessionId %d Cleanup"
Abhishek Singhcf4590b2014-04-16 18:58:08 +05304122#ifdef FEATURE_WLAN_ESE
4123 " isESE %d"
4124#endif
4125#ifdef FEATURE_WLAN_LFR
4126 " isLFR %d"
4127#endif
4128 " is11r %d, Deauth reason %d Trigger = %d"),
Mukul Sharma0820d0e2014-11-11 19:49:02 +05304129 psessionEntry->peSessionId,
Abhishek Singhcf4590b2014-04-16 18:58:08 +05304130#ifdef FEATURE_WLAN_ESE
4131 psessionEntry->isESEconnection,
4132#endif
4133#ifdef FEATURE_WLAN_LFR
4134 psessionEntry->isFastRoamIniFeatureEnabled,
4135#endif
4136 psessionEntry->is11Rconnection,
4137 pMlmDeauthReq->reasonCode,
4138 pMlmDeauthReq->deauthTrigger););
Mukul Sharma0820d0e2014-11-11 19:49:02 +05304139
4140 limFTCleanup(pMac);
Abhishek Singhcf4590b2014-04-16 18:58:08 +05304141 }
4142#endif
4143
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004144 /// Free up buffer allocated for mlmDeauthReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304145 vos_mem_free(pMlmDeauthReq);
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004146 pMac->lim.limDisassocDeauthCnfReq.pMlmDeauthReq = NULL;
4147 }
4148 return eHAL_STATUS_SUCCESS;
4149end:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304150 vos_mem_copy( (tANI_U8 *) &mlmDeauthCnf.peerMacAddr,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004151 (tANI_U8 *) pMlmDeauthReq->peerMacAddr,
4152 sizeof(tSirMacAddr));
4153 mlmDeauthCnf.deauthTrigger = pMlmDeauthReq->deauthTrigger;
4154 mlmDeauthCnf.aid = pMlmDeauthReq->aid;
4155 mlmDeauthCnf.sessionId = pMlmDeauthReq->sessionId;
4156
4157 // Free up buffer allocated
4158 // for mlmDeauthReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304159 vos_mem_free(pMlmDeauthReq);
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004160
4161 limPostSmeMessage(pMac,
4162 LIM_MLM_DEAUTH_CNF,
4163 (tANI_U32 *) &mlmDeauthCnf);
4164 return eHAL_STATUS_SUCCESS;
4165}
4166
4167eHalStatus limSendDisassocCnf(tpAniSirGlobal pMac)
4168{
4169 tANI_U16 aid;
4170 tpDphHashNode pStaDs;
4171 tLimMlmDisassocCnf mlmDisassocCnf;
4172 tpPESession psessionEntry;
4173 tLimMlmDisassocReq *pMlmDisassocReq;
4174
4175 pMlmDisassocReq = pMac->lim.limDisassocDeauthCnfReq.pMlmDisassocReq;
4176 if (pMlmDisassocReq)
4177 {
4178 if (tx_timer_running(&pMac->lim.limTimers.gLimDisassocAckTimer))
4179 {
4180 limDeactivateAndChangeTimer(pMac, eLIM_DISASSOC_ACK_TIMER);
4181 }
4182
4183 if((psessionEntry = peFindSessionBySessionId(pMac, pMlmDisassocReq->sessionId))== NULL)
4184 {
4185
4186 PELOGE(limLog(pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004187 FL("session does not exist for given sessionId"));)
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004188 mlmDisassocCnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
4189 goto end;
4190 }
4191
4192 pStaDs = dphLookupHashEntry(pMac, pMlmDisassocReq->peerMacAddr, &aid, &psessionEntry->dph.dphHashTable);
4193 if (pStaDs == NULL)
4194 {
Sachin Ahuja2fea3d12014-12-18 17:31:31 +05304195 limLog(pMac, LOGE,
4196 FL("StaDs Null"));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004197 mlmDisassocCnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
4198 goto end;
4199 }
4200
4201 /// Receive path cleanup with dummy packet
4202 if(eSIR_SUCCESS != limCleanupRxPath(pMac, pStaDs, psessionEntry))
4203 {
4204 mlmDisassocCnf.resultCode = eSIR_SME_RESOURCES_UNAVAILABLE;
Sachin Ahuja2fea3d12014-12-18 17:31:31 +05304205 limLog(pMac, LOGE,
4206 FL("CleanupRxPath error"));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004207 goto end;
4208 }
4209
4210#ifdef WLAN_FEATURE_VOWIFI_11R
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08004211 if ( (psessionEntry->limSystemRole == eLIM_STA_ROLE ) &&
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05304212 (pMlmDisassocReq->reasonCode !=
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08004213 eSIR_MAC_DISASSOC_DUE_TO_FTHANDOFF_REASON))
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004214 {
Mukul Sharma0820d0e2014-11-11 19:49:02 +05304215 PELOGE(limLog(pMac, LOG1,
4216 FL("FT Preauth SessionId %d Cleanup"
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004217#ifdef FEATURE_WLAN_ESE
4218 " isESE %d"
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08004219#endif
4220#ifdef FEATURE_WLAN_LFR
4221 " isLFR %d"
4222#endif
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004223 " is11r %d reason %d"),
Mukul Sharma0820d0e2014-11-11 19:49:02 +05304224 psessionEntry->peSessionId,
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004225#ifdef FEATURE_WLAN_ESE
4226 psessionEntry->isESEconnection,
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08004227#endif
4228#ifdef FEATURE_WLAN_LFR
4229 psessionEntry->isFastRoamIniFeatureEnabled,
4230#endif
4231 psessionEntry->is11Rconnection,
4232 pMlmDisassocReq->reasonCode););
Mukul Sharma0820d0e2014-11-11 19:49:02 +05304233 limFTCleanup(pMac);
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004234 }
4235#endif
4236
4237 /// Free up buffer allocated for mlmDisassocReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304238 vos_mem_free(pMlmDisassocReq);
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004239 pMac->lim.limDisassocDeauthCnfReq.pMlmDisassocReq = NULL;
4240 return eHAL_STATUS_SUCCESS;
4241 }
4242 else
4243 {
4244 return eHAL_STATUS_SUCCESS;
4245 }
4246end:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304247 vos_mem_copy( (tANI_U8 *) &mlmDisassocCnf.peerMacAddr,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004248 (tANI_U8 *) pMlmDisassocReq->peerMacAddr,
4249 sizeof(tSirMacAddr));
4250 mlmDisassocCnf.aid = pMlmDisassocReq->aid;
4251 mlmDisassocCnf.disassocTrigger = pMlmDisassocReq->disassocTrigger;
4252
4253 /* Update PE session ID*/
4254 mlmDisassocCnf.sessionId = pMlmDisassocReq->sessionId;
4255
Madan Mohan Koyyalamudib7f5a672012-11-29 11:17:46 -08004256 if(pMlmDisassocReq != NULL)
4257 {
4258 /// Free up buffer allocated for mlmDisassocReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304259 vos_mem_free(pMlmDisassocReq);
Madan Mohan Koyyalamudib7f5a672012-11-29 11:17:46 -08004260 pMac->lim.limDisassocDeauthCnfReq.pMlmDisassocReq = NULL;
4261 }
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004262
4263 limPostSmeMessage(pMac,
4264 LIM_MLM_DISASSOC_CNF,
4265 (tANI_U32 *) &mlmDisassocCnf);
4266 return eHAL_STATUS_SUCCESS;
4267}
4268
Ganesh Kondabattini358fc9b2015-03-11 16:14:25 +05304269eHalStatus limDisassocTxCompleteCnf(tpAniSirGlobal pMac, void *pData)
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004270{
Ganesh Kondabattinib18b3292015-03-16 16:59:26 +05304271 if (pData && IS_FEATURE_SUPPORTED_BY_FW(ENHANCED_TXBD_COMPLETION))
4272 {
4273 tpSirTxBdStatus pTxBdStatus;
4274 pTxBdStatus = (tpSirTxBdStatus) pData;
4275 limLog(pMac, LOG1, FL("txCompleteStatus %u, txBdToken %u"),
4276 pTxBdStatus->txCompleteStatus, pTxBdStatus->txBdToken);
4277 }
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004278 return limSendDisassocCnf(pMac);
4279}
4280
Ganesh Kondabattini358fc9b2015-03-11 16:14:25 +05304281eHalStatus limDeauthTxCompleteCnf(tpAniSirGlobal pMac, void *pData)
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004282{
Ganesh Kondabattinib18b3292015-03-16 16:59:26 +05304283 if (pData && IS_FEATURE_SUPPORTED_BY_FW(ENHANCED_TXBD_COMPLETION))
4284 {
4285 tpSirTxBdStatus pTxBdStatus;
4286 pTxBdStatus = (tpSirTxBdStatus) pData;
4287 limLog(pMac, LOG1, FL("txCompleteStatus %u, txBdToken %u"),
4288 pTxBdStatus->txCompleteStatus, pTxBdStatus->txBdToken);
4289 }
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004290 return limSendDeauthCnf(pMac);
4291}
4292
Jeff Johnson295189b2012-06-20 16:38:30 -07004293/**
4294 * \brief This function is called to send Disassociate frame.
4295 *
4296 *
4297 * \param pMac Pointer to Global MAC structure
4298 *
4299 * \param nReason Indicates the reason that need to be sent in
4300 * Disassociation frame
4301 *
4302 * \param peerMacAddr MAC address of the STA to which Disassociation frame is
4303 * sent
4304 *
4305 *
4306 */
4307
4308void
4309limSendDisassocMgmtFrame(tpAniSirGlobal pMac,
4310 tANI_U16 nReason,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004311 tSirMacAddr peer,
4312 tpPESession psessionEntry,
4313 tANI_BOOLEAN waitForAck)
Jeff Johnson295189b2012-06-20 16:38:30 -07004314{
4315 tDot11fDisassociation frm;
4316 tANI_U8 *pFrame;
4317 tSirRetStatus nSirStatus;
4318 tpSirMacMgmtHdr pMacHdr;
4319 tANI_U32 nBytes, nPayload, nStatus;
4320 void *pPacket;
4321 eHalStatus halstatus;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304322 tANI_U32 txFlag = 0;
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004323 tANI_U32 val = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004324 if(NULL == psessionEntry)
4325 {
4326 return;
4327 }
4328
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304329 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004330
4331 frm.Reason.code = nReason;
4332
4333 nStatus = dot11fGetPackedDisassociationSize( pMac, &frm, &nPayload );
4334 if ( DOT11F_FAILED( nStatus ) )
4335 {
4336 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004337 "or a Disassociation (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004338 nStatus );
4339 // We'll fall back on the worst case scenario:
4340 nPayload = sizeof( tDot11fDisassociation );
4341 }
4342 else if ( DOT11F_WARNED( nStatus ) )
4343 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004344 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07004345 "the packed size for a Disassociation "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004346 "(0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004347 }
4348
4349 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4350
4351 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
4352 ( tANI_U16 )nBytes, ( void** ) &pFrame,
4353 ( void** ) &pPacket );
4354 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4355 {
4356 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Dis"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004357 "association."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07004358 return;
4359 }
4360
4361 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304362 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004363
4364 // Next, we fill out the buffer descriptor:
4365 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
4366 SIR_MAC_MGMT_DISASSOC, peer,psessionEntry->selfMacAddr);
4367 if ( eSIR_SUCCESS != nSirStatus )
4368 {
4369 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004370 "tor for a Disassociation (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004371 nSirStatus );
4372 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
4373 ( void* ) pFrame, ( void* ) pPacket );
4374 return; // just allocated...
4375 }
4376
4377 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
4378
4379 // Prepare the BSSID
4380 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
4381
Chet Lanctot186b5732013-03-18 10:26:30 -07004382#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07004383 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07004384#endif
4385
Jeff Johnson295189b2012-06-20 16:38:30 -07004386 nStatus = dot11fPackDisassociation( pMac, &frm, pFrame +
4387 sizeof(tSirMacMgmtHdr),
4388 nPayload, &nPayload );
4389 if ( DOT11F_FAILED( nStatus ) )
4390 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004391 limLog( pMac, LOGE, FL("Failed to pack a Disassociation (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004392 nStatus );
4393 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
4394 ( void* ) pFrame, ( void* ) pPacket );
4395 return; // allocated!
4396 }
4397 else if ( DOT11F_WARNED( nStatus ) )
4398 {
4399 limLog( pMac, LOGW, FL("There were warnings while packing a D"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004400 "isassociation (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004401 }
4402
Abhishek Singhcd09b562013-12-24 16:02:20 +05304403 limLog( pMac, LOG1, FL("***Sessionid %d Sending Disassociation frame with "
4404 "reason %u and waitForAck %d to "MAC_ADDRESS_STR" ,From "
4405 MAC_ADDRESS_STR), psessionEntry->peSessionId, nReason, waitForAck,
4406 MAC_ADDR_ARRAY(pMacHdr->da),
4407 MAC_ADDR_ARRAY(psessionEntry->selfMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07004408
4409 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07004410 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
4411 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07004412 )
4413 {
4414 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
4415 }
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08004416
Sushant Kaushike8681d22015-04-21 12:08:25 +05304417 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08004418
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304419 if( IS_FW_IN_TX_PATH_FEATURE_ENABLE )
4420 {
4421 /* This frame will be sent on air by firmware,
4422 which will ensure that this frame goes out
4423 even though DEL_STA is sent immediately */
4424 /* Without this for DEL_STA command there is
4425 risk of flushing frame in BTQM queue without
4426 sending on air */
Agarwal Ashisha8e81f52014-04-02 01:59:52 +05304427 limLog( pMac, LOG1, FL("Sending Disassoc Frame over WQ5 to "MAC_ADDRESS_STR
4428 " From " MAC_ADDRESS_STR),MAC_ADDR_ARRAY(pMacHdr->da),
4429 MAC_ADDR_ARRAY(psessionEntry->selfMacAddr));
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304430 txFlag |= HAL_USE_FW_IN_TX_PATH;
4431 }
4432
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004433 if (waitForAck)
Jeff Johnson295189b2012-06-20 16:38:30 -07004434 {
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304435 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
4436 psessionEntry->peSessionId,
4437 pMacHdr->fc.subType));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004438 // Queue Disassociation frame in high priority WQ
4439 /* get the duration from the request */
4440 halstatus = halTxFrameWithTxComplete( pMac, pPacket, ( tANI_U16 ) nBytes,
4441 HAL_TXRX_FRM_802_11_MGMT,
4442 ANI_TXDIR_TODS,
4443 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4444 limTxComplete, pFrame, limDisassocTxCompleteCnf,
Ganesh Kondabattini10e67352015-03-16 17:41:57 +05304445 txFlag,
4446 pMac->lim.txBdToken++);
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304447 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
4448 psessionEntry->peSessionId,
4449 halstatus));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004450 val = SYS_MS_TO_TICKS(LIM_DISASSOC_DEAUTH_ACK_TIMEOUT);
Jeff Johnson295189b2012-06-20 16:38:30 -07004451
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004452 if (tx_timer_change(
4453 &pMac->lim.limTimers.gLimDisassocAckTimer, val, 0)
4454 != TX_SUCCESS)
4455 {
4456 limLog(pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004457 FL("Unable to change Disassoc ack Timer val"));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004458 return;
4459 }
4460 else if(TX_SUCCESS != tx_timer_activate(
4461 &pMac->lim.limTimers.gLimDisassocAckTimer))
4462 {
4463 limLog(pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004464 FL("Unable to activate Disassoc ack Timer"));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004465 limDeactivateAndChangeTimer(pMac, eLIM_DISASSOC_ACK_TIMER);
4466 return;
4467 }
4468 }
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08004469 else
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004470 {
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304471 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
4472 psessionEntry->peSessionId,
4473 pMacHdr->fc.subType));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004474 // Queue Disassociation frame in high priority WQ
4475 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4476 HAL_TXRX_FRM_802_11_MGMT,
4477 ANI_TXDIR_TODS,
4478 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4479 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304480 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
4481 psessionEntry->peSessionId,
4482 halstatus));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004483 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4484 {
4485 limLog( pMac, LOGE, FL("Failed to send Disassociation "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004486 "(%X)!"),
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004487 nSirStatus );
4488 //Pkt will be freed up by the callback
4489 return;
4490 }
4491 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004492} // End limSendDisassocMgmtFrame.
4493
4494/**
4495 * \brief This function is called to send a Deauthenticate frame
4496 *
4497 *
4498 * \param pMac Pointer to global MAC structure
4499 *
4500 * \param nReason Indicates the reason that need to be sent in the
4501 * Deauthenticate frame
4502 *
4503 * \param peeer address of the STA to which the frame is to be sent
4504 *
4505 *
4506 */
4507
4508void
4509limSendDeauthMgmtFrame(tpAniSirGlobal pMac,
4510 tANI_U16 nReason,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004511 tSirMacAddr peer,
4512 tpPESession psessionEntry,
4513 tANI_BOOLEAN waitForAck)
Jeff Johnson295189b2012-06-20 16:38:30 -07004514{
4515 tDot11fDeAuth frm;
4516 tANI_U8 *pFrame;
4517 tSirRetStatus nSirStatus;
4518 tpSirMacMgmtHdr pMacHdr;
4519 tANI_U32 nBytes, nPayload, nStatus;
4520 void *pPacket;
4521 eHalStatus halstatus;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304522 tANI_U32 txFlag = 0;
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004523 tANI_U32 val = 0;
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08004524#ifdef FEATURE_WLAN_TDLS
4525 tANI_U16 aid;
4526 tpDphHashNode pStaDs;
4527#endif
4528
Jeff Johnson295189b2012-06-20 16:38:30 -07004529 if(NULL == psessionEntry)
4530 {
4531 return;
4532 }
4533
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304534 vos_mem_set( ( tANI_U8* ) &frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004535
4536 frm.Reason.code = nReason;
4537
4538 nStatus = dot11fGetPackedDeAuthSize( pMac, &frm, &nPayload );
4539 if ( DOT11F_FAILED( nStatus ) )
4540 {
4541 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004542 "or a De-Authentication (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004543 nStatus );
4544 // We'll fall back on the worst case scenario:
4545 nPayload = sizeof( tDot11fDeAuth );
4546 }
4547 else if ( DOT11F_WARNED( nStatus ) )
4548 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004549 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07004550 "the packed size for a De-Authentication "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004551 "(0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004552 }
4553
4554 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4555
4556 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
4557 ( tANI_U16 )nBytes, ( void** ) &pFrame,
4558 ( void** ) &pPacket );
4559 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4560 {
4561 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a De-"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004562 "Authentication."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07004563 return;
4564 }
4565
4566 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304567 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004568
4569 // Next, we fill out the buffer descriptor:
4570 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
4571 SIR_MAC_MGMT_DEAUTH, peer,psessionEntry->selfMacAddr);
4572 if ( eSIR_SUCCESS != nSirStatus )
4573 {
4574 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004575 "tor for a De-Authentication (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004576 nSirStatus );
4577 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
4578 ( void* ) pFrame, ( void* ) pPacket );
4579 return; // just allocated...
4580 }
4581
4582 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
4583
4584 // Prepare the BSSID
4585 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
4586
Chet Lanctot186b5732013-03-18 10:26:30 -07004587#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07004588 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07004589#endif
4590
Jeff Johnson295189b2012-06-20 16:38:30 -07004591 nStatus = dot11fPackDeAuth( pMac, &frm, pFrame +
4592 sizeof(tSirMacMgmtHdr),
4593 nPayload, &nPayload );
4594 if ( DOT11F_FAILED( nStatus ) )
4595 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004596 limLog( pMac, LOGE, FL("Failed to pack a DeAuthentication (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004597 nStatus );
4598 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
4599 ( void* ) pFrame, ( void* ) pPacket );
4600 return;
4601 }
4602 else if ( DOT11F_WARNED( nStatus ) )
4603 {
4604 limLog( pMac, LOGW, FL("There were warnings while packing a D"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004605 "e-Authentication (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004606 }
Abhishek Singhcd09b562013-12-24 16:02:20 +05304607 limLog( pMac, LOG1, FL("***Sessionid %d Sending Deauth frame with "
4608 "reason %u and waitForAck %d to "MAC_ADDRESS_STR" ,From "
4609 MAC_ADDRESS_STR), psessionEntry->peSessionId, nReason, waitForAck,
4610 MAC_ADDR_ARRAY(pMacHdr->da),
4611 MAC_ADDR_ARRAY(psessionEntry->selfMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07004612
4613 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07004614 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
4615 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07004616 )
4617 {
4618 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
4619 }
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08004620
Sushant Kaushike8681d22015-04-21 12:08:25 +05304621 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08004622
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304623 if( IS_FW_IN_TX_PATH_FEATURE_ENABLE )
4624 {
4625 /* This frame will be sent on air by firmware,
4626 which will ensure that this frame goes out
4627 even though DEL_STA is sent immediately */
4628 /* Without this for DEL_STA command there is
4629 risk of flushing frame in BTQM queue without
4630 sending on air */
Agarwal Ashisha8e81f52014-04-02 01:59:52 +05304631 limLog( pMac, LOG1, FL("Sending Deauth Frame over WQ5 to "MAC_ADDRESS_STR
4632 " From " MAC_ADDRESS_STR),MAC_ADDR_ARRAY(pMacHdr->da),
4633 MAC_ADDR_ARRAY(psessionEntry->selfMacAddr));
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304634 txFlag |= HAL_USE_FW_IN_TX_PATH;
4635 }
4636
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08004637#ifdef FEATURE_WLAN_TDLS
4638 pStaDs = dphLookupHashEntry(pMac, peer, &aid, &psessionEntry->dph.dphHashTable);
4639#endif
4640
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004641 if (waitForAck)
Jeff Johnson295189b2012-06-20 16:38:30 -07004642 {
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304643 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
4644 psessionEntry->peSessionId,
4645 pMacHdr->fc.subType));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004646 // Queue Disassociation frame in high priority WQ
4647 halstatus = halTxFrameWithTxComplete( pMac, pPacket, ( tANI_U16 ) nBytes,
4648 HAL_TXRX_FRM_802_11_MGMT,
4649 ANI_TXDIR_TODS,
4650 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
Ganesh Kondabattini10e67352015-03-16 17:41:57 +05304651 limTxComplete, pFrame, limDeauthTxCompleteCnf, txFlag,
4652 pMac->lim.txBdToken++);
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304653 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
4654 psessionEntry->peSessionId,
4655 halstatus));
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304656 if (!HAL_STATUS_SUCCESS(halstatus))
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004657 {
4658 limLog( pMac, LOGE, FL("Failed to send De-Authentication "
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304659 "(%X)!"),
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004660 nSirStatus );
Gopichand Nakkala4261ea52012-12-31 16:43:00 -08004661 //Pkt will be freed up by the callback limTxComplete
4662
4663 /*Call limProcessDeauthAckTimeout which will send
4664 * DeauthCnf for this frame
4665 */
4666 limProcessDeauthAckTimeout(pMac);
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004667 return;
4668 }
4669
4670 val = SYS_MS_TO_TICKS(LIM_DISASSOC_DEAUTH_ACK_TIMEOUT);
4671
4672 if (tx_timer_change(
4673 &pMac->lim.limTimers.gLimDeauthAckTimer, val, 0)
4674 != TX_SUCCESS)
4675 {
4676 limLog(pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004677 FL("Unable to change Deauth ack Timer val"));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004678 return;
4679 }
4680 else if(TX_SUCCESS != tx_timer_activate(
4681 &pMac->lim.limTimers.gLimDeauthAckTimer))
4682 {
4683 limLog(pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004684 FL("Unable to activate Deauth ack Timer"));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004685 limDeactivateAndChangeTimer(pMac, eLIM_DEAUTH_ACK_TIMER);
4686 return;
4687 }
4688 }
4689 else
4690 {
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304691 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
4692 psessionEntry->peSessionId,
4693 pMacHdr->fc.subType));
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08004694#ifdef FEATURE_WLAN_TDLS
4695 if ((NULL != pStaDs) && (STA_ENTRY_TDLS_PEER == pStaDs->staType))
4696 {
4697 // Queue Disassociation frame in high priority WQ
4698 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004699 HAL_TXRX_FRM_802_11_MGMT,
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08004700 ANI_TXDIR_IBSS,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004701 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4702 limTxComplete, pFrame, txFlag );
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08004703 }
4704 else
4705 {
4706#endif
4707 // Queue Disassociation frame in high priority WQ
4708 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4709 HAL_TXRX_FRM_802_11_MGMT,
4710 ANI_TXDIR_TODS,
4711 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4712 limTxComplete, pFrame, txFlag );
4713#ifdef FEATURE_WLAN_TDLS
4714 }
4715#endif
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304716 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
4717 psessionEntry->peSessionId,
4718 halstatus));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004719 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4720 {
4721 limLog( pMac, LOGE, FL("Failed to send De-Authentication "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004722 "(%X)!"),
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004723 nSirStatus );
4724 //Pkt will be freed up by the callback
4725 return;
4726 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004727 }
4728
4729} // End limSendDeauthMgmtFrame.
4730
4731
4732#ifdef ANI_SUPPORT_11H
4733/**
4734 * \brief Send a Measurement Report Action frame
4735 *
4736 *
4737 * \param pMac Pointer to the global MAC structure
4738 *
4739 * \param pMeasReqFrame Address of a tSirMacMeasReqActionFrame
4740 *
4741 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
4742 *
4743 *
4744 */
4745
4746tSirRetStatus
4747limSendMeasReportFrame(tpAniSirGlobal pMac,
4748 tpSirMacMeasReqActionFrame pMeasReqFrame,
4749 tSirMacAddr peer)
4750{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304751 tDot11fMeasurementReport frm;
4752 tANI_U8 *pFrame;
4753 tSirRetStatus nSirStatus;
4754 tpSirMacMgmtHdr pMacHdr;
4755 tANI_U32 nBytes, nPayload, nStatus, nCfg;
4756 void *pPacket;
4757 eHalStatus halstatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07004758
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304759 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004760
4761 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
4762 frm.Action.action = SIR_MAC_ACTION_MEASURE_REPORT_ID;
4763 frm.DialogToken.token = pMeasReqFrame->actionHeader.dialogToken;
4764
4765 switch ( pMeasReqFrame->measReqIE.measType )
4766 {
4767 case SIR_MAC_BASIC_MEASUREMENT_TYPE:
4768 nSirStatus =
4769 PopulateDot11fMeasurementReport0( pMac, pMeasReqFrame,
4770 &frm.MeasurementReport );
4771 break;
4772 case SIR_MAC_CCA_MEASUREMENT_TYPE:
4773 nSirStatus =
4774 PopulateDot11fMeasurementReport1( pMac, pMeasReqFrame,
4775 &frm.MeasurementReport );
4776 break;
4777 case SIR_MAC_RPI_MEASUREMENT_TYPE:
4778 nSirStatus =
4779 PopulateDot11fMeasurementReport2( pMac, pMeasReqFrame,
4780 &frm.MeasurementReport );
4781 break;
4782 default:
4783 limLog( pMac, LOGE, FL("Unknown measurement type %d in limSen"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004784 "dMeasReportFrame."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004785 pMeasReqFrame->measReqIE.measType );
4786 return eSIR_FAILURE;
4787 }
4788
4789 if ( eSIR_SUCCESS != nSirStatus ) return eSIR_FAILURE;
4790
4791 nStatus = dot11fGetPackedMeasurementReportSize( pMac, &frm, &nPayload );
4792 if ( DOT11F_FAILED( nStatus ) )
4793 {
4794 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004795 "or a Measurement Report (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004796 nStatus );
4797 // We'll fall back on the worst case scenario:
4798 nPayload = sizeof( tDot11fMeasurementReport );
4799 }
4800 else if ( DOT11F_WARNED( nStatus ) )
4801 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004802 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07004803 "the packed size for a Measurement Rep"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004804 "ort (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004805 }
4806
4807 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4808
4809 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
4810 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4811 {
4812 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a De-"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004813 "Authentication."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07004814 return eSIR_FAILURE;
4815 }
4816
4817 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304818 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004819
4820 // Next, we fill out the buffer descriptor:
4821 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
4822 SIR_MAC_MGMT_ACTION, peer);
4823 if ( eSIR_SUCCESS != nSirStatus )
4824 {
4825 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004826 "tor for a Measurement Report (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004827 nSirStatus );
4828 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4829 return eSIR_FAILURE; // just allocated...
4830 }
4831
4832 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
4833
4834 nCfg = 6;
4835 nSirStatus = wlan_cfgGetStr( pMac, WNI_CFG_BSSID, pMacHdr->bssId, &nCfg );
4836 if ( eSIR_SUCCESS != nSirStatus )
4837 {
4838 limLog( pMac, LOGE, FL("Failed to retrieve WNI_CFG_BSSID from"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004839 " CFG (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004840 nSirStatus );
4841 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4842 return eSIR_FAILURE; // just allocated...
4843 }
4844
Chet Lanctot186b5732013-03-18 10:26:30 -07004845#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07004846 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07004847#endif
4848
Jeff Johnson295189b2012-06-20 16:38:30 -07004849 nStatus = dot11fPackMeasurementReport( pMac, &frm, pFrame +
4850 sizeof(tSirMacMgmtHdr),
4851 nPayload, &nPayload );
4852 if ( DOT11F_FAILED( nStatus ) )
4853 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004854 limLog( pMac, LOGE, FL("Failed to pack a Measurement Report (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004855 nStatus );
4856 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4857 return eSIR_FAILURE; // allocated!
4858 }
4859 else if ( DOT11F_WARNED( nStatus ) )
4860 {
4861 limLog( pMac, LOGW, FL("There were warnings while packing a M"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004862 "easurement Report (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004863 }
4864
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304865 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
4866 ((psessionEntry)? psessionEntry->peSessionId : NO_SESSION),
4867 pMacHdr->fc.subType));
Jeff Johnson295189b2012-06-20 16:38:30 -07004868 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4869 HAL_TXRX_FRM_802_11_MGMT,
4870 ANI_TXDIR_TODS,
4871 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4872 limTxComplete, pFrame, 0 );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304873 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
4874 ((psessionEntry)? psessionEntry->peSessionId : NO_SESSION),
4875 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07004876 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4877 {
4878 limLog( pMac, LOGE, FL("Failed to send a Measurement Report "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004879 "(%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07004880 nSirStatus );
4881 //Pkt will be freed up by the callback
4882 return eSIR_FAILURE; // just allocated...
4883 }
4884
4885 return eSIR_SUCCESS;
4886
4887} // End limSendMeasReportFrame.
4888
4889
4890/**
4891 * \brief Send a TPC Request Action frame
4892 *
4893 *
4894 * \param pMac Pointer to the global MAC datastructure
4895 *
4896 * \param peer MAC address to which the frame should be sent
4897 *
4898 *
4899 */
4900
4901void
4902limSendTpcRequestFrame(tpAniSirGlobal pMac,
4903 tSirMacAddr peer)
4904{
4905 tDot11fTPCRequest frm;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304906 tANI_U8 *pFrame;
Jeff Johnson295189b2012-06-20 16:38:30 -07004907 tSirRetStatus nSirStatus;
4908 tpSirMacMgmtHdr pMacHdr;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304909 tANI_U32 nBytes, nPayload, nStatus, nCfg;
4910 void *pPacket;
4911 eHalStatus halstatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07004912
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304913 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004914
4915 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
4916 frm.Action.action = SIR_MAC_ACTION_TPC_REQUEST_ID;
4917 frm.DialogToken.token = 1;
4918 frm.TPCRequest.present = 1;
4919
4920 nStatus = dot11fGetPackedTPCRequestSize( pMac, &frm, &nPayload );
4921 if ( DOT11F_FAILED( nStatus ) )
4922 {
4923 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004924 "or a TPC Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004925 nStatus );
4926 // We'll fall back on the worst case scenario:
4927 nPayload = sizeof( tDot11fTPCRequest );
4928 }
4929 else if ( DOT11F_WARNED( nStatus ) )
4930 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004931 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07004932 "the packed size for a TPC Request (0x"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004933 "%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004934 }
4935
4936 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4937
4938 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
4939 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4940 {
4941 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a TPC"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004942 " Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07004943 return;
4944 }
4945
4946 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304947 vos_mem_set(pFrame, nBytes,0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004948
4949 // Next, we fill out the buffer descriptor:
4950 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
4951 SIR_MAC_MGMT_ACTION, peer);
4952 if ( eSIR_SUCCESS != nSirStatus )
4953 {
4954 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004955 "tor for a TPC Request (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004956 nSirStatus );
4957 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4958 return; // just allocated...
4959 }
4960
4961 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
4962
4963 nCfg = 6;
4964 nSirStatus = wlan_cfgGetStr( pMac, WNI_CFG_BSSID, pMacHdr->bssId, &nCfg );
4965 if ( eSIR_SUCCESS != nSirStatus )
4966 {
4967 limLog( pMac, LOGE, FL("Failed to retrieve WNI_CFG_BSSID from"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004968 " CFG (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004969 nSirStatus );
4970 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4971 return; // just allocated...
4972 }
4973
Chet Lanctot186b5732013-03-18 10:26:30 -07004974#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07004975 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07004976#endif
4977
Jeff Johnson295189b2012-06-20 16:38:30 -07004978 nStatus = dot11fPackTPCRequest( pMac, &frm, pFrame +
4979 sizeof(tSirMacMgmtHdr),
4980 nPayload, &nPayload );
4981 if ( DOT11F_FAILED( nStatus ) )
4982 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004983 limLog( pMac, LOGE, FL("Failed to pack a TPC Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004984 nStatus );
4985 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4986 return; // allocated!
4987 }
4988 else if ( DOT11F_WARNED( nStatus ) )
4989 {
4990 limLog( pMac, LOGW, FL("There were warnings while packing a T"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004991 "PC Request (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004992 }
4993
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304994 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
4995 ((psessionEntry)? psessionEntry->peSessionId : NO_SESSION),
4996 pMacHdr->fc.subType));
Jeff Johnson295189b2012-06-20 16:38:30 -07004997 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4998 HAL_TXRX_FRM_802_11_MGMT,
4999 ANI_TXDIR_TODS,
5000 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
5001 limTxComplete, pFrame, 0 );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05305002 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
5003 ((psessionEntry)? psessionEntry->peSessionId : NO_SESSION),
5004 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07005005 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
5006 {
5007 limLog( pMac, LOGE, FL("Failed to send a TPC Request "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005008 "(%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07005009 nSirStatus );
5010 //Pkt will be freed up by the callback
5011 return;
5012 }
5013
5014} // End limSendTpcRequestFrame.
5015
5016
5017/**
5018 * \brief Send a TPC Report Action frame
5019 *
5020 *
5021 * \param pMac Pointer to the global MAC datastructure
5022 *
5023 * \param pTpcReqFrame Pointer to the received TPC Request
5024 *
5025 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
5026 *
5027 *
5028 */
5029
5030tSirRetStatus
5031limSendTpcReportFrame(tpAniSirGlobal pMac,
5032 tpSirMacTpcReqActionFrame pTpcReqFrame,
5033 tSirMacAddr peer)
5034{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05305035 tDot11fTPCReport frm;
5036 tANI_U8 *pFrame;
5037 tSirRetStatus nSirStatus;
5038 tpSirMacMgmtHdr pMacHdr;
5039 tANI_U32 nBytes, nPayload, nStatus, nCfg;
5040 void *pPacket;
5041 eHalStatus halstatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07005042
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305043 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005044
5045 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
5046 frm.Action.action = SIR_MAC_ACTION_TPC_REPORT_ID;
5047 frm.DialogToken.token = pTpcReqFrame->actionHeader.dialogToken;
5048
5049 // FramesToDo: On the Gen4_TVM branch, there was a comment:
5050 // "misplaced this function, need to replace:
5051 // txPower = halGetRateToPwrValue(pMac, staid,
5052 // pMac->lim.gLimCurrentChannelId, 0);
5053 frm.TPCReport.tx_power = 0;
5054 frm.TPCReport.link_margin = 0;
5055 frm.TPCReport.present = 1;
5056
5057 nStatus = dot11fGetPackedTPCReportSize( pMac, &frm, &nPayload );
5058 if ( DOT11F_FAILED( nStatus ) )
5059 {
5060 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005061 "or a TPC Report (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005062 nStatus );
5063 // We'll fall back on the worst case scenario:
5064 nPayload = sizeof( tDot11fTPCReport );
5065 }
5066 else if ( DOT11F_WARNED( nStatus ) )
5067 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005068 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07005069 "the packed size for a TPC Report (0x"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005070 "%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07005071 }
5072
5073 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
5074
5075 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
5076 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
5077 {
5078 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a TPC"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005079 " Report."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07005080 return eSIR_FAILURE;
5081 }
5082
5083 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305084 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005085
5086 // Next, we fill out the buffer descriptor:
5087 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
5088 SIR_MAC_MGMT_ACTION, peer);
5089 if ( eSIR_SUCCESS != nSirStatus )
5090 {
5091 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005092 "tor for a TPC Report (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005093 nSirStatus );
5094 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
5095 return eSIR_FAILURE; // just allocated...
5096 }
5097
5098 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
5099
5100 nCfg = 6;
5101 nSirStatus = wlan_cfgGetStr( pMac, WNI_CFG_BSSID, pMacHdr->bssId, &nCfg );
5102 if ( eSIR_SUCCESS != nSirStatus )
5103 {
5104 limLog( pMac, LOGE, FL("Failed to retrieve WNI_CFG_BSSID from"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005105 " CFG (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005106 nSirStatus );
5107 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
5108 return eSIR_FAILURE; // just allocated...
5109 }
5110
Chet Lanctot186b5732013-03-18 10:26:30 -07005111#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07005112 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07005113#endif
5114
Jeff Johnson295189b2012-06-20 16:38:30 -07005115 nStatus = dot11fPackTPCReport( pMac, &frm, pFrame +
5116 sizeof(tSirMacMgmtHdr),
5117 nPayload, &nPayload );
5118 if ( DOT11F_FAILED( nStatus ) )
5119 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005120 limLog( pMac, LOGE, FL("Failed to pack a TPC Report (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005121 nStatus );
5122 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
5123 return eSIR_FAILURE; // allocated!
5124 }
5125 else if ( DOT11F_WARNED( nStatus ) )
5126 {
5127 limLog( pMac, LOGW, FL("There were warnings while packing a T"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005128 "PC Report (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07005129 }
5130
5131
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05305132 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
5133 ((psessionEntry)? psessionEntry->peSessionId : NO_SESSION),
5134 pMacHdr->fc.subType));
Jeff Johnson295189b2012-06-20 16:38:30 -07005135 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
5136 HAL_TXRX_FRM_802_11_MGMT,
5137 ANI_TXDIR_TODS,
5138 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
5139 limTxComplete, pFrame, 0 );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05305140 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
5141 ((psessionEntry)? psessionEntry->peSessionId : NO_SESSION),
5142 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07005143 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
5144 {
5145 limLog( pMac, LOGE, FL("Failed to send a TPC Report "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005146 "(%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07005147 nSirStatus );
5148 //Pkt will be freed up by the callback
5149 return eSIR_FAILURE; // just allocated...
5150 }
5151
5152 return eSIR_SUCCESS;
5153
5154} // End limSendTpcReportFrame.
5155#endif //ANI_SUPPORT_11H
5156
5157
Jeff Johnson295189b2012-06-20 16:38:30 -07005158/**
5159 * \brief Send a Channel Switch Announcement
5160 *
5161 *
5162 * \param pMac Pointer to the global MAC datastructure
5163 *
5164 * \param peer MAC address to which this frame will be sent
5165 *
5166 * \param nMode
5167 *
5168 * \param nNewChannel
5169 *
5170 * \param nCount
5171 *
5172 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
5173 *
5174 *
5175 */
5176
5177tSirRetStatus
5178limSendChannelSwitchMgmtFrame(tpAniSirGlobal pMac,
5179 tSirMacAddr peer,
Jeff Johnsone7245742012-09-05 17:12:55 -07005180 tANI_U8 nMode,
5181 tANI_U8 nNewChannel,
5182 tANI_U8 nCount,
5183 tpPESession psessionEntry )
Jeff Johnson295189b2012-06-20 16:38:30 -07005184{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05305185 tDot11fChannelSwitch frm;
5186 tANI_U8 *pFrame;
5187 tSirRetStatus nSirStatus;
5188 tpSirMacMgmtHdr pMacHdr;
5189 tANI_U32 nBytes, nPayload, nStatus;//, nCfg;
5190 void *pPacket;
5191 eHalStatus halstatus;
5192 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005193
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305194 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005195
5196 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
5197 frm.Action.action = SIR_MAC_ACTION_CHANNEL_SWITCH_ID;
5198 frm.ChanSwitchAnn.switchMode = nMode;
5199 frm.ChanSwitchAnn.newChannel = nNewChannel;
5200 frm.ChanSwitchAnn.switchCount = nCount;
5201 frm.ChanSwitchAnn.present = 1;
5202
5203 nStatus = dot11fGetPackedChannelSwitchSize( pMac, &frm, &nPayload );
5204 if ( DOT11F_FAILED( nStatus ) )
5205 {
5206 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005207 "or a Channel Switch (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005208 nStatus );
5209 // We'll fall back on the worst case scenario:
5210 nPayload = sizeof( tDot11fChannelSwitch );
5211 }
5212 else if ( DOT11F_WARNED( nStatus ) )
5213 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005214 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07005215 "the packed size for a Channel Switch (0x"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005216 "%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07005217 }
5218
5219 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
5220
5221 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
5222 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
5223 {
5224 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a TPC"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005225 " Report."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07005226 return eSIR_FAILURE;
5227 }
5228
5229 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305230 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005231
5232 // Next, we fill out the buffer descriptor:
5233 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
Jeff Johnsone7245742012-09-05 17:12:55 -07005234 SIR_MAC_MGMT_ACTION, peer, psessionEntry->selfMacAddr);
5235 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305236 vos_mem_copy( (tANI_U8 *) pMacHdr->bssId,
5237 (tANI_U8 *) psessionEntry->bssId,
5238 sizeof( tSirMacAddr ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005239 if ( eSIR_SUCCESS != nSirStatus )
5240 {
5241 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005242 "tor for a Channel Switch (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005243 nSirStatus );
5244 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
5245 return eSIR_FAILURE; // just allocated...
5246 }
5247
Jeff Johnsone7245742012-09-05 17:12:55 -07005248#if 0
Jeff Johnson295189b2012-06-20 16:38:30 -07005249 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
5250
5251 nCfg = 6;
5252 nSirStatus = wlan_cfgGetStr( pMac, WNI_CFG_BSSID, pMacHdr->bssId, &nCfg );
5253 if ( eSIR_SUCCESS != nSirStatus )
5254 {
5255 limLog( pMac, LOGE, FL("Failed to retrieve WNI_CFG_BSSID from"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005256 " CFG (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005257 nSirStatus );
5258 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
5259 return eSIR_FAILURE; // just allocated...
5260 }
Jeff Johnsone7245742012-09-05 17:12:55 -07005261#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07005262
5263#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07005264 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07005265#endif
5266
Jeff Johnson295189b2012-06-20 16:38:30 -07005267 nStatus = dot11fPackChannelSwitch( pMac, &frm, pFrame +
5268 sizeof(tSirMacMgmtHdr),
5269 nPayload, &nPayload );
5270 if ( DOT11F_FAILED( nStatus ) )
5271 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005272 limLog( pMac, LOGE, FL("Failed to pack a Channel Switch (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005273 nStatus );
5274 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
5275 return eSIR_FAILURE; // allocated!
5276 }
5277 else if ( DOT11F_WARNED( nStatus ) )
5278 {
5279 limLog( pMac, LOGW, FL("There were warnings while packing a C"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005280 "hannel Switch (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07005281 }
5282
Jeff Johnsone7245742012-09-05 17:12:55 -07005283 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnsone7245742012-09-05 17:12:55 -07005284 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
5285 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnsone7245742012-09-05 17:12:55 -07005286 )
5287 {
5288 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
5289 }
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05305290
5291 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
5292 psessionEntry->peSessionId,
5293 pMacHdr->fc.subType));
Jeff Johnson295189b2012-06-20 16:38:30 -07005294 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
5295 HAL_TXRX_FRM_802_11_MGMT,
5296 ANI_TXDIR_TODS,
5297 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
Jeff Johnsone7245742012-09-05 17:12:55 -07005298 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05305299 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
5300 psessionEntry->peSessionId,
5301 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07005302 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
5303 {
5304 limLog( pMac, LOGE, FL("Failed to send a Channel Switch "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005305 "(%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07005306 nSirStatus );
5307 //Pkt will be freed up by the callback
5308 return eSIR_FAILURE;
5309 }
5310
5311 return eSIR_SUCCESS;
5312
5313} // End limSendChannelSwitchMgmtFrame.
5314
Abhishek Singh2b0cf1c2017-10-30 17:36:38 +05305315tSirRetStatus
5316lim_send_extended_chan_switch_action_frame(tpAniSirGlobal mac_ctx,
5317 tSirMacAddr peer, uint8_t mode, uint8_t new_op_class,
5318 uint8_t new_channel, uint8_t count, tpPESession session_entry)
5319{
5320 tDot11fext_channel_switch_action_frame frm;
5321 uint8_t *frame;
5322 tpSirMacMgmtHdr mac_hdr;
5323 uint32_t num_bytes, n_payload, status;
5324 void *packet;
5325 eHalStatus halstatus;
5326 uint8_t txFlag = 0;
5327
5328 if (!session_entry) {
5329 limLog(mac_ctx, LOGE, FL("Session entry is NULL!!!"));
5330 return eSIR_FAILURE;
5331 }
5332
5333 vos_mem_set(&frm, sizeof(frm), 0);
5334
5335 frm.Category.category = SIR_MAC_ACTION_PUBLIC_USAGE;
5336 frm.Action.action = SIR_MAC_ACTION_EXT_CHANNEL_SWITCH_ID;
5337
5338 frm.ext_chan_switch_ann_action.switch_mode = mode;
5339 frm.ext_chan_switch_ann_action.op_class = new_op_class;
5340 frm.ext_chan_switch_ann_action.new_channel = new_channel;
5341 frm.ext_chan_switch_ann_action.switch_count = count;
5342
5343
5344 status = dot11fGetPackedext_channel_switch_action_frameSize(mac_ctx,
5345 &frm, &n_payload);
5346 if (DOT11F_FAILED(status)) {
5347 limLog(mac_ctx, LOGE, FL("Failed to get packed size for Channel Switch 0x%08x"),
5348 status);
5349 /* We'll fall back on the worst case scenario*/
5350 n_payload = sizeof(tDot11fext_channel_switch_action_frame);
5351 } else if (DOT11F_WARNED(status)) {
5352 limLog(mac_ctx, LOGW, FL("There were warnings while calculating the packed size for a Ext Channel Switch (0x%08x)"),
5353 status);
5354 }
5355
5356 num_bytes = n_payload + sizeof(tSirMacMgmtHdr);
5357
5358 halstatus = palPktAlloc(mac_ctx->hHdd, HAL_TXRX_FRM_802_11_MGMT,
5359 (uint16_t )num_bytes, (void**) &frame,
5360 (void**) &packet);
5361
5362 if (!HAL_STATUS_SUCCESS(halstatus)) {
5363 limLog(mac_ctx, LOGE, FL("Failed to allocate %d bytes for a Ext Channel Switch"),
5364 num_bytes);
5365 return eSIR_FAILURE;
5366 }
5367
5368 /* Paranoia*/
5369 vos_mem_set(frame, num_bytes, 0);
5370
5371 /* Next, we fill out the buffer descriptor */
5372 limPopulateMacHeader(mac_ctx, frame, SIR_MAC_MGMT_FRAME,
5373 SIR_MAC_MGMT_ACTION, peer, session_entry->selfMacAddr);
5374 mac_hdr = (tpSirMacMgmtHdr) frame;
5375 vos_mem_copy((uint8_t *) mac_hdr->bssId,
5376 (uint8_t *) session_entry->bssId,
5377 sizeof(tSirMacAddr));
5378
5379#ifdef WLAN_FEATURE_11W
5380 limSetProtectedBit(mac_ctx, session_entry, peer, mac_hdr);
5381#endif
5382
5383 status = dot11fPackext_channel_switch_action_frame(mac_ctx, &frm,
5384 frame + sizeof(tSirMacMgmtHdr), n_payload, &n_payload);
5385 if (DOT11F_FAILED(status)) {
5386 limLog(mac_ctx, LOGE, FL("Failed to pack a Channel Switch 0x%08x"),
5387 status);
5388 palPktFree(mac_ctx->hHdd, HAL_TXRX_FRM_802_11_MGMT, (void*) frame,
5389 (void*) packet );
5390 return eSIR_FAILURE;
5391 } else if (DOT11F_WARNED(status)) {
5392 limLog(mac_ctx, LOGW, FL("There were warnings while packing a Channel Switch 0x%08x"),
5393 status);
5394 }
5395
5396 if ((SIR_BAND_5_GHZ ==
5397 limGetRFBand(session_entry->currentOperChannel)) ||
5398 (session_entry->pePersona == VOS_P2P_CLIENT_MODE) ||
5399 (session_entry->pePersona == VOS_P2P_GO_MODE)) {
5400 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
5401 }
Abhishek Singh5af90fe2017-12-27 16:17:51 +05305402 /* Use peer sta to transmit this frame */
5403 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
Abhishek Singh2b0cf1c2017-10-30 17:36:38 +05305404
5405 limLog(mac_ctx, LOG1, FL("Send Ext channel Switch to :"MAC_ADDRESS_STR" with swcount %d, swmode %d , newchannel %d newops %d"),
5406 MAC_ADDR_ARRAY(mac_hdr->da),
5407 frm.ext_chan_switch_ann_action.switch_count,
5408 frm.ext_chan_switch_ann_action.switch_mode,
5409 frm.ext_chan_switch_ann_action.new_channel,
5410 frm.ext_chan_switch_ann_action.op_class);
5411
5412 MTRACE(vos_trace(VOS_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
5413 session_entry->peSessionId, mac_hdr->fc.subType));
5414
5415 halstatus = halTxFrame(mac_ctx, packet, (uint16_t) num_bytes,
5416 HAL_TXRX_FRM_802_11_MGMT,
5417 ANI_TXDIR_TODS,
5418 7, limTxComplete, frame,
5419 txFlag);
5420 MTRACE(vos_trace(VOS_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
5421 session_entry->peSessionId, halstatus));
5422 if (!HAL_STATUS_SUCCESS(halstatus)) {
5423 limLog(mac_ctx, LOGE, FL("Failed to send a Ext Channel Switch %X!"),
5424 halstatus);
5425 /* Pkt will be freed up by the callback */
5426 return eSIR_FAILURE;
5427 }
5428 return eSIR_SUCCESS;
5429} /* End lim_send_extended_chan_switch_action_frame */
Jeff Johnson295189b2012-06-20 16:38:30 -07005430
5431
Mohit Khanna4a70d262012-09-11 16:30:12 -07005432#ifdef WLAN_FEATURE_11AC
5433tSirRetStatus
5434limSendVHTOpmodeNotificationFrame(tpAniSirGlobal pMac,
5435 tSirMacAddr peer,
5436 tANI_U8 nMode,
5437 tpPESession psessionEntry )
5438{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05305439 tDot11fOperatingMode frm;
5440 tANI_U8 *pFrame;
5441 tSirRetStatus nSirStatus;
5442 tpSirMacMgmtHdr pMacHdr;
5443 tANI_U32 nBytes, nPayload = 0, nStatus;//, nCfg;
5444 void *pPacket;
5445 eHalStatus halstatus;
5446 tANI_U32 txFlag = 0;
Mohit Khanna4a70d262012-09-11 16:30:12 -07005447
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305448 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Mohit Khanna4a70d262012-09-11 16:30:12 -07005449
5450 frm.Category.category = SIR_MAC_ACTION_VHT;
5451 frm.Action.action = SIR_MAC_VHT_OPMODE_NOTIFICATION;
5452 frm.OperatingMode.chanWidth = nMode;
5453 frm.OperatingMode.rxNSS = 0;
5454 frm.OperatingMode.rxNSSType = 0;
5455
5456 nStatus = dot11fGetPackedOperatingModeSize( pMac, &frm, &nPayload );
5457 if ( DOT11F_FAILED( nStatus ) )
5458 {
5459 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005460 "or a Operating Mode (0x%08x)."),
Mohit Khanna4a70d262012-09-11 16:30:12 -07005461 nStatus );
5462 // We'll fall back on the worst case scenario:
5463 nPayload = sizeof( tDot11fOperatingMode);
5464 }
5465 else if ( DOT11F_WARNED( nStatus ) )
5466 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005467 limLog( pMac, LOGW, FL("There were warnings while calculating "
Mohit Khanna4a70d262012-09-11 16:30:12 -07005468 "the packed size for a Operating Mode (0x"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005469 "%08x)."), nStatus );
Mohit Khanna4a70d262012-09-11 16:30:12 -07005470 }
5471
5472 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
5473
5474 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
5475 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
5476 {
5477 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Operating Mode"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005478 " Report."), nBytes );
Mohit Khanna4a70d262012-09-11 16:30:12 -07005479 return eSIR_FAILURE;
5480 }
5481
5482 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305483 vos_mem_set( pFrame, nBytes, 0 );
Mohit Khanna4a70d262012-09-11 16:30:12 -07005484
5485
5486 // Next, we fill out the buffer descriptor:
5487 if(psessionEntry->pePersona == VOS_STA_SAP_MODE) {
5488 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
5489 SIR_MAC_MGMT_ACTION, peer, psessionEntry->selfMacAddr);
5490 } else
5491 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
5492 SIR_MAC_MGMT_ACTION, psessionEntry->bssId, psessionEntry->selfMacAddr);
5493 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305494 vos_mem_copy( (tANI_U8 *) pMacHdr->bssId,
5495 (tANI_U8 *) psessionEntry->bssId,
5496 sizeof( tSirMacAddr ));
Mohit Khanna4a70d262012-09-11 16:30:12 -07005497 if ( eSIR_SUCCESS != nSirStatus )
5498 {
5499 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005500 "tor for a Operating Mode (%d)."),
Mohit Khanna4a70d262012-09-11 16:30:12 -07005501 nSirStatus );
5502 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
5503 return eSIR_FAILURE; // just allocated...
5504 }
5505 nStatus = dot11fPackOperatingMode( pMac, &frm, pFrame +
5506 sizeof(tSirMacMgmtHdr),
5507 nPayload, &nPayload );
5508 if ( DOT11F_FAILED( nStatus ) )
5509 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005510 limLog( pMac, LOGE, FL("Failed to pack a Operating Mode (0x%08x)."),
Mohit Khanna4a70d262012-09-11 16:30:12 -07005511 nStatus );
5512 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
5513 return eSIR_FAILURE; // allocated!
5514 }
5515 else if ( DOT11F_WARNED( nStatus ) )
5516 {
5517 limLog( pMac, LOGW, FL("There were warnings while packing a Operating Mode"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005518 " (0x%08x)."), nStatus );
Mohit Khanna4a70d262012-09-11 16:30:12 -07005519 }
5520 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Mohit Khanna4a70d262012-09-11 16:30:12 -07005521 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
5522 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Mohit Khanna4a70d262012-09-11 16:30:12 -07005523 )
5524 {
5525 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
5526 }
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05305527
5528 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
5529 psessionEntry->peSessionId,
5530 pMacHdr->fc.subType));
Mohit Khanna4a70d262012-09-11 16:30:12 -07005531 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
5532 HAL_TXRX_FRM_802_11_MGMT,
5533 ANI_TXDIR_TODS,
5534 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
5535 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05305536 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
5537 psessionEntry->peSessionId,
5538 halstatus));
Mohit Khanna4a70d262012-09-11 16:30:12 -07005539 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
5540 {
5541 limLog( pMac, LOGE, FL("Failed to send a Channel Switch "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005542 "(%X)!"),
Mohit Khanna4a70d262012-09-11 16:30:12 -07005543 nSirStatus );
5544 //Pkt will be freed up by the callback
5545 return eSIR_FAILURE;
5546 }
5547
5548 return eSIR_SUCCESS;
5549}
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005550
5551/**
5552 * \brief Send a VHT Channel Switch Announcement
5553 *
5554 *
5555 * \param pMac Pointer to the global MAC datastructure
5556 *
5557 * \param peer MAC address to which this frame will be sent
5558 *
5559 * \param nChanWidth
5560 *
5561 * \param nNewChannel
5562 *
5563 *
5564 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
5565 *
5566 *
5567 */
5568
5569tSirRetStatus
5570limSendVHTChannelSwitchMgmtFrame(tpAniSirGlobal pMac,
5571 tSirMacAddr peer,
5572 tANI_U8 nChanWidth,
5573 tANI_U8 nNewChannel,
5574 tANI_U8 ncbMode,
5575 tpPESession psessionEntry )
5576{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05305577 tDot11fChannelSwitch frm;
5578 tANI_U8 *pFrame;
5579 tSirRetStatus nSirStatus;
5580 tpSirMacMgmtHdr pMacHdr;
5581 tANI_U32 nBytes, nPayload, nStatus;//, nCfg;
5582 void *pPacket;
5583 eHalStatus halstatus;
5584 tANI_U32 txFlag = 0;
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005585
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305586 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005587
5588
5589 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
5590 frm.Action.action = SIR_MAC_ACTION_CHANNEL_SWITCH_ID;
5591 frm.ChanSwitchAnn.switchMode = 1;
5592 frm.ChanSwitchAnn.newChannel = nNewChannel;
5593 frm.ChanSwitchAnn.switchCount = 1;
Abhishek Singh15431c42017-10-25 15:43:02 +05305594 frm.sec_chan_offset.secondaryChannelOffset = limGetHTCBState(ncbMode);
5595 frm.sec_chan_offset.present = 1;
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005596 frm.WiderBWChanSwitchAnn.newChanWidth = nChanWidth;
5597 frm.WiderBWChanSwitchAnn.newCenterChanFreq0 = limGetCenterChannel(pMac,nNewChannel,ncbMode,nChanWidth);
5598 frm.WiderBWChanSwitchAnn.newCenterChanFreq1 = 0;
5599 frm.ChanSwitchAnn.present = 1;
5600 frm.WiderBWChanSwitchAnn.present = 1;
5601
5602 nStatus = dot11fGetPackedChannelSwitchSize( pMac, &frm, &nPayload );
5603 if ( DOT11F_FAILED( nStatus ) )
5604 {
5605 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005606 "or a Channel Switch (0x%08x)."),
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005607 nStatus );
5608 // We'll fall back on the worst case scenario:
5609 nPayload = sizeof( tDot11fChannelSwitch );
5610 }
5611 else if ( DOT11F_WARNED( nStatus ) )
5612 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005613 limLog( pMac, LOGW, FL("There were warnings while calculating "
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005614 "the packed size for a Channel Switch (0x"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005615 "%08x)."), nStatus );
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005616 }
5617
5618 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
5619
5620 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
5621 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
5622 {
5623 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a TPC"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005624 " Report."), nBytes );
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005625 return eSIR_FAILURE;
5626 }
5627 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305628 vos_mem_set( pFrame, nBytes, 0 );
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005629
5630 // Next, we fill out the buffer descriptor:
5631 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
5632 SIR_MAC_MGMT_ACTION, peer, psessionEntry->selfMacAddr);
5633 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305634 vos_mem_copy( (tANI_U8 *) pMacHdr->bssId,
5635 (tANI_U8 *) psessionEntry->bssId,
5636 sizeof( tSirMacAddr ));
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005637 if ( eSIR_SUCCESS != nSirStatus )
5638 {
5639 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005640 "tor for a Channel Switch (%d)."),
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005641 nSirStatus );
5642 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
5643 return eSIR_FAILURE; // just allocated...
5644 }
5645 nStatus = dot11fPackChannelSwitch( pMac, &frm, pFrame +
5646 sizeof(tSirMacMgmtHdr),
5647 nPayload, &nPayload );
5648 if ( DOT11F_FAILED( nStatus ) )
5649 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005650 limLog( pMac, LOGE, FL("Failed to pack a Channel Switch (0x%08x)."),
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005651 nStatus );
5652 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
5653 return eSIR_FAILURE; // allocated!
5654 }
5655 else if ( DOT11F_WARNED( nStatus ) )
5656 {
5657 limLog( pMac, LOGW, FL("There were warnings while packing a C"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005658 "hannel Switch (0x%08x)."), nStatus );
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005659 }
5660
5661 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005662 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
5663 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005664 )
5665 {
5666 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
5667 }
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05305668
5669 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
5670 psessionEntry->peSessionId,
5671 pMacHdr->fc.subType));
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005672 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
5673 HAL_TXRX_FRM_802_11_MGMT,
5674 ANI_TXDIR_TODS,
5675 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
5676 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05305677 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
5678 psessionEntry->peSessionId,
5679 halstatus));
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005680 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
5681 {
5682 limLog( pMac, LOGE, FL("Failed to send a Channel Switch "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005683 "(%X)!"),
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005684 nSirStatus );
5685 //Pkt will be freed up by the callback
5686 return eSIR_FAILURE;
5687 }
5688
5689 return eSIR_SUCCESS;
5690
5691} // End limSendVHTChannelSwitchMgmtFrame.
5692
5693
5694
Mohit Khanna4a70d262012-09-11 16:30:12 -07005695#endif
5696
Jeff Johnson295189b2012-06-20 16:38:30 -07005697/**
5698 * \brief Send an ADDBA Req Action Frame to peer
5699 *
5700 * \sa limSendAddBAReq
5701 *
5702 * \param pMac The global tpAniSirGlobal object
5703 *
5704 * \param pMlmAddBAReq A pointer to tLimMlmAddBAReq. This contains
5705 * the necessary parameters reqd by PE send the ADDBA Req Action
5706 * Frame to the peer
5707 *
5708 * \return eSIR_SUCCESS if setup completes successfully
5709 * eSIR_FAILURE is some problem is encountered
5710 */
5711tSirRetStatus limSendAddBAReq( tpAniSirGlobal pMac,
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305712 tpLimMlmAddBAReq pMlmAddBAReq, tpPESession psessionEntry)
Jeff Johnson295189b2012-06-20 16:38:30 -07005713{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05305714 tDot11fAddBAReq frmAddBAReq;
5715 tANI_U8 *pAddBAReqBuffer = NULL;
5716 tpSirMacMgmtHdr pMacHdr;
5717 tANI_U32 frameLen = 0, nStatus, nPayload;
5718 tSirRetStatus statusCode;
5719 eHalStatus halStatus;
5720 void *pPacket;
5721 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005722
5723 if(NULL == psessionEntry)
5724 {
5725 return eSIR_FAILURE;
5726 }
5727
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305728 vos_mem_set( (void *) &frmAddBAReq, sizeof( frmAddBAReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005729
5730 // Category - 3 (BA)
5731 frmAddBAReq.Category.category = SIR_MAC_ACTION_BLKACK;
5732
5733 // Action - 0 (ADDBA Req)
5734 frmAddBAReq.Action.action = SIR_MAC_BLKACK_ADD_REQ;
5735
5736 // FIXME - Dialog Token, generalize this...
5737 frmAddBAReq.DialogToken.token = pMlmAddBAReq->baDialogToken;
5738
5739 // Fill the ADDBA Parameter Set
5740 frmAddBAReq.AddBAParameterSet.tid = pMlmAddBAReq->baTID;
5741 frmAddBAReq.AddBAParameterSet.policy = pMlmAddBAReq->baPolicy;
5742 frmAddBAReq.AddBAParameterSet.bufferSize = pMlmAddBAReq->baBufferSize;
5743
5744 // BA timeout
5745 // 0 - indicates no BA timeout
5746 frmAddBAReq.BATimeout.timeout = pMlmAddBAReq->baTimeout;
5747
Abhishek Singh1f6e6532014-06-05 17:35:08 +05305748 /* Send SSN whatever we get from FW.
5749 */
5750 frmAddBAReq.BAStartingSequenceControl.ssn = pMlmAddBAReq->baSSN;
Jeff Johnson295189b2012-06-20 16:38:30 -07005751
5752 nStatus = dot11fGetPackedAddBAReqSize( pMac, &frmAddBAReq, &nPayload );
5753
5754 if( DOT11F_FAILED( nStatus ))
5755 {
5756 limLog( pMac, LOGW,
5757 FL( "Failed to calculate the packed size for "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005758 "an ADDBA Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005759 nStatus );
5760
5761 // We'll fall back on the worst case scenario:
5762 nPayload = sizeof( tDot11fAddBAReq );
5763 }
5764 else if( DOT11F_WARNED( nStatus ))
5765 {
5766 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005767 FL( "There were warnings while calculating "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005768 "the packed size for an ADDBA Req (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005769 nStatus );
5770 }
5771
5772 // Add the MGMT header to frame length
5773 frameLen = nPayload + sizeof( tSirMacMgmtHdr );
5774
5775 // Need to allocate a buffer for ADDBA AF
5776 if( eHAL_STATUS_SUCCESS !=
5777 (halStatus = palPktAlloc( pMac->hHdd,
5778 HAL_TXRX_FRM_802_11_MGMT,
5779 (tANI_U16) frameLen,
5780 (void **) &pAddBAReqBuffer,
5781 (void **) &pPacket )))
5782 {
5783 // Log error
5784 limLog( pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005785 FL("palPktAlloc FAILED! Length [%d], Status [%d]"),
Jeff Johnson295189b2012-06-20 16:38:30 -07005786 frameLen,
5787 halStatus );
5788
5789 statusCode = eSIR_MEM_ALLOC_FAILED;
5790 goto returnAfterError;
5791 }
5792
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305793 vos_mem_set( (void *) pAddBAReqBuffer, frameLen, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005794
5795 // Copy necessary info to BD
5796 if( eSIR_SUCCESS !=
5797 (statusCode = limPopulateMacHeader( pMac,
5798 pAddBAReqBuffer,
5799 SIR_MAC_MGMT_FRAME,
5800 SIR_MAC_MGMT_ACTION,
5801 pMlmAddBAReq->peerMacAddr,psessionEntry->selfMacAddr)))
5802 goto returnAfterError;
5803
5804 // Update A3 with the BSSID
5805 pMacHdr = ( tpSirMacMgmtHdr ) pAddBAReqBuffer;
5806
5807 #if 0
5808 cfgLen = SIR_MAC_ADDR_LENGTH;
5809 if( eSIR_SUCCESS != cfgGetStr( pMac,
5810 WNI_CFG_BSSID,
5811 (tANI_U8 *) pMacHdr->bssId,
5812 &cfgLen ))
5813 {
5814 limLog( pMac, LOGP,
5815 FL( "Failed to retrieve WNI_CFG_BSSID while"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005816 "sending an ACTION Frame" ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005817
5818 // FIXME - Need to convert to tSirRetStatus
5819 statusCode = eSIR_FAILURE;
5820 goto returnAfterError;
5821 }
5822 #endif//TO SUPPORT BT-AMP
5823 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
5824
Chet Lanctot186b5732013-03-18 10:26:30 -07005825#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07005826 limSetProtectedBit(pMac, psessionEntry, pMlmAddBAReq->peerMacAddr, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07005827#endif
5828
Jeff Johnson295189b2012-06-20 16:38:30 -07005829 // Now, we're ready to "pack" the frames
5830 nStatus = dot11fPackAddBAReq( pMac,
5831 &frmAddBAReq,
5832 pAddBAReqBuffer + sizeof( tSirMacMgmtHdr ),
5833 nPayload,
5834 &nPayload );
5835
5836 if( DOT11F_FAILED( nStatus ))
5837 {
5838 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005839 FL( "Failed to pack an ADDBA Req (0x%08x)." ),
Jeff Johnson295189b2012-06-20 16:38:30 -07005840 nStatus );
5841
5842 // FIXME - Need to convert to tSirRetStatus
5843 statusCode = eSIR_FAILURE;
5844 goto returnAfterError;
5845 }
5846 else if( DOT11F_WARNED( nStatus ))
5847 {
5848 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005849 FL( "There were warnings while packing an ADDBA Req (0x%08x)."),
5850 nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07005851 }
5852
Abhishek Singh02d9f6c2014-05-12 14:07:53 +05305853 limLog( pMac, LOG1, FL( "Sending an ADDBA REQ to "MAC_ADDRESS_STR " with"
5854 " tid = %d policy = %d buffsize = %d "
5855 " amsduSupported = %d"),
5856 MAC_ADDR_ARRAY(pMlmAddBAReq->peerMacAddr),
5857 frmAddBAReq.AddBAParameterSet.tid,
5858 frmAddBAReq.AddBAParameterSet.policy,
5859 frmAddBAReq.AddBAParameterSet.bufferSize,
5860 frmAddBAReq.AddBAParameterSet.amsduSupported);
Jeff Johnson295189b2012-06-20 16:38:30 -07005861
Abhishek Singh1f6e6532014-06-05 17:35:08 +05305862 limLog( pMac, LOG1, FL( "ssn = %d fragNum = %d" ),
5863 frmAddBAReq.BAStartingSequenceControl.ssn,
5864 frmAddBAReq.BAStartingSequenceControl.fragNumber);
5865
Jeff Johnson295189b2012-06-20 16:38:30 -07005866 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07005867 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
5868 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07005869 )
5870 {
5871 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
5872 }
5873
Yeshwanth Sriram Guntukada8466f2018-06-26 17:22:05 +05305874 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
5875
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05305876 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
5877 psessionEntry->peSessionId,
5878 pMacHdr->fc.subType));
5879 halStatus = halTxFrame( pMac,
5880 pPacket,
5881 (tANI_U16) frameLen,
5882 HAL_TXRX_FRM_802_11_MGMT,
5883 ANI_TXDIR_TODS,
5884 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
5885 limTxComplete,
5886 pAddBAReqBuffer, txFlag );
5887 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
5888 psessionEntry->peSessionId,
5889 halStatus));
5890 if( eHAL_STATUS_SUCCESS != halStatus )
Jeff Johnson295189b2012-06-20 16:38:30 -07005891 {
5892 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005893 FL( "halTxFrame FAILED! Status [%d]"),
Jeff Johnson295189b2012-06-20 16:38:30 -07005894 halStatus );
5895
5896 // FIXME - Need to convert eHalStatus to tSirRetStatus
5897 statusCode = eSIR_FAILURE;
5898 //Pkt will be freed up by the callback
5899 return statusCode;
5900 }
5901 else
5902 return eSIR_SUCCESS;
5903
5904returnAfterError:
5905
5906 // Release buffer, if allocated
5907 if( NULL != pAddBAReqBuffer )
5908 palPktFree( pMac->hHdd,
5909 HAL_TXRX_FRM_802_11_MGMT,
5910 (void *) pAddBAReqBuffer,
5911 (void *) pPacket );
5912
5913 return statusCode;
5914}
5915
5916/**
5917 * \brief Send an ADDBA Rsp Action Frame to peer
5918 *
5919 * \sa limSendAddBARsp
5920 *
5921 * \param pMac The global tpAniSirGlobal object
5922 *
5923 * \param pMlmAddBARsp A pointer to tLimMlmAddBARsp. This contains
5924 * the necessary parameters reqd by PE send the ADDBA Rsp Action
5925 * Frame to the peer
5926 *
5927 * \return eSIR_SUCCESS if setup completes successfully
5928 * eSIR_FAILURE is some problem is encountered
5929 */
5930tSirRetStatus limSendAddBARsp( tpAniSirGlobal pMac,
5931 tpLimMlmAddBARsp pMlmAddBARsp,
5932 tpPESession psessionEntry)
5933{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05305934 tDot11fAddBARsp frmAddBARsp;
5935 tANI_U8 *pAddBARspBuffer = NULL;
5936 tpSirMacMgmtHdr pMacHdr;
5937 tANI_U32 frameLen = 0, nStatus, nPayload;
5938 tSirRetStatus statusCode;
5939 eHalStatus halStatus;
5940 void *pPacket;
5941 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005942
5943 if(NULL == psessionEntry)
5944 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005945 PELOGE(limLog(pMac, LOGE, FL("Session entry is NULL!!!"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07005946 return eSIR_FAILURE;
5947 }
5948
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305949 vos_mem_set( (void *) &frmAddBARsp, sizeof( frmAddBARsp ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005950
5951 // Category - 3 (BA)
5952 frmAddBARsp.Category.category = SIR_MAC_ACTION_BLKACK;
5953 // Action - 1 (ADDBA Rsp)
5954 frmAddBARsp.Action.action = SIR_MAC_BLKACK_ADD_RSP;
5955
5956 // Should be same as the one we received in the ADDBA Req
5957 frmAddBARsp.DialogToken.token = pMlmAddBARsp->baDialogToken;
5958
5959 // ADDBA Req status
5960 frmAddBARsp.Status.status = pMlmAddBARsp->addBAResultCode;
5961
5962 // Fill the ADDBA Parameter Set as provided by caller
5963 frmAddBARsp.AddBAParameterSet.tid = pMlmAddBARsp->baTID;
5964 frmAddBARsp.AddBAParameterSet.policy = pMlmAddBARsp->baPolicy;
5965 frmAddBARsp.AddBAParameterSet.bufferSize = pMlmAddBARsp->baBufferSize;
krunal soni5afa96c2013-09-06 22:19:02 -07005966
guanglunyang(177503)1b85c502020-05-21 09:28:34 +08005967 frmAddBARsp.AddBAParameterSet.amsduSupported = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07005968
5969 // BA timeout
5970 // 0 - indicates no BA timeout
5971 frmAddBARsp.BATimeout.timeout = pMlmAddBARsp->baTimeout;
5972
5973 nStatus = dot11fGetPackedAddBARspSize( pMac, &frmAddBARsp, &nPayload );
5974
5975 if( DOT11F_FAILED( nStatus ))
5976 {
5977 limLog( pMac, LOGW,
5978 FL( "Failed to calculate the packed size for "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005979 "an ADDBA Response (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005980 nStatus );
5981
5982 // We'll fall back on the worst case scenario:
5983 nPayload = sizeof( tDot11fAddBARsp );
5984 }
5985 else if( DOT11F_WARNED( nStatus ))
5986 {
5987 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005988 FL( "There were warnings while calculating "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005989 "the packed size for an ADDBA Rsp (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005990 nStatus );
5991 }
5992
5993 // Need to allocate a buffer for ADDBA AF
5994 frameLen = nPayload + sizeof( tSirMacMgmtHdr );
5995
5996 // Allocate shared memory
5997 if( eHAL_STATUS_SUCCESS !=
5998 (halStatus = palPktAlloc( pMac->hHdd,
5999 HAL_TXRX_FRM_802_11_MGMT,
6000 (tANI_U16) frameLen,
6001 (void **) &pAddBARspBuffer,
6002 (void **) &pPacket )))
6003 {
6004 // Log error
6005 limLog( pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006006 FL("palPktAlloc FAILED! Length [%d], Status [%d]"),
Jeff Johnson295189b2012-06-20 16:38:30 -07006007 frameLen,
6008 halStatus );
6009
6010 statusCode = eSIR_MEM_ALLOC_FAILED;
6011 goto returnAfterError;
6012 }
6013
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05306014 vos_mem_set( (void *) pAddBARspBuffer, frameLen, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07006015
6016 // Copy necessary info to BD
6017 if( eSIR_SUCCESS !=
6018 (statusCode = limPopulateMacHeader( pMac,
6019 pAddBARspBuffer,
6020 SIR_MAC_MGMT_FRAME,
6021 SIR_MAC_MGMT_ACTION,
6022 pMlmAddBARsp->peerMacAddr,psessionEntry->selfMacAddr)))
6023 goto returnAfterError;
6024
6025 // Update A3 with the BSSID
6026
6027 pMacHdr = ( tpSirMacMgmtHdr ) pAddBARspBuffer;
6028
6029 #if 0
6030 cfgLen = SIR_MAC_ADDR_LENGTH;
6031 if( eSIR_SUCCESS != wlan_cfgGetStr( pMac,
6032 WNI_CFG_BSSID,
6033 (tANI_U8 *) pMacHdr->bssId,
6034 &cfgLen ))
6035 {
6036 limLog( pMac, LOGP,
6037 FL( "Failed to retrieve WNI_CFG_BSSID while"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006038 "sending an ACTION Frame" ));
Jeff Johnson295189b2012-06-20 16:38:30 -07006039
6040 // FIXME - Need to convert to tSirRetStatus
6041 statusCode = eSIR_FAILURE;
6042 goto returnAfterError;
6043 }
6044 #endif // TO SUPPORT BT-AMP
6045 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
6046
Chet Lanctot186b5732013-03-18 10:26:30 -07006047#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07006048 limSetProtectedBit(pMac, psessionEntry, pMlmAddBARsp->peerMacAddr, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07006049#endif
6050
Jeff Johnson295189b2012-06-20 16:38:30 -07006051 // Now, we're ready to "pack" the frames
6052 nStatus = dot11fPackAddBARsp( pMac,
6053 &frmAddBARsp,
6054 pAddBARspBuffer + sizeof( tSirMacMgmtHdr ),
6055 nPayload,
6056 &nPayload );
6057
6058 if( DOT11F_FAILED( nStatus ))
6059 {
6060 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006061 FL( "Failed to pack an ADDBA Rsp (0x%08x)." ),
Jeff Johnson295189b2012-06-20 16:38:30 -07006062 nStatus );
6063
6064 // FIXME - Need to convert to tSirRetStatus
6065 statusCode = eSIR_FAILURE;
6066 goto returnAfterError;
6067 }
6068 else if( DOT11F_WARNED( nStatus ))
6069 {
6070 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08006071 FL( "There were warnings while packing an ADDBA Rsp (0x%08x)." ),
6072 nStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07006073 }
6074
Abhishek Singh02d9f6c2014-05-12 14:07:53 +05306075 limLog( pMac, LOG1, FL( "Sending an ADDBA RSP to "MAC_ADDRESS_STR " with"
6076 " tid = %d policy = %d buffsize = %d"
6077 " amsduSupported = %d status %d"),
6078 MAC_ADDR_ARRAY(pMlmAddBARsp->peerMacAddr),
6079 frmAddBARsp.AddBAParameterSet.tid,
6080 frmAddBARsp.AddBAParameterSet.policy,
6081 frmAddBARsp.AddBAParameterSet.bufferSize,
6082 frmAddBARsp.AddBAParameterSet.amsduSupported,
6083 frmAddBARsp.Status.status);
6084
Jeff Johnson295189b2012-06-20 16:38:30 -07006085
6086 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07006087 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
6088 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07006089 )
6090 {
6091 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
6092 }
6093
Yeshwanth Sriram Guntukada8466f2018-06-26 17:22:05 +05306094 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
6095
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05306096 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
6097 psessionEntry->peSessionId,
6098 pMacHdr->fc.subType));
6099 halStatus = halTxFrame( pMac,
6100 pPacket,
6101 (tANI_U16) frameLen,
6102 HAL_TXRX_FRM_802_11_MGMT,
6103 ANI_TXDIR_TODS,
6104 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
6105 limTxComplete,
6106 pAddBARspBuffer, txFlag );
6107 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
6108 psessionEntry->peSessionId,
6109 halStatus));
6110 if( eHAL_STATUS_SUCCESS != halStatus )
6111 {
Jeff Johnson295189b2012-06-20 16:38:30 -07006112 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006113 FL( "halTxFrame FAILED! Status [%d]" ),
Jeff Johnson295189b2012-06-20 16:38:30 -07006114 halStatus );
6115
6116 // FIXME - HAL error codes are different from PE error
6117 // codes!! And, this routine is returning tSirRetStatus
6118 statusCode = eSIR_FAILURE;
6119 //Pkt will be freed up by the callback
6120 return statusCode;
6121 }
6122 else
6123 return eSIR_SUCCESS;
6124
6125 returnAfterError:
Jeff Johnson295189b2012-06-20 16:38:30 -07006126 // Release buffer, if allocated
6127 if( NULL != pAddBARspBuffer )
6128 palPktFree( pMac->hHdd,
6129 HAL_TXRX_FRM_802_11_MGMT,
6130 (void *) pAddBARspBuffer,
6131 (void *) pPacket );
6132
6133 return statusCode;
6134}
6135
6136/**
6137 * \brief Send a DELBA Indication Action Frame to peer
6138 *
6139 * \sa limSendDelBAInd
6140 *
6141 * \param pMac The global tpAniSirGlobal object
6142 *
6143 * \param peerMacAddr MAC Address of peer
6144 *
6145 * \param reasonCode Reason for the DELBA notification
6146 *
6147 * \param pBAParameterSet The DELBA Parameter Set.
6148 * This identifies the TID for which the BA session is
6149 * being deleted.
6150 *
6151 * \return eSIR_SUCCESS if setup completes successfully
6152 * eSIR_FAILURE is some problem is encountered
6153 */
6154tSirRetStatus limSendDelBAInd( tpAniSirGlobal pMac,
6155 tpLimMlmDelBAReq pMlmDelBAReq,tpPESession psessionEntry)
6156{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05306157 tDot11fDelBAInd frmDelBAInd;
6158 tANI_U8 *pDelBAIndBuffer = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07006159 //tANI_U32 val;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05306160 tpSirMacMgmtHdr pMacHdr;
6161 tANI_U32 frameLen = 0, nStatus, nPayload;
6162 tSirRetStatus statusCode;
6163 eHalStatus halStatus;
6164 void *pPacket;
6165 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07006166
6167 if(NULL == psessionEntry)
6168 {
6169 return eSIR_FAILURE;
6170 }
6171
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05306172 vos_mem_set( (void *) &frmDelBAInd, sizeof( frmDelBAInd ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07006173
6174 // Category - 3 (BA)
6175 frmDelBAInd.Category.category = SIR_MAC_ACTION_BLKACK;
6176 // Action - 2 (DELBA)
6177 frmDelBAInd.Action.action = SIR_MAC_BLKACK_DEL;
6178
6179 // Fill the DELBA Parameter Set as provided by caller
6180 frmDelBAInd.DelBAParameterSet.tid = pMlmDelBAReq->baTID;
6181 frmDelBAInd.DelBAParameterSet.initiator = pMlmDelBAReq->baDirection;
6182
6183 // BA Starting Sequence Number
6184 // Fragment number will always be zero
6185 frmDelBAInd.Reason.code = pMlmDelBAReq->delBAReasonCode;
6186
6187 nStatus = dot11fGetPackedDelBAIndSize( pMac, &frmDelBAInd, &nPayload );
6188
6189 if( DOT11F_FAILED( nStatus ))
6190 {
6191 limLog( pMac, LOGW,
6192 FL( "Failed to calculate the packed size for "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006193 "an DELBA Indication (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07006194 nStatus );
6195
6196 // We'll fall back on the worst case scenario:
6197 nPayload = sizeof( tDot11fDelBAInd );
6198 }
6199 else if( DOT11F_WARNED( nStatus ))
6200 {
6201 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08006202 FL( "There were warnings while calculating "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006203 "the packed size for an DELBA Ind (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07006204 nStatus );
6205 }
6206
6207 // Add the MGMT header to frame length
6208 frameLen = nPayload + sizeof( tSirMacMgmtHdr );
6209
6210 // Allocate shared memory
6211 if( eHAL_STATUS_SUCCESS !=
6212 (halStatus = palPktAlloc( pMac->hHdd,
6213 HAL_TXRX_FRM_802_11_MGMT,
6214 (tANI_U16) frameLen,
6215 (void **) &pDelBAIndBuffer,
6216 (void **) &pPacket )))
6217 {
6218 // Log error
6219 limLog( pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006220 FL("palPktAlloc FAILED! Length [%d], Status [%d]"),
Jeff Johnson295189b2012-06-20 16:38:30 -07006221 frameLen,
6222 halStatus );
6223
6224 statusCode = eSIR_MEM_ALLOC_FAILED;
6225 goto returnAfterError;
6226 }
6227
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05306228 vos_mem_set( (void *) pDelBAIndBuffer, frameLen, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07006229
6230 // Copy necessary info to BD
6231 if( eSIR_SUCCESS !=
6232 (statusCode = limPopulateMacHeader( pMac,
6233 pDelBAIndBuffer,
6234 SIR_MAC_MGMT_FRAME,
6235 SIR_MAC_MGMT_ACTION,
6236 pMlmDelBAReq->peerMacAddr,psessionEntry->selfMacAddr)))
6237 goto returnAfterError;
6238
6239 // Update A3 with the BSSID
6240 pMacHdr = ( tpSirMacMgmtHdr ) pDelBAIndBuffer;
6241
6242 #if 0
6243 cfgLen = SIR_MAC_ADDR_LENGTH;
6244 if( eSIR_SUCCESS != cfgGetStr( pMac,
6245 WNI_CFG_BSSID,
6246 (tANI_U8 *) pMacHdr->bssId,
6247 &cfgLen ))
6248 {
6249 limLog( pMac, LOGP,
6250 FL( "Failed to retrieve WNI_CFG_BSSID while"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006251 "sending an ACTION Frame" ));
Jeff Johnson295189b2012-06-20 16:38:30 -07006252
6253 // FIXME - Need to convert to tSirRetStatus
6254 statusCode = eSIR_FAILURE;
6255 goto returnAfterError;
6256 }
6257 #endif //TO SUPPORT BT-AMP
6258 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
6259
Chet Lanctot186b5732013-03-18 10:26:30 -07006260#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07006261 limSetProtectedBit(pMac, psessionEntry, pMlmDelBAReq->peerMacAddr, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07006262#endif
6263
Jeff Johnson295189b2012-06-20 16:38:30 -07006264 // Now, we're ready to "pack" the frames
6265 nStatus = dot11fPackDelBAInd( pMac,
6266 &frmDelBAInd,
6267 pDelBAIndBuffer + sizeof( tSirMacMgmtHdr ),
6268 nPayload,
6269 &nPayload );
6270
6271 if( DOT11F_FAILED( nStatus ))
6272 {
6273 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006274 FL( "Failed to pack an DELBA Ind (0x%08x)." ),
Jeff Johnson295189b2012-06-20 16:38:30 -07006275 nStatus );
6276
6277 // FIXME - Need to convert to tSirRetStatus
6278 statusCode = eSIR_FAILURE;
6279 goto returnAfterError;
6280 }
6281 else if( DOT11F_WARNED( nStatus ))
6282 {
6283 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08006284 FL( "There were warnings while packing an DELBA Ind (0x%08x)." ),
6285 nStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07006286 }
6287
Abhishek Singh1f6e6532014-06-05 17:35:08 +05306288 limLog( pMac, LOG1,
6289 FL( "Sending a DELBA IND to: "MAC_ADDRESS_STR" with Tid = %d"
6290 " initiator = %d reason = %d" ),
6291 MAC_ADDR_ARRAY(pMlmDelBAReq->peerMacAddr),
6292 frmDelBAInd.DelBAParameterSet.tid,
6293 frmDelBAInd.DelBAParameterSet.initiator,
6294 frmDelBAInd.Reason.code);
6295
Jeff Johnson295189b2012-06-20 16:38:30 -07006296
6297 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07006298 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
6299 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07006300 )
6301 {
6302 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
6303 }
6304
Yeshwanth Sriram Guntukada8466f2018-06-26 17:22:05 +05306305 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
6306
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05306307 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
6308 psessionEntry->peSessionId,
6309 pMacHdr->fc.subType));
6310 halStatus = halTxFrame( pMac,
6311 pPacket,
6312 (tANI_U16) frameLen,
6313 HAL_TXRX_FRM_802_11_MGMT,
6314 ANI_TXDIR_TODS,
6315 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
6316 limTxComplete,
6317 pDelBAIndBuffer, txFlag );
6318 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
6319 psessionEntry->peSessionId,
6320 halStatus));
6321 if( eHAL_STATUS_SUCCESS != halStatus )
Jeff Johnson295189b2012-06-20 16:38:30 -07006322 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006323 PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]" ), halStatus );)
Jeff Johnson295189b2012-06-20 16:38:30 -07006324 statusCode = eSIR_FAILURE;
6325 //Pkt will be freed up by the callback
6326 return statusCode;
6327 }
6328 else
6329 return eSIR_SUCCESS;
6330
6331 returnAfterError:
6332
6333 // Release buffer, if allocated
6334 if( NULL != pDelBAIndBuffer )
6335 palPktFree( pMac->hHdd,
6336 HAL_TXRX_FRM_802_11_MGMT,
6337 (void *) pDelBAIndBuffer,
6338 (void *) pPacket );
6339
6340 return statusCode;
6341}
6342
6343#if defined WLAN_FEATURE_VOWIFI
6344
6345/**
6346 * \brief Send a Neighbor Report Request Action frame
6347 *
6348 *
6349 * \param pMac Pointer to the global MAC structure
6350 *
6351 * \param pNeighborReq Address of a tSirMacNeighborReportReq
6352 *
6353 * \param peer mac address of peer station.
6354 *
6355 * \param psessionEntry address of session entry.
6356 *
6357 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
6358 *
6359 *
6360 */
6361
6362tSirRetStatus
6363limSendNeighborReportRequestFrame(tpAniSirGlobal pMac,
6364 tpSirMacNeighborReportReq pNeighborReq,
6365 tSirMacAddr peer,
6366 tpPESession psessionEntry
6367 )
6368{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05306369 tSirRetStatus statusCode = eSIR_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006370 tDot11fNeighborReportRequest frm;
6371 tANI_U8 *pFrame;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05306372 tpSirMacMgmtHdr pMacHdr;
6373 tANI_U32 nBytes, nPayload, nStatus;
6374 void *pPacket;
6375 eHalStatus halstatus;
6376 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07006377
6378 if ( psessionEntry == NULL )
6379 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006380 limLog( pMac, LOGE, FL("(psession == NULL) in Request to send Neighbor Report request action frame") );
Jeff Johnson295189b2012-06-20 16:38:30 -07006381 return eSIR_FAILURE;
6382 }
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05306383 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07006384
6385 frm.Category.category = SIR_MAC_ACTION_RRM;
6386 frm.Action.action = SIR_MAC_RRM_NEIGHBOR_REQ;
6387 frm.DialogToken.token = pNeighborReq->dialogToken;
6388
6389
6390 if( pNeighborReq->ssid_present )
6391 {
6392 PopulateDot11fSSID( pMac, &pNeighborReq->ssid, &frm.SSID );
6393 }
6394
6395 nStatus = dot11fGetPackedNeighborReportRequestSize( pMac, &frm, &nPayload );
6396 if ( DOT11F_FAILED( nStatus ) )
6397 {
6398 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006399 "or a Neighbor Report Request(0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07006400 nStatus );
6401 // We'll fall back on the worst case scenario:
6402 nPayload = sizeof( tDot11fNeighborReportRequest );
6403 }
6404 else if ( DOT11F_WARNED( nStatus ) )
6405 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08006406 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07006407 "the packed size for a Neighbor Rep"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006408 "ort Request(0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07006409 }
6410
6411 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
6412
6413 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
6414 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
6415 {
6416 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Neighbor "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006417 "Report Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07006418 return eSIR_FAILURE;
6419 }
6420
6421 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05306422 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07006423
6424 // Copy necessary info to BD
6425 if( eSIR_SUCCESS !=
6426 (statusCode = limPopulateMacHeader( pMac,
6427 pFrame,
6428 SIR_MAC_MGMT_FRAME,
6429 SIR_MAC_MGMT_ACTION,
6430 peer, psessionEntry->selfMacAddr)))
6431 goto returnAfterError;
6432
6433 // Update A3 with the BSSID
6434 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
6435
6436 sirCopyMacAddr( pMacHdr->bssId, psessionEntry->bssId );
6437
Chet Lanctot186b5732013-03-18 10:26:30 -07006438#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07006439 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07006440#endif
6441
Jeff Johnson295189b2012-06-20 16:38:30 -07006442 // Now, we're ready to "pack" the frames
6443 nStatus = dot11fPackNeighborReportRequest( pMac,
6444 &frm,
6445 pFrame + sizeof( tSirMacMgmtHdr ),
6446 nPayload,
6447 &nPayload );
6448
6449 if( DOT11F_FAILED( nStatus ))
6450 {
6451 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006452 FL( "Failed to pack an Neighbor Report Request (0x%08x)." ),
Jeff Johnson295189b2012-06-20 16:38:30 -07006453 nStatus );
6454
6455 // FIXME - Need to convert to tSirRetStatus
6456 statusCode = eSIR_FAILURE;
6457 goto returnAfterError;
6458 }
6459 else if( DOT11F_WARNED( nStatus ))
6460 {
6461 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08006462 FL( "There were warnings while packing Neighbor Report "
6463 "Request (0x%08x)." ), nStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07006464 }
6465
6466 limLog( pMac, LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006467 FL( "Sending a Neighbor Report Request to " ));
Jeff Johnson295189b2012-06-20 16:38:30 -07006468 limPrintMacAddr( pMac, peer, LOGW );
6469
6470 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07006471 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
6472 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07006473 )
6474 {
6475 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
6476 }
6477
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05306478 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
6479 psessionEntry->peSessionId,
6480 pMacHdr->fc.subType));
6481 halstatus = halTxFrame( pMac,
6482 pPacket,
6483 (tANI_U16) nBytes,
6484 HAL_TXRX_FRM_802_11_MGMT,
6485 ANI_TXDIR_TODS,
6486 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
6487 limTxComplete,
6488 pFrame, txFlag );
6489 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
6490 psessionEntry->peSessionId,
6491 halstatus));
6492 if( eHAL_STATUS_SUCCESS != halstatus )
Jeff Johnson295189b2012-06-20 16:38:30 -07006493 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006494 PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]" ), halstatus );)
Jeff Johnson295189b2012-06-20 16:38:30 -07006495 statusCode = eSIR_FAILURE;
6496 //Pkt will be freed up by the callback
6497 return statusCode;
6498 }
6499 else
6500 return eSIR_SUCCESS;
6501
6502returnAfterError:
6503 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
6504
6505 return statusCode;
6506} // End limSendNeighborReportRequestFrame.
6507
6508/**
6509 * \brief Send a Link Report Action frame
6510 *
6511 *
6512 * \param pMac Pointer to the global MAC structure
6513 *
6514 * \param pLinkReport Address of a tSirMacLinkReport
6515 *
6516 * \param peer mac address of peer station.
6517 *
6518 * \param psessionEntry address of session entry.
6519 *
6520 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
6521 *
6522 *
6523 */
6524
6525tSirRetStatus
6526limSendLinkReportActionFrame(tpAniSirGlobal pMac,
6527 tpSirMacLinkReport pLinkReport,
6528 tSirMacAddr peer,
6529 tpPESession psessionEntry
6530 )
6531{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05306532 tSirRetStatus statusCode = eSIR_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006533 tDot11fLinkMeasurementReport frm;
6534 tANI_U8 *pFrame;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05306535 tpSirMacMgmtHdr pMacHdr;
6536 tANI_U32 nBytes, nPayload, nStatus;
6537 void *pPacket;
6538 eHalStatus halstatus;
6539 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07006540
6541
6542 if ( psessionEntry == NULL )
6543 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006544 limLog( pMac, LOGE, FL("(psession == NULL) in Request to send Link Report action frame") );
Jeff Johnson295189b2012-06-20 16:38:30 -07006545 return eSIR_FAILURE;
6546 }
6547
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05306548 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07006549
6550 frm.Category.category = SIR_MAC_ACTION_RRM;
6551 frm.Action.action = SIR_MAC_RRM_LINK_MEASUREMENT_RPT;
6552 frm.DialogToken.token = pLinkReport->dialogToken;
6553
6554
6555 //IEEE Std. 802.11 7.3.2.18. for the report element.
6556 //Even though TPC report an IE, it is represented using fixed fields since it is positioned
6557 //in the middle of other fixed fields in the link report frame(IEEE Std. 802.11k section7.4.6.4
6558 //and frame parser always expects IEs to come after all fixed fields. It is easier to handle
6559 //such case this way than changing the frame parser.
6560 frm.TPCEleID.TPCId = SIR_MAC_TPC_RPT_EID;
6561 frm.TPCEleLen.TPCLen = 2;
6562 frm.TxPower.txPower = pLinkReport->txPower;
6563 frm.LinkMargin.linkMargin = 0;
6564
6565 frm.RxAntennaId.antennaId = pLinkReport->rxAntenna;
6566 frm.TxAntennaId.antennaId = pLinkReport->txAntenna;
6567 frm.RCPI.rcpi = pLinkReport->rcpi;
6568 frm.RSNI.rsni = pLinkReport->rsni;
6569
6570 nStatus = dot11fGetPackedLinkMeasurementReportSize( pMac, &frm, &nPayload );
6571 if ( DOT11F_FAILED( nStatus ) )
6572 {
6573 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006574 "or a Link Report (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07006575 nStatus );
6576 // We'll fall back on the worst case scenario:
6577 nPayload = sizeof( tDot11fLinkMeasurementReport );
6578 }
6579 else if ( DOT11F_WARNED( nStatus ) )
6580 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08006581 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07006582 "the packed size for a Link Rep"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006583 "ort (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07006584 }
6585
6586 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
6587
6588 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
6589 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
6590 {
6591 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Link "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006592 "Report."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07006593 return eSIR_FAILURE;
6594 }
6595
6596 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05306597 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07006598
6599 // Copy necessary info to BD
6600 if( eSIR_SUCCESS !=
6601 (statusCode = limPopulateMacHeader( pMac,
6602 pFrame,
6603 SIR_MAC_MGMT_FRAME,
6604 SIR_MAC_MGMT_ACTION,
6605 peer, psessionEntry->selfMacAddr)))
6606 goto returnAfterError;
6607
6608 // Update A3 with the BSSID
6609 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
6610
6611 sirCopyMacAddr( pMacHdr->bssId, psessionEntry->bssId );
6612
Chet Lanctot186b5732013-03-18 10:26:30 -07006613#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07006614 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07006615#endif
6616
Jeff Johnson295189b2012-06-20 16:38:30 -07006617 // Now, we're ready to "pack" the frames
6618 nStatus = dot11fPackLinkMeasurementReport( pMac,
6619 &frm,
6620 pFrame + sizeof( tSirMacMgmtHdr ),
6621 nPayload,
6622 &nPayload );
6623
6624 if( DOT11F_FAILED( nStatus ))
6625 {
6626 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006627 FL( "Failed to pack an Link Report (0x%08x)." ),
Jeff Johnson295189b2012-06-20 16:38:30 -07006628 nStatus );
6629
6630 // FIXME - Need to convert to tSirRetStatus
6631 statusCode = eSIR_FAILURE;
6632 goto returnAfterError;
6633 }
6634 else if( DOT11F_WARNED( nStatus ))
6635 {
6636 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08006637 FL( "There were warnings while packing Link Report (0x%08x)." ),
6638 nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07006639 }
6640
6641 limLog( pMac, LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006642 FL( "Sending a Link Report to " ));
Jeff Johnson295189b2012-06-20 16:38:30 -07006643 limPrintMacAddr( pMac, peer, LOGW );
6644
6645 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07006646 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
6647 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07006648 )
6649 {
6650 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
6651 }
6652
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05306653 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
6654 psessionEntry->peSessionId,
6655 pMacHdr->fc.subType));
6656 halstatus = halTxFrame( pMac,
6657 pPacket,
6658 (tANI_U16) nBytes,
6659 HAL_TXRX_FRM_802_11_MGMT,
6660 ANI_TXDIR_TODS,
6661 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
6662 limTxComplete,
6663 pFrame, txFlag );
6664 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
6665 psessionEntry->peSessionId,
6666 halstatus));
6667 if( eHAL_STATUS_SUCCESS != halstatus )
Jeff Johnson295189b2012-06-20 16:38:30 -07006668 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006669 PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]" ), halstatus );)
Jeff Johnson295189b2012-06-20 16:38:30 -07006670 statusCode = eSIR_FAILURE;
6671 //Pkt will be freed up by the callback
6672 return statusCode;
6673 }
6674 else
6675 return eSIR_SUCCESS;
6676
6677returnAfterError:
6678 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
6679
6680 return statusCode;
6681} // End limSendLinkReportActionFrame.
6682
6683/**
6684 * \brief Send a Beacon Report Action frame
6685 *
6686 *
6687 * \param pMac Pointer to the global MAC structure
6688 *
6689 * \param dialog_token dialog token to be used in the action frame.
6690 *
6691 * \param num_report number of reports in pRRMReport.
6692 *
6693 * \param pRRMReport Address of a tSirMacRadioMeasureReport.
6694 *
6695 * \param peer mac address of peer station.
6696 *
6697 * \param psessionEntry address of session entry.
6698 *
6699 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
6700 *
6701 *
6702 */
6703
6704tSirRetStatus
6705limSendRadioMeasureReportActionFrame(tpAniSirGlobal pMac,
6706 tANI_U8 dialog_token,
6707 tANI_U8 num_report,
6708 tpSirMacRadioMeasureReport pRRMReport,
6709 tSirMacAddr peer,
6710 tpPESession psessionEntry
6711 )
6712{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05306713 tSirRetStatus statusCode = eSIR_SUCCESS;
6714 tANI_U8 *pFrame;
6715 tpSirMacMgmtHdr pMacHdr;
6716 tANI_U32 nBytes, nPayload, nStatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07006717 void *pPacket;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05306718 eHalStatus halstatus;
6719 tANI_U8 i;
6720 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07006721
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006722 tDot11fRadioMeasurementReport *frm =
6723 vos_mem_malloc(sizeof(tDot11fRadioMeasurementReport));
6724 if (!frm) {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006725 limLog( pMac, LOGE, FL("Not enough memory to allocate tDot11fRadioMeasurementReport") );
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006726 return eSIR_FAILURE;
6727 }
6728
Jeff Johnson295189b2012-06-20 16:38:30 -07006729 if ( psessionEntry == NULL )
6730 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006731 limLog( pMac, LOGE, FL("(psession == NULL) in Request to send Beacon Report action frame") );
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006732 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07006733 return eSIR_FAILURE;
6734 }
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05306735 vos_mem_set( ( tANI_U8* )frm, sizeof( *frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07006736
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006737 frm->Category.category = SIR_MAC_ACTION_RRM;
6738 frm->Action.action = SIR_MAC_RRM_RADIO_MEASURE_RPT;
6739 frm->DialogToken.token = dialog_token;
Jeff Johnson295189b2012-06-20 16:38:30 -07006740
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006741 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 -07006742
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006743 for( i = 0 ; i < frm->num_MeasurementReport ; i++ )
Jeff Johnson295189b2012-06-20 16:38:30 -07006744 {
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006745 frm->MeasurementReport[i].type = pRRMReport[i].type;
6746 frm->MeasurementReport[i].token = pRRMReport[i].token;
6747 frm->MeasurementReport[i].late = 0; //IEEE 802.11k section 7.3.22. (always zero in rrm)
Jeff Johnson295189b2012-06-20 16:38:30 -07006748 switch( pRRMReport[i].type )
6749 {
6750 case SIR_MAC_RRM_BEACON_TYPE:
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006751 PopulateDot11fBeaconReport( pMac, &frm->MeasurementReport[i], &pRRMReport[i].report.beaconReport );
6752 frm->MeasurementReport[i].incapable = pRRMReport[i].incapable;
6753 frm->MeasurementReport[i].refused = pRRMReport[i].refused;
6754 frm->MeasurementReport[i].present = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07006755 break;
6756 default:
Gopichand Nakkala72717fd2013-02-08 12:23:45 +05306757 frm->MeasurementReport[i].incapable = pRRMReport[i].incapable;
6758 frm->MeasurementReport[i].refused = pRRMReport[i].refused;
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006759 frm->MeasurementReport[i].present = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07006760 break;
6761 }
6762 }
6763
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006764 nStatus = dot11fGetPackedRadioMeasurementReportSize( pMac, frm, &nPayload );
Jeff Johnson295189b2012-06-20 16:38:30 -07006765 if ( DOT11F_FAILED( nStatus ) )
6766 {
6767 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006768 "or a Radio Measure Report (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07006769 nStatus );
6770 // We'll fall back on the worst case scenario:
6771 nPayload = sizeof( tDot11fLinkMeasurementReport );
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006772 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07006773 return eSIR_FAILURE;
6774 }
6775 else if ( DOT11F_WARNED( nStatus ) )
6776 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08006777 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07006778 "the packed size for a Radio Measure Rep"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006779 "ort (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07006780 }
6781
6782 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
6783
6784 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
6785 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
6786 {
6787 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Radio Measure "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006788 "Report."), nBytes );
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006789 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07006790 return eSIR_FAILURE;
6791 }
6792
6793 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05306794 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07006795
6796 // Copy necessary info to BD
6797 if( eSIR_SUCCESS !=
6798 (statusCode = limPopulateMacHeader( pMac,
6799 pFrame,
6800 SIR_MAC_MGMT_FRAME,
6801 SIR_MAC_MGMT_ACTION,
6802 peer, psessionEntry->selfMacAddr)))
6803 goto returnAfterError;
6804
6805 // Update A3 with the BSSID
6806 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
6807
6808 sirCopyMacAddr( pMacHdr->bssId, psessionEntry->bssId );
6809
Chet Lanctot186b5732013-03-18 10:26:30 -07006810#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07006811 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07006812#endif
6813
Jeff Johnson295189b2012-06-20 16:38:30 -07006814 // Now, we're ready to "pack" the frames
6815 nStatus = dot11fPackRadioMeasurementReport( pMac,
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006816 frm,
Jeff Johnson295189b2012-06-20 16:38:30 -07006817 pFrame + sizeof( tSirMacMgmtHdr ),
6818 nPayload,
6819 &nPayload );
6820
6821 if( DOT11F_FAILED( nStatus ))
6822 {
6823 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006824 FL( "Failed to pack an Radio Measure Report (0x%08x)." ),
Jeff Johnson295189b2012-06-20 16:38:30 -07006825 nStatus );
6826
6827 // FIXME - Need to convert to tSirRetStatus
6828 statusCode = eSIR_FAILURE;
6829 goto returnAfterError;
6830 }
6831 else if( DOT11F_WARNED( nStatus ))
6832 {
6833 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08006834 FL( "There were warnings while packing Radio "
6835 "Measure Report (0x%08x)." ), nStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07006836 }
6837
6838 limLog( pMac, LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006839 FL( "Sending a Radio Measure Report to " ));
Jeff Johnson295189b2012-06-20 16:38:30 -07006840 limPrintMacAddr( pMac, peer, LOGW );
6841
6842 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07006843 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
6844 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07006845 )
6846 {
6847 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
6848 }
6849
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05306850 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
6851 psessionEntry->peSessionId,
6852 pMacHdr->fc.subType));
6853 halstatus = halTxFrame( pMac,
6854 pPacket,
6855 (tANI_U16) nBytes,
6856 HAL_TXRX_FRM_802_11_MGMT,
6857 ANI_TXDIR_TODS,
6858 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
6859 limTxComplete,
6860 pFrame, txFlag );
6861 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
6862 psessionEntry->peSessionId,
6863 halstatus));
6864 if( eHAL_STATUS_SUCCESS != halstatus )
Jeff Johnson295189b2012-06-20 16:38:30 -07006865 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006866 PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]" ), halstatus );)
Jeff Johnson295189b2012-06-20 16:38:30 -07006867 statusCode = eSIR_FAILURE;
6868 //Pkt will be freed up by the callback
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006869 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07006870 return statusCode;
6871 }
Madan Mohan Koyyalamudieeb56b12012-10-31 15:10:04 -07006872 else {
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006873 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07006874 return eSIR_SUCCESS;
Madan Mohan Koyyalamudieeb56b12012-10-31 15:10:04 -07006875 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006876
6877returnAfterError:
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006878 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07006879 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
Jeff Johnson295189b2012-06-20 16:38:30 -07006880 return statusCode;
6881} // End limSendBeaconReportActionFrame.
6882
6883#endif
6884
6885#ifdef WLAN_FEATURE_11W
6886/**
Chet Lanctot8cecea22014-02-11 19:09:36 -08006887 * \brief Send SA query request action frame to peer
6888 *
6889 * \sa limSendSaQueryRequestFrame
6890 *
6891 *
6892 * \param pMac The global tpAniSirGlobal object
6893 *
6894 * \param transId Transaction identifier
6895 *
6896 * \param peer The Mac address of the station to which this action frame is addressed
6897 *
6898 * \param psessionEntry The PE session entry
6899 *
6900 * \return eSIR_SUCCESS if setup completes successfully
6901 * eSIR_FAILURE is some problem is encountered
6902 */
6903
6904tSirRetStatus limSendSaQueryRequestFrame( tpAniSirGlobal pMac, tANI_U8 *transId,
6905 tSirMacAddr peer, tpPESession psessionEntry )
6906{
6907
6908 tDot11fSaQueryReq frm; // SA query request action frame
6909 tANI_U8 *pFrame;
6910 tSirRetStatus nSirStatus;
6911 tpSirMacMgmtHdr pMacHdr;
6912 tANI_U32 nBytes, nPayload, nStatus;
6913 void *pPacket;
6914 eHalStatus halstatus;
6915 tANI_U8 txFlag = 0;
6916
6917 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
6918 frm.Category.category = SIR_MAC_ACTION_SA_QUERY;
6919 /* 11w action field is :
6920 action: 0 --> SA Query Request action frame
6921 action: 1 --> SA Query Response action frame */
6922 frm.Action.action = SIR_MAC_SA_QUERY_REQ;
6923 /* 11w SA Query Request transId */
6924 vos_mem_copy( &frm.TransactionId.transId[0], &transId[0], 2 );
6925
6926 nStatus = dot11fGetPackedSaQueryReqSize(pMac, &frm, &nPayload);
6927 if ( DOT11F_FAILED( nStatus ) )
6928 {
6929 limLog( pMac, LOGP, FL("Failed to calculate the packed size "
6930 "for an SA Query Request (0x%08x)."),
6931 nStatus );
6932 // We'll fall back on the worst case scenario:
6933 nPayload = sizeof( tDot11fSaQueryReq );
6934 }
6935 else if ( DOT11F_WARNED( nStatus ) )
6936 {
6937 limLog( pMac, LOGW, FL("There were warnings while calculating "
6938 "the packed size for an SA Query Request"
6939 " (0x%08x)."), nStatus );
6940 }
6941
6942 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
6943 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
6944 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
6945 {
6946 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a SA Query Request "
6947 "action frame"), nBytes );
6948 return eSIR_FAILURE;
6949 }
6950
6951 // Paranoia:
6952 vos_mem_set( pFrame, nBytes, 0 );
6953
6954 // Copy necessary info to BD
6955 nSirStatus = limPopulateMacHeader( pMac,
6956 pFrame,
6957 SIR_MAC_MGMT_FRAME,
6958 SIR_MAC_MGMT_ACTION,
6959 peer, psessionEntry->selfMacAddr );
6960 if ( eSIR_SUCCESS != nSirStatus )
6961 goto returnAfterError;
6962
6963 // Update A3 with the BSSID
6964 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
6965
6966 sirCopyMacAddr( pMacHdr->bssId, psessionEntry->bssId );
6967
6968 // Since this is a SA Query Request, set the "protect" (aka WEP) bit
6969 // in the FC
6970 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
6971
6972 // Pack 11w SA Query Request frame
6973 nStatus = dot11fPackSaQueryReq( pMac,
6974 &frm,
6975 pFrame + sizeof( tSirMacMgmtHdr ),
6976 nPayload,
6977 &nPayload );
6978
6979 if ( DOT11F_FAILED( nStatus ))
6980 {
6981 limLog( pMac, LOGE,
6982 FL( "Failed to pack an SA Query Request (0x%08x)." ),
6983 nStatus );
6984 // FIXME - Need to convert to tSirRetStatus
6985 nSirStatus = eSIR_FAILURE;
6986 goto returnAfterError;
6987 }
6988 else if ( DOT11F_WARNED( nStatus ))
6989 {
6990 limLog( pMac, LOGW,
6991 FL( "There were warnings while packing SA Query Request (0x%08x)." ),
6992 nStatus);
6993 }
6994
6995 limLog( pMac, LOG1,
6996 FL( "Sending an SA Query Request to " ));
6997 limPrintMacAddr( pMac, peer, LOG1 );
6998 limPrintMacAddr( pMac, peer, LOGE );
6999 limLog( pMac, LOGE,
7000 FL( "Sending an SA Query Request from " ));
7001 limPrintMacAddr( pMac, psessionEntry->selfMacAddr, LOGE );
7002
7003 if ( ( SIR_BAND_5_GHZ == limGetRFBand( psessionEntry->currentOperChannel ) )
7004#ifdef WLAN_FEATURE_P2P
7005 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
7006 ( psessionEntry->pePersona == VOS_P2P_GO_MODE )
7007#endif
7008 )
7009 {
7010 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
7011 }
7012
7013 halstatus = halTxFrame( pMac,
7014 pPacket,
7015 (tANI_U16) nBytes,
7016 HAL_TXRX_FRM_802_11_MGMT,
7017 ANI_TXDIR_TODS,
7018 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
7019 limTxComplete,
7020 pFrame, txFlag );
7021 if ( eHAL_STATUS_SUCCESS != halstatus )
7022 {
7023 PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]" ), halstatus );)
7024 nSirStatus = eSIR_FAILURE;
7025 //Pkt will be freed up by the callback
7026 return nSirStatus;
7027 }
7028 else {
7029 return eSIR_SUCCESS;
7030 }
7031
7032returnAfterError:
7033 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
7034 return nSirStatus;
7035} // End limSendSaQueryRequestFrame
7036
7037/**
Jeff Johnson295189b2012-06-20 16:38:30 -07007038 * \brief Send SA query response action frame to peer
7039 *
7040 * \sa limSendSaQueryResponseFrame
7041 *
7042 *
7043 * \param pMac The global tpAniSirGlobal object
7044 *
Chet Lanctot186b5732013-03-18 10:26:30 -07007045 * \param transId Transaction identifier received in SA query request action frame
Jeff Johnson295189b2012-06-20 16:38:30 -07007046 *
Chet Lanctot186b5732013-03-18 10:26:30 -07007047 * \param peer The Mac address of the AP to which this action frame is addressed
7048 *
7049 * \param psessionEntry The PE session entry
Jeff Johnson295189b2012-06-20 16:38:30 -07007050 *
7051 * \return eSIR_SUCCESS if setup completes successfully
7052 * eSIR_FAILURE is some problem is encountered
7053 */
7054
Chet Lanctot186b5732013-03-18 10:26:30 -07007055tSirRetStatus limSendSaQueryResponseFrame( tpAniSirGlobal pMac, tANI_U8 *transId,
Jeff Johnson295189b2012-06-20 16:38:30 -07007056tSirMacAddr peer,tpPESession psessionEntry)
7057{
7058
Chet Lanctot186b5732013-03-18 10:26:30 -07007059 tDot11fSaQueryRsp frm; // SA query reponse action frame
Jeff Johnson295189b2012-06-20 16:38:30 -07007060 tANI_U8 *pFrame;
7061 tSirRetStatus nSirStatus;
7062 tpSirMacMgmtHdr pMacHdr;
Chet Lanctot186b5732013-03-18 10:26:30 -07007063 tANI_U32 nBytes, nPayload, nStatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07007064 void *pPacket;
7065 eHalStatus halstatus;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05307066 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07007067
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05307068 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Chet Lanctot186b5732013-03-18 10:26:30 -07007069 frm.Category.category = SIR_MAC_ACTION_SA_QUERY;
7070 /*11w action field is :
Jeff Johnson295189b2012-06-20 16:38:30 -07007071 action: 0 --> SA query request action frame
7072 action: 1 --> SA query response action frame */
Chet Lanctot186b5732013-03-18 10:26:30 -07007073 frm.Action.action = SIR_MAC_SA_QUERY_RSP;
7074 /*11w SA query response transId is same as
Jeff Johnson295189b2012-06-20 16:38:30 -07007075 SA query request transId*/
Chet Lanctot186b5732013-03-18 10:26:30 -07007076 vos_mem_copy( &frm.TransactionId.transId[0], &transId[0], 2 );
Jeff Johnson295189b2012-06-20 16:38:30 -07007077
Chet Lanctot186b5732013-03-18 10:26:30 -07007078 nStatus = dot11fGetPackedSaQueryRspSize(pMac, &frm, &nPayload);
7079 if ( DOT11F_FAILED( nStatus ) )
7080 {
7081 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
7082 "or a SA Query Response (0x%08x)."),
7083 nStatus );
7084 // We'll fall back on the worst case scenario:
7085 nPayload = sizeof( tDot11fSaQueryRsp );
7086 }
7087 else if ( DOT11F_WARNED( nStatus ) )
7088 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08007089 limLog( pMac, LOGW, FL("There were warnings while calculating "
Chet Lanctot186b5732013-03-18 10:26:30 -07007090 "the packed size for an SA Query Response"
7091 " (0x%08x)."), nStatus );
7092 }
7093
Jeff Johnson295189b2012-06-20 16:38:30 -07007094 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
7095 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
7096 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
7097 {
7098 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a SA query response"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07007099 " action frame"), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07007100 return eSIR_FAILURE;
7101 }
7102
7103 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05307104 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07007105
Chet Lanctot186b5732013-03-18 10:26:30 -07007106 // Copy necessary info to BD
Chet Lanctotb2b0d552013-03-22 16:58:44 -07007107 nSirStatus = limPopulateMacHeader( pMac,
Chet Lanctot186b5732013-03-18 10:26:30 -07007108 pFrame,
7109 SIR_MAC_MGMT_FRAME,
7110 SIR_MAC_MGMT_ACTION,
Chet Lanctotb2b0d552013-03-22 16:58:44 -07007111 peer, psessionEntry->selfMacAddr );
7112 if ( eSIR_SUCCESS != nSirStatus )
Chet Lanctot186b5732013-03-18 10:26:30 -07007113 goto returnAfterError;
Jeff Johnson295189b2012-06-20 16:38:30 -07007114
Chet Lanctot186b5732013-03-18 10:26:30 -07007115 // Update A3 with the BSSID
Jeff Johnson295189b2012-06-20 16:38:30 -07007116 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
7117
Chet Lanctot186b5732013-03-18 10:26:30 -07007118 sirCopyMacAddr( pMacHdr->bssId, psessionEntry->bssId );
Jeff Johnson295189b2012-06-20 16:38:30 -07007119
Chet Lanctot186b5732013-03-18 10:26:30 -07007120 // Since this is a SA Query Response, set the "protect" (aka WEP) bit
7121 // in the FC
Chet Lanctot8cecea22014-02-11 19:09:36 -08007122 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Jeff Johnson295189b2012-06-20 16:38:30 -07007123
Chet Lanctot186b5732013-03-18 10:26:30 -07007124 // Pack 11w SA query response frame
7125 nStatus = dot11fPackSaQueryRsp( pMac,
7126 &frm,
7127 pFrame + sizeof( tSirMacMgmtHdr ),
7128 nPayload,
7129 &nPayload );
7130
7131 if ( DOT11F_FAILED( nStatus ))
7132 {
7133 limLog( pMac, LOGE,
7134 FL( "Failed to pack an SA Query Response (0x%08x)." ),
7135 nStatus );
7136 // FIXME - Need to convert to tSirRetStatus
7137 nSirStatus = eSIR_FAILURE;
7138 goto returnAfterError;
7139 }
7140 else if ( DOT11F_WARNED( nStatus ))
7141 {
7142 limLog( pMac, LOGW,
7143 FL( "There were warnings while packing SA Query Response (0x%08x)." ),
7144 nStatus);
7145 }
7146
7147 limLog( pMac, LOG1,
7148 FL( "Sending a SA Query Response to " ));
7149 limPrintMacAddr( pMac, peer, LOGW );
7150
Chet Lanctotb2b0d552013-03-22 16:58:44 -07007151 if ( ( SIR_BAND_5_GHZ == limGetRFBand( psessionEntry->currentOperChannel ) )
Chet Lanctot186b5732013-03-18 10:26:30 -07007152#ifdef WLAN_FEATURE_P2P
Chet Lanctotb2b0d552013-03-22 16:58:44 -07007153 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
7154 ( psessionEntry->pePersona == VOS_P2P_GO_MODE )
Chet Lanctot186b5732013-03-18 10:26:30 -07007155#endif
Chet Lanctotb2b0d552013-03-22 16:58:44 -07007156 )
7157 {
7158 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
7159 }
Chet Lanctot186b5732013-03-18 10:26:30 -07007160
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05307161 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
7162 psessionEntry->peSessionId,
7163 pMacHdr->fc.subType));
Chet Lanctotb2b0d552013-03-22 16:58:44 -07007164 halstatus = halTxFrame( pMac,
7165 pPacket,
7166 (tANI_U16) nBytes,
7167 HAL_TXRX_FRM_802_11_MGMT,
7168 ANI_TXDIR_TODS,
7169 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
7170 limTxComplete,
7171 pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05307172 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
7173 psessionEntry->peSessionId,
7174 halstatus));
Chet Lanctotb2b0d552013-03-22 16:58:44 -07007175 if ( eHAL_STATUS_SUCCESS != halstatus )
Chet Lanctot186b5732013-03-18 10:26:30 -07007176 {
7177 PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]" ), halstatus );)
7178 nSirStatus = eSIR_FAILURE;
7179 //Pkt will be freed up by the callback
7180 return nSirStatus;
7181 }
7182 else {
7183 return eSIR_SUCCESS;
7184 }
7185
7186returnAfterError:
7187 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
7188 return nSirStatus;
7189} // End limSendSaQueryResponseFrame
Jeff Johnson295189b2012-06-20 16:38:30 -07007190#endif
Abhishek Singh00b71972016-01-07 10:51:04 +05307191
7192#ifdef WLAN_FEATURE_RMC
7193tSirRetStatus
7194limSendRMCActionFrame(tpAniSirGlobal pMac,
7195 tSirMacAddr peerMacAddr,
7196 tSirRMCInfo *pRMC,
7197 tpPESession psessionEntry)
7198{
7199 tSirRetStatus nSirStatus;
7200 tANI_U8 *pFrame;
7201 tDot11fRMC RMC;
7202 tANI_U32 nPayload, nBytes, nStatus;
7203 tpSirMacMgmtHdr pMacHdr;
7204 void *pPacket;
7205 eHalStatus halstatus;
7206 tANI_U8 txFlag = 0;
7207 tANI_U8 MagicCode[] = { 0x4f, 0x58, 0x59, 0x47, 0x45, 0x4e };
7208
7209 if (NULL == psessionEntry)
7210 {
7211 return eSIR_FAILURE;
7212 }
7213
7214 vos_mem_set(( tANI_U8* )&RMC, sizeof( RMC ), 0);
7215
7216 RMC.Action.action = pRMC->action;
7217 RMC.RMCDialogToken.token = pRMC->dialogToken;
7218 RMC.Category.category = SIR_MAC_ACTION_VENDOR_SPECIFIC_CATEGORY;
7219 RMC.RMCVersion.version = SIR_MAC_RMC_VER;
7220
7221 vos_mem_copy(&RMC.RMCOUI.oui, SIR_MAC_RMC_OUI, SIR_MAC_RMC_OUI_SIZE);
7222 vos_mem_copy(&RMC.MagicCode.magic, MagicCode, sizeof(MagicCode));
7223
7224 vos_mem_copy(&RMC.Ruler.mac, pRMC->mcastRuler, sizeof(tSirMacAddr));
7225
7226 nStatus = dot11fGetPackedRMCSize( pMac, &RMC, &nPayload );
7227 if ( DOT11F_FAILED( nStatus ) )
7228 {
7229 limLog( pMac, LOGE, FL("Failed to calculate the packed size for "
7230 "an RMC (0x%08x)."),
7231 nStatus );
7232 // We'll fall back on the worst case scenario:
7233 nPayload = sizeof( tDot11fRMC );
7234 }
7235 else if ( DOT11F_WARNED( nStatus ) )
7236 {
7237 limLog( pMac, LOGW, FL("There were warnings while calculating "
7238 "the packed size for an RMC Action Frame"
7239 " (0x%08x)."), nStatus );
7240 }
7241
7242 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
7243
7244 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
7245 ( tANI_U16 )nBytes, ( void** ) &pFrame,
7246 ( void** ) &pPacket );
7247 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
7248 {
7249 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for an RMC "
7250 "Action Frame."), nBytes );
7251 return eSIR_FAILURE;
7252 }
7253
7254 // Paranoia:
7255 vos_mem_set( pFrame, nBytes, 0 );
7256
7257 // Next, we fill out the buffer descriptor:
7258 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
7259 SIR_MAC_MGMT_ACTION, peerMacAddr,
7260 psessionEntry->selfMacAddr);
7261 if ( eSIR_SUCCESS != nSirStatus )
7262 {
7263 limLog( pMac, LOGE, FL("Failed to populate the buffer descriptor "
7264 "for an RMC Action Frame (%d)."),
7265 nSirStatus );
7266 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
7267 ( void* ) pFrame, ( void* ) pPacket );
7268 return nSirStatus;
7269 }
7270
7271 // Update A3 with the BSSID
7272 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
7273 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
7274
7275 // That done, pack the struct:
7276 nStatus = dot11fPackRMC( pMac, &RMC,
7277 pFrame + sizeof(tSirMacMgmtHdr),
7278 nPayload, &nPayload );
7279 if ( DOT11F_FAILED( nStatus ) )
7280 {
7281 limLog( pMac, LOGE, FL("Failed to pack an RMC "
7282 "(0x%08x)."),
7283 nStatus );
7284 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame,
7285 ( void* ) pPacket );
7286 return eSIR_FAILURE;
7287 }
7288 else if ( DOT11F_WARNED( nStatus ) )
7289 {
7290 limLog( pMac, LOGW, FL("There were warnings while packing "
7291 "an RMC (0x%08x)."), nStatus );
7292 }
7293
7294 limLog( pMac, LOG1, FL("Sending an RMC Action frame to "
7295 MAC_ADDRESS_STR), MAC_ADDR_ARRAY(peerMacAddr));
7296
7297 /*
7298 * With this masking, RMC action frames will be sent
7299 * at self-sta rates for both 2G and 5G bands.
7300 */
7301 txFlag |= HAL_USE_SELF_STA_REQUESTED_MASK;
7302
7303 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
7304 psessionEntry->peSessionId,
7305 pMacHdr->fc.subType));
7306 // Queue RMC Action frame in high priority WQ
7307 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
7308 HAL_TXRX_FRM_802_11_MGMT,
7309 ANI_TXDIR_TODS,
7310 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
7311 limTxComplete, pFrame, txFlag );
7312 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
7313 psessionEntry->peSessionId,
7314 halstatus));
7315 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
7316 {
7317 limLog( pMac, LOGE, FL( "*** Could not send an RMC Action frame"
7318 " (%X) ***" ), halstatus );
7319 //Pkt will be freed up by the callback
7320 return eSIR_FAILURE;
7321 }
7322
7323 return eSIR_SUCCESS;
7324
7325} // End limSendRMCActionFrame.
7326
7327#endif /* WLAN_FEATURE_RMC */
Abhinav Kumar8eed0362019-08-05 14:26:07 +05307328
7329/**
7330 * lim_tx_mgmt_frame() - Transmits Auth mgmt frame
7331 * @mac_ctx Pointer to Global MAC structure
7332 * @mb_msg: Received message info
7333 * @msg_len: Received message length
7334 * @packet: Packet to be transmitted
7335 * @frame: Received frame
7336 *
7337 * Return: None
7338 */
7339static void lim_tx_mgmt_frame(tpAniSirGlobal mac_ctx,
7340 struct sir_mgmt_msg *mb_msg, uint32_t msg_len,
7341 void *packet, uint8_t *frame)
7342{
7343 tpSirMacFrameCtl fc = (tpSirMacFrameCtl)mb_msg->data;
7344 eHalStatus hal_status;
7345 uint8_t sme_session_id = 0;
7346 tpPESession session;
7347
7348 sme_session_id = mb_msg->session_id;
7349 session = pe_find_session_by_sme_session_id(mac_ctx, sme_session_id);
7350 if (session == NULL) {
7351 limLog(mac_ctx, LOGP,
7352 FL("session not found for given sme session"));
7353 return;
7354 }
7355 MTRACE(vos_trace(VOS_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
7356 session->peSessionId, fc->subType));
7357 mac_ctx->authAckStatus = LIM_AUTH_ACK_NOT_RCD;
7358 hal_status =
7359 halTxFrameWithTxComplete(mac_ctx, packet, (uint16_t)msg_len,
7360 HAL_TXRX_FRM_802_11_MGMT,
7361 ANI_TXDIR_TODS,
7362 7, limTxComplete, frame,
7363 limAuthTxCompleteCnf,
7364 0, mac_ctx->lim.txBdToken);
7365 MTRACE(vos_trace(VOS_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
7366 session->peSessionId, hal_status));
7367 if (!HAL_STATUS_SUCCESS(hal_status)) {
7368 limLog(mac_ctx, LOGP,
7369 FL("*** Could not send Auth frame, retCode=%X ***"),
7370 hal_status);
7371 mac_ctx->authAckStatus = LIM_AUTH_ACK_RCD_FAILURE;
7372 limDiagEventReport(mac_ctx, WLAN_PE_DIAG_AUTH_REQ_EVENT,
7373 session, eSIR_FAILURE, eSIR_FAILURE);
7374 /* Pkt will be freed up by the callback */
7375 }
7376}
7377
7378void lim_send_mgmt_frame_tx(tpAniSirGlobal mac_ctx, tpSirMsgQ msg)
7379{
7380 struct sir_mgmt_msg *mb_msg = (struct sir_mgmt_msg *)msg->bodyptr;
7381 uint32_t msg_len;
7382 tpSirMacFrameCtl fc = (tpSirMacFrameCtl)mb_msg->data;
7383 uint8_t sme_session_id;
7384 eHalStatus halstatus;
7385 uint8_t *frame;
7386 void *packet;
7387
7388 msg_len = mb_msg->msg_len - sizeof(*mb_msg);
7389 limLog(mac_ctx, LOG1, FL("sending fc->type: %d fc->subType: %d"),
7390 fc->type, fc->subType);
7391 sme_session_id = mb_msg->session_id;
7392 halstatus = palPktAlloc(mac_ctx->hHdd, HAL_TXRX_FRM_802_11_MGMT,
7393 (uint16_t)msg_len, (void **)&frame,
7394 (void **)&packet);
7395 if (!HAL_STATUS_SUCCESS(halstatus)) {
7396 limLog(mac_ctx, LOGP, FL("call to bufAlloc failed for AUTH frame"));
7397 return;
7398 }
7399 vos_mem_copy(frame, mb_msg->data, msg_len);
7400 lim_tx_mgmt_frame(mac_ctx, mb_msg, msg_len, packet, frame);
7401}