blob: 08fec151552cc44586c6776dd25baec5da9f1d61 [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Satyanarayana Dash6f438272015-03-03 18:01:06 +05302 * Copyright (c) 2012-2015 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 {
Jeff Johnsone7245742012-09-05 17:12:55 -07001485 PopulateDot11fHTCaps( pMac, psessionEntry, &frm.HTCaps );
Sachin Ahujac3a26232014-09-23 22:27:30 +05301486 /*
1487 *Check the STA capability and update the HTCaps accordingly
1488 */
1489 frm.HTCaps.supportedChannelWidthSet =
1490 (pSta->htSupportedChannelWidthSet < psessionEntry->htSupportedChannelWidthSet) ?
1491 pSta->htSupportedChannelWidthSet : psessionEntry->htSupportedChannelWidthSet ;
1492
1493 if (!frm.HTCaps.supportedChannelWidthSet)
1494 frm.HTCaps.shortGI40MHz = 0;
1495
Jeff Johnson295189b2012-06-20 16:38:30 -07001496 PopulateDot11fHTInfo( pMac, &frm.HTInfo, psessionEntry );
Jeff Johnson295189b2012-06-20 16:38:30 -07001497 }
Jeff Johnsone7245742012-09-05 17:12:55 -07001498
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301499#ifdef WLAN_FEATURE_AP_HT40_24G
1500 /* Populate Overlapping BSS Scan Parameters IEs,
1501 * when operating in HT40 in 2.4GHz.
1502 */
Hardik Kantilal Patel3c235242015-01-02 17:56:18 +05301503 if ((pMac->roam.configParam.apHT40_24GEnabled)
1504 && (IS_DOT11_MODE_HT(psessionEntry->dot11mode)))
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301505 {
1506 PopulateDot11fOBSSScanParameters( pMac, &frm.OBSSScanParameters,
1507 psessionEntry);
Hardik Kantilal Patelee5874c2015-01-14 15:23:28 +05301508 /* 10.15.8 Support of DSSS/CCK in 40 MHz, An associated HT STA in
1509 * a 20/40 MHz BSS may generate DSSS/CCK transmissions.Set DSSS/CCK
1510 * Mode in 40 MHz bit in HT capablity.
1511 */
1512 frm.HTCaps.dsssCckMode40MHz = 1;
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301513 }
1514#endif
1515
1516 PopulateDot11fExtCap( pMac, &frm.ExtCap, psessionEntry);
Jeff Johnsone7245742012-09-05 17:12:55 -07001517#ifdef WLAN_FEATURE_11AC
1518 if( pSta->mlmStaContext.vhtCapability &&
1519 psessionEntry->vhtCapability )
1520 {
Chet Lanctotf19c1f62013-12-13 13:56:21 -08001521 limLog( pMac, LOG1, FL("Populate VHT IEs in Assoc Response"));
Abhishek Singh33f76ea2015-06-04 12:27:30 +05301522 PopulateDot11fVHTCaps( pMac, &frm.VHTCaps,
1523 psessionEntry->currentOperChannel, eSIR_TRUE );
1524 PopulateDot11fVHTOperation( pMac, &frm.VHTOperation,
1525 psessionEntry->currentOperChannel);
Jeff Johnsone7245742012-09-05 17:12:55 -07001526 }
1527#endif
1528
Chet Lanctot8cecea22014-02-11 19:09:36 -08001529#ifdef WLAN_FEATURE_11W
Dino Myclea7f18452014-04-24 08:55:31 +05301530 if( eSIR_MAC_TRY_AGAIN_LATER == statusCode )
1531 {
Chet Lanctotfadc8e32014-04-24 14:50:52 -07001532 if ( wlan_cfgGetInt(pMac, WNI_CFG_PMF_SA_QUERY_MAX_RETRIES,
1533 &maxRetries ) != eSIR_SUCCESS )
1534 limLog( pMac, LOGE,
1535 FL("Could not retrieve PMF SA Query maximum retries value") );
1536 else
1537 if ( wlan_cfgGetInt(pMac, WNI_CFG_PMF_SA_QUERY_RETRY_INTERVAL,
1538 &retryInterval ) != eSIR_SUCCESS)
1539 limLog( pMac, LOGE,
1540 FL("Could not retrieve PMF SA Query timer interval value") );
Dino Myclea7f18452014-04-24 08:55:31 +05301541 else
Chet Lanctotfadc8e32014-04-24 14:50:52 -07001542 PopulateDot11fTimeoutInterval(
1543 pMac, &frm.TimeoutInterval, SIR_MAC_TI_TYPE_ASSOC_COMEBACK,
1544 (maxRetries - pSta->pmfSaQueryRetryCount) * retryInterval );
Dino Myclea7f18452014-04-24 08:55:31 +05301545 }
Chet Lanctot8cecea22014-02-11 19:09:36 -08001546#endif
Dino Myclea7f18452014-04-24 08:55:31 +05301547 } // End if on non-NULL 'pSta'.
Jeff Johnson295189b2012-06-20 16:38:30 -07001548
Chet Lanctot8cecea22014-02-11 19:09:36 -08001549 vos_mem_set(( tANI_U8* )&beaconParams, sizeof( tUpdateBeaconParams), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001550
Jeff Johnson295189b2012-06-20 16:38:30 -07001551 if( psessionEntry->limSystemRole == eLIM_AP_ROLE ){
1552 if(psessionEntry->gLimProtectionControl != WNI_CFG_FORCE_POLICY_PROTECTION_DISABLE)
1553 limDecideApProtection(pMac, peerMacAddr, &beaconParams,psessionEntry);
1554 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001555
1556 limUpdateShortPreamble(pMac, peerMacAddr, &beaconParams, psessionEntry);
1557 limUpdateShortSlotTime(pMac, peerMacAddr, &beaconParams, psessionEntry);
1558
1559 beaconParams.bssIdx = psessionEntry->bssIdx;
1560
1561 //Send message to HAL about beacon parameter change.
1562 if(beaconParams.paramChangeBitmap)
1563 {
1564 schSetFixedBeaconFields(pMac,psessionEntry);
1565 limSendBeaconParams(pMac, &beaconParams, psessionEntry );
1566 }
1567
Jeff Johnson295189b2012-06-20 16:38:30 -07001568 if ( pAssocReq != NULL )
1569 {
1570 if (wlan_cfgGetInt(pMac, WNI_CFG_ASSOC_RSP_ADDNIE_FLAG,
1571 &addnIEPresent) != eSIR_SUCCESS)
1572 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05301573 limLog(pMac, LOGP, FL("Unable to get "
1574 "WNI_CFG_ASSOC_RSP_ADDNIE_FLAG"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001575 return;
1576 }
1577
1578 if (addnIEPresent)
1579 {
1580 //Assoc rsp IE available
1581 if (wlan_cfgGetStrLen(pMac, WNI_CFG_ASSOC_RSP_ADDNIE_DATA,
1582 &addnIELen) != eSIR_SUCCESS)
1583 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05301584 limLog(pMac, LOGP, FL("Unable to get "
1585 "WNI_CFG_ASSOC_RSP_ADDNIE_DATA length"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001586 return;
1587 }
1588
1589 if (addnIELen <= WNI_CFG_ASSOC_RSP_ADDNIE_DATA_LEN && addnIELen &&
1590 (nBytes + addnIELen) <= SIR_MAX_PACKET_SIZE)
1591 {
1592 if (wlan_cfgGetStr(pMac, WNI_CFG_ASSOC_RSP_ADDNIE_DATA,
1593 &addIE[0], &addnIELen) == eSIR_SUCCESS)
1594 {
Mahesh A Saptasagar38c177e2014-10-17 18:55:48 +05301595
1596 vos_mem_set(( tANI_U8* )&extractedExtCap,
1597 sizeof( tDot11fIEExtCap ), 0);
Mahesh A Saptasagare00ff532014-10-17 19:05:14 +05301598 addStripoffIELen = addnIELen;
Mahesh A Saptasagar38c177e2014-10-17 18:55:48 +05301599 nSirStatus = limStripOffExtCapIEAndUpdateStruct(pMac,
1600 &addIE[0],
1601 &addStripoffIELen,
1602 &extractedExtCap );
1603 if(eSIR_SUCCESS != nSirStatus)
1604 {
1605 limLog(pMac, LOG1,
1606 FL("Unable to Stripoff ExtCap IE from Assoc Rsp"));
1607 }
1608 else
1609 {
1610 addnIELen = addStripoffIELen;
1611 extractedExtCapFlag = eANI_BOOLEAN_TRUE;
1612 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001613 nBytes = nBytes + addnIELen;
1614 }
1615 }
1616 }
1617 }
1618
Mahesh A Saptasagar38c177e2014-10-17 18:55:48 +05301619 /* merge the ExtCap struct*/
1620 if (extractedExtCapFlag && extractedExtCap.present)
1621 {
1622 limMergeExtCapIEStruct(&(frm.ExtCap), &extractedExtCap);
1623 }
1624
c_hpothubcd78652014-04-28 22:31:08 +05301625 nStatus = dot11fGetPackedAssocResponseSize( pMac, &frm, &nPayload );
1626 if ( DOT11F_FAILED( nStatus ) )
1627 {
1628 limLog( pMac, LOGE, FL("Failed to calculate the packed size f"
1629 "or an Association Response (0x%08x)."),
1630 nStatus );
1631 return;
1632 }
1633 else if ( DOT11F_WARNED( nStatus ) )
1634 {
1635 limLog( pMac, LOGW, FL("There were warnings while calculating "
1636 "the packed size for an Association Re"
1637 "sponse (0x%08x)."), nStatus );
1638 }
1639
1640 nBytes += sizeof( tSirMacMgmtHdr ) + nPayload;
1641
Jeff Johnson295189b2012-06-20 16:38:30 -07001642 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1643 ( tANI_U16 )nBytes, ( void** ) &pFrame,
1644 ( void** ) &pPacket );
1645 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1646 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001647 limLog(pMac, LOGP, FL("Call to bufAlloc failed for RE/ASSOC RSP."));
Jeff Johnson295189b2012-06-20 16:38:30 -07001648 return;
1649 }
1650
1651 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301652 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07001653
1654 // Next, we fill out the buffer descriptor:
1655 nSirStatus = limPopulateMacHeader( pMac,
1656 pFrame,
1657 SIR_MAC_MGMT_FRAME,
1658 ( LIM_ASSOC == subType ) ?
1659 SIR_MAC_MGMT_ASSOC_RSP :
1660 SIR_MAC_MGMT_REASSOC_RSP,
1661 peerMacAddr,psessionEntry->selfMacAddr);
1662 if ( eSIR_SUCCESS != nSirStatus )
1663 {
1664 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001665 "tor for an Association Response (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001666 nSirStatus );
1667 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1668 ( void* ) pFrame, ( void* ) pPacket );
1669 return;
1670 }
1671
1672 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
1673
Jeff Johnson295189b2012-06-20 16:38:30 -07001674 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
1675
1676 nStatus = dot11fPackAssocResponse( pMac, &frm,
1677 pFrame + sizeof( tSirMacMgmtHdr ),
1678 nPayload, &nPayload );
1679 if ( DOT11F_FAILED( nStatus ) )
1680 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05301681 limLog( pMac, LOGE, FL("Failed to pack an Association Response"
1682 " (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001683 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1684 ( void* ) pFrame, ( void* ) pPacket );
1685 return; // allocated!
1686 }
1687 else if ( DOT11F_WARNED( nStatus ) )
1688 {
1689 limLog( pMac, LOGW, FL("There were warnings while packing an "
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001690 "Association Response (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001691 }
1692
1693 macAddr = pMacHdr->da;
1694
1695 if (subType == LIM_ASSOC)
1696 {
Abhishek Singh3cbf6052014-12-15 16:46:42 +05301697 limLog(pMac, LOG1,
Jeff Johnson295189b2012-06-20 16:38:30 -07001698 FL("*** Sending Assoc Resp status %d aid %d to "),
Abhishek Singh3cbf6052014-12-15 16:46:42 +05301699 statusCode, aid);
Jeff Johnson295189b2012-06-20 16:38:30 -07001700 }
1701 else{
Abhishek Singh3cbf6052014-12-15 16:46:42 +05301702 limLog(pMac, LOG1,
Jeff Johnson295189b2012-06-20 16:38:30 -07001703 FL("*** Sending ReAssoc Resp status %d aid %d to "),
Abhishek Singh3cbf6052014-12-15 16:46:42 +05301704 statusCode, aid);
Jeff Johnson295189b2012-06-20 16:38:30 -07001705 }
Abhishek Singh3cbf6052014-12-15 16:46:42 +05301706 limPrintMacAddr(pMac, pMacHdr->da, LOG1);
Jeff Johnson295189b2012-06-20 16:38:30 -07001707
1708 if ( addnIEPresent )
1709 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301710 vos_mem_copy ( pFrame+sizeof(tSirMacMgmtHdr)+nPayload, &addIE[0], addnIELen ) ;
Jeff Johnson295189b2012-06-20 16:38:30 -07001711 }
1712
1713 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07001714 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
1715 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07001716 )
1717 {
1718 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
1719 }
1720
Agarwal Ashisha8e81f52014-04-02 01:59:52 +05301721 limLog( pMac, LOG1, FL("Sending Assoc resp over WQ5 to "MAC_ADDRESS_STR
1722 " From " MAC_ADDRESS_STR),MAC_ADDR_ARRAY(pMacHdr->da),
1723 MAC_ADDR_ARRAY(psessionEntry->selfMacAddr));
1724
1725 txFlag |= HAL_USE_FW_IN_TX_PATH;
1726
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05301727 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
1728 psessionEntry->peSessionId,
1729 pMacHdr->fc.subType));
Ganesh Kondabattiniffc00b12015-03-18 13:11:33 +05301730
1731 if (IS_FEATURE_SUPPORTED_BY_FW(ENHANCED_TXBD_COMPLETION))
1732 {
1733 limLog(pMac, LOG1, FL("Re/AssocRsp - txBdToken %u"), pMac->lim.txBdToken);
1734 /// Queue Association Response frame in high priority WQ
1735 halstatus = halTxFrameWithTxComplete( pMac, pPacket, ( tANI_U16 ) nBytes,
1736 HAL_TXRX_FRM_802_11_MGMT,
1737 ANI_TXDIR_TODS,
1738 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
1739 limTxComplete, pFrame, limTxBdComplete,
1740 txFlag, pMac->lim.txBdToken );
1741 pMac->lim.txBdToken++;
1742 }
1743 else
1744 {
1745 /// Queue Association Response frame in high priority WQ
1746 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
1747 HAL_TXRX_FRM_802_11_MGMT,
1748 ANI_TXDIR_TODS,
1749 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
1750 limTxComplete, pFrame, txFlag );
1751 }
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05301752 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
1753 psessionEntry->peSessionId,
1754 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07001755 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1756 {
1757 limLog(pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001758 FL("*** Could not Send Re/AssocRsp, retCode=%X ***"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001759 nSirStatus);
1760
1761 //Pkt will be freed up by the callback
1762 }
1763
1764 // update the ANI peer station count
1765 //FIXME_PROTECTION : take care of different type of station
1766 // counter inside this function.
1767 limUtilCountStaAdd(pMac, pSta, psessionEntry);
1768
1769} // End limSendAssocRspMgmtFrame.
1770
1771
1772
1773void
1774limSendAddtsRspActionFrame(tpAniSirGlobal pMac,
1775 tSirMacAddr peer,
1776 tANI_U16 nStatusCode,
1777 tSirAddtsReqInfo *pAddTS,
1778 tSirMacScheduleIE *pSchedule,
1779 tpPESession psessionEntry)
1780{
1781 tANI_U8 *pFrame;
1782 tpSirMacMgmtHdr pMacHdr;
1783 tDot11fAddTSResponse AddTSRsp;
1784 tDot11fWMMAddTSResponse WMMAddTSRsp;
1785 tSirRetStatus nSirStatus;
1786 tANI_U32 i, nBytes, nPayload, nStatus;
1787 void *pPacket;
1788 eHalStatus halstatus;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05301789 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001790
1791 if(NULL == psessionEntry)
1792 {
1793 return;
1794 }
1795
1796 if ( ! pAddTS->wmeTspecPresent )
1797 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301798 vos_mem_set( ( tANI_U8* )&AddTSRsp, sizeof( AddTSRsp ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07001799
1800 AddTSRsp.Category.category = SIR_MAC_ACTION_QOS_MGMT;
1801 AddTSRsp.Action.action = SIR_MAC_QOS_ADD_TS_RSP;
1802 AddTSRsp.DialogToken.token = pAddTS->dialogToken;
1803 AddTSRsp.Status.status = nStatusCode;
1804
1805 // The TsDelay information element is only filled in for a specific
1806 // status code:
1807 if ( eSIR_MAC_TS_NOT_CREATED_STATUS == nStatusCode )
1808 {
1809 if ( pAddTS->wsmTspecPresent )
1810 {
1811 AddTSRsp.WMMTSDelay.version = 1;
1812 AddTSRsp.WMMTSDelay.delay = 10;
1813 AddTSRsp.WMMTSDelay.present = 1;
1814 }
1815 else
1816 {
1817 AddTSRsp.TSDelay.delay = 10;
1818 AddTSRsp.TSDelay.present = 1;
1819 }
1820 }
1821
1822 if ( pAddTS->wsmTspecPresent )
1823 {
1824 PopulateDot11fWMMTSPEC( &pAddTS->tspec, &AddTSRsp.WMMTSPEC );
1825 }
1826 else
1827 {
1828 PopulateDot11fTSPEC( &pAddTS->tspec, &AddTSRsp.TSPEC );
1829 }
1830
1831 if ( pAddTS->wsmTspecPresent )
1832 {
1833 AddTSRsp.num_WMMTCLAS = 0;
1834 AddTSRsp.num_TCLAS = pAddTS->numTclas;
1835 for ( i = 0; i < AddTSRsp.num_TCLAS; ++i)
1836 {
1837 PopulateDot11fTCLAS( pMac, &pAddTS->tclasInfo[i],
1838 &AddTSRsp.TCLAS[i] );
1839 }
1840 }
1841 else
1842 {
1843 AddTSRsp.num_TCLAS = 0;
1844 AddTSRsp.num_WMMTCLAS = pAddTS->numTclas;
1845 for ( i = 0; i < AddTSRsp.num_WMMTCLAS; ++i)
1846 {
1847 PopulateDot11fWMMTCLAS( pMac, &pAddTS->tclasInfo[i],
1848 &AddTSRsp.WMMTCLAS[i] );
1849 }
1850 }
1851
1852 if ( pAddTS->tclasProcPresent )
1853 {
1854 if ( pAddTS->wsmTspecPresent )
1855 {
1856 AddTSRsp.WMMTCLASPROC.version = 1;
1857 AddTSRsp.WMMTCLASPROC.processing = pAddTS->tclasProc;
1858 AddTSRsp.WMMTCLASPROC.present = 1;
1859 }
1860 else
1861 {
1862 AddTSRsp.TCLASSPROC.processing = pAddTS->tclasProc;
1863 AddTSRsp.TCLASSPROC.present = 1;
1864 }
1865 }
1866
1867 // schedule element is included only if requested in the tspec and we are
1868 // using hcca (or both edca and hcca)
1869 // 11e-D8.0 is inconsistent on whether the schedule element is included
1870 // based on tspec schedule bit or not. Sec 7.4.2.2. says one thing but
1871 // pg 46, line 17-18 says something else. So just include it and let the
1872 // sta figure it out
1873 if ((pSchedule != NULL) &&
1874 ((pAddTS->tspec.tsinfo.traffic.accessPolicy == SIR_MAC_ACCESSPOLICY_HCCA) ||
1875 (pAddTS->tspec.tsinfo.traffic.accessPolicy == SIR_MAC_ACCESSPOLICY_BOTH)))
1876 {
1877 if ( pAddTS->wsmTspecPresent )
1878 {
1879 PopulateDot11fWMMSchedule( pSchedule, &AddTSRsp.WMMSchedule );
1880 }
1881 else
1882 {
1883 PopulateDot11fSchedule( pSchedule, &AddTSRsp.Schedule );
1884 }
1885 }
1886
1887 nStatus = dot11fGetPackedAddTSResponseSize( pMac, &AddTSRsp, &nPayload );
1888 if ( DOT11F_FAILED( nStatus ) )
1889 {
1890 limLog( pMac, LOGP, FL("Failed to calculate the packed si"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001891 "ze for an Add TS Response (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001892 nStatus );
1893 // We'll fall back on the worst case scenario:
1894 nPayload = sizeof( tDot11fAddTSResponse );
1895 }
1896 else if ( DOT11F_WARNED( nStatus ) )
1897 {
1898 limLog( pMac, LOGW, FL("There were warnings while calcula"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001899 "ting the packed size for an Add TS"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001900 " Response (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001901 }
1902 }
1903 else
1904 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301905 vos_mem_set( ( tANI_U8* )&WMMAddTSRsp, sizeof( WMMAddTSRsp ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07001906
1907 WMMAddTSRsp.Category.category = SIR_MAC_ACTION_WME;
1908 WMMAddTSRsp.Action.action = SIR_MAC_QOS_ADD_TS_RSP;
1909 WMMAddTSRsp.DialogToken.token = pAddTS->dialogToken;
1910 WMMAddTSRsp.StatusCode.statusCode = (tANI_U8)nStatusCode;
1911
1912 PopulateDot11fWMMTSPEC( &pAddTS->tspec, &WMMAddTSRsp.WMMTSPEC );
1913
1914 nStatus = dot11fGetPackedWMMAddTSResponseSize( pMac, &WMMAddTSRsp, &nPayload );
1915 if ( DOT11F_FAILED( nStatus ) )
1916 {
1917 limLog( pMac, LOGP, FL("Failed to calculate the packed si"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001918 "ze for a WMM Add TS Response (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001919 nStatus );
1920 // We'll fall back on the worst case scenario:
1921 nPayload = sizeof( tDot11fWMMAddTSResponse );
1922 }
1923 else if ( DOT11F_WARNED( nStatus ) )
1924 {
1925 limLog( pMac, LOGW, FL("There were warnings while calcula"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001926 "ting the packed size for a WMM Add"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001927 "TS Response (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001928 }
1929 }
1930
1931 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
1932
1933 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
1934 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1935 {
1936 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for an Ad"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001937 "d TS Response."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07001938 return;
1939 }
1940
1941 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301942 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07001943
1944 // Next, we fill out the buffer descriptor:
1945 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
1946 SIR_MAC_MGMT_ACTION, peer,psessionEntry->selfMacAddr);
1947 if ( eSIR_SUCCESS != nSirStatus )
1948 {
1949 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001950 "tor for an Add TS Response (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001951 nSirStatus );
1952 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1953 return; // allocated!
1954 }
1955
1956 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
1957
1958
1959 #if 0
1960 if ( eSIR_SUCCESS != wlan_cfgGetStr( pMac, WNI_CFG_BSSID,
1961 ( tANI_U8* )pMacHdr->bssId, &cfgLen ) )
1962 {
1963 limLog( pMac, LOGP, FL("Failed to retrieve WNI_CFG_BSSID whil"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001964 "e sending an Add TS Response.") );
Jeff Johnson295189b2012-06-20 16:38:30 -07001965 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1966 return; // allocated!
1967 }
1968 #endif //TO SUPPORT BT-AMP
1969 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
1970
Chet Lanctot186b5732013-03-18 10:26:30 -07001971#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07001972 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07001973#endif
1974
Jeff Johnson295189b2012-06-20 16:38:30 -07001975 // That done, pack the struct:
1976 if ( ! pAddTS->wmeTspecPresent )
1977 {
1978 nStatus = dot11fPackAddTSResponse( pMac, &AddTSRsp,
1979 pFrame + sizeof( tSirMacMgmtHdr ),
1980 nPayload, &nPayload );
1981 if ( DOT11F_FAILED( nStatus ) )
1982 {
1983 limLog( pMac, LOGE, FL("Failed to pack an Add TS Response "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001984 "(0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001985 nStatus );
1986 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1987 return;
1988 }
1989 else if ( DOT11F_WARNED( nStatus ) )
1990 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001991 limLog( pMac, LOGW, FL("There were warnings while packing "
1992 "an Add TS Response (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001993 }
1994 }
1995 else
1996 {
1997 nStatus = dot11fPackWMMAddTSResponse( pMac, &WMMAddTSRsp,
1998 pFrame + sizeof( tSirMacMgmtHdr ),
1999 nPayload, &nPayload );
2000 if ( DOT11F_FAILED( nStatus ) )
2001 {
2002 limLog( pMac, LOGE, FL("Failed to pack a WMM Add TS Response "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002003 "(0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002004 nStatus );
2005 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
2006 return;
2007 }
2008 else if ( DOT11F_WARNED( nStatus ) )
2009 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08002010 limLog( pMac, LOGW, FL("There were warnings while packing "
2011 "a WMM Add TS Response (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07002012 }
2013 }
2014
Abhishek Singh3cbf6052014-12-15 16:46:42 +05302015 limLog( pMac, LOG1, FL("Sending an Add TS Response (status %d) to "),
Jeff Johnson295189b2012-06-20 16:38:30 -07002016 nStatusCode );
Abhishek Singh3cbf6052014-12-15 16:46:42 +05302017 limPrintMacAddr( pMac, pMacHdr->da, LOG1 );
Jeff Johnson295189b2012-06-20 16:38:30 -07002018
2019 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07002020 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
2021 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07002022 )
2023 {
2024 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
2025 }
2026
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05302027 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
2028 psessionEntry->peSessionId,
2029 pMacHdr->fc.subType));
Jeff Johnson295189b2012-06-20 16:38:30 -07002030 // Queue the frame in high priority WQ:
2031 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
2032 HAL_TXRX_FRM_802_11_MGMT,
2033 ANI_TXDIR_TODS,
2034 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
2035 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05302036 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
2037 psessionEntry->peSessionId,
2038 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07002039 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
2040 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002041 limLog( pMac, LOGE, FL("Failed to send Add TS Response (%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002042 nSirStatus );
2043 //Pkt will be freed up by the callback
2044 }
2045
2046} // End limSendAddtsRspActionFrame.
2047
2048void
2049limSendDeltsReqActionFrame(tpAniSirGlobal pMac,
2050 tSirMacAddr peer,
2051 tANI_U8 wmmTspecPresent,
2052 tSirMacTSInfo *pTsinfo,
2053 tSirMacTspecIE *pTspecIe,
2054 tpPESession psessionEntry)
2055{
2056 tANI_U8 *pFrame;
2057 tpSirMacMgmtHdr pMacHdr;
2058 tDot11fDelTS DelTS;
2059 tDot11fWMMDelTS WMMDelTS;
2060 tSirRetStatus nSirStatus;
2061 tANI_U32 nBytes, nPayload, nStatus;
2062 void *pPacket;
2063 eHalStatus halstatus;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05302064 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002065
2066 if(NULL == psessionEntry)
2067 {
2068 return;
2069 }
2070
2071 if ( ! wmmTspecPresent )
2072 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302073 vos_mem_set( ( tANI_U8* )&DelTS, sizeof( DelTS ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07002074
2075 DelTS.Category.category = SIR_MAC_ACTION_QOS_MGMT;
2076 DelTS.Action.action = SIR_MAC_QOS_DEL_TS_REQ;
2077 PopulateDot11fTSInfo( pTsinfo, &DelTS.TSInfo );
2078
2079 nStatus = dot11fGetPackedDelTSSize( pMac, &DelTS, &nPayload );
2080 if ( DOT11F_FAILED( nStatus ) )
2081 {
2082 limLog( pMac, LOGP, FL("Failed to calculate the packed si"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002083 "ze for a Del TS (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002084 nStatus );
2085 // We'll fall back on the worst case scenario:
2086 nPayload = sizeof( tDot11fDelTS );
2087 }
2088 else if ( DOT11F_WARNED( nStatus ) )
2089 {
2090 limLog( pMac, LOGW, FL("There were warnings while calcula"
2091 "ting the packed size for a Del TS"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002092 " (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07002093 }
2094 }
2095 else
2096 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302097 vos_mem_set( ( tANI_U8* )&WMMDelTS, sizeof( WMMDelTS ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07002098
2099 WMMDelTS.Category.category = SIR_MAC_ACTION_WME;
2100 WMMDelTS.Action.action = SIR_MAC_QOS_DEL_TS_REQ;
2101 WMMDelTS.DialogToken.token = 0;
2102 WMMDelTS.StatusCode.statusCode = 0;
2103 PopulateDot11fWMMTSPEC( pTspecIe, &WMMDelTS.WMMTSPEC );
2104 nStatus = dot11fGetPackedWMMDelTSSize( pMac, &WMMDelTS, &nPayload );
2105 if ( DOT11F_FAILED( nStatus ) )
2106 {
2107 limLog( pMac, LOGP, FL("Failed to calculate the packed si"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002108 "ze for a WMM Del TS (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002109 nStatus );
2110 // We'll fall back on the worst case scenario:
2111 nPayload = sizeof( tDot11fDelTS );
2112 }
2113 else if ( DOT11F_WARNED( nStatus ) )
2114 {
2115 limLog( pMac, LOGW, FL("There were warnings while calcula"
2116 "ting the packed size for a WMM De"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002117 "l TS (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07002118 }
2119 }
2120
2121 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
2122
2123 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
2124 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
2125 {
2126 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for an Ad"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002127 "d TS Response."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07002128 return;
2129 }
2130
2131 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302132 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07002133
2134 // Next, we fill out the buffer descriptor:
2135 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
2136 SIR_MAC_MGMT_ACTION, peer,
2137 psessionEntry->selfMacAddr);
2138 if ( eSIR_SUCCESS != nSirStatus )
2139 {
2140 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002141 "tor for an Add TS Response (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002142 nSirStatus );
2143 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
2144 return; // allocated!
2145 }
2146
2147 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
2148
2149 #if 0
2150
2151 cfgLen = SIR_MAC_ADDR_LENGTH;
2152 if ( eSIR_SUCCESS != wlan_cfgGetStr( pMac, WNI_CFG_BSSID,
2153 ( tANI_U8* )pMacHdr->bssId, &cfgLen ) )
2154 {
2155 limLog( pMac, LOGP, FL("Failed to retrieve WNI_CFG_BSSID whil"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002156 "e sending an Add TS Response.") );
Jeff Johnson295189b2012-06-20 16:38:30 -07002157 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
2158 return; // allocated!
2159 }
2160 #endif //TO SUPPORT BT-AMP
2161 sirCopyMacAddr(pMacHdr->bssId, psessionEntry->bssId);
2162
Chet Lanctot186b5732013-03-18 10:26:30 -07002163#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07002164 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07002165#endif
2166
Jeff Johnson295189b2012-06-20 16:38:30 -07002167 // That done, pack the struct:
2168 if ( !wmmTspecPresent )
2169 {
2170 nStatus = dot11fPackDelTS( pMac, &DelTS,
2171 pFrame + sizeof( tSirMacMgmtHdr ),
2172 nPayload, &nPayload );
2173 if ( DOT11F_FAILED( nStatus ) )
2174 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002175 limLog( pMac, LOGE, FL("Failed to pack a Del TS frame (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002176 nStatus );
2177 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
2178 return; // allocated!
2179 }
2180 else if ( DOT11F_WARNED( nStatus ) )
2181 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08002182 limLog( pMac, LOGW, FL("There were warnings while packing "
2183 "a Del TS frame (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07002184 }
2185 }
2186 else
2187 {
2188 nStatus = dot11fPackWMMDelTS( pMac, &WMMDelTS,
2189 pFrame + sizeof( tSirMacMgmtHdr ),
2190 nPayload, &nPayload );
2191 if ( DOT11F_FAILED( nStatus ) )
2192 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002193 limLog( pMac, LOGE, FL("Failed to pack a WMM Del TS frame (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002194 nStatus );
2195 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
2196 return; // allocated!
2197 }
2198 else if ( DOT11F_WARNED( nStatus ) )
2199 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08002200 limLog( pMac, LOGW, FL("There were warnings while packing "
2201 "a WMM Del TS frame (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07002202 }
2203 }
2204
Abhishek Singh3cbf6052014-12-15 16:46:42 +05302205 limLog(pMac, LOG1, FL("Sending DELTS REQ (size %d) to "), nBytes);
2206 limPrintMacAddr(pMac, pMacHdr->da, LOG1);
Jeff Johnson295189b2012-06-20 16:38:30 -07002207
2208 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07002209 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
2210 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07002211 )
2212 {
2213 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
2214 }
2215
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05302216 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
2217 psessionEntry->peSessionId,
2218 pMacHdr->fc.subType));
Jeff Johnson295189b2012-06-20 16:38:30 -07002219 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
2220 HAL_TXRX_FRM_802_11_MGMT,
2221 ANI_TXDIR_TODS,
2222 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
2223 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05302224 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
2225 psessionEntry->peSessionId,
2226 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07002227 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
2228 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002229 limLog( pMac, LOGE, FL("Failed to send Del TS (%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002230 nSirStatus );
2231 //Pkt will be freed up by the callback
2232 }
2233
2234} // End limSendDeltsReqActionFrame.
2235
2236void
2237limSendAssocReqMgmtFrame(tpAniSirGlobal pMac,
2238 tLimMlmAssocReq *pMlmAssocReq,
2239 tpPESession psessionEntry)
2240{
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002241 tDot11fAssocRequest *pFrm;
Jeff Johnson295189b2012-06-20 16:38:30 -07002242 tANI_U16 caps;
2243 tANI_U8 *pFrame;
2244 tSirRetStatus nSirStatus;
2245 tLimMlmAssocCnf mlmAssocCnf;
c_hpothubcd78652014-04-28 22:31:08 +05302246 tANI_U32 nPayload, nStatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07002247 tANI_U8 fQosEnabled, fWmeEnabled, fWsmEnabled;
2248 void *pPacket;
2249 eHalStatus halstatus;
2250 tANI_U16 nAddIELen;
2251 tANI_U8 *pAddIE;
2252 tANI_U8 *wpsIe = NULL;
2253#if defined WLAN_FEATURE_VOWIFI
2254 tANI_U8 PowerCapsPopulated = FALSE;
2255#endif
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05302256 tANI_U32 txFlag = 0;
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05302257 tpSirMacMgmtHdr pMacHdr;
Kalikinkar dhara205da782014-03-21 15:49:32 -07002258 tDot11fIEExtCap extractedExtCap;
2259 tANI_BOOLEAN extractedExtCapFlag = eANI_BOOLEAN_TRUE;
c_hpothubcd78652014-04-28 22:31:08 +05302260 tANI_U32 nBytes = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002261
2262 if(NULL == psessionEntry)
2263 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05302264 limLog(pMac, LOGE, FL("psessionEntry is NULL") );
Jeff Johnson295189b2012-06-20 16:38:30 -07002265 return;
2266 }
2267
Jeff Johnson295189b2012-06-20 16:38:30 -07002268 /* check this early to avoid unncessary operation */
2269 if(NULL == psessionEntry->pLimJoinReq)
2270 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05302271 limLog(pMac, LOGE, FL("psessionEntry->pLimJoinReq is NULL") );
Jeff Johnson295189b2012-06-20 16:38:30 -07002272 return;
2273 }
2274 nAddIELen = psessionEntry->pLimJoinReq->addIEAssoc.length;
2275 pAddIE = psessionEntry->pLimJoinReq->addIEAssoc.addIEdata;
2276
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302277 pFrm = vos_mem_malloc(sizeof(tDot11fAssocRequest));
2278 if ( NULL == pFrm )
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002279 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05302280 limLog(pMac, LOGE, FL("Unable to allocate memory") );
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002281 return;
2282 }
2283
2284
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302285 vos_mem_set( ( tANI_U8* )pFrm, sizeof( tDot11fAssocRequest ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07002286
Kalikinkar dhara205da782014-03-21 15:49:32 -07002287 vos_mem_set(( tANI_U8* )&extractedExtCap, sizeof( tDot11fIEExtCap ), 0);
2288 nSirStatus = limStripOffExtCapIEAndUpdateStruct(pMac, pAddIE,
2289 &nAddIELen,
2290 &extractedExtCap );
2291 if(eSIR_SUCCESS != nSirStatus )
2292 {
2293 extractedExtCapFlag = eANI_BOOLEAN_FALSE;
2294 limLog(pMac, LOG1,
2295 FL("Unable to Stripoff ExtCap IE from Assoc Req"));
2296 }
Leela Venkata Kiran Kumar Reddy Chirala2f9b5712014-05-06 00:09:42 -07002297 /* TODO:remove this code once driver provides the call back function
2298 * to supplicant for set_qos_map
2299 */
2300 else
2301 {
2302 if(extractedExtCap.interworkingService)
2303 {
2304 extractedExtCap.qosMap = 1;
2305 }
Abhishek Singh15d95602015-03-24 15:52:57 +05302306 /* No need to merge the EXT Cap from Supplicant
2307 * if interworkingService is not set, as currently
2308 * driver is only interested in interworkingService
2309 * capability from supplicant. if in
2310 * future any other EXT Cap info is required from
2311 * supplicant it needs to be handled here.
2312 */
2313 else
2314 {
2315 extractedExtCapFlag = eANI_BOOLEAN_FALSE;
2316 }
Leela Venkata Kiran Kumar Reddy Chirala2f9b5712014-05-06 00:09:42 -07002317 }
Kalikinkar dhara205da782014-03-21 15:49:32 -07002318
Jeff Johnson295189b2012-06-20 16:38:30 -07002319 caps = pMlmAssocReq->capabilityInfo;
2320 if ( PROP_CAPABILITY_GET( 11EQOS, psessionEntry->limCurrentBssPropCap ) )
2321 ((tSirMacCapabilityInfo *) &caps)->qos = 0;
2322#if defined(FEATURE_WLAN_WAPI)
2323 /* CR: 262463 :
2324 According to WAPI standard:
2325 7.3.1.4 Capability Information field
2326 In WAPI, non-AP STAs within an ESS set the Privacy subfield to 0 in transmitted
2327 Association or Reassociation management frames. APs ignore the Privacy subfield within received Association and
2328 Reassociation management frames. */
2329 if ( psessionEntry->encryptType == eSIR_ED_WPI)
2330 ((tSirMacCapabilityInfo *) &caps)->privacy = 0;
2331#endif
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002332 swapBitField16(caps, ( tANI_U16* )&pFrm->Capabilities );
Jeff Johnson295189b2012-06-20 16:38:30 -07002333
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002334 pFrm->ListenInterval.interval = pMlmAssocReq->listenInterval;
2335 PopulateDot11fSSID2( pMac, &pFrm->SSID );
Jeff Johnson295189b2012-06-20 16:38:30 -07002336 PopulateDot11fSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002337 &pFrm->SuppRates,psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07002338
2339 fQosEnabled = ( psessionEntry->limQosEnabled) &&
2340 SIR_MAC_GET_QOS( psessionEntry->limCurrentBssCaps );
2341
2342 fWmeEnabled = ( psessionEntry->limWmeEnabled ) &&
2343 LIM_BSS_CAPS_GET( WME, psessionEntry->limCurrentBssQosCaps );
2344
2345 // We prefer .11e asociations:
2346 if ( fQosEnabled ) fWmeEnabled = false;
2347
2348 fWsmEnabled = ( psessionEntry->limWsmEnabled ) && fWmeEnabled &&
2349 LIM_BSS_CAPS_GET( WSM, psessionEntry->limCurrentBssQosCaps );
2350
2351 if ( psessionEntry->lim11hEnable &&
2352 psessionEntry->pLimJoinReq->spectrumMgtIndicator == eSIR_TRUE )
2353 {
2354#if defined WLAN_FEATURE_VOWIFI
2355 PowerCapsPopulated = TRUE;
2356
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002357 PopulateDot11fPowerCaps( pMac, &pFrm->PowerCaps, LIM_ASSOC,psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07002358#endif
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002359 PopulateDot11fSuppChannels( pMac, &pFrm->SuppChannels, LIM_ASSOC,psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07002360
2361 }
2362
2363#if defined WLAN_FEATURE_VOWIFI
2364 if( pMac->rrm.rrmPEContext.rrmEnable &&
2365 SIR_MAC_GET_RRM( psessionEntry->limCurrentBssCaps ) )
2366 {
2367 if (PowerCapsPopulated == FALSE)
2368 {
2369 PowerCapsPopulated = TRUE;
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002370 PopulateDot11fPowerCaps(pMac, &pFrm->PowerCaps, LIM_ASSOC, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07002371 }
2372 }
2373#endif
2374
2375 if ( fQosEnabled &&
2376 ( ! PROP_CAPABILITY_GET(11EQOS, psessionEntry->limCurrentBssPropCap)))
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002377 PopulateDot11fQOSCapsStation( pMac, &pFrm->QOSCapsStation );
Jeff Johnson295189b2012-06-20 16:38:30 -07002378
2379 PopulateDot11fExtSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002380 &pFrm->ExtSuppRates, psessionEntry );
Jeff Johnson295189b2012-06-20 16:38:30 -07002381
2382#if defined WLAN_FEATURE_VOWIFI
2383 if( pMac->rrm.rrmPEContext.rrmEnable &&
2384 SIR_MAC_GET_RRM( psessionEntry->limCurrentBssCaps ) )
2385 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002386 PopulateDot11fRRMIe( pMac, &pFrm->RRMEnabledCap, psessionEntry );
Jeff Johnson295189b2012-06-20 16:38:30 -07002387 }
2388#endif
2389 // The join request *should* contain zero or one of the WPA and RSN
2390 // IEs. The payload send along with the request is a
2391 // 'tSirSmeJoinReq'; the IE portion is held inside a 'tSirRSNie':
2392
2393 // typedef struct sSirRSNie
2394 // {
2395 // tANI_U16 length;
2396 // tANI_U8 rsnIEdata[SIR_MAC_MAX_IE_LENGTH+2];
2397 // } tSirRSNie, *tpSirRSNie;
2398
2399 // So, we should be able to make the following two calls harmlessly,
2400 // since they do nothing if they don't find the given IE in the
2401 // bytestream with which they're provided.
2402
2403 // The net effect of this will be to faithfully transmit whatever
2404 // security IE is in the join request.
2405
2406 // *However*, if we're associating for the purpose of WPS
2407 // enrollment, and we've been configured to indicate that by
2408 // eliding the WPA or RSN IE, we just skip this:
2409 if( nAddIELen && pAddIE )
2410 {
2411 wpsIe = limGetWscIEPtr (pMac, pAddIE, nAddIELen);
2412 }
2413 if ( NULL == wpsIe )
2414 {
2415 PopulateDot11fRSNOpaque( pMac, &( psessionEntry->pLimJoinReq->rsnIE ),
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002416 &pFrm->RSNOpaque );
Jeff Johnson295189b2012-06-20 16:38:30 -07002417 PopulateDot11fWPAOpaque( pMac, &( psessionEntry->pLimJoinReq->rsnIE ),
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002418 &pFrm->WPAOpaque );
Jeff Johnson295189b2012-06-20 16:38:30 -07002419#if defined(FEATURE_WLAN_WAPI)
2420 PopulateDot11fWAPIOpaque( pMac, &( psessionEntry->pLimJoinReq->rsnIE ),
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002421 &pFrm->WAPIOpaque );
Jeff Johnson295189b2012-06-20 16:38:30 -07002422#endif // defined(FEATURE_WLAN_WAPI)
2423 }
2424
2425 // include WME EDCA IE as well
2426 if ( fWmeEnabled )
2427 {
2428 if ( ! PROP_CAPABILITY_GET( WME, psessionEntry->limCurrentBssPropCap ) )
2429 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002430 PopulateDot11fWMMInfoStation( pMac, &pFrm->WMMInfoStation );
Jeff Johnson295189b2012-06-20 16:38:30 -07002431 }
2432
2433 if ( fWsmEnabled &&
2434 ( ! PROP_CAPABILITY_GET(WSM, psessionEntry->limCurrentBssPropCap )))
2435 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002436 PopulateDot11fWMMCaps( &pFrm->WMMCaps );
Jeff Johnson295189b2012-06-20 16:38:30 -07002437 }
2438 }
2439
2440 //Populate HT IEs, when operating in 11n or Taurus modes AND
2441 //when AP is also operating in 11n mode.
Jeff Johnsone7245742012-09-05 17:12:55 -07002442 if ( psessionEntry->htCapability &&
Jeff Johnson295189b2012-06-20 16:38:30 -07002443 pMac->lim.htCapabilityPresentInBeacon)
2444 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002445 PopulateDot11fHTCaps( pMac, psessionEntry, &pFrm->HTCaps );
Jeff Johnson295189b2012-06-20 16:38:30 -07002446#ifdef DISABLE_GF_FOR_INTEROP
2447
2448 /*
2449 * To resolve the interop problem with Broadcom AP,
2450 * where TQ STA could not pass traffic with GF enabled,
2451 * TQ STA will do Greenfield only with TQ AP, for
2452 * everybody else it will be turned off.
2453 */
2454
2455 if( (psessionEntry->pLimJoinReq != NULL) && (!psessionEntry->pLimJoinReq->bssDescription.aniIndicator))
2456 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05302457 limLog( pMac, LOG1, FL("Sending Assoc Req to Non-TQ AP,"
2458 " Turning off Greenfield"));
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002459 pFrm->HTCaps.greenField = WNI_CFG_GREENFIELD_CAPABILITY_DISABLE;
Jeff Johnson295189b2012-06-20 16:38:30 -07002460 }
2461#endif
2462
2463 }
Jeff Johnsone7245742012-09-05 17:12:55 -07002464#ifdef WLAN_FEATURE_11AC
2465 if ( psessionEntry->vhtCapability &&
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07002466 psessionEntry->vhtCapabilityPresentInBeacon)
Jeff Johnsone7245742012-09-05 17:12:55 -07002467 {
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07002468 limLog( pMac, LOG1, FL("Populate VHT IEs in Assoc Request"));
Abhishek Singh33f76ea2015-06-04 12:27:30 +05302469 PopulateDot11fVHTCaps( pMac, &pFrm->VHTCaps,
2470 psessionEntry->currentOperChannel, eSIR_FALSE );
Abhishek Singhe038dc62015-05-22 11:36:45 +05302471
2472 if (SIR_11B_CHANNEL_END >= psessionEntry->currentOperChannel)
2473 PopulateDot11fOperatingMode(pMac, &pFrm->OperatingMode,
2474 psessionEntry);
Jeff Johnsone7245742012-09-05 17:12:55 -07002475 }
2476#endif
Sandeep Puligilla60342762014-01-30 21:05:37 +05302477 PopulateDot11fExtCap( pMac, &pFrm->ExtCap, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07002478
2479#if defined WLAN_FEATURE_VOWIFI_11R
2480 if (psessionEntry->pLimJoinReq->is11Rconnection)
2481 {
2482#if defined WLAN_FEATURE_VOWIFI_11R_DEBUG
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002483 limLog( pMac, LOG1, FL("mdie = %02x %02x %02x"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002484 (unsigned int)psessionEntry->pLimJoinReq->bssDescription.mdie[0],
2485 (unsigned int)psessionEntry->pLimJoinReq->bssDescription.mdie[1],
2486 (unsigned int)psessionEntry->pLimJoinReq->bssDescription.mdie[2]);
2487#endif
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302488 PopulateMDIE( pMac, &pFrm->MobilityDomain,
2489 psessionEntry->pLimJoinReq->bssDescription.mdie);
Jeff Johnson295189b2012-06-20 16:38:30 -07002490 }
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302491 else
Jeff Johnson295189b2012-06-20 16:38:30 -07002492 {
2493 // No 11r IEs dont send any MDIE
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302494 limLog( pMac, LOG1, FL("MDIE not present"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002495 }
2496#endif
2497
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002498#ifdef FEATURE_WLAN_ESE
2499 /* For ESE Associations fill the ESE IEs */
2500 if (psessionEntry->isESEconnection &&
2501 psessionEntry->pLimJoinReq->isESEFeatureIniEnabled)
Jeff Johnson295189b2012-06-20 16:38:30 -07002502 {
Varun Reddy Yeturu30779b42013-04-09 09:57:16 -07002503#ifndef FEATURE_DISABLE_RM
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002504 PopulateDot11fESERadMgmtCap(&pFrm->ESERadMgmtCap);
Varun Reddy Yeturu30779b42013-04-09 09:57:16 -07002505#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002506 PopulateDot11fESEVersion(&pFrm->ESEVersion);
Jeff Johnson295189b2012-06-20 16:38:30 -07002507 }
2508#endif
2509
c_hpothubcd78652014-04-28 22:31:08 +05302510 /* merge the ExtCap struct*/
2511 if (extractedExtCapFlag && extractedExtCap.present)
2512 {
2513 limMergeExtCapIEStruct(&pFrm->ExtCap, &extractedExtCap);
2514 }
2515
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002516 nStatus = dot11fGetPackedAssocRequestSize( pMac, pFrm, &nPayload );
Jeff Johnson295189b2012-06-20 16:38:30 -07002517 if ( DOT11F_FAILED( nStatus ) )
2518 {
2519 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002520 "or an Association Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002521 nStatus );
2522 // We'll fall back on the worst case scenario:
2523 nPayload = sizeof( tDot11fAssocRequest );
2524 }
2525 else if ( DOT11F_WARNED( nStatus ) )
2526 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08002527 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07002528 "the packed size for an Association Re "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002529 "quest(0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07002530 }
2531
2532 nBytes = nPayload + sizeof( tSirMacMgmtHdr ) + nAddIELen;
2533
2534 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
2535 ( tANI_U16 )nBytes, ( void** ) &pFrame,
2536 ( void** ) &pPacket );
2537 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
2538 {
2539 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for an As"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002540 "sociation Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07002541
2542 psessionEntry->limMlmState = psessionEntry->limPrevMlmState;
Jeff Johnsone7245742012-09-05 17:12:55 -07002543 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07002544
2545
2546 /* Update PE session id*/
2547 mlmAssocCnf.sessionId = psessionEntry->peSessionId;
2548
2549 mlmAssocCnf.resultCode = eSIR_SME_RESOURCES_UNAVAILABLE;
2550
2551 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
2552 ( void* ) pFrame, ( void* ) pPacket );
2553
2554 limPostSmeMessage( pMac, LIM_MLM_ASSOC_CNF,
2555 ( tANI_U32* ) &mlmAssocCnf);
2556
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302557 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -07002558 return;
2559 }
2560
2561 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302562 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07002563
2564 // Next, we fill out the buffer descriptor:
2565 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
2566 SIR_MAC_MGMT_ASSOC_REQ, psessionEntry->bssId,psessionEntry->selfMacAddr);
2567 if ( eSIR_SUCCESS != nSirStatus )
2568 {
2569 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002570 "tor for an Association Request (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002571 nSirStatus );
2572 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302573 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -07002574 return;
2575 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002576
Abhishek Singh57aebef2014-02-03 18:47:44 +05302577 // That done, pack the Assoc Request:
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002578 nStatus = dot11fPackAssocRequest( pMac, pFrm, pFrame +
Jeff Johnson295189b2012-06-20 16:38:30 -07002579 sizeof(tSirMacMgmtHdr),
2580 nPayload, &nPayload );
2581 if ( DOT11F_FAILED( nStatus ) )
2582 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05302583 limLog( pMac, LOGE, FL("Failed to pack a Assoc Request (0x%0"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002584 "8x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002585 nStatus );
2586 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
2587 ( void* ) pFrame, ( void* ) pPacket );
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302588 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -07002589 return;
2590 }
2591 else if ( DOT11F_WARNED( nStatus ) )
2592 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05302593 limLog( pMac, LOGW, FL("There were warnings while packing a Assoc"
2594 "Request (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07002595 }
2596
2597 PELOG1(limLog( pMac, LOG1, FL("*** Sending Association Request length %d"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002598 "to "),
Jeff Johnson295189b2012-06-20 16:38:30 -07002599 nBytes );)
2600 // limPrintMacAddr( pMac, bssid, LOG1 );
2601
2602 if( psessionEntry->assocReq != NULL )
2603 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302604 vos_mem_free(psessionEntry->assocReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07002605 psessionEntry->assocReq = NULL;
2606 }
2607
2608 if( nAddIELen )
2609 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302610 vos_mem_copy( pFrame + sizeof(tSirMacMgmtHdr) + nPayload,
2611 pAddIE,
2612 nAddIELen );
Jeff Johnson295189b2012-06-20 16:38:30 -07002613 nPayload += nAddIELen;
2614 }
2615
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302616 psessionEntry->assocReq = vos_mem_malloc(nPayload);
2617 if ( NULL == psessionEntry->assocReq )
Jeff Johnson295189b2012-06-20 16:38:30 -07002618 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05302619 PELOGE(limLog(pMac, LOGE, FL("Unable to allocate memory to store "
2620 "assoc request"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07002621 }
2622 else
2623 {
2624 //Store the Assoc request. This is sent to csr/hdd in join cnf response.
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302625 vos_mem_copy( psessionEntry->assocReq, pFrame + sizeof(tSirMacMgmtHdr), nPayload);
Jeff Johnson295189b2012-06-20 16:38:30 -07002626 psessionEntry->assocReqLen = nPayload;
2627 }
2628
2629 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07002630 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
2631 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07002632 )
2633 {
2634 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
2635 }
2636
Sushant Kaushike8681d22015-04-21 12:08:25 +05302637 if(psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ||
2638 psessionEntry->pePersona == VOS_STA_MODE)
Ganesh K08bce952012-12-13 15:04:41 -08002639 {
2640 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
2641 }
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05302642
2643 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
Agarwal Ashisha8e81f52014-04-02 01:59:52 +05302644 limLog( pMac, LOG1, FL("Sending Assoc req over WQ5 to "MAC_ADDRESS_STR
2645 " From " MAC_ADDRESS_STR),MAC_ADDR_ARRAY(pMacHdr->da),
2646 MAC_ADDR_ARRAY(psessionEntry->selfMacAddr));
2647 txFlag |= HAL_USE_FW_IN_TX_PATH;
2648
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05302649 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
2650 psessionEntry->peSessionId,
2651 pMacHdr->fc.subType));
Katya Nigam63902932014-06-26 19:04:23 +05302652
Masti, Narayanraddi67ea5912015-01-08 12:34:05 +05302653 if( ( psessionEntry->is11Gonly == true ) &&
2654 ( !IS_BROADCAST_MAC(pMlmAssocReq->peerMacAddr) ) ){
2655 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
2656 }
Ganesh Kondabattiniffc00b12015-03-18 13:11:33 +05302657 if (IS_FEATURE_SUPPORTED_BY_FW(ENHANCED_TXBD_COMPLETION))
2658 {
2659 limLog(pMac, LOG1, FL("Assoc Req - txBdToken %u"), pMac->lim.txBdToken);
2660 halstatus = halTxFrameWithTxComplete( pMac, pPacket,
2661 ( tANI_U16 ) (sizeof(tSirMacMgmtHdr) + nPayload),
2662 HAL_TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS,
2663 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
2664 limTxComplete, pFrame, limTxBdComplete, txFlag,
2665 pMac->lim.txBdToken);
2666 pMac->lim.txBdToken++;
2667 }
2668 else
2669 {
2670 halstatus = halTxFrame( pMac, pPacket,
2671 ( tANI_U16 ) (sizeof(tSirMacMgmtHdr) + nPayload),
2672 HAL_TXRX_FRM_802_11_MGMT,
2673 ANI_TXDIR_TODS,
2674 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
2675 limTxComplete, pFrame, txFlag );
2676 }
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05302677 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
2678 psessionEntry->peSessionId,
2679 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07002680 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
2681 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002682 limLog( pMac, LOGE, FL("Failed to send Association Request (%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002683 halstatus );
2684 //Pkt will be freed up by the callback
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302685 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -07002686 return;
2687 }
2688
Katya Nigamccaeda72015-04-20 18:51:22 +05302689 //Enable caching only if Assoc Request is successfully submitted to the h/w
2690 WLANTL_EnableCaching(psessionEntry->staId);
2691
Jeff Johnson295189b2012-06-20 16:38:30 -07002692 // Free up buffer allocated for mlmAssocReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302693 vos_mem_free(pMlmAssocReq);
Leela Venkata Kiran Kumar Reddy Chiralad6c0fe22013-12-11 19:10:50 -08002694 pMlmAssocReq = NULL;
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302695 vos_mem_free(pFrm);
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002696 return;
Jeff Johnson295189b2012-06-20 16:38:30 -07002697} // End limSendAssocReqMgmtFrame
2698
2699
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002700#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07002701/*------------------------------------------------------------------------------------
2702 *
2703 * Send Reassoc Req with FTIEs.
2704 *
2705 *-----------------------------------------------------------------------------------
2706 */
2707void
2708limSendReassocReqWithFTIEsMgmtFrame(tpAniSirGlobal pMac,
2709 tLimMlmReassocReq *pMlmReassocReq,tpPESession psessionEntry)
2710{
2711 static tDot11fReAssocRequest frm;
2712 tANI_U16 caps;
2713 tANI_U8 *pFrame;
2714 tSirRetStatus nSirStatus;
2715 tANI_U32 nBytes, nPayload, nStatus;
2716 tANI_U8 fQosEnabled, fWmeEnabled, fWsmEnabled;
2717 void *pPacket;
2718 eHalStatus halstatus;
2719#if defined WLAN_FEATURE_VOWIFI
2720 tANI_U8 PowerCapsPopulated = FALSE;
2721#endif
2722 tANI_U16 ft_ies_length = 0;
2723 tANI_U8 *pBody;
2724 tANI_U16 nAddIELen;
2725 tANI_U8 *pAddIE;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002726#if defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07002727 tANI_U8 *wpsIe = NULL;
2728#endif
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05302729 tANI_U32 txFlag = 0;
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05302730 tpSirMacMgmtHdr pMacHdr;
Jeff Johnson295189b2012-06-20 16:38:30 -07002731
2732 if (NULL == psessionEntry)
2733 {
2734 return;
2735 }
2736
Jeff Johnson295189b2012-06-20 16:38:30 -07002737 /* check this early to avoid unncessary operation */
2738 if(NULL == psessionEntry->pLimReAssocReq)
2739 {
2740 return;
2741 }
2742 nAddIELen = psessionEntry->pLimReAssocReq->addIEAssoc.length;
2743 pAddIE = psessionEntry->pLimReAssocReq->addIEAssoc.addIEdata;
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08002744 limLog( pMac, LOG1, FL("limSendReassocReqWithFTIEsMgmtFrame received in "
2745 "state (%d)."), psessionEntry->limMlmState);
Jeff Johnson295189b2012-06-20 16:38:30 -07002746
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302747 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07002748
2749 caps = pMlmReassocReq->capabilityInfo;
2750 if (PROP_CAPABILITY_GET(11EQOS, psessionEntry->limReassocBssPropCap))
2751 ((tSirMacCapabilityInfo *) &caps)->qos = 0;
2752#if defined(FEATURE_WLAN_WAPI)
2753 /* CR: 262463 :
2754 According to WAPI standard:
2755 7.3.1.4 Capability Information field
2756 In WAPI, non-AP STAs within an ESS set the Privacy subfield to 0 in transmitted
2757 Association or Reassociation management frames. APs ignore the Privacy subfield within received Association and
2758 Reassociation management frames. */
2759 if ( psessionEntry->encryptType == eSIR_ED_WPI)
2760 ((tSirMacCapabilityInfo *) &caps)->privacy = 0;
2761#endif
2762 swapBitField16(caps, ( tANI_U16* )&frm.Capabilities );
2763
2764 frm.ListenInterval.interval = pMlmReassocReq->listenInterval;
2765
2766 // Get the old bssid of the older AP.
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302767 vos_mem_copy( ( tANI_U8* )frm.CurrentAPAddress.mac,
Jeff Johnson295189b2012-06-20 16:38:30 -07002768 pMac->ft.ftPEContext.pFTPreAuthReq->currbssId, 6);
2769
2770 PopulateDot11fSSID2( pMac, &frm.SSID );
2771 PopulateDot11fSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
2772 &frm.SuppRates,psessionEntry);
2773
2774 fQosEnabled = ( psessionEntry->limQosEnabled) &&
2775 SIR_MAC_GET_QOS( psessionEntry->limReassocBssCaps );
2776
2777 fWmeEnabled = ( psessionEntry->limWmeEnabled ) &&
2778 LIM_BSS_CAPS_GET( WME, psessionEntry->limReassocBssQosCaps );
2779
2780 fWsmEnabled = ( psessionEntry->limWsmEnabled ) && fWmeEnabled &&
2781 LIM_BSS_CAPS_GET( WSM, psessionEntry->limReassocBssQosCaps );
2782
2783 if ( psessionEntry->lim11hEnable &&
2784 psessionEntry->pLimReAssocReq->spectrumMgtIndicator == eSIR_TRUE )
2785 {
2786#if defined WLAN_FEATURE_VOWIFI
2787 PowerCapsPopulated = TRUE;
2788
2789 PopulateDot11fPowerCaps( pMac, &frm.PowerCaps, LIM_REASSOC,psessionEntry);
2790 PopulateDot11fSuppChannels( pMac, &frm.SuppChannels, LIM_REASSOC,psessionEntry);
2791#endif
2792 }
2793
2794#if defined WLAN_FEATURE_VOWIFI
2795 if( pMac->rrm.rrmPEContext.rrmEnable &&
2796 SIR_MAC_GET_RRM( psessionEntry->limCurrentBssCaps ) )
2797 {
2798 if (PowerCapsPopulated == FALSE)
2799 {
2800 PowerCapsPopulated = TRUE;
2801 PopulateDot11fPowerCaps(pMac, &frm.PowerCaps, LIM_REASSOC, psessionEntry);
2802 }
2803 }
2804#endif
2805
2806 if ( fQosEnabled &&
2807 ( ! PROP_CAPABILITY_GET(11EQOS, psessionEntry->limReassocBssPropCap ) ))
2808 {
2809 PopulateDot11fQOSCapsStation( pMac, &frm.QOSCapsStation );
2810 }
2811
2812 PopulateDot11fExtSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
2813 &frm.ExtSuppRates, psessionEntry );
2814
2815#if defined WLAN_FEATURE_VOWIFI
2816 if( pMac->rrm.rrmPEContext.rrmEnable &&
2817 SIR_MAC_GET_RRM( psessionEntry->limReassocBssCaps ) )
2818 {
2819 PopulateDot11fRRMIe( pMac, &frm.RRMEnabledCap, psessionEntry );
2820 }
2821#endif
2822
2823 // Ideally this should be enabled for 11r also. But 11r does
2824 // not follow the usual norm of using the Opaque object
2825 // for rsnie and fties. Instead we just add
2826 // the rsnie and fties at the end of the pack routine for 11r.
2827 // This should ideally! be fixed.
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002828#if defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07002829 //
2830 // The join request *should* contain zero or one of the WPA and RSN
2831 // IEs. The payload send along with the request is a
2832 // 'tSirSmeJoinReq'; the IE portion is held inside a 'tSirRSNie':
2833
2834 // typedef struct sSirRSNie
2835 // {
2836 // tANI_U16 length;
2837 // tANI_U8 rsnIEdata[SIR_MAC_MAX_IE_LENGTH+2];
2838 // } tSirRSNie, *tpSirRSNie;
2839
2840 // So, we should be able to make the following two calls harmlessly,
2841 // since they do nothing if they don't find the given IE in the
2842 // bytestream with which they're provided.
2843
2844 // The net effect of this will be to faithfully transmit whatever
2845 // security IE is in the join request.
2846
2847 // *However*, if we're associating for the purpose of WPS
2848 // enrollment, and we've been configured to indicate that by
2849 // eliding the WPA or RSN IE, we just skip this:
2850 if (!psessionEntry->is11Rconnection)
2851 {
2852 if( nAddIELen && pAddIE )
2853 {
2854 wpsIe = limGetWscIEPtr(pMac, pAddIE, nAddIELen);
2855 }
2856 if ( NULL == wpsIe )
2857 {
2858 PopulateDot11fRSNOpaque( pMac, &( psessionEntry->pLimReAssocReq->rsnIE ),
2859 &frm.RSNOpaque );
2860 PopulateDot11fWPAOpaque( pMac, &( psessionEntry->pLimReAssocReq->rsnIE ),
2861 &frm.WPAOpaque );
2862 }
2863
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002864#ifdef FEATURE_WLAN_ESE
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302865 if (psessionEntry->pLimReAssocReq->cckmIE.length)
Jeff Johnson295189b2012-06-20 16:38:30 -07002866 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002867 PopulateDot11fESECckmOpaque( pMac, &( psessionEntry->pLimReAssocReq->cckmIE ),
2868 &frm.ESECckmOpaque );
Jeff Johnson295189b2012-06-20 16:38:30 -07002869 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002870#endif //FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07002871 }
2872
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002873#ifdef FEATURE_WLAN_ESE
2874 // For ESE Associations fill the ESE IEs
2875 if (psessionEntry->isESEconnection &&
2876 psessionEntry->pLimReAssocReq->isESEFeatureIniEnabled)
Jeff Johnson295189b2012-06-20 16:38:30 -07002877 {
Varun Reddy Yeturu30779b42013-04-09 09:57:16 -07002878#ifndef FEATURE_DISABLE_RM
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002879 PopulateDot11fESERadMgmtCap(&frm.ESERadMgmtCap);
Varun Reddy Yeturu30779b42013-04-09 09:57:16 -07002880#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002881 PopulateDot11fESEVersion(&frm.ESEVersion);
Jeff Johnson295189b2012-06-20 16:38:30 -07002882 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002883#endif //FEATURE_WLAN_ESE
2884#endif //FEATURE_WLAN_ESE || FEATURE_WLAN_LFR
Jeff Johnson295189b2012-06-20 16:38:30 -07002885
2886 // include WME EDCA IE as well
2887 if ( fWmeEnabled )
2888 {
2889 if ( ! PROP_CAPABILITY_GET( WME, psessionEntry->limReassocBssPropCap ) )
2890 {
2891 PopulateDot11fWMMInfoStation( pMac, &frm.WMMInfoStation );
2892 }
2893
2894 if ( fWsmEnabled &&
2895 ( ! PROP_CAPABILITY_GET(WSM, psessionEntry->limReassocBssPropCap )))
2896 {
2897 PopulateDot11fWMMCaps( &frm.WMMCaps );
2898 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002899#ifdef FEATURE_WLAN_ESE
2900 if (psessionEntry->isESEconnection)
Jeff Johnson295189b2012-06-20 16:38:30 -07002901 {
2902 PopulateDot11fReAssocTspec(pMac, &frm, psessionEntry);
2903
2904 // Populate the TSRS IE if TSPEC is included in the reassoc request
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002905 if (psessionEntry->pLimReAssocReq->eseTspecInfo.numTspecs)
Jeff Johnson295189b2012-06-20 16:38:30 -07002906 {
2907 tANI_U32 phyMode;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002908 tSirMacESETSRSIE tsrsIE;
Jeff Johnson295189b2012-06-20 16:38:30 -07002909 limGetPhyMode(pMac, &phyMode, psessionEntry);
2910
2911 tsrsIE.tsid = 0;
2912 if( phyMode == WNI_CFG_PHY_MODE_11G || phyMode == WNI_CFG_PHY_MODE_11A)
2913 {
2914 tsrsIE.rates[0] = TSRS_11AG_RATE_6MBPS;
2915 }
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302916 else
Jeff Johnson295189b2012-06-20 16:38:30 -07002917 {
2918 tsrsIE.rates[0] = TSRS_11B_RATE_5_5MBPS;
2919 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002920 PopulateDot11TSRSIE(pMac,&tsrsIE, &frm.ESETrafStrmRateSet, sizeof(tANI_U8));
Jeff Johnson295189b2012-06-20 16:38:30 -07002921 }
2922 }
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302923#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002924 }
2925
Jeff Johnsone7245742012-09-05 17:12:55 -07002926 if ( psessionEntry->htCapability &&
Jeff Johnson295189b2012-06-20 16:38:30 -07002927 pMac->lim.htCapabilityPresentInBeacon)
2928 {
Jeff Johnsone7245742012-09-05 17:12:55 -07002929 PopulateDot11fHTCaps( pMac, psessionEntry, &frm.HTCaps );
Jeff Johnson295189b2012-06-20 16:38:30 -07002930 }
2931
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08002932#if defined WLAN_FEATURE_VOWIFI_11R
Kanchanapally, Vidyullatha4f84f682014-04-29 20:40:34 +05302933 if ( psessionEntry->pLimReAssocReq->bssDescription.mdiePresent &&
2934 (pMac->ft.ftSmeContext.addMDIE == TRUE)
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002935#if defined FEATURE_WLAN_ESE
2936 && !psessionEntry->isESEconnection
Gopichand Nakkala0ac55062013-04-08 14:43:07 +05302937#endif
2938 )
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08002939 {
2940 PopulateMDIE( pMac, &frm.MobilityDomain, psessionEntry->pLimReAssocReq->bssDescription.mdie);
2941 }
2942#endif
2943
Chet Lanctotf19c1f62013-12-13 13:56:21 -08002944#ifdef WLAN_FEATURE_11AC
2945 if ( psessionEntry->vhtCapability &&
2946 psessionEntry->vhtCapabilityPresentInBeacon)
2947 {
2948 limLog( pMac, LOG1, FL("Populate VHT IEs in Re-Assoc Request"));
Abhishek Singh33f76ea2015-06-04 12:27:30 +05302949 PopulateDot11fVHTCaps( pMac, &frm.VHTCaps,
2950 psessionEntry->currentOperChannel, eSIR_FALSE );
Abhishek Singhe038dc62015-05-22 11:36:45 +05302951
2952 if (SIR_11B_CHANNEL_END >= psessionEntry->currentOperChannel)
2953 PopulateDot11fOperatingMode(pMac, &frm.OperatingMode,
2954 psessionEntry);
Chet Lanctotf19c1f62013-12-13 13:56:21 -08002955 }
2956#endif
Sandeep Puligilla60342762014-01-30 21:05:37 +05302957 PopulateDot11fExtCap( pMac, &frm.ExtCap, psessionEntry);
Chet Lanctotf19c1f62013-12-13 13:56:21 -08002958
Jeff Johnson295189b2012-06-20 16:38:30 -07002959 nStatus = dot11fGetPackedReAssocRequestSize( pMac, &frm, &nPayload );
2960 if ( DOT11F_FAILED( nStatus ) )
2961 {
2962 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002963 "or a Re-Association Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002964 nStatus );
2965 // We'll fall back on the worst case scenario:
2966 nPayload = sizeof( tDot11fReAssocRequest );
2967 }
2968 else if ( DOT11F_WARNED( nStatus ) )
2969 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08002970 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07002971 "the packed size for a Re-Association Re "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002972 "quest(0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07002973 }
2974
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07002975 nBytes = nPayload + sizeof( tSirMacMgmtHdr ) + nAddIELen;
Jeff Johnson295189b2012-06-20 16:38:30 -07002976
2977#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08002978 limLog( pMac, LOG1, FL("FT IE Reassoc Req (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002979 pMac->ft.ftSmeContext.reassoc_ft_ies_length);
2980#endif
2981
2982#if defined WLAN_FEATURE_VOWIFI_11R
2983 if (psessionEntry->is11Rconnection)
2984 {
2985 ft_ies_length = pMac->ft.ftSmeContext.reassoc_ft_ies_length;
2986 }
2987#endif
2988
2989 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
2990 ( tANI_U16 )nBytes+ft_ies_length, ( void** ) &pFrame,
2991 ( void** ) &pPacket );
2992 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
2993 {
2994 psessionEntry->limMlmState = psessionEntry->limPrevMlmState;
Jeff Johnsone7245742012-09-05 17:12:55 -07002995 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07002996 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Re-As"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002997 "sociation Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07002998 goto end;
2999 }
3000
3001 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303002 vos_mem_set( pFrame, nBytes + ft_ies_length, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07003003
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003004#if defined WLAN_FEATURE_VOWIFI_11R_DEBUG || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08003005 limPrintMacAddr(pMac, psessionEntry->limReAssocbssId, LOG1);
Jeff Johnson295189b2012-06-20 16:38:30 -07003006#endif
3007 // Next, we fill out the buffer descriptor:
3008 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
3009 SIR_MAC_MGMT_REASSOC_REQ,
3010 psessionEntry->limReAssocbssId,psessionEntry->selfMacAddr);
3011 if ( eSIR_SUCCESS != nSirStatus )
3012 {
3013 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003014 "tor for an Association Request (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003015 nSirStatus );
3016 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
3017 goto end;
3018 }
3019
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05303020 pMacHdr = (tpSirMacMgmtHdr) pFrame;
Jeff Johnson295189b2012-06-20 16:38:30 -07003021 // That done, pack the ReAssoc Request:
3022 nStatus = dot11fPackReAssocRequest( pMac, &frm, pFrame +
3023 sizeof(tSirMacMgmtHdr),
3024 nPayload, &nPayload );
3025 if ( DOT11F_FAILED( nStatus ) )
3026 {
3027 limLog( pMac, LOGE, FL("Failed to pack a Re-Association Reque"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003028 "st (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003029 nStatus );
3030 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
3031 goto end;
3032 }
3033 else if ( DOT11F_WARNED( nStatus ) )
3034 {
3035 limLog( pMac, LOGW, FL("There were warnings while packing a R"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08003036 "e-Association Request (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07003037 }
3038
3039 PELOG3(limLog( pMac, LOG3,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003040 FL("*** Sending Re-Association Request length %d %d to "),
Jeff Johnson295189b2012-06-20 16:38:30 -07003041 nBytes, nPayload );)
3042 if( psessionEntry->assocReq != NULL )
3043 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303044 vos_mem_free(psessionEntry->assocReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07003045 psessionEntry->assocReq = NULL;
3046 }
3047
3048 if( nAddIELen )
3049 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303050 vos_mem_copy( pFrame + sizeof(tSirMacMgmtHdr) + nPayload,
3051 pAddIE,
3052 nAddIELen );
Jeff Johnson295189b2012-06-20 16:38:30 -07003053 nPayload += nAddIELen;
3054 }
3055
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303056 psessionEntry->assocReq = vos_mem_malloc(nPayload);
3057 if ( NULL == psessionEntry->assocReq )
Jeff Johnson295189b2012-06-20 16:38:30 -07003058 {
3059 PELOGE(limLog(pMac, LOGE, FL("Unable to allocate memory to store assoc request"));)
Jeff Johnson43971f52012-07-17 12:26:56 -07003060 }
3061 else
3062 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003063 //Store the Assoc request. This is sent to csr/hdd in join cnf response.
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303064 vos_mem_copy( psessionEntry->assocReq, pFrame + sizeof(tSirMacMgmtHdr), nPayload);
Jeff Johnson295189b2012-06-20 16:38:30 -07003065 psessionEntry->assocReqLen = nPayload;
Jeff Johnson43971f52012-07-17 12:26:56 -07003066 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003067
3068 if (psessionEntry->is11Rconnection)
3069 {
3070 {
3071 int i = 0;
3072
3073 pBody = pFrame + nBytes;
3074 for (i=0; i<ft_ies_length; i++)
3075 {
3076 *pBody = pMac->ft.ftSmeContext.reassoc_ft_ies[i];
3077 pBody++;
3078 }
3079 }
3080 }
3081
3082#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08003083 PELOGE(limLog(pMac, LOG1, FL("Re-assoc Req Frame is: "));
3084 sirDumpBuf(pMac, SIR_LIM_MODULE_ID, LOG1,
Jeff Johnson295189b2012-06-20 16:38:30 -07003085 (tANI_U8 *)pFrame,
3086 (nBytes + ft_ies_length));)
3087#endif
3088
3089
3090 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07003091 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
3092 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07003093 )
3094 {
3095 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
3096 }
3097
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07003098 if( NULL != psessionEntry->assocReq )
3099 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303100 vos_mem_free(psessionEntry->assocReq);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07003101 psessionEntry->assocReq = NULL;
3102 }
3103
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303104 psessionEntry->assocReq = vos_mem_malloc(ft_ies_length);
3105 if ( NULL == psessionEntry->assocReq )
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07003106 {
3107 PELOGE(limLog(pMac, LOGE, FL("Unable to allocate memory to store assoc request"));)
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08003108 psessionEntry->assocReqLen = 0;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07003109 }
3110 else
3111 {
3112 //Store the Assoc request. This is sent to csr/hdd in join cnf response.
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303113 vos_mem_copy( psessionEntry->assocReq, pMac->ft.ftSmeContext.reassoc_ft_ies,
3114 (ft_ies_length));
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07003115 psessionEntry->assocReqLen = (ft_ies_length);
3116 }
3117
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05303118 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
3119 psessionEntry->peSessionId,
3120 pMacHdr->fc.subType));
Ganesh Kondabattiniffc00b12015-03-18 13:11:33 +05303121 if (IS_FEATURE_SUPPORTED_BY_FW(ENHANCED_TXBD_COMPLETION))
3122 {
3123 limLog( pMac, LOG1, FL("Reassoc req - txBdToken %u"), pMac->lim.txBdToken);
3124 halstatus = halTxFrameWithTxComplete( pMac, pPacket,
3125 ( tANI_U16 ) (nBytes + ft_ies_length),
3126 HAL_TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS,
3127 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
3128 limTxComplete, pFrame, limTxBdComplete, txFlag,
3129 pMac->lim.txBdToken);
3130 pMac->lim.txBdToken++;
3131 }
3132 else
3133 {
3134 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) (nBytes + ft_ies_length),
3135 HAL_TXRX_FRM_802_11_MGMT,
3136 ANI_TXDIR_TODS,
3137 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
3138 limTxComplete, pFrame, txFlag );
3139 }
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05303140 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
3141 psessionEntry->peSessionId,
3142 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07003143 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3144 {
3145 limLog( pMac, LOGE, FL("Failed to send Re-Association Request"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003146 "(%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07003147 nSirStatus );
3148 //Pkt will be freed up by the callback
3149 goto end;
3150 }
3151
Katya Nigamccaeda72015-04-20 18:51:22 +05303152 // Enable TL cahching in case of roaming
3153 WLANTL_EnableCaching(psessionEntry->staId);
3154
Jeff Johnson295189b2012-06-20 16:38:30 -07003155end:
3156 // Free up buffer allocated for mlmAssocReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303157 vos_mem_free( pMlmReassocReq );
Jeff Johnson295189b2012-06-20 16:38:30 -07003158 psessionEntry->pLimMlmReassocReq = NULL;
3159
3160}
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -07003161
3162void limSendRetryReassocReqFrame(tpAniSirGlobal pMac,
3163 tLimMlmReassocReq *pMlmReassocReq,
3164 tpPESession psessionEntry)
3165{
3166 tLimMlmReassocCnf mlmReassocCnf; // keep sme
3167 tLimMlmReassocReq *pTmpMlmReassocReq = NULL;
Sachin Ahuja07a43012015-01-30 17:04:38 +05303168#ifdef FEATURE_WLAN_ESE
3169 tANI_U32 val=0;
3170#endif
3171 if (pMlmReassocReq == NULL)
3172 {
3173 limLog(pMac, LOGE,
3174 FL("Invalid pMlmReassocReq"));
3175 goto end;
3176 }
Hema Aparna Medicharla43d0f7b2015-02-12 17:07:59 +05303177
3178 pTmpMlmReassocReq = vos_mem_malloc(sizeof(tLimMlmReassocReq));
3179 if ( NULL == pTmpMlmReassocReq ) goto end;
3180 vos_mem_set( pTmpMlmReassocReq, sizeof(tLimMlmReassocReq), 0);
3181 vos_mem_copy( pTmpMlmReassocReq, pMlmReassocReq, sizeof(tLimMlmReassocReq));
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -07003182
3183 // Prepare and send Reassociation request frame
3184 // start reassoc timer.
Sachin Ahuja07a43012015-01-30 17:04:38 +05303185#ifdef FEATURE_WLAN_ESE
3186 /*
3187 * In case of Ese Reassociation, change the reassoc timer
3188 * value.
3189 */
3190 val = pMlmReassocReq->reassocFailureTimeout;
3191 if (psessionEntry->isESEconnection)
3192 {
3193 val = val/LIM_MAX_REASSOC_RETRY_LIMIT;
3194 }
3195 if (tx_timer_deactivate(&pMac->lim.limTimers.gLimReassocFailureTimer) !=
3196 TX_SUCCESS)
3197 {
3198 limLog(pMac, LOGP,
3199 FL("unable to deactivate Reassoc failure timer"));
3200 }
3201 val = SYS_MS_TO_TICKS(val);
3202 if (tx_timer_change(&pMac->lim.limTimers.gLimReassocFailureTimer,
3203 val, 0) != TX_SUCCESS)
3204 {
3205 limLog(pMac, LOGP,
3206 FL("unable to change Reassociation failure timer"));
3207 }
3208#endif
3209
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -07003210 pMac->lim.limTimers.gLimReassocFailureTimer.sessionId = psessionEntry->peSessionId;
3211 // Start reassociation failure timer
Leela V Kiran Kumar Reddy Chiralac3b9d382013-01-31 20:49:53 -08003212 MTRACE(macTrace(pMac, TRACE_CODE_TIMER_ACTIVATE, psessionEntry->peSessionId, eLIM_REASSOC_FAIL_TIMER));
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -07003213 if (tx_timer_activate(&pMac->lim.limTimers.gLimReassocFailureTimer)
3214 != TX_SUCCESS)
3215 {
3216 // Could not start reassoc failure timer.
3217 // Log error
3218 limLog(pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003219 FL("could not start Reassociation failure timer"));
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -07003220 // Return Reassoc confirm with
3221 // Resources Unavailable
3222 mlmReassocCnf.resultCode = eSIR_SME_RESOURCES_UNAVAILABLE;
3223 mlmReassocCnf.protStatusCode = eSIR_MAC_UNSPEC_FAILURE_STATUS;
3224 goto end;
3225 }
3226
3227 limSendReassocReqWithFTIEsMgmtFrame(pMac, pTmpMlmReassocReq, psessionEntry);
3228 return;
3229
3230end:
3231 // Free up buffer allocated for reassocReq
3232 if (pMlmReassocReq != NULL)
3233 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303234 vos_mem_free(pMlmReassocReq);
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -07003235 pMlmReassocReq = NULL;
3236 }
3237 if (pTmpMlmReassocReq != NULL)
3238 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303239 vos_mem_free(pTmpMlmReassocReq);
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -07003240 pTmpMlmReassocReq = NULL;
3241 }
3242 mlmReassocCnf.resultCode = eSIR_SME_FT_REASSOC_FAILURE;
3243 mlmReassocCnf.protStatusCode = eSIR_MAC_UNSPEC_FAILURE_STATUS;
3244 /* Update PE sessio Id*/
3245 mlmReassocCnf.sessionId = psessionEntry->peSessionId;
3246
3247 limPostSmeMessage(pMac, LIM_MLM_REASSOC_CNF, (tANI_U32 *) &mlmReassocCnf);
3248}
3249
Jeff Johnson295189b2012-06-20 16:38:30 -07003250#endif /* WLAN_FEATURE_VOWIFI_11R */
3251
3252
3253void
3254limSendReassocReqMgmtFrame(tpAniSirGlobal pMac,
3255 tLimMlmReassocReq *pMlmReassocReq,tpPESession psessionEntry)
3256{
3257 static tDot11fReAssocRequest frm;
3258 tANI_U16 caps;
3259 tANI_U8 *pFrame;
3260 tSirRetStatus nSirStatus;
3261 tANI_U32 nBytes, nPayload, nStatus;
3262 tANI_U8 fQosEnabled, fWmeEnabled, fWsmEnabled;
3263 void *pPacket;
3264 eHalStatus halstatus;
3265 tANI_U16 nAddIELen;
3266 tANI_U8 *pAddIE;
3267 tANI_U8 *wpsIe = NULL;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05303268 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003269#if defined WLAN_FEATURE_VOWIFI
3270 tANI_U8 PowerCapsPopulated = FALSE;
3271#endif
Ganesh Kondabattiniffc00b12015-03-18 13:11:33 +05303272 tpSirMacMgmtHdr pMacHdr;
Jeff Johnson295189b2012-06-20 16:38:30 -07003273
3274 if(NULL == psessionEntry)
3275 {
3276 return;
3277 }
3278
3279 /* check this early to avoid unncessary operation */
3280 if(NULL == psessionEntry->pLimReAssocReq)
3281 {
3282 return;
3283 }
3284 nAddIELen = psessionEntry->pLimReAssocReq->addIEAssoc.length;
3285 pAddIE = psessionEntry->pLimReAssocReq->addIEAssoc.addIEdata;
3286
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303287 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07003288
3289 caps = pMlmReassocReq->capabilityInfo;
3290 if (PROP_CAPABILITY_GET(11EQOS, psessionEntry->limReassocBssPropCap))
3291 ((tSirMacCapabilityInfo *) &caps)->qos = 0;
3292#if defined(FEATURE_WLAN_WAPI)
3293 /* CR: 262463 :
3294 According to WAPI standard:
3295 7.3.1.4 Capability Information field
3296 In WAPI, non-AP STAs within an ESS set the Privacy subfield to 0 in transmitted
3297 Association or Reassociation management frames. APs ignore the Privacy subfield within received Association and
3298 Reassociation management frames. */
3299 if ( psessionEntry->encryptType == eSIR_ED_WPI)
3300 ((tSirMacCapabilityInfo *) &caps)->privacy = 0;
3301#endif
3302 swapBitField16(caps, ( tANI_U16* )&frm.Capabilities );
3303
3304 frm.ListenInterval.interval = pMlmReassocReq->listenInterval;
3305
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303306 vos_mem_copy(( tANI_U8* )frm.CurrentAPAddress.mac,
3307 ( tANI_U8* )psessionEntry->bssId, 6 );
Jeff Johnson295189b2012-06-20 16:38:30 -07003308
3309 PopulateDot11fSSID2( pMac, &frm.SSID );
3310 PopulateDot11fSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
3311 &frm.SuppRates,psessionEntry);
3312
3313 fQosEnabled = ( psessionEntry->limQosEnabled ) &&
3314 SIR_MAC_GET_QOS( psessionEntry->limReassocBssCaps );
3315
3316 fWmeEnabled = ( psessionEntry->limWmeEnabled ) &&
3317 LIM_BSS_CAPS_GET( WME, psessionEntry->limReassocBssQosCaps );
3318
3319 fWsmEnabled = ( psessionEntry->limWsmEnabled ) && fWmeEnabled &&
3320 LIM_BSS_CAPS_GET( WSM, psessionEntry->limReassocBssQosCaps );
3321
3322
3323 if ( psessionEntry->lim11hEnable &&
3324 psessionEntry->pLimReAssocReq->spectrumMgtIndicator == eSIR_TRUE )
3325 {
3326#if defined WLAN_FEATURE_VOWIFI
3327 PowerCapsPopulated = TRUE;
3328 PopulateDot11fPowerCaps( pMac, &frm.PowerCaps, LIM_REASSOC,psessionEntry);
3329 PopulateDot11fSuppChannels( pMac, &frm.SuppChannels, LIM_REASSOC,psessionEntry);
3330#endif
3331 }
3332
3333#if defined WLAN_FEATURE_VOWIFI
3334 if( pMac->rrm.rrmPEContext.rrmEnable &&
3335 SIR_MAC_GET_RRM( psessionEntry->limCurrentBssCaps ) )
3336 {
3337 if (PowerCapsPopulated == FALSE)
3338 {
3339 PowerCapsPopulated = TRUE;
3340 PopulateDot11fPowerCaps(pMac, &frm.PowerCaps, LIM_REASSOC, psessionEntry);
3341 }
3342 }
3343#endif
3344
3345 if ( fQosEnabled &&
3346 ( ! PROP_CAPABILITY_GET(11EQOS, psessionEntry->limReassocBssPropCap ) ))
3347 {
3348 PopulateDot11fQOSCapsStation( pMac, &frm.QOSCapsStation );
3349 }
3350
3351 PopulateDot11fExtSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
3352 &frm.ExtSuppRates, psessionEntry );
3353
3354#if defined WLAN_FEATURE_VOWIFI
3355 if( pMac->rrm.rrmPEContext.rrmEnable &&
3356 SIR_MAC_GET_RRM( psessionEntry->limReassocBssCaps ) )
3357 {
3358 PopulateDot11fRRMIe( pMac, &frm.RRMEnabledCap, psessionEntry );
3359 }
3360#endif
3361 // The join request *should* contain zero or one of the WPA and RSN
3362 // IEs. The payload send along with the request is a
3363 // 'tSirSmeJoinReq'; the IE portion is held inside a 'tSirRSNie':
3364
3365 // typedef struct sSirRSNie
3366 // {
3367 // tANI_U16 length;
3368 // tANI_U8 rsnIEdata[SIR_MAC_MAX_IE_LENGTH+2];
3369 // } tSirRSNie, *tpSirRSNie;
3370
3371 // So, we should be able to make the following two calls harmlessly,
3372 // since they do nothing if they don't find the given IE in the
3373 // bytestream with which they're provided.
3374
3375 // The net effect of this will be to faithfully transmit whatever
3376 // security IE is in the join request.
3377
3378 // *However*, if we're associating for the purpose of WPS
3379 // enrollment, and we've been configured to indicate that by
3380 // eliding the WPA or RSN IE, we just skip this:
3381 if( nAddIELen && pAddIE )
3382 {
3383 wpsIe = limGetWscIEPtr(pMac, pAddIE, nAddIELen);
3384 }
3385 if ( NULL == wpsIe )
3386 {
3387 PopulateDot11fRSNOpaque( pMac, &( psessionEntry->pLimReAssocReq->rsnIE ),
3388 &frm.RSNOpaque );
3389 PopulateDot11fWPAOpaque( pMac, &( psessionEntry->pLimReAssocReq->rsnIE ),
3390 &frm.WPAOpaque );
3391#if defined(FEATURE_WLAN_WAPI)
3392 PopulateDot11fWAPIOpaque( pMac, &( psessionEntry->pLimReAssocReq->rsnIE ),
3393 &frm.WAPIOpaque );
3394#endif // defined(FEATURE_WLAN_WAPI)
3395 }
3396
3397 // include WME EDCA IE as well
3398 if ( fWmeEnabled )
3399 {
3400 if ( ! PROP_CAPABILITY_GET( WME, psessionEntry->limReassocBssPropCap ) )
3401 {
3402 PopulateDot11fWMMInfoStation( pMac, &frm.WMMInfoStation );
3403 }
3404
3405 if ( fWsmEnabled &&
3406 ( ! PROP_CAPABILITY_GET(WSM, psessionEntry->limReassocBssPropCap )))
3407 {
3408 PopulateDot11fWMMCaps( &frm.WMMCaps );
3409 }
3410 }
3411
Jeff Johnsone7245742012-09-05 17:12:55 -07003412 if ( psessionEntry->htCapability &&
Jeff Johnson295189b2012-06-20 16:38:30 -07003413 pMac->lim.htCapabilityPresentInBeacon)
3414 {
Jeff Johnsone7245742012-09-05 17:12:55 -07003415 PopulateDot11fHTCaps( pMac, psessionEntry, &frm.HTCaps );
Jeff Johnson295189b2012-06-20 16:38:30 -07003416 }
Jeff Johnsone7245742012-09-05 17:12:55 -07003417#ifdef WLAN_FEATURE_11AC
3418 if ( psessionEntry->vhtCapability &&
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07003419 psessionEntry->vhtCapabilityPresentInBeacon)
Jeff Johnsone7245742012-09-05 17:12:55 -07003420 {
Chet Lanctotf19c1f62013-12-13 13:56:21 -08003421 limLog( pMac, LOG1, FL("Populate VHT IEs in Re-Assoc Request"));
Abhishek Singh33f76ea2015-06-04 12:27:30 +05303422 PopulateDot11fVHTCaps( pMac, &frm.VHTCaps,
3423 psessionEntry->currentOperChannel, eSIR_FALSE );
Sandeep Puligilla60342762014-01-30 21:05:37 +05303424 PopulateDot11fExtCap( pMac, &frm.ExtCap, psessionEntry);
Abhishek Singhe038dc62015-05-22 11:36:45 +05303425
3426 if (SIR_11B_CHANNEL_END >= psessionEntry->currentOperChannel)
3427 PopulateDot11fOperatingMode(pMac, &frm.OperatingMode,
3428 psessionEntry);
Jeff Johnsone7245742012-09-05 17:12:55 -07003429 }
3430#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003431
3432 nStatus = dot11fGetPackedReAssocRequestSize( pMac, &frm, &nPayload );
3433 if ( DOT11F_FAILED( nStatus ) )
3434 {
3435 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003436 "or a Re-Association Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003437 nStatus );
3438 // We'll fall back on the worst case scenario:
3439 nPayload = sizeof( tDot11fReAssocRequest );
3440 }
3441 else if ( DOT11F_WARNED( nStatus ) )
3442 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08003443 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07003444 "the packed size for a Re-Association Re "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003445 "quest(0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07003446 }
3447
3448 nBytes = nPayload + sizeof( tSirMacMgmtHdr ) + nAddIELen;
3449
3450 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
3451 ( tANI_U16 )nBytes, ( void** ) &pFrame,
3452 ( void** ) &pPacket );
3453 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3454 {
3455 psessionEntry->limMlmState = psessionEntry->limPrevMlmState;
Jeff Johnsone7245742012-09-05 17:12:55 -07003456 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07003457 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Re-As"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003458 "sociation Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07003459 goto end;
3460 }
3461
3462 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303463 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07003464
3465 // Next, we fill out the buffer descriptor:
3466 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
3467 SIR_MAC_MGMT_REASSOC_REQ,
3468 psessionEntry->limReAssocbssId,psessionEntry->selfMacAddr);
3469 if ( eSIR_SUCCESS != nSirStatus )
3470 {
3471 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003472 "tor for an Association Request (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003473 nSirStatus );
3474 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
3475 goto end;
3476 }
3477
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05303478 pMacHdr = (tpSirMacMgmtHdr) pFrame;
Jeff Johnson295189b2012-06-20 16:38:30 -07003479 // That done, pack the Probe Request:
3480 nStatus = dot11fPackReAssocRequest( pMac, &frm, pFrame +
3481 sizeof(tSirMacMgmtHdr),
3482 nPayload, &nPayload );
3483 if ( DOT11F_FAILED( nStatus ) )
3484 {
3485 limLog( pMac, LOGE, FL("Failed to pack a Re-Association Reque"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003486 "st (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003487 nStatus );
3488 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
3489 goto end;
3490 }
3491 else if ( DOT11F_WARNED( nStatus ) )
3492 {
3493 limLog( pMac, LOGW, FL("There were warnings while packing a R"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08003494 "e-Association Request (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07003495 }
3496
3497 PELOG1(limLog( pMac, LOG1, FL("*** Sending Re-Association Request length %d"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003498 "to "),
Jeff Johnson295189b2012-06-20 16:38:30 -07003499 nBytes );)
3500
3501 if( psessionEntry->assocReq != NULL )
3502 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303503 vos_mem_free(psessionEntry->assocReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07003504 psessionEntry->assocReq = NULL;
3505 }
3506
3507 if( nAddIELen )
3508 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303509 vos_mem_copy( pFrame + sizeof(tSirMacMgmtHdr) + nPayload,
3510 pAddIE,
3511 nAddIELen );
Jeff Johnson295189b2012-06-20 16:38:30 -07003512 nPayload += nAddIELen;
3513 }
3514
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303515 psessionEntry->assocReq = vos_mem_malloc(nPayload);
3516 if ( NULL == psessionEntry->assocReq )
Jeff Johnson295189b2012-06-20 16:38:30 -07003517 {
3518 PELOGE(limLog(pMac, LOGE, FL("Unable to allocate memory to store assoc request"));)
Jeff Johnson43971f52012-07-17 12:26:56 -07003519 }
3520 else
3521 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003522 //Store the Assoc request. This is sent to csr/hdd in join cnf response.
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303523 vos_mem_copy(psessionEntry->assocReq, pFrame + sizeof(tSirMacMgmtHdr), nPayload);
Jeff Johnson295189b2012-06-20 16:38:30 -07003524 psessionEntry->assocReqLen = nPayload;
Jeff Johnson43971f52012-07-17 12:26:56 -07003525 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003526
3527 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07003528 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
3529 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07003530 )
3531 {
3532 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
3533 }
3534
Sushant Kaushike8681d22015-04-21 12:08:25 +05303535 if(psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ||
3536 psessionEntry->pePersona == VOS_STA_MODE)
Ganesh K08bce952012-12-13 15:04:41 -08003537 {
3538 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
3539 }
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08003540
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05303541 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
3542 psessionEntry->peSessionId,
3543 pMacHdr->fc.subType));
Katya Nigam63902932014-06-26 19:04:23 +05303544
Ganesh Kondabattiniffc00b12015-03-18 13:11:33 +05303545 if (IS_FEATURE_SUPPORTED_BY_FW(ENHANCED_TXBD_COMPLETION))
3546 {
3547 limLog(pMac, LOG1, FL("Reassoc req - txBdToken %u"), pMac->lim.txBdToken);
3548 halstatus = halTxFrameWithTxComplete( pMac, pPacket,
3549 ( tANI_U16 ) (sizeof(tSirMacMgmtHdr) + nPayload),
3550 HAL_TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS,
3551 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
3552 limTxComplete, pFrame, limTxBdComplete,
3553 txFlag, pMac->lim.txBdToken );
3554 pMac->lim.txBdToken++;
3555 }
3556 else
3557 {
3558 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) (sizeof(tSirMacMgmtHdr) + nPayload),
3559 HAL_TXRX_FRM_802_11_MGMT,
3560 ANI_TXDIR_TODS,
3561 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
3562 limTxComplete, pFrame, txFlag );
3563 }
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05303564 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
3565 psessionEntry->peSessionId,
3566 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07003567 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3568 {
3569 limLog( pMac, LOGE, FL("Failed to send Re-Association Request"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003570 "(%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07003571 nSirStatus );
3572 //Pkt will be freed up by the callback
3573 goto end;
3574 }
3575
Katya Nigamccaeda72015-04-20 18:51:22 +05303576 // enable caching
3577 WLANTL_EnableCaching(psessionEntry->staId);
3578
Jeff Johnson295189b2012-06-20 16:38:30 -07003579end:
3580 // Free up buffer allocated for mlmAssocReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303581 vos_mem_free( pMlmReassocReq );
Jeff Johnson295189b2012-06-20 16:38:30 -07003582 psessionEntry->pLimMlmReassocReq = NULL;
3583
3584} // limSendReassocReqMgmtFrame
3585
Sushant Kaushik9e923872015-04-02 17:09:31 +05303586eHalStatus limAuthTxCompleteCnf(tpAniSirGlobal pMac, void *pData)
Ganesh Kondabattiniffc00b12015-03-18 13:11:33 +05303587{
Sushant Kaushik9e923872015-04-02 17:09:31 +05303588 tANI_U32 txCompleteSuccess;
Ganesh Kondabattiniffc00b12015-03-18 13:11:33 +05303589 tpSirTxBdStatus pTxBdStatus;
Sushant Kaushik9e923872015-04-02 17:09:31 +05303590
3591 if (!pData)
3592 {
3593 limLog(pMac, LOG1,
3594 FL(" pData is NULL"));
3595 return eHAL_STATUS_FAILURE;
3596 }
Sushant Kaushik9e923872015-04-02 17:09:31 +05303597
Ganesh Kondabattiniffc00b12015-03-18 13:11:33 +05303598 if (IS_FEATURE_SUPPORTED_BY_FW(ENHANCED_TXBD_COMPLETION))
3599 {
3600 pTxBdStatus = (tpSirTxBdStatus) pData;
3601 txCompleteSuccess = pTxBdStatus->txCompleteStatus;
3602 limLog(pMac, LOG1, FL("txCompleteStatus %u, txBdToken %u"),
3603 pTxBdStatus->txCompleteStatus, pTxBdStatus->txBdToken);
3604 }
3605 else
3606 {
3607 txCompleteSuccess = *((tANI_U32*) pData);
3608 limLog(pMac, LOG1,
3609 FL("txCompleteSuccess= %d"), txCompleteSuccess);
3610 }
3611
Sushant Kaushik9e923872015-04-02 17:09:31 +05303612 if(txCompleteSuccess)
3613 {
3614 pMac->authAckStatus = LIM_AUTH_ACK_RCD_SUCCESS;
3615 // 'Change' timer for future activations
3616 limDeactivateAndChangeTimer(pMac, eLIM_AUTH_RETRY_TIMER);
3617 }
3618 else
3619 pMac->authAckStatus = LIM_AUTH_ACK_RCD_FAILURE;
3620 return eHAL_STATUS_SUCCESS;
3621}
3622
Jeff Johnson295189b2012-06-20 16:38:30 -07003623/**
3624 * \brief Send an Authentication frame
3625 *
3626 *
3627 * \param pMac Pointer to Global MAC structure
3628 *
3629 * \param pAuthFrameBody Pointer to Authentication frame structure that need
3630 * to be sent
3631 *
3632 * \param peerMacAddr MAC address of the peer entity to which Authentication
3633 * frame is destined
3634 *
3635 * \param wepBit Indicates whether wep bit to be set in FC while sending
3636 * Authentication frame3
3637 *
3638 *
3639 * This function is called by limProcessMlmMessages(). Authentication frame
3640 * is formatted and sent when this function is called.
3641 *
3642 *
3643 */
3644
3645void
3646limSendAuthMgmtFrame(tpAniSirGlobal pMac,
3647 tpSirMacAuthFrameBody pAuthFrameBody,
3648 tSirMacAddr peerMacAddr,
3649 tANI_U8 wepBit,
Sushant Kaushik9e923872015-04-02 17:09:31 +05303650 tpPESession psessionEntry,
3651 tAniBool waitForAck
Jeff Johnson295189b2012-06-20 16:38:30 -07003652 )
3653{
3654 tANI_U8 *pFrame, *pBody;
3655 tANI_U32 frameLen = 0, bodyLen = 0;
3656 tpSirMacMgmtHdr pMacHdr;
3657 tANI_U16 i;
3658 void *pPacket;
3659 eHalStatus halstatus;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05303660 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003661
3662 if(NULL == psessionEntry)
3663 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05303664 limLog(pMac, LOGE, FL("Error: psession Entry is NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003665 return;
3666 }
Abhishek Singh57aebef2014-02-03 18:47:44 +05303667
3668 limLog(pMac, LOG1,
3669 FL("Sending Auth seq# %d status %d (%d) to "MAC_ADDRESS_STR),
3670 pAuthFrameBody->authTransactionSeqNumber,
3671 pAuthFrameBody->authStatusCode,
3672 (pAuthFrameBody->authStatusCode == eSIR_MAC_SUCCESS_STATUS),
3673 MAC_ADDR_ARRAY(peerMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07003674 if (wepBit == LIM_WEP_IN_FC)
3675 {
3676 /// Auth frame3 to be sent with encrypted framebody
3677 /**
3678 * Allocate buffer for Authenticaton frame of size equal
3679 * to management frame header length plus 2 bytes each for
3680 * auth algorithm number, transaction number, status code,
3681 * 128 bytes for challenge text and 4 bytes each for
3682 * IV & ICV.
3683 */
3684
3685 frameLen = sizeof(tSirMacMgmtHdr) + LIM_ENCR_AUTH_BODY_LEN;
3686
3687 bodyLen = LIM_ENCR_AUTH_BODY_LEN;
3688 } // if (wepBit == LIM_WEP_IN_FC)
3689 else
3690 {
3691 switch (pAuthFrameBody->authTransactionSeqNumber)
3692 {
3693 case SIR_MAC_AUTH_FRAME_1:
3694 /**
3695 * Allocate buffer for Authenticaton frame of size
3696 * equal to management frame header length plus 2 bytes
3697 * each for auth algorithm number, transaction number
3698 * and status code.
3699 */
3700
3701 frameLen = sizeof(tSirMacMgmtHdr) +
3702 SIR_MAC_AUTH_CHALLENGE_OFFSET;
3703 bodyLen = SIR_MAC_AUTH_CHALLENGE_OFFSET;
3704
3705#if defined WLAN_FEATURE_VOWIFI_11R
Madan Mohan Koyyalamudi6a00a802012-11-28 16:12:11 -08003706 if (pAuthFrameBody->authAlgoNumber == eSIR_FT_AUTH)
3707 {
3708 if (0 != pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length)
Jeff Johnson295189b2012-06-20 16:38:30 -07003709 {
Madan Mohan Koyyalamudi6a00a802012-11-28 16:12:11 -08003710 frameLen += pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length;
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003711 limLog(pMac, LOG3, FL("Auth frame, FTIES length added=%d"),
Madan Mohan Koyyalamudi6a00a802012-11-28 16:12:11 -08003712 pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length);
Jeff Johnson295189b2012-06-20 16:38:30 -07003713 }
Madan Mohan Koyyalamudi6a00a802012-11-28 16:12:11 -08003714 else
3715 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05303716 limLog(pMac, LOG3, FL("Auth frame, Does not contain "
3717 "FTIES!!!"));
Madan Mohan Koyyalamudi6a00a802012-11-28 16:12:11 -08003718 frameLen += (2+SIR_MDIE_SIZE);
3719 }
3720 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003721#endif
3722 break;
3723
3724 case SIR_MAC_AUTH_FRAME_2:
3725 if ((pAuthFrameBody->authAlgoNumber == eSIR_OPEN_SYSTEM) ||
3726 ((pAuthFrameBody->authAlgoNumber == eSIR_SHARED_KEY) &&
3727 (pAuthFrameBody->authStatusCode != eSIR_MAC_SUCCESS_STATUS)))
3728 {
3729 /**
3730 * Allocate buffer for Authenticaton frame of size
3731 * equal to management frame header length plus
3732 * 2 bytes each for auth algorithm number,
3733 * transaction number and status code.
3734 */
3735
3736 frameLen = sizeof(tSirMacMgmtHdr) +
3737 SIR_MAC_AUTH_CHALLENGE_OFFSET;
3738 bodyLen = SIR_MAC_AUTH_CHALLENGE_OFFSET;
3739 }
3740 else
3741 {
3742 // Shared Key algorithm with challenge text
3743 // to be sent
3744 /**
3745 * Allocate buffer for Authenticaton frame of size
3746 * equal to management frame header length plus
3747 * 2 bytes each for auth algorithm number,
3748 * transaction number, status code and 128 bytes
3749 * for challenge text.
3750 */
3751
3752 frameLen = sizeof(tSirMacMgmtHdr) +
3753 sizeof(tSirMacAuthFrame);
3754 bodyLen = sizeof(tSirMacAuthFrameBody);
3755 }
3756
3757 break;
3758
3759 case SIR_MAC_AUTH_FRAME_3:
3760 /// Auth frame3 to be sent without encrypted framebody
3761 /**
3762 * Allocate buffer for Authenticaton frame of size equal
3763 * to management frame header length plus 2 bytes each
3764 * for auth algorithm number, transaction number and
3765 * status code.
3766 */
3767
3768 frameLen = sizeof(tSirMacMgmtHdr) +
3769 SIR_MAC_AUTH_CHALLENGE_OFFSET;
3770 bodyLen = SIR_MAC_AUTH_CHALLENGE_OFFSET;
3771
3772 break;
3773
3774 case SIR_MAC_AUTH_FRAME_4:
3775 /**
3776 * Allocate buffer for Authenticaton frame of size equal
3777 * to management frame header length plus 2 bytes each
3778 * for auth algorithm number, transaction number and
3779 * status code.
3780 */
3781
3782 frameLen = sizeof(tSirMacMgmtHdr) +
3783 SIR_MAC_AUTH_CHALLENGE_OFFSET;
3784 bodyLen = SIR_MAC_AUTH_CHALLENGE_OFFSET;
3785
3786 break;
3787 } // switch (pAuthFrameBody->authTransactionSeqNumber)
3788 } // end if (wepBit == LIM_WEP_IN_FC)
3789
3790
3791 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )frameLen, ( void** ) &pFrame, ( void** ) &pPacket );
3792
3793 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3794 {
3795 // Log error
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003796 limLog(pMac, LOGP, FL("call to bufAlloc failed for AUTH frame"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003797
3798 return;
3799 }
3800
3801 for (i = 0; i < frameLen; i++)
3802 pFrame[i] = 0;
3803
3804 // Prepare BD
3805 if (limPopulateMacHeader(pMac, pFrame, SIR_MAC_MGMT_FRAME,
3806 SIR_MAC_MGMT_AUTH, peerMacAddr,psessionEntry->selfMacAddr) != eSIR_SUCCESS)
3807 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05303808 limLog(pMac, LOGE, FL("call to limPopulateMacHeader failed for "
3809 "AUTH frame"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003810 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
3811 return;
3812 }
3813
3814 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
3815 pMacHdr->fc.wep = wepBit;
3816
3817 // Prepare BSSId
3818 if( (psessionEntry->limSystemRole == eLIM_AP_ROLE)|| (psessionEntry->limSystemRole == eLIM_BT_AMP_AP_ROLE) )
3819 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303820 vos_mem_copy( (tANI_U8 *) pMacHdr->bssId,
3821 (tANI_U8 *) psessionEntry->bssId,
3822 sizeof( tSirMacAddr ));
Jeff Johnson295189b2012-06-20 16:38:30 -07003823 }
3824
3825 /// Prepare Authentication frame body
3826 pBody = pFrame + sizeof(tSirMacMgmtHdr);
3827
3828 if (wepBit == LIM_WEP_IN_FC)
3829 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303830 vos_mem_copy(pBody, (tANI_U8 *) pAuthFrameBody, bodyLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07003831
Abhishek Singh3cbf6052014-12-15 16:46:42 +05303832 limLog(pMac, LOG1,
Abhishek Singh57aebef2014-02-03 18:47:44 +05303833 FL("*** Sending Auth seq# 3 status %d (%d) to"MAC_ADDRESS_STR),
Jeff Johnson295189b2012-06-20 16:38:30 -07003834 pAuthFrameBody->authStatusCode,
Abhishek Singh57aebef2014-02-03 18:47:44 +05303835 (pAuthFrameBody->authStatusCode == eSIR_MAC_SUCCESS_STATUS),
Abhishek Singh3cbf6052014-12-15 16:46:42 +05303836 MAC_ADDR_ARRAY(pMacHdr->da));
Jeff Johnson295189b2012-06-20 16:38:30 -07003837
Jeff Johnson295189b2012-06-20 16:38:30 -07003838 }
3839 else
3840 {
3841 *((tANI_U16 *)(pBody)) = sirSwapU16ifNeeded(pAuthFrameBody->authAlgoNumber);
3842 pBody += sizeof(tANI_U16);
3843 bodyLen -= sizeof(tANI_U16);
3844
3845 *((tANI_U16 *)(pBody)) = sirSwapU16ifNeeded(pAuthFrameBody->authTransactionSeqNumber);
3846 pBody += sizeof(tANI_U16);
3847 bodyLen -= sizeof(tANI_U16);
3848
3849 *((tANI_U16 *)(pBody)) = sirSwapU16ifNeeded(pAuthFrameBody->authStatusCode);
3850 pBody += sizeof(tANI_U16);
3851 bodyLen -= sizeof(tANI_U16);
Leela Venkata Kiran Kumar Reddy Chirala7d3fa552013-08-28 10:52:21 -07003852 if ( bodyLen <= (sizeof (pAuthFrameBody->type) +
3853 sizeof (pAuthFrameBody->length) +
3854 sizeof (pAuthFrameBody->challengeText)))
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303855 vos_mem_copy(pBody, (tANI_U8 *) &pAuthFrameBody->type, bodyLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07003856
3857#if defined WLAN_FEATURE_VOWIFI_11R
3858 if ((pAuthFrameBody->authAlgoNumber == eSIR_FT_AUTH) &&
3859 (pAuthFrameBody->authTransactionSeqNumber == SIR_MAC_AUTH_FRAME_1))
3860 {
3861
3862 {
3863 int i = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003864 if (pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length)
3865 {
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08003866#if defined WLAN_FEATURE_VOWIFI_11R_DEBUG
Srinivas Girigowdad63eb492014-02-06 12:21:47 -08003867 PELOG2(limLog(pMac, LOG2, FL("Auth1 Frame FTIE is: "));
3868 sirDumpBuf(pMac, SIR_LIM_MODULE_ID, LOG2,
Jeff Johnson295189b2012-06-20 16:38:30 -07003869 (tANI_U8 *)pBody,
3870 (pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length));)
Jeff Johnson295189b2012-06-20 16:38:30 -07003871#endif
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08003872 for (i=0; i<pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length; i++)
3873 {
Madan Mohan Koyyalamudi6a00a802012-11-28 16:12:11 -08003874 *pBody = pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies[i];
3875 pBody++;
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08003876 }
3877 }
3878 else
3879 {
3880 /* MDID attr is 54*/
3881 *pBody = 54;
Jeff Johnson295189b2012-06-20 16:38:30 -07003882 pBody++;
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08003883 *pBody = SIR_MDIE_SIZE;
3884 pBody++;
3885 for(i=0;i<SIR_MDIE_SIZE;i++)
3886 {
3887 *pBody = pMac->ft.ftPEContext.pFTPreAuthReq->pbssDescription->mdie[i];
3888 pBody++;
3889 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003890 }
3891 }
3892 }
3893#endif
3894
Abhishek Singh3cbf6052014-12-15 16:46:42 +05303895 limLog(pMac, LOG1,
Abhishek Singh57aebef2014-02-03 18:47:44 +05303896 FL("*** Sending Auth seq# %d status %d (%d) to "MAC_ADDRESS_STR),
Jeff Johnson295189b2012-06-20 16:38:30 -07003897 pAuthFrameBody->authTransactionSeqNumber,
3898 pAuthFrameBody->authStatusCode,
Abhishek Singh57aebef2014-02-03 18:47:44 +05303899 (pAuthFrameBody->authStatusCode == eSIR_MAC_SUCCESS_STATUS),
Abhishek Singh3cbf6052014-12-15 16:46:42 +05303900 MAC_ADDR_ARRAY(pMacHdr->da));
Jeff Johnson295189b2012-06-20 16:38:30 -07003901 }
3902 PELOG2(sirDumpBuf(pMac, SIR_LIM_MODULE_ID, LOG2, pFrame, frameLen);)
3903
3904 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07003905 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
3906 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003907#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05303908 || ((NULL != pMac->ft.ftPEContext.pFTPreAuthReq)
Jeff Johnsone7245742012-09-05 17:12:55 -07003909 && ( SIR_BAND_5_GHZ == limGetRFBand(pMac->ft.ftPEContext.pFTPreAuthReq->preAuthchannelNum)))
3910#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003911 )
3912 {
3913 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
3914 }
3915
Sushant Kaushike8681d22015-04-21 12:08:25 +05303916 if(psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ||
3917 psessionEntry->pePersona == VOS_STA_MODE)
Ganesh K08bce952012-12-13 15:04:41 -08003918 {
3919 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
3920 }
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08003921
Sushant Kaushik9e923872015-04-02 17:09:31 +05303922 limLog( pMac, LOG1,
3923 FL("Sending Auth Frame over WQ5 with waitForAck %d to "MAC_ADDRESS_STR
3924 " From " MAC_ADDRESS_STR), waitForAck, MAC_ADDR_ARRAY(pMacHdr->da),
Agarwal Ashisha8e81f52014-04-02 01:59:52 +05303925 MAC_ADDR_ARRAY(psessionEntry->selfMacAddr));
3926
3927 txFlag |= HAL_USE_FW_IN_TX_PATH;
3928
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05303929 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
3930 psessionEntry->peSessionId,
3931 pMacHdr->fc.subType));
Masti, Narayanraddi67ea5912015-01-08 12:34:05 +05303932
3933 if( ( psessionEntry->is11Gonly == true ) &&
3934 ( !IS_BROADCAST_MAC(peerMacAddr) ) ){
3935 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
3936 }
Sushant Kaushik9e923872015-04-02 17:09:31 +05303937 if(eSIR_TRUE == waitForAck)
3938 {
3939 pMac->authAckStatus = LIM_AUTH_ACK_NOT_RCD;
Sushant Kaushik0b343422015-05-25 17:15:55 +05303940 limLog(pMac, LOG1, FL("Auth frame - txBdToken %u"),
Ganesh Kondabattiniffc00b12015-03-18 13:11:33 +05303941 pMac->lim.txBdToken);
Sushant Kaushik9e923872015-04-02 17:09:31 +05303942 halstatus = halTxFrameWithTxComplete( pMac, pPacket,
3943 ( tANI_U16 ) frameLen,
3944 HAL_TXRX_FRM_802_11_MGMT,
3945 ANI_TXDIR_TODS,
3946 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
Ganesh Kondabattiniffc00b12015-03-18 13:11:33 +05303947 limTxComplete, pFrame, limAuthTxCompleteCnf, txFlag,
3948 pMac->lim.txBdToken);
3949 pMac->lim.txBdToken++;
Sushant Kaushik9e923872015-04-02 17:09:31 +05303950 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
3951 psessionEntry->peSessionId,
3952 halstatus));
3953 if (!HAL_STATUS_SUCCESS(halstatus))
3954 {
3955 limLog( pMac, LOGE,
3956 FL("Could not send Auth frame, retCode=%X "),
3957 halstatus );
3958 pMac->authAckStatus = LIM_AUTH_ACK_RCD_FAILURE;
3959 //Pkt will be freed up by the callback
3960 }
3961 }
3962 else
3963 {
3964 /// Queue Authentication frame in high priority WQ
3965 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) frameLen,
Jeff Johnson295189b2012-06-20 16:38:30 -07003966 HAL_TXRX_FRM_802_11_MGMT,
3967 ANI_TXDIR_TODS,
3968 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
3969 limTxComplete, pFrame, txFlag );
Sushant Kaushik9e923872015-04-02 17:09:31 +05303970 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05303971 psessionEntry->peSessionId,
3972 halstatus));
Sushant Kaushik9e923872015-04-02 17:09:31 +05303973 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3974 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003975 limLog(pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003976 FL("*** Could not send Auth frame, retCode=%X ***"),
Jeff Johnson295189b2012-06-20 16:38:30 -07003977 halstatus);
3978
3979 //Pkt will be freed up by the callback
Sushant Kaushik9e923872015-04-02 17:09:31 +05303980 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003981 }
3982
3983 return;
3984} /*** end limSendAuthMgmtFrame() ***/
3985
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003986eHalStatus limSendDeauthCnf(tpAniSirGlobal pMac)
3987{
3988 tANI_U16 aid;
3989 tpDphHashNode pStaDs;
3990 tLimMlmDeauthReq *pMlmDeauthReq;
3991 tLimMlmDeauthCnf mlmDeauthCnf;
3992 tpPESession psessionEntry;
3993
3994 pMlmDeauthReq = pMac->lim.limDisassocDeauthCnfReq.pMlmDeauthReq;
3995 if (pMlmDeauthReq)
3996 {
3997 if (tx_timer_running(&pMac->lim.limTimers.gLimDeauthAckTimer))
3998 {
3999 limDeactivateAndChangeTimer(pMac, eLIM_DEAUTH_ACK_TIMER);
4000 }
4001
4002 if((psessionEntry = peFindSessionBySessionId(pMac, pMlmDeauthReq->sessionId))== NULL)
4003 {
4004
4005 PELOGE(limLog(pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004006 FL("session does not exist for given sessionId"));)
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004007 mlmDeauthCnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
4008 goto end;
4009 }
4010
4011 pStaDs = dphLookupHashEntry(pMac, pMlmDeauthReq->peerMacAddr, &aid, &psessionEntry->dph.dphHashTable);
4012 if (pStaDs == NULL)
4013 {
4014 mlmDeauthCnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
4015 goto end;
4016 }
4017
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004018 /// Receive path cleanup with dummy packet
4019 limCleanupRxPath(pMac, pStaDs,psessionEntry);
Abhishek Singhcf4590b2014-04-16 18:58:08 +05304020
4021#ifdef WLAN_FEATURE_VOWIFI_11R
Mukul Sharma0820d0e2014-11-11 19:49:02 +05304022 if ( psessionEntry->limSystemRole == eLIM_STA_ROLE )
Abhishek Singhcf4590b2014-04-16 18:58:08 +05304023 {
Mukul Sharma0820d0e2014-11-11 19:49:02 +05304024 PELOGE(limLog(pMac, LOG1,
4025 FL("FT Preauth SessionId %d Cleanup"
Abhishek Singhcf4590b2014-04-16 18:58:08 +05304026#ifdef FEATURE_WLAN_ESE
4027 " isESE %d"
4028#endif
4029#ifdef FEATURE_WLAN_LFR
4030 " isLFR %d"
4031#endif
4032 " is11r %d, Deauth reason %d Trigger = %d"),
Mukul Sharma0820d0e2014-11-11 19:49:02 +05304033 psessionEntry->peSessionId,
Abhishek Singhcf4590b2014-04-16 18:58:08 +05304034#ifdef FEATURE_WLAN_ESE
4035 psessionEntry->isESEconnection,
4036#endif
4037#ifdef FEATURE_WLAN_LFR
4038 psessionEntry->isFastRoamIniFeatureEnabled,
4039#endif
4040 psessionEntry->is11Rconnection,
4041 pMlmDeauthReq->reasonCode,
4042 pMlmDeauthReq->deauthTrigger););
Mukul Sharma0820d0e2014-11-11 19:49:02 +05304043
4044 limFTCleanup(pMac);
Abhishek Singhcf4590b2014-04-16 18:58:08 +05304045 }
4046#endif
4047
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004048 /// Free up buffer allocated for mlmDeauthReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304049 vos_mem_free(pMlmDeauthReq);
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004050 pMac->lim.limDisassocDeauthCnfReq.pMlmDeauthReq = NULL;
4051 }
4052 return eHAL_STATUS_SUCCESS;
4053end:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304054 vos_mem_copy( (tANI_U8 *) &mlmDeauthCnf.peerMacAddr,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004055 (tANI_U8 *) pMlmDeauthReq->peerMacAddr,
4056 sizeof(tSirMacAddr));
4057 mlmDeauthCnf.deauthTrigger = pMlmDeauthReq->deauthTrigger;
4058 mlmDeauthCnf.aid = pMlmDeauthReq->aid;
4059 mlmDeauthCnf.sessionId = pMlmDeauthReq->sessionId;
4060
4061 // Free up buffer allocated
4062 // for mlmDeauthReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304063 vos_mem_free(pMlmDeauthReq);
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004064
4065 limPostSmeMessage(pMac,
4066 LIM_MLM_DEAUTH_CNF,
4067 (tANI_U32 *) &mlmDeauthCnf);
4068 return eHAL_STATUS_SUCCESS;
4069}
4070
4071eHalStatus limSendDisassocCnf(tpAniSirGlobal pMac)
4072{
4073 tANI_U16 aid;
4074 tpDphHashNode pStaDs;
4075 tLimMlmDisassocCnf mlmDisassocCnf;
4076 tpPESession psessionEntry;
4077 tLimMlmDisassocReq *pMlmDisassocReq;
4078
4079 pMlmDisassocReq = pMac->lim.limDisassocDeauthCnfReq.pMlmDisassocReq;
4080 if (pMlmDisassocReq)
4081 {
4082 if (tx_timer_running(&pMac->lim.limTimers.gLimDisassocAckTimer))
4083 {
4084 limDeactivateAndChangeTimer(pMac, eLIM_DISASSOC_ACK_TIMER);
4085 }
4086
4087 if((psessionEntry = peFindSessionBySessionId(pMac, pMlmDisassocReq->sessionId))== NULL)
4088 {
4089
4090 PELOGE(limLog(pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004091 FL("session does not exist for given sessionId"));)
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004092 mlmDisassocCnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
4093 goto end;
4094 }
4095
4096 pStaDs = dphLookupHashEntry(pMac, pMlmDisassocReq->peerMacAddr, &aid, &psessionEntry->dph.dphHashTable);
4097 if (pStaDs == NULL)
4098 {
Sachin Ahuja2fea3d12014-12-18 17:31:31 +05304099 limLog(pMac, LOGE,
4100 FL("StaDs Null"));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004101 mlmDisassocCnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
4102 goto end;
4103 }
4104
4105 /// Receive path cleanup with dummy packet
4106 if(eSIR_SUCCESS != limCleanupRxPath(pMac, pStaDs, psessionEntry))
4107 {
4108 mlmDisassocCnf.resultCode = eSIR_SME_RESOURCES_UNAVAILABLE;
Sachin Ahuja2fea3d12014-12-18 17:31:31 +05304109 limLog(pMac, LOGE,
4110 FL("CleanupRxPath error"));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004111 goto end;
4112 }
4113
4114#ifdef WLAN_FEATURE_VOWIFI_11R
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08004115 if ( (psessionEntry->limSystemRole == eLIM_STA_ROLE ) &&
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05304116 (pMlmDisassocReq->reasonCode !=
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08004117 eSIR_MAC_DISASSOC_DUE_TO_FTHANDOFF_REASON))
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004118 {
Mukul Sharma0820d0e2014-11-11 19:49:02 +05304119 PELOGE(limLog(pMac, LOG1,
4120 FL("FT Preauth SessionId %d Cleanup"
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004121#ifdef FEATURE_WLAN_ESE
4122 " isESE %d"
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08004123#endif
4124#ifdef FEATURE_WLAN_LFR
4125 " isLFR %d"
4126#endif
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004127 " is11r %d reason %d"),
Mukul Sharma0820d0e2014-11-11 19:49:02 +05304128 psessionEntry->peSessionId,
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004129#ifdef FEATURE_WLAN_ESE
4130 psessionEntry->isESEconnection,
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08004131#endif
4132#ifdef FEATURE_WLAN_LFR
4133 psessionEntry->isFastRoamIniFeatureEnabled,
4134#endif
4135 psessionEntry->is11Rconnection,
4136 pMlmDisassocReq->reasonCode););
Mukul Sharma0820d0e2014-11-11 19:49:02 +05304137 limFTCleanup(pMac);
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004138 }
4139#endif
4140
4141 /// Free up buffer allocated for mlmDisassocReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304142 vos_mem_free(pMlmDisassocReq);
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004143 pMac->lim.limDisassocDeauthCnfReq.pMlmDisassocReq = NULL;
4144 return eHAL_STATUS_SUCCESS;
4145 }
4146 else
4147 {
4148 return eHAL_STATUS_SUCCESS;
4149 }
4150end:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304151 vos_mem_copy( (tANI_U8 *) &mlmDisassocCnf.peerMacAddr,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004152 (tANI_U8 *) pMlmDisassocReq->peerMacAddr,
4153 sizeof(tSirMacAddr));
4154 mlmDisassocCnf.aid = pMlmDisassocReq->aid;
4155 mlmDisassocCnf.disassocTrigger = pMlmDisassocReq->disassocTrigger;
4156
4157 /* Update PE session ID*/
4158 mlmDisassocCnf.sessionId = pMlmDisassocReq->sessionId;
4159
Madan Mohan Koyyalamudib7f5a672012-11-29 11:17:46 -08004160 if(pMlmDisassocReq != NULL)
4161 {
4162 /// Free up buffer allocated for mlmDisassocReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304163 vos_mem_free(pMlmDisassocReq);
Madan Mohan Koyyalamudib7f5a672012-11-29 11:17:46 -08004164 pMac->lim.limDisassocDeauthCnfReq.pMlmDisassocReq = NULL;
4165 }
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004166
4167 limPostSmeMessage(pMac,
4168 LIM_MLM_DISASSOC_CNF,
4169 (tANI_U32 *) &mlmDisassocCnf);
4170 return eHAL_STATUS_SUCCESS;
4171}
4172
Ganesh Kondabattini358fc9b2015-03-11 16:14:25 +05304173eHalStatus limDisassocTxCompleteCnf(tpAniSirGlobal pMac, void *pData)
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004174{
Ganesh Kondabattinib18b3292015-03-16 16:59:26 +05304175 if (pData && IS_FEATURE_SUPPORTED_BY_FW(ENHANCED_TXBD_COMPLETION))
4176 {
4177 tpSirTxBdStatus pTxBdStatus;
4178 pTxBdStatus = (tpSirTxBdStatus) pData;
4179 limLog(pMac, LOG1, FL("txCompleteStatus %u, txBdToken %u"),
4180 pTxBdStatus->txCompleteStatus, pTxBdStatus->txBdToken);
4181 }
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004182 return limSendDisassocCnf(pMac);
4183}
4184
Ganesh Kondabattini358fc9b2015-03-11 16:14:25 +05304185eHalStatus limDeauthTxCompleteCnf(tpAniSirGlobal pMac, void *pData)
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004186{
Ganesh Kondabattinib18b3292015-03-16 16:59:26 +05304187 if (pData && IS_FEATURE_SUPPORTED_BY_FW(ENHANCED_TXBD_COMPLETION))
4188 {
4189 tpSirTxBdStatus pTxBdStatus;
4190 pTxBdStatus = (tpSirTxBdStatus) pData;
4191 limLog(pMac, LOG1, FL("txCompleteStatus %u, txBdToken %u"),
4192 pTxBdStatus->txCompleteStatus, pTxBdStatus->txBdToken);
4193 }
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004194 return limSendDeauthCnf(pMac);
4195}
4196
Jeff Johnson295189b2012-06-20 16:38:30 -07004197/**
4198 * \brief This function is called to send Disassociate frame.
4199 *
4200 *
4201 * \param pMac Pointer to Global MAC structure
4202 *
4203 * \param nReason Indicates the reason that need to be sent in
4204 * Disassociation frame
4205 *
4206 * \param peerMacAddr MAC address of the STA to which Disassociation frame is
4207 * sent
4208 *
4209 *
4210 */
4211
4212void
4213limSendDisassocMgmtFrame(tpAniSirGlobal pMac,
4214 tANI_U16 nReason,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004215 tSirMacAddr peer,
4216 tpPESession psessionEntry,
4217 tANI_BOOLEAN waitForAck)
Jeff Johnson295189b2012-06-20 16:38:30 -07004218{
4219 tDot11fDisassociation frm;
4220 tANI_U8 *pFrame;
4221 tSirRetStatus nSirStatus;
4222 tpSirMacMgmtHdr pMacHdr;
4223 tANI_U32 nBytes, nPayload, nStatus;
4224 void *pPacket;
4225 eHalStatus halstatus;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304226 tANI_U32 txFlag = 0;
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004227 tANI_U32 val = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004228 if(NULL == psessionEntry)
4229 {
4230 return;
4231 }
4232
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304233 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004234
4235 frm.Reason.code = nReason;
4236
4237 nStatus = dot11fGetPackedDisassociationSize( pMac, &frm, &nPayload );
4238 if ( DOT11F_FAILED( nStatus ) )
4239 {
4240 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004241 "or a Disassociation (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004242 nStatus );
4243 // We'll fall back on the worst case scenario:
4244 nPayload = sizeof( tDot11fDisassociation );
4245 }
4246 else if ( DOT11F_WARNED( nStatus ) )
4247 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004248 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07004249 "the packed size for a Disassociation "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004250 "(0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004251 }
4252
4253 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4254
4255 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
4256 ( tANI_U16 )nBytes, ( void** ) &pFrame,
4257 ( void** ) &pPacket );
4258 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4259 {
4260 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Dis"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004261 "association."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07004262 return;
4263 }
4264
4265 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304266 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004267
4268 // Next, we fill out the buffer descriptor:
4269 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
4270 SIR_MAC_MGMT_DISASSOC, peer,psessionEntry->selfMacAddr);
4271 if ( eSIR_SUCCESS != nSirStatus )
4272 {
4273 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004274 "tor for a Disassociation (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004275 nSirStatus );
4276 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
4277 ( void* ) pFrame, ( void* ) pPacket );
4278 return; // just allocated...
4279 }
4280
4281 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
4282
4283 // Prepare the BSSID
4284 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
4285
Chet Lanctot186b5732013-03-18 10:26:30 -07004286#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07004287 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07004288#endif
4289
Jeff Johnson295189b2012-06-20 16:38:30 -07004290 nStatus = dot11fPackDisassociation( pMac, &frm, pFrame +
4291 sizeof(tSirMacMgmtHdr),
4292 nPayload, &nPayload );
4293 if ( DOT11F_FAILED( nStatus ) )
4294 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004295 limLog( pMac, LOGE, FL("Failed to pack a Disassociation (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004296 nStatus );
4297 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
4298 ( void* ) pFrame, ( void* ) pPacket );
4299 return; // allocated!
4300 }
4301 else if ( DOT11F_WARNED( nStatus ) )
4302 {
4303 limLog( pMac, LOGW, FL("There were warnings while packing a D"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004304 "isassociation (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004305 }
4306
Abhishek Singhcd09b562013-12-24 16:02:20 +05304307 limLog( pMac, LOG1, FL("***Sessionid %d Sending Disassociation frame with "
4308 "reason %u and waitForAck %d to "MAC_ADDRESS_STR" ,From "
4309 MAC_ADDRESS_STR), psessionEntry->peSessionId, nReason, waitForAck,
4310 MAC_ADDR_ARRAY(pMacHdr->da),
4311 MAC_ADDR_ARRAY(psessionEntry->selfMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07004312
4313 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07004314 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
4315 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07004316 )
4317 {
4318 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
4319 }
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08004320
Sushant Kaushike8681d22015-04-21 12:08:25 +05304321 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08004322
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304323 if( IS_FW_IN_TX_PATH_FEATURE_ENABLE )
4324 {
4325 /* This frame will be sent on air by firmware,
4326 which will ensure that this frame goes out
4327 even though DEL_STA is sent immediately */
4328 /* Without this for DEL_STA command there is
4329 risk of flushing frame in BTQM queue without
4330 sending on air */
Agarwal Ashisha8e81f52014-04-02 01:59:52 +05304331 limLog( pMac, LOG1, FL("Sending Disassoc Frame over WQ5 to "MAC_ADDRESS_STR
4332 " From " MAC_ADDRESS_STR),MAC_ADDR_ARRAY(pMacHdr->da),
4333 MAC_ADDR_ARRAY(psessionEntry->selfMacAddr));
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304334 txFlag |= HAL_USE_FW_IN_TX_PATH;
4335 }
4336
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004337 if (waitForAck)
Jeff Johnson295189b2012-06-20 16:38:30 -07004338 {
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304339 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
4340 psessionEntry->peSessionId,
4341 pMacHdr->fc.subType));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004342 // Queue Disassociation frame in high priority WQ
4343 /* get the duration from the request */
4344 halstatus = halTxFrameWithTxComplete( pMac, pPacket, ( tANI_U16 ) nBytes,
4345 HAL_TXRX_FRM_802_11_MGMT,
4346 ANI_TXDIR_TODS,
4347 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4348 limTxComplete, pFrame, limDisassocTxCompleteCnf,
Ganesh Kondabattini10e67352015-03-16 17:41:57 +05304349 txFlag,
4350 pMac->lim.txBdToken++);
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304351 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
4352 psessionEntry->peSessionId,
4353 halstatus));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004354 val = SYS_MS_TO_TICKS(LIM_DISASSOC_DEAUTH_ACK_TIMEOUT);
Jeff Johnson295189b2012-06-20 16:38:30 -07004355
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004356 if (tx_timer_change(
4357 &pMac->lim.limTimers.gLimDisassocAckTimer, val, 0)
4358 != TX_SUCCESS)
4359 {
4360 limLog(pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004361 FL("Unable to change Disassoc ack Timer val"));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004362 return;
4363 }
4364 else if(TX_SUCCESS != tx_timer_activate(
4365 &pMac->lim.limTimers.gLimDisassocAckTimer))
4366 {
4367 limLog(pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004368 FL("Unable to activate Disassoc ack Timer"));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004369 limDeactivateAndChangeTimer(pMac, eLIM_DISASSOC_ACK_TIMER);
4370 return;
4371 }
4372 }
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08004373 else
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004374 {
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304375 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
4376 psessionEntry->peSessionId,
4377 pMacHdr->fc.subType));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004378 // Queue Disassociation frame in high priority WQ
4379 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4380 HAL_TXRX_FRM_802_11_MGMT,
4381 ANI_TXDIR_TODS,
4382 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4383 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304384 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
4385 psessionEntry->peSessionId,
4386 halstatus));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004387 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4388 {
4389 limLog( pMac, LOGE, FL("Failed to send Disassociation "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004390 "(%X)!"),
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004391 nSirStatus );
4392 //Pkt will be freed up by the callback
4393 return;
4394 }
4395 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004396} // End limSendDisassocMgmtFrame.
4397
4398/**
4399 * \brief This function is called to send a Deauthenticate frame
4400 *
4401 *
4402 * \param pMac Pointer to global MAC structure
4403 *
4404 * \param nReason Indicates the reason that need to be sent in the
4405 * Deauthenticate frame
4406 *
4407 * \param peeer address of the STA to which the frame is to be sent
4408 *
4409 *
4410 */
4411
4412void
4413limSendDeauthMgmtFrame(tpAniSirGlobal pMac,
4414 tANI_U16 nReason,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004415 tSirMacAddr peer,
4416 tpPESession psessionEntry,
4417 tANI_BOOLEAN waitForAck)
Jeff Johnson295189b2012-06-20 16:38:30 -07004418{
4419 tDot11fDeAuth frm;
4420 tANI_U8 *pFrame;
4421 tSirRetStatus nSirStatus;
4422 tpSirMacMgmtHdr pMacHdr;
4423 tANI_U32 nBytes, nPayload, nStatus;
4424 void *pPacket;
4425 eHalStatus halstatus;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304426 tANI_U32 txFlag = 0;
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004427 tANI_U32 val = 0;
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08004428#ifdef FEATURE_WLAN_TDLS
4429 tANI_U16 aid;
4430 tpDphHashNode pStaDs;
4431#endif
4432
Jeff Johnson295189b2012-06-20 16:38:30 -07004433 if(NULL == psessionEntry)
4434 {
4435 return;
4436 }
4437
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304438 vos_mem_set( ( tANI_U8* ) &frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004439
4440 frm.Reason.code = nReason;
4441
4442 nStatus = dot11fGetPackedDeAuthSize( pMac, &frm, &nPayload );
4443 if ( DOT11F_FAILED( nStatus ) )
4444 {
4445 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004446 "or a De-Authentication (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004447 nStatus );
4448 // We'll fall back on the worst case scenario:
4449 nPayload = sizeof( tDot11fDeAuth );
4450 }
4451 else if ( DOT11F_WARNED( nStatus ) )
4452 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004453 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07004454 "the packed size for a De-Authentication "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004455 "(0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004456 }
4457
4458 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4459
4460 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
4461 ( tANI_U16 )nBytes, ( void** ) &pFrame,
4462 ( void** ) &pPacket );
4463 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4464 {
4465 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a De-"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004466 "Authentication."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07004467 return;
4468 }
4469
4470 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304471 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004472
4473 // Next, we fill out the buffer descriptor:
4474 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
4475 SIR_MAC_MGMT_DEAUTH, peer,psessionEntry->selfMacAddr);
4476 if ( eSIR_SUCCESS != nSirStatus )
4477 {
4478 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004479 "tor for a De-Authentication (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004480 nSirStatus );
4481 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
4482 ( void* ) pFrame, ( void* ) pPacket );
4483 return; // just allocated...
4484 }
4485
4486 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
4487
4488 // Prepare the BSSID
4489 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
4490
Chet Lanctot186b5732013-03-18 10:26:30 -07004491#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07004492 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07004493#endif
4494
Jeff Johnson295189b2012-06-20 16:38:30 -07004495 nStatus = dot11fPackDeAuth( pMac, &frm, pFrame +
4496 sizeof(tSirMacMgmtHdr),
4497 nPayload, &nPayload );
4498 if ( DOT11F_FAILED( nStatus ) )
4499 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004500 limLog( pMac, LOGE, FL("Failed to pack a DeAuthentication (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004501 nStatus );
4502 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
4503 ( void* ) pFrame, ( void* ) pPacket );
4504 return;
4505 }
4506 else if ( DOT11F_WARNED( nStatus ) )
4507 {
4508 limLog( pMac, LOGW, FL("There were warnings while packing a D"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004509 "e-Authentication (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004510 }
Abhishek Singhcd09b562013-12-24 16:02:20 +05304511 limLog( pMac, LOG1, FL("***Sessionid %d Sending Deauth frame with "
4512 "reason %u and waitForAck %d to "MAC_ADDRESS_STR" ,From "
4513 MAC_ADDRESS_STR), psessionEntry->peSessionId, nReason, waitForAck,
4514 MAC_ADDR_ARRAY(pMacHdr->da),
4515 MAC_ADDR_ARRAY(psessionEntry->selfMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07004516
4517 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07004518 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
4519 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07004520 )
4521 {
4522 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
4523 }
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08004524
Sushant Kaushike8681d22015-04-21 12:08:25 +05304525 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08004526
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304527 if( IS_FW_IN_TX_PATH_FEATURE_ENABLE )
4528 {
4529 /* This frame will be sent on air by firmware,
4530 which will ensure that this frame goes out
4531 even though DEL_STA is sent immediately */
4532 /* Without this for DEL_STA command there is
4533 risk of flushing frame in BTQM queue without
4534 sending on air */
Agarwal Ashisha8e81f52014-04-02 01:59:52 +05304535 limLog( pMac, LOG1, FL("Sending Deauth Frame over WQ5 to "MAC_ADDRESS_STR
4536 " From " MAC_ADDRESS_STR),MAC_ADDR_ARRAY(pMacHdr->da),
4537 MAC_ADDR_ARRAY(psessionEntry->selfMacAddr));
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304538 txFlag |= HAL_USE_FW_IN_TX_PATH;
4539 }
4540
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08004541#ifdef FEATURE_WLAN_TDLS
4542 pStaDs = dphLookupHashEntry(pMac, peer, &aid, &psessionEntry->dph.dphHashTable);
4543#endif
4544
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004545 if (waitForAck)
Jeff Johnson295189b2012-06-20 16:38:30 -07004546 {
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304547 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
4548 psessionEntry->peSessionId,
4549 pMacHdr->fc.subType));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004550 // Queue Disassociation frame in high priority WQ
4551 halstatus = halTxFrameWithTxComplete( pMac, pPacket, ( tANI_U16 ) nBytes,
4552 HAL_TXRX_FRM_802_11_MGMT,
4553 ANI_TXDIR_TODS,
4554 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
Ganesh Kondabattini10e67352015-03-16 17:41:57 +05304555 limTxComplete, pFrame, limDeauthTxCompleteCnf, txFlag,
4556 pMac->lim.txBdToken++);
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304557 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
4558 psessionEntry->peSessionId,
4559 halstatus));
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304560 if (!HAL_STATUS_SUCCESS(halstatus))
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004561 {
4562 limLog( pMac, LOGE, FL("Failed to send De-Authentication "
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304563 "(%X)!"),
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004564 nSirStatus );
Gopichand Nakkala4261ea52012-12-31 16:43:00 -08004565 //Pkt will be freed up by the callback limTxComplete
4566
4567 /*Call limProcessDeauthAckTimeout which will send
4568 * DeauthCnf for this frame
4569 */
4570 limProcessDeauthAckTimeout(pMac);
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004571 return;
4572 }
4573
4574 val = SYS_MS_TO_TICKS(LIM_DISASSOC_DEAUTH_ACK_TIMEOUT);
4575
4576 if (tx_timer_change(
4577 &pMac->lim.limTimers.gLimDeauthAckTimer, val, 0)
4578 != TX_SUCCESS)
4579 {
4580 limLog(pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004581 FL("Unable to change Deauth ack Timer val"));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004582 return;
4583 }
4584 else if(TX_SUCCESS != tx_timer_activate(
4585 &pMac->lim.limTimers.gLimDeauthAckTimer))
4586 {
4587 limLog(pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004588 FL("Unable to activate Deauth ack Timer"));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004589 limDeactivateAndChangeTimer(pMac, eLIM_DEAUTH_ACK_TIMER);
4590 return;
4591 }
4592 }
4593 else
4594 {
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304595 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
4596 psessionEntry->peSessionId,
4597 pMacHdr->fc.subType));
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08004598#ifdef FEATURE_WLAN_TDLS
4599 if ((NULL != pStaDs) && (STA_ENTRY_TDLS_PEER == pStaDs->staType))
4600 {
4601 // Queue Disassociation frame in high priority WQ
4602 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004603 HAL_TXRX_FRM_802_11_MGMT,
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08004604 ANI_TXDIR_IBSS,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004605 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4606 limTxComplete, pFrame, txFlag );
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08004607 }
4608 else
4609 {
4610#endif
4611 // Queue Disassociation frame in high priority WQ
4612 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4613 HAL_TXRX_FRM_802_11_MGMT,
4614 ANI_TXDIR_TODS,
4615 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4616 limTxComplete, pFrame, txFlag );
4617#ifdef FEATURE_WLAN_TDLS
4618 }
4619#endif
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304620 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
4621 psessionEntry->peSessionId,
4622 halstatus));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004623 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4624 {
4625 limLog( pMac, LOGE, FL("Failed to send De-Authentication "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004626 "(%X)!"),
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004627 nSirStatus );
4628 //Pkt will be freed up by the callback
4629 return;
4630 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004631 }
4632
4633} // End limSendDeauthMgmtFrame.
4634
4635
4636#ifdef ANI_SUPPORT_11H
4637/**
4638 * \brief Send a Measurement Report Action frame
4639 *
4640 *
4641 * \param pMac Pointer to the global MAC structure
4642 *
4643 * \param pMeasReqFrame Address of a tSirMacMeasReqActionFrame
4644 *
4645 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
4646 *
4647 *
4648 */
4649
4650tSirRetStatus
4651limSendMeasReportFrame(tpAniSirGlobal pMac,
4652 tpSirMacMeasReqActionFrame pMeasReqFrame,
4653 tSirMacAddr peer)
4654{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304655 tDot11fMeasurementReport frm;
4656 tANI_U8 *pFrame;
4657 tSirRetStatus nSirStatus;
4658 tpSirMacMgmtHdr pMacHdr;
4659 tANI_U32 nBytes, nPayload, nStatus, nCfg;
4660 void *pPacket;
4661 eHalStatus halstatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07004662
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304663 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004664
4665 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
4666 frm.Action.action = SIR_MAC_ACTION_MEASURE_REPORT_ID;
4667 frm.DialogToken.token = pMeasReqFrame->actionHeader.dialogToken;
4668
4669 switch ( pMeasReqFrame->measReqIE.measType )
4670 {
4671 case SIR_MAC_BASIC_MEASUREMENT_TYPE:
4672 nSirStatus =
4673 PopulateDot11fMeasurementReport0( pMac, pMeasReqFrame,
4674 &frm.MeasurementReport );
4675 break;
4676 case SIR_MAC_CCA_MEASUREMENT_TYPE:
4677 nSirStatus =
4678 PopulateDot11fMeasurementReport1( pMac, pMeasReqFrame,
4679 &frm.MeasurementReport );
4680 break;
4681 case SIR_MAC_RPI_MEASUREMENT_TYPE:
4682 nSirStatus =
4683 PopulateDot11fMeasurementReport2( pMac, pMeasReqFrame,
4684 &frm.MeasurementReport );
4685 break;
4686 default:
4687 limLog( pMac, LOGE, FL("Unknown measurement type %d in limSen"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004688 "dMeasReportFrame."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004689 pMeasReqFrame->measReqIE.measType );
4690 return eSIR_FAILURE;
4691 }
4692
4693 if ( eSIR_SUCCESS != nSirStatus ) return eSIR_FAILURE;
4694
4695 nStatus = dot11fGetPackedMeasurementReportSize( pMac, &frm, &nPayload );
4696 if ( DOT11F_FAILED( nStatus ) )
4697 {
4698 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004699 "or a Measurement Report (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004700 nStatus );
4701 // We'll fall back on the worst case scenario:
4702 nPayload = sizeof( tDot11fMeasurementReport );
4703 }
4704 else if ( DOT11F_WARNED( nStatus ) )
4705 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004706 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07004707 "the packed size for a Measurement Rep"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004708 "ort (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004709 }
4710
4711 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4712
4713 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
4714 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4715 {
4716 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a De-"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004717 "Authentication."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07004718 return eSIR_FAILURE;
4719 }
4720
4721 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304722 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004723
4724 // Next, we fill out the buffer descriptor:
4725 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
4726 SIR_MAC_MGMT_ACTION, peer);
4727 if ( eSIR_SUCCESS != nSirStatus )
4728 {
4729 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004730 "tor for a Measurement Report (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004731 nSirStatus );
4732 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4733 return eSIR_FAILURE; // just allocated...
4734 }
4735
4736 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
4737
4738 nCfg = 6;
4739 nSirStatus = wlan_cfgGetStr( pMac, WNI_CFG_BSSID, pMacHdr->bssId, &nCfg );
4740 if ( eSIR_SUCCESS != nSirStatus )
4741 {
4742 limLog( pMac, LOGE, FL("Failed to retrieve WNI_CFG_BSSID from"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004743 " CFG (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004744 nSirStatus );
4745 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4746 return eSIR_FAILURE; // just allocated...
4747 }
4748
Chet Lanctot186b5732013-03-18 10:26:30 -07004749#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07004750 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07004751#endif
4752
Jeff Johnson295189b2012-06-20 16:38:30 -07004753 nStatus = dot11fPackMeasurementReport( pMac, &frm, pFrame +
4754 sizeof(tSirMacMgmtHdr),
4755 nPayload, &nPayload );
4756 if ( DOT11F_FAILED( nStatus ) )
4757 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004758 limLog( pMac, LOGE, FL("Failed to pack a Measurement Report (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004759 nStatus );
4760 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4761 return eSIR_FAILURE; // allocated!
4762 }
4763 else if ( DOT11F_WARNED( nStatus ) )
4764 {
4765 limLog( pMac, LOGW, FL("There were warnings while packing a M"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004766 "easurement Report (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004767 }
4768
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304769 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
4770 ((psessionEntry)? psessionEntry->peSessionId : NO_SESSION),
4771 pMacHdr->fc.subType));
Jeff Johnson295189b2012-06-20 16:38:30 -07004772 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4773 HAL_TXRX_FRM_802_11_MGMT,
4774 ANI_TXDIR_TODS,
4775 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4776 limTxComplete, pFrame, 0 );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304777 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
4778 ((psessionEntry)? psessionEntry->peSessionId : NO_SESSION),
4779 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07004780 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4781 {
4782 limLog( pMac, LOGE, FL("Failed to send a Measurement Report "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004783 "(%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07004784 nSirStatus );
4785 //Pkt will be freed up by the callback
4786 return eSIR_FAILURE; // just allocated...
4787 }
4788
4789 return eSIR_SUCCESS;
4790
4791} // End limSendMeasReportFrame.
4792
4793
4794/**
4795 * \brief Send a TPC Request Action frame
4796 *
4797 *
4798 * \param pMac Pointer to the global MAC datastructure
4799 *
4800 * \param peer MAC address to which the frame should be sent
4801 *
4802 *
4803 */
4804
4805void
4806limSendTpcRequestFrame(tpAniSirGlobal pMac,
4807 tSirMacAddr peer)
4808{
4809 tDot11fTPCRequest frm;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304810 tANI_U8 *pFrame;
Jeff Johnson295189b2012-06-20 16:38:30 -07004811 tSirRetStatus nSirStatus;
4812 tpSirMacMgmtHdr pMacHdr;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304813 tANI_U32 nBytes, nPayload, nStatus, nCfg;
4814 void *pPacket;
4815 eHalStatus halstatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07004816
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304817 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004818
4819 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
4820 frm.Action.action = SIR_MAC_ACTION_TPC_REQUEST_ID;
4821 frm.DialogToken.token = 1;
4822 frm.TPCRequest.present = 1;
4823
4824 nStatus = dot11fGetPackedTPCRequestSize( pMac, &frm, &nPayload );
4825 if ( DOT11F_FAILED( nStatus ) )
4826 {
4827 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004828 "or a TPC Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004829 nStatus );
4830 // We'll fall back on the worst case scenario:
4831 nPayload = sizeof( tDot11fTPCRequest );
4832 }
4833 else if ( DOT11F_WARNED( nStatus ) )
4834 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004835 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07004836 "the packed size for a TPC Request (0x"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004837 "%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004838 }
4839
4840 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4841
4842 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
4843 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4844 {
4845 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a TPC"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004846 " Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07004847 return;
4848 }
4849
4850 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304851 vos_mem_set(pFrame, nBytes,0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004852
4853 // Next, we fill out the buffer descriptor:
4854 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
4855 SIR_MAC_MGMT_ACTION, peer);
4856 if ( eSIR_SUCCESS != nSirStatus )
4857 {
4858 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004859 "tor for a TPC Request (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004860 nSirStatus );
4861 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4862 return; // just allocated...
4863 }
4864
4865 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
4866
4867 nCfg = 6;
4868 nSirStatus = wlan_cfgGetStr( pMac, WNI_CFG_BSSID, pMacHdr->bssId, &nCfg );
4869 if ( eSIR_SUCCESS != nSirStatus )
4870 {
4871 limLog( pMac, LOGE, FL("Failed to retrieve WNI_CFG_BSSID from"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004872 " CFG (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004873 nSirStatus );
4874 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4875 return; // just allocated...
4876 }
4877
Chet Lanctot186b5732013-03-18 10:26:30 -07004878#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07004879 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07004880#endif
4881
Jeff Johnson295189b2012-06-20 16:38:30 -07004882 nStatus = dot11fPackTPCRequest( pMac, &frm, pFrame +
4883 sizeof(tSirMacMgmtHdr),
4884 nPayload, &nPayload );
4885 if ( DOT11F_FAILED( nStatus ) )
4886 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004887 limLog( pMac, LOGE, FL("Failed to pack a TPC Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004888 nStatus );
4889 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4890 return; // allocated!
4891 }
4892 else if ( DOT11F_WARNED( nStatus ) )
4893 {
4894 limLog( pMac, LOGW, FL("There were warnings while packing a T"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004895 "PC Request (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004896 }
4897
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304898 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
4899 ((psessionEntry)? psessionEntry->peSessionId : NO_SESSION),
4900 pMacHdr->fc.subType));
Jeff Johnson295189b2012-06-20 16:38:30 -07004901 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4902 HAL_TXRX_FRM_802_11_MGMT,
4903 ANI_TXDIR_TODS,
4904 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4905 limTxComplete, pFrame, 0 );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304906 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
4907 ((psessionEntry)? psessionEntry->peSessionId : NO_SESSION),
4908 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07004909 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4910 {
4911 limLog( pMac, LOGE, FL("Failed to send a TPC Request "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004912 "(%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07004913 nSirStatus );
4914 //Pkt will be freed up by the callback
4915 return;
4916 }
4917
4918} // End limSendTpcRequestFrame.
4919
4920
4921/**
4922 * \brief Send a TPC Report Action frame
4923 *
4924 *
4925 * \param pMac Pointer to the global MAC datastructure
4926 *
4927 * \param pTpcReqFrame Pointer to the received TPC Request
4928 *
4929 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
4930 *
4931 *
4932 */
4933
4934tSirRetStatus
4935limSendTpcReportFrame(tpAniSirGlobal pMac,
4936 tpSirMacTpcReqActionFrame pTpcReqFrame,
4937 tSirMacAddr peer)
4938{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304939 tDot11fTPCReport frm;
4940 tANI_U8 *pFrame;
4941 tSirRetStatus nSirStatus;
4942 tpSirMacMgmtHdr pMacHdr;
4943 tANI_U32 nBytes, nPayload, nStatus, nCfg;
4944 void *pPacket;
4945 eHalStatus halstatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07004946
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304947 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004948
4949 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
4950 frm.Action.action = SIR_MAC_ACTION_TPC_REPORT_ID;
4951 frm.DialogToken.token = pTpcReqFrame->actionHeader.dialogToken;
4952
4953 // FramesToDo: On the Gen4_TVM branch, there was a comment:
4954 // "misplaced this function, need to replace:
4955 // txPower = halGetRateToPwrValue(pMac, staid,
4956 // pMac->lim.gLimCurrentChannelId, 0);
4957 frm.TPCReport.tx_power = 0;
4958 frm.TPCReport.link_margin = 0;
4959 frm.TPCReport.present = 1;
4960
4961 nStatus = dot11fGetPackedTPCReportSize( pMac, &frm, &nPayload );
4962 if ( DOT11F_FAILED( nStatus ) )
4963 {
4964 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004965 "or a TPC Report (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004966 nStatus );
4967 // We'll fall back on the worst case scenario:
4968 nPayload = sizeof( tDot11fTPCReport );
4969 }
4970 else if ( DOT11F_WARNED( nStatus ) )
4971 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004972 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07004973 "the packed size for a TPC Report (0x"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004974 "%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004975 }
4976
4977 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4978
4979 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
4980 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4981 {
4982 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a TPC"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004983 " Report."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07004984 return eSIR_FAILURE;
4985 }
4986
4987 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304988 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004989
4990 // Next, we fill out the buffer descriptor:
4991 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
4992 SIR_MAC_MGMT_ACTION, peer);
4993 if ( eSIR_SUCCESS != nSirStatus )
4994 {
4995 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004996 "tor for a TPC Report (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004997 nSirStatus );
4998 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4999 return eSIR_FAILURE; // just allocated...
5000 }
5001
5002 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
5003
5004 nCfg = 6;
5005 nSirStatus = wlan_cfgGetStr( pMac, WNI_CFG_BSSID, pMacHdr->bssId, &nCfg );
5006 if ( eSIR_SUCCESS != nSirStatus )
5007 {
5008 limLog( pMac, LOGE, FL("Failed to retrieve WNI_CFG_BSSID from"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005009 " CFG (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005010 nSirStatus );
5011 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
5012 return eSIR_FAILURE; // just allocated...
5013 }
5014
Chet Lanctot186b5732013-03-18 10:26:30 -07005015#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07005016 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07005017#endif
5018
Jeff Johnson295189b2012-06-20 16:38:30 -07005019 nStatus = dot11fPackTPCReport( pMac, &frm, pFrame +
5020 sizeof(tSirMacMgmtHdr),
5021 nPayload, &nPayload );
5022 if ( DOT11F_FAILED( nStatus ) )
5023 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005024 limLog( pMac, LOGE, FL("Failed to pack a TPC Report (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005025 nStatus );
5026 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
5027 return eSIR_FAILURE; // allocated!
5028 }
5029 else if ( DOT11F_WARNED( nStatus ) )
5030 {
5031 limLog( pMac, LOGW, FL("There were warnings while packing a T"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005032 "PC Report (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07005033 }
5034
5035
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05305036 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
5037 ((psessionEntry)? psessionEntry->peSessionId : NO_SESSION),
5038 pMacHdr->fc.subType));
Jeff Johnson295189b2012-06-20 16:38:30 -07005039 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
5040 HAL_TXRX_FRM_802_11_MGMT,
5041 ANI_TXDIR_TODS,
5042 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
5043 limTxComplete, pFrame, 0 );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05305044 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
5045 ((psessionEntry)? psessionEntry->peSessionId : NO_SESSION),
5046 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07005047 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
5048 {
5049 limLog( pMac, LOGE, FL("Failed to send a TPC Report "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005050 "(%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07005051 nSirStatus );
5052 //Pkt will be freed up by the callback
5053 return eSIR_FAILURE; // just allocated...
5054 }
5055
5056 return eSIR_SUCCESS;
5057
5058} // End limSendTpcReportFrame.
5059#endif //ANI_SUPPORT_11H
5060
5061
Jeff Johnson295189b2012-06-20 16:38:30 -07005062/**
5063 * \brief Send a Channel Switch Announcement
5064 *
5065 *
5066 * \param pMac Pointer to the global MAC datastructure
5067 *
5068 * \param peer MAC address to which this frame will be sent
5069 *
5070 * \param nMode
5071 *
5072 * \param nNewChannel
5073 *
5074 * \param nCount
5075 *
5076 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
5077 *
5078 *
5079 */
5080
5081tSirRetStatus
5082limSendChannelSwitchMgmtFrame(tpAniSirGlobal pMac,
5083 tSirMacAddr peer,
Jeff Johnsone7245742012-09-05 17:12:55 -07005084 tANI_U8 nMode,
5085 tANI_U8 nNewChannel,
5086 tANI_U8 nCount,
5087 tpPESession psessionEntry )
Jeff Johnson295189b2012-06-20 16:38:30 -07005088{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05305089 tDot11fChannelSwitch frm;
5090 tANI_U8 *pFrame;
5091 tSirRetStatus nSirStatus;
5092 tpSirMacMgmtHdr pMacHdr;
5093 tANI_U32 nBytes, nPayload, nStatus;//, nCfg;
5094 void *pPacket;
5095 eHalStatus halstatus;
5096 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005097
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305098 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005099
5100 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
5101 frm.Action.action = SIR_MAC_ACTION_CHANNEL_SWITCH_ID;
5102 frm.ChanSwitchAnn.switchMode = nMode;
5103 frm.ChanSwitchAnn.newChannel = nNewChannel;
5104 frm.ChanSwitchAnn.switchCount = nCount;
5105 frm.ChanSwitchAnn.present = 1;
5106
5107 nStatus = dot11fGetPackedChannelSwitchSize( pMac, &frm, &nPayload );
5108 if ( DOT11F_FAILED( nStatus ) )
5109 {
5110 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005111 "or a Channel Switch (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005112 nStatus );
5113 // We'll fall back on the worst case scenario:
5114 nPayload = sizeof( tDot11fChannelSwitch );
5115 }
5116 else if ( DOT11F_WARNED( nStatus ) )
5117 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005118 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07005119 "the packed size for a Channel Switch (0x"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005120 "%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07005121 }
5122
5123 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
5124
5125 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
5126 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
5127 {
5128 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a TPC"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005129 " Report."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07005130 return eSIR_FAILURE;
5131 }
5132
5133 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305134 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005135
5136 // Next, we fill out the buffer descriptor:
5137 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
Jeff Johnsone7245742012-09-05 17:12:55 -07005138 SIR_MAC_MGMT_ACTION, peer, psessionEntry->selfMacAddr);
5139 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305140 vos_mem_copy( (tANI_U8 *) pMacHdr->bssId,
5141 (tANI_U8 *) psessionEntry->bssId,
5142 sizeof( tSirMacAddr ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005143 if ( eSIR_SUCCESS != nSirStatus )
5144 {
5145 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005146 "tor for a Channel Switch (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005147 nSirStatus );
5148 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
5149 return eSIR_FAILURE; // just allocated...
5150 }
5151
Jeff Johnsone7245742012-09-05 17:12:55 -07005152#if 0
Jeff Johnson295189b2012-06-20 16:38:30 -07005153 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
5154
5155 nCfg = 6;
5156 nSirStatus = wlan_cfgGetStr( pMac, WNI_CFG_BSSID, pMacHdr->bssId, &nCfg );
5157 if ( eSIR_SUCCESS != nSirStatus )
5158 {
5159 limLog( pMac, LOGE, FL("Failed to retrieve WNI_CFG_BSSID from"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005160 " CFG (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005161 nSirStatus );
5162 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
5163 return eSIR_FAILURE; // just allocated...
5164 }
Jeff Johnsone7245742012-09-05 17:12:55 -07005165#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07005166
5167#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07005168 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07005169#endif
5170
Jeff Johnson295189b2012-06-20 16:38:30 -07005171 nStatus = dot11fPackChannelSwitch( pMac, &frm, pFrame +
5172 sizeof(tSirMacMgmtHdr),
5173 nPayload, &nPayload );
5174 if ( DOT11F_FAILED( nStatus ) )
5175 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005176 limLog( pMac, LOGE, FL("Failed to pack a Channel Switch (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005177 nStatus );
5178 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
5179 return eSIR_FAILURE; // allocated!
5180 }
5181 else if ( DOT11F_WARNED( nStatus ) )
5182 {
5183 limLog( pMac, LOGW, FL("There were warnings while packing a C"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005184 "hannel Switch (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07005185 }
5186
Jeff Johnsone7245742012-09-05 17:12:55 -07005187 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnsone7245742012-09-05 17:12:55 -07005188 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
5189 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnsone7245742012-09-05 17:12:55 -07005190 )
5191 {
5192 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
5193 }
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05305194
5195 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
5196 psessionEntry->peSessionId,
5197 pMacHdr->fc.subType));
Jeff Johnson295189b2012-06-20 16:38:30 -07005198 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
5199 HAL_TXRX_FRM_802_11_MGMT,
5200 ANI_TXDIR_TODS,
5201 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
Jeff Johnsone7245742012-09-05 17:12:55 -07005202 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05305203 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
5204 psessionEntry->peSessionId,
5205 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07005206 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
5207 {
5208 limLog( pMac, LOGE, FL("Failed to send a Channel Switch "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005209 "(%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07005210 nSirStatus );
5211 //Pkt will be freed up by the callback
5212 return eSIR_FAILURE;
5213 }
5214
5215 return eSIR_SUCCESS;
5216
5217} // End limSendChannelSwitchMgmtFrame.
5218
Jeff Johnson295189b2012-06-20 16:38:30 -07005219
5220
Mohit Khanna4a70d262012-09-11 16:30:12 -07005221#ifdef WLAN_FEATURE_11AC
5222tSirRetStatus
5223limSendVHTOpmodeNotificationFrame(tpAniSirGlobal pMac,
5224 tSirMacAddr peer,
5225 tANI_U8 nMode,
5226 tpPESession psessionEntry )
5227{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05305228 tDot11fOperatingMode frm;
5229 tANI_U8 *pFrame;
5230 tSirRetStatus nSirStatus;
5231 tpSirMacMgmtHdr pMacHdr;
5232 tANI_U32 nBytes, nPayload = 0, nStatus;//, nCfg;
5233 void *pPacket;
5234 eHalStatus halstatus;
5235 tANI_U32 txFlag = 0;
Mohit Khanna4a70d262012-09-11 16:30:12 -07005236
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305237 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Mohit Khanna4a70d262012-09-11 16:30:12 -07005238
5239 frm.Category.category = SIR_MAC_ACTION_VHT;
5240 frm.Action.action = SIR_MAC_VHT_OPMODE_NOTIFICATION;
5241 frm.OperatingMode.chanWidth = nMode;
5242 frm.OperatingMode.rxNSS = 0;
5243 frm.OperatingMode.rxNSSType = 0;
5244
5245 nStatus = dot11fGetPackedOperatingModeSize( pMac, &frm, &nPayload );
5246 if ( DOT11F_FAILED( nStatus ) )
5247 {
5248 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005249 "or a Operating Mode (0x%08x)."),
Mohit Khanna4a70d262012-09-11 16:30:12 -07005250 nStatus );
5251 // We'll fall back on the worst case scenario:
5252 nPayload = sizeof( tDot11fOperatingMode);
5253 }
5254 else if ( DOT11F_WARNED( nStatus ) )
5255 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005256 limLog( pMac, LOGW, FL("There were warnings while calculating "
Mohit Khanna4a70d262012-09-11 16:30:12 -07005257 "the packed size for a Operating Mode (0x"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005258 "%08x)."), nStatus );
Mohit Khanna4a70d262012-09-11 16:30:12 -07005259 }
5260
5261 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
5262
5263 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
5264 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
5265 {
5266 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Operating Mode"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005267 " Report."), nBytes );
Mohit Khanna4a70d262012-09-11 16:30:12 -07005268 return eSIR_FAILURE;
5269 }
5270
5271 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305272 vos_mem_set( pFrame, nBytes, 0 );
Mohit Khanna4a70d262012-09-11 16:30:12 -07005273
5274
5275 // Next, we fill out the buffer descriptor:
5276 if(psessionEntry->pePersona == VOS_STA_SAP_MODE) {
5277 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
5278 SIR_MAC_MGMT_ACTION, peer, psessionEntry->selfMacAddr);
5279 } else
5280 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
5281 SIR_MAC_MGMT_ACTION, psessionEntry->bssId, psessionEntry->selfMacAddr);
5282 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305283 vos_mem_copy( (tANI_U8 *) pMacHdr->bssId,
5284 (tANI_U8 *) psessionEntry->bssId,
5285 sizeof( tSirMacAddr ));
Mohit Khanna4a70d262012-09-11 16:30:12 -07005286 if ( eSIR_SUCCESS != nSirStatus )
5287 {
5288 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005289 "tor for a Operating Mode (%d)."),
Mohit Khanna4a70d262012-09-11 16:30:12 -07005290 nSirStatus );
5291 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
5292 return eSIR_FAILURE; // just allocated...
5293 }
5294 nStatus = dot11fPackOperatingMode( pMac, &frm, pFrame +
5295 sizeof(tSirMacMgmtHdr),
5296 nPayload, &nPayload );
5297 if ( DOT11F_FAILED( nStatus ) )
5298 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005299 limLog( pMac, LOGE, FL("Failed to pack a Operating Mode (0x%08x)."),
Mohit Khanna4a70d262012-09-11 16:30:12 -07005300 nStatus );
5301 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
5302 return eSIR_FAILURE; // allocated!
5303 }
5304 else if ( DOT11F_WARNED( nStatus ) )
5305 {
5306 limLog( pMac, LOGW, FL("There were warnings while packing a Operating Mode"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005307 " (0x%08x)."), nStatus );
Mohit Khanna4a70d262012-09-11 16:30:12 -07005308 }
5309 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Mohit Khanna4a70d262012-09-11 16:30:12 -07005310 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
5311 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Mohit Khanna4a70d262012-09-11 16:30:12 -07005312 )
5313 {
5314 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
5315 }
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05305316
5317 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
5318 psessionEntry->peSessionId,
5319 pMacHdr->fc.subType));
Mohit Khanna4a70d262012-09-11 16:30:12 -07005320 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
5321 HAL_TXRX_FRM_802_11_MGMT,
5322 ANI_TXDIR_TODS,
5323 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
5324 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05305325 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
5326 psessionEntry->peSessionId,
5327 halstatus));
Mohit Khanna4a70d262012-09-11 16:30:12 -07005328 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
5329 {
5330 limLog( pMac, LOGE, FL("Failed to send a Channel Switch "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005331 "(%X)!"),
Mohit Khanna4a70d262012-09-11 16:30:12 -07005332 nSirStatus );
5333 //Pkt will be freed up by the callback
5334 return eSIR_FAILURE;
5335 }
5336
5337 return eSIR_SUCCESS;
5338}
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005339
5340/**
5341 * \brief Send a VHT Channel Switch Announcement
5342 *
5343 *
5344 * \param pMac Pointer to the global MAC datastructure
5345 *
5346 * \param peer MAC address to which this frame will be sent
5347 *
5348 * \param nChanWidth
5349 *
5350 * \param nNewChannel
5351 *
5352 *
5353 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
5354 *
5355 *
5356 */
5357
5358tSirRetStatus
5359limSendVHTChannelSwitchMgmtFrame(tpAniSirGlobal pMac,
5360 tSirMacAddr peer,
5361 tANI_U8 nChanWidth,
5362 tANI_U8 nNewChannel,
5363 tANI_U8 ncbMode,
5364 tpPESession psessionEntry )
5365{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05305366 tDot11fChannelSwitch frm;
5367 tANI_U8 *pFrame;
5368 tSirRetStatus nSirStatus;
5369 tpSirMacMgmtHdr pMacHdr;
5370 tANI_U32 nBytes, nPayload, nStatus;//, nCfg;
5371 void *pPacket;
5372 eHalStatus halstatus;
5373 tANI_U32 txFlag = 0;
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005374
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305375 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005376
5377
5378 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
5379 frm.Action.action = SIR_MAC_ACTION_CHANNEL_SWITCH_ID;
5380 frm.ChanSwitchAnn.switchMode = 1;
5381 frm.ChanSwitchAnn.newChannel = nNewChannel;
5382 frm.ChanSwitchAnn.switchCount = 1;
5383 frm.ExtChanSwitchAnn.secondaryChannelOffset = limGetHTCBState(ncbMode);
5384 frm.ExtChanSwitchAnn.present = 1;
5385 frm.WiderBWChanSwitchAnn.newChanWidth = nChanWidth;
5386 frm.WiderBWChanSwitchAnn.newCenterChanFreq0 = limGetCenterChannel(pMac,nNewChannel,ncbMode,nChanWidth);
5387 frm.WiderBWChanSwitchAnn.newCenterChanFreq1 = 0;
5388 frm.ChanSwitchAnn.present = 1;
5389 frm.WiderBWChanSwitchAnn.present = 1;
5390
5391 nStatus = dot11fGetPackedChannelSwitchSize( pMac, &frm, &nPayload );
5392 if ( DOT11F_FAILED( nStatus ) )
5393 {
5394 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005395 "or a Channel Switch (0x%08x)."),
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005396 nStatus );
5397 // We'll fall back on the worst case scenario:
5398 nPayload = sizeof( tDot11fChannelSwitch );
5399 }
5400 else if ( DOT11F_WARNED( nStatus ) )
5401 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005402 limLog( pMac, LOGW, FL("There were warnings while calculating "
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005403 "the packed size for a Channel Switch (0x"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005404 "%08x)."), nStatus );
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005405 }
5406
5407 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
5408
5409 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
5410 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
5411 {
5412 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a TPC"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005413 " Report."), nBytes );
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005414 return eSIR_FAILURE;
5415 }
5416 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305417 vos_mem_set( pFrame, nBytes, 0 );
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005418
5419 // Next, we fill out the buffer descriptor:
5420 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
5421 SIR_MAC_MGMT_ACTION, peer, psessionEntry->selfMacAddr);
5422 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305423 vos_mem_copy( (tANI_U8 *) pMacHdr->bssId,
5424 (tANI_U8 *) psessionEntry->bssId,
5425 sizeof( tSirMacAddr ));
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005426 if ( eSIR_SUCCESS != nSirStatus )
5427 {
5428 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005429 "tor for a Channel Switch (%d)."),
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005430 nSirStatus );
5431 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
5432 return eSIR_FAILURE; // just allocated...
5433 }
5434 nStatus = dot11fPackChannelSwitch( pMac, &frm, pFrame +
5435 sizeof(tSirMacMgmtHdr),
5436 nPayload, &nPayload );
5437 if ( DOT11F_FAILED( nStatus ) )
5438 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005439 limLog( pMac, LOGE, FL("Failed to pack a Channel Switch (0x%08x)."),
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005440 nStatus );
5441 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
5442 return eSIR_FAILURE; // allocated!
5443 }
5444 else if ( DOT11F_WARNED( nStatus ) )
5445 {
5446 limLog( pMac, LOGW, FL("There were warnings while packing a C"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005447 "hannel Switch (0x%08x)."), nStatus );
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005448 }
5449
5450 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005451 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
5452 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005453 )
5454 {
5455 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
5456 }
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05305457
5458 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
5459 psessionEntry->peSessionId,
5460 pMacHdr->fc.subType));
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005461 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
5462 HAL_TXRX_FRM_802_11_MGMT,
5463 ANI_TXDIR_TODS,
5464 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
5465 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05305466 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
5467 psessionEntry->peSessionId,
5468 halstatus));
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005469 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
5470 {
5471 limLog( pMac, LOGE, FL("Failed to send a Channel Switch "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005472 "(%X)!"),
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005473 nSirStatus );
5474 //Pkt will be freed up by the callback
5475 return eSIR_FAILURE;
5476 }
5477
5478 return eSIR_SUCCESS;
5479
5480} // End limSendVHTChannelSwitchMgmtFrame.
5481
5482
5483
Mohit Khanna4a70d262012-09-11 16:30:12 -07005484#endif
5485
Jeff Johnson295189b2012-06-20 16:38:30 -07005486/**
5487 * \brief Send an ADDBA Req Action Frame to peer
5488 *
5489 * \sa limSendAddBAReq
5490 *
5491 * \param pMac The global tpAniSirGlobal object
5492 *
5493 * \param pMlmAddBAReq A pointer to tLimMlmAddBAReq. This contains
5494 * the necessary parameters reqd by PE send the ADDBA Req Action
5495 * Frame to the peer
5496 *
5497 * \return eSIR_SUCCESS if setup completes successfully
5498 * eSIR_FAILURE is some problem is encountered
5499 */
5500tSirRetStatus limSendAddBAReq( tpAniSirGlobal pMac,
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305501 tpLimMlmAddBAReq pMlmAddBAReq, tpPESession psessionEntry)
Jeff Johnson295189b2012-06-20 16:38:30 -07005502{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05305503 tDot11fAddBAReq frmAddBAReq;
5504 tANI_U8 *pAddBAReqBuffer = NULL;
5505 tpSirMacMgmtHdr pMacHdr;
5506 tANI_U32 frameLen = 0, nStatus, nPayload;
5507 tSirRetStatus statusCode;
5508 eHalStatus halStatus;
5509 void *pPacket;
5510 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005511
5512 if(NULL == psessionEntry)
5513 {
5514 return eSIR_FAILURE;
5515 }
5516
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305517 vos_mem_set( (void *) &frmAddBAReq, sizeof( frmAddBAReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005518
5519 // Category - 3 (BA)
5520 frmAddBAReq.Category.category = SIR_MAC_ACTION_BLKACK;
5521
5522 // Action - 0 (ADDBA Req)
5523 frmAddBAReq.Action.action = SIR_MAC_BLKACK_ADD_REQ;
5524
5525 // FIXME - Dialog Token, generalize this...
5526 frmAddBAReq.DialogToken.token = pMlmAddBAReq->baDialogToken;
5527
5528 // Fill the ADDBA Parameter Set
5529 frmAddBAReq.AddBAParameterSet.tid = pMlmAddBAReq->baTID;
5530 frmAddBAReq.AddBAParameterSet.policy = pMlmAddBAReq->baPolicy;
5531 frmAddBAReq.AddBAParameterSet.bufferSize = pMlmAddBAReq->baBufferSize;
5532
5533 // BA timeout
5534 // 0 - indicates no BA timeout
5535 frmAddBAReq.BATimeout.timeout = pMlmAddBAReq->baTimeout;
5536
Abhishek Singh1f6e6532014-06-05 17:35:08 +05305537 /* Send SSN whatever we get from FW.
5538 */
5539 frmAddBAReq.BAStartingSequenceControl.ssn = pMlmAddBAReq->baSSN;
Jeff Johnson295189b2012-06-20 16:38:30 -07005540
5541 nStatus = dot11fGetPackedAddBAReqSize( pMac, &frmAddBAReq, &nPayload );
5542
5543 if( DOT11F_FAILED( nStatus ))
5544 {
5545 limLog( pMac, LOGW,
5546 FL( "Failed to calculate the packed size for "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005547 "an ADDBA Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005548 nStatus );
5549
5550 // We'll fall back on the worst case scenario:
5551 nPayload = sizeof( tDot11fAddBAReq );
5552 }
5553 else if( DOT11F_WARNED( nStatus ))
5554 {
5555 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005556 FL( "There were warnings while calculating "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005557 "the packed size for an ADDBA Req (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005558 nStatus );
5559 }
5560
5561 // Add the MGMT header to frame length
5562 frameLen = nPayload + sizeof( tSirMacMgmtHdr );
5563
5564 // Need to allocate a buffer for ADDBA AF
5565 if( eHAL_STATUS_SUCCESS !=
5566 (halStatus = palPktAlloc( pMac->hHdd,
5567 HAL_TXRX_FRM_802_11_MGMT,
5568 (tANI_U16) frameLen,
5569 (void **) &pAddBAReqBuffer,
5570 (void **) &pPacket )))
5571 {
5572 // Log error
5573 limLog( pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005574 FL("palPktAlloc FAILED! Length [%d], Status [%d]"),
Jeff Johnson295189b2012-06-20 16:38:30 -07005575 frameLen,
5576 halStatus );
5577
5578 statusCode = eSIR_MEM_ALLOC_FAILED;
5579 goto returnAfterError;
5580 }
5581
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305582 vos_mem_set( (void *) pAddBAReqBuffer, frameLen, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005583
5584 // Copy necessary info to BD
5585 if( eSIR_SUCCESS !=
5586 (statusCode = limPopulateMacHeader( pMac,
5587 pAddBAReqBuffer,
5588 SIR_MAC_MGMT_FRAME,
5589 SIR_MAC_MGMT_ACTION,
5590 pMlmAddBAReq->peerMacAddr,psessionEntry->selfMacAddr)))
5591 goto returnAfterError;
5592
5593 // Update A3 with the BSSID
5594 pMacHdr = ( tpSirMacMgmtHdr ) pAddBAReqBuffer;
5595
5596 #if 0
5597 cfgLen = SIR_MAC_ADDR_LENGTH;
5598 if( eSIR_SUCCESS != cfgGetStr( pMac,
5599 WNI_CFG_BSSID,
5600 (tANI_U8 *) pMacHdr->bssId,
5601 &cfgLen ))
5602 {
5603 limLog( pMac, LOGP,
5604 FL( "Failed to retrieve WNI_CFG_BSSID while"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005605 "sending an ACTION Frame" ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005606
5607 // FIXME - Need to convert to tSirRetStatus
5608 statusCode = eSIR_FAILURE;
5609 goto returnAfterError;
5610 }
5611 #endif//TO SUPPORT BT-AMP
5612 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
5613
Chet Lanctot186b5732013-03-18 10:26:30 -07005614#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07005615 limSetProtectedBit(pMac, psessionEntry, pMlmAddBAReq->peerMacAddr, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07005616#endif
5617
Jeff Johnson295189b2012-06-20 16:38:30 -07005618 // Now, we're ready to "pack" the frames
5619 nStatus = dot11fPackAddBAReq( pMac,
5620 &frmAddBAReq,
5621 pAddBAReqBuffer + sizeof( tSirMacMgmtHdr ),
5622 nPayload,
5623 &nPayload );
5624
5625 if( DOT11F_FAILED( nStatus ))
5626 {
5627 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005628 FL( "Failed to pack an ADDBA Req (0x%08x)." ),
Jeff Johnson295189b2012-06-20 16:38:30 -07005629 nStatus );
5630
5631 // FIXME - Need to convert to tSirRetStatus
5632 statusCode = eSIR_FAILURE;
5633 goto returnAfterError;
5634 }
5635 else if( DOT11F_WARNED( nStatus ))
5636 {
5637 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005638 FL( "There were warnings while packing an ADDBA Req (0x%08x)."),
5639 nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07005640 }
5641
Abhishek Singh02d9f6c2014-05-12 14:07:53 +05305642 limLog( pMac, LOG1, FL( "Sending an ADDBA REQ to "MAC_ADDRESS_STR " with"
5643 " tid = %d policy = %d buffsize = %d "
5644 " amsduSupported = %d"),
5645 MAC_ADDR_ARRAY(pMlmAddBAReq->peerMacAddr),
5646 frmAddBAReq.AddBAParameterSet.tid,
5647 frmAddBAReq.AddBAParameterSet.policy,
5648 frmAddBAReq.AddBAParameterSet.bufferSize,
5649 frmAddBAReq.AddBAParameterSet.amsduSupported);
Jeff Johnson295189b2012-06-20 16:38:30 -07005650
Abhishek Singh1f6e6532014-06-05 17:35:08 +05305651 limLog( pMac, LOG1, FL( "ssn = %d fragNum = %d" ),
5652 frmAddBAReq.BAStartingSequenceControl.ssn,
5653 frmAddBAReq.BAStartingSequenceControl.fragNumber);
5654
Jeff Johnson295189b2012-06-20 16:38:30 -07005655 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07005656 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
5657 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07005658 )
5659 {
5660 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
5661 }
5662
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05305663 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
5664 psessionEntry->peSessionId,
5665 pMacHdr->fc.subType));
5666 halStatus = halTxFrame( pMac,
5667 pPacket,
5668 (tANI_U16) frameLen,
5669 HAL_TXRX_FRM_802_11_MGMT,
5670 ANI_TXDIR_TODS,
5671 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
5672 limTxComplete,
5673 pAddBAReqBuffer, txFlag );
5674 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
5675 psessionEntry->peSessionId,
5676 halStatus));
5677 if( eHAL_STATUS_SUCCESS != halStatus )
Jeff Johnson295189b2012-06-20 16:38:30 -07005678 {
5679 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005680 FL( "halTxFrame FAILED! Status [%d]"),
Jeff Johnson295189b2012-06-20 16:38:30 -07005681 halStatus );
5682
5683 // FIXME - Need to convert eHalStatus to tSirRetStatus
5684 statusCode = eSIR_FAILURE;
5685 //Pkt will be freed up by the callback
5686 return statusCode;
5687 }
5688 else
5689 return eSIR_SUCCESS;
5690
5691returnAfterError:
5692
5693 // Release buffer, if allocated
5694 if( NULL != pAddBAReqBuffer )
5695 palPktFree( pMac->hHdd,
5696 HAL_TXRX_FRM_802_11_MGMT,
5697 (void *) pAddBAReqBuffer,
5698 (void *) pPacket );
5699
5700 return statusCode;
5701}
5702
5703/**
5704 * \brief Send an ADDBA Rsp Action Frame to peer
5705 *
5706 * \sa limSendAddBARsp
5707 *
5708 * \param pMac The global tpAniSirGlobal object
5709 *
5710 * \param pMlmAddBARsp A pointer to tLimMlmAddBARsp. This contains
5711 * the necessary parameters reqd by PE send the ADDBA Rsp Action
5712 * Frame to the peer
5713 *
5714 * \return eSIR_SUCCESS if setup completes successfully
5715 * eSIR_FAILURE is some problem is encountered
5716 */
5717tSirRetStatus limSendAddBARsp( tpAniSirGlobal pMac,
5718 tpLimMlmAddBARsp pMlmAddBARsp,
5719 tpPESession psessionEntry)
5720{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05305721 tDot11fAddBARsp frmAddBARsp;
5722 tANI_U8 *pAddBARspBuffer = NULL;
5723 tpSirMacMgmtHdr pMacHdr;
5724 tANI_U32 frameLen = 0, nStatus, nPayload;
5725 tSirRetStatus statusCode;
5726 eHalStatus halStatus;
5727 void *pPacket;
5728 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005729
5730 if(NULL == psessionEntry)
5731 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005732 PELOGE(limLog(pMac, LOGE, FL("Session entry is NULL!!!"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07005733 return eSIR_FAILURE;
5734 }
5735
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305736 vos_mem_set( (void *) &frmAddBARsp, sizeof( frmAddBARsp ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005737
5738 // Category - 3 (BA)
5739 frmAddBARsp.Category.category = SIR_MAC_ACTION_BLKACK;
5740 // Action - 1 (ADDBA Rsp)
5741 frmAddBARsp.Action.action = SIR_MAC_BLKACK_ADD_RSP;
5742
5743 // Should be same as the one we received in the ADDBA Req
5744 frmAddBARsp.DialogToken.token = pMlmAddBARsp->baDialogToken;
5745
5746 // ADDBA Req status
5747 frmAddBARsp.Status.status = pMlmAddBARsp->addBAResultCode;
5748
5749 // Fill the ADDBA Parameter Set as provided by caller
5750 frmAddBARsp.AddBAParameterSet.tid = pMlmAddBARsp->baTID;
5751 frmAddBARsp.AddBAParameterSet.policy = pMlmAddBARsp->baPolicy;
5752 frmAddBARsp.AddBAParameterSet.bufferSize = pMlmAddBARsp->baBufferSize;
krunal soni5afa96c2013-09-06 22:19:02 -07005753
5754 if(psessionEntry->isAmsduSupportInAMPDU)
5755 {
5756 frmAddBARsp.AddBAParameterSet.amsduSupported =
5757 psessionEntry->amsduSupportedInBA;
5758 }
5759 else
5760 {
5761 frmAddBARsp.AddBAParameterSet.amsduSupported = 0;
5762 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005763
5764 // BA timeout
5765 // 0 - indicates no BA timeout
5766 frmAddBARsp.BATimeout.timeout = pMlmAddBARsp->baTimeout;
5767
5768 nStatus = dot11fGetPackedAddBARspSize( pMac, &frmAddBARsp, &nPayload );
5769
5770 if( DOT11F_FAILED( nStatus ))
5771 {
5772 limLog( pMac, LOGW,
5773 FL( "Failed to calculate the packed size for "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005774 "an ADDBA Response (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005775 nStatus );
5776
5777 // We'll fall back on the worst case scenario:
5778 nPayload = sizeof( tDot11fAddBARsp );
5779 }
5780 else if( DOT11F_WARNED( nStatus ))
5781 {
5782 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005783 FL( "There were warnings while calculating "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005784 "the packed size for an ADDBA Rsp (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005785 nStatus );
5786 }
5787
5788 // Need to allocate a buffer for ADDBA AF
5789 frameLen = nPayload + sizeof( tSirMacMgmtHdr );
5790
5791 // Allocate shared memory
5792 if( eHAL_STATUS_SUCCESS !=
5793 (halStatus = palPktAlloc( pMac->hHdd,
5794 HAL_TXRX_FRM_802_11_MGMT,
5795 (tANI_U16) frameLen,
5796 (void **) &pAddBARspBuffer,
5797 (void **) &pPacket )))
5798 {
5799 // Log error
5800 limLog( pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005801 FL("palPktAlloc FAILED! Length [%d], Status [%d]"),
Jeff Johnson295189b2012-06-20 16:38:30 -07005802 frameLen,
5803 halStatus );
5804
5805 statusCode = eSIR_MEM_ALLOC_FAILED;
5806 goto returnAfterError;
5807 }
5808
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305809 vos_mem_set( (void *) pAddBARspBuffer, frameLen, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005810
5811 // Copy necessary info to BD
5812 if( eSIR_SUCCESS !=
5813 (statusCode = limPopulateMacHeader( pMac,
5814 pAddBARspBuffer,
5815 SIR_MAC_MGMT_FRAME,
5816 SIR_MAC_MGMT_ACTION,
5817 pMlmAddBARsp->peerMacAddr,psessionEntry->selfMacAddr)))
5818 goto returnAfterError;
5819
5820 // Update A3 with the BSSID
5821
5822 pMacHdr = ( tpSirMacMgmtHdr ) pAddBARspBuffer;
5823
5824 #if 0
5825 cfgLen = SIR_MAC_ADDR_LENGTH;
5826 if( eSIR_SUCCESS != wlan_cfgGetStr( pMac,
5827 WNI_CFG_BSSID,
5828 (tANI_U8 *) pMacHdr->bssId,
5829 &cfgLen ))
5830 {
5831 limLog( pMac, LOGP,
5832 FL( "Failed to retrieve WNI_CFG_BSSID while"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005833 "sending an ACTION Frame" ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005834
5835 // FIXME - Need to convert to tSirRetStatus
5836 statusCode = eSIR_FAILURE;
5837 goto returnAfterError;
5838 }
5839 #endif // TO SUPPORT BT-AMP
5840 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
5841
Chet Lanctot186b5732013-03-18 10:26:30 -07005842#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07005843 limSetProtectedBit(pMac, psessionEntry, pMlmAddBARsp->peerMacAddr, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07005844#endif
5845
Jeff Johnson295189b2012-06-20 16:38:30 -07005846 // Now, we're ready to "pack" the frames
5847 nStatus = dot11fPackAddBARsp( pMac,
5848 &frmAddBARsp,
5849 pAddBARspBuffer + sizeof( tSirMacMgmtHdr ),
5850 nPayload,
5851 &nPayload );
5852
5853 if( DOT11F_FAILED( nStatus ))
5854 {
5855 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005856 FL( "Failed to pack an ADDBA Rsp (0x%08x)." ),
Jeff Johnson295189b2012-06-20 16:38:30 -07005857 nStatus );
5858
5859 // FIXME - Need to convert to tSirRetStatus
5860 statusCode = eSIR_FAILURE;
5861 goto returnAfterError;
5862 }
5863 else if( DOT11F_WARNED( nStatus ))
5864 {
5865 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005866 FL( "There were warnings while packing an ADDBA Rsp (0x%08x)." ),
5867 nStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07005868 }
5869
Abhishek Singh02d9f6c2014-05-12 14:07:53 +05305870 limLog( pMac, LOG1, FL( "Sending an ADDBA RSP to "MAC_ADDRESS_STR " with"
5871 " tid = %d policy = %d buffsize = %d"
5872 " amsduSupported = %d status %d"),
5873 MAC_ADDR_ARRAY(pMlmAddBARsp->peerMacAddr),
5874 frmAddBARsp.AddBAParameterSet.tid,
5875 frmAddBARsp.AddBAParameterSet.policy,
5876 frmAddBARsp.AddBAParameterSet.bufferSize,
5877 frmAddBARsp.AddBAParameterSet.amsduSupported,
5878 frmAddBARsp.Status.status);
5879
Jeff Johnson295189b2012-06-20 16:38:30 -07005880
5881 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07005882 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
5883 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07005884 )
5885 {
5886 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
5887 }
5888
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05305889 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
5890 psessionEntry->peSessionId,
5891 pMacHdr->fc.subType));
5892 halStatus = halTxFrame( pMac,
5893 pPacket,
5894 (tANI_U16) frameLen,
5895 HAL_TXRX_FRM_802_11_MGMT,
5896 ANI_TXDIR_TODS,
5897 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
5898 limTxComplete,
5899 pAddBARspBuffer, txFlag );
5900 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
5901 psessionEntry->peSessionId,
5902 halStatus));
5903 if( eHAL_STATUS_SUCCESS != halStatus )
5904 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005905 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005906 FL( "halTxFrame FAILED! Status [%d]" ),
Jeff Johnson295189b2012-06-20 16:38:30 -07005907 halStatus );
5908
5909 // FIXME - HAL error codes are different from PE error
5910 // codes!! And, this routine is returning tSirRetStatus
5911 statusCode = eSIR_FAILURE;
5912 //Pkt will be freed up by the callback
5913 return statusCode;
5914 }
5915 else
5916 return eSIR_SUCCESS;
5917
5918 returnAfterError:
Jeff Johnson295189b2012-06-20 16:38:30 -07005919 // Release buffer, if allocated
5920 if( NULL != pAddBARspBuffer )
5921 palPktFree( pMac->hHdd,
5922 HAL_TXRX_FRM_802_11_MGMT,
5923 (void *) pAddBARspBuffer,
5924 (void *) pPacket );
5925
5926 return statusCode;
5927}
5928
5929/**
5930 * \brief Send a DELBA Indication Action Frame to peer
5931 *
5932 * \sa limSendDelBAInd
5933 *
5934 * \param pMac The global tpAniSirGlobal object
5935 *
5936 * \param peerMacAddr MAC Address of peer
5937 *
5938 * \param reasonCode Reason for the DELBA notification
5939 *
5940 * \param pBAParameterSet The DELBA Parameter Set.
5941 * This identifies the TID for which the BA session is
5942 * being deleted.
5943 *
5944 * \return eSIR_SUCCESS if setup completes successfully
5945 * eSIR_FAILURE is some problem is encountered
5946 */
5947tSirRetStatus limSendDelBAInd( tpAniSirGlobal pMac,
5948 tpLimMlmDelBAReq pMlmDelBAReq,tpPESession psessionEntry)
5949{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05305950 tDot11fDelBAInd frmDelBAInd;
5951 tANI_U8 *pDelBAIndBuffer = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005952 //tANI_U32 val;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05305953 tpSirMacMgmtHdr pMacHdr;
5954 tANI_U32 frameLen = 0, nStatus, nPayload;
5955 tSirRetStatus statusCode;
5956 eHalStatus halStatus;
5957 void *pPacket;
5958 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005959
5960 if(NULL == psessionEntry)
5961 {
5962 return eSIR_FAILURE;
5963 }
5964
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305965 vos_mem_set( (void *) &frmDelBAInd, sizeof( frmDelBAInd ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005966
5967 // Category - 3 (BA)
5968 frmDelBAInd.Category.category = SIR_MAC_ACTION_BLKACK;
5969 // Action - 2 (DELBA)
5970 frmDelBAInd.Action.action = SIR_MAC_BLKACK_DEL;
5971
5972 // Fill the DELBA Parameter Set as provided by caller
5973 frmDelBAInd.DelBAParameterSet.tid = pMlmDelBAReq->baTID;
5974 frmDelBAInd.DelBAParameterSet.initiator = pMlmDelBAReq->baDirection;
5975
5976 // BA Starting Sequence Number
5977 // Fragment number will always be zero
5978 frmDelBAInd.Reason.code = pMlmDelBAReq->delBAReasonCode;
5979
5980 nStatus = dot11fGetPackedDelBAIndSize( pMac, &frmDelBAInd, &nPayload );
5981
5982 if( DOT11F_FAILED( nStatus ))
5983 {
5984 limLog( pMac, LOGW,
5985 FL( "Failed to calculate the packed size for "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005986 "an DELBA Indication (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005987 nStatus );
5988
5989 // We'll fall back on the worst case scenario:
5990 nPayload = sizeof( tDot11fDelBAInd );
5991 }
5992 else if( DOT11F_WARNED( nStatus ))
5993 {
5994 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005995 FL( "There were warnings while calculating "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005996 "the packed size for an DELBA Ind (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005997 nStatus );
5998 }
5999
6000 // Add the MGMT header to frame length
6001 frameLen = nPayload + sizeof( tSirMacMgmtHdr );
6002
6003 // Allocate shared memory
6004 if( eHAL_STATUS_SUCCESS !=
6005 (halStatus = palPktAlloc( pMac->hHdd,
6006 HAL_TXRX_FRM_802_11_MGMT,
6007 (tANI_U16) frameLen,
6008 (void **) &pDelBAIndBuffer,
6009 (void **) &pPacket )))
6010 {
6011 // Log error
6012 limLog( pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006013 FL("palPktAlloc FAILED! Length [%d], Status [%d]"),
Jeff Johnson295189b2012-06-20 16:38:30 -07006014 frameLen,
6015 halStatus );
6016
6017 statusCode = eSIR_MEM_ALLOC_FAILED;
6018 goto returnAfterError;
6019 }
6020
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05306021 vos_mem_set( (void *) pDelBAIndBuffer, frameLen, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07006022
6023 // Copy necessary info to BD
6024 if( eSIR_SUCCESS !=
6025 (statusCode = limPopulateMacHeader( pMac,
6026 pDelBAIndBuffer,
6027 SIR_MAC_MGMT_FRAME,
6028 SIR_MAC_MGMT_ACTION,
6029 pMlmDelBAReq->peerMacAddr,psessionEntry->selfMacAddr)))
6030 goto returnAfterError;
6031
6032 // Update A3 with the BSSID
6033 pMacHdr = ( tpSirMacMgmtHdr ) pDelBAIndBuffer;
6034
6035 #if 0
6036 cfgLen = SIR_MAC_ADDR_LENGTH;
6037 if( eSIR_SUCCESS != cfgGetStr( pMac,
6038 WNI_CFG_BSSID,
6039 (tANI_U8 *) pMacHdr->bssId,
6040 &cfgLen ))
6041 {
6042 limLog( pMac, LOGP,
6043 FL( "Failed to retrieve WNI_CFG_BSSID while"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006044 "sending an ACTION Frame" ));
Jeff Johnson295189b2012-06-20 16:38:30 -07006045
6046 // FIXME - Need to convert to tSirRetStatus
6047 statusCode = eSIR_FAILURE;
6048 goto returnAfterError;
6049 }
6050 #endif //TO SUPPORT BT-AMP
6051 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
6052
Chet Lanctot186b5732013-03-18 10:26:30 -07006053#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07006054 limSetProtectedBit(pMac, psessionEntry, pMlmDelBAReq->peerMacAddr, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07006055#endif
6056
Jeff Johnson295189b2012-06-20 16:38:30 -07006057 // Now, we're ready to "pack" the frames
6058 nStatus = dot11fPackDelBAInd( pMac,
6059 &frmDelBAInd,
6060 pDelBAIndBuffer + sizeof( tSirMacMgmtHdr ),
6061 nPayload,
6062 &nPayload );
6063
6064 if( DOT11F_FAILED( nStatus ))
6065 {
6066 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006067 FL( "Failed to pack an DELBA Ind (0x%08x)." ),
Jeff Johnson295189b2012-06-20 16:38:30 -07006068 nStatus );
6069
6070 // FIXME - Need to convert to tSirRetStatus
6071 statusCode = eSIR_FAILURE;
6072 goto returnAfterError;
6073 }
6074 else if( DOT11F_WARNED( nStatus ))
6075 {
6076 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08006077 FL( "There were warnings while packing an DELBA Ind (0x%08x)." ),
6078 nStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07006079 }
6080
Abhishek Singh1f6e6532014-06-05 17:35:08 +05306081 limLog( pMac, LOG1,
6082 FL( "Sending a DELBA IND to: "MAC_ADDRESS_STR" with Tid = %d"
6083 " initiator = %d reason = %d" ),
6084 MAC_ADDR_ARRAY(pMlmDelBAReq->peerMacAddr),
6085 frmDelBAInd.DelBAParameterSet.tid,
6086 frmDelBAInd.DelBAParameterSet.initiator,
6087 frmDelBAInd.Reason.code);
6088
Jeff Johnson295189b2012-06-20 16:38:30 -07006089
6090 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07006091 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
6092 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07006093 )
6094 {
6095 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
6096 }
6097
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05306098 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
6099 psessionEntry->peSessionId,
6100 pMacHdr->fc.subType));
6101 halStatus = halTxFrame( pMac,
6102 pPacket,
6103 (tANI_U16) frameLen,
6104 HAL_TXRX_FRM_802_11_MGMT,
6105 ANI_TXDIR_TODS,
6106 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
6107 limTxComplete,
6108 pDelBAIndBuffer, txFlag );
6109 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
6110 psessionEntry->peSessionId,
6111 halStatus));
6112 if( eHAL_STATUS_SUCCESS != halStatus )
Jeff Johnson295189b2012-06-20 16:38:30 -07006113 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006114 PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]" ), halStatus );)
Jeff Johnson295189b2012-06-20 16:38:30 -07006115 statusCode = eSIR_FAILURE;
6116 //Pkt will be freed up by the callback
6117 return statusCode;
6118 }
6119 else
6120 return eSIR_SUCCESS;
6121
6122 returnAfterError:
6123
6124 // Release buffer, if allocated
6125 if( NULL != pDelBAIndBuffer )
6126 palPktFree( pMac->hHdd,
6127 HAL_TXRX_FRM_802_11_MGMT,
6128 (void *) pDelBAIndBuffer,
6129 (void *) pPacket );
6130
6131 return statusCode;
6132}
6133
6134#if defined WLAN_FEATURE_VOWIFI
6135
6136/**
6137 * \brief Send a Neighbor Report Request Action frame
6138 *
6139 *
6140 * \param pMac Pointer to the global MAC structure
6141 *
6142 * \param pNeighborReq Address of a tSirMacNeighborReportReq
6143 *
6144 * \param peer mac address of peer station.
6145 *
6146 * \param psessionEntry address of session entry.
6147 *
6148 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
6149 *
6150 *
6151 */
6152
6153tSirRetStatus
6154limSendNeighborReportRequestFrame(tpAniSirGlobal pMac,
6155 tpSirMacNeighborReportReq pNeighborReq,
6156 tSirMacAddr peer,
6157 tpPESession psessionEntry
6158 )
6159{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05306160 tSirRetStatus statusCode = eSIR_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006161 tDot11fNeighborReportRequest frm;
6162 tANI_U8 *pFrame;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05306163 tpSirMacMgmtHdr pMacHdr;
6164 tANI_U32 nBytes, nPayload, nStatus;
6165 void *pPacket;
6166 eHalStatus halstatus;
6167 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07006168
6169 if ( psessionEntry == NULL )
6170 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006171 limLog( pMac, LOGE, FL("(psession == NULL) in Request to send Neighbor Report request action frame") );
Jeff Johnson295189b2012-06-20 16:38:30 -07006172 return eSIR_FAILURE;
6173 }
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05306174 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07006175
6176 frm.Category.category = SIR_MAC_ACTION_RRM;
6177 frm.Action.action = SIR_MAC_RRM_NEIGHBOR_REQ;
6178 frm.DialogToken.token = pNeighborReq->dialogToken;
6179
6180
6181 if( pNeighborReq->ssid_present )
6182 {
6183 PopulateDot11fSSID( pMac, &pNeighborReq->ssid, &frm.SSID );
6184 }
6185
6186 nStatus = dot11fGetPackedNeighborReportRequestSize( pMac, &frm, &nPayload );
6187 if ( DOT11F_FAILED( nStatus ) )
6188 {
6189 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006190 "or a Neighbor Report Request(0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07006191 nStatus );
6192 // We'll fall back on the worst case scenario:
6193 nPayload = sizeof( tDot11fNeighborReportRequest );
6194 }
6195 else if ( DOT11F_WARNED( nStatus ) )
6196 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08006197 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07006198 "the packed size for a Neighbor Rep"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006199 "ort Request(0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07006200 }
6201
6202 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
6203
6204 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
6205 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
6206 {
6207 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Neighbor "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006208 "Report Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07006209 return eSIR_FAILURE;
6210 }
6211
6212 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05306213 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07006214
6215 // Copy necessary info to BD
6216 if( eSIR_SUCCESS !=
6217 (statusCode = limPopulateMacHeader( pMac,
6218 pFrame,
6219 SIR_MAC_MGMT_FRAME,
6220 SIR_MAC_MGMT_ACTION,
6221 peer, psessionEntry->selfMacAddr)))
6222 goto returnAfterError;
6223
6224 // Update A3 with the BSSID
6225 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
6226
6227 sirCopyMacAddr( pMacHdr->bssId, psessionEntry->bssId );
6228
Chet Lanctot186b5732013-03-18 10:26:30 -07006229#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07006230 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07006231#endif
6232
Jeff Johnson295189b2012-06-20 16:38:30 -07006233 // Now, we're ready to "pack" the frames
6234 nStatus = dot11fPackNeighborReportRequest( pMac,
6235 &frm,
6236 pFrame + sizeof( tSirMacMgmtHdr ),
6237 nPayload,
6238 &nPayload );
6239
6240 if( DOT11F_FAILED( nStatus ))
6241 {
6242 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006243 FL( "Failed to pack an Neighbor Report Request (0x%08x)." ),
Jeff Johnson295189b2012-06-20 16:38:30 -07006244 nStatus );
6245
6246 // FIXME - Need to convert to tSirRetStatus
6247 statusCode = eSIR_FAILURE;
6248 goto returnAfterError;
6249 }
6250 else if( DOT11F_WARNED( nStatus ))
6251 {
6252 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08006253 FL( "There were warnings while packing Neighbor Report "
6254 "Request (0x%08x)." ), nStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07006255 }
6256
6257 limLog( pMac, LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006258 FL( "Sending a Neighbor Report Request to " ));
Jeff Johnson295189b2012-06-20 16:38:30 -07006259 limPrintMacAddr( pMac, peer, LOGW );
6260
6261 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07006262 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
6263 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07006264 )
6265 {
6266 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
6267 }
6268
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05306269 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
6270 psessionEntry->peSessionId,
6271 pMacHdr->fc.subType));
6272 halstatus = halTxFrame( pMac,
6273 pPacket,
6274 (tANI_U16) nBytes,
6275 HAL_TXRX_FRM_802_11_MGMT,
6276 ANI_TXDIR_TODS,
6277 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
6278 limTxComplete,
6279 pFrame, txFlag );
6280 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
6281 psessionEntry->peSessionId,
6282 halstatus));
6283 if( eHAL_STATUS_SUCCESS != halstatus )
Jeff Johnson295189b2012-06-20 16:38:30 -07006284 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006285 PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]" ), halstatus );)
Jeff Johnson295189b2012-06-20 16:38:30 -07006286 statusCode = eSIR_FAILURE;
6287 //Pkt will be freed up by the callback
6288 return statusCode;
6289 }
6290 else
6291 return eSIR_SUCCESS;
6292
6293returnAfterError:
6294 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
6295
6296 return statusCode;
6297} // End limSendNeighborReportRequestFrame.
6298
6299/**
6300 * \brief Send a Link Report Action frame
6301 *
6302 *
6303 * \param pMac Pointer to the global MAC structure
6304 *
6305 * \param pLinkReport Address of a tSirMacLinkReport
6306 *
6307 * \param peer mac address of peer station.
6308 *
6309 * \param psessionEntry address of session entry.
6310 *
6311 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
6312 *
6313 *
6314 */
6315
6316tSirRetStatus
6317limSendLinkReportActionFrame(tpAniSirGlobal pMac,
6318 tpSirMacLinkReport pLinkReport,
6319 tSirMacAddr peer,
6320 tpPESession psessionEntry
6321 )
6322{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05306323 tSirRetStatus statusCode = eSIR_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006324 tDot11fLinkMeasurementReport frm;
6325 tANI_U8 *pFrame;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05306326 tpSirMacMgmtHdr pMacHdr;
6327 tANI_U32 nBytes, nPayload, nStatus;
6328 void *pPacket;
6329 eHalStatus halstatus;
6330 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07006331
6332
6333 if ( psessionEntry == NULL )
6334 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006335 limLog( pMac, LOGE, FL("(psession == NULL) in Request to send Link Report action frame") );
Jeff Johnson295189b2012-06-20 16:38:30 -07006336 return eSIR_FAILURE;
6337 }
6338
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05306339 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07006340
6341 frm.Category.category = SIR_MAC_ACTION_RRM;
6342 frm.Action.action = SIR_MAC_RRM_LINK_MEASUREMENT_RPT;
6343 frm.DialogToken.token = pLinkReport->dialogToken;
6344
6345
6346 //IEEE Std. 802.11 7.3.2.18. for the report element.
6347 //Even though TPC report an IE, it is represented using fixed fields since it is positioned
6348 //in the middle of other fixed fields in the link report frame(IEEE Std. 802.11k section7.4.6.4
6349 //and frame parser always expects IEs to come after all fixed fields. It is easier to handle
6350 //such case this way than changing the frame parser.
6351 frm.TPCEleID.TPCId = SIR_MAC_TPC_RPT_EID;
6352 frm.TPCEleLen.TPCLen = 2;
6353 frm.TxPower.txPower = pLinkReport->txPower;
6354 frm.LinkMargin.linkMargin = 0;
6355
6356 frm.RxAntennaId.antennaId = pLinkReport->rxAntenna;
6357 frm.TxAntennaId.antennaId = pLinkReport->txAntenna;
6358 frm.RCPI.rcpi = pLinkReport->rcpi;
6359 frm.RSNI.rsni = pLinkReport->rsni;
6360
6361 nStatus = dot11fGetPackedLinkMeasurementReportSize( pMac, &frm, &nPayload );
6362 if ( DOT11F_FAILED( nStatus ) )
6363 {
6364 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006365 "or a Link Report (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07006366 nStatus );
6367 // We'll fall back on the worst case scenario:
6368 nPayload = sizeof( tDot11fLinkMeasurementReport );
6369 }
6370 else if ( DOT11F_WARNED( nStatus ) )
6371 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08006372 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07006373 "the packed size for a Link Rep"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006374 "ort (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07006375 }
6376
6377 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
6378
6379 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
6380 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
6381 {
6382 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Link "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006383 "Report."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07006384 return eSIR_FAILURE;
6385 }
6386
6387 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05306388 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07006389
6390 // Copy necessary info to BD
6391 if( eSIR_SUCCESS !=
6392 (statusCode = limPopulateMacHeader( pMac,
6393 pFrame,
6394 SIR_MAC_MGMT_FRAME,
6395 SIR_MAC_MGMT_ACTION,
6396 peer, psessionEntry->selfMacAddr)))
6397 goto returnAfterError;
6398
6399 // Update A3 with the BSSID
6400 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
6401
6402 sirCopyMacAddr( pMacHdr->bssId, psessionEntry->bssId );
6403
Chet Lanctot186b5732013-03-18 10:26:30 -07006404#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07006405 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07006406#endif
6407
Jeff Johnson295189b2012-06-20 16:38:30 -07006408 // Now, we're ready to "pack" the frames
6409 nStatus = dot11fPackLinkMeasurementReport( pMac,
6410 &frm,
6411 pFrame + sizeof( tSirMacMgmtHdr ),
6412 nPayload,
6413 &nPayload );
6414
6415 if( DOT11F_FAILED( nStatus ))
6416 {
6417 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006418 FL( "Failed to pack an Link Report (0x%08x)." ),
Jeff Johnson295189b2012-06-20 16:38:30 -07006419 nStatus );
6420
6421 // FIXME - Need to convert to tSirRetStatus
6422 statusCode = eSIR_FAILURE;
6423 goto returnAfterError;
6424 }
6425 else if( DOT11F_WARNED( nStatus ))
6426 {
6427 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08006428 FL( "There were warnings while packing Link Report (0x%08x)." ),
6429 nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07006430 }
6431
6432 limLog( pMac, LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006433 FL( "Sending a Link Report to " ));
Jeff Johnson295189b2012-06-20 16:38:30 -07006434 limPrintMacAddr( pMac, peer, LOGW );
6435
6436 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07006437 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
6438 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07006439 )
6440 {
6441 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
6442 }
6443
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05306444 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
6445 psessionEntry->peSessionId,
6446 pMacHdr->fc.subType));
6447 halstatus = halTxFrame( pMac,
6448 pPacket,
6449 (tANI_U16) nBytes,
6450 HAL_TXRX_FRM_802_11_MGMT,
6451 ANI_TXDIR_TODS,
6452 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
6453 limTxComplete,
6454 pFrame, txFlag );
6455 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
6456 psessionEntry->peSessionId,
6457 halstatus));
6458 if( eHAL_STATUS_SUCCESS != halstatus )
Jeff Johnson295189b2012-06-20 16:38:30 -07006459 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006460 PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]" ), halstatus );)
Jeff Johnson295189b2012-06-20 16:38:30 -07006461 statusCode = eSIR_FAILURE;
6462 //Pkt will be freed up by the callback
6463 return statusCode;
6464 }
6465 else
6466 return eSIR_SUCCESS;
6467
6468returnAfterError:
6469 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
6470
6471 return statusCode;
6472} // End limSendLinkReportActionFrame.
6473
6474/**
6475 * \brief Send a Beacon Report Action frame
6476 *
6477 *
6478 * \param pMac Pointer to the global MAC structure
6479 *
6480 * \param dialog_token dialog token to be used in the action frame.
6481 *
6482 * \param num_report number of reports in pRRMReport.
6483 *
6484 * \param pRRMReport Address of a tSirMacRadioMeasureReport.
6485 *
6486 * \param peer mac address of peer station.
6487 *
6488 * \param psessionEntry address of session entry.
6489 *
6490 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
6491 *
6492 *
6493 */
6494
6495tSirRetStatus
6496limSendRadioMeasureReportActionFrame(tpAniSirGlobal pMac,
6497 tANI_U8 dialog_token,
6498 tANI_U8 num_report,
6499 tpSirMacRadioMeasureReport pRRMReport,
6500 tSirMacAddr peer,
6501 tpPESession psessionEntry
6502 )
6503{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05306504 tSirRetStatus statusCode = eSIR_SUCCESS;
6505 tANI_U8 *pFrame;
6506 tpSirMacMgmtHdr pMacHdr;
6507 tANI_U32 nBytes, nPayload, nStatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07006508 void *pPacket;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05306509 eHalStatus halstatus;
6510 tANI_U8 i;
6511 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07006512
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006513 tDot11fRadioMeasurementReport *frm =
6514 vos_mem_malloc(sizeof(tDot11fRadioMeasurementReport));
6515 if (!frm) {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006516 limLog( pMac, LOGE, FL("Not enough memory to allocate tDot11fRadioMeasurementReport") );
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006517 return eSIR_FAILURE;
6518 }
6519
Jeff Johnson295189b2012-06-20 16:38:30 -07006520 if ( psessionEntry == NULL )
6521 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006522 limLog( pMac, LOGE, FL("(psession == NULL) in Request to send Beacon Report action frame") );
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006523 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07006524 return eSIR_FAILURE;
6525 }
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05306526 vos_mem_set( ( tANI_U8* )frm, sizeof( *frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07006527
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006528 frm->Category.category = SIR_MAC_ACTION_RRM;
6529 frm->Action.action = SIR_MAC_RRM_RADIO_MEASURE_RPT;
6530 frm->DialogToken.token = dialog_token;
Jeff Johnson295189b2012-06-20 16:38:30 -07006531
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006532 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 -07006533
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006534 for( i = 0 ; i < frm->num_MeasurementReport ; i++ )
Jeff Johnson295189b2012-06-20 16:38:30 -07006535 {
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006536 frm->MeasurementReport[i].type = pRRMReport[i].type;
6537 frm->MeasurementReport[i].token = pRRMReport[i].token;
6538 frm->MeasurementReport[i].late = 0; //IEEE 802.11k section 7.3.22. (always zero in rrm)
Jeff Johnson295189b2012-06-20 16:38:30 -07006539 switch( pRRMReport[i].type )
6540 {
6541 case SIR_MAC_RRM_BEACON_TYPE:
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006542 PopulateDot11fBeaconReport( pMac, &frm->MeasurementReport[i], &pRRMReport[i].report.beaconReport );
6543 frm->MeasurementReport[i].incapable = pRRMReport[i].incapable;
6544 frm->MeasurementReport[i].refused = pRRMReport[i].refused;
6545 frm->MeasurementReport[i].present = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07006546 break;
6547 default:
Gopichand Nakkala72717fd2013-02-08 12:23:45 +05306548 frm->MeasurementReport[i].incapable = pRRMReport[i].incapable;
6549 frm->MeasurementReport[i].refused = pRRMReport[i].refused;
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006550 frm->MeasurementReport[i].present = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07006551 break;
6552 }
6553 }
6554
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006555 nStatus = dot11fGetPackedRadioMeasurementReportSize( pMac, frm, &nPayload );
Jeff Johnson295189b2012-06-20 16:38:30 -07006556 if ( DOT11F_FAILED( nStatus ) )
6557 {
6558 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006559 "or a Radio Measure Report (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07006560 nStatus );
6561 // We'll fall back on the worst case scenario:
6562 nPayload = sizeof( tDot11fLinkMeasurementReport );
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006563 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07006564 return eSIR_FAILURE;
6565 }
6566 else if ( DOT11F_WARNED( nStatus ) )
6567 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08006568 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07006569 "the packed size for a Radio Measure Rep"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006570 "ort (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07006571 }
6572
6573 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
6574
6575 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
6576 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
6577 {
6578 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Radio Measure "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006579 "Report."), nBytes );
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006580 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07006581 return eSIR_FAILURE;
6582 }
6583
6584 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05306585 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07006586
6587 // Copy necessary info to BD
6588 if( eSIR_SUCCESS !=
6589 (statusCode = limPopulateMacHeader( pMac,
6590 pFrame,
6591 SIR_MAC_MGMT_FRAME,
6592 SIR_MAC_MGMT_ACTION,
6593 peer, psessionEntry->selfMacAddr)))
6594 goto returnAfterError;
6595
6596 // Update A3 with the BSSID
6597 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
6598
6599 sirCopyMacAddr( pMacHdr->bssId, psessionEntry->bssId );
6600
Chet Lanctot186b5732013-03-18 10:26:30 -07006601#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07006602 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07006603#endif
6604
Jeff Johnson295189b2012-06-20 16:38:30 -07006605 // Now, we're ready to "pack" the frames
6606 nStatus = dot11fPackRadioMeasurementReport( pMac,
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006607 frm,
Jeff Johnson295189b2012-06-20 16:38:30 -07006608 pFrame + sizeof( tSirMacMgmtHdr ),
6609 nPayload,
6610 &nPayload );
6611
6612 if( DOT11F_FAILED( nStatus ))
6613 {
6614 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006615 FL( "Failed to pack an Radio Measure Report (0x%08x)." ),
Jeff Johnson295189b2012-06-20 16:38:30 -07006616 nStatus );
6617
6618 // FIXME - Need to convert to tSirRetStatus
6619 statusCode = eSIR_FAILURE;
6620 goto returnAfterError;
6621 }
6622 else if( DOT11F_WARNED( nStatus ))
6623 {
6624 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08006625 FL( "There were warnings while packing Radio "
6626 "Measure Report (0x%08x)." ), nStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07006627 }
6628
6629 limLog( pMac, LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006630 FL( "Sending a Radio Measure Report to " ));
Jeff Johnson295189b2012-06-20 16:38:30 -07006631 limPrintMacAddr( pMac, peer, LOGW );
6632
6633 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07006634 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
6635 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07006636 )
6637 {
6638 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
6639 }
6640
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05306641 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
6642 psessionEntry->peSessionId,
6643 pMacHdr->fc.subType));
6644 halstatus = halTxFrame( pMac,
6645 pPacket,
6646 (tANI_U16) nBytes,
6647 HAL_TXRX_FRM_802_11_MGMT,
6648 ANI_TXDIR_TODS,
6649 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
6650 limTxComplete,
6651 pFrame, txFlag );
6652 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
6653 psessionEntry->peSessionId,
6654 halstatus));
6655 if( eHAL_STATUS_SUCCESS != halstatus )
Jeff Johnson295189b2012-06-20 16:38:30 -07006656 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006657 PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]" ), halstatus );)
Jeff Johnson295189b2012-06-20 16:38:30 -07006658 statusCode = eSIR_FAILURE;
6659 //Pkt will be freed up by the callback
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006660 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07006661 return statusCode;
6662 }
Madan Mohan Koyyalamudieeb56b12012-10-31 15:10:04 -07006663 else {
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006664 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07006665 return eSIR_SUCCESS;
Madan Mohan Koyyalamudieeb56b12012-10-31 15:10:04 -07006666 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006667
6668returnAfterError:
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006669 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07006670 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
Jeff Johnson295189b2012-06-20 16:38:30 -07006671 return statusCode;
6672} // End limSendBeaconReportActionFrame.
6673
6674#endif
6675
6676#ifdef WLAN_FEATURE_11W
6677/**
Chet Lanctot8cecea22014-02-11 19:09:36 -08006678 * \brief Send SA query request action frame to peer
6679 *
6680 * \sa limSendSaQueryRequestFrame
6681 *
6682 *
6683 * \param pMac The global tpAniSirGlobal object
6684 *
6685 * \param transId Transaction identifier
6686 *
6687 * \param peer The Mac address of the station to which this action frame is addressed
6688 *
6689 * \param psessionEntry The PE session entry
6690 *
6691 * \return eSIR_SUCCESS if setup completes successfully
6692 * eSIR_FAILURE is some problem is encountered
6693 */
6694
6695tSirRetStatus limSendSaQueryRequestFrame( tpAniSirGlobal pMac, tANI_U8 *transId,
6696 tSirMacAddr peer, tpPESession psessionEntry )
6697{
6698
6699 tDot11fSaQueryReq frm; // SA query request action frame
6700 tANI_U8 *pFrame;
6701 tSirRetStatus nSirStatus;
6702 tpSirMacMgmtHdr pMacHdr;
6703 tANI_U32 nBytes, nPayload, nStatus;
6704 void *pPacket;
6705 eHalStatus halstatus;
6706 tANI_U8 txFlag = 0;
6707
6708 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
6709 frm.Category.category = SIR_MAC_ACTION_SA_QUERY;
6710 /* 11w action field is :
6711 action: 0 --> SA Query Request action frame
6712 action: 1 --> SA Query Response action frame */
6713 frm.Action.action = SIR_MAC_SA_QUERY_REQ;
6714 /* 11w SA Query Request transId */
6715 vos_mem_copy( &frm.TransactionId.transId[0], &transId[0], 2 );
6716
6717 nStatus = dot11fGetPackedSaQueryReqSize(pMac, &frm, &nPayload);
6718 if ( DOT11F_FAILED( nStatus ) )
6719 {
6720 limLog( pMac, LOGP, FL("Failed to calculate the packed size "
6721 "for an SA Query Request (0x%08x)."),
6722 nStatus );
6723 // We'll fall back on the worst case scenario:
6724 nPayload = sizeof( tDot11fSaQueryReq );
6725 }
6726 else if ( DOT11F_WARNED( nStatus ) )
6727 {
6728 limLog( pMac, LOGW, FL("There were warnings while calculating "
6729 "the packed size for an SA Query Request"
6730 " (0x%08x)."), nStatus );
6731 }
6732
6733 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
6734 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
6735 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
6736 {
6737 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a SA Query Request "
6738 "action frame"), nBytes );
6739 return eSIR_FAILURE;
6740 }
6741
6742 // Paranoia:
6743 vos_mem_set( pFrame, nBytes, 0 );
6744
6745 // Copy necessary info to BD
6746 nSirStatus = limPopulateMacHeader( pMac,
6747 pFrame,
6748 SIR_MAC_MGMT_FRAME,
6749 SIR_MAC_MGMT_ACTION,
6750 peer, psessionEntry->selfMacAddr );
6751 if ( eSIR_SUCCESS != nSirStatus )
6752 goto returnAfterError;
6753
6754 // Update A3 with the BSSID
6755 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
6756
6757 sirCopyMacAddr( pMacHdr->bssId, psessionEntry->bssId );
6758
6759 // Since this is a SA Query Request, set the "protect" (aka WEP) bit
6760 // in the FC
6761 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
6762
6763 // Pack 11w SA Query Request frame
6764 nStatus = dot11fPackSaQueryReq( pMac,
6765 &frm,
6766 pFrame + sizeof( tSirMacMgmtHdr ),
6767 nPayload,
6768 &nPayload );
6769
6770 if ( DOT11F_FAILED( nStatus ))
6771 {
6772 limLog( pMac, LOGE,
6773 FL( "Failed to pack an SA Query Request (0x%08x)." ),
6774 nStatus );
6775 // FIXME - Need to convert to tSirRetStatus
6776 nSirStatus = eSIR_FAILURE;
6777 goto returnAfterError;
6778 }
6779 else if ( DOT11F_WARNED( nStatus ))
6780 {
6781 limLog( pMac, LOGW,
6782 FL( "There were warnings while packing SA Query Request (0x%08x)." ),
6783 nStatus);
6784 }
6785
6786 limLog( pMac, LOG1,
6787 FL( "Sending an SA Query Request to " ));
6788 limPrintMacAddr( pMac, peer, LOG1 );
6789 limPrintMacAddr( pMac, peer, LOGE );
6790 limLog( pMac, LOGE,
6791 FL( "Sending an SA Query Request from " ));
6792 limPrintMacAddr( pMac, psessionEntry->selfMacAddr, LOGE );
6793
6794 if ( ( SIR_BAND_5_GHZ == limGetRFBand( psessionEntry->currentOperChannel ) )
6795#ifdef WLAN_FEATURE_P2P
6796 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
6797 ( psessionEntry->pePersona == VOS_P2P_GO_MODE )
6798#endif
6799 )
6800 {
6801 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
6802 }
6803
6804 halstatus = halTxFrame( pMac,
6805 pPacket,
6806 (tANI_U16) nBytes,
6807 HAL_TXRX_FRM_802_11_MGMT,
6808 ANI_TXDIR_TODS,
6809 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
6810 limTxComplete,
6811 pFrame, txFlag );
6812 if ( eHAL_STATUS_SUCCESS != halstatus )
6813 {
6814 PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]" ), halstatus );)
6815 nSirStatus = eSIR_FAILURE;
6816 //Pkt will be freed up by the callback
6817 return nSirStatus;
6818 }
6819 else {
6820 return eSIR_SUCCESS;
6821 }
6822
6823returnAfterError:
6824 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
6825 return nSirStatus;
6826} // End limSendSaQueryRequestFrame
6827
6828/**
Jeff Johnson295189b2012-06-20 16:38:30 -07006829 * \brief Send SA query response action frame to peer
6830 *
6831 * \sa limSendSaQueryResponseFrame
6832 *
6833 *
6834 * \param pMac The global tpAniSirGlobal object
6835 *
Chet Lanctot186b5732013-03-18 10:26:30 -07006836 * \param transId Transaction identifier received in SA query request action frame
Jeff Johnson295189b2012-06-20 16:38:30 -07006837 *
Chet Lanctot186b5732013-03-18 10:26:30 -07006838 * \param peer The Mac address of the AP to which this action frame is addressed
6839 *
6840 * \param psessionEntry The PE session entry
Jeff Johnson295189b2012-06-20 16:38:30 -07006841 *
6842 * \return eSIR_SUCCESS if setup completes successfully
6843 * eSIR_FAILURE is some problem is encountered
6844 */
6845
Chet Lanctot186b5732013-03-18 10:26:30 -07006846tSirRetStatus limSendSaQueryResponseFrame( tpAniSirGlobal pMac, tANI_U8 *transId,
Jeff Johnson295189b2012-06-20 16:38:30 -07006847tSirMacAddr peer,tpPESession psessionEntry)
6848{
6849
Chet Lanctot186b5732013-03-18 10:26:30 -07006850 tDot11fSaQueryRsp frm; // SA query reponse action frame
Jeff Johnson295189b2012-06-20 16:38:30 -07006851 tANI_U8 *pFrame;
6852 tSirRetStatus nSirStatus;
6853 tpSirMacMgmtHdr pMacHdr;
Chet Lanctot186b5732013-03-18 10:26:30 -07006854 tANI_U32 nBytes, nPayload, nStatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07006855 void *pPacket;
6856 eHalStatus halstatus;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05306857 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07006858
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05306859 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Chet Lanctot186b5732013-03-18 10:26:30 -07006860 frm.Category.category = SIR_MAC_ACTION_SA_QUERY;
6861 /*11w action field is :
Jeff Johnson295189b2012-06-20 16:38:30 -07006862 action: 0 --> SA query request action frame
6863 action: 1 --> SA query response action frame */
Chet Lanctot186b5732013-03-18 10:26:30 -07006864 frm.Action.action = SIR_MAC_SA_QUERY_RSP;
6865 /*11w SA query response transId is same as
Jeff Johnson295189b2012-06-20 16:38:30 -07006866 SA query request transId*/
Chet Lanctot186b5732013-03-18 10:26:30 -07006867 vos_mem_copy( &frm.TransactionId.transId[0], &transId[0], 2 );
Jeff Johnson295189b2012-06-20 16:38:30 -07006868
Chet Lanctot186b5732013-03-18 10:26:30 -07006869 nStatus = dot11fGetPackedSaQueryRspSize(pMac, &frm, &nPayload);
6870 if ( DOT11F_FAILED( nStatus ) )
6871 {
6872 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
6873 "or a SA Query Response (0x%08x)."),
6874 nStatus );
6875 // We'll fall back on the worst case scenario:
6876 nPayload = sizeof( tDot11fSaQueryRsp );
6877 }
6878 else if ( DOT11F_WARNED( nStatus ) )
6879 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08006880 limLog( pMac, LOGW, FL("There were warnings while calculating "
Chet Lanctot186b5732013-03-18 10:26:30 -07006881 "the packed size for an SA Query Response"
6882 " (0x%08x)."), nStatus );
6883 }
6884
Jeff Johnson295189b2012-06-20 16:38:30 -07006885 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
6886 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
6887 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
6888 {
6889 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a SA query response"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006890 " action frame"), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07006891 return eSIR_FAILURE;
6892 }
6893
6894 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05306895 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07006896
Chet Lanctot186b5732013-03-18 10:26:30 -07006897 // Copy necessary info to BD
Chet Lanctotb2b0d552013-03-22 16:58:44 -07006898 nSirStatus = limPopulateMacHeader( pMac,
Chet Lanctot186b5732013-03-18 10:26:30 -07006899 pFrame,
6900 SIR_MAC_MGMT_FRAME,
6901 SIR_MAC_MGMT_ACTION,
Chet Lanctotb2b0d552013-03-22 16:58:44 -07006902 peer, psessionEntry->selfMacAddr );
6903 if ( eSIR_SUCCESS != nSirStatus )
Chet Lanctot186b5732013-03-18 10:26:30 -07006904 goto returnAfterError;
Jeff Johnson295189b2012-06-20 16:38:30 -07006905
Chet Lanctot186b5732013-03-18 10:26:30 -07006906 // Update A3 with the BSSID
Jeff Johnson295189b2012-06-20 16:38:30 -07006907 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
6908
Chet Lanctot186b5732013-03-18 10:26:30 -07006909 sirCopyMacAddr( pMacHdr->bssId, psessionEntry->bssId );
Jeff Johnson295189b2012-06-20 16:38:30 -07006910
Chet Lanctot186b5732013-03-18 10:26:30 -07006911 // Since this is a SA Query Response, set the "protect" (aka WEP) bit
6912 // in the FC
Chet Lanctot8cecea22014-02-11 19:09:36 -08006913 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Jeff Johnson295189b2012-06-20 16:38:30 -07006914
Chet Lanctot186b5732013-03-18 10:26:30 -07006915 // Pack 11w SA query response frame
6916 nStatus = dot11fPackSaQueryRsp( pMac,
6917 &frm,
6918 pFrame + sizeof( tSirMacMgmtHdr ),
6919 nPayload,
6920 &nPayload );
6921
6922 if ( DOT11F_FAILED( nStatus ))
6923 {
6924 limLog( pMac, LOGE,
6925 FL( "Failed to pack an SA Query Response (0x%08x)." ),
6926 nStatus );
6927 // FIXME - Need to convert to tSirRetStatus
6928 nSirStatus = eSIR_FAILURE;
6929 goto returnAfterError;
6930 }
6931 else if ( DOT11F_WARNED( nStatus ))
6932 {
6933 limLog( pMac, LOGW,
6934 FL( "There were warnings while packing SA Query Response (0x%08x)." ),
6935 nStatus);
6936 }
6937
6938 limLog( pMac, LOG1,
6939 FL( "Sending a SA Query Response to " ));
6940 limPrintMacAddr( pMac, peer, LOGW );
6941
Chet Lanctotb2b0d552013-03-22 16:58:44 -07006942 if ( ( SIR_BAND_5_GHZ == limGetRFBand( psessionEntry->currentOperChannel ) )
Chet Lanctot186b5732013-03-18 10:26:30 -07006943#ifdef WLAN_FEATURE_P2P
Chet Lanctotb2b0d552013-03-22 16:58:44 -07006944 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
6945 ( psessionEntry->pePersona == VOS_P2P_GO_MODE )
Chet Lanctot186b5732013-03-18 10:26:30 -07006946#endif
Chet Lanctotb2b0d552013-03-22 16:58:44 -07006947 )
6948 {
6949 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
6950 }
Chet Lanctot186b5732013-03-18 10:26:30 -07006951
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05306952 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
6953 psessionEntry->peSessionId,
6954 pMacHdr->fc.subType));
Chet Lanctotb2b0d552013-03-22 16:58:44 -07006955 halstatus = halTxFrame( pMac,
6956 pPacket,
6957 (tANI_U16) nBytes,
6958 HAL_TXRX_FRM_802_11_MGMT,
6959 ANI_TXDIR_TODS,
6960 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
6961 limTxComplete,
6962 pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05306963 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
6964 psessionEntry->peSessionId,
6965 halstatus));
Chet Lanctotb2b0d552013-03-22 16:58:44 -07006966 if ( eHAL_STATUS_SUCCESS != halstatus )
Chet Lanctot186b5732013-03-18 10:26:30 -07006967 {
6968 PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]" ), halstatus );)
6969 nSirStatus = eSIR_FAILURE;
6970 //Pkt will be freed up by the callback
6971 return nSirStatus;
6972 }
6973 else {
6974 return eSIR_SUCCESS;
6975 }
6976
6977returnAfterError:
6978 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
6979 return nSirStatus;
6980} // End limSendSaQueryResponseFrame
Jeff Johnson295189b2012-06-20 16:38:30 -07006981#endif