blob: edcb7b276dd6b649112ea9ca31988db21aa76b3f [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Kiet Lam842dad02014-02-18 18:44:02 -08002 * Copyright (c) 2012-2014 The Linux Foundation. All rights reserved.
3 *
4 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
5 *
6 *
7 * Permission to use, copy, modify, and/or distribute this software for
8 * any purpose with or without fee is hereby granted, provided that the
9 * above copyright notice and this permission notice appear in all
10 * copies.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
13 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
14 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
15 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
16 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
17 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
18 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19 * PERFORMANCE OF THIS SOFTWARE.
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
56#include "wniCfgAp.h"
57#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
112 { /*Est Cap present size is 8 + 2 byte at present*/
113 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];
138
139 if ( NULL == pBuf )
140 {
141 limLog( pMac, LOGE,
142 FL("Invalid Buffer Address"));
143 return;
144 }
145 if(NULL == pDst)
146 {
147 PELOGE(limLog(pMac, LOGE,
148 FL("NULL pDst pointer"));)
149 return ;
150 }
151
152 if ( DOT11F_EID_EXTCAP != pBuf[0] ||
153 pBuf[1] > DOT11F_IE_EXTCAP_MAX_LEN )
154 {
Mahesh A Saptasagare00ff532014-10-17 19:05:14 +0530155 limLog( pMac, LOG1,
Kalikinkar dhara205da782014-03-21 15:49:32 -0700156 FL("Invalid IEs eid = %d elem_len=%d "),
157 pBuf[0],pBuf[1]);
158 return;
159 }
160 vos_mem_set(( tANI_U8* )&pOut[0], DOT11F_IE_EXTCAP_MAX_LEN, 0);
161 /* conversion should follow 4, 2, 2 byte order */
162 limUtilsframeshtonl(pMac, &pOut[0],*((tANI_U32*)&pBuf[2]),0);
163 limUtilsframeshtons(pMac, &pOut[4],*((tANI_U16*)&pBuf[6]),0);
164 limUtilsframeshtons(pMac, &pOut[6],*((tANI_U16*)&pBuf[8]),0);
165
166 if ( DOT11F_PARSE_SUCCESS != dot11fUnpackIeExtCap( pMac,
167 &pOut[0], DOT11F_IE_EXTCAP_MAX_LEN, pDst) )
168 {
169 limLog( pMac, LOGE,
170 FL("dot11fUnpackIeExtCap Parse Error "));
171 }
172}
173
174tSirRetStatus limStripOffExtCapIEAndUpdateStruct(tpAniSirGlobal pMac,
175 tANI_U8* addIE,
176 tANI_U16 *addnIELen,
177 tDot11fIEExtCap * pDst )
178{
179 tANI_U8 pExtractedExtCapIEBuf[DOT11F_IE_EXTCAP_MAX_LEN + 2];
180 tSirRetStatus nSirStatus;
181
182 vos_mem_set(( tANI_U8* )&pExtractedExtCapIEBuf[0],
183 DOT11F_IE_EXTCAP_MAX_LEN + 2, 0);
184 nSirStatus = limStripOffExtCapIE(pMac, addIE, addnIELen,
185 pExtractedExtCapIEBuf);
186 if ( eSIR_SUCCESS != nSirStatus )
187 {
188 limLog( pMac, LOG1, FL("Failed to strip off in"
189 "limStripOffExtCapIE status = (%d)."),
190 nSirStatus );
191 return nSirStatus;
192 }
193 /* update the extracted ExtCap to struct*/
194 limUpdateExtCapIEtoStruct(pMac, pExtractedExtCapIEBuf, pDst);
195 return nSirStatus;
196}
197
198void limMergeExtCapIEStruct(tDot11fIEExtCap *pDst,
199 tDot11fIEExtCap *pSrc)
200{
201 tANI_U8 *tempDst = (tANI_U8 *)pDst;
202 tANI_U8 *tempSrc = (tANI_U8 *)pSrc;
203 tANI_U8 structlen = sizeof(tDot11fIEExtCap);
204
205 while(tempDst && tempSrc && structlen--)
206 {
207 *tempDst |= *tempSrc;
208 tempDst++;
209 tempSrc++;
210 }
211}
Jeff Johnson295189b2012-06-20 16:38:30 -0700212
213/**
214 *
215 * \brief This function is called by various LIM modules to prepare the
216 * 802.11 frame MAC header
217 *
218 *
219 * \param pMac Pointer to Global MAC structure
220 *
221 * \param pBD Pointer to the frame buffer that needs to be populate
222 *
223 * \param type Type of the frame
224 *
225 * \param subType Subtype of the frame
226 *
227 * \return eHalStatus
228 *
229 *
230 * The pFrameBuf argument points to the beginning of the frame buffer to
231 * which - a) The 802.11 MAC header is set b) Following this MAC header
232 * will be the MGMT frame payload The payload itself is populated by the
233 * caller API
234 *
235 *
236 */
237
238tSirRetStatus limPopulateMacHeader( tpAniSirGlobal pMac,
239 tANI_U8* pBD,
240 tANI_U8 type,
241 tANI_U8 subType,
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530242 tSirMacAddr peerAddr, tSirMacAddr selfMacAddr)
Jeff Johnson295189b2012-06-20 16:38:30 -0700243{
244 tSirRetStatus statusCode = eSIR_SUCCESS;
245 tpSirMacMgmtHdr pMacHdr;
246
247 /// Prepare MAC management header
248 pMacHdr = (tpSirMacMgmtHdr) (pBD);
249
250 // Prepare FC
251 pMacHdr->fc.protVer = SIR_MAC_PROTOCOL_VERSION;
252 pMacHdr->fc.type = type;
253 pMacHdr->fc.subType = subType;
254
255 // Prepare Address 1
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530256 vos_mem_copy( (tANI_U8 *) pMacHdr->da,
Jeff Johnson295189b2012-06-20 16:38:30 -0700257 (tANI_U8 *) peerAddr,
258 sizeof( tSirMacAddr ));
259
260 // Prepare Address 2
Jeff Johnson295189b2012-06-20 16:38:30 -0700261 sirCopyMacAddr(pMacHdr->sa,selfMacAddr);
262
263 // Prepare Address 3
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530264 vos_mem_copy( (tANI_U8 *) pMacHdr->bssId,
Jeff Johnson295189b2012-06-20 16:38:30 -0700265 (tANI_U8 *) peerAddr,
266 sizeof( tSirMacAddr ));
267 return statusCode;
268} /*** end limPopulateMacHeader() ***/
269
270/**
271 * \brief limSendProbeReqMgmtFrame
272 *
273 *
274 * \param pMac Pointer to Global MAC structure
275 *
276 * \param pSsid SSID to be sent in Probe Request frame
277 *
278 * \param bssid BSSID to be sent in Probe Request frame
279 *
280 * \param nProbeDelay probe delay to be used before sending Probe Request
281 * frame
282 *
283 * \param nChannelNum Channel # on which the Probe Request is going out
284 *
285 * \param nAdditionalIELen if non-zero, include pAdditionalIE in the Probe Request frame
286 *
287 * \param pAdditionalIE if nAdditionalIELen is non zero, include this field in the Probe Request frame
288 *
289 * This function is called by various LIM modules to send Probe Request frame
290 * during active scan/learn phase.
291 * Probe request is sent out in the following scenarios:
292 * --heartbeat failure: session needed
293 * --join req: session needed
294 * --foreground scan: no session
295 * --background scan: no session
296 * --schBeaconProcessing: to get EDCA parameters: session needed
297 *
298 *
299 */
300tSirRetStatus
301limSendProbeReqMgmtFrame(tpAniSirGlobal pMac,
302 tSirMacSSid *pSsid,
303 tSirMacAddr bssid,
304 tANI_U8 nChannelNum,
305 tSirMacAddr SelfMacAddr,
306 tANI_U32 dot11mode,
307 tANI_U32 nAdditionalIELen,
308 tANI_U8 *pAdditionalIE)
309{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +0530310 tDot11fProbeRequest pr;
311 tANI_U32 nStatus, nBytes, nPayload;
312 tSirRetStatus nSirStatus;
313 tANI_U8 *pFrame;
314 void *pPacket;
315 eHalStatus halstatus;
316 tpPESession psessionEntry;
317 tANI_U8 sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -0700318 tANI_U8 *p2pIe = NULL;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +0530319 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700320
321#ifndef GEN4_SCAN
322 return eSIR_FAILURE;
323#endif
324
325#if defined ( ANI_DVT_DEBUG )
326 return eSIR_FAILURE;
327#endif
328
Abhishek Singh4beed422014-02-03 16:47:17 +0530329 /* The probe req should not send 11ac capabilieties if band is 2.4GHz,
330 * unless enableVhtFor24GHz is enabled in INI. So if enableVhtFor24GHz
331 * is false and dot11mode is 11ac set it to 11n.
332 */
333 if ( nChannelNum <= SIR_11B_CHANNEL_END &&
334 ( FALSE == pMac->roam.configParam.enableVhtFor24GHz ) &&
335 ( WNI_CFG_DOT11_MODE_11AC == dot11mode ||
336 WNI_CFG_DOT11_MODE_11AC_ONLY == dot11mode ) )
337 dot11mode = WNI_CFG_DOT11_MODE_11N;
Jeff Johnson295189b2012-06-20 16:38:30 -0700338 /*
339 * session context may or may not be present, when probe request needs to be sent out.
340 * following cases exist:
341 * --heartbeat failure: session needed
342 * --join req: session needed
343 * --foreground scan: no session
344 * --background scan: no session
345 * --schBeaconProcessing: to get EDCA parameters: session needed
346 * If session context does not exist, some IEs will be populated from CFGs,
347 * e.g. Supported and Extended rate set IEs
348 */
349 psessionEntry = peFindSessionByBssid(pMac,bssid,&sessionId);
350
351 // The scheme here is to fill out a 'tDot11fProbeRequest' structure
352 // and then hand it off to 'dot11fPackProbeRequest' (for
353 // serialization). We start by zero-initializing the structure:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530354 vos_mem_set(( tANI_U8* )&pr, sizeof( pr ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700355
356 // & delegating to assorted helpers:
357 PopulateDot11fSSID( pMac, pSsid, &pr.SSID );
358
Jeff Johnson295189b2012-06-20 16:38:30 -0700359 if( nAdditionalIELen && pAdditionalIE )
360 {
361 p2pIe = limGetP2pIEPtr(pMac, pAdditionalIE, nAdditionalIELen);
362 }
Jeff Johnsone7245742012-09-05 17:12:55 -0700363 /* Don't include 11b rate only when device is doing P2P Search */
364 if( ( WNI_CFG_DOT11_MODE_11B != dot11mode ) &&
365 ( p2pIe != NULL ) &&
366 /* Don't include 11b rate if it is a P2P serach or probe request is sent by P2P Client */
367 ( ( ( pMac->lim.gpLimMlmScanReq != NULL ) &&
368 pMac->lim.gpLimMlmScanReq->p2pSearch ) ||
369 ( ( psessionEntry != NULL ) &&
370 ( VOS_P2P_CLIENT_MODE == psessionEntry->pePersona ) )
371 )
372 )
Jeff Johnson295189b2012-06-20 16:38:30 -0700373 {
374 /* In the below API pass channel number > 14, do that it fills only
375 * 11a rates in supported rates */
376 PopulateDot11fSuppRates( pMac, 15, &pr.SuppRates,psessionEntry);
377 }
378 else
379 {
Jeff Johnson295189b2012-06-20 16:38:30 -0700380 PopulateDot11fSuppRates( pMac, nChannelNum,
381 &pr.SuppRates,psessionEntry);
382
383 if ( WNI_CFG_DOT11_MODE_11B != dot11mode )
384 {
385 PopulateDot11fExtSuppRates1( pMac, nChannelNum, &pr.ExtSuppRates );
386 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700387 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700388
389#if defined WLAN_FEATURE_VOWIFI
390 //Table 7-14 in IEEE Std. 802.11k-2008 says
391 //DS params "can" be present in RRM is disabled and "is" present if
392 //RRM is enabled. It should be ok even if we add it into probe req when
393 //RRM is not enabled.
394 PopulateDot11fDSParams( pMac, &pr.DSParams, nChannelNum, psessionEntry );
395 //Call RRM module to get the tx power for management used.
396 {
397 tANI_U8 txPower = (tANI_U8) rrmGetMgmtTxPower( pMac, psessionEntry );
398 PopulateDot11fWFATPC( pMac, &pr.WFATPC, txPower, 0 );
399 }
400#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700401
402 if (psessionEntry != NULL ) {
Jeff Johnsone7245742012-09-05 17:12:55 -0700403 psessionEntry->htCapability = IS_DOT11_MODE_HT(dot11mode);
Jeff Johnson295189b2012-06-20 16:38:30 -0700404 //Include HT Capability IE
Jeff Johnsone7245742012-09-05 17:12:55 -0700405 if (psessionEntry->htCapability)
Jeff Johnson295189b2012-06-20 16:38:30 -0700406 {
Jeff Johnsone7245742012-09-05 17:12:55 -0700407 PopulateDot11fHTCaps( pMac, psessionEntry, &pr.HTCaps );
Jeff Johnson295189b2012-06-20 16:38:30 -0700408 }
Jeff Johnsone7245742012-09-05 17:12:55 -0700409 } else { //psessionEntry == NULL
410 if (IS_DOT11_MODE_HT(dot11mode))
Jeff Johnson295189b2012-06-20 16:38:30 -0700411 {
Jeff Johnsone7245742012-09-05 17:12:55 -0700412 PopulateDot11fHTCaps( pMac, psessionEntry, &pr.HTCaps );
Jeff Johnson295189b2012-06-20 16:38:30 -0700413 }
414 }
Gopichand Nakkala40bc6502012-12-20 16:55:36 -0800415
Hardik Kantilal Patelbca5b002015-01-19 15:30:18 +0530416 if((nChannelNum <= SIR_11B_CHANNEL_END)
417 && (!IS_HT40_OBSS_SCAN_FEATURE_ENABLE)
418 && (!pMac->roam.configParam.channelBondingMode24GHz))
Gopichand Nakkala40bc6502012-12-20 16:55:36 -0800419 {
420 pr.HTCaps.supportedChannelWidthSet = eHT_CHANNEL_WIDTH_20MHZ;
421 pr.HTCaps.shortGI40MHz = 0;
422 }
Jeff Johnsone7245742012-09-05 17:12:55 -0700423#ifdef WLAN_FEATURE_11AC
424 if (psessionEntry != NULL ) {
425 psessionEntry->vhtCapability = IS_DOT11_MODE_VHT(dot11mode);
426 //Include HT Capability IE
427 if (psessionEntry->vhtCapability)
428 {
Abhishek Singh6d5d29c2014-07-03 14:25:22 +0530429 PopulateDot11fVHTCaps( pMac, &pr.VHTCaps, eSIR_FALSE );
Jeff Johnsone7245742012-09-05 17:12:55 -0700430 }
431 } else {
432 if (IS_DOT11_MODE_VHT(dot11mode))
433 {
Abhishek Singh6d5d29c2014-07-03 14:25:22 +0530434 PopulateDot11fVHTCaps( pMac, &pr.VHTCaps, eSIR_FALSE );
Jeff Johnsone7245742012-09-05 17:12:55 -0700435 }
436 }
437#endif
438
Jeff Johnson295189b2012-06-20 16:38:30 -0700439
440 // That's it-- now we pack it. First, how much space are we going to
441 // need?
442 nStatus = dot11fGetPackedProbeRequestSize( pMac, &pr, &nPayload );
443 if ( DOT11F_FAILED( nStatus ) )
444 {
445 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700446 "or a Probe Request (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -0700447 // We'll fall back on the worst case scenario:
448 nPayload = sizeof( tDot11fProbeRequest );
449 }
450 else if ( DOT11F_WARNED( nStatus ) )
451 {
452 limLog( pMac, LOGW, FL("There were warnings while calculating"
453 "the packed size for a Probe Request ("
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700454 "0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -0700455 }
456
457 nBytes = nPayload + sizeof( tSirMacMgmtHdr ) + nAdditionalIELen;
458
459 // Ok-- try to allocate some memory:
460 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
461 ( tANI_U16 )nBytes, ( void** ) &pFrame,
462 ( void** ) &pPacket );
463 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
464 {
465 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Pro"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700466 "be Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -0700467 return eSIR_MEM_ALLOC_FAILED;
468 }
469
470 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530471 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -0700472
473 // Next, we fill out the buffer descriptor:
474 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530475 SIR_MAC_MGMT_PROBE_REQ, bssid, SelfMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -0700476 if ( eSIR_SUCCESS != nSirStatus )
477 {
478 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700479 "tor for a Probe Request (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -0700480 nSirStatus );
481 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
482 ( void* ) pFrame, ( void* ) pPacket );
483 return nSirStatus; // allocated!
484 }
485
486 // That done, pack the Probe Request:
487 nStatus = dot11fPackProbeRequest( pMac, &pr, pFrame +
488 sizeof( tSirMacMgmtHdr ),
489 nPayload, &nPayload );
490 if ( DOT11F_FAILED( nStatus ) )
491 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700492 limLog( pMac, LOGE, FL("Failed to pack a Probe Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -0700493 nStatus );
494 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
495 return eSIR_FAILURE; // allocated!
496 }
497 else if ( DOT11F_WARNED( nStatus ) )
498 {
499 limLog( pMac, LOGW, FL("There were warnings while packing a P"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -0800500 "robe Request (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -0700501 }
502
503 // Append any AddIE if present.
504 if( nAdditionalIELen )
505 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530506 vos_mem_copy( pFrame+sizeof(tSirMacMgmtHdr)+nPayload,
Jeff Johnson295189b2012-06-20 16:38:30 -0700507 pAdditionalIE, nAdditionalIELen );
508 nPayload += nAdditionalIELen;
509 }
510
511 /* If this probe request is sent during P2P Search State, then we need
512 * to send it at OFDM rate.
513 */
514 if( ( SIR_BAND_5_GHZ == limGetRFBand(nChannelNum))
Jeff Johnson295189b2012-06-20 16:38:30 -0700515 || (( pMac->lim.gpLimMlmScanReq != NULL) &&
516 pMac->lim.gpLimMlmScanReq->p2pSearch )
Gopichand Nakkala67967212013-02-15 17:31:15 +0530517 /* For unicast probe req mgmt from Join function
518 we don't set above variables. So we need to add
519 one more check whether it is pePersona is P2P_CLIENT or not */
520 || ( ( psessionEntry != NULL ) &&
521 ( VOS_P2P_CLIENT_MODE == psessionEntry->pePersona ) )
Jeff Johnson295189b2012-06-20 16:38:30 -0700522 )
523 {
524 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
525 }
526
Masti, Narayanraddi67ea5912015-01-08 12:34:05 +0530527 if( ( psessionEntry != NULL ) && ( psessionEntry->is11Gonly == true ) &&
528 ( !IS_BROADCAST_MAC(bssid) ) ){
529 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
530 }
531
Jeff Johnson295189b2012-06-20 16:38:30 -0700532 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) sizeof(tSirMacMgmtHdr) + nPayload,
533 HAL_TXRX_FRM_802_11_MGMT,
534 ANI_TXDIR_TODS,
535 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
536 limTxComplete, pFrame, txFlag );
537 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
538 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700539 limLog( pMac, LOGE, FL("could not send Probe Request frame!" ));
Jeff Johnson295189b2012-06-20 16:38:30 -0700540 //Pkt will be freed up by the callback
541 return eSIR_FAILURE;
542 }
543
544 return eSIR_SUCCESS;
545} // End limSendProbeReqMgmtFrame.
546
Jeff Johnson295189b2012-06-20 16:38:30 -0700547tSirRetStatus limGetAddnIeForProbeResp(tpAniSirGlobal pMac,
548 tANI_U8* addIE, tANI_U16 *addnIELen,
549 tANI_U8 probeReqP2pIe)
550{
551 /* If Probe request doesn't have P2P IE, then take out P2P IE
552 from additional IE */
553 if(!probeReqP2pIe)
554 {
555 tANI_U8* tempbuf = NULL;
556 tANI_U16 tempLen = 0;
557 int left = *addnIELen;
558 v_U8_t *ptr = addIE;
559 v_U8_t elem_id, elem_len;
560
561 if(NULL == addIE)
562 {
563 PELOGE(limLog(pMac, LOGE,
564 FL(" NULL addIE pointer"));)
565 return eSIR_FAILURE;
566 }
567
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530568 tempbuf = vos_mem_malloc(left);
569 if ( NULL == tempbuf )
Jeff Johnson295189b2012-06-20 16:38:30 -0700570 {
571 PELOGE(limLog(pMac, LOGE,
572 FL("Unable to allocate memory to store addn IE"));)
573 return eSIR_MEM_ALLOC_FAILED;
574 }
575
576 while(left >= 2)
577 {
578 elem_id = ptr[0];
579 elem_len = ptr[1];
580 left -= 2;
581 if(elem_len > left)
582 {
583 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700584 FL("****Invalid IEs eid = %d elem_len=%d left=%d*****"),
Jeff Johnson295189b2012-06-20 16:38:30 -0700585 elem_id,elem_len,left);
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530586 vos_mem_free(tempbuf);
Jeff Johnson295189b2012-06-20 16:38:30 -0700587 return eSIR_FAILURE;
588 }
589 if ( !( (SIR_MAC_EID_VENDOR == elem_id) &&
590 (memcmp(&ptr[2], SIR_MAC_P2P_OUI, SIR_MAC_P2P_OUI_SIZE)==0) ) )
591 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530592 vos_mem_copy (tempbuf + tempLen, &ptr[0], elem_len + 2);
Jeff Johnson295189b2012-06-20 16:38:30 -0700593 tempLen += (elem_len + 2);
594 }
595 left -= elem_len;
596 ptr += (elem_len + 2);
597 }
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530598 vos_mem_copy (addIE, tempbuf, tempLen);
Jeff Johnson295189b2012-06-20 16:38:30 -0700599 *addnIELen = tempLen;
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530600 vos_mem_free(tempbuf);
Jeff Johnson295189b2012-06-20 16:38:30 -0700601 }
602 return eSIR_SUCCESS;
603}
Jeff Johnson295189b2012-06-20 16:38:30 -0700604
605void
606limSendProbeRspMgmtFrame(tpAniSirGlobal pMac,
607 tSirMacAddr peerMacAddr,
608 tpAniSSID pSsid,
609 short nStaId,
610 tANI_U8 nKeepAlive,
611 tpPESession psessionEntry,
612 tANI_U8 probeReqP2pIe)
613{
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700614 tDot11fProbeResponse *pFrm;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +0530615 tSirRetStatus nSirStatus;
c_hpothubcd78652014-04-28 22:31:08 +0530616 tANI_U32 cfg, nPayload, nStatus;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +0530617 tpSirMacMgmtHdr pMacHdr;
618 tANI_U8 *pFrame;
619 void *pPacket;
620 eHalStatus halstatus;
621 tANI_U32 addnIEPresent;
622 tANI_U32 addnIE1Len=0;
623 tANI_U32 addnIE2Len=0;
624 tANI_U32 addnIE3Len=0;
625 tANI_U16 totalAddnIeLen = 0;
626 tANI_U32 wpsApEnable=0, tmp;
627 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700628 tANI_U8 *addIE = NULL;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +0530629 tANI_U8 *pP2pIe = NULL;
630 tANI_U8 noaLen = 0;
631 tANI_U8 total_noaLen = 0;
632 tANI_U8 noaStream[SIR_MAX_NOA_ATTR_LEN
Jeff Johnson295189b2012-06-20 16:38:30 -0700633 + SIR_P2P_IE_HEADER_LEN];
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +0530634 tANI_U8 noaIe[SIR_MAX_NOA_ATTR_LEN + SIR_P2P_IE_HEADER_LEN];
Kalikinkar dhara205da782014-03-21 15:49:32 -0700635 tDot11fIEExtCap extractedExtCap;
636 tANI_BOOLEAN extractedExtCapFlag = eANI_BOOLEAN_TRUE;
c_hpothubcd78652014-04-28 22:31:08 +0530637 tANI_U32 nBytes = 0;
638
Jeff Johnson295189b2012-06-20 16:38:30 -0700639 if(pMac->gDriverType == eDRIVER_TYPE_MFG) // We don't answer requests
640 {
641 return; // in this case.
642 }
643
644 if(NULL == psessionEntry)
645 {
646 return;
647 }
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530648
649 pFrm = vos_mem_malloc(sizeof(tDot11fProbeResponse));
650 if ( NULL == pFrm )
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700651 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530652 limLog(pMac, LOGE, FL("Unable to allocate memory in limSendProbeRspMgmtFrame") );
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700653 return;
654 }
655
Girish Gowli0e826792014-05-17 17:56:44 +0530656 vos_mem_set(( tANI_U8* )&extractedExtCap, sizeof( tDot11fIEExtCap ), 0);
657
Jeff Johnson295189b2012-06-20 16:38:30 -0700658 // Fill out 'frm', after which we'll just hand the struct off to
659 // 'dot11fPackProbeResponse'.
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530660 vos_mem_set(( tANI_U8* )pFrm, sizeof( tDot11fProbeResponse ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700661
662 // Timestamp to be updated by TFP, below.
663
664 // Beacon Interval:
Jeff Johnson295189b2012-06-20 16:38:30 -0700665 if(psessionEntry->limSystemRole == eLIM_AP_ROLE)
666 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700667 pFrm->BeaconInterval.interval = pMac->sch.schObject.gSchBeaconInterval;
Jeff Johnson295189b2012-06-20 16:38:30 -0700668 }
669 else
670 {
Jeff Johnson3c3e1782013-02-27 10:48:42 -0800671 nSirStatus = wlan_cfgGetInt( pMac, WNI_CFG_BEACON_INTERVAL, &cfg);
672 if (eSIR_SUCCESS != nSirStatus)
673 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700674 limLog( pMac, LOGP, FL("Failed to retrieve WNI_CFG_BEACON_INTERVAL from CFG (%d)."),
Jeff Johnson3c3e1782013-02-27 10:48:42 -0800675 nSirStatus );
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530676 vos_mem_free(pFrm);
Jeff Johnson3c3e1782013-02-27 10:48:42 -0800677 return;
678 }
679 pFrm->BeaconInterval.interval = ( tANI_U16 ) cfg;
Madan Mohan Koyyalamudic0d1b3f2012-11-13 10:41:07 -0800680 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700681
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700682 PopulateDot11fCapabilities( pMac, &pFrm->Capabilities, psessionEntry );
683 PopulateDot11fSSID( pMac, ( tSirMacSSid* )pSsid, &pFrm->SSID );
Jeff Johnson295189b2012-06-20 16:38:30 -0700684 PopulateDot11fSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700685 &pFrm->SuppRates,psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -0700686
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700687 PopulateDot11fDSParams( pMac, &pFrm->DSParams, psessionEntry->currentOperChannel,psessionEntry);
688 PopulateDot11fIBSSParams( pMac, &pFrm->IBSSParams, psessionEntry );
Jeff Johnson295189b2012-06-20 16:38:30 -0700689
Jeff Johnson295189b2012-06-20 16:38:30 -0700690
Jeff Johnson295189b2012-06-20 16:38:30 -0700691 if(psessionEntry->limSystemRole == eLIM_AP_ROLE)
692 {
693 if(psessionEntry->wps_state != SAP_WPS_DISABLED)
694 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700695 PopulateDot11fProbeResWPSIEs(pMac, &pFrm->WscProbeRes, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -0700696 }
697 }
698 else
699 {
Jeff Johnson3c3e1782013-02-27 10:48:42 -0800700 if (wlan_cfgGetInt(pMac, (tANI_U16) WNI_CFG_WPS_ENABLE, &tmp) != eSIR_SUCCESS)
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700701 limLog(pMac, LOGP,"Failed to cfg get id %d", WNI_CFG_WPS_ENABLE );
Jeff Johnson295189b2012-06-20 16:38:30 -0700702
Jeff Johnson3c3e1782013-02-27 10:48:42 -0800703 wpsApEnable = tmp & WNI_CFG_WPS_ENABLE_AP;
Jeff Johnson295189b2012-06-20 16:38:30 -0700704
Jeff Johnson3c3e1782013-02-27 10:48:42 -0800705 if (wpsApEnable)
706 {
707 PopulateDot11fWscInProbeRes(pMac, &pFrm->WscProbeRes);
708 }
709
710 if (pMac->lim.wscIeInfo.probeRespWscEnrollmentState == eLIM_WSC_ENROLL_BEGIN)
711 {
712 PopulateDot11fWscRegistrarInfoInProbeRes(pMac, &pFrm->WscProbeRes);
713 pMac->lim.wscIeInfo.probeRespWscEnrollmentState = eLIM_WSC_ENROLL_IN_PROGRESS;
714 }
715
716 if (pMac->lim.wscIeInfo.wscEnrollmentState == eLIM_WSC_ENROLL_END)
717 {
718 DePopulateDot11fWscRegistrarInfoInProbeRes(pMac, &pFrm->WscProbeRes);
719 pMac->lim.wscIeInfo.probeRespWscEnrollmentState = eLIM_WSC_ENROLL_NOOP;
720 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700721 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700722
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700723 PopulateDot11fCountry( pMac, &pFrm->Country, psessionEntry);
724 PopulateDot11fEDCAParamSet( pMac, &pFrm->EDCAParamSet, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -0700725
Jeff Johnson295189b2012-06-20 16:38:30 -0700726
727 if (psessionEntry->dot11mode != WNI_CFG_DOT11_MODE_11B)
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700728 PopulateDot11fERPInfo( pMac, &pFrm->ERPInfo, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -0700729
730
731 // N.B. In earlier implementations, the RSN IE would be placed in
732 // the frame here, before the WPA IE, if 'RSN_BEFORE_WPA' was defined.
733 PopulateDot11fExtSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700734 &pFrm->ExtSuppRates, psessionEntry );
Jeff Johnson295189b2012-06-20 16:38:30 -0700735
736 //Populate HT IEs, when operating in 11n or Taurus modes.
Jeff Johnsone7245742012-09-05 17:12:55 -0700737 if ( psessionEntry->htCapability )
Jeff Johnson295189b2012-06-20 16:38:30 -0700738 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700739 PopulateDot11fHTCaps( pMac, psessionEntry, &pFrm->HTCaps );
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700740 PopulateDot11fHTInfo( pMac, &pFrm->HTInfo, psessionEntry );
Jeff Johnson295189b2012-06-20 16:38:30 -0700741 }
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +0530742
743#ifdef WLAN_FEATURE_AP_HT40_24G
744 /* Populate Overlapping BSS Scan Parameters IEs,
745 * when operating in HT40 in 2.4GHz.
746 */
Hardik Kantilal Patel3c235242015-01-02 17:56:18 +0530747 if ((pMac->roam.configParam.apHT40_24GEnabled)
748 && (IS_DOT11_MODE_HT(psessionEntry->dot11mode)))
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +0530749 {
750 PopulateDot11fOBSSScanParameters( pMac, &pFrm->OBSSScanParameters,
751 psessionEntry);
Hardik Kantilal Patelee5874c2015-01-14 15:23:28 +0530752 /* 10.15.8 Support of DSSS/CCK in 40 MHz, An associated HT STA in
753 * a 20/40 MHz BSS may generate DSSS/CCK transmissions.Set DSSS/CCK
754 * Mode in 40 MHz bit in HT capablity.
755 */
756 pFrm->HTCaps.dsssCckMode40MHz = 1;
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +0530757 }
758#endif
759
760 PopulateDot11fExtCap( pMac, &pFrm->ExtCap, psessionEntry);
761
Jeff Johnsone7245742012-09-05 17:12:55 -0700762#ifdef WLAN_FEATURE_11AC
763 if(psessionEntry->vhtCapability)
764 {
Chet Lanctotf19c1f62013-12-13 13:56:21 -0800765 limLog( pMac, LOG1, FL("Populate VHT IE in Probe Response"));
Abhishek Singh6d5d29c2014-07-03 14:25:22 +0530766 PopulateDot11fVHTCaps( pMac, &pFrm->VHTCaps, eSIR_TRUE );
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700767 PopulateDot11fVHTOperation( pMac, &pFrm->VHTOperation );
Jeff Johnsone7245742012-09-05 17:12:55 -0700768 // we do not support multi users yet
769 //PopulateDot11fVHTExtBssLoad( pMac, &frm.VHTExtBssLoad );
770 }
771#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700772
Sandeep Puligilla60342762014-01-30 21:05:37 +0530773
Hardik Kantilal Patelee5874c2015-01-14 15:23:28 +0530774 if ( psessionEntry->pLimStartBssReq )
Jeff Johnson295189b2012-06-20 16:38:30 -0700775 {
776 PopulateDot11fWPA( pMac, &( psessionEntry->pLimStartBssReq->rsnIE ),
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700777 &pFrm->WPA );
Chet Lanctot4b9abd72013-06-27 11:14:56 -0700778 PopulateDot11fRSNOpaque( pMac, &( psessionEntry->pLimStartBssReq->rsnIE ),
779 &pFrm->RSNOpaque );
Jeff Johnson295189b2012-06-20 16:38:30 -0700780 }
781
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700782 PopulateDot11fWMM( pMac, &pFrm->WMMInfoAp, &pFrm->WMMParams, &pFrm->WMMCaps, psessionEntry );
Jeff Johnson295189b2012-06-20 16:38:30 -0700783
784#if defined(FEATURE_WLAN_WAPI)
785 if( psessionEntry->pLimStartBssReq )
786 {
787 PopulateDot11fWAPI( pMac, &( psessionEntry->pLimStartBssReq->rsnIE ),
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700788 &pFrm->WAPI );
Jeff Johnson295189b2012-06-20 16:38:30 -0700789 }
790
791#endif // defined(FEATURE_WLAN_WAPI)
792
Jeff Johnson295189b2012-06-20 16:38:30 -0700793 addnIEPresent = false;
Jeff Johnson295189b2012-06-20 16:38:30 -0700794 if( pMac->lim.gpLimRemainOnChanReq )
795 {
796 nBytes += (pMac->lim.gpLimRemainOnChanReq->length - sizeof( tSirRemainOnChnReq ) );
797 }
798 //Only use CFG for non-listen mode. This CFG is not working for concurrency
799 //In listening mode, probe rsp IEs is passed in the message from SME to PE
800 else
Jeff Johnson295189b2012-06-20 16:38:30 -0700801 {
802
803 if (wlan_cfgGetInt(pMac, WNI_CFG_PROBE_RSP_ADDNIE_FLAG,
804 &addnIEPresent) != eSIR_SUCCESS)
805 {
806 limLog(pMac, LOGP, FL("Unable to get WNI_CFG_PROBE_RSP_ADDNIE_FLAG"));
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530807 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700808 return;
809 }
810 }
811
812 if (addnIEPresent)
813 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530814
815 addIE = vos_mem_malloc(WNI_CFG_PROBE_RSP_ADDNIE_DATA1_LEN*3);
816 if ( NULL == addIE )
Jeff Johnson295189b2012-06-20 16:38:30 -0700817 {
818 PELOGE(limLog(pMac, LOGE,
819 FL("Unable to allocate memory to store addn IE"));)
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530820 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700821 return;
822 }
823
824 //Probe rsp IE available
825 if ( eSIR_SUCCESS != wlan_cfgGetStrLen(pMac,
826 WNI_CFG_PROBE_RSP_ADDNIE_DATA1, &addnIE1Len) )
827 {
828 limLog(pMac, LOGP, FL("Unable to get WNI_CFG_PROBE_RSP_ADDNIE_DATA1 length"));
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530829 vos_mem_free(addIE);
830 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700831 return;
832 }
833 if (addnIE1Len <= WNI_CFG_PROBE_RSP_ADDNIE_DATA1_LEN && addnIE1Len &&
834 (nBytes + addnIE1Len) <= SIR_MAX_PACKET_SIZE)
835 {
836 if ( eSIR_SUCCESS != wlan_cfgGetStr(pMac,
837 WNI_CFG_PROBE_RSP_ADDNIE_DATA1, &addIE[0],
838 &addnIE1Len) )
839 {
840 limLog(pMac, LOGP,
841 FL("Unable to get WNI_CFG_PROBE_RSP_ADDNIE_DATA1 String"));
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530842 vos_mem_free(addIE);
843 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700844 return;
845 }
846 }
847
848 //Probe rsp IE available
849 if ( eSIR_SUCCESS != wlan_cfgGetStrLen(pMac,
850 WNI_CFG_PROBE_RSP_ADDNIE_DATA2, &addnIE2Len) )
851 {
852 limLog(pMac, LOGP, FL("Unable to get WNI_CFG_PROBE_RSP_ADDNIE_DATA2 length"));
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530853 vos_mem_free(addIE);
854 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700855 return;
856 }
857 if (addnIE2Len <= WNI_CFG_PROBE_RSP_ADDNIE_DATA2_LEN && addnIE2Len &&
858 (nBytes + addnIE2Len) <= SIR_MAX_PACKET_SIZE)
859 {
860 if ( eSIR_SUCCESS != wlan_cfgGetStr(pMac,
861 WNI_CFG_PROBE_RSP_ADDNIE_DATA2, &addIE[addnIE1Len],
862 &addnIE2Len) )
863 {
864 limLog(pMac, LOGP,
865 FL("Unable to get WNI_CFG_PROBE_RSP_ADDNIE_DATA2 String"));
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530866 vos_mem_free(addIE);
867 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700868 return;
869 }
870 }
871
872 //Probe rsp IE available
873 if ( eSIR_SUCCESS != wlan_cfgGetStrLen(pMac,
874 WNI_CFG_PROBE_RSP_ADDNIE_DATA3, &addnIE3Len) )
875 {
876 limLog(pMac, LOGP, FL("Unable to get WNI_CFG_PROBE_RSP_ADDNIE_DATA3 length"));
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530877 vos_mem_free(addIE);
878 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700879 return;
880 }
881 if (addnIE3Len <= WNI_CFG_PROBE_RSP_ADDNIE_DATA3_LEN && addnIE3Len &&
882 (nBytes + addnIE3Len) <= SIR_MAX_PACKET_SIZE)
883 {
884 if ( eSIR_SUCCESS != wlan_cfgGetStr(pMac,
885 WNI_CFG_PROBE_RSP_ADDNIE_DATA3,
886 &addIE[addnIE1Len + addnIE2Len],
887 &addnIE3Len) )
888 {
889 limLog(pMac, LOGP,
890 FL("Unable to get WNI_CFG_PROBE_RSP_ADDNIE_DATA3 String"));
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530891 vos_mem_free(addIE);
892 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700893 return;
894 }
895 }
896 totalAddnIeLen = addnIE1Len + addnIE2Len + addnIE3Len;
897
Jeff Johnson295189b2012-06-20 16:38:30 -0700898 if(eSIR_SUCCESS != limGetAddnIeForProbeResp(pMac, addIE, &totalAddnIeLen, probeReqP2pIe))
899 {
900 limLog(pMac, LOGP,
901 FL("Unable to get final Additional IE for Probe Req"));
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530902 vos_mem_free(addIE);
903 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700904 return;
905 }
Kalikinkar dhara205da782014-03-21 15:49:32 -0700906
Kalikinkar dhara205da782014-03-21 15:49:32 -0700907 nSirStatus = limStripOffExtCapIEAndUpdateStruct(pMac,
908 addIE,
909 &totalAddnIeLen,
910 &extractedExtCap );
911 if(eSIR_SUCCESS != nSirStatus )
912 {
913 extractedExtCapFlag = eANI_BOOLEAN_FALSE;
914 limLog(pMac, LOG1,
915 FL("Unable to Stripoff ExtCap IE from Probe Rsp"));
916 }
917
Jeff Johnson295189b2012-06-20 16:38:30 -0700918 nBytes = nBytes + totalAddnIeLen;
Kaushik, Sushanta5ee77a2014-07-30 19:35:25 +0530919 limLog(pMac, LOG1,
920 FL("probe rsp packet size is %d "), nBytes);
Jeff Johnson295189b2012-06-20 16:38:30 -0700921 if (probeReqP2pIe)
922 {
923 pP2pIe = limGetP2pIEPtr(pMac, &addIE[0], totalAddnIeLen);
924 if (pP2pIe != NULL)
925 {
926 //get NoA attribute stream P2P IE
927 noaLen = limGetNoaAttrStream(pMac, noaStream, psessionEntry);
928 if (noaLen != 0)
929 {
930 total_noaLen = limBuildP2pIe(pMac, &noaIe[0],
931 &noaStream[0], noaLen);
932 nBytes = nBytes + total_noaLen;
Kaushik, Sushanta5ee77a2014-07-30 19:35:25 +0530933 limLog(pMac, LOG1,
934 FL("p2p probe rsp packet size is %d, noalength is %d"),
935 nBytes, total_noaLen);
Jeff Johnson295189b2012-06-20 16:38:30 -0700936 }
937 }
938 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700939 }
940
c_hpothubcd78652014-04-28 22:31:08 +0530941 /*merge ExtCap IE*/
942 if (extractedExtCapFlag && extractedExtCap.present)
943 {
944 limMergeExtCapIEStruct(&pFrm->ExtCap, &extractedExtCap);
945 }
946
947 nStatus = dot11fGetPackedProbeResponseSize( pMac, pFrm, &nPayload );
948 if ( DOT11F_FAILED( nStatus ) )
949 {
950 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
951 "or a Probe Response (0x%08x)."),
952 nStatus );
953 // We'll fall back on the worst case scenario:
954 nPayload = sizeof( tDot11fProbeResponse );
955 }
956 else if ( DOT11F_WARNED( nStatus ) )
957 {
958 limLog( pMac, LOGW, FL("There were warnings while calculating"
959 "the packed size for a Probe Response "
960 "(0x%08x)."), nStatus );
961 }
962
963 nBytes += nPayload + sizeof( tSirMacMgmtHdr );
964
Jeff Johnson295189b2012-06-20 16:38:30 -0700965 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
966 ( tANI_U16 )nBytes, ( void** ) &pFrame,
967 ( void** ) &pPacket );
968 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
969 {
970 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Pro"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700971 "be Response."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -0700972 if ( addIE != NULL )
973 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530974 vos_mem_free(addIE);
Jeff Johnson295189b2012-06-20 16:38:30 -0700975 }
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530976 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700977 return;
978 }
979
980 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530981 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -0700982
983 // Next, we fill out the buffer descriptor:
984 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
985 SIR_MAC_MGMT_PROBE_RSP, peerMacAddr,psessionEntry->selfMacAddr);
986 if ( eSIR_SUCCESS != nSirStatus )
987 {
988 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700989 "tor for a Probe Response (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -0700990 nSirStatus );
991 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
992 ( void* ) pFrame, ( void* ) pPacket );
993 if ( addIE != NULL )
994 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530995 vos_mem_free(addIE);
Jeff Johnson295189b2012-06-20 16:38:30 -0700996 }
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530997 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700998 return;
999 }
1000
1001 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
1002
1003 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
1004
1005 // That done, pack the Probe Response:
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07001006 nStatus = dot11fPackProbeResponse( pMac, pFrm, pFrame + sizeof(tSirMacMgmtHdr),
Jeff Johnson295189b2012-06-20 16:38:30 -07001007 nPayload, &nPayload );
1008 if ( DOT11F_FAILED( nStatus ) )
1009 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001010 limLog( pMac, LOGE, FL("Failed to pack a Probe Response (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001011 nStatus );
1012 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1013 if ( addIE != NULL )
1014 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301015 vos_mem_free(addIE);
Jeff Johnson295189b2012-06-20 16:38:30 -07001016 }
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301017 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -07001018 return; // allocated!
1019 }
1020 else if ( DOT11F_WARNED( nStatus ) )
1021 {
1022 limLog( pMac, LOGW, FL("There were warnings while packing a P"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001023 "robe Response (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001024 }
1025
1026 PELOG3(limLog( pMac, LOG3, FL("Sending Probe Response frame to ") );
1027 limPrintMacAddr( pMac, peerMacAddr, LOG3 );)
1028
1029 pMac->sys.probeRespond++;
1030
Jeff Johnson295189b2012-06-20 16:38:30 -07001031 if( pMac->lim.gpLimRemainOnChanReq )
1032 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301033 vos_mem_copy ( pFrame+sizeof(tSirMacMgmtHdr)+nPayload,
Jeff Johnson295189b2012-06-20 16:38:30 -07001034 pMac->lim.gpLimRemainOnChanReq->probeRspIe, (pMac->lim.gpLimRemainOnChanReq->length - sizeof( tSirRemainOnChnReq )) );
1035 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001036
1037 if ( addnIEPresent )
1038 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301039 vos_mem_copy(pFrame+sizeof(tSirMacMgmtHdr)+nPayload, &addIE[0], totalAddnIeLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07001040 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001041 if (noaLen != 0)
1042 {
Krunal Soni81b24262013-05-15 17:46:41 -07001043 if (total_noaLen > (SIR_MAX_NOA_ATTR_LEN + SIR_P2P_IE_HEADER_LEN))
Jeff Johnson295189b2012-06-20 16:38:30 -07001044 {
1045 limLog(pMac, LOGE,
Kaushik, Sushant96ac9d72013-12-11 19:28:10 +05301046 FL("Not able to insert NoA because of length constraint."
1047 "Total Length is :%d"),total_noaLen);
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301048 vos_mem_free(addIE);
1049 vos_mem_free(pFrm);
Krunal Soni81b24262013-05-15 17:46:41 -07001050 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1051 ( void* ) pFrame, ( void* ) pPacket );
1052 return;
1053 }
1054 else
1055 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301056 vos_mem_copy( &pFrame[nBytes - (total_noaLen)],
Krunal Soni81b24262013-05-15 17:46:41 -07001057 &noaIe[0], total_noaLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07001058 }
1059 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001060
1061 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07001062 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
1063 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07001064 )
1065 {
1066 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
1067 }
1068
1069 // Queue Probe Response frame in high priority WQ
1070 halstatus = halTxFrame( ( tHalHandle ) pMac, pPacket,
1071 ( tANI_U16 ) nBytes,
1072 HAL_TXRX_FRM_802_11_MGMT,
1073 ANI_TXDIR_TODS,
1074 7,//SMAC_SWBD_TX_TID_MGMT_LOW,
1075 limTxComplete, pFrame, txFlag );
1076 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1077 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001078 limLog( pMac, LOGE, FL("Could not send Probe Response.") );
Jeff Johnson295189b2012-06-20 16:38:30 -07001079 //Pkt will be freed up by the callback
1080 }
1081
1082 if ( addIE != NULL )
1083 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301084 vos_mem_free(addIE);
Jeff Johnson295189b2012-06-20 16:38:30 -07001085 }
1086
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301087 vos_mem_free(pFrm);
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07001088 return;
1089
1090
Jeff Johnson295189b2012-06-20 16:38:30 -07001091} // End limSendProbeRspMgmtFrame.
1092
1093void
1094limSendAddtsReqActionFrame(tpAniSirGlobal pMac,
1095 tSirMacAddr peerMacAddr,
1096 tSirAddtsReqInfo *pAddTS,
1097 tpPESession psessionEntry)
1098{
1099 tANI_U16 i;
1100 tANI_U8 *pFrame;
1101 tSirRetStatus nSirStatus;
1102 tDot11fAddTSRequest AddTSReq;
1103 tDot11fWMMAddTSRequest WMMAddTSReq;
1104 tANI_U32 nPayload, nBytes, nStatus;
1105 tpSirMacMgmtHdr pMacHdr;
1106 void *pPacket;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001107#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07001108 tANI_U32 phyMode;
1109#endif
1110 eHalStatus halstatus;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05301111 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001112
1113 if(NULL == psessionEntry)
1114 {
1115 return;
1116 }
1117
1118 if ( ! pAddTS->wmeTspecPresent )
1119 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301120 vos_mem_set(( tANI_U8* )&AddTSReq, sizeof( AddTSReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001121
1122 AddTSReq.Action.action = SIR_MAC_QOS_ADD_TS_REQ;
1123 AddTSReq.DialogToken.token = pAddTS->dialogToken;
1124 AddTSReq.Category.category = SIR_MAC_ACTION_QOS_MGMT;
1125 if ( pAddTS->lleTspecPresent )
1126 {
1127 PopulateDot11fTSPEC( &pAddTS->tspec, &AddTSReq.TSPEC );
1128 }
1129 else
1130 {
1131 PopulateDot11fWMMTSPEC( &pAddTS->tspec, &AddTSReq.WMMTSPEC );
1132 }
1133
1134 if ( pAddTS->lleTspecPresent )
1135 {
1136 AddTSReq.num_WMMTCLAS = 0;
1137 AddTSReq.num_TCLAS = pAddTS->numTclas;
1138 for ( i = 0; i < pAddTS->numTclas; ++i)
1139 {
1140 PopulateDot11fTCLAS( pMac, &pAddTS->tclasInfo[i],
1141 &AddTSReq.TCLAS[i] );
1142 }
1143 }
1144 else
1145 {
1146 AddTSReq.num_TCLAS = 0;
1147 AddTSReq.num_WMMTCLAS = pAddTS->numTclas;
1148 for ( i = 0; i < pAddTS->numTclas; ++i)
1149 {
1150 PopulateDot11fWMMTCLAS( pMac, &pAddTS->tclasInfo[i],
1151 &AddTSReq.WMMTCLAS[i] );
1152 }
1153 }
1154
1155 if ( pAddTS->tclasProcPresent )
1156 {
1157 if ( pAddTS->lleTspecPresent )
1158 {
1159 AddTSReq.TCLASSPROC.processing = pAddTS->tclasProc;
1160 AddTSReq.TCLASSPROC.present = 1;
1161 }
1162 else
1163 {
1164 AddTSReq.WMMTCLASPROC.version = 1;
1165 AddTSReq.WMMTCLASPROC.processing = pAddTS->tclasProc;
1166 AddTSReq.WMMTCLASPROC.present = 1;
1167 }
1168 }
1169
1170 nStatus = dot11fGetPackedAddTSRequestSize( pMac, &AddTSReq, &nPayload );
1171 if ( DOT11F_FAILED( nStatus ) )
1172 {
1173 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001174 "or an Add TS Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001175 nStatus );
1176 // We'll fall back on the worst case scenario:
1177 nPayload = sizeof( tDot11fAddTSRequest );
1178 }
1179 else if ( DOT11F_WARNED( nStatus ) )
1180 {
1181 limLog( pMac, LOGW, FL("There were warnings while calculating"
1182 "the packed size for an Add TS Request"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001183 " (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001184 }
1185 }
1186 else
1187 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301188 vos_mem_set(( tANI_U8* )&WMMAddTSReq, sizeof( WMMAddTSReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001189
1190 WMMAddTSReq.Action.action = SIR_MAC_QOS_ADD_TS_REQ;
1191 WMMAddTSReq.DialogToken.token = pAddTS->dialogToken;
1192 WMMAddTSReq.Category.category = SIR_MAC_ACTION_WME;
1193
1194 // WMM spec 2.2.10 - status code is only filled in for ADDTS response
1195 WMMAddTSReq.StatusCode.statusCode = 0;
1196
1197 PopulateDot11fWMMTSPEC( &pAddTS->tspec, &WMMAddTSReq.WMMTSPEC );
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001198#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07001199 limGetPhyMode(pMac, &phyMode, psessionEntry);
1200
1201 if( phyMode == WNI_CFG_PHY_MODE_11G || phyMode == WNI_CFG_PHY_MODE_11A)
1202 {
1203 pAddTS->tsrsIE.rates[0] = TSRS_11AG_RATE_6MBPS;
1204 }
1205 else
1206 {
1207 pAddTS->tsrsIE.rates[0] = TSRS_11B_RATE_5_5MBPS;
1208 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001209 PopulateDot11TSRSIE(pMac,&pAddTS->tsrsIE, &WMMAddTSReq.ESETrafStrmRateSet,sizeof(tANI_U8));
Jeff Johnson295189b2012-06-20 16:38:30 -07001210#endif
1211 // fillWmeTspecIE
1212
1213 nStatus = dot11fGetPackedWMMAddTSRequestSize( pMac, &WMMAddTSReq, &nPayload );
1214 if ( DOT11F_FAILED( nStatus ) )
1215 {
1216 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001217 "or a WMM Add TS Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001218 nStatus );
1219 // We'll fall back on the worst case scenario:
1220 nPayload = sizeof( tDot11fAddTSRequest );
1221 }
1222 else if ( DOT11F_WARNED( nStatus ) )
1223 {
1224 limLog( pMac, LOGW, FL("There were warnings while calculating"
1225 "the packed size for a WMM Add TS Requ"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001226 "est (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001227 }
1228 }
1229
1230 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
1231
1232 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1233 ( tANI_U16 )nBytes, ( void** ) &pFrame,
1234 ( void** ) &pPacket );
1235 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1236 {
1237 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for an Ad"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001238 "d TS Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07001239 return;
1240 }
1241
1242 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301243 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07001244
1245 // Next, we fill out the buffer descriptor:
1246 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
1247 SIR_MAC_MGMT_ACTION, peerMacAddr,psessionEntry->selfMacAddr);
1248 if ( eSIR_SUCCESS != nSirStatus )
1249 {
1250 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001251 "tor for an Add TS Request (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001252 nSirStatus );
1253 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1254 ( void* ) pFrame, ( void* ) pPacket );
1255 return;
1256 }
1257
1258 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
1259
1260 #if 0
1261 cfgLen = SIR_MAC_ADDR_LENGTH;
1262 if ( eSIR_SUCCESS != wlan_cfgGetStr( pMac, WNI_CFG_BSSID,
1263 ( tANI_U8* )pMacHdr->bssId, &cfgLen ) )
1264 {
1265 limLog( pMac, LOGP, FL("Failed to retrieve WNI_CFG_BSSID whil"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001266 "e sending an Add TS Request.") );
Jeff Johnson295189b2012-06-20 16:38:30 -07001267 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1268 ( void* ) pFrame, ( void* ) pPacket );
1269 return;
1270 }
1271 #endif //TO SUPPORT BT-AMP
1272
1273 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
1274
Chet Lanctot186b5732013-03-18 10:26:30 -07001275#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07001276 limSetProtectedBit(pMac, psessionEntry, peerMacAddr, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07001277#endif
1278
Jeff Johnson295189b2012-06-20 16:38:30 -07001279 // That done, pack the struct:
1280 if ( ! pAddTS->wmeTspecPresent )
1281 {
1282 nStatus = dot11fPackAddTSRequest( pMac, &AddTSReq,
1283 pFrame + sizeof(tSirMacMgmtHdr),
1284 nPayload, &nPayload );
1285 if ( DOT11F_FAILED( nStatus ) )
1286 {
1287 limLog( pMac, LOGE, FL("Failed to pack an Add TS Request "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001288 "(0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001289 nStatus );
1290 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1291 return; // allocated!
1292 }
1293 else if ( DOT11F_WARNED( nStatus ) )
1294 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001295 limLog( pMac, LOGW, FL("There were warnings while packing "
1296 "an Add TS Request (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001297 }
1298 }
1299 else
1300 {
1301 nStatus = dot11fPackWMMAddTSRequest( pMac, &WMMAddTSReq,
1302 pFrame + sizeof(tSirMacMgmtHdr),
1303 nPayload, &nPayload );
1304 if ( DOT11F_FAILED( nStatus ) )
1305 {
1306 limLog( pMac, LOGE, FL("Failed to pack a WMM Add TS Reque"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001307 "st (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001308 nStatus );
1309 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1310 return; // allocated!
1311 }
1312 else if ( DOT11F_WARNED( nStatus ) )
1313 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001314 limLog( pMac, LOGW, FL("There were warnings while packing "
1315 "a WMM Add TS Request (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001316 }
1317 }
1318
Abhishek Singh127a8442014-12-15 17:31:27 +05301319 limLog( pMac, LOG1, FL("Sending an Add TS Request frame to ") );
1320 limPrintMacAddr( pMac, peerMacAddr, LOG1 );
Jeff Johnson295189b2012-06-20 16:38:30 -07001321
1322 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07001323 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
1324 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07001325 )
1326 {
1327 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
1328 }
1329
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05301330 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
1331 psessionEntry->peSessionId,
1332 pMacHdr->fc.subType));
Jeff Johnson295189b2012-06-20 16:38:30 -07001333 // Queue Addts Response frame in high priority WQ
1334 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
1335 HAL_TXRX_FRM_802_11_MGMT,
1336 ANI_TXDIR_TODS,
1337 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
1338 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05301339 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
1340 psessionEntry->peSessionId,
1341 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07001342 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1343 {
1344 limLog( pMac, LOGE, FL( "*** Could not send an Add TS Request"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001345 " (%X) ***" ), halstatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001346 //Pkt will be freed up by the callback
1347 }
1348
1349} // End limSendAddtsReqActionFrame.
1350
Jeff Johnson295189b2012-06-20 16:38:30 -07001351
1352
1353void
1354limSendAssocRspMgmtFrame(tpAniSirGlobal pMac,
1355 tANI_U16 statusCode,
1356 tANI_U16 aid,
1357 tSirMacAddr peerMacAddr,
1358 tANI_U8 subType,
1359 tpDphHashNode pSta,tpPESession psessionEntry)
1360{
1361 static tDot11fAssocResponse frm;
1362 tANI_U8 *pFrame, *macAddr;
1363 tpSirMacMgmtHdr pMacHdr;
1364 tSirRetStatus nSirStatus;
1365 tANI_U8 lleMode = 0, fAddTS, edcaInclude = 0;
1366 tHalBitVal qosMode, wmeMode;
c_hpothubcd78652014-04-28 22:31:08 +05301367 tANI_U32 nPayload, nStatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07001368 void *pPacket;
1369 eHalStatus halstatus;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05301370 tUpdateBeaconParams beaconParams;
1371 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001372 tANI_U32 addnIEPresent = false;
1373 tANI_U32 addnIELen=0;
1374 tANI_U8 addIE[WNI_CFG_ASSOC_RSP_ADDNIE_DATA_LEN];
1375 tpSirAssocReq pAssocReq = NULL;
Mahesh A Saptasagar38c177e2014-10-17 18:55:48 +05301376 tANI_U16 addStripoffIELen = 0;
1377 tDot11fIEExtCap extractedExtCap;
1378 tANI_BOOLEAN extractedExtCapFlag = eANI_BOOLEAN_FALSE;
c_hpothubcd78652014-04-28 22:31:08 +05301379 tANI_U32 nBytes = 0;
Kalikinkar dhara205da782014-03-21 15:49:32 -07001380
Chet Lanctot8cecea22014-02-11 19:09:36 -08001381#ifdef WLAN_FEATURE_11W
1382 tANI_U32 retryInterval;
1383 tANI_U32 maxRetries;
1384#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001385
1386 if(NULL == psessionEntry)
1387 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05301388 limLog( pMac, LOGE, FL("psessionEntry is NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001389 return;
1390 }
1391
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301392 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07001393
1394 limGetQosMode(psessionEntry, &qosMode);
1395 limGetWmeMode(psessionEntry, &wmeMode);
1396
1397 // An Add TS IE is added only if the AP supports it and the requesting
1398 // STA sent a traffic spec.
1399 fAddTS = ( qosMode && pSta && pSta->qos.addtsPresent ) ? 1 : 0;
1400
1401 PopulateDot11fCapabilities( pMac, &frm.Capabilities, psessionEntry );
1402
1403 frm.Status.status = statusCode;
1404
1405 frm.AID.associd = aid | LIM_AID_MASK;
1406
1407 if ( NULL == pSta )
1408 {
1409 PopulateDot11fSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL, &frm.SuppRates,psessionEntry);
1410 PopulateDot11fExtSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL, &frm.ExtSuppRates, psessionEntry );
1411 }
1412 else
1413 {
1414 PopulateDot11fAssocRspRates( pMac, &frm.SuppRates, &frm.ExtSuppRates,
1415 pSta->supportedRates.llbRates, pSta->supportedRates.llaRates );
1416 }
1417
Jeff Johnson295189b2012-06-20 16:38:30 -07001418 if(psessionEntry->limSystemRole == eLIM_AP_ROLE)
1419 {
1420 if( pSta != NULL && eSIR_SUCCESS == statusCode )
1421 {
1422 pAssocReq =
1423 (tpSirAssocReq) psessionEntry->parsedAssocReq[pSta->assocId];
Jeff Johnson295189b2012-06-20 16:38:30 -07001424 /* populate P2P IE in AssocRsp when assocReq from the peer includes P2P IE */
1425 if( pAssocReq != NULL && pAssocReq->addIEPresent ) {
1426 PopulateDot11AssocResP2PIE(pMac, &frm.P2PAssocRes, pAssocReq);
1427 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001428 }
1429 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001430
1431 if ( NULL != pSta )
1432 {
1433 if ( eHAL_SET == qosMode )
1434 {
1435 if ( pSta->lleEnabled )
1436 {
1437 lleMode = 1;
1438 if ( ( ! pSta->aniPeer ) || ( ! PROP_CAPABILITY_GET( 11EQOS, pSta->propCapability ) ) )
1439 {
1440 PopulateDot11fEDCAParamSet( pMac, &frm.EDCAParamSet, psessionEntry);
1441
1442// FramesToDo:...
1443// if ( fAddTS )
1444// {
1445// tANI_U8 *pAf = pBody;
1446// *pAf++ = SIR_MAC_QOS_ACTION_EID;
1447// tANI_U32 tlen;
1448// status = sirAddtsRspFill(pMac, pAf, statusCode, &pSta->qos.addts, NULL,
1449// &tlen, bufLen - frameLen);
1450// } // End if on Add TS.
1451 }
1452 } // End if on .11e enabled in 'pSta'.
1453 } // End if on QOS Mode on.
1454
1455 if ( ( ! lleMode ) && ( eHAL_SET == wmeMode ) && pSta->wmeEnabled )
1456 {
1457 if ( ( ! pSta->aniPeer ) || ( ! PROP_CAPABILITY_GET( WME, pSta->propCapability ) ) )
1458 {
1459
Jeff Johnson295189b2012-06-20 16:38:30 -07001460 PopulateDot11fWMMParams( pMac, &frm.WMMParams, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07001461
1462 if ( pSta->wsmEnabled )
1463 {
1464 PopulateDot11fWMMCaps(&frm.WMMCaps );
1465 }
1466 }
1467 }
1468
1469 if ( pSta->aniPeer )
1470 {
1471 if ( ( lleMode && PROP_CAPABILITY_GET( 11EQOS, pSta->propCapability ) ) ||
1472 ( pSta->wmeEnabled && PROP_CAPABILITY_GET( WME, pSta->propCapability ) ) )
1473 {
1474 edcaInclude = 1;
1475 }
1476
1477 } // End if on Airgo peer.
1478
1479 if ( pSta->mlmStaContext.htCapability &&
Jeff Johnsone7245742012-09-05 17:12:55 -07001480 psessionEntry->htCapability )
Jeff Johnson295189b2012-06-20 16:38:30 -07001481 {
Jeff Johnsone7245742012-09-05 17:12:55 -07001482 PopulateDot11fHTCaps( pMac, psessionEntry, &frm.HTCaps );
Sachin Ahujac3a26232014-09-23 22:27:30 +05301483 /*
1484 *Check the STA capability and update the HTCaps accordingly
1485 */
1486 frm.HTCaps.supportedChannelWidthSet =
1487 (pSta->htSupportedChannelWidthSet < psessionEntry->htSupportedChannelWidthSet) ?
1488 pSta->htSupportedChannelWidthSet : psessionEntry->htSupportedChannelWidthSet ;
1489
1490 if (!frm.HTCaps.supportedChannelWidthSet)
1491 frm.HTCaps.shortGI40MHz = 0;
1492
Jeff Johnson295189b2012-06-20 16:38:30 -07001493 PopulateDot11fHTInfo( pMac, &frm.HTInfo, psessionEntry );
Jeff Johnson295189b2012-06-20 16:38:30 -07001494 }
Jeff Johnsone7245742012-09-05 17:12:55 -07001495
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301496#ifdef WLAN_FEATURE_AP_HT40_24G
1497 /* Populate Overlapping BSS Scan Parameters IEs,
1498 * when operating in HT40 in 2.4GHz.
1499 */
Hardik Kantilal Patel3c235242015-01-02 17:56:18 +05301500 if ((pMac->roam.configParam.apHT40_24GEnabled)
1501 && (IS_DOT11_MODE_HT(psessionEntry->dot11mode)))
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301502 {
1503 PopulateDot11fOBSSScanParameters( pMac, &frm.OBSSScanParameters,
1504 psessionEntry);
Hardik Kantilal Patelee5874c2015-01-14 15:23:28 +05301505 /* 10.15.8 Support of DSSS/CCK in 40 MHz, An associated HT STA in
1506 * a 20/40 MHz BSS may generate DSSS/CCK transmissions.Set DSSS/CCK
1507 * Mode in 40 MHz bit in HT capablity.
1508 */
1509 frm.HTCaps.dsssCckMode40MHz = 1;
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301510 }
1511#endif
1512
1513 PopulateDot11fExtCap( pMac, &frm.ExtCap, psessionEntry);
Jeff Johnsone7245742012-09-05 17:12:55 -07001514#ifdef WLAN_FEATURE_11AC
1515 if( pSta->mlmStaContext.vhtCapability &&
1516 psessionEntry->vhtCapability )
1517 {
Chet Lanctotf19c1f62013-12-13 13:56:21 -08001518 limLog( pMac, LOG1, FL("Populate VHT IEs in Assoc Response"));
Abhishek Singh6d5d29c2014-07-03 14:25:22 +05301519 PopulateDot11fVHTCaps( pMac, &frm.VHTCaps, eSIR_TRUE );
Jeff Johnsone7245742012-09-05 17:12:55 -07001520 PopulateDot11fVHTOperation( pMac, &frm.VHTOperation);
1521 }
1522#endif
1523
Chet Lanctot8cecea22014-02-11 19:09:36 -08001524#ifdef WLAN_FEATURE_11W
Dino Myclea7f18452014-04-24 08:55:31 +05301525 if( eSIR_MAC_TRY_AGAIN_LATER == statusCode )
1526 {
Chet Lanctotfadc8e32014-04-24 14:50:52 -07001527 if ( wlan_cfgGetInt(pMac, WNI_CFG_PMF_SA_QUERY_MAX_RETRIES,
1528 &maxRetries ) != eSIR_SUCCESS )
1529 limLog( pMac, LOGE,
1530 FL("Could not retrieve PMF SA Query maximum retries value") );
1531 else
1532 if ( wlan_cfgGetInt(pMac, WNI_CFG_PMF_SA_QUERY_RETRY_INTERVAL,
1533 &retryInterval ) != eSIR_SUCCESS)
1534 limLog( pMac, LOGE,
1535 FL("Could not retrieve PMF SA Query timer interval value") );
Dino Myclea7f18452014-04-24 08:55:31 +05301536 else
Chet Lanctotfadc8e32014-04-24 14:50:52 -07001537 PopulateDot11fTimeoutInterval(
1538 pMac, &frm.TimeoutInterval, SIR_MAC_TI_TYPE_ASSOC_COMEBACK,
1539 (maxRetries - pSta->pmfSaQueryRetryCount) * retryInterval );
Dino Myclea7f18452014-04-24 08:55:31 +05301540 }
Chet Lanctot8cecea22014-02-11 19:09:36 -08001541#endif
Dino Myclea7f18452014-04-24 08:55:31 +05301542 } // End if on non-NULL 'pSta'.
Jeff Johnson295189b2012-06-20 16:38:30 -07001543
Chet Lanctot8cecea22014-02-11 19:09:36 -08001544 vos_mem_set(( tANI_U8* )&beaconParams, sizeof( tUpdateBeaconParams), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001545
Jeff Johnson295189b2012-06-20 16:38:30 -07001546 if( psessionEntry->limSystemRole == eLIM_AP_ROLE ){
1547 if(psessionEntry->gLimProtectionControl != WNI_CFG_FORCE_POLICY_PROTECTION_DISABLE)
1548 limDecideApProtection(pMac, peerMacAddr, &beaconParams,psessionEntry);
1549 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001550
1551 limUpdateShortPreamble(pMac, peerMacAddr, &beaconParams, psessionEntry);
1552 limUpdateShortSlotTime(pMac, peerMacAddr, &beaconParams, psessionEntry);
1553
1554 beaconParams.bssIdx = psessionEntry->bssIdx;
1555
1556 //Send message to HAL about beacon parameter change.
1557 if(beaconParams.paramChangeBitmap)
1558 {
1559 schSetFixedBeaconFields(pMac,psessionEntry);
1560 limSendBeaconParams(pMac, &beaconParams, psessionEntry );
1561 }
1562
Jeff Johnson295189b2012-06-20 16:38:30 -07001563 if ( pAssocReq != NULL )
1564 {
1565 if (wlan_cfgGetInt(pMac, WNI_CFG_ASSOC_RSP_ADDNIE_FLAG,
1566 &addnIEPresent) != eSIR_SUCCESS)
1567 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05301568 limLog(pMac, LOGP, FL("Unable to get "
1569 "WNI_CFG_ASSOC_RSP_ADDNIE_FLAG"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001570 return;
1571 }
1572
1573 if (addnIEPresent)
1574 {
1575 //Assoc rsp IE available
1576 if (wlan_cfgGetStrLen(pMac, WNI_CFG_ASSOC_RSP_ADDNIE_DATA,
1577 &addnIELen) != eSIR_SUCCESS)
1578 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05301579 limLog(pMac, LOGP, FL("Unable to get "
1580 "WNI_CFG_ASSOC_RSP_ADDNIE_DATA length"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001581 return;
1582 }
1583
1584 if (addnIELen <= WNI_CFG_ASSOC_RSP_ADDNIE_DATA_LEN && addnIELen &&
1585 (nBytes + addnIELen) <= SIR_MAX_PACKET_SIZE)
1586 {
1587 if (wlan_cfgGetStr(pMac, WNI_CFG_ASSOC_RSP_ADDNIE_DATA,
1588 &addIE[0], &addnIELen) == eSIR_SUCCESS)
1589 {
Mahesh A Saptasagar38c177e2014-10-17 18:55:48 +05301590
1591 vos_mem_set(( tANI_U8* )&extractedExtCap,
1592 sizeof( tDot11fIEExtCap ), 0);
Mahesh A Saptasagare00ff532014-10-17 19:05:14 +05301593 addStripoffIELen = addnIELen;
Mahesh A Saptasagar38c177e2014-10-17 18:55:48 +05301594 nSirStatus = limStripOffExtCapIEAndUpdateStruct(pMac,
1595 &addIE[0],
1596 &addStripoffIELen,
1597 &extractedExtCap );
1598 if(eSIR_SUCCESS != nSirStatus)
1599 {
1600 limLog(pMac, LOG1,
1601 FL("Unable to Stripoff ExtCap IE from Assoc Rsp"));
1602 }
1603 else
1604 {
1605 addnIELen = addStripoffIELen;
1606 extractedExtCapFlag = eANI_BOOLEAN_TRUE;
1607 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001608 nBytes = nBytes + addnIELen;
1609 }
1610 }
1611 }
1612 }
1613
Mahesh A Saptasagar38c177e2014-10-17 18:55:48 +05301614 /* merge the ExtCap struct*/
1615 if (extractedExtCapFlag && extractedExtCap.present)
1616 {
1617 limMergeExtCapIEStruct(&(frm.ExtCap), &extractedExtCap);
1618 }
1619
c_hpothubcd78652014-04-28 22:31:08 +05301620 nStatus = dot11fGetPackedAssocResponseSize( pMac, &frm, &nPayload );
1621 if ( DOT11F_FAILED( nStatus ) )
1622 {
1623 limLog( pMac, LOGE, FL("Failed to calculate the packed size f"
1624 "or an Association Response (0x%08x)."),
1625 nStatus );
1626 return;
1627 }
1628 else if ( DOT11F_WARNED( nStatus ) )
1629 {
1630 limLog( pMac, LOGW, FL("There were warnings while calculating "
1631 "the packed size for an Association Re"
1632 "sponse (0x%08x)."), nStatus );
1633 }
1634
1635 nBytes += sizeof( tSirMacMgmtHdr ) + nPayload;
1636
Jeff Johnson295189b2012-06-20 16:38:30 -07001637 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1638 ( tANI_U16 )nBytes, ( void** ) &pFrame,
1639 ( void** ) &pPacket );
1640 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1641 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001642 limLog(pMac, LOGP, FL("Call to bufAlloc failed for RE/ASSOC RSP."));
Jeff Johnson295189b2012-06-20 16:38:30 -07001643 return;
1644 }
1645
1646 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301647 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07001648
1649 // Next, we fill out the buffer descriptor:
1650 nSirStatus = limPopulateMacHeader( pMac,
1651 pFrame,
1652 SIR_MAC_MGMT_FRAME,
1653 ( LIM_ASSOC == subType ) ?
1654 SIR_MAC_MGMT_ASSOC_RSP :
1655 SIR_MAC_MGMT_REASSOC_RSP,
1656 peerMacAddr,psessionEntry->selfMacAddr);
1657 if ( eSIR_SUCCESS != nSirStatus )
1658 {
1659 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001660 "tor for an Association Response (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001661 nSirStatus );
1662 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1663 ( void* ) pFrame, ( void* ) pPacket );
1664 return;
1665 }
1666
1667 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
1668
Jeff Johnson295189b2012-06-20 16:38:30 -07001669 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
1670
1671 nStatus = dot11fPackAssocResponse( pMac, &frm,
1672 pFrame + sizeof( tSirMacMgmtHdr ),
1673 nPayload, &nPayload );
1674 if ( DOT11F_FAILED( nStatus ) )
1675 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05301676 limLog( pMac, LOGE, FL("Failed to pack an Association Response"
1677 " (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001678 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1679 ( void* ) pFrame, ( void* ) pPacket );
1680 return; // allocated!
1681 }
1682 else if ( DOT11F_WARNED( nStatus ) )
1683 {
1684 limLog( pMac, LOGW, FL("There were warnings while packing an "
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001685 "Association Response (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001686 }
1687
1688 macAddr = pMacHdr->da;
1689
1690 if (subType == LIM_ASSOC)
1691 {
Abhishek Singh3cbf6052014-12-15 16:46:42 +05301692 limLog(pMac, LOG1,
Jeff Johnson295189b2012-06-20 16:38:30 -07001693 FL("*** Sending Assoc Resp status %d aid %d to "),
Abhishek Singh3cbf6052014-12-15 16:46:42 +05301694 statusCode, aid);
Jeff Johnson295189b2012-06-20 16:38:30 -07001695 }
1696 else{
Abhishek Singh3cbf6052014-12-15 16:46:42 +05301697 limLog(pMac, LOG1,
Jeff Johnson295189b2012-06-20 16:38:30 -07001698 FL("*** Sending ReAssoc Resp status %d aid %d to "),
Abhishek Singh3cbf6052014-12-15 16:46:42 +05301699 statusCode, aid);
Jeff Johnson295189b2012-06-20 16:38:30 -07001700 }
Abhishek Singh3cbf6052014-12-15 16:46:42 +05301701 limPrintMacAddr(pMac, pMacHdr->da, LOG1);
Jeff Johnson295189b2012-06-20 16:38:30 -07001702
1703 if ( addnIEPresent )
1704 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301705 vos_mem_copy ( pFrame+sizeof(tSirMacMgmtHdr)+nPayload, &addIE[0], addnIELen ) ;
Jeff Johnson295189b2012-06-20 16:38:30 -07001706 }
1707
1708 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07001709 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
1710 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07001711 )
1712 {
1713 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
1714 }
1715
Agarwal Ashisha8e81f52014-04-02 01:59:52 +05301716 limLog( pMac, LOG1, FL("Sending Assoc resp over WQ5 to "MAC_ADDRESS_STR
1717 " From " MAC_ADDRESS_STR),MAC_ADDR_ARRAY(pMacHdr->da),
1718 MAC_ADDR_ARRAY(psessionEntry->selfMacAddr));
1719
1720 txFlag |= HAL_USE_FW_IN_TX_PATH;
1721
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05301722 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
1723 psessionEntry->peSessionId,
1724 pMacHdr->fc.subType));
Jeff Johnson295189b2012-06-20 16:38:30 -07001725 /// Queue Association Response frame in high priority WQ
1726 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
1727 HAL_TXRX_FRM_802_11_MGMT,
1728 ANI_TXDIR_TODS,
1729 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
1730 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05301731 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
1732 psessionEntry->peSessionId,
1733 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07001734 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1735 {
1736 limLog(pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001737 FL("*** Could not Send Re/AssocRsp, retCode=%X ***"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001738 nSirStatus);
1739
1740 //Pkt will be freed up by the callback
1741 }
1742
1743 // update the ANI peer station count
1744 //FIXME_PROTECTION : take care of different type of station
1745 // counter inside this function.
1746 limUtilCountStaAdd(pMac, pSta, psessionEntry);
1747
1748} // End limSendAssocRspMgmtFrame.
1749
1750
1751
1752void
1753limSendAddtsRspActionFrame(tpAniSirGlobal pMac,
1754 tSirMacAddr peer,
1755 tANI_U16 nStatusCode,
1756 tSirAddtsReqInfo *pAddTS,
1757 tSirMacScheduleIE *pSchedule,
1758 tpPESession psessionEntry)
1759{
1760 tANI_U8 *pFrame;
1761 tpSirMacMgmtHdr pMacHdr;
1762 tDot11fAddTSResponse AddTSRsp;
1763 tDot11fWMMAddTSResponse WMMAddTSRsp;
1764 tSirRetStatus nSirStatus;
1765 tANI_U32 i, nBytes, nPayload, nStatus;
1766 void *pPacket;
1767 eHalStatus halstatus;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05301768 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001769
1770 if(NULL == psessionEntry)
1771 {
1772 return;
1773 }
1774
1775 if ( ! pAddTS->wmeTspecPresent )
1776 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301777 vos_mem_set( ( tANI_U8* )&AddTSRsp, sizeof( AddTSRsp ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07001778
1779 AddTSRsp.Category.category = SIR_MAC_ACTION_QOS_MGMT;
1780 AddTSRsp.Action.action = SIR_MAC_QOS_ADD_TS_RSP;
1781 AddTSRsp.DialogToken.token = pAddTS->dialogToken;
1782 AddTSRsp.Status.status = nStatusCode;
1783
1784 // The TsDelay information element is only filled in for a specific
1785 // status code:
1786 if ( eSIR_MAC_TS_NOT_CREATED_STATUS == nStatusCode )
1787 {
1788 if ( pAddTS->wsmTspecPresent )
1789 {
1790 AddTSRsp.WMMTSDelay.version = 1;
1791 AddTSRsp.WMMTSDelay.delay = 10;
1792 AddTSRsp.WMMTSDelay.present = 1;
1793 }
1794 else
1795 {
1796 AddTSRsp.TSDelay.delay = 10;
1797 AddTSRsp.TSDelay.present = 1;
1798 }
1799 }
1800
1801 if ( pAddTS->wsmTspecPresent )
1802 {
1803 PopulateDot11fWMMTSPEC( &pAddTS->tspec, &AddTSRsp.WMMTSPEC );
1804 }
1805 else
1806 {
1807 PopulateDot11fTSPEC( &pAddTS->tspec, &AddTSRsp.TSPEC );
1808 }
1809
1810 if ( pAddTS->wsmTspecPresent )
1811 {
1812 AddTSRsp.num_WMMTCLAS = 0;
1813 AddTSRsp.num_TCLAS = pAddTS->numTclas;
1814 for ( i = 0; i < AddTSRsp.num_TCLAS; ++i)
1815 {
1816 PopulateDot11fTCLAS( pMac, &pAddTS->tclasInfo[i],
1817 &AddTSRsp.TCLAS[i] );
1818 }
1819 }
1820 else
1821 {
1822 AddTSRsp.num_TCLAS = 0;
1823 AddTSRsp.num_WMMTCLAS = pAddTS->numTclas;
1824 for ( i = 0; i < AddTSRsp.num_WMMTCLAS; ++i)
1825 {
1826 PopulateDot11fWMMTCLAS( pMac, &pAddTS->tclasInfo[i],
1827 &AddTSRsp.WMMTCLAS[i] );
1828 }
1829 }
1830
1831 if ( pAddTS->tclasProcPresent )
1832 {
1833 if ( pAddTS->wsmTspecPresent )
1834 {
1835 AddTSRsp.WMMTCLASPROC.version = 1;
1836 AddTSRsp.WMMTCLASPROC.processing = pAddTS->tclasProc;
1837 AddTSRsp.WMMTCLASPROC.present = 1;
1838 }
1839 else
1840 {
1841 AddTSRsp.TCLASSPROC.processing = pAddTS->tclasProc;
1842 AddTSRsp.TCLASSPROC.present = 1;
1843 }
1844 }
1845
1846 // schedule element is included only if requested in the tspec and we are
1847 // using hcca (or both edca and hcca)
1848 // 11e-D8.0 is inconsistent on whether the schedule element is included
1849 // based on tspec schedule bit or not. Sec 7.4.2.2. says one thing but
1850 // pg 46, line 17-18 says something else. So just include it and let the
1851 // sta figure it out
1852 if ((pSchedule != NULL) &&
1853 ((pAddTS->tspec.tsinfo.traffic.accessPolicy == SIR_MAC_ACCESSPOLICY_HCCA) ||
1854 (pAddTS->tspec.tsinfo.traffic.accessPolicy == SIR_MAC_ACCESSPOLICY_BOTH)))
1855 {
1856 if ( pAddTS->wsmTspecPresent )
1857 {
1858 PopulateDot11fWMMSchedule( pSchedule, &AddTSRsp.WMMSchedule );
1859 }
1860 else
1861 {
1862 PopulateDot11fSchedule( pSchedule, &AddTSRsp.Schedule );
1863 }
1864 }
1865
1866 nStatus = dot11fGetPackedAddTSResponseSize( pMac, &AddTSRsp, &nPayload );
1867 if ( DOT11F_FAILED( nStatus ) )
1868 {
1869 limLog( pMac, LOGP, FL("Failed to calculate the packed si"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001870 "ze for an Add TS Response (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001871 nStatus );
1872 // We'll fall back on the worst case scenario:
1873 nPayload = sizeof( tDot11fAddTSResponse );
1874 }
1875 else if ( DOT11F_WARNED( nStatus ) )
1876 {
1877 limLog( pMac, LOGW, FL("There were warnings while calcula"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001878 "ting the packed size for an Add TS"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001879 " Response (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001880 }
1881 }
1882 else
1883 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301884 vos_mem_set( ( tANI_U8* )&WMMAddTSRsp, sizeof( WMMAddTSRsp ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07001885
1886 WMMAddTSRsp.Category.category = SIR_MAC_ACTION_WME;
1887 WMMAddTSRsp.Action.action = SIR_MAC_QOS_ADD_TS_RSP;
1888 WMMAddTSRsp.DialogToken.token = pAddTS->dialogToken;
1889 WMMAddTSRsp.StatusCode.statusCode = (tANI_U8)nStatusCode;
1890
1891 PopulateDot11fWMMTSPEC( &pAddTS->tspec, &WMMAddTSRsp.WMMTSPEC );
1892
1893 nStatus = dot11fGetPackedWMMAddTSResponseSize( pMac, &WMMAddTSRsp, &nPayload );
1894 if ( DOT11F_FAILED( nStatus ) )
1895 {
1896 limLog( pMac, LOGP, FL("Failed to calculate the packed si"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001897 "ze for a WMM Add TS Response (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001898 nStatus );
1899 // We'll fall back on the worst case scenario:
1900 nPayload = sizeof( tDot11fWMMAddTSResponse );
1901 }
1902 else if ( DOT11F_WARNED( nStatus ) )
1903 {
1904 limLog( pMac, LOGW, FL("There were warnings while calcula"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001905 "ting the packed size for a WMM Add"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001906 "TS Response (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001907 }
1908 }
1909
1910 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
1911
1912 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
1913 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1914 {
1915 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for an Ad"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001916 "d TS Response."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07001917 return;
1918 }
1919
1920 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301921 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07001922
1923 // Next, we fill out the buffer descriptor:
1924 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
1925 SIR_MAC_MGMT_ACTION, peer,psessionEntry->selfMacAddr);
1926 if ( eSIR_SUCCESS != nSirStatus )
1927 {
1928 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001929 "tor for an Add TS Response (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001930 nSirStatus );
1931 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1932 return; // allocated!
1933 }
1934
1935 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
1936
1937
1938 #if 0
1939 if ( eSIR_SUCCESS != wlan_cfgGetStr( pMac, WNI_CFG_BSSID,
1940 ( tANI_U8* )pMacHdr->bssId, &cfgLen ) )
1941 {
1942 limLog( pMac, LOGP, FL("Failed to retrieve WNI_CFG_BSSID whil"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001943 "e sending an Add TS Response.") );
Jeff Johnson295189b2012-06-20 16:38:30 -07001944 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1945 return; // allocated!
1946 }
1947 #endif //TO SUPPORT BT-AMP
1948 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
1949
Chet Lanctot186b5732013-03-18 10:26:30 -07001950#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07001951 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07001952#endif
1953
Jeff Johnson295189b2012-06-20 16:38:30 -07001954 // That done, pack the struct:
1955 if ( ! pAddTS->wmeTspecPresent )
1956 {
1957 nStatus = dot11fPackAddTSResponse( pMac, &AddTSRsp,
1958 pFrame + sizeof( tSirMacMgmtHdr ),
1959 nPayload, &nPayload );
1960 if ( DOT11F_FAILED( nStatus ) )
1961 {
1962 limLog( pMac, LOGE, FL("Failed to pack an Add TS Response "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001963 "(0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001964 nStatus );
1965 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1966 return;
1967 }
1968 else if ( DOT11F_WARNED( nStatus ) )
1969 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001970 limLog( pMac, LOGW, FL("There were warnings while packing "
1971 "an Add TS Response (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001972 }
1973 }
1974 else
1975 {
1976 nStatus = dot11fPackWMMAddTSResponse( pMac, &WMMAddTSRsp,
1977 pFrame + sizeof( tSirMacMgmtHdr ),
1978 nPayload, &nPayload );
1979 if ( DOT11F_FAILED( nStatus ) )
1980 {
1981 limLog( pMac, LOGE, FL("Failed to pack a WMM Add TS Response "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001982 "(0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001983 nStatus );
1984 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1985 return;
1986 }
1987 else if ( DOT11F_WARNED( nStatus ) )
1988 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001989 limLog( pMac, LOGW, FL("There were warnings while packing "
1990 "a WMM Add TS Response (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001991 }
1992 }
1993
Abhishek Singh3cbf6052014-12-15 16:46:42 +05301994 limLog( pMac, LOG1, FL("Sending an Add TS Response (status %d) to "),
Jeff Johnson295189b2012-06-20 16:38:30 -07001995 nStatusCode );
Abhishek Singh3cbf6052014-12-15 16:46:42 +05301996 limPrintMacAddr( pMac, pMacHdr->da, LOG1 );
Jeff Johnson295189b2012-06-20 16:38:30 -07001997
1998 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07001999 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
2000 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07002001 )
2002 {
2003 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
2004 }
2005
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05302006 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
2007 psessionEntry->peSessionId,
2008 pMacHdr->fc.subType));
Jeff Johnson295189b2012-06-20 16:38:30 -07002009 // Queue the frame in high priority WQ:
2010 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
2011 HAL_TXRX_FRM_802_11_MGMT,
2012 ANI_TXDIR_TODS,
2013 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
2014 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05302015 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
2016 psessionEntry->peSessionId,
2017 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07002018 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
2019 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002020 limLog( pMac, LOGE, FL("Failed to send Add TS Response (%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002021 nSirStatus );
2022 //Pkt will be freed up by the callback
2023 }
2024
2025} // End limSendAddtsRspActionFrame.
2026
2027void
2028limSendDeltsReqActionFrame(tpAniSirGlobal pMac,
2029 tSirMacAddr peer,
2030 tANI_U8 wmmTspecPresent,
2031 tSirMacTSInfo *pTsinfo,
2032 tSirMacTspecIE *pTspecIe,
2033 tpPESession psessionEntry)
2034{
2035 tANI_U8 *pFrame;
2036 tpSirMacMgmtHdr pMacHdr;
2037 tDot11fDelTS DelTS;
2038 tDot11fWMMDelTS WMMDelTS;
2039 tSirRetStatus nSirStatus;
2040 tANI_U32 nBytes, nPayload, nStatus;
2041 void *pPacket;
2042 eHalStatus halstatus;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05302043 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002044
2045 if(NULL == psessionEntry)
2046 {
2047 return;
2048 }
2049
2050 if ( ! wmmTspecPresent )
2051 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302052 vos_mem_set( ( tANI_U8* )&DelTS, sizeof( DelTS ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07002053
2054 DelTS.Category.category = SIR_MAC_ACTION_QOS_MGMT;
2055 DelTS.Action.action = SIR_MAC_QOS_DEL_TS_REQ;
2056 PopulateDot11fTSInfo( pTsinfo, &DelTS.TSInfo );
2057
2058 nStatus = dot11fGetPackedDelTSSize( pMac, &DelTS, &nPayload );
2059 if ( DOT11F_FAILED( nStatus ) )
2060 {
2061 limLog( pMac, LOGP, FL("Failed to calculate the packed si"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002062 "ze for a Del TS (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002063 nStatus );
2064 // We'll fall back on the worst case scenario:
2065 nPayload = sizeof( tDot11fDelTS );
2066 }
2067 else if ( DOT11F_WARNED( nStatus ) )
2068 {
2069 limLog( pMac, LOGW, FL("There were warnings while calcula"
2070 "ting the packed size for a Del TS"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002071 " (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07002072 }
2073 }
2074 else
2075 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302076 vos_mem_set( ( tANI_U8* )&WMMDelTS, sizeof( WMMDelTS ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07002077
2078 WMMDelTS.Category.category = SIR_MAC_ACTION_WME;
2079 WMMDelTS.Action.action = SIR_MAC_QOS_DEL_TS_REQ;
2080 WMMDelTS.DialogToken.token = 0;
2081 WMMDelTS.StatusCode.statusCode = 0;
2082 PopulateDot11fWMMTSPEC( pTspecIe, &WMMDelTS.WMMTSPEC );
2083 nStatus = dot11fGetPackedWMMDelTSSize( pMac, &WMMDelTS, &nPayload );
2084 if ( DOT11F_FAILED( nStatus ) )
2085 {
2086 limLog( pMac, LOGP, FL("Failed to calculate the packed si"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002087 "ze for a WMM Del TS (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002088 nStatus );
2089 // We'll fall back on the worst case scenario:
2090 nPayload = sizeof( tDot11fDelTS );
2091 }
2092 else if ( DOT11F_WARNED( nStatus ) )
2093 {
2094 limLog( pMac, LOGW, FL("There were warnings while calcula"
2095 "ting the packed size for a WMM De"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002096 "l TS (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07002097 }
2098 }
2099
2100 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
2101
2102 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
2103 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
2104 {
2105 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for an Ad"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002106 "d TS Response."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07002107 return;
2108 }
2109
2110 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302111 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07002112
2113 // Next, we fill out the buffer descriptor:
2114 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
2115 SIR_MAC_MGMT_ACTION, peer,
2116 psessionEntry->selfMacAddr);
2117 if ( eSIR_SUCCESS != nSirStatus )
2118 {
2119 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002120 "tor for an Add TS Response (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002121 nSirStatus );
2122 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
2123 return; // allocated!
2124 }
2125
2126 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
2127
2128 #if 0
2129
2130 cfgLen = SIR_MAC_ADDR_LENGTH;
2131 if ( eSIR_SUCCESS != wlan_cfgGetStr( pMac, WNI_CFG_BSSID,
2132 ( tANI_U8* )pMacHdr->bssId, &cfgLen ) )
2133 {
2134 limLog( pMac, LOGP, FL("Failed to retrieve WNI_CFG_BSSID whil"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002135 "e sending an Add TS Response.") );
Jeff Johnson295189b2012-06-20 16:38:30 -07002136 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
2137 return; // allocated!
2138 }
2139 #endif //TO SUPPORT BT-AMP
2140 sirCopyMacAddr(pMacHdr->bssId, psessionEntry->bssId);
2141
Chet Lanctot186b5732013-03-18 10:26:30 -07002142#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07002143 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07002144#endif
2145
Jeff Johnson295189b2012-06-20 16:38:30 -07002146 // That done, pack the struct:
2147 if ( !wmmTspecPresent )
2148 {
2149 nStatus = dot11fPackDelTS( pMac, &DelTS,
2150 pFrame + sizeof( tSirMacMgmtHdr ),
2151 nPayload, &nPayload );
2152 if ( DOT11F_FAILED( nStatus ) )
2153 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002154 limLog( pMac, LOGE, FL("Failed to pack a Del TS frame (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002155 nStatus );
2156 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
2157 return; // allocated!
2158 }
2159 else if ( DOT11F_WARNED( nStatus ) )
2160 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08002161 limLog( pMac, LOGW, FL("There were warnings while packing "
2162 "a Del TS frame (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07002163 }
2164 }
2165 else
2166 {
2167 nStatus = dot11fPackWMMDelTS( pMac, &WMMDelTS,
2168 pFrame + sizeof( tSirMacMgmtHdr ),
2169 nPayload, &nPayload );
2170 if ( DOT11F_FAILED( nStatus ) )
2171 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002172 limLog( pMac, LOGE, FL("Failed to pack a WMM Del TS frame (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002173 nStatus );
2174 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
2175 return; // allocated!
2176 }
2177 else if ( DOT11F_WARNED( nStatus ) )
2178 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08002179 limLog( pMac, LOGW, FL("There were warnings while packing "
2180 "a WMM Del TS frame (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07002181 }
2182 }
2183
Abhishek Singh3cbf6052014-12-15 16:46:42 +05302184 limLog(pMac, LOG1, FL("Sending DELTS REQ (size %d) to "), nBytes);
2185 limPrintMacAddr(pMac, pMacHdr->da, LOG1);
Jeff Johnson295189b2012-06-20 16:38:30 -07002186
2187 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07002188 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
2189 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07002190 )
2191 {
2192 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
2193 }
2194
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05302195 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
2196 psessionEntry->peSessionId,
2197 pMacHdr->fc.subType));
Jeff Johnson295189b2012-06-20 16:38:30 -07002198 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
2199 HAL_TXRX_FRM_802_11_MGMT,
2200 ANI_TXDIR_TODS,
2201 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
2202 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05302203 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
2204 psessionEntry->peSessionId,
2205 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07002206 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
2207 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002208 limLog( pMac, LOGE, FL("Failed to send Del TS (%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002209 nSirStatus );
2210 //Pkt will be freed up by the callback
2211 }
2212
2213} // End limSendDeltsReqActionFrame.
2214
2215void
2216limSendAssocReqMgmtFrame(tpAniSirGlobal pMac,
2217 tLimMlmAssocReq *pMlmAssocReq,
2218 tpPESession psessionEntry)
2219{
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002220 tDot11fAssocRequest *pFrm;
Jeff Johnson295189b2012-06-20 16:38:30 -07002221 tANI_U16 caps;
2222 tANI_U8 *pFrame;
2223 tSirRetStatus nSirStatus;
2224 tLimMlmAssocCnf mlmAssocCnf;
c_hpothubcd78652014-04-28 22:31:08 +05302225 tANI_U32 nPayload, nStatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07002226 tANI_U8 fQosEnabled, fWmeEnabled, fWsmEnabled;
2227 void *pPacket;
2228 eHalStatus halstatus;
2229 tANI_U16 nAddIELen;
2230 tANI_U8 *pAddIE;
2231 tANI_U8 *wpsIe = NULL;
2232#if defined WLAN_FEATURE_VOWIFI
2233 tANI_U8 PowerCapsPopulated = FALSE;
2234#endif
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05302235 tANI_U32 txFlag = 0;
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05302236 tpSirMacMgmtHdr pMacHdr;
Kalikinkar dhara205da782014-03-21 15:49:32 -07002237 tDot11fIEExtCap extractedExtCap;
2238 tANI_BOOLEAN extractedExtCapFlag = eANI_BOOLEAN_TRUE;
c_hpothubcd78652014-04-28 22:31:08 +05302239 tANI_U32 nBytes = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002240
2241 if(NULL == psessionEntry)
2242 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05302243 limLog(pMac, LOGE, FL("psessionEntry is NULL") );
Jeff Johnson295189b2012-06-20 16:38:30 -07002244 return;
2245 }
2246
Jeff Johnson295189b2012-06-20 16:38:30 -07002247 /* check this early to avoid unncessary operation */
2248 if(NULL == psessionEntry->pLimJoinReq)
2249 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05302250 limLog(pMac, LOGE, FL("psessionEntry->pLimJoinReq is NULL") );
Jeff Johnson295189b2012-06-20 16:38:30 -07002251 return;
2252 }
2253 nAddIELen = psessionEntry->pLimJoinReq->addIEAssoc.length;
2254 pAddIE = psessionEntry->pLimJoinReq->addIEAssoc.addIEdata;
2255
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302256 pFrm = vos_mem_malloc(sizeof(tDot11fAssocRequest));
2257 if ( NULL == pFrm )
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002258 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05302259 limLog(pMac, LOGE, FL("Unable to allocate memory") );
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002260 return;
2261 }
2262
2263
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302264 vos_mem_set( ( tANI_U8* )pFrm, sizeof( tDot11fAssocRequest ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07002265
Kalikinkar dhara205da782014-03-21 15:49:32 -07002266 vos_mem_set(( tANI_U8* )&extractedExtCap, sizeof( tDot11fIEExtCap ), 0);
2267 nSirStatus = limStripOffExtCapIEAndUpdateStruct(pMac, pAddIE,
2268 &nAddIELen,
2269 &extractedExtCap );
2270 if(eSIR_SUCCESS != nSirStatus )
2271 {
2272 extractedExtCapFlag = eANI_BOOLEAN_FALSE;
2273 limLog(pMac, LOG1,
2274 FL("Unable to Stripoff ExtCap IE from Assoc Req"));
2275 }
Leela Venkata Kiran Kumar Reddy Chirala2f9b5712014-05-06 00:09:42 -07002276 /* TODO:remove this code once driver provides the call back function
2277 * to supplicant for set_qos_map
2278 */
2279 else
2280 {
2281 if(extractedExtCap.interworkingService)
2282 {
2283 extractedExtCap.qosMap = 1;
2284 }
2285 }
Kalikinkar dhara205da782014-03-21 15:49:32 -07002286
Jeff Johnson295189b2012-06-20 16:38:30 -07002287 caps = pMlmAssocReq->capabilityInfo;
2288 if ( PROP_CAPABILITY_GET( 11EQOS, psessionEntry->limCurrentBssPropCap ) )
2289 ((tSirMacCapabilityInfo *) &caps)->qos = 0;
2290#if defined(FEATURE_WLAN_WAPI)
2291 /* CR: 262463 :
2292 According to WAPI standard:
2293 7.3.1.4 Capability Information field
2294 In WAPI, non-AP STAs within an ESS set the Privacy subfield to 0 in transmitted
2295 Association or Reassociation management frames. APs ignore the Privacy subfield within received Association and
2296 Reassociation management frames. */
2297 if ( psessionEntry->encryptType == eSIR_ED_WPI)
2298 ((tSirMacCapabilityInfo *) &caps)->privacy = 0;
2299#endif
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002300 swapBitField16(caps, ( tANI_U16* )&pFrm->Capabilities );
Jeff Johnson295189b2012-06-20 16:38:30 -07002301
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002302 pFrm->ListenInterval.interval = pMlmAssocReq->listenInterval;
2303 PopulateDot11fSSID2( pMac, &pFrm->SSID );
Jeff Johnson295189b2012-06-20 16:38:30 -07002304 PopulateDot11fSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002305 &pFrm->SuppRates,psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07002306
2307 fQosEnabled = ( psessionEntry->limQosEnabled) &&
2308 SIR_MAC_GET_QOS( psessionEntry->limCurrentBssCaps );
2309
2310 fWmeEnabled = ( psessionEntry->limWmeEnabled ) &&
2311 LIM_BSS_CAPS_GET( WME, psessionEntry->limCurrentBssQosCaps );
2312
2313 // We prefer .11e asociations:
2314 if ( fQosEnabled ) fWmeEnabled = false;
2315
2316 fWsmEnabled = ( psessionEntry->limWsmEnabled ) && fWmeEnabled &&
2317 LIM_BSS_CAPS_GET( WSM, psessionEntry->limCurrentBssQosCaps );
2318
2319 if ( psessionEntry->lim11hEnable &&
2320 psessionEntry->pLimJoinReq->spectrumMgtIndicator == eSIR_TRUE )
2321 {
2322#if defined WLAN_FEATURE_VOWIFI
2323 PowerCapsPopulated = TRUE;
2324
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002325 PopulateDot11fPowerCaps( pMac, &pFrm->PowerCaps, LIM_ASSOC,psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07002326#endif
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002327 PopulateDot11fSuppChannels( pMac, &pFrm->SuppChannels, LIM_ASSOC,psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07002328
2329 }
2330
2331#if defined WLAN_FEATURE_VOWIFI
2332 if( pMac->rrm.rrmPEContext.rrmEnable &&
2333 SIR_MAC_GET_RRM( psessionEntry->limCurrentBssCaps ) )
2334 {
2335 if (PowerCapsPopulated == FALSE)
2336 {
2337 PowerCapsPopulated = TRUE;
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002338 PopulateDot11fPowerCaps(pMac, &pFrm->PowerCaps, LIM_ASSOC, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07002339 }
2340 }
2341#endif
2342
2343 if ( fQosEnabled &&
2344 ( ! PROP_CAPABILITY_GET(11EQOS, psessionEntry->limCurrentBssPropCap)))
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002345 PopulateDot11fQOSCapsStation( pMac, &pFrm->QOSCapsStation );
Jeff Johnson295189b2012-06-20 16:38:30 -07002346
2347 PopulateDot11fExtSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002348 &pFrm->ExtSuppRates, psessionEntry );
Jeff Johnson295189b2012-06-20 16:38:30 -07002349
2350#if defined WLAN_FEATURE_VOWIFI
2351 if( pMac->rrm.rrmPEContext.rrmEnable &&
2352 SIR_MAC_GET_RRM( psessionEntry->limCurrentBssCaps ) )
2353 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002354 PopulateDot11fRRMIe( pMac, &pFrm->RRMEnabledCap, psessionEntry );
Jeff Johnson295189b2012-06-20 16:38:30 -07002355 }
2356#endif
2357 // The join request *should* contain zero or one of the WPA and RSN
2358 // IEs. The payload send along with the request is a
2359 // 'tSirSmeJoinReq'; the IE portion is held inside a 'tSirRSNie':
2360
2361 // typedef struct sSirRSNie
2362 // {
2363 // tANI_U16 length;
2364 // tANI_U8 rsnIEdata[SIR_MAC_MAX_IE_LENGTH+2];
2365 // } tSirRSNie, *tpSirRSNie;
2366
2367 // So, we should be able to make the following two calls harmlessly,
2368 // since they do nothing if they don't find the given IE in the
2369 // bytestream with which they're provided.
2370
2371 // The net effect of this will be to faithfully transmit whatever
2372 // security IE is in the join request.
2373
2374 // *However*, if we're associating for the purpose of WPS
2375 // enrollment, and we've been configured to indicate that by
2376 // eliding the WPA or RSN IE, we just skip this:
2377 if( nAddIELen && pAddIE )
2378 {
2379 wpsIe = limGetWscIEPtr (pMac, pAddIE, nAddIELen);
2380 }
2381 if ( NULL == wpsIe )
2382 {
2383 PopulateDot11fRSNOpaque( pMac, &( psessionEntry->pLimJoinReq->rsnIE ),
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002384 &pFrm->RSNOpaque );
Jeff Johnson295189b2012-06-20 16:38:30 -07002385 PopulateDot11fWPAOpaque( pMac, &( psessionEntry->pLimJoinReq->rsnIE ),
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002386 &pFrm->WPAOpaque );
Jeff Johnson295189b2012-06-20 16:38:30 -07002387#if defined(FEATURE_WLAN_WAPI)
2388 PopulateDot11fWAPIOpaque( pMac, &( psessionEntry->pLimJoinReq->rsnIE ),
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002389 &pFrm->WAPIOpaque );
Jeff Johnson295189b2012-06-20 16:38:30 -07002390#endif // defined(FEATURE_WLAN_WAPI)
2391 }
2392
2393 // include WME EDCA IE as well
2394 if ( fWmeEnabled )
2395 {
2396 if ( ! PROP_CAPABILITY_GET( WME, psessionEntry->limCurrentBssPropCap ) )
2397 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002398 PopulateDot11fWMMInfoStation( pMac, &pFrm->WMMInfoStation );
Jeff Johnson295189b2012-06-20 16:38:30 -07002399 }
2400
2401 if ( fWsmEnabled &&
2402 ( ! PROP_CAPABILITY_GET(WSM, psessionEntry->limCurrentBssPropCap )))
2403 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002404 PopulateDot11fWMMCaps( &pFrm->WMMCaps );
Jeff Johnson295189b2012-06-20 16:38:30 -07002405 }
2406 }
2407
2408 //Populate HT IEs, when operating in 11n or Taurus modes AND
2409 //when AP is also operating in 11n mode.
Jeff Johnsone7245742012-09-05 17:12:55 -07002410 if ( psessionEntry->htCapability &&
Jeff Johnson295189b2012-06-20 16:38:30 -07002411 pMac->lim.htCapabilityPresentInBeacon)
2412 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002413 PopulateDot11fHTCaps( pMac, psessionEntry, &pFrm->HTCaps );
Jeff Johnson295189b2012-06-20 16:38:30 -07002414#ifdef DISABLE_GF_FOR_INTEROP
2415
2416 /*
2417 * To resolve the interop problem with Broadcom AP,
2418 * where TQ STA could not pass traffic with GF enabled,
2419 * TQ STA will do Greenfield only with TQ AP, for
2420 * everybody else it will be turned off.
2421 */
2422
2423 if( (psessionEntry->pLimJoinReq != NULL) && (!psessionEntry->pLimJoinReq->bssDescription.aniIndicator))
2424 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05302425 limLog( pMac, LOG1, FL("Sending Assoc Req to Non-TQ AP,"
2426 " Turning off Greenfield"));
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002427 pFrm->HTCaps.greenField = WNI_CFG_GREENFIELD_CAPABILITY_DISABLE;
Jeff Johnson295189b2012-06-20 16:38:30 -07002428 }
2429#endif
2430
2431 }
Jeff Johnsone7245742012-09-05 17:12:55 -07002432#ifdef WLAN_FEATURE_11AC
2433 if ( psessionEntry->vhtCapability &&
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07002434 psessionEntry->vhtCapabilityPresentInBeacon)
Jeff Johnsone7245742012-09-05 17:12:55 -07002435 {
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07002436 limLog( pMac, LOG1, FL("Populate VHT IEs in Assoc Request"));
Abhishek Singh6d5d29c2014-07-03 14:25:22 +05302437 PopulateDot11fVHTCaps( pMac, &pFrm->VHTCaps, eSIR_FALSE );
Jeff Johnsone7245742012-09-05 17:12:55 -07002438 }
2439#endif
Sandeep Puligilla60342762014-01-30 21:05:37 +05302440 PopulateDot11fExtCap( pMac, &pFrm->ExtCap, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07002441
2442#if defined WLAN_FEATURE_VOWIFI_11R
2443 if (psessionEntry->pLimJoinReq->is11Rconnection)
2444 {
2445#if defined WLAN_FEATURE_VOWIFI_11R_DEBUG
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002446 limLog( pMac, LOG1, FL("mdie = %02x %02x %02x"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002447 (unsigned int)psessionEntry->pLimJoinReq->bssDescription.mdie[0],
2448 (unsigned int)psessionEntry->pLimJoinReq->bssDescription.mdie[1],
2449 (unsigned int)psessionEntry->pLimJoinReq->bssDescription.mdie[2]);
2450#endif
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302451 PopulateMDIE( pMac, &pFrm->MobilityDomain,
2452 psessionEntry->pLimJoinReq->bssDescription.mdie);
Jeff Johnson295189b2012-06-20 16:38:30 -07002453 }
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302454 else
Jeff Johnson295189b2012-06-20 16:38:30 -07002455 {
2456 // No 11r IEs dont send any MDIE
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302457 limLog( pMac, LOG1, FL("MDIE not present"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002458 }
2459#endif
2460
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002461#ifdef FEATURE_WLAN_ESE
2462 /* For ESE Associations fill the ESE IEs */
2463 if (psessionEntry->isESEconnection &&
2464 psessionEntry->pLimJoinReq->isESEFeatureIniEnabled)
Jeff Johnson295189b2012-06-20 16:38:30 -07002465 {
Varun Reddy Yeturu30779b42013-04-09 09:57:16 -07002466#ifndef FEATURE_DISABLE_RM
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002467 PopulateDot11fESERadMgmtCap(&pFrm->ESERadMgmtCap);
Varun Reddy Yeturu30779b42013-04-09 09:57:16 -07002468#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002469 PopulateDot11fESEVersion(&pFrm->ESEVersion);
Jeff Johnson295189b2012-06-20 16:38:30 -07002470 }
2471#endif
2472
c_hpothubcd78652014-04-28 22:31:08 +05302473 /* merge the ExtCap struct*/
2474 if (extractedExtCapFlag && extractedExtCap.present)
2475 {
2476 limMergeExtCapIEStruct(&pFrm->ExtCap, &extractedExtCap);
2477 }
2478
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002479 nStatus = dot11fGetPackedAssocRequestSize( pMac, pFrm, &nPayload );
Jeff Johnson295189b2012-06-20 16:38:30 -07002480 if ( DOT11F_FAILED( nStatus ) )
2481 {
2482 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002483 "or an Association Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002484 nStatus );
2485 // We'll fall back on the worst case scenario:
2486 nPayload = sizeof( tDot11fAssocRequest );
2487 }
2488 else if ( DOT11F_WARNED( nStatus ) )
2489 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08002490 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07002491 "the packed size for an Association Re "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002492 "quest(0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07002493 }
2494
2495 nBytes = nPayload + sizeof( tSirMacMgmtHdr ) + nAddIELen;
2496
2497 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
2498 ( tANI_U16 )nBytes, ( void** ) &pFrame,
2499 ( void** ) &pPacket );
2500 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
2501 {
2502 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for an As"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002503 "sociation Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07002504
2505 psessionEntry->limMlmState = psessionEntry->limPrevMlmState;
Jeff Johnsone7245742012-09-05 17:12:55 -07002506 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07002507
2508
2509 /* Update PE session id*/
2510 mlmAssocCnf.sessionId = psessionEntry->peSessionId;
2511
2512 mlmAssocCnf.resultCode = eSIR_SME_RESOURCES_UNAVAILABLE;
2513
2514 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
2515 ( void* ) pFrame, ( void* ) pPacket );
2516
2517 limPostSmeMessage( pMac, LIM_MLM_ASSOC_CNF,
2518 ( tANI_U32* ) &mlmAssocCnf);
2519
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302520 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -07002521 return;
2522 }
2523
2524 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302525 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07002526
2527 // Next, we fill out the buffer descriptor:
2528 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
2529 SIR_MAC_MGMT_ASSOC_REQ, psessionEntry->bssId,psessionEntry->selfMacAddr);
2530 if ( eSIR_SUCCESS != nSirStatus )
2531 {
2532 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002533 "tor for an Association Request (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002534 nSirStatus );
2535 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302536 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -07002537 return;
2538 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002539
Abhishek Singh57aebef2014-02-03 18:47:44 +05302540 // That done, pack the Assoc Request:
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002541 nStatus = dot11fPackAssocRequest( pMac, pFrm, pFrame +
Jeff Johnson295189b2012-06-20 16:38:30 -07002542 sizeof(tSirMacMgmtHdr),
2543 nPayload, &nPayload );
2544 if ( DOT11F_FAILED( nStatus ) )
2545 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05302546 limLog( pMac, LOGE, FL("Failed to pack a Assoc Request (0x%0"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002547 "8x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002548 nStatus );
2549 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
2550 ( void* ) pFrame, ( void* ) pPacket );
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302551 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -07002552 return;
2553 }
2554 else if ( DOT11F_WARNED( nStatus ) )
2555 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05302556 limLog( pMac, LOGW, FL("There were warnings while packing a Assoc"
2557 "Request (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07002558 }
2559
2560 PELOG1(limLog( pMac, LOG1, FL("*** Sending Association Request length %d"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002561 "to "),
Jeff Johnson295189b2012-06-20 16:38:30 -07002562 nBytes );)
2563 // limPrintMacAddr( pMac, bssid, LOG1 );
2564
2565 if( psessionEntry->assocReq != NULL )
2566 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302567 vos_mem_free(psessionEntry->assocReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07002568 psessionEntry->assocReq = NULL;
2569 }
2570
2571 if( nAddIELen )
2572 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302573 vos_mem_copy( pFrame + sizeof(tSirMacMgmtHdr) + nPayload,
2574 pAddIE,
2575 nAddIELen );
Jeff Johnson295189b2012-06-20 16:38:30 -07002576 nPayload += nAddIELen;
2577 }
2578
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302579 psessionEntry->assocReq = vos_mem_malloc(nPayload);
2580 if ( NULL == psessionEntry->assocReq )
Jeff Johnson295189b2012-06-20 16:38:30 -07002581 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05302582 PELOGE(limLog(pMac, LOGE, FL("Unable to allocate memory to store "
2583 "assoc request"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07002584 }
2585 else
2586 {
2587 //Store the Assoc request. This is sent to csr/hdd in join cnf response.
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302588 vos_mem_copy( psessionEntry->assocReq, pFrame + sizeof(tSirMacMgmtHdr), nPayload);
Jeff Johnson295189b2012-06-20 16:38:30 -07002589 psessionEntry->assocReqLen = nPayload;
2590 }
2591
2592 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07002593 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
2594 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07002595 )
2596 {
2597 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
2598 }
2599
Ganesh K08bce952012-12-13 15:04:41 -08002600 if(psessionEntry->pePersona == VOS_P2P_CLIENT_MODE)
2601 {
2602 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
2603 }
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05302604
2605 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
Agarwal Ashisha8e81f52014-04-02 01:59:52 +05302606 limLog( pMac, LOG1, FL("Sending Assoc req over WQ5 to "MAC_ADDRESS_STR
2607 " From " MAC_ADDRESS_STR),MAC_ADDR_ARRAY(pMacHdr->da),
2608 MAC_ADDR_ARRAY(psessionEntry->selfMacAddr));
2609 txFlag |= HAL_USE_FW_IN_TX_PATH;
2610
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05302611 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
2612 psessionEntry->peSessionId,
2613 pMacHdr->fc.subType));
Katya Nigam63902932014-06-26 19:04:23 +05302614
2615 // enable caching
2616 WLANTL_EnableCaching(psessionEntry->staId);
2617
Masti, Narayanraddi67ea5912015-01-08 12:34:05 +05302618 if( ( psessionEntry->is11Gonly == true ) &&
2619 ( !IS_BROADCAST_MAC(pMlmAssocReq->peerMacAddr) ) ){
2620 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
2621 }
2622
Jeff Johnson295189b2012-06-20 16:38:30 -07002623 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) (sizeof(tSirMacMgmtHdr) + nPayload),
2624 HAL_TXRX_FRM_802_11_MGMT,
2625 ANI_TXDIR_TODS,
2626 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
2627 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05302628 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
2629 psessionEntry->peSessionId,
2630 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07002631 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
2632 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002633 limLog( pMac, LOGE, FL("Failed to send Association Request (%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002634 halstatus );
2635 //Pkt will be freed up by the callback
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302636 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -07002637 return;
2638 }
2639
2640 // Free up buffer allocated for mlmAssocReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302641 vos_mem_free(pMlmAssocReq);
Leela Venkata Kiran Kumar Reddy Chiralad6c0fe22013-12-11 19:10:50 -08002642 pMlmAssocReq = NULL;
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302643 vos_mem_free(pFrm);
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002644 return;
Jeff Johnson295189b2012-06-20 16:38:30 -07002645} // End limSendAssocReqMgmtFrame
2646
2647
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002648#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07002649/*------------------------------------------------------------------------------------
2650 *
2651 * Send Reassoc Req with FTIEs.
2652 *
2653 *-----------------------------------------------------------------------------------
2654 */
2655void
2656limSendReassocReqWithFTIEsMgmtFrame(tpAniSirGlobal pMac,
2657 tLimMlmReassocReq *pMlmReassocReq,tpPESession psessionEntry)
2658{
2659 static tDot11fReAssocRequest frm;
2660 tANI_U16 caps;
2661 tANI_U8 *pFrame;
2662 tSirRetStatus nSirStatus;
2663 tANI_U32 nBytes, nPayload, nStatus;
2664 tANI_U8 fQosEnabled, fWmeEnabled, fWsmEnabled;
2665 void *pPacket;
2666 eHalStatus halstatus;
2667#if defined WLAN_FEATURE_VOWIFI
2668 tANI_U8 PowerCapsPopulated = FALSE;
2669#endif
2670 tANI_U16 ft_ies_length = 0;
2671 tANI_U8 *pBody;
2672 tANI_U16 nAddIELen;
2673 tANI_U8 *pAddIE;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002674#if defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07002675 tANI_U8 *wpsIe = NULL;
2676#endif
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05302677 tANI_U32 txFlag = 0;
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05302678 tpSirMacMgmtHdr pMacHdr;
Jeff Johnson295189b2012-06-20 16:38:30 -07002679
2680 if (NULL == psessionEntry)
2681 {
2682 return;
2683 }
2684
Jeff Johnson295189b2012-06-20 16:38:30 -07002685 /* check this early to avoid unncessary operation */
2686 if(NULL == psessionEntry->pLimReAssocReq)
2687 {
2688 return;
2689 }
2690 nAddIELen = psessionEntry->pLimReAssocReq->addIEAssoc.length;
2691 pAddIE = psessionEntry->pLimReAssocReq->addIEAssoc.addIEdata;
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08002692 limLog( pMac, LOG1, FL("limSendReassocReqWithFTIEsMgmtFrame received in "
2693 "state (%d)."), psessionEntry->limMlmState);
Jeff Johnson295189b2012-06-20 16:38:30 -07002694
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302695 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07002696
2697 caps = pMlmReassocReq->capabilityInfo;
2698 if (PROP_CAPABILITY_GET(11EQOS, psessionEntry->limReassocBssPropCap))
2699 ((tSirMacCapabilityInfo *) &caps)->qos = 0;
2700#if defined(FEATURE_WLAN_WAPI)
2701 /* CR: 262463 :
2702 According to WAPI standard:
2703 7.3.1.4 Capability Information field
2704 In WAPI, non-AP STAs within an ESS set the Privacy subfield to 0 in transmitted
2705 Association or Reassociation management frames. APs ignore the Privacy subfield within received Association and
2706 Reassociation management frames. */
2707 if ( psessionEntry->encryptType == eSIR_ED_WPI)
2708 ((tSirMacCapabilityInfo *) &caps)->privacy = 0;
2709#endif
2710 swapBitField16(caps, ( tANI_U16* )&frm.Capabilities );
2711
2712 frm.ListenInterval.interval = pMlmReassocReq->listenInterval;
2713
2714 // Get the old bssid of the older AP.
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302715 vos_mem_copy( ( tANI_U8* )frm.CurrentAPAddress.mac,
Jeff Johnson295189b2012-06-20 16:38:30 -07002716 pMac->ft.ftPEContext.pFTPreAuthReq->currbssId, 6);
2717
2718 PopulateDot11fSSID2( pMac, &frm.SSID );
2719 PopulateDot11fSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
2720 &frm.SuppRates,psessionEntry);
2721
2722 fQosEnabled = ( psessionEntry->limQosEnabled) &&
2723 SIR_MAC_GET_QOS( psessionEntry->limReassocBssCaps );
2724
2725 fWmeEnabled = ( psessionEntry->limWmeEnabled ) &&
2726 LIM_BSS_CAPS_GET( WME, psessionEntry->limReassocBssQosCaps );
2727
2728 fWsmEnabled = ( psessionEntry->limWsmEnabled ) && fWmeEnabled &&
2729 LIM_BSS_CAPS_GET( WSM, psessionEntry->limReassocBssQosCaps );
2730
2731 if ( psessionEntry->lim11hEnable &&
2732 psessionEntry->pLimReAssocReq->spectrumMgtIndicator == eSIR_TRUE )
2733 {
2734#if defined WLAN_FEATURE_VOWIFI
2735 PowerCapsPopulated = TRUE;
2736
2737 PopulateDot11fPowerCaps( pMac, &frm.PowerCaps, LIM_REASSOC,psessionEntry);
2738 PopulateDot11fSuppChannels( pMac, &frm.SuppChannels, LIM_REASSOC,psessionEntry);
2739#endif
2740 }
2741
2742#if defined WLAN_FEATURE_VOWIFI
2743 if( pMac->rrm.rrmPEContext.rrmEnable &&
2744 SIR_MAC_GET_RRM( psessionEntry->limCurrentBssCaps ) )
2745 {
2746 if (PowerCapsPopulated == FALSE)
2747 {
2748 PowerCapsPopulated = TRUE;
2749 PopulateDot11fPowerCaps(pMac, &frm.PowerCaps, LIM_REASSOC, psessionEntry);
2750 }
2751 }
2752#endif
2753
2754 if ( fQosEnabled &&
2755 ( ! PROP_CAPABILITY_GET(11EQOS, psessionEntry->limReassocBssPropCap ) ))
2756 {
2757 PopulateDot11fQOSCapsStation( pMac, &frm.QOSCapsStation );
2758 }
2759
2760 PopulateDot11fExtSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
2761 &frm.ExtSuppRates, psessionEntry );
2762
2763#if defined WLAN_FEATURE_VOWIFI
2764 if( pMac->rrm.rrmPEContext.rrmEnable &&
2765 SIR_MAC_GET_RRM( psessionEntry->limReassocBssCaps ) )
2766 {
2767 PopulateDot11fRRMIe( pMac, &frm.RRMEnabledCap, psessionEntry );
2768 }
2769#endif
2770
2771 // Ideally this should be enabled for 11r also. But 11r does
2772 // not follow the usual norm of using the Opaque object
2773 // for rsnie and fties. Instead we just add
2774 // the rsnie and fties at the end of the pack routine for 11r.
2775 // This should ideally! be fixed.
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002776#if defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07002777 //
2778 // The join request *should* contain zero or one of the WPA and RSN
2779 // IEs. The payload send along with the request is a
2780 // 'tSirSmeJoinReq'; the IE portion is held inside a 'tSirRSNie':
2781
2782 // typedef struct sSirRSNie
2783 // {
2784 // tANI_U16 length;
2785 // tANI_U8 rsnIEdata[SIR_MAC_MAX_IE_LENGTH+2];
2786 // } tSirRSNie, *tpSirRSNie;
2787
2788 // So, we should be able to make the following two calls harmlessly,
2789 // since they do nothing if they don't find the given IE in the
2790 // bytestream with which they're provided.
2791
2792 // The net effect of this will be to faithfully transmit whatever
2793 // security IE is in the join request.
2794
2795 // *However*, if we're associating for the purpose of WPS
2796 // enrollment, and we've been configured to indicate that by
2797 // eliding the WPA or RSN IE, we just skip this:
2798 if (!psessionEntry->is11Rconnection)
2799 {
2800 if( nAddIELen && pAddIE )
2801 {
2802 wpsIe = limGetWscIEPtr(pMac, pAddIE, nAddIELen);
2803 }
2804 if ( NULL == wpsIe )
2805 {
2806 PopulateDot11fRSNOpaque( pMac, &( psessionEntry->pLimReAssocReq->rsnIE ),
2807 &frm.RSNOpaque );
2808 PopulateDot11fWPAOpaque( pMac, &( psessionEntry->pLimReAssocReq->rsnIE ),
2809 &frm.WPAOpaque );
2810 }
2811
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002812#ifdef FEATURE_WLAN_ESE
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302813 if (psessionEntry->pLimReAssocReq->cckmIE.length)
Jeff Johnson295189b2012-06-20 16:38:30 -07002814 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002815 PopulateDot11fESECckmOpaque( pMac, &( psessionEntry->pLimReAssocReq->cckmIE ),
2816 &frm.ESECckmOpaque );
Jeff Johnson295189b2012-06-20 16:38:30 -07002817 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002818#endif //FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07002819 }
2820
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002821#ifdef FEATURE_WLAN_ESE
2822 // For ESE Associations fill the ESE IEs
2823 if (psessionEntry->isESEconnection &&
2824 psessionEntry->pLimReAssocReq->isESEFeatureIniEnabled)
Jeff Johnson295189b2012-06-20 16:38:30 -07002825 {
Varun Reddy Yeturu30779b42013-04-09 09:57:16 -07002826#ifndef FEATURE_DISABLE_RM
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002827 PopulateDot11fESERadMgmtCap(&frm.ESERadMgmtCap);
Varun Reddy Yeturu30779b42013-04-09 09:57:16 -07002828#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002829 PopulateDot11fESEVersion(&frm.ESEVersion);
Jeff Johnson295189b2012-06-20 16:38:30 -07002830 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002831#endif //FEATURE_WLAN_ESE
2832#endif //FEATURE_WLAN_ESE || FEATURE_WLAN_LFR
Jeff Johnson295189b2012-06-20 16:38:30 -07002833
2834 // include WME EDCA IE as well
2835 if ( fWmeEnabled )
2836 {
2837 if ( ! PROP_CAPABILITY_GET( WME, psessionEntry->limReassocBssPropCap ) )
2838 {
2839 PopulateDot11fWMMInfoStation( pMac, &frm.WMMInfoStation );
2840 }
2841
2842 if ( fWsmEnabled &&
2843 ( ! PROP_CAPABILITY_GET(WSM, psessionEntry->limReassocBssPropCap )))
2844 {
2845 PopulateDot11fWMMCaps( &frm.WMMCaps );
2846 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002847#ifdef FEATURE_WLAN_ESE
2848 if (psessionEntry->isESEconnection)
Jeff Johnson295189b2012-06-20 16:38:30 -07002849 {
2850 PopulateDot11fReAssocTspec(pMac, &frm, psessionEntry);
2851
2852 // Populate the TSRS IE if TSPEC is included in the reassoc request
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002853 if (psessionEntry->pLimReAssocReq->eseTspecInfo.numTspecs)
Jeff Johnson295189b2012-06-20 16:38:30 -07002854 {
2855 tANI_U32 phyMode;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002856 tSirMacESETSRSIE tsrsIE;
Jeff Johnson295189b2012-06-20 16:38:30 -07002857 limGetPhyMode(pMac, &phyMode, psessionEntry);
2858
2859 tsrsIE.tsid = 0;
2860 if( phyMode == WNI_CFG_PHY_MODE_11G || phyMode == WNI_CFG_PHY_MODE_11A)
2861 {
2862 tsrsIE.rates[0] = TSRS_11AG_RATE_6MBPS;
2863 }
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302864 else
Jeff Johnson295189b2012-06-20 16:38:30 -07002865 {
2866 tsrsIE.rates[0] = TSRS_11B_RATE_5_5MBPS;
2867 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002868 PopulateDot11TSRSIE(pMac,&tsrsIE, &frm.ESETrafStrmRateSet, sizeof(tANI_U8));
Jeff Johnson295189b2012-06-20 16:38:30 -07002869 }
2870 }
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302871#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002872 }
2873
Jeff Johnsone7245742012-09-05 17:12:55 -07002874 if ( psessionEntry->htCapability &&
Jeff Johnson295189b2012-06-20 16:38:30 -07002875 pMac->lim.htCapabilityPresentInBeacon)
2876 {
Jeff Johnsone7245742012-09-05 17:12:55 -07002877 PopulateDot11fHTCaps( pMac, psessionEntry, &frm.HTCaps );
Jeff Johnson295189b2012-06-20 16:38:30 -07002878 }
2879
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08002880#if defined WLAN_FEATURE_VOWIFI_11R
Kanchanapally, Vidyullatha4f84f682014-04-29 20:40:34 +05302881 if ( psessionEntry->pLimReAssocReq->bssDescription.mdiePresent &&
2882 (pMac->ft.ftSmeContext.addMDIE == TRUE)
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002883#if defined FEATURE_WLAN_ESE
2884 && !psessionEntry->isESEconnection
Gopichand Nakkala0ac55062013-04-08 14:43:07 +05302885#endif
2886 )
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08002887 {
2888 PopulateMDIE( pMac, &frm.MobilityDomain, psessionEntry->pLimReAssocReq->bssDescription.mdie);
2889 }
2890#endif
2891
Chet Lanctotf19c1f62013-12-13 13:56:21 -08002892#ifdef WLAN_FEATURE_11AC
2893 if ( psessionEntry->vhtCapability &&
2894 psessionEntry->vhtCapabilityPresentInBeacon)
2895 {
2896 limLog( pMac, LOG1, FL("Populate VHT IEs in Re-Assoc Request"));
Abhishek Singh6d5d29c2014-07-03 14:25:22 +05302897 PopulateDot11fVHTCaps( pMac, &frm.VHTCaps, eSIR_FALSE );
Chet Lanctotf19c1f62013-12-13 13:56:21 -08002898 }
2899#endif
Sandeep Puligilla60342762014-01-30 21:05:37 +05302900 PopulateDot11fExtCap( pMac, &frm.ExtCap, psessionEntry);
Chet Lanctotf19c1f62013-12-13 13:56:21 -08002901
Jeff Johnson295189b2012-06-20 16:38:30 -07002902 nStatus = dot11fGetPackedReAssocRequestSize( pMac, &frm, &nPayload );
2903 if ( DOT11F_FAILED( nStatus ) )
2904 {
2905 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002906 "or a Re-Association Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002907 nStatus );
2908 // We'll fall back on the worst case scenario:
2909 nPayload = sizeof( tDot11fReAssocRequest );
2910 }
2911 else if ( DOT11F_WARNED( nStatus ) )
2912 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08002913 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07002914 "the packed size for a Re-Association Re "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002915 "quest(0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07002916 }
2917
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07002918 nBytes = nPayload + sizeof( tSirMacMgmtHdr ) + nAddIELen;
Jeff Johnson295189b2012-06-20 16:38:30 -07002919
2920#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08002921 limLog( pMac, LOG1, FL("FT IE Reassoc Req (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002922 pMac->ft.ftSmeContext.reassoc_ft_ies_length);
2923#endif
2924
2925#if defined WLAN_FEATURE_VOWIFI_11R
2926 if (psessionEntry->is11Rconnection)
2927 {
2928 ft_ies_length = pMac->ft.ftSmeContext.reassoc_ft_ies_length;
2929 }
2930#endif
2931
2932 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
2933 ( tANI_U16 )nBytes+ft_ies_length, ( void** ) &pFrame,
2934 ( void** ) &pPacket );
2935 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
2936 {
2937 psessionEntry->limMlmState = psessionEntry->limPrevMlmState;
Jeff Johnsone7245742012-09-05 17:12:55 -07002938 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07002939 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Re-As"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002940 "sociation Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07002941 goto end;
2942 }
2943
2944 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302945 vos_mem_set( pFrame, nBytes + ft_ies_length, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07002946
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002947#if defined WLAN_FEATURE_VOWIFI_11R_DEBUG || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08002948 limPrintMacAddr(pMac, psessionEntry->limReAssocbssId, LOG1);
Jeff Johnson295189b2012-06-20 16:38:30 -07002949#endif
2950 // Next, we fill out the buffer descriptor:
2951 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
2952 SIR_MAC_MGMT_REASSOC_REQ,
2953 psessionEntry->limReAssocbssId,psessionEntry->selfMacAddr);
2954 if ( eSIR_SUCCESS != nSirStatus )
2955 {
2956 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002957 "tor for an Association Request (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002958 nSirStatus );
2959 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
2960 goto end;
2961 }
2962
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05302963 pMacHdr = (tpSirMacMgmtHdr) pFrame;
Jeff Johnson295189b2012-06-20 16:38:30 -07002964 // That done, pack the ReAssoc Request:
2965 nStatus = dot11fPackReAssocRequest( pMac, &frm, pFrame +
2966 sizeof(tSirMacMgmtHdr),
2967 nPayload, &nPayload );
2968 if ( DOT11F_FAILED( nStatus ) )
2969 {
2970 limLog( pMac, LOGE, FL("Failed to pack a Re-Association Reque"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002971 "st (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002972 nStatus );
2973 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
2974 goto end;
2975 }
2976 else if ( DOT11F_WARNED( nStatus ) )
2977 {
2978 limLog( pMac, LOGW, FL("There were warnings while packing a R"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08002979 "e-Association Request (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07002980 }
2981
2982 PELOG3(limLog( pMac, LOG3,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002983 FL("*** Sending Re-Association Request length %d %d to "),
Jeff Johnson295189b2012-06-20 16:38:30 -07002984 nBytes, nPayload );)
2985 if( psessionEntry->assocReq != NULL )
2986 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302987 vos_mem_free(psessionEntry->assocReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07002988 psessionEntry->assocReq = NULL;
2989 }
2990
2991 if( nAddIELen )
2992 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302993 vos_mem_copy( pFrame + sizeof(tSirMacMgmtHdr) + nPayload,
2994 pAddIE,
2995 nAddIELen );
Jeff Johnson295189b2012-06-20 16:38:30 -07002996 nPayload += nAddIELen;
2997 }
2998
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302999 psessionEntry->assocReq = vos_mem_malloc(nPayload);
3000 if ( NULL == psessionEntry->assocReq )
Jeff Johnson295189b2012-06-20 16:38:30 -07003001 {
3002 PELOGE(limLog(pMac, LOGE, FL("Unable to allocate memory to store assoc request"));)
Jeff Johnson43971f52012-07-17 12:26:56 -07003003 }
3004 else
3005 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003006 //Store the Assoc request. This is sent to csr/hdd in join cnf response.
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303007 vos_mem_copy( psessionEntry->assocReq, pFrame + sizeof(tSirMacMgmtHdr), nPayload);
Jeff Johnson295189b2012-06-20 16:38:30 -07003008 psessionEntry->assocReqLen = nPayload;
Jeff Johnson43971f52012-07-17 12:26:56 -07003009 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003010
3011 if (psessionEntry->is11Rconnection)
3012 {
3013 {
3014 int i = 0;
3015
3016 pBody = pFrame + nBytes;
3017 for (i=0; i<ft_ies_length; i++)
3018 {
3019 *pBody = pMac->ft.ftSmeContext.reassoc_ft_ies[i];
3020 pBody++;
3021 }
3022 }
3023 }
3024
3025#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08003026 PELOGE(limLog(pMac, LOG1, FL("Re-assoc Req Frame is: "));
3027 sirDumpBuf(pMac, SIR_LIM_MODULE_ID, LOG1,
Jeff Johnson295189b2012-06-20 16:38:30 -07003028 (tANI_U8 *)pFrame,
3029 (nBytes + ft_ies_length));)
3030#endif
3031
3032
3033 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07003034 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
3035 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07003036 )
3037 {
3038 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
3039 }
3040
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07003041 if( NULL != psessionEntry->assocReq )
3042 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303043 vos_mem_free(psessionEntry->assocReq);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07003044 psessionEntry->assocReq = NULL;
3045 }
3046
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303047 psessionEntry->assocReq = vos_mem_malloc(ft_ies_length);
3048 if ( NULL == psessionEntry->assocReq )
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07003049 {
3050 PELOGE(limLog(pMac, LOGE, FL("Unable to allocate memory to store assoc request"));)
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08003051 psessionEntry->assocReqLen = 0;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07003052 }
3053 else
3054 {
3055 //Store the Assoc request. This is sent to csr/hdd in join cnf response.
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303056 vos_mem_copy( psessionEntry->assocReq, pMac->ft.ftSmeContext.reassoc_ft_ies,
3057 (ft_ies_length));
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07003058 psessionEntry->assocReqLen = (ft_ies_length);
3059 }
3060
3061
Mihir Shete63561c82014-08-23 16:58:07 +05303062 // Enable TL cahching in case of roaming
3063 WLANTL_EnableCaching(psessionEntry->staId);
3064
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05303065 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
3066 psessionEntry->peSessionId,
3067 pMacHdr->fc.subType));
Jeff Johnson295189b2012-06-20 16:38:30 -07003068 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) (nBytes + ft_ies_length),
3069 HAL_TXRX_FRM_802_11_MGMT,
3070 ANI_TXDIR_TODS,
3071 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
3072 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05303073 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
3074 psessionEntry->peSessionId,
3075 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07003076 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3077 {
3078 limLog( pMac, LOGE, FL("Failed to send Re-Association Request"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003079 "(%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07003080 nSirStatus );
3081 //Pkt will be freed up by the callback
3082 goto end;
3083 }
3084
3085end:
3086 // Free up buffer allocated for mlmAssocReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303087 vos_mem_free( pMlmReassocReq );
Jeff Johnson295189b2012-06-20 16:38:30 -07003088 psessionEntry->pLimMlmReassocReq = NULL;
3089
3090}
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -07003091
3092void limSendRetryReassocReqFrame(tpAniSirGlobal pMac,
3093 tLimMlmReassocReq *pMlmReassocReq,
3094 tpPESession psessionEntry)
3095{
3096 tLimMlmReassocCnf mlmReassocCnf; // keep sme
3097 tLimMlmReassocReq *pTmpMlmReassocReq = NULL;
Sachin Ahuja07a43012015-01-30 17:04:38 +05303098#ifdef FEATURE_WLAN_ESE
3099 tANI_U32 val=0;
3100#endif
3101 if (pMlmReassocReq == NULL)
3102 {
3103 limLog(pMac, LOGE,
3104 FL("Invalid pMlmReassocReq"));
3105 goto end;
3106 }
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -07003107 if(NULL == pTmpMlmReassocReq)
3108 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303109 pTmpMlmReassocReq = vos_mem_malloc(sizeof(tLimMlmReassocReq));
3110 if ( NULL == pTmpMlmReassocReq ) goto end;
3111 vos_mem_set( pTmpMlmReassocReq, sizeof(tLimMlmReassocReq), 0);
3112 vos_mem_copy( pTmpMlmReassocReq, pMlmReassocReq, sizeof(tLimMlmReassocReq));
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -07003113 }
3114
3115 // Prepare and send Reassociation request frame
3116 // start reassoc timer.
Sachin Ahuja07a43012015-01-30 17:04:38 +05303117#ifdef FEATURE_WLAN_ESE
3118 /*
3119 * In case of Ese Reassociation, change the reassoc timer
3120 * value.
3121 */
3122 val = pMlmReassocReq->reassocFailureTimeout;
3123 if (psessionEntry->isESEconnection)
3124 {
3125 val = val/LIM_MAX_REASSOC_RETRY_LIMIT;
3126 }
3127 if (tx_timer_deactivate(&pMac->lim.limTimers.gLimReassocFailureTimer) !=
3128 TX_SUCCESS)
3129 {
3130 limLog(pMac, LOGP,
3131 FL("unable to deactivate Reassoc failure timer"));
3132 }
3133 val = SYS_MS_TO_TICKS(val);
3134 if (tx_timer_change(&pMac->lim.limTimers.gLimReassocFailureTimer,
3135 val, 0) != TX_SUCCESS)
3136 {
3137 limLog(pMac, LOGP,
3138 FL("unable to change Reassociation failure timer"));
3139 }
3140#endif
3141
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -07003142 pMac->lim.limTimers.gLimReassocFailureTimer.sessionId = psessionEntry->peSessionId;
3143 // Start reassociation failure timer
Leela V Kiran Kumar Reddy Chiralac3b9d382013-01-31 20:49:53 -08003144 MTRACE(macTrace(pMac, TRACE_CODE_TIMER_ACTIVATE, psessionEntry->peSessionId, eLIM_REASSOC_FAIL_TIMER));
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -07003145 if (tx_timer_activate(&pMac->lim.limTimers.gLimReassocFailureTimer)
3146 != TX_SUCCESS)
3147 {
3148 // Could not start reassoc failure timer.
3149 // Log error
3150 limLog(pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003151 FL("could not start Reassociation failure timer"));
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -07003152 // Return Reassoc confirm with
3153 // Resources Unavailable
3154 mlmReassocCnf.resultCode = eSIR_SME_RESOURCES_UNAVAILABLE;
3155 mlmReassocCnf.protStatusCode = eSIR_MAC_UNSPEC_FAILURE_STATUS;
3156 goto end;
3157 }
3158
3159 limSendReassocReqWithFTIEsMgmtFrame(pMac, pTmpMlmReassocReq, psessionEntry);
3160 return;
3161
3162end:
3163 // Free up buffer allocated for reassocReq
3164 if (pMlmReassocReq != NULL)
3165 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303166 vos_mem_free(pMlmReassocReq);
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -07003167 pMlmReassocReq = NULL;
3168 }
3169 if (pTmpMlmReassocReq != NULL)
3170 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303171 vos_mem_free(pTmpMlmReassocReq);
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -07003172 pTmpMlmReassocReq = NULL;
3173 }
3174 mlmReassocCnf.resultCode = eSIR_SME_FT_REASSOC_FAILURE;
3175 mlmReassocCnf.protStatusCode = eSIR_MAC_UNSPEC_FAILURE_STATUS;
3176 /* Update PE sessio Id*/
3177 mlmReassocCnf.sessionId = psessionEntry->peSessionId;
3178
3179 limPostSmeMessage(pMac, LIM_MLM_REASSOC_CNF, (tANI_U32 *) &mlmReassocCnf);
3180}
3181
Jeff Johnson295189b2012-06-20 16:38:30 -07003182#endif /* WLAN_FEATURE_VOWIFI_11R */
3183
3184
3185void
3186limSendReassocReqMgmtFrame(tpAniSirGlobal pMac,
3187 tLimMlmReassocReq *pMlmReassocReq,tpPESession psessionEntry)
3188{
3189 static tDot11fReAssocRequest frm;
3190 tANI_U16 caps;
3191 tANI_U8 *pFrame;
3192 tSirRetStatus nSirStatus;
3193 tANI_U32 nBytes, nPayload, nStatus;
3194 tANI_U8 fQosEnabled, fWmeEnabled, fWsmEnabled;
3195 void *pPacket;
3196 eHalStatus halstatus;
3197 tANI_U16 nAddIELen;
3198 tANI_U8 *pAddIE;
3199 tANI_U8 *wpsIe = NULL;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05303200 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003201#if defined WLAN_FEATURE_VOWIFI
3202 tANI_U8 PowerCapsPopulated = FALSE;
3203#endif
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05303204 tpSirMacMgmtHdr pMacHdr;
Jeff Johnson295189b2012-06-20 16:38:30 -07003205
3206 if(NULL == psessionEntry)
3207 {
3208 return;
3209 }
3210
3211 /* check this early to avoid unncessary operation */
3212 if(NULL == psessionEntry->pLimReAssocReq)
3213 {
3214 return;
3215 }
3216 nAddIELen = psessionEntry->pLimReAssocReq->addIEAssoc.length;
3217 pAddIE = psessionEntry->pLimReAssocReq->addIEAssoc.addIEdata;
3218
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303219 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07003220
3221 caps = pMlmReassocReq->capabilityInfo;
3222 if (PROP_CAPABILITY_GET(11EQOS, psessionEntry->limReassocBssPropCap))
3223 ((tSirMacCapabilityInfo *) &caps)->qos = 0;
3224#if defined(FEATURE_WLAN_WAPI)
3225 /* CR: 262463 :
3226 According to WAPI standard:
3227 7.3.1.4 Capability Information field
3228 In WAPI, non-AP STAs within an ESS set the Privacy subfield to 0 in transmitted
3229 Association or Reassociation management frames. APs ignore the Privacy subfield within received Association and
3230 Reassociation management frames. */
3231 if ( psessionEntry->encryptType == eSIR_ED_WPI)
3232 ((tSirMacCapabilityInfo *) &caps)->privacy = 0;
3233#endif
3234 swapBitField16(caps, ( tANI_U16* )&frm.Capabilities );
3235
3236 frm.ListenInterval.interval = pMlmReassocReq->listenInterval;
3237
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303238 vos_mem_copy(( tANI_U8* )frm.CurrentAPAddress.mac,
3239 ( tANI_U8* )psessionEntry->bssId, 6 );
Jeff Johnson295189b2012-06-20 16:38:30 -07003240
3241 PopulateDot11fSSID2( pMac, &frm.SSID );
3242 PopulateDot11fSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
3243 &frm.SuppRates,psessionEntry);
3244
3245 fQosEnabled = ( psessionEntry->limQosEnabled ) &&
3246 SIR_MAC_GET_QOS( psessionEntry->limReassocBssCaps );
3247
3248 fWmeEnabled = ( psessionEntry->limWmeEnabled ) &&
3249 LIM_BSS_CAPS_GET( WME, psessionEntry->limReassocBssQosCaps );
3250
3251 fWsmEnabled = ( psessionEntry->limWsmEnabled ) && fWmeEnabled &&
3252 LIM_BSS_CAPS_GET( WSM, psessionEntry->limReassocBssQosCaps );
3253
3254
3255 if ( psessionEntry->lim11hEnable &&
3256 psessionEntry->pLimReAssocReq->spectrumMgtIndicator == eSIR_TRUE )
3257 {
3258#if defined WLAN_FEATURE_VOWIFI
3259 PowerCapsPopulated = TRUE;
3260 PopulateDot11fPowerCaps( pMac, &frm.PowerCaps, LIM_REASSOC,psessionEntry);
3261 PopulateDot11fSuppChannels( pMac, &frm.SuppChannels, LIM_REASSOC,psessionEntry);
3262#endif
3263 }
3264
3265#if defined WLAN_FEATURE_VOWIFI
3266 if( pMac->rrm.rrmPEContext.rrmEnable &&
3267 SIR_MAC_GET_RRM( psessionEntry->limCurrentBssCaps ) )
3268 {
3269 if (PowerCapsPopulated == FALSE)
3270 {
3271 PowerCapsPopulated = TRUE;
3272 PopulateDot11fPowerCaps(pMac, &frm.PowerCaps, LIM_REASSOC, psessionEntry);
3273 }
3274 }
3275#endif
3276
3277 if ( fQosEnabled &&
3278 ( ! PROP_CAPABILITY_GET(11EQOS, psessionEntry->limReassocBssPropCap ) ))
3279 {
3280 PopulateDot11fQOSCapsStation( pMac, &frm.QOSCapsStation );
3281 }
3282
3283 PopulateDot11fExtSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
3284 &frm.ExtSuppRates, psessionEntry );
3285
3286#if defined WLAN_FEATURE_VOWIFI
3287 if( pMac->rrm.rrmPEContext.rrmEnable &&
3288 SIR_MAC_GET_RRM( psessionEntry->limReassocBssCaps ) )
3289 {
3290 PopulateDot11fRRMIe( pMac, &frm.RRMEnabledCap, psessionEntry );
3291 }
3292#endif
3293 // The join request *should* contain zero or one of the WPA and RSN
3294 // IEs. The payload send along with the request is a
3295 // 'tSirSmeJoinReq'; the IE portion is held inside a 'tSirRSNie':
3296
3297 // typedef struct sSirRSNie
3298 // {
3299 // tANI_U16 length;
3300 // tANI_U8 rsnIEdata[SIR_MAC_MAX_IE_LENGTH+2];
3301 // } tSirRSNie, *tpSirRSNie;
3302
3303 // So, we should be able to make the following two calls harmlessly,
3304 // since they do nothing if they don't find the given IE in the
3305 // bytestream with which they're provided.
3306
3307 // The net effect of this will be to faithfully transmit whatever
3308 // security IE is in the join request.
3309
3310 // *However*, if we're associating for the purpose of WPS
3311 // enrollment, and we've been configured to indicate that by
3312 // eliding the WPA or RSN IE, we just skip this:
3313 if( nAddIELen && pAddIE )
3314 {
3315 wpsIe = limGetWscIEPtr(pMac, pAddIE, nAddIELen);
3316 }
3317 if ( NULL == wpsIe )
3318 {
3319 PopulateDot11fRSNOpaque( pMac, &( psessionEntry->pLimReAssocReq->rsnIE ),
3320 &frm.RSNOpaque );
3321 PopulateDot11fWPAOpaque( pMac, &( psessionEntry->pLimReAssocReq->rsnIE ),
3322 &frm.WPAOpaque );
3323#if defined(FEATURE_WLAN_WAPI)
3324 PopulateDot11fWAPIOpaque( pMac, &( psessionEntry->pLimReAssocReq->rsnIE ),
3325 &frm.WAPIOpaque );
3326#endif // defined(FEATURE_WLAN_WAPI)
3327 }
3328
3329 // include WME EDCA IE as well
3330 if ( fWmeEnabled )
3331 {
3332 if ( ! PROP_CAPABILITY_GET( WME, psessionEntry->limReassocBssPropCap ) )
3333 {
3334 PopulateDot11fWMMInfoStation( pMac, &frm.WMMInfoStation );
3335 }
3336
3337 if ( fWsmEnabled &&
3338 ( ! PROP_CAPABILITY_GET(WSM, psessionEntry->limReassocBssPropCap )))
3339 {
3340 PopulateDot11fWMMCaps( &frm.WMMCaps );
3341 }
3342 }
3343
Jeff Johnsone7245742012-09-05 17:12:55 -07003344 if ( psessionEntry->htCapability &&
Jeff Johnson295189b2012-06-20 16:38:30 -07003345 pMac->lim.htCapabilityPresentInBeacon)
3346 {
Jeff Johnsone7245742012-09-05 17:12:55 -07003347 PopulateDot11fHTCaps( pMac, psessionEntry, &frm.HTCaps );
Jeff Johnson295189b2012-06-20 16:38:30 -07003348 }
Jeff Johnsone7245742012-09-05 17:12:55 -07003349#ifdef WLAN_FEATURE_11AC
3350 if ( psessionEntry->vhtCapability &&
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07003351 psessionEntry->vhtCapabilityPresentInBeacon)
Jeff Johnsone7245742012-09-05 17:12:55 -07003352 {
Chet Lanctotf19c1f62013-12-13 13:56:21 -08003353 limLog( pMac, LOG1, FL("Populate VHT IEs in Re-Assoc Request"));
Abhishek Singh6d5d29c2014-07-03 14:25:22 +05303354 PopulateDot11fVHTCaps( pMac, &frm.VHTCaps, eSIR_FALSE );
Sandeep Puligilla60342762014-01-30 21:05:37 +05303355 PopulateDot11fExtCap( pMac, &frm.ExtCap, psessionEntry);
Jeff Johnsone7245742012-09-05 17:12:55 -07003356 }
3357#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003358
3359 nStatus = dot11fGetPackedReAssocRequestSize( pMac, &frm, &nPayload );
3360 if ( DOT11F_FAILED( nStatus ) )
3361 {
3362 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003363 "or a Re-Association Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003364 nStatus );
3365 // We'll fall back on the worst case scenario:
3366 nPayload = sizeof( tDot11fReAssocRequest );
3367 }
3368 else if ( DOT11F_WARNED( nStatus ) )
3369 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08003370 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07003371 "the packed size for a Re-Association Re "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003372 "quest(0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07003373 }
3374
3375 nBytes = nPayload + sizeof( tSirMacMgmtHdr ) + nAddIELen;
3376
3377 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
3378 ( tANI_U16 )nBytes, ( void** ) &pFrame,
3379 ( void** ) &pPacket );
3380 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3381 {
3382 psessionEntry->limMlmState = psessionEntry->limPrevMlmState;
Jeff Johnsone7245742012-09-05 17:12:55 -07003383 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07003384 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Re-As"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003385 "sociation Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07003386 goto end;
3387 }
3388
3389 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303390 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07003391
3392 // Next, we fill out the buffer descriptor:
3393 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
3394 SIR_MAC_MGMT_REASSOC_REQ,
3395 psessionEntry->limReAssocbssId,psessionEntry->selfMacAddr);
3396 if ( eSIR_SUCCESS != nSirStatus )
3397 {
3398 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003399 "tor for an Association Request (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003400 nSirStatus );
3401 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
3402 goto end;
3403 }
3404
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05303405 pMacHdr = (tpSirMacMgmtHdr) pFrame;
Jeff Johnson295189b2012-06-20 16:38:30 -07003406 // That done, pack the Probe Request:
3407 nStatus = dot11fPackReAssocRequest( pMac, &frm, pFrame +
3408 sizeof(tSirMacMgmtHdr),
3409 nPayload, &nPayload );
3410 if ( DOT11F_FAILED( nStatus ) )
3411 {
3412 limLog( pMac, LOGE, FL("Failed to pack a Re-Association Reque"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003413 "st (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003414 nStatus );
3415 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
3416 goto end;
3417 }
3418 else if ( DOT11F_WARNED( nStatus ) )
3419 {
3420 limLog( pMac, LOGW, FL("There were warnings while packing a R"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08003421 "e-Association Request (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07003422 }
3423
3424 PELOG1(limLog( pMac, LOG1, FL("*** Sending Re-Association Request length %d"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003425 "to "),
Jeff Johnson295189b2012-06-20 16:38:30 -07003426 nBytes );)
3427
3428 if( psessionEntry->assocReq != NULL )
3429 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303430 vos_mem_free(psessionEntry->assocReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07003431 psessionEntry->assocReq = NULL;
3432 }
3433
3434 if( nAddIELen )
3435 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303436 vos_mem_copy( pFrame + sizeof(tSirMacMgmtHdr) + nPayload,
3437 pAddIE,
3438 nAddIELen );
Jeff Johnson295189b2012-06-20 16:38:30 -07003439 nPayload += nAddIELen;
3440 }
3441
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303442 psessionEntry->assocReq = vos_mem_malloc(nPayload);
3443 if ( NULL == psessionEntry->assocReq )
Jeff Johnson295189b2012-06-20 16:38:30 -07003444 {
3445 PELOGE(limLog(pMac, LOGE, FL("Unable to allocate memory to store assoc request"));)
Jeff Johnson43971f52012-07-17 12:26:56 -07003446 }
3447 else
3448 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003449 //Store the Assoc request. This is sent to csr/hdd in join cnf response.
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303450 vos_mem_copy(psessionEntry->assocReq, pFrame + sizeof(tSirMacMgmtHdr), nPayload);
Jeff Johnson295189b2012-06-20 16:38:30 -07003451 psessionEntry->assocReqLen = nPayload;
Jeff Johnson43971f52012-07-17 12:26:56 -07003452 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003453
3454 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07003455 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
3456 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07003457 )
3458 {
3459 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
3460 }
3461
Gopichand Nakkalad3918dd2012-12-31 16:27:55 -08003462 if(psessionEntry->pePersona == VOS_P2P_CLIENT_MODE)
Ganesh K08bce952012-12-13 15:04:41 -08003463 {
3464 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
3465 }
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08003466
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05303467 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
3468 psessionEntry->peSessionId,
3469 pMacHdr->fc.subType));
Katya Nigam63902932014-06-26 19:04:23 +05303470
3471 // enable caching
3472 WLANTL_EnableCaching(psessionEntry->staId);
3473
Jeff Johnson295189b2012-06-20 16:38:30 -07003474 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) (sizeof(tSirMacMgmtHdr) + nPayload),
3475 HAL_TXRX_FRM_802_11_MGMT,
3476 ANI_TXDIR_TODS,
3477 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
3478 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05303479 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
3480 psessionEntry->peSessionId,
3481 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07003482 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3483 {
3484 limLog( pMac, LOGE, FL("Failed to send Re-Association Request"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003485 "(%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07003486 nSirStatus );
3487 //Pkt will be freed up by the callback
3488 goto end;
3489 }
3490
3491end:
3492 // Free up buffer allocated for mlmAssocReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303493 vos_mem_free( pMlmReassocReq );
Jeff Johnson295189b2012-06-20 16:38:30 -07003494 psessionEntry->pLimMlmReassocReq = NULL;
3495
3496} // limSendReassocReqMgmtFrame
3497
3498/**
3499 * \brief Send an Authentication frame
3500 *
3501 *
3502 * \param pMac Pointer to Global MAC structure
3503 *
3504 * \param pAuthFrameBody Pointer to Authentication frame structure that need
3505 * to be sent
3506 *
3507 * \param peerMacAddr MAC address of the peer entity to which Authentication
3508 * frame is destined
3509 *
3510 * \param wepBit Indicates whether wep bit to be set in FC while sending
3511 * Authentication frame3
3512 *
3513 *
3514 * This function is called by limProcessMlmMessages(). Authentication frame
3515 * is formatted and sent when this function is called.
3516 *
3517 *
3518 */
3519
3520void
3521limSendAuthMgmtFrame(tpAniSirGlobal pMac,
3522 tpSirMacAuthFrameBody pAuthFrameBody,
3523 tSirMacAddr peerMacAddr,
3524 tANI_U8 wepBit,
3525 tpPESession psessionEntry
3526 )
3527{
3528 tANI_U8 *pFrame, *pBody;
3529 tANI_U32 frameLen = 0, bodyLen = 0;
3530 tpSirMacMgmtHdr pMacHdr;
3531 tANI_U16 i;
3532 void *pPacket;
3533 eHalStatus halstatus;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05303534 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003535
3536 if(NULL == psessionEntry)
3537 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05303538 limLog(pMac, LOGE, FL("Error: psession Entry is NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003539 return;
3540 }
Abhishek Singh57aebef2014-02-03 18:47:44 +05303541
3542 limLog(pMac, LOG1,
3543 FL("Sending Auth seq# %d status %d (%d) to "MAC_ADDRESS_STR),
3544 pAuthFrameBody->authTransactionSeqNumber,
3545 pAuthFrameBody->authStatusCode,
3546 (pAuthFrameBody->authStatusCode == eSIR_MAC_SUCCESS_STATUS),
3547 MAC_ADDR_ARRAY(peerMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07003548 if (wepBit == LIM_WEP_IN_FC)
3549 {
3550 /// Auth frame3 to be sent with encrypted framebody
3551 /**
3552 * Allocate buffer for Authenticaton frame of size equal
3553 * to management frame header length plus 2 bytes each for
3554 * auth algorithm number, transaction number, status code,
3555 * 128 bytes for challenge text and 4 bytes each for
3556 * IV & ICV.
3557 */
3558
3559 frameLen = sizeof(tSirMacMgmtHdr) + LIM_ENCR_AUTH_BODY_LEN;
3560
3561 bodyLen = LIM_ENCR_AUTH_BODY_LEN;
3562 } // if (wepBit == LIM_WEP_IN_FC)
3563 else
3564 {
3565 switch (pAuthFrameBody->authTransactionSeqNumber)
3566 {
3567 case SIR_MAC_AUTH_FRAME_1:
3568 /**
3569 * Allocate buffer for Authenticaton frame of size
3570 * equal to management frame header length plus 2 bytes
3571 * each for auth algorithm number, transaction number
3572 * and status code.
3573 */
3574
3575 frameLen = sizeof(tSirMacMgmtHdr) +
3576 SIR_MAC_AUTH_CHALLENGE_OFFSET;
3577 bodyLen = SIR_MAC_AUTH_CHALLENGE_OFFSET;
3578
3579#if defined WLAN_FEATURE_VOWIFI_11R
Madan Mohan Koyyalamudi6a00a802012-11-28 16:12:11 -08003580 if (pAuthFrameBody->authAlgoNumber == eSIR_FT_AUTH)
3581 {
3582 if (0 != pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length)
Jeff Johnson295189b2012-06-20 16:38:30 -07003583 {
Madan Mohan Koyyalamudi6a00a802012-11-28 16:12:11 -08003584 frameLen += pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length;
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003585 limLog(pMac, LOG3, FL("Auth frame, FTIES length added=%d"),
Madan Mohan Koyyalamudi6a00a802012-11-28 16:12:11 -08003586 pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length);
Jeff Johnson295189b2012-06-20 16:38:30 -07003587 }
Madan Mohan Koyyalamudi6a00a802012-11-28 16:12:11 -08003588 else
3589 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05303590 limLog(pMac, LOG3, FL("Auth frame, Does not contain "
3591 "FTIES!!!"));
Madan Mohan Koyyalamudi6a00a802012-11-28 16:12:11 -08003592 frameLen += (2+SIR_MDIE_SIZE);
3593 }
3594 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003595#endif
3596 break;
3597
3598 case SIR_MAC_AUTH_FRAME_2:
3599 if ((pAuthFrameBody->authAlgoNumber == eSIR_OPEN_SYSTEM) ||
3600 ((pAuthFrameBody->authAlgoNumber == eSIR_SHARED_KEY) &&
3601 (pAuthFrameBody->authStatusCode != eSIR_MAC_SUCCESS_STATUS)))
3602 {
3603 /**
3604 * Allocate buffer for Authenticaton frame of size
3605 * equal to management frame header length plus
3606 * 2 bytes each for auth algorithm number,
3607 * transaction number and status code.
3608 */
3609
3610 frameLen = sizeof(tSirMacMgmtHdr) +
3611 SIR_MAC_AUTH_CHALLENGE_OFFSET;
3612 bodyLen = SIR_MAC_AUTH_CHALLENGE_OFFSET;
3613 }
3614 else
3615 {
3616 // Shared Key algorithm with challenge text
3617 // to be sent
3618 /**
3619 * Allocate buffer for Authenticaton frame of size
3620 * equal to management frame header length plus
3621 * 2 bytes each for auth algorithm number,
3622 * transaction number, status code and 128 bytes
3623 * for challenge text.
3624 */
3625
3626 frameLen = sizeof(tSirMacMgmtHdr) +
3627 sizeof(tSirMacAuthFrame);
3628 bodyLen = sizeof(tSirMacAuthFrameBody);
3629 }
3630
3631 break;
3632
3633 case SIR_MAC_AUTH_FRAME_3:
3634 /// Auth frame3 to be sent without encrypted framebody
3635 /**
3636 * Allocate buffer for Authenticaton frame of size equal
3637 * to management frame header length plus 2 bytes each
3638 * for auth algorithm number, transaction number and
3639 * status code.
3640 */
3641
3642 frameLen = sizeof(tSirMacMgmtHdr) +
3643 SIR_MAC_AUTH_CHALLENGE_OFFSET;
3644 bodyLen = SIR_MAC_AUTH_CHALLENGE_OFFSET;
3645
3646 break;
3647
3648 case SIR_MAC_AUTH_FRAME_4:
3649 /**
3650 * Allocate buffer for Authenticaton frame of size equal
3651 * to management frame header length plus 2 bytes each
3652 * for auth algorithm number, transaction number and
3653 * status code.
3654 */
3655
3656 frameLen = sizeof(tSirMacMgmtHdr) +
3657 SIR_MAC_AUTH_CHALLENGE_OFFSET;
3658 bodyLen = SIR_MAC_AUTH_CHALLENGE_OFFSET;
3659
3660 break;
3661 } // switch (pAuthFrameBody->authTransactionSeqNumber)
3662 } // end if (wepBit == LIM_WEP_IN_FC)
3663
3664
3665 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )frameLen, ( void** ) &pFrame, ( void** ) &pPacket );
3666
3667 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3668 {
3669 // Log error
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003670 limLog(pMac, LOGP, FL("call to bufAlloc failed for AUTH frame"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003671
3672 return;
3673 }
3674
3675 for (i = 0; i < frameLen; i++)
3676 pFrame[i] = 0;
3677
3678 // Prepare BD
3679 if (limPopulateMacHeader(pMac, pFrame, SIR_MAC_MGMT_FRAME,
3680 SIR_MAC_MGMT_AUTH, peerMacAddr,psessionEntry->selfMacAddr) != eSIR_SUCCESS)
3681 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05303682 limLog(pMac, LOGE, FL("call to limPopulateMacHeader failed for "
3683 "AUTH frame"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003684 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
3685 return;
3686 }
3687
3688 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
3689 pMacHdr->fc.wep = wepBit;
3690
3691 // Prepare BSSId
3692 if( (psessionEntry->limSystemRole == eLIM_AP_ROLE)|| (psessionEntry->limSystemRole == eLIM_BT_AMP_AP_ROLE) )
3693 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303694 vos_mem_copy( (tANI_U8 *) pMacHdr->bssId,
3695 (tANI_U8 *) psessionEntry->bssId,
3696 sizeof( tSirMacAddr ));
Jeff Johnson295189b2012-06-20 16:38:30 -07003697 }
3698
3699 /// Prepare Authentication frame body
3700 pBody = pFrame + sizeof(tSirMacMgmtHdr);
3701
3702 if (wepBit == LIM_WEP_IN_FC)
3703 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303704 vos_mem_copy(pBody, (tANI_U8 *) pAuthFrameBody, bodyLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07003705
Abhishek Singh3cbf6052014-12-15 16:46:42 +05303706 limLog(pMac, LOG1,
Abhishek Singh57aebef2014-02-03 18:47:44 +05303707 FL("*** Sending Auth seq# 3 status %d (%d) to"MAC_ADDRESS_STR),
Jeff Johnson295189b2012-06-20 16:38:30 -07003708 pAuthFrameBody->authStatusCode,
Abhishek Singh57aebef2014-02-03 18:47:44 +05303709 (pAuthFrameBody->authStatusCode == eSIR_MAC_SUCCESS_STATUS),
Abhishek Singh3cbf6052014-12-15 16:46:42 +05303710 MAC_ADDR_ARRAY(pMacHdr->da));
Jeff Johnson295189b2012-06-20 16:38:30 -07003711
Jeff Johnson295189b2012-06-20 16:38:30 -07003712 }
3713 else
3714 {
3715 *((tANI_U16 *)(pBody)) = sirSwapU16ifNeeded(pAuthFrameBody->authAlgoNumber);
3716 pBody += sizeof(tANI_U16);
3717 bodyLen -= sizeof(tANI_U16);
3718
3719 *((tANI_U16 *)(pBody)) = sirSwapU16ifNeeded(pAuthFrameBody->authTransactionSeqNumber);
3720 pBody += sizeof(tANI_U16);
3721 bodyLen -= sizeof(tANI_U16);
3722
3723 *((tANI_U16 *)(pBody)) = sirSwapU16ifNeeded(pAuthFrameBody->authStatusCode);
3724 pBody += sizeof(tANI_U16);
3725 bodyLen -= sizeof(tANI_U16);
Leela Venkata Kiran Kumar Reddy Chirala7d3fa552013-08-28 10:52:21 -07003726 if ( bodyLen <= (sizeof (pAuthFrameBody->type) +
3727 sizeof (pAuthFrameBody->length) +
3728 sizeof (pAuthFrameBody->challengeText)))
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303729 vos_mem_copy(pBody, (tANI_U8 *) &pAuthFrameBody->type, bodyLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07003730
3731#if defined WLAN_FEATURE_VOWIFI_11R
3732 if ((pAuthFrameBody->authAlgoNumber == eSIR_FT_AUTH) &&
3733 (pAuthFrameBody->authTransactionSeqNumber == SIR_MAC_AUTH_FRAME_1))
3734 {
3735
3736 {
3737 int i = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003738 if (pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length)
3739 {
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08003740#if defined WLAN_FEATURE_VOWIFI_11R_DEBUG
Srinivas Girigowdad63eb492014-02-06 12:21:47 -08003741 PELOG2(limLog(pMac, LOG2, FL("Auth1 Frame FTIE is: "));
3742 sirDumpBuf(pMac, SIR_LIM_MODULE_ID, LOG2,
Jeff Johnson295189b2012-06-20 16:38:30 -07003743 (tANI_U8 *)pBody,
3744 (pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length));)
Jeff Johnson295189b2012-06-20 16:38:30 -07003745#endif
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08003746 for (i=0; i<pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length; i++)
3747 {
Madan Mohan Koyyalamudi6a00a802012-11-28 16:12:11 -08003748 *pBody = pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies[i];
3749 pBody++;
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08003750 }
3751 }
3752 else
3753 {
3754 /* MDID attr is 54*/
3755 *pBody = 54;
Jeff Johnson295189b2012-06-20 16:38:30 -07003756 pBody++;
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08003757 *pBody = SIR_MDIE_SIZE;
3758 pBody++;
3759 for(i=0;i<SIR_MDIE_SIZE;i++)
3760 {
3761 *pBody = pMac->ft.ftPEContext.pFTPreAuthReq->pbssDescription->mdie[i];
3762 pBody++;
3763 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003764 }
3765 }
3766 }
3767#endif
3768
Abhishek Singh3cbf6052014-12-15 16:46:42 +05303769 limLog(pMac, LOG1,
Abhishek Singh57aebef2014-02-03 18:47:44 +05303770 FL("*** Sending Auth seq# %d status %d (%d) to "MAC_ADDRESS_STR),
Jeff Johnson295189b2012-06-20 16:38:30 -07003771 pAuthFrameBody->authTransactionSeqNumber,
3772 pAuthFrameBody->authStatusCode,
Abhishek Singh57aebef2014-02-03 18:47:44 +05303773 (pAuthFrameBody->authStatusCode == eSIR_MAC_SUCCESS_STATUS),
Abhishek Singh3cbf6052014-12-15 16:46:42 +05303774 MAC_ADDR_ARRAY(pMacHdr->da));
Jeff Johnson295189b2012-06-20 16:38:30 -07003775 }
3776 PELOG2(sirDumpBuf(pMac, SIR_LIM_MODULE_ID, LOG2, pFrame, frameLen);)
3777
3778 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07003779 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
3780 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003781#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05303782 || ((NULL != pMac->ft.ftPEContext.pFTPreAuthReq)
Jeff Johnsone7245742012-09-05 17:12:55 -07003783 && ( SIR_BAND_5_GHZ == limGetRFBand(pMac->ft.ftPEContext.pFTPreAuthReq->preAuthchannelNum)))
3784#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003785 )
3786 {
3787 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
3788 }
3789
Ganesh K08bce952012-12-13 15:04:41 -08003790 if(psessionEntry->pePersona == VOS_P2P_CLIENT_MODE)
3791 {
3792 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
3793 }
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08003794
Agarwal Ashisha8e81f52014-04-02 01:59:52 +05303795 limLog( pMac, LOG1, FL("Sending Auth Frame over WQ5 to "MAC_ADDRESS_STR
3796 " From " MAC_ADDRESS_STR),MAC_ADDR_ARRAY(pMacHdr->da),
3797 MAC_ADDR_ARRAY(psessionEntry->selfMacAddr));
3798
3799 txFlag |= HAL_USE_FW_IN_TX_PATH;
3800
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05303801 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
3802 psessionEntry->peSessionId,
3803 pMacHdr->fc.subType));
Masti, Narayanraddi67ea5912015-01-08 12:34:05 +05303804
3805 if( ( psessionEntry->is11Gonly == true ) &&
3806 ( !IS_BROADCAST_MAC(peerMacAddr) ) ){
3807 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
3808 }
3809
Jeff Johnson295189b2012-06-20 16:38:30 -07003810 /// Queue Authentication frame in high priority WQ
3811 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) frameLen,
3812 HAL_TXRX_FRM_802_11_MGMT,
3813 ANI_TXDIR_TODS,
3814 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
3815 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05303816 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
3817 psessionEntry->peSessionId,
3818 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07003819 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3820 {
3821 limLog(pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003822 FL("*** Could not send Auth frame, retCode=%X ***"),
Jeff Johnson295189b2012-06-20 16:38:30 -07003823 halstatus);
3824
3825 //Pkt will be freed up by the callback
3826 }
3827
3828 return;
3829} /*** end limSendAuthMgmtFrame() ***/
3830
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003831eHalStatus limSendDeauthCnf(tpAniSirGlobal pMac)
3832{
3833 tANI_U16 aid;
3834 tpDphHashNode pStaDs;
3835 tLimMlmDeauthReq *pMlmDeauthReq;
3836 tLimMlmDeauthCnf mlmDeauthCnf;
3837 tpPESession psessionEntry;
3838
3839 pMlmDeauthReq = pMac->lim.limDisassocDeauthCnfReq.pMlmDeauthReq;
3840 if (pMlmDeauthReq)
3841 {
3842 if (tx_timer_running(&pMac->lim.limTimers.gLimDeauthAckTimer))
3843 {
3844 limDeactivateAndChangeTimer(pMac, eLIM_DEAUTH_ACK_TIMER);
3845 }
3846
3847 if((psessionEntry = peFindSessionBySessionId(pMac, pMlmDeauthReq->sessionId))== NULL)
3848 {
3849
3850 PELOGE(limLog(pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003851 FL("session does not exist for given sessionId"));)
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003852 mlmDeauthCnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
3853 goto end;
3854 }
3855
3856 pStaDs = dphLookupHashEntry(pMac, pMlmDeauthReq->peerMacAddr, &aid, &psessionEntry->dph.dphHashTable);
3857 if (pStaDs == NULL)
3858 {
3859 mlmDeauthCnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
3860 goto end;
3861 }
3862
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003863 /// Receive path cleanup with dummy packet
3864 limCleanupRxPath(pMac, pStaDs,psessionEntry);
Abhishek Singhcf4590b2014-04-16 18:58:08 +05303865
3866#ifdef WLAN_FEATURE_VOWIFI_11R
Mukul Sharma0820d0e2014-11-11 19:49:02 +05303867 if ( psessionEntry->limSystemRole == eLIM_STA_ROLE )
Abhishek Singhcf4590b2014-04-16 18:58:08 +05303868 {
Mukul Sharma0820d0e2014-11-11 19:49:02 +05303869 PELOGE(limLog(pMac, LOG1,
3870 FL("FT Preauth SessionId %d Cleanup"
Abhishek Singhcf4590b2014-04-16 18:58:08 +05303871#ifdef FEATURE_WLAN_ESE
3872 " isESE %d"
3873#endif
3874#ifdef FEATURE_WLAN_LFR
3875 " isLFR %d"
3876#endif
3877 " is11r %d, Deauth reason %d Trigger = %d"),
Mukul Sharma0820d0e2014-11-11 19:49:02 +05303878 psessionEntry->peSessionId,
Abhishek Singhcf4590b2014-04-16 18:58:08 +05303879#ifdef FEATURE_WLAN_ESE
3880 psessionEntry->isESEconnection,
3881#endif
3882#ifdef FEATURE_WLAN_LFR
3883 psessionEntry->isFastRoamIniFeatureEnabled,
3884#endif
3885 psessionEntry->is11Rconnection,
3886 pMlmDeauthReq->reasonCode,
3887 pMlmDeauthReq->deauthTrigger););
Mukul Sharma0820d0e2014-11-11 19:49:02 +05303888
3889 limFTCleanup(pMac);
Abhishek Singhcf4590b2014-04-16 18:58:08 +05303890 }
3891#endif
3892
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003893 /// Free up buffer allocated for mlmDeauthReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303894 vos_mem_free(pMlmDeauthReq);
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003895 pMac->lim.limDisassocDeauthCnfReq.pMlmDeauthReq = NULL;
3896 }
3897 return eHAL_STATUS_SUCCESS;
3898end:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303899 vos_mem_copy( (tANI_U8 *) &mlmDeauthCnf.peerMacAddr,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003900 (tANI_U8 *) pMlmDeauthReq->peerMacAddr,
3901 sizeof(tSirMacAddr));
3902 mlmDeauthCnf.deauthTrigger = pMlmDeauthReq->deauthTrigger;
3903 mlmDeauthCnf.aid = pMlmDeauthReq->aid;
3904 mlmDeauthCnf.sessionId = pMlmDeauthReq->sessionId;
3905
3906 // Free up buffer allocated
3907 // for mlmDeauthReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303908 vos_mem_free(pMlmDeauthReq);
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003909
3910 limPostSmeMessage(pMac,
3911 LIM_MLM_DEAUTH_CNF,
3912 (tANI_U32 *) &mlmDeauthCnf);
3913 return eHAL_STATUS_SUCCESS;
3914}
3915
3916eHalStatus limSendDisassocCnf(tpAniSirGlobal pMac)
3917{
3918 tANI_U16 aid;
3919 tpDphHashNode pStaDs;
3920 tLimMlmDisassocCnf mlmDisassocCnf;
3921 tpPESession psessionEntry;
3922 tLimMlmDisassocReq *pMlmDisassocReq;
3923
3924 pMlmDisassocReq = pMac->lim.limDisassocDeauthCnfReq.pMlmDisassocReq;
3925 if (pMlmDisassocReq)
3926 {
3927 if (tx_timer_running(&pMac->lim.limTimers.gLimDisassocAckTimer))
3928 {
3929 limDeactivateAndChangeTimer(pMac, eLIM_DISASSOC_ACK_TIMER);
3930 }
3931
3932 if((psessionEntry = peFindSessionBySessionId(pMac, pMlmDisassocReq->sessionId))== NULL)
3933 {
3934
3935 PELOGE(limLog(pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003936 FL("session does not exist for given sessionId"));)
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003937 mlmDisassocCnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
3938 goto end;
3939 }
3940
3941 pStaDs = dphLookupHashEntry(pMac, pMlmDisassocReq->peerMacAddr, &aid, &psessionEntry->dph.dphHashTable);
3942 if (pStaDs == NULL)
3943 {
Sachin Ahuja2fea3d12014-12-18 17:31:31 +05303944 limLog(pMac, LOGE,
3945 FL("StaDs Null"));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003946 mlmDisassocCnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
3947 goto end;
3948 }
3949
3950 /// Receive path cleanup with dummy packet
3951 if(eSIR_SUCCESS != limCleanupRxPath(pMac, pStaDs, psessionEntry))
3952 {
3953 mlmDisassocCnf.resultCode = eSIR_SME_RESOURCES_UNAVAILABLE;
Sachin Ahuja2fea3d12014-12-18 17:31:31 +05303954 limLog(pMac, LOGE,
3955 FL("CleanupRxPath error"));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003956 goto end;
3957 }
3958
3959#ifdef WLAN_FEATURE_VOWIFI_11R
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08003960 if ( (psessionEntry->limSystemRole == eLIM_STA_ROLE ) &&
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05303961 (pMlmDisassocReq->reasonCode !=
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08003962 eSIR_MAC_DISASSOC_DUE_TO_FTHANDOFF_REASON))
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003963 {
Mukul Sharma0820d0e2014-11-11 19:49:02 +05303964 PELOGE(limLog(pMac, LOG1,
3965 FL("FT Preauth SessionId %d Cleanup"
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003966#ifdef FEATURE_WLAN_ESE
3967 " isESE %d"
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08003968#endif
3969#ifdef FEATURE_WLAN_LFR
3970 " isLFR %d"
3971#endif
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003972 " is11r %d reason %d"),
Mukul Sharma0820d0e2014-11-11 19:49:02 +05303973 psessionEntry->peSessionId,
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003974#ifdef FEATURE_WLAN_ESE
3975 psessionEntry->isESEconnection,
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08003976#endif
3977#ifdef FEATURE_WLAN_LFR
3978 psessionEntry->isFastRoamIniFeatureEnabled,
3979#endif
3980 psessionEntry->is11Rconnection,
3981 pMlmDisassocReq->reasonCode););
Mukul Sharma0820d0e2014-11-11 19:49:02 +05303982 limFTCleanup(pMac);
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003983 }
3984#endif
3985
3986 /// Free up buffer allocated for mlmDisassocReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303987 vos_mem_free(pMlmDisassocReq);
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003988 pMac->lim.limDisassocDeauthCnfReq.pMlmDisassocReq = NULL;
3989 return eHAL_STATUS_SUCCESS;
3990 }
3991 else
3992 {
3993 return eHAL_STATUS_SUCCESS;
3994 }
3995end:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303996 vos_mem_copy( (tANI_U8 *) &mlmDisassocCnf.peerMacAddr,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003997 (tANI_U8 *) pMlmDisassocReq->peerMacAddr,
3998 sizeof(tSirMacAddr));
3999 mlmDisassocCnf.aid = pMlmDisassocReq->aid;
4000 mlmDisassocCnf.disassocTrigger = pMlmDisassocReq->disassocTrigger;
4001
4002 /* Update PE session ID*/
4003 mlmDisassocCnf.sessionId = pMlmDisassocReq->sessionId;
4004
Madan Mohan Koyyalamudib7f5a672012-11-29 11:17:46 -08004005 if(pMlmDisassocReq != NULL)
4006 {
4007 /// Free up buffer allocated for mlmDisassocReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304008 vos_mem_free(pMlmDisassocReq);
Madan Mohan Koyyalamudib7f5a672012-11-29 11:17:46 -08004009 pMac->lim.limDisassocDeauthCnfReq.pMlmDisassocReq = NULL;
4010 }
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004011
4012 limPostSmeMessage(pMac,
4013 LIM_MLM_DISASSOC_CNF,
4014 (tANI_U32 *) &mlmDisassocCnf);
4015 return eHAL_STATUS_SUCCESS;
4016}
4017
4018eHalStatus limDisassocTxCompleteCnf(tpAniSirGlobal pMac, tANI_U32 txCompleteSuccess)
4019{
4020 return limSendDisassocCnf(pMac);
4021}
4022
4023eHalStatus limDeauthTxCompleteCnf(tpAniSirGlobal pMac, tANI_U32 txCompleteSuccess)
4024{
4025 return limSendDeauthCnf(pMac);
4026}
4027
Jeff Johnson295189b2012-06-20 16:38:30 -07004028/**
4029 * \brief This function is called to send Disassociate frame.
4030 *
4031 *
4032 * \param pMac Pointer to Global MAC structure
4033 *
4034 * \param nReason Indicates the reason that need to be sent in
4035 * Disassociation frame
4036 *
4037 * \param peerMacAddr MAC address of the STA to which Disassociation frame is
4038 * sent
4039 *
4040 *
4041 */
4042
4043void
4044limSendDisassocMgmtFrame(tpAniSirGlobal pMac,
4045 tANI_U16 nReason,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004046 tSirMacAddr peer,
4047 tpPESession psessionEntry,
4048 tANI_BOOLEAN waitForAck)
Jeff Johnson295189b2012-06-20 16:38:30 -07004049{
4050 tDot11fDisassociation frm;
4051 tANI_U8 *pFrame;
4052 tSirRetStatus nSirStatus;
4053 tpSirMacMgmtHdr pMacHdr;
4054 tANI_U32 nBytes, nPayload, nStatus;
4055 void *pPacket;
4056 eHalStatus halstatus;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304057 tANI_U32 txFlag = 0;
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004058 tANI_U32 val = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004059 if(NULL == psessionEntry)
4060 {
4061 return;
4062 }
4063
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304064 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004065
4066 frm.Reason.code = nReason;
4067
4068 nStatus = dot11fGetPackedDisassociationSize( pMac, &frm, &nPayload );
4069 if ( DOT11F_FAILED( nStatus ) )
4070 {
4071 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004072 "or a Disassociation (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004073 nStatus );
4074 // We'll fall back on the worst case scenario:
4075 nPayload = sizeof( tDot11fDisassociation );
4076 }
4077 else if ( DOT11F_WARNED( nStatus ) )
4078 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004079 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07004080 "the packed size for a Disassociation "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004081 "(0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004082 }
4083
4084 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4085
4086 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
4087 ( tANI_U16 )nBytes, ( void** ) &pFrame,
4088 ( void** ) &pPacket );
4089 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4090 {
4091 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Dis"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004092 "association."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07004093 return;
4094 }
4095
4096 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304097 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004098
4099 // Next, we fill out the buffer descriptor:
4100 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
4101 SIR_MAC_MGMT_DISASSOC, peer,psessionEntry->selfMacAddr);
4102 if ( eSIR_SUCCESS != nSirStatus )
4103 {
4104 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004105 "tor for a Disassociation (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004106 nSirStatus );
4107 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
4108 ( void* ) pFrame, ( void* ) pPacket );
4109 return; // just allocated...
4110 }
4111
4112 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
4113
4114 // Prepare the BSSID
4115 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
4116
Chet Lanctot186b5732013-03-18 10:26:30 -07004117#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07004118 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07004119#endif
4120
Jeff Johnson295189b2012-06-20 16:38:30 -07004121 nStatus = dot11fPackDisassociation( pMac, &frm, pFrame +
4122 sizeof(tSirMacMgmtHdr),
4123 nPayload, &nPayload );
4124 if ( DOT11F_FAILED( nStatus ) )
4125 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004126 limLog( pMac, LOGE, FL("Failed to pack a Disassociation (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004127 nStatus );
4128 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
4129 ( void* ) pFrame, ( void* ) pPacket );
4130 return; // allocated!
4131 }
4132 else if ( DOT11F_WARNED( nStatus ) )
4133 {
4134 limLog( pMac, LOGW, FL("There were warnings while packing a D"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004135 "isassociation (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004136 }
4137
Abhishek Singhcd09b562013-12-24 16:02:20 +05304138 limLog( pMac, LOG1, FL("***Sessionid %d Sending Disassociation frame with "
4139 "reason %u and waitForAck %d to "MAC_ADDRESS_STR" ,From "
4140 MAC_ADDRESS_STR), psessionEntry->peSessionId, nReason, waitForAck,
4141 MAC_ADDR_ARRAY(pMacHdr->da),
4142 MAC_ADDR_ARRAY(psessionEntry->selfMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07004143
4144 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07004145 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
4146 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07004147 )
4148 {
4149 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
4150 }
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08004151
Ganesh K08bce952012-12-13 15:04:41 -08004152 if((psessionEntry->pePersona == VOS_P2P_CLIENT_MODE) ||
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304153 (psessionEntry->pePersona == VOS_P2P_GO_MODE) ||
4154 (psessionEntry->pePersona == VOS_STA_SAP_MODE))
Ganesh K08bce952012-12-13 15:04:41 -08004155 {
4156 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
4157 }
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08004158
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304159 if( IS_FW_IN_TX_PATH_FEATURE_ENABLE )
4160 {
4161 /* This frame will be sent on air by firmware,
4162 which will ensure that this frame goes out
4163 even though DEL_STA is sent immediately */
4164 /* Without this for DEL_STA command there is
4165 risk of flushing frame in BTQM queue without
4166 sending on air */
Agarwal Ashisha8e81f52014-04-02 01:59:52 +05304167 limLog( pMac, LOG1, FL("Sending Disassoc Frame over WQ5 to "MAC_ADDRESS_STR
4168 " From " MAC_ADDRESS_STR),MAC_ADDR_ARRAY(pMacHdr->da),
4169 MAC_ADDR_ARRAY(psessionEntry->selfMacAddr));
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304170 txFlag |= HAL_USE_FW_IN_TX_PATH;
4171 }
4172
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004173 if (waitForAck)
Jeff Johnson295189b2012-06-20 16:38:30 -07004174 {
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304175 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
4176 psessionEntry->peSessionId,
4177 pMacHdr->fc.subType));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004178 // Queue Disassociation frame in high priority WQ
4179 /* get the duration from the request */
4180 halstatus = halTxFrameWithTxComplete( pMac, pPacket, ( tANI_U16 ) nBytes,
4181 HAL_TXRX_FRM_802_11_MGMT,
4182 ANI_TXDIR_TODS,
4183 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4184 limTxComplete, pFrame, limDisassocTxCompleteCnf,
4185 txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304186 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
4187 psessionEntry->peSessionId,
4188 halstatus));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004189 val = SYS_MS_TO_TICKS(LIM_DISASSOC_DEAUTH_ACK_TIMEOUT);
Jeff Johnson295189b2012-06-20 16:38:30 -07004190
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004191 if (tx_timer_change(
4192 &pMac->lim.limTimers.gLimDisassocAckTimer, val, 0)
4193 != TX_SUCCESS)
4194 {
4195 limLog(pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004196 FL("Unable to change Disassoc ack Timer val"));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004197 return;
4198 }
4199 else if(TX_SUCCESS != tx_timer_activate(
4200 &pMac->lim.limTimers.gLimDisassocAckTimer))
4201 {
4202 limLog(pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004203 FL("Unable to activate Disassoc ack Timer"));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004204 limDeactivateAndChangeTimer(pMac, eLIM_DISASSOC_ACK_TIMER);
4205 return;
4206 }
4207 }
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08004208 else
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004209 {
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304210 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
4211 psessionEntry->peSessionId,
4212 pMacHdr->fc.subType));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004213 // Queue Disassociation frame in high priority WQ
4214 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4215 HAL_TXRX_FRM_802_11_MGMT,
4216 ANI_TXDIR_TODS,
4217 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4218 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304219 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
4220 psessionEntry->peSessionId,
4221 halstatus));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004222 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4223 {
4224 limLog( pMac, LOGE, FL("Failed to send Disassociation "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004225 "(%X)!"),
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004226 nSirStatus );
4227 //Pkt will be freed up by the callback
4228 return;
4229 }
4230 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004231} // End limSendDisassocMgmtFrame.
4232
4233/**
4234 * \brief This function is called to send a Deauthenticate frame
4235 *
4236 *
4237 * \param pMac Pointer to global MAC structure
4238 *
4239 * \param nReason Indicates the reason that need to be sent in the
4240 * Deauthenticate frame
4241 *
4242 * \param peeer address of the STA to which the frame is to be sent
4243 *
4244 *
4245 */
4246
4247void
4248limSendDeauthMgmtFrame(tpAniSirGlobal pMac,
4249 tANI_U16 nReason,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004250 tSirMacAddr peer,
4251 tpPESession psessionEntry,
4252 tANI_BOOLEAN waitForAck)
Jeff Johnson295189b2012-06-20 16:38:30 -07004253{
4254 tDot11fDeAuth frm;
4255 tANI_U8 *pFrame;
4256 tSirRetStatus nSirStatus;
4257 tpSirMacMgmtHdr pMacHdr;
4258 tANI_U32 nBytes, nPayload, nStatus;
4259 void *pPacket;
4260 eHalStatus halstatus;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304261 tANI_U32 txFlag = 0;
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004262 tANI_U32 val = 0;
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08004263#ifdef FEATURE_WLAN_TDLS
4264 tANI_U16 aid;
4265 tpDphHashNode pStaDs;
4266#endif
4267
Jeff Johnson295189b2012-06-20 16:38:30 -07004268 if(NULL == psessionEntry)
4269 {
4270 return;
4271 }
4272
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304273 vos_mem_set( ( tANI_U8* ) &frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004274
4275 frm.Reason.code = nReason;
4276
4277 nStatus = dot11fGetPackedDeAuthSize( pMac, &frm, &nPayload );
4278 if ( DOT11F_FAILED( nStatus ) )
4279 {
4280 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004281 "or a De-Authentication (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004282 nStatus );
4283 // We'll fall back on the worst case scenario:
4284 nPayload = sizeof( tDot11fDeAuth );
4285 }
4286 else if ( DOT11F_WARNED( nStatus ) )
4287 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004288 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07004289 "the packed size for a De-Authentication "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004290 "(0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004291 }
4292
4293 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4294
4295 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
4296 ( tANI_U16 )nBytes, ( void** ) &pFrame,
4297 ( void** ) &pPacket );
4298 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4299 {
4300 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a De-"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004301 "Authentication."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07004302 return;
4303 }
4304
4305 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304306 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004307
4308 // Next, we fill out the buffer descriptor:
4309 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
4310 SIR_MAC_MGMT_DEAUTH, peer,psessionEntry->selfMacAddr);
4311 if ( eSIR_SUCCESS != nSirStatus )
4312 {
4313 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004314 "tor for a De-Authentication (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004315 nSirStatus );
4316 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
4317 ( void* ) pFrame, ( void* ) pPacket );
4318 return; // just allocated...
4319 }
4320
4321 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
4322
4323 // Prepare the BSSID
4324 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
4325
Chet Lanctot186b5732013-03-18 10:26:30 -07004326#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07004327 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07004328#endif
4329
Jeff Johnson295189b2012-06-20 16:38:30 -07004330 nStatus = dot11fPackDeAuth( pMac, &frm, pFrame +
4331 sizeof(tSirMacMgmtHdr),
4332 nPayload, &nPayload );
4333 if ( DOT11F_FAILED( nStatus ) )
4334 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004335 limLog( pMac, LOGE, FL("Failed to pack a DeAuthentication (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004336 nStatus );
4337 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
4338 ( void* ) pFrame, ( void* ) pPacket );
4339 return;
4340 }
4341 else if ( DOT11F_WARNED( nStatus ) )
4342 {
4343 limLog( pMac, LOGW, FL("There were warnings while packing a D"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004344 "e-Authentication (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004345 }
Abhishek Singhcd09b562013-12-24 16:02:20 +05304346 limLog( pMac, LOG1, FL("***Sessionid %d Sending Deauth frame with "
4347 "reason %u and waitForAck %d to "MAC_ADDRESS_STR" ,From "
4348 MAC_ADDRESS_STR), psessionEntry->peSessionId, nReason, waitForAck,
4349 MAC_ADDR_ARRAY(pMacHdr->da),
4350 MAC_ADDR_ARRAY(psessionEntry->selfMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07004351
4352 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07004353 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
4354 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07004355 )
4356 {
4357 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
4358 }
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08004359
Ganesh K08bce952012-12-13 15:04:41 -08004360 if((psessionEntry->pePersona == VOS_P2P_CLIENT_MODE) ||
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304361 (psessionEntry->pePersona == VOS_P2P_GO_MODE) ||
4362 (psessionEntry->pePersona == VOS_STA_SAP_MODE))
Ganesh K08bce952012-12-13 15:04:41 -08004363 {
4364 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
4365 }
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08004366
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304367 if( IS_FW_IN_TX_PATH_FEATURE_ENABLE )
4368 {
4369 /* This frame will be sent on air by firmware,
4370 which will ensure that this frame goes out
4371 even though DEL_STA is sent immediately */
4372 /* Without this for DEL_STA command there is
4373 risk of flushing frame in BTQM queue without
4374 sending on air */
Agarwal Ashisha8e81f52014-04-02 01:59:52 +05304375 limLog( pMac, LOG1, FL("Sending Deauth Frame over WQ5 to "MAC_ADDRESS_STR
4376 " From " MAC_ADDRESS_STR),MAC_ADDR_ARRAY(pMacHdr->da),
4377 MAC_ADDR_ARRAY(psessionEntry->selfMacAddr));
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304378 txFlag |= HAL_USE_FW_IN_TX_PATH;
4379 }
4380
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08004381#ifdef FEATURE_WLAN_TDLS
4382 pStaDs = dphLookupHashEntry(pMac, peer, &aid, &psessionEntry->dph.dphHashTable);
4383#endif
4384
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004385 if (waitForAck)
Jeff Johnson295189b2012-06-20 16:38:30 -07004386 {
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304387 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
4388 psessionEntry->peSessionId,
4389 pMacHdr->fc.subType));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004390 // Queue Disassociation frame in high priority WQ
4391 halstatus = halTxFrameWithTxComplete( pMac, pPacket, ( tANI_U16 ) nBytes,
4392 HAL_TXRX_FRM_802_11_MGMT,
4393 ANI_TXDIR_TODS,
4394 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4395 limTxComplete, pFrame, limDeauthTxCompleteCnf, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304396 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
4397 psessionEntry->peSessionId,
4398 halstatus));
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304399 if (!HAL_STATUS_SUCCESS(halstatus))
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004400 {
4401 limLog( pMac, LOGE, FL("Failed to send De-Authentication "
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304402 "(%X)!"),
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004403 nSirStatus );
Gopichand Nakkala4261ea52012-12-31 16:43:00 -08004404 //Pkt will be freed up by the callback limTxComplete
4405
4406 /*Call limProcessDeauthAckTimeout which will send
4407 * DeauthCnf for this frame
4408 */
4409 limProcessDeauthAckTimeout(pMac);
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004410 return;
4411 }
4412
4413 val = SYS_MS_TO_TICKS(LIM_DISASSOC_DEAUTH_ACK_TIMEOUT);
4414
4415 if (tx_timer_change(
4416 &pMac->lim.limTimers.gLimDeauthAckTimer, val, 0)
4417 != TX_SUCCESS)
4418 {
4419 limLog(pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004420 FL("Unable to change Deauth ack Timer val"));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004421 return;
4422 }
4423 else if(TX_SUCCESS != tx_timer_activate(
4424 &pMac->lim.limTimers.gLimDeauthAckTimer))
4425 {
4426 limLog(pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004427 FL("Unable to activate Deauth ack Timer"));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004428 limDeactivateAndChangeTimer(pMac, eLIM_DEAUTH_ACK_TIMER);
4429 return;
4430 }
4431 }
4432 else
4433 {
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304434 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
4435 psessionEntry->peSessionId,
4436 pMacHdr->fc.subType));
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08004437#ifdef FEATURE_WLAN_TDLS
4438 if ((NULL != pStaDs) && (STA_ENTRY_TDLS_PEER == pStaDs->staType))
4439 {
4440 // Queue Disassociation frame in high priority WQ
4441 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004442 HAL_TXRX_FRM_802_11_MGMT,
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08004443 ANI_TXDIR_IBSS,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004444 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4445 limTxComplete, pFrame, txFlag );
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08004446 }
4447 else
4448 {
4449#endif
4450 // Queue Disassociation frame in high priority WQ
4451 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4452 HAL_TXRX_FRM_802_11_MGMT,
4453 ANI_TXDIR_TODS,
4454 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4455 limTxComplete, pFrame, txFlag );
4456#ifdef FEATURE_WLAN_TDLS
4457 }
4458#endif
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304459 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
4460 psessionEntry->peSessionId,
4461 halstatus));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004462 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4463 {
4464 limLog( pMac, LOGE, FL("Failed to send De-Authentication "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004465 "(%X)!"),
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004466 nSirStatus );
4467 //Pkt will be freed up by the callback
4468 return;
4469 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004470 }
4471
4472} // End limSendDeauthMgmtFrame.
4473
4474
4475#ifdef ANI_SUPPORT_11H
4476/**
4477 * \brief Send a Measurement Report Action frame
4478 *
4479 *
4480 * \param pMac Pointer to the global MAC structure
4481 *
4482 * \param pMeasReqFrame Address of a tSirMacMeasReqActionFrame
4483 *
4484 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
4485 *
4486 *
4487 */
4488
4489tSirRetStatus
4490limSendMeasReportFrame(tpAniSirGlobal pMac,
4491 tpSirMacMeasReqActionFrame pMeasReqFrame,
4492 tSirMacAddr peer)
4493{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304494 tDot11fMeasurementReport frm;
4495 tANI_U8 *pFrame;
4496 tSirRetStatus nSirStatus;
4497 tpSirMacMgmtHdr pMacHdr;
4498 tANI_U32 nBytes, nPayload, nStatus, nCfg;
4499 void *pPacket;
4500 eHalStatus halstatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07004501
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304502 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004503
4504 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
4505 frm.Action.action = SIR_MAC_ACTION_MEASURE_REPORT_ID;
4506 frm.DialogToken.token = pMeasReqFrame->actionHeader.dialogToken;
4507
4508 switch ( pMeasReqFrame->measReqIE.measType )
4509 {
4510 case SIR_MAC_BASIC_MEASUREMENT_TYPE:
4511 nSirStatus =
4512 PopulateDot11fMeasurementReport0( pMac, pMeasReqFrame,
4513 &frm.MeasurementReport );
4514 break;
4515 case SIR_MAC_CCA_MEASUREMENT_TYPE:
4516 nSirStatus =
4517 PopulateDot11fMeasurementReport1( pMac, pMeasReqFrame,
4518 &frm.MeasurementReport );
4519 break;
4520 case SIR_MAC_RPI_MEASUREMENT_TYPE:
4521 nSirStatus =
4522 PopulateDot11fMeasurementReport2( pMac, pMeasReqFrame,
4523 &frm.MeasurementReport );
4524 break;
4525 default:
4526 limLog( pMac, LOGE, FL("Unknown measurement type %d in limSen"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004527 "dMeasReportFrame."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004528 pMeasReqFrame->measReqIE.measType );
4529 return eSIR_FAILURE;
4530 }
4531
4532 if ( eSIR_SUCCESS != nSirStatus ) return eSIR_FAILURE;
4533
4534 nStatus = dot11fGetPackedMeasurementReportSize( pMac, &frm, &nPayload );
4535 if ( DOT11F_FAILED( nStatus ) )
4536 {
4537 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004538 "or a Measurement Report (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004539 nStatus );
4540 // We'll fall back on the worst case scenario:
4541 nPayload = sizeof( tDot11fMeasurementReport );
4542 }
4543 else if ( DOT11F_WARNED( nStatus ) )
4544 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004545 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07004546 "the packed size for a Measurement Rep"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004547 "ort (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004548 }
4549
4550 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4551
4552 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
4553 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4554 {
4555 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a De-"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004556 "Authentication."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07004557 return eSIR_FAILURE;
4558 }
4559
4560 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304561 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004562
4563 // Next, we fill out the buffer descriptor:
4564 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
4565 SIR_MAC_MGMT_ACTION, peer);
4566 if ( eSIR_SUCCESS != nSirStatus )
4567 {
4568 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004569 "tor for a Measurement Report (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004570 nSirStatus );
4571 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4572 return eSIR_FAILURE; // just allocated...
4573 }
4574
4575 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
4576
4577 nCfg = 6;
4578 nSirStatus = wlan_cfgGetStr( pMac, WNI_CFG_BSSID, pMacHdr->bssId, &nCfg );
4579 if ( eSIR_SUCCESS != nSirStatus )
4580 {
4581 limLog( pMac, LOGE, FL("Failed to retrieve WNI_CFG_BSSID from"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004582 " CFG (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004583 nSirStatus );
4584 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4585 return eSIR_FAILURE; // just allocated...
4586 }
4587
Chet Lanctot186b5732013-03-18 10:26:30 -07004588#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07004589 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07004590#endif
4591
Jeff Johnson295189b2012-06-20 16:38:30 -07004592 nStatus = dot11fPackMeasurementReport( pMac, &frm, pFrame +
4593 sizeof(tSirMacMgmtHdr),
4594 nPayload, &nPayload );
4595 if ( DOT11F_FAILED( nStatus ) )
4596 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004597 limLog( pMac, LOGE, FL("Failed to pack a Measurement Report (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004598 nStatus );
4599 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4600 return eSIR_FAILURE; // allocated!
4601 }
4602 else if ( DOT11F_WARNED( nStatus ) )
4603 {
4604 limLog( pMac, LOGW, FL("There were warnings while packing a M"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004605 "easurement Report (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004606 }
4607
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304608 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
4609 ((psessionEntry)? psessionEntry->peSessionId : NO_SESSION),
4610 pMacHdr->fc.subType));
Jeff Johnson295189b2012-06-20 16:38:30 -07004611 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4612 HAL_TXRX_FRM_802_11_MGMT,
4613 ANI_TXDIR_TODS,
4614 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4615 limTxComplete, pFrame, 0 );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304616 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
4617 ((psessionEntry)? psessionEntry->peSessionId : NO_SESSION),
4618 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07004619 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4620 {
4621 limLog( pMac, LOGE, FL("Failed to send a Measurement Report "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004622 "(%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07004623 nSirStatus );
4624 //Pkt will be freed up by the callback
4625 return eSIR_FAILURE; // just allocated...
4626 }
4627
4628 return eSIR_SUCCESS;
4629
4630} // End limSendMeasReportFrame.
4631
4632
4633/**
4634 * \brief Send a TPC Request Action frame
4635 *
4636 *
4637 * \param pMac Pointer to the global MAC datastructure
4638 *
4639 * \param peer MAC address to which the frame should be sent
4640 *
4641 *
4642 */
4643
4644void
4645limSendTpcRequestFrame(tpAniSirGlobal pMac,
4646 tSirMacAddr peer)
4647{
4648 tDot11fTPCRequest frm;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304649 tANI_U8 *pFrame;
Jeff Johnson295189b2012-06-20 16:38:30 -07004650 tSirRetStatus nSirStatus;
4651 tpSirMacMgmtHdr pMacHdr;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304652 tANI_U32 nBytes, nPayload, nStatus, nCfg;
4653 void *pPacket;
4654 eHalStatus halstatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07004655
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304656 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004657
4658 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
4659 frm.Action.action = SIR_MAC_ACTION_TPC_REQUEST_ID;
4660 frm.DialogToken.token = 1;
4661 frm.TPCRequest.present = 1;
4662
4663 nStatus = dot11fGetPackedTPCRequestSize( pMac, &frm, &nPayload );
4664 if ( DOT11F_FAILED( nStatus ) )
4665 {
4666 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004667 "or a TPC Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004668 nStatus );
4669 // We'll fall back on the worst case scenario:
4670 nPayload = sizeof( tDot11fTPCRequest );
4671 }
4672 else if ( DOT11F_WARNED( nStatus ) )
4673 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004674 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07004675 "the packed size for a TPC Request (0x"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004676 "%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004677 }
4678
4679 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4680
4681 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
4682 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4683 {
4684 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a TPC"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004685 " Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07004686 return;
4687 }
4688
4689 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304690 vos_mem_set(pFrame, nBytes,0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004691
4692 // Next, we fill out the buffer descriptor:
4693 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
4694 SIR_MAC_MGMT_ACTION, peer);
4695 if ( eSIR_SUCCESS != nSirStatus )
4696 {
4697 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004698 "tor for a TPC Request (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004699 nSirStatus );
4700 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4701 return; // just allocated...
4702 }
4703
4704 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
4705
4706 nCfg = 6;
4707 nSirStatus = wlan_cfgGetStr( pMac, WNI_CFG_BSSID, pMacHdr->bssId, &nCfg );
4708 if ( eSIR_SUCCESS != nSirStatus )
4709 {
4710 limLog( pMac, LOGE, FL("Failed to retrieve WNI_CFG_BSSID from"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004711 " CFG (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004712 nSirStatus );
4713 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4714 return; // just allocated...
4715 }
4716
Chet Lanctot186b5732013-03-18 10:26:30 -07004717#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07004718 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07004719#endif
4720
Jeff Johnson295189b2012-06-20 16:38:30 -07004721 nStatus = dot11fPackTPCRequest( pMac, &frm, pFrame +
4722 sizeof(tSirMacMgmtHdr),
4723 nPayload, &nPayload );
4724 if ( DOT11F_FAILED( nStatus ) )
4725 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004726 limLog( pMac, LOGE, FL("Failed to pack a TPC Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004727 nStatus );
4728 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4729 return; // allocated!
4730 }
4731 else if ( DOT11F_WARNED( nStatus ) )
4732 {
4733 limLog( pMac, LOGW, FL("There were warnings while packing a T"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004734 "PC Request (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004735 }
4736
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304737 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
4738 ((psessionEntry)? psessionEntry->peSessionId : NO_SESSION),
4739 pMacHdr->fc.subType));
Jeff Johnson295189b2012-06-20 16:38:30 -07004740 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4741 HAL_TXRX_FRM_802_11_MGMT,
4742 ANI_TXDIR_TODS,
4743 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4744 limTxComplete, pFrame, 0 );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304745 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
4746 ((psessionEntry)? psessionEntry->peSessionId : NO_SESSION),
4747 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07004748 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4749 {
4750 limLog( pMac, LOGE, FL("Failed to send a TPC Request "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004751 "(%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07004752 nSirStatus );
4753 //Pkt will be freed up by the callback
4754 return;
4755 }
4756
4757} // End limSendTpcRequestFrame.
4758
4759
4760/**
4761 * \brief Send a TPC Report Action frame
4762 *
4763 *
4764 * \param pMac Pointer to the global MAC datastructure
4765 *
4766 * \param pTpcReqFrame Pointer to the received TPC Request
4767 *
4768 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
4769 *
4770 *
4771 */
4772
4773tSirRetStatus
4774limSendTpcReportFrame(tpAniSirGlobal pMac,
4775 tpSirMacTpcReqActionFrame pTpcReqFrame,
4776 tSirMacAddr peer)
4777{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304778 tDot11fTPCReport frm;
4779 tANI_U8 *pFrame;
4780 tSirRetStatus nSirStatus;
4781 tpSirMacMgmtHdr pMacHdr;
4782 tANI_U32 nBytes, nPayload, nStatus, nCfg;
4783 void *pPacket;
4784 eHalStatus halstatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07004785
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304786 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004787
4788 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
4789 frm.Action.action = SIR_MAC_ACTION_TPC_REPORT_ID;
4790 frm.DialogToken.token = pTpcReqFrame->actionHeader.dialogToken;
4791
4792 // FramesToDo: On the Gen4_TVM branch, there was a comment:
4793 // "misplaced this function, need to replace:
4794 // txPower = halGetRateToPwrValue(pMac, staid,
4795 // pMac->lim.gLimCurrentChannelId, 0);
4796 frm.TPCReport.tx_power = 0;
4797 frm.TPCReport.link_margin = 0;
4798 frm.TPCReport.present = 1;
4799
4800 nStatus = dot11fGetPackedTPCReportSize( pMac, &frm, &nPayload );
4801 if ( DOT11F_FAILED( nStatus ) )
4802 {
4803 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004804 "or a TPC Report (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004805 nStatus );
4806 // We'll fall back on the worst case scenario:
4807 nPayload = sizeof( tDot11fTPCReport );
4808 }
4809 else if ( DOT11F_WARNED( nStatus ) )
4810 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004811 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07004812 "the packed size for a TPC Report (0x"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004813 "%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004814 }
4815
4816 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4817
4818 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
4819 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4820 {
4821 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a TPC"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004822 " Report."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07004823 return eSIR_FAILURE;
4824 }
4825
4826 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304827 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004828
4829 // Next, we fill out the buffer descriptor:
4830 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
4831 SIR_MAC_MGMT_ACTION, peer);
4832 if ( eSIR_SUCCESS != nSirStatus )
4833 {
4834 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004835 "tor for a TPC Report (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004836 nSirStatus );
4837 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4838 return eSIR_FAILURE; // just allocated...
4839 }
4840
4841 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
4842
4843 nCfg = 6;
4844 nSirStatus = wlan_cfgGetStr( pMac, WNI_CFG_BSSID, pMacHdr->bssId, &nCfg );
4845 if ( eSIR_SUCCESS != nSirStatus )
4846 {
4847 limLog( pMac, LOGE, FL("Failed to retrieve WNI_CFG_BSSID from"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004848 " CFG (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004849 nSirStatus );
4850 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4851 return eSIR_FAILURE; // just allocated...
4852 }
4853
Chet Lanctot186b5732013-03-18 10:26:30 -07004854#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07004855 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07004856#endif
4857
Jeff Johnson295189b2012-06-20 16:38:30 -07004858 nStatus = dot11fPackTPCReport( pMac, &frm, pFrame +
4859 sizeof(tSirMacMgmtHdr),
4860 nPayload, &nPayload );
4861 if ( DOT11F_FAILED( nStatus ) )
4862 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004863 limLog( pMac, LOGE, FL("Failed to pack a TPC Report (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004864 nStatus );
4865 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4866 return eSIR_FAILURE; // allocated!
4867 }
4868 else if ( DOT11F_WARNED( nStatus ) )
4869 {
4870 limLog( pMac, LOGW, FL("There were warnings while packing a T"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004871 "PC Report (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004872 }
4873
4874
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304875 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
4876 ((psessionEntry)? psessionEntry->peSessionId : NO_SESSION),
4877 pMacHdr->fc.subType));
Jeff Johnson295189b2012-06-20 16:38:30 -07004878 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4879 HAL_TXRX_FRM_802_11_MGMT,
4880 ANI_TXDIR_TODS,
4881 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4882 limTxComplete, pFrame, 0 );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304883 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
4884 ((psessionEntry)? psessionEntry->peSessionId : NO_SESSION),
4885 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07004886 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4887 {
4888 limLog( pMac, LOGE, FL("Failed to send a TPC Report "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004889 "(%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07004890 nSirStatus );
4891 //Pkt will be freed up by the callback
4892 return eSIR_FAILURE; // just allocated...
4893 }
4894
4895 return eSIR_SUCCESS;
4896
4897} // End limSendTpcReportFrame.
4898#endif //ANI_SUPPORT_11H
4899
4900
Jeff Johnson295189b2012-06-20 16:38:30 -07004901/**
4902 * \brief Send a Channel Switch Announcement
4903 *
4904 *
4905 * \param pMac Pointer to the global MAC datastructure
4906 *
4907 * \param peer MAC address to which this frame will be sent
4908 *
4909 * \param nMode
4910 *
4911 * \param nNewChannel
4912 *
4913 * \param nCount
4914 *
4915 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
4916 *
4917 *
4918 */
4919
4920tSirRetStatus
4921limSendChannelSwitchMgmtFrame(tpAniSirGlobal pMac,
4922 tSirMacAddr peer,
Jeff Johnsone7245742012-09-05 17:12:55 -07004923 tANI_U8 nMode,
4924 tANI_U8 nNewChannel,
4925 tANI_U8 nCount,
4926 tpPESession psessionEntry )
Jeff Johnson295189b2012-06-20 16:38:30 -07004927{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304928 tDot11fChannelSwitch frm;
4929 tANI_U8 *pFrame;
4930 tSirRetStatus nSirStatus;
4931 tpSirMacMgmtHdr pMacHdr;
4932 tANI_U32 nBytes, nPayload, nStatus;//, nCfg;
4933 void *pPacket;
4934 eHalStatus halstatus;
4935 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004936
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304937 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004938
4939 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
4940 frm.Action.action = SIR_MAC_ACTION_CHANNEL_SWITCH_ID;
4941 frm.ChanSwitchAnn.switchMode = nMode;
4942 frm.ChanSwitchAnn.newChannel = nNewChannel;
4943 frm.ChanSwitchAnn.switchCount = nCount;
4944 frm.ChanSwitchAnn.present = 1;
4945
4946 nStatus = dot11fGetPackedChannelSwitchSize( pMac, &frm, &nPayload );
4947 if ( DOT11F_FAILED( nStatus ) )
4948 {
4949 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004950 "or a Channel Switch (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004951 nStatus );
4952 // We'll fall back on the worst case scenario:
4953 nPayload = sizeof( tDot11fChannelSwitch );
4954 }
4955 else if ( DOT11F_WARNED( nStatus ) )
4956 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004957 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07004958 "the packed size for a Channel Switch (0x"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004959 "%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004960 }
4961
4962 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4963
4964 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
4965 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4966 {
4967 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a TPC"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004968 " Report."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07004969 return eSIR_FAILURE;
4970 }
4971
4972 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304973 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004974
4975 // Next, we fill out the buffer descriptor:
4976 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
Jeff Johnsone7245742012-09-05 17:12:55 -07004977 SIR_MAC_MGMT_ACTION, peer, psessionEntry->selfMacAddr);
4978 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304979 vos_mem_copy( (tANI_U8 *) pMacHdr->bssId,
4980 (tANI_U8 *) psessionEntry->bssId,
4981 sizeof( tSirMacAddr ));
Jeff Johnson295189b2012-06-20 16:38:30 -07004982 if ( eSIR_SUCCESS != nSirStatus )
4983 {
4984 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004985 "tor for a Channel Switch (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004986 nSirStatus );
4987 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4988 return eSIR_FAILURE; // just allocated...
4989 }
4990
Jeff Johnsone7245742012-09-05 17:12:55 -07004991#if 0
Jeff Johnson295189b2012-06-20 16:38:30 -07004992 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
4993
4994 nCfg = 6;
4995 nSirStatus = wlan_cfgGetStr( pMac, WNI_CFG_BSSID, pMacHdr->bssId, &nCfg );
4996 if ( eSIR_SUCCESS != nSirStatus )
4997 {
4998 limLog( pMac, LOGE, FL("Failed to retrieve WNI_CFG_BSSID from"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004999 " CFG (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005000 nSirStatus );
5001 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
5002 return eSIR_FAILURE; // just allocated...
5003 }
Jeff Johnsone7245742012-09-05 17:12:55 -07005004#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07005005
5006#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07005007 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07005008#endif
5009
Jeff Johnson295189b2012-06-20 16:38:30 -07005010 nStatus = dot11fPackChannelSwitch( pMac, &frm, pFrame +
5011 sizeof(tSirMacMgmtHdr),
5012 nPayload, &nPayload );
5013 if ( DOT11F_FAILED( nStatus ) )
5014 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005015 limLog( pMac, LOGE, FL("Failed to pack a Channel Switch (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005016 nStatus );
5017 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
5018 return eSIR_FAILURE; // allocated!
5019 }
5020 else if ( DOT11F_WARNED( nStatus ) )
5021 {
5022 limLog( pMac, LOGW, FL("There were warnings while packing a C"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005023 "hannel Switch (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07005024 }
5025
Jeff Johnsone7245742012-09-05 17:12:55 -07005026 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnsone7245742012-09-05 17:12:55 -07005027 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
5028 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnsone7245742012-09-05 17:12:55 -07005029 )
5030 {
5031 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
5032 }
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05305033
5034 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
5035 psessionEntry->peSessionId,
5036 pMacHdr->fc.subType));
Jeff Johnson295189b2012-06-20 16:38:30 -07005037 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
5038 HAL_TXRX_FRM_802_11_MGMT,
5039 ANI_TXDIR_TODS,
5040 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
Jeff Johnsone7245742012-09-05 17:12:55 -07005041 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05305042 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
5043 psessionEntry->peSessionId,
5044 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07005045 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
5046 {
5047 limLog( pMac, LOGE, FL("Failed to send a Channel Switch "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005048 "(%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07005049 nSirStatus );
5050 //Pkt will be freed up by the callback
5051 return eSIR_FAILURE;
5052 }
5053
5054 return eSIR_SUCCESS;
5055
5056} // End limSendChannelSwitchMgmtFrame.
5057
Jeff Johnson295189b2012-06-20 16:38:30 -07005058
5059
Mohit Khanna4a70d262012-09-11 16:30:12 -07005060#ifdef WLAN_FEATURE_11AC
5061tSirRetStatus
5062limSendVHTOpmodeNotificationFrame(tpAniSirGlobal pMac,
5063 tSirMacAddr peer,
5064 tANI_U8 nMode,
5065 tpPESession psessionEntry )
5066{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05305067 tDot11fOperatingMode frm;
5068 tANI_U8 *pFrame;
5069 tSirRetStatus nSirStatus;
5070 tpSirMacMgmtHdr pMacHdr;
5071 tANI_U32 nBytes, nPayload = 0, nStatus;//, nCfg;
5072 void *pPacket;
5073 eHalStatus halstatus;
5074 tANI_U32 txFlag = 0;
Mohit Khanna4a70d262012-09-11 16:30:12 -07005075
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305076 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Mohit Khanna4a70d262012-09-11 16:30:12 -07005077
5078 frm.Category.category = SIR_MAC_ACTION_VHT;
5079 frm.Action.action = SIR_MAC_VHT_OPMODE_NOTIFICATION;
5080 frm.OperatingMode.chanWidth = nMode;
5081 frm.OperatingMode.rxNSS = 0;
5082 frm.OperatingMode.rxNSSType = 0;
5083
5084 nStatus = dot11fGetPackedOperatingModeSize( pMac, &frm, &nPayload );
5085 if ( DOT11F_FAILED( nStatus ) )
5086 {
5087 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005088 "or a Operating Mode (0x%08x)."),
Mohit Khanna4a70d262012-09-11 16:30:12 -07005089 nStatus );
5090 // We'll fall back on the worst case scenario:
5091 nPayload = sizeof( tDot11fOperatingMode);
5092 }
5093 else if ( DOT11F_WARNED( nStatus ) )
5094 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005095 limLog( pMac, LOGW, FL("There were warnings while calculating "
Mohit Khanna4a70d262012-09-11 16:30:12 -07005096 "the packed size for a Operating Mode (0x"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005097 "%08x)."), nStatus );
Mohit Khanna4a70d262012-09-11 16:30:12 -07005098 }
5099
5100 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
5101
5102 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
5103 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
5104 {
5105 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Operating Mode"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005106 " Report."), nBytes );
Mohit Khanna4a70d262012-09-11 16:30:12 -07005107 return eSIR_FAILURE;
5108 }
5109
5110 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305111 vos_mem_set( pFrame, nBytes, 0 );
Mohit Khanna4a70d262012-09-11 16:30:12 -07005112
5113
5114 // Next, we fill out the buffer descriptor:
5115 if(psessionEntry->pePersona == VOS_STA_SAP_MODE) {
5116 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
5117 SIR_MAC_MGMT_ACTION, peer, psessionEntry->selfMacAddr);
5118 } else
5119 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
5120 SIR_MAC_MGMT_ACTION, psessionEntry->bssId, psessionEntry->selfMacAddr);
5121 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305122 vos_mem_copy( (tANI_U8 *) pMacHdr->bssId,
5123 (tANI_U8 *) psessionEntry->bssId,
5124 sizeof( tSirMacAddr ));
Mohit Khanna4a70d262012-09-11 16:30:12 -07005125 if ( eSIR_SUCCESS != nSirStatus )
5126 {
5127 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005128 "tor for a Operating Mode (%d)."),
Mohit Khanna4a70d262012-09-11 16:30:12 -07005129 nSirStatus );
5130 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
5131 return eSIR_FAILURE; // just allocated...
5132 }
5133 nStatus = dot11fPackOperatingMode( pMac, &frm, pFrame +
5134 sizeof(tSirMacMgmtHdr),
5135 nPayload, &nPayload );
5136 if ( DOT11F_FAILED( nStatus ) )
5137 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005138 limLog( pMac, LOGE, FL("Failed to pack a Operating Mode (0x%08x)."),
Mohit Khanna4a70d262012-09-11 16:30:12 -07005139 nStatus );
5140 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
5141 return eSIR_FAILURE; // allocated!
5142 }
5143 else if ( DOT11F_WARNED( nStatus ) )
5144 {
5145 limLog( pMac, LOGW, FL("There were warnings while packing a Operating Mode"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005146 " (0x%08x)."), nStatus );
Mohit Khanna4a70d262012-09-11 16:30:12 -07005147 }
5148 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Mohit Khanna4a70d262012-09-11 16:30:12 -07005149 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
5150 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Mohit Khanna4a70d262012-09-11 16:30:12 -07005151 )
5152 {
5153 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
5154 }
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05305155
5156 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
5157 psessionEntry->peSessionId,
5158 pMacHdr->fc.subType));
Mohit Khanna4a70d262012-09-11 16:30:12 -07005159 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
5160 HAL_TXRX_FRM_802_11_MGMT,
5161 ANI_TXDIR_TODS,
5162 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
5163 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05305164 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
5165 psessionEntry->peSessionId,
5166 halstatus));
Mohit Khanna4a70d262012-09-11 16:30:12 -07005167 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
5168 {
5169 limLog( pMac, LOGE, FL("Failed to send a Channel Switch "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005170 "(%X)!"),
Mohit Khanna4a70d262012-09-11 16:30:12 -07005171 nSirStatus );
5172 //Pkt will be freed up by the callback
5173 return eSIR_FAILURE;
5174 }
5175
5176 return eSIR_SUCCESS;
5177}
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005178
5179/**
5180 * \brief Send a VHT Channel Switch Announcement
5181 *
5182 *
5183 * \param pMac Pointer to the global MAC datastructure
5184 *
5185 * \param peer MAC address to which this frame will be sent
5186 *
5187 * \param nChanWidth
5188 *
5189 * \param nNewChannel
5190 *
5191 *
5192 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
5193 *
5194 *
5195 */
5196
5197tSirRetStatus
5198limSendVHTChannelSwitchMgmtFrame(tpAniSirGlobal pMac,
5199 tSirMacAddr peer,
5200 tANI_U8 nChanWidth,
5201 tANI_U8 nNewChannel,
5202 tANI_U8 ncbMode,
5203 tpPESession psessionEntry )
5204{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05305205 tDot11fChannelSwitch frm;
5206 tANI_U8 *pFrame;
5207 tSirRetStatus nSirStatus;
5208 tpSirMacMgmtHdr pMacHdr;
5209 tANI_U32 nBytes, nPayload, nStatus;//, nCfg;
5210 void *pPacket;
5211 eHalStatus halstatus;
5212 tANI_U32 txFlag = 0;
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005213
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305214 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005215
5216
5217 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
5218 frm.Action.action = SIR_MAC_ACTION_CHANNEL_SWITCH_ID;
5219 frm.ChanSwitchAnn.switchMode = 1;
5220 frm.ChanSwitchAnn.newChannel = nNewChannel;
5221 frm.ChanSwitchAnn.switchCount = 1;
5222 frm.ExtChanSwitchAnn.secondaryChannelOffset = limGetHTCBState(ncbMode);
5223 frm.ExtChanSwitchAnn.present = 1;
5224 frm.WiderBWChanSwitchAnn.newChanWidth = nChanWidth;
5225 frm.WiderBWChanSwitchAnn.newCenterChanFreq0 = limGetCenterChannel(pMac,nNewChannel,ncbMode,nChanWidth);
5226 frm.WiderBWChanSwitchAnn.newCenterChanFreq1 = 0;
5227 frm.ChanSwitchAnn.present = 1;
5228 frm.WiderBWChanSwitchAnn.present = 1;
5229
5230 nStatus = dot11fGetPackedChannelSwitchSize( pMac, &frm, &nPayload );
5231 if ( DOT11F_FAILED( nStatus ) )
5232 {
5233 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005234 "or a Channel Switch (0x%08x)."),
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005235 nStatus );
5236 // We'll fall back on the worst case scenario:
5237 nPayload = sizeof( tDot11fChannelSwitch );
5238 }
5239 else if ( DOT11F_WARNED( nStatus ) )
5240 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005241 limLog( pMac, LOGW, FL("There were warnings while calculating "
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005242 "the packed size for a Channel Switch (0x"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005243 "%08x)."), nStatus );
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005244 }
5245
5246 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
5247
5248 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
5249 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
5250 {
5251 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a TPC"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005252 " Report."), nBytes );
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005253 return eSIR_FAILURE;
5254 }
5255 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305256 vos_mem_set( pFrame, nBytes, 0 );
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005257
5258 // Next, we fill out the buffer descriptor:
5259 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
5260 SIR_MAC_MGMT_ACTION, peer, psessionEntry->selfMacAddr);
5261 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305262 vos_mem_copy( (tANI_U8 *) pMacHdr->bssId,
5263 (tANI_U8 *) psessionEntry->bssId,
5264 sizeof( tSirMacAddr ));
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005265 if ( eSIR_SUCCESS != nSirStatus )
5266 {
5267 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005268 "tor for a Channel Switch (%d)."),
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005269 nSirStatus );
5270 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
5271 return eSIR_FAILURE; // just allocated...
5272 }
5273 nStatus = dot11fPackChannelSwitch( pMac, &frm, pFrame +
5274 sizeof(tSirMacMgmtHdr),
5275 nPayload, &nPayload );
5276 if ( DOT11F_FAILED( nStatus ) )
5277 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005278 limLog( pMac, LOGE, FL("Failed to pack a Channel Switch (0x%08x)."),
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005279 nStatus );
5280 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
5281 return eSIR_FAILURE; // allocated!
5282 }
5283 else if ( DOT11F_WARNED( nStatus ) )
5284 {
5285 limLog( pMac, LOGW, FL("There were warnings while packing a C"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005286 "hannel Switch (0x%08x)."), nStatus );
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005287 }
5288
5289 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005290 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
5291 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005292 )
5293 {
5294 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
5295 }
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05305296
5297 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
5298 psessionEntry->peSessionId,
5299 pMacHdr->fc.subType));
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005300 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
5301 HAL_TXRX_FRM_802_11_MGMT,
5302 ANI_TXDIR_TODS,
5303 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
5304 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05305305 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
5306 psessionEntry->peSessionId,
5307 halstatus));
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005308 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
5309 {
5310 limLog( pMac, LOGE, FL("Failed to send a Channel Switch "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005311 "(%X)!"),
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005312 nSirStatus );
5313 //Pkt will be freed up by the callback
5314 return eSIR_FAILURE;
5315 }
5316
5317 return eSIR_SUCCESS;
5318
5319} // End limSendVHTChannelSwitchMgmtFrame.
5320
5321
5322
Mohit Khanna4a70d262012-09-11 16:30:12 -07005323#endif
5324
Jeff Johnson295189b2012-06-20 16:38:30 -07005325/**
5326 * \brief Send an ADDBA Req Action Frame to peer
5327 *
5328 * \sa limSendAddBAReq
5329 *
5330 * \param pMac The global tpAniSirGlobal object
5331 *
5332 * \param pMlmAddBAReq A pointer to tLimMlmAddBAReq. This contains
5333 * the necessary parameters reqd by PE send the ADDBA Req Action
5334 * Frame to the peer
5335 *
5336 * \return eSIR_SUCCESS if setup completes successfully
5337 * eSIR_FAILURE is some problem is encountered
5338 */
5339tSirRetStatus limSendAddBAReq( tpAniSirGlobal pMac,
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305340 tpLimMlmAddBAReq pMlmAddBAReq, tpPESession psessionEntry)
Jeff Johnson295189b2012-06-20 16:38:30 -07005341{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05305342 tDot11fAddBAReq frmAddBAReq;
5343 tANI_U8 *pAddBAReqBuffer = NULL;
5344 tpSirMacMgmtHdr pMacHdr;
5345 tANI_U32 frameLen = 0, nStatus, nPayload;
5346 tSirRetStatus statusCode;
5347 eHalStatus halStatus;
5348 void *pPacket;
5349 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005350
5351 if(NULL == psessionEntry)
5352 {
5353 return eSIR_FAILURE;
5354 }
5355
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305356 vos_mem_set( (void *) &frmAddBAReq, sizeof( frmAddBAReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005357
5358 // Category - 3 (BA)
5359 frmAddBAReq.Category.category = SIR_MAC_ACTION_BLKACK;
5360
5361 // Action - 0 (ADDBA Req)
5362 frmAddBAReq.Action.action = SIR_MAC_BLKACK_ADD_REQ;
5363
5364 // FIXME - Dialog Token, generalize this...
5365 frmAddBAReq.DialogToken.token = pMlmAddBAReq->baDialogToken;
5366
5367 // Fill the ADDBA Parameter Set
5368 frmAddBAReq.AddBAParameterSet.tid = pMlmAddBAReq->baTID;
5369 frmAddBAReq.AddBAParameterSet.policy = pMlmAddBAReq->baPolicy;
5370 frmAddBAReq.AddBAParameterSet.bufferSize = pMlmAddBAReq->baBufferSize;
5371
5372 // BA timeout
5373 // 0 - indicates no BA timeout
5374 frmAddBAReq.BATimeout.timeout = pMlmAddBAReq->baTimeout;
5375
Abhishek Singh1f6e6532014-06-05 17:35:08 +05305376 /* Send SSN whatever we get from FW.
5377 */
5378 frmAddBAReq.BAStartingSequenceControl.ssn = pMlmAddBAReq->baSSN;
Jeff Johnson295189b2012-06-20 16:38:30 -07005379
5380 nStatus = dot11fGetPackedAddBAReqSize( pMac, &frmAddBAReq, &nPayload );
5381
5382 if( DOT11F_FAILED( nStatus ))
5383 {
5384 limLog( pMac, LOGW,
5385 FL( "Failed to calculate the packed size for "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005386 "an ADDBA Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005387 nStatus );
5388
5389 // We'll fall back on the worst case scenario:
5390 nPayload = sizeof( tDot11fAddBAReq );
5391 }
5392 else if( DOT11F_WARNED( nStatus ))
5393 {
5394 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005395 FL( "There were warnings while calculating "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005396 "the packed size for an ADDBA Req (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005397 nStatus );
5398 }
5399
5400 // Add the MGMT header to frame length
5401 frameLen = nPayload + sizeof( tSirMacMgmtHdr );
5402
5403 // Need to allocate a buffer for ADDBA AF
5404 if( eHAL_STATUS_SUCCESS !=
5405 (halStatus = palPktAlloc( pMac->hHdd,
5406 HAL_TXRX_FRM_802_11_MGMT,
5407 (tANI_U16) frameLen,
5408 (void **) &pAddBAReqBuffer,
5409 (void **) &pPacket )))
5410 {
5411 // Log error
5412 limLog( pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005413 FL("palPktAlloc FAILED! Length [%d], Status [%d]"),
Jeff Johnson295189b2012-06-20 16:38:30 -07005414 frameLen,
5415 halStatus );
5416
5417 statusCode = eSIR_MEM_ALLOC_FAILED;
5418 goto returnAfterError;
5419 }
5420
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305421 vos_mem_set( (void *) pAddBAReqBuffer, frameLen, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005422
5423 // Copy necessary info to BD
5424 if( eSIR_SUCCESS !=
5425 (statusCode = limPopulateMacHeader( pMac,
5426 pAddBAReqBuffer,
5427 SIR_MAC_MGMT_FRAME,
5428 SIR_MAC_MGMT_ACTION,
5429 pMlmAddBAReq->peerMacAddr,psessionEntry->selfMacAddr)))
5430 goto returnAfterError;
5431
5432 // Update A3 with the BSSID
5433 pMacHdr = ( tpSirMacMgmtHdr ) pAddBAReqBuffer;
5434
5435 #if 0
5436 cfgLen = SIR_MAC_ADDR_LENGTH;
5437 if( eSIR_SUCCESS != cfgGetStr( pMac,
5438 WNI_CFG_BSSID,
5439 (tANI_U8 *) pMacHdr->bssId,
5440 &cfgLen ))
5441 {
5442 limLog( pMac, LOGP,
5443 FL( "Failed to retrieve WNI_CFG_BSSID while"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005444 "sending an ACTION Frame" ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005445
5446 // FIXME - Need to convert to tSirRetStatus
5447 statusCode = eSIR_FAILURE;
5448 goto returnAfterError;
5449 }
5450 #endif//TO SUPPORT BT-AMP
5451 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
5452
Chet Lanctot186b5732013-03-18 10:26:30 -07005453#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07005454 limSetProtectedBit(pMac, psessionEntry, pMlmAddBAReq->peerMacAddr, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07005455#endif
5456
Jeff Johnson295189b2012-06-20 16:38:30 -07005457 // Now, we're ready to "pack" the frames
5458 nStatus = dot11fPackAddBAReq( pMac,
5459 &frmAddBAReq,
5460 pAddBAReqBuffer + sizeof( tSirMacMgmtHdr ),
5461 nPayload,
5462 &nPayload );
5463
5464 if( DOT11F_FAILED( nStatus ))
5465 {
5466 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005467 FL( "Failed to pack an ADDBA Req (0x%08x)." ),
Jeff Johnson295189b2012-06-20 16:38:30 -07005468 nStatus );
5469
5470 // FIXME - Need to convert to tSirRetStatus
5471 statusCode = eSIR_FAILURE;
5472 goto returnAfterError;
5473 }
5474 else if( DOT11F_WARNED( nStatus ))
5475 {
5476 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005477 FL( "There were warnings while packing an ADDBA Req (0x%08x)."),
5478 nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07005479 }
5480
Abhishek Singh02d9f6c2014-05-12 14:07:53 +05305481 limLog( pMac, LOG1, FL( "Sending an ADDBA REQ to "MAC_ADDRESS_STR " with"
5482 " tid = %d policy = %d buffsize = %d "
5483 " amsduSupported = %d"),
5484 MAC_ADDR_ARRAY(pMlmAddBAReq->peerMacAddr),
5485 frmAddBAReq.AddBAParameterSet.tid,
5486 frmAddBAReq.AddBAParameterSet.policy,
5487 frmAddBAReq.AddBAParameterSet.bufferSize,
5488 frmAddBAReq.AddBAParameterSet.amsduSupported);
Jeff Johnson295189b2012-06-20 16:38:30 -07005489
Abhishek Singh1f6e6532014-06-05 17:35:08 +05305490 limLog( pMac, LOG1, FL( "ssn = %d fragNum = %d" ),
5491 frmAddBAReq.BAStartingSequenceControl.ssn,
5492 frmAddBAReq.BAStartingSequenceControl.fragNumber);
5493
Jeff Johnson295189b2012-06-20 16:38:30 -07005494 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07005495 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
5496 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07005497 )
5498 {
5499 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
5500 }
5501
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05305502 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
5503 psessionEntry->peSessionId,
5504 pMacHdr->fc.subType));
5505 halStatus = halTxFrame( pMac,
5506 pPacket,
5507 (tANI_U16) frameLen,
5508 HAL_TXRX_FRM_802_11_MGMT,
5509 ANI_TXDIR_TODS,
5510 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
5511 limTxComplete,
5512 pAddBAReqBuffer, txFlag );
5513 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
5514 psessionEntry->peSessionId,
5515 halStatus));
5516 if( eHAL_STATUS_SUCCESS != halStatus )
Jeff Johnson295189b2012-06-20 16:38:30 -07005517 {
5518 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005519 FL( "halTxFrame FAILED! Status [%d]"),
Jeff Johnson295189b2012-06-20 16:38:30 -07005520 halStatus );
5521
5522 // FIXME - Need to convert eHalStatus to tSirRetStatus
5523 statusCode = eSIR_FAILURE;
5524 //Pkt will be freed up by the callback
5525 return statusCode;
5526 }
5527 else
5528 return eSIR_SUCCESS;
5529
5530returnAfterError:
5531
5532 // Release buffer, if allocated
5533 if( NULL != pAddBAReqBuffer )
5534 palPktFree( pMac->hHdd,
5535 HAL_TXRX_FRM_802_11_MGMT,
5536 (void *) pAddBAReqBuffer,
5537 (void *) pPacket );
5538
5539 return statusCode;
5540}
5541
5542/**
5543 * \brief Send an ADDBA Rsp Action Frame to peer
5544 *
5545 * \sa limSendAddBARsp
5546 *
5547 * \param pMac The global tpAniSirGlobal object
5548 *
5549 * \param pMlmAddBARsp A pointer to tLimMlmAddBARsp. This contains
5550 * the necessary parameters reqd by PE send the ADDBA Rsp Action
5551 * Frame to the peer
5552 *
5553 * \return eSIR_SUCCESS if setup completes successfully
5554 * eSIR_FAILURE is some problem is encountered
5555 */
5556tSirRetStatus limSendAddBARsp( tpAniSirGlobal pMac,
5557 tpLimMlmAddBARsp pMlmAddBARsp,
5558 tpPESession psessionEntry)
5559{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05305560 tDot11fAddBARsp frmAddBARsp;
5561 tANI_U8 *pAddBARspBuffer = NULL;
5562 tpSirMacMgmtHdr pMacHdr;
5563 tANI_U32 frameLen = 0, nStatus, nPayload;
5564 tSirRetStatus statusCode;
5565 eHalStatus halStatus;
5566 void *pPacket;
5567 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005568
5569 if(NULL == psessionEntry)
5570 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005571 PELOGE(limLog(pMac, LOGE, FL("Session entry is NULL!!!"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07005572 return eSIR_FAILURE;
5573 }
5574
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305575 vos_mem_set( (void *) &frmAddBARsp, sizeof( frmAddBARsp ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005576
5577 // Category - 3 (BA)
5578 frmAddBARsp.Category.category = SIR_MAC_ACTION_BLKACK;
5579 // Action - 1 (ADDBA Rsp)
5580 frmAddBARsp.Action.action = SIR_MAC_BLKACK_ADD_RSP;
5581
5582 // Should be same as the one we received in the ADDBA Req
5583 frmAddBARsp.DialogToken.token = pMlmAddBARsp->baDialogToken;
5584
5585 // ADDBA Req status
5586 frmAddBARsp.Status.status = pMlmAddBARsp->addBAResultCode;
5587
5588 // Fill the ADDBA Parameter Set as provided by caller
5589 frmAddBARsp.AddBAParameterSet.tid = pMlmAddBARsp->baTID;
5590 frmAddBARsp.AddBAParameterSet.policy = pMlmAddBARsp->baPolicy;
5591 frmAddBARsp.AddBAParameterSet.bufferSize = pMlmAddBARsp->baBufferSize;
krunal soni5afa96c2013-09-06 22:19:02 -07005592
5593 if(psessionEntry->isAmsduSupportInAMPDU)
5594 {
5595 frmAddBARsp.AddBAParameterSet.amsduSupported =
5596 psessionEntry->amsduSupportedInBA;
5597 }
5598 else
5599 {
5600 frmAddBARsp.AddBAParameterSet.amsduSupported = 0;
5601 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005602
5603 // BA timeout
5604 // 0 - indicates no BA timeout
5605 frmAddBARsp.BATimeout.timeout = pMlmAddBARsp->baTimeout;
5606
5607 nStatus = dot11fGetPackedAddBARspSize( pMac, &frmAddBARsp, &nPayload );
5608
5609 if( DOT11F_FAILED( nStatus ))
5610 {
5611 limLog( pMac, LOGW,
5612 FL( "Failed to calculate the packed size for "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005613 "an ADDBA Response (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005614 nStatus );
5615
5616 // We'll fall back on the worst case scenario:
5617 nPayload = sizeof( tDot11fAddBARsp );
5618 }
5619 else if( DOT11F_WARNED( nStatus ))
5620 {
5621 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005622 FL( "There were warnings while calculating "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005623 "the packed size for an ADDBA Rsp (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005624 nStatus );
5625 }
5626
5627 // Need to allocate a buffer for ADDBA AF
5628 frameLen = nPayload + sizeof( tSirMacMgmtHdr );
5629
5630 // Allocate shared memory
5631 if( eHAL_STATUS_SUCCESS !=
5632 (halStatus = palPktAlloc( pMac->hHdd,
5633 HAL_TXRX_FRM_802_11_MGMT,
5634 (tANI_U16) frameLen,
5635 (void **) &pAddBARspBuffer,
5636 (void **) &pPacket )))
5637 {
5638 // Log error
5639 limLog( pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005640 FL("palPktAlloc FAILED! Length [%d], Status [%d]"),
Jeff Johnson295189b2012-06-20 16:38:30 -07005641 frameLen,
5642 halStatus );
5643
5644 statusCode = eSIR_MEM_ALLOC_FAILED;
5645 goto returnAfterError;
5646 }
5647
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305648 vos_mem_set( (void *) pAddBARspBuffer, frameLen, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005649
5650 // Copy necessary info to BD
5651 if( eSIR_SUCCESS !=
5652 (statusCode = limPopulateMacHeader( pMac,
5653 pAddBARspBuffer,
5654 SIR_MAC_MGMT_FRAME,
5655 SIR_MAC_MGMT_ACTION,
5656 pMlmAddBARsp->peerMacAddr,psessionEntry->selfMacAddr)))
5657 goto returnAfterError;
5658
5659 // Update A3 with the BSSID
5660
5661 pMacHdr = ( tpSirMacMgmtHdr ) pAddBARspBuffer;
5662
5663 #if 0
5664 cfgLen = SIR_MAC_ADDR_LENGTH;
5665 if( eSIR_SUCCESS != wlan_cfgGetStr( pMac,
5666 WNI_CFG_BSSID,
5667 (tANI_U8 *) pMacHdr->bssId,
5668 &cfgLen ))
5669 {
5670 limLog( pMac, LOGP,
5671 FL( "Failed to retrieve WNI_CFG_BSSID while"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005672 "sending an ACTION Frame" ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005673
5674 // FIXME - Need to convert to tSirRetStatus
5675 statusCode = eSIR_FAILURE;
5676 goto returnAfterError;
5677 }
5678 #endif // TO SUPPORT BT-AMP
5679 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
5680
Chet Lanctot186b5732013-03-18 10:26:30 -07005681#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07005682 limSetProtectedBit(pMac, psessionEntry, pMlmAddBARsp->peerMacAddr, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07005683#endif
5684
Jeff Johnson295189b2012-06-20 16:38:30 -07005685 // Now, we're ready to "pack" the frames
5686 nStatus = dot11fPackAddBARsp( pMac,
5687 &frmAddBARsp,
5688 pAddBARspBuffer + sizeof( tSirMacMgmtHdr ),
5689 nPayload,
5690 &nPayload );
5691
5692 if( DOT11F_FAILED( nStatus ))
5693 {
5694 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005695 FL( "Failed to pack an ADDBA Rsp (0x%08x)." ),
Jeff Johnson295189b2012-06-20 16:38:30 -07005696 nStatus );
5697
5698 // FIXME - Need to convert to tSirRetStatus
5699 statusCode = eSIR_FAILURE;
5700 goto returnAfterError;
5701 }
5702 else if( DOT11F_WARNED( nStatus ))
5703 {
5704 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005705 FL( "There were warnings while packing an ADDBA Rsp (0x%08x)." ),
5706 nStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07005707 }
5708
Abhishek Singh02d9f6c2014-05-12 14:07:53 +05305709 limLog( pMac, LOG1, FL( "Sending an ADDBA RSP to "MAC_ADDRESS_STR " with"
5710 " tid = %d policy = %d buffsize = %d"
5711 " amsduSupported = %d status %d"),
5712 MAC_ADDR_ARRAY(pMlmAddBARsp->peerMacAddr),
5713 frmAddBARsp.AddBAParameterSet.tid,
5714 frmAddBARsp.AddBAParameterSet.policy,
5715 frmAddBARsp.AddBAParameterSet.bufferSize,
5716 frmAddBARsp.AddBAParameterSet.amsduSupported,
5717 frmAddBARsp.Status.status);
5718
Jeff Johnson295189b2012-06-20 16:38:30 -07005719
5720 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07005721 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
5722 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07005723 )
5724 {
5725 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
5726 }
5727
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05305728 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
5729 psessionEntry->peSessionId,
5730 pMacHdr->fc.subType));
5731 halStatus = halTxFrame( pMac,
5732 pPacket,
5733 (tANI_U16) frameLen,
5734 HAL_TXRX_FRM_802_11_MGMT,
5735 ANI_TXDIR_TODS,
5736 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
5737 limTxComplete,
5738 pAddBARspBuffer, txFlag );
5739 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
5740 psessionEntry->peSessionId,
5741 halStatus));
5742 if( eHAL_STATUS_SUCCESS != halStatus )
5743 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005744 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005745 FL( "halTxFrame FAILED! Status [%d]" ),
Jeff Johnson295189b2012-06-20 16:38:30 -07005746 halStatus );
5747
5748 // FIXME - HAL error codes are different from PE error
5749 // codes!! And, this routine is returning tSirRetStatus
5750 statusCode = eSIR_FAILURE;
5751 //Pkt will be freed up by the callback
5752 return statusCode;
5753 }
5754 else
5755 return eSIR_SUCCESS;
5756
5757 returnAfterError:
Jeff Johnson295189b2012-06-20 16:38:30 -07005758 // Release buffer, if allocated
5759 if( NULL != pAddBARspBuffer )
5760 palPktFree( pMac->hHdd,
5761 HAL_TXRX_FRM_802_11_MGMT,
5762 (void *) pAddBARspBuffer,
5763 (void *) pPacket );
5764
5765 return statusCode;
5766}
5767
5768/**
5769 * \brief Send a DELBA Indication Action Frame to peer
5770 *
5771 * \sa limSendDelBAInd
5772 *
5773 * \param pMac The global tpAniSirGlobal object
5774 *
5775 * \param peerMacAddr MAC Address of peer
5776 *
5777 * \param reasonCode Reason for the DELBA notification
5778 *
5779 * \param pBAParameterSet The DELBA Parameter Set.
5780 * This identifies the TID for which the BA session is
5781 * being deleted.
5782 *
5783 * \return eSIR_SUCCESS if setup completes successfully
5784 * eSIR_FAILURE is some problem is encountered
5785 */
5786tSirRetStatus limSendDelBAInd( tpAniSirGlobal pMac,
5787 tpLimMlmDelBAReq pMlmDelBAReq,tpPESession psessionEntry)
5788{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05305789 tDot11fDelBAInd frmDelBAInd;
5790 tANI_U8 *pDelBAIndBuffer = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005791 //tANI_U32 val;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05305792 tpSirMacMgmtHdr pMacHdr;
5793 tANI_U32 frameLen = 0, nStatus, nPayload;
5794 tSirRetStatus statusCode;
5795 eHalStatus halStatus;
5796 void *pPacket;
5797 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005798
5799 if(NULL == psessionEntry)
5800 {
5801 return eSIR_FAILURE;
5802 }
5803
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305804 vos_mem_set( (void *) &frmDelBAInd, sizeof( frmDelBAInd ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005805
5806 // Category - 3 (BA)
5807 frmDelBAInd.Category.category = SIR_MAC_ACTION_BLKACK;
5808 // Action - 2 (DELBA)
5809 frmDelBAInd.Action.action = SIR_MAC_BLKACK_DEL;
5810
5811 // Fill the DELBA Parameter Set as provided by caller
5812 frmDelBAInd.DelBAParameterSet.tid = pMlmDelBAReq->baTID;
5813 frmDelBAInd.DelBAParameterSet.initiator = pMlmDelBAReq->baDirection;
5814
5815 // BA Starting Sequence Number
5816 // Fragment number will always be zero
5817 frmDelBAInd.Reason.code = pMlmDelBAReq->delBAReasonCode;
5818
5819 nStatus = dot11fGetPackedDelBAIndSize( pMac, &frmDelBAInd, &nPayload );
5820
5821 if( DOT11F_FAILED( nStatus ))
5822 {
5823 limLog( pMac, LOGW,
5824 FL( "Failed to calculate the packed size for "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005825 "an DELBA Indication (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005826 nStatus );
5827
5828 // We'll fall back on the worst case scenario:
5829 nPayload = sizeof( tDot11fDelBAInd );
5830 }
5831 else if( DOT11F_WARNED( nStatus ))
5832 {
5833 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005834 FL( "There were warnings while calculating "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005835 "the packed size for an DELBA Ind (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005836 nStatus );
5837 }
5838
5839 // Add the MGMT header to frame length
5840 frameLen = nPayload + sizeof( tSirMacMgmtHdr );
5841
5842 // Allocate shared memory
5843 if( eHAL_STATUS_SUCCESS !=
5844 (halStatus = palPktAlloc( pMac->hHdd,
5845 HAL_TXRX_FRM_802_11_MGMT,
5846 (tANI_U16) frameLen,
5847 (void **) &pDelBAIndBuffer,
5848 (void **) &pPacket )))
5849 {
5850 // Log error
5851 limLog( pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005852 FL("palPktAlloc FAILED! Length [%d], Status [%d]"),
Jeff Johnson295189b2012-06-20 16:38:30 -07005853 frameLen,
5854 halStatus );
5855
5856 statusCode = eSIR_MEM_ALLOC_FAILED;
5857 goto returnAfterError;
5858 }
5859
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305860 vos_mem_set( (void *) pDelBAIndBuffer, frameLen, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005861
5862 // Copy necessary info to BD
5863 if( eSIR_SUCCESS !=
5864 (statusCode = limPopulateMacHeader( pMac,
5865 pDelBAIndBuffer,
5866 SIR_MAC_MGMT_FRAME,
5867 SIR_MAC_MGMT_ACTION,
5868 pMlmDelBAReq->peerMacAddr,psessionEntry->selfMacAddr)))
5869 goto returnAfterError;
5870
5871 // Update A3 with the BSSID
5872 pMacHdr = ( tpSirMacMgmtHdr ) pDelBAIndBuffer;
5873
5874 #if 0
5875 cfgLen = SIR_MAC_ADDR_LENGTH;
5876 if( eSIR_SUCCESS != cfgGetStr( pMac,
5877 WNI_CFG_BSSID,
5878 (tANI_U8 *) pMacHdr->bssId,
5879 &cfgLen ))
5880 {
5881 limLog( pMac, LOGP,
5882 FL( "Failed to retrieve WNI_CFG_BSSID while"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005883 "sending an ACTION Frame" ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005884
5885 // FIXME - Need to convert to tSirRetStatus
5886 statusCode = eSIR_FAILURE;
5887 goto returnAfterError;
5888 }
5889 #endif //TO SUPPORT BT-AMP
5890 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
5891
Chet Lanctot186b5732013-03-18 10:26:30 -07005892#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07005893 limSetProtectedBit(pMac, psessionEntry, pMlmDelBAReq->peerMacAddr, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07005894#endif
5895
Jeff Johnson295189b2012-06-20 16:38:30 -07005896 // Now, we're ready to "pack" the frames
5897 nStatus = dot11fPackDelBAInd( pMac,
5898 &frmDelBAInd,
5899 pDelBAIndBuffer + sizeof( tSirMacMgmtHdr ),
5900 nPayload,
5901 &nPayload );
5902
5903 if( DOT11F_FAILED( nStatus ))
5904 {
5905 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005906 FL( "Failed to pack an DELBA Ind (0x%08x)." ),
Jeff Johnson295189b2012-06-20 16:38:30 -07005907 nStatus );
5908
5909 // FIXME - Need to convert to tSirRetStatus
5910 statusCode = eSIR_FAILURE;
5911 goto returnAfterError;
5912 }
5913 else if( DOT11F_WARNED( nStatus ))
5914 {
5915 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005916 FL( "There were warnings while packing an DELBA Ind (0x%08x)." ),
5917 nStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07005918 }
5919
Abhishek Singh1f6e6532014-06-05 17:35:08 +05305920 limLog( pMac, LOG1,
5921 FL( "Sending a DELBA IND to: "MAC_ADDRESS_STR" with Tid = %d"
5922 " initiator = %d reason = %d" ),
5923 MAC_ADDR_ARRAY(pMlmDelBAReq->peerMacAddr),
5924 frmDelBAInd.DelBAParameterSet.tid,
5925 frmDelBAInd.DelBAParameterSet.initiator,
5926 frmDelBAInd.Reason.code);
5927
Jeff Johnson295189b2012-06-20 16:38:30 -07005928
5929 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07005930 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
5931 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07005932 )
5933 {
5934 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
5935 }
5936
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05305937 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
5938 psessionEntry->peSessionId,
5939 pMacHdr->fc.subType));
5940 halStatus = halTxFrame( pMac,
5941 pPacket,
5942 (tANI_U16) frameLen,
5943 HAL_TXRX_FRM_802_11_MGMT,
5944 ANI_TXDIR_TODS,
5945 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
5946 limTxComplete,
5947 pDelBAIndBuffer, txFlag );
5948 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
5949 psessionEntry->peSessionId,
5950 halStatus));
5951 if( eHAL_STATUS_SUCCESS != halStatus )
Jeff Johnson295189b2012-06-20 16:38:30 -07005952 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005953 PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]" ), halStatus );)
Jeff Johnson295189b2012-06-20 16:38:30 -07005954 statusCode = eSIR_FAILURE;
5955 //Pkt will be freed up by the callback
5956 return statusCode;
5957 }
5958 else
5959 return eSIR_SUCCESS;
5960
5961 returnAfterError:
5962
5963 // Release buffer, if allocated
5964 if( NULL != pDelBAIndBuffer )
5965 palPktFree( pMac->hHdd,
5966 HAL_TXRX_FRM_802_11_MGMT,
5967 (void *) pDelBAIndBuffer,
5968 (void *) pPacket );
5969
5970 return statusCode;
5971}
5972
5973#if defined WLAN_FEATURE_VOWIFI
5974
5975/**
5976 * \brief Send a Neighbor Report Request Action frame
5977 *
5978 *
5979 * \param pMac Pointer to the global MAC structure
5980 *
5981 * \param pNeighborReq Address of a tSirMacNeighborReportReq
5982 *
5983 * \param peer mac address of peer station.
5984 *
5985 * \param psessionEntry address of session entry.
5986 *
5987 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
5988 *
5989 *
5990 */
5991
5992tSirRetStatus
5993limSendNeighborReportRequestFrame(tpAniSirGlobal pMac,
5994 tpSirMacNeighborReportReq pNeighborReq,
5995 tSirMacAddr peer,
5996 tpPESession psessionEntry
5997 )
5998{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05305999 tSirRetStatus statusCode = eSIR_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006000 tDot11fNeighborReportRequest frm;
6001 tANI_U8 *pFrame;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05306002 tpSirMacMgmtHdr pMacHdr;
6003 tANI_U32 nBytes, nPayload, nStatus;
6004 void *pPacket;
6005 eHalStatus halstatus;
6006 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07006007
6008 if ( psessionEntry == NULL )
6009 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006010 limLog( pMac, LOGE, FL("(psession == NULL) in Request to send Neighbor Report request action frame") );
Jeff Johnson295189b2012-06-20 16:38:30 -07006011 return eSIR_FAILURE;
6012 }
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05306013 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07006014
6015 frm.Category.category = SIR_MAC_ACTION_RRM;
6016 frm.Action.action = SIR_MAC_RRM_NEIGHBOR_REQ;
6017 frm.DialogToken.token = pNeighborReq->dialogToken;
6018
6019
6020 if( pNeighborReq->ssid_present )
6021 {
6022 PopulateDot11fSSID( pMac, &pNeighborReq->ssid, &frm.SSID );
6023 }
6024
6025 nStatus = dot11fGetPackedNeighborReportRequestSize( pMac, &frm, &nPayload );
6026 if ( DOT11F_FAILED( nStatus ) )
6027 {
6028 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006029 "or a Neighbor Report Request(0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07006030 nStatus );
6031 // We'll fall back on the worst case scenario:
6032 nPayload = sizeof( tDot11fNeighborReportRequest );
6033 }
6034 else if ( DOT11F_WARNED( nStatus ) )
6035 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08006036 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07006037 "the packed size for a Neighbor Rep"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006038 "ort Request(0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07006039 }
6040
6041 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
6042
6043 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
6044 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
6045 {
6046 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Neighbor "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006047 "Report Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07006048 return eSIR_FAILURE;
6049 }
6050
6051 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05306052 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07006053
6054 // Copy necessary info to BD
6055 if( eSIR_SUCCESS !=
6056 (statusCode = limPopulateMacHeader( pMac,
6057 pFrame,
6058 SIR_MAC_MGMT_FRAME,
6059 SIR_MAC_MGMT_ACTION,
6060 peer, psessionEntry->selfMacAddr)))
6061 goto returnAfterError;
6062
6063 // Update A3 with the BSSID
6064 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
6065
6066 sirCopyMacAddr( pMacHdr->bssId, psessionEntry->bssId );
6067
Chet Lanctot186b5732013-03-18 10:26:30 -07006068#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07006069 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07006070#endif
6071
Jeff Johnson295189b2012-06-20 16:38:30 -07006072 // Now, we're ready to "pack" the frames
6073 nStatus = dot11fPackNeighborReportRequest( pMac,
6074 &frm,
6075 pFrame + sizeof( tSirMacMgmtHdr ),
6076 nPayload,
6077 &nPayload );
6078
6079 if( DOT11F_FAILED( nStatus ))
6080 {
6081 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006082 FL( "Failed to pack an Neighbor Report Request (0x%08x)." ),
Jeff Johnson295189b2012-06-20 16:38:30 -07006083 nStatus );
6084
6085 // FIXME - Need to convert to tSirRetStatus
6086 statusCode = eSIR_FAILURE;
6087 goto returnAfterError;
6088 }
6089 else if( DOT11F_WARNED( nStatus ))
6090 {
6091 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08006092 FL( "There were warnings while packing Neighbor Report "
6093 "Request (0x%08x)." ), nStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07006094 }
6095
6096 limLog( pMac, LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006097 FL( "Sending a Neighbor Report Request to " ));
Jeff Johnson295189b2012-06-20 16:38:30 -07006098 limPrintMacAddr( pMac, peer, LOGW );
6099
6100 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07006101 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
6102 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07006103 )
6104 {
6105 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
6106 }
6107
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05306108 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
6109 psessionEntry->peSessionId,
6110 pMacHdr->fc.subType));
6111 halstatus = halTxFrame( pMac,
6112 pPacket,
6113 (tANI_U16) nBytes,
6114 HAL_TXRX_FRM_802_11_MGMT,
6115 ANI_TXDIR_TODS,
6116 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
6117 limTxComplete,
6118 pFrame, txFlag );
6119 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
6120 psessionEntry->peSessionId,
6121 halstatus));
6122 if( eHAL_STATUS_SUCCESS != halstatus )
Jeff Johnson295189b2012-06-20 16:38:30 -07006123 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006124 PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]" ), halstatus );)
Jeff Johnson295189b2012-06-20 16:38:30 -07006125 statusCode = eSIR_FAILURE;
6126 //Pkt will be freed up by the callback
6127 return statusCode;
6128 }
6129 else
6130 return eSIR_SUCCESS;
6131
6132returnAfterError:
6133 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
6134
6135 return statusCode;
6136} // End limSendNeighborReportRequestFrame.
6137
6138/**
6139 * \brief Send a Link Report Action frame
6140 *
6141 *
6142 * \param pMac Pointer to the global MAC structure
6143 *
6144 * \param pLinkReport Address of a tSirMacLinkReport
6145 *
6146 * \param peer mac address of peer station.
6147 *
6148 * \param psessionEntry address of session entry.
6149 *
6150 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
6151 *
6152 *
6153 */
6154
6155tSirRetStatus
6156limSendLinkReportActionFrame(tpAniSirGlobal pMac,
6157 tpSirMacLinkReport pLinkReport,
6158 tSirMacAddr peer,
6159 tpPESession psessionEntry
6160 )
6161{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05306162 tSirRetStatus statusCode = eSIR_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006163 tDot11fLinkMeasurementReport frm;
6164 tANI_U8 *pFrame;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05306165 tpSirMacMgmtHdr pMacHdr;
6166 tANI_U32 nBytes, nPayload, nStatus;
6167 void *pPacket;
6168 eHalStatus halstatus;
6169 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07006170
6171
6172 if ( psessionEntry == NULL )
6173 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006174 limLog( pMac, LOGE, FL("(psession == NULL) in Request to send Link Report action frame") );
Jeff Johnson295189b2012-06-20 16:38:30 -07006175 return eSIR_FAILURE;
6176 }
6177
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05306178 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07006179
6180 frm.Category.category = SIR_MAC_ACTION_RRM;
6181 frm.Action.action = SIR_MAC_RRM_LINK_MEASUREMENT_RPT;
6182 frm.DialogToken.token = pLinkReport->dialogToken;
6183
6184
6185 //IEEE Std. 802.11 7.3.2.18. for the report element.
6186 //Even though TPC report an IE, it is represented using fixed fields since it is positioned
6187 //in the middle of other fixed fields in the link report frame(IEEE Std. 802.11k section7.4.6.4
6188 //and frame parser always expects IEs to come after all fixed fields. It is easier to handle
6189 //such case this way than changing the frame parser.
6190 frm.TPCEleID.TPCId = SIR_MAC_TPC_RPT_EID;
6191 frm.TPCEleLen.TPCLen = 2;
6192 frm.TxPower.txPower = pLinkReport->txPower;
6193 frm.LinkMargin.linkMargin = 0;
6194
6195 frm.RxAntennaId.antennaId = pLinkReport->rxAntenna;
6196 frm.TxAntennaId.antennaId = pLinkReport->txAntenna;
6197 frm.RCPI.rcpi = pLinkReport->rcpi;
6198 frm.RSNI.rsni = pLinkReport->rsni;
6199
6200 nStatus = dot11fGetPackedLinkMeasurementReportSize( pMac, &frm, &nPayload );
6201 if ( DOT11F_FAILED( nStatus ) )
6202 {
6203 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006204 "or a Link Report (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07006205 nStatus );
6206 // We'll fall back on the worst case scenario:
6207 nPayload = sizeof( tDot11fLinkMeasurementReport );
6208 }
6209 else if ( DOT11F_WARNED( nStatus ) )
6210 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08006211 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07006212 "the packed size for a Link Rep"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006213 "ort (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07006214 }
6215
6216 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
6217
6218 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
6219 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
6220 {
6221 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Link "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006222 "Report."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07006223 return eSIR_FAILURE;
6224 }
6225
6226 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05306227 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07006228
6229 // Copy necessary info to BD
6230 if( eSIR_SUCCESS !=
6231 (statusCode = limPopulateMacHeader( pMac,
6232 pFrame,
6233 SIR_MAC_MGMT_FRAME,
6234 SIR_MAC_MGMT_ACTION,
6235 peer, psessionEntry->selfMacAddr)))
6236 goto returnAfterError;
6237
6238 // Update A3 with the BSSID
6239 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
6240
6241 sirCopyMacAddr( pMacHdr->bssId, psessionEntry->bssId );
6242
Chet Lanctot186b5732013-03-18 10:26:30 -07006243#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07006244 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07006245#endif
6246
Jeff Johnson295189b2012-06-20 16:38:30 -07006247 // Now, we're ready to "pack" the frames
6248 nStatus = dot11fPackLinkMeasurementReport( pMac,
6249 &frm,
6250 pFrame + sizeof( tSirMacMgmtHdr ),
6251 nPayload,
6252 &nPayload );
6253
6254 if( DOT11F_FAILED( nStatus ))
6255 {
6256 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006257 FL( "Failed to pack an Link Report (0x%08x)." ),
Jeff Johnson295189b2012-06-20 16:38:30 -07006258 nStatus );
6259
6260 // FIXME - Need to convert to tSirRetStatus
6261 statusCode = eSIR_FAILURE;
6262 goto returnAfterError;
6263 }
6264 else if( DOT11F_WARNED( nStatus ))
6265 {
6266 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08006267 FL( "There were warnings while packing Link Report (0x%08x)." ),
6268 nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07006269 }
6270
6271 limLog( pMac, LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006272 FL( "Sending a Link Report to " ));
Jeff Johnson295189b2012-06-20 16:38:30 -07006273 limPrintMacAddr( pMac, peer, LOGW );
6274
6275 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07006276 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
6277 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07006278 )
6279 {
6280 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
6281 }
6282
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05306283 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
6284 psessionEntry->peSessionId,
6285 pMacHdr->fc.subType));
6286 halstatus = halTxFrame( pMac,
6287 pPacket,
6288 (tANI_U16) nBytes,
6289 HAL_TXRX_FRM_802_11_MGMT,
6290 ANI_TXDIR_TODS,
6291 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
6292 limTxComplete,
6293 pFrame, txFlag );
6294 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
6295 psessionEntry->peSessionId,
6296 halstatus));
6297 if( eHAL_STATUS_SUCCESS != halstatus )
Jeff Johnson295189b2012-06-20 16:38:30 -07006298 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006299 PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]" ), halstatus );)
Jeff Johnson295189b2012-06-20 16:38:30 -07006300 statusCode = eSIR_FAILURE;
6301 //Pkt will be freed up by the callback
6302 return statusCode;
6303 }
6304 else
6305 return eSIR_SUCCESS;
6306
6307returnAfterError:
6308 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
6309
6310 return statusCode;
6311} // End limSendLinkReportActionFrame.
6312
6313/**
6314 * \brief Send a Beacon Report Action frame
6315 *
6316 *
6317 * \param pMac Pointer to the global MAC structure
6318 *
6319 * \param dialog_token dialog token to be used in the action frame.
6320 *
6321 * \param num_report number of reports in pRRMReport.
6322 *
6323 * \param pRRMReport Address of a tSirMacRadioMeasureReport.
6324 *
6325 * \param peer mac address of peer station.
6326 *
6327 * \param psessionEntry address of session entry.
6328 *
6329 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
6330 *
6331 *
6332 */
6333
6334tSirRetStatus
6335limSendRadioMeasureReportActionFrame(tpAniSirGlobal pMac,
6336 tANI_U8 dialog_token,
6337 tANI_U8 num_report,
6338 tpSirMacRadioMeasureReport pRRMReport,
6339 tSirMacAddr peer,
6340 tpPESession psessionEntry
6341 )
6342{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05306343 tSirRetStatus statusCode = eSIR_SUCCESS;
6344 tANI_U8 *pFrame;
6345 tpSirMacMgmtHdr pMacHdr;
6346 tANI_U32 nBytes, nPayload, nStatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07006347 void *pPacket;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05306348 eHalStatus halstatus;
6349 tANI_U8 i;
6350 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07006351
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006352 tDot11fRadioMeasurementReport *frm =
6353 vos_mem_malloc(sizeof(tDot11fRadioMeasurementReport));
6354 if (!frm) {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006355 limLog( pMac, LOGE, FL("Not enough memory to allocate tDot11fRadioMeasurementReport") );
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006356 return eSIR_FAILURE;
6357 }
6358
Jeff Johnson295189b2012-06-20 16:38:30 -07006359 if ( psessionEntry == NULL )
6360 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006361 limLog( pMac, LOGE, FL("(psession == NULL) in Request to send Beacon Report action frame") );
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006362 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07006363 return eSIR_FAILURE;
6364 }
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05306365 vos_mem_set( ( tANI_U8* )frm, sizeof( *frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07006366
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006367 frm->Category.category = SIR_MAC_ACTION_RRM;
6368 frm->Action.action = SIR_MAC_RRM_RADIO_MEASURE_RPT;
6369 frm->DialogToken.token = dialog_token;
Jeff Johnson295189b2012-06-20 16:38:30 -07006370
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006371 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 -07006372
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006373 for( i = 0 ; i < frm->num_MeasurementReport ; i++ )
Jeff Johnson295189b2012-06-20 16:38:30 -07006374 {
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006375 frm->MeasurementReport[i].type = pRRMReport[i].type;
6376 frm->MeasurementReport[i].token = pRRMReport[i].token;
6377 frm->MeasurementReport[i].late = 0; //IEEE 802.11k section 7.3.22. (always zero in rrm)
Jeff Johnson295189b2012-06-20 16:38:30 -07006378 switch( pRRMReport[i].type )
6379 {
6380 case SIR_MAC_RRM_BEACON_TYPE:
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006381 PopulateDot11fBeaconReport( pMac, &frm->MeasurementReport[i], &pRRMReport[i].report.beaconReport );
6382 frm->MeasurementReport[i].incapable = pRRMReport[i].incapable;
6383 frm->MeasurementReport[i].refused = pRRMReport[i].refused;
6384 frm->MeasurementReport[i].present = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07006385 break;
6386 default:
Gopichand Nakkala72717fd2013-02-08 12:23:45 +05306387 frm->MeasurementReport[i].incapable = pRRMReport[i].incapable;
6388 frm->MeasurementReport[i].refused = pRRMReport[i].refused;
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006389 frm->MeasurementReport[i].present = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07006390 break;
6391 }
6392 }
6393
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006394 nStatus = dot11fGetPackedRadioMeasurementReportSize( pMac, frm, &nPayload );
Jeff Johnson295189b2012-06-20 16:38:30 -07006395 if ( DOT11F_FAILED( nStatus ) )
6396 {
6397 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006398 "or a Radio Measure Report (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07006399 nStatus );
6400 // We'll fall back on the worst case scenario:
6401 nPayload = sizeof( tDot11fLinkMeasurementReport );
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006402 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07006403 return eSIR_FAILURE;
6404 }
6405 else if ( DOT11F_WARNED( nStatus ) )
6406 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08006407 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07006408 "the packed size for a Radio Measure Rep"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006409 "ort (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07006410 }
6411
6412 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
6413
6414 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
6415 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
6416 {
6417 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Radio Measure "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006418 "Report."), nBytes );
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006419 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07006420 return eSIR_FAILURE;
6421 }
6422
6423 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05306424 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07006425
6426 // Copy necessary info to BD
6427 if( eSIR_SUCCESS !=
6428 (statusCode = limPopulateMacHeader( pMac,
6429 pFrame,
6430 SIR_MAC_MGMT_FRAME,
6431 SIR_MAC_MGMT_ACTION,
6432 peer, psessionEntry->selfMacAddr)))
6433 goto returnAfterError;
6434
6435 // Update A3 with the BSSID
6436 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
6437
6438 sirCopyMacAddr( pMacHdr->bssId, psessionEntry->bssId );
6439
Chet Lanctot186b5732013-03-18 10:26:30 -07006440#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07006441 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07006442#endif
6443
Jeff Johnson295189b2012-06-20 16:38:30 -07006444 // Now, we're ready to "pack" the frames
6445 nStatus = dot11fPackRadioMeasurementReport( pMac,
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006446 frm,
Jeff Johnson295189b2012-06-20 16:38:30 -07006447 pFrame + sizeof( tSirMacMgmtHdr ),
6448 nPayload,
6449 &nPayload );
6450
6451 if( DOT11F_FAILED( nStatus ))
6452 {
6453 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006454 FL( "Failed to pack an Radio Measure Report (0x%08x)." ),
Jeff Johnson295189b2012-06-20 16:38:30 -07006455 nStatus );
6456
6457 // FIXME - Need to convert to tSirRetStatus
6458 statusCode = eSIR_FAILURE;
6459 goto returnAfterError;
6460 }
6461 else if( DOT11F_WARNED( nStatus ))
6462 {
6463 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08006464 FL( "There were warnings while packing Radio "
6465 "Measure Report (0x%08x)." ), nStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07006466 }
6467
6468 limLog( pMac, LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006469 FL( "Sending a Radio Measure Report to " ));
Jeff Johnson295189b2012-06-20 16:38:30 -07006470 limPrintMacAddr( pMac, peer, LOGW );
6471
6472 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07006473 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
6474 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07006475 )
6476 {
6477 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
6478 }
6479
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05306480 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
6481 psessionEntry->peSessionId,
6482 pMacHdr->fc.subType));
6483 halstatus = halTxFrame( pMac,
6484 pPacket,
6485 (tANI_U16) nBytes,
6486 HAL_TXRX_FRM_802_11_MGMT,
6487 ANI_TXDIR_TODS,
6488 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
6489 limTxComplete,
6490 pFrame, txFlag );
6491 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
6492 psessionEntry->peSessionId,
6493 halstatus));
6494 if( eHAL_STATUS_SUCCESS != halstatus )
Jeff Johnson295189b2012-06-20 16:38:30 -07006495 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006496 PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]" ), halstatus );)
Jeff Johnson295189b2012-06-20 16:38:30 -07006497 statusCode = eSIR_FAILURE;
6498 //Pkt will be freed up by the callback
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006499 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07006500 return statusCode;
6501 }
Madan Mohan Koyyalamudieeb56b12012-10-31 15:10:04 -07006502 else {
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006503 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07006504 return eSIR_SUCCESS;
Madan Mohan Koyyalamudieeb56b12012-10-31 15:10:04 -07006505 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006506
6507returnAfterError:
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006508 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07006509 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
Jeff Johnson295189b2012-06-20 16:38:30 -07006510 return statusCode;
6511} // End limSendBeaconReportActionFrame.
6512
6513#endif
6514
6515#ifdef WLAN_FEATURE_11W
6516/**
Chet Lanctot8cecea22014-02-11 19:09:36 -08006517 * \brief Send SA query request action frame to peer
6518 *
6519 * \sa limSendSaQueryRequestFrame
6520 *
6521 *
6522 * \param pMac The global tpAniSirGlobal object
6523 *
6524 * \param transId Transaction identifier
6525 *
6526 * \param peer The Mac address of the station to which this action frame is addressed
6527 *
6528 * \param psessionEntry The PE session entry
6529 *
6530 * \return eSIR_SUCCESS if setup completes successfully
6531 * eSIR_FAILURE is some problem is encountered
6532 */
6533
6534tSirRetStatus limSendSaQueryRequestFrame( tpAniSirGlobal pMac, tANI_U8 *transId,
6535 tSirMacAddr peer, tpPESession psessionEntry )
6536{
6537
6538 tDot11fSaQueryReq frm; // SA query request action frame
6539 tANI_U8 *pFrame;
6540 tSirRetStatus nSirStatus;
6541 tpSirMacMgmtHdr pMacHdr;
6542 tANI_U32 nBytes, nPayload, nStatus;
6543 void *pPacket;
6544 eHalStatus halstatus;
6545 tANI_U8 txFlag = 0;
6546
6547 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
6548 frm.Category.category = SIR_MAC_ACTION_SA_QUERY;
6549 /* 11w action field is :
6550 action: 0 --> SA Query Request action frame
6551 action: 1 --> SA Query Response action frame */
6552 frm.Action.action = SIR_MAC_SA_QUERY_REQ;
6553 /* 11w SA Query Request transId */
6554 vos_mem_copy( &frm.TransactionId.transId[0], &transId[0], 2 );
6555
6556 nStatus = dot11fGetPackedSaQueryReqSize(pMac, &frm, &nPayload);
6557 if ( DOT11F_FAILED( nStatus ) )
6558 {
6559 limLog( pMac, LOGP, FL("Failed to calculate the packed size "
6560 "for an SA Query Request (0x%08x)."),
6561 nStatus );
6562 // We'll fall back on the worst case scenario:
6563 nPayload = sizeof( tDot11fSaQueryReq );
6564 }
6565 else if ( DOT11F_WARNED( nStatus ) )
6566 {
6567 limLog( pMac, LOGW, FL("There were warnings while calculating "
6568 "the packed size for an SA Query Request"
6569 " (0x%08x)."), nStatus );
6570 }
6571
6572 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
6573 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
6574 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
6575 {
6576 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a SA Query Request "
6577 "action frame"), nBytes );
6578 return eSIR_FAILURE;
6579 }
6580
6581 // Paranoia:
6582 vos_mem_set( pFrame, nBytes, 0 );
6583
6584 // Copy necessary info to BD
6585 nSirStatus = limPopulateMacHeader( pMac,
6586 pFrame,
6587 SIR_MAC_MGMT_FRAME,
6588 SIR_MAC_MGMT_ACTION,
6589 peer, psessionEntry->selfMacAddr );
6590 if ( eSIR_SUCCESS != nSirStatus )
6591 goto returnAfterError;
6592
6593 // Update A3 with the BSSID
6594 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
6595
6596 sirCopyMacAddr( pMacHdr->bssId, psessionEntry->bssId );
6597
6598 // Since this is a SA Query Request, set the "protect" (aka WEP) bit
6599 // in the FC
6600 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
6601
6602 // Pack 11w SA Query Request frame
6603 nStatus = dot11fPackSaQueryReq( pMac,
6604 &frm,
6605 pFrame + sizeof( tSirMacMgmtHdr ),
6606 nPayload,
6607 &nPayload );
6608
6609 if ( DOT11F_FAILED( nStatus ))
6610 {
6611 limLog( pMac, LOGE,
6612 FL( "Failed to pack an SA Query Request (0x%08x)." ),
6613 nStatus );
6614 // FIXME - Need to convert to tSirRetStatus
6615 nSirStatus = eSIR_FAILURE;
6616 goto returnAfterError;
6617 }
6618 else if ( DOT11F_WARNED( nStatus ))
6619 {
6620 limLog( pMac, LOGW,
6621 FL( "There were warnings while packing SA Query Request (0x%08x)." ),
6622 nStatus);
6623 }
6624
6625 limLog( pMac, LOG1,
6626 FL( "Sending an SA Query Request to " ));
6627 limPrintMacAddr( pMac, peer, LOG1 );
6628 limPrintMacAddr( pMac, peer, LOGE );
6629 limLog( pMac, LOGE,
6630 FL( "Sending an SA Query Request from " ));
6631 limPrintMacAddr( pMac, psessionEntry->selfMacAddr, LOGE );
6632
6633 if ( ( SIR_BAND_5_GHZ == limGetRFBand( psessionEntry->currentOperChannel ) )
6634#ifdef WLAN_FEATURE_P2P
6635 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
6636 ( psessionEntry->pePersona == VOS_P2P_GO_MODE )
6637#endif
6638 )
6639 {
6640 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
6641 }
6642
6643 halstatus = halTxFrame( pMac,
6644 pPacket,
6645 (tANI_U16) nBytes,
6646 HAL_TXRX_FRM_802_11_MGMT,
6647 ANI_TXDIR_TODS,
6648 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
6649 limTxComplete,
6650 pFrame, txFlag );
6651 if ( eHAL_STATUS_SUCCESS != halstatus )
6652 {
6653 PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]" ), halstatus );)
6654 nSirStatus = eSIR_FAILURE;
6655 //Pkt will be freed up by the callback
6656 return nSirStatus;
6657 }
6658 else {
6659 return eSIR_SUCCESS;
6660 }
6661
6662returnAfterError:
6663 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
6664 return nSirStatus;
6665} // End limSendSaQueryRequestFrame
6666
6667/**
Jeff Johnson295189b2012-06-20 16:38:30 -07006668 * \brief Send SA query response action frame to peer
6669 *
6670 * \sa limSendSaQueryResponseFrame
6671 *
6672 *
6673 * \param pMac The global tpAniSirGlobal object
6674 *
Chet Lanctot186b5732013-03-18 10:26:30 -07006675 * \param transId Transaction identifier received in SA query request action frame
Jeff Johnson295189b2012-06-20 16:38:30 -07006676 *
Chet Lanctot186b5732013-03-18 10:26:30 -07006677 * \param peer The Mac address of the AP to which this action frame is addressed
6678 *
6679 * \param psessionEntry The PE session entry
Jeff Johnson295189b2012-06-20 16:38:30 -07006680 *
6681 * \return eSIR_SUCCESS if setup completes successfully
6682 * eSIR_FAILURE is some problem is encountered
6683 */
6684
Chet Lanctot186b5732013-03-18 10:26:30 -07006685tSirRetStatus limSendSaQueryResponseFrame( tpAniSirGlobal pMac, tANI_U8 *transId,
Jeff Johnson295189b2012-06-20 16:38:30 -07006686tSirMacAddr peer,tpPESession psessionEntry)
6687{
6688
Chet Lanctot186b5732013-03-18 10:26:30 -07006689 tDot11fSaQueryRsp frm; // SA query reponse action frame
Jeff Johnson295189b2012-06-20 16:38:30 -07006690 tANI_U8 *pFrame;
6691 tSirRetStatus nSirStatus;
6692 tpSirMacMgmtHdr pMacHdr;
Chet Lanctot186b5732013-03-18 10:26:30 -07006693 tANI_U32 nBytes, nPayload, nStatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07006694 void *pPacket;
6695 eHalStatus halstatus;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05306696 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07006697
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05306698 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Chet Lanctot186b5732013-03-18 10:26:30 -07006699 frm.Category.category = SIR_MAC_ACTION_SA_QUERY;
6700 /*11w action field is :
Jeff Johnson295189b2012-06-20 16:38:30 -07006701 action: 0 --> SA query request action frame
6702 action: 1 --> SA query response action frame */
Chet Lanctot186b5732013-03-18 10:26:30 -07006703 frm.Action.action = SIR_MAC_SA_QUERY_RSP;
6704 /*11w SA query response transId is same as
Jeff Johnson295189b2012-06-20 16:38:30 -07006705 SA query request transId*/
Chet Lanctot186b5732013-03-18 10:26:30 -07006706 vos_mem_copy( &frm.TransactionId.transId[0], &transId[0], 2 );
Jeff Johnson295189b2012-06-20 16:38:30 -07006707
Chet Lanctot186b5732013-03-18 10:26:30 -07006708 nStatus = dot11fGetPackedSaQueryRspSize(pMac, &frm, &nPayload);
6709 if ( DOT11F_FAILED( nStatus ) )
6710 {
6711 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
6712 "or a SA Query Response (0x%08x)."),
6713 nStatus );
6714 // We'll fall back on the worst case scenario:
6715 nPayload = sizeof( tDot11fSaQueryRsp );
6716 }
6717 else if ( DOT11F_WARNED( nStatus ) )
6718 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08006719 limLog( pMac, LOGW, FL("There were warnings while calculating "
Chet Lanctot186b5732013-03-18 10:26:30 -07006720 "the packed size for an SA Query Response"
6721 " (0x%08x)."), nStatus );
6722 }
6723
Jeff Johnson295189b2012-06-20 16:38:30 -07006724 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
6725 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
6726 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
6727 {
6728 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a SA query response"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006729 " action frame"), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07006730 return eSIR_FAILURE;
6731 }
6732
6733 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05306734 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07006735
Chet Lanctot186b5732013-03-18 10:26:30 -07006736 // Copy necessary info to BD
Chet Lanctotb2b0d552013-03-22 16:58:44 -07006737 nSirStatus = limPopulateMacHeader( pMac,
Chet Lanctot186b5732013-03-18 10:26:30 -07006738 pFrame,
6739 SIR_MAC_MGMT_FRAME,
6740 SIR_MAC_MGMT_ACTION,
Chet Lanctotb2b0d552013-03-22 16:58:44 -07006741 peer, psessionEntry->selfMacAddr );
6742 if ( eSIR_SUCCESS != nSirStatus )
Chet Lanctot186b5732013-03-18 10:26:30 -07006743 goto returnAfterError;
Jeff Johnson295189b2012-06-20 16:38:30 -07006744
Chet Lanctot186b5732013-03-18 10:26:30 -07006745 // Update A3 with the BSSID
Jeff Johnson295189b2012-06-20 16:38:30 -07006746 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
6747
Chet Lanctot186b5732013-03-18 10:26:30 -07006748 sirCopyMacAddr( pMacHdr->bssId, psessionEntry->bssId );
Jeff Johnson295189b2012-06-20 16:38:30 -07006749
Chet Lanctot186b5732013-03-18 10:26:30 -07006750 // Since this is a SA Query Response, set the "protect" (aka WEP) bit
6751 // in the FC
Chet Lanctot8cecea22014-02-11 19:09:36 -08006752 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Jeff Johnson295189b2012-06-20 16:38:30 -07006753
Chet Lanctot186b5732013-03-18 10:26:30 -07006754 // Pack 11w SA query response frame
6755 nStatus = dot11fPackSaQueryRsp( pMac,
6756 &frm,
6757 pFrame + sizeof( tSirMacMgmtHdr ),
6758 nPayload,
6759 &nPayload );
6760
6761 if ( DOT11F_FAILED( nStatus ))
6762 {
6763 limLog( pMac, LOGE,
6764 FL( "Failed to pack an SA Query Response (0x%08x)." ),
6765 nStatus );
6766 // FIXME - Need to convert to tSirRetStatus
6767 nSirStatus = eSIR_FAILURE;
6768 goto returnAfterError;
6769 }
6770 else if ( DOT11F_WARNED( nStatus ))
6771 {
6772 limLog( pMac, LOGW,
6773 FL( "There were warnings while packing SA Query Response (0x%08x)." ),
6774 nStatus);
6775 }
6776
6777 limLog( pMac, LOG1,
6778 FL( "Sending a SA Query Response to " ));
6779 limPrintMacAddr( pMac, peer, LOGW );
6780
Chet Lanctotb2b0d552013-03-22 16:58:44 -07006781 if ( ( SIR_BAND_5_GHZ == limGetRFBand( psessionEntry->currentOperChannel ) )
Chet Lanctot186b5732013-03-18 10:26:30 -07006782#ifdef WLAN_FEATURE_P2P
Chet Lanctotb2b0d552013-03-22 16:58:44 -07006783 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
6784 ( psessionEntry->pePersona == VOS_P2P_GO_MODE )
Chet Lanctot186b5732013-03-18 10:26:30 -07006785#endif
Chet Lanctotb2b0d552013-03-22 16:58:44 -07006786 )
6787 {
6788 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
6789 }
Chet Lanctot186b5732013-03-18 10:26:30 -07006790
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05306791 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
6792 psessionEntry->peSessionId,
6793 pMacHdr->fc.subType));
Chet Lanctotb2b0d552013-03-22 16:58:44 -07006794 halstatus = halTxFrame( pMac,
6795 pPacket,
6796 (tANI_U16) nBytes,
6797 HAL_TXRX_FRM_802_11_MGMT,
6798 ANI_TXDIR_TODS,
6799 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
6800 limTxComplete,
6801 pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05306802 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
6803 psessionEntry->peSessionId,
6804 halstatus));
Chet Lanctotb2b0d552013-03-22 16:58:44 -07006805 if ( eHAL_STATUS_SUCCESS != halstatus )
Chet Lanctot186b5732013-03-18 10:26:30 -07006806 {
6807 PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]" ), halstatus );)
6808 nSirStatus = eSIR_FAILURE;
6809 //Pkt will be freed up by the callback
6810 return nSirStatus;
6811 }
6812 else {
6813 return eSIR_SUCCESS;
6814 }
6815
6816returnAfterError:
6817 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
6818 return nSirStatus;
6819} // End limSendSaQueryResponseFrame
Jeff Johnson295189b2012-06-20 16:38:30 -07006820#endif