blob: 15c263f68763b31e3f0effe8e5d30150b32dee91 [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 {
155 limLog( pMac, LOGE,
156 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;
Kalikinkar dhara205da782014-03-21 15:49:32 -07001353 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 );
Jeff Johnson295189b2012-06-20 16:38:30 -07001460 PopulateDot11fHTInfo( pMac, &frm.HTInfo, psessionEntry );
Jeff Johnson295189b2012-06-20 16:38:30 -07001461 }
Jeff Johnsone7245742012-09-05 17:12:55 -07001462
1463#ifdef WLAN_FEATURE_11AC
1464 if( pSta->mlmStaContext.vhtCapability &&
1465 psessionEntry->vhtCapability )
1466 {
Chet Lanctotf19c1f62013-12-13 13:56:21 -08001467 limLog( pMac, LOG1, FL("Populate VHT IEs in Assoc Response"));
Abhishek Singh6d5d29c2014-07-03 14:25:22 +05301468 PopulateDot11fVHTCaps( pMac, &frm.VHTCaps, eSIR_TRUE );
Jeff Johnsone7245742012-09-05 17:12:55 -07001469 PopulateDot11fVHTOperation( pMac, &frm.VHTOperation);
Sandeep Puligilla60342762014-01-30 21:05:37 +05301470 PopulateDot11fExtCap( pMac, &frm.ExtCap, psessionEntry);
Jeff Johnsone7245742012-09-05 17:12:55 -07001471 }
1472#endif
1473
Chet Lanctot8cecea22014-02-11 19:09:36 -08001474#ifdef WLAN_FEATURE_11W
Dino Myclea7f18452014-04-24 08:55:31 +05301475 if( eSIR_MAC_TRY_AGAIN_LATER == statusCode )
1476 {
Chet Lanctotfadc8e32014-04-24 14:50:52 -07001477 if ( wlan_cfgGetInt(pMac, WNI_CFG_PMF_SA_QUERY_MAX_RETRIES,
1478 &maxRetries ) != eSIR_SUCCESS )
1479 limLog( pMac, LOGE,
1480 FL("Could not retrieve PMF SA Query maximum retries value") );
1481 else
1482 if ( wlan_cfgGetInt(pMac, WNI_CFG_PMF_SA_QUERY_RETRY_INTERVAL,
1483 &retryInterval ) != eSIR_SUCCESS)
1484 limLog( pMac, LOGE,
1485 FL("Could not retrieve PMF SA Query timer interval value") );
Dino Myclea7f18452014-04-24 08:55:31 +05301486 else
Chet Lanctotfadc8e32014-04-24 14:50:52 -07001487 PopulateDot11fTimeoutInterval(
1488 pMac, &frm.TimeoutInterval, SIR_MAC_TI_TYPE_ASSOC_COMEBACK,
1489 (maxRetries - pSta->pmfSaQueryRetryCount) * retryInterval );
Dino Myclea7f18452014-04-24 08:55:31 +05301490 }
Chet Lanctot8cecea22014-02-11 19:09:36 -08001491#endif
Dino Myclea7f18452014-04-24 08:55:31 +05301492 } // End if on non-NULL 'pSta'.
Jeff Johnson295189b2012-06-20 16:38:30 -07001493
Chet Lanctot8cecea22014-02-11 19:09:36 -08001494 vos_mem_set(( tANI_U8* )&beaconParams, sizeof( tUpdateBeaconParams), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001495
Jeff Johnson295189b2012-06-20 16:38:30 -07001496 if( psessionEntry->limSystemRole == eLIM_AP_ROLE ){
1497 if(psessionEntry->gLimProtectionControl != WNI_CFG_FORCE_POLICY_PROTECTION_DISABLE)
1498 limDecideApProtection(pMac, peerMacAddr, &beaconParams,psessionEntry);
1499 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001500
1501 limUpdateShortPreamble(pMac, peerMacAddr, &beaconParams, psessionEntry);
1502 limUpdateShortSlotTime(pMac, peerMacAddr, &beaconParams, psessionEntry);
1503
1504 beaconParams.bssIdx = psessionEntry->bssIdx;
1505
1506 //Send message to HAL about beacon parameter change.
1507 if(beaconParams.paramChangeBitmap)
1508 {
1509 schSetFixedBeaconFields(pMac,psessionEntry);
1510 limSendBeaconParams(pMac, &beaconParams, psessionEntry );
1511 }
1512
Jeff Johnson295189b2012-06-20 16:38:30 -07001513 if ( pAssocReq != NULL )
1514 {
1515 if (wlan_cfgGetInt(pMac, WNI_CFG_ASSOC_RSP_ADDNIE_FLAG,
1516 &addnIEPresent) != eSIR_SUCCESS)
1517 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05301518 limLog(pMac, LOGP, FL("Unable to get "
1519 "WNI_CFG_ASSOC_RSP_ADDNIE_FLAG"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001520 return;
1521 }
1522
1523 if (addnIEPresent)
1524 {
1525 //Assoc rsp IE available
1526 if (wlan_cfgGetStrLen(pMac, WNI_CFG_ASSOC_RSP_ADDNIE_DATA,
1527 &addnIELen) != eSIR_SUCCESS)
1528 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05301529 limLog(pMac, LOGP, FL("Unable to get "
1530 "WNI_CFG_ASSOC_RSP_ADDNIE_DATA length"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001531 return;
1532 }
1533
1534 if (addnIELen <= WNI_CFG_ASSOC_RSP_ADDNIE_DATA_LEN && addnIELen &&
1535 (nBytes + addnIELen) <= SIR_MAX_PACKET_SIZE)
1536 {
1537 if (wlan_cfgGetStr(pMac, WNI_CFG_ASSOC_RSP_ADDNIE_DATA,
1538 &addIE[0], &addnIELen) == eSIR_SUCCESS)
1539 {
Kalikinkar dhara205da782014-03-21 15:49:32 -07001540
1541 vos_mem_set(( tANI_U8* )&extractedExtCap,
1542 sizeof( tDot11fIEExtCap ), 0);
1543 nSirStatus = limStripOffExtCapIEAndUpdateStruct(pMac,
1544 &addIE[0],
1545 &addStripoffIELen,
1546 &extractedExtCap );
1547 if(eSIR_SUCCESS != nSirStatus)
1548 {
1549 limLog(pMac, LOG1,
1550 FL("Unable to Stripoff ExtCap IE from Assoc Rsp"));
1551 }
1552 else
1553 {
1554 addnIELen = addStripoffIELen;
1555 extractedExtCapFlag = eANI_BOOLEAN_TRUE;
1556 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001557 nBytes = nBytes + addnIELen;
1558 }
1559 }
1560 }
1561 }
1562
c_hpothubcd78652014-04-28 22:31:08 +05301563 /* merge the ExtCap struct*/
1564 if (extractedExtCapFlag && extractedExtCap.present)
1565 {
1566 limMergeExtCapIEStruct(&(frm.ExtCap), &extractedExtCap);
1567 }
1568
1569 nStatus = dot11fGetPackedAssocResponseSize( pMac, &frm, &nPayload );
1570 if ( DOT11F_FAILED( nStatus ) )
1571 {
1572 limLog( pMac, LOGE, FL("Failed to calculate the packed size f"
1573 "or an Association Response (0x%08x)."),
1574 nStatus );
1575 return;
1576 }
1577 else if ( DOT11F_WARNED( nStatus ) )
1578 {
1579 limLog( pMac, LOGW, FL("There were warnings while calculating "
1580 "the packed size for an Association Re"
1581 "sponse (0x%08x)."), nStatus );
1582 }
1583
1584 nBytes += sizeof( tSirMacMgmtHdr ) + nPayload;
1585
Jeff Johnson295189b2012-06-20 16:38:30 -07001586 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1587 ( tANI_U16 )nBytes, ( void** ) &pFrame,
1588 ( void** ) &pPacket );
1589 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1590 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001591 limLog(pMac, LOGP, FL("Call to bufAlloc failed for RE/ASSOC RSP."));
Jeff Johnson295189b2012-06-20 16:38:30 -07001592 return;
1593 }
1594
1595 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301596 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07001597
1598 // Next, we fill out the buffer descriptor:
1599 nSirStatus = limPopulateMacHeader( pMac,
1600 pFrame,
1601 SIR_MAC_MGMT_FRAME,
1602 ( LIM_ASSOC == subType ) ?
1603 SIR_MAC_MGMT_ASSOC_RSP :
1604 SIR_MAC_MGMT_REASSOC_RSP,
1605 peerMacAddr,psessionEntry->selfMacAddr);
1606 if ( eSIR_SUCCESS != nSirStatus )
1607 {
1608 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001609 "tor for an Association Response (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001610 nSirStatus );
1611 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1612 ( void* ) pFrame, ( void* ) pPacket );
1613 return;
1614 }
1615
1616 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
1617
Jeff Johnson295189b2012-06-20 16:38:30 -07001618 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
1619
1620 nStatus = dot11fPackAssocResponse( pMac, &frm,
1621 pFrame + sizeof( tSirMacMgmtHdr ),
1622 nPayload, &nPayload );
1623 if ( DOT11F_FAILED( nStatus ) )
1624 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05301625 limLog( pMac, LOGE, FL("Failed to pack an Association Response"
1626 " (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001627 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1628 ( void* ) pFrame, ( void* ) pPacket );
1629 return; // allocated!
1630 }
1631 else if ( DOT11F_WARNED( nStatus ) )
1632 {
1633 limLog( pMac, LOGW, FL("There were warnings while packing an "
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001634 "Association Response (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001635 }
1636
1637 macAddr = pMacHdr->da;
1638
1639 if (subType == LIM_ASSOC)
1640 {
1641 PELOG1(limLog(pMac, LOG1,
1642 FL("*** Sending Assoc Resp status %d aid %d to "),
1643 statusCode, aid);)
1644 }
1645 else{
1646 PELOG1(limLog(pMac, LOG1,
1647 FL("*** Sending ReAssoc Resp status %d aid %d to "),
1648 statusCode, aid);)
1649 }
1650 PELOG1(limPrintMacAddr(pMac, pMacHdr->da, LOG1);)
1651
1652 if ( addnIEPresent )
1653 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301654 vos_mem_copy ( pFrame+sizeof(tSirMacMgmtHdr)+nPayload, &addIE[0], addnIELen ) ;
Jeff Johnson295189b2012-06-20 16:38:30 -07001655 }
1656
1657 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07001658 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
1659 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07001660 )
1661 {
1662 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
1663 }
1664
Agarwal Ashisha8e81f52014-04-02 01:59:52 +05301665 limLog( pMac, LOG1, FL("Sending Assoc resp over WQ5 to "MAC_ADDRESS_STR
1666 " From " MAC_ADDRESS_STR),MAC_ADDR_ARRAY(pMacHdr->da),
1667 MAC_ADDR_ARRAY(psessionEntry->selfMacAddr));
1668
1669 txFlag |= HAL_USE_FW_IN_TX_PATH;
1670
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05301671 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
1672 psessionEntry->peSessionId,
1673 pMacHdr->fc.subType));
Jeff Johnson295189b2012-06-20 16:38:30 -07001674 /// Queue Association Response frame in high priority WQ
1675 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
1676 HAL_TXRX_FRM_802_11_MGMT,
1677 ANI_TXDIR_TODS,
1678 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
1679 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05301680 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
1681 psessionEntry->peSessionId,
1682 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07001683 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1684 {
1685 limLog(pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001686 FL("*** Could not Send Re/AssocRsp, retCode=%X ***"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001687 nSirStatus);
1688
1689 //Pkt will be freed up by the callback
1690 }
1691
1692 // update the ANI peer station count
1693 //FIXME_PROTECTION : take care of different type of station
1694 // counter inside this function.
1695 limUtilCountStaAdd(pMac, pSta, psessionEntry);
1696
1697} // End limSendAssocRspMgmtFrame.
1698
1699
1700
1701void
1702limSendAddtsRspActionFrame(tpAniSirGlobal pMac,
1703 tSirMacAddr peer,
1704 tANI_U16 nStatusCode,
1705 tSirAddtsReqInfo *pAddTS,
1706 tSirMacScheduleIE *pSchedule,
1707 tpPESession psessionEntry)
1708{
1709 tANI_U8 *pFrame;
1710 tpSirMacMgmtHdr pMacHdr;
1711 tDot11fAddTSResponse AddTSRsp;
1712 tDot11fWMMAddTSResponse WMMAddTSRsp;
1713 tSirRetStatus nSirStatus;
1714 tANI_U32 i, nBytes, nPayload, nStatus;
1715 void *pPacket;
1716 eHalStatus halstatus;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05301717 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001718
1719 if(NULL == psessionEntry)
1720 {
1721 return;
1722 }
1723
1724 if ( ! pAddTS->wmeTspecPresent )
1725 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301726 vos_mem_set( ( tANI_U8* )&AddTSRsp, sizeof( AddTSRsp ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07001727
1728 AddTSRsp.Category.category = SIR_MAC_ACTION_QOS_MGMT;
1729 AddTSRsp.Action.action = SIR_MAC_QOS_ADD_TS_RSP;
1730 AddTSRsp.DialogToken.token = pAddTS->dialogToken;
1731 AddTSRsp.Status.status = nStatusCode;
1732
1733 // The TsDelay information element is only filled in for a specific
1734 // status code:
1735 if ( eSIR_MAC_TS_NOT_CREATED_STATUS == nStatusCode )
1736 {
1737 if ( pAddTS->wsmTspecPresent )
1738 {
1739 AddTSRsp.WMMTSDelay.version = 1;
1740 AddTSRsp.WMMTSDelay.delay = 10;
1741 AddTSRsp.WMMTSDelay.present = 1;
1742 }
1743 else
1744 {
1745 AddTSRsp.TSDelay.delay = 10;
1746 AddTSRsp.TSDelay.present = 1;
1747 }
1748 }
1749
1750 if ( pAddTS->wsmTspecPresent )
1751 {
1752 PopulateDot11fWMMTSPEC( &pAddTS->tspec, &AddTSRsp.WMMTSPEC );
1753 }
1754 else
1755 {
1756 PopulateDot11fTSPEC( &pAddTS->tspec, &AddTSRsp.TSPEC );
1757 }
1758
1759 if ( pAddTS->wsmTspecPresent )
1760 {
1761 AddTSRsp.num_WMMTCLAS = 0;
1762 AddTSRsp.num_TCLAS = pAddTS->numTclas;
1763 for ( i = 0; i < AddTSRsp.num_TCLAS; ++i)
1764 {
1765 PopulateDot11fTCLAS( pMac, &pAddTS->tclasInfo[i],
1766 &AddTSRsp.TCLAS[i] );
1767 }
1768 }
1769 else
1770 {
1771 AddTSRsp.num_TCLAS = 0;
1772 AddTSRsp.num_WMMTCLAS = pAddTS->numTclas;
1773 for ( i = 0; i < AddTSRsp.num_WMMTCLAS; ++i)
1774 {
1775 PopulateDot11fWMMTCLAS( pMac, &pAddTS->tclasInfo[i],
1776 &AddTSRsp.WMMTCLAS[i] );
1777 }
1778 }
1779
1780 if ( pAddTS->tclasProcPresent )
1781 {
1782 if ( pAddTS->wsmTspecPresent )
1783 {
1784 AddTSRsp.WMMTCLASPROC.version = 1;
1785 AddTSRsp.WMMTCLASPROC.processing = pAddTS->tclasProc;
1786 AddTSRsp.WMMTCLASPROC.present = 1;
1787 }
1788 else
1789 {
1790 AddTSRsp.TCLASSPROC.processing = pAddTS->tclasProc;
1791 AddTSRsp.TCLASSPROC.present = 1;
1792 }
1793 }
1794
1795 // schedule element is included only if requested in the tspec and we are
1796 // using hcca (or both edca and hcca)
1797 // 11e-D8.0 is inconsistent on whether the schedule element is included
1798 // based on tspec schedule bit or not. Sec 7.4.2.2. says one thing but
1799 // pg 46, line 17-18 says something else. So just include it and let the
1800 // sta figure it out
1801 if ((pSchedule != NULL) &&
1802 ((pAddTS->tspec.tsinfo.traffic.accessPolicy == SIR_MAC_ACCESSPOLICY_HCCA) ||
1803 (pAddTS->tspec.tsinfo.traffic.accessPolicy == SIR_MAC_ACCESSPOLICY_BOTH)))
1804 {
1805 if ( pAddTS->wsmTspecPresent )
1806 {
1807 PopulateDot11fWMMSchedule( pSchedule, &AddTSRsp.WMMSchedule );
1808 }
1809 else
1810 {
1811 PopulateDot11fSchedule( pSchedule, &AddTSRsp.Schedule );
1812 }
1813 }
1814
1815 nStatus = dot11fGetPackedAddTSResponseSize( pMac, &AddTSRsp, &nPayload );
1816 if ( DOT11F_FAILED( nStatus ) )
1817 {
1818 limLog( pMac, LOGP, FL("Failed to calculate the packed si"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001819 "ze for an Add TS Response (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001820 nStatus );
1821 // We'll fall back on the worst case scenario:
1822 nPayload = sizeof( tDot11fAddTSResponse );
1823 }
1824 else if ( DOT11F_WARNED( nStatus ) )
1825 {
1826 limLog( pMac, LOGW, FL("There were warnings while calcula"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001827 "ting the packed size for an Add TS"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001828 " Response (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001829 }
1830 }
1831 else
1832 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301833 vos_mem_set( ( tANI_U8* )&WMMAddTSRsp, sizeof( WMMAddTSRsp ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07001834
1835 WMMAddTSRsp.Category.category = SIR_MAC_ACTION_WME;
1836 WMMAddTSRsp.Action.action = SIR_MAC_QOS_ADD_TS_RSP;
1837 WMMAddTSRsp.DialogToken.token = pAddTS->dialogToken;
1838 WMMAddTSRsp.StatusCode.statusCode = (tANI_U8)nStatusCode;
1839
1840 PopulateDot11fWMMTSPEC( &pAddTS->tspec, &WMMAddTSRsp.WMMTSPEC );
1841
1842 nStatus = dot11fGetPackedWMMAddTSResponseSize( pMac, &WMMAddTSRsp, &nPayload );
1843 if ( DOT11F_FAILED( nStatus ) )
1844 {
1845 limLog( pMac, LOGP, FL("Failed to calculate the packed si"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001846 "ze for a WMM Add TS Response (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001847 nStatus );
1848 // We'll fall back on the worst case scenario:
1849 nPayload = sizeof( tDot11fWMMAddTSResponse );
1850 }
1851 else if ( DOT11F_WARNED( nStatus ) )
1852 {
1853 limLog( pMac, LOGW, FL("There were warnings while calcula"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001854 "ting the packed size for a WMM Add"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001855 "TS Response (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001856 }
1857 }
1858
1859 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
1860
1861 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
1862 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1863 {
1864 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for an Ad"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001865 "d TS Response."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07001866 return;
1867 }
1868
1869 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301870 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07001871
1872 // Next, we fill out the buffer descriptor:
1873 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
1874 SIR_MAC_MGMT_ACTION, peer,psessionEntry->selfMacAddr);
1875 if ( eSIR_SUCCESS != nSirStatus )
1876 {
1877 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001878 "tor for an Add TS Response (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001879 nSirStatus );
1880 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1881 return; // allocated!
1882 }
1883
1884 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
1885
1886
1887 #if 0
1888 if ( eSIR_SUCCESS != wlan_cfgGetStr( pMac, WNI_CFG_BSSID,
1889 ( tANI_U8* )pMacHdr->bssId, &cfgLen ) )
1890 {
1891 limLog( pMac, LOGP, FL("Failed to retrieve WNI_CFG_BSSID whil"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001892 "e sending an Add TS Response.") );
Jeff Johnson295189b2012-06-20 16:38:30 -07001893 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1894 return; // allocated!
1895 }
1896 #endif //TO SUPPORT BT-AMP
1897 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
1898
Chet Lanctot186b5732013-03-18 10:26:30 -07001899#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07001900 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07001901#endif
1902
Jeff Johnson295189b2012-06-20 16:38:30 -07001903 // That done, pack the struct:
1904 if ( ! pAddTS->wmeTspecPresent )
1905 {
1906 nStatus = dot11fPackAddTSResponse( pMac, &AddTSRsp,
1907 pFrame + sizeof( tSirMacMgmtHdr ),
1908 nPayload, &nPayload );
1909 if ( DOT11F_FAILED( nStatus ) )
1910 {
1911 limLog( pMac, LOGE, FL("Failed to pack an Add TS Response "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001912 "(0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001913 nStatus );
1914 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1915 return;
1916 }
1917 else if ( DOT11F_WARNED( nStatus ) )
1918 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001919 limLog( pMac, LOGW, FL("There were warnings while packing "
1920 "an Add TS Response (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001921 }
1922 }
1923 else
1924 {
1925 nStatus = dot11fPackWMMAddTSResponse( pMac, &WMMAddTSRsp,
1926 pFrame + sizeof( tSirMacMgmtHdr ),
1927 nPayload, &nPayload );
1928 if ( DOT11F_FAILED( nStatus ) )
1929 {
1930 limLog( pMac, LOGE, FL("Failed to pack a WMM Add TS Response "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001931 "(0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001932 nStatus );
1933 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1934 return;
1935 }
1936 else if ( DOT11F_WARNED( nStatus ) )
1937 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001938 limLog( pMac, LOGW, FL("There were warnings while packing "
1939 "a WMM Add TS Response (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001940 }
1941 }
1942
1943 PELOG1(limLog( pMac, LOG1, FL("Sending an Add TS Response (status %d) to "),
1944 nStatusCode );
1945 limPrintMacAddr( pMac, pMacHdr->da, LOG1 );)
1946
1947 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07001948 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
1949 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07001950 )
1951 {
1952 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
1953 }
1954
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05301955 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
1956 psessionEntry->peSessionId,
1957 pMacHdr->fc.subType));
Jeff Johnson295189b2012-06-20 16:38:30 -07001958 // Queue the frame in high priority WQ:
1959 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
1960 HAL_TXRX_FRM_802_11_MGMT,
1961 ANI_TXDIR_TODS,
1962 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
1963 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05301964 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
1965 psessionEntry->peSessionId,
1966 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07001967 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1968 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001969 limLog( pMac, LOGE, FL("Failed to send Add TS Response (%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001970 nSirStatus );
1971 //Pkt will be freed up by the callback
1972 }
1973
1974} // End limSendAddtsRspActionFrame.
1975
1976void
1977limSendDeltsReqActionFrame(tpAniSirGlobal pMac,
1978 tSirMacAddr peer,
1979 tANI_U8 wmmTspecPresent,
1980 tSirMacTSInfo *pTsinfo,
1981 tSirMacTspecIE *pTspecIe,
1982 tpPESession psessionEntry)
1983{
1984 tANI_U8 *pFrame;
1985 tpSirMacMgmtHdr pMacHdr;
1986 tDot11fDelTS DelTS;
1987 tDot11fWMMDelTS WMMDelTS;
1988 tSirRetStatus nSirStatus;
1989 tANI_U32 nBytes, nPayload, nStatus;
1990 void *pPacket;
1991 eHalStatus halstatus;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05301992 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001993
1994 if(NULL == psessionEntry)
1995 {
1996 return;
1997 }
1998
1999 if ( ! wmmTspecPresent )
2000 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302001 vos_mem_set( ( tANI_U8* )&DelTS, sizeof( DelTS ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07002002
2003 DelTS.Category.category = SIR_MAC_ACTION_QOS_MGMT;
2004 DelTS.Action.action = SIR_MAC_QOS_DEL_TS_REQ;
2005 PopulateDot11fTSInfo( pTsinfo, &DelTS.TSInfo );
2006
2007 nStatus = dot11fGetPackedDelTSSize( pMac, &DelTS, &nPayload );
2008 if ( DOT11F_FAILED( nStatus ) )
2009 {
2010 limLog( pMac, LOGP, FL("Failed to calculate the packed si"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002011 "ze for a Del TS (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002012 nStatus );
2013 // We'll fall back on the worst case scenario:
2014 nPayload = sizeof( tDot11fDelTS );
2015 }
2016 else if ( DOT11F_WARNED( nStatus ) )
2017 {
2018 limLog( pMac, LOGW, FL("There were warnings while calcula"
2019 "ting the packed size for a Del TS"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002020 " (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07002021 }
2022 }
2023 else
2024 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302025 vos_mem_set( ( tANI_U8* )&WMMDelTS, sizeof( WMMDelTS ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07002026
2027 WMMDelTS.Category.category = SIR_MAC_ACTION_WME;
2028 WMMDelTS.Action.action = SIR_MAC_QOS_DEL_TS_REQ;
2029 WMMDelTS.DialogToken.token = 0;
2030 WMMDelTS.StatusCode.statusCode = 0;
2031 PopulateDot11fWMMTSPEC( pTspecIe, &WMMDelTS.WMMTSPEC );
2032 nStatus = dot11fGetPackedWMMDelTSSize( pMac, &WMMDelTS, &nPayload );
2033 if ( DOT11F_FAILED( nStatus ) )
2034 {
2035 limLog( pMac, LOGP, FL("Failed to calculate the packed si"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002036 "ze for a WMM Del TS (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002037 nStatus );
2038 // We'll fall back on the worst case scenario:
2039 nPayload = sizeof( tDot11fDelTS );
2040 }
2041 else if ( DOT11F_WARNED( nStatus ) )
2042 {
2043 limLog( pMac, LOGW, FL("There were warnings while calcula"
2044 "ting the packed size for a WMM De"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002045 "l TS (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07002046 }
2047 }
2048
2049 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
2050
2051 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
2052 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
2053 {
2054 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for an Ad"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002055 "d TS Response."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07002056 return;
2057 }
2058
2059 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302060 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07002061
2062 // Next, we fill out the buffer descriptor:
2063 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
2064 SIR_MAC_MGMT_ACTION, peer,
2065 psessionEntry->selfMacAddr);
2066 if ( eSIR_SUCCESS != nSirStatus )
2067 {
2068 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002069 "tor for an Add TS Response (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002070 nSirStatus );
2071 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
2072 return; // allocated!
2073 }
2074
2075 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
2076
2077 #if 0
2078
2079 cfgLen = SIR_MAC_ADDR_LENGTH;
2080 if ( eSIR_SUCCESS != wlan_cfgGetStr( pMac, WNI_CFG_BSSID,
2081 ( tANI_U8* )pMacHdr->bssId, &cfgLen ) )
2082 {
2083 limLog( pMac, LOGP, FL("Failed to retrieve WNI_CFG_BSSID whil"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002084 "e sending an Add TS Response.") );
Jeff Johnson295189b2012-06-20 16:38:30 -07002085 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
2086 return; // allocated!
2087 }
2088 #endif //TO SUPPORT BT-AMP
2089 sirCopyMacAddr(pMacHdr->bssId, psessionEntry->bssId);
2090
Chet Lanctot186b5732013-03-18 10:26:30 -07002091#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07002092 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07002093#endif
2094
Jeff Johnson295189b2012-06-20 16:38:30 -07002095 // That done, pack the struct:
2096 if ( !wmmTspecPresent )
2097 {
2098 nStatus = dot11fPackDelTS( pMac, &DelTS,
2099 pFrame + sizeof( tSirMacMgmtHdr ),
2100 nPayload, &nPayload );
2101 if ( DOT11F_FAILED( nStatus ) )
2102 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002103 limLog( pMac, LOGE, FL("Failed to pack a Del TS frame (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002104 nStatus );
2105 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
2106 return; // allocated!
2107 }
2108 else if ( DOT11F_WARNED( nStatus ) )
2109 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08002110 limLog( pMac, LOGW, FL("There were warnings while packing "
2111 "a Del TS frame (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07002112 }
2113 }
2114 else
2115 {
2116 nStatus = dot11fPackWMMDelTS( pMac, &WMMDelTS,
2117 pFrame + sizeof( tSirMacMgmtHdr ),
2118 nPayload, &nPayload );
2119 if ( DOT11F_FAILED( nStatus ) )
2120 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002121 limLog( pMac, LOGE, FL("Failed to pack a WMM Del TS frame (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002122 nStatus );
2123 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
2124 return; // allocated!
2125 }
2126 else if ( DOT11F_WARNED( nStatus ) )
2127 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08002128 limLog( pMac, LOGW, FL("There were warnings while packing "
2129 "a WMM Del TS frame (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07002130 }
2131 }
2132
2133 PELOG1(limLog(pMac, LOG1, FL("Sending DELTS REQ (size %d) to "), nBytes);
2134 limPrintMacAddr(pMac, pMacHdr->da, LOG1);)
2135
2136 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07002137 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
2138 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07002139 )
2140 {
2141 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
2142 }
2143
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05302144 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
2145 psessionEntry->peSessionId,
2146 pMacHdr->fc.subType));
Jeff Johnson295189b2012-06-20 16:38:30 -07002147 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
2148 HAL_TXRX_FRM_802_11_MGMT,
2149 ANI_TXDIR_TODS,
2150 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
2151 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05302152 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
2153 psessionEntry->peSessionId,
2154 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07002155 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
2156 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002157 limLog( pMac, LOGE, FL("Failed to send Del TS (%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002158 nSirStatus );
2159 //Pkt will be freed up by the callback
2160 }
2161
2162} // End limSendDeltsReqActionFrame.
2163
2164void
2165limSendAssocReqMgmtFrame(tpAniSirGlobal pMac,
2166 tLimMlmAssocReq *pMlmAssocReq,
2167 tpPESession psessionEntry)
2168{
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002169 tDot11fAssocRequest *pFrm;
Jeff Johnson295189b2012-06-20 16:38:30 -07002170 tANI_U16 caps;
2171 tANI_U8 *pFrame;
2172 tSirRetStatus nSirStatus;
2173 tLimMlmAssocCnf mlmAssocCnf;
c_hpothubcd78652014-04-28 22:31:08 +05302174 tANI_U32 nPayload, nStatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07002175 tANI_U8 fQosEnabled, fWmeEnabled, fWsmEnabled;
2176 void *pPacket;
2177 eHalStatus halstatus;
2178 tANI_U16 nAddIELen;
2179 tANI_U8 *pAddIE;
2180 tANI_U8 *wpsIe = NULL;
2181#if defined WLAN_FEATURE_VOWIFI
2182 tANI_U8 PowerCapsPopulated = FALSE;
2183#endif
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05302184 tANI_U32 txFlag = 0;
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05302185 tpSirMacMgmtHdr pMacHdr;
Kalikinkar dhara205da782014-03-21 15:49:32 -07002186 tDot11fIEExtCap extractedExtCap;
2187 tANI_BOOLEAN extractedExtCapFlag = eANI_BOOLEAN_TRUE;
c_hpothubcd78652014-04-28 22:31:08 +05302188 tANI_U32 nBytes = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002189
2190 if(NULL == psessionEntry)
2191 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05302192 limLog(pMac, LOGE, FL("psessionEntry is NULL") );
Jeff Johnson295189b2012-06-20 16:38:30 -07002193 return;
2194 }
2195
Jeff Johnson295189b2012-06-20 16:38:30 -07002196 /* check this early to avoid unncessary operation */
2197 if(NULL == psessionEntry->pLimJoinReq)
2198 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05302199 limLog(pMac, LOGE, FL("psessionEntry->pLimJoinReq is NULL") );
Jeff Johnson295189b2012-06-20 16:38:30 -07002200 return;
2201 }
2202 nAddIELen = psessionEntry->pLimJoinReq->addIEAssoc.length;
2203 pAddIE = psessionEntry->pLimJoinReq->addIEAssoc.addIEdata;
2204
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302205 pFrm = vos_mem_malloc(sizeof(tDot11fAssocRequest));
2206 if ( NULL == pFrm )
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002207 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05302208 limLog(pMac, LOGE, FL("Unable to allocate memory") );
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002209 return;
2210 }
2211
2212
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302213 vos_mem_set( ( tANI_U8* )pFrm, sizeof( tDot11fAssocRequest ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07002214
Kalikinkar dhara205da782014-03-21 15:49:32 -07002215 vos_mem_set(( tANI_U8* )&extractedExtCap, sizeof( tDot11fIEExtCap ), 0);
2216 nSirStatus = limStripOffExtCapIEAndUpdateStruct(pMac, pAddIE,
2217 &nAddIELen,
2218 &extractedExtCap );
2219 if(eSIR_SUCCESS != nSirStatus )
2220 {
2221 extractedExtCapFlag = eANI_BOOLEAN_FALSE;
2222 limLog(pMac, LOG1,
2223 FL("Unable to Stripoff ExtCap IE from Assoc Req"));
2224 }
Leela Venkata Kiran Kumar Reddy Chirala2f9b5712014-05-06 00:09:42 -07002225 /* TODO:remove this code once driver provides the call back function
2226 * to supplicant for set_qos_map
2227 */
2228 else
2229 {
2230 if(extractedExtCap.interworkingService)
2231 {
2232 extractedExtCap.qosMap = 1;
2233 }
2234 }
Kalikinkar dhara205da782014-03-21 15:49:32 -07002235
Jeff Johnson295189b2012-06-20 16:38:30 -07002236 caps = pMlmAssocReq->capabilityInfo;
2237 if ( PROP_CAPABILITY_GET( 11EQOS, psessionEntry->limCurrentBssPropCap ) )
2238 ((tSirMacCapabilityInfo *) &caps)->qos = 0;
2239#if defined(FEATURE_WLAN_WAPI)
2240 /* CR: 262463 :
2241 According to WAPI standard:
2242 7.3.1.4 Capability Information field
2243 In WAPI, non-AP STAs within an ESS set the Privacy subfield to 0 in transmitted
2244 Association or Reassociation management frames. APs ignore the Privacy subfield within received Association and
2245 Reassociation management frames. */
2246 if ( psessionEntry->encryptType == eSIR_ED_WPI)
2247 ((tSirMacCapabilityInfo *) &caps)->privacy = 0;
2248#endif
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002249 swapBitField16(caps, ( tANI_U16* )&pFrm->Capabilities );
Jeff Johnson295189b2012-06-20 16:38:30 -07002250
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002251 pFrm->ListenInterval.interval = pMlmAssocReq->listenInterval;
2252 PopulateDot11fSSID2( pMac, &pFrm->SSID );
Jeff Johnson295189b2012-06-20 16:38:30 -07002253 PopulateDot11fSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002254 &pFrm->SuppRates,psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07002255
2256 fQosEnabled = ( psessionEntry->limQosEnabled) &&
2257 SIR_MAC_GET_QOS( psessionEntry->limCurrentBssCaps );
2258
2259 fWmeEnabled = ( psessionEntry->limWmeEnabled ) &&
2260 LIM_BSS_CAPS_GET( WME, psessionEntry->limCurrentBssQosCaps );
2261
2262 // We prefer .11e asociations:
2263 if ( fQosEnabled ) fWmeEnabled = false;
2264
2265 fWsmEnabled = ( psessionEntry->limWsmEnabled ) && fWmeEnabled &&
2266 LIM_BSS_CAPS_GET( WSM, psessionEntry->limCurrentBssQosCaps );
2267
2268 if ( psessionEntry->lim11hEnable &&
2269 psessionEntry->pLimJoinReq->spectrumMgtIndicator == eSIR_TRUE )
2270 {
2271#if defined WLAN_FEATURE_VOWIFI
2272 PowerCapsPopulated = TRUE;
2273
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002274 PopulateDot11fPowerCaps( pMac, &pFrm->PowerCaps, LIM_ASSOC,psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07002275#endif
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002276 PopulateDot11fSuppChannels( pMac, &pFrm->SuppChannels, LIM_ASSOC,psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07002277
2278 }
2279
2280#if defined WLAN_FEATURE_VOWIFI
2281 if( pMac->rrm.rrmPEContext.rrmEnable &&
2282 SIR_MAC_GET_RRM( psessionEntry->limCurrentBssCaps ) )
2283 {
2284 if (PowerCapsPopulated == FALSE)
2285 {
2286 PowerCapsPopulated = TRUE;
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002287 PopulateDot11fPowerCaps(pMac, &pFrm->PowerCaps, LIM_ASSOC, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07002288 }
2289 }
2290#endif
2291
2292 if ( fQosEnabled &&
2293 ( ! PROP_CAPABILITY_GET(11EQOS, psessionEntry->limCurrentBssPropCap)))
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002294 PopulateDot11fQOSCapsStation( pMac, &pFrm->QOSCapsStation );
Jeff Johnson295189b2012-06-20 16:38:30 -07002295
2296 PopulateDot11fExtSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002297 &pFrm->ExtSuppRates, psessionEntry );
Jeff Johnson295189b2012-06-20 16:38:30 -07002298
2299#if defined WLAN_FEATURE_VOWIFI
2300 if( pMac->rrm.rrmPEContext.rrmEnable &&
2301 SIR_MAC_GET_RRM( psessionEntry->limCurrentBssCaps ) )
2302 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002303 PopulateDot11fRRMIe( pMac, &pFrm->RRMEnabledCap, psessionEntry );
Jeff Johnson295189b2012-06-20 16:38:30 -07002304 }
2305#endif
2306 // The join request *should* contain zero or one of the WPA and RSN
2307 // IEs. The payload send along with the request is a
2308 // 'tSirSmeJoinReq'; the IE portion is held inside a 'tSirRSNie':
2309
2310 // typedef struct sSirRSNie
2311 // {
2312 // tANI_U16 length;
2313 // tANI_U8 rsnIEdata[SIR_MAC_MAX_IE_LENGTH+2];
2314 // } tSirRSNie, *tpSirRSNie;
2315
2316 // So, we should be able to make the following two calls harmlessly,
2317 // since they do nothing if they don't find the given IE in the
2318 // bytestream with which they're provided.
2319
2320 // The net effect of this will be to faithfully transmit whatever
2321 // security IE is in the join request.
2322
2323 // *However*, if we're associating for the purpose of WPS
2324 // enrollment, and we've been configured to indicate that by
2325 // eliding the WPA or RSN IE, we just skip this:
2326 if( nAddIELen && pAddIE )
2327 {
2328 wpsIe = limGetWscIEPtr (pMac, pAddIE, nAddIELen);
2329 }
2330 if ( NULL == wpsIe )
2331 {
2332 PopulateDot11fRSNOpaque( pMac, &( psessionEntry->pLimJoinReq->rsnIE ),
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002333 &pFrm->RSNOpaque );
Jeff Johnson295189b2012-06-20 16:38:30 -07002334 PopulateDot11fWPAOpaque( pMac, &( psessionEntry->pLimJoinReq->rsnIE ),
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002335 &pFrm->WPAOpaque );
Jeff Johnson295189b2012-06-20 16:38:30 -07002336#if defined(FEATURE_WLAN_WAPI)
2337 PopulateDot11fWAPIOpaque( pMac, &( psessionEntry->pLimJoinReq->rsnIE ),
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002338 &pFrm->WAPIOpaque );
Jeff Johnson295189b2012-06-20 16:38:30 -07002339#endif // defined(FEATURE_WLAN_WAPI)
2340 }
2341
2342 // include WME EDCA IE as well
2343 if ( fWmeEnabled )
2344 {
2345 if ( ! PROP_CAPABILITY_GET( WME, psessionEntry->limCurrentBssPropCap ) )
2346 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002347 PopulateDot11fWMMInfoStation( pMac, &pFrm->WMMInfoStation );
Jeff Johnson295189b2012-06-20 16:38:30 -07002348 }
2349
2350 if ( fWsmEnabled &&
2351 ( ! PROP_CAPABILITY_GET(WSM, psessionEntry->limCurrentBssPropCap )))
2352 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002353 PopulateDot11fWMMCaps( &pFrm->WMMCaps );
Jeff Johnson295189b2012-06-20 16:38:30 -07002354 }
2355 }
2356
2357 //Populate HT IEs, when operating in 11n or Taurus modes AND
2358 //when AP is also operating in 11n mode.
Jeff Johnsone7245742012-09-05 17:12:55 -07002359 if ( psessionEntry->htCapability &&
Jeff Johnson295189b2012-06-20 16:38:30 -07002360 pMac->lim.htCapabilityPresentInBeacon)
2361 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002362 PopulateDot11fHTCaps( pMac, psessionEntry, &pFrm->HTCaps );
Jeff Johnson295189b2012-06-20 16:38:30 -07002363#ifdef DISABLE_GF_FOR_INTEROP
2364
2365 /*
2366 * To resolve the interop problem with Broadcom AP,
2367 * where TQ STA could not pass traffic with GF enabled,
2368 * TQ STA will do Greenfield only with TQ AP, for
2369 * everybody else it will be turned off.
2370 */
2371
2372 if( (psessionEntry->pLimJoinReq != NULL) && (!psessionEntry->pLimJoinReq->bssDescription.aniIndicator))
2373 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05302374 limLog( pMac, LOG1, FL("Sending Assoc Req to Non-TQ AP,"
2375 " Turning off Greenfield"));
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002376 pFrm->HTCaps.greenField = WNI_CFG_GREENFIELD_CAPABILITY_DISABLE;
Jeff Johnson295189b2012-06-20 16:38:30 -07002377 }
2378#endif
2379
2380 }
Jeff Johnsone7245742012-09-05 17:12:55 -07002381#ifdef WLAN_FEATURE_11AC
2382 if ( psessionEntry->vhtCapability &&
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07002383 psessionEntry->vhtCapabilityPresentInBeacon)
Jeff Johnsone7245742012-09-05 17:12:55 -07002384 {
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07002385 limLog( pMac, LOG1, FL("Populate VHT IEs in Assoc Request"));
Abhishek Singh6d5d29c2014-07-03 14:25:22 +05302386 PopulateDot11fVHTCaps( pMac, &pFrm->VHTCaps, eSIR_FALSE );
Jeff Johnsone7245742012-09-05 17:12:55 -07002387 }
2388#endif
Sandeep Puligilla60342762014-01-30 21:05:37 +05302389 PopulateDot11fExtCap( pMac, &pFrm->ExtCap, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07002390
2391#if defined WLAN_FEATURE_VOWIFI_11R
2392 if (psessionEntry->pLimJoinReq->is11Rconnection)
2393 {
2394#if defined WLAN_FEATURE_VOWIFI_11R_DEBUG
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002395 limLog( pMac, LOG1, FL("mdie = %02x %02x %02x"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002396 (unsigned int)psessionEntry->pLimJoinReq->bssDescription.mdie[0],
2397 (unsigned int)psessionEntry->pLimJoinReq->bssDescription.mdie[1],
2398 (unsigned int)psessionEntry->pLimJoinReq->bssDescription.mdie[2]);
2399#endif
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302400 PopulateMDIE( pMac, &pFrm->MobilityDomain,
2401 psessionEntry->pLimJoinReq->bssDescription.mdie);
Jeff Johnson295189b2012-06-20 16:38:30 -07002402 }
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302403 else
Jeff Johnson295189b2012-06-20 16:38:30 -07002404 {
2405 // No 11r IEs dont send any MDIE
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302406 limLog( pMac, LOG1, FL("MDIE not present"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002407 }
2408#endif
2409
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002410#ifdef FEATURE_WLAN_ESE
2411 /* For ESE Associations fill the ESE IEs */
2412 if (psessionEntry->isESEconnection &&
2413 psessionEntry->pLimJoinReq->isESEFeatureIniEnabled)
Jeff Johnson295189b2012-06-20 16:38:30 -07002414 {
Varun Reddy Yeturu30779b42013-04-09 09:57:16 -07002415#ifndef FEATURE_DISABLE_RM
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002416 PopulateDot11fESERadMgmtCap(&pFrm->ESERadMgmtCap);
Varun Reddy Yeturu30779b42013-04-09 09:57:16 -07002417#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002418 PopulateDot11fESEVersion(&pFrm->ESEVersion);
Jeff Johnson295189b2012-06-20 16:38:30 -07002419 }
2420#endif
2421
c_hpothubcd78652014-04-28 22:31:08 +05302422 /* merge the ExtCap struct*/
2423 if (extractedExtCapFlag && extractedExtCap.present)
2424 {
2425 limMergeExtCapIEStruct(&pFrm->ExtCap, &extractedExtCap);
2426 }
2427
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002428 nStatus = dot11fGetPackedAssocRequestSize( pMac, pFrm, &nPayload );
Jeff Johnson295189b2012-06-20 16:38:30 -07002429 if ( DOT11F_FAILED( nStatus ) )
2430 {
2431 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002432 "or an Association Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002433 nStatus );
2434 // We'll fall back on the worst case scenario:
2435 nPayload = sizeof( tDot11fAssocRequest );
2436 }
2437 else if ( DOT11F_WARNED( nStatus ) )
2438 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08002439 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07002440 "the packed size for an Association Re "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002441 "quest(0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07002442 }
2443
2444 nBytes = nPayload + sizeof( tSirMacMgmtHdr ) + nAddIELen;
2445
2446 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
2447 ( tANI_U16 )nBytes, ( void** ) &pFrame,
2448 ( void** ) &pPacket );
2449 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
2450 {
2451 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for an As"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002452 "sociation Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07002453
2454 psessionEntry->limMlmState = psessionEntry->limPrevMlmState;
Jeff Johnsone7245742012-09-05 17:12:55 -07002455 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07002456
2457
2458 /* Update PE session id*/
2459 mlmAssocCnf.sessionId = psessionEntry->peSessionId;
2460
2461 mlmAssocCnf.resultCode = eSIR_SME_RESOURCES_UNAVAILABLE;
2462
2463 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
2464 ( void* ) pFrame, ( void* ) pPacket );
2465
2466 limPostSmeMessage( pMac, LIM_MLM_ASSOC_CNF,
2467 ( tANI_U32* ) &mlmAssocCnf);
2468
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302469 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -07002470 return;
2471 }
2472
2473 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302474 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07002475
2476 // Next, we fill out the buffer descriptor:
2477 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
2478 SIR_MAC_MGMT_ASSOC_REQ, psessionEntry->bssId,psessionEntry->selfMacAddr);
2479 if ( eSIR_SUCCESS != nSirStatus )
2480 {
2481 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002482 "tor for an Association Request (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002483 nSirStatus );
2484 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302485 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -07002486 return;
2487 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002488
Abhishek Singh57aebef2014-02-03 18:47:44 +05302489 // That done, pack the Assoc Request:
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002490 nStatus = dot11fPackAssocRequest( pMac, pFrm, pFrame +
Jeff Johnson295189b2012-06-20 16:38:30 -07002491 sizeof(tSirMacMgmtHdr),
2492 nPayload, &nPayload );
2493 if ( DOT11F_FAILED( nStatus ) )
2494 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05302495 limLog( pMac, LOGE, FL("Failed to pack a Assoc Request (0x%0"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002496 "8x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002497 nStatus );
2498 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
2499 ( void* ) pFrame, ( void* ) pPacket );
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302500 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -07002501 return;
2502 }
2503 else if ( DOT11F_WARNED( nStatus ) )
2504 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05302505 limLog( pMac, LOGW, FL("There were warnings while packing a Assoc"
2506 "Request (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07002507 }
2508
2509 PELOG1(limLog( pMac, LOG1, FL("*** Sending Association Request length %d"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002510 "to "),
Jeff Johnson295189b2012-06-20 16:38:30 -07002511 nBytes );)
2512 // limPrintMacAddr( pMac, bssid, LOG1 );
2513
2514 if( psessionEntry->assocReq != NULL )
2515 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302516 vos_mem_free(psessionEntry->assocReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07002517 psessionEntry->assocReq = NULL;
2518 }
2519
2520 if( nAddIELen )
2521 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302522 vos_mem_copy( pFrame + sizeof(tSirMacMgmtHdr) + nPayload,
2523 pAddIE,
2524 nAddIELen );
Jeff Johnson295189b2012-06-20 16:38:30 -07002525 nPayload += nAddIELen;
2526 }
2527
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302528 psessionEntry->assocReq = vos_mem_malloc(nPayload);
2529 if ( NULL == psessionEntry->assocReq )
Jeff Johnson295189b2012-06-20 16:38:30 -07002530 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05302531 PELOGE(limLog(pMac, LOGE, FL("Unable to allocate memory to store "
2532 "assoc request"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07002533 }
2534 else
2535 {
2536 //Store the Assoc request. This is sent to csr/hdd in join cnf response.
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302537 vos_mem_copy( psessionEntry->assocReq, pFrame + sizeof(tSirMacMgmtHdr), nPayload);
Jeff Johnson295189b2012-06-20 16:38:30 -07002538 psessionEntry->assocReqLen = nPayload;
2539 }
2540
2541 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07002542 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
2543 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07002544 )
2545 {
2546 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
2547 }
2548
Ganesh K08bce952012-12-13 15:04:41 -08002549 if(psessionEntry->pePersona == VOS_P2P_CLIENT_MODE)
2550 {
2551 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
2552 }
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05302553
2554 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
Agarwal Ashisha8e81f52014-04-02 01:59:52 +05302555 limLog( pMac, LOG1, FL("Sending Assoc req over WQ5 to "MAC_ADDRESS_STR
2556 " From " MAC_ADDRESS_STR),MAC_ADDR_ARRAY(pMacHdr->da),
2557 MAC_ADDR_ARRAY(psessionEntry->selfMacAddr));
2558 txFlag |= HAL_USE_FW_IN_TX_PATH;
2559
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05302560 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
2561 psessionEntry->peSessionId,
2562 pMacHdr->fc.subType));
Katya Nigam63902932014-06-26 19:04:23 +05302563
2564 // enable caching
2565 WLANTL_EnableCaching(psessionEntry->staId);
2566
Jeff Johnson295189b2012-06-20 16:38:30 -07002567 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) (sizeof(tSirMacMgmtHdr) + nPayload),
2568 HAL_TXRX_FRM_802_11_MGMT,
2569 ANI_TXDIR_TODS,
2570 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
2571 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05302572 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
2573 psessionEntry->peSessionId,
2574 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07002575 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
2576 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002577 limLog( pMac, LOGE, FL("Failed to send Association Request (%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002578 halstatus );
2579 //Pkt will be freed up by the callback
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302580 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -07002581 return;
2582 }
2583
2584 // Free up buffer allocated for mlmAssocReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302585 vos_mem_free(pMlmAssocReq);
Leela Venkata Kiran Kumar Reddy Chiralad6c0fe22013-12-11 19:10:50 -08002586 pMlmAssocReq = NULL;
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302587 vos_mem_free(pFrm);
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002588 return;
Jeff Johnson295189b2012-06-20 16:38:30 -07002589} // End limSendAssocReqMgmtFrame
2590
2591
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002592#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07002593/*------------------------------------------------------------------------------------
2594 *
2595 * Send Reassoc Req with FTIEs.
2596 *
2597 *-----------------------------------------------------------------------------------
2598 */
2599void
2600limSendReassocReqWithFTIEsMgmtFrame(tpAniSirGlobal pMac,
2601 tLimMlmReassocReq *pMlmReassocReq,tpPESession psessionEntry)
2602{
2603 static tDot11fReAssocRequest frm;
2604 tANI_U16 caps;
2605 tANI_U8 *pFrame;
2606 tSirRetStatus nSirStatus;
2607 tANI_U32 nBytes, nPayload, nStatus;
2608 tANI_U8 fQosEnabled, fWmeEnabled, fWsmEnabled;
2609 void *pPacket;
2610 eHalStatus halstatus;
2611#if defined WLAN_FEATURE_VOWIFI
2612 tANI_U8 PowerCapsPopulated = FALSE;
2613#endif
2614 tANI_U16 ft_ies_length = 0;
2615 tANI_U8 *pBody;
2616 tANI_U16 nAddIELen;
2617 tANI_U8 *pAddIE;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002618#if defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07002619 tANI_U8 *wpsIe = NULL;
2620#endif
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05302621 tANI_U32 txFlag = 0;
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05302622 tpSirMacMgmtHdr pMacHdr;
Jeff Johnson295189b2012-06-20 16:38:30 -07002623
2624 if (NULL == psessionEntry)
2625 {
2626 return;
2627 }
2628
Jeff Johnson295189b2012-06-20 16:38:30 -07002629 /* check this early to avoid unncessary operation */
2630 if(NULL == psessionEntry->pLimReAssocReq)
2631 {
2632 return;
2633 }
2634 nAddIELen = psessionEntry->pLimReAssocReq->addIEAssoc.length;
2635 pAddIE = psessionEntry->pLimReAssocReq->addIEAssoc.addIEdata;
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08002636 limLog( pMac, LOG1, FL("limSendReassocReqWithFTIEsMgmtFrame received in "
2637 "state (%d)."), psessionEntry->limMlmState);
Jeff Johnson295189b2012-06-20 16:38:30 -07002638
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302639 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07002640
2641 caps = pMlmReassocReq->capabilityInfo;
2642 if (PROP_CAPABILITY_GET(11EQOS, psessionEntry->limReassocBssPropCap))
2643 ((tSirMacCapabilityInfo *) &caps)->qos = 0;
2644#if defined(FEATURE_WLAN_WAPI)
2645 /* CR: 262463 :
2646 According to WAPI standard:
2647 7.3.1.4 Capability Information field
2648 In WAPI, non-AP STAs within an ESS set the Privacy subfield to 0 in transmitted
2649 Association or Reassociation management frames. APs ignore the Privacy subfield within received Association and
2650 Reassociation management frames. */
2651 if ( psessionEntry->encryptType == eSIR_ED_WPI)
2652 ((tSirMacCapabilityInfo *) &caps)->privacy = 0;
2653#endif
2654 swapBitField16(caps, ( tANI_U16* )&frm.Capabilities );
2655
2656 frm.ListenInterval.interval = pMlmReassocReq->listenInterval;
2657
2658 // Get the old bssid of the older AP.
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302659 vos_mem_copy( ( tANI_U8* )frm.CurrentAPAddress.mac,
Jeff Johnson295189b2012-06-20 16:38:30 -07002660 pMac->ft.ftPEContext.pFTPreAuthReq->currbssId, 6);
2661
2662 PopulateDot11fSSID2( pMac, &frm.SSID );
2663 PopulateDot11fSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
2664 &frm.SuppRates,psessionEntry);
2665
2666 fQosEnabled = ( psessionEntry->limQosEnabled) &&
2667 SIR_MAC_GET_QOS( psessionEntry->limReassocBssCaps );
2668
2669 fWmeEnabled = ( psessionEntry->limWmeEnabled ) &&
2670 LIM_BSS_CAPS_GET( WME, psessionEntry->limReassocBssQosCaps );
2671
2672 fWsmEnabled = ( psessionEntry->limWsmEnabled ) && fWmeEnabled &&
2673 LIM_BSS_CAPS_GET( WSM, psessionEntry->limReassocBssQosCaps );
2674
2675 if ( psessionEntry->lim11hEnable &&
2676 psessionEntry->pLimReAssocReq->spectrumMgtIndicator == eSIR_TRUE )
2677 {
2678#if defined WLAN_FEATURE_VOWIFI
2679 PowerCapsPopulated = TRUE;
2680
2681 PopulateDot11fPowerCaps( pMac, &frm.PowerCaps, LIM_REASSOC,psessionEntry);
2682 PopulateDot11fSuppChannels( pMac, &frm.SuppChannels, LIM_REASSOC,psessionEntry);
2683#endif
2684 }
2685
2686#if defined WLAN_FEATURE_VOWIFI
2687 if( pMac->rrm.rrmPEContext.rrmEnable &&
2688 SIR_MAC_GET_RRM( psessionEntry->limCurrentBssCaps ) )
2689 {
2690 if (PowerCapsPopulated == FALSE)
2691 {
2692 PowerCapsPopulated = TRUE;
2693 PopulateDot11fPowerCaps(pMac, &frm.PowerCaps, LIM_REASSOC, psessionEntry);
2694 }
2695 }
2696#endif
2697
2698 if ( fQosEnabled &&
2699 ( ! PROP_CAPABILITY_GET(11EQOS, psessionEntry->limReassocBssPropCap ) ))
2700 {
2701 PopulateDot11fQOSCapsStation( pMac, &frm.QOSCapsStation );
2702 }
2703
2704 PopulateDot11fExtSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
2705 &frm.ExtSuppRates, psessionEntry );
2706
2707#if defined WLAN_FEATURE_VOWIFI
2708 if( pMac->rrm.rrmPEContext.rrmEnable &&
2709 SIR_MAC_GET_RRM( psessionEntry->limReassocBssCaps ) )
2710 {
2711 PopulateDot11fRRMIe( pMac, &frm.RRMEnabledCap, psessionEntry );
2712 }
2713#endif
2714
2715 // Ideally this should be enabled for 11r also. But 11r does
2716 // not follow the usual norm of using the Opaque object
2717 // for rsnie and fties. Instead we just add
2718 // the rsnie and fties at the end of the pack routine for 11r.
2719 // This should ideally! be fixed.
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002720#if defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07002721 //
2722 // The join request *should* contain zero or one of the WPA and RSN
2723 // IEs. The payload send along with the request is a
2724 // 'tSirSmeJoinReq'; the IE portion is held inside a 'tSirRSNie':
2725
2726 // typedef struct sSirRSNie
2727 // {
2728 // tANI_U16 length;
2729 // tANI_U8 rsnIEdata[SIR_MAC_MAX_IE_LENGTH+2];
2730 // } tSirRSNie, *tpSirRSNie;
2731
2732 // So, we should be able to make the following two calls harmlessly,
2733 // since they do nothing if they don't find the given IE in the
2734 // bytestream with which they're provided.
2735
2736 // The net effect of this will be to faithfully transmit whatever
2737 // security IE is in the join request.
2738
2739 // *However*, if we're associating for the purpose of WPS
2740 // enrollment, and we've been configured to indicate that by
2741 // eliding the WPA or RSN IE, we just skip this:
2742 if (!psessionEntry->is11Rconnection)
2743 {
2744 if( nAddIELen && pAddIE )
2745 {
2746 wpsIe = limGetWscIEPtr(pMac, pAddIE, nAddIELen);
2747 }
2748 if ( NULL == wpsIe )
2749 {
2750 PopulateDot11fRSNOpaque( pMac, &( psessionEntry->pLimReAssocReq->rsnIE ),
2751 &frm.RSNOpaque );
2752 PopulateDot11fWPAOpaque( pMac, &( psessionEntry->pLimReAssocReq->rsnIE ),
2753 &frm.WPAOpaque );
2754 }
2755
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002756#ifdef FEATURE_WLAN_ESE
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302757 if (psessionEntry->pLimReAssocReq->cckmIE.length)
Jeff Johnson295189b2012-06-20 16:38:30 -07002758 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002759 PopulateDot11fESECckmOpaque( pMac, &( psessionEntry->pLimReAssocReq->cckmIE ),
2760 &frm.ESECckmOpaque );
Jeff Johnson295189b2012-06-20 16:38:30 -07002761 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002762#endif //FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07002763 }
2764
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002765#ifdef FEATURE_WLAN_ESE
2766 // For ESE Associations fill the ESE IEs
2767 if (psessionEntry->isESEconnection &&
2768 psessionEntry->pLimReAssocReq->isESEFeatureIniEnabled)
Jeff Johnson295189b2012-06-20 16:38:30 -07002769 {
Varun Reddy Yeturu30779b42013-04-09 09:57:16 -07002770#ifndef FEATURE_DISABLE_RM
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002771 PopulateDot11fESERadMgmtCap(&frm.ESERadMgmtCap);
Varun Reddy Yeturu30779b42013-04-09 09:57:16 -07002772#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002773 PopulateDot11fESEVersion(&frm.ESEVersion);
Jeff Johnson295189b2012-06-20 16:38:30 -07002774 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002775#endif //FEATURE_WLAN_ESE
2776#endif //FEATURE_WLAN_ESE || FEATURE_WLAN_LFR
Jeff Johnson295189b2012-06-20 16:38:30 -07002777
2778 // include WME EDCA IE as well
2779 if ( fWmeEnabled )
2780 {
2781 if ( ! PROP_CAPABILITY_GET( WME, psessionEntry->limReassocBssPropCap ) )
2782 {
2783 PopulateDot11fWMMInfoStation( pMac, &frm.WMMInfoStation );
2784 }
2785
2786 if ( fWsmEnabled &&
2787 ( ! PROP_CAPABILITY_GET(WSM, psessionEntry->limReassocBssPropCap )))
2788 {
2789 PopulateDot11fWMMCaps( &frm.WMMCaps );
2790 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002791#ifdef FEATURE_WLAN_ESE
2792 if (psessionEntry->isESEconnection)
Jeff Johnson295189b2012-06-20 16:38:30 -07002793 {
2794 PopulateDot11fReAssocTspec(pMac, &frm, psessionEntry);
2795
2796 // Populate the TSRS IE if TSPEC is included in the reassoc request
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002797 if (psessionEntry->pLimReAssocReq->eseTspecInfo.numTspecs)
Jeff Johnson295189b2012-06-20 16:38:30 -07002798 {
2799 tANI_U32 phyMode;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002800 tSirMacESETSRSIE tsrsIE;
Jeff Johnson295189b2012-06-20 16:38:30 -07002801 limGetPhyMode(pMac, &phyMode, psessionEntry);
2802
2803 tsrsIE.tsid = 0;
2804 if( phyMode == WNI_CFG_PHY_MODE_11G || phyMode == WNI_CFG_PHY_MODE_11A)
2805 {
2806 tsrsIE.rates[0] = TSRS_11AG_RATE_6MBPS;
2807 }
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302808 else
Jeff Johnson295189b2012-06-20 16:38:30 -07002809 {
2810 tsrsIE.rates[0] = TSRS_11B_RATE_5_5MBPS;
2811 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002812 PopulateDot11TSRSIE(pMac,&tsrsIE, &frm.ESETrafStrmRateSet, sizeof(tANI_U8));
Jeff Johnson295189b2012-06-20 16:38:30 -07002813 }
2814 }
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302815#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002816 }
2817
Jeff Johnsone7245742012-09-05 17:12:55 -07002818 if ( psessionEntry->htCapability &&
Jeff Johnson295189b2012-06-20 16:38:30 -07002819 pMac->lim.htCapabilityPresentInBeacon)
2820 {
Jeff Johnsone7245742012-09-05 17:12:55 -07002821 PopulateDot11fHTCaps( pMac, psessionEntry, &frm.HTCaps );
Jeff Johnson295189b2012-06-20 16:38:30 -07002822 }
2823
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08002824#if defined WLAN_FEATURE_VOWIFI_11R
Kanchanapally, Vidyullatha4f84f682014-04-29 20:40:34 +05302825 if ( psessionEntry->pLimReAssocReq->bssDescription.mdiePresent &&
2826 (pMac->ft.ftSmeContext.addMDIE == TRUE)
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002827#if defined FEATURE_WLAN_ESE
2828 && !psessionEntry->isESEconnection
Gopichand Nakkala0ac55062013-04-08 14:43:07 +05302829#endif
2830 )
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08002831 {
2832 PopulateMDIE( pMac, &frm.MobilityDomain, psessionEntry->pLimReAssocReq->bssDescription.mdie);
2833 }
2834#endif
2835
Chet Lanctotf19c1f62013-12-13 13:56:21 -08002836#ifdef WLAN_FEATURE_11AC
2837 if ( psessionEntry->vhtCapability &&
2838 psessionEntry->vhtCapabilityPresentInBeacon)
2839 {
2840 limLog( pMac, LOG1, FL("Populate VHT IEs in Re-Assoc Request"));
Abhishek Singh6d5d29c2014-07-03 14:25:22 +05302841 PopulateDot11fVHTCaps( pMac, &frm.VHTCaps, eSIR_FALSE );
Chet Lanctotf19c1f62013-12-13 13:56:21 -08002842 }
2843#endif
Sandeep Puligilla60342762014-01-30 21:05:37 +05302844 PopulateDot11fExtCap( pMac, &frm.ExtCap, psessionEntry);
Chet Lanctotf19c1f62013-12-13 13:56:21 -08002845
Jeff Johnson295189b2012-06-20 16:38:30 -07002846 nStatus = dot11fGetPackedReAssocRequestSize( pMac, &frm, &nPayload );
2847 if ( DOT11F_FAILED( nStatus ) )
2848 {
2849 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002850 "or a Re-Association Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002851 nStatus );
2852 // We'll fall back on the worst case scenario:
2853 nPayload = sizeof( tDot11fReAssocRequest );
2854 }
2855 else if ( DOT11F_WARNED( nStatus ) )
2856 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08002857 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07002858 "the packed size for a Re-Association Re "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002859 "quest(0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07002860 }
2861
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07002862 nBytes = nPayload + sizeof( tSirMacMgmtHdr ) + nAddIELen;
Jeff Johnson295189b2012-06-20 16:38:30 -07002863
2864#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08002865 limLog( pMac, LOG1, FL("FT IE Reassoc Req (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002866 pMac->ft.ftSmeContext.reassoc_ft_ies_length);
2867#endif
2868
2869#if defined WLAN_FEATURE_VOWIFI_11R
2870 if (psessionEntry->is11Rconnection)
2871 {
2872 ft_ies_length = pMac->ft.ftSmeContext.reassoc_ft_ies_length;
2873 }
2874#endif
2875
2876 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
2877 ( tANI_U16 )nBytes+ft_ies_length, ( void** ) &pFrame,
2878 ( void** ) &pPacket );
2879 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
2880 {
2881 psessionEntry->limMlmState = psessionEntry->limPrevMlmState;
Jeff Johnsone7245742012-09-05 17:12:55 -07002882 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07002883 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Re-As"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002884 "sociation Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07002885 goto end;
2886 }
2887
2888 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302889 vos_mem_set( pFrame, nBytes + ft_ies_length, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07002890
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002891#if defined WLAN_FEATURE_VOWIFI_11R_DEBUG || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08002892 limPrintMacAddr(pMac, psessionEntry->limReAssocbssId, LOG1);
Jeff Johnson295189b2012-06-20 16:38:30 -07002893#endif
2894 // Next, we fill out the buffer descriptor:
2895 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
2896 SIR_MAC_MGMT_REASSOC_REQ,
2897 psessionEntry->limReAssocbssId,psessionEntry->selfMacAddr);
2898 if ( eSIR_SUCCESS != nSirStatus )
2899 {
2900 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002901 "tor for an Association Request (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002902 nSirStatus );
2903 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
2904 goto end;
2905 }
2906
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05302907 pMacHdr = (tpSirMacMgmtHdr) pFrame;
Jeff Johnson295189b2012-06-20 16:38:30 -07002908 // That done, pack the ReAssoc Request:
2909 nStatus = dot11fPackReAssocRequest( pMac, &frm, pFrame +
2910 sizeof(tSirMacMgmtHdr),
2911 nPayload, &nPayload );
2912 if ( DOT11F_FAILED( nStatus ) )
2913 {
2914 limLog( pMac, LOGE, FL("Failed to pack a Re-Association Reque"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002915 "st (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002916 nStatus );
2917 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
2918 goto end;
2919 }
2920 else if ( DOT11F_WARNED( nStatus ) )
2921 {
2922 limLog( pMac, LOGW, FL("There were warnings while packing a R"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08002923 "e-Association Request (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07002924 }
2925
2926 PELOG3(limLog( pMac, LOG3,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002927 FL("*** Sending Re-Association Request length %d %d to "),
Jeff Johnson295189b2012-06-20 16:38:30 -07002928 nBytes, nPayload );)
2929 if( psessionEntry->assocReq != NULL )
2930 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302931 vos_mem_free(psessionEntry->assocReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07002932 psessionEntry->assocReq = NULL;
2933 }
2934
2935 if( nAddIELen )
2936 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302937 vos_mem_copy( pFrame + sizeof(tSirMacMgmtHdr) + nPayload,
2938 pAddIE,
2939 nAddIELen );
Jeff Johnson295189b2012-06-20 16:38:30 -07002940 nPayload += nAddIELen;
2941 }
2942
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302943 psessionEntry->assocReq = vos_mem_malloc(nPayload);
2944 if ( NULL == psessionEntry->assocReq )
Jeff Johnson295189b2012-06-20 16:38:30 -07002945 {
2946 PELOGE(limLog(pMac, LOGE, FL("Unable to allocate memory to store assoc request"));)
Jeff Johnson43971f52012-07-17 12:26:56 -07002947 }
2948 else
2949 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002950 //Store the Assoc request. This is sent to csr/hdd in join cnf response.
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302951 vos_mem_copy( psessionEntry->assocReq, pFrame + sizeof(tSirMacMgmtHdr), nPayload);
Jeff Johnson295189b2012-06-20 16:38:30 -07002952 psessionEntry->assocReqLen = nPayload;
Jeff Johnson43971f52012-07-17 12:26:56 -07002953 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002954
2955 if (psessionEntry->is11Rconnection)
2956 {
2957 {
2958 int i = 0;
2959
2960 pBody = pFrame + nBytes;
2961 for (i=0; i<ft_ies_length; i++)
2962 {
2963 *pBody = pMac->ft.ftSmeContext.reassoc_ft_ies[i];
2964 pBody++;
2965 }
2966 }
2967 }
2968
2969#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08002970 PELOGE(limLog(pMac, LOG1, FL("Re-assoc Req Frame is: "));
2971 sirDumpBuf(pMac, SIR_LIM_MODULE_ID, LOG1,
Jeff Johnson295189b2012-06-20 16:38:30 -07002972 (tANI_U8 *)pFrame,
2973 (nBytes + ft_ies_length));)
2974#endif
2975
2976
2977 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07002978 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
2979 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07002980 )
2981 {
2982 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
2983 }
2984
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07002985 if( NULL != psessionEntry->assocReq )
2986 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302987 vos_mem_free(psessionEntry->assocReq);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07002988 psessionEntry->assocReq = NULL;
2989 }
2990
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302991 psessionEntry->assocReq = vos_mem_malloc(ft_ies_length);
2992 if ( NULL == psessionEntry->assocReq )
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07002993 {
2994 PELOGE(limLog(pMac, LOGE, FL("Unable to allocate memory to store assoc request"));)
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08002995 psessionEntry->assocReqLen = 0;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07002996 }
2997 else
2998 {
2999 //Store the Assoc request. This is sent to csr/hdd in join cnf response.
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303000 vos_mem_copy( psessionEntry->assocReq, pMac->ft.ftSmeContext.reassoc_ft_ies,
3001 (ft_ies_length));
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07003002 psessionEntry->assocReqLen = (ft_ies_length);
3003 }
3004
3005
Mihir Shete63561c82014-08-23 16:58:07 +05303006 // Enable TL cahching in case of roaming
3007 WLANTL_EnableCaching(psessionEntry->staId);
3008
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05303009 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
3010 psessionEntry->peSessionId,
3011 pMacHdr->fc.subType));
Jeff Johnson295189b2012-06-20 16:38:30 -07003012 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) (nBytes + ft_ies_length),
3013 HAL_TXRX_FRM_802_11_MGMT,
3014 ANI_TXDIR_TODS,
3015 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
3016 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05303017 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
3018 psessionEntry->peSessionId,
3019 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07003020 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3021 {
3022 limLog( pMac, LOGE, FL("Failed to send Re-Association Request"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003023 "(%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07003024 nSirStatus );
3025 //Pkt will be freed up by the callback
3026 goto end;
3027 }
3028
3029end:
3030 // Free up buffer allocated for mlmAssocReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303031 vos_mem_free( pMlmReassocReq );
Jeff Johnson295189b2012-06-20 16:38:30 -07003032 psessionEntry->pLimMlmReassocReq = NULL;
3033
3034}
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -07003035
3036void limSendRetryReassocReqFrame(tpAniSirGlobal pMac,
3037 tLimMlmReassocReq *pMlmReassocReq,
3038 tpPESession psessionEntry)
3039{
3040 tLimMlmReassocCnf mlmReassocCnf; // keep sme
3041 tLimMlmReassocReq *pTmpMlmReassocReq = NULL;
3042 if(NULL == pTmpMlmReassocReq)
3043 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303044 pTmpMlmReassocReq = vos_mem_malloc(sizeof(tLimMlmReassocReq));
3045 if ( NULL == pTmpMlmReassocReq ) goto end;
3046 vos_mem_set( pTmpMlmReassocReq, sizeof(tLimMlmReassocReq), 0);
3047 vos_mem_copy( pTmpMlmReassocReq, pMlmReassocReq, sizeof(tLimMlmReassocReq));
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -07003048 }
3049
3050 // Prepare and send Reassociation request frame
3051 // start reassoc timer.
3052 pMac->lim.limTimers.gLimReassocFailureTimer.sessionId = psessionEntry->peSessionId;
3053 // Start reassociation failure timer
Leela V Kiran Kumar Reddy Chiralac3b9d382013-01-31 20:49:53 -08003054 MTRACE(macTrace(pMac, TRACE_CODE_TIMER_ACTIVATE, psessionEntry->peSessionId, eLIM_REASSOC_FAIL_TIMER));
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -07003055 if (tx_timer_activate(&pMac->lim.limTimers.gLimReassocFailureTimer)
3056 != TX_SUCCESS)
3057 {
3058 // Could not start reassoc failure timer.
3059 // Log error
3060 limLog(pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003061 FL("could not start Reassociation failure timer"));
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -07003062 // Return Reassoc confirm with
3063 // Resources Unavailable
3064 mlmReassocCnf.resultCode = eSIR_SME_RESOURCES_UNAVAILABLE;
3065 mlmReassocCnf.protStatusCode = eSIR_MAC_UNSPEC_FAILURE_STATUS;
3066 goto end;
3067 }
3068
3069 limSendReassocReqWithFTIEsMgmtFrame(pMac, pTmpMlmReassocReq, psessionEntry);
3070 return;
3071
3072end:
3073 // Free up buffer allocated for reassocReq
3074 if (pMlmReassocReq != NULL)
3075 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303076 vos_mem_free(pMlmReassocReq);
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -07003077 pMlmReassocReq = NULL;
3078 }
3079 if (pTmpMlmReassocReq != NULL)
3080 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303081 vos_mem_free(pTmpMlmReassocReq);
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -07003082 pTmpMlmReassocReq = NULL;
3083 }
3084 mlmReassocCnf.resultCode = eSIR_SME_FT_REASSOC_FAILURE;
3085 mlmReassocCnf.protStatusCode = eSIR_MAC_UNSPEC_FAILURE_STATUS;
3086 /* Update PE sessio Id*/
3087 mlmReassocCnf.sessionId = psessionEntry->peSessionId;
3088
3089 limPostSmeMessage(pMac, LIM_MLM_REASSOC_CNF, (tANI_U32 *) &mlmReassocCnf);
3090}
3091
Jeff Johnson295189b2012-06-20 16:38:30 -07003092#endif /* WLAN_FEATURE_VOWIFI_11R */
3093
3094
3095void
3096limSendReassocReqMgmtFrame(tpAniSirGlobal pMac,
3097 tLimMlmReassocReq *pMlmReassocReq,tpPESession psessionEntry)
3098{
3099 static tDot11fReAssocRequest frm;
3100 tANI_U16 caps;
3101 tANI_U8 *pFrame;
3102 tSirRetStatus nSirStatus;
3103 tANI_U32 nBytes, nPayload, nStatus;
3104 tANI_U8 fQosEnabled, fWmeEnabled, fWsmEnabled;
3105 void *pPacket;
3106 eHalStatus halstatus;
3107 tANI_U16 nAddIELen;
3108 tANI_U8 *pAddIE;
3109 tANI_U8 *wpsIe = NULL;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05303110 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003111#if defined WLAN_FEATURE_VOWIFI
3112 tANI_U8 PowerCapsPopulated = FALSE;
3113#endif
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05303114 tpSirMacMgmtHdr pMacHdr;
Jeff Johnson295189b2012-06-20 16:38:30 -07003115
3116 if(NULL == psessionEntry)
3117 {
3118 return;
3119 }
3120
3121 /* check this early to avoid unncessary operation */
3122 if(NULL == psessionEntry->pLimReAssocReq)
3123 {
3124 return;
3125 }
3126 nAddIELen = psessionEntry->pLimReAssocReq->addIEAssoc.length;
3127 pAddIE = psessionEntry->pLimReAssocReq->addIEAssoc.addIEdata;
3128
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303129 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07003130
3131 caps = pMlmReassocReq->capabilityInfo;
3132 if (PROP_CAPABILITY_GET(11EQOS, psessionEntry->limReassocBssPropCap))
3133 ((tSirMacCapabilityInfo *) &caps)->qos = 0;
3134#if defined(FEATURE_WLAN_WAPI)
3135 /* CR: 262463 :
3136 According to WAPI standard:
3137 7.3.1.4 Capability Information field
3138 In WAPI, non-AP STAs within an ESS set the Privacy subfield to 0 in transmitted
3139 Association or Reassociation management frames. APs ignore the Privacy subfield within received Association and
3140 Reassociation management frames. */
3141 if ( psessionEntry->encryptType == eSIR_ED_WPI)
3142 ((tSirMacCapabilityInfo *) &caps)->privacy = 0;
3143#endif
3144 swapBitField16(caps, ( tANI_U16* )&frm.Capabilities );
3145
3146 frm.ListenInterval.interval = pMlmReassocReq->listenInterval;
3147
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303148 vos_mem_copy(( tANI_U8* )frm.CurrentAPAddress.mac,
3149 ( tANI_U8* )psessionEntry->bssId, 6 );
Jeff Johnson295189b2012-06-20 16:38:30 -07003150
3151 PopulateDot11fSSID2( pMac, &frm.SSID );
3152 PopulateDot11fSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
3153 &frm.SuppRates,psessionEntry);
3154
3155 fQosEnabled = ( psessionEntry->limQosEnabled ) &&
3156 SIR_MAC_GET_QOS( psessionEntry->limReassocBssCaps );
3157
3158 fWmeEnabled = ( psessionEntry->limWmeEnabled ) &&
3159 LIM_BSS_CAPS_GET( WME, psessionEntry->limReassocBssQosCaps );
3160
3161 fWsmEnabled = ( psessionEntry->limWsmEnabled ) && fWmeEnabled &&
3162 LIM_BSS_CAPS_GET( WSM, psessionEntry->limReassocBssQosCaps );
3163
3164
3165 if ( psessionEntry->lim11hEnable &&
3166 psessionEntry->pLimReAssocReq->spectrumMgtIndicator == eSIR_TRUE )
3167 {
3168#if defined WLAN_FEATURE_VOWIFI
3169 PowerCapsPopulated = TRUE;
3170 PopulateDot11fPowerCaps( pMac, &frm.PowerCaps, LIM_REASSOC,psessionEntry);
3171 PopulateDot11fSuppChannels( pMac, &frm.SuppChannels, LIM_REASSOC,psessionEntry);
3172#endif
3173 }
3174
3175#if defined WLAN_FEATURE_VOWIFI
3176 if( pMac->rrm.rrmPEContext.rrmEnable &&
3177 SIR_MAC_GET_RRM( psessionEntry->limCurrentBssCaps ) )
3178 {
3179 if (PowerCapsPopulated == FALSE)
3180 {
3181 PowerCapsPopulated = TRUE;
3182 PopulateDot11fPowerCaps(pMac, &frm.PowerCaps, LIM_REASSOC, psessionEntry);
3183 }
3184 }
3185#endif
3186
3187 if ( fQosEnabled &&
3188 ( ! PROP_CAPABILITY_GET(11EQOS, psessionEntry->limReassocBssPropCap ) ))
3189 {
3190 PopulateDot11fQOSCapsStation( pMac, &frm.QOSCapsStation );
3191 }
3192
3193 PopulateDot11fExtSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
3194 &frm.ExtSuppRates, psessionEntry );
3195
3196#if defined WLAN_FEATURE_VOWIFI
3197 if( pMac->rrm.rrmPEContext.rrmEnable &&
3198 SIR_MAC_GET_RRM( psessionEntry->limReassocBssCaps ) )
3199 {
3200 PopulateDot11fRRMIe( pMac, &frm.RRMEnabledCap, psessionEntry );
3201 }
3202#endif
3203 // The join request *should* contain zero or one of the WPA and RSN
3204 // IEs. The payload send along with the request is a
3205 // 'tSirSmeJoinReq'; the IE portion is held inside a 'tSirRSNie':
3206
3207 // typedef struct sSirRSNie
3208 // {
3209 // tANI_U16 length;
3210 // tANI_U8 rsnIEdata[SIR_MAC_MAX_IE_LENGTH+2];
3211 // } tSirRSNie, *tpSirRSNie;
3212
3213 // So, we should be able to make the following two calls harmlessly,
3214 // since they do nothing if they don't find the given IE in the
3215 // bytestream with which they're provided.
3216
3217 // The net effect of this will be to faithfully transmit whatever
3218 // security IE is in the join request.
3219
3220 // *However*, if we're associating for the purpose of WPS
3221 // enrollment, and we've been configured to indicate that by
3222 // eliding the WPA or RSN IE, we just skip this:
3223 if( nAddIELen && pAddIE )
3224 {
3225 wpsIe = limGetWscIEPtr(pMac, pAddIE, nAddIELen);
3226 }
3227 if ( NULL == wpsIe )
3228 {
3229 PopulateDot11fRSNOpaque( pMac, &( psessionEntry->pLimReAssocReq->rsnIE ),
3230 &frm.RSNOpaque );
3231 PopulateDot11fWPAOpaque( pMac, &( psessionEntry->pLimReAssocReq->rsnIE ),
3232 &frm.WPAOpaque );
3233#if defined(FEATURE_WLAN_WAPI)
3234 PopulateDot11fWAPIOpaque( pMac, &( psessionEntry->pLimReAssocReq->rsnIE ),
3235 &frm.WAPIOpaque );
3236#endif // defined(FEATURE_WLAN_WAPI)
3237 }
3238
3239 // include WME EDCA IE as well
3240 if ( fWmeEnabled )
3241 {
3242 if ( ! PROP_CAPABILITY_GET( WME, psessionEntry->limReassocBssPropCap ) )
3243 {
3244 PopulateDot11fWMMInfoStation( pMac, &frm.WMMInfoStation );
3245 }
3246
3247 if ( fWsmEnabled &&
3248 ( ! PROP_CAPABILITY_GET(WSM, psessionEntry->limReassocBssPropCap )))
3249 {
3250 PopulateDot11fWMMCaps( &frm.WMMCaps );
3251 }
3252 }
3253
Jeff Johnsone7245742012-09-05 17:12:55 -07003254 if ( psessionEntry->htCapability &&
Jeff Johnson295189b2012-06-20 16:38:30 -07003255 pMac->lim.htCapabilityPresentInBeacon)
3256 {
Jeff Johnsone7245742012-09-05 17:12:55 -07003257 PopulateDot11fHTCaps( pMac, psessionEntry, &frm.HTCaps );
Jeff Johnson295189b2012-06-20 16:38:30 -07003258 }
Jeff Johnsone7245742012-09-05 17:12:55 -07003259#ifdef WLAN_FEATURE_11AC
3260 if ( psessionEntry->vhtCapability &&
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07003261 psessionEntry->vhtCapabilityPresentInBeacon)
Jeff Johnsone7245742012-09-05 17:12:55 -07003262 {
Chet Lanctotf19c1f62013-12-13 13:56:21 -08003263 limLog( pMac, LOG1, FL("Populate VHT IEs in Re-Assoc Request"));
Abhishek Singh6d5d29c2014-07-03 14:25:22 +05303264 PopulateDot11fVHTCaps( pMac, &frm.VHTCaps, eSIR_FALSE );
Sandeep Puligilla60342762014-01-30 21:05:37 +05303265 PopulateDot11fExtCap( pMac, &frm.ExtCap, psessionEntry);
Jeff Johnsone7245742012-09-05 17:12:55 -07003266 }
3267#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003268
3269 nStatus = dot11fGetPackedReAssocRequestSize( pMac, &frm, &nPayload );
3270 if ( DOT11F_FAILED( nStatus ) )
3271 {
3272 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003273 "or a Re-Association Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003274 nStatus );
3275 // We'll fall back on the worst case scenario:
3276 nPayload = sizeof( tDot11fReAssocRequest );
3277 }
3278 else if ( DOT11F_WARNED( nStatus ) )
3279 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08003280 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07003281 "the packed size for a Re-Association Re "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003282 "quest(0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07003283 }
3284
3285 nBytes = nPayload + sizeof( tSirMacMgmtHdr ) + nAddIELen;
3286
3287 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
3288 ( tANI_U16 )nBytes, ( void** ) &pFrame,
3289 ( void** ) &pPacket );
3290 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3291 {
3292 psessionEntry->limMlmState = psessionEntry->limPrevMlmState;
Jeff Johnsone7245742012-09-05 17:12:55 -07003293 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07003294 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Re-As"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003295 "sociation Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07003296 goto end;
3297 }
3298
3299 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303300 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07003301
3302 // Next, we fill out the buffer descriptor:
3303 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
3304 SIR_MAC_MGMT_REASSOC_REQ,
3305 psessionEntry->limReAssocbssId,psessionEntry->selfMacAddr);
3306 if ( eSIR_SUCCESS != nSirStatus )
3307 {
3308 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003309 "tor for an Association Request (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003310 nSirStatus );
3311 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
3312 goto end;
3313 }
3314
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05303315 pMacHdr = (tpSirMacMgmtHdr) pFrame;
Jeff Johnson295189b2012-06-20 16:38:30 -07003316 // That done, pack the Probe Request:
3317 nStatus = dot11fPackReAssocRequest( pMac, &frm, pFrame +
3318 sizeof(tSirMacMgmtHdr),
3319 nPayload, &nPayload );
3320 if ( DOT11F_FAILED( nStatus ) )
3321 {
3322 limLog( pMac, LOGE, FL("Failed to pack a Re-Association Reque"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003323 "st (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003324 nStatus );
3325 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
3326 goto end;
3327 }
3328 else if ( DOT11F_WARNED( nStatus ) )
3329 {
3330 limLog( pMac, LOGW, FL("There were warnings while packing a R"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08003331 "e-Association Request (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07003332 }
3333
3334 PELOG1(limLog( pMac, LOG1, FL("*** Sending Re-Association Request length %d"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003335 "to "),
Jeff Johnson295189b2012-06-20 16:38:30 -07003336 nBytes );)
3337
3338 if( psessionEntry->assocReq != NULL )
3339 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303340 vos_mem_free(psessionEntry->assocReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07003341 psessionEntry->assocReq = NULL;
3342 }
3343
3344 if( nAddIELen )
3345 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303346 vos_mem_copy( pFrame + sizeof(tSirMacMgmtHdr) + nPayload,
3347 pAddIE,
3348 nAddIELen );
Jeff Johnson295189b2012-06-20 16:38:30 -07003349 nPayload += nAddIELen;
3350 }
3351
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303352 psessionEntry->assocReq = vos_mem_malloc(nPayload);
3353 if ( NULL == psessionEntry->assocReq )
Jeff Johnson295189b2012-06-20 16:38:30 -07003354 {
3355 PELOGE(limLog(pMac, LOGE, FL("Unable to allocate memory to store assoc request"));)
Jeff Johnson43971f52012-07-17 12:26:56 -07003356 }
3357 else
3358 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003359 //Store the Assoc request. This is sent to csr/hdd in join cnf response.
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303360 vos_mem_copy(psessionEntry->assocReq, pFrame + sizeof(tSirMacMgmtHdr), nPayload);
Jeff Johnson295189b2012-06-20 16:38:30 -07003361 psessionEntry->assocReqLen = nPayload;
Jeff Johnson43971f52012-07-17 12:26:56 -07003362 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003363
3364 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07003365 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
3366 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07003367 )
3368 {
3369 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
3370 }
3371
Gopichand Nakkalad3918dd2012-12-31 16:27:55 -08003372 if(psessionEntry->pePersona == VOS_P2P_CLIENT_MODE)
Ganesh K08bce952012-12-13 15:04:41 -08003373 {
3374 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
3375 }
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08003376
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05303377 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
3378 psessionEntry->peSessionId,
3379 pMacHdr->fc.subType));
Katya Nigam63902932014-06-26 19:04:23 +05303380
3381 // enable caching
3382 WLANTL_EnableCaching(psessionEntry->staId);
3383
Jeff Johnson295189b2012-06-20 16:38:30 -07003384 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) (sizeof(tSirMacMgmtHdr) + nPayload),
3385 HAL_TXRX_FRM_802_11_MGMT,
3386 ANI_TXDIR_TODS,
3387 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
3388 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05303389 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
3390 psessionEntry->peSessionId,
3391 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07003392 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3393 {
3394 limLog( pMac, LOGE, FL("Failed to send Re-Association Request"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003395 "(%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07003396 nSirStatus );
3397 //Pkt will be freed up by the callback
3398 goto end;
3399 }
3400
3401end:
3402 // Free up buffer allocated for mlmAssocReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303403 vos_mem_free( pMlmReassocReq );
Jeff Johnson295189b2012-06-20 16:38:30 -07003404 psessionEntry->pLimMlmReassocReq = NULL;
3405
3406} // limSendReassocReqMgmtFrame
3407
3408/**
3409 * \brief Send an Authentication frame
3410 *
3411 *
3412 * \param pMac Pointer to Global MAC structure
3413 *
3414 * \param pAuthFrameBody Pointer to Authentication frame structure that need
3415 * to be sent
3416 *
3417 * \param peerMacAddr MAC address of the peer entity to which Authentication
3418 * frame is destined
3419 *
3420 * \param wepBit Indicates whether wep bit to be set in FC while sending
3421 * Authentication frame3
3422 *
3423 *
3424 * This function is called by limProcessMlmMessages(). Authentication frame
3425 * is formatted and sent when this function is called.
3426 *
3427 *
3428 */
3429
3430void
3431limSendAuthMgmtFrame(tpAniSirGlobal pMac,
3432 tpSirMacAuthFrameBody pAuthFrameBody,
3433 tSirMacAddr peerMacAddr,
3434 tANI_U8 wepBit,
3435 tpPESession psessionEntry
3436 )
3437{
3438 tANI_U8 *pFrame, *pBody;
3439 tANI_U32 frameLen = 0, bodyLen = 0;
3440 tpSirMacMgmtHdr pMacHdr;
3441 tANI_U16 i;
3442 void *pPacket;
3443 eHalStatus halstatus;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05303444 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003445
3446 if(NULL == psessionEntry)
3447 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05303448 limLog(pMac, LOGE, FL("Error: psession Entry is NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003449 return;
3450 }
Abhishek Singh57aebef2014-02-03 18:47:44 +05303451
3452 limLog(pMac, LOG1,
3453 FL("Sending Auth seq# %d status %d (%d) to "MAC_ADDRESS_STR),
3454 pAuthFrameBody->authTransactionSeqNumber,
3455 pAuthFrameBody->authStatusCode,
3456 (pAuthFrameBody->authStatusCode == eSIR_MAC_SUCCESS_STATUS),
3457 MAC_ADDR_ARRAY(peerMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07003458 if (wepBit == LIM_WEP_IN_FC)
3459 {
3460 /// Auth frame3 to be sent with encrypted framebody
3461 /**
3462 * Allocate buffer for Authenticaton frame of size equal
3463 * to management frame header length plus 2 bytes each for
3464 * auth algorithm number, transaction number, status code,
3465 * 128 bytes for challenge text and 4 bytes each for
3466 * IV & ICV.
3467 */
3468
3469 frameLen = sizeof(tSirMacMgmtHdr) + LIM_ENCR_AUTH_BODY_LEN;
3470
3471 bodyLen = LIM_ENCR_AUTH_BODY_LEN;
3472 } // if (wepBit == LIM_WEP_IN_FC)
3473 else
3474 {
3475 switch (pAuthFrameBody->authTransactionSeqNumber)
3476 {
3477 case SIR_MAC_AUTH_FRAME_1:
3478 /**
3479 * Allocate buffer for Authenticaton frame of size
3480 * equal to management frame header length plus 2 bytes
3481 * each for auth algorithm number, transaction number
3482 * and status code.
3483 */
3484
3485 frameLen = sizeof(tSirMacMgmtHdr) +
3486 SIR_MAC_AUTH_CHALLENGE_OFFSET;
3487 bodyLen = SIR_MAC_AUTH_CHALLENGE_OFFSET;
3488
3489#if defined WLAN_FEATURE_VOWIFI_11R
Madan Mohan Koyyalamudi6a00a802012-11-28 16:12:11 -08003490 if (pAuthFrameBody->authAlgoNumber == eSIR_FT_AUTH)
3491 {
3492 if (0 != pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length)
Jeff Johnson295189b2012-06-20 16:38:30 -07003493 {
Madan Mohan Koyyalamudi6a00a802012-11-28 16:12:11 -08003494 frameLen += pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length;
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003495 limLog(pMac, LOG3, FL("Auth frame, FTIES length added=%d"),
Madan Mohan Koyyalamudi6a00a802012-11-28 16:12:11 -08003496 pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length);
Jeff Johnson295189b2012-06-20 16:38:30 -07003497 }
Madan Mohan Koyyalamudi6a00a802012-11-28 16:12:11 -08003498 else
3499 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05303500 limLog(pMac, LOG3, FL("Auth frame, Does not contain "
3501 "FTIES!!!"));
Madan Mohan Koyyalamudi6a00a802012-11-28 16:12:11 -08003502 frameLen += (2+SIR_MDIE_SIZE);
3503 }
3504 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003505#endif
3506 break;
3507
3508 case SIR_MAC_AUTH_FRAME_2:
3509 if ((pAuthFrameBody->authAlgoNumber == eSIR_OPEN_SYSTEM) ||
3510 ((pAuthFrameBody->authAlgoNumber == eSIR_SHARED_KEY) &&
3511 (pAuthFrameBody->authStatusCode != eSIR_MAC_SUCCESS_STATUS)))
3512 {
3513 /**
3514 * Allocate buffer for Authenticaton frame of size
3515 * equal to management frame header length plus
3516 * 2 bytes each for auth algorithm number,
3517 * transaction number and status code.
3518 */
3519
3520 frameLen = sizeof(tSirMacMgmtHdr) +
3521 SIR_MAC_AUTH_CHALLENGE_OFFSET;
3522 bodyLen = SIR_MAC_AUTH_CHALLENGE_OFFSET;
3523 }
3524 else
3525 {
3526 // Shared Key algorithm with challenge text
3527 // to be sent
3528 /**
3529 * Allocate buffer for Authenticaton frame of size
3530 * equal to management frame header length plus
3531 * 2 bytes each for auth algorithm number,
3532 * transaction number, status code and 128 bytes
3533 * for challenge text.
3534 */
3535
3536 frameLen = sizeof(tSirMacMgmtHdr) +
3537 sizeof(tSirMacAuthFrame);
3538 bodyLen = sizeof(tSirMacAuthFrameBody);
3539 }
3540
3541 break;
3542
3543 case SIR_MAC_AUTH_FRAME_3:
3544 /// Auth frame3 to be sent without encrypted framebody
3545 /**
3546 * Allocate buffer for Authenticaton frame of size equal
3547 * to management frame header length plus 2 bytes each
3548 * for auth algorithm number, transaction number and
3549 * status code.
3550 */
3551
3552 frameLen = sizeof(tSirMacMgmtHdr) +
3553 SIR_MAC_AUTH_CHALLENGE_OFFSET;
3554 bodyLen = SIR_MAC_AUTH_CHALLENGE_OFFSET;
3555
3556 break;
3557
3558 case SIR_MAC_AUTH_FRAME_4:
3559 /**
3560 * Allocate buffer for Authenticaton frame of size equal
3561 * to management frame header length plus 2 bytes each
3562 * for auth algorithm number, transaction number and
3563 * status code.
3564 */
3565
3566 frameLen = sizeof(tSirMacMgmtHdr) +
3567 SIR_MAC_AUTH_CHALLENGE_OFFSET;
3568 bodyLen = SIR_MAC_AUTH_CHALLENGE_OFFSET;
3569
3570 break;
3571 } // switch (pAuthFrameBody->authTransactionSeqNumber)
3572 } // end if (wepBit == LIM_WEP_IN_FC)
3573
3574
3575 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )frameLen, ( void** ) &pFrame, ( void** ) &pPacket );
3576
3577 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3578 {
3579 // Log error
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003580 limLog(pMac, LOGP, FL("call to bufAlloc failed for AUTH frame"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003581
3582 return;
3583 }
3584
3585 for (i = 0; i < frameLen; i++)
3586 pFrame[i] = 0;
3587
3588 // Prepare BD
3589 if (limPopulateMacHeader(pMac, pFrame, SIR_MAC_MGMT_FRAME,
3590 SIR_MAC_MGMT_AUTH, peerMacAddr,psessionEntry->selfMacAddr) != eSIR_SUCCESS)
3591 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05303592 limLog(pMac, LOGE, FL("call to limPopulateMacHeader failed for "
3593 "AUTH frame"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003594 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
3595 return;
3596 }
3597
3598 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
3599 pMacHdr->fc.wep = wepBit;
3600
3601 // Prepare BSSId
3602 if( (psessionEntry->limSystemRole == eLIM_AP_ROLE)|| (psessionEntry->limSystemRole == eLIM_BT_AMP_AP_ROLE) )
3603 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303604 vos_mem_copy( (tANI_U8 *) pMacHdr->bssId,
3605 (tANI_U8 *) psessionEntry->bssId,
3606 sizeof( tSirMacAddr ));
Jeff Johnson295189b2012-06-20 16:38:30 -07003607 }
3608
3609 /// Prepare Authentication frame body
3610 pBody = pFrame + sizeof(tSirMacMgmtHdr);
3611
3612 if (wepBit == LIM_WEP_IN_FC)
3613 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303614 vos_mem_copy(pBody, (tANI_U8 *) pAuthFrameBody, bodyLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07003615
3616 PELOG1(limLog(pMac, LOG1,
Abhishek Singh57aebef2014-02-03 18:47:44 +05303617 FL("*** Sending Auth seq# 3 status %d (%d) to"MAC_ADDRESS_STR),
Jeff Johnson295189b2012-06-20 16:38:30 -07003618 pAuthFrameBody->authStatusCode,
Abhishek Singh57aebef2014-02-03 18:47:44 +05303619 (pAuthFrameBody->authStatusCode == eSIR_MAC_SUCCESS_STATUS),
3620 MAC_ADDR_ARRAY(pMacHdr->da));)
Jeff Johnson295189b2012-06-20 16:38:30 -07003621
Jeff Johnson295189b2012-06-20 16:38:30 -07003622 }
3623 else
3624 {
3625 *((tANI_U16 *)(pBody)) = sirSwapU16ifNeeded(pAuthFrameBody->authAlgoNumber);
3626 pBody += sizeof(tANI_U16);
3627 bodyLen -= sizeof(tANI_U16);
3628
3629 *((tANI_U16 *)(pBody)) = sirSwapU16ifNeeded(pAuthFrameBody->authTransactionSeqNumber);
3630 pBody += sizeof(tANI_U16);
3631 bodyLen -= sizeof(tANI_U16);
3632
3633 *((tANI_U16 *)(pBody)) = sirSwapU16ifNeeded(pAuthFrameBody->authStatusCode);
3634 pBody += sizeof(tANI_U16);
3635 bodyLen -= sizeof(tANI_U16);
Leela Venkata Kiran Kumar Reddy Chirala7d3fa552013-08-28 10:52:21 -07003636 if ( bodyLen <= (sizeof (pAuthFrameBody->type) +
3637 sizeof (pAuthFrameBody->length) +
3638 sizeof (pAuthFrameBody->challengeText)))
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303639 vos_mem_copy(pBody, (tANI_U8 *) &pAuthFrameBody->type, bodyLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07003640
3641#if defined WLAN_FEATURE_VOWIFI_11R
3642 if ((pAuthFrameBody->authAlgoNumber == eSIR_FT_AUTH) &&
3643 (pAuthFrameBody->authTransactionSeqNumber == SIR_MAC_AUTH_FRAME_1))
3644 {
3645
3646 {
3647 int i = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003648 if (pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length)
3649 {
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08003650#if defined WLAN_FEATURE_VOWIFI_11R_DEBUG
Srinivas Girigowdad63eb492014-02-06 12:21:47 -08003651 PELOG2(limLog(pMac, LOG2, FL("Auth1 Frame FTIE is: "));
3652 sirDumpBuf(pMac, SIR_LIM_MODULE_ID, LOG2,
Jeff Johnson295189b2012-06-20 16:38:30 -07003653 (tANI_U8 *)pBody,
3654 (pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length));)
Jeff Johnson295189b2012-06-20 16:38:30 -07003655#endif
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08003656 for (i=0; i<pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length; i++)
3657 {
Madan Mohan Koyyalamudi6a00a802012-11-28 16:12:11 -08003658 *pBody = pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies[i];
3659 pBody++;
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08003660 }
3661 }
3662 else
3663 {
3664 /* MDID attr is 54*/
3665 *pBody = 54;
Jeff Johnson295189b2012-06-20 16:38:30 -07003666 pBody++;
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08003667 *pBody = SIR_MDIE_SIZE;
3668 pBody++;
3669 for(i=0;i<SIR_MDIE_SIZE;i++)
3670 {
3671 *pBody = pMac->ft.ftPEContext.pFTPreAuthReq->pbssDescription->mdie[i];
3672 pBody++;
3673 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003674 }
3675 }
3676 }
3677#endif
3678
3679 PELOG1(limLog(pMac, LOG1,
Abhishek Singh57aebef2014-02-03 18:47:44 +05303680 FL("*** Sending Auth seq# %d status %d (%d) to "MAC_ADDRESS_STR),
Jeff Johnson295189b2012-06-20 16:38:30 -07003681 pAuthFrameBody->authTransactionSeqNumber,
3682 pAuthFrameBody->authStatusCode,
Abhishek Singh57aebef2014-02-03 18:47:44 +05303683 (pAuthFrameBody->authStatusCode == eSIR_MAC_SUCCESS_STATUS),
3684 MAC_ADDR_ARRAY(pMacHdr->da));)
Jeff Johnson295189b2012-06-20 16:38:30 -07003685 }
3686 PELOG2(sirDumpBuf(pMac, SIR_LIM_MODULE_ID, LOG2, pFrame, frameLen);)
3687
3688 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07003689 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
3690 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003691#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05303692 || ((NULL != pMac->ft.ftPEContext.pFTPreAuthReq)
Jeff Johnsone7245742012-09-05 17:12:55 -07003693 && ( SIR_BAND_5_GHZ == limGetRFBand(pMac->ft.ftPEContext.pFTPreAuthReq->preAuthchannelNum)))
3694#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003695 )
3696 {
3697 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
3698 }
3699
Ganesh K08bce952012-12-13 15:04:41 -08003700 if(psessionEntry->pePersona == VOS_P2P_CLIENT_MODE)
3701 {
3702 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
3703 }
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08003704
Agarwal Ashisha8e81f52014-04-02 01:59:52 +05303705 limLog( pMac, LOG1, FL("Sending Auth Frame over WQ5 to "MAC_ADDRESS_STR
3706 " From " MAC_ADDRESS_STR),MAC_ADDR_ARRAY(pMacHdr->da),
3707 MAC_ADDR_ARRAY(psessionEntry->selfMacAddr));
3708
3709 txFlag |= HAL_USE_FW_IN_TX_PATH;
3710
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05303711 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
3712 psessionEntry->peSessionId,
3713 pMacHdr->fc.subType));
Jeff Johnson295189b2012-06-20 16:38:30 -07003714 /// Queue Authentication frame in high priority WQ
3715 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) frameLen,
3716 HAL_TXRX_FRM_802_11_MGMT,
3717 ANI_TXDIR_TODS,
3718 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
3719 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05303720 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
3721 psessionEntry->peSessionId,
3722 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07003723 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3724 {
3725 limLog(pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003726 FL("*** Could not send Auth frame, retCode=%X ***"),
Jeff Johnson295189b2012-06-20 16:38:30 -07003727 halstatus);
3728
3729 //Pkt will be freed up by the callback
3730 }
3731
3732 return;
3733} /*** end limSendAuthMgmtFrame() ***/
3734
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003735eHalStatus limSendDeauthCnf(tpAniSirGlobal pMac)
3736{
3737 tANI_U16 aid;
3738 tpDphHashNode pStaDs;
3739 tLimMlmDeauthReq *pMlmDeauthReq;
3740 tLimMlmDeauthCnf mlmDeauthCnf;
3741 tpPESession psessionEntry;
3742
3743 pMlmDeauthReq = pMac->lim.limDisassocDeauthCnfReq.pMlmDeauthReq;
3744 if (pMlmDeauthReq)
3745 {
3746 if (tx_timer_running(&pMac->lim.limTimers.gLimDeauthAckTimer))
3747 {
3748 limDeactivateAndChangeTimer(pMac, eLIM_DEAUTH_ACK_TIMER);
3749 }
3750
3751 if((psessionEntry = peFindSessionBySessionId(pMac, pMlmDeauthReq->sessionId))== NULL)
3752 {
3753
3754 PELOGE(limLog(pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003755 FL("session does not exist for given sessionId"));)
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003756 mlmDeauthCnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
3757 goto end;
3758 }
3759
3760 pStaDs = dphLookupHashEntry(pMac, pMlmDeauthReq->peerMacAddr, &aid, &psessionEntry->dph.dphHashTable);
3761 if (pStaDs == NULL)
3762 {
3763 mlmDeauthCnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
3764 goto end;
3765 }
3766
3767
3768 /// Receive path cleanup with dummy packet
3769 limCleanupRxPath(pMac, pStaDs,psessionEntry);
Abhishek Singhcf4590b2014-04-16 18:58:08 +05303770
3771#ifdef WLAN_FEATURE_VOWIFI_11R
3772 if ( (psessionEntry->limSystemRole == eLIM_STA_ROLE ) &&
3773 (
3774#ifdef FEATURE_WLAN_ESE
3775 (psessionEntry->isESEconnection ) ||
3776#endif
3777#ifdef FEATURE_WLAN_LFR
3778 (psessionEntry->isFastRoamIniFeatureEnabled ) ||
3779#endif
3780 (psessionEntry->is11Rconnection )))
3781 {
3782 PELOGE(limLog(pMac, LOGE,
3783 FL("FT Preauth Session (%p,%d) Cleanup"
3784 " Deauth reason %d Trigger = %d"),
3785 psessionEntry, psessionEntry->peSessionId,
3786 pMlmDeauthReq->reasonCode,
3787 pMlmDeauthReq->deauthTrigger););
3788 limFTCleanup(pMac);
3789 }
3790 else
3791 {
3792 PELOGE(limLog(pMac, LOGE,
3793 FL("No FT Preauth Session Cleanup in role %d"
3794#ifdef FEATURE_WLAN_ESE
3795 " isESE %d"
3796#endif
3797#ifdef FEATURE_WLAN_LFR
3798 " isLFR %d"
3799#endif
3800 " is11r %d, Deauth reason %d Trigger = %d"),
3801 psessionEntry->limSystemRole,
3802#ifdef FEATURE_WLAN_ESE
3803 psessionEntry->isESEconnection,
3804#endif
3805#ifdef FEATURE_WLAN_LFR
3806 psessionEntry->isFastRoamIniFeatureEnabled,
3807#endif
3808 psessionEntry->is11Rconnection,
3809 pMlmDeauthReq->reasonCode,
3810 pMlmDeauthReq->deauthTrigger););
3811 }
3812#endif
3813
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003814 /// Free up buffer allocated for mlmDeauthReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303815 vos_mem_free(pMlmDeauthReq);
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003816 pMac->lim.limDisassocDeauthCnfReq.pMlmDeauthReq = NULL;
3817 }
3818 return eHAL_STATUS_SUCCESS;
3819end:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303820 vos_mem_copy( (tANI_U8 *) &mlmDeauthCnf.peerMacAddr,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003821 (tANI_U8 *) pMlmDeauthReq->peerMacAddr,
3822 sizeof(tSirMacAddr));
3823 mlmDeauthCnf.deauthTrigger = pMlmDeauthReq->deauthTrigger;
3824 mlmDeauthCnf.aid = pMlmDeauthReq->aid;
3825 mlmDeauthCnf.sessionId = pMlmDeauthReq->sessionId;
3826
3827 // Free up buffer allocated
3828 // for mlmDeauthReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303829 vos_mem_free(pMlmDeauthReq);
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003830
3831 limPostSmeMessage(pMac,
3832 LIM_MLM_DEAUTH_CNF,
3833 (tANI_U32 *) &mlmDeauthCnf);
3834 return eHAL_STATUS_SUCCESS;
3835}
3836
3837eHalStatus limSendDisassocCnf(tpAniSirGlobal pMac)
3838{
3839 tANI_U16 aid;
3840 tpDphHashNode pStaDs;
3841 tLimMlmDisassocCnf mlmDisassocCnf;
3842 tpPESession psessionEntry;
3843 tLimMlmDisassocReq *pMlmDisassocReq;
3844
3845 pMlmDisassocReq = pMac->lim.limDisassocDeauthCnfReq.pMlmDisassocReq;
3846 if (pMlmDisassocReq)
3847 {
3848 if (tx_timer_running(&pMac->lim.limTimers.gLimDisassocAckTimer))
3849 {
3850 limDeactivateAndChangeTimer(pMac, eLIM_DISASSOC_ACK_TIMER);
3851 }
3852
3853 if((psessionEntry = peFindSessionBySessionId(pMac, pMlmDisassocReq->sessionId))== NULL)
3854 {
3855
3856 PELOGE(limLog(pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003857 FL("session does not exist for given sessionId"));)
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003858 mlmDisassocCnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
3859 goto end;
3860 }
3861
3862 pStaDs = dphLookupHashEntry(pMac, pMlmDisassocReq->peerMacAddr, &aid, &psessionEntry->dph.dphHashTable);
3863 if (pStaDs == NULL)
3864 {
3865 mlmDisassocCnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
3866 goto end;
3867 }
3868
3869 /// Receive path cleanup with dummy packet
3870 if(eSIR_SUCCESS != limCleanupRxPath(pMac, pStaDs, psessionEntry))
3871 {
3872 mlmDisassocCnf.resultCode = eSIR_SME_RESOURCES_UNAVAILABLE;
3873 goto end;
3874 }
3875
3876#ifdef WLAN_FEATURE_VOWIFI_11R
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08003877 if ( (psessionEntry->limSystemRole == eLIM_STA_ROLE ) &&
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05303878 (
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003879#ifdef FEATURE_WLAN_ESE
3880 (psessionEntry->isESEconnection ) ||
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08003881#endif
3882#ifdef FEATURE_WLAN_LFR
3883 (psessionEntry->isFastRoamIniFeatureEnabled ) ||
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003884#endif
3885 (psessionEntry->is11Rconnection )) &&
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05303886 (pMlmDisassocReq->reasonCode !=
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08003887 eSIR_MAC_DISASSOC_DUE_TO_FTHANDOFF_REASON))
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003888 {
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05303889 PELOGE(limLog(pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003890 FL("FT Preauth Session (%p,%d) Cleanup"),
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08003891 psessionEntry, psessionEntry->peSessionId););
3892 limFTCleanup(pMac);
3893 }
3894 else
3895 {
3896 PELOGE(limLog(pMac, LOGE,
3897 FL("No FT Preauth Session Cleanup in role %d"
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003898#ifdef FEATURE_WLAN_ESE
3899 " isESE %d"
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08003900#endif
3901#ifdef FEATURE_WLAN_LFR
3902 " isLFR %d"
3903#endif
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003904 " is11r %d reason %d"),
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08003905 psessionEntry->limSystemRole,
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003906#ifdef FEATURE_WLAN_ESE
3907 psessionEntry->isESEconnection,
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08003908#endif
3909#ifdef FEATURE_WLAN_LFR
3910 psessionEntry->isFastRoamIniFeatureEnabled,
3911#endif
3912 psessionEntry->is11Rconnection,
3913 pMlmDisassocReq->reasonCode););
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003914 }
3915#endif
3916
3917 /// Free up buffer allocated for mlmDisassocReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303918 vos_mem_free(pMlmDisassocReq);
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003919 pMac->lim.limDisassocDeauthCnfReq.pMlmDisassocReq = NULL;
3920 return eHAL_STATUS_SUCCESS;
3921 }
3922 else
3923 {
3924 return eHAL_STATUS_SUCCESS;
3925 }
3926end:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303927 vos_mem_copy( (tANI_U8 *) &mlmDisassocCnf.peerMacAddr,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003928 (tANI_U8 *) pMlmDisassocReq->peerMacAddr,
3929 sizeof(tSirMacAddr));
3930 mlmDisassocCnf.aid = pMlmDisassocReq->aid;
3931 mlmDisassocCnf.disassocTrigger = pMlmDisassocReq->disassocTrigger;
3932
3933 /* Update PE session ID*/
3934 mlmDisassocCnf.sessionId = pMlmDisassocReq->sessionId;
3935
Madan Mohan Koyyalamudib7f5a672012-11-29 11:17:46 -08003936 if(pMlmDisassocReq != NULL)
3937 {
3938 /// Free up buffer allocated for mlmDisassocReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303939 vos_mem_free(pMlmDisassocReq);
Madan Mohan Koyyalamudib7f5a672012-11-29 11:17:46 -08003940 pMac->lim.limDisassocDeauthCnfReq.pMlmDisassocReq = NULL;
3941 }
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003942
3943 limPostSmeMessage(pMac,
3944 LIM_MLM_DISASSOC_CNF,
3945 (tANI_U32 *) &mlmDisassocCnf);
3946 return eHAL_STATUS_SUCCESS;
3947}
3948
3949eHalStatus limDisassocTxCompleteCnf(tpAniSirGlobal pMac, tANI_U32 txCompleteSuccess)
3950{
3951 return limSendDisassocCnf(pMac);
3952}
3953
3954eHalStatus limDeauthTxCompleteCnf(tpAniSirGlobal pMac, tANI_U32 txCompleteSuccess)
3955{
3956 return limSendDeauthCnf(pMac);
3957}
3958
Jeff Johnson295189b2012-06-20 16:38:30 -07003959/**
3960 * \brief This function is called to send Disassociate frame.
3961 *
3962 *
3963 * \param pMac Pointer to Global MAC structure
3964 *
3965 * \param nReason Indicates the reason that need to be sent in
3966 * Disassociation frame
3967 *
3968 * \param peerMacAddr MAC address of the STA to which Disassociation frame is
3969 * sent
3970 *
3971 *
3972 */
3973
3974void
3975limSendDisassocMgmtFrame(tpAniSirGlobal pMac,
3976 tANI_U16 nReason,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003977 tSirMacAddr peer,
3978 tpPESession psessionEntry,
3979 tANI_BOOLEAN waitForAck)
Jeff Johnson295189b2012-06-20 16:38:30 -07003980{
3981 tDot11fDisassociation frm;
3982 tANI_U8 *pFrame;
3983 tSirRetStatus nSirStatus;
3984 tpSirMacMgmtHdr pMacHdr;
3985 tANI_U32 nBytes, nPayload, nStatus;
3986 void *pPacket;
3987 eHalStatus halstatus;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05303988 tANI_U32 txFlag = 0;
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003989 tANI_U32 val = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003990 if(NULL == psessionEntry)
3991 {
3992 return;
3993 }
3994
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303995 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07003996
3997 frm.Reason.code = nReason;
3998
3999 nStatus = dot11fGetPackedDisassociationSize( pMac, &frm, &nPayload );
4000 if ( DOT11F_FAILED( nStatus ) )
4001 {
4002 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004003 "or a Disassociation (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004004 nStatus );
4005 // We'll fall back on the worst case scenario:
4006 nPayload = sizeof( tDot11fDisassociation );
4007 }
4008 else if ( DOT11F_WARNED( nStatus ) )
4009 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004010 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07004011 "the packed size for a Disassociation "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004012 "(0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004013 }
4014
4015 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4016
4017 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
4018 ( tANI_U16 )nBytes, ( void** ) &pFrame,
4019 ( void** ) &pPacket );
4020 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4021 {
4022 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Dis"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004023 "association."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07004024 return;
4025 }
4026
4027 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304028 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004029
4030 // Next, we fill out the buffer descriptor:
4031 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
4032 SIR_MAC_MGMT_DISASSOC, peer,psessionEntry->selfMacAddr);
4033 if ( eSIR_SUCCESS != nSirStatus )
4034 {
4035 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004036 "tor for a Disassociation (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004037 nSirStatus );
4038 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
4039 ( void* ) pFrame, ( void* ) pPacket );
4040 return; // just allocated...
4041 }
4042
4043 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
4044
4045 // Prepare the BSSID
4046 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
4047
Chet Lanctot186b5732013-03-18 10:26:30 -07004048#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07004049 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07004050#endif
4051
Jeff Johnson295189b2012-06-20 16:38:30 -07004052 nStatus = dot11fPackDisassociation( pMac, &frm, pFrame +
4053 sizeof(tSirMacMgmtHdr),
4054 nPayload, &nPayload );
4055 if ( DOT11F_FAILED( nStatus ) )
4056 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004057 limLog( pMac, LOGE, FL("Failed to pack a Disassociation (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004058 nStatus );
4059 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
4060 ( void* ) pFrame, ( void* ) pPacket );
4061 return; // allocated!
4062 }
4063 else if ( DOT11F_WARNED( nStatus ) )
4064 {
4065 limLog( pMac, LOGW, FL("There were warnings while packing a D"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004066 "isassociation (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004067 }
4068
Abhishek Singhcd09b562013-12-24 16:02:20 +05304069 limLog( pMac, LOG1, FL("***Sessionid %d Sending Disassociation frame with "
4070 "reason %u and waitForAck %d to "MAC_ADDRESS_STR" ,From "
4071 MAC_ADDRESS_STR), psessionEntry->peSessionId, nReason, waitForAck,
4072 MAC_ADDR_ARRAY(pMacHdr->da),
4073 MAC_ADDR_ARRAY(psessionEntry->selfMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07004074
4075 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07004076 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
4077 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07004078 )
4079 {
4080 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
4081 }
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08004082
Ganesh K08bce952012-12-13 15:04:41 -08004083 if((psessionEntry->pePersona == VOS_P2P_CLIENT_MODE) ||
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304084 (psessionEntry->pePersona == VOS_P2P_GO_MODE) ||
4085 (psessionEntry->pePersona == VOS_STA_SAP_MODE))
Ganesh K08bce952012-12-13 15:04:41 -08004086 {
4087 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
4088 }
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08004089
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304090 if( IS_FW_IN_TX_PATH_FEATURE_ENABLE )
4091 {
4092 /* This frame will be sent on air by firmware,
4093 which will ensure that this frame goes out
4094 even though DEL_STA is sent immediately */
4095 /* Without this for DEL_STA command there is
4096 risk of flushing frame in BTQM queue without
4097 sending on air */
Agarwal Ashisha8e81f52014-04-02 01:59:52 +05304098 limLog( pMac, LOG1, FL("Sending Disassoc Frame over WQ5 to "MAC_ADDRESS_STR
4099 " From " MAC_ADDRESS_STR),MAC_ADDR_ARRAY(pMacHdr->da),
4100 MAC_ADDR_ARRAY(psessionEntry->selfMacAddr));
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304101 txFlag |= HAL_USE_FW_IN_TX_PATH;
4102 }
4103
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004104 if (waitForAck)
Jeff Johnson295189b2012-06-20 16:38:30 -07004105 {
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304106 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
4107 psessionEntry->peSessionId,
4108 pMacHdr->fc.subType));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004109 // Queue Disassociation frame in high priority WQ
4110 /* get the duration from the request */
4111 halstatus = halTxFrameWithTxComplete( pMac, pPacket, ( tANI_U16 ) nBytes,
4112 HAL_TXRX_FRM_802_11_MGMT,
4113 ANI_TXDIR_TODS,
4114 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4115 limTxComplete, pFrame, limDisassocTxCompleteCnf,
4116 txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304117 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
4118 psessionEntry->peSessionId,
4119 halstatus));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004120 val = SYS_MS_TO_TICKS(LIM_DISASSOC_DEAUTH_ACK_TIMEOUT);
Jeff Johnson295189b2012-06-20 16:38:30 -07004121
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004122 if (tx_timer_change(
4123 &pMac->lim.limTimers.gLimDisassocAckTimer, val, 0)
4124 != TX_SUCCESS)
4125 {
4126 limLog(pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004127 FL("Unable to change Disassoc ack Timer val"));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004128 return;
4129 }
4130 else if(TX_SUCCESS != tx_timer_activate(
4131 &pMac->lim.limTimers.gLimDisassocAckTimer))
4132 {
4133 limLog(pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004134 FL("Unable to activate Disassoc ack Timer"));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004135 limDeactivateAndChangeTimer(pMac, eLIM_DISASSOC_ACK_TIMER);
4136 return;
4137 }
4138 }
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08004139 else
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004140 {
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304141 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
4142 psessionEntry->peSessionId,
4143 pMacHdr->fc.subType));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004144 // Queue Disassociation frame in high priority WQ
4145 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4146 HAL_TXRX_FRM_802_11_MGMT,
4147 ANI_TXDIR_TODS,
4148 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4149 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304150 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
4151 psessionEntry->peSessionId,
4152 halstatus));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004153 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4154 {
4155 limLog( pMac, LOGE, FL("Failed to send Disassociation "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004156 "(%X)!"),
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004157 nSirStatus );
4158 //Pkt will be freed up by the callback
4159 return;
4160 }
4161 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004162} // End limSendDisassocMgmtFrame.
4163
4164/**
4165 * \brief This function is called to send a Deauthenticate frame
4166 *
4167 *
4168 * \param pMac Pointer to global MAC structure
4169 *
4170 * \param nReason Indicates the reason that need to be sent in the
4171 * Deauthenticate frame
4172 *
4173 * \param peeer address of the STA to which the frame is to be sent
4174 *
4175 *
4176 */
4177
4178void
4179limSendDeauthMgmtFrame(tpAniSirGlobal pMac,
4180 tANI_U16 nReason,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004181 tSirMacAddr peer,
4182 tpPESession psessionEntry,
4183 tANI_BOOLEAN waitForAck)
Jeff Johnson295189b2012-06-20 16:38:30 -07004184{
4185 tDot11fDeAuth frm;
4186 tANI_U8 *pFrame;
4187 tSirRetStatus nSirStatus;
4188 tpSirMacMgmtHdr pMacHdr;
4189 tANI_U32 nBytes, nPayload, nStatus;
4190 void *pPacket;
4191 eHalStatus halstatus;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304192 tANI_U32 txFlag = 0;
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004193 tANI_U32 val = 0;
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08004194#ifdef FEATURE_WLAN_TDLS
4195 tANI_U16 aid;
4196 tpDphHashNode pStaDs;
4197#endif
4198
Jeff Johnson295189b2012-06-20 16:38:30 -07004199 if(NULL == psessionEntry)
4200 {
4201 return;
4202 }
4203
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304204 vos_mem_set( ( tANI_U8* ) &frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004205
4206 frm.Reason.code = nReason;
4207
4208 nStatus = dot11fGetPackedDeAuthSize( pMac, &frm, &nPayload );
4209 if ( DOT11F_FAILED( nStatus ) )
4210 {
4211 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004212 "or a De-Authentication (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004213 nStatus );
4214 // We'll fall back on the worst case scenario:
4215 nPayload = sizeof( tDot11fDeAuth );
4216 }
4217 else if ( DOT11F_WARNED( nStatus ) )
4218 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004219 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07004220 "the packed size for a De-Authentication "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004221 "(0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004222 }
4223
4224 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4225
4226 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
4227 ( tANI_U16 )nBytes, ( void** ) &pFrame,
4228 ( void** ) &pPacket );
4229 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4230 {
4231 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a De-"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004232 "Authentication."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07004233 return;
4234 }
4235
4236 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304237 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004238
4239 // Next, we fill out the buffer descriptor:
4240 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
4241 SIR_MAC_MGMT_DEAUTH, peer,psessionEntry->selfMacAddr);
4242 if ( eSIR_SUCCESS != nSirStatus )
4243 {
4244 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004245 "tor for a De-Authentication (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004246 nSirStatus );
4247 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
4248 ( void* ) pFrame, ( void* ) pPacket );
4249 return; // just allocated...
4250 }
4251
4252 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
4253
4254 // Prepare the BSSID
4255 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
4256
Chet Lanctot186b5732013-03-18 10:26:30 -07004257#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07004258 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07004259#endif
4260
Jeff Johnson295189b2012-06-20 16:38:30 -07004261 nStatus = dot11fPackDeAuth( pMac, &frm, pFrame +
4262 sizeof(tSirMacMgmtHdr),
4263 nPayload, &nPayload );
4264 if ( DOT11F_FAILED( nStatus ) )
4265 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004266 limLog( pMac, LOGE, FL("Failed to pack a DeAuthentication (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004267 nStatus );
4268 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
4269 ( void* ) pFrame, ( void* ) pPacket );
4270 return;
4271 }
4272 else if ( DOT11F_WARNED( nStatus ) )
4273 {
4274 limLog( pMac, LOGW, FL("There were warnings while packing a D"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004275 "e-Authentication (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004276 }
Abhishek Singhcd09b562013-12-24 16:02:20 +05304277 limLog( pMac, LOG1, FL("***Sessionid %d Sending Deauth frame with "
4278 "reason %u and waitForAck %d to "MAC_ADDRESS_STR" ,From "
4279 MAC_ADDRESS_STR), psessionEntry->peSessionId, nReason, waitForAck,
4280 MAC_ADDR_ARRAY(pMacHdr->da),
4281 MAC_ADDR_ARRAY(psessionEntry->selfMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07004282
4283 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07004284 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
4285 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07004286 )
4287 {
4288 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
4289 }
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08004290
Ganesh K08bce952012-12-13 15:04:41 -08004291 if((psessionEntry->pePersona == VOS_P2P_CLIENT_MODE) ||
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304292 (psessionEntry->pePersona == VOS_P2P_GO_MODE) ||
4293 (psessionEntry->pePersona == VOS_STA_SAP_MODE))
Ganesh K08bce952012-12-13 15:04:41 -08004294 {
4295 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
4296 }
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08004297
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304298 if( IS_FW_IN_TX_PATH_FEATURE_ENABLE )
4299 {
4300 /* This frame will be sent on air by firmware,
4301 which will ensure that this frame goes out
4302 even though DEL_STA is sent immediately */
4303 /* Without this for DEL_STA command there is
4304 risk of flushing frame in BTQM queue without
4305 sending on air */
Agarwal Ashisha8e81f52014-04-02 01:59:52 +05304306 limLog( pMac, LOG1, FL("Sending Deauth Frame over WQ5 to "MAC_ADDRESS_STR
4307 " From " MAC_ADDRESS_STR),MAC_ADDR_ARRAY(pMacHdr->da),
4308 MAC_ADDR_ARRAY(psessionEntry->selfMacAddr));
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304309 txFlag |= HAL_USE_FW_IN_TX_PATH;
4310 }
4311
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08004312#ifdef FEATURE_WLAN_TDLS
4313 pStaDs = dphLookupHashEntry(pMac, peer, &aid, &psessionEntry->dph.dphHashTable);
4314#endif
4315
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004316 if (waitForAck)
Jeff Johnson295189b2012-06-20 16:38:30 -07004317 {
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304318 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
4319 psessionEntry->peSessionId,
4320 pMacHdr->fc.subType));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004321 // Queue Disassociation frame in high priority WQ
4322 halstatus = halTxFrameWithTxComplete( pMac, pPacket, ( tANI_U16 ) nBytes,
4323 HAL_TXRX_FRM_802_11_MGMT,
4324 ANI_TXDIR_TODS,
4325 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4326 limTxComplete, pFrame, limDeauthTxCompleteCnf, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304327 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
4328 psessionEntry->peSessionId,
4329 halstatus));
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304330 if (!HAL_STATUS_SUCCESS(halstatus))
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004331 {
4332 limLog( pMac, LOGE, FL("Failed to send De-Authentication "
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304333 "(%X)!"),
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004334 nSirStatus );
Gopichand Nakkala4261ea52012-12-31 16:43:00 -08004335 //Pkt will be freed up by the callback limTxComplete
4336
4337 /*Call limProcessDeauthAckTimeout which will send
4338 * DeauthCnf for this frame
4339 */
4340 limProcessDeauthAckTimeout(pMac);
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004341 return;
4342 }
4343
4344 val = SYS_MS_TO_TICKS(LIM_DISASSOC_DEAUTH_ACK_TIMEOUT);
4345
4346 if (tx_timer_change(
4347 &pMac->lim.limTimers.gLimDeauthAckTimer, val, 0)
4348 != TX_SUCCESS)
4349 {
4350 limLog(pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004351 FL("Unable to change Deauth ack Timer val"));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004352 return;
4353 }
4354 else if(TX_SUCCESS != tx_timer_activate(
4355 &pMac->lim.limTimers.gLimDeauthAckTimer))
4356 {
4357 limLog(pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004358 FL("Unable to activate Deauth ack Timer"));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004359 limDeactivateAndChangeTimer(pMac, eLIM_DEAUTH_ACK_TIMER);
4360 return;
4361 }
4362 }
4363 else
4364 {
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304365 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
4366 psessionEntry->peSessionId,
4367 pMacHdr->fc.subType));
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08004368#ifdef FEATURE_WLAN_TDLS
4369 if ((NULL != pStaDs) && (STA_ENTRY_TDLS_PEER == pStaDs->staType))
4370 {
4371 // Queue Disassociation frame in high priority WQ
4372 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004373 HAL_TXRX_FRM_802_11_MGMT,
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08004374 ANI_TXDIR_IBSS,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004375 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4376 limTxComplete, pFrame, txFlag );
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08004377 }
4378 else
4379 {
4380#endif
4381 // Queue Disassociation frame in high priority WQ
4382 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4383 HAL_TXRX_FRM_802_11_MGMT,
4384 ANI_TXDIR_TODS,
4385 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4386 limTxComplete, pFrame, txFlag );
4387#ifdef FEATURE_WLAN_TDLS
4388 }
4389#endif
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304390 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
4391 psessionEntry->peSessionId,
4392 halstatus));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004393 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4394 {
4395 limLog( pMac, LOGE, FL("Failed to send De-Authentication "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004396 "(%X)!"),
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004397 nSirStatus );
4398 //Pkt will be freed up by the callback
4399 return;
4400 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004401 }
4402
4403} // End limSendDeauthMgmtFrame.
4404
4405
4406#ifdef ANI_SUPPORT_11H
4407/**
4408 * \brief Send a Measurement Report Action frame
4409 *
4410 *
4411 * \param pMac Pointer to the global MAC structure
4412 *
4413 * \param pMeasReqFrame Address of a tSirMacMeasReqActionFrame
4414 *
4415 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
4416 *
4417 *
4418 */
4419
4420tSirRetStatus
4421limSendMeasReportFrame(tpAniSirGlobal pMac,
4422 tpSirMacMeasReqActionFrame pMeasReqFrame,
4423 tSirMacAddr peer)
4424{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304425 tDot11fMeasurementReport frm;
4426 tANI_U8 *pFrame;
4427 tSirRetStatus nSirStatus;
4428 tpSirMacMgmtHdr pMacHdr;
4429 tANI_U32 nBytes, nPayload, nStatus, nCfg;
4430 void *pPacket;
4431 eHalStatus halstatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07004432
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304433 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004434
4435 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
4436 frm.Action.action = SIR_MAC_ACTION_MEASURE_REPORT_ID;
4437 frm.DialogToken.token = pMeasReqFrame->actionHeader.dialogToken;
4438
4439 switch ( pMeasReqFrame->measReqIE.measType )
4440 {
4441 case SIR_MAC_BASIC_MEASUREMENT_TYPE:
4442 nSirStatus =
4443 PopulateDot11fMeasurementReport0( pMac, pMeasReqFrame,
4444 &frm.MeasurementReport );
4445 break;
4446 case SIR_MAC_CCA_MEASUREMENT_TYPE:
4447 nSirStatus =
4448 PopulateDot11fMeasurementReport1( pMac, pMeasReqFrame,
4449 &frm.MeasurementReport );
4450 break;
4451 case SIR_MAC_RPI_MEASUREMENT_TYPE:
4452 nSirStatus =
4453 PopulateDot11fMeasurementReport2( pMac, pMeasReqFrame,
4454 &frm.MeasurementReport );
4455 break;
4456 default:
4457 limLog( pMac, LOGE, FL("Unknown measurement type %d in limSen"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004458 "dMeasReportFrame."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004459 pMeasReqFrame->measReqIE.measType );
4460 return eSIR_FAILURE;
4461 }
4462
4463 if ( eSIR_SUCCESS != nSirStatus ) return eSIR_FAILURE;
4464
4465 nStatus = dot11fGetPackedMeasurementReportSize( pMac, &frm, &nPayload );
4466 if ( DOT11F_FAILED( nStatus ) )
4467 {
4468 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004469 "or a Measurement Report (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004470 nStatus );
4471 // We'll fall back on the worst case scenario:
4472 nPayload = sizeof( tDot11fMeasurementReport );
4473 }
4474 else if ( DOT11F_WARNED( nStatus ) )
4475 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004476 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07004477 "the packed size for a Measurement Rep"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004478 "ort (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004479 }
4480
4481 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4482
4483 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
4484 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4485 {
4486 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a De-"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004487 "Authentication."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07004488 return eSIR_FAILURE;
4489 }
4490
4491 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304492 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004493
4494 // Next, we fill out the buffer descriptor:
4495 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
4496 SIR_MAC_MGMT_ACTION, peer);
4497 if ( eSIR_SUCCESS != nSirStatus )
4498 {
4499 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004500 "tor for a Measurement Report (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004501 nSirStatus );
4502 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4503 return eSIR_FAILURE; // just allocated...
4504 }
4505
4506 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
4507
4508 nCfg = 6;
4509 nSirStatus = wlan_cfgGetStr( pMac, WNI_CFG_BSSID, pMacHdr->bssId, &nCfg );
4510 if ( eSIR_SUCCESS != nSirStatus )
4511 {
4512 limLog( pMac, LOGE, FL("Failed to retrieve WNI_CFG_BSSID from"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004513 " CFG (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004514 nSirStatus );
4515 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4516 return eSIR_FAILURE; // just allocated...
4517 }
4518
Chet Lanctot186b5732013-03-18 10:26:30 -07004519#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07004520 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07004521#endif
4522
Jeff Johnson295189b2012-06-20 16:38:30 -07004523 nStatus = dot11fPackMeasurementReport( pMac, &frm, pFrame +
4524 sizeof(tSirMacMgmtHdr),
4525 nPayload, &nPayload );
4526 if ( DOT11F_FAILED( nStatus ) )
4527 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004528 limLog( pMac, LOGE, FL("Failed to pack a Measurement Report (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004529 nStatus );
4530 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4531 return eSIR_FAILURE; // allocated!
4532 }
4533 else if ( DOT11F_WARNED( nStatus ) )
4534 {
4535 limLog( pMac, LOGW, FL("There were warnings while packing a M"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004536 "easurement Report (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004537 }
4538
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304539 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
4540 ((psessionEntry)? psessionEntry->peSessionId : NO_SESSION),
4541 pMacHdr->fc.subType));
Jeff Johnson295189b2012-06-20 16:38:30 -07004542 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4543 HAL_TXRX_FRM_802_11_MGMT,
4544 ANI_TXDIR_TODS,
4545 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4546 limTxComplete, pFrame, 0 );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304547 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
4548 ((psessionEntry)? psessionEntry->peSessionId : NO_SESSION),
4549 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07004550 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4551 {
4552 limLog( pMac, LOGE, FL("Failed to send a Measurement Report "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004553 "(%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07004554 nSirStatus );
4555 //Pkt will be freed up by the callback
4556 return eSIR_FAILURE; // just allocated...
4557 }
4558
4559 return eSIR_SUCCESS;
4560
4561} // End limSendMeasReportFrame.
4562
4563
4564/**
4565 * \brief Send a TPC Request Action frame
4566 *
4567 *
4568 * \param pMac Pointer to the global MAC datastructure
4569 *
4570 * \param peer MAC address to which the frame should be sent
4571 *
4572 *
4573 */
4574
4575void
4576limSendTpcRequestFrame(tpAniSirGlobal pMac,
4577 tSirMacAddr peer)
4578{
4579 tDot11fTPCRequest frm;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304580 tANI_U8 *pFrame;
Jeff Johnson295189b2012-06-20 16:38:30 -07004581 tSirRetStatus nSirStatus;
4582 tpSirMacMgmtHdr pMacHdr;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304583 tANI_U32 nBytes, nPayload, nStatus, nCfg;
4584 void *pPacket;
4585 eHalStatus halstatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07004586
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304587 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004588
4589 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
4590 frm.Action.action = SIR_MAC_ACTION_TPC_REQUEST_ID;
4591 frm.DialogToken.token = 1;
4592 frm.TPCRequest.present = 1;
4593
4594 nStatus = dot11fGetPackedTPCRequestSize( pMac, &frm, &nPayload );
4595 if ( DOT11F_FAILED( nStatus ) )
4596 {
4597 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004598 "or a TPC Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004599 nStatus );
4600 // We'll fall back on the worst case scenario:
4601 nPayload = sizeof( tDot11fTPCRequest );
4602 }
4603 else if ( DOT11F_WARNED( nStatus ) )
4604 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004605 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07004606 "the packed size for a TPC Request (0x"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004607 "%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004608 }
4609
4610 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4611
4612 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
4613 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4614 {
4615 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a TPC"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004616 " Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07004617 return;
4618 }
4619
4620 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304621 vos_mem_set(pFrame, nBytes,0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004622
4623 // Next, we fill out the buffer descriptor:
4624 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
4625 SIR_MAC_MGMT_ACTION, peer);
4626 if ( eSIR_SUCCESS != nSirStatus )
4627 {
4628 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004629 "tor for a TPC Request (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004630 nSirStatus );
4631 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4632 return; // just allocated...
4633 }
4634
4635 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
4636
4637 nCfg = 6;
4638 nSirStatus = wlan_cfgGetStr( pMac, WNI_CFG_BSSID, pMacHdr->bssId, &nCfg );
4639 if ( eSIR_SUCCESS != nSirStatus )
4640 {
4641 limLog( pMac, LOGE, FL("Failed to retrieve WNI_CFG_BSSID from"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004642 " CFG (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004643 nSirStatus );
4644 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4645 return; // just allocated...
4646 }
4647
Chet Lanctot186b5732013-03-18 10:26:30 -07004648#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07004649 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07004650#endif
4651
Jeff Johnson295189b2012-06-20 16:38:30 -07004652 nStatus = dot11fPackTPCRequest( pMac, &frm, pFrame +
4653 sizeof(tSirMacMgmtHdr),
4654 nPayload, &nPayload );
4655 if ( DOT11F_FAILED( nStatus ) )
4656 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004657 limLog( pMac, LOGE, FL("Failed to pack a TPC Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004658 nStatus );
4659 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4660 return; // allocated!
4661 }
4662 else if ( DOT11F_WARNED( nStatus ) )
4663 {
4664 limLog( pMac, LOGW, FL("There were warnings while packing a T"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004665 "PC Request (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004666 }
4667
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304668 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
4669 ((psessionEntry)? psessionEntry->peSessionId : NO_SESSION),
4670 pMacHdr->fc.subType));
Jeff Johnson295189b2012-06-20 16:38:30 -07004671 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4672 HAL_TXRX_FRM_802_11_MGMT,
4673 ANI_TXDIR_TODS,
4674 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4675 limTxComplete, pFrame, 0 );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304676 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
4677 ((psessionEntry)? psessionEntry->peSessionId : NO_SESSION),
4678 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07004679 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4680 {
4681 limLog( pMac, LOGE, FL("Failed to send a TPC Request "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004682 "(%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07004683 nSirStatus );
4684 //Pkt will be freed up by the callback
4685 return;
4686 }
4687
4688} // End limSendTpcRequestFrame.
4689
4690
4691/**
4692 * \brief Send a TPC Report Action frame
4693 *
4694 *
4695 * \param pMac Pointer to the global MAC datastructure
4696 *
4697 * \param pTpcReqFrame Pointer to the received TPC Request
4698 *
4699 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
4700 *
4701 *
4702 */
4703
4704tSirRetStatus
4705limSendTpcReportFrame(tpAniSirGlobal pMac,
4706 tpSirMacTpcReqActionFrame pTpcReqFrame,
4707 tSirMacAddr peer)
4708{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304709 tDot11fTPCReport frm;
4710 tANI_U8 *pFrame;
4711 tSirRetStatus nSirStatus;
4712 tpSirMacMgmtHdr pMacHdr;
4713 tANI_U32 nBytes, nPayload, nStatus, nCfg;
4714 void *pPacket;
4715 eHalStatus halstatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07004716
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304717 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004718
4719 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
4720 frm.Action.action = SIR_MAC_ACTION_TPC_REPORT_ID;
4721 frm.DialogToken.token = pTpcReqFrame->actionHeader.dialogToken;
4722
4723 // FramesToDo: On the Gen4_TVM branch, there was a comment:
4724 // "misplaced this function, need to replace:
4725 // txPower = halGetRateToPwrValue(pMac, staid,
4726 // pMac->lim.gLimCurrentChannelId, 0);
4727 frm.TPCReport.tx_power = 0;
4728 frm.TPCReport.link_margin = 0;
4729 frm.TPCReport.present = 1;
4730
4731 nStatus = dot11fGetPackedTPCReportSize( pMac, &frm, &nPayload );
4732 if ( DOT11F_FAILED( nStatus ) )
4733 {
4734 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004735 "or a TPC Report (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004736 nStatus );
4737 // We'll fall back on the worst case scenario:
4738 nPayload = sizeof( tDot11fTPCReport );
4739 }
4740 else if ( DOT11F_WARNED( nStatus ) )
4741 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004742 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07004743 "the packed size for a TPC Report (0x"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004744 "%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004745 }
4746
4747 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4748
4749 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
4750 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4751 {
4752 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a TPC"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004753 " Report."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07004754 return eSIR_FAILURE;
4755 }
4756
4757 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304758 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004759
4760 // Next, we fill out the buffer descriptor:
4761 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
4762 SIR_MAC_MGMT_ACTION, peer);
4763 if ( eSIR_SUCCESS != nSirStatus )
4764 {
4765 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004766 "tor for a TPC Report (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004767 nSirStatus );
4768 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4769 return eSIR_FAILURE; // just allocated...
4770 }
4771
4772 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
4773
4774 nCfg = 6;
4775 nSirStatus = wlan_cfgGetStr( pMac, WNI_CFG_BSSID, pMacHdr->bssId, &nCfg );
4776 if ( eSIR_SUCCESS != nSirStatus )
4777 {
4778 limLog( pMac, LOGE, FL("Failed to retrieve WNI_CFG_BSSID from"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004779 " CFG (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004780 nSirStatus );
4781 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4782 return eSIR_FAILURE; // just allocated...
4783 }
4784
Chet Lanctot186b5732013-03-18 10:26:30 -07004785#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07004786 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07004787#endif
4788
Jeff Johnson295189b2012-06-20 16:38:30 -07004789 nStatus = dot11fPackTPCReport( pMac, &frm, pFrame +
4790 sizeof(tSirMacMgmtHdr),
4791 nPayload, &nPayload );
4792 if ( DOT11F_FAILED( nStatus ) )
4793 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004794 limLog( pMac, LOGE, FL("Failed to pack a TPC Report (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004795 nStatus );
4796 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4797 return eSIR_FAILURE; // allocated!
4798 }
4799 else if ( DOT11F_WARNED( nStatus ) )
4800 {
4801 limLog( pMac, LOGW, FL("There were warnings while packing a T"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004802 "PC Report (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004803 }
4804
4805
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304806 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
4807 ((psessionEntry)? psessionEntry->peSessionId : NO_SESSION),
4808 pMacHdr->fc.subType));
Jeff Johnson295189b2012-06-20 16:38:30 -07004809 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4810 HAL_TXRX_FRM_802_11_MGMT,
4811 ANI_TXDIR_TODS,
4812 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4813 limTxComplete, pFrame, 0 );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304814 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
4815 ((psessionEntry)? psessionEntry->peSessionId : NO_SESSION),
4816 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07004817 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4818 {
4819 limLog( pMac, LOGE, FL("Failed to send a TPC Report "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004820 "(%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07004821 nSirStatus );
4822 //Pkt will be freed up by the callback
4823 return eSIR_FAILURE; // just allocated...
4824 }
4825
4826 return eSIR_SUCCESS;
4827
4828} // End limSendTpcReportFrame.
4829#endif //ANI_SUPPORT_11H
4830
4831
Jeff Johnson295189b2012-06-20 16:38:30 -07004832/**
4833 * \brief Send a Channel Switch Announcement
4834 *
4835 *
4836 * \param pMac Pointer to the global MAC datastructure
4837 *
4838 * \param peer MAC address to which this frame will be sent
4839 *
4840 * \param nMode
4841 *
4842 * \param nNewChannel
4843 *
4844 * \param nCount
4845 *
4846 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
4847 *
4848 *
4849 */
4850
4851tSirRetStatus
4852limSendChannelSwitchMgmtFrame(tpAniSirGlobal pMac,
4853 tSirMacAddr peer,
Jeff Johnsone7245742012-09-05 17:12:55 -07004854 tANI_U8 nMode,
4855 tANI_U8 nNewChannel,
4856 tANI_U8 nCount,
4857 tpPESession psessionEntry )
Jeff Johnson295189b2012-06-20 16:38:30 -07004858{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304859 tDot11fChannelSwitch frm;
4860 tANI_U8 *pFrame;
4861 tSirRetStatus nSirStatus;
4862 tpSirMacMgmtHdr pMacHdr;
4863 tANI_U32 nBytes, nPayload, nStatus;//, nCfg;
4864 void *pPacket;
4865 eHalStatus halstatus;
4866 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004867
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304868 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004869
4870 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
4871 frm.Action.action = SIR_MAC_ACTION_CHANNEL_SWITCH_ID;
4872 frm.ChanSwitchAnn.switchMode = nMode;
4873 frm.ChanSwitchAnn.newChannel = nNewChannel;
4874 frm.ChanSwitchAnn.switchCount = nCount;
4875 frm.ChanSwitchAnn.present = 1;
4876
4877 nStatus = dot11fGetPackedChannelSwitchSize( pMac, &frm, &nPayload );
4878 if ( DOT11F_FAILED( nStatus ) )
4879 {
4880 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004881 "or a Channel Switch (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004882 nStatus );
4883 // We'll fall back on the worst case scenario:
4884 nPayload = sizeof( tDot11fChannelSwitch );
4885 }
4886 else if ( DOT11F_WARNED( nStatus ) )
4887 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004888 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07004889 "the packed size for a Channel Switch (0x"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004890 "%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004891 }
4892
4893 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4894
4895 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
4896 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4897 {
4898 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a TPC"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004899 " Report."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07004900 return eSIR_FAILURE;
4901 }
4902
4903 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304904 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004905
4906 // Next, we fill out the buffer descriptor:
4907 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
Jeff Johnsone7245742012-09-05 17:12:55 -07004908 SIR_MAC_MGMT_ACTION, peer, psessionEntry->selfMacAddr);
4909 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304910 vos_mem_copy( (tANI_U8 *) pMacHdr->bssId,
4911 (tANI_U8 *) psessionEntry->bssId,
4912 sizeof( tSirMacAddr ));
Jeff Johnson295189b2012-06-20 16:38:30 -07004913 if ( eSIR_SUCCESS != nSirStatus )
4914 {
4915 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004916 "tor for a Channel Switch (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004917 nSirStatus );
4918 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4919 return eSIR_FAILURE; // just allocated...
4920 }
4921
Jeff Johnsone7245742012-09-05 17:12:55 -07004922#if 0
Jeff Johnson295189b2012-06-20 16:38:30 -07004923 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
4924
4925 nCfg = 6;
4926 nSirStatus = wlan_cfgGetStr( pMac, WNI_CFG_BSSID, pMacHdr->bssId, &nCfg );
4927 if ( eSIR_SUCCESS != nSirStatus )
4928 {
4929 limLog( pMac, LOGE, FL("Failed to retrieve WNI_CFG_BSSID from"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004930 " CFG (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004931 nSirStatus );
4932 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4933 return eSIR_FAILURE; // just allocated...
4934 }
Jeff Johnsone7245742012-09-05 17:12:55 -07004935#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07004936
4937#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07004938 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07004939#endif
4940
Jeff Johnson295189b2012-06-20 16:38:30 -07004941 nStatus = dot11fPackChannelSwitch( pMac, &frm, pFrame +
4942 sizeof(tSirMacMgmtHdr),
4943 nPayload, &nPayload );
4944 if ( DOT11F_FAILED( nStatus ) )
4945 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004946 limLog( pMac, LOGE, FL("Failed to pack a Channel Switch (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004947 nStatus );
4948 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4949 return eSIR_FAILURE; // allocated!
4950 }
4951 else if ( DOT11F_WARNED( nStatus ) )
4952 {
4953 limLog( pMac, LOGW, FL("There were warnings while packing a C"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004954 "hannel Switch (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004955 }
4956
Jeff Johnsone7245742012-09-05 17:12:55 -07004957 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnsone7245742012-09-05 17:12:55 -07004958 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
4959 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnsone7245742012-09-05 17:12:55 -07004960 )
4961 {
4962 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
4963 }
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304964
4965 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
4966 psessionEntry->peSessionId,
4967 pMacHdr->fc.subType));
Jeff Johnson295189b2012-06-20 16:38:30 -07004968 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4969 HAL_TXRX_FRM_802_11_MGMT,
4970 ANI_TXDIR_TODS,
4971 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
Jeff Johnsone7245742012-09-05 17:12:55 -07004972 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304973 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
4974 psessionEntry->peSessionId,
4975 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07004976 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4977 {
4978 limLog( pMac, LOGE, FL("Failed to send a Channel Switch "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004979 "(%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07004980 nSirStatus );
4981 //Pkt will be freed up by the callback
4982 return eSIR_FAILURE;
4983 }
4984
4985 return eSIR_SUCCESS;
4986
4987} // End limSendChannelSwitchMgmtFrame.
4988
Jeff Johnson295189b2012-06-20 16:38:30 -07004989
4990
Mohit Khanna4a70d262012-09-11 16:30:12 -07004991#ifdef WLAN_FEATURE_11AC
4992tSirRetStatus
4993limSendVHTOpmodeNotificationFrame(tpAniSirGlobal pMac,
4994 tSirMacAddr peer,
4995 tANI_U8 nMode,
4996 tpPESession psessionEntry )
4997{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304998 tDot11fOperatingMode frm;
4999 tANI_U8 *pFrame;
5000 tSirRetStatus nSirStatus;
5001 tpSirMacMgmtHdr pMacHdr;
5002 tANI_U32 nBytes, nPayload = 0, nStatus;//, nCfg;
5003 void *pPacket;
5004 eHalStatus halstatus;
5005 tANI_U32 txFlag = 0;
Mohit Khanna4a70d262012-09-11 16:30:12 -07005006
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305007 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Mohit Khanna4a70d262012-09-11 16:30:12 -07005008
5009 frm.Category.category = SIR_MAC_ACTION_VHT;
5010 frm.Action.action = SIR_MAC_VHT_OPMODE_NOTIFICATION;
5011 frm.OperatingMode.chanWidth = nMode;
5012 frm.OperatingMode.rxNSS = 0;
5013 frm.OperatingMode.rxNSSType = 0;
5014
5015 nStatus = dot11fGetPackedOperatingModeSize( pMac, &frm, &nPayload );
5016 if ( DOT11F_FAILED( nStatus ) )
5017 {
5018 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005019 "or a Operating Mode (0x%08x)."),
Mohit Khanna4a70d262012-09-11 16:30:12 -07005020 nStatus );
5021 // We'll fall back on the worst case scenario:
5022 nPayload = sizeof( tDot11fOperatingMode);
5023 }
5024 else if ( DOT11F_WARNED( nStatus ) )
5025 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005026 limLog( pMac, LOGW, FL("There were warnings while calculating "
Mohit Khanna4a70d262012-09-11 16:30:12 -07005027 "the packed size for a Operating Mode (0x"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005028 "%08x)."), nStatus );
Mohit Khanna4a70d262012-09-11 16:30:12 -07005029 }
5030
5031 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
5032
5033 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
5034 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
5035 {
5036 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Operating Mode"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005037 " Report."), nBytes );
Mohit Khanna4a70d262012-09-11 16:30:12 -07005038 return eSIR_FAILURE;
5039 }
5040
5041 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305042 vos_mem_set( pFrame, nBytes, 0 );
Mohit Khanna4a70d262012-09-11 16:30:12 -07005043
5044
5045 // Next, we fill out the buffer descriptor:
5046 if(psessionEntry->pePersona == VOS_STA_SAP_MODE) {
5047 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
5048 SIR_MAC_MGMT_ACTION, peer, psessionEntry->selfMacAddr);
5049 } else
5050 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
5051 SIR_MAC_MGMT_ACTION, psessionEntry->bssId, psessionEntry->selfMacAddr);
5052 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305053 vos_mem_copy( (tANI_U8 *) pMacHdr->bssId,
5054 (tANI_U8 *) psessionEntry->bssId,
5055 sizeof( tSirMacAddr ));
Mohit Khanna4a70d262012-09-11 16:30:12 -07005056 if ( eSIR_SUCCESS != nSirStatus )
5057 {
5058 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005059 "tor for a Operating Mode (%d)."),
Mohit Khanna4a70d262012-09-11 16:30:12 -07005060 nSirStatus );
5061 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
5062 return eSIR_FAILURE; // just allocated...
5063 }
5064 nStatus = dot11fPackOperatingMode( pMac, &frm, pFrame +
5065 sizeof(tSirMacMgmtHdr),
5066 nPayload, &nPayload );
5067 if ( DOT11F_FAILED( nStatus ) )
5068 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005069 limLog( pMac, LOGE, FL("Failed to pack a Operating Mode (0x%08x)."),
Mohit Khanna4a70d262012-09-11 16:30:12 -07005070 nStatus );
5071 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
5072 return eSIR_FAILURE; // allocated!
5073 }
5074 else if ( DOT11F_WARNED( nStatus ) )
5075 {
5076 limLog( pMac, LOGW, FL("There were warnings while packing a Operating Mode"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005077 " (0x%08x)."), nStatus );
Mohit Khanna4a70d262012-09-11 16:30:12 -07005078 }
5079 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Mohit Khanna4a70d262012-09-11 16:30:12 -07005080 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
5081 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Mohit Khanna4a70d262012-09-11 16:30:12 -07005082 )
5083 {
5084 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
5085 }
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05305086
5087 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
5088 psessionEntry->peSessionId,
5089 pMacHdr->fc.subType));
Mohit Khanna4a70d262012-09-11 16:30:12 -07005090 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
5091 HAL_TXRX_FRM_802_11_MGMT,
5092 ANI_TXDIR_TODS,
5093 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
5094 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05305095 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
5096 psessionEntry->peSessionId,
5097 halstatus));
Mohit Khanna4a70d262012-09-11 16:30:12 -07005098 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
5099 {
5100 limLog( pMac, LOGE, FL("Failed to send a Channel Switch "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005101 "(%X)!"),
Mohit Khanna4a70d262012-09-11 16:30:12 -07005102 nSirStatus );
5103 //Pkt will be freed up by the callback
5104 return eSIR_FAILURE;
5105 }
5106
5107 return eSIR_SUCCESS;
5108}
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005109
5110/**
5111 * \brief Send a VHT Channel Switch Announcement
5112 *
5113 *
5114 * \param pMac Pointer to the global MAC datastructure
5115 *
5116 * \param peer MAC address to which this frame will be sent
5117 *
5118 * \param nChanWidth
5119 *
5120 * \param nNewChannel
5121 *
5122 *
5123 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
5124 *
5125 *
5126 */
5127
5128tSirRetStatus
5129limSendVHTChannelSwitchMgmtFrame(tpAniSirGlobal pMac,
5130 tSirMacAddr peer,
5131 tANI_U8 nChanWidth,
5132 tANI_U8 nNewChannel,
5133 tANI_U8 ncbMode,
5134 tpPESession psessionEntry )
5135{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05305136 tDot11fChannelSwitch frm;
5137 tANI_U8 *pFrame;
5138 tSirRetStatus nSirStatus;
5139 tpSirMacMgmtHdr pMacHdr;
5140 tANI_U32 nBytes, nPayload, nStatus;//, nCfg;
5141 void *pPacket;
5142 eHalStatus halstatus;
5143 tANI_U32 txFlag = 0;
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005144
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305145 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005146
5147
5148 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
5149 frm.Action.action = SIR_MAC_ACTION_CHANNEL_SWITCH_ID;
5150 frm.ChanSwitchAnn.switchMode = 1;
5151 frm.ChanSwitchAnn.newChannel = nNewChannel;
5152 frm.ChanSwitchAnn.switchCount = 1;
5153 frm.ExtChanSwitchAnn.secondaryChannelOffset = limGetHTCBState(ncbMode);
5154 frm.ExtChanSwitchAnn.present = 1;
5155 frm.WiderBWChanSwitchAnn.newChanWidth = nChanWidth;
5156 frm.WiderBWChanSwitchAnn.newCenterChanFreq0 = limGetCenterChannel(pMac,nNewChannel,ncbMode,nChanWidth);
5157 frm.WiderBWChanSwitchAnn.newCenterChanFreq1 = 0;
5158 frm.ChanSwitchAnn.present = 1;
5159 frm.WiderBWChanSwitchAnn.present = 1;
5160
5161 nStatus = dot11fGetPackedChannelSwitchSize( pMac, &frm, &nPayload );
5162 if ( DOT11F_FAILED( nStatus ) )
5163 {
5164 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005165 "or a Channel Switch (0x%08x)."),
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005166 nStatus );
5167 // We'll fall back on the worst case scenario:
5168 nPayload = sizeof( tDot11fChannelSwitch );
5169 }
5170 else if ( DOT11F_WARNED( nStatus ) )
5171 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005172 limLog( pMac, LOGW, FL("There were warnings while calculating "
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005173 "the packed size for a Channel Switch (0x"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005174 "%08x)."), nStatus );
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005175 }
5176
5177 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
5178
5179 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
5180 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
5181 {
5182 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a TPC"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005183 " Report."), nBytes );
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005184 return eSIR_FAILURE;
5185 }
5186 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305187 vos_mem_set( pFrame, nBytes, 0 );
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005188
5189 // Next, we fill out the buffer descriptor:
5190 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
5191 SIR_MAC_MGMT_ACTION, peer, psessionEntry->selfMacAddr);
5192 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305193 vos_mem_copy( (tANI_U8 *) pMacHdr->bssId,
5194 (tANI_U8 *) psessionEntry->bssId,
5195 sizeof( tSirMacAddr ));
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005196 if ( eSIR_SUCCESS != nSirStatus )
5197 {
5198 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005199 "tor for a Channel Switch (%d)."),
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005200 nSirStatus );
5201 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
5202 return eSIR_FAILURE; // just allocated...
5203 }
5204 nStatus = dot11fPackChannelSwitch( pMac, &frm, pFrame +
5205 sizeof(tSirMacMgmtHdr),
5206 nPayload, &nPayload );
5207 if ( DOT11F_FAILED( nStatus ) )
5208 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005209 limLog( pMac, LOGE, FL("Failed to pack a Channel Switch (0x%08x)."),
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005210 nStatus );
5211 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
5212 return eSIR_FAILURE; // allocated!
5213 }
5214 else if ( DOT11F_WARNED( nStatus ) )
5215 {
5216 limLog( pMac, LOGW, FL("There were warnings while packing a C"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005217 "hannel Switch (0x%08x)."), nStatus );
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005218 }
5219
5220 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005221 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
5222 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005223 )
5224 {
5225 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
5226 }
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05305227
5228 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
5229 psessionEntry->peSessionId,
5230 pMacHdr->fc.subType));
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005231 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
5232 HAL_TXRX_FRM_802_11_MGMT,
5233 ANI_TXDIR_TODS,
5234 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
5235 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05305236 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
5237 psessionEntry->peSessionId,
5238 halstatus));
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005239 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
5240 {
5241 limLog( pMac, LOGE, FL("Failed to send a Channel Switch "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005242 "(%X)!"),
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005243 nSirStatus );
5244 //Pkt will be freed up by the callback
5245 return eSIR_FAILURE;
5246 }
5247
5248 return eSIR_SUCCESS;
5249
5250} // End limSendVHTChannelSwitchMgmtFrame.
5251
5252
5253
Mohit Khanna4a70d262012-09-11 16:30:12 -07005254#endif
5255
Jeff Johnson295189b2012-06-20 16:38:30 -07005256/**
5257 * \brief Send an ADDBA Req Action Frame to peer
5258 *
5259 * \sa limSendAddBAReq
5260 *
5261 * \param pMac The global tpAniSirGlobal object
5262 *
5263 * \param pMlmAddBAReq A pointer to tLimMlmAddBAReq. This contains
5264 * the necessary parameters reqd by PE send the ADDBA Req Action
5265 * Frame to the peer
5266 *
5267 * \return eSIR_SUCCESS if setup completes successfully
5268 * eSIR_FAILURE is some problem is encountered
5269 */
5270tSirRetStatus limSendAddBAReq( tpAniSirGlobal pMac,
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305271 tpLimMlmAddBAReq pMlmAddBAReq, tpPESession psessionEntry)
Jeff Johnson295189b2012-06-20 16:38:30 -07005272{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05305273 tDot11fAddBAReq frmAddBAReq;
5274 tANI_U8 *pAddBAReqBuffer = NULL;
5275 tpSirMacMgmtHdr pMacHdr;
5276 tANI_U32 frameLen = 0, nStatus, nPayload;
5277 tSirRetStatus statusCode;
5278 eHalStatus halStatus;
5279 void *pPacket;
5280 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005281
5282 if(NULL == psessionEntry)
5283 {
5284 return eSIR_FAILURE;
5285 }
5286
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305287 vos_mem_set( (void *) &frmAddBAReq, sizeof( frmAddBAReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005288
5289 // Category - 3 (BA)
5290 frmAddBAReq.Category.category = SIR_MAC_ACTION_BLKACK;
5291
5292 // Action - 0 (ADDBA Req)
5293 frmAddBAReq.Action.action = SIR_MAC_BLKACK_ADD_REQ;
5294
5295 // FIXME - Dialog Token, generalize this...
5296 frmAddBAReq.DialogToken.token = pMlmAddBAReq->baDialogToken;
5297
5298 // Fill the ADDBA Parameter Set
5299 frmAddBAReq.AddBAParameterSet.tid = pMlmAddBAReq->baTID;
5300 frmAddBAReq.AddBAParameterSet.policy = pMlmAddBAReq->baPolicy;
5301 frmAddBAReq.AddBAParameterSet.bufferSize = pMlmAddBAReq->baBufferSize;
5302
5303 // BA timeout
5304 // 0 - indicates no BA timeout
5305 frmAddBAReq.BATimeout.timeout = pMlmAddBAReq->baTimeout;
5306
Abhishek Singh1f6e6532014-06-05 17:35:08 +05305307 /* Send SSN whatever we get from FW.
5308 */
5309 frmAddBAReq.BAStartingSequenceControl.ssn = pMlmAddBAReq->baSSN;
Jeff Johnson295189b2012-06-20 16:38:30 -07005310
5311 nStatus = dot11fGetPackedAddBAReqSize( pMac, &frmAddBAReq, &nPayload );
5312
5313 if( DOT11F_FAILED( nStatus ))
5314 {
5315 limLog( pMac, LOGW,
5316 FL( "Failed to calculate the packed size for "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005317 "an ADDBA Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005318 nStatus );
5319
5320 // We'll fall back on the worst case scenario:
5321 nPayload = sizeof( tDot11fAddBAReq );
5322 }
5323 else if( DOT11F_WARNED( nStatus ))
5324 {
5325 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005326 FL( "There were warnings while calculating "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005327 "the packed size for an ADDBA Req (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005328 nStatus );
5329 }
5330
5331 // Add the MGMT header to frame length
5332 frameLen = nPayload + sizeof( tSirMacMgmtHdr );
5333
5334 // Need to allocate a buffer for ADDBA AF
5335 if( eHAL_STATUS_SUCCESS !=
5336 (halStatus = palPktAlloc( pMac->hHdd,
5337 HAL_TXRX_FRM_802_11_MGMT,
5338 (tANI_U16) frameLen,
5339 (void **) &pAddBAReqBuffer,
5340 (void **) &pPacket )))
5341 {
5342 // Log error
5343 limLog( pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005344 FL("palPktAlloc FAILED! Length [%d], Status [%d]"),
Jeff Johnson295189b2012-06-20 16:38:30 -07005345 frameLen,
5346 halStatus );
5347
5348 statusCode = eSIR_MEM_ALLOC_FAILED;
5349 goto returnAfterError;
5350 }
5351
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305352 vos_mem_set( (void *) pAddBAReqBuffer, frameLen, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005353
5354 // Copy necessary info to BD
5355 if( eSIR_SUCCESS !=
5356 (statusCode = limPopulateMacHeader( pMac,
5357 pAddBAReqBuffer,
5358 SIR_MAC_MGMT_FRAME,
5359 SIR_MAC_MGMT_ACTION,
5360 pMlmAddBAReq->peerMacAddr,psessionEntry->selfMacAddr)))
5361 goto returnAfterError;
5362
5363 // Update A3 with the BSSID
5364 pMacHdr = ( tpSirMacMgmtHdr ) pAddBAReqBuffer;
5365
5366 #if 0
5367 cfgLen = SIR_MAC_ADDR_LENGTH;
5368 if( eSIR_SUCCESS != cfgGetStr( pMac,
5369 WNI_CFG_BSSID,
5370 (tANI_U8 *) pMacHdr->bssId,
5371 &cfgLen ))
5372 {
5373 limLog( pMac, LOGP,
5374 FL( "Failed to retrieve WNI_CFG_BSSID while"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005375 "sending an ACTION Frame" ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005376
5377 // FIXME - Need to convert to tSirRetStatus
5378 statusCode = eSIR_FAILURE;
5379 goto returnAfterError;
5380 }
5381 #endif//TO SUPPORT BT-AMP
5382 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
5383
Chet Lanctot186b5732013-03-18 10:26:30 -07005384#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07005385 limSetProtectedBit(pMac, psessionEntry, pMlmAddBAReq->peerMacAddr, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07005386#endif
5387
Jeff Johnson295189b2012-06-20 16:38:30 -07005388 // Now, we're ready to "pack" the frames
5389 nStatus = dot11fPackAddBAReq( pMac,
5390 &frmAddBAReq,
5391 pAddBAReqBuffer + sizeof( tSirMacMgmtHdr ),
5392 nPayload,
5393 &nPayload );
5394
5395 if( DOT11F_FAILED( nStatus ))
5396 {
5397 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005398 FL( "Failed to pack an ADDBA Req (0x%08x)." ),
Jeff Johnson295189b2012-06-20 16:38:30 -07005399 nStatus );
5400
5401 // FIXME - Need to convert to tSirRetStatus
5402 statusCode = eSIR_FAILURE;
5403 goto returnAfterError;
5404 }
5405 else if( DOT11F_WARNED( nStatus ))
5406 {
5407 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005408 FL( "There were warnings while packing an ADDBA Req (0x%08x)."),
5409 nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07005410 }
5411
Abhishek Singh02d9f6c2014-05-12 14:07:53 +05305412 limLog( pMac, LOG1, FL( "Sending an ADDBA REQ to "MAC_ADDRESS_STR " with"
5413 " tid = %d policy = %d buffsize = %d "
5414 " amsduSupported = %d"),
5415 MAC_ADDR_ARRAY(pMlmAddBAReq->peerMacAddr),
5416 frmAddBAReq.AddBAParameterSet.tid,
5417 frmAddBAReq.AddBAParameterSet.policy,
5418 frmAddBAReq.AddBAParameterSet.bufferSize,
5419 frmAddBAReq.AddBAParameterSet.amsduSupported);
Jeff Johnson295189b2012-06-20 16:38:30 -07005420
Abhishek Singh1f6e6532014-06-05 17:35:08 +05305421 limLog( pMac, LOG1, FL( "ssn = %d fragNum = %d" ),
5422 frmAddBAReq.BAStartingSequenceControl.ssn,
5423 frmAddBAReq.BAStartingSequenceControl.fragNumber);
5424
Jeff Johnson295189b2012-06-20 16:38:30 -07005425 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07005426 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
5427 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07005428 )
5429 {
5430 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
5431 }
5432
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05305433 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
5434 psessionEntry->peSessionId,
5435 pMacHdr->fc.subType));
5436 halStatus = halTxFrame( pMac,
5437 pPacket,
5438 (tANI_U16) frameLen,
5439 HAL_TXRX_FRM_802_11_MGMT,
5440 ANI_TXDIR_TODS,
5441 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
5442 limTxComplete,
5443 pAddBAReqBuffer, txFlag );
5444 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
5445 psessionEntry->peSessionId,
5446 halStatus));
5447 if( eHAL_STATUS_SUCCESS != halStatus )
Jeff Johnson295189b2012-06-20 16:38:30 -07005448 {
5449 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005450 FL( "halTxFrame FAILED! Status [%d]"),
Jeff Johnson295189b2012-06-20 16:38:30 -07005451 halStatus );
5452
5453 // FIXME - Need to convert eHalStatus to tSirRetStatus
5454 statusCode = eSIR_FAILURE;
5455 //Pkt will be freed up by the callback
5456 return statusCode;
5457 }
5458 else
5459 return eSIR_SUCCESS;
5460
5461returnAfterError:
5462
5463 // Release buffer, if allocated
5464 if( NULL != pAddBAReqBuffer )
5465 palPktFree( pMac->hHdd,
5466 HAL_TXRX_FRM_802_11_MGMT,
5467 (void *) pAddBAReqBuffer,
5468 (void *) pPacket );
5469
5470 return statusCode;
5471}
5472
5473/**
5474 * \brief Send an ADDBA Rsp Action Frame to peer
5475 *
5476 * \sa limSendAddBARsp
5477 *
5478 * \param pMac The global tpAniSirGlobal object
5479 *
5480 * \param pMlmAddBARsp A pointer to tLimMlmAddBARsp. This contains
5481 * the necessary parameters reqd by PE send the ADDBA Rsp Action
5482 * Frame to the peer
5483 *
5484 * \return eSIR_SUCCESS if setup completes successfully
5485 * eSIR_FAILURE is some problem is encountered
5486 */
5487tSirRetStatus limSendAddBARsp( tpAniSirGlobal pMac,
5488 tpLimMlmAddBARsp pMlmAddBARsp,
5489 tpPESession psessionEntry)
5490{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05305491 tDot11fAddBARsp frmAddBARsp;
5492 tANI_U8 *pAddBARspBuffer = NULL;
5493 tpSirMacMgmtHdr pMacHdr;
5494 tANI_U32 frameLen = 0, nStatus, nPayload;
5495 tSirRetStatus statusCode;
5496 eHalStatus halStatus;
5497 void *pPacket;
5498 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005499
5500 if(NULL == psessionEntry)
5501 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005502 PELOGE(limLog(pMac, LOGE, FL("Session entry is NULL!!!"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07005503 return eSIR_FAILURE;
5504 }
5505
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305506 vos_mem_set( (void *) &frmAddBARsp, sizeof( frmAddBARsp ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005507
5508 // Category - 3 (BA)
5509 frmAddBARsp.Category.category = SIR_MAC_ACTION_BLKACK;
5510 // Action - 1 (ADDBA Rsp)
5511 frmAddBARsp.Action.action = SIR_MAC_BLKACK_ADD_RSP;
5512
5513 // Should be same as the one we received in the ADDBA Req
5514 frmAddBARsp.DialogToken.token = pMlmAddBARsp->baDialogToken;
5515
5516 // ADDBA Req status
5517 frmAddBARsp.Status.status = pMlmAddBARsp->addBAResultCode;
5518
5519 // Fill the ADDBA Parameter Set as provided by caller
5520 frmAddBARsp.AddBAParameterSet.tid = pMlmAddBARsp->baTID;
5521 frmAddBARsp.AddBAParameterSet.policy = pMlmAddBARsp->baPolicy;
5522 frmAddBARsp.AddBAParameterSet.bufferSize = pMlmAddBARsp->baBufferSize;
krunal soni5afa96c2013-09-06 22:19:02 -07005523
5524 if(psessionEntry->isAmsduSupportInAMPDU)
5525 {
5526 frmAddBARsp.AddBAParameterSet.amsduSupported =
5527 psessionEntry->amsduSupportedInBA;
5528 }
5529 else
5530 {
5531 frmAddBARsp.AddBAParameterSet.amsduSupported = 0;
5532 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005533
5534 // BA timeout
5535 // 0 - indicates no BA timeout
5536 frmAddBARsp.BATimeout.timeout = pMlmAddBARsp->baTimeout;
5537
5538 nStatus = dot11fGetPackedAddBARspSize( pMac, &frmAddBARsp, &nPayload );
5539
5540 if( DOT11F_FAILED( nStatus ))
5541 {
5542 limLog( pMac, LOGW,
5543 FL( "Failed to calculate the packed size for "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005544 "an ADDBA Response (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005545 nStatus );
5546
5547 // We'll fall back on the worst case scenario:
5548 nPayload = sizeof( tDot11fAddBARsp );
5549 }
5550 else if( DOT11F_WARNED( nStatus ))
5551 {
5552 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005553 FL( "There were warnings while calculating "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005554 "the packed size for an ADDBA Rsp (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005555 nStatus );
5556 }
5557
5558 // Need to allocate a buffer for ADDBA AF
5559 frameLen = nPayload + sizeof( tSirMacMgmtHdr );
5560
5561 // Allocate shared memory
5562 if( eHAL_STATUS_SUCCESS !=
5563 (halStatus = palPktAlloc( pMac->hHdd,
5564 HAL_TXRX_FRM_802_11_MGMT,
5565 (tANI_U16) frameLen,
5566 (void **) &pAddBARspBuffer,
5567 (void **) &pPacket )))
5568 {
5569 // Log error
5570 limLog( pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005571 FL("palPktAlloc FAILED! Length [%d], Status [%d]"),
Jeff Johnson295189b2012-06-20 16:38:30 -07005572 frameLen,
5573 halStatus );
5574
5575 statusCode = eSIR_MEM_ALLOC_FAILED;
5576 goto returnAfterError;
5577 }
5578
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305579 vos_mem_set( (void *) pAddBARspBuffer, frameLen, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005580
5581 // Copy necessary info to BD
5582 if( eSIR_SUCCESS !=
5583 (statusCode = limPopulateMacHeader( pMac,
5584 pAddBARspBuffer,
5585 SIR_MAC_MGMT_FRAME,
5586 SIR_MAC_MGMT_ACTION,
5587 pMlmAddBARsp->peerMacAddr,psessionEntry->selfMacAddr)))
5588 goto returnAfterError;
5589
5590 // Update A3 with the BSSID
5591
5592 pMacHdr = ( tpSirMacMgmtHdr ) pAddBARspBuffer;
5593
5594 #if 0
5595 cfgLen = SIR_MAC_ADDR_LENGTH;
5596 if( eSIR_SUCCESS != wlan_cfgGetStr( pMac,
5597 WNI_CFG_BSSID,
5598 (tANI_U8 *) pMacHdr->bssId,
5599 &cfgLen ))
5600 {
5601 limLog( pMac, LOGP,
5602 FL( "Failed to retrieve WNI_CFG_BSSID while"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005603 "sending an ACTION Frame" ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005604
5605 // FIXME - Need to convert to tSirRetStatus
5606 statusCode = eSIR_FAILURE;
5607 goto returnAfterError;
5608 }
5609 #endif // TO SUPPORT BT-AMP
5610 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
5611
Chet Lanctot186b5732013-03-18 10:26:30 -07005612#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07005613 limSetProtectedBit(pMac, psessionEntry, pMlmAddBARsp->peerMacAddr, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07005614#endif
5615
Jeff Johnson295189b2012-06-20 16:38:30 -07005616 // Now, we're ready to "pack" the frames
5617 nStatus = dot11fPackAddBARsp( pMac,
5618 &frmAddBARsp,
5619 pAddBARspBuffer + sizeof( tSirMacMgmtHdr ),
5620 nPayload,
5621 &nPayload );
5622
5623 if( DOT11F_FAILED( nStatus ))
5624 {
5625 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005626 FL( "Failed to pack an ADDBA Rsp (0x%08x)." ),
Jeff Johnson295189b2012-06-20 16:38:30 -07005627 nStatus );
5628
5629 // FIXME - Need to convert to tSirRetStatus
5630 statusCode = eSIR_FAILURE;
5631 goto returnAfterError;
5632 }
5633 else if( DOT11F_WARNED( nStatus ))
5634 {
5635 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005636 FL( "There were warnings while packing an ADDBA Rsp (0x%08x)." ),
5637 nStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07005638 }
5639
Abhishek Singh02d9f6c2014-05-12 14:07:53 +05305640 limLog( pMac, LOG1, FL( "Sending an ADDBA RSP to "MAC_ADDRESS_STR " with"
5641 " tid = %d policy = %d buffsize = %d"
5642 " amsduSupported = %d status %d"),
5643 MAC_ADDR_ARRAY(pMlmAddBARsp->peerMacAddr),
5644 frmAddBARsp.AddBAParameterSet.tid,
5645 frmAddBARsp.AddBAParameterSet.policy,
5646 frmAddBARsp.AddBAParameterSet.bufferSize,
5647 frmAddBARsp.AddBAParameterSet.amsduSupported,
5648 frmAddBARsp.Status.status);
5649
Jeff Johnson295189b2012-06-20 16:38:30 -07005650
5651 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07005652 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
5653 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07005654 )
5655 {
5656 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
5657 }
5658
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05305659 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
5660 psessionEntry->peSessionId,
5661 pMacHdr->fc.subType));
5662 halStatus = halTxFrame( pMac,
5663 pPacket,
5664 (tANI_U16) frameLen,
5665 HAL_TXRX_FRM_802_11_MGMT,
5666 ANI_TXDIR_TODS,
5667 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
5668 limTxComplete,
5669 pAddBARspBuffer, txFlag );
5670 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
5671 psessionEntry->peSessionId,
5672 halStatus));
5673 if( eHAL_STATUS_SUCCESS != halStatus )
5674 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005675 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005676 FL( "halTxFrame FAILED! Status [%d]" ),
Jeff Johnson295189b2012-06-20 16:38:30 -07005677 halStatus );
5678
5679 // FIXME - HAL error codes are different from PE error
5680 // codes!! And, this routine is returning tSirRetStatus
5681 statusCode = eSIR_FAILURE;
5682 //Pkt will be freed up by the callback
5683 return statusCode;
5684 }
5685 else
5686 return eSIR_SUCCESS;
5687
5688 returnAfterError:
Jeff Johnson295189b2012-06-20 16:38:30 -07005689 // Release buffer, if allocated
5690 if( NULL != pAddBARspBuffer )
5691 palPktFree( pMac->hHdd,
5692 HAL_TXRX_FRM_802_11_MGMT,
5693 (void *) pAddBARspBuffer,
5694 (void *) pPacket );
5695
5696 return statusCode;
5697}
5698
5699/**
5700 * \brief Send a DELBA Indication Action Frame to peer
5701 *
5702 * \sa limSendDelBAInd
5703 *
5704 * \param pMac The global tpAniSirGlobal object
5705 *
5706 * \param peerMacAddr MAC Address of peer
5707 *
5708 * \param reasonCode Reason for the DELBA notification
5709 *
5710 * \param pBAParameterSet The DELBA Parameter Set.
5711 * This identifies the TID for which the BA session is
5712 * being deleted.
5713 *
5714 * \return eSIR_SUCCESS if setup completes successfully
5715 * eSIR_FAILURE is some problem is encountered
5716 */
5717tSirRetStatus limSendDelBAInd( tpAniSirGlobal pMac,
5718 tpLimMlmDelBAReq pMlmDelBAReq,tpPESession psessionEntry)
5719{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05305720 tDot11fDelBAInd frmDelBAInd;
5721 tANI_U8 *pDelBAIndBuffer = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005722 //tANI_U32 val;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05305723 tpSirMacMgmtHdr pMacHdr;
5724 tANI_U32 frameLen = 0, nStatus, nPayload;
5725 tSirRetStatus statusCode;
5726 eHalStatus halStatus;
5727 void *pPacket;
5728 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005729
5730 if(NULL == psessionEntry)
5731 {
5732 return eSIR_FAILURE;
5733 }
5734
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305735 vos_mem_set( (void *) &frmDelBAInd, sizeof( frmDelBAInd ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005736
5737 // Category - 3 (BA)
5738 frmDelBAInd.Category.category = SIR_MAC_ACTION_BLKACK;
5739 // Action - 2 (DELBA)
5740 frmDelBAInd.Action.action = SIR_MAC_BLKACK_DEL;
5741
5742 // Fill the DELBA Parameter Set as provided by caller
5743 frmDelBAInd.DelBAParameterSet.tid = pMlmDelBAReq->baTID;
5744 frmDelBAInd.DelBAParameterSet.initiator = pMlmDelBAReq->baDirection;
5745
5746 // BA Starting Sequence Number
5747 // Fragment number will always be zero
5748 frmDelBAInd.Reason.code = pMlmDelBAReq->delBAReasonCode;
5749
5750 nStatus = dot11fGetPackedDelBAIndSize( pMac, &frmDelBAInd, &nPayload );
5751
5752 if( DOT11F_FAILED( nStatus ))
5753 {
5754 limLog( pMac, LOGW,
5755 FL( "Failed to calculate the packed size for "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005756 "an DELBA Indication (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005757 nStatus );
5758
5759 // We'll fall back on the worst case scenario:
5760 nPayload = sizeof( tDot11fDelBAInd );
5761 }
5762 else if( DOT11F_WARNED( nStatus ))
5763 {
5764 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005765 FL( "There were warnings while calculating "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005766 "the packed size for an DELBA Ind (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005767 nStatus );
5768 }
5769
5770 // Add the MGMT header to frame length
5771 frameLen = nPayload + sizeof( tSirMacMgmtHdr );
5772
5773 // Allocate shared memory
5774 if( eHAL_STATUS_SUCCESS !=
5775 (halStatus = palPktAlloc( pMac->hHdd,
5776 HAL_TXRX_FRM_802_11_MGMT,
5777 (tANI_U16) frameLen,
5778 (void **) &pDelBAIndBuffer,
5779 (void **) &pPacket )))
5780 {
5781 // Log error
5782 limLog( pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005783 FL("palPktAlloc FAILED! Length [%d], Status [%d]"),
Jeff Johnson295189b2012-06-20 16:38:30 -07005784 frameLen,
5785 halStatus );
5786
5787 statusCode = eSIR_MEM_ALLOC_FAILED;
5788 goto returnAfterError;
5789 }
5790
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305791 vos_mem_set( (void *) pDelBAIndBuffer, frameLen, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005792
5793 // Copy necessary info to BD
5794 if( eSIR_SUCCESS !=
5795 (statusCode = limPopulateMacHeader( pMac,
5796 pDelBAIndBuffer,
5797 SIR_MAC_MGMT_FRAME,
5798 SIR_MAC_MGMT_ACTION,
5799 pMlmDelBAReq->peerMacAddr,psessionEntry->selfMacAddr)))
5800 goto returnAfterError;
5801
5802 // Update A3 with the BSSID
5803 pMacHdr = ( tpSirMacMgmtHdr ) pDelBAIndBuffer;
5804
5805 #if 0
5806 cfgLen = SIR_MAC_ADDR_LENGTH;
5807 if( eSIR_SUCCESS != cfgGetStr( pMac,
5808 WNI_CFG_BSSID,
5809 (tANI_U8 *) pMacHdr->bssId,
5810 &cfgLen ))
5811 {
5812 limLog( pMac, LOGP,
5813 FL( "Failed to retrieve WNI_CFG_BSSID while"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005814 "sending an ACTION Frame" ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005815
5816 // FIXME - Need to convert to tSirRetStatus
5817 statusCode = eSIR_FAILURE;
5818 goto returnAfterError;
5819 }
5820 #endif //TO SUPPORT BT-AMP
5821 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
5822
Chet Lanctot186b5732013-03-18 10:26:30 -07005823#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07005824 limSetProtectedBit(pMac, psessionEntry, pMlmDelBAReq->peerMacAddr, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07005825#endif
5826
Jeff Johnson295189b2012-06-20 16:38:30 -07005827 // Now, we're ready to "pack" the frames
5828 nStatus = dot11fPackDelBAInd( pMac,
5829 &frmDelBAInd,
5830 pDelBAIndBuffer + sizeof( tSirMacMgmtHdr ),
5831 nPayload,
5832 &nPayload );
5833
5834 if( DOT11F_FAILED( nStatus ))
5835 {
5836 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005837 FL( "Failed to pack an DELBA Ind (0x%08x)." ),
Jeff Johnson295189b2012-06-20 16:38:30 -07005838 nStatus );
5839
5840 // FIXME - Need to convert to tSirRetStatus
5841 statusCode = eSIR_FAILURE;
5842 goto returnAfterError;
5843 }
5844 else if( DOT11F_WARNED( nStatus ))
5845 {
5846 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005847 FL( "There were warnings while packing an DELBA Ind (0x%08x)." ),
5848 nStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07005849 }
5850
Abhishek Singh1f6e6532014-06-05 17:35:08 +05305851 limLog( pMac, LOG1,
5852 FL( "Sending a DELBA IND to: "MAC_ADDRESS_STR" with Tid = %d"
5853 " initiator = %d reason = %d" ),
5854 MAC_ADDR_ARRAY(pMlmDelBAReq->peerMacAddr),
5855 frmDelBAInd.DelBAParameterSet.tid,
5856 frmDelBAInd.DelBAParameterSet.initiator,
5857 frmDelBAInd.Reason.code);
5858
Jeff Johnson295189b2012-06-20 16:38:30 -07005859
5860 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07005861 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
5862 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07005863 )
5864 {
5865 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
5866 }
5867
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05305868 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
5869 psessionEntry->peSessionId,
5870 pMacHdr->fc.subType));
5871 halStatus = halTxFrame( pMac,
5872 pPacket,
5873 (tANI_U16) frameLen,
5874 HAL_TXRX_FRM_802_11_MGMT,
5875 ANI_TXDIR_TODS,
5876 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
5877 limTxComplete,
5878 pDelBAIndBuffer, txFlag );
5879 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
5880 psessionEntry->peSessionId,
5881 halStatus));
5882 if( eHAL_STATUS_SUCCESS != halStatus )
Jeff Johnson295189b2012-06-20 16:38:30 -07005883 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005884 PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]" ), halStatus );)
Jeff Johnson295189b2012-06-20 16:38:30 -07005885 statusCode = eSIR_FAILURE;
5886 //Pkt will be freed up by the callback
5887 return statusCode;
5888 }
5889 else
5890 return eSIR_SUCCESS;
5891
5892 returnAfterError:
5893
5894 // Release buffer, if allocated
5895 if( NULL != pDelBAIndBuffer )
5896 palPktFree( pMac->hHdd,
5897 HAL_TXRX_FRM_802_11_MGMT,
5898 (void *) pDelBAIndBuffer,
5899 (void *) pPacket );
5900
5901 return statusCode;
5902}
5903
5904#if defined WLAN_FEATURE_VOWIFI
5905
5906/**
5907 * \brief Send a Neighbor Report Request Action frame
5908 *
5909 *
5910 * \param pMac Pointer to the global MAC structure
5911 *
5912 * \param pNeighborReq Address of a tSirMacNeighborReportReq
5913 *
5914 * \param peer mac address of peer station.
5915 *
5916 * \param psessionEntry address of session entry.
5917 *
5918 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
5919 *
5920 *
5921 */
5922
5923tSirRetStatus
5924limSendNeighborReportRequestFrame(tpAniSirGlobal pMac,
5925 tpSirMacNeighborReportReq pNeighborReq,
5926 tSirMacAddr peer,
5927 tpPESession psessionEntry
5928 )
5929{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05305930 tSirRetStatus statusCode = eSIR_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07005931 tDot11fNeighborReportRequest frm;
5932 tANI_U8 *pFrame;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05305933 tpSirMacMgmtHdr pMacHdr;
5934 tANI_U32 nBytes, nPayload, nStatus;
5935 void *pPacket;
5936 eHalStatus halstatus;
5937 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005938
5939 if ( psessionEntry == NULL )
5940 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005941 limLog( pMac, LOGE, FL("(psession == NULL) in Request to send Neighbor Report request action frame") );
Jeff Johnson295189b2012-06-20 16:38:30 -07005942 return eSIR_FAILURE;
5943 }
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305944 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005945
5946 frm.Category.category = SIR_MAC_ACTION_RRM;
5947 frm.Action.action = SIR_MAC_RRM_NEIGHBOR_REQ;
5948 frm.DialogToken.token = pNeighborReq->dialogToken;
5949
5950
5951 if( pNeighborReq->ssid_present )
5952 {
5953 PopulateDot11fSSID( pMac, &pNeighborReq->ssid, &frm.SSID );
5954 }
5955
5956 nStatus = dot11fGetPackedNeighborReportRequestSize( pMac, &frm, &nPayload );
5957 if ( DOT11F_FAILED( nStatus ) )
5958 {
5959 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005960 "or a Neighbor Report Request(0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005961 nStatus );
5962 // We'll fall back on the worst case scenario:
5963 nPayload = sizeof( tDot11fNeighborReportRequest );
5964 }
5965 else if ( DOT11F_WARNED( nStatus ) )
5966 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005967 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07005968 "the packed size for a Neighbor Rep"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005969 "ort Request(0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07005970 }
5971
5972 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
5973
5974 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
5975 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
5976 {
5977 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Neighbor "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005978 "Report Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07005979 return eSIR_FAILURE;
5980 }
5981
5982 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305983 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005984
5985 // Copy necessary info to BD
5986 if( eSIR_SUCCESS !=
5987 (statusCode = limPopulateMacHeader( pMac,
5988 pFrame,
5989 SIR_MAC_MGMT_FRAME,
5990 SIR_MAC_MGMT_ACTION,
5991 peer, psessionEntry->selfMacAddr)))
5992 goto returnAfterError;
5993
5994 // Update A3 with the BSSID
5995 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
5996
5997 sirCopyMacAddr( pMacHdr->bssId, psessionEntry->bssId );
5998
Chet Lanctot186b5732013-03-18 10:26:30 -07005999#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07006000 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07006001#endif
6002
Jeff Johnson295189b2012-06-20 16:38:30 -07006003 // Now, we're ready to "pack" the frames
6004 nStatus = dot11fPackNeighborReportRequest( pMac,
6005 &frm,
6006 pFrame + sizeof( tSirMacMgmtHdr ),
6007 nPayload,
6008 &nPayload );
6009
6010 if( DOT11F_FAILED( nStatus ))
6011 {
6012 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006013 FL( "Failed to pack an Neighbor Report Request (0x%08x)." ),
Jeff Johnson295189b2012-06-20 16:38:30 -07006014 nStatus );
6015
6016 // FIXME - Need to convert to tSirRetStatus
6017 statusCode = eSIR_FAILURE;
6018 goto returnAfterError;
6019 }
6020 else if( DOT11F_WARNED( nStatus ))
6021 {
6022 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08006023 FL( "There were warnings while packing Neighbor Report "
6024 "Request (0x%08x)." ), nStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07006025 }
6026
6027 limLog( pMac, LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006028 FL( "Sending a Neighbor Report Request to " ));
Jeff Johnson295189b2012-06-20 16:38:30 -07006029 limPrintMacAddr( pMac, peer, LOGW );
6030
6031 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07006032 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
6033 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07006034 )
6035 {
6036 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
6037 }
6038
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05306039 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
6040 psessionEntry->peSessionId,
6041 pMacHdr->fc.subType));
6042 halstatus = halTxFrame( pMac,
6043 pPacket,
6044 (tANI_U16) nBytes,
6045 HAL_TXRX_FRM_802_11_MGMT,
6046 ANI_TXDIR_TODS,
6047 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
6048 limTxComplete,
6049 pFrame, txFlag );
6050 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
6051 psessionEntry->peSessionId,
6052 halstatus));
6053 if( eHAL_STATUS_SUCCESS != halstatus )
Jeff Johnson295189b2012-06-20 16:38:30 -07006054 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006055 PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]" ), halstatus );)
Jeff Johnson295189b2012-06-20 16:38:30 -07006056 statusCode = eSIR_FAILURE;
6057 //Pkt will be freed up by the callback
6058 return statusCode;
6059 }
6060 else
6061 return eSIR_SUCCESS;
6062
6063returnAfterError:
6064 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
6065
6066 return statusCode;
6067} // End limSendNeighborReportRequestFrame.
6068
6069/**
6070 * \brief Send a Link Report Action frame
6071 *
6072 *
6073 * \param pMac Pointer to the global MAC structure
6074 *
6075 * \param pLinkReport Address of a tSirMacLinkReport
6076 *
6077 * \param peer mac address of peer station.
6078 *
6079 * \param psessionEntry address of session entry.
6080 *
6081 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
6082 *
6083 *
6084 */
6085
6086tSirRetStatus
6087limSendLinkReportActionFrame(tpAniSirGlobal pMac,
6088 tpSirMacLinkReport pLinkReport,
6089 tSirMacAddr peer,
6090 tpPESession psessionEntry
6091 )
6092{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05306093 tSirRetStatus statusCode = eSIR_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006094 tDot11fLinkMeasurementReport frm;
6095 tANI_U8 *pFrame;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05306096 tpSirMacMgmtHdr pMacHdr;
6097 tANI_U32 nBytes, nPayload, nStatus;
6098 void *pPacket;
6099 eHalStatus halstatus;
6100 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07006101
6102
6103 if ( psessionEntry == NULL )
6104 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006105 limLog( pMac, LOGE, FL("(psession == NULL) in Request to send Link Report action frame") );
Jeff Johnson295189b2012-06-20 16:38:30 -07006106 return eSIR_FAILURE;
6107 }
6108
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05306109 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07006110
6111 frm.Category.category = SIR_MAC_ACTION_RRM;
6112 frm.Action.action = SIR_MAC_RRM_LINK_MEASUREMENT_RPT;
6113 frm.DialogToken.token = pLinkReport->dialogToken;
6114
6115
6116 //IEEE Std. 802.11 7.3.2.18. for the report element.
6117 //Even though TPC report an IE, it is represented using fixed fields since it is positioned
6118 //in the middle of other fixed fields in the link report frame(IEEE Std. 802.11k section7.4.6.4
6119 //and frame parser always expects IEs to come after all fixed fields. It is easier to handle
6120 //such case this way than changing the frame parser.
6121 frm.TPCEleID.TPCId = SIR_MAC_TPC_RPT_EID;
6122 frm.TPCEleLen.TPCLen = 2;
6123 frm.TxPower.txPower = pLinkReport->txPower;
6124 frm.LinkMargin.linkMargin = 0;
6125
6126 frm.RxAntennaId.antennaId = pLinkReport->rxAntenna;
6127 frm.TxAntennaId.antennaId = pLinkReport->txAntenna;
6128 frm.RCPI.rcpi = pLinkReport->rcpi;
6129 frm.RSNI.rsni = pLinkReport->rsni;
6130
6131 nStatus = dot11fGetPackedLinkMeasurementReportSize( pMac, &frm, &nPayload );
6132 if ( DOT11F_FAILED( nStatus ) )
6133 {
6134 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006135 "or a Link Report (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07006136 nStatus );
6137 // We'll fall back on the worst case scenario:
6138 nPayload = sizeof( tDot11fLinkMeasurementReport );
6139 }
6140 else if ( DOT11F_WARNED( nStatus ) )
6141 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08006142 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07006143 "the packed size for a Link Rep"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006144 "ort (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07006145 }
6146
6147 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
6148
6149 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
6150 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
6151 {
6152 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Link "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006153 "Report."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07006154 return eSIR_FAILURE;
6155 }
6156
6157 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05306158 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07006159
6160 // Copy necessary info to BD
6161 if( eSIR_SUCCESS !=
6162 (statusCode = limPopulateMacHeader( pMac,
6163 pFrame,
6164 SIR_MAC_MGMT_FRAME,
6165 SIR_MAC_MGMT_ACTION,
6166 peer, psessionEntry->selfMacAddr)))
6167 goto returnAfterError;
6168
6169 // Update A3 with the BSSID
6170 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
6171
6172 sirCopyMacAddr( pMacHdr->bssId, psessionEntry->bssId );
6173
Chet Lanctot186b5732013-03-18 10:26:30 -07006174#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07006175 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07006176#endif
6177
Jeff Johnson295189b2012-06-20 16:38:30 -07006178 // Now, we're ready to "pack" the frames
6179 nStatus = dot11fPackLinkMeasurementReport( pMac,
6180 &frm,
6181 pFrame + sizeof( tSirMacMgmtHdr ),
6182 nPayload,
6183 &nPayload );
6184
6185 if( DOT11F_FAILED( nStatus ))
6186 {
6187 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006188 FL( "Failed to pack an Link Report (0x%08x)." ),
Jeff Johnson295189b2012-06-20 16:38:30 -07006189 nStatus );
6190
6191 // FIXME - Need to convert to tSirRetStatus
6192 statusCode = eSIR_FAILURE;
6193 goto returnAfterError;
6194 }
6195 else if( DOT11F_WARNED( nStatus ))
6196 {
6197 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08006198 FL( "There were warnings while packing Link Report (0x%08x)." ),
6199 nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07006200 }
6201
6202 limLog( pMac, LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006203 FL( "Sending a Link Report to " ));
Jeff Johnson295189b2012-06-20 16:38:30 -07006204 limPrintMacAddr( pMac, peer, LOGW );
6205
6206 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07006207 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
6208 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07006209 )
6210 {
6211 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
6212 }
6213
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05306214 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
6215 psessionEntry->peSessionId,
6216 pMacHdr->fc.subType));
6217 halstatus = halTxFrame( pMac,
6218 pPacket,
6219 (tANI_U16) nBytes,
6220 HAL_TXRX_FRM_802_11_MGMT,
6221 ANI_TXDIR_TODS,
6222 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
6223 limTxComplete,
6224 pFrame, txFlag );
6225 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
6226 psessionEntry->peSessionId,
6227 halstatus));
6228 if( eHAL_STATUS_SUCCESS != halstatus )
Jeff Johnson295189b2012-06-20 16:38:30 -07006229 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006230 PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]" ), halstatus );)
Jeff Johnson295189b2012-06-20 16:38:30 -07006231 statusCode = eSIR_FAILURE;
6232 //Pkt will be freed up by the callback
6233 return statusCode;
6234 }
6235 else
6236 return eSIR_SUCCESS;
6237
6238returnAfterError:
6239 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
6240
6241 return statusCode;
6242} // End limSendLinkReportActionFrame.
6243
6244/**
6245 * \brief Send a Beacon Report Action frame
6246 *
6247 *
6248 * \param pMac Pointer to the global MAC structure
6249 *
6250 * \param dialog_token dialog token to be used in the action frame.
6251 *
6252 * \param num_report number of reports in pRRMReport.
6253 *
6254 * \param pRRMReport Address of a tSirMacRadioMeasureReport.
6255 *
6256 * \param peer mac address of peer station.
6257 *
6258 * \param psessionEntry address of session entry.
6259 *
6260 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
6261 *
6262 *
6263 */
6264
6265tSirRetStatus
6266limSendRadioMeasureReportActionFrame(tpAniSirGlobal pMac,
6267 tANI_U8 dialog_token,
6268 tANI_U8 num_report,
6269 tpSirMacRadioMeasureReport pRRMReport,
6270 tSirMacAddr peer,
6271 tpPESession psessionEntry
6272 )
6273{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05306274 tSirRetStatus statusCode = eSIR_SUCCESS;
6275 tANI_U8 *pFrame;
6276 tpSirMacMgmtHdr pMacHdr;
6277 tANI_U32 nBytes, nPayload, nStatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07006278 void *pPacket;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05306279 eHalStatus halstatus;
6280 tANI_U8 i;
6281 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07006282
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006283 tDot11fRadioMeasurementReport *frm =
6284 vos_mem_malloc(sizeof(tDot11fRadioMeasurementReport));
6285 if (!frm) {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006286 limLog( pMac, LOGE, FL("Not enough memory to allocate tDot11fRadioMeasurementReport") );
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006287 return eSIR_FAILURE;
6288 }
6289
Jeff Johnson295189b2012-06-20 16:38:30 -07006290 if ( psessionEntry == NULL )
6291 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006292 limLog( pMac, LOGE, FL("(psession == NULL) in Request to send Beacon Report action frame") );
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006293 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07006294 return eSIR_FAILURE;
6295 }
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05306296 vos_mem_set( ( tANI_U8* )frm, sizeof( *frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07006297
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006298 frm->Category.category = SIR_MAC_ACTION_RRM;
6299 frm->Action.action = SIR_MAC_RRM_RADIO_MEASURE_RPT;
6300 frm->DialogToken.token = dialog_token;
Jeff Johnson295189b2012-06-20 16:38:30 -07006301
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006302 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 -07006303
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006304 for( i = 0 ; i < frm->num_MeasurementReport ; i++ )
Jeff Johnson295189b2012-06-20 16:38:30 -07006305 {
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006306 frm->MeasurementReport[i].type = pRRMReport[i].type;
6307 frm->MeasurementReport[i].token = pRRMReport[i].token;
6308 frm->MeasurementReport[i].late = 0; //IEEE 802.11k section 7.3.22. (always zero in rrm)
Jeff Johnson295189b2012-06-20 16:38:30 -07006309 switch( pRRMReport[i].type )
6310 {
6311 case SIR_MAC_RRM_BEACON_TYPE:
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006312 PopulateDot11fBeaconReport( pMac, &frm->MeasurementReport[i], &pRRMReport[i].report.beaconReport );
6313 frm->MeasurementReport[i].incapable = pRRMReport[i].incapable;
6314 frm->MeasurementReport[i].refused = pRRMReport[i].refused;
6315 frm->MeasurementReport[i].present = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07006316 break;
6317 default:
Gopichand Nakkala72717fd2013-02-08 12:23:45 +05306318 frm->MeasurementReport[i].incapable = pRRMReport[i].incapable;
6319 frm->MeasurementReport[i].refused = pRRMReport[i].refused;
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006320 frm->MeasurementReport[i].present = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07006321 break;
6322 }
6323 }
6324
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006325 nStatus = dot11fGetPackedRadioMeasurementReportSize( pMac, frm, &nPayload );
Jeff Johnson295189b2012-06-20 16:38:30 -07006326 if ( DOT11F_FAILED( nStatus ) )
6327 {
6328 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006329 "or a Radio Measure Report (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07006330 nStatus );
6331 // We'll fall back on the worst case scenario:
6332 nPayload = sizeof( tDot11fLinkMeasurementReport );
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006333 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07006334 return eSIR_FAILURE;
6335 }
6336 else if ( DOT11F_WARNED( nStatus ) )
6337 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08006338 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07006339 "the packed size for a Radio Measure Rep"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006340 "ort (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07006341 }
6342
6343 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
6344
6345 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
6346 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
6347 {
6348 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Radio Measure "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006349 "Report."), nBytes );
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006350 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07006351 return eSIR_FAILURE;
6352 }
6353
6354 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05306355 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07006356
6357 // Copy necessary info to BD
6358 if( eSIR_SUCCESS !=
6359 (statusCode = limPopulateMacHeader( pMac,
6360 pFrame,
6361 SIR_MAC_MGMT_FRAME,
6362 SIR_MAC_MGMT_ACTION,
6363 peer, psessionEntry->selfMacAddr)))
6364 goto returnAfterError;
6365
6366 // Update A3 with the BSSID
6367 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
6368
6369 sirCopyMacAddr( pMacHdr->bssId, psessionEntry->bssId );
6370
Chet Lanctot186b5732013-03-18 10:26:30 -07006371#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07006372 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07006373#endif
6374
Jeff Johnson295189b2012-06-20 16:38:30 -07006375 // Now, we're ready to "pack" the frames
6376 nStatus = dot11fPackRadioMeasurementReport( pMac,
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006377 frm,
Jeff Johnson295189b2012-06-20 16:38:30 -07006378 pFrame + sizeof( tSirMacMgmtHdr ),
6379 nPayload,
6380 &nPayload );
6381
6382 if( DOT11F_FAILED( nStatus ))
6383 {
6384 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006385 FL( "Failed to pack an Radio Measure Report (0x%08x)." ),
Jeff Johnson295189b2012-06-20 16:38:30 -07006386 nStatus );
6387
6388 // FIXME - Need to convert to tSirRetStatus
6389 statusCode = eSIR_FAILURE;
6390 goto returnAfterError;
6391 }
6392 else if( DOT11F_WARNED( nStatus ))
6393 {
6394 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08006395 FL( "There were warnings while packing Radio "
6396 "Measure Report (0x%08x)." ), nStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07006397 }
6398
6399 limLog( pMac, LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006400 FL( "Sending a Radio Measure Report to " ));
Jeff Johnson295189b2012-06-20 16:38:30 -07006401 limPrintMacAddr( pMac, peer, LOGW );
6402
6403 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07006404 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
6405 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07006406 )
6407 {
6408 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
6409 }
6410
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05306411 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
6412 psessionEntry->peSessionId,
6413 pMacHdr->fc.subType));
6414 halstatus = halTxFrame( pMac,
6415 pPacket,
6416 (tANI_U16) nBytes,
6417 HAL_TXRX_FRM_802_11_MGMT,
6418 ANI_TXDIR_TODS,
6419 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
6420 limTxComplete,
6421 pFrame, txFlag );
6422 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
6423 psessionEntry->peSessionId,
6424 halstatus));
6425 if( eHAL_STATUS_SUCCESS != halstatus )
Jeff Johnson295189b2012-06-20 16:38:30 -07006426 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006427 PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]" ), halstatus );)
Jeff Johnson295189b2012-06-20 16:38:30 -07006428 statusCode = eSIR_FAILURE;
6429 //Pkt will be freed up by the callback
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006430 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07006431 return statusCode;
6432 }
Madan Mohan Koyyalamudieeb56b12012-10-31 15:10:04 -07006433 else {
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006434 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07006435 return eSIR_SUCCESS;
Madan Mohan Koyyalamudieeb56b12012-10-31 15:10:04 -07006436 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006437
6438returnAfterError:
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006439 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07006440 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
Jeff Johnson295189b2012-06-20 16:38:30 -07006441 return statusCode;
6442} // End limSendBeaconReportActionFrame.
6443
6444#endif
6445
6446#ifdef WLAN_FEATURE_11W
6447/**
Chet Lanctot8cecea22014-02-11 19:09:36 -08006448 * \brief Send SA query request action frame to peer
6449 *
6450 * \sa limSendSaQueryRequestFrame
6451 *
6452 *
6453 * \param pMac The global tpAniSirGlobal object
6454 *
6455 * \param transId Transaction identifier
6456 *
6457 * \param peer The Mac address of the station to which this action frame is addressed
6458 *
6459 * \param psessionEntry The PE session entry
6460 *
6461 * \return eSIR_SUCCESS if setup completes successfully
6462 * eSIR_FAILURE is some problem is encountered
6463 */
6464
6465tSirRetStatus limSendSaQueryRequestFrame( tpAniSirGlobal pMac, tANI_U8 *transId,
6466 tSirMacAddr peer, tpPESession psessionEntry )
6467{
6468
6469 tDot11fSaQueryReq frm; // SA query request action frame
6470 tANI_U8 *pFrame;
6471 tSirRetStatus nSirStatus;
6472 tpSirMacMgmtHdr pMacHdr;
6473 tANI_U32 nBytes, nPayload, nStatus;
6474 void *pPacket;
6475 eHalStatus halstatus;
6476 tANI_U8 txFlag = 0;
6477
6478 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
6479 frm.Category.category = SIR_MAC_ACTION_SA_QUERY;
6480 /* 11w action field is :
6481 action: 0 --> SA Query Request action frame
6482 action: 1 --> SA Query Response action frame */
6483 frm.Action.action = SIR_MAC_SA_QUERY_REQ;
6484 /* 11w SA Query Request transId */
6485 vos_mem_copy( &frm.TransactionId.transId[0], &transId[0], 2 );
6486
6487 nStatus = dot11fGetPackedSaQueryReqSize(pMac, &frm, &nPayload);
6488 if ( DOT11F_FAILED( nStatus ) )
6489 {
6490 limLog( pMac, LOGP, FL("Failed to calculate the packed size "
6491 "for an SA Query Request (0x%08x)."),
6492 nStatus );
6493 // We'll fall back on the worst case scenario:
6494 nPayload = sizeof( tDot11fSaQueryReq );
6495 }
6496 else if ( DOT11F_WARNED( nStatus ) )
6497 {
6498 limLog( pMac, LOGW, FL("There were warnings while calculating "
6499 "the packed size for an SA Query Request"
6500 " (0x%08x)."), nStatus );
6501 }
6502
6503 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
6504 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
6505 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
6506 {
6507 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a SA Query Request "
6508 "action frame"), nBytes );
6509 return eSIR_FAILURE;
6510 }
6511
6512 // Paranoia:
6513 vos_mem_set( pFrame, nBytes, 0 );
6514
6515 // Copy necessary info to BD
6516 nSirStatus = limPopulateMacHeader( pMac,
6517 pFrame,
6518 SIR_MAC_MGMT_FRAME,
6519 SIR_MAC_MGMT_ACTION,
6520 peer, psessionEntry->selfMacAddr );
6521 if ( eSIR_SUCCESS != nSirStatus )
6522 goto returnAfterError;
6523
6524 // Update A3 with the BSSID
6525 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
6526
6527 sirCopyMacAddr( pMacHdr->bssId, psessionEntry->bssId );
6528
6529 // Since this is a SA Query Request, set the "protect" (aka WEP) bit
6530 // in the FC
6531 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
6532
6533 // Pack 11w SA Query Request frame
6534 nStatus = dot11fPackSaQueryReq( pMac,
6535 &frm,
6536 pFrame + sizeof( tSirMacMgmtHdr ),
6537 nPayload,
6538 &nPayload );
6539
6540 if ( DOT11F_FAILED( nStatus ))
6541 {
6542 limLog( pMac, LOGE,
6543 FL( "Failed to pack an SA Query Request (0x%08x)." ),
6544 nStatus );
6545 // FIXME - Need to convert to tSirRetStatus
6546 nSirStatus = eSIR_FAILURE;
6547 goto returnAfterError;
6548 }
6549 else if ( DOT11F_WARNED( nStatus ))
6550 {
6551 limLog( pMac, LOGW,
6552 FL( "There were warnings while packing SA Query Request (0x%08x)." ),
6553 nStatus);
6554 }
6555
6556 limLog( pMac, LOG1,
6557 FL( "Sending an SA Query Request to " ));
6558 limPrintMacAddr( pMac, peer, LOG1 );
6559 limPrintMacAddr( pMac, peer, LOGE );
6560 limLog( pMac, LOGE,
6561 FL( "Sending an SA Query Request from " ));
6562 limPrintMacAddr( pMac, psessionEntry->selfMacAddr, LOGE );
6563
6564 if ( ( SIR_BAND_5_GHZ == limGetRFBand( psessionEntry->currentOperChannel ) )
6565#ifdef WLAN_FEATURE_P2P
6566 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
6567 ( psessionEntry->pePersona == VOS_P2P_GO_MODE )
6568#endif
6569 )
6570 {
6571 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
6572 }
6573
6574 halstatus = halTxFrame( pMac,
6575 pPacket,
6576 (tANI_U16) nBytes,
6577 HAL_TXRX_FRM_802_11_MGMT,
6578 ANI_TXDIR_TODS,
6579 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
6580 limTxComplete,
6581 pFrame, txFlag );
6582 if ( eHAL_STATUS_SUCCESS != halstatus )
6583 {
6584 PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]" ), halstatus );)
6585 nSirStatus = eSIR_FAILURE;
6586 //Pkt will be freed up by the callback
6587 return nSirStatus;
6588 }
6589 else {
6590 return eSIR_SUCCESS;
6591 }
6592
6593returnAfterError:
6594 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
6595 return nSirStatus;
6596} // End limSendSaQueryRequestFrame
6597
6598/**
Jeff Johnson295189b2012-06-20 16:38:30 -07006599 * \brief Send SA query response action frame to peer
6600 *
6601 * \sa limSendSaQueryResponseFrame
6602 *
6603 *
6604 * \param pMac The global tpAniSirGlobal object
6605 *
Chet Lanctot186b5732013-03-18 10:26:30 -07006606 * \param transId Transaction identifier received in SA query request action frame
Jeff Johnson295189b2012-06-20 16:38:30 -07006607 *
Chet Lanctot186b5732013-03-18 10:26:30 -07006608 * \param peer The Mac address of the AP to which this action frame is addressed
6609 *
6610 * \param psessionEntry The PE session entry
Jeff Johnson295189b2012-06-20 16:38:30 -07006611 *
6612 * \return eSIR_SUCCESS if setup completes successfully
6613 * eSIR_FAILURE is some problem is encountered
6614 */
6615
Chet Lanctot186b5732013-03-18 10:26:30 -07006616tSirRetStatus limSendSaQueryResponseFrame( tpAniSirGlobal pMac, tANI_U8 *transId,
Jeff Johnson295189b2012-06-20 16:38:30 -07006617tSirMacAddr peer,tpPESession psessionEntry)
6618{
6619
Chet Lanctot186b5732013-03-18 10:26:30 -07006620 tDot11fSaQueryRsp frm; // SA query reponse action frame
Jeff Johnson295189b2012-06-20 16:38:30 -07006621 tANI_U8 *pFrame;
6622 tSirRetStatus nSirStatus;
6623 tpSirMacMgmtHdr pMacHdr;
Chet Lanctot186b5732013-03-18 10:26:30 -07006624 tANI_U32 nBytes, nPayload, nStatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07006625 void *pPacket;
6626 eHalStatus halstatus;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05306627 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07006628
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05306629 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Chet Lanctot186b5732013-03-18 10:26:30 -07006630 frm.Category.category = SIR_MAC_ACTION_SA_QUERY;
6631 /*11w action field is :
Jeff Johnson295189b2012-06-20 16:38:30 -07006632 action: 0 --> SA query request action frame
6633 action: 1 --> SA query response action frame */
Chet Lanctot186b5732013-03-18 10:26:30 -07006634 frm.Action.action = SIR_MAC_SA_QUERY_RSP;
6635 /*11w SA query response transId is same as
Jeff Johnson295189b2012-06-20 16:38:30 -07006636 SA query request transId*/
Chet Lanctot186b5732013-03-18 10:26:30 -07006637 vos_mem_copy( &frm.TransactionId.transId[0], &transId[0], 2 );
Jeff Johnson295189b2012-06-20 16:38:30 -07006638
Chet Lanctot186b5732013-03-18 10:26:30 -07006639 nStatus = dot11fGetPackedSaQueryRspSize(pMac, &frm, &nPayload);
6640 if ( DOT11F_FAILED( nStatus ) )
6641 {
6642 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
6643 "or a SA Query Response (0x%08x)."),
6644 nStatus );
6645 // We'll fall back on the worst case scenario:
6646 nPayload = sizeof( tDot11fSaQueryRsp );
6647 }
6648 else if ( DOT11F_WARNED( nStatus ) )
6649 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08006650 limLog( pMac, LOGW, FL("There were warnings while calculating "
Chet Lanctot186b5732013-03-18 10:26:30 -07006651 "the packed size for an SA Query Response"
6652 " (0x%08x)."), nStatus );
6653 }
6654
Jeff Johnson295189b2012-06-20 16:38:30 -07006655 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
6656 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
6657 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
6658 {
6659 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a SA query response"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006660 " action frame"), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07006661 return eSIR_FAILURE;
6662 }
6663
6664 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05306665 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07006666
Chet Lanctot186b5732013-03-18 10:26:30 -07006667 // Copy necessary info to BD
Chet Lanctotb2b0d552013-03-22 16:58:44 -07006668 nSirStatus = limPopulateMacHeader( pMac,
Chet Lanctot186b5732013-03-18 10:26:30 -07006669 pFrame,
6670 SIR_MAC_MGMT_FRAME,
6671 SIR_MAC_MGMT_ACTION,
Chet Lanctotb2b0d552013-03-22 16:58:44 -07006672 peer, psessionEntry->selfMacAddr );
6673 if ( eSIR_SUCCESS != nSirStatus )
Chet Lanctot186b5732013-03-18 10:26:30 -07006674 goto returnAfterError;
Jeff Johnson295189b2012-06-20 16:38:30 -07006675
Chet Lanctot186b5732013-03-18 10:26:30 -07006676 // Update A3 with the BSSID
Jeff Johnson295189b2012-06-20 16:38:30 -07006677 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
6678
Chet Lanctot186b5732013-03-18 10:26:30 -07006679 sirCopyMacAddr( pMacHdr->bssId, psessionEntry->bssId );
Jeff Johnson295189b2012-06-20 16:38:30 -07006680
Chet Lanctot186b5732013-03-18 10:26:30 -07006681 // Since this is a SA Query Response, set the "protect" (aka WEP) bit
6682 // in the FC
Chet Lanctot8cecea22014-02-11 19:09:36 -08006683 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Jeff Johnson295189b2012-06-20 16:38:30 -07006684
Chet Lanctot186b5732013-03-18 10:26:30 -07006685 // Pack 11w SA query response frame
6686 nStatus = dot11fPackSaQueryRsp( pMac,
6687 &frm,
6688 pFrame + sizeof( tSirMacMgmtHdr ),
6689 nPayload,
6690 &nPayload );
6691
6692 if ( DOT11F_FAILED( nStatus ))
6693 {
6694 limLog( pMac, LOGE,
6695 FL( "Failed to pack an SA Query Response (0x%08x)." ),
6696 nStatus );
6697 // FIXME - Need to convert to tSirRetStatus
6698 nSirStatus = eSIR_FAILURE;
6699 goto returnAfterError;
6700 }
6701 else if ( DOT11F_WARNED( nStatus ))
6702 {
6703 limLog( pMac, LOGW,
6704 FL( "There were warnings while packing SA Query Response (0x%08x)." ),
6705 nStatus);
6706 }
6707
6708 limLog( pMac, LOG1,
6709 FL( "Sending a SA Query Response to " ));
6710 limPrintMacAddr( pMac, peer, LOGW );
6711
Chet Lanctotb2b0d552013-03-22 16:58:44 -07006712 if ( ( SIR_BAND_5_GHZ == limGetRFBand( psessionEntry->currentOperChannel ) )
Chet Lanctot186b5732013-03-18 10:26:30 -07006713#ifdef WLAN_FEATURE_P2P
Chet Lanctotb2b0d552013-03-22 16:58:44 -07006714 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
6715 ( psessionEntry->pePersona == VOS_P2P_GO_MODE )
Chet Lanctot186b5732013-03-18 10:26:30 -07006716#endif
Chet Lanctotb2b0d552013-03-22 16:58:44 -07006717 )
6718 {
6719 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
6720 }
Chet Lanctot186b5732013-03-18 10:26:30 -07006721
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05306722 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
6723 psessionEntry->peSessionId,
6724 pMacHdr->fc.subType));
Chet Lanctotb2b0d552013-03-22 16:58:44 -07006725 halstatus = halTxFrame( pMac,
6726 pPacket,
6727 (tANI_U16) nBytes,
6728 HAL_TXRX_FRM_802_11_MGMT,
6729 ANI_TXDIR_TODS,
6730 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
6731 limTxComplete,
6732 pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05306733 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
6734 psessionEntry->peSessionId,
6735 halstatus));
Chet Lanctotb2b0d552013-03-22 16:58:44 -07006736 if ( eHAL_STATUS_SUCCESS != halstatus )
Chet Lanctot186b5732013-03-18 10:26:30 -07006737 {
6738 PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]" ), halstatus );)
6739 nSirStatus = eSIR_FAILURE;
6740 //Pkt will be freed up by the callback
6741 return nSirStatus;
6742 }
6743 else {
6744 return eSIR_SUCCESS;
6745 }
6746
6747returnAfterError:
6748 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
6749 return nSirStatus;
6750} // End limSendSaQueryResponseFrame
Jeff Johnson295189b2012-06-20 16:38:30 -07006751#endif