blob: 655a41e1eb599e79df2703fdf292536ec40b04ad [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Abhishek Singhc601a472016-01-20 11:08:32 +05302 * Copyright (c) 2011-2016 The Linux Foundation. All rights reserved.
Kiet Lam842dad02014-02-18 18:44:02 -08003 *
4 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
5 *
6 *
7 * Permission to use, copy, modify, and/or distribute this software for
8 * any purpose with or without fee is hereby granted, provided that the
9 * above copyright notice and this permission notice appear in all
10 * copies.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
13 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
14 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
15 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
16 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
17 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
18 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19 * PERFORMANCE OF THIS SOFTWARE.
20 */
21
22/*
Kiet Lama7f454d2014-07-24 12:04:06 -070023 * This file was originally distributed by Qualcomm Atheros, Inc.
24 * under proprietary terms before Copyright ownership was assigned
25 * to the Linux Foundation.
Jeff Johnson295189b2012-06-20 16:38:30 -070026 */
Kiet Lam842dad02014-02-18 18:44:02 -080027
28
Kiet Lama7f454d2014-07-24 12:04:06 -070029
30
Jeff Johnson295189b2012-06-20 16:38:30 -070031/**
32 * \file limSendManagementFrames.c
33 *
34 * \brief Code for preparing and sending 802.11 Management frames
35 *
Kiet Lam842dad02014-02-18 18:44:02 -080036
Jeff Johnson295189b2012-06-20 16:38:30 -070037 *
38 */
39
40#include "sirApi.h"
41#include "aniGlobal.h"
42#include "sirMacProtDef.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070043#include "cfgApi.h"
44#include "utilsApi.h"
45#include "limTypes.h"
46#include "limUtils.h"
47#include "limSecurityUtils.h"
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -070048#include "limPropExtsUtils.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070049#include "dot11f.h"
50#include "limStaHashApi.h"
51#include "schApi.h"
52#include "limSendMessages.h"
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -080053#include "limAssocUtils.h"
54#include "limFT.h"
Chet Lanctot8cecea22014-02-11 19:09:36 -080055#ifdef WLAN_FEATURE_11W
Satyanarayana Dash6f438272015-03-03 18:01:06 +053056#include "wniCfg.h"
Chet Lanctot8cecea22014-02-11 19:09:36 -080057#endif
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -080058
Jeff Johnson295189b2012-06-20 16:38:30 -070059#if defined WLAN_FEATURE_VOWIFI
60#include "rrmApi.h"
61#endif
62
Jeff Johnson295189b2012-06-20 16:38:30 -070063#include "wlan_qct_wda.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070064
Masti, Narayanraddi67ea5912015-01-08 12:34:05 +053065#define IS_BROADCAST_MAC(x) (((x[0] & x[1] & x[2] & x[3] & x[4] & x[5]) == 0xff) ? 1 : 0)
Jeff Johnson295189b2012-06-20 16:38:30 -070066////////////////////////////////////////////////////////////////////////
67
Kalikinkar dhara205da782014-03-21 15:49:32 -070068tSirRetStatus limStripOffExtCapIE(tpAniSirGlobal pMac,
69 tANI_U8 *addIE,
70 tANI_U16 *addnIELen,
71 tANI_U8 *pExtractedExtCapIEBuf )
72{
73 tANI_U8* tempbuf = NULL;
74 tANI_U16 tempLen = 0;
75 int left = *addnIELen;
76 tANI_U8 *ptr = addIE;
77 tANI_U8 elem_id, elem_len;
78
79 if (NULL == addIE)
80 {
81 PELOGE(limLog(pMac, LOG1, FL("NULL addIE pointer"));)
82 return eSIR_IGNORE_IE ;
83 }
84
85 tempbuf = vos_mem_malloc(left);
86 if ( NULL == tempbuf )
87 {
88 PELOGE(limLog(pMac, LOGE,
89 FL("Unable to allocate memory to store addn IE"));)
90 return eSIR_MEM_ALLOC_FAILED;
91 }
92
93 while(left >= 2)
94 {
95 elem_id = ptr[0];
96 elem_len = ptr[1];
97 left -= 2;
98 if (elem_len > left)
99 {
100 limLog( pMac, LOGE,
101 FL("Invalid IEs eid = %d elem_len=%d left=%d"),
102 elem_id,elem_len,left);
103 vos_mem_free(tempbuf);
104 return eSIR_FAILURE;
105 }
106 if ( !(DOT11F_EID_EXTCAP == elem_id) )
107 {
108 vos_mem_copy (tempbuf + tempLen, &ptr[0], elem_len + 2);
109 tempLen += (elem_len + 2);
110 }
111 else
112 { /*Est Cap present size is 8 + 2 byte at present*/
113 if ( NULL != pExtractedExtCapIEBuf )
114 {
115 vos_mem_set(pExtractedExtCapIEBuf,
116 DOT11F_IE_EXTCAP_MAX_LEN + 2, 0);
117 if (elem_len <= DOT11F_IE_EXTCAP_MAX_LEN )
118 {
119 vos_mem_copy (pExtractedExtCapIEBuf, &ptr[0],
120 elem_len + 2);
121 }
122 }
123 }
124 left -= elem_len;
125 ptr += (elem_len + 2);
126 }
127 vos_mem_copy (addIE, tempbuf, tempLen);
128 *addnIELen = tempLen;
129 vos_mem_free(tempbuf);
130 return eSIR_SUCCESS;
131}
132
133void limUpdateExtCapIEtoStruct(tpAniSirGlobal pMac,
134 tANI_U8 *pBuf,
135 tDot11fIEExtCap *pDst)
136{
137 tANI_U8 pOut[DOT11F_IE_EXTCAP_MAX_LEN];
138
139 if ( NULL == pBuf )
140 {
141 limLog( pMac, LOGE,
142 FL("Invalid Buffer Address"));
143 return;
144 }
145 if(NULL == pDst)
146 {
147 PELOGE(limLog(pMac, LOGE,
148 FL("NULL pDst pointer"));)
149 return ;
150 }
151
152 if ( DOT11F_EID_EXTCAP != pBuf[0] ||
153 pBuf[1] > DOT11F_IE_EXTCAP_MAX_LEN )
154 {
Mahesh A Saptasagare00ff532014-10-17 19:05:14 +0530155 limLog( pMac, LOG1,
Kalikinkar dhara205da782014-03-21 15:49:32 -0700156 FL("Invalid IEs eid = %d elem_len=%d "),
157 pBuf[0],pBuf[1]);
158 return;
159 }
160 vos_mem_set(( tANI_U8* )&pOut[0], DOT11F_IE_EXTCAP_MAX_LEN, 0);
161 /* conversion should follow 4, 2, 2 byte order */
162 limUtilsframeshtonl(pMac, &pOut[0],*((tANI_U32*)&pBuf[2]),0);
163 limUtilsframeshtons(pMac, &pOut[4],*((tANI_U16*)&pBuf[6]),0);
164 limUtilsframeshtons(pMac, &pOut[6],*((tANI_U16*)&pBuf[8]),0);
165
166 if ( DOT11F_PARSE_SUCCESS != dot11fUnpackIeExtCap( pMac,
167 &pOut[0], DOT11F_IE_EXTCAP_MAX_LEN, pDst) )
168 {
169 limLog( pMac, LOGE,
170 FL("dot11fUnpackIeExtCap Parse Error "));
171 }
172}
173
174tSirRetStatus limStripOffExtCapIEAndUpdateStruct(tpAniSirGlobal pMac,
175 tANI_U8* addIE,
176 tANI_U16 *addnIELen,
177 tDot11fIEExtCap * pDst )
178{
179 tANI_U8 pExtractedExtCapIEBuf[DOT11F_IE_EXTCAP_MAX_LEN + 2];
180 tSirRetStatus nSirStatus;
181
182 vos_mem_set(( tANI_U8* )&pExtractedExtCapIEBuf[0],
183 DOT11F_IE_EXTCAP_MAX_LEN + 2, 0);
184 nSirStatus = limStripOffExtCapIE(pMac, addIE, addnIELen,
185 pExtractedExtCapIEBuf);
186 if ( eSIR_SUCCESS != nSirStatus )
187 {
188 limLog( pMac, LOG1, FL("Failed to strip off in"
189 "limStripOffExtCapIE status = (%d)."),
190 nSirStatus );
191 return nSirStatus;
192 }
193 /* update the extracted ExtCap to struct*/
194 limUpdateExtCapIEtoStruct(pMac, pExtractedExtCapIEBuf, pDst);
195 return nSirStatus;
196}
197
198void limMergeExtCapIEStruct(tDot11fIEExtCap *pDst,
199 tDot11fIEExtCap *pSrc)
200{
201 tANI_U8 *tempDst = (tANI_U8 *)pDst;
202 tANI_U8 *tempSrc = (tANI_U8 *)pSrc;
203 tANI_U8 structlen = sizeof(tDot11fIEExtCap);
204
205 while(tempDst && tempSrc && structlen--)
206 {
207 *tempDst |= *tempSrc;
208 tempDst++;
209 tempSrc++;
210 }
211}
Jeff Johnson295189b2012-06-20 16:38:30 -0700212
213/**
214 *
215 * \brief This function is called by various LIM modules to prepare the
216 * 802.11 frame MAC header
217 *
218 *
219 * \param pMac Pointer to Global MAC structure
220 *
221 * \param pBD Pointer to the frame buffer that needs to be populate
222 *
223 * \param type Type of the frame
224 *
225 * \param subType Subtype of the frame
226 *
227 * \return eHalStatus
228 *
229 *
230 * The pFrameBuf argument points to the beginning of the frame buffer to
231 * which - a) The 802.11 MAC header is set b) Following this MAC header
232 * will be the MGMT frame payload The payload itself is populated by the
233 * caller API
234 *
235 *
236 */
237
238tSirRetStatus limPopulateMacHeader( tpAniSirGlobal pMac,
239 tANI_U8* pBD,
240 tANI_U8 type,
241 tANI_U8 subType,
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530242 tSirMacAddr peerAddr, tSirMacAddr selfMacAddr)
Jeff Johnson295189b2012-06-20 16:38:30 -0700243{
244 tSirRetStatus statusCode = eSIR_SUCCESS;
245 tpSirMacMgmtHdr pMacHdr;
246
247 /// Prepare MAC management header
248 pMacHdr = (tpSirMacMgmtHdr) (pBD);
249
250 // Prepare FC
251 pMacHdr->fc.protVer = SIR_MAC_PROTOCOL_VERSION;
252 pMacHdr->fc.type = type;
253 pMacHdr->fc.subType = subType;
254
255 // Prepare Address 1
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530256 vos_mem_copy( (tANI_U8 *) pMacHdr->da,
Jeff Johnson295189b2012-06-20 16:38:30 -0700257 (tANI_U8 *) peerAddr,
258 sizeof( tSirMacAddr ));
259
260 // Prepare Address 2
Jeff Johnson295189b2012-06-20 16:38:30 -0700261 sirCopyMacAddr(pMacHdr->sa,selfMacAddr);
262
263 // Prepare Address 3
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530264 vos_mem_copy( (tANI_U8 *) pMacHdr->bssId,
Jeff Johnson295189b2012-06-20 16:38:30 -0700265 (tANI_U8 *) peerAddr,
266 sizeof( tSirMacAddr ));
267 return statusCode;
268} /*** end limPopulateMacHeader() ***/
269
270/**
271 * \brief limSendProbeReqMgmtFrame
272 *
273 *
274 * \param pMac Pointer to Global MAC structure
275 *
276 * \param pSsid SSID to be sent in Probe Request frame
277 *
278 * \param bssid BSSID to be sent in Probe Request frame
279 *
280 * \param nProbeDelay probe delay to be used before sending Probe Request
281 * frame
282 *
283 * \param nChannelNum Channel # on which the Probe Request is going out
284 *
285 * \param nAdditionalIELen if non-zero, include pAdditionalIE in the Probe Request frame
286 *
287 * \param pAdditionalIE if nAdditionalIELen is non zero, include this field in the Probe Request frame
288 *
289 * This function is called by various LIM modules to send Probe Request frame
290 * during active scan/learn phase.
291 * Probe request is sent out in the following scenarios:
292 * --heartbeat failure: session needed
293 * --join req: session needed
294 * --foreground scan: no session
295 * --background scan: no session
296 * --schBeaconProcessing: to get EDCA parameters: session needed
297 *
298 *
299 */
300tSirRetStatus
301limSendProbeReqMgmtFrame(tpAniSirGlobal pMac,
302 tSirMacSSid *pSsid,
303 tSirMacAddr bssid,
304 tANI_U8 nChannelNum,
305 tSirMacAddr SelfMacAddr,
306 tANI_U32 dot11mode,
307 tANI_U32 nAdditionalIELen,
308 tANI_U8 *pAdditionalIE)
309{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +0530310 tDot11fProbeRequest pr;
311 tANI_U32 nStatus, nBytes, nPayload;
312 tSirRetStatus nSirStatus;
313 tANI_U8 *pFrame;
314 void *pPacket;
315 eHalStatus halstatus;
316 tpPESession psessionEntry;
317 tANI_U8 sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -0700318 tANI_U8 *p2pIe = NULL;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +0530319 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700320
321#ifndef GEN4_SCAN
322 return eSIR_FAILURE;
323#endif
324
325#if defined ( ANI_DVT_DEBUG )
326 return eSIR_FAILURE;
327#endif
328
Abhishek Singh4beed422014-02-03 16:47:17 +0530329 /* The probe req should not send 11ac capabilieties if band is 2.4GHz,
330 * unless enableVhtFor24GHz is enabled in INI. So if enableVhtFor24GHz
331 * is false and dot11mode is 11ac set it to 11n.
332 */
333 if ( nChannelNum <= SIR_11B_CHANNEL_END &&
334 ( FALSE == pMac->roam.configParam.enableVhtFor24GHz ) &&
335 ( WNI_CFG_DOT11_MODE_11AC == dot11mode ||
336 WNI_CFG_DOT11_MODE_11AC_ONLY == dot11mode ) )
337 dot11mode = WNI_CFG_DOT11_MODE_11N;
Jeff Johnson295189b2012-06-20 16:38:30 -0700338 /*
339 * session context may or may not be present, when probe request needs to be sent out.
340 * following cases exist:
341 * --heartbeat failure: session needed
342 * --join req: session needed
343 * --foreground scan: no session
344 * --background scan: no session
345 * --schBeaconProcessing: to get EDCA parameters: session needed
346 * If session context does not exist, some IEs will be populated from CFGs,
347 * e.g. Supported and Extended rate set IEs
348 */
349 psessionEntry = peFindSessionByBssid(pMac,bssid,&sessionId);
350
351 // The scheme here is to fill out a 'tDot11fProbeRequest' structure
352 // and then hand it off to 'dot11fPackProbeRequest' (for
353 // serialization). We start by zero-initializing the structure:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530354 vos_mem_set(( tANI_U8* )&pr, sizeof( pr ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700355
356 // & delegating to assorted helpers:
357 PopulateDot11fSSID( pMac, pSsid, &pr.SSID );
358
Jeff Johnson295189b2012-06-20 16:38:30 -0700359 if( nAdditionalIELen && pAdditionalIE )
360 {
361 p2pIe = limGetP2pIEPtr(pMac, pAdditionalIE, nAdditionalIELen);
362 }
Jeff Johnsone7245742012-09-05 17:12:55 -0700363 /* Don't include 11b rate only when device is doing P2P Search */
364 if( ( WNI_CFG_DOT11_MODE_11B != dot11mode ) &&
365 ( p2pIe != NULL ) &&
366 /* Don't include 11b rate if it is a P2P serach or probe request is sent by P2P Client */
367 ( ( ( pMac->lim.gpLimMlmScanReq != NULL ) &&
368 pMac->lim.gpLimMlmScanReq->p2pSearch ) ||
369 ( ( psessionEntry != NULL ) &&
370 ( VOS_P2P_CLIENT_MODE == psessionEntry->pePersona ) )
371 )
372 )
Jeff Johnson295189b2012-06-20 16:38:30 -0700373 {
374 /* In the below API pass channel number > 14, do that it fills only
375 * 11a rates in supported rates */
376 PopulateDot11fSuppRates( pMac, 15, &pr.SuppRates,psessionEntry);
377 }
378 else
379 {
Jeff Johnson295189b2012-06-20 16:38:30 -0700380 PopulateDot11fSuppRates( pMac, nChannelNum,
381 &pr.SuppRates,psessionEntry);
382
383 if ( WNI_CFG_DOT11_MODE_11B != dot11mode )
384 {
385 PopulateDot11fExtSuppRates1( pMac, nChannelNum, &pr.ExtSuppRates );
386 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700387 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700388
389#if defined WLAN_FEATURE_VOWIFI
390 //Table 7-14 in IEEE Std. 802.11k-2008 says
391 //DS params "can" be present in RRM is disabled and "is" present if
392 //RRM is enabled. It should be ok even if we add it into probe req when
393 //RRM is not enabled.
394 PopulateDot11fDSParams( pMac, &pr.DSParams, nChannelNum, psessionEntry );
395 //Call RRM module to get the tx power for management used.
396 {
397 tANI_U8 txPower = (tANI_U8) rrmGetMgmtTxPower( pMac, psessionEntry );
398 PopulateDot11fWFATPC( pMac, &pr.WFATPC, txPower, 0 );
399 }
400#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700401
402 if (psessionEntry != NULL ) {
Jeff Johnsone7245742012-09-05 17:12:55 -0700403 psessionEntry->htCapability = IS_DOT11_MODE_HT(dot11mode);
Jeff Johnson295189b2012-06-20 16:38:30 -0700404 //Include HT Capability IE
Jeff Johnsone7245742012-09-05 17:12:55 -0700405 if (psessionEntry->htCapability)
Jeff Johnson295189b2012-06-20 16:38:30 -0700406 {
Jeff Johnsone7245742012-09-05 17:12:55 -0700407 PopulateDot11fHTCaps( pMac, psessionEntry, &pr.HTCaps );
Jeff Johnson295189b2012-06-20 16:38:30 -0700408 }
Jeff Johnsone7245742012-09-05 17:12:55 -0700409 } else { //psessionEntry == NULL
410 if (IS_DOT11_MODE_HT(dot11mode))
Jeff Johnson295189b2012-06-20 16:38:30 -0700411 {
Jeff Johnsone7245742012-09-05 17:12:55 -0700412 PopulateDot11fHTCaps( pMac, psessionEntry, &pr.HTCaps );
Jeff Johnson295189b2012-06-20 16:38:30 -0700413 }
414 }
Gopichand Nakkala40bc6502012-12-20 16:55:36 -0800415
Hardik Kantilal Patelbca5b002015-01-19 15:30:18 +0530416 if((nChannelNum <= SIR_11B_CHANNEL_END)
417 && (!IS_HT40_OBSS_SCAN_FEATURE_ENABLE)
418 && (!pMac->roam.configParam.channelBondingMode24GHz))
Gopichand Nakkala40bc6502012-12-20 16:55:36 -0800419 {
420 pr.HTCaps.supportedChannelWidthSet = eHT_CHANNEL_WIDTH_20MHZ;
421 pr.HTCaps.shortGI40MHz = 0;
422 }
Jeff Johnsone7245742012-09-05 17:12:55 -0700423#ifdef WLAN_FEATURE_11AC
424 if (psessionEntry != NULL ) {
425 psessionEntry->vhtCapability = IS_DOT11_MODE_VHT(dot11mode);
426 //Include HT Capability IE
427 if (psessionEntry->vhtCapability)
428 {
Abhishek Singh33f76ea2015-06-04 12:27:30 +0530429 PopulateDot11fVHTCaps( pMac, &pr.VHTCaps,
430 psessionEntry->currentOperChannel , eSIR_FALSE );
Jeff Johnsone7245742012-09-05 17:12:55 -0700431 }
432 } else {
433 if (IS_DOT11_MODE_VHT(dot11mode))
434 {
Abhishek Singh33f76ea2015-06-04 12:27:30 +0530435 PopulateDot11fVHTCaps( pMac, &pr.VHTCaps, nChannelNum, 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
Masti, Narayanraddi67ea5912015-01-08 12:34:05 +0530528 if( ( psessionEntry != NULL ) && ( psessionEntry->is11Gonly == true ) &&
529 ( !IS_BROADCAST_MAC(bssid) ) ){
530 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
531 }
532
Jeff Johnson295189b2012-06-20 16:38:30 -0700533 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) sizeof(tSirMacMgmtHdr) + nPayload,
534 HAL_TXRX_FRM_802_11_MGMT,
535 ANI_TXDIR_TODS,
536 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
537 limTxComplete, pFrame, txFlag );
538 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
539 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700540 limLog( pMac, LOGE, FL("could not send Probe Request frame!" ));
Jeff Johnson295189b2012-06-20 16:38:30 -0700541 //Pkt will be freed up by the callback
542 return eSIR_FAILURE;
543 }
544
545 return eSIR_SUCCESS;
546} // End limSendProbeReqMgmtFrame.
547
Jeff Johnson295189b2012-06-20 16:38:30 -0700548tSirRetStatus limGetAddnIeForProbeResp(tpAniSirGlobal pMac,
549 tANI_U8* addIE, tANI_U16 *addnIELen,
550 tANI_U8 probeReqP2pIe)
551{
552 /* If Probe request doesn't have P2P IE, then take out P2P IE
553 from additional IE */
554 if(!probeReqP2pIe)
555 {
556 tANI_U8* tempbuf = NULL;
557 tANI_U16 tempLen = 0;
558 int left = *addnIELen;
559 v_U8_t *ptr = addIE;
560 v_U8_t elem_id, elem_len;
561
562 if(NULL == addIE)
563 {
564 PELOGE(limLog(pMac, LOGE,
565 FL(" NULL addIE pointer"));)
566 return eSIR_FAILURE;
567 }
568
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530569 tempbuf = vos_mem_malloc(left);
570 if ( NULL == tempbuf )
Jeff Johnson295189b2012-06-20 16:38:30 -0700571 {
572 PELOGE(limLog(pMac, LOGE,
573 FL("Unable to allocate memory to store addn IE"));)
574 return eSIR_MEM_ALLOC_FAILED;
575 }
576
577 while(left >= 2)
578 {
579 elem_id = ptr[0];
580 elem_len = ptr[1];
581 left -= 2;
582 if(elem_len > left)
583 {
584 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700585 FL("****Invalid IEs eid = %d elem_len=%d left=%d*****"),
Jeff Johnson295189b2012-06-20 16:38:30 -0700586 elem_id,elem_len,left);
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530587 vos_mem_free(tempbuf);
Jeff Johnson295189b2012-06-20 16:38:30 -0700588 return eSIR_FAILURE;
589 }
590 if ( !( (SIR_MAC_EID_VENDOR == elem_id) &&
591 (memcmp(&ptr[2], SIR_MAC_P2P_OUI, SIR_MAC_P2P_OUI_SIZE)==0) ) )
592 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530593 vos_mem_copy (tempbuf + tempLen, &ptr[0], elem_len + 2);
Jeff Johnson295189b2012-06-20 16:38:30 -0700594 tempLen += (elem_len + 2);
595 }
596 left -= elem_len;
597 ptr += (elem_len + 2);
598 }
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530599 vos_mem_copy (addIE, tempbuf, tempLen);
Jeff Johnson295189b2012-06-20 16:38:30 -0700600 *addnIELen = tempLen;
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530601 vos_mem_free(tempbuf);
Jeff Johnson295189b2012-06-20 16:38:30 -0700602 }
603 return eSIR_SUCCESS;
604}
Jeff Johnson295189b2012-06-20 16:38:30 -0700605
606void
607limSendProbeRspMgmtFrame(tpAniSirGlobal pMac,
608 tSirMacAddr peerMacAddr,
609 tpAniSSID pSsid,
610 short nStaId,
611 tANI_U8 nKeepAlive,
612 tpPESession psessionEntry,
613 tANI_U8 probeReqP2pIe)
614{
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700615 tDot11fProbeResponse *pFrm;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +0530616 tSirRetStatus nSirStatus;
c_hpothubcd78652014-04-28 22:31:08 +0530617 tANI_U32 cfg, nPayload, nStatus;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +0530618 tpSirMacMgmtHdr pMacHdr;
619 tANI_U8 *pFrame;
620 void *pPacket;
621 eHalStatus halstatus;
622 tANI_U32 addnIEPresent;
623 tANI_U32 addnIE1Len=0;
624 tANI_U32 addnIE2Len=0;
625 tANI_U32 addnIE3Len=0;
626 tANI_U16 totalAddnIeLen = 0;
627 tANI_U32 wpsApEnable=0, tmp;
628 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700629 tANI_U8 *addIE = NULL;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +0530630 tANI_U8 *pP2pIe = NULL;
631 tANI_U8 noaLen = 0;
632 tANI_U8 total_noaLen = 0;
633 tANI_U8 noaStream[SIR_MAX_NOA_ATTR_LEN
Jeff Johnson295189b2012-06-20 16:38:30 -0700634 + SIR_P2P_IE_HEADER_LEN];
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +0530635 tANI_U8 noaIe[SIR_MAX_NOA_ATTR_LEN + SIR_P2P_IE_HEADER_LEN];
Kalikinkar dhara205da782014-03-21 15:49:32 -0700636 tDot11fIEExtCap extractedExtCap;
637 tANI_BOOLEAN extractedExtCapFlag = eANI_BOOLEAN_TRUE;
c_hpothubcd78652014-04-28 22:31:08 +0530638 tANI_U32 nBytes = 0;
639
Jeff Johnson295189b2012-06-20 16:38:30 -0700640 if(pMac->gDriverType == eDRIVER_TYPE_MFG) // We don't answer requests
641 {
642 return; // in this case.
643 }
644
645 if(NULL == psessionEntry)
646 {
647 return;
648 }
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530649
650 pFrm = vos_mem_malloc(sizeof(tDot11fProbeResponse));
651 if ( NULL == pFrm )
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700652 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530653 limLog(pMac, LOGE, FL("Unable to allocate memory in limSendProbeRspMgmtFrame") );
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700654 return;
655 }
656
Girish Gowli0e826792014-05-17 17:56:44 +0530657 vos_mem_set(( tANI_U8* )&extractedExtCap, sizeof( tDot11fIEExtCap ), 0);
658
Jeff Johnson295189b2012-06-20 16:38:30 -0700659 // Fill out 'frm', after which we'll just hand the struct off to
660 // 'dot11fPackProbeResponse'.
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530661 vos_mem_set(( tANI_U8* )pFrm, sizeof( tDot11fProbeResponse ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700662
663 // Timestamp to be updated by TFP, below.
664
665 // Beacon Interval:
Jeff Johnson295189b2012-06-20 16:38:30 -0700666 if(psessionEntry->limSystemRole == eLIM_AP_ROLE)
667 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700668 pFrm->BeaconInterval.interval = pMac->sch.schObject.gSchBeaconInterval;
Jeff Johnson295189b2012-06-20 16:38:30 -0700669 }
670 else
671 {
Jeff Johnson3c3e1782013-02-27 10:48:42 -0800672 nSirStatus = wlan_cfgGetInt( pMac, WNI_CFG_BEACON_INTERVAL, &cfg);
673 if (eSIR_SUCCESS != nSirStatus)
674 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700675 limLog( pMac, LOGP, FL("Failed to retrieve WNI_CFG_BEACON_INTERVAL from CFG (%d)."),
Jeff Johnson3c3e1782013-02-27 10:48:42 -0800676 nSirStatus );
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530677 vos_mem_free(pFrm);
Jeff Johnson3c3e1782013-02-27 10:48:42 -0800678 return;
679 }
680 pFrm->BeaconInterval.interval = ( tANI_U16 ) cfg;
Madan Mohan Koyyalamudic0d1b3f2012-11-13 10:41:07 -0800681 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700682
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700683 PopulateDot11fCapabilities( pMac, &pFrm->Capabilities, psessionEntry );
684 PopulateDot11fSSID( pMac, ( tSirMacSSid* )pSsid, &pFrm->SSID );
Jeff Johnson295189b2012-06-20 16:38:30 -0700685 PopulateDot11fSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700686 &pFrm->SuppRates,psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -0700687
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700688 PopulateDot11fDSParams( pMac, &pFrm->DSParams, psessionEntry->currentOperChannel,psessionEntry);
689 PopulateDot11fIBSSParams( pMac, &pFrm->IBSSParams, psessionEntry );
Jeff Johnson295189b2012-06-20 16:38:30 -0700690
Jeff Johnson295189b2012-06-20 16:38:30 -0700691
Jeff Johnson295189b2012-06-20 16:38:30 -0700692 if(psessionEntry->limSystemRole == eLIM_AP_ROLE)
693 {
694 if(psessionEntry->wps_state != SAP_WPS_DISABLED)
695 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700696 PopulateDot11fProbeResWPSIEs(pMac, &pFrm->WscProbeRes, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -0700697 }
698 }
699 else
700 {
Jeff Johnson3c3e1782013-02-27 10:48:42 -0800701 if (wlan_cfgGetInt(pMac, (tANI_U16) WNI_CFG_WPS_ENABLE, &tmp) != eSIR_SUCCESS)
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700702 limLog(pMac, LOGP,"Failed to cfg get id %d", WNI_CFG_WPS_ENABLE );
Jeff Johnson295189b2012-06-20 16:38:30 -0700703
Jeff Johnson3c3e1782013-02-27 10:48:42 -0800704 wpsApEnable = tmp & WNI_CFG_WPS_ENABLE_AP;
Jeff Johnson295189b2012-06-20 16:38:30 -0700705
Jeff Johnson3c3e1782013-02-27 10:48:42 -0800706 if (wpsApEnable)
707 {
708 PopulateDot11fWscInProbeRes(pMac, &pFrm->WscProbeRes);
709 }
710
711 if (pMac->lim.wscIeInfo.probeRespWscEnrollmentState == eLIM_WSC_ENROLL_BEGIN)
712 {
713 PopulateDot11fWscRegistrarInfoInProbeRes(pMac, &pFrm->WscProbeRes);
714 pMac->lim.wscIeInfo.probeRespWscEnrollmentState = eLIM_WSC_ENROLL_IN_PROGRESS;
715 }
716
717 if (pMac->lim.wscIeInfo.wscEnrollmentState == eLIM_WSC_ENROLL_END)
718 {
719 DePopulateDot11fWscRegistrarInfoInProbeRes(pMac, &pFrm->WscProbeRes);
720 pMac->lim.wscIeInfo.probeRespWscEnrollmentState = eLIM_WSC_ENROLL_NOOP;
721 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700722 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700723
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700724 PopulateDot11fCountry( pMac, &pFrm->Country, psessionEntry);
725 PopulateDot11fEDCAParamSet( pMac, &pFrm->EDCAParamSet, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -0700726
Jeff Johnson295189b2012-06-20 16:38:30 -0700727
728 if (psessionEntry->dot11mode != WNI_CFG_DOT11_MODE_11B)
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700729 PopulateDot11fERPInfo( pMac, &pFrm->ERPInfo, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -0700730
731
732 // N.B. In earlier implementations, the RSN IE would be placed in
733 // the frame here, before the WPA IE, if 'RSN_BEFORE_WPA' was defined.
734 PopulateDot11fExtSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700735 &pFrm->ExtSuppRates, psessionEntry );
Jeff Johnson295189b2012-06-20 16:38:30 -0700736
737 //Populate HT IEs, when operating in 11n or Taurus modes.
Jeff Johnsone7245742012-09-05 17:12:55 -0700738 if ( psessionEntry->htCapability )
Jeff Johnson295189b2012-06-20 16:38:30 -0700739 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700740 PopulateDot11fHTCaps( pMac, psessionEntry, &pFrm->HTCaps );
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700741 PopulateDot11fHTInfo( pMac, &pFrm->HTInfo, psessionEntry );
Jeff Johnson295189b2012-06-20 16:38:30 -0700742 }
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +0530743
744#ifdef WLAN_FEATURE_AP_HT40_24G
745 /* Populate Overlapping BSS Scan Parameters IEs,
746 * when operating in HT40 in 2.4GHz.
747 */
Hardik Kantilal Patel3c235242015-01-02 17:56:18 +0530748 if ((pMac->roam.configParam.apHT40_24GEnabled)
749 && (IS_DOT11_MODE_HT(psessionEntry->dot11mode)))
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +0530750 {
751 PopulateDot11fOBSSScanParameters( pMac, &pFrm->OBSSScanParameters,
752 psessionEntry);
Hardik Kantilal Patelee5874c2015-01-14 15:23:28 +0530753 /* 10.15.8 Support of DSSS/CCK in 40 MHz, An associated HT STA in
754 * a 20/40 MHz BSS may generate DSSS/CCK transmissions.Set DSSS/CCK
755 * Mode in 40 MHz bit in HT capablity.
756 */
757 pFrm->HTCaps.dsssCckMode40MHz = 1;
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +0530758 }
759#endif
760
761 PopulateDot11fExtCap( pMac, &pFrm->ExtCap, psessionEntry);
762
Jeff Johnsone7245742012-09-05 17:12:55 -0700763#ifdef WLAN_FEATURE_11AC
764 if(psessionEntry->vhtCapability)
765 {
Chet Lanctotf19c1f62013-12-13 13:56:21 -0800766 limLog( pMac, LOG1, FL("Populate VHT IE in Probe Response"));
Abhishek Singh33f76ea2015-06-04 12:27:30 +0530767 PopulateDot11fVHTCaps( pMac, &pFrm->VHTCaps,
768 psessionEntry->currentOperChannel, eSIR_TRUE );
769 PopulateDot11fVHTOperation( pMac, &pFrm->VHTOperation ,
770 psessionEntry->currentOperChannel);
Jeff Johnsone7245742012-09-05 17:12:55 -0700771 // we do not support multi users yet
772 //PopulateDot11fVHTExtBssLoad( pMac, &frm.VHTExtBssLoad );
773 }
774#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700775
Sandeep Puligilla60342762014-01-30 21:05:37 +0530776
Hardik Kantilal Patelee5874c2015-01-14 15:23:28 +0530777 if ( psessionEntry->pLimStartBssReq )
Jeff Johnson295189b2012-06-20 16:38:30 -0700778 {
779 PopulateDot11fWPA( pMac, &( psessionEntry->pLimStartBssReq->rsnIE ),
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700780 &pFrm->WPA );
Chet Lanctot4b9abd72013-06-27 11:14:56 -0700781 PopulateDot11fRSNOpaque( pMac, &( psessionEntry->pLimStartBssReq->rsnIE ),
782 &pFrm->RSNOpaque );
Jeff Johnson295189b2012-06-20 16:38:30 -0700783 }
784
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700785 PopulateDot11fWMM( pMac, &pFrm->WMMInfoAp, &pFrm->WMMParams, &pFrm->WMMCaps, psessionEntry );
Jeff Johnson295189b2012-06-20 16:38:30 -0700786
787#if defined(FEATURE_WLAN_WAPI)
788 if( psessionEntry->pLimStartBssReq )
789 {
790 PopulateDot11fWAPI( pMac, &( psessionEntry->pLimStartBssReq->rsnIE ),
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700791 &pFrm->WAPI );
Jeff Johnson295189b2012-06-20 16:38:30 -0700792 }
793
794#endif // defined(FEATURE_WLAN_WAPI)
795
Jeff Johnson295189b2012-06-20 16:38:30 -0700796 addnIEPresent = false;
Jeff Johnson295189b2012-06-20 16:38:30 -0700797 if( pMac->lim.gpLimRemainOnChanReq )
798 {
799 nBytes += (pMac->lim.gpLimRemainOnChanReq->length - sizeof( tSirRemainOnChnReq ) );
800 }
801 //Only use CFG for non-listen mode. This CFG is not working for concurrency
802 //In listening mode, probe rsp IEs is passed in the message from SME to PE
803 else
Jeff Johnson295189b2012-06-20 16:38:30 -0700804 {
805
806 if (wlan_cfgGetInt(pMac, WNI_CFG_PROBE_RSP_ADDNIE_FLAG,
807 &addnIEPresent) != eSIR_SUCCESS)
808 {
809 limLog(pMac, LOGP, FL("Unable to get WNI_CFG_PROBE_RSP_ADDNIE_FLAG"));
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530810 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700811 return;
812 }
813 }
814
815 if (addnIEPresent)
816 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530817
818 addIE = vos_mem_malloc(WNI_CFG_PROBE_RSP_ADDNIE_DATA1_LEN*3);
819 if ( NULL == addIE )
Jeff Johnson295189b2012-06-20 16:38:30 -0700820 {
821 PELOGE(limLog(pMac, LOGE,
822 FL("Unable to allocate memory to store addn IE"));)
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530823 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700824 return;
825 }
826
827 //Probe rsp IE available
828 if ( eSIR_SUCCESS != wlan_cfgGetStrLen(pMac,
829 WNI_CFG_PROBE_RSP_ADDNIE_DATA1, &addnIE1Len) )
830 {
831 limLog(pMac, LOGP, FL("Unable to get WNI_CFG_PROBE_RSP_ADDNIE_DATA1 length"));
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530832 vos_mem_free(addIE);
833 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700834 return;
835 }
836 if (addnIE1Len <= WNI_CFG_PROBE_RSP_ADDNIE_DATA1_LEN && addnIE1Len &&
837 (nBytes + addnIE1Len) <= SIR_MAX_PACKET_SIZE)
838 {
839 if ( eSIR_SUCCESS != wlan_cfgGetStr(pMac,
840 WNI_CFG_PROBE_RSP_ADDNIE_DATA1, &addIE[0],
841 &addnIE1Len) )
842 {
843 limLog(pMac, LOGP,
844 FL("Unable to get WNI_CFG_PROBE_RSP_ADDNIE_DATA1 String"));
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530845 vos_mem_free(addIE);
846 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700847 return;
848 }
849 }
850
851 //Probe rsp IE available
852 if ( eSIR_SUCCESS != wlan_cfgGetStrLen(pMac,
853 WNI_CFG_PROBE_RSP_ADDNIE_DATA2, &addnIE2Len) )
854 {
855 limLog(pMac, LOGP, FL("Unable to get WNI_CFG_PROBE_RSP_ADDNIE_DATA2 length"));
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530856 vos_mem_free(addIE);
857 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700858 return;
859 }
860 if (addnIE2Len <= WNI_CFG_PROBE_RSP_ADDNIE_DATA2_LEN && addnIE2Len &&
861 (nBytes + addnIE2Len) <= SIR_MAX_PACKET_SIZE)
862 {
863 if ( eSIR_SUCCESS != wlan_cfgGetStr(pMac,
864 WNI_CFG_PROBE_RSP_ADDNIE_DATA2, &addIE[addnIE1Len],
865 &addnIE2Len) )
866 {
867 limLog(pMac, LOGP,
868 FL("Unable to get WNI_CFG_PROBE_RSP_ADDNIE_DATA2 String"));
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530869 vos_mem_free(addIE);
870 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700871 return;
872 }
873 }
874
875 //Probe rsp IE available
876 if ( eSIR_SUCCESS != wlan_cfgGetStrLen(pMac,
877 WNI_CFG_PROBE_RSP_ADDNIE_DATA3, &addnIE3Len) )
878 {
879 limLog(pMac, LOGP, FL("Unable to get WNI_CFG_PROBE_RSP_ADDNIE_DATA3 length"));
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530880 vos_mem_free(addIE);
881 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700882 return;
883 }
884 if (addnIE3Len <= WNI_CFG_PROBE_RSP_ADDNIE_DATA3_LEN && addnIE3Len &&
885 (nBytes + addnIE3Len) <= SIR_MAX_PACKET_SIZE)
886 {
887 if ( eSIR_SUCCESS != wlan_cfgGetStr(pMac,
888 WNI_CFG_PROBE_RSP_ADDNIE_DATA3,
889 &addIE[addnIE1Len + addnIE2Len],
890 &addnIE3Len) )
891 {
892 limLog(pMac, LOGP,
893 FL("Unable to get WNI_CFG_PROBE_RSP_ADDNIE_DATA3 String"));
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530894 vos_mem_free(addIE);
895 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700896 return;
897 }
898 }
899 totalAddnIeLen = addnIE1Len + addnIE2Len + addnIE3Len;
900
Jeff Johnson295189b2012-06-20 16:38:30 -0700901 if(eSIR_SUCCESS != limGetAddnIeForProbeResp(pMac, addIE, &totalAddnIeLen, probeReqP2pIe))
902 {
903 limLog(pMac, LOGP,
904 FL("Unable to get final Additional IE for Probe Req"));
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530905 vos_mem_free(addIE);
906 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700907 return;
908 }
Kalikinkar dhara205da782014-03-21 15:49:32 -0700909
Kalikinkar dhara205da782014-03-21 15:49:32 -0700910 nSirStatus = limStripOffExtCapIEAndUpdateStruct(pMac,
911 addIE,
912 &totalAddnIeLen,
913 &extractedExtCap );
914 if(eSIR_SUCCESS != nSirStatus )
915 {
916 extractedExtCapFlag = eANI_BOOLEAN_FALSE;
917 limLog(pMac, LOG1,
918 FL("Unable to Stripoff ExtCap IE from Probe Rsp"));
919 }
920
Jeff Johnson295189b2012-06-20 16:38:30 -0700921 nBytes = nBytes + totalAddnIeLen;
Kaushik, Sushanta5ee77a2014-07-30 19:35:25 +0530922 limLog(pMac, LOG1,
923 FL("probe rsp packet size is %d "), nBytes);
Jeff Johnson295189b2012-06-20 16:38:30 -0700924 if (probeReqP2pIe)
925 {
926 pP2pIe = limGetP2pIEPtr(pMac, &addIE[0], totalAddnIeLen);
927 if (pP2pIe != NULL)
928 {
929 //get NoA attribute stream P2P IE
930 noaLen = limGetNoaAttrStream(pMac, noaStream, psessionEntry);
931 if (noaLen != 0)
932 {
933 total_noaLen = limBuildP2pIe(pMac, &noaIe[0],
934 &noaStream[0], noaLen);
935 nBytes = nBytes + total_noaLen;
Kaushik, Sushanta5ee77a2014-07-30 19:35:25 +0530936 limLog(pMac, LOG1,
937 FL("p2p probe rsp packet size is %d, noalength is %d"),
938 nBytes, total_noaLen);
Jeff Johnson295189b2012-06-20 16:38:30 -0700939 }
940 }
941 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700942 }
943
c_hpothubcd78652014-04-28 22:31:08 +0530944 /*merge ExtCap IE*/
945 if (extractedExtCapFlag && extractedExtCap.present)
946 {
947 limMergeExtCapIEStruct(&pFrm->ExtCap, &extractedExtCap);
948 }
949
950 nStatus = dot11fGetPackedProbeResponseSize( pMac, pFrm, &nPayload );
951 if ( DOT11F_FAILED( nStatus ) )
952 {
953 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
954 "or a Probe Response (0x%08x)."),
955 nStatus );
956 // We'll fall back on the worst case scenario:
957 nPayload = sizeof( tDot11fProbeResponse );
958 }
959 else if ( DOT11F_WARNED( nStatus ) )
960 {
961 limLog( pMac, LOGW, FL("There were warnings while calculating"
962 "the packed size for a Probe Response "
963 "(0x%08x)."), nStatus );
964 }
965
966 nBytes += nPayload + sizeof( tSirMacMgmtHdr );
967
Jeff Johnson295189b2012-06-20 16:38:30 -0700968 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
969 ( tANI_U16 )nBytes, ( void** ) &pFrame,
970 ( void** ) &pPacket );
971 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
972 {
973 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Pro"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700974 "be Response."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -0700975 if ( addIE != NULL )
976 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530977 vos_mem_free(addIE);
Jeff Johnson295189b2012-06-20 16:38:30 -0700978 }
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530979 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700980 return;
981 }
982
983 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530984 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -0700985
986 // Next, we fill out the buffer descriptor:
987 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
988 SIR_MAC_MGMT_PROBE_RSP, peerMacAddr,psessionEntry->selfMacAddr);
989 if ( eSIR_SUCCESS != nSirStatus )
990 {
991 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700992 "tor for a Probe Response (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -0700993 nSirStatus );
994 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
995 ( void* ) pFrame, ( void* ) pPacket );
996 if ( addIE != NULL )
997 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530998 vos_mem_free(addIE);
Jeff Johnson295189b2012-06-20 16:38:30 -0700999 }
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301000 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -07001001 return;
1002 }
1003
1004 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
1005
1006 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
1007
1008 // That done, pack the Probe Response:
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07001009 nStatus = dot11fPackProbeResponse( pMac, pFrm, pFrame + sizeof(tSirMacMgmtHdr),
Jeff Johnson295189b2012-06-20 16:38:30 -07001010 nPayload, &nPayload );
1011 if ( DOT11F_FAILED( nStatus ) )
1012 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001013 limLog( pMac, LOGE, FL("Failed to pack a Probe Response (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001014 nStatus );
1015 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1016 if ( addIE != NULL )
1017 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301018 vos_mem_free(addIE);
Jeff Johnson295189b2012-06-20 16:38:30 -07001019 }
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301020 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -07001021 return; // allocated!
1022 }
1023 else if ( DOT11F_WARNED( nStatus ) )
1024 {
1025 limLog( pMac, LOGW, FL("There were warnings while packing a P"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001026 "robe Response (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001027 }
1028
1029 PELOG3(limLog( pMac, LOG3, FL("Sending Probe Response frame to ") );
1030 limPrintMacAddr( pMac, peerMacAddr, LOG3 );)
1031
1032 pMac->sys.probeRespond++;
1033
Jeff Johnson295189b2012-06-20 16:38:30 -07001034 if( pMac->lim.gpLimRemainOnChanReq )
1035 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301036 vos_mem_copy ( pFrame+sizeof(tSirMacMgmtHdr)+nPayload,
Jeff Johnson295189b2012-06-20 16:38:30 -07001037 pMac->lim.gpLimRemainOnChanReq->probeRspIe, (pMac->lim.gpLimRemainOnChanReq->length - sizeof( tSirRemainOnChnReq )) );
1038 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001039
1040 if ( addnIEPresent )
1041 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301042 vos_mem_copy(pFrame+sizeof(tSirMacMgmtHdr)+nPayload, &addIE[0], totalAddnIeLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07001043 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001044 if (noaLen != 0)
1045 {
Krunal Soni81b24262013-05-15 17:46:41 -07001046 if (total_noaLen > (SIR_MAX_NOA_ATTR_LEN + SIR_P2P_IE_HEADER_LEN))
Jeff Johnson295189b2012-06-20 16:38:30 -07001047 {
1048 limLog(pMac, LOGE,
Kaushik, Sushant96ac9d72013-12-11 19:28:10 +05301049 FL("Not able to insert NoA because of length constraint."
1050 "Total Length is :%d"),total_noaLen);
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301051 vos_mem_free(addIE);
1052 vos_mem_free(pFrm);
Krunal Soni81b24262013-05-15 17:46:41 -07001053 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1054 ( void* ) pFrame, ( void* ) pPacket );
1055 return;
1056 }
1057 else
1058 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301059 vos_mem_copy( &pFrame[nBytes - (total_noaLen)],
Krunal Soni81b24262013-05-15 17:46:41 -07001060 &noaIe[0], total_noaLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07001061 }
1062 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001063
1064 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07001065 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
1066 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07001067 )
1068 {
1069 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
1070 }
1071
1072 // Queue Probe Response frame in high priority WQ
1073 halstatus = halTxFrame( ( tHalHandle ) pMac, pPacket,
1074 ( tANI_U16 ) nBytes,
1075 HAL_TXRX_FRM_802_11_MGMT,
1076 ANI_TXDIR_TODS,
1077 7,//SMAC_SWBD_TX_TID_MGMT_LOW,
1078 limTxComplete, pFrame, txFlag );
1079 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1080 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001081 limLog( pMac, LOGE, FL("Could not send Probe Response.") );
Jeff Johnson295189b2012-06-20 16:38:30 -07001082 //Pkt will be freed up by the callback
1083 }
1084
1085 if ( addIE != NULL )
1086 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301087 vos_mem_free(addIE);
Jeff Johnson295189b2012-06-20 16:38:30 -07001088 }
1089
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301090 vos_mem_free(pFrm);
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07001091 return;
1092
1093
Jeff Johnson295189b2012-06-20 16:38:30 -07001094} // End limSendProbeRspMgmtFrame.
1095
1096void
1097limSendAddtsReqActionFrame(tpAniSirGlobal pMac,
1098 tSirMacAddr peerMacAddr,
1099 tSirAddtsReqInfo *pAddTS,
1100 tpPESession psessionEntry)
1101{
1102 tANI_U16 i;
1103 tANI_U8 *pFrame;
1104 tSirRetStatus nSirStatus;
1105 tDot11fAddTSRequest AddTSReq;
1106 tDot11fWMMAddTSRequest WMMAddTSReq;
1107 tANI_U32 nPayload, nBytes, nStatus;
1108 tpSirMacMgmtHdr pMacHdr;
1109 void *pPacket;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001110#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07001111 tANI_U32 phyMode;
1112#endif
1113 eHalStatus halstatus;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05301114 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001115
1116 if(NULL == psessionEntry)
1117 {
1118 return;
1119 }
1120
1121 if ( ! pAddTS->wmeTspecPresent )
1122 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301123 vos_mem_set(( tANI_U8* )&AddTSReq, sizeof( AddTSReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001124
1125 AddTSReq.Action.action = SIR_MAC_QOS_ADD_TS_REQ;
1126 AddTSReq.DialogToken.token = pAddTS->dialogToken;
1127 AddTSReq.Category.category = SIR_MAC_ACTION_QOS_MGMT;
1128 if ( pAddTS->lleTspecPresent )
1129 {
1130 PopulateDot11fTSPEC( &pAddTS->tspec, &AddTSReq.TSPEC );
1131 }
1132 else
1133 {
1134 PopulateDot11fWMMTSPEC( &pAddTS->tspec, &AddTSReq.WMMTSPEC );
1135 }
1136
1137 if ( pAddTS->lleTspecPresent )
1138 {
1139 AddTSReq.num_WMMTCLAS = 0;
1140 AddTSReq.num_TCLAS = pAddTS->numTclas;
1141 for ( i = 0; i < pAddTS->numTclas; ++i)
1142 {
1143 PopulateDot11fTCLAS( pMac, &pAddTS->tclasInfo[i],
1144 &AddTSReq.TCLAS[i] );
1145 }
1146 }
1147 else
1148 {
1149 AddTSReq.num_TCLAS = 0;
1150 AddTSReq.num_WMMTCLAS = pAddTS->numTclas;
1151 for ( i = 0; i < pAddTS->numTclas; ++i)
1152 {
1153 PopulateDot11fWMMTCLAS( pMac, &pAddTS->tclasInfo[i],
1154 &AddTSReq.WMMTCLAS[i] );
1155 }
1156 }
1157
1158 if ( pAddTS->tclasProcPresent )
1159 {
1160 if ( pAddTS->lleTspecPresent )
1161 {
1162 AddTSReq.TCLASSPROC.processing = pAddTS->tclasProc;
1163 AddTSReq.TCLASSPROC.present = 1;
1164 }
1165 else
1166 {
1167 AddTSReq.WMMTCLASPROC.version = 1;
1168 AddTSReq.WMMTCLASPROC.processing = pAddTS->tclasProc;
1169 AddTSReq.WMMTCLASPROC.present = 1;
1170 }
1171 }
1172
1173 nStatus = dot11fGetPackedAddTSRequestSize( pMac, &AddTSReq, &nPayload );
1174 if ( DOT11F_FAILED( nStatus ) )
1175 {
1176 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001177 "or an Add TS Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001178 nStatus );
1179 // We'll fall back on the worst case scenario:
1180 nPayload = sizeof( tDot11fAddTSRequest );
1181 }
1182 else if ( DOT11F_WARNED( nStatus ) )
1183 {
1184 limLog( pMac, LOGW, FL("There were warnings while calculating"
1185 "the packed size for an Add TS Request"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001186 " (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001187 }
1188 }
1189 else
1190 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301191 vos_mem_set(( tANI_U8* )&WMMAddTSReq, sizeof( WMMAddTSReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001192
1193 WMMAddTSReq.Action.action = SIR_MAC_QOS_ADD_TS_REQ;
1194 WMMAddTSReq.DialogToken.token = pAddTS->dialogToken;
1195 WMMAddTSReq.Category.category = SIR_MAC_ACTION_WME;
1196
1197 // WMM spec 2.2.10 - status code is only filled in for ADDTS response
1198 WMMAddTSReq.StatusCode.statusCode = 0;
1199
1200 PopulateDot11fWMMTSPEC( &pAddTS->tspec, &WMMAddTSReq.WMMTSPEC );
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001201#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07001202 limGetPhyMode(pMac, &phyMode, psessionEntry);
1203
1204 if( phyMode == WNI_CFG_PHY_MODE_11G || phyMode == WNI_CFG_PHY_MODE_11A)
1205 {
1206 pAddTS->tsrsIE.rates[0] = TSRS_11AG_RATE_6MBPS;
1207 }
1208 else
1209 {
1210 pAddTS->tsrsIE.rates[0] = TSRS_11B_RATE_5_5MBPS;
1211 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001212 PopulateDot11TSRSIE(pMac,&pAddTS->tsrsIE, &WMMAddTSReq.ESETrafStrmRateSet,sizeof(tANI_U8));
Jeff Johnson295189b2012-06-20 16:38:30 -07001213#endif
1214 // fillWmeTspecIE
1215
1216 nStatus = dot11fGetPackedWMMAddTSRequestSize( pMac, &WMMAddTSReq, &nPayload );
1217 if ( DOT11F_FAILED( nStatus ) )
1218 {
1219 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001220 "or a WMM Add TS Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001221 nStatus );
1222 // We'll fall back on the worst case scenario:
1223 nPayload = sizeof( tDot11fAddTSRequest );
1224 }
1225 else if ( DOT11F_WARNED( nStatus ) )
1226 {
1227 limLog( pMac, LOGW, FL("There were warnings while calculating"
1228 "the packed size for a WMM Add TS Requ"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001229 "est (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001230 }
1231 }
1232
1233 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
1234
1235 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1236 ( tANI_U16 )nBytes, ( void** ) &pFrame,
1237 ( void** ) &pPacket );
1238 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1239 {
1240 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for an Ad"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001241 "d TS Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07001242 return;
1243 }
1244
1245 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301246 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07001247
1248 // Next, we fill out the buffer descriptor:
1249 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
1250 SIR_MAC_MGMT_ACTION, peerMacAddr,psessionEntry->selfMacAddr);
1251 if ( eSIR_SUCCESS != nSirStatus )
1252 {
1253 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001254 "tor for an Add TS Request (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001255 nSirStatus );
1256 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1257 ( void* ) pFrame, ( void* ) pPacket );
1258 return;
1259 }
1260
1261 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
1262
1263 #if 0
1264 cfgLen = SIR_MAC_ADDR_LENGTH;
1265 if ( eSIR_SUCCESS != wlan_cfgGetStr( pMac, WNI_CFG_BSSID,
1266 ( tANI_U8* )pMacHdr->bssId, &cfgLen ) )
1267 {
1268 limLog( pMac, LOGP, FL("Failed to retrieve WNI_CFG_BSSID whil"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001269 "e sending an Add TS Request.") );
Jeff Johnson295189b2012-06-20 16:38:30 -07001270 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1271 ( void* ) pFrame, ( void* ) pPacket );
1272 return;
1273 }
1274 #endif //TO SUPPORT BT-AMP
1275
1276 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
1277
Chet Lanctot186b5732013-03-18 10:26:30 -07001278#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07001279 limSetProtectedBit(pMac, psessionEntry, peerMacAddr, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07001280#endif
1281
Jeff Johnson295189b2012-06-20 16:38:30 -07001282 // That done, pack the struct:
1283 if ( ! pAddTS->wmeTspecPresent )
1284 {
1285 nStatus = dot11fPackAddTSRequest( pMac, &AddTSReq,
1286 pFrame + sizeof(tSirMacMgmtHdr),
1287 nPayload, &nPayload );
1288 if ( DOT11F_FAILED( nStatus ) )
1289 {
1290 limLog( pMac, LOGE, FL("Failed to pack an Add TS Request "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001291 "(0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001292 nStatus );
1293 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1294 return; // allocated!
1295 }
1296 else if ( DOT11F_WARNED( nStatus ) )
1297 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001298 limLog( pMac, LOGW, FL("There were warnings while packing "
1299 "an Add TS Request (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001300 }
1301 }
1302 else
1303 {
1304 nStatus = dot11fPackWMMAddTSRequest( pMac, &WMMAddTSReq,
1305 pFrame + sizeof(tSirMacMgmtHdr),
1306 nPayload, &nPayload );
1307 if ( DOT11F_FAILED( nStatus ) )
1308 {
1309 limLog( pMac, LOGE, FL("Failed to pack a WMM Add TS Reque"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001310 "st (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001311 nStatus );
1312 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1313 return; // allocated!
1314 }
1315 else if ( DOT11F_WARNED( nStatus ) )
1316 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001317 limLog( pMac, LOGW, FL("There were warnings while packing "
1318 "a WMM Add TS Request (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001319 }
1320 }
1321
Abhishek Singh127a8442014-12-15 17:31:27 +05301322 limLog( pMac, LOG1, FL("Sending an Add TS Request frame to ") );
1323 limPrintMacAddr( pMac, peerMacAddr, LOG1 );
Jeff Johnson295189b2012-06-20 16:38:30 -07001324
1325 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07001326 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
1327 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07001328 )
1329 {
1330 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
1331 }
1332
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05301333 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
1334 psessionEntry->peSessionId,
1335 pMacHdr->fc.subType));
Jeff Johnson295189b2012-06-20 16:38:30 -07001336 // Queue Addts Response frame in high priority WQ
1337 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
1338 HAL_TXRX_FRM_802_11_MGMT,
1339 ANI_TXDIR_TODS,
1340 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
1341 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05301342 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
1343 psessionEntry->peSessionId,
1344 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07001345 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1346 {
1347 limLog( pMac, LOGE, FL( "*** Could not send an Add TS Request"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001348 " (%X) ***" ), halstatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001349 //Pkt will be freed up by the callback
1350 }
1351
1352} // End limSendAddtsReqActionFrame.
1353
Jeff Johnson295189b2012-06-20 16:38:30 -07001354
1355
1356void
1357limSendAssocRspMgmtFrame(tpAniSirGlobal pMac,
1358 tANI_U16 statusCode,
1359 tANI_U16 aid,
1360 tSirMacAddr peerMacAddr,
1361 tANI_U8 subType,
1362 tpDphHashNode pSta,tpPESession psessionEntry)
1363{
1364 static tDot11fAssocResponse frm;
1365 tANI_U8 *pFrame, *macAddr;
1366 tpSirMacMgmtHdr pMacHdr;
1367 tSirRetStatus nSirStatus;
1368 tANI_U8 lleMode = 0, fAddTS, edcaInclude = 0;
1369 tHalBitVal qosMode, wmeMode;
c_hpothubcd78652014-04-28 22:31:08 +05301370 tANI_U32 nPayload, nStatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07001371 void *pPacket;
1372 eHalStatus halstatus;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05301373 tUpdateBeaconParams beaconParams;
1374 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001375 tANI_U32 addnIEPresent = false;
1376 tANI_U32 addnIELen=0;
1377 tANI_U8 addIE[WNI_CFG_ASSOC_RSP_ADDNIE_DATA_LEN];
1378 tpSirAssocReq pAssocReq = NULL;
Mahesh A Saptasagar38c177e2014-10-17 18:55:48 +05301379 tANI_U16 addStripoffIELen = 0;
1380 tDot11fIEExtCap extractedExtCap;
1381 tANI_BOOLEAN extractedExtCapFlag = eANI_BOOLEAN_FALSE;
c_hpothubcd78652014-04-28 22:31:08 +05301382 tANI_U32 nBytes = 0;
Kalikinkar dhara205da782014-03-21 15:49:32 -07001383
Chet Lanctot8cecea22014-02-11 19:09:36 -08001384#ifdef WLAN_FEATURE_11W
1385 tANI_U32 retryInterval;
1386 tANI_U32 maxRetries;
1387#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001388
1389 if(NULL == psessionEntry)
1390 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05301391 limLog( pMac, LOGE, FL("psessionEntry is NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001392 return;
1393 }
1394
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301395 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07001396
1397 limGetQosMode(psessionEntry, &qosMode);
1398 limGetWmeMode(psessionEntry, &wmeMode);
1399
1400 // An Add TS IE is added only if the AP supports it and the requesting
1401 // STA sent a traffic spec.
1402 fAddTS = ( qosMode && pSta && pSta->qos.addtsPresent ) ? 1 : 0;
1403
1404 PopulateDot11fCapabilities( pMac, &frm.Capabilities, psessionEntry );
1405
1406 frm.Status.status = statusCode;
1407
1408 frm.AID.associd = aid | LIM_AID_MASK;
1409
1410 if ( NULL == pSta )
1411 {
1412 PopulateDot11fSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL, &frm.SuppRates,psessionEntry);
1413 PopulateDot11fExtSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL, &frm.ExtSuppRates, psessionEntry );
1414 }
1415 else
1416 {
1417 PopulateDot11fAssocRspRates( pMac, &frm.SuppRates, &frm.ExtSuppRates,
1418 pSta->supportedRates.llbRates, pSta->supportedRates.llaRates );
1419 }
1420
Jeff Johnson295189b2012-06-20 16:38:30 -07001421 if(psessionEntry->limSystemRole == eLIM_AP_ROLE)
1422 {
1423 if( pSta != NULL && eSIR_SUCCESS == statusCode )
1424 {
1425 pAssocReq =
1426 (tpSirAssocReq) psessionEntry->parsedAssocReq[pSta->assocId];
Jeff Johnson295189b2012-06-20 16:38:30 -07001427 /* populate P2P IE in AssocRsp when assocReq from the peer includes P2P IE */
1428 if( pAssocReq != NULL && pAssocReq->addIEPresent ) {
1429 PopulateDot11AssocResP2PIE(pMac, &frm.P2PAssocRes, pAssocReq);
1430 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001431 }
1432 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001433
1434 if ( NULL != pSta )
1435 {
1436 if ( eHAL_SET == qosMode )
1437 {
1438 if ( pSta->lleEnabled )
1439 {
1440 lleMode = 1;
1441 if ( ( ! pSta->aniPeer ) || ( ! PROP_CAPABILITY_GET( 11EQOS, pSta->propCapability ) ) )
1442 {
1443 PopulateDot11fEDCAParamSet( pMac, &frm.EDCAParamSet, psessionEntry);
1444
1445// FramesToDo:...
1446// if ( fAddTS )
1447// {
1448// tANI_U8 *pAf = pBody;
1449// *pAf++ = SIR_MAC_QOS_ACTION_EID;
1450// tANI_U32 tlen;
1451// status = sirAddtsRspFill(pMac, pAf, statusCode, &pSta->qos.addts, NULL,
1452// &tlen, bufLen - frameLen);
1453// } // End if on Add TS.
1454 }
1455 } // End if on .11e enabled in 'pSta'.
1456 } // End if on QOS Mode on.
1457
1458 if ( ( ! lleMode ) && ( eHAL_SET == wmeMode ) && pSta->wmeEnabled )
1459 {
1460 if ( ( ! pSta->aniPeer ) || ( ! PROP_CAPABILITY_GET( WME, pSta->propCapability ) ) )
1461 {
1462
Jeff Johnson295189b2012-06-20 16:38:30 -07001463 PopulateDot11fWMMParams( pMac, &frm.WMMParams, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07001464
1465 if ( pSta->wsmEnabled )
1466 {
1467 PopulateDot11fWMMCaps(&frm.WMMCaps );
1468 }
1469 }
1470 }
1471
1472 if ( pSta->aniPeer )
1473 {
1474 if ( ( lleMode && PROP_CAPABILITY_GET( 11EQOS, pSta->propCapability ) ) ||
1475 ( pSta->wmeEnabled && PROP_CAPABILITY_GET( WME, pSta->propCapability ) ) )
1476 {
1477 edcaInclude = 1;
1478 }
1479
1480 } // End if on Airgo peer.
1481
1482 if ( pSta->mlmStaContext.htCapability &&
Jeff Johnsone7245742012-09-05 17:12:55 -07001483 psessionEntry->htCapability )
Jeff Johnson295189b2012-06-20 16:38:30 -07001484 {
Krishna Kumaar Natarajan025a8602015-08-04 16:31:36 +05301485 limLog(pMac, LOG1, FL("Populate HT IEs in Assoc Response"));
Jeff Johnsone7245742012-09-05 17:12:55 -07001486 PopulateDot11fHTCaps( pMac, psessionEntry, &frm.HTCaps );
Sachin Ahujac3a26232014-09-23 22:27:30 +05301487 /*
1488 *Check the STA capability and update the HTCaps accordingly
1489 */
1490 frm.HTCaps.supportedChannelWidthSet =
1491 (pSta->htSupportedChannelWidthSet < psessionEntry->htSupportedChannelWidthSet) ?
1492 pSta->htSupportedChannelWidthSet : psessionEntry->htSupportedChannelWidthSet ;
1493
1494 if (!frm.HTCaps.supportedChannelWidthSet)
1495 frm.HTCaps.shortGI40MHz = 0;
1496
Jeff Johnson295189b2012-06-20 16:38:30 -07001497 PopulateDot11fHTInfo( pMac, &frm.HTInfo, psessionEntry );
Jeff Johnson295189b2012-06-20 16:38:30 -07001498 }
Agrawal Ashishb10d0392015-08-06 16:18:20 +05301499 limLog(pMac, LOG1, FL("SupportedChnlWidth: %d, mimoPS: %d, GF: %d,"
1500 "shortGI20:%d, shortGI40: %d, dsssCck: %d, AMPDU Param: %x"),
1501 frm.HTCaps.supportedChannelWidthSet, frm.HTCaps.mimoPowerSave,
1502 frm.HTCaps.greenField, frm.HTCaps.shortGI20MHz, frm.HTCaps.shortGI40MHz,
1503 frm.HTCaps.dsssCckMode40MHz, frm.HTCaps.maxRxAMPDUFactor);
1504
1505
Jeff Johnsone7245742012-09-05 17:12:55 -07001506
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301507#ifdef WLAN_FEATURE_AP_HT40_24G
1508 /* Populate Overlapping BSS Scan Parameters IEs,
1509 * when operating in HT40 in 2.4GHz.
1510 */
Hardik Kantilal Patel3c235242015-01-02 17:56:18 +05301511 if ((pMac->roam.configParam.apHT40_24GEnabled)
1512 && (IS_DOT11_MODE_HT(psessionEntry->dot11mode)))
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301513 {
1514 PopulateDot11fOBSSScanParameters( pMac, &frm.OBSSScanParameters,
1515 psessionEntry);
Hardik Kantilal Patelee5874c2015-01-14 15:23:28 +05301516 /* 10.15.8 Support of DSSS/CCK in 40 MHz, An associated HT STA in
1517 * a 20/40 MHz BSS may generate DSSS/CCK transmissions.Set DSSS/CCK
1518 * Mode in 40 MHz bit in HT capablity.
1519 */
1520 frm.HTCaps.dsssCckMode40MHz = 1;
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301521 }
1522#endif
1523
1524 PopulateDot11fExtCap( pMac, &frm.ExtCap, psessionEntry);
Jeff Johnsone7245742012-09-05 17:12:55 -07001525#ifdef WLAN_FEATURE_11AC
1526 if( pSta->mlmStaContext.vhtCapability &&
1527 psessionEntry->vhtCapability )
1528 {
Chet Lanctotf19c1f62013-12-13 13:56:21 -08001529 limLog( pMac, LOG1, FL("Populate VHT IEs in Assoc Response"));
Abhishek Singh33f76ea2015-06-04 12:27:30 +05301530 PopulateDot11fVHTCaps( pMac, &frm.VHTCaps,
1531 psessionEntry->currentOperChannel, eSIR_TRUE );
1532 PopulateDot11fVHTOperation( pMac, &frm.VHTOperation,
1533 psessionEntry->currentOperChannel);
Jeff Johnsone7245742012-09-05 17:12:55 -07001534 }
1535#endif
1536
Chet Lanctot8cecea22014-02-11 19:09:36 -08001537#ifdef WLAN_FEATURE_11W
Dino Myclea7f18452014-04-24 08:55:31 +05301538 if( eSIR_MAC_TRY_AGAIN_LATER == statusCode )
1539 {
Chet Lanctotfadc8e32014-04-24 14:50:52 -07001540 if ( wlan_cfgGetInt(pMac, WNI_CFG_PMF_SA_QUERY_MAX_RETRIES,
1541 &maxRetries ) != eSIR_SUCCESS )
1542 limLog( pMac, LOGE,
1543 FL("Could not retrieve PMF SA Query maximum retries value") );
1544 else
1545 if ( wlan_cfgGetInt(pMac, WNI_CFG_PMF_SA_QUERY_RETRY_INTERVAL,
1546 &retryInterval ) != eSIR_SUCCESS)
1547 limLog( pMac, LOGE,
1548 FL("Could not retrieve PMF SA Query timer interval value") );
Dino Myclea7f18452014-04-24 08:55:31 +05301549 else
Chet Lanctotfadc8e32014-04-24 14:50:52 -07001550 PopulateDot11fTimeoutInterval(
1551 pMac, &frm.TimeoutInterval, SIR_MAC_TI_TYPE_ASSOC_COMEBACK,
1552 (maxRetries - pSta->pmfSaQueryRetryCount) * retryInterval );
Dino Myclea7f18452014-04-24 08:55:31 +05301553 }
Chet Lanctot8cecea22014-02-11 19:09:36 -08001554#endif
Dino Myclea7f18452014-04-24 08:55:31 +05301555 } // End if on non-NULL 'pSta'.
Jeff Johnson295189b2012-06-20 16:38:30 -07001556
Chet Lanctot8cecea22014-02-11 19:09:36 -08001557 vos_mem_set(( tANI_U8* )&beaconParams, sizeof( tUpdateBeaconParams), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001558
Jeff Johnson295189b2012-06-20 16:38:30 -07001559 if( psessionEntry->limSystemRole == eLIM_AP_ROLE ){
1560 if(psessionEntry->gLimProtectionControl != WNI_CFG_FORCE_POLICY_PROTECTION_DISABLE)
1561 limDecideApProtection(pMac, peerMacAddr, &beaconParams,psessionEntry);
1562 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001563
1564 limUpdateShortPreamble(pMac, peerMacAddr, &beaconParams, psessionEntry);
1565 limUpdateShortSlotTime(pMac, peerMacAddr, &beaconParams, psessionEntry);
1566
1567 beaconParams.bssIdx = psessionEntry->bssIdx;
1568
1569 //Send message to HAL about beacon parameter change.
1570 if(beaconParams.paramChangeBitmap)
1571 {
1572 schSetFixedBeaconFields(pMac,psessionEntry);
1573 limSendBeaconParams(pMac, &beaconParams, psessionEntry );
1574 }
1575
Jeff Johnson295189b2012-06-20 16:38:30 -07001576 if ( pAssocReq != NULL )
1577 {
1578 if (wlan_cfgGetInt(pMac, WNI_CFG_ASSOC_RSP_ADDNIE_FLAG,
1579 &addnIEPresent) != eSIR_SUCCESS)
1580 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05301581 limLog(pMac, LOGP, FL("Unable to get "
1582 "WNI_CFG_ASSOC_RSP_ADDNIE_FLAG"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001583 return;
1584 }
1585
1586 if (addnIEPresent)
1587 {
1588 //Assoc rsp IE available
1589 if (wlan_cfgGetStrLen(pMac, WNI_CFG_ASSOC_RSP_ADDNIE_DATA,
1590 &addnIELen) != eSIR_SUCCESS)
1591 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05301592 limLog(pMac, LOGP, FL("Unable to get "
1593 "WNI_CFG_ASSOC_RSP_ADDNIE_DATA length"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001594 return;
1595 }
1596
1597 if (addnIELen <= WNI_CFG_ASSOC_RSP_ADDNIE_DATA_LEN && addnIELen &&
1598 (nBytes + addnIELen) <= SIR_MAX_PACKET_SIZE)
1599 {
1600 if (wlan_cfgGetStr(pMac, WNI_CFG_ASSOC_RSP_ADDNIE_DATA,
1601 &addIE[0], &addnIELen) == eSIR_SUCCESS)
1602 {
Mahesh A Saptasagar38c177e2014-10-17 18:55:48 +05301603
1604 vos_mem_set(( tANI_U8* )&extractedExtCap,
1605 sizeof( tDot11fIEExtCap ), 0);
Mahesh A Saptasagare00ff532014-10-17 19:05:14 +05301606 addStripoffIELen = addnIELen;
Mahesh A Saptasagar38c177e2014-10-17 18:55:48 +05301607 nSirStatus = limStripOffExtCapIEAndUpdateStruct(pMac,
1608 &addIE[0],
1609 &addStripoffIELen,
1610 &extractedExtCap );
1611 if(eSIR_SUCCESS != nSirStatus)
1612 {
1613 limLog(pMac, LOG1,
1614 FL("Unable to Stripoff ExtCap IE from Assoc Rsp"));
1615 }
1616 else
1617 {
1618 addnIELen = addStripoffIELen;
1619 extractedExtCapFlag = eANI_BOOLEAN_TRUE;
1620 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001621 nBytes = nBytes + addnIELen;
1622 }
1623 }
1624 }
1625 }
1626
Mahesh A Saptasagar38c177e2014-10-17 18:55:48 +05301627 /* merge the ExtCap struct*/
1628 if (extractedExtCapFlag && extractedExtCap.present)
1629 {
1630 limMergeExtCapIEStruct(&(frm.ExtCap), &extractedExtCap);
1631 }
1632
c_hpothubcd78652014-04-28 22:31:08 +05301633 nStatus = dot11fGetPackedAssocResponseSize( pMac, &frm, &nPayload );
1634 if ( DOT11F_FAILED( nStatus ) )
1635 {
1636 limLog( pMac, LOGE, FL("Failed to calculate the packed size f"
1637 "or an Association Response (0x%08x)."),
1638 nStatus );
1639 return;
1640 }
1641 else if ( DOT11F_WARNED( nStatus ) )
1642 {
1643 limLog( pMac, LOGW, FL("There were warnings while calculating "
1644 "the packed size for an Association Re"
1645 "sponse (0x%08x)."), nStatus );
1646 }
1647
1648 nBytes += sizeof( tSirMacMgmtHdr ) + nPayload;
1649
Jeff Johnson295189b2012-06-20 16:38:30 -07001650 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1651 ( tANI_U16 )nBytes, ( void** ) &pFrame,
1652 ( void** ) &pPacket );
1653 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1654 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001655 limLog(pMac, LOGP, FL("Call to bufAlloc failed for RE/ASSOC RSP."));
Jeff Johnson295189b2012-06-20 16:38:30 -07001656 return;
1657 }
1658
1659 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301660 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07001661
1662 // Next, we fill out the buffer descriptor:
1663 nSirStatus = limPopulateMacHeader( pMac,
1664 pFrame,
1665 SIR_MAC_MGMT_FRAME,
1666 ( LIM_ASSOC == subType ) ?
1667 SIR_MAC_MGMT_ASSOC_RSP :
1668 SIR_MAC_MGMT_REASSOC_RSP,
1669 peerMacAddr,psessionEntry->selfMacAddr);
1670 if ( eSIR_SUCCESS != nSirStatus )
1671 {
1672 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001673 "tor for an Association Response (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001674 nSirStatus );
1675 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1676 ( void* ) pFrame, ( void* ) pPacket );
1677 return;
1678 }
1679
1680 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
1681
Jeff Johnson295189b2012-06-20 16:38:30 -07001682 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
1683
1684 nStatus = dot11fPackAssocResponse( pMac, &frm,
1685 pFrame + sizeof( tSirMacMgmtHdr ),
1686 nPayload, &nPayload );
1687 if ( DOT11F_FAILED( nStatus ) )
1688 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05301689 limLog( pMac, LOGE, FL("Failed to pack an Association Response"
1690 " (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001691 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1692 ( void* ) pFrame, ( void* ) pPacket );
1693 return; // allocated!
1694 }
1695 else if ( DOT11F_WARNED( nStatus ) )
1696 {
1697 limLog( pMac, LOGW, FL("There were warnings while packing an "
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001698 "Association Response (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001699 }
1700
1701 macAddr = pMacHdr->da;
1702
1703 if (subType == LIM_ASSOC)
1704 {
Abhishek Singh3cbf6052014-12-15 16:46:42 +05301705 limLog(pMac, LOG1,
Jeff Johnson295189b2012-06-20 16:38:30 -07001706 FL("*** Sending Assoc Resp status %d aid %d to "),
Abhishek Singh3cbf6052014-12-15 16:46:42 +05301707 statusCode, aid);
Jeff Johnson295189b2012-06-20 16:38:30 -07001708 }
1709 else{
Abhishek Singh3cbf6052014-12-15 16:46:42 +05301710 limLog(pMac, LOG1,
Jeff Johnson295189b2012-06-20 16:38:30 -07001711 FL("*** Sending ReAssoc Resp status %d aid %d to "),
Abhishek Singh3cbf6052014-12-15 16:46:42 +05301712 statusCode, aid);
Jeff Johnson295189b2012-06-20 16:38:30 -07001713 }
Abhishek Singh3cbf6052014-12-15 16:46:42 +05301714 limPrintMacAddr(pMac, pMacHdr->da, LOG1);
Jeff Johnson295189b2012-06-20 16:38:30 -07001715
1716 if ( addnIEPresent )
1717 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301718 vos_mem_copy ( pFrame+sizeof(tSirMacMgmtHdr)+nPayload, &addIE[0], addnIELen ) ;
Jeff Johnson295189b2012-06-20 16:38:30 -07001719 }
1720
1721 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07001722 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
1723 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07001724 )
1725 {
1726 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
1727 }
1728
Agarwal Ashisha8e81f52014-04-02 01:59:52 +05301729 limLog( pMac, LOG1, FL("Sending Assoc resp over WQ5 to "MAC_ADDRESS_STR
1730 " From " MAC_ADDRESS_STR),MAC_ADDR_ARRAY(pMacHdr->da),
1731 MAC_ADDR_ARRAY(psessionEntry->selfMacAddr));
1732
1733 txFlag |= HAL_USE_FW_IN_TX_PATH;
1734
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05301735 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
1736 psessionEntry->peSessionId,
1737 pMacHdr->fc.subType));
Ganesh Kondabattiniffc00b12015-03-18 13:11:33 +05301738
1739 if (IS_FEATURE_SUPPORTED_BY_FW(ENHANCED_TXBD_COMPLETION))
1740 {
1741 limLog(pMac, LOG1, FL("Re/AssocRsp - txBdToken %u"), pMac->lim.txBdToken);
1742 /// Queue Association Response frame in high priority WQ
1743 halstatus = halTxFrameWithTxComplete( pMac, pPacket, ( tANI_U16 ) nBytes,
1744 HAL_TXRX_FRM_802_11_MGMT,
1745 ANI_TXDIR_TODS,
1746 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
1747 limTxComplete, pFrame, limTxBdComplete,
1748 txFlag, pMac->lim.txBdToken );
1749 pMac->lim.txBdToken++;
1750 }
1751 else
1752 {
1753 /// Queue Association Response frame in high priority WQ
1754 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
1755 HAL_TXRX_FRM_802_11_MGMT,
1756 ANI_TXDIR_TODS,
1757 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
1758 limTxComplete, pFrame, txFlag );
1759 }
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05301760 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
1761 psessionEntry->peSessionId,
1762 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07001763 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1764 {
1765 limLog(pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001766 FL("*** Could not Send Re/AssocRsp, retCode=%X ***"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001767 nSirStatus);
1768
1769 //Pkt will be freed up by the callback
1770 }
1771
1772 // update the ANI peer station count
1773 //FIXME_PROTECTION : take care of different type of station
1774 // counter inside this function.
1775 limUtilCountStaAdd(pMac, pSta, psessionEntry);
1776
1777} // End limSendAssocRspMgmtFrame.
1778
1779
1780
1781void
1782limSendAddtsRspActionFrame(tpAniSirGlobal pMac,
1783 tSirMacAddr peer,
1784 tANI_U16 nStatusCode,
1785 tSirAddtsReqInfo *pAddTS,
1786 tSirMacScheduleIE *pSchedule,
1787 tpPESession psessionEntry)
1788{
1789 tANI_U8 *pFrame;
1790 tpSirMacMgmtHdr pMacHdr;
1791 tDot11fAddTSResponse AddTSRsp;
1792 tDot11fWMMAddTSResponse WMMAddTSRsp;
1793 tSirRetStatus nSirStatus;
1794 tANI_U32 i, nBytes, nPayload, nStatus;
1795 void *pPacket;
1796 eHalStatus halstatus;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05301797 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001798
1799 if(NULL == psessionEntry)
1800 {
1801 return;
1802 }
1803
1804 if ( ! pAddTS->wmeTspecPresent )
1805 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301806 vos_mem_set( ( tANI_U8* )&AddTSRsp, sizeof( AddTSRsp ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07001807
1808 AddTSRsp.Category.category = SIR_MAC_ACTION_QOS_MGMT;
1809 AddTSRsp.Action.action = SIR_MAC_QOS_ADD_TS_RSP;
1810 AddTSRsp.DialogToken.token = pAddTS->dialogToken;
1811 AddTSRsp.Status.status = nStatusCode;
1812
1813 // The TsDelay information element is only filled in for a specific
1814 // status code:
1815 if ( eSIR_MAC_TS_NOT_CREATED_STATUS == nStatusCode )
1816 {
1817 if ( pAddTS->wsmTspecPresent )
1818 {
1819 AddTSRsp.WMMTSDelay.version = 1;
1820 AddTSRsp.WMMTSDelay.delay = 10;
1821 AddTSRsp.WMMTSDelay.present = 1;
1822 }
1823 else
1824 {
1825 AddTSRsp.TSDelay.delay = 10;
1826 AddTSRsp.TSDelay.present = 1;
1827 }
1828 }
1829
1830 if ( pAddTS->wsmTspecPresent )
1831 {
1832 PopulateDot11fWMMTSPEC( &pAddTS->tspec, &AddTSRsp.WMMTSPEC );
1833 }
1834 else
1835 {
1836 PopulateDot11fTSPEC( &pAddTS->tspec, &AddTSRsp.TSPEC );
1837 }
1838
1839 if ( pAddTS->wsmTspecPresent )
1840 {
1841 AddTSRsp.num_WMMTCLAS = 0;
1842 AddTSRsp.num_TCLAS = pAddTS->numTclas;
1843 for ( i = 0; i < AddTSRsp.num_TCLAS; ++i)
1844 {
1845 PopulateDot11fTCLAS( pMac, &pAddTS->tclasInfo[i],
1846 &AddTSRsp.TCLAS[i] );
1847 }
1848 }
1849 else
1850 {
1851 AddTSRsp.num_TCLAS = 0;
1852 AddTSRsp.num_WMMTCLAS = pAddTS->numTclas;
1853 for ( i = 0; i < AddTSRsp.num_WMMTCLAS; ++i)
1854 {
1855 PopulateDot11fWMMTCLAS( pMac, &pAddTS->tclasInfo[i],
1856 &AddTSRsp.WMMTCLAS[i] );
1857 }
1858 }
1859
1860 if ( pAddTS->tclasProcPresent )
1861 {
1862 if ( pAddTS->wsmTspecPresent )
1863 {
1864 AddTSRsp.WMMTCLASPROC.version = 1;
1865 AddTSRsp.WMMTCLASPROC.processing = pAddTS->tclasProc;
1866 AddTSRsp.WMMTCLASPROC.present = 1;
1867 }
1868 else
1869 {
1870 AddTSRsp.TCLASSPROC.processing = pAddTS->tclasProc;
1871 AddTSRsp.TCLASSPROC.present = 1;
1872 }
1873 }
1874
1875 // schedule element is included only if requested in the tspec and we are
1876 // using hcca (or both edca and hcca)
1877 // 11e-D8.0 is inconsistent on whether the schedule element is included
1878 // based on tspec schedule bit or not. Sec 7.4.2.2. says one thing but
1879 // pg 46, line 17-18 says something else. So just include it and let the
1880 // sta figure it out
1881 if ((pSchedule != NULL) &&
1882 ((pAddTS->tspec.tsinfo.traffic.accessPolicy == SIR_MAC_ACCESSPOLICY_HCCA) ||
1883 (pAddTS->tspec.tsinfo.traffic.accessPolicy == SIR_MAC_ACCESSPOLICY_BOTH)))
1884 {
1885 if ( pAddTS->wsmTspecPresent )
1886 {
1887 PopulateDot11fWMMSchedule( pSchedule, &AddTSRsp.WMMSchedule );
1888 }
1889 else
1890 {
1891 PopulateDot11fSchedule( pSchedule, &AddTSRsp.Schedule );
1892 }
1893 }
1894
1895 nStatus = dot11fGetPackedAddTSResponseSize( pMac, &AddTSRsp, &nPayload );
1896 if ( DOT11F_FAILED( nStatus ) )
1897 {
1898 limLog( pMac, LOGP, FL("Failed to calculate the packed si"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001899 "ze for an Add TS Response (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001900 nStatus );
1901 // We'll fall back on the worst case scenario:
1902 nPayload = sizeof( tDot11fAddTSResponse );
1903 }
1904 else if ( DOT11F_WARNED( nStatus ) )
1905 {
1906 limLog( pMac, LOGW, FL("There were warnings while calcula"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001907 "ting the packed size for an Add TS"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001908 " Response (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001909 }
1910 }
1911 else
1912 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301913 vos_mem_set( ( tANI_U8* )&WMMAddTSRsp, sizeof( WMMAddTSRsp ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07001914
1915 WMMAddTSRsp.Category.category = SIR_MAC_ACTION_WME;
1916 WMMAddTSRsp.Action.action = SIR_MAC_QOS_ADD_TS_RSP;
1917 WMMAddTSRsp.DialogToken.token = pAddTS->dialogToken;
1918 WMMAddTSRsp.StatusCode.statusCode = (tANI_U8)nStatusCode;
1919
1920 PopulateDot11fWMMTSPEC( &pAddTS->tspec, &WMMAddTSRsp.WMMTSPEC );
1921
1922 nStatus = dot11fGetPackedWMMAddTSResponseSize( pMac, &WMMAddTSRsp, &nPayload );
1923 if ( DOT11F_FAILED( nStatus ) )
1924 {
1925 limLog( pMac, LOGP, FL("Failed to calculate the packed si"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001926 "ze for a WMM Add TS Response (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001927 nStatus );
1928 // We'll fall back on the worst case scenario:
1929 nPayload = sizeof( tDot11fWMMAddTSResponse );
1930 }
1931 else if ( DOT11F_WARNED( nStatus ) )
1932 {
1933 limLog( pMac, LOGW, FL("There were warnings while calcula"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001934 "ting the packed size for a WMM Add"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001935 "TS Response (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001936 }
1937 }
1938
1939 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
1940
1941 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
1942 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1943 {
1944 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for an Ad"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001945 "d TS Response."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07001946 return;
1947 }
1948
1949 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301950 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07001951
1952 // Next, we fill out the buffer descriptor:
1953 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
1954 SIR_MAC_MGMT_ACTION, peer,psessionEntry->selfMacAddr);
1955 if ( eSIR_SUCCESS != nSirStatus )
1956 {
1957 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001958 "tor for an Add TS Response (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001959 nSirStatus );
1960 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1961 return; // allocated!
1962 }
1963
1964 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
1965
1966
1967 #if 0
1968 if ( eSIR_SUCCESS != wlan_cfgGetStr( pMac, WNI_CFG_BSSID,
1969 ( tANI_U8* )pMacHdr->bssId, &cfgLen ) )
1970 {
1971 limLog( pMac, LOGP, FL("Failed to retrieve WNI_CFG_BSSID whil"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001972 "e sending an Add TS Response.") );
Jeff Johnson295189b2012-06-20 16:38:30 -07001973 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1974 return; // allocated!
1975 }
1976 #endif //TO SUPPORT BT-AMP
1977 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
1978
Chet Lanctot186b5732013-03-18 10:26:30 -07001979#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07001980 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07001981#endif
1982
Jeff Johnson295189b2012-06-20 16:38:30 -07001983 // That done, pack the struct:
1984 if ( ! pAddTS->wmeTspecPresent )
1985 {
1986 nStatus = dot11fPackAddTSResponse( pMac, &AddTSRsp,
1987 pFrame + sizeof( tSirMacMgmtHdr ),
1988 nPayload, &nPayload );
1989 if ( DOT11F_FAILED( nStatus ) )
1990 {
1991 limLog( pMac, LOGE, FL("Failed to pack an Add TS Response "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001992 "(0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001993 nStatus );
1994 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1995 return;
1996 }
1997 else if ( DOT11F_WARNED( nStatus ) )
1998 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001999 limLog( pMac, LOGW, FL("There were warnings while packing "
2000 "an Add TS Response (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07002001 }
2002 }
2003 else
2004 {
2005 nStatus = dot11fPackWMMAddTSResponse( pMac, &WMMAddTSRsp,
2006 pFrame + sizeof( tSirMacMgmtHdr ),
2007 nPayload, &nPayload );
2008 if ( DOT11F_FAILED( nStatus ) )
2009 {
2010 limLog( pMac, LOGE, FL("Failed to pack a WMM Add TS Response "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002011 "(0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002012 nStatus );
2013 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
2014 return;
2015 }
2016 else if ( DOT11F_WARNED( nStatus ) )
2017 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08002018 limLog( pMac, LOGW, FL("There were warnings while packing "
2019 "a WMM Add TS Response (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07002020 }
2021 }
2022
Abhishek Singh3cbf6052014-12-15 16:46:42 +05302023 limLog( pMac, LOG1, FL("Sending an Add TS Response (status %d) to "),
Jeff Johnson295189b2012-06-20 16:38:30 -07002024 nStatusCode );
Abhishek Singh3cbf6052014-12-15 16:46:42 +05302025 limPrintMacAddr( pMac, pMacHdr->da, LOG1 );
Jeff Johnson295189b2012-06-20 16:38:30 -07002026
2027 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07002028 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
2029 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07002030 )
2031 {
2032 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
2033 }
2034
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05302035 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
2036 psessionEntry->peSessionId,
2037 pMacHdr->fc.subType));
Jeff Johnson295189b2012-06-20 16:38:30 -07002038 // Queue the frame in high priority WQ:
2039 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
2040 HAL_TXRX_FRM_802_11_MGMT,
2041 ANI_TXDIR_TODS,
2042 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
2043 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05302044 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
2045 psessionEntry->peSessionId,
2046 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07002047 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
2048 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002049 limLog( pMac, LOGE, FL("Failed to send Add TS Response (%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002050 nSirStatus );
2051 //Pkt will be freed up by the callback
2052 }
2053
2054} // End limSendAddtsRspActionFrame.
2055
2056void
2057limSendDeltsReqActionFrame(tpAniSirGlobal pMac,
2058 tSirMacAddr peer,
2059 tANI_U8 wmmTspecPresent,
2060 tSirMacTSInfo *pTsinfo,
2061 tSirMacTspecIE *pTspecIe,
2062 tpPESession psessionEntry)
2063{
2064 tANI_U8 *pFrame;
2065 tpSirMacMgmtHdr pMacHdr;
2066 tDot11fDelTS DelTS;
2067 tDot11fWMMDelTS WMMDelTS;
2068 tSirRetStatus nSirStatus;
2069 tANI_U32 nBytes, nPayload, nStatus;
2070 void *pPacket;
2071 eHalStatus halstatus;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05302072 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002073
2074 if(NULL == psessionEntry)
2075 {
2076 return;
2077 }
2078
2079 if ( ! wmmTspecPresent )
2080 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302081 vos_mem_set( ( tANI_U8* )&DelTS, sizeof( DelTS ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07002082
2083 DelTS.Category.category = SIR_MAC_ACTION_QOS_MGMT;
2084 DelTS.Action.action = SIR_MAC_QOS_DEL_TS_REQ;
2085 PopulateDot11fTSInfo( pTsinfo, &DelTS.TSInfo );
2086
2087 nStatus = dot11fGetPackedDelTSSize( pMac, &DelTS, &nPayload );
2088 if ( DOT11F_FAILED( nStatus ) )
2089 {
2090 limLog( pMac, LOGP, FL("Failed to calculate the packed si"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002091 "ze for a Del TS (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002092 nStatus );
2093 // We'll fall back on the worst case scenario:
2094 nPayload = sizeof( tDot11fDelTS );
2095 }
2096 else if ( DOT11F_WARNED( nStatus ) )
2097 {
2098 limLog( pMac, LOGW, FL("There were warnings while calcula"
2099 "ting the packed size for a Del TS"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002100 " (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07002101 }
2102 }
2103 else
2104 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302105 vos_mem_set( ( tANI_U8* )&WMMDelTS, sizeof( WMMDelTS ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07002106
2107 WMMDelTS.Category.category = SIR_MAC_ACTION_WME;
2108 WMMDelTS.Action.action = SIR_MAC_QOS_DEL_TS_REQ;
2109 WMMDelTS.DialogToken.token = 0;
2110 WMMDelTS.StatusCode.statusCode = 0;
2111 PopulateDot11fWMMTSPEC( pTspecIe, &WMMDelTS.WMMTSPEC );
2112 nStatus = dot11fGetPackedWMMDelTSSize( pMac, &WMMDelTS, &nPayload );
2113 if ( DOT11F_FAILED( nStatus ) )
2114 {
2115 limLog( pMac, LOGP, FL("Failed to calculate the packed si"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002116 "ze for a WMM Del TS (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002117 nStatus );
2118 // We'll fall back on the worst case scenario:
2119 nPayload = sizeof( tDot11fDelTS );
2120 }
2121 else if ( DOT11F_WARNED( nStatus ) )
2122 {
2123 limLog( pMac, LOGW, FL("There were warnings while calcula"
2124 "ting the packed size for a WMM De"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002125 "l TS (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07002126 }
2127 }
2128
2129 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
2130
2131 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
2132 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
2133 {
2134 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for an Ad"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002135 "d TS Response."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07002136 return;
2137 }
2138
2139 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302140 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07002141
2142 // Next, we fill out the buffer descriptor:
2143 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
2144 SIR_MAC_MGMT_ACTION, peer,
2145 psessionEntry->selfMacAddr);
2146 if ( eSIR_SUCCESS != nSirStatus )
2147 {
2148 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002149 "tor for an Add TS Response (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002150 nSirStatus );
2151 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
2152 return; // allocated!
2153 }
2154
2155 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
2156
2157 #if 0
2158
2159 cfgLen = SIR_MAC_ADDR_LENGTH;
2160 if ( eSIR_SUCCESS != wlan_cfgGetStr( pMac, WNI_CFG_BSSID,
2161 ( tANI_U8* )pMacHdr->bssId, &cfgLen ) )
2162 {
2163 limLog( pMac, LOGP, FL("Failed to retrieve WNI_CFG_BSSID whil"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002164 "e sending an Add TS Response.") );
Jeff Johnson295189b2012-06-20 16:38:30 -07002165 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
2166 return; // allocated!
2167 }
2168 #endif //TO SUPPORT BT-AMP
2169 sirCopyMacAddr(pMacHdr->bssId, psessionEntry->bssId);
2170
Chet Lanctot186b5732013-03-18 10:26:30 -07002171#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07002172 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07002173#endif
2174
Jeff Johnson295189b2012-06-20 16:38:30 -07002175 // That done, pack the struct:
2176 if ( !wmmTspecPresent )
2177 {
2178 nStatus = dot11fPackDelTS( pMac, &DelTS,
2179 pFrame + sizeof( tSirMacMgmtHdr ),
2180 nPayload, &nPayload );
2181 if ( DOT11F_FAILED( nStatus ) )
2182 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002183 limLog( pMac, LOGE, FL("Failed to pack a Del TS frame (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002184 nStatus );
2185 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
2186 return; // allocated!
2187 }
2188 else if ( DOT11F_WARNED( nStatus ) )
2189 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08002190 limLog( pMac, LOGW, FL("There were warnings while packing "
2191 "a Del TS frame (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07002192 }
2193 }
2194 else
2195 {
2196 nStatus = dot11fPackWMMDelTS( pMac, &WMMDelTS,
2197 pFrame + sizeof( tSirMacMgmtHdr ),
2198 nPayload, &nPayload );
2199 if ( DOT11F_FAILED( nStatus ) )
2200 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002201 limLog( pMac, LOGE, FL("Failed to pack a WMM Del TS frame (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002202 nStatus );
2203 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
2204 return; // allocated!
2205 }
2206 else if ( DOT11F_WARNED( nStatus ) )
2207 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08002208 limLog( pMac, LOGW, FL("There were warnings while packing "
2209 "a WMM Del TS frame (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07002210 }
2211 }
2212
Abhishek Singh3cbf6052014-12-15 16:46:42 +05302213 limLog(pMac, LOG1, FL("Sending DELTS REQ (size %d) to "), nBytes);
2214 limPrintMacAddr(pMac, pMacHdr->da, LOG1);
Jeff Johnson295189b2012-06-20 16:38:30 -07002215
2216 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07002217 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
2218 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07002219 )
2220 {
2221 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
2222 }
2223
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05302224 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
2225 psessionEntry->peSessionId,
2226 pMacHdr->fc.subType));
Jeff Johnson295189b2012-06-20 16:38:30 -07002227 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
2228 HAL_TXRX_FRM_802_11_MGMT,
2229 ANI_TXDIR_TODS,
2230 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
2231 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05302232 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
2233 psessionEntry->peSessionId,
2234 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07002235 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
2236 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002237 limLog( pMac, LOGE, FL("Failed to send Del TS (%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002238 nSirStatus );
2239 //Pkt will be freed up by the callback
2240 }
2241
2242} // End limSendDeltsReqActionFrame.
2243
2244void
2245limSendAssocReqMgmtFrame(tpAniSirGlobal pMac,
2246 tLimMlmAssocReq *pMlmAssocReq,
2247 tpPESession psessionEntry)
2248{
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002249 tDot11fAssocRequest *pFrm;
Jeff Johnson295189b2012-06-20 16:38:30 -07002250 tANI_U16 caps;
2251 tANI_U8 *pFrame;
Agrawal Ashish5ac89da2015-10-26 19:08:47 +05302252 tSirRetStatus nSirStatus = eSIR_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07002253 tLimMlmAssocCnf mlmAssocCnf;
c_hpothubcd78652014-04-28 22:31:08 +05302254 tANI_U32 nPayload, nStatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07002255 tANI_U8 fQosEnabled, fWmeEnabled, fWsmEnabled;
2256 void *pPacket;
2257 eHalStatus halstatus;
2258 tANI_U16 nAddIELen;
2259 tANI_U8 *pAddIE;
2260 tANI_U8 *wpsIe = NULL;
2261#if defined WLAN_FEATURE_VOWIFI
2262 tANI_U8 PowerCapsPopulated = FALSE;
2263#endif
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05302264 tANI_U32 txFlag = 0;
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05302265 tpSirMacMgmtHdr pMacHdr;
Kalikinkar dhara205da782014-03-21 15:49:32 -07002266 tDot11fIEExtCap extractedExtCap;
2267 tANI_BOOLEAN extractedExtCapFlag = eANI_BOOLEAN_TRUE;
c_hpothubcd78652014-04-28 22:31:08 +05302268 tANI_U32 nBytes = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002269
2270 if(NULL == psessionEntry)
2271 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05302272 limLog(pMac, LOGE, FL("psessionEntry is NULL") );
Jeff Johnson295189b2012-06-20 16:38:30 -07002273 return;
2274 }
2275
Jeff Johnson295189b2012-06-20 16:38:30 -07002276 /* check this early to avoid unncessary operation */
2277 if(NULL == psessionEntry->pLimJoinReq)
2278 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05302279 limLog(pMac, LOGE, FL("psessionEntry->pLimJoinReq is NULL") );
Jeff Johnson295189b2012-06-20 16:38:30 -07002280 return;
2281 }
2282 nAddIELen = psessionEntry->pLimJoinReq->addIEAssoc.length;
2283 pAddIE = psessionEntry->pLimJoinReq->addIEAssoc.addIEdata;
2284
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302285 pFrm = vos_mem_malloc(sizeof(tDot11fAssocRequest));
2286 if ( NULL == pFrm )
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002287 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05302288 limLog(pMac, LOGE, FL("Unable to allocate memory") );
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002289 return;
2290 }
2291
2292
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302293 vos_mem_set( ( tANI_U8* )pFrm, sizeof( tDot11fAssocRequest ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07002294
Kalikinkar dhara205da782014-03-21 15:49:32 -07002295 vos_mem_set(( tANI_U8* )&extractedExtCap, sizeof( tDot11fIEExtCap ), 0);
Agrawal Ashish5ac89da2015-10-26 19:08:47 +05302296 if (psessionEntry->is_ext_caps_present)
2297 {
2298 nSirStatus = limStripOffExtCapIEAndUpdateStruct(pMac, pAddIE,
Kalikinkar dhara205da782014-03-21 15:49:32 -07002299 &nAddIELen,
2300 &extractedExtCap );
Agrawal Ashish5ac89da2015-10-26 19:08:47 +05302301 }
Kalikinkar dhara205da782014-03-21 15:49:32 -07002302 if(eSIR_SUCCESS != nSirStatus )
2303 {
2304 extractedExtCapFlag = eANI_BOOLEAN_FALSE;
2305 limLog(pMac, LOG1,
2306 FL("Unable to Stripoff ExtCap IE from Assoc Req"));
2307 }
Leela Venkata Kiran Kumar Reddy Chirala2f9b5712014-05-06 00:09:42 -07002308 /* TODO:remove this code once driver provides the call back function
2309 * to supplicant for set_qos_map
2310 */
2311 else
2312 {
Abhishek Singhc601a472016-01-20 11:08:32 +05302313 if (extractedExtCap.interworkingService ||
2314 extractedExtCap.bssTransition)
Leela Venkata Kiran Kumar Reddy Chirala2f9b5712014-05-06 00:09:42 -07002315 {
2316 extractedExtCap.qosMap = 1;
2317 }
Abhishek Singh15d95602015-03-24 15:52:57 +05302318 /* No need to merge the EXT Cap from Supplicant
Abhishek Singhc601a472016-01-20 11:08:32 +05302319 * if interworkingService or bsstransition is not set,
2320 * as currently driver is only interested in interworkingService
2321 * and bsstransition capability from supplicant. if in
Abhishek Singh15d95602015-03-24 15:52:57 +05302322 * future any other EXT Cap info is required from
2323 * supplicant it needs to be handled here.
2324 */
2325 else
2326 {
2327 extractedExtCapFlag = eANI_BOOLEAN_FALSE;
2328 }
Leela Venkata Kiran Kumar Reddy Chirala2f9b5712014-05-06 00:09:42 -07002329 }
Kalikinkar dhara205da782014-03-21 15:49:32 -07002330
Jeff Johnson295189b2012-06-20 16:38:30 -07002331 caps = pMlmAssocReq->capabilityInfo;
2332 if ( PROP_CAPABILITY_GET( 11EQOS, psessionEntry->limCurrentBssPropCap ) )
2333 ((tSirMacCapabilityInfo *) &caps)->qos = 0;
2334#if defined(FEATURE_WLAN_WAPI)
2335 /* CR: 262463 :
2336 According to WAPI standard:
2337 7.3.1.4 Capability Information field
2338 In WAPI, non-AP STAs within an ESS set the Privacy subfield to 0 in transmitted
2339 Association or Reassociation management frames. APs ignore the Privacy subfield within received Association and
2340 Reassociation management frames. */
2341 if ( psessionEntry->encryptType == eSIR_ED_WPI)
2342 ((tSirMacCapabilityInfo *) &caps)->privacy = 0;
2343#endif
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002344 swapBitField16(caps, ( tANI_U16* )&pFrm->Capabilities );
Jeff Johnson295189b2012-06-20 16:38:30 -07002345
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002346 pFrm->ListenInterval.interval = pMlmAssocReq->listenInterval;
2347 PopulateDot11fSSID2( pMac, &pFrm->SSID );
Jeff Johnson295189b2012-06-20 16:38:30 -07002348 PopulateDot11fSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002349 &pFrm->SuppRates,psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07002350
2351 fQosEnabled = ( psessionEntry->limQosEnabled) &&
2352 SIR_MAC_GET_QOS( psessionEntry->limCurrentBssCaps );
2353
2354 fWmeEnabled = ( psessionEntry->limWmeEnabled ) &&
2355 LIM_BSS_CAPS_GET( WME, psessionEntry->limCurrentBssQosCaps );
2356
2357 // We prefer .11e asociations:
2358 if ( fQosEnabled ) fWmeEnabled = false;
2359
2360 fWsmEnabled = ( psessionEntry->limWsmEnabled ) && fWmeEnabled &&
2361 LIM_BSS_CAPS_GET( WSM, psessionEntry->limCurrentBssQosCaps );
2362
2363 if ( psessionEntry->lim11hEnable &&
2364 psessionEntry->pLimJoinReq->spectrumMgtIndicator == eSIR_TRUE )
2365 {
2366#if defined WLAN_FEATURE_VOWIFI
2367 PowerCapsPopulated = TRUE;
2368
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002369 PopulateDot11fPowerCaps( pMac, &pFrm->PowerCaps, LIM_ASSOC,psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07002370#endif
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002371 PopulateDot11fSuppChannels( pMac, &pFrm->SuppChannels, LIM_ASSOC,psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07002372
2373 }
2374
2375#if defined WLAN_FEATURE_VOWIFI
2376 if( pMac->rrm.rrmPEContext.rrmEnable &&
2377 SIR_MAC_GET_RRM( psessionEntry->limCurrentBssCaps ) )
2378 {
2379 if (PowerCapsPopulated == FALSE)
2380 {
2381 PowerCapsPopulated = TRUE;
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002382 PopulateDot11fPowerCaps(pMac, &pFrm->PowerCaps, LIM_ASSOC, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07002383 }
2384 }
2385#endif
2386
2387 if ( fQosEnabled &&
2388 ( ! PROP_CAPABILITY_GET(11EQOS, psessionEntry->limCurrentBssPropCap)))
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002389 PopulateDot11fQOSCapsStation( pMac, &pFrm->QOSCapsStation );
Jeff Johnson295189b2012-06-20 16:38:30 -07002390
2391 PopulateDot11fExtSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002392 &pFrm->ExtSuppRates, psessionEntry );
Jeff Johnson295189b2012-06-20 16:38:30 -07002393
2394#if defined WLAN_FEATURE_VOWIFI
2395 if( pMac->rrm.rrmPEContext.rrmEnable &&
2396 SIR_MAC_GET_RRM( psessionEntry->limCurrentBssCaps ) )
2397 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002398 PopulateDot11fRRMIe( pMac, &pFrm->RRMEnabledCap, psessionEntry );
Jeff Johnson295189b2012-06-20 16:38:30 -07002399 }
2400#endif
2401 // The join request *should* contain zero or one of the WPA and RSN
2402 // IEs. The payload send along with the request is a
2403 // 'tSirSmeJoinReq'; the IE portion is held inside a 'tSirRSNie':
2404
2405 // typedef struct sSirRSNie
2406 // {
2407 // tANI_U16 length;
2408 // tANI_U8 rsnIEdata[SIR_MAC_MAX_IE_LENGTH+2];
2409 // } tSirRSNie, *tpSirRSNie;
2410
2411 // So, we should be able to make the following two calls harmlessly,
2412 // since they do nothing if they don't find the given IE in the
2413 // bytestream with which they're provided.
2414
2415 // The net effect of this will be to faithfully transmit whatever
2416 // security IE is in the join request.
2417
2418 // *However*, if we're associating for the purpose of WPS
2419 // enrollment, and we've been configured to indicate that by
2420 // eliding the WPA or RSN IE, we just skip this:
2421 if( nAddIELen && pAddIE )
2422 {
2423 wpsIe = limGetWscIEPtr (pMac, pAddIE, nAddIELen);
2424 }
2425 if ( NULL == wpsIe )
2426 {
2427 PopulateDot11fRSNOpaque( pMac, &( psessionEntry->pLimJoinReq->rsnIE ),
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002428 &pFrm->RSNOpaque );
Jeff Johnson295189b2012-06-20 16:38:30 -07002429 PopulateDot11fWPAOpaque( pMac, &( psessionEntry->pLimJoinReq->rsnIE ),
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002430 &pFrm->WPAOpaque );
Jeff Johnson295189b2012-06-20 16:38:30 -07002431#if defined(FEATURE_WLAN_WAPI)
2432 PopulateDot11fWAPIOpaque( pMac, &( psessionEntry->pLimJoinReq->rsnIE ),
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002433 &pFrm->WAPIOpaque );
Jeff Johnson295189b2012-06-20 16:38:30 -07002434#endif // defined(FEATURE_WLAN_WAPI)
2435 }
2436
2437 // include WME EDCA IE as well
2438 if ( fWmeEnabled )
2439 {
2440 if ( ! PROP_CAPABILITY_GET( WME, psessionEntry->limCurrentBssPropCap ) )
2441 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002442 PopulateDot11fWMMInfoStation( pMac, &pFrm->WMMInfoStation );
Jeff Johnson295189b2012-06-20 16:38:30 -07002443 }
2444
2445 if ( fWsmEnabled &&
2446 ( ! PROP_CAPABILITY_GET(WSM, psessionEntry->limCurrentBssPropCap )))
2447 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002448 PopulateDot11fWMMCaps( &pFrm->WMMCaps );
Jeff Johnson295189b2012-06-20 16:38:30 -07002449 }
2450 }
2451
2452 //Populate HT IEs, when operating in 11n or Taurus modes AND
2453 //when AP is also operating in 11n mode.
Jeff Johnsone7245742012-09-05 17:12:55 -07002454 if ( psessionEntry->htCapability &&
Jeff Johnson295189b2012-06-20 16:38:30 -07002455 pMac->lim.htCapabilityPresentInBeacon)
2456 {
Krishna Kumaar Natarajan025a8602015-08-04 16:31:36 +05302457 limLog(pMac, LOG1, FL("Populate HT IEs in Assoc Request"));
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002458 PopulateDot11fHTCaps( pMac, psessionEntry, &pFrm->HTCaps );
Jeff Johnson295189b2012-06-20 16:38:30 -07002459#ifdef DISABLE_GF_FOR_INTEROP
2460
2461 /*
2462 * To resolve the interop problem with Broadcom AP,
2463 * where TQ STA could not pass traffic with GF enabled,
2464 * TQ STA will do Greenfield only with TQ AP, for
2465 * everybody else it will be turned off.
2466 */
2467
2468 if( (psessionEntry->pLimJoinReq != NULL) && (!psessionEntry->pLimJoinReq->bssDescription.aniIndicator))
2469 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05302470 limLog( pMac, LOG1, FL("Sending Assoc Req to Non-TQ AP,"
2471 " Turning off Greenfield"));
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002472 pFrm->HTCaps.greenField = WNI_CFG_GREENFIELD_CAPABILITY_DISABLE;
Jeff Johnson295189b2012-06-20 16:38:30 -07002473 }
2474#endif
2475
2476 }
Agrawal Ashishb10d0392015-08-06 16:18:20 +05302477
2478 limLog(pMac, LOG1, FL("SupportedChnlWidth: %d, mimoPS: %d, GF: %d,"
2479 "shortGI20:%d, shortGI40: %d, dsssCck: %d, AMPDU Param: %x"),
2480 pFrm->HTCaps.supportedChannelWidthSet, pFrm->HTCaps.mimoPowerSave,
2481 pFrm->HTCaps.greenField, pFrm->HTCaps.shortGI20MHz, pFrm->HTCaps.shortGI40MHz,
2482 pFrm->HTCaps.dsssCckMode40MHz, pFrm->HTCaps.maxRxAMPDUFactor);
2483
2484
Jeff Johnsone7245742012-09-05 17:12:55 -07002485#ifdef WLAN_FEATURE_11AC
2486 if ( psessionEntry->vhtCapability &&
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07002487 psessionEntry->vhtCapabilityPresentInBeacon)
Jeff Johnsone7245742012-09-05 17:12:55 -07002488 {
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07002489 limLog( pMac, LOG1, FL("Populate VHT IEs in Assoc Request"));
Abhishek Singh33f76ea2015-06-04 12:27:30 +05302490 PopulateDot11fVHTCaps( pMac, &pFrm->VHTCaps,
2491 psessionEntry->currentOperChannel, eSIR_FALSE );
Abhishek Singhe038dc62015-05-22 11:36:45 +05302492
Jeff Johnsone7245742012-09-05 17:12:55 -07002493 }
2494#endif
Agrawal Ashish5ac89da2015-10-26 19:08:47 +05302495 if (psessionEntry->is_ext_caps_present)
2496 PopulateDot11fExtCap( pMac, &pFrm->ExtCap, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07002497
2498#if defined WLAN_FEATURE_VOWIFI_11R
2499 if (psessionEntry->pLimJoinReq->is11Rconnection)
2500 {
2501#if defined WLAN_FEATURE_VOWIFI_11R_DEBUG
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002502 limLog( pMac, LOG1, FL("mdie = %02x %02x %02x"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002503 (unsigned int)psessionEntry->pLimJoinReq->bssDescription.mdie[0],
2504 (unsigned int)psessionEntry->pLimJoinReq->bssDescription.mdie[1],
2505 (unsigned int)psessionEntry->pLimJoinReq->bssDescription.mdie[2]);
2506#endif
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302507 PopulateMDIE( pMac, &pFrm->MobilityDomain,
2508 psessionEntry->pLimJoinReq->bssDescription.mdie);
Jeff Johnson295189b2012-06-20 16:38:30 -07002509 }
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302510 else
Jeff Johnson295189b2012-06-20 16:38:30 -07002511 {
2512 // No 11r IEs dont send any MDIE
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302513 limLog( pMac, LOG1, FL("MDIE not present"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002514 }
2515#endif
2516
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002517#ifdef FEATURE_WLAN_ESE
2518 /* For ESE Associations fill the ESE IEs */
2519 if (psessionEntry->isESEconnection &&
2520 psessionEntry->pLimJoinReq->isESEFeatureIniEnabled)
Jeff Johnson295189b2012-06-20 16:38:30 -07002521 {
Varun Reddy Yeturu30779b42013-04-09 09:57:16 -07002522#ifndef FEATURE_DISABLE_RM
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002523 PopulateDot11fESERadMgmtCap(&pFrm->ESERadMgmtCap);
Varun Reddy Yeturu30779b42013-04-09 09:57:16 -07002524#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002525 PopulateDot11fESEVersion(&pFrm->ESEVersion);
Jeff Johnson295189b2012-06-20 16:38:30 -07002526 }
2527#endif
2528
c_hpothubcd78652014-04-28 22:31:08 +05302529 /* merge the ExtCap struct*/
2530 if (extractedExtCapFlag && extractedExtCap.present)
2531 {
2532 limMergeExtCapIEStruct(&pFrm->ExtCap, &extractedExtCap);
2533 }
2534
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002535 nStatus = dot11fGetPackedAssocRequestSize( pMac, pFrm, &nPayload );
Jeff Johnson295189b2012-06-20 16:38:30 -07002536 if ( DOT11F_FAILED( nStatus ) )
2537 {
2538 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002539 "or an Association Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002540 nStatus );
2541 // We'll fall back on the worst case scenario:
2542 nPayload = sizeof( tDot11fAssocRequest );
2543 }
2544 else if ( DOT11F_WARNED( nStatus ) )
2545 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08002546 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07002547 "the packed size for an Association Re "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002548 "quest(0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07002549 }
2550
2551 nBytes = nPayload + sizeof( tSirMacMgmtHdr ) + nAddIELen;
2552
2553 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
2554 ( tANI_U16 )nBytes, ( void** ) &pFrame,
2555 ( void** ) &pPacket );
2556 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
2557 {
2558 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for an As"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002559 "sociation Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07002560
2561 psessionEntry->limMlmState = psessionEntry->limPrevMlmState;
Jeff Johnsone7245742012-09-05 17:12:55 -07002562 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07002563
2564
2565 /* Update PE session id*/
2566 mlmAssocCnf.sessionId = psessionEntry->peSessionId;
2567
2568 mlmAssocCnf.resultCode = eSIR_SME_RESOURCES_UNAVAILABLE;
2569
2570 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
2571 ( void* ) pFrame, ( void* ) pPacket );
2572
2573 limPostSmeMessage( pMac, LIM_MLM_ASSOC_CNF,
2574 ( tANI_U32* ) &mlmAssocCnf);
2575
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302576 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -07002577 return;
2578 }
2579
2580 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302581 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07002582
2583 // Next, we fill out the buffer descriptor:
2584 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
2585 SIR_MAC_MGMT_ASSOC_REQ, psessionEntry->bssId,psessionEntry->selfMacAddr);
2586 if ( eSIR_SUCCESS != nSirStatus )
2587 {
2588 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002589 "tor for an Association Request (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002590 nSirStatus );
2591 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302592 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -07002593 return;
2594 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002595
Abhishek Singh57aebef2014-02-03 18:47:44 +05302596 // That done, pack the Assoc Request:
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002597 nStatus = dot11fPackAssocRequest( pMac, pFrm, pFrame +
Jeff Johnson295189b2012-06-20 16:38:30 -07002598 sizeof(tSirMacMgmtHdr),
2599 nPayload, &nPayload );
2600 if ( DOT11F_FAILED( nStatus ) )
2601 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05302602 limLog( pMac, LOGE, FL("Failed to pack a Assoc Request (0x%0"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002603 "8x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002604 nStatus );
2605 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
2606 ( void* ) pFrame, ( void* ) pPacket );
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302607 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -07002608 return;
2609 }
2610 else if ( DOT11F_WARNED( nStatus ) )
2611 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05302612 limLog( pMac, LOGW, FL("There were warnings while packing a Assoc"
2613 "Request (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07002614 }
2615
2616 PELOG1(limLog( pMac, LOG1, FL("*** Sending Association Request length %d"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002617 "to "),
Jeff Johnson295189b2012-06-20 16:38:30 -07002618 nBytes );)
2619 // limPrintMacAddr( pMac, bssid, LOG1 );
2620
2621 if( psessionEntry->assocReq != NULL )
2622 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302623 vos_mem_free(psessionEntry->assocReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07002624 psessionEntry->assocReq = NULL;
2625 }
2626
2627 if( nAddIELen )
2628 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302629 vos_mem_copy( pFrame + sizeof(tSirMacMgmtHdr) + nPayload,
2630 pAddIE,
2631 nAddIELen );
Jeff Johnson295189b2012-06-20 16:38:30 -07002632 nPayload += nAddIELen;
2633 }
2634
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302635 psessionEntry->assocReq = vos_mem_malloc(nPayload);
2636 if ( NULL == psessionEntry->assocReq )
Jeff Johnson295189b2012-06-20 16:38:30 -07002637 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05302638 PELOGE(limLog(pMac, LOGE, FL("Unable to allocate memory to store "
2639 "assoc request"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07002640 }
2641 else
2642 {
2643 //Store the Assoc request. This is sent to csr/hdd in join cnf response.
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302644 vos_mem_copy( psessionEntry->assocReq, pFrame + sizeof(tSirMacMgmtHdr), nPayload);
Jeff Johnson295189b2012-06-20 16:38:30 -07002645 psessionEntry->assocReqLen = nPayload;
2646 }
2647
2648 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07002649 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
2650 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07002651 )
2652 {
2653 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
2654 }
2655
Sushant Kaushike8681d22015-04-21 12:08:25 +05302656 if(psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ||
2657 psessionEntry->pePersona == VOS_STA_MODE)
Ganesh K08bce952012-12-13 15:04:41 -08002658 {
2659 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
2660 }
Deepthi Gowri639d5042015-11-16 20:23:39 +05302661#ifdef FEATURE_WLAN_DIAG_SUPPORT
2662 limDiagEventReport(pMac, WLAN_PE_DIAG_ASSOC_START_EVENT, psessionEntry,
2663 eSIR_SUCCESS, eSIR_SUCCESS);
2664#endif
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05302665 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
Agarwal Ashisha8e81f52014-04-02 01:59:52 +05302666 limLog( pMac, LOG1, FL("Sending Assoc req over WQ5 to "MAC_ADDRESS_STR
2667 " From " MAC_ADDRESS_STR),MAC_ADDR_ARRAY(pMacHdr->da),
2668 MAC_ADDR_ARRAY(psessionEntry->selfMacAddr));
2669 txFlag |= HAL_USE_FW_IN_TX_PATH;
2670
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05302671 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
2672 psessionEntry->peSessionId,
2673 pMacHdr->fc.subType));
Katya Nigam63902932014-06-26 19:04:23 +05302674
Masti, Narayanraddi67ea5912015-01-08 12:34:05 +05302675 if( ( psessionEntry->is11Gonly == true ) &&
2676 ( !IS_BROADCAST_MAC(pMlmAssocReq->peerMacAddr) ) ){
2677 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
2678 }
Ganesh Kondabattiniffc00b12015-03-18 13:11:33 +05302679 if (IS_FEATURE_SUPPORTED_BY_FW(ENHANCED_TXBD_COMPLETION))
2680 {
2681 limLog(pMac, LOG1, FL("Assoc Req - txBdToken %u"), pMac->lim.txBdToken);
2682 halstatus = halTxFrameWithTxComplete( pMac, pPacket,
2683 ( tANI_U16 ) (sizeof(tSirMacMgmtHdr) + nPayload),
2684 HAL_TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS,
2685 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
2686 limTxComplete, pFrame, limTxBdComplete, txFlag,
2687 pMac->lim.txBdToken);
2688 pMac->lim.txBdToken++;
2689 }
2690 else
2691 {
2692 halstatus = halTxFrame( pMac, pPacket,
2693 ( tANI_U16 ) (sizeof(tSirMacMgmtHdr) + nPayload),
2694 HAL_TXRX_FRM_802_11_MGMT,
2695 ANI_TXDIR_TODS,
2696 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
2697 limTxComplete, pFrame, txFlag );
2698 }
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05302699 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
2700 psessionEntry->peSessionId,
2701 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07002702 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
2703 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002704 limLog( pMac, LOGE, FL("Failed to send Association Request (%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002705 halstatus );
2706 //Pkt will be freed up by the callback
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302707 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -07002708 return;
2709 }
2710
Katya Nigamccaeda72015-04-20 18:51:22 +05302711 //Enable caching only if Assoc Request is successfully submitted to the h/w
2712 WLANTL_EnableCaching(psessionEntry->staId);
2713
Jeff Johnson295189b2012-06-20 16:38:30 -07002714 // Free up buffer allocated for mlmAssocReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302715 vos_mem_free(pMlmAssocReq);
Leela Venkata Kiran Kumar Reddy Chiralad6c0fe22013-12-11 19:10:50 -08002716 pMlmAssocReq = NULL;
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302717 vos_mem_free(pFrm);
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002718 return;
Jeff Johnson295189b2012-06-20 16:38:30 -07002719} // End limSendAssocReqMgmtFrame
2720
2721
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002722#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07002723/*------------------------------------------------------------------------------------
2724 *
2725 * Send Reassoc Req with FTIEs.
2726 *
2727 *-----------------------------------------------------------------------------------
2728 */
2729void
2730limSendReassocReqWithFTIEsMgmtFrame(tpAniSirGlobal pMac,
2731 tLimMlmReassocReq *pMlmReassocReq,tpPESession psessionEntry)
2732{
2733 static tDot11fReAssocRequest frm;
2734 tANI_U16 caps;
2735 tANI_U8 *pFrame;
2736 tSirRetStatus nSirStatus;
2737 tANI_U32 nBytes, nPayload, nStatus;
2738 tANI_U8 fQosEnabled, fWmeEnabled, fWsmEnabled;
2739 void *pPacket;
2740 eHalStatus halstatus;
2741#if defined WLAN_FEATURE_VOWIFI
2742 tANI_U8 PowerCapsPopulated = FALSE;
2743#endif
2744 tANI_U16 ft_ies_length = 0;
2745 tANI_U8 *pBody;
2746 tANI_U16 nAddIELen;
2747 tANI_U8 *pAddIE;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002748#if defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07002749 tANI_U8 *wpsIe = NULL;
2750#endif
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05302751 tANI_U32 txFlag = 0;
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05302752 tpSirMacMgmtHdr pMacHdr;
Jeff Johnson295189b2012-06-20 16:38:30 -07002753
2754 if (NULL == psessionEntry)
2755 {
2756 return;
2757 }
2758
Jeff Johnson295189b2012-06-20 16:38:30 -07002759 /* check this early to avoid unncessary operation */
2760 if(NULL == psessionEntry->pLimReAssocReq)
2761 {
2762 return;
2763 }
2764 nAddIELen = psessionEntry->pLimReAssocReq->addIEAssoc.length;
2765 pAddIE = psessionEntry->pLimReAssocReq->addIEAssoc.addIEdata;
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08002766 limLog( pMac, LOG1, FL("limSendReassocReqWithFTIEsMgmtFrame received in "
2767 "state (%d)."), psessionEntry->limMlmState);
Jeff Johnson295189b2012-06-20 16:38:30 -07002768
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302769 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07002770
2771 caps = pMlmReassocReq->capabilityInfo;
2772 if (PROP_CAPABILITY_GET(11EQOS, psessionEntry->limReassocBssPropCap))
2773 ((tSirMacCapabilityInfo *) &caps)->qos = 0;
2774#if defined(FEATURE_WLAN_WAPI)
2775 /* CR: 262463 :
2776 According to WAPI standard:
2777 7.3.1.4 Capability Information field
2778 In WAPI, non-AP STAs within an ESS set the Privacy subfield to 0 in transmitted
2779 Association or Reassociation management frames. APs ignore the Privacy subfield within received Association and
2780 Reassociation management frames. */
2781 if ( psessionEntry->encryptType == eSIR_ED_WPI)
2782 ((tSirMacCapabilityInfo *) &caps)->privacy = 0;
2783#endif
2784 swapBitField16(caps, ( tANI_U16* )&frm.Capabilities );
2785
2786 frm.ListenInterval.interval = pMlmReassocReq->listenInterval;
2787
2788 // Get the old bssid of the older AP.
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302789 vos_mem_copy( ( tANI_U8* )frm.CurrentAPAddress.mac,
Jeff Johnson295189b2012-06-20 16:38:30 -07002790 pMac->ft.ftPEContext.pFTPreAuthReq->currbssId, 6);
2791
2792 PopulateDot11fSSID2( pMac, &frm.SSID );
2793 PopulateDot11fSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
2794 &frm.SuppRates,psessionEntry);
2795
2796 fQosEnabled = ( psessionEntry->limQosEnabled) &&
2797 SIR_MAC_GET_QOS( psessionEntry->limReassocBssCaps );
2798
2799 fWmeEnabled = ( psessionEntry->limWmeEnabled ) &&
2800 LIM_BSS_CAPS_GET( WME, psessionEntry->limReassocBssQosCaps );
2801
2802 fWsmEnabled = ( psessionEntry->limWsmEnabled ) && fWmeEnabled &&
2803 LIM_BSS_CAPS_GET( WSM, psessionEntry->limReassocBssQosCaps );
2804
2805 if ( psessionEntry->lim11hEnable &&
2806 psessionEntry->pLimReAssocReq->spectrumMgtIndicator == eSIR_TRUE )
2807 {
2808#if defined WLAN_FEATURE_VOWIFI
2809 PowerCapsPopulated = TRUE;
2810
2811 PopulateDot11fPowerCaps( pMac, &frm.PowerCaps, LIM_REASSOC,psessionEntry);
2812 PopulateDot11fSuppChannels( pMac, &frm.SuppChannels, LIM_REASSOC,psessionEntry);
2813#endif
2814 }
2815
2816#if defined WLAN_FEATURE_VOWIFI
2817 if( pMac->rrm.rrmPEContext.rrmEnable &&
2818 SIR_MAC_GET_RRM( psessionEntry->limCurrentBssCaps ) )
2819 {
2820 if (PowerCapsPopulated == FALSE)
2821 {
2822 PowerCapsPopulated = TRUE;
2823 PopulateDot11fPowerCaps(pMac, &frm.PowerCaps, LIM_REASSOC, psessionEntry);
2824 }
2825 }
2826#endif
2827
2828 if ( fQosEnabled &&
2829 ( ! PROP_CAPABILITY_GET(11EQOS, psessionEntry->limReassocBssPropCap ) ))
2830 {
2831 PopulateDot11fQOSCapsStation( pMac, &frm.QOSCapsStation );
2832 }
2833
2834 PopulateDot11fExtSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
2835 &frm.ExtSuppRates, psessionEntry );
2836
2837#if defined WLAN_FEATURE_VOWIFI
2838 if( pMac->rrm.rrmPEContext.rrmEnable &&
2839 SIR_MAC_GET_RRM( psessionEntry->limReassocBssCaps ) )
2840 {
2841 PopulateDot11fRRMIe( pMac, &frm.RRMEnabledCap, psessionEntry );
2842 }
2843#endif
2844
2845 // Ideally this should be enabled for 11r also. But 11r does
2846 // not follow the usual norm of using the Opaque object
2847 // for rsnie and fties. Instead we just add
2848 // the rsnie and fties at the end of the pack routine for 11r.
2849 // This should ideally! be fixed.
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002850#if defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07002851 //
2852 // The join request *should* contain zero or one of the WPA and RSN
2853 // IEs. The payload send along with the request is a
2854 // 'tSirSmeJoinReq'; the IE portion is held inside a 'tSirRSNie':
2855
2856 // typedef struct sSirRSNie
2857 // {
2858 // tANI_U16 length;
2859 // tANI_U8 rsnIEdata[SIR_MAC_MAX_IE_LENGTH+2];
2860 // } tSirRSNie, *tpSirRSNie;
2861
2862 // So, we should be able to make the following two calls harmlessly,
2863 // since they do nothing if they don't find the given IE in the
2864 // bytestream with which they're provided.
2865
2866 // The net effect of this will be to faithfully transmit whatever
2867 // security IE is in the join request.
2868
2869 // *However*, if we're associating for the purpose of WPS
2870 // enrollment, and we've been configured to indicate that by
2871 // eliding the WPA or RSN IE, we just skip this:
2872 if (!psessionEntry->is11Rconnection)
2873 {
2874 if( nAddIELen && pAddIE )
2875 {
2876 wpsIe = limGetWscIEPtr(pMac, pAddIE, nAddIELen);
2877 }
2878 if ( NULL == wpsIe )
2879 {
2880 PopulateDot11fRSNOpaque( pMac, &( psessionEntry->pLimReAssocReq->rsnIE ),
2881 &frm.RSNOpaque );
2882 PopulateDot11fWPAOpaque( pMac, &( psessionEntry->pLimReAssocReq->rsnIE ),
2883 &frm.WPAOpaque );
2884 }
2885
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002886#ifdef FEATURE_WLAN_ESE
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302887 if (psessionEntry->pLimReAssocReq->cckmIE.length)
Jeff Johnson295189b2012-06-20 16:38:30 -07002888 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002889 PopulateDot11fESECckmOpaque( pMac, &( psessionEntry->pLimReAssocReq->cckmIE ),
2890 &frm.ESECckmOpaque );
Jeff Johnson295189b2012-06-20 16:38:30 -07002891 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002892#endif //FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07002893 }
2894
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002895#ifdef FEATURE_WLAN_ESE
2896 // For ESE Associations fill the ESE IEs
2897 if (psessionEntry->isESEconnection &&
2898 psessionEntry->pLimReAssocReq->isESEFeatureIniEnabled)
Jeff Johnson295189b2012-06-20 16:38:30 -07002899 {
Varun Reddy Yeturu30779b42013-04-09 09:57:16 -07002900#ifndef FEATURE_DISABLE_RM
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002901 PopulateDot11fESERadMgmtCap(&frm.ESERadMgmtCap);
Varun Reddy Yeturu30779b42013-04-09 09:57:16 -07002902#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002903 PopulateDot11fESEVersion(&frm.ESEVersion);
Jeff Johnson295189b2012-06-20 16:38:30 -07002904 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002905#endif //FEATURE_WLAN_ESE
2906#endif //FEATURE_WLAN_ESE || FEATURE_WLAN_LFR
Jeff Johnson295189b2012-06-20 16:38:30 -07002907
2908 // include WME EDCA IE as well
2909 if ( fWmeEnabled )
2910 {
2911 if ( ! PROP_CAPABILITY_GET( WME, psessionEntry->limReassocBssPropCap ) )
2912 {
2913 PopulateDot11fWMMInfoStation( pMac, &frm.WMMInfoStation );
2914 }
2915
2916 if ( fWsmEnabled &&
2917 ( ! PROP_CAPABILITY_GET(WSM, psessionEntry->limReassocBssPropCap )))
2918 {
2919 PopulateDot11fWMMCaps( &frm.WMMCaps );
2920 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002921#ifdef FEATURE_WLAN_ESE
2922 if (psessionEntry->isESEconnection)
Jeff Johnson295189b2012-06-20 16:38:30 -07002923 {
2924 PopulateDot11fReAssocTspec(pMac, &frm, psessionEntry);
2925
2926 // Populate the TSRS IE if TSPEC is included in the reassoc request
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002927 if (psessionEntry->pLimReAssocReq->eseTspecInfo.numTspecs)
Jeff Johnson295189b2012-06-20 16:38:30 -07002928 {
2929 tANI_U32 phyMode;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002930 tSirMacESETSRSIE tsrsIE;
Jeff Johnson295189b2012-06-20 16:38:30 -07002931 limGetPhyMode(pMac, &phyMode, psessionEntry);
2932
2933 tsrsIE.tsid = 0;
2934 if( phyMode == WNI_CFG_PHY_MODE_11G || phyMode == WNI_CFG_PHY_MODE_11A)
2935 {
2936 tsrsIE.rates[0] = TSRS_11AG_RATE_6MBPS;
2937 }
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302938 else
Jeff Johnson295189b2012-06-20 16:38:30 -07002939 {
2940 tsrsIE.rates[0] = TSRS_11B_RATE_5_5MBPS;
2941 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002942 PopulateDot11TSRSIE(pMac,&tsrsIE, &frm.ESETrafStrmRateSet, sizeof(tANI_U8));
Jeff Johnson295189b2012-06-20 16:38:30 -07002943 }
2944 }
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302945#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002946 }
2947
Jeff Johnsone7245742012-09-05 17:12:55 -07002948 if ( psessionEntry->htCapability &&
Jeff Johnson295189b2012-06-20 16:38:30 -07002949 pMac->lim.htCapabilityPresentInBeacon)
2950 {
Jeff Johnsone7245742012-09-05 17:12:55 -07002951 PopulateDot11fHTCaps( pMac, psessionEntry, &frm.HTCaps );
Jeff Johnson295189b2012-06-20 16:38:30 -07002952 }
Agrawal Ashishb10d0392015-08-06 16:18:20 +05302953 limLog(pMac, LOG1, FL("SupportedChnlWidth: %d, mimoPS: %d, GF: %d,"
2954 "shortGI20:%d, shortGI40: %d, dsssCck: %d, AMPDU Param: %x"),
2955 frm.HTCaps.supportedChannelWidthSet, frm.HTCaps.mimoPowerSave,
2956 frm.HTCaps.greenField, frm.HTCaps.shortGI20MHz, frm.HTCaps.shortGI40MHz,
2957 frm.HTCaps.dsssCckMode40MHz, frm.HTCaps.maxRxAMPDUFactor);
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08002958#if defined WLAN_FEATURE_VOWIFI_11R
Kanchanapally, Vidyullatha4f84f682014-04-29 20:40:34 +05302959 if ( psessionEntry->pLimReAssocReq->bssDescription.mdiePresent &&
2960 (pMac->ft.ftSmeContext.addMDIE == TRUE)
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002961#if defined FEATURE_WLAN_ESE
2962 && !psessionEntry->isESEconnection
Gopichand Nakkala0ac55062013-04-08 14:43:07 +05302963#endif
2964 )
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08002965 {
2966 PopulateMDIE( pMac, &frm.MobilityDomain, psessionEntry->pLimReAssocReq->bssDescription.mdie);
2967 }
2968#endif
2969
Chet Lanctotf19c1f62013-12-13 13:56:21 -08002970#ifdef WLAN_FEATURE_11AC
2971 if ( psessionEntry->vhtCapability &&
2972 psessionEntry->vhtCapabilityPresentInBeacon)
2973 {
2974 limLog( pMac, LOG1, FL("Populate VHT IEs in Re-Assoc Request"));
Abhishek Singh33f76ea2015-06-04 12:27:30 +05302975 PopulateDot11fVHTCaps( pMac, &frm.VHTCaps,
2976 psessionEntry->currentOperChannel, eSIR_FALSE );
Abhishek Singhe038dc62015-05-22 11:36:45 +05302977
Chet Lanctotf19c1f62013-12-13 13:56:21 -08002978 }
2979#endif
Agrawal Ashish5ac89da2015-10-26 19:08:47 +05302980 if (psessionEntry->is_ext_caps_present)
2981 PopulateDot11fExtCap( pMac, &frm.ExtCap, psessionEntry);
Chet Lanctotf19c1f62013-12-13 13:56:21 -08002982
Jeff Johnson295189b2012-06-20 16:38:30 -07002983 nStatus = dot11fGetPackedReAssocRequestSize( pMac, &frm, &nPayload );
2984 if ( DOT11F_FAILED( nStatus ) )
2985 {
2986 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002987 "or a Re-Association Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002988 nStatus );
2989 // We'll fall back on the worst case scenario:
2990 nPayload = sizeof( tDot11fReAssocRequest );
2991 }
2992 else if ( DOT11F_WARNED( nStatus ) )
2993 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08002994 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07002995 "the packed size for a Re-Association Re "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002996 "quest(0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07002997 }
2998
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07002999 nBytes = nPayload + sizeof( tSirMacMgmtHdr ) + nAddIELen;
Jeff Johnson295189b2012-06-20 16:38:30 -07003000
3001#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08003002 limLog( pMac, LOG1, FL("FT IE Reassoc Req (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003003 pMac->ft.ftSmeContext.reassoc_ft_ies_length);
3004#endif
3005
3006#if defined WLAN_FEATURE_VOWIFI_11R
3007 if (psessionEntry->is11Rconnection)
3008 {
3009 ft_ies_length = pMac->ft.ftSmeContext.reassoc_ft_ies_length;
3010 }
3011#endif
3012
3013 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
3014 ( tANI_U16 )nBytes+ft_ies_length, ( void** ) &pFrame,
3015 ( void** ) &pPacket );
3016 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3017 {
3018 psessionEntry->limMlmState = psessionEntry->limPrevMlmState;
Jeff Johnsone7245742012-09-05 17:12:55 -07003019 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07003020 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Re-As"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003021 "sociation Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07003022 goto end;
3023 }
3024
3025 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303026 vos_mem_set( pFrame, nBytes + ft_ies_length, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07003027
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003028#if defined WLAN_FEATURE_VOWIFI_11R_DEBUG || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08003029 limPrintMacAddr(pMac, psessionEntry->limReAssocbssId, LOG1);
Jeff Johnson295189b2012-06-20 16:38:30 -07003030#endif
3031 // Next, we fill out the buffer descriptor:
3032 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
3033 SIR_MAC_MGMT_REASSOC_REQ,
3034 psessionEntry->limReAssocbssId,psessionEntry->selfMacAddr);
3035 if ( eSIR_SUCCESS != nSirStatus )
3036 {
3037 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003038 "tor for an Association Request (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003039 nSirStatus );
3040 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
3041 goto end;
3042 }
3043
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05303044 pMacHdr = (tpSirMacMgmtHdr) pFrame;
Jeff Johnson295189b2012-06-20 16:38:30 -07003045 // That done, pack the ReAssoc Request:
3046 nStatus = dot11fPackReAssocRequest( pMac, &frm, pFrame +
3047 sizeof(tSirMacMgmtHdr),
3048 nPayload, &nPayload );
3049 if ( DOT11F_FAILED( nStatus ) )
3050 {
3051 limLog( pMac, LOGE, FL("Failed to pack a Re-Association Reque"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003052 "st (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003053 nStatus );
3054 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
3055 goto end;
3056 }
3057 else if ( DOT11F_WARNED( nStatus ) )
3058 {
3059 limLog( pMac, LOGW, FL("There were warnings while packing a R"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08003060 "e-Association Request (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07003061 }
3062
3063 PELOG3(limLog( pMac, LOG3,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003064 FL("*** Sending Re-Association Request length %d %d to "),
Jeff Johnson295189b2012-06-20 16:38:30 -07003065 nBytes, nPayload );)
3066 if( psessionEntry->assocReq != NULL )
3067 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303068 vos_mem_free(psessionEntry->assocReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07003069 psessionEntry->assocReq = NULL;
3070 }
3071
3072 if( nAddIELen )
3073 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303074 vos_mem_copy( pFrame + sizeof(tSirMacMgmtHdr) + nPayload,
3075 pAddIE,
3076 nAddIELen );
Jeff Johnson295189b2012-06-20 16:38:30 -07003077 nPayload += nAddIELen;
3078 }
3079
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303080 psessionEntry->assocReq = vos_mem_malloc(nPayload);
3081 if ( NULL == psessionEntry->assocReq )
Jeff Johnson295189b2012-06-20 16:38:30 -07003082 {
3083 PELOGE(limLog(pMac, LOGE, FL("Unable to allocate memory to store assoc request"));)
Jeff Johnson43971f52012-07-17 12:26:56 -07003084 }
3085 else
3086 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003087 //Store the Assoc request. This is sent to csr/hdd in join cnf response.
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303088 vos_mem_copy( psessionEntry->assocReq, pFrame + sizeof(tSirMacMgmtHdr), nPayload);
Jeff Johnson295189b2012-06-20 16:38:30 -07003089 psessionEntry->assocReqLen = nPayload;
Jeff Johnson43971f52012-07-17 12:26:56 -07003090 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003091
3092 if (psessionEntry->is11Rconnection)
3093 {
3094 {
3095 int i = 0;
3096
3097 pBody = pFrame + nBytes;
3098 for (i=0; i<ft_ies_length; i++)
3099 {
3100 *pBody = pMac->ft.ftSmeContext.reassoc_ft_ies[i];
3101 pBody++;
3102 }
3103 }
3104 }
3105
3106#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08003107 PELOGE(limLog(pMac, LOG1, FL("Re-assoc Req Frame is: "));
3108 sirDumpBuf(pMac, SIR_LIM_MODULE_ID, LOG1,
Jeff Johnson295189b2012-06-20 16:38:30 -07003109 (tANI_U8 *)pFrame,
3110 (nBytes + ft_ies_length));)
3111#endif
3112
3113
3114 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07003115 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
3116 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07003117 )
3118 {
3119 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
3120 }
3121
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07003122 if( NULL != psessionEntry->assocReq )
3123 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303124 vos_mem_free(psessionEntry->assocReq);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07003125 psessionEntry->assocReq = NULL;
3126 }
3127
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303128 psessionEntry->assocReq = vos_mem_malloc(ft_ies_length);
3129 if ( NULL == psessionEntry->assocReq )
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07003130 {
3131 PELOGE(limLog(pMac, LOGE, FL("Unable to allocate memory to store assoc request"));)
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08003132 psessionEntry->assocReqLen = 0;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07003133 }
3134 else
3135 {
3136 //Store the Assoc request. This is sent to csr/hdd in join cnf response.
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303137 vos_mem_copy( psessionEntry->assocReq, pMac->ft.ftSmeContext.reassoc_ft_ies,
3138 (ft_ies_length));
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07003139 psessionEntry->assocReqLen = (ft_ies_length);
3140 }
Deepthi Gowri639d5042015-11-16 20:23:39 +05303141#ifdef FEATURE_WLAN_DIAG_SUPPORT
3142 limDiagEventReport(pMac, WLAN_PE_DIAG_REASSOC_START_EVENT, psessionEntry,
3143 eSIR_SUCCESS, eSIR_SUCCESS);
3144#endif
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05303145 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
3146 psessionEntry->peSessionId,
3147 pMacHdr->fc.subType));
Ganesh Kondabattiniffc00b12015-03-18 13:11:33 +05303148 if (IS_FEATURE_SUPPORTED_BY_FW(ENHANCED_TXBD_COMPLETION))
3149 {
3150 limLog( pMac, LOG1, FL("Reassoc req - txBdToken %u"), pMac->lim.txBdToken);
3151 halstatus = halTxFrameWithTxComplete( pMac, pPacket,
3152 ( tANI_U16 ) (nBytes + ft_ies_length),
3153 HAL_TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS,
3154 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
3155 limTxComplete, pFrame, limTxBdComplete, txFlag,
3156 pMac->lim.txBdToken);
3157 pMac->lim.txBdToken++;
3158 }
3159 else
3160 {
3161 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) (nBytes + ft_ies_length),
3162 HAL_TXRX_FRM_802_11_MGMT,
3163 ANI_TXDIR_TODS,
3164 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
3165 limTxComplete, pFrame, txFlag );
3166 }
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05303167 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
3168 psessionEntry->peSessionId,
3169 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07003170 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3171 {
3172 limLog( pMac, LOGE, FL("Failed to send Re-Association Request"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003173 "(%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07003174 nSirStatus );
3175 //Pkt will be freed up by the callback
3176 goto end;
3177 }
3178
Katya Nigamccaeda72015-04-20 18:51:22 +05303179 // Enable TL cahching in case of roaming
3180 WLANTL_EnableCaching(psessionEntry->staId);
3181
Jeff Johnson295189b2012-06-20 16:38:30 -07003182end:
3183 // Free up buffer allocated for mlmAssocReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303184 vos_mem_free( pMlmReassocReq );
Jeff Johnson295189b2012-06-20 16:38:30 -07003185 psessionEntry->pLimMlmReassocReq = NULL;
3186
3187}
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -07003188
3189void limSendRetryReassocReqFrame(tpAniSirGlobal pMac,
3190 tLimMlmReassocReq *pMlmReassocReq,
3191 tpPESession psessionEntry)
3192{
3193 tLimMlmReassocCnf mlmReassocCnf; // keep sme
3194 tLimMlmReassocReq *pTmpMlmReassocReq = NULL;
Sachin Ahuja07a43012015-01-30 17:04:38 +05303195#ifdef FEATURE_WLAN_ESE
3196 tANI_U32 val=0;
3197#endif
3198 if (pMlmReassocReq == NULL)
3199 {
3200 limLog(pMac, LOGE,
3201 FL("Invalid pMlmReassocReq"));
3202 goto end;
3203 }
Hema Aparna Medicharla43d0f7b2015-02-12 17:07:59 +05303204
3205 pTmpMlmReassocReq = vos_mem_malloc(sizeof(tLimMlmReassocReq));
3206 if ( NULL == pTmpMlmReassocReq ) goto end;
3207 vos_mem_set( pTmpMlmReassocReq, sizeof(tLimMlmReassocReq), 0);
3208 vos_mem_copy( pTmpMlmReassocReq, pMlmReassocReq, sizeof(tLimMlmReassocReq));
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -07003209
3210 // Prepare and send Reassociation request frame
3211 // start reassoc timer.
Sachin Ahuja07a43012015-01-30 17:04:38 +05303212#ifdef FEATURE_WLAN_ESE
3213 /*
3214 * In case of Ese Reassociation, change the reassoc timer
3215 * value.
3216 */
3217 val = pMlmReassocReq->reassocFailureTimeout;
3218 if (psessionEntry->isESEconnection)
3219 {
3220 val = val/LIM_MAX_REASSOC_RETRY_LIMIT;
3221 }
3222 if (tx_timer_deactivate(&pMac->lim.limTimers.gLimReassocFailureTimer) !=
3223 TX_SUCCESS)
3224 {
3225 limLog(pMac, LOGP,
3226 FL("unable to deactivate Reassoc failure timer"));
3227 }
3228 val = SYS_MS_TO_TICKS(val);
3229 if (tx_timer_change(&pMac->lim.limTimers.gLimReassocFailureTimer,
3230 val, 0) != TX_SUCCESS)
3231 {
3232 limLog(pMac, LOGP,
3233 FL("unable to change Reassociation failure timer"));
3234 }
3235#endif
3236
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -07003237 pMac->lim.limTimers.gLimReassocFailureTimer.sessionId = psessionEntry->peSessionId;
3238 // Start reassociation failure timer
Leela V Kiran Kumar Reddy Chiralac3b9d382013-01-31 20:49:53 -08003239 MTRACE(macTrace(pMac, TRACE_CODE_TIMER_ACTIVATE, psessionEntry->peSessionId, eLIM_REASSOC_FAIL_TIMER));
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -07003240 if (tx_timer_activate(&pMac->lim.limTimers.gLimReassocFailureTimer)
3241 != TX_SUCCESS)
3242 {
3243 // Could not start reassoc failure timer.
3244 // Log error
3245 limLog(pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003246 FL("could not start Reassociation failure timer"));
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -07003247 // Return Reassoc confirm with
3248 // Resources Unavailable
3249 mlmReassocCnf.resultCode = eSIR_SME_RESOURCES_UNAVAILABLE;
3250 mlmReassocCnf.protStatusCode = eSIR_MAC_UNSPEC_FAILURE_STATUS;
3251 goto end;
3252 }
3253
3254 limSendReassocReqWithFTIEsMgmtFrame(pMac, pTmpMlmReassocReq, psessionEntry);
3255 return;
3256
3257end:
3258 // Free up buffer allocated for reassocReq
3259 if (pMlmReassocReq != NULL)
3260 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303261 vos_mem_free(pMlmReassocReq);
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -07003262 pMlmReassocReq = NULL;
3263 }
3264 if (pTmpMlmReassocReq != NULL)
3265 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303266 vos_mem_free(pTmpMlmReassocReq);
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -07003267 pTmpMlmReassocReq = NULL;
3268 }
3269 mlmReassocCnf.resultCode = eSIR_SME_FT_REASSOC_FAILURE;
3270 mlmReassocCnf.protStatusCode = eSIR_MAC_UNSPEC_FAILURE_STATUS;
3271 /* Update PE sessio Id*/
3272 mlmReassocCnf.sessionId = psessionEntry->peSessionId;
3273
3274 limPostSmeMessage(pMac, LIM_MLM_REASSOC_CNF, (tANI_U32 *) &mlmReassocCnf);
3275}
3276
Jeff Johnson295189b2012-06-20 16:38:30 -07003277#endif /* WLAN_FEATURE_VOWIFI_11R */
3278
3279
3280void
3281limSendReassocReqMgmtFrame(tpAniSirGlobal pMac,
3282 tLimMlmReassocReq *pMlmReassocReq,tpPESession psessionEntry)
3283{
3284 static tDot11fReAssocRequest frm;
3285 tANI_U16 caps;
3286 tANI_U8 *pFrame;
3287 tSirRetStatus nSirStatus;
3288 tANI_U32 nBytes, nPayload, nStatus;
3289 tANI_U8 fQosEnabled, fWmeEnabled, fWsmEnabled;
3290 void *pPacket;
3291 eHalStatus halstatus;
3292 tANI_U16 nAddIELen;
3293 tANI_U8 *pAddIE;
3294 tANI_U8 *wpsIe = NULL;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05303295 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003296#if defined WLAN_FEATURE_VOWIFI
3297 tANI_U8 PowerCapsPopulated = FALSE;
3298#endif
Ganesh Kondabattiniffc00b12015-03-18 13:11:33 +05303299 tpSirMacMgmtHdr pMacHdr;
Jeff Johnson295189b2012-06-20 16:38:30 -07003300
3301 if(NULL == psessionEntry)
3302 {
3303 return;
3304 }
3305
3306 /* check this early to avoid unncessary operation */
3307 if(NULL == psessionEntry->pLimReAssocReq)
3308 {
3309 return;
3310 }
3311 nAddIELen = psessionEntry->pLimReAssocReq->addIEAssoc.length;
3312 pAddIE = psessionEntry->pLimReAssocReq->addIEAssoc.addIEdata;
3313
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303314 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07003315
3316 caps = pMlmReassocReq->capabilityInfo;
3317 if (PROP_CAPABILITY_GET(11EQOS, psessionEntry->limReassocBssPropCap))
3318 ((tSirMacCapabilityInfo *) &caps)->qos = 0;
3319#if defined(FEATURE_WLAN_WAPI)
3320 /* CR: 262463 :
3321 According to WAPI standard:
3322 7.3.1.4 Capability Information field
3323 In WAPI, non-AP STAs within an ESS set the Privacy subfield to 0 in transmitted
3324 Association or Reassociation management frames. APs ignore the Privacy subfield within received Association and
3325 Reassociation management frames. */
3326 if ( psessionEntry->encryptType == eSIR_ED_WPI)
3327 ((tSirMacCapabilityInfo *) &caps)->privacy = 0;
3328#endif
3329 swapBitField16(caps, ( tANI_U16* )&frm.Capabilities );
3330
3331 frm.ListenInterval.interval = pMlmReassocReq->listenInterval;
3332
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303333 vos_mem_copy(( tANI_U8* )frm.CurrentAPAddress.mac,
3334 ( tANI_U8* )psessionEntry->bssId, 6 );
Jeff Johnson295189b2012-06-20 16:38:30 -07003335
3336 PopulateDot11fSSID2( pMac, &frm.SSID );
3337 PopulateDot11fSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
3338 &frm.SuppRates,psessionEntry);
3339
3340 fQosEnabled = ( psessionEntry->limQosEnabled ) &&
3341 SIR_MAC_GET_QOS( psessionEntry->limReassocBssCaps );
3342
3343 fWmeEnabled = ( psessionEntry->limWmeEnabled ) &&
3344 LIM_BSS_CAPS_GET( WME, psessionEntry->limReassocBssQosCaps );
3345
3346 fWsmEnabled = ( psessionEntry->limWsmEnabled ) && fWmeEnabled &&
3347 LIM_BSS_CAPS_GET( WSM, psessionEntry->limReassocBssQosCaps );
3348
3349
3350 if ( psessionEntry->lim11hEnable &&
3351 psessionEntry->pLimReAssocReq->spectrumMgtIndicator == eSIR_TRUE )
3352 {
3353#if defined WLAN_FEATURE_VOWIFI
3354 PowerCapsPopulated = TRUE;
3355 PopulateDot11fPowerCaps( pMac, &frm.PowerCaps, LIM_REASSOC,psessionEntry);
3356 PopulateDot11fSuppChannels( pMac, &frm.SuppChannels, LIM_REASSOC,psessionEntry);
3357#endif
3358 }
3359
3360#if defined WLAN_FEATURE_VOWIFI
3361 if( pMac->rrm.rrmPEContext.rrmEnable &&
3362 SIR_MAC_GET_RRM( psessionEntry->limCurrentBssCaps ) )
3363 {
3364 if (PowerCapsPopulated == FALSE)
3365 {
3366 PowerCapsPopulated = TRUE;
3367 PopulateDot11fPowerCaps(pMac, &frm.PowerCaps, LIM_REASSOC, psessionEntry);
3368 }
3369 }
3370#endif
3371
3372 if ( fQosEnabled &&
3373 ( ! PROP_CAPABILITY_GET(11EQOS, psessionEntry->limReassocBssPropCap ) ))
3374 {
3375 PopulateDot11fQOSCapsStation( pMac, &frm.QOSCapsStation );
3376 }
3377
3378 PopulateDot11fExtSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
3379 &frm.ExtSuppRates, psessionEntry );
3380
3381#if defined WLAN_FEATURE_VOWIFI
3382 if( pMac->rrm.rrmPEContext.rrmEnable &&
3383 SIR_MAC_GET_RRM( psessionEntry->limReassocBssCaps ) )
3384 {
3385 PopulateDot11fRRMIe( pMac, &frm.RRMEnabledCap, psessionEntry );
3386 }
3387#endif
3388 // The join request *should* contain zero or one of the WPA and RSN
3389 // IEs. The payload send along with the request is a
3390 // 'tSirSmeJoinReq'; the IE portion is held inside a 'tSirRSNie':
3391
3392 // typedef struct sSirRSNie
3393 // {
3394 // tANI_U16 length;
3395 // tANI_U8 rsnIEdata[SIR_MAC_MAX_IE_LENGTH+2];
3396 // } tSirRSNie, *tpSirRSNie;
3397
3398 // So, we should be able to make the following two calls harmlessly,
3399 // since they do nothing if they don't find the given IE in the
3400 // bytestream with which they're provided.
3401
3402 // The net effect of this will be to faithfully transmit whatever
3403 // security IE is in the join request.
3404
3405 // *However*, if we're associating for the purpose of WPS
3406 // enrollment, and we've been configured to indicate that by
3407 // eliding the WPA or RSN IE, we just skip this:
3408 if( nAddIELen && pAddIE )
3409 {
3410 wpsIe = limGetWscIEPtr(pMac, pAddIE, nAddIELen);
3411 }
3412 if ( NULL == wpsIe )
3413 {
3414 PopulateDot11fRSNOpaque( pMac, &( psessionEntry->pLimReAssocReq->rsnIE ),
3415 &frm.RSNOpaque );
3416 PopulateDot11fWPAOpaque( pMac, &( psessionEntry->pLimReAssocReq->rsnIE ),
3417 &frm.WPAOpaque );
3418#if defined(FEATURE_WLAN_WAPI)
3419 PopulateDot11fWAPIOpaque( pMac, &( psessionEntry->pLimReAssocReq->rsnIE ),
3420 &frm.WAPIOpaque );
3421#endif // defined(FEATURE_WLAN_WAPI)
3422 }
3423
3424 // include WME EDCA IE as well
3425 if ( fWmeEnabled )
3426 {
3427 if ( ! PROP_CAPABILITY_GET( WME, psessionEntry->limReassocBssPropCap ) )
3428 {
3429 PopulateDot11fWMMInfoStation( pMac, &frm.WMMInfoStation );
3430 }
3431
3432 if ( fWsmEnabled &&
3433 ( ! PROP_CAPABILITY_GET(WSM, psessionEntry->limReassocBssPropCap )))
3434 {
3435 PopulateDot11fWMMCaps( &frm.WMMCaps );
3436 }
3437 }
3438
Jeff Johnsone7245742012-09-05 17:12:55 -07003439 if ( psessionEntry->htCapability &&
Jeff Johnson295189b2012-06-20 16:38:30 -07003440 pMac->lim.htCapabilityPresentInBeacon)
3441 {
Jeff Johnsone7245742012-09-05 17:12:55 -07003442 PopulateDot11fHTCaps( pMac, psessionEntry, &frm.HTCaps );
Jeff Johnson295189b2012-06-20 16:38:30 -07003443 }
Agrawal Ashishb10d0392015-08-06 16:18:20 +05303444 limLog(pMac, LOG1, FL("SupportedChnlWidth: %d, mimoPS: %d, GF: %d,"
3445 "shortGI20:%d, shortGI40: %d, dsssCck: %d, AMPDU Param: %x"),
3446 frm.HTCaps.supportedChannelWidthSet, frm.HTCaps.mimoPowerSave,
3447 frm.HTCaps.greenField, frm.HTCaps.shortGI20MHz, frm.HTCaps.shortGI40MHz,
3448 frm.HTCaps.dsssCckMode40MHz, frm.HTCaps.maxRxAMPDUFactor);
Jeff Johnsone7245742012-09-05 17:12:55 -07003449#ifdef WLAN_FEATURE_11AC
3450 if ( psessionEntry->vhtCapability &&
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07003451 psessionEntry->vhtCapabilityPresentInBeacon)
Jeff Johnsone7245742012-09-05 17:12:55 -07003452 {
Chet Lanctotf19c1f62013-12-13 13:56:21 -08003453 limLog( pMac, LOG1, FL("Populate VHT IEs in Re-Assoc Request"));
Abhishek Singh33f76ea2015-06-04 12:27:30 +05303454 PopulateDot11fVHTCaps( pMac, &frm.VHTCaps,
3455 psessionEntry->currentOperChannel, eSIR_FALSE );
Agrawal Ashish5ac89da2015-10-26 19:08:47 +05303456 if (psessionEntry->is_ext_caps_present)
3457 PopulateDot11fExtCap( pMac, &frm.ExtCap, psessionEntry);
Jeff Johnsone7245742012-09-05 17:12:55 -07003458 }
3459#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003460
3461 nStatus = dot11fGetPackedReAssocRequestSize( pMac, &frm, &nPayload );
3462 if ( DOT11F_FAILED( nStatus ) )
3463 {
3464 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003465 "or a Re-Association Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003466 nStatus );
3467 // We'll fall back on the worst case scenario:
3468 nPayload = sizeof( tDot11fReAssocRequest );
3469 }
3470 else if ( DOT11F_WARNED( nStatus ) )
3471 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08003472 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07003473 "the packed size for a Re-Association Re "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003474 "quest(0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07003475 }
3476
3477 nBytes = nPayload + sizeof( tSirMacMgmtHdr ) + nAddIELen;
3478
3479 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
3480 ( tANI_U16 )nBytes, ( void** ) &pFrame,
3481 ( void** ) &pPacket );
3482 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3483 {
3484 psessionEntry->limMlmState = psessionEntry->limPrevMlmState;
Jeff Johnsone7245742012-09-05 17:12:55 -07003485 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07003486 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Re-As"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003487 "sociation Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07003488 goto end;
3489 }
3490
3491 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303492 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07003493
3494 // Next, we fill out the buffer descriptor:
3495 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
3496 SIR_MAC_MGMT_REASSOC_REQ,
3497 psessionEntry->limReAssocbssId,psessionEntry->selfMacAddr);
3498 if ( eSIR_SUCCESS != nSirStatus )
3499 {
3500 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003501 "tor for an Association Request (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003502 nSirStatus );
3503 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
3504 goto end;
3505 }
3506
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05303507 pMacHdr = (tpSirMacMgmtHdr) pFrame;
Jeff Johnson295189b2012-06-20 16:38:30 -07003508 // That done, pack the Probe Request:
3509 nStatus = dot11fPackReAssocRequest( pMac, &frm, pFrame +
3510 sizeof(tSirMacMgmtHdr),
3511 nPayload, &nPayload );
3512 if ( DOT11F_FAILED( nStatus ) )
3513 {
3514 limLog( pMac, LOGE, FL("Failed to pack a Re-Association Reque"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003515 "st (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003516 nStatus );
3517 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
3518 goto end;
3519 }
3520 else if ( DOT11F_WARNED( nStatus ) )
3521 {
3522 limLog( pMac, LOGW, FL("There were warnings while packing a R"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08003523 "e-Association Request (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07003524 }
3525
3526 PELOG1(limLog( pMac, LOG1, FL("*** Sending Re-Association Request length %d"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003527 "to "),
Jeff Johnson295189b2012-06-20 16:38:30 -07003528 nBytes );)
3529
3530 if( psessionEntry->assocReq != NULL )
3531 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303532 vos_mem_free(psessionEntry->assocReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07003533 psessionEntry->assocReq = NULL;
3534 }
3535
3536 if( nAddIELen )
3537 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303538 vos_mem_copy( pFrame + sizeof(tSirMacMgmtHdr) + nPayload,
3539 pAddIE,
3540 nAddIELen );
Jeff Johnson295189b2012-06-20 16:38:30 -07003541 nPayload += nAddIELen;
3542 }
3543
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303544 psessionEntry->assocReq = vos_mem_malloc(nPayload);
3545 if ( NULL == psessionEntry->assocReq )
Jeff Johnson295189b2012-06-20 16:38:30 -07003546 {
3547 PELOGE(limLog(pMac, LOGE, FL("Unable to allocate memory to store assoc request"));)
Jeff Johnson43971f52012-07-17 12:26:56 -07003548 }
3549 else
3550 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003551 //Store the Assoc request. This is sent to csr/hdd in join cnf response.
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303552 vos_mem_copy(psessionEntry->assocReq, pFrame + sizeof(tSirMacMgmtHdr), nPayload);
Jeff Johnson295189b2012-06-20 16:38:30 -07003553 psessionEntry->assocReqLen = nPayload;
Jeff Johnson43971f52012-07-17 12:26:56 -07003554 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003555
3556 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07003557 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
3558 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07003559 )
3560 {
3561 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
3562 }
3563
Sushant Kaushike8681d22015-04-21 12:08:25 +05303564 if(psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ||
3565 psessionEntry->pePersona == VOS_STA_MODE)
Ganesh K08bce952012-12-13 15:04:41 -08003566 {
3567 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
3568 }
Deepthi Gowri639d5042015-11-16 20:23:39 +05303569#ifdef FEATURE_WLAN_DIAG_SUPPORT
3570 limDiagEventReport(pMac, WLAN_PE_DIAG_REASSOC_START_EVENT, psessionEntry,
3571 eSIR_SUCCESS, eSIR_SUCCESS);
3572#endif
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08003573
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05303574 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
3575 psessionEntry->peSessionId,
3576 pMacHdr->fc.subType));
Katya Nigam63902932014-06-26 19:04:23 +05303577
Ganesh Kondabattiniffc00b12015-03-18 13:11:33 +05303578 if (IS_FEATURE_SUPPORTED_BY_FW(ENHANCED_TXBD_COMPLETION))
3579 {
3580 limLog(pMac, LOG1, FL("Reassoc req - txBdToken %u"), pMac->lim.txBdToken);
3581 halstatus = halTxFrameWithTxComplete( pMac, pPacket,
3582 ( tANI_U16 ) (sizeof(tSirMacMgmtHdr) + nPayload),
3583 HAL_TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS,
3584 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
3585 limTxComplete, pFrame, limTxBdComplete,
3586 txFlag, pMac->lim.txBdToken );
3587 pMac->lim.txBdToken++;
3588 }
3589 else
3590 {
3591 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) (sizeof(tSirMacMgmtHdr) + nPayload),
3592 HAL_TXRX_FRM_802_11_MGMT,
3593 ANI_TXDIR_TODS,
3594 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
3595 limTxComplete, pFrame, txFlag );
3596 }
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05303597 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
3598 psessionEntry->peSessionId,
3599 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07003600 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3601 {
3602 limLog( pMac, LOGE, FL("Failed to send Re-Association Request"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003603 "(%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07003604 nSirStatus );
3605 //Pkt will be freed up by the callback
3606 goto end;
3607 }
3608
Katya Nigamccaeda72015-04-20 18:51:22 +05303609 // enable caching
3610 WLANTL_EnableCaching(psessionEntry->staId);
3611
Jeff Johnson295189b2012-06-20 16:38:30 -07003612end:
3613 // Free up buffer allocated for mlmAssocReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303614 vos_mem_free( pMlmReassocReq );
Jeff Johnson295189b2012-06-20 16:38:30 -07003615 psessionEntry->pLimMlmReassocReq = NULL;
3616
3617} // limSendReassocReqMgmtFrame
3618
Sushant Kaushik9e923872015-04-02 17:09:31 +05303619eHalStatus limAuthTxCompleteCnf(tpAniSirGlobal pMac, void *pData)
Ganesh Kondabattiniffc00b12015-03-18 13:11:33 +05303620{
Sushant Kaushik9e923872015-04-02 17:09:31 +05303621 tANI_U32 txCompleteSuccess;
Ganesh Kondabattiniffc00b12015-03-18 13:11:33 +05303622 tpSirTxBdStatus pTxBdStatus;
Sushant Kaushik9e923872015-04-02 17:09:31 +05303623
3624 if (!pData)
3625 {
3626 limLog(pMac, LOG1,
3627 FL(" pData is NULL"));
3628 return eHAL_STATUS_FAILURE;
3629 }
Sushant Kaushik9e923872015-04-02 17:09:31 +05303630
Ganesh Kondabattiniffc00b12015-03-18 13:11:33 +05303631 if (IS_FEATURE_SUPPORTED_BY_FW(ENHANCED_TXBD_COMPLETION))
3632 {
3633 pTxBdStatus = (tpSirTxBdStatus) pData;
3634 txCompleteSuccess = pTxBdStatus->txCompleteStatus;
3635 limLog(pMac, LOG1, FL("txCompleteStatus %u, txBdToken %u"),
3636 pTxBdStatus->txCompleteStatus, pTxBdStatus->txBdToken);
3637 }
3638 else
3639 {
3640 txCompleteSuccess = *((tANI_U32*) pData);
3641 limLog(pMac, LOG1,
3642 FL("txCompleteSuccess= %d"), txCompleteSuccess);
3643 }
3644
Sushant Kaushik9e923872015-04-02 17:09:31 +05303645 if(txCompleteSuccess)
3646 {
3647 pMac->authAckStatus = LIM_AUTH_ACK_RCD_SUCCESS;
3648 // 'Change' timer for future activations
3649 limDeactivateAndChangeTimer(pMac, eLIM_AUTH_RETRY_TIMER);
3650 }
3651 else
3652 pMac->authAckStatus = LIM_AUTH_ACK_RCD_FAILURE;
Sushant Kaushikb97a0082015-08-31 12:36:45 +05303653#ifdef FEATURE_WLAN_DIAG_SUPPORT
Deepthi Gowri639d5042015-11-16 20:23:39 +05303654 limDiagEventReport(pMac, WLAN_PE_DIAG_AUTH_START_EVENT, NULL,
Sushant Kaushikb97a0082015-08-31 12:36:45 +05303655 pMac->authAckStatus, eSIR_SUCCESS);
3656#endif
3657
Sushant Kaushik9e923872015-04-02 17:09:31 +05303658 return eHAL_STATUS_SUCCESS;
3659}
3660
Jeff Johnson295189b2012-06-20 16:38:30 -07003661/**
3662 * \brief Send an Authentication frame
3663 *
3664 *
3665 * \param pMac Pointer to Global MAC structure
3666 *
3667 * \param pAuthFrameBody Pointer to Authentication frame structure that need
3668 * to be sent
3669 *
3670 * \param peerMacAddr MAC address of the peer entity to which Authentication
3671 * frame is destined
3672 *
3673 * \param wepBit Indicates whether wep bit to be set in FC while sending
3674 * Authentication frame3
3675 *
3676 *
3677 * This function is called by limProcessMlmMessages(). Authentication frame
3678 * is formatted and sent when this function is called.
3679 *
3680 *
3681 */
3682
3683void
3684limSendAuthMgmtFrame(tpAniSirGlobal pMac,
3685 tpSirMacAuthFrameBody pAuthFrameBody,
3686 tSirMacAddr peerMacAddr,
3687 tANI_U8 wepBit,
Sushant Kaushik9e923872015-04-02 17:09:31 +05303688 tpPESession psessionEntry,
3689 tAniBool waitForAck
Jeff Johnson295189b2012-06-20 16:38:30 -07003690 )
3691{
3692 tANI_U8 *pFrame, *pBody;
3693 tANI_U32 frameLen = 0, bodyLen = 0;
3694 tpSirMacMgmtHdr pMacHdr;
3695 tANI_U16 i;
3696 void *pPacket;
3697 eHalStatus halstatus;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05303698 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003699
3700 if(NULL == psessionEntry)
3701 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05303702 limLog(pMac, LOGE, FL("Error: psession Entry is NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003703 return;
3704 }
Abhishek Singh57aebef2014-02-03 18:47:44 +05303705
3706 limLog(pMac, LOG1,
3707 FL("Sending Auth seq# %d status %d (%d) to "MAC_ADDRESS_STR),
3708 pAuthFrameBody->authTransactionSeqNumber,
3709 pAuthFrameBody->authStatusCode,
3710 (pAuthFrameBody->authStatusCode == eSIR_MAC_SUCCESS_STATUS),
3711 MAC_ADDR_ARRAY(peerMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07003712 if (wepBit == LIM_WEP_IN_FC)
3713 {
3714 /// Auth frame3 to be sent with encrypted framebody
3715 /**
3716 * Allocate buffer for Authenticaton frame of size equal
3717 * to management frame header length plus 2 bytes each for
3718 * auth algorithm number, transaction number, status code,
3719 * 128 bytes for challenge text and 4 bytes each for
3720 * IV & ICV.
3721 */
3722
3723 frameLen = sizeof(tSirMacMgmtHdr) + LIM_ENCR_AUTH_BODY_LEN;
3724
3725 bodyLen = LIM_ENCR_AUTH_BODY_LEN;
3726 } // if (wepBit == LIM_WEP_IN_FC)
3727 else
3728 {
3729 switch (pAuthFrameBody->authTransactionSeqNumber)
3730 {
3731 case SIR_MAC_AUTH_FRAME_1:
3732 /**
3733 * Allocate buffer for Authenticaton frame of size
3734 * equal to management frame header length plus 2 bytes
3735 * each for auth algorithm number, transaction number
3736 * and status code.
3737 */
3738
3739 frameLen = sizeof(tSirMacMgmtHdr) +
3740 SIR_MAC_AUTH_CHALLENGE_OFFSET;
3741 bodyLen = SIR_MAC_AUTH_CHALLENGE_OFFSET;
3742
3743#if defined WLAN_FEATURE_VOWIFI_11R
Madan Mohan Koyyalamudi6a00a802012-11-28 16:12:11 -08003744 if (pAuthFrameBody->authAlgoNumber == eSIR_FT_AUTH)
3745 {
3746 if (0 != pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length)
Jeff Johnson295189b2012-06-20 16:38:30 -07003747 {
Madan Mohan Koyyalamudi6a00a802012-11-28 16:12:11 -08003748 frameLen += pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length;
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003749 limLog(pMac, LOG3, FL("Auth frame, FTIES length added=%d"),
Madan Mohan Koyyalamudi6a00a802012-11-28 16:12:11 -08003750 pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length);
Jeff Johnson295189b2012-06-20 16:38:30 -07003751 }
Madan Mohan Koyyalamudi6a00a802012-11-28 16:12:11 -08003752 else
3753 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05303754 limLog(pMac, LOG3, FL("Auth frame, Does not contain "
3755 "FTIES!!!"));
Madan Mohan Koyyalamudi6a00a802012-11-28 16:12:11 -08003756 frameLen += (2+SIR_MDIE_SIZE);
3757 }
3758 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003759#endif
3760 break;
3761
3762 case SIR_MAC_AUTH_FRAME_2:
3763 if ((pAuthFrameBody->authAlgoNumber == eSIR_OPEN_SYSTEM) ||
3764 ((pAuthFrameBody->authAlgoNumber == eSIR_SHARED_KEY) &&
3765 (pAuthFrameBody->authStatusCode != eSIR_MAC_SUCCESS_STATUS)))
3766 {
3767 /**
3768 * Allocate buffer for Authenticaton frame of size
3769 * equal to management frame header length plus
3770 * 2 bytes each for auth algorithm number,
3771 * transaction number and status code.
3772 */
3773
3774 frameLen = sizeof(tSirMacMgmtHdr) +
3775 SIR_MAC_AUTH_CHALLENGE_OFFSET;
3776 bodyLen = SIR_MAC_AUTH_CHALLENGE_OFFSET;
3777 }
3778 else
3779 {
3780 // Shared Key algorithm with challenge text
3781 // to be sent
3782 /**
3783 * Allocate buffer for Authenticaton frame of size
3784 * equal to management frame header length plus
3785 * 2 bytes each for auth algorithm number,
3786 * transaction number, status code and 128 bytes
3787 * for challenge text.
3788 */
3789
3790 frameLen = sizeof(tSirMacMgmtHdr) +
3791 sizeof(tSirMacAuthFrame);
3792 bodyLen = sizeof(tSirMacAuthFrameBody);
3793 }
3794
3795 break;
3796
3797 case SIR_MAC_AUTH_FRAME_3:
3798 /// Auth frame3 to be sent without encrypted framebody
3799 /**
3800 * Allocate buffer for Authenticaton frame of size equal
3801 * to management frame header length plus 2 bytes each
3802 * for auth algorithm number, transaction number and
3803 * status code.
3804 */
3805
3806 frameLen = sizeof(tSirMacMgmtHdr) +
3807 SIR_MAC_AUTH_CHALLENGE_OFFSET;
3808 bodyLen = SIR_MAC_AUTH_CHALLENGE_OFFSET;
3809
3810 break;
3811
3812 case SIR_MAC_AUTH_FRAME_4:
3813 /**
3814 * Allocate buffer for Authenticaton frame of size equal
3815 * to management frame header length plus 2 bytes each
3816 * for auth algorithm number, transaction number and
3817 * status code.
3818 */
3819
3820 frameLen = sizeof(tSirMacMgmtHdr) +
3821 SIR_MAC_AUTH_CHALLENGE_OFFSET;
3822 bodyLen = SIR_MAC_AUTH_CHALLENGE_OFFSET;
3823
3824 break;
3825 } // switch (pAuthFrameBody->authTransactionSeqNumber)
3826 } // end if (wepBit == LIM_WEP_IN_FC)
3827
3828
3829 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )frameLen, ( void** ) &pFrame, ( void** ) &pPacket );
3830
3831 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3832 {
3833 // Log error
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003834 limLog(pMac, LOGP, FL("call to bufAlloc failed for AUTH frame"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003835
3836 return;
3837 }
3838
3839 for (i = 0; i < frameLen; i++)
3840 pFrame[i] = 0;
3841
3842 // Prepare BD
3843 if (limPopulateMacHeader(pMac, pFrame, SIR_MAC_MGMT_FRAME,
3844 SIR_MAC_MGMT_AUTH, peerMacAddr,psessionEntry->selfMacAddr) != eSIR_SUCCESS)
3845 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05303846 limLog(pMac, LOGE, FL("call to limPopulateMacHeader failed for "
3847 "AUTH frame"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003848 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
3849 return;
3850 }
3851
3852 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
3853 pMacHdr->fc.wep = wepBit;
3854
3855 // Prepare BSSId
3856 if( (psessionEntry->limSystemRole == eLIM_AP_ROLE)|| (psessionEntry->limSystemRole == eLIM_BT_AMP_AP_ROLE) )
3857 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303858 vos_mem_copy( (tANI_U8 *) pMacHdr->bssId,
3859 (tANI_U8 *) psessionEntry->bssId,
3860 sizeof( tSirMacAddr ));
Jeff Johnson295189b2012-06-20 16:38:30 -07003861 }
3862
3863 /// Prepare Authentication frame body
3864 pBody = pFrame + sizeof(tSirMacMgmtHdr);
3865
3866 if (wepBit == LIM_WEP_IN_FC)
3867 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303868 vos_mem_copy(pBody, (tANI_U8 *) pAuthFrameBody, bodyLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07003869
Abhishek Singh3cbf6052014-12-15 16:46:42 +05303870 limLog(pMac, LOG1,
Abhishek Singh57aebef2014-02-03 18:47:44 +05303871 FL("*** Sending Auth seq# 3 status %d (%d) to"MAC_ADDRESS_STR),
Jeff Johnson295189b2012-06-20 16:38:30 -07003872 pAuthFrameBody->authStatusCode,
Abhishek Singh57aebef2014-02-03 18:47:44 +05303873 (pAuthFrameBody->authStatusCode == eSIR_MAC_SUCCESS_STATUS),
Abhishek Singh3cbf6052014-12-15 16:46:42 +05303874 MAC_ADDR_ARRAY(pMacHdr->da));
Jeff Johnson295189b2012-06-20 16:38:30 -07003875
Jeff Johnson295189b2012-06-20 16:38:30 -07003876 }
3877 else
3878 {
3879 *((tANI_U16 *)(pBody)) = sirSwapU16ifNeeded(pAuthFrameBody->authAlgoNumber);
3880 pBody += sizeof(tANI_U16);
3881 bodyLen -= sizeof(tANI_U16);
3882
3883 *((tANI_U16 *)(pBody)) = sirSwapU16ifNeeded(pAuthFrameBody->authTransactionSeqNumber);
3884 pBody += sizeof(tANI_U16);
3885 bodyLen -= sizeof(tANI_U16);
3886
3887 *((tANI_U16 *)(pBody)) = sirSwapU16ifNeeded(pAuthFrameBody->authStatusCode);
3888 pBody += sizeof(tANI_U16);
3889 bodyLen -= sizeof(tANI_U16);
Leela Venkata Kiran Kumar Reddy Chirala7d3fa552013-08-28 10:52:21 -07003890 if ( bodyLen <= (sizeof (pAuthFrameBody->type) +
3891 sizeof (pAuthFrameBody->length) +
3892 sizeof (pAuthFrameBody->challengeText)))
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303893 vos_mem_copy(pBody, (tANI_U8 *) &pAuthFrameBody->type, bodyLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07003894
3895#if defined WLAN_FEATURE_VOWIFI_11R
3896 if ((pAuthFrameBody->authAlgoNumber == eSIR_FT_AUTH) &&
3897 (pAuthFrameBody->authTransactionSeqNumber == SIR_MAC_AUTH_FRAME_1))
3898 {
3899
3900 {
3901 int i = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003902 if (pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length)
3903 {
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08003904#if defined WLAN_FEATURE_VOWIFI_11R_DEBUG
Srinivas Girigowdad63eb492014-02-06 12:21:47 -08003905 PELOG2(limLog(pMac, LOG2, FL("Auth1 Frame FTIE is: "));
3906 sirDumpBuf(pMac, SIR_LIM_MODULE_ID, LOG2,
Jeff Johnson295189b2012-06-20 16:38:30 -07003907 (tANI_U8 *)pBody,
3908 (pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length));)
Jeff Johnson295189b2012-06-20 16:38:30 -07003909#endif
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08003910 for (i=0; i<pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length; i++)
3911 {
Madan Mohan Koyyalamudi6a00a802012-11-28 16:12:11 -08003912 *pBody = pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies[i];
3913 pBody++;
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08003914 }
3915 }
3916 else
3917 {
3918 /* MDID attr is 54*/
3919 *pBody = 54;
Jeff Johnson295189b2012-06-20 16:38:30 -07003920 pBody++;
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08003921 *pBody = SIR_MDIE_SIZE;
3922 pBody++;
3923 for(i=0;i<SIR_MDIE_SIZE;i++)
3924 {
3925 *pBody = pMac->ft.ftPEContext.pFTPreAuthReq->pbssDescription->mdie[i];
3926 pBody++;
3927 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003928 }
3929 }
3930 }
3931#endif
3932
Abhishek Singh3cbf6052014-12-15 16:46:42 +05303933 limLog(pMac, LOG1,
Abhishek Singh57aebef2014-02-03 18:47:44 +05303934 FL("*** Sending Auth seq# %d status %d (%d) to "MAC_ADDRESS_STR),
Jeff Johnson295189b2012-06-20 16:38:30 -07003935 pAuthFrameBody->authTransactionSeqNumber,
3936 pAuthFrameBody->authStatusCode,
Abhishek Singh57aebef2014-02-03 18:47:44 +05303937 (pAuthFrameBody->authStatusCode == eSIR_MAC_SUCCESS_STATUS),
Abhishek Singh3cbf6052014-12-15 16:46:42 +05303938 MAC_ADDR_ARRAY(pMacHdr->da));
Jeff Johnson295189b2012-06-20 16:38:30 -07003939 }
3940 PELOG2(sirDumpBuf(pMac, SIR_LIM_MODULE_ID, LOG2, pFrame, frameLen);)
3941
3942 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07003943 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
3944 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003945#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05303946 || ((NULL != pMac->ft.ftPEContext.pFTPreAuthReq)
Jeff Johnsone7245742012-09-05 17:12:55 -07003947 && ( SIR_BAND_5_GHZ == limGetRFBand(pMac->ft.ftPEContext.pFTPreAuthReq->preAuthchannelNum)))
3948#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003949 )
3950 {
3951 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
3952 }
3953
Sushant Kaushike8681d22015-04-21 12:08:25 +05303954 if(psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ||
3955 psessionEntry->pePersona == VOS_STA_MODE)
Ganesh K08bce952012-12-13 15:04:41 -08003956 {
3957 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
3958 }
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08003959
Sushant Kaushik9e923872015-04-02 17:09:31 +05303960 limLog( pMac, LOG1,
3961 FL("Sending Auth Frame over WQ5 with waitForAck %d to "MAC_ADDRESS_STR
3962 " From " MAC_ADDRESS_STR), waitForAck, MAC_ADDR_ARRAY(pMacHdr->da),
Agarwal Ashisha8e81f52014-04-02 01:59:52 +05303963 MAC_ADDR_ARRAY(psessionEntry->selfMacAddr));
3964
3965 txFlag |= HAL_USE_FW_IN_TX_PATH;
3966
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05303967 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
3968 psessionEntry->peSessionId,
3969 pMacHdr->fc.subType));
Masti, Narayanraddi67ea5912015-01-08 12:34:05 +05303970
3971 if( ( psessionEntry->is11Gonly == true ) &&
3972 ( !IS_BROADCAST_MAC(peerMacAddr) ) ){
3973 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
3974 }
Sushant Kaushik9e923872015-04-02 17:09:31 +05303975 if(eSIR_TRUE == waitForAck)
3976 {
3977 pMac->authAckStatus = LIM_AUTH_ACK_NOT_RCD;
Sushant Kaushik0b343422015-05-25 17:15:55 +05303978 limLog(pMac, LOG1, FL("Auth frame - txBdToken %u"),
Ganesh Kondabattiniffc00b12015-03-18 13:11:33 +05303979 pMac->lim.txBdToken);
Sushant Kaushik9e923872015-04-02 17:09:31 +05303980 halstatus = halTxFrameWithTxComplete( pMac, pPacket,
3981 ( tANI_U16 ) frameLen,
3982 HAL_TXRX_FRM_802_11_MGMT,
3983 ANI_TXDIR_TODS,
3984 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
Ganesh Kondabattiniffc00b12015-03-18 13:11:33 +05303985 limTxComplete, pFrame, limAuthTxCompleteCnf, txFlag,
3986 pMac->lim.txBdToken);
3987 pMac->lim.txBdToken++;
Sushant Kaushik9e923872015-04-02 17:09:31 +05303988 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
3989 psessionEntry->peSessionId,
3990 halstatus));
3991 if (!HAL_STATUS_SUCCESS(halstatus))
3992 {
3993 limLog( pMac, LOGE,
3994 FL("Could not send Auth frame, retCode=%X "),
3995 halstatus );
3996 pMac->authAckStatus = LIM_AUTH_ACK_RCD_FAILURE;
3997 //Pkt will be freed up by the callback
3998 }
3999 }
4000 else
4001 {
4002 /// Queue Authentication frame in high priority WQ
4003 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) frameLen,
Jeff Johnson295189b2012-06-20 16:38:30 -07004004 HAL_TXRX_FRM_802_11_MGMT,
4005 ANI_TXDIR_TODS,
4006 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4007 limTxComplete, pFrame, txFlag );
Sushant Kaushik9e923872015-04-02 17:09:31 +05304008 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304009 psessionEntry->peSessionId,
4010 halstatus));
Sushant Kaushik9e923872015-04-02 17:09:31 +05304011 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4012 {
Jeff Johnson295189b2012-06-20 16:38:30 -07004013 limLog(pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004014 FL("*** Could not send Auth frame, retCode=%X ***"),
Jeff Johnson295189b2012-06-20 16:38:30 -07004015 halstatus);
4016
4017 //Pkt will be freed up by the callback
Sushant Kaushik9e923872015-04-02 17:09:31 +05304018 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004019 }
4020
4021 return;
4022} /*** end limSendAuthMgmtFrame() ***/
4023
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004024eHalStatus limSendDeauthCnf(tpAniSirGlobal pMac)
4025{
4026 tANI_U16 aid;
4027 tpDphHashNode pStaDs;
4028 tLimMlmDeauthReq *pMlmDeauthReq;
4029 tLimMlmDeauthCnf mlmDeauthCnf;
4030 tpPESession psessionEntry;
4031
4032 pMlmDeauthReq = pMac->lim.limDisassocDeauthCnfReq.pMlmDeauthReq;
4033 if (pMlmDeauthReq)
4034 {
4035 if (tx_timer_running(&pMac->lim.limTimers.gLimDeauthAckTimer))
4036 {
4037 limDeactivateAndChangeTimer(pMac, eLIM_DEAUTH_ACK_TIMER);
4038 }
4039
4040 if((psessionEntry = peFindSessionBySessionId(pMac, pMlmDeauthReq->sessionId))== NULL)
4041 {
4042
4043 PELOGE(limLog(pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004044 FL("session does not exist for given sessionId"));)
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004045 mlmDeauthCnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
4046 goto end;
4047 }
4048
4049 pStaDs = dphLookupHashEntry(pMac, pMlmDeauthReq->peerMacAddr, &aid, &psessionEntry->dph.dphHashTable);
4050 if (pStaDs == NULL)
4051 {
4052 mlmDeauthCnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
4053 goto end;
4054 }
4055
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004056 /// Receive path cleanup with dummy packet
4057 limCleanupRxPath(pMac, pStaDs,psessionEntry);
Abhishek Singhcf4590b2014-04-16 18:58:08 +05304058
4059#ifdef WLAN_FEATURE_VOWIFI_11R
Mukul Sharma0820d0e2014-11-11 19:49:02 +05304060 if ( psessionEntry->limSystemRole == eLIM_STA_ROLE )
Abhishek Singhcf4590b2014-04-16 18:58:08 +05304061 {
Mukul Sharma0820d0e2014-11-11 19:49:02 +05304062 PELOGE(limLog(pMac, LOG1,
4063 FL("FT Preauth SessionId %d Cleanup"
Abhishek Singhcf4590b2014-04-16 18:58:08 +05304064#ifdef FEATURE_WLAN_ESE
4065 " isESE %d"
4066#endif
4067#ifdef FEATURE_WLAN_LFR
4068 " isLFR %d"
4069#endif
4070 " is11r %d, Deauth reason %d Trigger = %d"),
Mukul Sharma0820d0e2014-11-11 19:49:02 +05304071 psessionEntry->peSessionId,
Abhishek Singhcf4590b2014-04-16 18:58:08 +05304072#ifdef FEATURE_WLAN_ESE
4073 psessionEntry->isESEconnection,
4074#endif
4075#ifdef FEATURE_WLAN_LFR
4076 psessionEntry->isFastRoamIniFeatureEnabled,
4077#endif
4078 psessionEntry->is11Rconnection,
4079 pMlmDeauthReq->reasonCode,
4080 pMlmDeauthReq->deauthTrigger););
Mukul Sharma0820d0e2014-11-11 19:49:02 +05304081
4082 limFTCleanup(pMac);
Abhishek Singhcf4590b2014-04-16 18:58:08 +05304083 }
4084#endif
4085
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004086 /// Free up buffer allocated for mlmDeauthReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304087 vos_mem_free(pMlmDeauthReq);
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004088 pMac->lim.limDisassocDeauthCnfReq.pMlmDeauthReq = NULL;
4089 }
4090 return eHAL_STATUS_SUCCESS;
4091end:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304092 vos_mem_copy( (tANI_U8 *) &mlmDeauthCnf.peerMacAddr,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004093 (tANI_U8 *) pMlmDeauthReq->peerMacAddr,
4094 sizeof(tSirMacAddr));
4095 mlmDeauthCnf.deauthTrigger = pMlmDeauthReq->deauthTrigger;
4096 mlmDeauthCnf.aid = pMlmDeauthReq->aid;
4097 mlmDeauthCnf.sessionId = pMlmDeauthReq->sessionId;
4098
4099 // Free up buffer allocated
4100 // for mlmDeauthReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304101 vos_mem_free(pMlmDeauthReq);
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004102
4103 limPostSmeMessage(pMac,
4104 LIM_MLM_DEAUTH_CNF,
4105 (tANI_U32 *) &mlmDeauthCnf);
4106 return eHAL_STATUS_SUCCESS;
4107}
4108
4109eHalStatus limSendDisassocCnf(tpAniSirGlobal pMac)
4110{
4111 tANI_U16 aid;
4112 tpDphHashNode pStaDs;
4113 tLimMlmDisassocCnf mlmDisassocCnf;
4114 tpPESession psessionEntry;
4115 tLimMlmDisassocReq *pMlmDisassocReq;
4116
4117 pMlmDisassocReq = pMac->lim.limDisassocDeauthCnfReq.pMlmDisassocReq;
4118 if (pMlmDisassocReq)
4119 {
4120 if (tx_timer_running(&pMac->lim.limTimers.gLimDisassocAckTimer))
4121 {
4122 limDeactivateAndChangeTimer(pMac, eLIM_DISASSOC_ACK_TIMER);
4123 }
4124
4125 if((psessionEntry = peFindSessionBySessionId(pMac, pMlmDisassocReq->sessionId))== NULL)
4126 {
4127
4128 PELOGE(limLog(pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004129 FL("session does not exist for given sessionId"));)
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004130 mlmDisassocCnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
4131 goto end;
4132 }
4133
4134 pStaDs = dphLookupHashEntry(pMac, pMlmDisassocReq->peerMacAddr, &aid, &psessionEntry->dph.dphHashTable);
4135 if (pStaDs == NULL)
4136 {
Sachin Ahuja2fea3d12014-12-18 17:31:31 +05304137 limLog(pMac, LOGE,
4138 FL("StaDs Null"));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004139 mlmDisassocCnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
4140 goto end;
4141 }
4142
4143 /// Receive path cleanup with dummy packet
4144 if(eSIR_SUCCESS != limCleanupRxPath(pMac, pStaDs, psessionEntry))
4145 {
4146 mlmDisassocCnf.resultCode = eSIR_SME_RESOURCES_UNAVAILABLE;
Sachin Ahuja2fea3d12014-12-18 17:31:31 +05304147 limLog(pMac, LOGE,
4148 FL("CleanupRxPath error"));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004149 goto end;
4150 }
4151
4152#ifdef WLAN_FEATURE_VOWIFI_11R
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08004153 if ( (psessionEntry->limSystemRole == eLIM_STA_ROLE ) &&
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05304154 (pMlmDisassocReq->reasonCode !=
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08004155 eSIR_MAC_DISASSOC_DUE_TO_FTHANDOFF_REASON))
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004156 {
Mukul Sharma0820d0e2014-11-11 19:49:02 +05304157 PELOGE(limLog(pMac, LOG1,
4158 FL("FT Preauth SessionId %d Cleanup"
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004159#ifdef FEATURE_WLAN_ESE
4160 " isESE %d"
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08004161#endif
4162#ifdef FEATURE_WLAN_LFR
4163 " isLFR %d"
4164#endif
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004165 " is11r %d reason %d"),
Mukul Sharma0820d0e2014-11-11 19:49:02 +05304166 psessionEntry->peSessionId,
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004167#ifdef FEATURE_WLAN_ESE
4168 psessionEntry->isESEconnection,
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08004169#endif
4170#ifdef FEATURE_WLAN_LFR
4171 psessionEntry->isFastRoamIniFeatureEnabled,
4172#endif
4173 psessionEntry->is11Rconnection,
4174 pMlmDisassocReq->reasonCode););
Mukul Sharma0820d0e2014-11-11 19:49:02 +05304175 limFTCleanup(pMac);
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004176 }
4177#endif
4178
4179 /// Free up buffer allocated for mlmDisassocReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304180 vos_mem_free(pMlmDisassocReq);
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004181 pMac->lim.limDisassocDeauthCnfReq.pMlmDisassocReq = NULL;
4182 return eHAL_STATUS_SUCCESS;
4183 }
4184 else
4185 {
4186 return eHAL_STATUS_SUCCESS;
4187 }
4188end:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304189 vos_mem_copy( (tANI_U8 *) &mlmDisassocCnf.peerMacAddr,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004190 (tANI_U8 *) pMlmDisassocReq->peerMacAddr,
4191 sizeof(tSirMacAddr));
4192 mlmDisassocCnf.aid = pMlmDisassocReq->aid;
4193 mlmDisassocCnf.disassocTrigger = pMlmDisassocReq->disassocTrigger;
4194
4195 /* Update PE session ID*/
4196 mlmDisassocCnf.sessionId = pMlmDisassocReq->sessionId;
4197
Madan Mohan Koyyalamudib7f5a672012-11-29 11:17:46 -08004198 if(pMlmDisassocReq != NULL)
4199 {
4200 /// Free up buffer allocated for mlmDisassocReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304201 vos_mem_free(pMlmDisassocReq);
Madan Mohan Koyyalamudib7f5a672012-11-29 11:17:46 -08004202 pMac->lim.limDisassocDeauthCnfReq.pMlmDisassocReq = NULL;
4203 }
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004204
4205 limPostSmeMessage(pMac,
4206 LIM_MLM_DISASSOC_CNF,
4207 (tANI_U32 *) &mlmDisassocCnf);
4208 return eHAL_STATUS_SUCCESS;
4209}
4210
Ganesh Kondabattini358fc9b2015-03-11 16:14:25 +05304211eHalStatus limDisassocTxCompleteCnf(tpAniSirGlobal pMac, void *pData)
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004212{
Ganesh Kondabattinib18b3292015-03-16 16:59:26 +05304213 if (pData && IS_FEATURE_SUPPORTED_BY_FW(ENHANCED_TXBD_COMPLETION))
4214 {
4215 tpSirTxBdStatus pTxBdStatus;
4216 pTxBdStatus = (tpSirTxBdStatus) pData;
4217 limLog(pMac, LOG1, FL("txCompleteStatus %u, txBdToken %u"),
4218 pTxBdStatus->txCompleteStatus, pTxBdStatus->txBdToken);
4219 }
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004220 return limSendDisassocCnf(pMac);
4221}
4222
Ganesh Kondabattini358fc9b2015-03-11 16:14:25 +05304223eHalStatus limDeauthTxCompleteCnf(tpAniSirGlobal pMac, void *pData)
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004224{
Ganesh Kondabattinib18b3292015-03-16 16:59:26 +05304225 if (pData && IS_FEATURE_SUPPORTED_BY_FW(ENHANCED_TXBD_COMPLETION))
4226 {
4227 tpSirTxBdStatus pTxBdStatus;
4228 pTxBdStatus = (tpSirTxBdStatus) pData;
4229 limLog(pMac, LOG1, FL("txCompleteStatus %u, txBdToken %u"),
4230 pTxBdStatus->txCompleteStatus, pTxBdStatus->txBdToken);
4231 }
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004232 return limSendDeauthCnf(pMac);
4233}
4234
Jeff Johnson295189b2012-06-20 16:38:30 -07004235/**
4236 * \brief This function is called to send Disassociate frame.
4237 *
4238 *
4239 * \param pMac Pointer to Global MAC structure
4240 *
4241 * \param nReason Indicates the reason that need to be sent in
4242 * Disassociation frame
4243 *
4244 * \param peerMacAddr MAC address of the STA to which Disassociation frame is
4245 * sent
4246 *
4247 *
4248 */
4249
4250void
4251limSendDisassocMgmtFrame(tpAniSirGlobal pMac,
4252 tANI_U16 nReason,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004253 tSirMacAddr peer,
4254 tpPESession psessionEntry,
4255 tANI_BOOLEAN waitForAck)
Jeff Johnson295189b2012-06-20 16:38:30 -07004256{
4257 tDot11fDisassociation frm;
4258 tANI_U8 *pFrame;
4259 tSirRetStatus nSirStatus;
4260 tpSirMacMgmtHdr pMacHdr;
4261 tANI_U32 nBytes, nPayload, nStatus;
4262 void *pPacket;
4263 eHalStatus halstatus;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304264 tANI_U32 txFlag = 0;
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004265 tANI_U32 val = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004266 if(NULL == psessionEntry)
4267 {
4268 return;
4269 }
4270
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304271 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004272
4273 frm.Reason.code = nReason;
4274
4275 nStatus = dot11fGetPackedDisassociationSize( pMac, &frm, &nPayload );
4276 if ( DOT11F_FAILED( nStatus ) )
4277 {
4278 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004279 "or a Disassociation (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004280 nStatus );
4281 // We'll fall back on the worst case scenario:
4282 nPayload = sizeof( tDot11fDisassociation );
4283 }
4284 else if ( DOT11F_WARNED( nStatus ) )
4285 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004286 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07004287 "the packed size for a Disassociation "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004288 "(0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004289 }
4290
4291 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4292
4293 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
4294 ( tANI_U16 )nBytes, ( void** ) &pFrame,
4295 ( void** ) &pPacket );
4296 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4297 {
4298 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Dis"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004299 "association."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07004300 return;
4301 }
4302
4303 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304304 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004305
4306 // Next, we fill out the buffer descriptor:
4307 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
4308 SIR_MAC_MGMT_DISASSOC, peer,psessionEntry->selfMacAddr);
4309 if ( eSIR_SUCCESS != nSirStatus )
4310 {
4311 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004312 "tor for a Disassociation (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004313 nSirStatus );
4314 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
4315 ( void* ) pFrame, ( void* ) pPacket );
4316 return; // just allocated...
4317 }
4318
4319 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
4320
4321 // Prepare the BSSID
4322 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
4323
Chet Lanctot186b5732013-03-18 10:26:30 -07004324#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07004325 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07004326#endif
4327
Jeff Johnson295189b2012-06-20 16:38:30 -07004328 nStatus = dot11fPackDisassociation( pMac, &frm, pFrame +
4329 sizeof(tSirMacMgmtHdr),
4330 nPayload, &nPayload );
4331 if ( DOT11F_FAILED( nStatus ) )
4332 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004333 limLog( pMac, LOGE, FL("Failed to pack a Disassociation (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004334 nStatus );
4335 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
4336 ( void* ) pFrame, ( void* ) pPacket );
4337 return; // allocated!
4338 }
4339 else if ( DOT11F_WARNED( nStatus ) )
4340 {
4341 limLog( pMac, LOGW, FL("There were warnings while packing a D"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004342 "isassociation (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004343 }
4344
Abhishek Singhcd09b562013-12-24 16:02:20 +05304345 limLog( pMac, LOG1, FL("***Sessionid %d Sending Disassociation frame with "
4346 "reason %u and waitForAck %d to "MAC_ADDRESS_STR" ,From "
4347 MAC_ADDRESS_STR), psessionEntry->peSessionId, nReason, waitForAck,
4348 MAC_ADDR_ARRAY(pMacHdr->da),
4349 MAC_ADDR_ARRAY(psessionEntry->selfMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07004350
4351 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07004352 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
4353 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07004354 )
4355 {
4356 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
4357 }
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08004358
Sushant Kaushike8681d22015-04-21 12:08:25 +05304359 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08004360
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304361 if( IS_FW_IN_TX_PATH_FEATURE_ENABLE )
4362 {
4363 /* This frame will be sent on air by firmware,
4364 which will ensure that this frame goes out
4365 even though DEL_STA is sent immediately */
4366 /* Without this for DEL_STA command there is
4367 risk of flushing frame in BTQM queue without
4368 sending on air */
Agarwal Ashisha8e81f52014-04-02 01:59:52 +05304369 limLog( pMac, LOG1, FL("Sending Disassoc Frame over WQ5 to "MAC_ADDRESS_STR
4370 " From " MAC_ADDRESS_STR),MAC_ADDR_ARRAY(pMacHdr->da),
4371 MAC_ADDR_ARRAY(psessionEntry->selfMacAddr));
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304372 txFlag |= HAL_USE_FW_IN_TX_PATH;
4373 }
4374
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004375 if (waitForAck)
Jeff Johnson295189b2012-06-20 16:38:30 -07004376 {
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304377 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
4378 psessionEntry->peSessionId,
4379 pMacHdr->fc.subType));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004380 // Queue Disassociation frame in high priority WQ
4381 /* get the duration from the request */
4382 halstatus = halTxFrameWithTxComplete( 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, limDisassocTxCompleteCnf,
Ganesh Kondabattini10e67352015-03-16 17:41:57 +05304387 txFlag,
4388 pMac->lim.txBdToken++);
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304389 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
4390 psessionEntry->peSessionId,
4391 halstatus));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004392 val = SYS_MS_TO_TICKS(LIM_DISASSOC_DEAUTH_ACK_TIMEOUT);
Jeff Johnson295189b2012-06-20 16:38:30 -07004393
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004394 if (tx_timer_change(
4395 &pMac->lim.limTimers.gLimDisassocAckTimer, val, 0)
4396 != TX_SUCCESS)
4397 {
4398 limLog(pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004399 FL("Unable to change Disassoc ack Timer val"));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004400 return;
4401 }
4402 else if(TX_SUCCESS != tx_timer_activate(
4403 &pMac->lim.limTimers.gLimDisassocAckTimer))
4404 {
4405 limLog(pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004406 FL("Unable to activate Disassoc ack Timer"));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004407 limDeactivateAndChangeTimer(pMac, eLIM_DISASSOC_ACK_TIMER);
4408 return;
4409 }
4410 }
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08004411 else
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004412 {
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304413 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
4414 psessionEntry->peSessionId,
4415 pMacHdr->fc.subType));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004416 // Queue Disassociation frame in high priority WQ
4417 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4418 HAL_TXRX_FRM_802_11_MGMT,
4419 ANI_TXDIR_TODS,
4420 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4421 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304422 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
4423 psessionEntry->peSessionId,
4424 halstatus));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004425 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4426 {
4427 limLog( pMac, LOGE, FL("Failed to send Disassociation "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004428 "(%X)!"),
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004429 nSirStatus );
4430 //Pkt will be freed up by the callback
4431 return;
4432 }
4433 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004434} // End limSendDisassocMgmtFrame.
4435
4436/**
4437 * \brief This function is called to send a Deauthenticate frame
4438 *
4439 *
4440 * \param pMac Pointer to global MAC structure
4441 *
4442 * \param nReason Indicates the reason that need to be sent in the
4443 * Deauthenticate frame
4444 *
4445 * \param peeer address of the STA to which the frame is to be sent
4446 *
4447 *
4448 */
4449
4450void
4451limSendDeauthMgmtFrame(tpAniSirGlobal pMac,
4452 tANI_U16 nReason,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004453 tSirMacAddr peer,
4454 tpPESession psessionEntry,
4455 tANI_BOOLEAN waitForAck)
Jeff Johnson295189b2012-06-20 16:38:30 -07004456{
4457 tDot11fDeAuth frm;
4458 tANI_U8 *pFrame;
4459 tSirRetStatus nSirStatus;
4460 tpSirMacMgmtHdr pMacHdr;
4461 tANI_U32 nBytes, nPayload, nStatus;
4462 void *pPacket;
4463 eHalStatus halstatus;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304464 tANI_U32 txFlag = 0;
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004465 tANI_U32 val = 0;
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08004466#ifdef FEATURE_WLAN_TDLS
4467 tANI_U16 aid;
4468 tpDphHashNode pStaDs;
4469#endif
4470
Jeff Johnson295189b2012-06-20 16:38:30 -07004471 if(NULL == psessionEntry)
4472 {
4473 return;
4474 }
4475
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304476 vos_mem_set( ( tANI_U8* ) &frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004477
4478 frm.Reason.code = nReason;
4479
4480 nStatus = dot11fGetPackedDeAuthSize( pMac, &frm, &nPayload );
4481 if ( DOT11F_FAILED( nStatus ) )
4482 {
4483 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004484 "or a De-Authentication (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004485 nStatus );
4486 // We'll fall back on the worst case scenario:
4487 nPayload = sizeof( tDot11fDeAuth );
4488 }
4489 else if ( DOT11F_WARNED( nStatus ) )
4490 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004491 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07004492 "the packed size for a De-Authentication "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004493 "(0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004494 }
4495
4496 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4497
4498 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
4499 ( tANI_U16 )nBytes, ( void** ) &pFrame,
4500 ( void** ) &pPacket );
4501 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4502 {
4503 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a De-"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004504 "Authentication."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07004505 return;
4506 }
4507
4508 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304509 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004510
4511 // Next, we fill out the buffer descriptor:
4512 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
4513 SIR_MAC_MGMT_DEAUTH, peer,psessionEntry->selfMacAddr);
4514 if ( eSIR_SUCCESS != nSirStatus )
4515 {
4516 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004517 "tor for a De-Authentication (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004518 nSirStatus );
4519 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
4520 ( void* ) pFrame, ( void* ) pPacket );
4521 return; // just allocated...
4522 }
4523
4524 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
4525
4526 // Prepare the BSSID
4527 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
4528
Chet Lanctot186b5732013-03-18 10:26:30 -07004529#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07004530 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07004531#endif
4532
Jeff Johnson295189b2012-06-20 16:38:30 -07004533 nStatus = dot11fPackDeAuth( pMac, &frm, pFrame +
4534 sizeof(tSirMacMgmtHdr),
4535 nPayload, &nPayload );
4536 if ( DOT11F_FAILED( nStatus ) )
4537 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004538 limLog( pMac, LOGE, FL("Failed to pack a DeAuthentication (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004539 nStatus );
4540 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
4541 ( void* ) pFrame, ( void* ) pPacket );
4542 return;
4543 }
4544 else if ( DOT11F_WARNED( nStatus ) )
4545 {
4546 limLog( pMac, LOGW, FL("There were warnings while packing a D"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004547 "e-Authentication (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004548 }
Abhishek Singhcd09b562013-12-24 16:02:20 +05304549 limLog( pMac, LOG1, FL("***Sessionid %d Sending Deauth frame with "
4550 "reason %u and waitForAck %d to "MAC_ADDRESS_STR" ,From "
4551 MAC_ADDRESS_STR), psessionEntry->peSessionId, nReason, waitForAck,
4552 MAC_ADDR_ARRAY(pMacHdr->da),
4553 MAC_ADDR_ARRAY(psessionEntry->selfMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07004554
4555 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07004556 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
4557 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07004558 )
4559 {
4560 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
4561 }
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08004562
Sushant Kaushike8681d22015-04-21 12:08:25 +05304563 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08004564
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304565 if( IS_FW_IN_TX_PATH_FEATURE_ENABLE )
4566 {
4567 /* This frame will be sent on air by firmware,
4568 which will ensure that this frame goes out
4569 even though DEL_STA is sent immediately */
4570 /* Without this for DEL_STA command there is
4571 risk of flushing frame in BTQM queue without
4572 sending on air */
Agarwal Ashisha8e81f52014-04-02 01:59:52 +05304573 limLog( pMac, LOG1, FL("Sending Deauth Frame over WQ5 to "MAC_ADDRESS_STR
4574 " From " MAC_ADDRESS_STR),MAC_ADDR_ARRAY(pMacHdr->da),
4575 MAC_ADDR_ARRAY(psessionEntry->selfMacAddr));
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304576 txFlag |= HAL_USE_FW_IN_TX_PATH;
4577 }
4578
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08004579#ifdef FEATURE_WLAN_TDLS
4580 pStaDs = dphLookupHashEntry(pMac, peer, &aid, &psessionEntry->dph.dphHashTable);
4581#endif
4582
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004583 if (waitForAck)
Jeff Johnson295189b2012-06-20 16:38:30 -07004584 {
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304585 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
4586 psessionEntry->peSessionId,
4587 pMacHdr->fc.subType));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004588 // Queue Disassociation frame in high priority WQ
4589 halstatus = halTxFrameWithTxComplete( pMac, pPacket, ( tANI_U16 ) nBytes,
4590 HAL_TXRX_FRM_802_11_MGMT,
4591 ANI_TXDIR_TODS,
4592 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
Ganesh Kondabattini10e67352015-03-16 17:41:57 +05304593 limTxComplete, pFrame, limDeauthTxCompleteCnf, txFlag,
4594 pMac->lim.txBdToken++);
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304595 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
4596 psessionEntry->peSessionId,
4597 halstatus));
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304598 if (!HAL_STATUS_SUCCESS(halstatus))
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004599 {
4600 limLog( pMac, LOGE, FL("Failed to send De-Authentication "
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304601 "(%X)!"),
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004602 nSirStatus );
Gopichand Nakkala4261ea52012-12-31 16:43:00 -08004603 //Pkt will be freed up by the callback limTxComplete
4604
4605 /*Call limProcessDeauthAckTimeout which will send
4606 * DeauthCnf for this frame
4607 */
4608 limProcessDeauthAckTimeout(pMac);
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004609 return;
4610 }
4611
4612 val = SYS_MS_TO_TICKS(LIM_DISASSOC_DEAUTH_ACK_TIMEOUT);
4613
4614 if (tx_timer_change(
4615 &pMac->lim.limTimers.gLimDeauthAckTimer, val, 0)
4616 != TX_SUCCESS)
4617 {
4618 limLog(pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004619 FL("Unable to change Deauth ack Timer val"));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004620 return;
4621 }
4622 else if(TX_SUCCESS != tx_timer_activate(
4623 &pMac->lim.limTimers.gLimDeauthAckTimer))
4624 {
4625 limLog(pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004626 FL("Unable to activate Deauth ack Timer"));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004627 limDeactivateAndChangeTimer(pMac, eLIM_DEAUTH_ACK_TIMER);
4628 return;
4629 }
4630 }
4631 else
4632 {
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304633 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
4634 psessionEntry->peSessionId,
4635 pMacHdr->fc.subType));
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08004636#ifdef FEATURE_WLAN_TDLS
4637 if ((NULL != pStaDs) && (STA_ENTRY_TDLS_PEER == pStaDs->staType))
4638 {
4639 // Queue Disassociation frame in high priority WQ
4640 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004641 HAL_TXRX_FRM_802_11_MGMT,
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08004642 ANI_TXDIR_IBSS,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004643 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4644 limTxComplete, pFrame, txFlag );
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08004645 }
4646 else
4647 {
4648#endif
4649 // Queue Disassociation frame in high priority WQ
4650 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4651 HAL_TXRX_FRM_802_11_MGMT,
4652 ANI_TXDIR_TODS,
4653 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4654 limTxComplete, pFrame, txFlag );
4655#ifdef FEATURE_WLAN_TDLS
4656 }
4657#endif
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304658 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
4659 psessionEntry->peSessionId,
4660 halstatus));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004661 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4662 {
4663 limLog( pMac, LOGE, FL("Failed to send De-Authentication "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004664 "(%X)!"),
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004665 nSirStatus );
4666 //Pkt will be freed up by the callback
4667 return;
4668 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004669 }
4670
4671} // End limSendDeauthMgmtFrame.
4672
4673
4674#ifdef ANI_SUPPORT_11H
4675/**
4676 * \brief Send a Measurement Report Action frame
4677 *
4678 *
4679 * \param pMac Pointer to the global MAC structure
4680 *
4681 * \param pMeasReqFrame Address of a tSirMacMeasReqActionFrame
4682 *
4683 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
4684 *
4685 *
4686 */
4687
4688tSirRetStatus
4689limSendMeasReportFrame(tpAniSirGlobal pMac,
4690 tpSirMacMeasReqActionFrame pMeasReqFrame,
4691 tSirMacAddr peer)
4692{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304693 tDot11fMeasurementReport frm;
4694 tANI_U8 *pFrame;
4695 tSirRetStatus nSirStatus;
4696 tpSirMacMgmtHdr pMacHdr;
4697 tANI_U32 nBytes, nPayload, nStatus, nCfg;
4698 void *pPacket;
4699 eHalStatus halstatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07004700
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304701 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004702
4703 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
4704 frm.Action.action = SIR_MAC_ACTION_MEASURE_REPORT_ID;
4705 frm.DialogToken.token = pMeasReqFrame->actionHeader.dialogToken;
4706
4707 switch ( pMeasReqFrame->measReqIE.measType )
4708 {
4709 case SIR_MAC_BASIC_MEASUREMENT_TYPE:
4710 nSirStatus =
4711 PopulateDot11fMeasurementReport0( pMac, pMeasReqFrame,
4712 &frm.MeasurementReport );
4713 break;
4714 case SIR_MAC_CCA_MEASUREMENT_TYPE:
4715 nSirStatus =
4716 PopulateDot11fMeasurementReport1( pMac, pMeasReqFrame,
4717 &frm.MeasurementReport );
4718 break;
4719 case SIR_MAC_RPI_MEASUREMENT_TYPE:
4720 nSirStatus =
4721 PopulateDot11fMeasurementReport2( pMac, pMeasReqFrame,
4722 &frm.MeasurementReport );
4723 break;
4724 default:
4725 limLog( pMac, LOGE, FL("Unknown measurement type %d in limSen"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004726 "dMeasReportFrame."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004727 pMeasReqFrame->measReqIE.measType );
4728 return eSIR_FAILURE;
4729 }
4730
4731 if ( eSIR_SUCCESS != nSirStatus ) return eSIR_FAILURE;
4732
4733 nStatus = dot11fGetPackedMeasurementReportSize( pMac, &frm, &nPayload );
4734 if ( DOT11F_FAILED( nStatus ) )
4735 {
4736 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004737 "or a Measurement Report (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004738 nStatus );
4739 // We'll fall back on the worst case scenario:
4740 nPayload = sizeof( tDot11fMeasurementReport );
4741 }
4742 else if ( DOT11F_WARNED( nStatus ) )
4743 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004744 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07004745 "the packed size for a Measurement Rep"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004746 "ort (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004747 }
4748
4749 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4750
4751 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
4752 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4753 {
4754 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a De-"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004755 "Authentication."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07004756 return eSIR_FAILURE;
4757 }
4758
4759 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304760 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004761
4762 // Next, we fill out the buffer descriptor:
4763 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
4764 SIR_MAC_MGMT_ACTION, peer);
4765 if ( eSIR_SUCCESS != nSirStatus )
4766 {
4767 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004768 "tor for a Measurement Report (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004769 nSirStatus );
4770 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4771 return eSIR_FAILURE; // just allocated...
4772 }
4773
4774 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
4775
4776 nCfg = 6;
4777 nSirStatus = wlan_cfgGetStr( pMac, WNI_CFG_BSSID, pMacHdr->bssId, &nCfg );
4778 if ( eSIR_SUCCESS != nSirStatus )
4779 {
4780 limLog( pMac, LOGE, FL("Failed to retrieve WNI_CFG_BSSID from"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004781 " CFG (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004782 nSirStatus );
4783 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4784 return eSIR_FAILURE; // just allocated...
4785 }
4786
Chet Lanctot186b5732013-03-18 10:26:30 -07004787#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07004788 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07004789#endif
4790
Jeff Johnson295189b2012-06-20 16:38:30 -07004791 nStatus = dot11fPackMeasurementReport( pMac, &frm, pFrame +
4792 sizeof(tSirMacMgmtHdr),
4793 nPayload, &nPayload );
4794 if ( DOT11F_FAILED( nStatus ) )
4795 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004796 limLog( pMac, LOGE, FL("Failed to pack a Measurement Report (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004797 nStatus );
4798 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4799 return eSIR_FAILURE; // allocated!
4800 }
4801 else if ( DOT11F_WARNED( nStatus ) )
4802 {
4803 limLog( pMac, LOGW, FL("There were warnings while packing a M"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004804 "easurement Report (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004805 }
4806
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304807 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
4808 ((psessionEntry)? psessionEntry->peSessionId : NO_SESSION),
4809 pMacHdr->fc.subType));
Jeff Johnson295189b2012-06-20 16:38:30 -07004810 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4811 HAL_TXRX_FRM_802_11_MGMT,
4812 ANI_TXDIR_TODS,
4813 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4814 limTxComplete, pFrame, 0 );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304815 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
4816 ((psessionEntry)? psessionEntry->peSessionId : NO_SESSION),
4817 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07004818 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4819 {
4820 limLog( pMac, LOGE, FL("Failed to send a Measurement Report "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004821 "(%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07004822 nSirStatus );
4823 //Pkt will be freed up by the callback
4824 return eSIR_FAILURE; // just allocated...
4825 }
4826
4827 return eSIR_SUCCESS;
4828
4829} // End limSendMeasReportFrame.
4830
4831
4832/**
4833 * \brief Send a TPC Request Action frame
4834 *
4835 *
4836 * \param pMac Pointer to the global MAC datastructure
4837 *
4838 * \param peer MAC address to which the frame should be sent
4839 *
4840 *
4841 */
4842
4843void
4844limSendTpcRequestFrame(tpAniSirGlobal pMac,
4845 tSirMacAddr peer)
4846{
4847 tDot11fTPCRequest frm;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304848 tANI_U8 *pFrame;
Jeff Johnson295189b2012-06-20 16:38:30 -07004849 tSirRetStatus nSirStatus;
4850 tpSirMacMgmtHdr pMacHdr;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304851 tANI_U32 nBytes, nPayload, nStatus, nCfg;
4852 void *pPacket;
4853 eHalStatus halstatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07004854
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304855 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004856
4857 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
4858 frm.Action.action = SIR_MAC_ACTION_TPC_REQUEST_ID;
4859 frm.DialogToken.token = 1;
4860 frm.TPCRequest.present = 1;
4861
4862 nStatus = dot11fGetPackedTPCRequestSize( pMac, &frm, &nPayload );
4863 if ( DOT11F_FAILED( nStatus ) )
4864 {
4865 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004866 "or a TPC Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004867 nStatus );
4868 // We'll fall back on the worst case scenario:
4869 nPayload = sizeof( tDot11fTPCRequest );
4870 }
4871 else if ( DOT11F_WARNED( nStatus ) )
4872 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004873 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07004874 "the packed size for a TPC Request (0x"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004875 "%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004876 }
4877
4878 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4879
4880 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
4881 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4882 {
4883 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a TPC"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004884 " Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07004885 return;
4886 }
4887
4888 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304889 vos_mem_set(pFrame, nBytes,0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004890
4891 // Next, we fill out the buffer descriptor:
4892 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
4893 SIR_MAC_MGMT_ACTION, peer);
4894 if ( eSIR_SUCCESS != nSirStatus )
4895 {
4896 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004897 "tor for a TPC Request (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004898 nSirStatus );
4899 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4900 return; // just allocated...
4901 }
4902
4903 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
4904
4905 nCfg = 6;
4906 nSirStatus = wlan_cfgGetStr( pMac, WNI_CFG_BSSID, pMacHdr->bssId, &nCfg );
4907 if ( eSIR_SUCCESS != nSirStatus )
4908 {
4909 limLog( pMac, LOGE, FL("Failed to retrieve WNI_CFG_BSSID from"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004910 " CFG (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004911 nSirStatus );
4912 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4913 return; // just allocated...
4914 }
4915
Chet Lanctot186b5732013-03-18 10:26:30 -07004916#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07004917 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07004918#endif
4919
Jeff Johnson295189b2012-06-20 16:38:30 -07004920 nStatus = dot11fPackTPCRequest( pMac, &frm, pFrame +
4921 sizeof(tSirMacMgmtHdr),
4922 nPayload, &nPayload );
4923 if ( DOT11F_FAILED( nStatus ) )
4924 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004925 limLog( pMac, LOGE, FL("Failed to pack a TPC Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004926 nStatus );
4927 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4928 return; // allocated!
4929 }
4930 else if ( DOT11F_WARNED( nStatus ) )
4931 {
4932 limLog( pMac, LOGW, FL("There were warnings while packing a T"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004933 "PC Request (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004934 }
4935
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304936 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
4937 ((psessionEntry)? psessionEntry->peSessionId : NO_SESSION),
4938 pMacHdr->fc.subType));
Jeff Johnson295189b2012-06-20 16:38:30 -07004939 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4940 HAL_TXRX_FRM_802_11_MGMT,
4941 ANI_TXDIR_TODS,
4942 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4943 limTxComplete, pFrame, 0 );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304944 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
4945 ((psessionEntry)? psessionEntry->peSessionId : NO_SESSION),
4946 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07004947 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4948 {
4949 limLog( pMac, LOGE, FL("Failed to send a TPC Request "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004950 "(%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07004951 nSirStatus );
4952 //Pkt will be freed up by the callback
4953 return;
4954 }
4955
4956} // End limSendTpcRequestFrame.
4957
4958
4959/**
4960 * \brief Send a TPC Report Action frame
4961 *
4962 *
4963 * \param pMac Pointer to the global MAC datastructure
4964 *
4965 * \param pTpcReqFrame Pointer to the received TPC Request
4966 *
4967 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
4968 *
4969 *
4970 */
4971
4972tSirRetStatus
4973limSendTpcReportFrame(tpAniSirGlobal pMac,
4974 tpSirMacTpcReqActionFrame pTpcReqFrame,
4975 tSirMacAddr peer)
4976{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304977 tDot11fTPCReport frm;
4978 tANI_U8 *pFrame;
4979 tSirRetStatus nSirStatus;
4980 tpSirMacMgmtHdr pMacHdr;
4981 tANI_U32 nBytes, nPayload, nStatus, nCfg;
4982 void *pPacket;
4983 eHalStatus halstatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07004984
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304985 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004986
4987 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
4988 frm.Action.action = SIR_MAC_ACTION_TPC_REPORT_ID;
4989 frm.DialogToken.token = pTpcReqFrame->actionHeader.dialogToken;
4990
4991 // FramesToDo: On the Gen4_TVM branch, there was a comment:
4992 // "misplaced this function, need to replace:
4993 // txPower = halGetRateToPwrValue(pMac, staid,
4994 // pMac->lim.gLimCurrentChannelId, 0);
4995 frm.TPCReport.tx_power = 0;
4996 frm.TPCReport.link_margin = 0;
4997 frm.TPCReport.present = 1;
4998
4999 nStatus = dot11fGetPackedTPCReportSize( pMac, &frm, &nPayload );
5000 if ( DOT11F_FAILED( nStatus ) )
5001 {
5002 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005003 "or a TPC Report (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005004 nStatus );
5005 // We'll fall back on the worst case scenario:
5006 nPayload = sizeof( tDot11fTPCReport );
5007 }
5008 else if ( DOT11F_WARNED( nStatus ) )
5009 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005010 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07005011 "the packed size for a TPC Report (0x"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005012 "%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07005013 }
5014
5015 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
5016
5017 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
5018 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
5019 {
5020 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a TPC"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005021 " Report."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07005022 return eSIR_FAILURE;
5023 }
5024
5025 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305026 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005027
5028 // Next, we fill out the buffer descriptor:
5029 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
5030 SIR_MAC_MGMT_ACTION, peer);
5031 if ( eSIR_SUCCESS != nSirStatus )
5032 {
5033 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005034 "tor for a TPC Report (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005035 nSirStatus );
5036 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
5037 return eSIR_FAILURE; // just allocated...
5038 }
5039
5040 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
5041
5042 nCfg = 6;
5043 nSirStatus = wlan_cfgGetStr( pMac, WNI_CFG_BSSID, pMacHdr->bssId, &nCfg );
5044 if ( eSIR_SUCCESS != nSirStatus )
5045 {
5046 limLog( pMac, LOGE, FL("Failed to retrieve WNI_CFG_BSSID from"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005047 " CFG (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005048 nSirStatus );
5049 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
5050 return eSIR_FAILURE; // just allocated...
5051 }
5052
Chet Lanctot186b5732013-03-18 10:26:30 -07005053#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07005054 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07005055#endif
5056
Jeff Johnson295189b2012-06-20 16:38:30 -07005057 nStatus = dot11fPackTPCReport( pMac, &frm, pFrame +
5058 sizeof(tSirMacMgmtHdr),
5059 nPayload, &nPayload );
5060 if ( DOT11F_FAILED( nStatus ) )
5061 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005062 limLog( pMac, LOGE, FL("Failed to pack a TPC Report (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005063 nStatus );
5064 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
5065 return eSIR_FAILURE; // allocated!
5066 }
5067 else if ( DOT11F_WARNED( nStatus ) )
5068 {
5069 limLog( pMac, LOGW, FL("There were warnings while packing a T"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005070 "PC Report (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07005071 }
5072
5073
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05305074 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
5075 ((psessionEntry)? psessionEntry->peSessionId : NO_SESSION),
5076 pMacHdr->fc.subType));
Jeff Johnson295189b2012-06-20 16:38:30 -07005077 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
5078 HAL_TXRX_FRM_802_11_MGMT,
5079 ANI_TXDIR_TODS,
5080 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
5081 limTxComplete, pFrame, 0 );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05305082 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
5083 ((psessionEntry)? psessionEntry->peSessionId : NO_SESSION),
5084 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07005085 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
5086 {
5087 limLog( pMac, LOGE, FL("Failed to send a TPC Report "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005088 "(%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07005089 nSirStatus );
5090 //Pkt will be freed up by the callback
5091 return eSIR_FAILURE; // just allocated...
5092 }
5093
5094 return eSIR_SUCCESS;
5095
5096} // End limSendTpcReportFrame.
5097#endif //ANI_SUPPORT_11H
5098
5099
Jeff Johnson295189b2012-06-20 16:38:30 -07005100/**
5101 * \brief Send a Channel Switch Announcement
5102 *
5103 *
5104 * \param pMac Pointer to the global MAC datastructure
5105 *
5106 * \param peer MAC address to which this frame will be sent
5107 *
5108 * \param nMode
5109 *
5110 * \param nNewChannel
5111 *
5112 * \param nCount
5113 *
5114 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
5115 *
5116 *
5117 */
5118
5119tSirRetStatus
5120limSendChannelSwitchMgmtFrame(tpAniSirGlobal pMac,
5121 tSirMacAddr peer,
Jeff Johnsone7245742012-09-05 17:12:55 -07005122 tANI_U8 nMode,
5123 tANI_U8 nNewChannel,
5124 tANI_U8 nCount,
5125 tpPESession psessionEntry )
Jeff Johnson295189b2012-06-20 16:38:30 -07005126{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05305127 tDot11fChannelSwitch frm;
5128 tANI_U8 *pFrame;
5129 tSirRetStatus nSirStatus;
5130 tpSirMacMgmtHdr pMacHdr;
5131 tANI_U32 nBytes, nPayload, nStatus;//, nCfg;
5132 void *pPacket;
5133 eHalStatus halstatus;
5134 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005135
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305136 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005137
5138 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
5139 frm.Action.action = SIR_MAC_ACTION_CHANNEL_SWITCH_ID;
5140 frm.ChanSwitchAnn.switchMode = nMode;
5141 frm.ChanSwitchAnn.newChannel = nNewChannel;
5142 frm.ChanSwitchAnn.switchCount = nCount;
5143 frm.ChanSwitchAnn.present = 1;
5144
5145 nStatus = dot11fGetPackedChannelSwitchSize( pMac, &frm, &nPayload );
5146 if ( DOT11F_FAILED( nStatus ) )
5147 {
5148 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005149 "or a Channel Switch (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005150 nStatus );
5151 // We'll fall back on the worst case scenario:
5152 nPayload = sizeof( tDot11fChannelSwitch );
5153 }
5154 else if ( DOT11F_WARNED( nStatus ) )
5155 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005156 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07005157 "the packed size for a Channel Switch (0x"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005158 "%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07005159 }
5160
5161 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
5162
5163 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
5164 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
5165 {
5166 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a TPC"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005167 " Report."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07005168 return eSIR_FAILURE;
5169 }
5170
5171 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305172 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005173
5174 // Next, we fill out the buffer descriptor:
5175 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
Jeff Johnsone7245742012-09-05 17:12:55 -07005176 SIR_MAC_MGMT_ACTION, peer, psessionEntry->selfMacAddr);
5177 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305178 vos_mem_copy( (tANI_U8 *) pMacHdr->bssId,
5179 (tANI_U8 *) psessionEntry->bssId,
5180 sizeof( tSirMacAddr ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005181 if ( eSIR_SUCCESS != nSirStatus )
5182 {
5183 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005184 "tor for a Channel Switch (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005185 nSirStatus );
5186 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
5187 return eSIR_FAILURE; // just allocated...
5188 }
5189
Jeff Johnsone7245742012-09-05 17:12:55 -07005190#if 0
Jeff Johnson295189b2012-06-20 16:38:30 -07005191 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
5192
5193 nCfg = 6;
5194 nSirStatus = wlan_cfgGetStr( pMac, WNI_CFG_BSSID, pMacHdr->bssId, &nCfg );
5195 if ( eSIR_SUCCESS != nSirStatus )
5196 {
5197 limLog( pMac, LOGE, FL("Failed to retrieve WNI_CFG_BSSID from"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005198 " CFG (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005199 nSirStatus );
5200 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
5201 return eSIR_FAILURE; // just allocated...
5202 }
Jeff Johnsone7245742012-09-05 17:12:55 -07005203#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07005204
5205#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07005206 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07005207#endif
5208
Jeff Johnson295189b2012-06-20 16:38:30 -07005209 nStatus = dot11fPackChannelSwitch( pMac, &frm, pFrame +
5210 sizeof(tSirMacMgmtHdr),
5211 nPayload, &nPayload );
5212 if ( DOT11F_FAILED( nStatus ) )
5213 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005214 limLog( pMac, LOGE, FL("Failed to pack a Channel Switch (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005215 nStatus );
5216 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
5217 return eSIR_FAILURE; // allocated!
5218 }
5219 else if ( DOT11F_WARNED( nStatus ) )
5220 {
5221 limLog( pMac, LOGW, FL("There were warnings while packing a C"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005222 "hannel Switch (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07005223 }
5224
Jeff Johnsone7245742012-09-05 17:12:55 -07005225 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnsone7245742012-09-05 17:12:55 -07005226 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
5227 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnsone7245742012-09-05 17:12:55 -07005228 )
5229 {
5230 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
5231 }
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05305232
5233 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
5234 psessionEntry->peSessionId,
5235 pMacHdr->fc.subType));
Jeff Johnson295189b2012-06-20 16:38:30 -07005236 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
5237 HAL_TXRX_FRM_802_11_MGMT,
5238 ANI_TXDIR_TODS,
5239 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
Jeff Johnsone7245742012-09-05 17:12:55 -07005240 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05305241 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
5242 psessionEntry->peSessionId,
5243 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07005244 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
5245 {
5246 limLog( pMac, LOGE, FL("Failed to send a Channel Switch "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005247 "(%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07005248 nSirStatus );
5249 //Pkt will be freed up by the callback
5250 return eSIR_FAILURE;
5251 }
5252
5253 return eSIR_SUCCESS;
5254
5255} // End limSendChannelSwitchMgmtFrame.
5256
Jeff Johnson295189b2012-06-20 16:38:30 -07005257
5258
Mohit Khanna4a70d262012-09-11 16:30:12 -07005259#ifdef WLAN_FEATURE_11AC
5260tSirRetStatus
5261limSendVHTOpmodeNotificationFrame(tpAniSirGlobal pMac,
5262 tSirMacAddr peer,
5263 tANI_U8 nMode,
5264 tpPESession psessionEntry )
5265{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05305266 tDot11fOperatingMode frm;
5267 tANI_U8 *pFrame;
5268 tSirRetStatus nSirStatus;
5269 tpSirMacMgmtHdr pMacHdr;
5270 tANI_U32 nBytes, nPayload = 0, nStatus;//, nCfg;
5271 void *pPacket;
5272 eHalStatus halstatus;
5273 tANI_U32 txFlag = 0;
Mohit Khanna4a70d262012-09-11 16:30:12 -07005274
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305275 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Mohit Khanna4a70d262012-09-11 16:30:12 -07005276
5277 frm.Category.category = SIR_MAC_ACTION_VHT;
5278 frm.Action.action = SIR_MAC_VHT_OPMODE_NOTIFICATION;
5279 frm.OperatingMode.chanWidth = nMode;
5280 frm.OperatingMode.rxNSS = 0;
5281 frm.OperatingMode.rxNSSType = 0;
5282
5283 nStatus = dot11fGetPackedOperatingModeSize( pMac, &frm, &nPayload );
5284 if ( DOT11F_FAILED( nStatus ) )
5285 {
5286 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005287 "or a Operating Mode (0x%08x)."),
Mohit Khanna4a70d262012-09-11 16:30:12 -07005288 nStatus );
5289 // We'll fall back on the worst case scenario:
5290 nPayload = sizeof( tDot11fOperatingMode);
5291 }
5292 else if ( DOT11F_WARNED( nStatus ) )
5293 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005294 limLog( pMac, LOGW, FL("There were warnings while calculating "
Mohit Khanna4a70d262012-09-11 16:30:12 -07005295 "the packed size for a Operating Mode (0x"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005296 "%08x)."), nStatus );
Mohit Khanna4a70d262012-09-11 16:30:12 -07005297 }
5298
5299 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
5300
5301 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
5302 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
5303 {
5304 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Operating Mode"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005305 " Report."), nBytes );
Mohit Khanna4a70d262012-09-11 16:30:12 -07005306 return eSIR_FAILURE;
5307 }
5308
5309 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305310 vos_mem_set( pFrame, nBytes, 0 );
Mohit Khanna4a70d262012-09-11 16:30:12 -07005311
5312
5313 // Next, we fill out the buffer descriptor:
5314 if(psessionEntry->pePersona == VOS_STA_SAP_MODE) {
5315 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
5316 SIR_MAC_MGMT_ACTION, peer, psessionEntry->selfMacAddr);
5317 } else
5318 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
5319 SIR_MAC_MGMT_ACTION, psessionEntry->bssId, psessionEntry->selfMacAddr);
5320 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305321 vos_mem_copy( (tANI_U8 *) pMacHdr->bssId,
5322 (tANI_U8 *) psessionEntry->bssId,
5323 sizeof( tSirMacAddr ));
Mohit Khanna4a70d262012-09-11 16:30:12 -07005324 if ( eSIR_SUCCESS != nSirStatus )
5325 {
5326 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005327 "tor for a Operating Mode (%d)."),
Mohit Khanna4a70d262012-09-11 16:30:12 -07005328 nSirStatus );
5329 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
5330 return eSIR_FAILURE; // just allocated...
5331 }
5332 nStatus = dot11fPackOperatingMode( pMac, &frm, pFrame +
5333 sizeof(tSirMacMgmtHdr),
5334 nPayload, &nPayload );
5335 if ( DOT11F_FAILED( nStatus ) )
5336 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005337 limLog( pMac, LOGE, FL("Failed to pack a Operating Mode (0x%08x)."),
Mohit Khanna4a70d262012-09-11 16:30:12 -07005338 nStatus );
5339 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
5340 return eSIR_FAILURE; // allocated!
5341 }
5342 else if ( DOT11F_WARNED( nStatus ) )
5343 {
5344 limLog( pMac, LOGW, FL("There were warnings while packing a Operating Mode"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005345 " (0x%08x)."), nStatus );
Mohit Khanna4a70d262012-09-11 16:30:12 -07005346 }
5347 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Mohit Khanna4a70d262012-09-11 16:30:12 -07005348 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
5349 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Mohit Khanna4a70d262012-09-11 16:30:12 -07005350 )
5351 {
5352 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
5353 }
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05305354
5355 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
5356 psessionEntry->peSessionId,
5357 pMacHdr->fc.subType));
Mohit Khanna4a70d262012-09-11 16:30:12 -07005358 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
5359 HAL_TXRX_FRM_802_11_MGMT,
5360 ANI_TXDIR_TODS,
5361 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
5362 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05305363 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
5364 psessionEntry->peSessionId,
5365 halstatus));
Mohit Khanna4a70d262012-09-11 16:30:12 -07005366 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
5367 {
5368 limLog( pMac, LOGE, FL("Failed to send a Channel Switch "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005369 "(%X)!"),
Mohit Khanna4a70d262012-09-11 16:30:12 -07005370 nSirStatus );
5371 //Pkt will be freed up by the callback
5372 return eSIR_FAILURE;
5373 }
5374
5375 return eSIR_SUCCESS;
5376}
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005377
5378/**
5379 * \brief Send a VHT Channel Switch Announcement
5380 *
5381 *
5382 * \param pMac Pointer to the global MAC datastructure
5383 *
5384 * \param peer MAC address to which this frame will be sent
5385 *
5386 * \param nChanWidth
5387 *
5388 * \param nNewChannel
5389 *
5390 *
5391 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
5392 *
5393 *
5394 */
5395
5396tSirRetStatus
5397limSendVHTChannelSwitchMgmtFrame(tpAniSirGlobal pMac,
5398 tSirMacAddr peer,
5399 tANI_U8 nChanWidth,
5400 tANI_U8 nNewChannel,
5401 tANI_U8 ncbMode,
5402 tpPESession psessionEntry )
5403{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05305404 tDot11fChannelSwitch frm;
5405 tANI_U8 *pFrame;
5406 tSirRetStatus nSirStatus;
5407 tpSirMacMgmtHdr pMacHdr;
5408 tANI_U32 nBytes, nPayload, nStatus;//, nCfg;
5409 void *pPacket;
5410 eHalStatus halstatus;
5411 tANI_U32 txFlag = 0;
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005412
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305413 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005414
5415
5416 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
5417 frm.Action.action = SIR_MAC_ACTION_CHANNEL_SWITCH_ID;
5418 frm.ChanSwitchAnn.switchMode = 1;
5419 frm.ChanSwitchAnn.newChannel = nNewChannel;
5420 frm.ChanSwitchAnn.switchCount = 1;
5421 frm.ExtChanSwitchAnn.secondaryChannelOffset = limGetHTCBState(ncbMode);
5422 frm.ExtChanSwitchAnn.present = 1;
5423 frm.WiderBWChanSwitchAnn.newChanWidth = nChanWidth;
5424 frm.WiderBWChanSwitchAnn.newCenterChanFreq0 = limGetCenterChannel(pMac,nNewChannel,ncbMode,nChanWidth);
5425 frm.WiderBWChanSwitchAnn.newCenterChanFreq1 = 0;
5426 frm.ChanSwitchAnn.present = 1;
5427 frm.WiderBWChanSwitchAnn.present = 1;
5428
5429 nStatus = dot11fGetPackedChannelSwitchSize( pMac, &frm, &nPayload );
5430 if ( DOT11F_FAILED( nStatus ) )
5431 {
5432 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005433 "or a Channel Switch (0x%08x)."),
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005434 nStatus );
5435 // We'll fall back on the worst case scenario:
5436 nPayload = sizeof( tDot11fChannelSwitch );
5437 }
5438 else if ( DOT11F_WARNED( nStatus ) )
5439 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005440 limLog( pMac, LOGW, FL("There were warnings while calculating "
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005441 "the packed size for a Channel Switch (0x"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005442 "%08x)."), nStatus );
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005443 }
5444
5445 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
5446
5447 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
5448 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
5449 {
5450 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a TPC"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005451 " Report."), nBytes );
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005452 return eSIR_FAILURE;
5453 }
5454 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305455 vos_mem_set( pFrame, nBytes, 0 );
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005456
5457 // Next, we fill out the buffer descriptor:
5458 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
5459 SIR_MAC_MGMT_ACTION, peer, psessionEntry->selfMacAddr);
5460 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305461 vos_mem_copy( (tANI_U8 *) pMacHdr->bssId,
5462 (tANI_U8 *) psessionEntry->bssId,
5463 sizeof( tSirMacAddr ));
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005464 if ( eSIR_SUCCESS != nSirStatus )
5465 {
5466 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005467 "tor for a Channel Switch (%d)."),
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005468 nSirStatus );
5469 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
5470 return eSIR_FAILURE; // just allocated...
5471 }
5472 nStatus = dot11fPackChannelSwitch( pMac, &frm, pFrame +
5473 sizeof(tSirMacMgmtHdr),
5474 nPayload, &nPayload );
5475 if ( DOT11F_FAILED( nStatus ) )
5476 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005477 limLog( pMac, LOGE, FL("Failed to pack a Channel Switch (0x%08x)."),
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005478 nStatus );
5479 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
5480 return eSIR_FAILURE; // allocated!
5481 }
5482 else if ( DOT11F_WARNED( nStatus ) )
5483 {
5484 limLog( pMac, LOGW, FL("There were warnings while packing a C"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005485 "hannel Switch (0x%08x)."), nStatus );
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005486 }
5487
5488 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005489 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
5490 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005491 )
5492 {
5493 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
5494 }
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05305495
5496 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
5497 psessionEntry->peSessionId,
5498 pMacHdr->fc.subType));
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005499 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
5500 HAL_TXRX_FRM_802_11_MGMT,
5501 ANI_TXDIR_TODS,
5502 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
5503 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05305504 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
5505 psessionEntry->peSessionId,
5506 halstatus));
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005507 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
5508 {
5509 limLog( pMac, LOGE, FL("Failed to send a Channel Switch "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005510 "(%X)!"),
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005511 nSirStatus );
5512 //Pkt will be freed up by the callback
5513 return eSIR_FAILURE;
5514 }
5515
5516 return eSIR_SUCCESS;
5517
5518} // End limSendVHTChannelSwitchMgmtFrame.
5519
5520
5521
Mohit Khanna4a70d262012-09-11 16:30:12 -07005522#endif
5523
Jeff Johnson295189b2012-06-20 16:38:30 -07005524/**
5525 * \brief Send an ADDBA Req Action Frame to peer
5526 *
5527 * \sa limSendAddBAReq
5528 *
5529 * \param pMac The global tpAniSirGlobal object
5530 *
5531 * \param pMlmAddBAReq A pointer to tLimMlmAddBAReq. This contains
5532 * the necessary parameters reqd by PE send the ADDBA Req Action
5533 * Frame to the peer
5534 *
5535 * \return eSIR_SUCCESS if setup completes successfully
5536 * eSIR_FAILURE is some problem is encountered
5537 */
5538tSirRetStatus limSendAddBAReq( tpAniSirGlobal pMac,
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305539 tpLimMlmAddBAReq pMlmAddBAReq, tpPESession psessionEntry)
Jeff Johnson295189b2012-06-20 16:38:30 -07005540{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05305541 tDot11fAddBAReq frmAddBAReq;
5542 tANI_U8 *pAddBAReqBuffer = NULL;
5543 tpSirMacMgmtHdr pMacHdr;
5544 tANI_U32 frameLen = 0, nStatus, nPayload;
5545 tSirRetStatus statusCode;
5546 eHalStatus halStatus;
5547 void *pPacket;
5548 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005549
5550 if(NULL == psessionEntry)
5551 {
5552 return eSIR_FAILURE;
5553 }
5554
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305555 vos_mem_set( (void *) &frmAddBAReq, sizeof( frmAddBAReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005556
5557 // Category - 3 (BA)
5558 frmAddBAReq.Category.category = SIR_MAC_ACTION_BLKACK;
5559
5560 // Action - 0 (ADDBA Req)
5561 frmAddBAReq.Action.action = SIR_MAC_BLKACK_ADD_REQ;
5562
5563 // FIXME - Dialog Token, generalize this...
5564 frmAddBAReq.DialogToken.token = pMlmAddBAReq->baDialogToken;
5565
5566 // Fill the ADDBA Parameter Set
5567 frmAddBAReq.AddBAParameterSet.tid = pMlmAddBAReq->baTID;
5568 frmAddBAReq.AddBAParameterSet.policy = pMlmAddBAReq->baPolicy;
5569 frmAddBAReq.AddBAParameterSet.bufferSize = pMlmAddBAReq->baBufferSize;
5570
5571 // BA timeout
5572 // 0 - indicates no BA timeout
5573 frmAddBAReq.BATimeout.timeout = pMlmAddBAReq->baTimeout;
5574
Abhishek Singh1f6e6532014-06-05 17:35:08 +05305575 /* Send SSN whatever we get from FW.
5576 */
5577 frmAddBAReq.BAStartingSequenceControl.ssn = pMlmAddBAReq->baSSN;
Jeff Johnson295189b2012-06-20 16:38:30 -07005578
5579 nStatus = dot11fGetPackedAddBAReqSize( pMac, &frmAddBAReq, &nPayload );
5580
5581 if( DOT11F_FAILED( nStatus ))
5582 {
5583 limLog( pMac, LOGW,
5584 FL( "Failed to calculate the packed size for "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005585 "an ADDBA Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005586 nStatus );
5587
5588 // We'll fall back on the worst case scenario:
5589 nPayload = sizeof( tDot11fAddBAReq );
5590 }
5591 else if( DOT11F_WARNED( nStatus ))
5592 {
5593 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005594 FL( "There were warnings while calculating "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005595 "the packed size for an ADDBA Req (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005596 nStatus );
5597 }
5598
5599 // Add the MGMT header to frame length
5600 frameLen = nPayload + sizeof( tSirMacMgmtHdr );
5601
5602 // Need to allocate a buffer for ADDBA AF
5603 if( eHAL_STATUS_SUCCESS !=
5604 (halStatus = palPktAlloc( pMac->hHdd,
5605 HAL_TXRX_FRM_802_11_MGMT,
5606 (tANI_U16) frameLen,
5607 (void **) &pAddBAReqBuffer,
5608 (void **) &pPacket )))
5609 {
5610 // Log error
5611 limLog( pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005612 FL("palPktAlloc FAILED! Length [%d], Status [%d]"),
Jeff Johnson295189b2012-06-20 16:38:30 -07005613 frameLen,
5614 halStatus );
5615
5616 statusCode = eSIR_MEM_ALLOC_FAILED;
5617 goto returnAfterError;
5618 }
5619
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305620 vos_mem_set( (void *) pAddBAReqBuffer, frameLen, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005621
5622 // Copy necessary info to BD
5623 if( eSIR_SUCCESS !=
5624 (statusCode = limPopulateMacHeader( pMac,
5625 pAddBAReqBuffer,
5626 SIR_MAC_MGMT_FRAME,
5627 SIR_MAC_MGMT_ACTION,
5628 pMlmAddBAReq->peerMacAddr,psessionEntry->selfMacAddr)))
5629 goto returnAfterError;
5630
5631 // Update A3 with the BSSID
5632 pMacHdr = ( tpSirMacMgmtHdr ) pAddBAReqBuffer;
5633
5634 #if 0
5635 cfgLen = SIR_MAC_ADDR_LENGTH;
5636 if( eSIR_SUCCESS != cfgGetStr( pMac,
5637 WNI_CFG_BSSID,
5638 (tANI_U8 *) pMacHdr->bssId,
5639 &cfgLen ))
5640 {
5641 limLog( pMac, LOGP,
5642 FL( "Failed to retrieve WNI_CFG_BSSID while"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005643 "sending an ACTION Frame" ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005644
5645 // FIXME - Need to convert to tSirRetStatus
5646 statusCode = eSIR_FAILURE;
5647 goto returnAfterError;
5648 }
5649 #endif//TO SUPPORT BT-AMP
5650 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
5651
Chet Lanctot186b5732013-03-18 10:26:30 -07005652#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07005653 limSetProtectedBit(pMac, psessionEntry, pMlmAddBAReq->peerMacAddr, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07005654#endif
5655
Jeff Johnson295189b2012-06-20 16:38:30 -07005656 // Now, we're ready to "pack" the frames
5657 nStatus = dot11fPackAddBAReq( pMac,
5658 &frmAddBAReq,
5659 pAddBAReqBuffer + sizeof( tSirMacMgmtHdr ),
5660 nPayload,
5661 &nPayload );
5662
5663 if( DOT11F_FAILED( nStatus ))
5664 {
5665 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005666 FL( "Failed to pack an ADDBA Req (0x%08x)." ),
Jeff Johnson295189b2012-06-20 16:38:30 -07005667 nStatus );
5668
5669 // FIXME - Need to convert to tSirRetStatus
5670 statusCode = eSIR_FAILURE;
5671 goto returnAfterError;
5672 }
5673 else if( DOT11F_WARNED( nStatus ))
5674 {
5675 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005676 FL( "There were warnings while packing an ADDBA Req (0x%08x)."),
5677 nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07005678 }
5679
Abhishek Singh02d9f6c2014-05-12 14:07:53 +05305680 limLog( pMac, LOG1, FL( "Sending an ADDBA REQ to "MAC_ADDRESS_STR " with"
5681 " tid = %d policy = %d buffsize = %d "
5682 " amsduSupported = %d"),
5683 MAC_ADDR_ARRAY(pMlmAddBAReq->peerMacAddr),
5684 frmAddBAReq.AddBAParameterSet.tid,
5685 frmAddBAReq.AddBAParameterSet.policy,
5686 frmAddBAReq.AddBAParameterSet.bufferSize,
5687 frmAddBAReq.AddBAParameterSet.amsduSupported);
Jeff Johnson295189b2012-06-20 16:38:30 -07005688
Abhishek Singh1f6e6532014-06-05 17:35:08 +05305689 limLog( pMac, LOG1, FL( "ssn = %d fragNum = %d" ),
5690 frmAddBAReq.BAStartingSequenceControl.ssn,
5691 frmAddBAReq.BAStartingSequenceControl.fragNumber);
5692
Jeff Johnson295189b2012-06-20 16:38:30 -07005693 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07005694 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
5695 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07005696 )
5697 {
5698 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
5699 }
5700
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05305701 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
5702 psessionEntry->peSessionId,
5703 pMacHdr->fc.subType));
5704 halStatus = halTxFrame( pMac,
5705 pPacket,
5706 (tANI_U16) frameLen,
5707 HAL_TXRX_FRM_802_11_MGMT,
5708 ANI_TXDIR_TODS,
5709 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
5710 limTxComplete,
5711 pAddBAReqBuffer, txFlag );
5712 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
5713 psessionEntry->peSessionId,
5714 halStatus));
5715 if( eHAL_STATUS_SUCCESS != halStatus )
Jeff Johnson295189b2012-06-20 16:38:30 -07005716 {
5717 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005718 FL( "halTxFrame FAILED! Status [%d]"),
Jeff Johnson295189b2012-06-20 16:38:30 -07005719 halStatus );
5720
5721 // FIXME - Need to convert eHalStatus to tSirRetStatus
5722 statusCode = eSIR_FAILURE;
5723 //Pkt will be freed up by the callback
5724 return statusCode;
5725 }
5726 else
5727 return eSIR_SUCCESS;
5728
5729returnAfterError:
5730
5731 // Release buffer, if allocated
5732 if( NULL != pAddBAReqBuffer )
5733 palPktFree( pMac->hHdd,
5734 HAL_TXRX_FRM_802_11_MGMT,
5735 (void *) pAddBAReqBuffer,
5736 (void *) pPacket );
5737
5738 return statusCode;
5739}
5740
5741/**
5742 * \brief Send an ADDBA Rsp Action Frame to peer
5743 *
5744 * \sa limSendAddBARsp
5745 *
5746 * \param pMac The global tpAniSirGlobal object
5747 *
5748 * \param pMlmAddBARsp A pointer to tLimMlmAddBARsp. This contains
5749 * the necessary parameters reqd by PE send the ADDBA Rsp Action
5750 * Frame to the peer
5751 *
5752 * \return eSIR_SUCCESS if setup completes successfully
5753 * eSIR_FAILURE is some problem is encountered
5754 */
5755tSirRetStatus limSendAddBARsp( tpAniSirGlobal pMac,
5756 tpLimMlmAddBARsp pMlmAddBARsp,
5757 tpPESession psessionEntry)
5758{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05305759 tDot11fAddBARsp frmAddBARsp;
5760 tANI_U8 *pAddBARspBuffer = NULL;
5761 tpSirMacMgmtHdr pMacHdr;
5762 tANI_U32 frameLen = 0, nStatus, nPayload;
5763 tSirRetStatus statusCode;
5764 eHalStatus halStatus;
5765 void *pPacket;
5766 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005767
5768 if(NULL == psessionEntry)
5769 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005770 PELOGE(limLog(pMac, LOGE, FL("Session entry is NULL!!!"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07005771 return eSIR_FAILURE;
5772 }
5773
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305774 vos_mem_set( (void *) &frmAddBARsp, sizeof( frmAddBARsp ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005775
5776 // Category - 3 (BA)
5777 frmAddBARsp.Category.category = SIR_MAC_ACTION_BLKACK;
5778 // Action - 1 (ADDBA Rsp)
5779 frmAddBARsp.Action.action = SIR_MAC_BLKACK_ADD_RSP;
5780
5781 // Should be same as the one we received in the ADDBA Req
5782 frmAddBARsp.DialogToken.token = pMlmAddBARsp->baDialogToken;
5783
5784 // ADDBA Req status
5785 frmAddBARsp.Status.status = pMlmAddBARsp->addBAResultCode;
5786
5787 // Fill the ADDBA Parameter Set as provided by caller
5788 frmAddBARsp.AddBAParameterSet.tid = pMlmAddBARsp->baTID;
5789 frmAddBARsp.AddBAParameterSet.policy = pMlmAddBARsp->baPolicy;
5790 frmAddBARsp.AddBAParameterSet.bufferSize = pMlmAddBARsp->baBufferSize;
krunal soni5afa96c2013-09-06 22:19:02 -07005791
5792 if(psessionEntry->isAmsduSupportInAMPDU)
5793 {
5794 frmAddBARsp.AddBAParameterSet.amsduSupported =
5795 psessionEntry->amsduSupportedInBA;
5796 }
5797 else
5798 {
5799 frmAddBARsp.AddBAParameterSet.amsduSupported = 0;
5800 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005801
5802 // BA timeout
5803 // 0 - indicates no BA timeout
5804 frmAddBARsp.BATimeout.timeout = pMlmAddBARsp->baTimeout;
5805
5806 nStatus = dot11fGetPackedAddBARspSize( pMac, &frmAddBARsp, &nPayload );
5807
5808 if( DOT11F_FAILED( nStatus ))
5809 {
5810 limLog( pMac, LOGW,
5811 FL( "Failed to calculate the packed size for "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005812 "an ADDBA Response (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005813 nStatus );
5814
5815 // We'll fall back on the worst case scenario:
5816 nPayload = sizeof( tDot11fAddBARsp );
5817 }
5818 else if( DOT11F_WARNED( nStatus ))
5819 {
5820 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005821 FL( "There were warnings while calculating "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005822 "the packed size for an ADDBA Rsp (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005823 nStatus );
5824 }
5825
5826 // Need to allocate a buffer for ADDBA AF
5827 frameLen = nPayload + sizeof( tSirMacMgmtHdr );
5828
5829 // Allocate shared memory
5830 if( eHAL_STATUS_SUCCESS !=
5831 (halStatus = palPktAlloc( pMac->hHdd,
5832 HAL_TXRX_FRM_802_11_MGMT,
5833 (tANI_U16) frameLen,
5834 (void **) &pAddBARspBuffer,
5835 (void **) &pPacket )))
5836 {
5837 // Log error
5838 limLog( pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005839 FL("palPktAlloc FAILED! Length [%d], Status [%d]"),
Jeff Johnson295189b2012-06-20 16:38:30 -07005840 frameLen,
5841 halStatus );
5842
5843 statusCode = eSIR_MEM_ALLOC_FAILED;
5844 goto returnAfterError;
5845 }
5846
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305847 vos_mem_set( (void *) pAddBARspBuffer, frameLen, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005848
5849 // Copy necessary info to BD
5850 if( eSIR_SUCCESS !=
5851 (statusCode = limPopulateMacHeader( pMac,
5852 pAddBARspBuffer,
5853 SIR_MAC_MGMT_FRAME,
5854 SIR_MAC_MGMT_ACTION,
5855 pMlmAddBARsp->peerMacAddr,psessionEntry->selfMacAddr)))
5856 goto returnAfterError;
5857
5858 // Update A3 with the BSSID
5859
5860 pMacHdr = ( tpSirMacMgmtHdr ) pAddBARspBuffer;
5861
5862 #if 0
5863 cfgLen = SIR_MAC_ADDR_LENGTH;
5864 if( eSIR_SUCCESS != wlan_cfgGetStr( pMac,
5865 WNI_CFG_BSSID,
5866 (tANI_U8 *) pMacHdr->bssId,
5867 &cfgLen ))
5868 {
5869 limLog( pMac, LOGP,
5870 FL( "Failed to retrieve WNI_CFG_BSSID while"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005871 "sending an ACTION Frame" ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005872
5873 // FIXME - Need to convert to tSirRetStatus
5874 statusCode = eSIR_FAILURE;
5875 goto returnAfterError;
5876 }
5877 #endif // TO SUPPORT BT-AMP
5878 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
5879
Chet Lanctot186b5732013-03-18 10:26:30 -07005880#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07005881 limSetProtectedBit(pMac, psessionEntry, pMlmAddBARsp->peerMacAddr, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07005882#endif
5883
Jeff Johnson295189b2012-06-20 16:38:30 -07005884 // Now, we're ready to "pack" the frames
5885 nStatus = dot11fPackAddBARsp( pMac,
5886 &frmAddBARsp,
5887 pAddBARspBuffer + sizeof( tSirMacMgmtHdr ),
5888 nPayload,
5889 &nPayload );
5890
5891 if( DOT11F_FAILED( nStatus ))
5892 {
5893 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005894 FL( "Failed to pack an ADDBA Rsp (0x%08x)." ),
Jeff Johnson295189b2012-06-20 16:38:30 -07005895 nStatus );
5896
5897 // FIXME - Need to convert to tSirRetStatus
5898 statusCode = eSIR_FAILURE;
5899 goto returnAfterError;
5900 }
5901 else if( DOT11F_WARNED( nStatus ))
5902 {
5903 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005904 FL( "There were warnings while packing an ADDBA Rsp (0x%08x)." ),
5905 nStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07005906 }
5907
Abhishek Singh02d9f6c2014-05-12 14:07:53 +05305908 limLog( pMac, LOG1, FL( "Sending an ADDBA RSP to "MAC_ADDRESS_STR " with"
5909 " tid = %d policy = %d buffsize = %d"
5910 " amsduSupported = %d status %d"),
5911 MAC_ADDR_ARRAY(pMlmAddBARsp->peerMacAddr),
5912 frmAddBARsp.AddBAParameterSet.tid,
5913 frmAddBARsp.AddBAParameterSet.policy,
5914 frmAddBARsp.AddBAParameterSet.bufferSize,
5915 frmAddBARsp.AddBAParameterSet.amsduSupported,
5916 frmAddBARsp.Status.status);
5917
Jeff Johnson295189b2012-06-20 16:38:30 -07005918
5919 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07005920 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
5921 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07005922 )
5923 {
5924 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
5925 }
5926
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05305927 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
5928 psessionEntry->peSessionId,
5929 pMacHdr->fc.subType));
5930 halStatus = halTxFrame( pMac,
5931 pPacket,
5932 (tANI_U16) frameLen,
5933 HAL_TXRX_FRM_802_11_MGMT,
5934 ANI_TXDIR_TODS,
5935 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
5936 limTxComplete,
5937 pAddBARspBuffer, txFlag );
5938 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
5939 psessionEntry->peSessionId,
5940 halStatus));
5941 if( eHAL_STATUS_SUCCESS != halStatus )
5942 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005943 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005944 FL( "halTxFrame FAILED! Status [%d]" ),
Jeff Johnson295189b2012-06-20 16:38:30 -07005945 halStatus );
5946
5947 // FIXME - HAL error codes are different from PE error
5948 // codes!! And, this routine is returning tSirRetStatus
5949 statusCode = eSIR_FAILURE;
5950 //Pkt will be freed up by the callback
5951 return statusCode;
5952 }
5953 else
5954 return eSIR_SUCCESS;
5955
5956 returnAfterError:
Jeff Johnson295189b2012-06-20 16:38:30 -07005957 // Release buffer, if allocated
5958 if( NULL != pAddBARspBuffer )
5959 palPktFree( pMac->hHdd,
5960 HAL_TXRX_FRM_802_11_MGMT,
5961 (void *) pAddBARspBuffer,
5962 (void *) pPacket );
5963
5964 return statusCode;
5965}
5966
5967/**
5968 * \brief Send a DELBA Indication Action Frame to peer
5969 *
5970 * \sa limSendDelBAInd
5971 *
5972 * \param pMac The global tpAniSirGlobal object
5973 *
5974 * \param peerMacAddr MAC Address of peer
5975 *
5976 * \param reasonCode Reason for the DELBA notification
5977 *
5978 * \param pBAParameterSet The DELBA Parameter Set.
5979 * This identifies the TID for which the BA session is
5980 * being deleted.
5981 *
5982 * \return eSIR_SUCCESS if setup completes successfully
5983 * eSIR_FAILURE is some problem is encountered
5984 */
5985tSirRetStatus limSendDelBAInd( tpAniSirGlobal pMac,
5986 tpLimMlmDelBAReq pMlmDelBAReq,tpPESession psessionEntry)
5987{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05305988 tDot11fDelBAInd frmDelBAInd;
5989 tANI_U8 *pDelBAIndBuffer = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005990 //tANI_U32 val;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05305991 tpSirMacMgmtHdr pMacHdr;
5992 tANI_U32 frameLen = 0, nStatus, nPayload;
5993 tSirRetStatus statusCode;
5994 eHalStatus halStatus;
5995 void *pPacket;
5996 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005997
5998 if(NULL == psessionEntry)
5999 {
6000 return eSIR_FAILURE;
6001 }
6002
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05306003 vos_mem_set( (void *) &frmDelBAInd, sizeof( frmDelBAInd ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07006004
6005 // Category - 3 (BA)
6006 frmDelBAInd.Category.category = SIR_MAC_ACTION_BLKACK;
6007 // Action - 2 (DELBA)
6008 frmDelBAInd.Action.action = SIR_MAC_BLKACK_DEL;
6009
6010 // Fill the DELBA Parameter Set as provided by caller
6011 frmDelBAInd.DelBAParameterSet.tid = pMlmDelBAReq->baTID;
6012 frmDelBAInd.DelBAParameterSet.initiator = pMlmDelBAReq->baDirection;
6013
6014 // BA Starting Sequence Number
6015 // Fragment number will always be zero
6016 frmDelBAInd.Reason.code = pMlmDelBAReq->delBAReasonCode;
6017
6018 nStatus = dot11fGetPackedDelBAIndSize( pMac, &frmDelBAInd, &nPayload );
6019
6020 if( DOT11F_FAILED( nStatus ))
6021 {
6022 limLog( pMac, LOGW,
6023 FL( "Failed to calculate the packed size for "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006024 "an DELBA Indication (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07006025 nStatus );
6026
6027 // We'll fall back on the worst case scenario:
6028 nPayload = sizeof( tDot11fDelBAInd );
6029 }
6030 else if( DOT11F_WARNED( nStatus ))
6031 {
6032 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08006033 FL( "There were warnings while calculating "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006034 "the packed size for an DELBA Ind (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07006035 nStatus );
6036 }
6037
6038 // Add the MGMT header to frame length
6039 frameLen = nPayload + sizeof( tSirMacMgmtHdr );
6040
6041 // Allocate shared memory
6042 if( eHAL_STATUS_SUCCESS !=
6043 (halStatus = palPktAlloc( pMac->hHdd,
6044 HAL_TXRX_FRM_802_11_MGMT,
6045 (tANI_U16) frameLen,
6046 (void **) &pDelBAIndBuffer,
6047 (void **) &pPacket )))
6048 {
6049 // Log error
6050 limLog( pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006051 FL("palPktAlloc FAILED! Length [%d], Status [%d]"),
Jeff Johnson295189b2012-06-20 16:38:30 -07006052 frameLen,
6053 halStatus );
6054
6055 statusCode = eSIR_MEM_ALLOC_FAILED;
6056 goto returnAfterError;
6057 }
6058
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05306059 vos_mem_set( (void *) pDelBAIndBuffer, frameLen, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07006060
6061 // Copy necessary info to BD
6062 if( eSIR_SUCCESS !=
6063 (statusCode = limPopulateMacHeader( pMac,
6064 pDelBAIndBuffer,
6065 SIR_MAC_MGMT_FRAME,
6066 SIR_MAC_MGMT_ACTION,
6067 pMlmDelBAReq->peerMacAddr,psessionEntry->selfMacAddr)))
6068 goto returnAfterError;
6069
6070 // Update A3 with the BSSID
6071 pMacHdr = ( tpSirMacMgmtHdr ) pDelBAIndBuffer;
6072
6073 #if 0
6074 cfgLen = SIR_MAC_ADDR_LENGTH;
6075 if( eSIR_SUCCESS != cfgGetStr( pMac,
6076 WNI_CFG_BSSID,
6077 (tANI_U8 *) pMacHdr->bssId,
6078 &cfgLen ))
6079 {
6080 limLog( pMac, LOGP,
6081 FL( "Failed to retrieve WNI_CFG_BSSID while"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006082 "sending an ACTION Frame" ));
Jeff Johnson295189b2012-06-20 16:38:30 -07006083
6084 // FIXME - Need to convert to tSirRetStatus
6085 statusCode = eSIR_FAILURE;
6086 goto returnAfterError;
6087 }
6088 #endif //TO SUPPORT BT-AMP
6089 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
6090
Chet Lanctot186b5732013-03-18 10:26:30 -07006091#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07006092 limSetProtectedBit(pMac, psessionEntry, pMlmDelBAReq->peerMacAddr, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07006093#endif
6094
Jeff Johnson295189b2012-06-20 16:38:30 -07006095 // Now, we're ready to "pack" the frames
6096 nStatus = dot11fPackDelBAInd( pMac,
6097 &frmDelBAInd,
6098 pDelBAIndBuffer + sizeof( tSirMacMgmtHdr ),
6099 nPayload,
6100 &nPayload );
6101
6102 if( DOT11F_FAILED( nStatus ))
6103 {
6104 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006105 FL( "Failed to pack an DELBA Ind (0x%08x)." ),
Jeff Johnson295189b2012-06-20 16:38:30 -07006106 nStatus );
6107
6108 // FIXME - Need to convert to tSirRetStatus
6109 statusCode = eSIR_FAILURE;
6110 goto returnAfterError;
6111 }
6112 else if( DOT11F_WARNED( nStatus ))
6113 {
6114 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08006115 FL( "There were warnings while packing an DELBA Ind (0x%08x)." ),
6116 nStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07006117 }
6118
Abhishek Singh1f6e6532014-06-05 17:35:08 +05306119 limLog( pMac, LOG1,
6120 FL( "Sending a DELBA IND to: "MAC_ADDRESS_STR" with Tid = %d"
6121 " initiator = %d reason = %d" ),
6122 MAC_ADDR_ARRAY(pMlmDelBAReq->peerMacAddr),
6123 frmDelBAInd.DelBAParameterSet.tid,
6124 frmDelBAInd.DelBAParameterSet.initiator,
6125 frmDelBAInd.Reason.code);
6126
Jeff Johnson295189b2012-06-20 16:38:30 -07006127
6128 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07006129 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
6130 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07006131 )
6132 {
6133 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
6134 }
6135
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05306136 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
6137 psessionEntry->peSessionId,
6138 pMacHdr->fc.subType));
6139 halStatus = halTxFrame( pMac,
6140 pPacket,
6141 (tANI_U16) frameLen,
6142 HAL_TXRX_FRM_802_11_MGMT,
6143 ANI_TXDIR_TODS,
6144 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
6145 limTxComplete,
6146 pDelBAIndBuffer, txFlag );
6147 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
6148 psessionEntry->peSessionId,
6149 halStatus));
6150 if( eHAL_STATUS_SUCCESS != halStatus )
Jeff Johnson295189b2012-06-20 16:38:30 -07006151 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006152 PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]" ), halStatus );)
Jeff Johnson295189b2012-06-20 16:38:30 -07006153 statusCode = eSIR_FAILURE;
6154 //Pkt will be freed up by the callback
6155 return statusCode;
6156 }
6157 else
6158 return eSIR_SUCCESS;
6159
6160 returnAfterError:
6161
6162 // Release buffer, if allocated
6163 if( NULL != pDelBAIndBuffer )
6164 palPktFree( pMac->hHdd,
6165 HAL_TXRX_FRM_802_11_MGMT,
6166 (void *) pDelBAIndBuffer,
6167 (void *) pPacket );
6168
6169 return statusCode;
6170}
6171
6172#if defined WLAN_FEATURE_VOWIFI
6173
6174/**
6175 * \brief Send a Neighbor Report Request Action frame
6176 *
6177 *
6178 * \param pMac Pointer to the global MAC structure
6179 *
6180 * \param pNeighborReq Address of a tSirMacNeighborReportReq
6181 *
6182 * \param peer mac address of peer station.
6183 *
6184 * \param psessionEntry address of session entry.
6185 *
6186 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
6187 *
6188 *
6189 */
6190
6191tSirRetStatus
6192limSendNeighborReportRequestFrame(tpAniSirGlobal pMac,
6193 tpSirMacNeighborReportReq pNeighborReq,
6194 tSirMacAddr peer,
6195 tpPESession psessionEntry
6196 )
6197{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05306198 tSirRetStatus statusCode = eSIR_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006199 tDot11fNeighborReportRequest frm;
6200 tANI_U8 *pFrame;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05306201 tpSirMacMgmtHdr pMacHdr;
6202 tANI_U32 nBytes, nPayload, nStatus;
6203 void *pPacket;
6204 eHalStatus halstatus;
6205 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07006206
6207 if ( psessionEntry == NULL )
6208 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006209 limLog( pMac, LOGE, FL("(psession == NULL) in Request to send Neighbor Report request action frame") );
Jeff Johnson295189b2012-06-20 16:38:30 -07006210 return eSIR_FAILURE;
6211 }
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05306212 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07006213
6214 frm.Category.category = SIR_MAC_ACTION_RRM;
6215 frm.Action.action = SIR_MAC_RRM_NEIGHBOR_REQ;
6216 frm.DialogToken.token = pNeighborReq->dialogToken;
6217
6218
6219 if( pNeighborReq->ssid_present )
6220 {
6221 PopulateDot11fSSID( pMac, &pNeighborReq->ssid, &frm.SSID );
6222 }
6223
6224 nStatus = dot11fGetPackedNeighborReportRequestSize( pMac, &frm, &nPayload );
6225 if ( DOT11F_FAILED( nStatus ) )
6226 {
6227 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006228 "or a Neighbor Report Request(0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07006229 nStatus );
6230 // We'll fall back on the worst case scenario:
6231 nPayload = sizeof( tDot11fNeighborReportRequest );
6232 }
6233 else if ( DOT11F_WARNED( nStatus ) )
6234 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08006235 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07006236 "the packed size for a Neighbor Rep"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006237 "ort Request(0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07006238 }
6239
6240 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
6241
6242 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
6243 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
6244 {
6245 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Neighbor "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006246 "Report Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07006247 return eSIR_FAILURE;
6248 }
6249
6250 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05306251 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07006252
6253 // Copy necessary info to BD
6254 if( eSIR_SUCCESS !=
6255 (statusCode = limPopulateMacHeader( pMac,
6256 pFrame,
6257 SIR_MAC_MGMT_FRAME,
6258 SIR_MAC_MGMT_ACTION,
6259 peer, psessionEntry->selfMacAddr)))
6260 goto returnAfterError;
6261
6262 // Update A3 with the BSSID
6263 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
6264
6265 sirCopyMacAddr( pMacHdr->bssId, psessionEntry->bssId );
6266
Chet Lanctot186b5732013-03-18 10:26:30 -07006267#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07006268 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07006269#endif
6270
Jeff Johnson295189b2012-06-20 16:38:30 -07006271 // Now, we're ready to "pack" the frames
6272 nStatus = dot11fPackNeighborReportRequest( pMac,
6273 &frm,
6274 pFrame + sizeof( tSirMacMgmtHdr ),
6275 nPayload,
6276 &nPayload );
6277
6278 if( DOT11F_FAILED( nStatus ))
6279 {
6280 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006281 FL( "Failed to pack an Neighbor Report Request (0x%08x)." ),
Jeff Johnson295189b2012-06-20 16:38:30 -07006282 nStatus );
6283
6284 // FIXME - Need to convert to tSirRetStatus
6285 statusCode = eSIR_FAILURE;
6286 goto returnAfterError;
6287 }
6288 else if( DOT11F_WARNED( nStatus ))
6289 {
6290 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08006291 FL( "There were warnings while packing Neighbor Report "
6292 "Request (0x%08x)." ), nStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07006293 }
6294
6295 limLog( pMac, LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006296 FL( "Sending a Neighbor Report Request to " ));
Jeff Johnson295189b2012-06-20 16:38:30 -07006297 limPrintMacAddr( pMac, peer, LOGW );
6298
6299 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07006300 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
6301 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07006302 )
6303 {
6304 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
6305 }
6306
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05306307 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
6308 psessionEntry->peSessionId,
6309 pMacHdr->fc.subType));
6310 halstatus = halTxFrame( pMac,
6311 pPacket,
6312 (tANI_U16) nBytes,
6313 HAL_TXRX_FRM_802_11_MGMT,
6314 ANI_TXDIR_TODS,
6315 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
6316 limTxComplete,
6317 pFrame, txFlag );
6318 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
6319 psessionEntry->peSessionId,
6320 halstatus));
6321 if( eHAL_STATUS_SUCCESS != halstatus )
Jeff Johnson295189b2012-06-20 16:38:30 -07006322 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006323 PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]" ), halstatus );)
Jeff Johnson295189b2012-06-20 16:38:30 -07006324 statusCode = eSIR_FAILURE;
6325 //Pkt will be freed up by the callback
6326 return statusCode;
6327 }
6328 else
6329 return eSIR_SUCCESS;
6330
6331returnAfterError:
6332 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
6333
6334 return statusCode;
6335} // End limSendNeighborReportRequestFrame.
6336
6337/**
6338 * \brief Send a Link Report Action frame
6339 *
6340 *
6341 * \param pMac Pointer to the global MAC structure
6342 *
6343 * \param pLinkReport Address of a tSirMacLinkReport
6344 *
6345 * \param peer mac address of peer station.
6346 *
6347 * \param psessionEntry address of session entry.
6348 *
6349 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
6350 *
6351 *
6352 */
6353
6354tSirRetStatus
6355limSendLinkReportActionFrame(tpAniSirGlobal pMac,
6356 tpSirMacLinkReport pLinkReport,
6357 tSirMacAddr peer,
6358 tpPESession psessionEntry
6359 )
6360{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05306361 tSirRetStatus statusCode = eSIR_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006362 tDot11fLinkMeasurementReport frm;
6363 tANI_U8 *pFrame;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05306364 tpSirMacMgmtHdr pMacHdr;
6365 tANI_U32 nBytes, nPayload, nStatus;
6366 void *pPacket;
6367 eHalStatus halstatus;
6368 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07006369
6370
6371 if ( psessionEntry == NULL )
6372 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006373 limLog( pMac, LOGE, FL("(psession == NULL) in Request to send Link Report action frame") );
Jeff Johnson295189b2012-06-20 16:38:30 -07006374 return eSIR_FAILURE;
6375 }
6376
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05306377 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07006378
6379 frm.Category.category = SIR_MAC_ACTION_RRM;
6380 frm.Action.action = SIR_MAC_RRM_LINK_MEASUREMENT_RPT;
6381 frm.DialogToken.token = pLinkReport->dialogToken;
6382
6383
6384 //IEEE Std. 802.11 7.3.2.18. for the report element.
6385 //Even though TPC report an IE, it is represented using fixed fields since it is positioned
6386 //in the middle of other fixed fields in the link report frame(IEEE Std. 802.11k section7.4.6.4
6387 //and frame parser always expects IEs to come after all fixed fields. It is easier to handle
6388 //such case this way than changing the frame parser.
6389 frm.TPCEleID.TPCId = SIR_MAC_TPC_RPT_EID;
6390 frm.TPCEleLen.TPCLen = 2;
6391 frm.TxPower.txPower = pLinkReport->txPower;
6392 frm.LinkMargin.linkMargin = 0;
6393
6394 frm.RxAntennaId.antennaId = pLinkReport->rxAntenna;
6395 frm.TxAntennaId.antennaId = pLinkReport->txAntenna;
6396 frm.RCPI.rcpi = pLinkReport->rcpi;
6397 frm.RSNI.rsni = pLinkReport->rsni;
6398
6399 nStatus = dot11fGetPackedLinkMeasurementReportSize( pMac, &frm, &nPayload );
6400 if ( DOT11F_FAILED( nStatus ) )
6401 {
6402 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006403 "or a Link Report (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07006404 nStatus );
6405 // We'll fall back on the worst case scenario:
6406 nPayload = sizeof( tDot11fLinkMeasurementReport );
6407 }
6408 else if ( DOT11F_WARNED( nStatus ) )
6409 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08006410 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07006411 "the packed size for a Link Rep"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006412 "ort (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07006413 }
6414
6415 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
6416
6417 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
6418 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
6419 {
6420 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Link "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006421 "Report."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07006422 return eSIR_FAILURE;
6423 }
6424
6425 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05306426 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07006427
6428 // Copy necessary info to BD
6429 if( eSIR_SUCCESS !=
6430 (statusCode = limPopulateMacHeader( pMac,
6431 pFrame,
6432 SIR_MAC_MGMT_FRAME,
6433 SIR_MAC_MGMT_ACTION,
6434 peer, psessionEntry->selfMacAddr)))
6435 goto returnAfterError;
6436
6437 // Update A3 with the BSSID
6438 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
6439
6440 sirCopyMacAddr( pMacHdr->bssId, psessionEntry->bssId );
6441
Chet Lanctot186b5732013-03-18 10:26:30 -07006442#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07006443 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07006444#endif
6445
Jeff Johnson295189b2012-06-20 16:38:30 -07006446 // Now, we're ready to "pack" the frames
6447 nStatus = dot11fPackLinkMeasurementReport( pMac,
6448 &frm,
6449 pFrame + sizeof( tSirMacMgmtHdr ),
6450 nPayload,
6451 &nPayload );
6452
6453 if( DOT11F_FAILED( nStatus ))
6454 {
6455 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006456 FL( "Failed to pack an Link Report (0x%08x)." ),
Jeff Johnson295189b2012-06-20 16:38:30 -07006457 nStatus );
6458
6459 // FIXME - Need to convert to tSirRetStatus
6460 statusCode = eSIR_FAILURE;
6461 goto returnAfterError;
6462 }
6463 else if( DOT11F_WARNED( nStatus ))
6464 {
6465 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08006466 FL( "There were warnings while packing Link Report (0x%08x)." ),
6467 nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07006468 }
6469
6470 limLog( pMac, LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006471 FL( "Sending a Link Report to " ));
Jeff Johnson295189b2012-06-20 16:38:30 -07006472 limPrintMacAddr( pMac, peer, LOGW );
6473
6474 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07006475 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
6476 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07006477 )
6478 {
6479 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
6480 }
6481
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05306482 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
6483 psessionEntry->peSessionId,
6484 pMacHdr->fc.subType));
6485 halstatus = halTxFrame( pMac,
6486 pPacket,
6487 (tANI_U16) nBytes,
6488 HAL_TXRX_FRM_802_11_MGMT,
6489 ANI_TXDIR_TODS,
6490 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
6491 limTxComplete,
6492 pFrame, txFlag );
6493 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
6494 psessionEntry->peSessionId,
6495 halstatus));
6496 if( eHAL_STATUS_SUCCESS != halstatus )
Jeff Johnson295189b2012-06-20 16:38:30 -07006497 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006498 PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]" ), halstatus );)
Jeff Johnson295189b2012-06-20 16:38:30 -07006499 statusCode = eSIR_FAILURE;
6500 //Pkt will be freed up by the callback
6501 return statusCode;
6502 }
6503 else
6504 return eSIR_SUCCESS;
6505
6506returnAfterError:
6507 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
6508
6509 return statusCode;
6510} // End limSendLinkReportActionFrame.
6511
6512/**
6513 * \brief Send a Beacon Report Action frame
6514 *
6515 *
6516 * \param pMac Pointer to the global MAC structure
6517 *
6518 * \param dialog_token dialog token to be used in the action frame.
6519 *
6520 * \param num_report number of reports in pRRMReport.
6521 *
6522 * \param pRRMReport Address of a tSirMacRadioMeasureReport.
6523 *
6524 * \param peer mac address of peer station.
6525 *
6526 * \param psessionEntry address of session entry.
6527 *
6528 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
6529 *
6530 *
6531 */
6532
6533tSirRetStatus
6534limSendRadioMeasureReportActionFrame(tpAniSirGlobal pMac,
6535 tANI_U8 dialog_token,
6536 tANI_U8 num_report,
6537 tpSirMacRadioMeasureReport pRRMReport,
6538 tSirMacAddr peer,
6539 tpPESession psessionEntry
6540 )
6541{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05306542 tSirRetStatus statusCode = eSIR_SUCCESS;
6543 tANI_U8 *pFrame;
6544 tpSirMacMgmtHdr pMacHdr;
6545 tANI_U32 nBytes, nPayload, nStatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07006546 void *pPacket;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05306547 eHalStatus halstatus;
6548 tANI_U8 i;
6549 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07006550
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006551 tDot11fRadioMeasurementReport *frm =
6552 vos_mem_malloc(sizeof(tDot11fRadioMeasurementReport));
6553 if (!frm) {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006554 limLog( pMac, LOGE, FL("Not enough memory to allocate tDot11fRadioMeasurementReport") );
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006555 return eSIR_FAILURE;
6556 }
6557
Jeff Johnson295189b2012-06-20 16:38:30 -07006558 if ( psessionEntry == NULL )
6559 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006560 limLog( pMac, LOGE, FL("(psession == NULL) in Request to send Beacon Report action frame") );
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006561 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07006562 return eSIR_FAILURE;
6563 }
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05306564 vos_mem_set( ( tANI_U8* )frm, sizeof( *frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07006565
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006566 frm->Category.category = SIR_MAC_ACTION_RRM;
6567 frm->Action.action = SIR_MAC_RRM_RADIO_MEASURE_RPT;
6568 frm->DialogToken.token = dialog_token;
Jeff Johnson295189b2012-06-20 16:38:30 -07006569
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006570 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 -07006571
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006572 for( i = 0 ; i < frm->num_MeasurementReport ; i++ )
Jeff Johnson295189b2012-06-20 16:38:30 -07006573 {
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006574 frm->MeasurementReport[i].type = pRRMReport[i].type;
6575 frm->MeasurementReport[i].token = pRRMReport[i].token;
6576 frm->MeasurementReport[i].late = 0; //IEEE 802.11k section 7.3.22. (always zero in rrm)
Jeff Johnson295189b2012-06-20 16:38:30 -07006577 switch( pRRMReport[i].type )
6578 {
6579 case SIR_MAC_RRM_BEACON_TYPE:
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006580 PopulateDot11fBeaconReport( pMac, &frm->MeasurementReport[i], &pRRMReport[i].report.beaconReport );
6581 frm->MeasurementReport[i].incapable = pRRMReport[i].incapable;
6582 frm->MeasurementReport[i].refused = pRRMReport[i].refused;
6583 frm->MeasurementReport[i].present = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07006584 break;
6585 default:
Gopichand Nakkala72717fd2013-02-08 12:23:45 +05306586 frm->MeasurementReport[i].incapable = pRRMReport[i].incapable;
6587 frm->MeasurementReport[i].refused = pRRMReport[i].refused;
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006588 frm->MeasurementReport[i].present = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07006589 break;
6590 }
6591 }
6592
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006593 nStatus = dot11fGetPackedRadioMeasurementReportSize( pMac, frm, &nPayload );
Jeff Johnson295189b2012-06-20 16:38:30 -07006594 if ( DOT11F_FAILED( nStatus ) )
6595 {
6596 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006597 "or a Radio Measure Report (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07006598 nStatus );
6599 // We'll fall back on the worst case scenario:
6600 nPayload = sizeof( tDot11fLinkMeasurementReport );
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006601 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07006602 return eSIR_FAILURE;
6603 }
6604 else if ( DOT11F_WARNED( nStatus ) )
6605 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08006606 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07006607 "the packed size for a Radio Measure Rep"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006608 "ort (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07006609 }
6610
6611 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
6612
6613 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
6614 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
6615 {
6616 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Radio Measure "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006617 "Report."), nBytes );
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006618 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07006619 return eSIR_FAILURE;
6620 }
6621
6622 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05306623 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07006624
6625 // Copy necessary info to BD
6626 if( eSIR_SUCCESS !=
6627 (statusCode = limPopulateMacHeader( pMac,
6628 pFrame,
6629 SIR_MAC_MGMT_FRAME,
6630 SIR_MAC_MGMT_ACTION,
6631 peer, psessionEntry->selfMacAddr)))
6632 goto returnAfterError;
6633
6634 // Update A3 with the BSSID
6635 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
6636
6637 sirCopyMacAddr( pMacHdr->bssId, psessionEntry->bssId );
6638
Chet Lanctot186b5732013-03-18 10:26:30 -07006639#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07006640 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07006641#endif
6642
Jeff Johnson295189b2012-06-20 16:38:30 -07006643 // Now, we're ready to "pack" the frames
6644 nStatus = dot11fPackRadioMeasurementReport( pMac,
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006645 frm,
Jeff Johnson295189b2012-06-20 16:38:30 -07006646 pFrame + sizeof( tSirMacMgmtHdr ),
6647 nPayload,
6648 &nPayload );
6649
6650 if( DOT11F_FAILED( nStatus ))
6651 {
6652 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006653 FL( "Failed to pack an Radio Measure Report (0x%08x)." ),
Jeff Johnson295189b2012-06-20 16:38:30 -07006654 nStatus );
6655
6656 // FIXME - Need to convert to tSirRetStatus
6657 statusCode = eSIR_FAILURE;
6658 goto returnAfterError;
6659 }
6660 else if( DOT11F_WARNED( nStatus ))
6661 {
6662 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08006663 FL( "There were warnings while packing Radio "
6664 "Measure Report (0x%08x)." ), nStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07006665 }
6666
6667 limLog( pMac, LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006668 FL( "Sending a Radio Measure Report to " ));
Jeff Johnson295189b2012-06-20 16:38:30 -07006669 limPrintMacAddr( pMac, peer, LOGW );
6670
6671 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07006672 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
6673 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07006674 )
6675 {
6676 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
6677 }
6678
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05306679 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
6680 psessionEntry->peSessionId,
6681 pMacHdr->fc.subType));
6682 halstatus = halTxFrame( pMac,
6683 pPacket,
6684 (tANI_U16) nBytes,
6685 HAL_TXRX_FRM_802_11_MGMT,
6686 ANI_TXDIR_TODS,
6687 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
6688 limTxComplete,
6689 pFrame, txFlag );
6690 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
6691 psessionEntry->peSessionId,
6692 halstatus));
6693 if( eHAL_STATUS_SUCCESS != halstatus )
Jeff Johnson295189b2012-06-20 16:38:30 -07006694 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006695 PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]" ), halstatus );)
Jeff Johnson295189b2012-06-20 16:38:30 -07006696 statusCode = eSIR_FAILURE;
6697 //Pkt will be freed up by the callback
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006698 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07006699 return statusCode;
6700 }
Madan Mohan Koyyalamudieeb56b12012-10-31 15:10:04 -07006701 else {
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006702 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07006703 return eSIR_SUCCESS;
Madan Mohan Koyyalamudieeb56b12012-10-31 15:10:04 -07006704 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006705
6706returnAfterError:
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006707 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07006708 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
Jeff Johnson295189b2012-06-20 16:38:30 -07006709 return statusCode;
6710} // End limSendBeaconReportActionFrame.
6711
6712#endif
6713
6714#ifdef WLAN_FEATURE_11W
6715/**
Chet Lanctot8cecea22014-02-11 19:09:36 -08006716 * \brief Send SA query request action frame to peer
6717 *
6718 * \sa limSendSaQueryRequestFrame
6719 *
6720 *
6721 * \param pMac The global tpAniSirGlobal object
6722 *
6723 * \param transId Transaction identifier
6724 *
6725 * \param peer The Mac address of the station to which this action frame is addressed
6726 *
6727 * \param psessionEntry The PE session entry
6728 *
6729 * \return eSIR_SUCCESS if setup completes successfully
6730 * eSIR_FAILURE is some problem is encountered
6731 */
6732
6733tSirRetStatus limSendSaQueryRequestFrame( tpAniSirGlobal pMac, tANI_U8 *transId,
6734 tSirMacAddr peer, tpPESession psessionEntry )
6735{
6736
6737 tDot11fSaQueryReq frm; // SA query request action frame
6738 tANI_U8 *pFrame;
6739 tSirRetStatus nSirStatus;
6740 tpSirMacMgmtHdr pMacHdr;
6741 tANI_U32 nBytes, nPayload, nStatus;
6742 void *pPacket;
6743 eHalStatus halstatus;
6744 tANI_U8 txFlag = 0;
6745
6746 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
6747 frm.Category.category = SIR_MAC_ACTION_SA_QUERY;
6748 /* 11w action field is :
6749 action: 0 --> SA Query Request action frame
6750 action: 1 --> SA Query Response action frame */
6751 frm.Action.action = SIR_MAC_SA_QUERY_REQ;
6752 /* 11w SA Query Request transId */
6753 vos_mem_copy( &frm.TransactionId.transId[0], &transId[0], 2 );
6754
6755 nStatus = dot11fGetPackedSaQueryReqSize(pMac, &frm, &nPayload);
6756 if ( DOT11F_FAILED( nStatus ) )
6757 {
6758 limLog( pMac, LOGP, FL("Failed to calculate the packed size "
6759 "for an SA Query Request (0x%08x)."),
6760 nStatus );
6761 // We'll fall back on the worst case scenario:
6762 nPayload = sizeof( tDot11fSaQueryReq );
6763 }
6764 else if ( DOT11F_WARNED( nStatus ) )
6765 {
6766 limLog( pMac, LOGW, FL("There were warnings while calculating "
6767 "the packed size for an SA Query Request"
6768 " (0x%08x)."), nStatus );
6769 }
6770
6771 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
6772 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
6773 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
6774 {
6775 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a SA Query Request "
6776 "action frame"), nBytes );
6777 return eSIR_FAILURE;
6778 }
6779
6780 // Paranoia:
6781 vos_mem_set( pFrame, nBytes, 0 );
6782
6783 // Copy necessary info to BD
6784 nSirStatus = limPopulateMacHeader( pMac,
6785 pFrame,
6786 SIR_MAC_MGMT_FRAME,
6787 SIR_MAC_MGMT_ACTION,
6788 peer, psessionEntry->selfMacAddr );
6789 if ( eSIR_SUCCESS != nSirStatus )
6790 goto returnAfterError;
6791
6792 // Update A3 with the BSSID
6793 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
6794
6795 sirCopyMacAddr( pMacHdr->bssId, psessionEntry->bssId );
6796
6797 // Since this is a SA Query Request, set the "protect" (aka WEP) bit
6798 // in the FC
6799 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
6800
6801 // Pack 11w SA Query Request frame
6802 nStatus = dot11fPackSaQueryReq( pMac,
6803 &frm,
6804 pFrame + sizeof( tSirMacMgmtHdr ),
6805 nPayload,
6806 &nPayload );
6807
6808 if ( DOT11F_FAILED( nStatus ))
6809 {
6810 limLog( pMac, LOGE,
6811 FL( "Failed to pack an SA Query Request (0x%08x)." ),
6812 nStatus );
6813 // FIXME - Need to convert to tSirRetStatus
6814 nSirStatus = eSIR_FAILURE;
6815 goto returnAfterError;
6816 }
6817 else if ( DOT11F_WARNED( nStatus ))
6818 {
6819 limLog( pMac, LOGW,
6820 FL( "There were warnings while packing SA Query Request (0x%08x)." ),
6821 nStatus);
6822 }
6823
6824 limLog( pMac, LOG1,
6825 FL( "Sending an SA Query Request to " ));
6826 limPrintMacAddr( pMac, peer, LOG1 );
6827 limPrintMacAddr( pMac, peer, LOGE );
6828 limLog( pMac, LOGE,
6829 FL( "Sending an SA Query Request from " ));
6830 limPrintMacAddr( pMac, psessionEntry->selfMacAddr, LOGE );
6831
6832 if ( ( SIR_BAND_5_GHZ == limGetRFBand( psessionEntry->currentOperChannel ) )
6833#ifdef WLAN_FEATURE_P2P
6834 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
6835 ( psessionEntry->pePersona == VOS_P2P_GO_MODE )
6836#endif
6837 )
6838 {
6839 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
6840 }
6841
6842 halstatus = halTxFrame( pMac,
6843 pPacket,
6844 (tANI_U16) nBytes,
6845 HAL_TXRX_FRM_802_11_MGMT,
6846 ANI_TXDIR_TODS,
6847 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
6848 limTxComplete,
6849 pFrame, txFlag );
6850 if ( eHAL_STATUS_SUCCESS != halstatus )
6851 {
6852 PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]" ), halstatus );)
6853 nSirStatus = eSIR_FAILURE;
6854 //Pkt will be freed up by the callback
6855 return nSirStatus;
6856 }
6857 else {
6858 return eSIR_SUCCESS;
6859 }
6860
6861returnAfterError:
6862 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
6863 return nSirStatus;
6864} // End limSendSaQueryRequestFrame
6865
6866/**
Jeff Johnson295189b2012-06-20 16:38:30 -07006867 * \brief Send SA query response action frame to peer
6868 *
6869 * \sa limSendSaQueryResponseFrame
6870 *
6871 *
6872 * \param pMac The global tpAniSirGlobal object
6873 *
Chet Lanctot186b5732013-03-18 10:26:30 -07006874 * \param transId Transaction identifier received in SA query request action frame
Jeff Johnson295189b2012-06-20 16:38:30 -07006875 *
Chet Lanctot186b5732013-03-18 10:26:30 -07006876 * \param peer The Mac address of the AP to which this action frame is addressed
6877 *
6878 * \param psessionEntry The PE session entry
Jeff Johnson295189b2012-06-20 16:38:30 -07006879 *
6880 * \return eSIR_SUCCESS if setup completes successfully
6881 * eSIR_FAILURE is some problem is encountered
6882 */
6883
Chet Lanctot186b5732013-03-18 10:26:30 -07006884tSirRetStatus limSendSaQueryResponseFrame( tpAniSirGlobal pMac, tANI_U8 *transId,
Jeff Johnson295189b2012-06-20 16:38:30 -07006885tSirMacAddr peer,tpPESession psessionEntry)
6886{
6887
Chet Lanctot186b5732013-03-18 10:26:30 -07006888 tDot11fSaQueryRsp frm; // SA query reponse action frame
Jeff Johnson295189b2012-06-20 16:38:30 -07006889 tANI_U8 *pFrame;
6890 tSirRetStatus nSirStatus;
6891 tpSirMacMgmtHdr pMacHdr;
Chet Lanctot186b5732013-03-18 10:26:30 -07006892 tANI_U32 nBytes, nPayload, nStatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07006893 void *pPacket;
6894 eHalStatus halstatus;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05306895 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07006896
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05306897 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Chet Lanctot186b5732013-03-18 10:26:30 -07006898 frm.Category.category = SIR_MAC_ACTION_SA_QUERY;
6899 /*11w action field is :
Jeff Johnson295189b2012-06-20 16:38:30 -07006900 action: 0 --> SA query request action frame
6901 action: 1 --> SA query response action frame */
Chet Lanctot186b5732013-03-18 10:26:30 -07006902 frm.Action.action = SIR_MAC_SA_QUERY_RSP;
6903 /*11w SA query response transId is same as
Jeff Johnson295189b2012-06-20 16:38:30 -07006904 SA query request transId*/
Chet Lanctot186b5732013-03-18 10:26:30 -07006905 vos_mem_copy( &frm.TransactionId.transId[0], &transId[0], 2 );
Jeff Johnson295189b2012-06-20 16:38:30 -07006906
Chet Lanctot186b5732013-03-18 10:26:30 -07006907 nStatus = dot11fGetPackedSaQueryRspSize(pMac, &frm, &nPayload);
6908 if ( DOT11F_FAILED( nStatus ) )
6909 {
6910 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
6911 "or a SA Query Response (0x%08x)."),
6912 nStatus );
6913 // We'll fall back on the worst case scenario:
6914 nPayload = sizeof( tDot11fSaQueryRsp );
6915 }
6916 else if ( DOT11F_WARNED( nStatus ) )
6917 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08006918 limLog( pMac, LOGW, FL("There were warnings while calculating "
Chet Lanctot186b5732013-03-18 10:26:30 -07006919 "the packed size for an SA Query Response"
6920 " (0x%08x)."), nStatus );
6921 }
6922
Jeff Johnson295189b2012-06-20 16:38:30 -07006923 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
6924 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
6925 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
6926 {
6927 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a SA query response"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006928 " action frame"), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07006929 return eSIR_FAILURE;
6930 }
6931
6932 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05306933 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07006934
Chet Lanctot186b5732013-03-18 10:26:30 -07006935 // Copy necessary info to BD
Chet Lanctotb2b0d552013-03-22 16:58:44 -07006936 nSirStatus = limPopulateMacHeader( pMac,
Chet Lanctot186b5732013-03-18 10:26:30 -07006937 pFrame,
6938 SIR_MAC_MGMT_FRAME,
6939 SIR_MAC_MGMT_ACTION,
Chet Lanctotb2b0d552013-03-22 16:58:44 -07006940 peer, psessionEntry->selfMacAddr );
6941 if ( eSIR_SUCCESS != nSirStatus )
Chet Lanctot186b5732013-03-18 10:26:30 -07006942 goto returnAfterError;
Jeff Johnson295189b2012-06-20 16:38:30 -07006943
Chet Lanctot186b5732013-03-18 10:26:30 -07006944 // Update A3 with the BSSID
Jeff Johnson295189b2012-06-20 16:38:30 -07006945 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
6946
Chet Lanctot186b5732013-03-18 10:26:30 -07006947 sirCopyMacAddr( pMacHdr->bssId, psessionEntry->bssId );
Jeff Johnson295189b2012-06-20 16:38:30 -07006948
Chet Lanctot186b5732013-03-18 10:26:30 -07006949 // Since this is a SA Query Response, set the "protect" (aka WEP) bit
6950 // in the FC
Chet Lanctot8cecea22014-02-11 19:09:36 -08006951 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Jeff Johnson295189b2012-06-20 16:38:30 -07006952
Chet Lanctot186b5732013-03-18 10:26:30 -07006953 // Pack 11w SA query response frame
6954 nStatus = dot11fPackSaQueryRsp( pMac,
6955 &frm,
6956 pFrame + sizeof( tSirMacMgmtHdr ),
6957 nPayload,
6958 &nPayload );
6959
6960 if ( DOT11F_FAILED( nStatus ))
6961 {
6962 limLog( pMac, LOGE,
6963 FL( "Failed to pack an SA Query Response (0x%08x)." ),
6964 nStatus );
6965 // FIXME - Need to convert to tSirRetStatus
6966 nSirStatus = eSIR_FAILURE;
6967 goto returnAfterError;
6968 }
6969 else if ( DOT11F_WARNED( nStatus ))
6970 {
6971 limLog( pMac, LOGW,
6972 FL( "There were warnings while packing SA Query Response (0x%08x)." ),
6973 nStatus);
6974 }
6975
6976 limLog( pMac, LOG1,
6977 FL( "Sending a SA Query Response to " ));
6978 limPrintMacAddr( pMac, peer, LOGW );
6979
Chet Lanctotb2b0d552013-03-22 16:58:44 -07006980 if ( ( SIR_BAND_5_GHZ == limGetRFBand( psessionEntry->currentOperChannel ) )
Chet Lanctot186b5732013-03-18 10:26:30 -07006981#ifdef WLAN_FEATURE_P2P
Chet Lanctotb2b0d552013-03-22 16:58:44 -07006982 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
6983 ( psessionEntry->pePersona == VOS_P2P_GO_MODE )
Chet Lanctot186b5732013-03-18 10:26:30 -07006984#endif
Chet Lanctotb2b0d552013-03-22 16:58:44 -07006985 )
6986 {
6987 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
6988 }
Chet Lanctot186b5732013-03-18 10:26:30 -07006989
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05306990 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
6991 psessionEntry->peSessionId,
6992 pMacHdr->fc.subType));
Chet Lanctotb2b0d552013-03-22 16:58:44 -07006993 halstatus = halTxFrame( pMac,
6994 pPacket,
6995 (tANI_U16) nBytes,
6996 HAL_TXRX_FRM_802_11_MGMT,
6997 ANI_TXDIR_TODS,
6998 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
6999 limTxComplete,
7000 pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05307001 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
7002 psessionEntry->peSessionId,
7003 halstatus));
Chet Lanctotb2b0d552013-03-22 16:58:44 -07007004 if ( eHAL_STATUS_SUCCESS != halstatus )
Chet Lanctot186b5732013-03-18 10:26:30 -07007005 {
7006 PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]" ), halstatus );)
7007 nSirStatus = eSIR_FAILURE;
7008 //Pkt will be freed up by the callback
7009 return nSirStatus;
7010 }
7011 else {
7012 return eSIR_SUCCESS;
7013 }
7014
7015returnAfterError:
7016 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
7017 return nSirStatus;
7018} // End limSendSaQueryResponseFrame
Jeff Johnson295189b2012-06-20 16:38:30 -07007019#endif