blob: 15b61942b8e7339ba3a4ebacf57a0b0660d23621 [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
65
66////////////////////////////////////////////////////////////////////////
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;
Sandeep Puligilla60342762014-01-30 21:05:37 +0530320 tANI_U32 chanbond24G = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700321
322#ifndef GEN4_SCAN
323 return eSIR_FAILURE;
324#endif
325
326#if defined ( ANI_DVT_DEBUG )
327 return eSIR_FAILURE;
328#endif
329
Abhishek Singh4beed422014-02-03 16:47:17 +0530330 /* The probe req should not send 11ac capabilieties if band is 2.4GHz,
331 * unless enableVhtFor24GHz is enabled in INI. So if enableVhtFor24GHz
332 * is false and dot11mode is 11ac set it to 11n.
333 */
334 if ( nChannelNum <= SIR_11B_CHANNEL_END &&
335 ( FALSE == pMac->roam.configParam.enableVhtFor24GHz ) &&
336 ( WNI_CFG_DOT11_MODE_11AC == dot11mode ||
337 WNI_CFG_DOT11_MODE_11AC_ONLY == dot11mode ) )
338 dot11mode = WNI_CFG_DOT11_MODE_11N;
Jeff Johnson295189b2012-06-20 16:38:30 -0700339 /*
340 * session context may or may not be present, when probe request needs to be sent out.
341 * following cases exist:
342 * --heartbeat failure: session needed
343 * --join req: session needed
344 * --foreground scan: no session
345 * --background scan: no session
346 * --schBeaconProcessing: to get EDCA parameters: session needed
347 * If session context does not exist, some IEs will be populated from CFGs,
348 * e.g. Supported and Extended rate set IEs
349 */
350 psessionEntry = peFindSessionByBssid(pMac,bssid,&sessionId);
351
352 // The scheme here is to fill out a 'tDot11fProbeRequest' structure
353 // and then hand it off to 'dot11fPackProbeRequest' (for
354 // serialization). We start by zero-initializing the structure:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530355 vos_mem_set(( tANI_U8* )&pr, sizeof( pr ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700356
357 // & delegating to assorted helpers:
358 PopulateDot11fSSID( pMac, pSsid, &pr.SSID );
359
Jeff Johnson295189b2012-06-20 16:38:30 -0700360 if( nAdditionalIELen && pAdditionalIE )
361 {
362 p2pIe = limGetP2pIEPtr(pMac, pAdditionalIE, nAdditionalIELen);
363 }
Jeff Johnsone7245742012-09-05 17:12:55 -0700364 /* Don't include 11b rate only when device is doing P2P Search */
365 if( ( WNI_CFG_DOT11_MODE_11B != dot11mode ) &&
366 ( p2pIe != NULL ) &&
367 /* Don't include 11b rate if it is a P2P serach or probe request is sent by P2P Client */
368 ( ( ( pMac->lim.gpLimMlmScanReq != NULL ) &&
369 pMac->lim.gpLimMlmScanReq->p2pSearch ) ||
370 ( ( psessionEntry != NULL ) &&
371 ( VOS_P2P_CLIENT_MODE == psessionEntry->pePersona ) )
372 )
373 )
Jeff Johnson295189b2012-06-20 16:38:30 -0700374 {
375 /* In the below API pass channel number > 14, do that it fills only
376 * 11a rates in supported rates */
377 PopulateDot11fSuppRates( pMac, 15, &pr.SuppRates,psessionEntry);
378 }
379 else
380 {
Jeff Johnson295189b2012-06-20 16:38:30 -0700381 PopulateDot11fSuppRates( pMac, nChannelNum,
382 &pr.SuppRates,psessionEntry);
383
384 if ( WNI_CFG_DOT11_MODE_11B != dot11mode )
385 {
386 PopulateDot11fExtSuppRates1( pMac, nChannelNum, &pr.ExtSuppRates );
387 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700388 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700389
390#if defined WLAN_FEATURE_VOWIFI
391 //Table 7-14 in IEEE Std. 802.11k-2008 says
392 //DS params "can" be present in RRM is disabled and "is" present if
393 //RRM is enabled. It should be ok even if we add it into probe req when
394 //RRM is not enabled.
395 PopulateDot11fDSParams( pMac, &pr.DSParams, nChannelNum, psessionEntry );
396 //Call RRM module to get the tx power for management used.
397 {
398 tANI_U8 txPower = (tANI_U8) rrmGetMgmtTxPower( pMac, psessionEntry );
399 PopulateDot11fWFATPC( pMac, &pr.WFATPC, txPower, 0 );
400 }
401#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700402
403 if (psessionEntry != NULL ) {
Jeff Johnsone7245742012-09-05 17:12:55 -0700404 psessionEntry->htCapability = IS_DOT11_MODE_HT(dot11mode);
Jeff Johnson295189b2012-06-20 16:38:30 -0700405 //Include HT Capability IE
Jeff Johnsone7245742012-09-05 17:12:55 -0700406 if (psessionEntry->htCapability)
Jeff Johnson295189b2012-06-20 16:38:30 -0700407 {
Jeff Johnsone7245742012-09-05 17:12:55 -0700408 PopulateDot11fHTCaps( pMac, psessionEntry, &pr.HTCaps );
Jeff Johnson295189b2012-06-20 16:38:30 -0700409 }
Jeff Johnsone7245742012-09-05 17:12:55 -0700410 } else { //psessionEntry == NULL
411 if (IS_DOT11_MODE_HT(dot11mode))
Jeff Johnson295189b2012-06-20 16:38:30 -0700412 {
Jeff Johnsone7245742012-09-05 17:12:55 -0700413 PopulateDot11fHTCaps( pMac, psessionEntry, &pr.HTCaps );
Jeff Johnson295189b2012-06-20 16:38:30 -0700414 }
415 }
Gopichand Nakkala40bc6502012-12-20 16:55:36 -0800416
Sandeep Puligilla60342762014-01-30 21:05:37 +0530417 /* Get HT40 capability for 2.4GHz band */
418 wlan_cfgGetInt(pMac,WNI_CFG_CHANNEL_BONDING_24G,&chanbond24G);
419 if( (nChannelNum <= SIR_11B_CHANNEL_END) && chanbond24G != TRUE)
Gopichand Nakkala40bc6502012-12-20 16:55:36 -0800420 {
421 pr.HTCaps.supportedChannelWidthSet = eHT_CHANNEL_WIDTH_20MHZ;
422 pr.HTCaps.shortGI40MHz = 0;
423 }
Jeff Johnsone7245742012-09-05 17:12:55 -0700424#ifdef WLAN_FEATURE_11AC
425 if (psessionEntry != NULL ) {
426 psessionEntry->vhtCapability = IS_DOT11_MODE_VHT(dot11mode);
427 //Include HT Capability IE
428 if (psessionEntry->vhtCapability)
429 {
Abhishek Singh6d5d29c2014-07-03 14:25:22 +0530430 PopulateDot11fVHTCaps( pMac, &pr.VHTCaps, eSIR_FALSE );
Jeff Johnsone7245742012-09-05 17:12:55 -0700431 }
432 } else {
433 if (IS_DOT11_MODE_VHT(dot11mode))
434 {
Abhishek Singh6d5d29c2014-07-03 14:25:22 +0530435 PopulateDot11fVHTCaps( pMac, &pr.VHTCaps, eSIR_FALSE );
Jeff Johnsone7245742012-09-05 17:12:55 -0700436 }
437 }
438#endif
439
Jeff Johnson295189b2012-06-20 16:38:30 -0700440
441 // That's it-- now we pack it. First, how much space are we going to
442 // need?
443 nStatus = dot11fGetPackedProbeRequestSize( pMac, &pr, &nPayload );
444 if ( DOT11F_FAILED( nStatus ) )
445 {
446 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700447 "or a Probe Request (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -0700448 // We'll fall back on the worst case scenario:
449 nPayload = sizeof( tDot11fProbeRequest );
450 }
451 else if ( DOT11F_WARNED( nStatus ) )
452 {
453 limLog( pMac, LOGW, FL("There were warnings while calculating"
454 "the packed size for a Probe Request ("
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700455 "0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -0700456 }
457
458 nBytes = nPayload + sizeof( tSirMacMgmtHdr ) + nAdditionalIELen;
459
460 // Ok-- try to allocate some memory:
461 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
462 ( tANI_U16 )nBytes, ( void** ) &pFrame,
463 ( void** ) &pPacket );
464 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
465 {
466 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Pro"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700467 "be Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -0700468 return eSIR_MEM_ALLOC_FAILED;
469 }
470
471 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530472 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -0700473
474 // Next, we fill out the buffer descriptor:
475 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530476 SIR_MAC_MGMT_PROBE_REQ, bssid, SelfMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -0700477 if ( eSIR_SUCCESS != nSirStatus )
478 {
479 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700480 "tor for a Probe Request (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -0700481 nSirStatus );
482 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
483 ( void* ) pFrame, ( void* ) pPacket );
484 return nSirStatus; // allocated!
485 }
486
487 // That done, pack the Probe Request:
488 nStatus = dot11fPackProbeRequest( pMac, &pr, pFrame +
489 sizeof( tSirMacMgmtHdr ),
490 nPayload, &nPayload );
491 if ( DOT11F_FAILED( nStatus ) )
492 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700493 limLog( pMac, LOGE, FL("Failed to pack a Probe Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -0700494 nStatus );
495 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
496 return eSIR_FAILURE; // allocated!
497 }
498 else if ( DOT11F_WARNED( nStatus ) )
499 {
500 limLog( pMac, LOGW, FL("There were warnings while packing a P"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -0800501 "robe Request (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -0700502 }
503
504 // Append any AddIE if present.
505 if( nAdditionalIELen )
506 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530507 vos_mem_copy( pFrame+sizeof(tSirMacMgmtHdr)+nPayload,
Jeff Johnson295189b2012-06-20 16:38:30 -0700508 pAdditionalIE, nAdditionalIELen );
509 nPayload += nAdditionalIELen;
510 }
511
512 /* If this probe request is sent during P2P Search State, then we need
513 * to send it at OFDM rate.
514 */
515 if( ( SIR_BAND_5_GHZ == limGetRFBand(nChannelNum))
Jeff Johnson295189b2012-06-20 16:38:30 -0700516 || (( pMac->lim.gpLimMlmScanReq != NULL) &&
517 pMac->lim.gpLimMlmScanReq->p2pSearch )
Gopichand Nakkala67967212013-02-15 17:31:15 +0530518 /* For unicast probe req mgmt from Join function
519 we don't set above variables. So we need to add
520 one more check whether it is pePersona is P2P_CLIENT or not */
521 || ( ( psessionEntry != NULL ) &&
522 ( VOS_P2P_CLIENT_MODE == psessionEntry->pePersona ) )
Jeff Johnson295189b2012-06-20 16:38:30 -0700523 )
524 {
525 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
526 }
527
Jeff Johnson295189b2012-06-20 16:38:30 -0700528 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) sizeof(tSirMacMgmtHdr) + nPayload,
529 HAL_TXRX_FRM_802_11_MGMT,
530 ANI_TXDIR_TODS,
531 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
532 limTxComplete, pFrame, txFlag );
533 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
534 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700535 limLog( pMac, LOGE, FL("could not send Probe Request frame!" ));
Jeff Johnson295189b2012-06-20 16:38:30 -0700536 //Pkt will be freed up by the callback
537 return eSIR_FAILURE;
538 }
539
540 return eSIR_SUCCESS;
541} // End limSendProbeReqMgmtFrame.
542
Jeff Johnson295189b2012-06-20 16:38:30 -0700543tSirRetStatus limGetAddnIeForProbeResp(tpAniSirGlobal pMac,
544 tANI_U8* addIE, tANI_U16 *addnIELen,
545 tANI_U8 probeReqP2pIe)
546{
547 /* If Probe request doesn't have P2P IE, then take out P2P IE
548 from additional IE */
549 if(!probeReqP2pIe)
550 {
551 tANI_U8* tempbuf = NULL;
552 tANI_U16 tempLen = 0;
553 int left = *addnIELen;
554 v_U8_t *ptr = addIE;
555 v_U8_t elem_id, elem_len;
556
557 if(NULL == addIE)
558 {
559 PELOGE(limLog(pMac, LOGE,
560 FL(" NULL addIE pointer"));)
561 return eSIR_FAILURE;
562 }
563
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530564 tempbuf = vos_mem_malloc(left);
565 if ( NULL == tempbuf )
Jeff Johnson295189b2012-06-20 16:38:30 -0700566 {
567 PELOGE(limLog(pMac, LOGE,
568 FL("Unable to allocate memory to store addn IE"));)
569 return eSIR_MEM_ALLOC_FAILED;
570 }
571
572 while(left >= 2)
573 {
574 elem_id = ptr[0];
575 elem_len = ptr[1];
576 left -= 2;
577 if(elem_len > left)
578 {
579 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700580 FL("****Invalid IEs eid = %d elem_len=%d left=%d*****"),
Jeff Johnson295189b2012-06-20 16:38:30 -0700581 elem_id,elem_len,left);
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530582 vos_mem_free(tempbuf);
Jeff Johnson295189b2012-06-20 16:38:30 -0700583 return eSIR_FAILURE;
584 }
585 if ( !( (SIR_MAC_EID_VENDOR == elem_id) &&
586 (memcmp(&ptr[2], SIR_MAC_P2P_OUI, SIR_MAC_P2P_OUI_SIZE)==0) ) )
587 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530588 vos_mem_copy (tempbuf + tempLen, &ptr[0], elem_len + 2);
Jeff Johnson295189b2012-06-20 16:38:30 -0700589 tempLen += (elem_len + 2);
590 }
591 left -= elem_len;
592 ptr += (elem_len + 2);
593 }
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530594 vos_mem_copy (addIE, tempbuf, tempLen);
Jeff Johnson295189b2012-06-20 16:38:30 -0700595 *addnIELen = tempLen;
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530596 vos_mem_free(tempbuf);
Jeff Johnson295189b2012-06-20 16:38:30 -0700597 }
598 return eSIR_SUCCESS;
599}
Jeff Johnson295189b2012-06-20 16:38:30 -0700600
601void
602limSendProbeRspMgmtFrame(tpAniSirGlobal pMac,
603 tSirMacAddr peerMacAddr,
604 tpAniSSID pSsid,
605 short nStaId,
606 tANI_U8 nKeepAlive,
607 tpPESession psessionEntry,
608 tANI_U8 probeReqP2pIe)
609{
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700610 tDot11fProbeResponse *pFrm;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +0530611 tSirRetStatus nSirStatus;
c_hpothubcd78652014-04-28 22:31:08 +0530612 tANI_U32 cfg, nPayload, nStatus;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +0530613 tpSirMacMgmtHdr pMacHdr;
614 tANI_U8 *pFrame;
615 void *pPacket;
616 eHalStatus halstatus;
617 tANI_U32 addnIEPresent;
618 tANI_U32 addnIE1Len=0;
619 tANI_U32 addnIE2Len=0;
620 tANI_U32 addnIE3Len=0;
621 tANI_U16 totalAddnIeLen = 0;
622 tANI_U32 wpsApEnable=0, tmp;
623 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700624 tANI_U8 *addIE = NULL;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +0530625 tANI_U8 *pP2pIe = NULL;
626 tANI_U8 noaLen = 0;
627 tANI_U8 total_noaLen = 0;
628 tANI_U8 noaStream[SIR_MAX_NOA_ATTR_LEN
Jeff Johnson295189b2012-06-20 16:38:30 -0700629 + SIR_P2P_IE_HEADER_LEN];
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +0530630 tANI_U8 noaIe[SIR_MAX_NOA_ATTR_LEN + SIR_P2P_IE_HEADER_LEN];
Kalikinkar dhara205da782014-03-21 15:49:32 -0700631 tDot11fIEExtCap extractedExtCap;
632 tANI_BOOLEAN extractedExtCapFlag = eANI_BOOLEAN_TRUE;
c_hpothubcd78652014-04-28 22:31:08 +0530633 tANI_U32 nBytes = 0;
634
Jeff Johnson295189b2012-06-20 16:38:30 -0700635 if(pMac->gDriverType == eDRIVER_TYPE_MFG) // We don't answer requests
636 {
637 return; // in this case.
638 }
639
640 if(NULL == psessionEntry)
641 {
642 return;
643 }
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530644
645 pFrm = vos_mem_malloc(sizeof(tDot11fProbeResponse));
646 if ( NULL == pFrm )
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700647 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530648 limLog(pMac, LOGE, FL("Unable to allocate memory in limSendProbeRspMgmtFrame") );
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700649 return;
650 }
651
Girish Gowli0e826792014-05-17 17:56:44 +0530652 vos_mem_set(( tANI_U8* )&extractedExtCap, sizeof( tDot11fIEExtCap ), 0);
653
Jeff Johnson295189b2012-06-20 16:38:30 -0700654 // Fill out 'frm', after which we'll just hand the struct off to
655 // 'dot11fPackProbeResponse'.
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530656 vos_mem_set(( tANI_U8* )pFrm, sizeof( tDot11fProbeResponse ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700657
658 // Timestamp to be updated by TFP, below.
659
660 // Beacon Interval:
Jeff Johnson295189b2012-06-20 16:38:30 -0700661 if(psessionEntry->limSystemRole == eLIM_AP_ROLE)
662 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700663 pFrm->BeaconInterval.interval = pMac->sch.schObject.gSchBeaconInterval;
Jeff Johnson295189b2012-06-20 16:38:30 -0700664 }
665 else
666 {
Jeff Johnson3c3e1782013-02-27 10:48:42 -0800667 nSirStatus = wlan_cfgGetInt( pMac, WNI_CFG_BEACON_INTERVAL, &cfg);
668 if (eSIR_SUCCESS != nSirStatus)
669 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700670 limLog( pMac, LOGP, FL("Failed to retrieve WNI_CFG_BEACON_INTERVAL from CFG (%d)."),
Jeff Johnson3c3e1782013-02-27 10:48:42 -0800671 nSirStatus );
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530672 vos_mem_free(pFrm);
Jeff Johnson3c3e1782013-02-27 10:48:42 -0800673 return;
674 }
675 pFrm->BeaconInterval.interval = ( tANI_U16 ) cfg;
Madan Mohan Koyyalamudic0d1b3f2012-11-13 10:41:07 -0800676 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700677
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700678 PopulateDot11fCapabilities( pMac, &pFrm->Capabilities, psessionEntry );
679 PopulateDot11fSSID( pMac, ( tSirMacSSid* )pSsid, &pFrm->SSID );
Jeff Johnson295189b2012-06-20 16:38:30 -0700680 PopulateDot11fSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700681 &pFrm->SuppRates,psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -0700682
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700683 PopulateDot11fDSParams( pMac, &pFrm->DSParams, psessionEntry->currentOperChannel,psessionEntry);
684 PopulateDot11fIBSSParams( pMac, &pFrm->IBSSParams, psessionEntry );
Jeff Johnson295189b2012-06-20 16:38:30 -0700685
Jeff Johnson295189b2012-06-20 16:38:30 -0700686
Jeff Johnson295189b2012-06-20 16:38:30 -0700687 if(psessionEntry->limSystemRole == eLIM_AP_ROLE)
688 {
689 if(psessionEntry->wps_state != SAP_WPS_DISABLED)
690 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700691 PopulateDot11fProbeResWPSIEs(pMac, &pFrm->WscProbeRes, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -0700692 }
693 }
694 else
695 {
Jeff Johnson3c3e1782013-02-27 10:48:42 -0800696 if (wlan_cfgGetInt(pMac, (tANI_U16) WNI_CFG_WPS_ENABLE, &tmp) != eSIR_SUCCESS)
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700697 limLog(pMac, LOGP,"Failed to cfg get id %d", WNI_CFG_WPS_ENABLE );
Jeff Johnson295189b2012-06-20 16:38:30 -0700698
Jeff Johnson3c3e1782013-02-27 10:48:42 -0800699 wpsApEnable = tmp & WNI_CFG_WPS_ENABLE_AP;
Jeff Johnson295189b2012-06-20 16:38:30 -0700700
Jeff Johnson3c3e1782013-02-27 10:48:42 -0800701 if (wpsApEnable)
702 {
703 PopulateDot11fWscInProbeRes(pMac, &pFrm->WscProbeRes);
704 }
705
706 if (pMac->lim.wscIeInfo.probeRespWscEnrollmentState == eLIM_WSC_ENROLL_BEGIN)
707 {
708 PopulateDot11fWscRegistrarInfoInProbeRes(pMac, &pFrm->WscProbeRes);
709 pMac->lim.wscIeInfo.probeRespWscEnrollmentState = eLIM_WSC_ENROLL_IN_PROGRESS;
710 }
711
712 if (pMac->lim.wscIeInfo.wscEnrollmentState == eLIM_WSC_ENROLL_END)
713 {
714 DePopulateDot11fWscRegistrarInfoInProbeRes(pMac, &pFrm->WscProbeRes);
715 pMac->lim.wscIeInfo.probeRespWscEnrollmentState = eLIM_WSC_ENROLL_NOOP;
716 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700717 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700718
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700719 PopulateDot11fCountry( pMac, &pFrm->Country, psessionEntry);
720 PopulateDot11fEDCAParamSet( pMac, &pFrm->EDCAParamSet, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -0700721
Jeff Johnson295189b2012-06-20 16:38:30 -0700722
723 if (psessionEntry->dot11mode != WNI_CFG_DOT11_MODE_11B)
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700724 PopulateDot11fERPInfo( pMac, &pFrm->ERPInfo, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -0700725
726
727 // N.B. In earlier implementations, the RSN IE would be placed in
728 // the frame here, before the WPA IE, if 'RSN_BEFORE_WPA' was defined.
729 PopulateDot11fExtSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700730 &pFrm->ExtSuppRates, psessionEntry );
Jeff Johnson295189b2012-06-20 16:38:30 -0700731
732 //Populate HT IEs, when operating in 11n or Taurus modes.
Jeff Johnsone7245742012-09-05 17:12:55 -0700733 if ( psessionEntry->htCapability )
Jeff Johnson295189b2012-06-20 16:38:30 -0700734 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700735 PopulateDot11fHTCaps( pMac, psessionEntry, &pFrm->HTCaps );
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700736 PopulateDot11fHTInfo( pMac, &pFrm->HTInfo, psessionEntry );
Jeff Johnson295189b2012-06-20 16:38:30 -0700737 }
Jeff Johnsone7245742012-09-05 17:12:55 -0700738#ifdef WLAN_FEATURE_11AC
739 if(psessionEntry->vhtCapability)
740 {
Chet Lanctotf19c1f62013-12-13 13:56:21 -0800741 limLog( pMac, LOG1, FL("Populate VHT IE in Probe Response"));
Abhishek Singh6d5d29c2014-07-03 14:25:22 +0530742 PopulateDot11fVHTCaps( pMac, &pFrm->VHTCaps, eSIR_TRUE );
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700743 PopulateDot11fVHTOperation( pMac, &pFrm->VHTOperation );
Jeff Johnsone7245742012-09-05 17:12:55 -0700744 // we do not support multi users yet
745 //PopulateDot11fVHTExtBssLoad( pMac, &frm.VHTExtBssLoad );
Sandeep Puligilla60342762014-01-30 21:05:37 +0530746 PopulateDot11fExtCap( pMac, &pFrm->ExtCap, psessionEntry);
Jeff Johnsone7245742012-09-05 17:12:55 -0700747 }
748#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700749
Sandeep Puligilla60342762014-01-30 21:05:37 +0530750
Jeff Johnson295189b2012-06-20 16:38:30 -0700751 if ( psessionEntry->pLimStartBssReq )
752 {
753 PopulateDot11fWPA( pMac, &( psessionEntry->pLimStartBssReq->rsnIE ),
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700754 &pFrm->WPA );
Chet Lanctot4b9abd72013-06-27 11:14:56 -0700755 PopulateDot11fRSNOpaque( pMac, &( psessionEntry->pLimStartBssReq->rsnIE ),
756 &pFrm->RSNOpaque );
Jeff Johnson295189b2012-06-20 16:38:30 -0700757 }
758
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700759 PopulateDot11fWMM( pMac, &pFrm->WMMInfoAp, &pFrm->WMMParams, &pFrm->WMMCaps, psessionEntry );
Jeff Johnson295189b2012-06-20 16:38:30 -0700760
761#if defined(FEATURE_WLAN_WAPI)
762 if( psessionEntry->pLimStartBssReq )
763 {
764 PopulateDot11fWAPI( pMac, &( psessionEntry->pLimStartBssReq->rsnIE ),
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700765 &pFrm->WAPI );
Jeff Johnson295189b2012-06-20 16:38:30 -0700766 }
767
768#endif // defined(FEATURE_WLAN_WAPI)
769
Jeff Johnson295189b2012-06-20 16:38:30 -0700770 addnIEPresent = false;
Jeff Johnson295189b2012-06-20 16:38:30 -0700771 if( pMac->lim.gpLimRemainOnChanReq )
772 {
773 nBytes += (pMac->lim.gpLimRemainOnChanReq->length - sizeof( tSirRemainOnChnReq ) );
774 }
775 //Only use CFG for non-listen mode. This CFG is not working for concurrency
776 //In listening mode, probe rsp IEs is passed in the message from SME to PE
777 else
Jeff Johnson295189b2012-06-20 16:38:30 -0700778 {
779
780 if (wlan_cfgGetInt(pMac, WNI_CFG_PROBE_RSP_ADDNIE_FLAG,
781 &addnIEPresent) != eSIR_SUCCESS)
782 {
783 limLog(pMac, LOGP, FL("Unable to get WNI_CFG_PROBE_RSP_ADDNIE_FLAG"));
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530784 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700785 return;
786 }
787 }
788
789 if (addnIEPresent)
790 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530791
792 addIE = vos_mem_malloc(WNI_CFG_PROBE_RSP_ADDNIE_DATA1_LEN*3);
793 if ( NULL == addIE )
Jeff Johnson295189b2012-06-20 16:38:30 -0700794 {
795 PELOGE(limLog(pMac, LOGE,
796 FL("Unable to allocate memory to store addn IE"));)
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530797 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700798 return;
799 }
800
801 //Probe rsp IE available
802 if ( eSIR_SUCCESS != wlan_cfgGetStrLen(pMac,
803 WNI_CFG_PROBE_RSP_ADDNIE_DATA1, &addnIE1Len) )
804 {
805 limLog(pMac, LOGP, FL("Unable to get WNI_CFG_PROBE_RSP_ADDNIE_DATA1 length"));
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530806 vos_mem_free(addIE);
807 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700808 return;
809 }
810 if (addnIE1Len <= WNI_CFG_PROBE_RSP_ADDNIE_DATA1_LEN && addnIE1Len &&
811 (nBytes + addnIE1Len) <= SIR_MAX_PACKET_SIZE)
812 {
813 if ( eSIR_SUCCESS != wlan_cfgGetStr(pMac,
814 WNI_CFG_PROBE_RSP_ADDNIE_DATA1, &addIE[0],
815 &addnIE1Len) )
816 {
817 limLog(pMac, LOGP,
818 FL("Unable to get WNI_CFG_PROBE_RSP_ADDNIE_DATA1 String"));
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530819 vos_mem_free(addIE);
820 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700821 return;
822 }
823 }
824
825 //Probe rsp IE available
826 if ( eSIR_SUCCESS != wlan_cfgGetStrLen(pMac,
827 WNI_CFG_PROBE_RSP_ADDNIE_DATA2, &addnIE2Len) )
828 {
829 limLog(pMac, LOGP, FL("Unable to get WNI_CFG_PROBE_RSP_ADDNIE_DATA2 length"));
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530830 vos_mem_free(addIE);
831 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700832 return;
833 }
834 if (addnIE2Len <= WNI_CFG_PROBE_RSP_ADDNIE_DATA2_LEN && addnIE2Len &&
835 (nBytes + addnIE2Len) <= SIR_MAX_PACKET_SIZE)
836 {
837 if ( eSIR_SUCCESS != wlan_cfgGetStr(pMac,
838 WNI_CFG_PROBE_RSP_ADDNIE_DATA2, &addIE[addnIE1Len],
839 &addnIE2Len) )
840 {
841 limLog(pMac, LOGP,
842 FL("Unable to get WNI_CFG_PROBE_RSP_ADDNIE_DATA2 String"));
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530843 vos_mem_free(addIE);
844 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700845 return;
846 }
847 }
848
849 //Probe rsp IE available
850 if ( eSIR_SUCCESS != wlan_cfgGetStrLen(pMac,
851 WNI_CFG_PROBE_RSP_ADDNIE_DATA3, &addnIE3Len) )
852 {
853 limLog(pMac, LOGP, FL("Unable to get WNI_CFG_PROBE_RSP_ADDNIE_DATA3 length"));
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530854 vos_mem_free(addIE);
855 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700856 return;
857 }
858 if (addnIE3Len <= WNI_CFG_PROBE_RSP_ADDNIE_DATA3_LEN && addnIE3Len &&
859 (nBytes + addnIE3Len) <= SIR_MAX_PACKET_SIZE)
860 {
861 if ( eSIR_SUCCESS != wlan_cfgGetStr(pMac,
862 WNI_CFG_PROBE_RSP_ADDNIE_DATA3,
863 &addIE[addnIE1Len + addnIE2Len],
864 &addnIE3Len) )
865 {
866 limLog(pMac, LOGP,
867 FL("Unable to get WNI_CFG_PROBE_RSP_ADDNIE_DATA3 String"));
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530868 vos_mem_free(addIE);
869 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700870 return;
871 }
872 }
873 totalAddnIeLen = addnIE1Len + addnIE2Len + addnIE3Len;
874
Jeff Johnson295189b2012-06-20 16:38:30 -0700875 if(eSIR_SUCCESS != limGetAddnIeForProbeResp(pMac, addIE, &totalAddnIeLen, probeReqP2pIe))
876 {
877 limLog(pMac, LOGP,
878 FL("Unable to get final Additional IE for Probe Req"));
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530879 vos_mem_free(addIE);
880 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700881 return;
882 }
Kalikinkar dhara205da782014-03-21 15:49:32 -0700883
Kalikinkar dhara205da782014-03-21 15:49:32 -0700884 nSirStatus = limStripOffExtCapIEAndUpdateStruct(pMac,
885 addIE,
886 &totalAddnIeLen,
887 &extractedExtCap );
888 if(eSIR_SUCCESS != nSirStatus )
889 {
890 extractedExtCapFlag = eANI_BOOLEAN_FALSE;
891 limLog(pMac, LOG1,
892 FL("Unable to Stripoff ExtCap IE from Probe Rsp"));
893 }
894
Jeff Johnson295189b2012-06-20 16:38:30 -0700895 nBytes = nBytes + totalAddnIeLen;
Kaushik, Sushanta5ee77a2014-07-30 19:35:25 +0530896 limLog(pMac, LOG1,
897 FL("probe rsp packet size is %d "), nBytes);
Jeff Johnson295189b2012-06-20 16:38:30 -0700898 if (probeReqP2pIe)
899 {
900 pP2pIe = limGetP2pIEPtr(pMac, &addIE[0], totalAddnIeLen);
901 if (pP2pIe != NULL)
902 {
903 //get NoA attribute stream P2P IE
904 noaLen = limGetNoaAttrStream(pMac, noaStream, psessionEntry);
905 if (noaLen != 0)
906 {
907 total_noaLen = limBuildP2pIe(pMac, &noaIe[0],
908 &noaStream[0], noaLen);
909 nBytes = nBytes + total_noaLen;
Kaushik, Sushanta5ee77a2014-07-30 19:35:25 +0530910 limLog(pMac, LOG1,
911 FL("p2p probe rsp packet size is %d, noalength is %d"),
912 nBytes, total_noaLen);
Jeff Johnson295189b2012-06-20 16:38:30 -0700913 }
914 }
915 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700916 }
917
c_hpothubcd78652014-04-28 22:31:08 +0530918 /*merge ExtCap IE*/
919 if (extractedExtCapFlag && extractedExtCap.present)
920 {
921 limMergeExtCapIEStruct(&pFrm->ExtCap, &extractedExtCap);
922 }
923
924 nStatus = dot11fGetPackedProbeResponseSize( pMac, pFrm, &nPayload );
925 if ( DOT11F_FAILED( nStatus ) )
926 {
927 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
928 "or a Probe Response (0x%08x)."),
929 nStatus );
930 // We'll fall back on the worst case scenario:
931 nPayload = sizeof( tDot11fProbeResponse );
932 }
933 else if ( DOT11F_WARNED( nStatus ) )
934 {
935 limLog( pMac, LOGW, FL("There were warnings while calculating"
936 "the packed size for a Probe Response "
937 "(0x%08x)."), nStatus );
938 }
939
940 nBytes += nPayload + sizeof( tSirMacMgmtHdr );
941
Jeff Johnson295189b2012-06-20 16:38:30 -0700942 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
943 ( tANI_U16 )nBytes, ( void** ) &pFrame,
944 ( void** ) &pPacket );
945 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
946 {
947 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Pro"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700948 "be Response."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -0700949 if ( addIE != NULL )
950 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530951 vos_mem_free(addIE);
Jeff Johnson295189b2012-06-20 16:38:30 -0700952 }
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530953 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700954 return;
955 }
956
957 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530958 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -0700959
960 // Next, we fill out the buffer descriptor:
961 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
962 SIR_MAC_MGMT_PROBE_RSP, peerMacAddr,psessionEntry->selfMacAddr);
963 if ( eSIR_SUCCESS != nSirStatus )
964 {
965 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700966 "tor for a Probe Response (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -0700967 nSirStatus );
968 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
969 ( void* ) pFrame, ( void* ) pPacket );
970 if ( addIE != NULL )
971 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530972 vos_mem_free(addIE);
Jeff Johnson295189b2012-06-20 16:38:30 -0700973 }
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530974 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700975 return;
976 }
977
978 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
979
980 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
981
982 // That done, pack the Probe Response:
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700983 nStatus = dot11fPackProbeResponse( pMac, pFrm, pFrame + sizeof(tSirMacMgmtHdr),
Jeff Johnson295189b2012-06-20 16:38:30 -0700984 nPayload, &nPayload );
985 if ( DOT11F_FAILED( nStatus ) )
986 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700987 limLog( pMac, LOGE, FL("Failed to pack a Probe Response (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -0700988 nStatus );
989 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
990 if ( addIE != NULL )
991 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530992 vos_mem_free(addIE);
Jeff Johnson295189b2012-06-20 16:38:30 -0700993 }
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530994 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700995 return; // allocated!
996 }
997 else if ( DOT11F_WARNED( nStatus ) )
998 {
999 limLog( pMac, LOGW, FL("There were warnings while packing a P"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001000 "robe Response (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001001 }
1002
1003 PELOG3(limLog( pMac, LOG3, FL("Sending Probe Response frame to ") );
1004 limPrintMacAddr( pMac, peerMacAddr, LOG3 );)
1005
1006 pMac->sys.probeRespond++;
1007
Jeff Johnson295189b2012-06-20 16:38:30 -07001008 if( pMac->lim.gpLimRemainOnChanReq )
1009 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301010 vos_mem_copy ( pFrame+sizeof(tSirMacMgmtHdr)+nPayload,
Jeff Johnson295189b2012-06-20 16:38:30 -07001011 pMac->lim.gpLimRemainOnChanReq->probeRspIe, (pMac->lim.gpLimRemainOnChanReq->length - sizeof( tSirRemainOnChnReq )) );
1012 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001013
1014 if ( addnIEPresent )
1015 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301016 vos_mem_copy(pFrame+sizeof(tSirMacMgmtHdr)+nPayload, &addIE[0], totalAddnIeLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07001017 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001018 if (noaLen != 0)
1019 {
Krunal Soni81b24262013-05-15 17:46:41 -07001020 if (total_noaLen > (SIR_MAX_NOA_ATTR_LEN + SIR_P2P_IE_HEADER_LEN))
Jeff Johnson295189b2012-06-20 16:38:30 -07001021 {
1022 limLog(pMac, LOGE,
Kaushik, Sushant96ac9d72013-12-11 19:28:10 +05301023 FL("Not able to insert NoA because of length constraint."
1024 "Total Length is :%d"),total_noaLen);
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301025 vos_mem_free(addIE);
1026 vos_mem_free(pFrm);
Krunal Soni81b24262013-05-15 17:46:41 -07001027 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1028 ( void* ) pFrame, ( void* ) pPacket );
1029 return;
1030 }
1031 else
1032 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301033 vos_mem_copy( &pFrame[nBytes - (total_noaLen)],
Krunal Soni81b24262013-05-15 17:46:41 -07001034 &noaIe[0], total_noaLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07001035 }
1036 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001037
1038 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07001039 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
1040 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07001041 )
1042 {
1043 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
1044 }
1045
1046 // Queue Probe Response frame in high priority WQ
1047 halstatus = halTxFrame( ( tHalHandle ) pMac, pPacket,
1048 ( tANI_U16 ) nBytes,
1049 HAL_TXRX_FRM_802_11_MGMT,
1050 ANI_TXDIR_TODS,
1051 7,//SMAC_SWBD_TX_TID_MGMT_LOW,
1052 limTxComplete, pFrame, txFlag );
1053 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1054 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001055 limLog( pMac, LOGE, FL("Could not send Probe Response.") );
Jeff Johnson295189b2012-06-20 16:38:30 -07001056 //Pkt will be freed up by the callback
1057 }
1058
1059 if ( addIE != NULL )
1060 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301061 vos_mem_free(addIE);
Jeff Johnson295189b2012-06-20 16:38:30 -07001062 }
1063
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301064 vos_mem_free(pFrm);
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07001065 return;
1066
1067
Jeff Johnson295189b2012-06-20 16:38:30 -07001068} // End limSendProbeRspMgmtFrame.
1069
1070void
1071limSendAddtsReqActionFrame(tpAniSirGlobal pMac,
1072 tSirMacAddr peerMacAddr,
1073 tSirAddtsReqInfo *pAddTS,
1074 tpPESession psessionEntry)
1075{
1076 tANI_U16 i;
1077 tANI_U8 *pFrame;
1078 tSirRetStatus nSirStatus;
1079 tDot11fAddTSRequest AddTSReq;
1080 tDot11fWMMAddTSRequest WMMAddTSReq;
1081 tANI_U32 nPayload, nBytes, nStatus;
1082 tpSirMacMgmtHdr pMacHdr;
1083 void *pPacket;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001084#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07001085 tANI_U32 phyMode;
1086#endif
1087 eHalStatus halstatus;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05301088 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001089
1090 if(NULL == psessionEntry)
1091 {
1092 return;
1093 }
1094
1095 if ( ! pAddTS->wmeTspecPresent )
1096 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301097 vos_mem_set(( tANI_U8* )&AddTSReq, sizeof( AddTSReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001098
1099 AddTSReq.Action.action = SIR_MAC_QOS_ADD_TS_REQ;
1100 AddTSReq.DialogToken.token = pAddTS->dialogToken;
1101 AddTSReq.Category.category = SIR_MAC_ACTION_QOS_MGMT;
1102 if ( pAddTS->lleTspecPresent )
1103 {
1104 PopulateDot11fTSPEC( &pAddTS->tspec, &AddTSReq.TSPEC );
1105 }
1106 else
1107 {
1108 PopulateDot11fWMMTSPEC( &pAddTS->tspec, &AddTSReq.WMMTSPEC );
1109 }
1110
1111 if ( pAddTS->lleTspecPresent )
1112 {
1113 AddTSReq.num_WMMTCLAS = 0;
1114 AddTSReq.num_TCLAS = pAddTS->numTclas;
1115 for ( i = 0; i < pAddTS->numTclas; ++i)
1116 {
1117 PopulateDot11fTCLAS( pMac, &pAddTS->tclasInfo[i],
1118 &AddTSReq.TCLAS[i] );
1119 }
1120 }
1121 else
1122 {
1123 AddTSReq.num_TCLAS = 0;
1124 AddTSReq.num_WMMTCLAS = pAddTS->numTclas;
1125 for ( i = 0; i < pAddTS->numTclas; ++i)
1126 {
1127 PopulateDot11fWMMTCLAS( pMac, &pAddTS->tclasInfo[i],
1128 &AddTSReq.WMMTCLAS[i] );
1129 }
1130 }
1131
1132 if ( pAddTS->tclasProcPresent )
1133 {
1134 if ( pAddTS->lleTspecPresent )
1135 {
1136 AddTSReq.TCLASSPROC.processing = pAddTS->tclasProc;
1137 AddTSReq.TCLASSPROC.present = 1;
1138 }
1139 else
1140 {
1141 AddTSReq.WMMTCLASPROC.version = 1;
1142 AddTSReq.WMMTCLASPROC.processing = pAddTS->tclasProc;
1143 AddTSReq.WMMTCLASPROC.present = 1;
1144 }
1145 }
1146
1147 nStatus = dot11fGetPackedAddTSRequestSize( pMac, &AddTSReq, &nPayload );
1148 if ( DOT11F_FAILED( nStatus ) )
1149 {
1150 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001151 "or an Add TS Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001152 nStatus );
1153 // We'll fall back on the worst case scenario:
1154 nPayload = sizeof( tDot11fAddTSRequest );
1155 }
1156 else if ( DOT11F_WARNED( nStatus ) )
1157 {
1158 limLog( pMac, LOGW, FL("There were warnings while calculating"
1159 "the packed size for an Add TS Request"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001160 " (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001161 }
1162 }
1163 else
1164 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301165 vos_mem_set(( tANI_U8* )&WMMAddTSReq, sizeof( WMMAddTSReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001166
1167 WMMAddTSReq.Action.action = SIR_MAC_QOS_ADD_TS_REQ;
1168 WMMAddTSReq.DialogToken.token = pAddTS->dialogToken;
1169 WMMAddTSReq.Category.category = SIR_MAC_ACTION_WME;
1170
1171 // WMM spec 2.2.10 - status code is only filled in for ADDTS response
1172 WMMAddTSReq.StatusCode.statusCode = 0;
1173
1174 PopulateDot11fWMMTSPEC( &pAddTS->tspec, &WMMAddTSReq.WMMTSPEC );
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001175#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07001176 limGetPhyMode(pMac, &phyMode, psessionEntry);
1177
1178 if( phyMode == WNI_CFG_PHY_MODE_11G || phyMode == WNI_CFG_PHY_MODE_11A)
1179 {
1180 pAddTS->tsrsIE.rates[0] = TSRS_11AG_RATE_6MBPS;
1181 }
1182 else
1183 {
1184 pAddTS->tsrsIE.rates[0] = TSRS_11B_RATE_5_5MBPS;
1185 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001186 PopulateDot11TSRSIE(pMac,&pAddTS->tsrsIE, &WMMAddTSReq.ESETrafStrmRateSet,sizeof(tANI_U8));
Jeff Johnson295189b2012-06-20 16:38:30 -07001187#endif
1188 // fillWmeTspecIE
1189
1190 nStatus = dot11fGetPackedWMMAddTSRequestSize( pMac, &WMMAddTSReq, &nPayload );
1191 if ( DOT11F_FAILED( nStatus ) )
1192 {
1193 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001194 "or a WMM Add TS Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001195 nStatus );
1196 // We'll fall back on the worst case scenario:
1197 nPayload = sizeof( tDot11fAddTSRequest );
1198 }
1199 else if ( DOT11F_WARNED( nStatus ) )
1200 {
1201 limLog( pMac, LOGW, FL("There were warnings while calculating"
1202 "the packed size for a WMM Add TS Requ"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001203 "est (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001204 }
1205 }
1206
1207 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
1208
1209 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1210 ( tANI_U16 )nBytes, ( void** ) &pFrame,
1211 ( void** ) &pPacket );
1212 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1213 {
1214 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for an Ad"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001215 "d TS Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07001216 return;
1217 }
1218
1219 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301220 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07001221
1222 // Next, we fill out the buffer descriptor:
1223 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
1224 SIR_MAC_MGMT_ACTION, peerMacAddr,psessionEntry->selfMacAddr);
1225 if ( eSIR_SUCCESS != nSirStatus )
1226 {
1227 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001228 "tor for an Add TS Request (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001229 nSirStatus );
1230 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1231 ( void* ) pFrame, ( void* ) pPacket );
1232 return;
1233 }
1234
1235 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
1236
1237 #if 0
1238 cfgLen = SIR_MAC_ADDR_LENGTH;
1239 if ( eSIR_SUCCESS != wlan_cfgGetStr( pMac, WNI_CFG_BSSID,
1240 ( tANI_U8* )pMacHdr->bssId, &cfgLen ) )
1241 {
1242 limLog( pMac, LOGP, FL("Failed to retrieve WNI_CFG_BSSID whil"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001243 "e sending an Add TS Request.") );
Jeff Johnson295189b2012-06-20 16:38:30 -07001244 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1245 ( void* ) pFrame, ( void* ) pPacket );
1246 return;
1247 }
1248 #endif //TO SUPPORT BT-AMP
1249
1250 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
1251
Chet Lanctot186b5732013-03-18 10:26:30 -07001252#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07001253 limSetProtectedBit(pMac, psessionEntry, peerMacAddr, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07001254#endif
1255
Jeff Johnson295189b2012-06-20 16:38:30 -07001256 // That done, pack the struct:
1257 if ( ! pAddTS->wmeTspecPresent )
1258 {
1259 nStatus = dot11fPackAddTSRequest( pMac, &AddTSReq,
1260 pFrame + sizeof(tSirMacMgmtHdr),
1261 nPayload, &nPayload );
1262 if ( DOT11F_FAILED( nStatus ) )
1263 {
1264 limLog( pMac, LOGE, FL("Failed to pack an Add TS Request "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001265 "(0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001266 nStatus );
1267 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1268 return; // allocated!
1269 }
1270 else if ( DOT11F_WARNED( nStatus ) )
1271 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001272 limLog( pMac, LOGW, FL("There were warnings while packing "
1273 "an Add TS Request (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001274 }
1275 }
1276 else
1277 {
1278 nStatus = dot11fPackWMMAddTSRequest( pMac, &WMMAddTSReq,
1279 pFrame + sizeof(tSirMacMgmtHdr),
1280 nPayload, &nPayload );
1281 if ( DOT11F_FAILED( nStatus ) )
1282 {
1283 limLog( pMac, LOGE, FL("Failed to pack a WMM Add TS Reque"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001284 "st (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001285 nStatus );
1286 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1287 return; // allocated!
1288 }
1289 else if ( DOT11F_WARNED( nStatus ) )
1290 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001291 limLog( pMac, LOGW, FL("There were warnings while packing "
1292 "a WMM Add TS Request (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001293 }
1294 }
1295
1296 PELOG3(limLog( pMac, LOG3, FL("Sending an Add TS Request frame to ") );
1297 limPrintMacAddr( pMac, peerMacAddr, LOG3 );)
1298
1299 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07001300 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
1301 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07001302 )
1303 {
1304 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
1305 }
1306
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05301307 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
1308 psessionEntry->peSessionId,
1309 pMacHdr->fc.subType));
Jeff Johnson295189b2012-06-20 16:38:30 -07001310 // Queue Addts Response frame in high priority WQ
1311 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
1312 HAL_TXRX_FRM_802_11_MGMT,
1313 ANI_TXDIR_TODS,
1314 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
1315 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05301316 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
1317 psessionEntry->peSessionId,
1318 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07001319 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1320 {
1321 limLog( pMac, LOGE, FL( "*** Could not send an Add TS Request"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001322 " (%X) ***" ), halstatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001323 //Pkt will be freed up by the callback
1324 }
1325
1326} // End limSendAddtsReqActionFrame.
1327
Jeff Johnson295189b2012-06-20 16:38:30 -07001328
1329
1330void
1331limSendAssocRspMgmtFrame(tpAniSirGlobal pMac,
1332 tANI_U16 statusCode,
1333 tANI_U16 aid,
1334 tSirMacAddr peerMacAddr,
1335 tANI_U8 subType,
1336 tpDphHashNode pSta,tpPESession psessionEntry)
1337{
1338 static tDot11fAssocResponse frm;
1339 tANI_U8 *pFrame, *macAddr;
1340 tpSirMacMgmtHdr pMacHdr;
1341 tSirRetStatus nSirStatus;
1342 tANI_U8 lleMode = 0, fAddTS, edcaInclude = 0;
1343 tHalBitVal qosMode, wmeMode;
c_hpothubcd78652014-04-28 22:31:08 +05301344 tANI_U32 nPayload, nStatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07001345 void *pPacket;
1346 eHalStatus halstatus;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05301347 tUpdateBeaconParams beaconParams;
1348 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001349 tANI_U32 addnIEPresent = false;
1350 tANI_U32 addnIELen=0;
1351 tANI_U8 addIE[WNI_CFG_ASSOC_RSP_ADDNIE_DATA_LEN];
1352 tpSirAssocReq pAssocReq = NULL;
Mahesh A Saptasagar38c177e2014-10-17 18:55:48 +05301353 tANI_U16 addStripoffIELen = 0;
1354 tDot11fIEExtCap extractedExtCap;
1355 tANI_BOOLEAN extractedExtCapFlag = eANI_BOOLEAN_FALSE;
c_hpothubcd78652014-04-28 22:31:08 +05301356 tANI_U32 nBytes = 0;
Kalikinkar dhara205da782014-03-21 15:49:32 -07001357
Chet Lanctot8cecea22014-02-11 19:09:36 -08001358#ifdef WLAN_FEATURE_11W
1359 tANI_U32 retryInterval;
1360 tANI_U32 maxRetries;
1361#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001362
1363 if(NULL == psessionEntry)
1364 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05301365 limLog( pMac, LOGE, FL("psessionEntry is NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001366 return;
1367 }
1368
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301369 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07001370
1371 limGetQosMode(psessionEntry, &qosMode);
1372 limGetWmeMode(psessionEntry, &wmeMode);
1373
1374 // An Add TS IE is added only if the AP supports it and the requesting
1375 // STA sent a traffic spec.
1376 fAddTS = ( qosMode && pSta && pSta->qos.addtsPresent ) ? 1 : 0;
1377
1378 PopulateDot11fCapabilities( pMac, &frm.Capabilities, psessionEntry );
1379
1380 frm.Status.status = statusCode;
1381
1382 frm.AID.associd = aid | LIM_AID_MASK;
1383
1384 if ( NULL == pSta )
1385 {
1386 PopulateDot11fSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL, &frm.SuppRates,psessionEntry);
1387 PopulateDot11fExtSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL, &frm.ExtSuppRates, psessionEntry );
1388 }
1389 else
1390 {
1391 PopulateDot11fAssocRspRates( pMac, &frm.SuppRates, &frm.ExtSuppRates,
1392 pSta->supportedRates.llbRates, pSta->supportedRates.llaRates );
1393 }
1394
Jeff Johnson295189b2012-06-20 16:38:30 -07001395 if(psessionEntry->limSystemRole == eLIM_AP_ROLE)
1396 {
1397 if( pSta != NULL && eSIR_SUCCESS == statusCode )
1398 {
1399 pAssocReq =
1400 (tpSirAssocReq) psessionEntry->parsedAssocReq[pSta->assocId];
Jeff Johnson295189b2012-06-20 16:38:30 -07001401 /* populate P2P IE in AssocRsp when assocReq from the peer includes P2P IE */
1402 if( pAssocReq != NULL && pAssocReq->addIEPresent ) {
1403 PopulateDot11AssocResP2PIE(pMac, &frm.P2PAssocRes, pAssocReq);
1404 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001405 }
1406 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001407
1408 if ( NULL != pSta )
1409 {
1410 if ( eHAL_SET == qosMode )
1411 {
1412 if ( pSta->lleEnabled )
1413 {
1414 lleMode = 1;
1415 if ( ( ! pSta->aniPeer ) || ( ! PROP_CAPABILITY_GET( 11EQOS, pSta->propCapability ) ) )
1416 {
1417 PopulateDot11fEDCAParamSet( pMac, &frm.EDCAParamSet, psessionEntry);
1418
1419// FramesToDo:...
1420// if ( fAddTS )
1421// {
1422// tANI_U8 *pAf = pBody;
1423// *pAf++ = SIR_MAC_QOS_ACTION_EID;
1424// tANI_U32 tlen;
1425// status = sirAddtsRspFill(pMac, pAf, statusCode, &pSta->qos.addts, NULL,
1426// &tlen, bufLen - frameLen);
1427// } // End if on Add TS.
1428 }
1429 } // End if on .11e enabled in 'pSta'.
1430 } // End if on QOS Mode on.
1431
1432 if ( ( ! lleMode ) && ( eHAL_SET == wmeMode ) && pSta->wmeEnabled )
1433 {
1434 if ( ( ! pSta->aniPeer ) || ( ! PROP_CAPABILITY_GET( WME, pSta->propCapability ) ) )
1435 {
1436
Jeff Johnson295189b2012-06-20 16:38:30 -07001437 PopulateDot11fWMMParams( pMac, &frm.WMMParams, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07001438
1439 if ( pSta->wsmEnabled )
1440 {
1441 PopulateDot11fWMMCaps(&frm.WMMCaps );
1442 }
1443 }
1444 }
1445
1446 if ( pSta->aniPeer )
1447 {
1448 if ( ( lleMode && PROP_CAPABILITY_GET( 11EQOS, pSta->propCapability ) ) ||
1449 ( pSta->wmeEnabled && PROP_CAPABILITY_GET( WME, pSta->propCapability ) ) )
1450 {
1451 edcaInclude = 1;
1452 }
1453
1454 } // End if on Airgo peer.
1455
1456 if ( pSta->mlmStaContext.htCapability &&
Jeff Johnsone7245742012-09-05 17:12:55 -07001457 psessionEntry->htCapability )
Jeff Johnson295189b2012-06-20 16:38:30 -07001458 {
Jeff Johnsone7245742012-09-05 17:12:55 -07001459 PopulateDot11fHTCaps( pMac, psessionEntry, &frm.HTCaps );
Sachin Ahujac3a26232014-09-23 22:27:30 +05301460 /*
1461 *Check the STA capability and update the HTCaps accordingly
1462 */
1463 frm.HTCaps.supportedChannelWidthSet =
1464 (pSta->htSupportedChannelWidthSet < psessionEntry->htSupportedChannelWidthSet) ?
1465 pSta->htSupportedChannelWidthSet : psessionEntry->htSupportedChannelWidthSet ;
1466
1467 if (!frm.HTCaps.supportedChannelWidthSet)
1468 frm.HTCaps.shortGI40MHz = 0;
1469
Jeff Johnson295189b2012-06-20 16:38:30 -07001470 PopulateDot11fHTInfo( pMac, &frm.HTInfo, psessionEntry );
Jeff Johnson295189b2012-06-20 16:38:30 -07001471 }
Jeff Johnsone7245742012-09-05 17:12:55 -07001472
1473#ifdef WLAN_FEATURE_11AC
1474 if( pSta->mlmStaContext.vhtCapability &&
1475 psessionEntry->vhtCapability )
1476 {
Chet Lanctotf19c1f62013-12-13 13:56:21 -08001477 limLog( pMac, LOG1, FL("Populate VHT IEs in Assoc Response"));
Abhishek Singh6d5d29c2014-07-03 14:25:22 +05301478 PopulateDot11fVHTCaps( pMac, &frm.VHTCaps, eSIR_TRUE );
Jeff Johnsone7245742012-09-05 17:12:55 -07001479 PopulateDot11fVHTOperation( pMac, &frm.VHTOperation);
Sandeep Puligilla60342762014-01-30 21:05:37 +05301480 PopulateDot11fExtCap( pMac, &frm.ExtCap, psessionEntry);
Jeff Johnsone7245742012-09-05 17:12:55 -07001481 }
1482#endif
1483
Chet Lanctot8cecea22014-02-11 19:09:36 -08001484#ifdef WLAN_FEATURE_11W
Dino Myclea7f18452014-04-24 08:55:31 +05301485 if( eSIR_MAC_TRY_AGAIN_LATER == statusCode )
1486 {
Chet Lanctotfadc8e32014-04-24 14:50:52 -07001487 if ( wlan_cfgGetInt(pMac, WNI_CFG_PMF_SA_QUERY_MAX_RETRIES,
1488 &maxRetries ) != eSIR_SUCCESS )
1489 limLog( pMac, LOGE,
1490 FL("Could not retrieve PMF SA Query maximum retries value") );
1491 else
1492 if ( wlan_cfgGetInt(pMac, WNI_CFG_PMF_SA_QUERY_RETRY_INTERVAL,
1493 &retryInterval ) != eSIR_SUCCESS)
1494 limLog( pMac, LOGE,
1495 FL("Could not retrieve PMF SA Query timer interval value") );
Dino Myclea7f18452014-04-24 08:55:31 +05301496 else
Chet Lanctotfadc8e32014-04-24 14:50:52 -07001497 PopulateDot11fTimeoutInterval(
1498 pMac, &frm.TimeoutInterval, SIR_MAC_TI_TYPE_ASSOC_COMEBACK,
1499 (maxRetries - pSta->pmfSaQueryRetryCount) * retryInterval );
Dino Myclea7f18452014-04-24 08:55:31 +05301500 }
Chet Lanctot8cecea22014-02-11 19:09:36 -08001501#endif
Dino Myclea7f18452014-04-24 08:55:31 +05301502 } // End if on non-NULL 'pSta'.
Jeff Johnson295189b2012-06-20 16:38:30 -07001503
Chet Lanctot8cecea22014-02-11 19:09:36 -08001504 vos_mem_set(( tANI_U8* )&beaconParams, sizeof( tUpdateBeaconParams), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001505
Jeff Johnson295189b2012-06-20 16:38:30 -07001506 if( psessionEntry->limSystemRole == eLIM_AP_ROLE ){
1507 if(psessionEntry->gLimProtectionControl != WNI_CFG_FORCE_POLICY_PROTECTION_DISABLE)
1508 limDecideApProtection(pMac, peerMacAddr, &beaconParams,psessionEntry);
1509 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001510
1511 limUpdateShortPreamble(pMac, peerMacAddr, &beaconParams, psessionEntry);
1512 limUpdateShortSlotTime(pMac, peerMacAddr, &beaconParams, psessionEntry);
1513
1514 beaconParams.bssIdx = psessionEntry->bssIdx;
1515
1516 //Send message to HAL about beacon parameter change.
1517 if(beaconParams.paramChangeBitmap)
1518 {
1519 schSetFixedBeaconFields(pMac,psessionEntry);
1520 limSendBeaconParams(pMac, &beaconParams, psessionEntry );
1521 }
1522
Jeff Johnson295189b2012-06-20 16:38:30 -07001523 if ( pAssocReq != NULL )
1524 {
1525 if (wlan_cfgGetInt(pMac, WNI_CFG_ASSOC_RSP_ADDNIE_FLAG,
1526 &addnIEPresent) != eSIR_SUCCESS)
1527 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05301528 limLog(pMac, LOGP, FL("Unable to get "
1529 "WNI_CFG_ASSOC_RSP_ADDNIE_FLAG"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001530 return;
1531 }
1532
1533 if (addnIEPresent)
1534 {
1535 //Assoc rsp IE available
1536 if (wlan_cfgGetStrLen(pMac, WNI_CFG_ASSOC_RSP_ADDNIE_DATA,
1537 &addnIELen) != eSIR_SUCCESS)
1538 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05301539 limLog(pMac, LOGP, FL("Unable to get "
1540 "WNI_CFG_ASSOC_RSP_ADDNIE_DATA length"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001541 return;
1542 }
1543
1544 if (addnIELen <= WNI_CFG_ASSOC_RSP_ADDNIE_DATA_LEN && addnIELen &&
1545 (nBytes + addnIELen) <= SIR_MAX_PACKET_SIZE)
1546 {
1547 if (wlan_cfgGetStr(pMac, WNI_CFG_ASSOC_RSP_ADDNIE_DATA,
1548 &addIE[0], &addnIELen) == eSIR_SUCCESS)
1549 {
Mahesh A Saptasagar38c177e2014-10-17 18:55:48 +05301550
1551 vos_mem_set(( tANI_U8* )&extractedExtCap,
1552 sizeof( tDot11fIEExtCap ), 0);
Mahesh A Saptasagare00ff532014-10-17 19:05:14 +05301553 addStripoffIELen = addnIELen;
Mahesh A Saptasagar38c177e2014-10-17 18:55:48 +05301554 nSirStatus = limStripOffExtCapIEAndUpdateStruct(pMac,
1555 &addIE[0],
1556 &addStripoffIELen,
1557 &extractedExtCap );
1558 if(eSIR_SUCCESS != nSirStatus)
1559 {
1560 limLog(pMac, LOG1,
1561 FL("Unable to Stripoff ExtCap IE from Assoc Rsp"));
1562 }
1563 else
1564 {
1565 addnIELen = addStripoffIELen;
1566 extractedExtCapFlag = eANI_BOOLEAN_TRUE;
1567 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001568 nBytes = nBytes + addnIELen;
1569 }
1570 }
1571 }
1572 }
1573
Mahesh A Saptasagar38c177e2014-10-17 18:55:48 +05301574 /* merge the ExtCap struct*/
1575 if (extractedExtCapFlag && extractedExtCap.present)
1576 {
1577 limMergeExtCapIEStruct(&(frm.ExtCap), &extractedExtCap);
1578 }
1579
c_hpothubcd78652014-04-28 22:31:08 +05301580 nStatus = dot11fGetPackedAssocResponseSize( pMac, &frm, &nPayload );
1581 if ( DOT11F_FAILED( nStatus ) )
1582 {
1583 limLog( pMac, LOGE, FL("Failed to calculate the packed size f"
1584 "or an Association Response (0x%08x)."),
1585 nStatus );
1586 return;
1587 }
1588 else if ( DOT11F_WARNED( nStatus ) )
1589 {
1590 limLog( pMac, LOGW, FL("There were warnings while calculating "
1591 "the packed size for an Association Re"
1592 "sponse (0x%08x)."), nStatus );
1593 }
1594
1595 nBytes += sizeof( tSirMacMgmtHdr ) + nPayload;
1596
Jeff Johnson295189b2012-06-20 16:38:30 -07001597 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1598 ( tANI_U16 )nBytes, ( void** ) &pFrame,
1599 ( void** ) &pPacket );
1600 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1601 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001602 limLog(pMac, LOGP, FL("Call to bufAlloc failed for RE/ASSOC RSP."));
Jeff Johnson295189b2012-06-20 16:38:30 -07001603 return;
1604 }
1605
1606 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301607 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07001608
1609 // Next, we fill out the buffer descriptor:
1610 nSirStatus = limPopulateMacHeader( pMac,
1611 pFrame,
1612 SIR_MAC_MGMT_FRAME,
1613 ( LIM_ASSOC == subType ) ?
1614 SIR_MAC_MGMT_ASSOC_RSP :
1615 SIR_MAC_MGMT_REASSOC_RSP,
1616 peerMacAddr,psessionEntry->selfMacAddr);
1617 if ( eSIR_SUCCESS != nSirStatus )
1618 {
1619 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001620 "tor for an Association Response (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001621 nSirStatus );
1622 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1623 ( void* ) pFrame, ( void* ) pPacket );
1624 return;
1625 }
1626
1627 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
1628
Jeff Johnson295189b2012-06-20 16:38:30 -07001629 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
1630
1631 nStatus = dot11fPackAssocResponse( pMac, &frm,
1632 pFrame + sizeof( tSirMacMgmtHdr ),
1633 nPayload, &nPayload );
1634 if ( DOT11F_FAILED( nStatus ) )
1635 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05301636 limLog( pMac, LOGE, FL("Failed to pack an Association Response"
1637 " (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001638 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1639 ( void* ) pFrame, ( void* ) pPacket );
1640 return; // allocated!
1641 }
1642 else if ( DOT11F_WARNED( nStatus ) )
1643 {
1644 limLog( pMac, LOGW, FL("There were warnings while packing an "
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001645 "Association Response (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001646 }
1647
1648 macAddr = pMacHdr->da;
1649
1650 if (subType == LIM_ASSOC)
1651 {
1652 PELOG1(limLog(pMac, LOG1,
1653 FL("*** Sending Assoc Resp status %d aid %d to "),
1654 statusCode, aid);)
1655 }
1656 else{
1657 PELOG1(limLog(pMac, LOG1,
1658 FL("*** Sending ReAssoc Resp status %d aid %d to "),
1659 statusCode, aid);)
1660 }
1661 PELOG1(limPrintMacAddr(pMac, pMacHdr->da, LOG1);)
1662
1663 if ( addnIEPresent )
1664 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301665 vos_mem_copy ( pFrame+sizeof(tSirMacMgmtHdr)+nPayload, &addIE[0], addnIELen ) ;
Jeff Johnson295189b2012-06-20 16:38:30 -07001666 }
1667
1668 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07001669 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
1670 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07001671 )
1672 {
1673 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
1674 }
1675
Agarwal Ashisha8e81f52014-04-02 01:59:52 +05301676 limLog( pMac, LOG1, FL("Sending Assoc resp over WQ5 to "MAC_ADDRESS_STR
1677 " From " MAC_ADDRESS_STR),MAC_ADDR_ARRAY(pMacHdr->da),
1678 MAC_ADDR_ARRAY(psessionEntry->selfMacAddr));
1679
1680 txFlag |= HAL_USE_FW_IN_TX_PATH;
1681
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05301682 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
1683 psessionEntry->peSessionId,
1684 pMacHdr->fc.subType));
Jeff Johnson295189b2012-06-20 16:38:30 -07001685 /// Queue Association Response frame in high priority WQ
1686 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
1687 HAL_TXRX_FRM_802_11_MGMT,
1688 ANI_TXDIR_TODS,
1689 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
1690 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05301691 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
1692 psessionEntry->peSessionId,
1693 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07001694 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1695 {
1696 limLog(pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001697 FL("*** Could not Send Re/AssocRsp, retCode=%X ***"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001698 nSirStatus);
1699
1700 //Pkt will be freed up by the callback
1701 }
1702
1703 // update the ANI peer station count
1704 //FIXME_PROTECTION : take care of different type of station
1705 // counter inside this function.
1706 limUtilCountStaAdd(pMac, pSta, psessionEntry);
1707
1708} // End limSendAssocRspMgmtFrame.
1709
1710
1711
1712void
1713limSendAddtsRspActionFrame(tpAniSirGlobal pMac,
1714 tSirMacAddr peer,
1715 tANI_U16 nStatusCode,
1716 tSirAddtsReqInfo *pAddTS,
1717 tSirMacScheduleIE *pSchedule,
1718 tpPESession psessionEntry)
1719{
1720 tANI_U8 *pFrame;
1721 tpSirMacMgmtHdr pMacHdr;
1722 tDot11fAddTSResponse AddTSRsp;
1723 tDot11fWMMAddTSResponse WMMAddTSRsp;
1724 tSirRetStatus nSirStatus;
1725 tANI_U32 i, nBytes, nPayload, nStatus;
1726 void *pPacket;
1727 eHalStatus halstatus;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05301728 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001729
1730 if(NULL == psessionEntry)
1731 {
1732 return;
1733 }
1734
1735 if ( ! pAddTS->wmeTspecPresent )
1736 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301737 vos_mem_set( ( tANI_U8* )&AddTSRsp, sizeof( AddTSRsp ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07001738
1739 AddTSRsp.Category.category = SIR_MAC_ACTION_QOS_MGMT;
1740 AddTSRsp.Action.action = SIR_MAC_QOS_ADD_TS_RSP;
1741 AddTSRsp.DialogToken.token = pAddTS->dialogToken;
1742 AddTSRsp.Status.status = nStatusCode;
1743
1744 // The TsDelay information element is only filled in for a specific
1745 // status code:
1746 if ( eSIR_MAC_TS_NOT_CREATED_STATUS == nStatusCode )
1747 {
1748 if ( pAddTS->wsmTspecPresent )
1749 {
1750 AddTSRsp.WMMTSDelay.version = 1;
1751 AddTSRsp.WMMTSDelay.delay = 10;
1752 AddTSRsp.WMMTSDelay.present = 1;
1753 }
1754 else
1755 {
1756 AddTSRsp.TSDelay.delay = 10;
1757 AddTSRsp.TSDelay.present = 1;
1758 }
1759 }
1760
1761 if ( pAddTS->wsmTspecPresent )
1762 {
1763 PopulateDot11fWMMTSPEC( &pAddTS->tspec, &AddTSRsp.WMMTSPEC );
1764 }
1765 else
1766 {
1767 PopulateDot11fTSPEC( &pAddTS->tspec, &AddTSRsp.TSPEC );
1768 }
1769
1770 if ( pAddTS->wsmTspecPresent )
1771 {
1772 AddTSRsp.num_WMMTCLAS = 0;
1773 AddTSRsp.num_TCLAS = pAddTS->numTclas;
1774 for ( i = 0; i < AddTSRsp.num_TCLAS; ++i)
1775 {
1776 PopulateDot11fTCLAS( pMac, &pAddTS->tclasInfo[i],
1777 &AddTSRsp.TCLAS[i] );
1778 }
1779 }
1780 else
1781 {
1782 AddTSRsp.num_TCLAS = 0;
1783 AddTSRsp.num_WMMTCLAS = pAddTS->numTclas;
1784 for ( i = 0; i < AddTSRsp.num_WMMTCLAS; ++i)
1785 {
1786 PopulateDot11fWMMTCLAS( pMac, &pAddTS->tclasInfo[i],
1787 &AddTSRsp.WMMTCLAS[i] );
1788 }
1789 }
1790
1791 if ( pAddTS->tclasProcPresent )
1792 {
1793 if ( pAddTS->wsmTspecPresent )
1794 {
1795 AddTSRsp.WMMTCLASPROC.version = 1;
1796 AddTSRsp.WMMTCLASPROC.processing = pAddTS->tclasProc;
1797 AddTSRsp.WMMTCLASPROC.present = 1;
1798 }
1799 else
1800 {
1801 AddTSRsp.TCLASSPROC.processing = pAddTS->tclasProc;
1802 AddTSRsp.TCLASSPROC.present = 1;
1803 }
1804 }
1805
1806 // schedule element is included only if requested in the tspec and we are
1807 // using hcca (or both edca and hcca)
1808 // 11e-D8.0 is inconsistent on whether the schedule element is included
1809 // based on tspec schedule bit or not. Sec 7.4.2.2. says one thing but
1810 // pg 46, line 17-18 says something else. So just include it and let the
1811 // sta figure it out
1812 if ((pSchedule != NULL) &&
1813 ((pAddTS->tspec.tsinfo.traffic.accessPolicy == SIR_MAC_ACCESSPOLICY_HCCA) ||
1814 (pAddTS->tspec.tsinfo.traffic.accessPolicy == SIR_MAC_ACCESSPOLICY_BOTH)))
1815 {
1816 if ( pAddTS->wsmTspecPresent )
1817 {
1818 PopulateDot11fWMMSchedule( pSchedule, &AddTSRsp.WMMSchedule );
1819 }
1820 else
1821 {
1822 PopulateDot11fSchedule( pSchedule, &AddTSRsp.Schedule );
1823 }
1824 }
1825
1826 nStatus = dot11fGetPackedAddTSResponseSize( pMac, &AddTSRsp, &nPayload );
1827 if ( DOT11F_FAILED( nStatus ) )
1828 {
1829 limLog( pMac, LOGP, FL("Failed to calculate the packed si"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001830 "ze for an Add TS Response (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001831 nStatus );
1832 // We'll fall back on the worst case scenario:
1833 nPayload = sizeof( tDot11fAddTSResponse );
1834 }
1835 else if ( DOT11F_WARNED( nStatus ) )
1836 {
1837 limLog( pMac, LOGW, FL("There were warnings while calcula"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001838 "ting the packed size for an Add TS"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001839 " Response (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001840 }
1841 }
1842 else
1843 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301844 vos_mem_set( ( tANI_U8* )&WMMAddTSRsp, sizeof( WMMAddTSRsp ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07001845
1846 WMMAddTSRsp.Category.category = SIR_MAC_ACTION_WME;
1847 WMMAddTSRsp.Action.action = SIR_MAC_QOS_ADD_TS_RSP;
1848 WMMAddTSRsp.DialogToken.token = pAddTS->dialogToken;
1849 WMMAddTSRsp.StatusCode.statusCode = (tANI_U8)nStatusCode;
1850
1851 PopulateDot11fWMMTSPEC( &pAddTS->tspec, &WMMAddTSRsp.WMMTSPEC );
1852
1853 nStatus = dot11fGetPackedWMMAddTSResponseSize( pMac, &WMMAddTSRsp, &nPayload );
1854 if ( DOT11F_FAILED( nStatus ) )
1855 {
1856 limLog( pMac, LOGP, FL("Failed to calculate the packed si"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001857 "ze for a WMM Add TS Response (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001858 nStatus );
1859 // We'll fall back on the worst case scenario:
1860 nPayload = sizeof( tDot11fWMMAddTSResponse );
1861 }
1862 else if ( DOT11F_WARNED( nStatus ) )
1863 {
1864 limLog( pMac, LOGW, FL("There were warnings while calcula"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001865 "ting the packed size for a WMM Add"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001866 "TS Response (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001867 }
1868 }
1869
1870 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
1871
1872 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
1873 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1874 {
1875 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for an Ad"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001876 "d TS Response."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07001877 return;
1878 }
1879
1880 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301881 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07001882
1883 // Next, we fill out the buffer descriptor:
1884 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
1885 SIR_MAC_MGMT_ACTION, peer,psessionEntry->selfMacAddr);
1886 if ( eSIR_SUCCESS != nSirStatus )
1887 {
1888 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001889 "tor for an Add TS Response (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001890 nSirStatus );
1891 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1892 return; // allocated!
1893 }
1894
1895 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
1896
1897
1898 #if 0
1899 if ( eSIR_SUCCESS != wlan_cfgGetStr( pMac, WNI_CFG_BSSID,
1900 ( tANI_U8* )pMacHdr->bssId, &cfgLen ) )
1901 {
1902 limLog( pMac, LOGP, FL("Failed to retrieve WNI_CFG_BSSID whil"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001903 "e sending an Add TS Response.") );
Jeff Johnson295189b2012-06-20 16:38:30 -07001904 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1905 return; // allocated!
1906 }
1907 #endif //TO SUPPORT BT-AMP
1908 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
1909
Chet Lanctot186b5732013-03-18 10:26:30 -07001910#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07001911 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07001912#endif
1913
Jeff Johnson295189b2012-06-20 16:38:30 -07001914 // That done, pack the struct:
1915 if ( ! pAddTS->wmeTspecPresent )
1916 {
1917 nStatus = dot11fPackAddTSResponse( pMac, &AddTSRsp,
1918 pFrame + sizeof( tSirMacMgmtHdr ),
1919 nPayload, &nPayload );
1920 if ( DOT11F_FAILED( nStatus ) )
1921 {
1922 limLog( pMac, LOGE, FL("Failed to pack an Add TS Response "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001923 "(0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001924 nStatus );
1925 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1926 return;
1927 }
1928 else if ( DOT11F_WARNED( nStatus ) )
1929 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001930 limLog( pMac, LOGW, FL("There were warnings while packing "
1931 "an Add TS Response (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001932 }
1933 }
1934 else
1935 {
1936 nStatus = dot11fPackWMMAddTSResponse( pMac, &WMMAddTSRsp,
1937 pFrame + sizeof( tSirMacMgmtHdr ),
1938 nPayload, &nPayload );
1939 if ( DOT11F_FAILED( nStatus ) )
1940 {
1941 limLog( pMac, LOGE, FL("Failed to pack a WMM Add TS Response "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001942 "(0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001943 nStatus );
1944 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1945 return;
1946 }
1947 else if ( DOT11F_WARNED( nStatus ) )
1948 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001949 limLog( pMac, LOGW, FL("There were warnings while packing "
1950 "a WMM Add TS Response (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001951 }
1952 }
1953
1954 PELOG1(limLog( pMac, LOG1, FL("Sending an Add TS Response (status %d) to "),
1955 nStatusCode );
1956 limPrintMacAddr( pMac, pMacHdr->da, LOG1 );)
1957
1958 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07001959 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
1960 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07001961 )
1962 {
1963 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
1964 }
1965
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05301966 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
1967 psessionEntry->peSessionId,
1968 pMacHdr->fc.subType));
Jeff Johnson295189b2012-06-20 16:38:30 -07001969 // Queue the frame in high priority WQ:
1970 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
1971 HAL_TXRX_FRM_802_11_MGMT,
1972 ANI_TXDIR_TODS,
1973 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
1974 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05301975 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
1976 psessionEntry->peSessionId,
1977 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07001978 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1979 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001980 limLog( pMac, LOGE, FL("Failed to send Add TS Response (%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001981 nSirStatus );
1982 //Pkt will be freed up by the callback
1983 }
1984
1985} // End limSendAddtsRspActionFrame.
1986
1987void
1988limSendDeltsReqActionFrame(tpAniSirGlobal pMac,
1989 tSirMacAddr peer,
1990 tANI_U8 wmmTspecPresent,
1991 tSirMacTSInfo *pTsinfo,
1992 tSirMacTspecIE *pTspecIe,
1993 tpPESession psessionEntry)
1994{
1995 tANI_U8 *pFrame;
1996 tpSirMacMgmtHdr pMacHdr;
1997 tDot11fDelTS DelTS;
1998 tDot11fWMMDelTS WMMDelTS;
1999 tSirRetStatus nSirStatus;
2000 tANI_U32 nBytes, nPayload, nStatus;
2001 void *pPacket;
2002 eHalStatus halstatus;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05302003 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002004
2005 if(NULL == psessionEntry)
2006 {
2007 return;
2008 }
2009
2010 if ( ! wmmTspecPresent )
2011 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302012 vos_mem_set( ( tANI_U8* )&DelTS, sizeof( DelTS ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07002013
2014 DelTS.Category.category = SIR_MAC_ACTION_QOS_MGMT;
2015 DelTS.Action.action = SIR_MAC_QOS_DEL_TS_REQ;
2016 PopulateDot11fTSInfo( pTsinfo, &DelTS.TSInfo );
2017
2018 nStatus = dot11fGetPackedDelTSSize( pMac, &DelTS, &nPayload );
2019 if ( DOT11F_FAILED( nStatus ) )
2020 {
2021 limLog( pMac, LOGP, FL("Failed to calculate the packed si"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002022 "ze for a Del TS (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002023 nStatus );
2024 // We'll fall back on the worst case scenario:
2025 nPayload = sizeof( tDot11fDelTS );
2026 }
2027 else if ( DOT11F_WARNED( nStatus ) )
2028 {
2029 limLog( pMac, LOGW, FL("There were warnings while calcula"
2030 "ting the packed size for a Del TS"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002031 " (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07002032 }
2033 }
2034 else
2035 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302036 vos_mem_set( ( tANI_U8* )&WMMDelTS, sizeof( WMMDelTS ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07002037
2038 WMMDelTS.Category.category = SIR_MAC_ACTION_WME;
2039 WMMDelTS.Action.action = SIR_MAC_QOS_DEL_TS_REQ;
2040 WMMDelTS.DialogToken.token = 0;
2041 WMMDelTS.StatusCode.statusCode = 0;
2042 PopulateDot11fWMMTSPEC( pTspecIe, &WMMDelTS.WMMTSPEC );
2043 nStatus = dot11fGetPackedWMMDelTSSize( pMac, &WMMDelTS, &nPayload );
2044 if ( DOT11F_FAILED( nStatus ) )
2045 {
2046 limLog( pMac, LOGP, FL("Failed to calculate the packed si"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002047 "ze for a WMM Del TS (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002048 nStatus );
2049 // We'll fall back on the worst case scenario:
2050 nPayload = sizeof( tDot11fDelTS );
2051 }
2052 else if ( DOT11F_WARNED( nStatus ) )
2053 {
2054 limLog( pMac, LOGW, FL("There were warnings while calcula"
2055 "ting the packed size for a WMM De"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002056 "l TS (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07002057 }
2058 }
2059
2060 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
2061
2062 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
2063 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
2064 {
2065 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for an Ad"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002066 "d TS Response."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07002067 return;
2068 }
2069
2070 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302071 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07002072
2073 // Next, we fill out the buffer descriptor:
2074 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
2075 SIR_MAC_MGMT_ACTION, peer,
2076 psessionEntry->selfMacAddr);
2077 if ( eSIR_SUCCESS != nSirStatus )
2078 {
2079 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002080 "tor for an Add TS Response (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002081 nSirStatus );
2082 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
2083 return; // allocated!
2084 }
2085
2086 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
2087
2088 #if 0
2089
2090 cfgLen = SIR_MAC_ADDR_LENGTH;
2091 if ( eSIR_SUCCESS != wlan_cfgGetStr( pMac, WNI_CFG_BSSID,
2092 ( tANI_U8* )pMacHdr->bssId, &cfgLen ) )
2093 {
2094 limLog( pMac, LOGP, FL("Failed to retrieve WNI_CFG_BSSID whil"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002095 "e sending an Add TS Response.") );
Jeff Johnson295189b2012-06-20 16:38:30 -07002096 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
2097 return; // allocated!
2098 }
2099 #endif //TO SUPPORT BT-AMP
2100 sirCopyMacAddr(pMacHdr->bssId, psessionEntry->bssId);
2101
Chet Lanctot186b5732013-03-18 10:26:30 -07002102#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07002103 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07002104#endif
2105
Jeff Johnson295189b2012-06-20 16:38:30 -07002106 // That done, pack the struct:
2107 if ( !wmmTspecPresent )
2108 {
2109 nStatus = dot11fPackDelTS( pMac, &DelTS,
2110 pFrame + sizeof( tSirMacMgmtHdr ),
2111 nPayload, &nPayload );
2112 if ( DOT11F_FAILED( nStatus ) )
2113 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002114 limLog( pMac, LOGE, FL("Failed to pack a Del TS frame (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002115 nStatus );
2116 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
2117 return; // allocated!
2118 }
2119 else if ( DOT11F_WARNED( nStatus ) )
2120 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08002121 limLog( pMac, LOGW, FL("There were warnings while packing "
2122 "a Del TS frame (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07002123 }
2124 }
2125 else
2126 {
2127 nStatus = dot11fPackWMMDelTS( pMac, &WMMDelTS,
2128 pFrame + sizeof( tSirMacMgmtHdr ),
2129 nPayload, &nPayload );
2130 if ( DOT11F_FAILED( nStatus ) )
2131 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002132 limLog( pMac, LOGE, FL("Failed to pack a WMM Del TS frame (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002133 nStatus );
2134 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
2135 return; // allocated!
2136 }
2137 else if ( DOT11F_WARNED( nStatus ) )
2138 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08002139 limLog( pMac, LOGW, FL("There were warnings while packing "
2140 "a WMM Del TS frame (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07002141 }
2142 }
2143
2144 PELOG1(limLog(pMac, LOG1, FL("Sending DELTS REQ (size %d) to "), nBytes);
2145 limPrintMacAddr(pMac, pMacHdr->da, LOG1);)
2146
2147 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07002148 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
2149 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07002150 )
2151 {
2152 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
2153 }
2154
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05302155 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
2156 psessionEntry->peSessionId,
2157 pMacHdr->fc.subType));
Jeff Johnson295189b2012-06-20 16:38:30 -07002158 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
2159 HAL_TXRX_FRM_802_11_MGMT,
2160 ANI_TXDIR_TODS,
2161 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
2162 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05302163 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
2164 psessionEntry->peSessionId,
2165 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07002166 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
2167 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002168 limLog( pMac, LOGE, FL("Failed to send Del TS (%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002169 nSirStatus );
2170 //Pkt will be freed up by the callback
2171 }
2172
2173} // End limSendDeltsReqActionFrame.
2174
2175void
2176limSendAssocReqMgmtFrame(tpAniSirGlobal pMac,
2177 tLimMlmAssocReq *pMlmAssocReq,
2178 tpPESession psessionEntry)
2179{
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002180 tDot11fAssocRequest *pFrm;
Jeff Johnson295189b2012-06-20 16:38:30 -07002181 tANI_U16 caps;
2182 tANI_U8 *pFrame;
2183 tSirRetStatus nSirStatus;
2184 tLimMlmAssocCnf mlmAssocCnf;
c_hpothubcd78652014-04-28 22:31:08 +05302185 tANI_U32 nPayload, nStatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07002186 tANI_U8 fQosEnabled, fWmeEnabled, fWsmEnabled;
2187 void *pPacket;
2188 eHalStatus halstatus;
2189 tANI_U16 nAddIELen;
2190 tANI_U8 *pAddIE;
2191 tANI_U8 *wpsIe = NULL;
2192#if defined WLAN_FEATURE_VOWIFI
2193 tANI_U8 PowerCapsPopulated = FALSE;
2194#endif
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05302195 tANI_U32 txFlag = 0;
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05302196 tpSirMacMgmtHdr pMacHdr;
Kalikinkar dhara205da782014-03-21 15:49:32 -07002197 tDot11fIEExtCap extractedExtCap;
2198 tANI_BOOLEAN extractedExtCapFlag = eANI_BOOLEAN_TRUE;
c_hpothubcd78652014-04-28 22:31:08 +05302199 tANI_U32 nBytes = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002200
2201 if(NULL == psessionEntry)
2202 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05302203 limLog(pMac, LOGE, FL("psessionEntry is NULL") );
Jeff Johnson295189b2012-06-20 16:38:30 -07002204 return;
2205 }
2206
Jeff Johnson295189b2012-06-20 16:38:30 -07002207 /* check this early to avoid unncessary operation */
2208 if(NULL == psessionEntry->pLimJoinReq)
2209 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05302210 limLog(pMac, LOGE, FL("psessionEntry->pLimJoinReq is NULL") );
Jeff Johnson295189b2012-06-20 16:38:30 -07002211 return;
2212 }
2213 nAddIELen = psessionEntry->pLimJoinReq->addIEAssoc.length;
2214 pAddIE = psessionEntry->pLimJoinReq->addIEAssoc.addIEdata;
2215
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302216 pFrm = vos_mem_malloc(sizeof(tDot11fAssocRequest));
2217 if ( NULL == pFrm )
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002218 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05302219 limLog(pMac, LOGE, FL("Unable to allocate memory") );
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002220 return;
2221 }
2222
2223
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302224 vos_mem_set( ( tANI_U8* )pFrm, sizeof( tDot11fAssocRequest ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07002225
Kalikinkar dhara205da782014-03-21 15:49:32 -07002226 vos_mem_set(( tANI_U8* )&extractedExtCap, sizeof( tDot11fIEExtCap ), 0);
2227 nSirStatus = limStripOffExtCapIEAndUpdateStruct(pMac, pAddIE,
2228 &nAddIELen,
2229 &extractedExtCap );
2230 if(eSIR_SUCCESS != nSirStatus )
2231 {
2232 extractedExtCapFlag = eANI_BOOLEAN_FALSE;
2233 limLog(pMac, LOG1,
2234 FL("Unable to Stripoff ExtCap IE from Assoc Req"));
2235 }
Leela Venkata Kiran Kumar Reddy Chirala2f9b5712014-05-06 00:09:42 -07002236 /* TODO:remove this code once driver provides the call back function
2237 * to supplicant for set_qos_map
2238 */
2239 else
2240 {
2241 if(extractedExtCap.interworkingService)
2242 {
2243 extractedExtCap.qosMap = 1;
2244 }
2245 }
Kalikinkar dhara205da782014-03-21 15:49:32 -07002246
Jeff Johnson295189b2012-06-20 16:38:30 -07002247 caps = pMlmAssocReq->capabilityInfo;
2248 if ( PROP_CAPABILITY_GET( 11EQOS, psessionEntry->limCurrentBssPropCap ) )
2249 ((tSirMacCapabilityInfo *) &caps)->qos = 0;
2250#if defined(FEATURE_WLAN_WAPI)
2251 /* CR: 262463 :
2252 According to WAPI standard:
2253 7.3.1.4 Capability Information field
2254 In WAPI, non-AP STAs within an ESS set the Privacy subfield to 0 in transmitted
2255 Association or Reassociation management frames. APs ignore the Privacy subfield within received Association and
2256 Reassociation management frames. */
2257 if ( psessionEntry->encryptType == eSIR_ED_WPI)
2258 ((tSirMacCapabilityInfo *) &caps)->privacy = 0;
2259#endif
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002260 swapBitField16(caps, ( tANI_U16* )&pFrm->Capabilities );
Jeff Johnson295189b2012-06-20 16:38:30 -07002261
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002262 pFrm->ListenInterval.interval = pMlmAssocReq->listenInterval;
2263 PopulateDot11fSSID2( pMac, &pFrm->SSID );
Jeff Johnson295189b2012-06-20 16:38:30 -07002264 PopulateDot11fSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002265 &pFrm->SuppRates,psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07002266
2267 fQosEnabled = ( psessionEntry->limQosEnabled) &&
2268 SIR_MAC_GET_QOS( psessionEntry->limCurrentBssCaps );
2269
2270 fWmeEnabled = ( psessionEntry->limWmeEnabled ) &&
2271 LIM_BSS_CAPS_GET( WME, psessionEntry->limCurrentBssQosCaps );
2272
2273 // We prefer .11e asociations:
2274 if ( fQosEnabled ) fWmeEnabled = false;
2275
2276 fWsmEnabled = ( psessionEntry->limWsmEnabled ) && fWmeEnabled &&
2277 LIM_BSS_CAPS_GET( WSM, psessionEntry->limCurrentBssQosCaps );
2278
2279 if ( psessionEntry->lim11hEnable &&
2280 psessionEntry->pLimJoinReq->spectrumMgtIndicator == eSIR_TRUE )
2281 {
2282#if defined WLAN_FEATURE_VOWIFI
2283 PowerCapsPopulated = TRUE;
2284
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002285 PopulateDot11fPowerCaps( pMac, &pFrm->PowerCaps, LIM_ASSOC,psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07002286#endif
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002287 PopulateDot11fSuppChannels( pMac, &pFrm->SuppChannels, LIM_ASSOC,psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07002288
2289 }
2290
2291#if defined WLAN_FEATURE_VOWIFI
2292 if( pMac->rrm.rrmPEContext.rrmEnable &&
2293 SIR_MAC_GET_RRM( psessionEntry->limCurrentBssCaps ) )
2294 {
2295 if (PowerCapsPopulated == FALSE)
2296 {
2297 PowerCapsPopulated = TRUE;
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002298 PopulateDot11fPowerCaps(pMac, &pFrm->PowerCaps, LIM_ASSOC, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07002299 }
2300 }
2301#endif
2302
2303 if ( fQosEnabled &&
2304 ( ! PROP_CAPABILITY_GET(11EQOS, psessionEntry->limCurrentBssPropCap)))
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002305 PopulateDot11fQOSCapsStation( pMac, &pFrm->QOSCapsStation );
Jeff Johnson295189b2012-06-20 16:38:30 -07002306
2307 PopulateDot11fExtSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002308 &pFrm->ExtSuppRates, psessionEntry );
Jeff Johnson295189b2012-06-20 16:38:30 -07002309
2310#if defined WLAN_FEATURE_VOWIFI
2311 if( pMac->rrm.rrmPEContext.rrmEnable &&
2312 SIR_MAC_GET_RRM( psessionEntry->limCurrentBssCaps ) )
2313 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002314 PopulateDot11fRRMIe( pMac, &pFrm->RRMEnabledCap, psessionEntry );
Jeff Johnson295189b2012-06-20 16:38:30 -07002315 }
2316#endif
2317 // The join request *should* contain zero or one of the WPA and RSN
2318 // IEs. The payload send along with the request is a
2319 // 'tSirSmeJoinReq'; the IE portion is held inside a 'tSirRSNie':
2320
2321 // typedef struct sSirRSNie
2322 // {
2323 // tANI_U16 length;
2324 // tANI_U8 rsnIEdata[SIR_MAC_MAX_IE_LENGTH+2];
2325 // } tSirRSNie, *tpSirRSNie;
2326
2327 // So, we should be able to make the following two calls harmlessly,
2328 // since they do nothing if they don't find the given IE in the
2329 // bytestream with which they're provided.
2330
2331 // The net effect of this will be to faithfully transmit whatever
2332 // security IE is in the join request.
2333
2334 // *However*, if we're associating for the purpose of WPS
2335 // enrollment, and we've been configured to indicate that by
2336 // eliding the WPA or RSN IE, we just skip this:
2337 if( nAddIELen && pAddIE )
2338 {
2339 wpsIe = limGetWscIEPtr (pMac, pAddIE, nAddIELen);
2340 }
2341 if ( NULL == wpsIe )
2342 {
2343 PopulateDot11fRSNOpaque( pMac, &( psessionEntry->pLimJoinReq->rsnIE ),
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002344 &pFrm->RSNOpaque );
Jeff Johnson295189b2012-06-20 16:38:30 -07002345 PopulateDot11fWPAOpaque( pMac, &( psessionEntry->pLimJoinReq->rsnIE ),
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002346 &pFrm->WPAOpaque );
Jeff Johnson295189b2012-06-20 16:38:30 -07002347#if defined(FEATURE_WLAN_WAPI)
2348 PopulateDot11fWAPIOpaque( pMac, &( psessionEntry->pLimJoinReq->rsnIE ),
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002349 &pFrm->WAPIOpaque );
Jeff Johnson295189b2012-06-20 16:38:30 -07002350#endif // defined(FEATURE_WLAN_WAPI)
2351 }
2352
2353 // include WME EDCA IE as well
2354 if ( fWmeEnabled )
2355 {
2356 if ( ! PROP_CAPABILITY_GET( WME, psessionEntry->limCurrentBssPropCap ) )
2357 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002358 PopulateDot11fWMMInfoStation( pMac, &pFrm->WMMInfoStation );
Jeff Johnson295189b2012-06-20 16:38:30 -07002359 }
2360
2361 if ( fWsmEnabled &&
2362 ( ! PROP_CAPABILITY_GET(WSM, psessionEntry->limCurrentBssPropCap )))
2363 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002364 PopulateDot11fWMMCaps( &pFrm->WMMCaps );
Jeff Johnson295189b2012-06-20 16:38:30 -07002365 }
2366 }
2367
2368 //Populate HT IEs, when operating in 11n or Taurus modes AND
2369 //when AP is also operating in 11n mode.
Jeff Johnsone7245742012-09-05 17:12:55 -07002370 if ( psessionEntry->htCapability &&
Jeff Johnson295189b2012-06-20 16:38:30 -07002371 pMac->lim.htCapabilityPresentInBeacon)
2372 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002373 PopulateDot11fHTCaps( pMac, psessionEntry, &pFrm->HTCaps );
Jeff Johnson295189b2012-06-20 16:38:30 -07002374#ifdef DISABLE_GF_FOR_INTEROP
2375
2376 /*
2377 * To resolve the interop problem with Broadcom AP,
2378 * where TQ STA could not pass traffic with GF enabled,
2379 * TQ STA will do Greenfield only with TQ AP, for
2380 * everybody else it will be turned off.
2381 */
2382
2383 if( (psessionEntry->pLimJoinReq != NULL) && (!psessionEntry->pLimJoinReq->bssDescription.aniIndicator))
2384 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05302385 limLog( pMac, LOG1, FL("Sending Assoc Req to Non-TQ AP,"
2386 " Turning off Greenfield"));
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002387 pFrm->HTCaps.greenField = WNI_CFG_GREENFIELD_CAPABILITY_DISABLE;
Jeff Johnson295189b2012-06-20 16:38:30 -07002388 }
2389#endif
2390
2391 }
Jeff Johnsone7245742012-09-05 17:12:55 -07002392#ifdef WLAN_FEATURE_11AC
2393 if ( psessionEntry->vhtCapability &&
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07002394 psessionEntry->vhtCapabilityPresentInBeacon)
Jeff Johnsone7245742012-09-05 17:12:55 -07002395 {
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07002396 limLog( pMac, LOG1, FL("Populate VHT IEs in Assoc Request"));
Abhishek Singh6d5d29c2014-07-03 14:25:22 +05302397 PopulateDot11fVHTCaps( pMac, &pFrm->VHTCaps, eSIR_FALSE );
Jeff Johnsone7245742012-09-05 17:12:55 -07002398 }
2399#endif
Sandeep Puligilla60342762014-01-30 21:05:37 +05302400 PopulateDot11fExtCap( pMac, &pFrm->ExtCap, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07002401
2402#if defined WLAN_FEATURE_VOWIFI_11R
2403 if (psessionEntry->pLimJoinReq->is11Rconnection)
2404 {
2405#if defined WLAN_FEATURE_VOWIFI_11R_DEBUG
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002406 limLog( pMac, LOG1, FL("mdie = %02x %02x %02x"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002407 (unsigned int)psessionEntry->pLimJoinReq->bssDescription.mdie[0],
2408 (unsigned int)psessionEntry->pLimJoinReq->bssDescription.mdie[1],
2409 (unsigned int)psessionEntry->pLimJoinReq->bssDescription.mdie[2]);
2410#endif
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302411 PopulateMDIE( pMac, &pFrm->MobilityDomain,
2412 psessionEntry->pLimJoinReq->bssDescription.mdie);
Jeff Johnson295189b2012-06-20 16:38:30 -07002413 }
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302414 else
Jeff Johnson295189b2012-06-20 16:38:30 -07002415 {
2416 // No 11r IEs dont send any MDIE
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302417 limLog( pMac, LOG1, FL("MDIE not present"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002418 }
2419#endif
2420
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002421#ifdef FEATURE_WLAN_ESE
2422 /* For ESE Associations fill the ESE IEs */
2423 if (psessionEntry->isESEconnection &&
2424 psessionEntry->pLimJoinReq->isESEFeatureIniEnabled)
Jeff Johnson295189b2012-06-20 16:38:30 -07002425 {
Varun Reddy Yeturu30779b42013-04-09 09:57:16 -07002426#ifndef FEATURE_DISABLE_RM
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002427 PopulateDot11fESERadMgmtCap(&pFrm->ESERadMgmtCap);
Varun Reddy Yeturu30779b42013-04-09 09:57:16 -07002428#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002429 PopulateDot11fESEVersion(&pFrm->ESEVersion);
Jeff Johnson295189b2012-06-20 16:38:30 -07002430 }
2431#endif
2432
c_hpothubcd78652014-04-28 22:31:08 +05302433 /* merge the ExtCap struct*/
2434 if (extractedExtCapFlag && extractedExtCap.present)
2435 {
2436 limMergeExtCapIEStruct(&pFrm->ExtCap, &extractedExtCap);
2437 }
2438
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002439 nStatus = dot11fGetPackedAssocRequestSize( pMac, pFrm, &nPayload );
Jeff Johnson295189b2012-06-20 16:38:30 -07002440 if ( DOT11F_FAILED( nStatus ) )
2441 {
2442 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002443 "or an Association Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002444 nStatus );
2445 // We'll fall back on the worst case scenario:
2446 nPayload = sizeof( tDot11fAssocRequest );
2447 }
2448 else if ( DOT11F_WARNED( nStatus ) )
2449 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08002450 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07002451 "the packed size for an Association Re "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002452 "quest(0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07002453 }
2454
2455 nBytes = nPayload + sizeof( tSirMacMgmtHdr ) + nAddIELen;
2456
2457 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
2458 ( tANI_U16 )nBytes, ( void** ) &pFrame,
2459 ( void** ) &pPacket );
2460 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
2461 {
2462 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for an As"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002463 "sociation Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07002464
2465 psessionEntry->limMlmState = psessionEntry->limPrevMlmState;
Jeff Johnsone7245742012-09-05 17:12:55 -07002466 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07002467
2468
2469 /* Update PE session id*/
2470 mlmAssocCnf.sessionId = psessionEntry->peSessionId;
2471
2472 mlmAssocCnf.resultCode = eSIR_SME_RESOURCES_UNAVAILABLE;
2473
2474 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
2475 ( void* ) pFrame, ( void* ) pPacket );
2476
2477 limPostSmeMessage( pMac, LIM_MLM_ASSOC_CNF,
2478 ( tANI_U32* ) &mlmAssocCnf);
2479
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302480 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -07002481 return;
2482 }
2483
2484 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302485 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07002486
2487 // Next, we fill out the buffer descriptor:
2488 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
2489 SIR_MAC_MGMT_ASSOC_REQ, psessionEntry->bssId,psessionEntry->selfMacAddr);
2490 if ( eSIR_SUCCESS != nSirStatus )
2491 {
2492 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002493 "tor for an Association Request (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002494 nSirStatus );
2495 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302496 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -07002497 return;
2498 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002499
Abhishek Singh57aebef2014-02-03 18:47:44 +05302500 // That done, pack the Assoc Request:
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002501 nStatus = dot11fPackAssocRequest( pMac, pFrm, pFrame +
Jeff Johnson295189b2012-06-20 16:38:30 -07002502 sizeof(tSirMacMgmtHdr),
2503 nPayload, &nPayload );
2504 if ( DOT11F_FAILED( nStatus ) )
2505 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05302506 limLog( pMac, LOGE, FL("Failed to pack a Assoc Request (0x%0"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002507 "8x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002508 nStatus );
2509 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
2510 ( void* ) pFrame, ( void* ) pPacket );
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302511 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -07002512 return;
2513 }
2514 else if ( DOT11F_WARNED( nStatus ) )
2515 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05302516 limLog( pMac, LOGW, FL("There were warnings while packing a Assoc"
2517 "Request (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07002518 }
2519
2520 PELOG1(limLog( pMac, LOG1, FL("*** Sending Association Request length %d"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002521 "to "),
Jeff Johnson295189b2012-06-20 16:38:30 -07002522 nBytes );)
2523 // limPrintMacAddr( pMac, bssid, LOG1 );
2524
2525 if( psessionEntry->assocReq != NULL )
2526 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302527 vos_mem_free(psessionEntry->assocReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07002528 psessionEntry->assocReq = NULL;
2529 }
2530
2531 if( nAddIELen )
2532 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302533 vos_mem_copy( pFrame + sizeof(tSirMacMgmtHdr) + nPayload,
2534 pAddIE,
2535 nAddIELen );
Jeff Johnson295189b2012-06-20 16:38:30 -07002536 nPayload += nAddIELen;
2537 }
2538
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302539 psessionEntry->assocReq = vos_mem_malloc(nPayload);
2540 if ( NULL == psessionEntry->assocReq )
Jeff Johnson295189b2012-06-20 16:38:30 -07002541 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05302542 PELOGE(limLog(pMac, LOGE, FL("Unable to allocate memory to store "
2543 "assoc request"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07002544 }
2545 else
2546 {
2547 //Store the Assoc request. This is sent to csr/hdd in join cnf response.
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302548 vos_mem_copy( psessionEntry->assocReq, pFrame + sizeof(tSirMacMgmtHdr), nPayload);
Jeff Johnson295189b2012-06-20 16:38:30 -07002549 psessionEntry->assocReqLen = nPayload;
2550 }
2551
2552 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07002553 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
2554 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07002555 )
2556 {
2557 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
2558 }
2559
Ganesh K08bce952012-12-13 15:04:41 -08002560 if(psessionEntry->pePersona == VOS_P2P_CLIENT_MODE)
2561 {
2562 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
2563 }
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05302564
2565 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
Agarwal Ashisha8e81f52014-04-02 01:59:52 +05302566 limLog( pMac, LOG1, FL("Sending Assoc req over WQ5 to "MAC_ADDRESS_STR
2567 " From " MAC_ADDRESS_STR),MAC_ADDR_ARRAY(pMacHdr->da),
2568 MAC_ADDR_ARRAY(psessionEntry->selfMacAddr));
2569 txFlag |= HAL_USE_FW_IN_TX_PATH;
2570
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05302571 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
2572 psessionEntry->peSessionId,
2573 pMacHdr->fc.subType));
Katya Nigam63902932014-06-26 19:04:23 +05302574
2575 // enable caching
2576 WLANTL_EnableCaching(psessionEntry->staId);
2577
Jeff Johnson295189b2012-06-20 16:38:30 -07002578 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) (sizeof(tSirMacMgmtHdr) + nPayload),
2579 HAL_TXRX_FRM_802_11_MGMT,
2580 ANI_TXDIR_TODS,
2581 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
2582 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05302583 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
2584 psessionEntry->peSessionId,
2585 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07002586 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
2587 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002588 limLog( pMac, LOGE, FL("Failed to send Association Request (%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002589 halstatus );
2590 //Pkt will be freed up by the callback
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302591 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -07002592 return;
2593 }
2594
2595 // Free up buffer allocated for mlmAssocReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302596 vos_mem_free(pMlmAssocReq);
Leela Venkata Kiran Kumar Reddy Chiralad6c0fe22013-12-11 19:10:50 -08002597 pMlmAssocReq = NULL;
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302598 vos_mem_free(pFrm);
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002599 return;
Jeff Johnson295189b2012-06-20 16:38:30 -07002600} // End limSendAssocReqMgmtFrame
2601
2602
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002603#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07002604/*------------------------------------------------------------------------------------
2605 *
2606 * Send Reassoc Req with FTIEs.
2607 *
2608 *-----------------------------------------------------------------------------------
2609 */
2610void
2611limSendReassocReqWithFTIEsMgmtFrame(tpAniSirGlobal pMac,
2612 tLimMlmReassocReq *pMlmReassocReq,tpPESession psessionEntry)
2613{
2614 static tDot11fReAssocRequest frm;
2615 tANI_U16 caps;
2616 tANI_U8 *pFrame;
2617 tSirRetStatus nSirStatus;
2618 tANI_U32 nBytes, nPayload, nStatus;
2619 tANI_U8 fQosEnabled, fWmeEnabled, fWsmEnabled;
2620 void *pPacket;
2621 eHalStatus halstatus;
2622#if defined WLAN_FEATURE_VOWIFI
2623 tANI_U8 PowerCapsPopulated = FALSE;
2624#endif
2625 tANI_U16 ft_ies_length = 0;
2626 tANI_U8 *pBody;
2627 tANI_U16 nAddIELen;
2628 tANI_U8 *pAddIE;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002629#if defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07002630 tANI_U8 *wpsIe = NULL;
2631#endif
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05302632 tANI_U32 txFlag = 0;
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05302633 tpSirMacMgmtHdr pMacHdr;
Jeff Johnson295189b2012-06-20 16:38:30 -07002634
2635 if (NULL == psessionEntry)
2636 {
2637 return;
2638 }
2639
Jeff Johnson295189b2012-06-20 16:38:30 -07002640 /* check this early to avoid unncessary operation */
2641 if(NULL == psessionEntry->pLimReAssocReq)
2642 {
2643 return;
2644 }
2645 nAddIELen = psessionEntry->pLimReAssocReq->addIEAssoc.length;
2646 pAddIE = psessionEntry->pLimReAssocReq->addIEAssoc.addIEdata;
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08002647 limLog( pMac, LOG1, FL("limSendReassocReqWithFTIEsMgmtFrame received in "
2648 "state (%d)."), psessionEntry->limMlmState);
Jeff Johnson295189b2012-06-20 16:38:30 -07002649
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302650 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07002651
2652 caps = pMlmReassocReq->capabilityInfo;
2653 if (PROP_CAPABILITY_GET(11EQOS, psessionEntry->limReassocBssPropCap))
2654 ((tSirMacCapabilityInfo *) &caps)->qos = 0;
2655#if defined(FEATURE_WLAN_WAPI)
2656 /* CR: 262463 :
2657 According to WAPI standard:
2658 7.3.1.4 Capability Information field
2659 In WAPI, non-AP STAs within an ESS set the Privacy subfield to 0 in transmitted
2660 Association or Reassociation management frames. APs ignore the Privacy subfield within received Association and
2661 Reassociation management frames. */
2662 if ( psessionEntry->encryptType == eSIR_ED_WPI)
2663 ((tSirMacCapabilityInfo *) &caps)->privacy = 0;
2664#endif
2665 swapBitField16(caps, ( tANI_U16* )&frm.Capabilities );
2666
2667 frm.ListenInterval.interval = pMlmReassocReq->listenInterval;
2668
2669 // Get the old bssid of the older AP.
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302670 vos_mem_copy( ( tANI_U8* )frm.CurrentAPAddress.mac,
Jeff Johnson295189b2012-06-20 16:38:30 -07002671 pMac->ft.ftPEContext.pFTPreAuthReq->currbssId, 6);
2672
2673 PopulateDot11fSSID2( pMac, &frm.SSID );
2674 PopulateDot11fSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
2675 &frm.SuppRates,psessionEntry);
2676
2677 fQosEnabled = ( psessionEntry->limQosEnabled) &&
2678 SIR_MAC_GET_QOS( psessionEntry->limReassocBssCaps );
2679
2680 fWmeEnabled = ( psessionEntry->limWmeEnabled ) &&
2681 LIM_BSS_CAPS_GET( WME, psessionEntry->limReassocBssQosCaps );
2682
2683 fWsmEnabled = ( psessionEntry->limWsmEnabled ) && fWmeEnabled &&
2684 LIM_BSS_CAPS_GET( WSM, psessionEntry->limReassocBssQosCaps );
2685
2686 if ( psessionEntry->lim11hEnable &&
2687 psessionEntry->pLimReAssocReq->spectrumMgtIndicator == eSIR_TRUE )
2688 {
2689#if defined WLAN_FEATURE_VOWIFI
2690 PowerCapsPopulated = TRUE;
2691
2692 PopulateDot11fPowerCaps( pMac, &frm.PowerCaps, LIM_REASSOC,psessionEntry);
2693 PopulateDot11fSuppChannels( pMac, &frm.SuppChannels, LIM_REASSOC,psessionEntry);
2694#endif
2695 }
2696
2697#if defined WLAN_FEATURE_VOWIFI
2698 if( pMac->rrm.rrmPEContext.rrmEnable &&
2699 SIR_MAC_GET_RRM( psessionEntry->limCurrentBssCaps ) )
2700 {
2701 if (PowerCapsPopulated == FALSE)
2702 {
2703 PowerCapsPopulated = TRUE;
2704 PopulateDot11fPowerCaps(pMac, &frm.PowerCaps, LIM_REASSOC, psessionEntry);
2705 }
2706 }
2707#endif
2708
2709 if ( fQosEnabled &&
2710 ( ! PROP_CAPABILITY_GET(11EQOS, psessionEntry->limReassocBssPropCap ) ))
2711 {
2712 PopulateDot11fQOSCapsStation( pMac, &frm.QOSCapsStation );
2713 }
2714
2715 PopulateDot11fExtSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
2716 &frm.ExtSuppRates, psessionEntry );
2717
2718#if defined WLAN_FEATURE_VOWIFI
2719 if( pMac->rrm.rrmPEContext.rrmEnable &&
2720 SIR_MAC_GET_RRM( psessionEntry->limReassocBssCaps ) )
2721 {
2722 PopulateDot11fRRMIe( pMac, &frm.RRMEnabledCap, psessionEntry );
2723 }
2724#endif
2725
2726 // Ideally this should be enabled for 11r also. But 11r does
2727 // not follow the usual norm of using the Opaque object
2728 // for rsnie and fties. Instead we just add
2729 // the rsnie and fties at the end of the pack routine for 11r.
2730 // This should ideally! be fixed.
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002731#if defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07002732 //
2733 // The join request *should* contain zero or one of the WPA and RSN
2734 // IEs. The payload send along with the request is a
2735 // 'tSirSmeJoinReq'; the IE portion is held inside a 'tSirRSNie':
2736
2737 // typedef struct sSirRSNie
2738 // {
2739 // tANI_U16 length;
2740 // tANI_U8 rsnIEdata[SIR_MAC_MAX_IE_LENGTH+2];
2741 // } tSirRSNie, *tpSirRSNie;
2742
2743 // So, we should be able to make the following two calls harmlessly,
2744 // since they do nothing if they don't find the given IE in the
2745 // bytestream with which they're provided.
2746
2747 // The net effect of this will be to faithfully transmit whatever
2748 // security IE is in the join request.
2749
2750 // *However*, if we're associating for the purpose of WPS
2751 // enrollment, and we've been configured to indicate that by
2752 // eliding the WPA or RSN IE, we just skip this:
2753 if (!psessionEntry->is11Rconnection)
2754 {
2755 if( nAddIELen && pAddIE )
2756 {
2757 wpsIe = limGetWscIEPtr(pMac, pAddIE, nAddIELen);
2758 }
2759 if ( NULL == wpsIe )
2760 {
2761 PopulateDot11fRSNOpaque( pMac, &( psessionEntry->pLimReAssocReq->rsnIE ),
2762 &frm.RSNOpaque );
2763 PopulateDot11fWPAOpaque( pMac, &( psessionEntry->pLimReAssocReq->rsnIE ),
2764 &frm.WPAOpaque );
2765 }
2766
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002767#ifdef FEATURE_WLAN_ESE
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302768 if (psessionEntry->pLimReAssocReq->cckmIE.length)
Jeff Johnson295189b2012-06-20 16:38:30 -07002769 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002770 PopulateDot11fESECckmOpaque( pMac, &( psessionEntry->pLimReAssocReq->cckmIE ),
2771 &frm.ESECckmOpaque );
Jeff Johnson295189b2012-06-20 16:38:30 -07002772 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002773#endif //FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07002774 }
2775
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002776#ifdef FEATURE_WLAN_ESE
2777 // For ESE Associations fill the ESE IEs
2778 if (psessionEntry->isESEconnection &&
2779 psessionEntry->pLimReAssocReq->isESEFeatureIniEnabled)
Jeff Johnson295189b2012-06-20 16:38:30 -07002780 {
Varun Reddy Yeturu30779b42013-04-09 09:57:16 -07002781#ifndef FEATURE_DISABLE_RM
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002782 PopulateDot11fESERadMgmtCap(&frm.ESERadMgmtCap);
Varun Reddy Yeturu30779b42013-04-09 09:57:16 -07002783#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002784 PopulateDot11fESEVersion(&frm.ESEVersion);
Jeff Johnson295189b2012-06-20 16:38:30 -07002785 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002786#endif //FEATURE_WLAN_ESE
2787#endif //FEATURE_WLAN_ESE || FEATURE_WLAN_LFR
Jeff Johnson295189b2012-06-20 16:38:30 -07002788
2789 // include WME EDCA IE as well
2790 if ( fWmeEnabled )
2791 {
2792 if ( ! PROP_CAPABILITY_GET( WME, psessionEntry->limReassocBssPropCap ) )
2793 {
2794 PopulateDot11fWMMInfoStation( pMac, &frm.WMMInfoStation );
2795 }
2796
2797 if ( fWsmEnabled &&
2798 ( ! PROP_CAPABILITY_GET(WSM, psessionEntry->limReassocBssPropCap )))
2799 {
2800 PopulateDot11fWMMCaps( &frm.WMMCaps );
2801 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002802#ifdef FEATURE_WLAN_ESE
2803 if (psessionEntry->isESEconnection)
Jeff Johnson295189b2012-06-20 16:38:30 -07002804 {
2805 PopulateDot11fReAssocTspec(pMac, &frm, psessionEntry);
2806
2807 // Populate the TSRS IE if TSPEC is included in the reassoc request
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002808 if (psessionEntry->pLimReAssocReq->eseTspecInfo.numTspecs)
Jeff Johnson295189b2012-06-20 16:38:30 -07002809 {
2810 tANI_U32 phyMode;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002811 tSirMacESETSRSIE tsrsIE;
Jeff Johnson295189b2012-06-20 16:38:30 -07002812 limGetPhyMode(pMac, &phyMode, psessionEntry);
2813
2814 tsrsIE.tsid = 0;
2815 if( phyMode == WNI_CFG_PHY_MODE_11G || phyMode == WNI_CFG_PHY_MODE_11A)
2816 {
2817 tsrsIE.rates[0] = TSRS_11AG_RATE_6MBPS;
2818 }
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302819 else
Jeff Johnson295189b2012-06-20 16:38:30 -07002820 {
2821 tsrsIE.rates[0] = TSRS_11B_RATE_5_5MBPS;
2822 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002823 PopulateDot11TSRSIE(pMac,&tsrsIE, &frm.ESETrafStrmRateSet, sizeof(tANI_U8));
Jeff Johnson295189b2012-06-20 16:38:30 -07002824 }
2825 }
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302826#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002827 }
2828
Jeff Johnsone7245742012-09-05 17:12:55 -07002829 if ( psessionEntry->htCapability &&
Jeff Johnson295189b2012-06-20 16:38:30 -07002830 pMac->lim.htCapabilityPresentInBeacon)
2831 {
Jeff Johnsone7245742012-09-05 17:12:55 -07002832 PopulateDot11fHTCaps( pMac, psessionEntry, &frm.HTCaps );
Jeff Johnson295189b2012-06-20 16:38:30 -07002833 }
2834
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08002835#if defined WLAN_FEATURE_VOWIFI_11R
Kanchanapally, Vidyullatha4f84f682014-04-29 20:40:34 +05302836 if ( psessionEntry->pLimReAssocReq->bssDescription.mdiePresent &&
2837 (pMac->ft.ftSmeContext.addMDIE == TRUE)
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002838#if defined FEATURE_WLAN_ESE
2839 && !psessionEntry->isESEconnection
Gopichand Nakkala0ac55062013-04-08 14:43:07 +05302840#endif
2841 )
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08002842 {
2843 PopulateMDIE( pMac, &frm.MobilityDomain, psessionEntry->pLimReAssocReq->bssDescription.mdie);
2844 }
2845#endif
2846
Chet Lanctotf19c1f62013-12-13 13:56:21 -08002847#ifdef WLAN_FEATURE_11AC
2848 if ( psessionEntry->vhtCapability &&
2849 psessionEntry->vhtCapabilityPresentInBeacon)
2850 {
2851 limLog( pMac, LOG1, FL("Populate VHT IEs in Re-Assoc Request"));
Abhishek Singh6d5d29c2014-07-03 14:25:22 +05302852 PopulateDot11fVHTCaps( pMac, &frm.VHTCaps, eSIR_FALSE );
Chet Lanctotf19c1f62013-12-13 13:56:21 -08002853 }
2854#endif
Sandeep Puligilla60342762014-01-30 21:05:37 +05302855 PopulateDot11fExtCap( pMac, &frm.ExtCap, psessionEntry);
Chet Lanctotf19c1f62013-12-13 13:56:21 -08002856
Jeff Johnson295189b2012-06-20 16:38:30 -07002857 nStatus = dot11fGetPackedReAssocRequestSize( pMac, &frm, &nPayload );
2858 if ( DOT11F_FAILED( nStatus ) )
2859 {
2860 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002861 "or a Re-Association Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002862 nStatus );
2863 // We'll fall back on the worst case scenario:
2864 nPayload = sizeof( tDot11fReAssocRequest );
2865 }
2866 else if ( DOT11F_WARNED( nStatus ) )
2867 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08002868 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07002869 "the packed size for a Re-Association Re "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002870 "quest(0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07002871 }
2872
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07002873 nBytes = nPayload + sizeof( tSirMacMgmtHdr ) + nAddIELen;
Jeff Johnson295189b2012-06-20 16:38:30 -07002874
2875#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08002876 limLog( pMac, LOG1, FL("FT IE Reassoc Req (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002877 pMac->ft.ftSmeContext.reassoc_ft_ies_length);
2878#endif
2879
2880#if defined WLAN_FEATURE_VOWIFI_11R
2881 if (psessionEntry->is11Rconnection)
2882 {
2883 ft_ies_length = pMac->ft.ftSmeContext.reassoc_ft_ies_length;
2884 }
2885#endif
2886
2887 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
2888 ( tANI_U16 )nBytes+ft_ies_length, ( void** ) &pFrame,
2889 ( void** ) &pPacket );
2890 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
2891 {
2892 psessionEntry->limMlmState = psessionEntry->limPrevMlmState;
Jeff Johnsone7245742012-09-05 17:12:55 -07002893 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07002894 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Re-As"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002895 "sociation Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07002896 goto end;
2897 }
2898
2899 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302900 vos_mem_set( pFrame, nBytes + ft_ies_length, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07002901
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002902#if defined WLAN_FEATURE_VOWIFI_11R_DEBUG || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08002903 limPrintMacAddr(pMac, psessionEntry->limReAssocbssId, LOG1);
Jeff Johnson295189b2012-06-20 16:38:30 -07002904#endif
2905 // Next, we fill out the buffer descriptor:
2906 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
2907 SIR_MAC_MGMT_REASSOC_REQ,
2908 psessionEntry->limReAssocbssId,psessionEntry->selfMacAddr);
2909 if ( eSIR_SUCCESS != nSirStatus )
2910 {
2911 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002912 "tor for an Association Request (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002913 nSirStatus );
2914 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
2915 goto end;
2916 }
2917
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05302918 pMacHdr = (tpSirMacMgmtHdr) pFrame;
Jeff Johnson295189b2012-06-20 16:38:30 -07002919 // That done, pack the ReAssoc Request:
2920 nStatus = dot11fPackReAssocRequest( pMac, &frm, pFrame +
2921 sizeof(tSirMacMgmtHdr),
2922 nPayload, &nPayload );
2923 if ( DOT11F_FAILED( nStatus ) )
2924 {
2925 limLog( pMac, LOGE, FL("Failed to pack a Re-Association Reque"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002926 "st (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002927 nStatus );
2928 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
2929 goto end;
2930 }
2931 else if ( DOT11F_WARNED( nStatus ) )
2932 {
2933 limLog( pMac, LOGW, FL("There were warnings while packing a R"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08002934 "e-Association Request (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07002935 }
2936
2937 PELOG3(limLog( pMac, LOG3,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002938 FL("*** Sending Re-Association Request length %d %d to "),
Jeff Johnson295189b2012-06-20 16:38:30 -07002939 nBytes, nPayload );)
2940 if( psessionEntry->assocReq != NULL )
2941 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302942 vos_mem_free(psessionEntry->assocReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07002943 psessionEntry->assocReq = NULL;
2944 }
2945
2946 if( nAddIELen )
2947 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302948 vos_mem_copy( pFrame + sizeof(tSirMacMgmtHdr) + nPayload,
2949 pAddIE,
2950 nAddIELen );
Jeff Johnson295189b2012-06-20 16:38:30 -07002951 nPayload += nAddIELen;
2952 }
2953
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302954 psessionEntry->assocReq = vos_mem_malloc(nPayload);
2955 if ( NULL == psessionEntry->assocReq )
Jeff Johnson295189b2012-06-20 16:38:30 -07002956 {
2957 PELOGE(limLog(pMac, LOGE, FL("Unable to allocate memory to store assoc request"));)
Jeff Johnson43971f52012-07-17 12:26:56 -07002958 }
2959 else
2960 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002961 //Store the Assoc request. This is sent to csr/hdd in join cnf response.
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302962 vos_mem_copy( psessionEntry->assocReq, pFrame + sizeof(tSirMacMgmtHdr), nPayload);
Jeff Johnson295189b2012-06-20 16:38:30 -07002963 psessionEntry->assocReqLen = nPayload;
Jeff Johnson43971f52012-07-17 12:26:56 -07002964 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002965
2966 if (psessionEntry->is11Rconnection)
2967 {
2968 {
2969 int i = 0;
2970
2971 pBody = pFrame + nBytes;
2972 for (i=0; i<ft_ies_length; i++)
2973 {
2974 *pBody = pMac->ft.ftSmeContext.reassoc_ft_ies[i];
2975 pBody++;
2976 }
2977 }
2978 }
2979
2980#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08002981 PELOGE(limLog(pMac, LOG1, FL("Re-assoc Req Frame is: "));
2982 sirDumpBuf(pMac, SIR_LIM_MODULE_ID, LOG1,
Jeff Johnson295189b2012-06-20 16:38:30 -07002983 (tANI_U8 *)pFrame,
2984 (nBytes + ft_ies_length));)
2985#endif
2986
2987
2988 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07002989 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
2990 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07002991 )
2992 {
2993 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
2994 }
2995
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07002996 if( NULL != psessionEntry->assocReq )
2997 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302998 vos_mem_free(psessionEntry->assocReq);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07002999 psessionEntry->assocReq = NULL;
3000 }
3001
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303002 psessionEntry->assocReq = vos_mem_malloc(ft_ies_length);
3003 if ( NULL == psessionEntry->assocReq )
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07003004 {
3005 PELOGE(limLog(pMac, LOGE, FL("Unable to allocate memory to store assoc request"));)
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08003006 psessionEntry->assocReqLen = 0;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07003007 }
3008 else
3009 {
3010 //Store the Assoc request. This is sent to csr/hdd in join cnf response.
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303011 vos_mem_copy( psessionEntry->assocReq, pMac->ft.ftSmeContext.reassoc_ft_ies,
3012 (ft_ies_length));
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07003013 psessionEntry->assocReqLen = (ft_ies_length);
3014 }
3015
3016
Mihir Shete63561c82014-08-23 16:58:07 +05303017 // Enable TL cahching in case of roaming
3018 WLANTL_EnableCaching(psessionEntry->staId);
3019
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05303020 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
3021 psessionEntry->peSessionId,
3022 pMacHdr->fc.subType));
Jeff Johnson295189b2012-06-20 16:38:30 -07003023 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) (nBytes + ft_ies_length),
3024 HAL_TXRX_FRM_802_11_MGMT,
3025 ANI_TXDIR_TODS,
3026 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
3027 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05303028 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
3029 psessionEntry->peSessionId,
3030 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07003031 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3032 {
3033 limLog( pMac, LOGE, FL("Failed to send Re-Association Request"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003034 "(%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07003035 nSirStatus );
3036 //Pkt will be freed up by the callback
3037 goto end;
3038 }
3039
3040end:
3041 // Free up buffer allocated for mlmAssocReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303042 vos_mem_free( pMlmReassocReq );
Jeff Johnson295189b2012-06-20 16:38:30 -07003043 psessionEntry->pLimMlmReassocReq = NULL;
3044
3045}
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -07003046
3047void limSendRetryReassocReqFrame(tpAniSirGlobal pMac,
3048 tLimMlmReassocReq *pMlmReassocReq,
3049 tpPESession psessionEntry)
3050{
3051 tLimMlmReassocCnf mlmReassocCnf; // keep sme
3052 tLimMlmReassocReq *pTmpMlmReassocReq = NULL;
3053 if(NULL == pTmpMlmReassocReq)
3054 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303055 pTmpMlmReassocReq = vos_mem_malloc(sizeof(tLimMlmReassocReq));
3056 if ( NULL == pTmpMlmReassocReq ) goto end;
3057 vos_mem_set( pTmpMlmReassocReq, sizeof(tLimMlmReassocReq), 0);
3058 vos_mem_copy( pTmpMlmReassocReq, pMlmReassocReq, sizeof(tLimMlmReassocReq));
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -07003059 }
3060
3061 // Prepare and send Reassociation request frame
3062 // start reassoc timer.
3063 pMac->lim.limTimers.gLimReassocFailureTimer.sessionId = psessionEntry->peSessionId;
3064 // Start reassociation failure timer
Leela V Kiran Kumar Reddy Chiralac3b9d382013-01-31 20:49:53 -08003065 MTRACE(macTrace(pMac, TRACE_CODE_TIMER_ACTIVATE, psessionEntry->peSessionId, eLIM_REASSOC_FAIL_TIMER));
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -07003066 if (tx_timer_activate(&pMac->lim.limTimers.gLimReassocFailureTimer)
3067 != TX_SUCCESS)
3068 {
3069 // Could not start reassoc failure timer.
3070 // Log error
3071 limLog(pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003072 FL("could not start Reassociation failure timer"));
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -07003073 // Return Reassoc confirm with
3074 // Resources Unavailable
3075 mlmReassocCnf.resultCode = eSIR_SME_RESOURCES_UNAVAILABLE;
3076 mlmReassocCnf.protStatusCode = eSIR_MAC_UNSPEC_FAILURE_STATUS;
3077 goto end;
3078 }
3079
3080 limSendReassocReqWithFTIEsMgmtFrame(pMac, pTmpMlmReassocReq, psessionEntry);
3081 return;
3082
3083end:
3084 // Free up buffer allocated for reassocReq
3085 if (pMlmReassocReq != NULL)
3086 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303087 vos_mem_free(pMlmReassocReq);
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -07003088 pMlmReassocReq = NULL;
3089 }
3090 if (pTmpMlmReassocReq != NULL)
3091 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303092 vos_mem_free(pTmpMlmReassocReq);
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -07003093 pTmpMlmReassocReq = NULL;
3094 }
3095 mlmReassocCnf.resultCode = eSIR_SME_FT_REASSOC_FAILURE;
3096 mlmReassocCnf.protStatusCode = eSIR_MAC_UNSPEC_FAILURE_STATUS;
3097 /* Update PE sessio Id*/
3098 mlmReassocCnf.sessionId = psessionEntry->peSessionId;
3099
3100 limPostSmeMessage(pMac, LIM_MLM_REASSOC_CNF, (tANI_U32 *) &mlmReassocCnf);
3101}
3102
Jeff Johnson295189b2012-06-20 16:38:30 -07003103#endif /* WLAN_FEATURE_VOWIFI_11R */
3104
3105
3106void
3107limSendReassocReqMgmtFrame(tpAniSirGlobal pMac,
3108 tLimMlmReassocReq *pMlmReassocReq,tpPESession psessionEntry)
3109{
3110 static tDot11fReAssocRequest frm;
3111 tANI_U16 caps;
3112 tANI_U8 *pFrame;
3113 tSirRetStatus nSirStatus;
3114 tANI_U32 nBytes, nPayload, nStatus;
3115 tANI_U8 fQosEnabled, fWmeEnabled, fWsmEnabled;
3116 void *pPacket;
3117 eHalStatus halstatus;
3118 tANI_U16 nAddIELen;
3119 tANI_U8 *pAddIE;
3120 tANI_U8 *wpsIe = NULL;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05303121 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003122#if defined WLAN_FEATURE_VOWIFI
3123 tANI_U8 PowerCapsPopulated = FALSE;
3124#endif
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05303125 tpSirMacMgmtHdr pMacHdr;
Jeff Johnson295189b2012-06-20 16:38:30 -07003126
3127 if(NULL == psessionEntry)
3128 {
3129 return;
3130 }
3131
3132 /* check this early to avoid unncessary operation */
3133 if(NULL == psessionEntry->pLimReAssocReq)
3134 {
3135 return;
3136 }
3137 nAddIELen = psessionEntry->pLimReAssocReq->addIEAssoc.length;
3138 pAddIE = psessionEntry->pLimReAssocReq->addIEAssoc.addIEdata;
3139
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303140 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07003141
3142 caps = pMlmReassocReq->capabilityInfo;
3143 if (PROP_CAPABILITY_GET(11EQOS, psessionEntry->limReassocBssPropCap))
3144 ((tSirMacCapabilityInfo *) &caps)->qos = 0;
3145#if defined(FEATURE_WLAN_WAPI)
3146 /* CR: 262463 :
3147 According to WAPI standard:
3148 7.3.1.4 Capability Information field
3149 In WAPI, non-AP STAs within an ESS set the Privacy subfield to 0 in transmitted
3150 Association or Reassociation management frames. APs ignore the Privacy subfield within received Association and
3151 Reassociation management frames. */
3152 if ( psessionEntry->encryptType == eSIR_ED_WPI)
3153 ((tSirMacCapabilityInfo *) &caps)->privacy = 0;
3154#endif
3155 swapBitField16(caps, ( tANI_U16* )&frm.Capabilities );
3156
3157 frm.ListenInterval.interval = pMlmReassocReq->listenInterval;
3158
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303159 vos_mem_copy(( tANI_U8* )frm.CurrentAPAddress.mac,
3160 ( tANI_U8* )psessionEntry->bssId, 6 );
Jeff Johnson295189b2012-06-20 16:38:30 -07003161
3162 PopulateDot11fSSID2( pMac, &frm.SSID );
3163 PopulateDot11fSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
3164 &frm.SuppRates,psessionEntry);
3165
3166 fQosEnabled = ( psessionEntry->limQosEnabled ) &&
3167 SIR_MAC_GET_QOS( psessionEntry->limReassocBssCaps );
3168
3169 fWmeEnabled = ( psessionEntry->limWmeEnabled ) &&
3170 LIM_BSS_CAPS_GET( WME, psessionEntry->limReassocBssQosCaps );
3171
3172 fWsmEnabled = ( psessionEntry->limWsmEnabled ) && fWmeEnabled &&
3173 LIM_BSS_CAPS_GET( WSM, psessionEntry->limReassocBssQosCaps );
3174
3175
3176 if ( psessionEntry->lim11hEnable &&
3177 psessionEntry->pLimReAssocReq->spectrumMgtIndicator == eSIR_TRUE )
3178 {
3179#if defined WLAN_FEATURE_VOWIFI
3180 PowerCapsPopulated = TRUE;
3181 PopulateDot11fPowerCaps( pMac, &frm.PowerCaps, LIM_REASSOC,psessionEntry);
3182 PopulateDot11fSuppChannels( pMac, &frm.SuppChannels, LIM_REASSOC,psessionEntry);
3183#endif
3184 }
3185
3186#if defined WLAN_FEATURE_VOWIFI
3187 if( pMac->rrm.rrmPEContext.rrmEnable &&
3188 SIR_MAC_GET_RRM( psessionEntry->limCurrentBssCaps ) )
3189 {
3190 if (PowerCapsPopulated == FALSE)
3191 {
3192 PowerCapsPopulated = TRUE;
3193 PopulateDot11fPowerCaps(pMac, &frm.PowerCaps, LIM_REASSOC, psessionEntry);
3194 }
3195 }
3196#endif
3197
3198 if ( fQosEnabled &&
3199 ( ! PROP_CAPABILITY_GET(11EQOS, psessionEntry->limReassocBssPropCap ) ))
3200 {
3201 PopulateDot11fQOSCapsStation( pMac, &frm.QOSCapsStation );
3202 }
3203
3204 PopulateDot11fExtSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
3205 &frm.ExtSuppRates, psessionEntry );
3206
3207#if defined WLAN_FEATURE_VOWIFI
3208 if( pMac->rrm.rrmPEContext.rrmEnable &&
3209 SIR_MAC_GET_RRM( psessionEntry->limReassocBssCaps ) )
3210 {
3211 PopulateDot11fRRMIe( pMac, &frm.RRMEnabledCap, psessionEntry );
3212 }
3213#endif
3214 // The join request *should* contain zero or one of the WPA and RSN
3215 // IEs. The payload send along with the request is a
3216 // 'tSirSmeJoinReq'; the IE portion is held inside a 'tSirRSNie':
3217
3218 // typedef struct sSirRSNie
3219 // {
3220 // tANI_U16 length;
3221 // tANI_U8 rsnIEdata[SIR_MAC_MAX_IE_LENGTH+2];
3222 // } tSirRSNie, *tpSirRSNie;
3223
3224 // So, we should be able to make the following two calls harmlessly,
3225 // since they do nothing if they don't find the given IE in the
3226 // bytestream with which they're provided.
3227
3228 // The net effect of this will be to faithfully transmit whatever
3229 // security IE is in the join request.
3230
3231 // *However*, if we're associating for the purpose of WPS
3232 // enrollment, and we've been configured to indicate that by
3233 // eliding the WPA or RSN IE, we just skip this:
3234 if( nAddIELen && pAddIE )
3235 {
3236 wpsIe = limGetWscIEPtr(pMac, pAddIE, nAddIELen);
3237 }
3238 if ( NULL == wpsIe )
3239 {
3240 PopulateDot11fRSNOpaque( pMac, &( psessionEntry->pLimReAssocReq->rsnIE ),
3241 &frm.RSNOpaque );
3242 PopulateDot11fWPAOpaque( pMac, &( psessionEntry->pLimReAssocReq->rsnIE ),
3243 &frm.WPAOpaque );
3244#if defined(FEATURE_WLAN_WAPI)
3245 PopulateDot11fWAPIOpaque( pMac, &( psessionEntry->pLimReAssocReq->rsnIE ),
3246 &frm.WAPIOpaque );
3247#endif // defined(FEATURE_WLAN_WAPI)
3248 }
3249
3250 // include WME EDCA IE as well
3251 if ( fWmeEnabled )
3252 {
3253 if ( ! PROP_CAPABILITY_GET( WME, psessionEntry->limReassocBssPropCap ) )
3254 {
3255 PopulateDot11fWMMInfoStation( pMac, &frm.WMMInfoStation );
3256 }
3257
3258 if ( fWsmEnabled &&
3259 ( ! PROP_CAPABILITY_GET(WSM, psessionEntry->limReassocBssPropCap )))
3260 {
3261 PopulateDot11fWMMCaps( &frm.WMMCaps );
3262 }
3263 }
3264
Jeff Johnsone7245742012-09-05 17:12:55 -07003265 if ( psessionEntry->htCapability &&
Jeff Johnson295189b2012-06-20 16:38:30 -07003266 pMac->lim.htCapabilityPresentInBeacon)
3267 {
Jeff Johnsone7245742012-09-05 17:12:55 -07003268 PopulateDot11fHTCaps( pMac, psessionEntry, &frm.HTCaps );
Jeff Johnson295189b2012-06-20 16:38:30 -07003269 }
Jeff Johnsone7245742012-09-05 17:12:55 -07003270#ifdef WLAN_FEATURE_11AC
3271 if ( psessionEntry->vhtCapability &&
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07003272 psessionEntry->vhtCapabilityPresentInBeacon)
Jeff Johnsone7245742012-09-05 17:12:55 -07003273 {
Chet Lanctotf19c1f62013-12-13 13:56:21 -08003274 limLog( pMac, LOG1, FL("Populate VHT IEs in Re-Assoc Request"));
Abhishek Singh6d5d29c2014-07-03 14:25:22 +05303275 PopulateDot11fVHTCaps( pMac, &frm.VHTCaps, eSIR_FALSE );
Sandeep Puligilla60342762014-01-30 21:05:37 +05303276 PopulateDot11fExtCap( pMac, &frm.ExtCap, psessionEntry);
Jeff Johnsone7245742012-09-05 17:12:55 -07003277 }
3278#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003279
3280 nStatus = dot11fGetPackedReAssocRequestSize( pMac, &frm, &nPayload );
3281 if ( DOT11F_FAILED( nStatus ) )
3282 {
3283 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003284 "or a Re-Association Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003285 nStatus );
3286 // We'll fall back on the worst case scenario:
3287 nPayload = sizeof( tDot11fReAssocRequest );
3288 }
3289 else if ( DOT11F_WARNED( nStatus ) )
3290 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08003291 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07003292 "the packed size for a Re-Association Re "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003293 "quest(0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07003294 }
3295
3296 nBytes = nPayload + sizeof( tSirMacMgmtHdr ) + nAddIELen;
3297
3298 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
3299 ( tANI_U16 )nBytes, ( void** ) &pFrame,
3300 ( void** ) &pPacket );
3301 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3302 {
3303 psessionEntry->limMlmState = psessionEntry->limPrevMlmState;
Jeff Johnsone7245742012-09-05 17:12:55 -07003304 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07003305 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Re-As"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003306 "sociation Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07003307 goto end;
3308 }
3309
3310 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303311 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07003312
3313 // Next, we fill out the buffer descriptor:
3314 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
3315 SIR_MAC_MGMT_REASSOC_REQ,
3316 psessionEntry->limReAssocbssId,psessionEntry->selfMacAddr);
3317 if ( eSIR_SUCCESS != nSirStatus )
3318 {
3319 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003320 "tor for an Association Request (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003321 nSirStatus );
3322 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
3323 goto end;
3324 }
3325
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05303326 pMacHdr = (tpSirMacMgmtHdr) pFrame;
Jeff Johnson295189b2012-06-20 16:38:30 -07003327 // That done, pack the Probe Request:
3328 nStatus = dot11fPackReAssocRequest( pMac, &frm, pFrame +
3329 sizeof(tSirMacMgmtHdr),
3330 nPayload, &nPayload );
3331 if ( DOT11F_FAILED( nStatus ) )
3332 {
3333 limLog( pMac, LOGE, FL("Failed to pack a Re-Association Reque"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003334 "st (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003335 nStatus );
3336 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
3337 goto end;
3338 }
3339 else if ( DOT11F_WARNED( nStatus ) )
3340 {
3341 limLog( pMac, LOGW, FL("There were warnings while packing a R"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08003342 "e-Association Request (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07003343 }
3344
3345 PELOG1(limLog( pMac, LOG1, FL("*** Sending Re-Association Request length %d"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003346 "to "),
Jeff Johnson295189b2012-06-20 16:38:30 -07003347 nBytes );)
3348
3349 if( psessionEntry->assocReq != NULL )
3350 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303351 vos_mem_free(psessionEntry->assocReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07003352 psessionEntry->assocReq = NULL;
3353 }
3354
3355 if( nAddIELen )
3356 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303357 vos_mem_copy( pFrame + sizeof(tSirMacMgmtHdr) + nPayload,
3358 pAddIE,
3359 nAddIELen );
Jeff Johnson295189b2012-06-20 16:38:30 -07003360 nPayload += nAddIELen;
3361 }
3362
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303363 psessionEntry->assocReq = vos_mem_malloc(nPayload);
3364 if ( NULL == psessionEntry->assocReq )
Jeff Johnson295189b2012-06-20 16:38:30 -07003365 {
3366 PELOGE(limLog(pMac, LOGE, FL("Unable to allocate memory to store assoc request"));)
Jeff Johnson43971f52012-07-17 12:26:56 -07003367 }
3368 else
3369 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003370 //Store the Assoc request. This is sent to csr/hdd in join cnf response.
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303371 vos_mem_copy(psessionEntry->assocReq, pFrame + sizeof(tSirMacMgmtHdr), nPayload);
Jeff Johnson295189b2012-06-20 16:38:30 -07003372 psessionEntry->assocReqLen = nPayload;
Jeff Johnson43971f52012-07-17 12:26:56 -07003373 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003374
3375 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07003376 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
3377 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07003378 )
3379 {
3380 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
3381 }
3382
Gopichand Nakkalad3918dd2012-12-31 16:27:55 -08003383 if(psessionEntry->pePersona == VOS_P2P_CLIENT_MODE)
Ganesh K08bce952012-12-13 15:04:41 -08003384 {
3385 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
3386 }
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08003387
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05303388 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
3389 psessionEntry->peSessionId,
3390 pMacHdr->fc.subType));
Katya Nigam63902932014-06-26 19:04:23 +05303391
3392 // enable caching
3393 WLANTL_EnableCaching(psessionEntry->staId);
3394
Jeff Johnson295189b2012-06-20 16:38:30 -07003395 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) (sizeof(tSirMacMgmtHdr) + nPayload),
3396 HAL_TXRX_FRM_802_11_MGMT,
3397 ANI_TXDIR_TODS,
3398 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
3399 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05303400 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
3401 psessionEntry->peSessionId,
3402 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07003403 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3404 {
3405 limLog( pMac, LOGE, FL("Failed to send Re-Association Request"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003406 "(%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07003407 nSirStatus );
3408 //Pkt will be freed up by the callback
3409 goto end;
3410 }
3411
3412end:
3413 // Free up buffer allocated for mlmAssocReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303414 vos_mem_free( pMlmReassocReq );
Jeff Johnson295189b2012-06-20 16:38:30 -07003415 psessionEntry->pLimMlmReassocReq = NULL;
3416
3417} // limSendReassocReqMgmtFrame
3418
3419/**
3420 * \brief Send an Authentication frame
3421 *
3422 *
3423 * \param pMac Pointer to Global MAC structure
3424 *
3425 * \param pAuthFrameBody Pointer to Authentication frame structure that need
3426 * to be sent
3427 *
3428 * \param peerMacAddr MAC address of the peer entity to which Authentication
3429 * frame is destined
3430 *
3431 * \param wepBit Indicates whether wep bit to be set in FC while sending
3432 * Authentication frame3
3433 *
3434 *
3435 * This function is called by limProcessMlmMessages(). Authentication frame
3436 * is formatted and sent when this function is called.
3437 *
3438 *
3439 */
3440
3441void
3442limSendAuthMgmtFrame(tpAniSirGlobal pMac,
3443 tpSirMacAuthFrameBody pAuthFrameBody,
3444 tSirMacAddr peerMacAddr,
3445 tANI_U8 wepBit,
3446 tpPESession psessionEntry
3447 )
3448{
3449 tANI_U8 *pFrame, *pBody;
3450 tANI_U32 frameLen = 0, bodyLen = 0;
3451 tpSirMacMgmtHdr pMacHdr;
3452 tANI_U16 i;
3453 void *pPacket;
3454 eHalStatus halstatus;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05303455 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003456
3457 if(NULL == psessionEntry)
3458 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05303459 limLog(pMac, LOGE, FL("Error: psession Entry is NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003460 return;
3461 }
Abhishek Singh57aebef2014-02-03 18:47:44 +05303462
3463 limLog(pMac, LOG1,
3464 FL("Sending Auth seq# %d status %d (%d) to "MAC_ADDRESS_STR),
3465 pAuthFrameBody->authTransactionSeqNumber,
3466 pAuthFrameBody->authStatusCode,
3467 (pAuthFrameBody->authStatusCode == eSIR_MAC_SUCCESS_STATUS),
3468 MAC_ADDR_ARRAY(peerMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07003469 if (wepBit == LIM_WEP_IN_FC)
3470 {
3471 /// Auth frame3 to be sent with encrypted framebody
3472 /**
3473 * Allocate buffer for Authenticaton frame of size equal
3474 * to management frame header length plus 2 bytes each for
3475 * auth algorithm number, transaction number, status code,
3476 * 128 bytes for challenge text and 4 bytes each for
3477 * IV & ICV.
3478 */
3479
3480 frameLen = sizeof(tSirMacMgmtHdr) + LIM_ENCR_AUTH_BODY_LEN;
3481
3482 bodyLen = LIM_ENCR_AUTH_BODY_LEN;
3483 } // if (wepBit == LIM_WEP_IN_FC)
3484 else
3485 {
3486 switch (pAuthFrameBody->authTransactionSeqNumber)
3487 {
3488 case SIR_MAC_AUTH_FRAME_1:
3489 /**
3490 * Allocate buffer for Authenticaton frame of size
3491 * equal to management frame header length plus 2 bytes
3492 * each for auth algorithm number, transaction number
3493 * and status code.
3494 */
3495
3496 frameLen = sizeof(tSirMacMgmtHdr) +
3497 SIR_MAC_AUTH_CHALLENGE_OFFSET;
3498 bodyLen = SIR_MAC_AUTH_CHALLENGE_OFFSET;
3499
3500#if defined WLAN_FEATURE_VOWIFI_11R
Madan Mohan Koyyalamudi6a00a802012-11-28 16:12:11 -08003501 if (pAuthFrameBody->authAlgoNumber == eSIR_FT_AUTH)
3502 {
3503 if (0 != pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length)
Jeff Johnson295189b2012-06-20 16:38:30 -07003504 {
Madan Mohan Koyyalamudi6a00a802012-11-28 16:12:11 -08003505 frameLen += pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length;
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003506 limLog(pMac, LOG3, FL("Auth frame, FTIES length added=%d"),
Madan Mohan Koyyalamudi6a00a802012-11-28 16:12:11 -08003507 pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length);
Jeff Johnson295189b2012-06-20 16:38:30 -07003508 }
Madan Mohan Koyyalamudi6a00a802012-11-28 16:12:11 -08003509 else
3510 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05303511 limLog(pMac, LOG3, FL("Auth frame, Does not contain "
3512 "FTIES!!!"));
Madan Mohan Koyyalamudi6a00a802012-11-28 16:12:11 -08003513 frameLen += (2+SIR_MDIE_SIZE);
3514 }
3515 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003516#endif
3517 break;
3518
3519 case SIR_MAC_AUTH_FRAME_2:
3520 if ((pAuthFrameBody->authAlgoNumber == eSIR_OPEN_SYSTEM) ||
3521 ((pAuthFrameBody->authAlgoNumber == eSIR_SHARED_KEY) &&
3522 (pAuthFrameBody->authStatusCode != eSIR_MAC_SUCCESS_STATUS)))
3523 {
3524 /**
3525 * Allocate buffer for Authenticaton frame of size
3526 * equal to management frame header length plus
3527 * 2 bytes each for auth algorithm number,
3528 * transaction number and status code.
3529 */
3530
3531 frameLen = sizeof(tSirMacMgmtHdr) +
3532 SIR_MAC_AUTH_CHALLENGE_OFFSET;
3533 bodyLen = SIR_MAC_AUTH_CHALLENGE_OFFSET;
3534 }
3535 else
3536 {
3537 // Shared Key algorithm with challenge text
3538 // to be sent
3539 /**
3540 * Allocate buffer for Authenticaton frame of size
3541 * equal to management frame header length plus
3542 * 2 bytes each for auth algorithm number,
3543 * transaction number, status code and 128 bytes
3544 * for challenge text.
3545 */
3546
3547 frameLen = sizeof(tSirMacMgmtHdr) +
3548 sizeof(tSirMacAuthFrame);
3549 bodyLen = sizeof(tSirMacAuthFrameBody);
3550 }
3551
3552 break;
3553
3554 case SIR_MAC_AUTH_FRAME_3:
3555 /// Auth frame3 to be sent without encrypted framebody
3556 /**
3557 * Allocate buffer for Authenticaton frame of size equal
3558 * to management frame header length plus 2 bytes each
3559 * for auth algorithm number, transaction number and
3560 * status code.
3561 */
3562
3563 frameLen = sizeof(tSirMacMgmtHdr) +
3564 SIR_MAC_AUTH_CHALLENGE_OFFSET;
3565 bodyLen = SIR_MAC_AUTH_CHALLENGE_OFFSET;
3566
3567 break;
3568
3569 case SIR_MAC_AUTH_FRAME_4:
3570 /**
3571 * Allocate buffer for Authenticaton frame of size equal
3572 * to management frame header length plus 2 bytes each
3573 * for auth algorithm number, transaction number and
3574 * status code.
3575 */
3576
3577 frameLen = sizeof(tSirMacMgmtHdr) +
3578 SIR_MAC_AUTH_CHALLENGE_OFFSET;
3579 bodyLen = SIR_MAC_AUTH_CHALLENGE_OFFSET;
3580
3581 break;
3582 } // switch (pAuthFrameBody->authTransactionSeqNumber)
3583 } // end if (wepBit == LIM_WEP_IN_FC)
3584
3585
3586 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )frameLen, ( void** ) &pFrame, ( void** ) &pPacket );
3587
3588 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3589 {
3590 // Log error
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003591 limLog(pMac, LOGP, FL("call to bufAlloc failed for AUTH frame"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003592
3593 return;
3594 }
3595
3596 for (i = 0; i < frameLen; i++)
3597 pFrame[i] = 0;
3598
3599 // Prepare BD
3600 if (limPopulateMacHeader(pMac, pFrame, SIR_MAC_MGMT_FRAME,
3601 SIR_MAC_MGMT_AUTH, peerMacAddr,psessionEntry->selfMacAddr) != eSIR_SUCCESS)
3602 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05303603 limLog(pMac, LOGE, FL("call to limPopulateMacHeader failed for "
3604 "AUTH frame"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003605 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
3606 return;
3607 }
3608
3609 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
3610 pMacHdr->fc.wep = wepBit;
3611
3612 // Prepare BSSId
3613 if( (psessionEntry->limSystemRole == eLIM_AP_ROLE)|| (psessionEntry->limSystemRole == eLIM_BT_AMP_AP_ROLE) )
3614 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303615 vos_mem_copy( (tANI_U8 *) pMacHdr->bssId,
3616 (tANI_U8 *) psessionEntry->bssId,
3617 sizeof( tSirMacAddr ));
Jeff Johnson295189b2012-06-20 16:38:30 -07003618 }
3619
3620 /// Prepare Authentication frame body
3621 pBody = pFrame + sizeof(tSirMacMgmtHdr);
3622
3623 if (wepBit == LIM_WEP_IN_FC)
3624 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303625 vos_mem_copy(pBody, (tANI_U8 *) pAuthFrameBody, bodyLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07003626
3627 PELOG1(limLog(pMac, LOG1,
Abhishek Singh57aebef2014-02-03 18:47:44 +05303628 FL("*** Sending Auth seq# 3 status %d (%d) to"MAC_ADDRESS_STR),
Jeff Johnson295189b2012-06-20 16:38:30 -07003629 pAuthFrameBody->authStatusCode,
Abhishek Singh57aebef2014-02-03 18:47:44 +05303630 (pAuthFrameBody->authStatusCode == eSIR_MAC_SUCCESS_STATUS),
3631 MAC_ADDR_ARRAY(pMacHdr->da));)
Jeff Johnson295189b2012-06-20 16:38:30 -07003632
Jeff Johnson295189b2012-06-20 16:38:30 -07003633 }
3634 else
3635 {
3636 *((tANI_U16 *)(pBody)) = sirSwapU16ifNeeded(pAuthFrameBody->authAlgoNumber);
3637 pBody += sizeof(tANI_U16);
3638 bodyLen -= sizeof(tANI_U16);
3639
3640 *((tANI_U16 *)(pBody)) = sirSwapU16ifNeeded(pAuthFrameBody->authTransactionSeqNumber);
3641 pBody += sizeof(tANI_U16);
3642 bodyLen -= sizeof(tANI_U16);
3643
3644 *((tANI_U16 *)(pBody)) = sirSwapU16ifNeeded(pAuthFrameBody->authStatusCode);
3645 pBody += sizeof(tANI_U16);
3646 bodyLen -= sizeof(tANI_U16);
Leela Venkata Kiran Kumar Reddy Chirala7d3fa552013-08-28 10:52:21 -07003647 if ( bodyLen <= (sizeof (pAuthFrameBody->type) +
3648 sizeof (pAuthFrameBody->length) +
3649 sizeof (pAuthFrameBody->challengeText)))
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303650 vos_mem_copy(pBody, (tANI_U8 *) &pAuthFrameBody->type, bodyLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07003651
3652#if defined WLAN_FEATURE_VOWIFI_11R
3653 if ((pAuthFrameBody->authAlgoNumber == eSIR_FT_AUTH) &&
3654 (pAuthFrameBody->authTransactionSeqNumber == SIR_MAC_AUTH_FRAME_1))
3655 {
3656
3657 {
3658 int i = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003659 if (pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length)
3660 {
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08003661#if defined WLAN_FEATURE_VOWIFI_11R_DEBUG
Srinivas Girigowdad63eb492014-02-06 12:21:47 -08003662 PELOG2(limLog(pMac, LOG2, FL("Auth1 Frame FTIE is: "));
3663 sirDumpBuf(pMac, SIR_LIM_MODULE_ID, LOG2,
Jeff Johnson295189b2012-06-20 16:38:30 -07003664 (tANI_U8 *)pBody,
3665 (pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length));)
Jeff Johnson295189b2012-06-20 16:38:30 -07003666#endif
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08003667 for (i=0; i<pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length; i++)
3668 {
Madan Mohan Koyyalamudi6a00a802012-11-28 16:12:11 -08003669 *pBody = pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies[i];
3670 pBody++;
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08003671 }
3672 }
3673 else
3674 {
3675 /* MDID attr is 54*/
3676 *pBody = 54;
Jeff Johnson295189b2012-06-20 16:38:30 -07003677 pBody++;
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08003678 *pBody = SIR_MDIE_SIZE;
3679 pBody++;
3680 for(i=0;i<SIR_MDIE_SIZE;i++)
3681 {
3682 *pBody = pMac->ft.ftPEContext.pFTPreAuthReq->pbssDescription->mdie[i];
3683 pBody++;
3684 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003685 }
3686 }
3687 }
3688#endif
3689
3690 PELOG1(limLog(pMac, LOG1,
Abhishek Singh57aebef2014-02-03 18:47:44 +05303691 FL("*** Sending Auth seq# %d status %d (%d) to "MAC_ADDRESS_STR),
Jeff Johnson295189b2012-06-20 16:38:30 -07003692 pAuthFrameBody->authTransactionSeqNumber,
3693 pAuthFrameBody->authStatusCode,
Abhishek Singh57aebef2014-02-03 18:47:44 +05303694 (pAuthFrameBody->authStatusCode == eSIR_MAC_SUCCESS_STATUS),
3695 MAC_ADDR_ARRAY(pMacHdr->da));)
Jeff Johnson295189b2012-06-20 16:38:30 -07003696 }
3697 PELOG2(sirDumpBuf(pMac, SIR_LIM_MODULE_ID, LOG2, pFrame, frameLen);)
3698
3699 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07003700 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
3701 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003702#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05303703 || ((NULL != pMac->ft.ftPEContext.pFTPreAuthReq)
Jeff Johnsone7245742012-09-05 17:12:55 -07003704 && ( SIR_BAND_5_GHZ == limGetRFBand(pMac->ft.ftPEContext.pFTPreAuthReq->preAuthchannelNum)))
3705#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003706 )
3707 {
3708 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
3709 }
3710
Ganesh K08bce952012-12-13 15:04:41 -08003711 if(psessionEntry->pePersona == VOS_P2P_CLIENT_MODE)
3712 {
3713 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
3714 }
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08003715
Agarwal Ashisha8e81f52014-04-02 01:59:52 +05303716 limLog( pMac, LOG1, FL("Sending Auth Frame over WQ5 to "MAC_ADDRESS_STR
3717 " From " MAC_ADDRESS_STR),MAC_ADDR_ARRAY(pMacHdr->da),
3718 MAC_ADDR_ARRAY(psessionEntry->selfMacAddr));
3719
3720 txFlag |= HAL_USE_FW_IN_TX_PATH;
3721
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05303722 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
3723 psessionEntry->peSessionId,
3724 pMacHdr->fc.subType));
Jeff Johnson295189b2012-06-20 16:38:30 -07003725 /// Queue Authentication frame in high priority WQ
3726 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) frameLen,
3727 HAL_TXRX_FRM_802_11_MGMT,
3728 ANI_TXDIR_TODS,
3729 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
3730 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05303731 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
3732 psessionEntry->peSessionId,
3733 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07003734 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3735 {
3736 limLog(pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003737 FL("*** Could not send Auth frame, retCode=%X ***"),
Jeff Johnson295189b2012-06-20 16:38:30 -07003738 halstatus);
3739
3740 //Pkt will be freed up by the callback
3741 }
3742
3743 return;
3744} /*** end limSendAuthMgmtFrame() ***/
3745
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003746eHalStatus limSendDeauthCnf(tpAniSirGlobal pMac)
3747{
3748 tANI_U16 aid;
3749 tpDphHashNode pStaDs;
3750 tLimMlmDeauthReq *pMlmDeauthReq;
3751 tLimMlmDeauthCnf mlmDeauthCnf;
3752 tpPESession psessionEntry;
3753
3754 pMlmDeauthReq = pMac->lim.limDisassocDeauthCnfReq.pMlmDeauthReq;
3755 if (pMlmDeauthReq)
3756 {
3757 if (tx_timer_running(&pMac->lim.limTimers.gLimDeauthAckTimer))
3758 {
3759 limDeactivateAndChangeTimer(pMac, eLIM_DEAUTH_ACK_TIMER);
3760 }
3761
3762 if((psessionEntry = peFindSessionBySessionId(pMac, pMlmDeauthReq->sessionId))== NULL)
3763 {
3764
3765 PELOGE(limLog(pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003766 FL("session does not exist for given sessionId"));)
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003767 mlmDeauthCnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
3768 goto end;
3769 }
3770
3771 pStaDs = dphLookupHashEntry(pMac, pMlmDeauthReq->peerMacAddr, &aid, &psessionEntry->dph.dphHashTable);
3772 if (pStaDs == NULL)
3773 {
3774 mlmDeauthCnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
3775 goto end;
3776 }
3777
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003778 /// Receive path cleanup with dummy packet
3779 limCleanupRxPath(pMac, pStaDs,psessionEntry);
Abhishek Singhcf4590b2014-04-16 18:58:08 +05303780
3781#ifdef WLAN_FEATURE_VOWIFI_11R
Mukul Sharma0820d0e2014-11-11 19:49:02 +05303782 if ( psessionEntry->limSystemRole == eLIM_STA_ROLE )
Abhishek Singhcf4590b2014-04-16 18:58:08 +05303783 {
Mukul Sharma0820d0e2014-11-11 19:49:02 +05303784 PELOGE(limLog(pMac, LOG1,
3785 FL("FT Preauth SessionId %d Cleanup"
Abhishek Singhcf4590b2014-04-16 18:58:08 +05303786#ifdef FEATURE_WLAN_ESE
3787 " isESE %d"
3788#endif
3789#ifdef FEATURE_WLAN_LFR
3790 " isLFR %d"
3791#endif
3792 " is11r %d, Deauth reason %d Trigger = %d"),
Mukul Sharma0820d0e2014-11-11 19:49:02 +05303793 psessionEntry->peSessionId,
Abhishek Singhcf4590b2014-04-16 18:58:08 +05303794#ifdef FEATURE_WLAN_ESE
3795 psessionEntry->isESEconnection,
3796#endif
3797#ifdef FEATURE_WLAN_LFR
3798 psessionEntry->isFastRoamIniFeatureEnabled,
3799#endif
3800 psessionEntry->is11Rconnection,
3801 pMlmDeauthReq->reasonCode,
3802 pMlmDeauthReq->deauthTrigger););
Mukul Sharma0820d0e2014-11-11 19:49:02 +05303803
3804 limFTCleanup(pMac);
Abhishek Singhcf4590b2014-04-16 18:58:08 +05303805 }
3806#endif
3807
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003808 /// Free up buffer allocated for mlmDeauthReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303809 vos_mem_free(pMlmDeauthReq);
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003810 pMac->lim.limDisassocDeauthCnfReq.pMlmDeauthReq = NULL;
3811 }
3812 return eHAL_STATUS_SUCCESS;
3813end:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303814 vos_mem_copy( (tANI_U8 *) &mlmDeauthCnf.peerMacAddr,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003815 (tANI_U8 *) pMlmDeauthReq->peerMacAddr,
3816 sizeof(tSirMacAddr));
3817 mlmDeauthCnf.deauthTrigger = pMlmDeauthReq->deauthTrigger;
3818 mlmDeauthCnf.aid = pMlmDeauthReq->aid;
3819 mlmDeauthCnf.sessionId = pMlmDeauthReq->sessionId;
3820
3821 // Free up buffer allocated
3822 // for mlmDeauthReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303823 vos_mem_free(pMlmDeauthReq);
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003824
3825 limPostSmeMessage(pMac,
3826 LIM_MLM_DEAUTH_CNF,
3827 (tANI_U32 *) &mlmDeauthCnf);
3828 return eHAL_STATUS_SUCCESS;
3829}
3830
3831eHalStatus limSendDisassocCnf(tpAniSirGlobal pMac)
3832{
3833 tANI_U16 aid;
3834 tpDphHashNode pStaDs;
3835 tLimMlmDisassocCnf mlmDisassocCnf;
3836 tpPESession psessionEntry;
3837 tLimMlmDisassocReq *pMlmDisassocReq;
3838
3839 pMlmDisassocReq = pMac->lim.limDisassocDeauthCnfReq.pMlmDisassocReq;
3840 if (pMlmDisassocReq)
3841 {
3842 if (tx_timer_running(&pMac->lim.limTimers.gLimDisassocAckTimer))
3843 {
3844 limDeactivateAndChangeTimer(pMac, eLIM_DISASSOC_ACK_TIMER);
3845 }
3846
3847 if((psessionEntry = peFindSessionBySessionId(pMac, pMlmDisassocReq->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 mlmDisassocCnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
3853 goto end;
3854 }
3855
3856 pStaDs = dphLookupHashEntry(pMac, pMlmDisassocReq->peerMacAddr, &aid, &psessionEntry->dph.dphHashTable);
3857 if (pStaDs == NULL)
3858 {
3859 mlmDisassocCnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
3860 goto end;
3861 }
3862
3863 /// Receive path cleanup with dummy packet
3864 if(eSIR_SUCCESS != limCleanupRxPath(pMac, pStaDs, psessionEntry))
3865 {
3866 mlmDisassocCnf.resultCode = eSIR_SME_RESOURCES_UNAVAILABLE;
3867 goto end;
3868 }
3869
3870#ifdef WLAN_FEATURE_VOWIFI_11R
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08003871 if ( (psessionEntry->limSystemRole == eLIM_STA_ROLE ) &&
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05303872 (pMlmDisassocReq->reasonCode !=
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08003873 eSIR_MAC_DISASSOC_DUE_TO_FTHANDOFF_REASON))
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003874 {
Mukul Sharma0820d0e2014-11-11 19:49:02 +05303875 PELOGE(limLog(pMac, LOG1,
3876 FL("FT Preauth SessionId %d Cleanup"
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003877#ifdef FEATURE_WLAN_ESE
3878 " isESE %d"
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08003879#endif
3880#ifdef FEATURE_WLAN_LFR
3881 " isLFR %d"
3882#endif
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003883 " is11r %d reason %d"),
Mukul Sharma0820d0e2014-11-11 19:49:02 +05303884 psessionEntry->peSessionId,
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003885#ifdef FEATURE_WLAN_ESE
3886 psessionEntry->isESEconnection,
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08003887#endif
3888#ifdef FEATURE_WLAN_LFR
3889 psessionEntry->isFastRoamIniFeatureEnabled,
3890#endif
3891 psessionEntry->is11Rconnection,
3892 pMlmDisassocReq->reasonCode););
Mukul Sharma0820d0e2014-11-11 19:49:02 +05303893 limFTCleanup(pMac);
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003894 }
3895#endif
3896
3897 /// Free up buffer allocated for mlmDisassocReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303898 vos_mem_free(pMlmDisassocReq);
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003899 pMac->lim.limDisassocDeauthCnfReq.pMlmDisassocReq = NULL;
3900 return eHAL_STATUS_SUCCESS;
3901 }
3902 else
3903 {
3904 return eHAL_STATUS_SUCCESS;
3905 }
3906end:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303907 vos_mem_copy( (tANI_U8 *) &mlmDisassocCnf.peerMacAddr,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003908 (tANI_U8 *) pMlmDisassocReq->peerMacAddr,
3909 sizeof(tSirMacAddr));
3910 mlmDisassocCnf.aid = pMlmDisassocReq->aid;
3911 mlmDisassocCnf.disassocTrigger = pMlmDisassocReq->disassocTrigger;
3912
3913 /* Update PE session ID*/
3914 mlmDisassocCnf.sessionId = pMlmDisassocReq->sessionId;
3915
Madan Mohan Koyyalamudib7f5a672012-11-29 11:17:46 -08003916 if(pMlmDisassocReq != NULL)
3917 {
3918 /// Free up buffer allocated for mlmDisassocReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303919 vos_mem_free(pMlmDisassocReq);
Madan Mohan Koyyalamudib7f5a672012-11-29 11:17:46 -08003920 pMac->lim.limDisassocDeauthCnfReq.pMlmDisassocReq = NULL;
3921 }
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003922
3923 limPostSmeMessage(pMac,
3924 LIM_MLM_DISASSOC_CNF,
3925 (tANI_U32 *) &mlmDisassocCnf);
3926 return eHAL_STATUS_SUCCESS;
3927}
3928
3929eHalStatus limDisassocTxCompleteCnf(tpAniSirGlobal pMac, tANI_U32 txCompleteSuccess)
3930{
3931 return limSendDisassocCnf(pMac);
3932}
3933
3934eHalStatus limDeauthTxCompleteCnf(tpAniSirGlobal pMac, tANI_U32 txCompleteSuccess)
3935{
3936 return limSendDeauthCnf(pMac);
3937}
3938
Jeff Johnson295189b2012-06-20 16:38:30 -07003939/**
3940 * \brief This function is called to send Disassociate frame.
3941 *
3942 *
3943 * \param pMac Pointer to Global MAC structure
3944 *
3945 * \param nReason Indicates the reason that need to be sent in
3946 * Disassociation frame
3947 *
3948 * \param peerMacAddr MAC address of the STA to which Disassociation frame is
3949 * sent
3950 *
3951 *
3952 */
3953
3954void
3955limSendDisassocMgmtFrame(tpAniSirGlobal pMac,
3956 tANI_U16 nReason,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003957 tSirMacAddr peer,
3958 tpPESession psessionEntry,
3959 tANI_BOOLEAN waitForAck)
Jeff Johnson295189b2012-06-20 16:38:30 -07003960{
3961 tDot11fDisassociation frm;
3962 tANI_U8 *pFrame;
3963 tSirRetStatus nSirStatus;
3964 tpSirMacMgmtHdr pMacHdr;
3965 tANI_U32 nBytes, nPayload, nStatus;
3966 void *pPacket;
3967 eHalStatus halstatus;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05303968 tANI_U32 txFlag = 0;
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003969 tANI_U32 val = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003970 if(NULL == psessionEntry)
3971 {
3972 return;
3973 }
3974
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303975 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07003976
3977 frm.Reason.code = nReason;
3978
3979 nStatus = dot11fGetPackedDisassociationSize( pMac, &frm, &nPayload );
3980 if ( DOT11F_FAILED( nStatus ) )
3981 {
3982 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003983 "or a Disassociation (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003984 nStatus );
3985 // We'll fall back on the worst case scenario:
3986 nPayload = sizeof( tDot11fDisassociation );
3987 }
3988 else if ( DOT11F_WARNED( nStatus ) )
3989 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08003990 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07003991 "the packed size for a Disassociation "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003992 "(0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07003993 }
3994
3995 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
3996
3997 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
3998 ( tANI_U16 )nBytes, ( void** ) &pFrame,
3999 ( void** ) &pPacket );
4000 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4001 {
4002 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Dis"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004003 "association."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07004004 return;
4005 }
4006
4007 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304008 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004009
4010 // Next, we fill out the buffer descriptor:
4011 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
4012 SIR_MAC_MGMT_DISASSOC, peer,psessionEntry->selfMacAddr);
4013 if ( eSIR_SUCCESS != nSirStatus )
4014 {
4015 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004016 "tor for a Disassociation (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004017 nSirStatus );
4018 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
4019 ( void* ) pFrame, ( void* ) pPacket );
4020 return; // just allocated...
4021 }
4022
4023 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
4024
4025 // Prepare the BSSID
4026 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
4027
Chet Lanctot186b5732013-03-18 10:26:30 -07004028#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07004029 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07004030#endif
4031
Jeff Johnson295189b2012-06-20 16:38:30 -07004032 nStatus = dot11fPackDisassociation( pMac, &frm, pFrame +
4033 sizeof(tSirMacMgmtHdr),
4034 nPayload, &nPayload );
4035 if ( DOT11F_FAILED( nStatus ) )
4036 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004037 limLog( pMac, LOGE, FL("Failed to pack a Disassociation (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004038 nStatus );
4039 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
4040 ( void* ) pFrame, ( void* ) pPacket );
4041 return; // allocated!
4042 }
4043 else if ( DOT11F_WARNED( nStatus ) )
4044 {
4045 limLog( pMac, LOGW, FL("There were warnings while packing a D"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004046 "isassociation (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004047 }
4048
Abhishek Singhcd09b562013-12-24 16:02:20 +05304049 limLog( pMac, LOG1, FL("***Sessionid %d Sending Disassociation frame with "
4050 "reason %u and waitForAck %d to "MAC_ADDRESS_STR" ,From "
4051 MAC_ADDRESS_STR), psessionEntry->peSessionId, nReason, waitForAck,
4052 MAC_ADDR_ARRAY(pMacHdr->da),
4053 MAC_ADDR_ARRAY(psessionEntry->selfMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07004054
4055 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07004056 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
4057 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07004058 )
4059 {
4060 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
4061 }
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08004062
Ganesh K08bce952012-12-13 15:04:41 -08004063 if((psessionEntry->pePersona == VOS_P2P_CLIENT_MODE) ||
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304064 (psessionEntry->pePersona == VOS_P2P_GO_MODE) ||
4065 (psessionEntry->pePersona == VOS_STA_SAP_MODE))
Ganesh K08bce952012-12-13 15:04:41 -08004066 {
4067 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
4068 }
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08004069
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304070 if( IS_FW_IN_TX_PATH_FEATURE_ENABLE )
4071 {
4072 /* This frame will be sent on air by firmware,
4073 which will ensure that this frame goes out
4074 even though DEL_STA is sent immediately */
4075 /* Without this for DEL_STA command there is
4076 risk of flushing frame in BTQM queue without
4077 sending on air */
Agarwal Ashisha8e81f52014-04-02 01:59:52 +05304078 limLog( pMac, LOG1, FL("Sending Disassoc Frame over WQ5 to "MAC_ADDRESS_STR
4079 " From " MAC_ADDRESS_STR),MAC_ADDR_ARRAY(pMacHdr->da),
4080 MAC_ADDR_ARRAY(psessionEntry->selfMacAddr));
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304081 txFlag |= HAL_USE_FW_IN_TX_PATH;
4082 }
4083
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004084 if (waitForAck)
Jeff Johnson295189b2012-06-20 16:38:30 -07004085 {
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304086 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
4087 psessionEntry->peSessionId,
4088 pMacHdr->fc.subType));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004089 // Queue Disassociation frame in high priority WQ
4090 /* get the duration from the request */
4091 halstatus = halTxFrameWithTxComplete( pMac, pPacket, ( tANI_U16 ) nBytes,
4092 HAL_TXRX_FRM_802_11_MGMT,
4093 ANI_TXDIR_TODS,
4094 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4095 limTxComplete, pFrame, limDisassocTxCompleteCnf,
4096 txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304097 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
4098 psessionEntry->peSessionId,
4099 halstatus));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004100 val = SYS_MS_TO_TICKS(LIM_DISASSOC_DEAUTH_ACK_TIMEOUT);
Jeff Johnson295189b2012-06-20 16:38:30 -07004101
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004102 if (tx_timer_change(
4103 &pMac->lim.limTimers.gLimDisassocAckTimer, val, 0)
4104 != TX_SUCCESS)
4105 {
4106 limLog(pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004107 FL("Unable to change Disassoc ack Timer val"));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004108 return;
4109 }
4110 else if(TX_SUCCESS != tx_timer_activate(
4111 &pMac->lim.limTimers.gLimDisassocAckTimer))
4112 {
4113 limLog(pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004114 FL("Unable to activate Disassoc ack Timer"));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004115 limDeactivateAndChangeTimer(pMac, eLIM_DISASSOC_ACK_TIMER);
4116 return;
4117 }
4118 }
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08004119 else
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004120 {
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304121 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
4122 psessionEntry->peSessionId,
4123 pMacHdr->fc.subType));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004124 // Queue Disassociation frame in high priority WQ
4125 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4126 HAL_TXRX_FRM_802_11_MGMT,
4127 ANI_TXDIR_TODS,
4128 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4129 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304130 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
4131 psessionEntry->peSessionId,
4132 halstatus));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004133 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4134 {
4135 limLog( pMac, LOGE, FL("Failed to send Disassociation "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004136 "(%X)!"),
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004137 nSirStatus );
4138 //Pkt will be freed up by the callback
4139 return;
4140 }
4141 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004142} // End limSendDisassocMgmtFrame.
4143
4144/**
4145 * \brief This function is called to send a Deauthenticate frame
4146 *
4147 *
4148 * \param pMac Pointer to global MAC structure
4149 *
4150 * \param nReason Indicates the reason that need to be sent in the
4151 * Deauthenticate frame
4152 *
4153 * \param peeer address of the STA to which the frame is to be sent
4154 *
4155 *
4156 */
4157
4158void
4159limSendDeauthMgmtFrame(tpAniSirGlobal pMac,
4160 tANI_U16 nReason,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004161 tSirMacAddr peer,
4162 tpPESession psessionEntry,
4163 tANI_BOOLEAN waitForAck)
Jeff Johnson295189b2012-06-20 16:38:30 -07004164{
4165 tDot11fDeAuth frm;
4166 tANI_U8 *pFrame;
4167 tSirRetStatus nSirStatus;
4168 tpSirMacMgmtHdr pMacHdr;
4169 tANI_U32 nBytes, nPayload, nStatus;
4170 void *pPacket;
4171 eHalStatus halstatus;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304172 tANI_U32 txFlag = 0;
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004173 tANI_U32 val = 0;
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08004174#ifdef FEATURE_WLAN_TDLS
4175 tANI_U16 aid;
4176 tpDphHashNode pStaDs;
4177#endif
4178
Jeff Johnson295189b2012-06-20 16:38:30 -07004179 if(NULL == psessionEntry)
4180 {
4181 return;
4182 }
4183
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304184 vos_mem_set( ( tANI_U8* ) &frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004185
4186 frm.Reason.code = nReason;
4187
4188 nStatus = dot11fGetPackedDeAuthSize( pMac, &frm, &nPayload );
4189 if ( DOT11F_FAILED( nStatus ) )
4190 {
4191 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004192 "or a De-Authentication (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004193 nStatus );
4194 // We'll fall back on the worst case scenario:
4195 nPayload = sizeof( tDot11fDeAuth );
4196 }
4197 else if ( DOT11F_WARNED( nStatus ) )
4198 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004199 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07004200 "the packed size for a De-Authentication "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004201 "(0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004202 }
4203
4204 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4205
4206 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
4207 ( tANI_U16 )nBytes, ( void** ) &pFrame,
4208 ( void** ) &pPacket );
4209 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4210 {
4211 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a De-"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004212 "Authentication."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07004213 return;
4214 }
4215
4216 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304217 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004218
4219 // Next, we fill out the buffer descriptor:
4220 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
4221 SIR_MAC_MGMT_DEAUTH, peer,psessionEntry->selfMacAddr);
4222 if ( eSIR_SUCCESS != nSirStatus )
4223 {
4224 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004225 "tor for a De-Authentication (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004226 nSirStatus );
4227 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
4228 ( void* ) pFrame, ( void* ) pPacket );
4229 return; // just allocated...
4230 }
4231
4232 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
4233
4234 // Prepare the BSSID
4235 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
4236
Chet Lanctot186b5732013-03-18 10:26:30 -07004237#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07004238 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07004239#endif
4240
Jeff Johnson295189b2012-06-20 16:38:30 -07004241 nStatus = dot11fPackDeAuth( pMac, &frm, pFrame +
4242 sizeof(tSirMacMgmtHdr),
4243 nPayload, &nPayload );
4244 if ( DOT11F_FAILED( nStatus ) )
4245 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004246 limLog( pMac, LOGE, FL("Failed to pack a DeAuthentication (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004247 nStatus );
4248 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
4249 ( void* ) pFrame, ( void* ) pPacket );
4250 return;
4251 }
4252 else if ( DOT11F_WARNED( nStatus ) )
4253 {
4254 limLog( pMac, LOGW, FL("There were warnings while packing a D"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004255 "e-Authentication (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004256 }
Abhishek Singhcd09b562013-12-24 16:02:20 +05304257 limLog( pMac, LOG1, FL("***Sessionid %d Sending Deauth frame with "
4258 "reason %u and waitForAck %d to "MAC_ADDRESS_STR" ,From "
4259 MAC_ADDRESS_STR), psessionEntry->peSessionId, nReason, waitForAck,
4260 MAC_ADDR_ARRAY(pMacHdr->da),
4261 MAC_ADDR_ARRAY(psessionEntry->selfMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07004262
4263 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07004264 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
4265 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07004266 )
4267 {
4268 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
4269 }
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08004270
Ganesh K08bce952012-12-13 15:04:41 -08004271 if((psessionEntry->pePersona == VOS_P2P_CLIENT_MODE) ||
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304272 (psessionEntry->pePersona == VOS_P2P_GO_MODE) ||
4273 (psessionEntry->pePersona == VOS_STA_SAP_MODE))
Ganesh K08bce952012-12-13 15:04:41 -08004274 {
4275 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
4276 }
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08004277
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304278 if( IS_FW_IN_TX_PATH_FEATURE_ENABLE )
4279 {
4280 /* This frame will be sent on air by firmware,
4281 which will ensure that this frame goes out
4282 even though DEL_STA is sent immediately */
4283 /* Without this for DEL_STA command there is
4284 risk of flushing frame in BTQM queue without
4285 sending on air */
Agarwal Ashisha8e81f52014-04-02 01:59:52 +05304286 limLog( pMac, LOG1, FL("Sending Deauth Frame over WQ5 to "MAC_ADDRESS_STR
4287 " From " MAC_ADDRESS_STR),MAC_ADDR_ARRAY(pMacHdr->da),
4288 MAC_ADDR_ARRAY(psessionEntry->selfMacAddr));
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304289 txFlag |= HAL_USE_FW_IN_TX_PATH;
4290 }
4291
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08004292#ifdef FEATURE_WLAN_TDLS
4293 pStaDs = dphLookupHashEntry(pMac, peer, &aid, &psessionEntry->dph.dphHashTable);
4294#endif
4295
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004296 if (waitForAck)
Jeff Johnson295189b2012-06-20 16:38:30 -07004297 {
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304298 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
4299 psessionEntry->peSessionId,
4300 pMacHdr->fc.subType));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004301 // Queue Disassociation frame in high priority WQ
4302 halstatus = halTxFrameWithTxComplete( pMac, pPacket, ( tANI_U16 ) nBytes,
4303 HAL_TXRX_FRM_802_11_MGMT,
4304 ANI_TXDIR_TODS,
4305 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4306 limTxComplete, pFrame, limDeauthTxCompleteCnf, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304307 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
4308 psessionEntry->peSessionId,
4309 halstatus));
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304310 if (!HAL_STATUS_SUCCESS(halstatus))
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004311 {
4312 limLog( pMac, LOGE, FL("Failed to send De-Authentication "
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304313 "(%X)!"),
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004314 nSirStatus );
Gopichand Nakkala4261ea52012-12-31 16:43:00 -08004315 //Pkt will be freed up by the callback limTxComplete
4316
4317 /*Call limProcessDeauthAckTimeout which will send
4318 * DeauthCnf for this frame
4319 */
4320 limProcessDeauthAckTimeout(pMac);
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004321 return;
4322 }
4323
4324 val = SYS_MS_TO_TICKS(LIM_DISASSOC_DEAUTH_ACK_TIMEOUT);
4325
4326 if (tx_timer_change(
4327 &pMac->lim.limTimers.gLimDeauthAckTimer, val, 0)
4328 != TX_SUCCESS)
4329 {
4330 limLog(pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004331 FL("Unable to change Deauth ack Timer val"));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004332 return;
4333 }
4334 else if(TX_SUCCESS != tx_timer_activate(
4335 &pMac->lim.limTimers.gLimDeauthAckTimer))
4336 {
4337 limLog(pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004338 FL("Unable to activate Deauth ack Timer"));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004339 limDeactivateAndChangeTimer(pMac, eLIM_DEAUTH_ACK_TIMER);
4340 return;
4341 }
4342 }
4343 else
4344 {
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304345 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
4346 psessionEntry->peSessionId,
4347 pMacHdr->fc.subType));
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08004348#ifdef FEATURE_WLAN_TDLS
4349 if ((NULL != pStaDs) && (STA_ENTRY_TDLS_PEER == pStaDs->staType))
4350 {
4351 // Queue Disassociation frame in high priority WQ
4352 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004353 HAL_TXRX_FRM_802_11_MGMT,
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08004354 ANI_TXDIR_IBSS,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004355 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4356 limTxComplete, pFrame, txFlag );
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08004357 }
4358 else
4359 {
4360#endif
4361 // Queue Disassociation frame in high priority WQ
4362 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4363 HAL_TXRX_FRM_802_11_MGMT,
4364 ANI_TXDIR_TODS,
4365 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4366 limTxComplete, pFrame, txFlag );
4367#ifdef FEATURE_WLAN_TDLS
4368 }
4369#endif
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304370 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
4371 psessionEntry->peSessionId,
4372 halstatus));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004373 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4374 {
4375 limLog( pMac, LOGE, FL("Failed to send De-Authentication "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004376 "(%X)!"),
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004377 nSirStatus );
4378 //Pkt will be freed up by the callback
4379 return;
4380 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004381 }
4382
4383} // End limSendDeauthMgmtFrame.
4384
4385
4386#ifdef ANI_SUPPORT_11H
4387/**
4388 * \brief Send a Measurement Report Action frame
4389 *
4390 *
4391 * \param pMac Pointer to the global MAC structure
4392 *
4393 * \param pMeasReqFrame Address of a tSirMacMeasReqActionFrame
4394 *
4395 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
4396 *
4397 *
4398 */
4399
4400tSirRetStatus
4401limSendMeasReportFrame(tpAniSirGlobal pMac,
4402 tpSirMacMeasReqActionFrame pMeasReqFrame,
4403 tSirMacAddr peer)
4404{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304405 tDot11fMeasurementReport frm;
4406 tANI_U8 *pFrame;
4407 tSirRetStatus nSirStatus;
4408 tpSirMacMgmtHdr pMacHdr;
4409 tANI_U32 nBytes, nPayload, nStatus, nCfg;
4410 void *pPacket;
4411 eHalStatus halstatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07004412
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304413 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004414
4415 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
4416 frm.Action.action = SIR_MAC_ACTION_MEASURE_REPORT_ID;
4417 frm.DialogToken.token = pMeasReqFrame->actionHeader.dialogToken;
4418
4419 switch ( pMeasReqFrame->measReqIE.measType )
4420 {
4421 case SIR_MAC_BASIC_MEASUREMENT_TYPE:
4422 nSirStatus =
4423 PopulateDot11fMeasurementReport0( pMac, pMeasReqFrame,
4424 &frm.MeasurementReport );
4425 break;
4426 case SIR_MAC_CCA_MEASUREMENT_TYPE:
4427 nSirStatus =
4428 PopulateDot11fMeasurementReport1( pMac, pMeasReqFrame,
4429 &frm.MeasurementReport );
4430 break;
4431 case SIR_MAC_RPI_MEASUREMENT_TYPE:
4432 nSirStatus =
4433 PopulateDot11fMeasurementReport2( pMac, pMeasReqFrame,
4434 &frm.MeasurementReport );
4435 break;
4436 default:
4437 limLog( pMac, LOGE, FL("Unknown measurement type %d in limSen"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004438 "dMeasReportFrame."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004439 pMeasReqFrame->measReqIE.measType );
4440 return eSIR_FAILURE;
4441 }
4442
4443 if ( eSIR_SUCCESS != nSirStatus ) return eSIR_FAILURE;
4444
4445 nStatus = dot11fGetPackedMeasurementReportSize( pMac, &frm, &nPayload );
4446 if ( DOT11F_FAILED( nStatus ) )
4447 {
4448 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004449 "or a Measurement Report (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004450 nStatus );
4451 // We'll fall back on the worst case scenario:
4452 nPayload = sizeof( tDot11fMeasurementReport );
4453 }
4454 else if ( DOT11F_WARNED( nStatus ) )
4455 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004456 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07004457 "the packed size for a Measurement Rep"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004458 "ort (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004459 }
4460
4461 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4462
4463 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
4464 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4465 {
4466 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a De-"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004467 "Authentication."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07004468 return eSIR_FAILURE;
4469 }
4470
4471 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304472 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004473
4474 // Next, we fill out the buffer descriptor:
4475 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
4476 SIR_MAC_MGMT_ACTION, peer);
4477 if ( eSIR_SUCCESS != nSirStatus )
4478 {
4479 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004480 "tor for a Measurement Report (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004481 nSirStatus );
4482 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4483 return eSIR_FAILURE; // just allocated...
4484 }
4485
4486 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
4487
4488 nCfg = 6;
4489 nSirStatus = wlan_cfgGetStr( pMac, WNI_CFG_BSSID, pMacHdr->bssId, &nCfg );
4490 if ( eSIR_SUCCESS != nSirStatus )
4491 {
4492 limLog( pMac, LOGE, FL("Failed to retrieve WNI_CFG_BSSID from"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004493 " CFG (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004494 nSirStatus );
4495 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4496 return eSIR_FAILURE; // just allocated...
4497 }
4498
Chet Lanctot186b5732013-03-18 10:26:30 -07004499#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07004500 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07004501#endif
4502
Jeff Johnson295189b2012-06-20 16:38:30 -07004503 nStatus = dot11fPackMeasurementReport( pMac, &frm, pFrame +
4504 sizeof(tSirMacMgmtHdr),
4505 nPayload, &nPayload );
4506 if ( DOT11F_FAILED( nStatus ) )
4507 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004508 limLog( pMac, LOGE, FL("Failed to pack a Measurement Report (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004509 nStatus );
4510 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4511 return eSIR_FAILURE; // allocated!
4512 }
4513 else if ( DOT11F_WARNED( nStatus ) )
4514 {
4515 limLog( pMac, LOGW, FL("There were warnings while packing a M"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004516 "easurement Report (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004517 }
4518
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304519 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
4520 ((psessionEntry)? psessionEntry->peSessionId : NO_SESSION),
4521 pMacHdr->fc.subType));
Jeff Johnson295189b2012-06-20 16:38:30 -07004522 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4523 HAL_TXRX_FRM_802_11_MGMT,
4524 ANI_TXDIR_TODS,
4525 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4526 limTxComplete, pFrame, 0 );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304527 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
4528 ((psessionEntry)? psessionEntry->peSessionId : NO_SESSION),
4529 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07004530 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4531 {
4532 limLog( pMac, LOGE, FL("Failed to send a Measurement Report "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004533 "(%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07004534 nSirStatus );
4535 //Pkt will be freed up by the callback
4536 return eSIR_FAILURE; // just allocated...
4537 }
4538
4539 return eSIR_SUCCESS;
4540
4541} // End limSendMeasReportFrame.
4542
4543
4544/**
4545 * \brief Send a TPC Request Action frame
4546 *
4547 *
4548 * \param pMac Pointer to the global MAC datastructure
4549 *
4550 * \param peer MAC address to which the frame should be sent
4551 *
4552 *
4553 */
4554
4555void
4556limSendTpcRequestFrame(tpAniSirGlobal pMac,
4557 tSirMacAddr peer)
4558{
4559 tDot11fTPCRequest frm;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304560 tANI_U8 *pFrame;
Jeff Johnson295189b2012-06-20 16:38:30 -07004561 tSirRetStatus nSirStatus;
4562 tpSirMacMgmtHdr pMacHdr;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304563 tANI_U32 nBytes, nPayload, nStatus, nCfg;
4564 void *pPacket;
4565 eHalStatus halstatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07004566
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304567 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004568
4569 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
4570 frm.Action.action = SIR_MAC_ACTION_TPC_REQUEST_ID;
4571 frm.DialogToken.token = 1;
4572 frm.TPCRequest.present = 1;
4573
4574 nStatus = dot11fGetPackedTPCRequestSize( pMac, &frm, &nPayload );
4575 if ( DOT11F_FAILED( nStatus ) )
4576 {
4577 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004578 "or a TPC Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004579 nStatus );
4580 // We'll fall back on the worst case scenario:
4581 nPayload = sizeof( tDot11fTPCRequest );
4582 }
4583 else if ( DOT11F_WARNED( nStatus ) )
4584 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004585 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07004586 "the packed size for a TPC Request (0x"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004587 "%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004588 }
4589
4590 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4591
4592 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
4593 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4594 {
4595 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a TPC"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004596 " Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07004597 return;
4598 }
4599
4600 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304601 vos_mem_set(pFrame, nBytes,0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004602
4603 // Next, we fill out the buffer descriptor:
4604 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
4605 SIR_MAC_MGMT_ACTION, peer);
4606 if ( eSIR_SUCCESS != nSirStatus )
4607 {
4608 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004609 "tor for a TPC Request (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004610 nSirStatus );
4611 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4612 return; // just allocated...
4613 }
4614
4615 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
4616
4617 nCfg = 6;
4618 nSirStatus = wlan_cfgGetStr( pMac, WNI_CFG_BSSID, pMacHdr->bssId, &nCfg );
4619 if ( eSIR_SUCCESS != nSirStatus )
4620 {
4621 limLog( pMac, LOGE, FL("Failed to retrieve WNI_CFG_BSSID from"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004622 " CFG (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004623 nSirStatus );
4624 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4625 return; // just allocated...
4626 }
4627
Chet Lanctot186b5732013-03-18 10:26:30 -07004628#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07004629 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07004630#endif
4631
Jeff Johnson295189b2012-06-20 16:38:30 -07004632 nStatus = dot11fPackTPCRequest( pMac, &frm, pFrame +
4633 sizeof(tSirMacMgmtHdr),
4634 nPayload, &nPayload );
4635 if ( DOT11F_FAILED( nStatus ) )
4636 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004637 limLog( pMac, LOGE, FL("Failed to pack a TPC Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004638 nStatus );
4639 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4640 return; // allocated!
4641 }
4642 else if ( DOT11F_WARNED( nStatus ) )
4643 {
4644 limLog( pMac, LOGW, FL("There were warnings while packing a T"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004645 "PC Request (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004646 }
4647
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304648 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
4649 ((psessionEntry)? psessionEntry->peSessionId : NO_SESSION),
4650 pMacHdr->fc.subType));
Jeff Johnson295189b2012-06-20 16:38:30 -07004651 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4652 HAL_TXRX_FRM_802_11_MGMT,
4653 ANI_TXDIR_TODS,
4654 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4655 limTxComplete, pFrame, 0 );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304656 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
4657 ((psessionEntry)? psessionEntry->peSessionId : NO_SESSION),
4658 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07004659 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4660 {
4661 limLog( pMac, LOGE, FL("Failed to send a TPC Request "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004662 "(%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07004663 nSirStatus );
4664 //Pkt will be freed up by the callback
4665 return;
4666 }
4667
4668} // End limSendTpcRequestFrame.
4669
4670
4671/**
4672 * \brief Send a TPC Report Action frame
4673 *
4674 *
4675 * \param pMac Pointer to the global MAC datastructure
4676 *
4677 * \param pTpcReqFrame Pointer to the received TPC Request
4678 *
4679 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
4680 *
4681 *
4682 */
4683
4684tSirRetStatus
4685limSendTpcReportFrame(tpAniSirGlobal pMac,
4686 tpSirMacTpcReqActionFrame pTpcReqFrame,
4687 tSirMacAddr peer)
4688{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304689 tDot11fTPCReport frm;
4690 tANI_U8 *pFrame;
4691 tSirRetStatus nSirStatus;
4692 tpSirMacMgmtHdr pMacHdr;
4693 tANI_U32 nBytes, nPayload, nStatus, nCfg;
4694 void *pPacket;
4695 eHalStatus halstatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07004696
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304697 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004698
4699 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
4700 frm.Action.action = SIR_MAC_ACTION_TPC_REPORT_ID;
4701 frm.DialogToken.token = pTpcReqFrame->actionHeader.dialogToken;
4702
4703 // FramesToDo: On the Gen4_TVM branch, there was a comment:
4704 // "misplaced this function, need to replace:
4705 // txPower = halGetRateToPwrValue(pMac, staid,
4706 // pMac->lim.gLimCurrentChannelId, 0);
4707 frm.TPCReport.tx_power = 0;
4708 frm.TPCReport.link_margin = 0;
4709 frm.TPCReport.present = 1;
4710
4711 nStatus = dot11fGetPackedTPCReportSize( pMac, &frm, &nPayload );
4712 if ( DOT11F_FAILED( nStatus ) )
4713 {
4714 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004715 "or a TPC Report (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004716 nStatus );
4717 // We'll fall back on the worst case scenario:
4718 nPayload = sizeof( tDot11fTPCReport );
4719 }
4720 else if ( DOT11F_WARNED( nStatus ) )
4721 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004722 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07004723 "the packed size for a TPC Report (0x"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004724 "%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004725 }
4726
4727 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4728
4729 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
4730 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4731 {
4732 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a TPC"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004733 " Report."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07004734 return eSIR_FAILURE;
4735 }
4736
4737 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304738 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004739
4740 // Next, we fill out the buffer descriptor:
4741 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
4742 SIR_MAC_MGMT_ACTION, peer);
4743 if ( eSIR_SUCCESS != nSirStatus )
4744 {
4745 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004746 "tor for a TPC Report (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004747 nSirStatus );
4748 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4749 return eSIR_FAILURE; // just allocated...
4750 }
4751
4752 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
4753
4754 nCfg = 6;
4755 nSirStatus = wlan_cfgGetStr( pMac, WNI_CFG_BSSID, pMacHdr->bssId, &nCfg );
4756 if ( eSIR_SUCCESS != nSirStatus )
4757 {
4758 limLog( pMac, LOGE, FL("Failed to retrieve WNI_CFG_BSSID from"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004759 " CFG (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004760 nSirStatus );
4761 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4762 return eSIR_FAILURE; // just allocated...
4763 }
4764
Chet Lanctot186b5732013-03-18 10:26:30 -07004765#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07004766 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07004767#endif
4768
Jeff Johnson295189b2012-06-20 16:38:30 -07004769 nStatus = dot11fPackTPCReport( pMac, &frm, pFrame +
4770 sizeof(tSirMacMgmtHdr),
4771 nPayload, &nPayload );
4772 if ( DOT11F_FAILED( nStatus ) )
4773 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004774 limLog( pMac, LOGE, FL("Failed to pack a TPC Report (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004775 nStatus );
4776 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4777 return eSIR_FAILURE; // allocated!
4778 }
4779 else if ( DOT11F_WARNED( nStatus ) )
4780 {
4781 limLog( pMac, LOGW, FL("There were warnings while packing a T"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004782 "PC Report (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004783 }
4784
4785
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304786 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
4787 ((psessionEntry)? psessionEntry->peSessionId : NO_SESSION),
4788 pMacHdr->fc.subType));
Jeff Johnson295189b2012-06-20 16:38:30 -07004789 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4790 HAL_TXRX_FRM_802_11_MGMT,
4791 ANI_TXDIR_TODS,
4792 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4793 limTxComplete, pFrame, 0 );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304794 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
4795 ((psessionEntry)? psessionEntry->peSessionId : NO_SESSION),
4796 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07004797 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4798 {
4799 limLog( pMac, LOGE, FL("Failed to send a TPC Report "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004800 "(%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07004801 nSirStatus );
4802 //Pkt will be freed up by the callback
4803 return eSIR_FAILURE; // just allocated...
4804 }
4805
4806 return eSIR_SUCCESS;
4807
4808} // End limSendTpcReportFrame.
4809#endif //ANI_SUPPORT_11H
4810
4811
Jeff Johnson295189b2012-06-20 16:38:30 -07004812/**
4813 * \brief Send a Channel Switch Announcement
4814 *
4815 *
4816 * \param pMac Pointer to the global MAC datastructure
4817 *
4818 * \param peer MAC address to which this frame will be sent
4819 *
4820 * \param nMode
4821 *
4822 * \param nNewChannel
4823 *
4824 * \param nCount
4825 *
4826 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
4827 *
4828 *
4829 */
4830
4831tSirRetStatus
4832limSendChannelSwitchMgmtFrame(tpAniSirGlobal pMac,
4833 tSirMacAddr peer,
Jeff Johnsone7245742012-09-05 17:12:55 -07004834 tANI_U8 nMode,
4835 tANI_U8 nNewChannel,
4836 tANI_U8 nCount,
4837 tpPESession psessionEntry )
Jeff Johnson295189b2012-06-20 16:38:30 -07004838{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304839 tDot11fChannelSwitch frm;
4840 tANI_U8 *pFrame;
4841 tSirRetStatus nSirStatus;
4842 tpSirMacMgmtHdr pMacHdr;
4843 tANI_U32 nBytes, nPayload, nStatus;//, nCfg;
4844 void *pPacket;
4845 eHalStatus halstatus;
4846 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004847
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304848 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004849
4850 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
4851 frm.Action.action = SIR_MAC_ACTION_CHANNEL_SWITCH_ID;
4852 frm.ChanSwitchAnn.switchMode = nMode;
4853 frm.ChanSwitchAnn.newChannel = nNewChannel;
4854 frm.ChanSwitchAnn.switchCount = nCount;
4855 frm.ChanSwitchAnn.present = 1;
4856
4857 nStatus = dot11fGetPackedChannelSwitchSize( pMac, &frm, &nPayload );
4858 if ( DOT11F_FAILED( nStatus ) )
4859 {
4860 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004861 "or a Channel Switch (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004862 nStatus );
4863 // We'll fall back on the worst case scenario:
4864 nPayload = sizeof( tDot11fChannelSwitch );
4865 }
4866 else if ( DOT11F_WARNED( nStatus ) )
4867 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004868 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07004869 "the packed size for a Channel Switch (0x"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004870 "%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004871 }
4872
4873 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4874
4875 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
4876 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4877 {
4878 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a TPC"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004879 " Report."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07004880 return eSIR_FAILURE;
4881 }
4882
4883 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304884 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004885
4886 // Next, we fill out the buffer descriptor:
4887 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
Jeff Johnsone7245742012-09-05 17:12:55 -07004888 SIR_MAC_MGMT_ACTION, peer, psessionEntry->selfMacAddr);
4889 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304890 vos_mem_copy( (tANI_U8 *) pMacHdr->bssId,
4891 (tANI_U8 *) psessionEntry->bssId,
4892 sizeof( tSirMacAddr ));
Jeff Johnson295189b2012-06-20 16:38:30 -07004893 if ( eSIR_SUCCESS != nSirStatus )
4894 {
4895 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004896 "tor for a Channel Switch (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004897 nSirStatus );
4898 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4899 return eSIR_FAILURE; // just allocated...
4900 }
4901
Jeff Johnsone7245742012-09-05 17:12:55 -07004902#if 0
Jeff Johnson295189b2012-06-20 16:38:30 -07004903 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
4904
4905 nCfg = 6;
4906 nSirStatus = wlan_cfgGetStr( pMac, WNI_CFG_BSSID, pMacHdr->bssId, &nCfg );
4907 if ( eSIR_SUCCESS != nSirStatus )
4908 {
4909 limLog( pMac, LOGE, FL("Failed to retrieve WNI_CFG_BSSID from"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004910 " CFG (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004911 nSirStatus );
4912 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4913 return eSIR_FAILURE; // just allocated...
4914 }
Jeff Johnsone7245742012-09-05 17:12:55 -07004915#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07004916
4917#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07004918 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07004919#endif
4920
Jeff Johnson295189b2012-06-20 16:38:30 -07004921 nStatus = dot11fPackChannelSwitch( pMac, &frm, pFrame +
4922 sizeof(tSirMacMgmtHdr),
4923 nPayload, &nPayload );
4924 if ( DOT11F_FAILED( nStatus ) )
4925 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004926 limLog( pMac, LOGE, FL("Failed to pack a Channel Switch (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004927 nStatus );
4928 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4929 return eSIR_FAILURE; // allocated!
4930 }
4931 else if ( DOT11F_WARNED( nStatus ) )
4932 {
4933 limLog( pMac, LOGW, FL("There were warnings while packing a C"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004934 "hannel Switch (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004935 }
4936
Jeff Johnsone7245742012-09-05 17:12:55 -07004937 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnsone7245742012-09-05 17:12:55 -07004938 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
4939 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnsone7245742012-09-05 17:12:55 -07004940 )
4941 {
4942 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
4943 }
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304944
4945 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
4946 psessionEntry->peSessionId,
4947 pMacHdr->fc.subType));
Jeff Johnson295189b2012-06-20 16:38:30 -07004948 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4949 HAL_TXRX_FRM_802_11_MGMT,
4950 ANI_TXDIR_TODS,
4951 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
Jeff Johnsone7245742012-09-05 17:12:55 -07004952 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304953 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
4954 psessionEntry->peSessionId,
4955 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07004956 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4957 {
4958 limLog( pMac, LOGE, FL("Failed to send a Channel Switch "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004959 "(%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07004960 nSirStatus );
4961 //Pkt will be freed up by the callback
4962 return eSIR_FAILURE;
4963 }
4964
4965 return eSIR_SUCCESS;
4966
4967} // End limSendChannelSwitchMgmtFrame.
4968
Jeff Johnson295189b2012-06-20 16:38:30 -07004969
4970
Mohit Khanna4a70d262012-09-11 16:30:12 -07004971#ifdef WLAN_FEATURE_11AC
4972tSirRetStatus
4973limSendVHTOpmodeNotificationFrame(tpAniSirGlobal pMac,
4974 tSirMacAddr peer,
4975 tANI_U8 nMode,
4976 tpPESession psessionEntry )
4977{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304978 tDot11fOperatingMode frm;
4979 tANI_U8 *pFrame;
4980 tSirRetStatus nSirStatus;
4981 tpSirMacMgmtHdr pMacHdr;
4982 tANI_U32 nBytes, nPayload = 0, nStatus;//, nCfg;
4983 void *pPacket;
4984 eHalStatus halstatus;
4985 tANI_U32 txFlag = 0;
Mohit Khanna4a70d262012-09-11 16:30:12 -07004986
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304987 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Mohit Khanna4a70d262012-09-11 16:30:12 -07004988
4989 frm.Category.category = SIR_MAC_ACTION_VHT;
4990 frm.Action.action = SIR_MAC_VHT_OPMODE_NOTIFICATION;
4991 frm.OperatingMode.chanWidth = nMode;
4992 frm.OperatingMode.rxNSS = 0;
4993 frm.OperatingMode.rxNSSType = 0;
4994
4995 nStatus = dot11fGetPackedOperatingModeSize( pMac, &frm, &nPayload );
4996 if ( DOT11F_FAILED( nStatus ) )
4997 {
4998 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004999 "or a Operating Mode (0x%08x)."),
Mohit Khanna4a70d262012-09-11 16:30:12 -07005000 nStatus );
5001 // We'll fall back on the worst case scenario:
5002 nPayload = sizeof( tDot11fOperatingMode);
5003 }
5004 else if ( DOT11F_WARNED( nStatus ) )
5005 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005006 limLog( pMac, LOGW, FL("There were warnings while calculating "
Mohit Khanna4a70d262012-09-11 16:30:12 -07005007 "the packed size for a Operating Mode (0x"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005008 "%08x)."), nStatus );
Mohit Khanna4a70d262012-09-11 16:30:12 -07005009 }
5010
5011 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
5012
5013 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
5014 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
5015 {
5016 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Operating Mode"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005017 " Report."), nBytes );
Mohit Khanna4a70d262012-09-11 16:30:12 -07005018 return eSIR_FAILURE;
5019 }
5020
5021 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305022 vos_mem_set( pFrame, nBytes, 0 );
Mohit Khanna4a70d262012-09-11 16:30:12 -07005023
5024
5025 // Next, we fill out the buffer descriptor:
5026 if(psessionEntry->pePersona == VOS_STA_SAP_MODE) {
5027 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
5028 SIR_MAC_MGMT_ACTION, peer, psessionEntry->selfMacAddr);
5029 } else
5030 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
5031 SIR_MAC_MGMT_ACTION, psessionEntry->bssId, psessionEntry->selfMacAddr);
5032 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305033 vos_mem_copy( (tANI_U8 *) pMacHdr->bssId,
5034 (tANI_U8 *) psessionEntry->bssId,
5035 sizeof( tSirMacAddr ));
Mohit Khanna4a70d262012-09-11 16:30:12 -07005036 if ( eSIR_SUCCESS != nSirStatus )
5037 {
5038 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005039 "tor for a Operating Mode (%d)."),
Mohit Khanna4a70d262012-09-11 16:30:12 -07005040 nSirStatus );
5041 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
5042 return eSIR_FAILURE; // just allocated...
5043 }
5044 nStatus = dot11fPackOperatingMode( pMac, &frm, pFrame +
5045 sizeof(tSirMacMgmtHdr),
5046 nPayload, &nPayload );
5047 if ( DOT11F_FAILED( nStatus ) )
5048 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005049 limLog( pMac, LOGE, FL("Failed to pack a Operating Mode (0x%08x)."),
Mohit Khanna4a70d262012-09-11 16:30:12 -07005050 nStatus );
5051 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
5052 return eSIR_FAILURE; // allocated!
5053 }
5054 else if ( DOT11F_WARNED( nStatus ) )
5055 {
5056 limLog( pMac, LOGW, FL("There were warnings while packing a Operating Mode"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005057 " (0x%08x)."), nStatus );
Mohit Khanna4a70d262012-09-11 16:30:12 -07005058 }
5059 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Mohit Khanna4a70d262012-09-11 16:30:12 -07005060 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
5061 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Mohit Khanna4a70d262012-09-11 16:30:12 -07005062 )
5063 {
5064 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
5065 }
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05305066
5067 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
5068 psessionEntry->peSessionId,
5069 pMacHdr->fc.subType));
Mohit Khanna4a70d262012-09-11 16:30:12 -07005070 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
5071 HAL_TXRX_FRM_802_11_MGMT,
5072 ANI_TXDIR_TODS,
5073 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
5074 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05305075 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
5076 psessionEntry->peSessionId,
5077 halstatus));
Mohit Khanna4a70d262012-09-11 16:30:12 -07005078 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
5079 {
5080 limLog( pMac, LOGE, FL("Failed to send a Channel Switch "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005081 "(%X)!"),
Mohit Khanna4a70d262012-09-11 16:30:12 -07005082 nSirStatus );
5083 //Pkt will be freed up by the callback
5084 return eSIR_FAILURE;
5085 }
5086
5087 return eSIR_SUCCESS;
5088}
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005089
5090/**
5091 * \brief Send a VHT Channel Switch Announcement
5092 *
5093 *
5094 * \param pMac Pointer to the global MAC datastructure
5095 *
5096 * \param peer MAC address to which this frame will be sent
5097 *
5098 * \param nChanWidth
5099 *
5100 * \param nNewChannel
5101 *
5102 *
5103 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
5104 *
5105 *
5106 */
5107
5108tSirRetStatus
5109limSendVHTChannelSwitchMgmtFrame(tpAniSirGlobal pMac,
5110 tSirMacAddr peer,
5111 tANI_U8 nChanWidth,
5112 tANI_U8 nNewChannel,
5113 tANI_U8 ncbMode,
5114 tpPESession psessionEntry )
5115{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05305116 tDot11fChannelSwitch frm;
5117 tANI_U8 *pFrame;
5118 tSirRetStatus nSirStatus;
5119 tpSirMacMgmtHdr pMacHdr;
5120 tANI_U32 nBytes, nPayload, nStatus;//, nCfg;
5121 void *pPacket;
5122 eHalStatus halstatus;
5123 tANI_U32 txFlag = 0;
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005124
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305125 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005126
5127
5128 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
5129 frm.Action.action = SIR_MAC_ACTION_CHANNEL_SWITCH_ID;
5130 frm.ChanSwitchAnn.switchMode = 1;
5131 frm.ChanSwitchAnn.newChannel = nNewChannel;
5132 frm.ChanSwitchAnn.switchCount = 1;
5133 frm.ExtChanSwitchAnn.secondaryChannelOffset = limGetHTCBState(ncbMode);
5134 frm.ExtChanSwitchAnn.present = 1;
5135 frm.WiderBWChanSwitchAnn.newChanWidth = nChanWidth;
5136 frm.WiderBWChanSwitchAnn.newCenterChanFreq0 = limGetCenterChannel(pMac,nNewChannel,ncbMode,nChanWidth);
5137 frm.WiderBWChanSwitchAnn.newCenterChanFreq1 = 0;
5138 frm.ChanSwitchAnn.present = 1;
5139 frm.WiderBWChanSwitchAnn.present = 1;
5140
5141 nStatus = dot11fGetPackedChannelSwitchSize( pMac, &frm, &nPayload );
5142 if ( DOT11F_FAILED( nStatus ) )
5143 {
5144 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005145 "or a Channel Switch (0x%08x)."),
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005146 nStatus );
5147 // We'll fall back on the worst case scenario:
5148 nPayload = sizeof( tDot11fChannelSwitch );
5149 }
5150 else if ( DOT11F_WARNED( nStatus ) )
5151 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005152 limLog( pMac, LOGW, FL("There were warnings while calculating "
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005153 "the packed size for a Channel Switch (0x"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005154 "%08x)."), nStatus );
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005155 }
5156
5157 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
5158
5159 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
5160 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
5161 {
5162 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a TPC"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005163 " Report."), nBytes );
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005164 return eSIR_FAILURE;
5165 }
5166 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305167 vos_mem_set( pFrame, nBytes, 0 );
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005168
5169 // Next, we fill out the buffer descriptor:
5170 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
5171 SIR_MAC_MGMT_ACTION, peer, psessionEntry->selfMacAddr);
5172 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305173 vos_mem_copy( (tANI_U8 *) pMacHdr->bssId,
5174 (tANI_U8 *) psessionEntry->bssId,
5175 sizeof( tSirMacAddr ));
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005176 if ( eSIR_SUCCESS != nSirStatus )
5177 {
5178 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005179 "tor for a Channel Switch (%d)."),
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005180 nSirStatus );
5181 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
5182 return eSIR_FAILURE; // just allocated...
5183 }
5184 nStatus = dot11fPackChannelSwitch( pMac, &frm, pFrame +
5185 sizeof(tSirMacMgmtHdr),
5186 nPayload, &nPayload );
5187 if ( DOT11F_FAILED( nStatus ) )
5188 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005189 limLog( pMac, LOGE, FL("Failed to pack a Channel Switch (0x%08x)."),
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005190 nStatus );
5191 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
5192 return eSIR_FAILURE; // allocated!
5193 }
5194 else if ( DOT11F_WARNED( nStatus ) )
5195 {
5196 limLog( pMac, LOGW, FL("There were warnings while packing a C"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005197 "hannel Switch (0x%08x)."), nStatus );
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005198 }
5199
5200 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005201 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
5202 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005203 )
5204 {
5205 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
5206 }
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05305207
5208 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
5209 psessionEntry->peSessionId,
5210 pMacHdr->fc.subType));
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005211 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
5212 HAL_TXRX_FRM_802_11_MGMT,
5213 ANI_TXDIR_TODS,
5214 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
5215 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05305216 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
5217 psessionEntry->peSessionId,
5218 halstatus));
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005219 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
5220 {
5221 limLog( pMac, LOGE, FL("Failed to send a Channel Switch "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005222 "(%X)!"),
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005223 nSirStatus );
5224 //Pkt will be freed up by the callback
5225 return eSIR_FAILURE;
5226 }
5227
5228 return eSIR_SUCCESS;
5229
5230} // End limSendVHTChannelSwitchMgmtFrame.
5231
5232
5233
Mohit Khanna4a70d262012-09-11 16:30:12 -07005234#endif
5235
Jeff Johnson295189b2012-06-20 16:38:30 -07005236/**
5237 * \brief Send an ADDBA Req Action Frame to peer
5238 *
5239 * \sa limSendAddBAReq
5240 *
5241 * \param pMac The global tpAniSirGlobal object
5242 *
5243 * \param pMlmAddBAReq A pointer to tLimMlmAddBAReq. This contains
5244 * the necessary parameters reqd by PE send the ADDBA Req Action
5245 * Frame to the peer
5246 *
5247 * \return eSIR_SUCCESS if setup completes successfully
5248 * eSIR_FAILURE is some problem is encountered
5249 */
5250tSirRetStatus limSendAddBAReq( tpAniSirGlobal pMac,
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305251 tpLimMlmAddBAReq pMlmAddBAReq, tpPESession psessionEntry)
Jeff Johnson295189b2012-06-20 16:38:30 -07005252{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05305253 tDot11fAddBAReq frmAddBAReq;
5254 tANI_U8 *pAddBAReqBuffer = NULL;
5255 tpSirMacMgmtHdr pMacHdr;
5256 tANI_U32 frameLen = 0, nStatus, nPayload;
5257 tSirRetStatus statusCode;
5258 eHalStatus halStatus;
5259 void *pPacket;
5260 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005261
5262 if(NULL == psessionEntry)
5263 {
5264 return eSIR_FAILURE;
5265 }
5266
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305267 vos_mem_set( (void *) &frmAddBAReq, sizeof( frmAddBAReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005268
5269 // Category - 3 (BA)
5270 frmAddBAReq.Category.category = SIR_MAC_ACTION_BLKACK;
5271
5272 // Action - 0 (ADDBA Req)
5273 frmAddBAReq.Action.action = SIR_MAC_BLKACK_ADD_REQ;
5274
5275 // FIXME - Dialog Token, generalize this...
5276 frmAddBAReq.DialogToken.token = pMlmAddBAReq->baDialogToken;
5277
5278 // Fill the ADDBA Parameter Set
5279 frmAddBAReq.AddBAParameterSet.tid = pMlmAddBAReq->baTID;
5280 frmAddBAReq.AddBAParameterSet.policy = pMlmAddBAReq->baPolicy;
5281 frmAddBAReq.AddBAParameterSet.bufferSize = pMlmAddBAReq->baBufferSize;
5282
5283 // BA timeout
5284 // 0 - indicates no BA timeout
5285 frmAddBAReq.BATimeout.timeout = pMlmAddBAReq->baTimeout;
5286
Abhishek Singh1f6e6532014-06-05 17:35:08 +05305287 /* Send SSN whatever we get from FW.
5288 */
5289 frmAddBAReq.BAStartingSequenceControl.ssn = pMlmAddBAReq->baSSN;
Jeff Johnson295189b2012-06-20 16:38:30 -07005290
5291 nStatus = dot11fGetPackedAddBAReqSize( pMac, &frmAddBAReq, &nPayload );
5292
5293 if( DOT11F_FAILED( nStatus ))
5294 {
5295 limLog( pMac, LOGW,
5296 FL( "Failed to calculate the packed size for "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005297 "an ADDBA Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005298 nStatus );
5299
5300 // We'll fall back on the worst case scenario:
5301 nPayload = sizeof( tDot11fAddBAReq );
5302 }
5303 else if( DOT11F_WARNED( nStatus ))
5304 {
5305 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005306 FL( "There were warnings while calculating "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005307 "the packed size for an ADDBA Req (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005308 nStatus );
5309 }
5310
5311 // Add the MGMT header to frame length
5312 frameLen = nPayload + sizeof( tSirMacMgmtHdr );
5313
5314 // Need to allocate a buffer for ADDBA AF
5315 if( eHAL_STATUS_SUCCESS !=
5316 (halStatus = palPktAlloc( pMac->hHdd,
5317 HAL_TXRX_FRM_802_11_MGMT,
5318 (tANI_U16) frameLen,
5319 (void **) &pAddBAReqBuffer,
5320 (void **) &pPacket )))
5321 {
5322 // Log error
5323 limLog( pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005324 FL("palPktAlloc FAILED! Length [%d], Status [%d]"),
Jeff Johnson295189b2012-06-20 16:38:30 -07005325 frameLen,
5326 halStatus );
5327
5328 statusCode = eSIR_MEM_ALLOC_FAILED;
5329 goto returnAfterError;
5330 }
5331
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305332 vos_mem_set( (void *) pAddBAReqBuffer, frameLen, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005333
5334 // Copy necessary info to BD
5335 if( eSIR_SUCCESS !=
5336 (statusCode = limPopulateMacHeader( pMac,
5337 pAddBAReqBuffer,
5338 SIR_MAC_MGMT_FRAME,
5339 SIR_MAC_MGMT_ACTION,
5340 pMlmAddBAReq->peerMacAddr,psessionEntry->selfMacAddr)))
5341 goto returnAfterError;
5342
5343 // Update A3 with the BSSID
5344 pMacHdr = ( tpSirMacMgmtHdr ) pAddBAReqBuffer;
5345
5346 #if 0
5347 cfgLen = SIR_MAC_ADDR_LENGTH;
5348 if( eSIR_SUCCESS != cfgGetStr( pMac,
5349 WNI_CFG_BSSID,
5350 (tANI_U8 *) pMacHdr->bssId,
5351 &cfgLen ))
5352 {
5353 limLog( pMac, LOGP,
5354 FL( "Failed to retrieve WNI_CFG_BSSID while"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005355 "sending an ACTION Frame" ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005356
5357 // FIXME - Need to convert to tSirRetStatus
5358 statusCode = eSIR_FAILURE;
5359 goto returnAfterError;
5360 }
5361 #endif//TO SUPPORT BT-AMP
5362 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
5363
Chet Lanctot186b5732013-03-18 10:26:30 -07005364#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07005365 limSetProtectedBit(pMac, psessionEntry, pMlmAddBAReq->peerMacAddr, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07005366#endif
5367
Jeff Johnson295189b2012-06-20 16:38:30 -07005368 // Now, we're ready to "pack" the frames
5369 nStatus = dot11fPackAddBAReq( pMac,
5370 &frmAddBAReq,
5371 pAddBAReqBuffer + sizeof( tSirMacMgmtHdr ),
5372 nPayload,
5373 &nPayload );
5374
5375 if( DOT11F_FAILED( nStatus ))
5376 {
5377 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005378 FL( "Failed to pack an ADDBA Req (0x%08x)." ),
Jeff Johnson295189b2012-06-20 16:38:30 -07005379 nStatus );
5380
5381 // FIXME - Need to convert to tSirRetStatus
5382 statusCode = eSIR_FAILURE;
5383 goto returnAfterError;
5384 }
5385 else if( DOT11F_WARNED( nStatus ))
5386 {
5387 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005388 FL( "There were warnings while packing an ADDBA Req (0x%08x)."),
5389 nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07005390 }
5391
Abhishek Singh02d9f6c2014-05-12 14:07:53 +05305392 limLog( pMac, LOG1, FL( "Sending an ADDBA REQ to "MAC_ADDRESS_STR " with"
5393 " tid = %d policy = %d buffsize = %d "
5394 " amsduSupported = %d"),
5395 MAC_ADDR_ARRAY(pMlmAddBAReq->peerMacAddr),
5396 frmAddBAReq.AddBAParameterSet.tid,
5397 frmAddBAReq.AddBAParameterSet.policy,
5398 frmAddBAReq.AddBAParameterSet.bufferSize,
5399 frmAddBAReq.AddBAParameterSet.amsduSupported);
Jeff Johnson295189b2012-06-20 16:38:30 -07005400
Abhishek Singh1f6e6532014-06-05 17:35:08 +05305401 limLog( pMac, LOG1, FL( "ssn = %d fragNum = %d" ),
5402 frmAddBAReq.BAStartingSequenceControl.ssn,
5403 frmAddBAReq.BAStartingSequenceControl.fragNumber);
5404
Jeff Johnson295189b2012-06-20 16:38:30 -07005405 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07005406 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
5407 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07005408 )
5409 {
5410 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
5411 }
5412
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05305413 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
5414 psessionEntry->peSessionId,
5415 pMacHdr->fc.subType));
5416 halStatus = halTxFrame( pMac,
5417 pPacket,
5418 (tANI_U16) frameLen,
5419 HAL_TXRX_FRM_802_11_MGMT,
5420 ANI_TXDIR_TODS,
5421 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
5422 limTxComplete,
5423 pAddBAReqBuffer, txFlag );
5424 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
5425 psessionEntry->peSessionId,
5426 halStatus));
5427 if( eHAL_STATUS_SUCCESS != halStatus )
Jeff Johnson295189b2012-06-20 16:38:30 -07005428 {
5429 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005430 FL( "halTxFrame FAILED! Status [%d]"),
Jeff Johnson295189b2012-06-20 16:38:30 -07005431 halStatus );
5432
5433 // FIXME - Need to convert eHalStatus to tSirRetStatus
5434 statusCode = eSIR_FAILURE;
5435 //Pkt will be freed up by the callback
5436 return statusCode;
5437 }
5438 else
5439 return eSIR_SUCCESS;
5440
5441returnAfterError:
5442
5443 // Release buffer, if allocated
5444 if( NULL != pAddBAReqBuffer )
5445 palPktFree( pMac->hHdd,
5446 HAL_TXRX_FRM_802_11_MGMT,
5447 (void *) pAddBAReqBuffer,
5448 (void *) pPacket );
5449
5450 return statusCode;
5451}
5452
5453/**
5454 * \brief Send an ADDBA Rsp Action Frame to peer
5455 *
5456 * \sa limSendAddBARsp
5457 *
5458 * \param pMac The global tpAniSirGlobal object
5459 *
5460 * \param pMlmAddBARsp A pointer to tLimMlmAddBARsp. This contains
5461 * the necessary parameters reqd by PE send the ADDBA Rsp Action
5462 * Frame to the peer
5463 *
5464 * \return eSIR_SUCCESS if setup completes successfully
5465 * eSIR_FAILURE is some problem is encountered
5466 */
5467tSirRetStatus limSendAddBARsp( tpAniSirGlobal pMac,
5468 tpLimMlmAddBARsp pMlmAddBARsp,
5469 tpPESession psessionEntry)
5470{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05305471 tDot11fAddBARsp frmAddBARsp;
5472 tANI_U8 *pAddBARspBuffer = NULL;
5473 tpSirMacMgmtHdr pMacHdr;
5474 tANI_U32 frameLen = 0, nStatus, nPayload;
5475 tSirRetStatus statusCode;
5476 eHalStatus halStatus;
5477 void *pPacket;
5478 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005479
5480 if(NULL == psessionEntry)
5481 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005482 PELOGE(limLog(pMac, LOGE, FL("Session entry is NULL!!!"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07005483 return eSIR_FAILURE;
5484 }
5485
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305486 vos_mem_set( (void *) &frmAddBARsp, sizeof( frmAddBARsp ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005487
5488 // Category - 3 (BA)
5489 frmAddBARsp.Category.category = SIR_MAC_ACTION_BLKACK;
5490 // Action - 1 (ADDBA Rsp)
5491 frmAddBARsp.Action.action = SIR_MAC_BLKACK_ADD_RSP;
5492
5493 // Should be same as the one we received in the ADDBA Req
5494 frmAddBARsp.DialogToken.token = pMlmAddBARsp->baDialogToken;
5495
5496 // ADDBA Req status
5497 frmAddBARsp.Status.status = pMlmAddBARsp->addBAResultCode;
5498
5499 // Fill the ADDBA Parameter Set as provided by caller
5500 frmAddBARsp.AddBAParameterSet.tid = pMlmAddBARsp->baTID;
5501 frmAddBARsp.AddBAParameterSet.policy = pMlmAddBARsp->baPolicy;
5502 frmAddBARsp.AddBAParameterSet.bufferSize = pMlmAddBARsp->baBufferSize;
krunal soni5afa96c2013-09-06 22:19:02 -07005503
5504 if(psessionEntry->isAmsduSupportInAMPDU)
5505 {
5506 frmAddBARsp.AddBAParameterSet.amsduSupported =
5507 psessionEntry->amsduSupportedInBA;
5508 }
5509 else
5510 {
5511 frmAddBARsp.AddBAParameterSet.amsduSupported = 0;
5512 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005513
5514 // BA timeout
5515 // 0 - indicates no BA timeout
5516 frmAddBARsp.BATimeout.timeout = pMlmAddBARsp->baTimeout;
5517
5518 nStatus = dot11fGetPackedAddBARspSize( pMac, &frmAddBARsp, &nPayload );
5519
5520 if( DOT11F_FAILED( nStatus ))
5521 {
5522 limLog( pMac, LOGW,
5523 FL( "Failed to calculate the packed size for "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005524 "an ADDBA Response (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005525 nStatus );
5526
5527 // We'll fall back on the worst case scenario:
5528 nPayload = sizeof( tDot11fAddBARsp );
5529 }
5530 else if( DOT11F_WARNED( nStatus ))
5531 {
5532 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005533 FL( "There were warnings while calculating "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005534 "the packed size for an ADDBA Rsp (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005535 nStatus );
5536 }
5537
5538 // Need to allocate a buffer for ADDBA AF
5539 frameLen = nPayload + sizeof( tSirMacMgmtHdr );
5540
5541 // Allocate shared memory
5542 if( eHAL_STATUS_SUCCESS !=
5543 (halStatus = palPktAlloc( pMac->hHdd,
5544 HAL_TXRX_FRM_802_11_MGMT,
5545 (tANI_U16) frameLen,
5546 (void **) &pAddBARspBuffer,
5547 (void **) &pPacket )))
5548 {
5549 // Log error
5550 limLog( pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005551 FL("palPktAlloc FAILED! Length [%d], Status [%d]"),
Jeff Johnson295189b2012-06-20 16:38:30 -07005552 frameLen,
5553 halStatus );
5554
5555 statusCode = eSIR_MEM_ALLOC_FAILED;
5556 goto returnAfterError;
5557 }
5558
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305559 vos_mem_set( (void *) pAddBARspBuffer, frameLen, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005560
5561 // Copy necessary info to BD
5562 if( eSIR_SUCCESS !=
5563 (statusCode = limPopulateMacHeader( pMac,
5564 pAddBARspBuffer,
5565 SIR_MAC_MGMT_FRAME,
5566 SIR_MAC_MGMT_ACTION,
5567 pMlmAddBARsp->peerMacAddr,psessionEntry->selfMacAddr)))
5568 goto returnAfterError;
5569
5570 // Update A3 with the BSSID
5571
5572 pMacHdr = ( tpSirMacMgmtHdr ) pAddBARspBuffer;
5573
5574 #if 0
5575 cfgLen = SIR_MAC_ADDR_LENGTH;
5576 if( eSIR_SUCCESS != wlan_cfgGetStr( pMac,
5577 WNI_CFG_BSSID,
5578 (tANI_U8 *) pMacHdr->bssId,
5579 &cfgLen ))
5580 {
5581 limLog( pMac, LOGP,
5582 FL( "Failed to retrieve WNI_CFG_BSSID while"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005583 "sending an ACTION Frame" ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005584
5585 // FIXME - Need to convert to tSirRetStatus
5586 statusCode = eSIR_FAILURE;
5587 goto returnAfterError;
5588 }
5589 #endif // TO SUPPORT BT-AMP
5590 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
5591
Chet Lanctot186b5732013-03-18 10:26:30 -07005592#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07005593 limSetProtectedBit(pMac, psessionEntry, pMlmAddBARsp->peerMacAddr, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07005594#endif
5595
Jeff Johnson295189b2012-06-20 16:38:30 -07005596 // Now, we're ready to "pack" the frames
5597 nStatus = dot11fPackAddBARsp( pMac,
5598 &frmAddBARsp,
5599 pAddBARspBuffer + sizeof( tSirMacMgmtHdr ),
5600 nPayload,
5601 &nPayload );
5602
5603 if( DOT11F_FAILED( nStatus ))
5604 {
5605 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005606 FL( "Failed to pack an ADDBA Rsp (0x%08x)." ),
Jeff Johnson295189b2012-06-20 16:38:30 -07005607 nStatus );
5608
5609 // FIXME - Need to convert to tSirRetStatus
5610 statusCode = eSIR_FAILURE;
5611 goto returnAfterError;
5612 }
5613 else if( DOT11F_WARNED( nStatus ))
5614 {
5615 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005616 FL( "There were warnings while packing an ADDBA Rsp (0x%08x)." ),
5617 nStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07005618 }
5619
Abhishek Singh02d9f6c2014-05-12 14:07:53 +05305620 limLog( pMac, LOG1, FL( "Sending an ADDBA RSP to "MAC_ADDRESS_STR " with"
5621 " tid = %d policy = %d buffsize = %d"
5622 " amsduSupported = %d status %d"),
5623 MAC_ADDR_ARRAY(pMlmAddBARsp->peerMacAddr),
5624 frmAddBARsp.AddBAParameterSet.tid,
5625 frmAddBARsp.AddBAParameterSet.policy,
5626 frmAddBARsp.AddBAParameterSet.bufferSize,
5627 frmAddBARsp.AddBAParameterSet.amsduSupported,
5628 frmAddBARsp.Status.status);
5629
Jeff Johnson295189b2012-06-20 16:38:30 -07005630
5631 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07005632 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
5633 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07005634 )
5635 {
5636 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
5637 }
5638
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05305639 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
5640 psessionEntry->peSessionId,
5641 pMacHdr->fc.subType));
5642 halStatus = halTxFrame( pMac,
5643 pPacket,
5644 (tANI_U16) frameLen,
5645 HAL_TXRX_FRM_802_11_MGMT,
5646 ANI_TXDIR_TODS,
5647 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
5648 limTxComplete,
5649 pAddBARspBuffer, txFlag );
5650 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
5651 psessionEntry->peSessionId,
5652 halStatus));
5653 if( eHAL_STATUS_SUCCESS != halStatus )
5654 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005655 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005656 FL( "halTxFrame FAILED! Status [%d]" ),
Jeff Johnson295189b2012-06-20 16:38:30 -07005657 halStatus );
5658
5659 // FIXME - HAL error codes are different from PE error
5660 // codes!! And, this routine is returning tSirRetStatus
5661 statusCode = eSIR_FAILURE;
5662 //Pkt will be freed up by the callback
5663 return statusCode;
5664 }
5665 else
5666 return eSIR_SUCCESS;
5667
5668 returnAfterError:
Jeff Johnson295189b2012-06-20 16:38:30 -07005669 // Release buffer, if allocated
5670 if( NULL != pAddBARspBuffer )
5671 palPktFree( pMac->hHdd,
5672 HAL_TXRX_FRM_802_11_MGMT,
5673 (void *) pAddBARspBuffer,
5674 (void *) pPacket );
5675
5676 return statusCode;
5677}
5678
5679/**
5680 * \brief Send a DELBA Indication Action Frame to peer
5681 *
5682 * \sa limSendDelBAInd
5683 *
5684 * \param pMac The global tpAniSirGlobal object
5685 *
5686 * \param peerMacAddr MAC Address of peer
5687 *
5688 * \param reasonCode Reason for the DELBA notification
5689 *
5690 * \param pBAParameterSet The DELBA Parameter Set.
5691 * This identifies the TID for which the BA session is
5692 * being deleted.
5693 *
5694 * \return eSIR_SUCCESS if setup completes successfully
5695 * eSIR_FAILURE is some problem is encountered
5696 */
5697tSirRetStatus limSendDelBAInd( tpAniSirGlobal pMac,
5698 tpLimMlmDelBAReq pMlmDelBAReq,tpPESession psessionEntry)
5699{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05305700 tDot11fDelBAInd frmDelBAInd;
5701 tANI_U8 *pDelBAIndBuffer = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005702 //tANI_U32 val;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05305703 tpSirMacMgmtHdr pMacHdr;
5704 tANI_U32 frameLen = 0, nStatus, nPayload;
5705 tSirRetStatus statusCode;
5706 eHalStatus halStatus;
5707 void *pPacket;
5708 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005709
5710 if(NULL == psessionEntry)
5711 {
5712 return eSIR_FAILURE;
5713 }
5714
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305715 vos_mem_set( (void *) &frmDelBAInd, sizeof( frmDelBAInd ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005716
5717 // Category - 3 (BA)
5718 frmDelBAInd.Category.category = SIR_MAC_ACTION_BLKACK;
5719 // Action - 2 (DELBA)
5720 frmDelBAInd.Action.action = SIR_MAC_BLKACK_DEL;
5721
5722 // Fill the DELBA Parameter Set as provided by caller
5723 frmDelBAInd.DelBAParameterSet.tid = pMlmDelBAReq->baTID;
5724 frmDelBAInd.DelBAParameterSet.initiator = pMlmDelBAReq->baDirection;
5725
5726 // BA Starting Sequence Number
5727 // Fragment number will always be zero
5728 frmDelBAInd.Reason.code = pMlmDelBAReq->delBAReasonCode;
5729
5730 nStatus = dot11fGetPackedDelBAIndSize( pMac, &frmDelBAInd, &nPayload );
5731
5732 if( DOT11F_FAILED( nStatus ))
5733 {
5734 limLog( pMac, LOGW,
5735 FL( "Failed to calculate the packed size for "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005736 "an DELBA Indication (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005737 nStatus );
5738
5739 // We'll fall back on the worst case scenario:
5740 nPayload = sizeof( tDot11fDelBAInd );
5741 }
5742 else if( DOT11F_WARNED( nStatus ))
5743 {
5744 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005745 FL( "There were warnings while calculating "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005746 "the packed size for an DELBA Ind (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005747 nStatus );
5748 }
5749
5750 // Add the MGMT header to frame length
5751 frameLen = nPayload + sizeof( tSirMacMgmtHdr );
5752
5753 // Allocate shared memory
5754 if( eHAL_STATUS_SUCCESS !=
5755 (halStatus = palPktAlloc( pMac->hHdd,
5756 HAL_TXRX_FRM_802_11_MGMT,
5757 (tANI_U16) frameLen,
5758 (void **) &pDelBAIndBuffer,
5759 (void **) &pPacket )))
5760 {
5761 // Log error
5762 limLog( pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005763 FL("palPktAlloc FAILED! Length [%d], Status [%d]"),
Jeff Johnson295189b2012-06-20 16:38:30 -07005764 frameLen,
5765 halStatus );
5766
5767 statusCode = eSIR_MEM_ALLOC_FAILED;
5768 goto returnAfterError;
5769 }
5770
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305771 vos_mem_set( (void *) pDelBAIndBuffer, frameLen, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005772
5773 // Copy necessary info to BD
5774 if( eSIR_SUCCESS !=
5775 (statusCode = limPopulateMacHeader( pMac,
5776 pDelBAIndBuffer,
5777 SIR_MAC_MGMT_FRAME,
5778 SIR_MAC_MGMT_ACTION,
5779 pMlmDelBAReq->peerMacAddr,psessionEntry->selfMacAddr)))
5780 goto returnAfterError;
5781
5782 // Update A3 with the BSSID
5783 pMacHdr = ( tpSirMacMgmtHdr ) pDelBAIndBuffer;
5784
5785 #if 0
5786 cfgLen = SIR_MAC_ADDR_LENGTH;
5787 if( eSIR_SUCCESS != cfgGetStr( pMac,
5788 WNI_CFG_BSSID,
5789 (tANI_U8 *) pMacHdr->bssId,
5790 &cfgLen ))
5791 {
5792 limLog( pMac, LOGP,
5793 FL( "Failed to retrieve WNI_CFG_BSSID while"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005794 "sending an ACTION Frame" ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005795
5796 // FIXME - Need to convert to tSirRetStatus
5797 statusCode = eSIR_FAILURE;
5798 goto returnAfterError;
5799 }
5800 #endif //TO SUPPORT BT-AMP
5801 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
5802
Chet Lanctot186b5732013-03-18 10:26:30 -07005803#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07005804 limSetProtectedBit(pMac, psessionEntry, pMlmDelBAReq->peerMacAddr, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07005805#endif
5806
Jeff Johnson295189b2012-06-20 16:38:30 -07005807 // Now, we're ready to "pack" the frames
5808 nStatus = dot11fPackDelBAInd( pMac,
5809 &frmDelBAInd,
5810 pDelBAIndBuffer + sizeof( tSirMacMgmtHdr ),
5811 nPayload,
5812 &nPayload );
5813
5814 if( DOT11F_FAILED( nStatus ))
5815 {
5816 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005817 FL( "Failed to pack an DELBA Ind (0x%08x)." ),
Jeff Johnson295189b2012-06-20 16:38:30 -07005818 nStatus );
5819
5820 // FIXME - Need to convert to tSirRetStatus
5821 statusCode = eSIR_FAILURE;
5822 goto returnAfterError;
5823 }
5824 else if( DOT11F_WARNED( nStatus ))
5825 {
5826 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005827 FL( "There were warnings while packing an DELBA Ind (0x%08x)." ),
5828 nStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07005829 }
5830
Abhishek Singh1f6e6532014-06-05 17:35:08 +05305831 limLog( pMac, LOG1,
5832 FL( "Sending a DELBA IND to: "MAC_ADDRESS_STR" with Tid = %d"
5833 " initiator = %d reason = %d" ),
5834 MAC_ADDR_ARRAY(pMlmDelBAReq->peerMacAddr),
5835 frmDelBAInd.DelBAParameterSet.tid,
5836 frmDelBAInd.DelBAParameterSet.initiator,
5837 frmDelBAInd.Reason.code);
5838
Jeff Johnson295189b2012-06-20 16:38:30 -07005839
5840 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07005841 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
5842 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07005843 )
5844 {
5845 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
5846 }
5847
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05305848 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
5849 psessionEntry->peSessionId,
5850 pMacHdr->fc.subType));
5851 halStatus = halTxFrame( pMac,
5852 pPacket,
5853 (tANI_U16) frameLen,
5854 HAL_TXRX_FRM_802_11_MGMT,
5855 ANI_TXDIR_TODS,
5856 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
5857 limTxComplete,
5858 pDelBAIndBuffer, txFlag );
5859 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
5860 psessionEntry->peSessionId,
5861 halStatus));
5862 if( eHAL_STATUS_SUCCESS != halStatus )
Jeff Johnson295189b2012-06-20 16:38:30 -07005863 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005864 PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]" ), halStatus );)
Jeff Johnson295189b2012-06-20 16:38:30 -07005865 statusCode = eSIR_FAILURE;
5866 //Pkt will be freed up by the callback
5867 return statusCode;
5868 }
5869 else
5870 return eSIR_SUCCESS;
5871
5872 returnAfterError:
5873
5874 // Release buffer, if allocated
5875 if( NULL != pDelBAIndBuffer )
5876 palPktFree( pMac->hHdd,
5877 HAL_TXRX_FRM_802_11_MGMT,
5878 (void *) pDelBAIndBuffer,
5879 (void *) pPacket );
5880
5881 return statusCode;
5882}
5883
5884#if defined WLAN_FEATURE_VOWIFI
5885
5886/**
5887 * \brief Send a Neighbor Report Request Action frame
5888 *
5889 *
5890 * \param pMac Pointer to the global MAC structure
5891 *
5892 * \param pNeighborReq Address of a tSirMacNeighborReportReq
5893 *
5894 * \param peer mac address of peer station.
5895 *
5896 * \param psessionEntry address of session entry.
5897 *
5898 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
5899 *
5900 *
5901 */
5902
5903tSirRetStatus
5904limSendNeighborReportRequestFrame(tpAniSirGlobal pMac,
5905 tpSirMacNeighborReportReq pNeighborReq,
5906 tSirMacAddr peer,
5907 tpPESession psessionEntry
5908 )
5909{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05305910 tSirRetStatus statusCode = eSIR_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07005911 tDot11fNeighborReportRequest frm;
5912 tANI_U8 *pFrame;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05305913 tpSirMacMgmtHdr pMacHdr;
5914 tANI_U32 nBytes, nPayload, nStatus;
5915 void *pPacket;
5916 eHalStatus halstatus;
5917 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005918
5919 if ( psessionEntry == NULL )
5920 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005921 limLog( pMac, LOGE, FL("(psession == NULL) in Request to send Neighbor Report request action frame") );
Jeff Johnson295189b2012-06-20 16:38:30 -07005922 return eSIR_FAILURE;
5923 }
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305924 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005925
5926 frm.Category.category = SIR_MAC_ACTION_RRM;
5927 frm.Action.action = SIR_MAC_RRM_NEIGHBOR_REQ;
5928 frm.DialogToken.token = pNeighborReq->dialogToken;
5929
5930
5931 if( pNeighborReq->ssid_present )
5932 {
5933 PopulateDot11fSSID( pMac, &pNeighborReq->ssid, &frm.SSID );
5934 }
5935
5936 nStatus = dot11fGetPackedNeighborReportRequestSize( pMac, &frm, &nPayload );
5937 if ( DOT11F_FAILED( nStatus ) )
5938 {
5939 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005940 "or a Neighbor Report Request(0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005941 nStatus );
5942 // We'll fall back on the worst case scenario:
5943 nPayload = sizeof( tDot11fNeighborReportRequest );
5944 }
5945 else if ( DOT11F_WARNED( nStatus ) )
5946 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005947 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07005948 "the packed size for a Neighbor Rep"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005949 "ort Request(0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07005950 }
5951
5952 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
5953
5954 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
5955 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
5956 {
5957 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Neighbor "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005958 "Report Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07005959 return eSIR_FAILURE;
5960 }
5961
5962 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305963 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005964
5965 // Copy necessary info to BD
5966 if( eSIR_SUCCESS !=
5967 (statusCode = limPopulateMacHeader( pMac,
5968 pFrame,
5969 SIR_MAC_MGMT_FRAME,
5970 SIR_MAC_MGMT_ACTION,
5971 peer, psessionEntry->selfMacAddr)))
5972 goto returnAfterError;
5973
5974 // Update A3 with the BSSID
5975 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
5976
5977 sirCopyMacAddr( pMacHdr->bssId, psessionEntry->bssId );
5978
Chet Lanctot186b5732013-03-18 10:26:30 -07005979#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07005980 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07005981#endif
5982
Jeff Johnson295189b2012-06-20 16:38:30 -07005983 // Now, we're ready to "pack" the frames
5984 nStatus = dot11fPackNeighborReportRequest( pMac,
5985 &frm,
5986 pFrame + sizeof( tSirMacMgmtHdr ),
5987 nPayload,
5988 &nPayload );
5989
5990 if( DOT11F_FAILED( nStatus ))
5991 {
5992 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005993 FL( "Failed to pack an Neighbor Report Request (0x%08x)." ),
Jeff Johnson295189b2012-06-20 16:38:30 -07005994 nStatus );
5995
5996 // FIXME - Need to convert to tSirRetStatus
5997 statusCode = eSIR_FAILURE;
5998 goto returnAfterError;
5999 }
6000 else if( DOT11F_WARNED( nStatus ))
6001 {
6002 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08006003 FL( "There were warnings while packing Neighbor Report "
6004 "Request (0x%08x)." ), nStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07006005 }
6006
6007 limLog( pMac, LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006008 FL( "Sending a Neighbor Report Request to " ));
Jeff Johnson295189b2012-06-20 16:38:30 -07006009 limPrintMacAddr( pMac, peer, LOGW );
6010
6011 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07006012 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
6013 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07006014 )
6015 {
6016 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
6017 }
6018
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05306019 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
6020 psessionEntry->peSessionId,
6021 pMacHdr->fc.subType));
6022 halstatus = halTxFrame( pMac,
6023 pPacket,
6024 (tANI_U16) nBytes,
6025 HAL_TXRX_FRM_802_11_MGMT,
6026 ANI_TXDIR_TODS,
6027 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
6028 limTxComplete,
6029 pFrame, txFlag );
6030 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
6031 psessionEntry->peSessionId,
6032 halstatus));
6033 if( eHAL_STATUS_SUCCESS != halstatus )
Jeff Johnson295189b2012-06-20 16:38:30 -07006034 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006035 PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]" ), halstatus );)
Jeff Johnson295189b2012-06-20 16:38:30 -07006036 statusCode = eSIR_FAILURE;
6037 //Pkt will be freed up by the callback
6038 return statusCode;
6039 }
6040 else
6041 return eSIR_SUCCESS;
6042
6043returnAfterError:
6044 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
6045
6046 return statusCode;
6047} // End limSendNeighborReportRequestFrame.
6048
6049/**
6050 * \brief Send a Link Report Action frame
6051 *
6052 *
6053 * \param pMac Pointer to the global MAC structure
6054 *
6055 * \param pLinkReport Address of a tSirMacLinkReport
6056 *
6057 * \param peer mac address of peer station.
6058 *
6059 * \param psessionEntry address of session entry.
6060 *
6061 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
6062 *
6063 *
6064 */
6065
6066tSirRetStatus
6067limSendLinkReportActionFrame(tpAniSirGlobal pMac,
6068 tpSirMacLinkReport pLinkReport,
6069 tSirMacAddr peer,
6070 tpPESession psessionEntry
6071 )
6072{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05306073 tSirRetStatus statusCode = eSIR_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006074 tDot11fLinkMeasurementReport frm;
6075 tANI_U8 *pFrame;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05306076 tpSirMacMgmtHdr pMacHdr;
6077 tANI_U32 nBytes, nPayload, nStatus;
6078 void *pPacket;
6079 eHalStatus halstatus;
6080 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07006081
6082
6083 if ( psessionEntry == NULL )
6084 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006085 limLog( pMac, LOGE, FL("(psession == NULL) in Request to send Link Report action frame") );
Jeff Johnson295189b2012-06-20 16:38:30 -07006086 return eSIR_FAILURE;
6087 }
6088
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05306089 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07006090
6091 frm.Category.category = SIR_MAC_ACTION_RRM;
6092 frm.Action.action = SIR_MAC_RRM_LINK_MEASUREMENT_RPT;
6093 frm.DialogToken.token = pLinkReport->dialogToken;
6094
6095
6096 //IEEE Std. 802.11 7.3.2.18. for the report element.
6097 //Even though TPC report an IE, it is represented using fixed fields since it is positioned
6098 //in the middle of other fixed fields in the link report frame(IEEE Std. 802.11k section7.4.6.4
6099 //and frame parser always expects IEs to come after all fixed fields. It is easier to handle
6100 //such case this way than changing the frame parser.
6101 frm.TPCEleID.TPCId = SIR_MAC_TPC_RPT_EID;
6102 frm.TPCEleLen.TPCLen = 2;
6103 frm.TxPower.txPower = pLinkReport->txPower;
6104 frm.LinkMargin.linkMargin = 0;
6105
6106 frm.RxAntennaId.antennaId = pLinkReport->rxAntenna;
6107 frm.TxAntennaId.antennaId = pLinkReport->txAntenna;
6108 frm.RCPI.rcpi = pLinkReport->rcpi;
6109 frm.RSNI.rsni = pLinkReport->rsni;
6110
6111 nStatus = dot11fGetPackedLinkMeasurementReportSize( pMac, &frm, &nPayload );
6112 if ( DOT11F_FAILED( nStatus ) )
6113 {
6114 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006115 "or a Link Report (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07006116 nStatus );
6117 // We'll fall back on the worst case scenario:
6118 nPayload = sizeof( tDot11fLinkMeasurementReport );
6119 }
6120 else if ( DOT11F_WARNED( nStatus ) )
6121 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08006122 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07006123 "the packed size for a Link Rep"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006124 "ort (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07006125 }
6126
6127 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
6128
6129 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
6130 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
6131 {
6132 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Link "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006133 "Report."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07006134 return eSIR_FAILURE;
6135 }
6136
6137 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05306138 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07006139
6140 // Copy necessary info to BD
6141 if( eSIR_SUCCESS !=
6142 (statusCode = limPopulateMacHeader( pMac,
6143 pFrame,
6144 SIR_MAC_MGMT_FRAME,
6145 SIR_MAC_MGMT_ACTION,
6146 peer, psessionEntry->selfMacAddr)))
6147 goto returnAfterError;
6148
6149 // Update A3 with the BSSID
6150 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
6151
6152 sirCopyMacAddr( pMacHdr->bssId, psessionEntry->bssId );
6153
Chet Lanctot186b5732013-03-18 10:26:30 -07006154#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07006155 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07006156#endif
6157
Jeff Johnson295189b2012-06-20 16:38:30 -07006158 // Now, we're ready to "pack" the frames
6159 nStatus = dot11fPackLinkMeasurementReport( pMac,
6160 &frm,
6161 pFrame + sizeof( tSirMacMgmtHdr ),
6162 nPayload,
6163 &nPayload );
6164
6165 if( DOT11F_FAILED( nStatus ))
6166 {
6167 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006168 FL( "Failed to pack an Link Report (0x%08x)." ),
Jeff Johnson295189b2012-06-20 16:38:30 -07006169 nStatus );
6170
6171 // FIXME - Need to convert to tSirRetStatus
6172 statusCode = eSIR_FAILURE;
6173 goto returnAfterError;
6174 }
6175 else if( DOT11F_WARNED( nStatus ))
6176 {
6177 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08006178 FL( "There were warnings while packing Link Report (0x%08x)." ),
6179 nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07006180 }
6181
6182 limLog( pMac, LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006183 FL( "Sending a Link Report to " ));
Jeff Johnson295189b2012-06-20 16:38:30 -07006184 limPrintMacAddr( pMac, peer, LOGW );
6185
6186 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07006187 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
6188 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07006189 )
6190 {
6191 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
6192 }
6193
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05306194 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
6195 psessionEntry->peSessionId,
6196 pMacHdr->fc.subType));
6197 halstatus = halTxFrame( pMac,
6198 pPacket,
6199 (tANI_U16) nBytes,
6200 HAL_TXRX_FRM_802_11_MGMT,
6201 ANI_TXDIR_TODS,
6202 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
6203 limTxComplete,
6204 pFrame, txFlag );
6205 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
6206 psessionEntry->peSessionId,
6207 halstatus));
6208 if( eHAL_STATUS_SUCCESS != halstatus )
Jeff Johnson295189b2012-06-20 16:38:30 -07006209 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006210 PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]" ), halstatus );)
Jeff Johnson295189b2012-06-20 16:38:30 -07006211 statusCode = eSIR_FAILURE;
6212 //Pkt will be freed up by the callback
6213 return statusCode;
6214 }
6215 else
6216 return eSIR_SUCCESS;
6217
6218returnAfterError:
6219 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
6220
6221 return statusCode;
6222} // End limSendLinkReportActionFrame.
6223
6224/**
6225 * \brief Send a Beacon Report Action frame
6226 *
6227 *
6228 * \param pMac Pointer to the global MAC structure
6229 *
6230 * \param dialog_token dialog token to be used in the action frame.
6231 *
6232 * \param num_report number of reports in pRRMReport.
6233 *
6234 * \param pRRMReport Address of a tSirMacRadioMeasureReport.
6235 *
6236 * \param peer mac address of peer station.
6237 *
6238 * \param psessionEntry address of session entry.
6239 *
6240 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
6241 *
6242 *
6243 */
6244
6245tSirRetStatus
6246limSendRadioMeasureReportActionFrame(tpAniSirGlobal pMac,
6247 tANI_U8 dialog_token,
6248 tANI_U8 num_report,
6249 tpSirMacRadioMeasureReport pRRMReport,
6250 tSirMacAddr peer,
6251 tpPESession psessionEntry
6252 )
6253{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05306254 tSirRetStatus statusCode = eSIR_SUCCESS;
6255 tANI_U8 *pFrame;
6256 tpSirMacMgmtHdr pMacHdr;
6257 tANI_U32 nBytes, nPayload, nStatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07006258 void *pPacket;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05306259 eHalStatus halstatus;
6260 tANI_U8 i;
6261 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07006262
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006263 tDot11fRadioMeasurementReport *frm =
6264 vos_mem_malloc(sizeof(tDot11fRadioMeasurementReport));
6265 if (!frm) {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006266 limLog( pMac, LOGE, FL("Not enough memory to allocate tDot11fRadioMeasurementReport") );
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006267 return eSIR_FAILURE;
6268 }
6269
Jeff Johnson295189b2012-06-20 16:38:30 -07006270 if ( psessionEntry == NULL )
6271 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006272 limLog( pMac, LOGE, FL("(psession == NULL) in Request to send Beacon Report action frame") );
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006273 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07006274 return eSIR_FAILURE;
6275 }
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05306276 vos_mem_set( ( tANI_U8* )frm, sizeof( *frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07006277
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006278 frm->Category.category = SIR_MAC_ACTION_RRM;
6279 frm->Action.action = SIR_MAC_RRM_RADIO_MEASURE_RPT;
6280 frm->DialogToken.token = dialog_token;
Jeff Johnson295189b2012-06-20 16:38:30 -07006281
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006282 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 -07006283
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006284 for( i = 0 ; i < frm->num_MeasurementReport ; i++ )
Jeff Johnson295189b2012-06-20 16:38:30 -07006285 {
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006286 frm->MeasurementReport[i].type = pRRMReport[i].type;
6287 frm->MeasurementReport[i].token = pRRMReport[i].token;
6288 frm->MeasurementReport[i].late = 0; //IEEE 802.11k section 7.3.22. (always zero in rrm)
Jeff Johnson295189b2012-06-20 16:38:30 -07006289 switch( pRRMReport[i].type )
6290 {
6291 case SIR_MAC_RRM_BEACON_TYPE:
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006292 PopulateDot11fBeaconReport( pMac, &frm->MeasurementReport[i], &pRRMReport[i].report.beaconReport );
6293 frm->MeasurementReport[i].incapable = pRRMReport[i].incapable;
6294 frm->MeasurementReport[i].refused = pRRMReport[i].refused;
6295 frm->MeasurementReport[i].present = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07006296 break;
6297 default:
Gopichand Nakkala72717fd2013-02-08 12:23:45 +05306298 frm->MeasurementReport[i].incapable = pRRMReport[i].incapable;
6299 frm->MeasurementReport[i].refused = pRRMReport[i].refused;
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006300 frm->MeasurementReport[i].present = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07006301 break;
6302 }
6303 }
6304
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006305 nStatus = dot11fGetPackedRadioMeasurementReportSize( pMac, frm, &nPayload );
Jeff Johnson295189b2012-06-20 16:38:30 -07006306 if ( DOT11F_FAILED( nStatus ) )
6307 {
6308 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006309 "or a Radio Measure Report (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07006310 nStatus );
6311 // We'll fall back on the worst case scenario:
6312 nPayload = sizeof( tDot11fLinkMeasurementReport );
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006313 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07006314 return eSIR_FAILURE;
6315 }
6316 else if ( DOT11F_WARNED( nStatus ) )
6317 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08006318 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07006319 "the packed size for a Radio Measure Rep"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006320 "ort (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07006321 }
6322
6323 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
6324
6325 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
6326 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
6327 {
6328 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Radio Measure "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006329 "Report."), nBytes );
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006330 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07006331 return eSIR_FAILURE;
6332 }
6333
6334 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05306335 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07006336
6337 // Copy necessary info to BD
6338 if( eSIR_SUCCESS !=
6339 (statusCode = limPopulateMacHeader( pMac,
6340 pFrame,
6341 SIR_MAC_MGMT_FRAME,
6342 SIR_MAC_MGMT_ACTION,
6343 peer, psessionEntry->selfMacAddr)))
6344 goto returnAfterError;
6345
6346 // Update A3 with the BSSID
6347 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
6348
6349 sirCopyMacAddr( pMacHdr->bssId, psessionEntry->bssId );
6350
Chet Lanctot186b5732013-03-18 10:26:30 -07006351#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07006352 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07006353#endif
6354
Jeff Johnson295189b2012-06-20 16:38:30 -07006355 // Now, we're ready to "pack" the frames
6356 nStatus = dot11fPackRadioMeasurementReport( pMac,
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006357 frm,
Jeff Johnson295189b2012-06-20 16:38:30 -07006358 pFrame + sizeof( tSirMacMgmtHdr ),
6359 nPayload,
6360 &nPayload );
6361
6362 if( DOT11F_FAILED( nStatus ))
6363 {
6364 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006365 FL( "Failed to pack an Radio Measure Report (0x%08x)." ),
Jeff Johnson295189b2012-06-20 16:38:30 -07006366 nStatus );
6367
6368 // FIXME - Need to convert to tSirRetStatus
6369 statusCode = eSIR_FAILURE;
6370 goto returnAfterError;
6371 }
6372 else if( DOT11F_WARNED( nStatus ))
6373 {
6374 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08006375 FL( "There were warnings while packing Radio "
6376 "Measure Report (0x%08x)." ), nStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07006377 }
6378
6379 limLog( pMac, LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006380 FL( "Sending a Radio Measure Report to " ));
Jeff Johnson295189b2012-06-20 16:38:30 -07006381 limPrintMacAddr( pMac, peer, LOGW );
6382
6383 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07006384 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
6385 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07006386 )
6387 {
6388 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
6389 }
6390
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05306391 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
6392 psessionEntry->peSessionId,
6393 pMacHdr->fc.subType));
6394 halstatus = halTxFrame( pMac,
6395 pPacket,
6396 (tANI_U16) nBytes,
6397 HAL_TXRX_FRM_802_11_MGMT,
6398 ANI_TXDIR_TODS,
6399 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
6400 limTxComplete,
6401 pFrame, txFlag );
6402 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
6403 psessionEntry->peSessionId,
6404 halstatus));
6405 if( eHAL_STATUS_SUCCESS != halstatus )
Jeff Johnson295189b2012-06-20 16:38:30 -07006406 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006407 PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]" ), halstatus );)
Jeff Johnson295189b2012-06-20 16:38:30 -07006408 statusCode = eSIR_FAILURE;
6409 //Pkt will be freed up by the callback
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006410 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07006411 return statusCode;
6412 }
Madan Mohan Koyyalamudieeb56b12012-10-31 15:10:04 -07006413 else {
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006414 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07006415 return eSIR_SUCCESS;
Madan Mohan Koyyalamudieeb56b12012-10-31 15:10:04 -07006416 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006417
6418returnAfterError:
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006419 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07006420 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
Jeff Johnson295189b2012-06-20 16:38:30 -07006421 return statusCode;
6422} // End limSendBeaconReportActionFrame.
6423
6424#endif
6425
6426#ifdef WLAN_FEATURE_11W
6427/**
Chet Lanctot8cecea22014-02-11 19:09:36 -08006428 * \brief Send SA query request action frame to peer
6429 *
6430 * \sa limSendSaQueryRequestFrame
6431 *
6432 *
6433 * \param pMac The global tpAniSirGlobal object
6434 *
6435 * \param transId Transaction identifier
6436 *
6437 * \param peer The Mac address of the station to which this action frame is addressed
6438 *
6439 * \param psessionEntry The PE session entry
6440 *
6441 * \return eSIR_SUCCESS if setup completes successfully
6442 * eSIR_FAILURE is some problem is encountered
6443 */
6444
6445tSirRetStatus limSendSaQueryRequestFrame( tpAniSirGlobal pMac, tANI_U8 *transId,
6446 tSirMacAddr peer, tpPESession psessionEntry )
6447{
6448
6449 tDot11fSaQueryReq frm; // SA query request action frame
6450 tANI_U8 *pFrame;
6451 tSirRetStatus nSirStatus;
6452 tpSirMacMgmtHdr pMacHdr;
6453 tANI_U32 nBytes, nPayload, nStatus;
6454 void *pPacket;
6455 eHalStatus halstatus;
6456 tANI_U8 txFlag = 0;
6457
6458 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
6459 frm.Category.category = SIR_MAC_ACTION_SA_QUERY;
6460 /* 11w action field is :
6461 action: 0 --> SA Query Request action frame
6462 action: 1 --> SA Query Response action frame */
6463 frm.Action.action = SIR_MAC_SA_QUERY_REQ;
6464 /* 11w SA Query Request transId */
6465 vos_mem_copy( &frm.TransactionId.transId[0], &transId[0], 2 );
6466
6467 nStatus = dot11fGetPackedSaQueryReqSize(pMac, &frm, &nPayload);
6468 if ( DOT11F_FAILED( nStatus ) )
6469 {
6470 limLog( pMac, LOGP, FL("Failed to calculate the packed size "
6471 "for an SA Query Request (0x%08x)."),
6472 nStatus );
6473 // We'll fall back on the worst case scenario:
6474 nPayload = sizeof( tDot11fSaQueryReq );
6475 }
6476 else if ( DOT11F_WARNED( nStatus ) )
6477 {
6478 limLog( pMac, LOGW, FL("There were warnings while calculating "
6479 "the packed size for an SA Query Request"
6480 " (0x%08x)."), nStatus );
6481 }
6482
6483 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
6484 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
6485 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
6486 {
6487 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a SA Query Request "
6488 "action frame"), nBytes );
6489 return eSIR_FAILURE;
6490 }
6491
6492 // Paranoia:
6493 vos_mem_set( pFrame, nBytes, 0 );
6494
6495 // Copy necessary info to BD
6496 nSirStatus = limPopulateMacHeader( pMac,
6497 pFrame,
6498 SIR_MAC_MGMT_FRAME,
6499 SIR_MAC_MGMT_ACTION,
6500 peer, psessionEntry->selfMacAddr );
6501 if ( eSIR_SUCCESS != nSirStatus )
6502 goto returnAfterError;
6503
6504 // Update A3 with the BSSID
6505 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
6506
6507 sirCopyMacAddr( pMacHdr->bssId, psessionEntry->bssId );
6508
6509 // Since this is a SA Query Request, set the "protect" (aka WEP) bit
6510 // in the FC
6511 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
6512
6513 // Pack 11w SA Query Request frame
6514 nStatus = dot11fPackSaQueryReq( pMac,
6515 &frm,
6516 pFrame + sizeof( tSirMacMgmtHdr ),
6517 nPayload,
6518 &nPayload );
6519
6520 if ( DOT11F_FAILED( nStatus ))
6521 {
6522 limLog( pMac, LOGE,
6523 FL( "Failed to pack an SA Query Request (0x%08x)." ),
6524 nStatus );
6525 // FIXME - Need to convert to tSirRetStatus
6526 nSirStatus = eSIR_FAILURE;
6527 goto returnAfterError;
6528 }
6529 else if ( DOT11F_WARNED( nStatus ))
6530 {
6531 limLog( pMac, LOGW,
6532 FL( "There were warnings while packing SA Query Request (0x%08x)." ),
6533 nStatus);
6534 }
6535
6536 limLog( pMac, LOG1,
6537 FL( "Sending an SA Query Request to " ));
6538 limPrintMacAddr( pMac, peer, LOG1 );
6539 limPrintMacAddr( pMac, peer, LOGE );
6540 limLog( pMac, LOGE,
6541 FL( "Sending an SA Query Request from " ));
6542 limPrintMacAddr( pMac, psessionEntry->selfMacAddr, LOGE );
6543
6544 if ( ( SIR_BAND_5_GHZ == limGetRFBand( psessionEntry->currentOperChannel ) )
6545#ifdef WLAN_FEATURE_P2P
6546 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
6547 ( psessionEntry->pePersona == VOS_P2P_GO_MODE )
6548#endif
6549 )
6550 {
6551 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
6552 }
6553
6554 halstatus = halTxFrame( pMac,
6555 pPacket,
6556 (tANI_U16) nBytes,
6557 HAL_TXRX_FRM_802_11_MGMT,
6558 ANI_TXDIR_TODS,
6559 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
6560 limTxComplete,
6561 pFrame, txFlag );
6562 if ( eHAL_STATUS_SUCCESS != halstatus )
6563 {
6564 PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]" ), halstatus );)
6565 nSirStatus = eSIR_FAILURE;
6566 //Pkt will be freed up by the callback
6567 return nSirStatus;
6568 }
6569 else {
6570 return eSIR_SUCCESS;
6571 }
6572
6573returnAfterError:
6574 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
6575 return nSirStatus;
6576} // End limSendSaQueryRequestFrame
6577
6578/**
Jeff Johnson295189b2012-06-20 16:38:30 -07006579 * \brief Send SA query response action frame to peer
6580 *
6581 * \sa limSendSaQueryResponseFrame
6582 *
6583 *
6584 * \param pMac The global tpAniSirGlobal object
6585 *
Chet Lanctot186b5732013-03-18 10:26:30 -07006586 * \param transId Transaction identifier received in SA query request action frame
Jeff Johnson295189b2012-06-20 16:38:30 -07006587 *
Chet Lanctot186b5732013-03-18 10:26:30 -07006588 * \param peer The Mac address of the AP to which this action frame is addressed
6589 *
6590 * \param psessionEntry The PE session entry
Jeff Johnson295189b2012-06-20 16:38:30 -07006591 *
6592 * \return eSIR_SUCCESS if setup completes successfully
6593 * eSIR_FAILURE is some problem is encountered
6594 */
6595
Chet Lanctot186b5732013-03-18 10:26:30 -07006596tSirRetStatus limSendSaQueryResponseFrame( tpAniSirGlobal pMac, tANI_U8 *transId,
Jeff Johnson295189b2012-06-20 16:38:30 -07006597tSirMacAddr peer,tpPESession psessionEntry)
6598{
6599
Chet Lanctot186b5732013-03-18 10:26:30 -07006600 tDot11fSaQueryRsp frm; // SA query reponse action frame
Jeff Johnson295189b2012-06-20 16:38:30 -07006601 tANI_U8 *pFrame;
6602 tSirRetStatus nSirStatus;
6603 tpSirMacMgmtHdr pMacHdr;
Chet Lanctot186b5732013-03-18 10:26:30 -07006604 tANI_U32 nBytes, nPayload, nStatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07006605 void *pPacket;
6606 eHalStatus halstatus;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05306607 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07006608
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05306609 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Chet Lanctot186b5732013-03-18 10:26:30 -07006610 frm.Category.category = SIR_MAC_ACTION_SA_QUERY;
6611 /*11w action field is :
Jeff Johnson295189b2012-06-20 16:38:30 -07006612 action: 0 --> SA query request action frame
6613 action: 1 --> SA query response action frame */
Chet Lanctot186b5732013-03-18 10:26:30 -07006614 frm.Action.action = SIR_MAC_SA_QUERY_RSP;
6615 /*11w SA query response transId is same as
Jeff Johnson295189b2012-06-20 16:38:30 -07006616 SA query request transId*/
Chet Lanctot186b5732013-03-18 10:26:30 -07006617 vos_mem_copy( &frm.TransactionId.transId[0], &transId[0], 2 );
Jeff Johnson295189b2012-06-20 16:38:30 -07006618
Chet Lanctot186b5732013-03-18 10:26:30 -07006619 nStatus = dot11fGetPackedSaQueryRspSize(pMac, &frm, &nPayload);
6620 if ( DOT11F_FAILED( nStatus ) )
6621 {
6622 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
6623 "or a SA Query Response (0x%08x)."),
6624 nStatus );
6625 // We'll fall back on the worst case scenario:
6626 nPayload = sizeof( tDot11fSaQueryRsp );
6627 }
6628 else if ( DOT11F_WARNED( nStatus ) )
6629 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08006630 limLog( pMac, LOGW, FL("There were warnings while calculating "
Chet Lanctot186b5732013-03-18 10:26:30 -07006631 "the packed size for an SA Query Response"
6632 " (0x%08x)."), nStatus );
6633 }
6634
Jeff Johnson295189b2012-06-20 16:38:30 -07006635 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
6636 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
6637 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
6638 {
6639 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a SA query response"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006640 " action frame"), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07006641 return eSIR_FAILURE;
6642 }
6643
6644 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05306645 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07006646
Chet Lanctot186b5732013-03-18 10:26:30 -07006647 // Copy necessary info to BD
Chet Lanctotb2b0d552013-03-22 16:58:44 -07006648 nSirStatus = limPopulateMacHeader( pMac,
Chet Lanctot186b5732013-03-18 10:26:30 -07006649 pFrame,
6650 SIR_MAC_MGMT_FRAME,
6651 SIR_MAC_MGMT_ACTION,
Chet Lanctotb2b0d552013-03-22 16:58:44 -07006652 peer, psessionEntry->selfMacAddr );
6653 if ( eSIR_SUCCESS != nSirStatus )
Chet Lanctot186b5732013-03-18 10:26:30 -07006654 goto returnAfterError;
Jeff Johnson295189b2012-06-20 16:38:30 -07006655
Chet Lanctot186b5732013-03-18 10:26:30 -07006656 // Update A3 with the BSSID
Jeff Johnson295189b2012-06-20 16:38:30 -07006657 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
6658
Chet Lanctot186b5732013-03-18 10:26:30 -07006659 sirCopyMacAddr( pMacHdr->bssId, psessionEntry->bssId );
Jeff Johnson295189b2012-06-20 16:38:30 -07006660
Chet Lanctot186b5732013-03-18 10:26:30 -07006661 // Since this is a SA Query Response, set the "protect" (aka WEP) bit
6662 // in the FC
Chet Lanctot8cecea22014-02-11 19:09:36 -08006663 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Jeff Johnson295189b2012-06-20 16:38:30 -07006664
Chet Lanctot186b5732013-03-18 10:26:30 -07006665 // Pack 11w SA query response frame
6666 nStatus = dot11fPackSaQueryRsp( pMac,
6667 &frm,
6668 pFrame + sizeof( tSirMacMgmtHdr ),
6669 nPayload,
6670 &nPayload );
6671
6672 if ( DOT11F_FAILED( nStatus ))
6673 {
6674 limLog( pMac, LOGE,
6675 FL( "Failed to pack an SA Query Response (0x%08x)." ),
6676 nStatus );
6677 // FIXME - Need to convert to tSirRetStatus
6678 nSirStatus = eSIR_FAILURE;
6679 goto returnAfterError;
6680 }
6681 else if ( DOT11F_WARNED( nStatus ))
6682 {
6683 limLog( pMac, LOGW,
6684 FL( "There were warnings while packing SA Query Response (0x%08x)." ),
6685 nStatus);
6686 }
6687
6688 limLog( pMac, LOG1,
6689 FL( "Sending a SA Query Response to " ));
6690 limPrintMacAddr( pMac, peer, LOGW );
6691
Chet Lanctotb2b0d552013-03-22 16:58:44 -07006692 if ( ( SIR_BAND_5_GHZ == limGetRFBand( psessionEntry->currentOperChannel ) )
Chet Lanctot186b5732013-03-18 10:26:30 -07006693#ifdef WLAN_FEATURE_P2P
Chet Lanctotb2b0d552013-03-22 16:58:44 -07006694 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
6695 ( psessionEntry->pePersona == VOS_P2P_GO_MODE )
Chet Lanctot186b5732013-03-18 10:26:30 -07006696#endif
Chet Lanctotb2b0d552013-03-22 16:58:44 -07006697 )
6698 {
6699 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
6700 }
Chet Lanctot186b5732013-03-18 10:26:30 -07006701
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05306702 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
6703 psessionEntry->peSessionId,
6704 pMacHdr->fc.subType));
Chet Lanctotb2b0d552013-03-22 16:58:44 -07006705 halstatus = halTxFrame( pMac,
6706 pPacket,
6707 (tANI_U16) nBytes,
6708 HAL_TXRX_FRM_802_11_MGMT,
6709 ANI_TXDIR_TODS,
6710 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
6711 limTxComplete,
6712 pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05306713 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
6714 psessionEntry->peSessionId,
6715 halstatus));
Chet Lanctotb2b0d552013-03-22 16:58:44 -07006716 if ( eHAL_STATUS_SUCCESS != halstatus )
Chet Lanctot186b5732013-03-18 10:26:30 -07006717 {
6718 PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]" ), halstatus );)
6719 nSirStatus = eSIR_FAILURE;
6720 //Pkt will be freed up by the callback
6721 return nSirStatus;
6722 }
6723 else {
6724 return eSIR_SUCCESS;
6725 }
6726
6727returnAfterError:
6728 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
6729 return nSirStatus;
6730} // End limSendSaQueryResponseFrame
Jeff Johnson295189b2012-06-20 16:38:30 -07006731#endif