blob: 93408fc9f590a611dabead3053c557db524c09a5 [file] [log] [blame]
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001/*
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002 * Copyright (c) 2011-2016 The Linux Foundation. All rights reserved.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -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/*
23 * This file was originally distributed by Qualcomm Atheros, Inc.
24 * under proprietary terms before Copyright ownership was assigned
25 * to the Linux Foundation.
26 */
27
28/**
29 * \file lim_send_management_frames.c
30 *
31 * \brief Code for preparing and sending 802.11 Management frames
32 *
33 *
34 */
35
36#include "sir_api.h"
37#include "ani_global.h"
38#include "sir_mac_prot_def.h"
39#include "cfg_api.h"
40#include "utils_api.h"
41#include "lim_types.h"
42#include "lim_utils.h"
43#include "lim_security_utils.h"
44#include "lim_prop_exts_utils.h"
45#include "dot11f.h"
46#include "lim_sta_hash_api.h"
47#include "sch_api.h"
48#include "lim_send_messages.h"
49#include "lim_assoc_utils.h"
50#include "lim_ft.h"
51#ifdef WLAN_FEATURE_11W
52#include "wni_cfg.h"
53#endif
54
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080055#include "lim_ft_defs.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080056#include "lim_session.h"
Anurag Chouhan6d760662016-02-20 16:05:43 +053057#include "qdf_types.h"
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053058#include "qdf_trace.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080059#include "cds_utils.h"
60#include "sme_trace.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080061#include "rrm_api.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080062
63#include "wma_types.h"
64
65/**
66 *
67 * \brief This function is called to add the sequence number to the
68 * management frames
69 *
70 * \param pMac Pointer to Global MAC structure
71 *
72 * \param pMacHdr Pointer to MAC management header
73 *
74 * The pMacHdr argument points to the MAC management header. The
75 * sequence number stored in the pMac structure will be incremented
76 * and updated to the MAC management header. The start sequence
77 * number is WLAN_HOST_SEQ_NUM_MIN and the end value is
78 * WLAN_HOST_SEQ_NUM_MAX. After reaching the MAX value, the sequence
79 * number will roll over.
80 *
81 */
82void lim_add_mgmt_seq_num(tpAniSirGlobal pMac, tpSirMacMgmtHdr pMacHdr)
83{
84 if (pMac->mgmtSeqNum >= WLAN_HOST_SEQ_NUM_MAX) {
85 pMac->mgmtSeqNum = WLAN_HOST_SEQ_NUM_MIN - 1;
86 }
87
88 pMac->mgmtSeqNum++;
89
90 pMacHdr->seqControl.seqNumLo = (pMac->mgmtSeqNum & LOW_SEQ_NUM_MASK);
91 pMacHdr->seqControl.seqNumHi =
92 ((pMac->mgmtSeqNum & HIGH_SEQ_NUM_MASK) >> HIGH_SEQ_NUM_OFFSET);
93}
94
95/**
96 *
97 * \brief This function is called before sending a p2p action frame
98 * inorder to add sequence numbers to action packets
99 *
100 * \param pMac Pointer to Global MAC structure
101 *
102 * \param pBD Pointer to the frame buffer that needs to be populate
103 *
104 * The pMacHdr argument points to the MAC management header. The
105 * sequence number stored in the pMac structure will be incremented
106 * and updated to the MAC management header. The start sequence
107 * number is WLAN_HOST_SEQ_NUM_MIN and the end value is
108 * WLAN_HOST_SEQ_NUM_MAX. After reaching the MAX value, the sequence
109 * number will roll over.
110 *
111 */
112void lim_populate_p2p_mac_header(tpAniSirGlobal pMac, uint8_t *pBD)
113{
114 tpSirMacMgmtHdr pMacHdr;
115
116 /* / Prepare MAC management header */
117 pMacHdr = (tpSirMacMgmtHdr) (pBD);
118
119 /* Prepare sequence number */
120 lim_add_mgmt_seq_num(pMac, pMacHdr);
121 lim_log(pMac, LOG1, "seqNumLo=%d, seqNumHi=%d, mgmtSeqNum=%d",
122 pMacHdr->seqControl.seqNumLo,
123 pMacHdr->seqControl.seqNumHi, pMac->mgmtSeqNum);
124}
125
126/**
127 * lim_populate_mac_header() - Fill in 802.11 header of frame
128 *
129 * @mac_ctx: Pointer to Global MAC structure
130 * @buf: Pointer to the frame buffer that needs to be populate
131 * @type: 802.11 Type of the frame
132 * @sub_type: 802.11 Subtype of the frame
133 * @peer_addr: dst address
134 * @self_mac_addr: local mac address
135 *
136 * This function is called by various LIM modules to prepare the
137 * 802.11 frame MAC header
138 *
139 * The buf argument points to the beginning of the frame buffer to
140 * which - a) The 802.11 MAC header is set b) Following this MAC header
141 * will be the MGMT frame payload The payload itself is populated by the
142 * caller API
143 *
144 * Return: None
145 */
146
147void lim_populate_mac_header(tpAniSirGlobal mac_ctx, uint8_t *buf,
148 uint8_t type, uint8_t sub_type, tSirMacAddr peer_addr,
149 tSirMacAddr self_mac_addr)
150{
151 tpSirMacMgmtHdr mac_hdr;
152
153 /* Prepare MAC management header */
154 mac_hdr = (tpSirMacMgmtHdr) (buf);
155
156 /* Prepare FC */
157 mac_hdr->fc.protVer = SIR_MAC_PROTOCOL_VERSION;
158 mac_hdr->fc.type = type;
159 mac_hdr->fc.subType = sub_type;
160
161 /* Prepare Address 1 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530162 qdf_mem_copy((uint8_t *) mac_hdr->da,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800163 (uint8_t *) peer_addr, sizeof(tSirMacAddr));
164
165 /* Prepare Address 2 */
166 sir_copy_mac_addr(mac_hdr->sa, self_mac_addr);
167
168 /* Prepare Address 3 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530169 qdf_mem_copy((uint8_t *) mac_hdr->bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800170 (uint8_t *) peer_addr, sizeof(tSirMacAddr));
171
172 /* Prepare sequence number */
173 lim_add_mgmt_seq_num(mac_ctx, mac_hdr);
174 lim_log(mac_ctx, LOG1, "seqNumLo=%d, seqNumHi=%d, mgmtSeqNum=%d",
175 mac_hdr->seqControl.seqNumLo,
176 mac_hdr->seqControl.seqNumHi, mac_ctx->mgmtSeqNum);
177}
178
179/**
180 * lim_send_probe_req_mgmt_frame() - send probe request management frame
181 * @mac_ctx: Pointer to Global MAC structure
182 * @ssid: SSID to be sent in Probe Request frame
183 * @bssid: BSSID to be sent in Probe Request frame
184 * @channel: Channel # on which the Probe Request is going out
185 * @self_macaddr: self MAC address
186 * @dot11mode: self dotllmode
187 * @additional_ielen: if non-zero, include additional_ie in the Probe Request
188 * frame
189 * @additional_ie: if additional_ielen is non zero, include this field in the
190 * Probe Request frame
191 *
192 * This function is called by various LIM modules to send Probe Request frame
193 * during active scan/learn phase.
194 * Probe request is sent out in the following scenarios:
195 * --heartbeat failure: session needed
196 * --join req: session needed
197 * --foreground scan: no session
198 * --background scan: no session
199 * --sch_beacon_processing: to get EDCA parameters: session needed
200 *
201 * Return: tSirRetStatus (eSIR_SUCCESS on success and error codes otherwise)
202 */
203tSirRetStatus
204lim_send_probe_req_mgmt_frame(tpAniSirGlobal mac_ctx,
205 tSirMacSSid *ssid,
206 tSirMacAddr bssid,
207 uint8_t channel,
208 tSirMacAddr self_macaddr,
209 uint32_t dot11mode,
210 uint32_t additional_ielen, uint8_t *additional_ie)
211{
212 tDot11fProbeRequest pr;
213 uint32_t status, bytes, payload;
214 uint8_t *frame;
215 void *packet;
Kapil Guptac03eb072016-08-09 14:01:36 +0530216 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800217 tpPESession pesession;
218 uint8_t sessionid;
219 uint8_t *p2pie = NULL;
220 uint8_t txflag = 0;
221 uint8_t sme_sessionid = 0;
222 bool is_vht_enabled = false;
223 uint8_t txPower;
224 uint16_t addn_ielen = additional_ielen;
Kapil Guptac03eb072016-08-09 14:01:36 +0530225 bool extracted_ext_cap_flag = false;
226 tDot11fIEExtCap extracted_ext_cap;
227 tSirRetStatus sir_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800228
229 /* The probe req should not send 11ac capabilieties if band is 2.4GHz,
230 * unless enableVhtFor24GHz is enabled in INI. So if enableVhtFor24GHz
231 * is false and dot11mode is 11ac set it to 11n.
232 */
233 if (channel <= SIR_11B_CHANNEL_END &&
234 (false == mac_ctx->roam.configParam.enableVhtFor24GHz) &&
235 (WNI_CFG_DOT11_MODE_11AC == dot11mode ||
236 WNI_CFG_DOT11_MODE_11AC_ONLY == dot11mode))
237 dot11mode = WNI_CFG_DOT11_MODE_11N;
238 /*
239 * session context may or may not be present, when probe request needs
240 * to be sent out. Following cases exist:
241 * --heartbeat failure: session needed
242 * --join req: session needed
243 * --foreground scan: no session
244 * --background scan: no session
245 * --sch_beacon_processing: to get EDCA parameters: session needed
246 * If session context does not exist, some IEs will be populated from
247 * CFGs, e.g. Supported and Extended rate set IEs
248 */
249 pesession = pe_find_session_by_bssid(mac_ctx, bssid, &sessionid);
250
251 if (pesession != NULL)
252 sme_sessionid = pesession->smeSessionId;
253
254 /* The scheme here is to fill out a 'tDot11fProbeRequest' structure */
255 /* and then hand it off to 'dot11f_pack_probe_request' (for */
256 /* serialization). We start by zero-initializing the structure: */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530257 qdf_mem_set((uint8_t *) &pr, sizeof(pr), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800258
259 /* & delegating to assorted helpers: */
260 populate_dot11f_ssid(mac_ctx, ssid, &pr.SSID);
261
262 if (addn_ielen && additional_ie)
263 p2pie = limGetP2pIEPtr(mac_ctx, additional_ie, addn_ielen);
264
265 /*
266 * Don't include 11b rate if it is a P2P serach or probe request is
267 * sent by P2P Client
268 */
269 if ((WNI_CFG_DOT11_MODE_11B != dot11mode) && (p2pie != NULL) &&
270 (((mac_ctx->lim.gpLimMlmScanReq != NULL) &&
271 mac_ctx->lim.gpLimMlmScanReq->p2pSearch) ||
272 ((pesession != NULL) &&
Anurag Chouhan6d760662016-02-20 16:05:43 +0530273 (QDF_P2P_CLIENT_MODE == pesession->pePersona))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800274 )
275 ) {
276 /*
277 * In the below API pass channel number > 14, do that it fills
278 * only 11a rates in supported rates
279 */
280 populate_dot11f_supp_rates(mac_ctx, 15, &pr.SuppRates,
281 pesession);
282 } else {
283 populate_dot11f_supp_rates(mac_ctx, channel,
284 &pr.SuppRates, pesession);
285
286 if (WNI_CFG_DOT11_MODE_11B != dot11mode) {
287 populate_dot11f_ext_supp_rates1(mac_ctx, channel,
288 &pr.ExtSuppRates);
289 }
290 }
291
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800292 /*
293 * Table 7-14 in IEEE Std. 802.11k-2008 says
294 * DS params "can" be present in RRM is disabled and "is" present if
295 * RRM is enabled. It should be ok even if we add it into probe req when
296 * RRM is not enabled.
297 */
298 populate_dot11f_ds_params(mac_ctx, &pr.DSParams, channel);
299 /* Call RRM module to get the tx power for management used. */
300 txPower = (uint8_t) rrm_get_mgmt_tx_power(mac_ctx, pesession);
301 populate_dot11f_wfatpc(mac_ctx, &pr.WFATPC, txPower, 0);
302
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800303
304 if (pesession != NULL) {
305 pesession->htCapability = IS_DOT11_MODE_HT(dot11mode);
306 /* Include HT Capability IE */
307 if (pesession->htCapability)
308 populate_dot11f_ht_caps(mac_ctx, pesession, &pr.HTCaps);
309 } else { /* pesession == NULL */
310 if (IS_DOT11_MODE_HT(dot11mode))
311 populate_dot11f_ht_caps(mac_ctx, NULL, &pr.HTCaps);
312 }
313
314 /*
315 * Set channelbonding information as "disabled" when tunned to a
316 * 2.4 GHz channel
317 */
318 if (channel <= SIR_11B_CHANNEL_END) {
319 if (mac_ctx->roam.configParam.channelBondingMode24GHz
320 == PHY_SINGLE_CHANNEL_CENTERED) {
321 pr.HTCaps.supportedChannelWidthSet =
322 eHT_CHANNEL_WIDTH_20MHZ;
323 pr.HTCaps.shortGI40MHz = 0;
324 } else {
325 pr.HTCaps.supportedChannelWidthSet =
326 eHT_CHANNEL_WIDTH_40MHZ;
327 }
328 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800329 if (pesession != NULL) {
330 pesession->vhtCapability = IS_DOT11_MODE_VHT(dot11mode);
331 /* Include VHT Capability IE */
332 if (pesession->vhtCapability) {
333 populate_dot11f_vht_caps(mac_ctx, pesession,
334 &pr.VHTCaps);
335 is_vht_enabled = true;
336 }
337 } else {
338 if (IS_DOT11_MODE_VHT(dot11mode)) {
339 populate_dot11f_vht_caps(mac_ctx, pesession,
340 &pr.VHTCaps);
341 is_vht_enabled = true;
342 }
343 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800344 if (pesession != NULL)
345 populate_dot11f_ext_cap(mac_ctx, is_vht_enabled, &pr.ExtCap,
346 pesession);
347
348 /* That's it-- now we pack it. First, how much space are we going to */
349 status = dot11f_get_packed_probe_request_size(mac_ctx, &pr, &payload);
350 if (DOT11F_FAILED(status)) {
351 lim_log(mac_ctx, LOGP, FL("Failed to calculate the packed size for a Probe Request (0x%08x)."), status);
352 /* We'll fall back on the worst case scenario: */
353 payload = sizeof(tDot11fProbeRequest);
354 } else if (DOT11F_WARNED(status)) {
355 lim_log(mac_ctx, LOGW,
356 FL("There were warnings while calculating the packed size for a Probe Request (0x%08x)."), status);
357 }
358
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800359 if (addn_ielen) {
Kapil Guptac03eb072016-08-09 14:01:36 +0530360 qdf_mem_zero((uint8_t *)&extracted_ext_cap,
361 sizeof(tDot11fIEExtCap));
362 sir_status = lim_strip_extcap_update_struct(mac_ctx,
363 additional_ie,
364 &addn_ielen,
365 &extracted_ext_cap);
366 if (eSIR_SUCCESS != sir_status) {
367 lim_log(mac_ctx, LOG1,
368 FL("Unable to Stripoff ExtCap IE from Probe Req"));
369 } else {
370 struct s_ext_cap *p_ext_cap =
371 (struct s_ext_cap *)
372 extracted_ext_cap.bytes;
373 if (p_ext_cap->interworking_service)
374 p_ext_cap->qos_map = 1;
375 extracted_ext_cap_flag =
376 lim_is_ext_cap_ie_present(p_ext_cap);
377 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800378 }
379
380 bytes = payload + sizeof(tSirMacMgmtHdr) + addn_ielen;
381
382 /* Ok-- try to allocate some memory: */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530383 qdf_status = cds_packet_alloc((uint16_t) bytes, (void **)&frame,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800384 (void **)&packet);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530385 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800386 lim_log(mac_ctx, LOGP, FL("Failed to allocate %d bytes for a Probe Request."), bytes);
387 return eSIR_MEM_ALLOC_FAILED;
388 }
389 /* Paranoia: */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530390 qdf_mem_set(frame, bytes, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800391
392 /* Next, we fill out the buffer descriptor: */
393 lim_populate_mac_header(mac_ctx, frame, SIR_MAC_MGMT_FRAME,
394 SIR_MAC_MGMT_PROBE_REQ, bssid, self_macaddr);
395
Kapil Guptac03eb072016-08-09 14:01:36 +0530396 /* merge the ExtCap struct*/
397 if (extracted_ext_cap_flag)
398 lim_merge_extcap_struct(&pr.ExtCap, &extracted_ext_cap);
399
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800400 /* That done, pack the Probe Request: */
401 status = dot11f_pack_probe_request(mac_ctx, &pr, frame +
402 sizeof(tSirMacMgmtHdr),
403 payload, &payload);
404 if (DOT11F_FAILED(status)) {
405 lim_log(mac_ctx, LOGE,
406 FL("Failed to pack a Probe Request (0x%08x)."), status);
407 cds_packet_free((void *)packet);
408 return eSIR_FAILURE; /* allocated! */
409 } else if (DOT11F_WARNED(status)) {
410 lim_log(mac_ctx, LOGW, FL("There were warnings while packing a Probe Request (0x%08x)."), status);
411 }
412 /* Append any AddIE if present. */
413 if (addn_ielen) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530414 qdf_mem_copy(frame + sizeof(tSirMacMgmtHdr) + payload,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800415 additional_ie, addn_ielen);
416 payload += addn_ielen;
417 }
418
419 /* If this probe request is sent during P2P Search State, then we need
420 * to send it at OFDM rate.
421 */
422 if ((SIR_BAND_5_GHZ == lim_get_rf_band(channel))
423 || ((mac_ctx->lim.gpLimMlmScanReq != NULL) &&
424 mac_ctx->lim.gpLimMlmScanReq->p2pSearch)
425 /*
426 * For unicast probe req mgmt from Join function we don't set
427 * above variables. So we need to add one more check whether it
428 * is pePersona is P2P_CLIENT or not
429 */
430 || ((pesession != NULL) &&
Anurag Chouhan6d760662016-02-20 16:05:43 +0530431 (QDF_P2P_CLIENT_MODE == pesession->pePersona))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800432 ) {
433 txflag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
434 }
435
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530436 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800437 wma_tx_frame(mac_ctx, packet,
438 (uint16_t) sizeof(tSirMacMgmtHdr) + payload,
439 TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS, 7,
440 lim_tx_complete, frame, txflag, sme_sessionid,
441 0);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530442 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800443 lim_log(mac_ctx, LOGE,
444 FL("could not send Probe Request frame!"));
445 /* Pkt will be freed up by the callback */
446 return eSIR_FAILURE;
447 }
448
449 return eSIR_SUCCESS;
450} /* End lim_send_probe_req_mgmt_frame. */
451
452tSirRetStatus lim_get_addn_ie_for_probe_resp(tpAniSirGlobal pMac,
453 uint8_t *addIE, uint16_t *addnIELen,
454 uint8_t probeReqP2pIe)
455{
456 /* If Probe request doesn't have P2P IE, then take out P2P IE
457 from additional IE */
458 if (!probeReqP2pIe) {
459 uint8_t *tempbuf = NULL;
460 uint16_t tempLen = 0;
461 int left = *addnIELen;
462 uint8_t *ptr = addIE;
463 uint8_t elem_id, elem_len;
464
465 if (NULL == addIE) {
466 PELOGE(lim_log(pMac, LOGE, FL(" NULL addIE pointer"));)
467 return eSIR_FAILURE;
468 }
469
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530470 tempbuf = qdf_mem_malloc(left);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800471 if (NULL == tempbuf) {
472 PELOGE(lim_log(pMac, LOGE,
473 FL
474 ("Unable to allocate memory to store addn IE"));
475 )
476 return eSIR_MEM_ALLOC_FAILED;
477 }
478
479 while (left >= 2) {
480 elem_id = ptr[0];
481 elem_len = ptr[1];
482 left -= 2;
483 if (elem_len > left) {
484 lim_log(pMac, LOGE,
485 FL
486 ("****Invalid IEs eid = %d elem_len=%d left=%d*****"),
487 elem_id, elem_len, left);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530488 qdf_mem_free(tempbuf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800489 return eSIR_FAILURE;
490 }
491 if (!((SIR_MAC_EID_VENDOR == elem_id) &&
492 (memcmp
493 (&ptr[2], SIR_MAC_P2P_OUI,
494 SIR_MAC_P2P_OUI_SIZE) == 0))) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530495 qdf_mem_copy(tempbuf + tempLen, &ptr[0],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800496 elem_len + 2);
497 tempLen += (elem_len + 2);
498 }
499 left -= elem_len;
500 ptr += (elem_len + 2);
501 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530502 qdf_mem_copy(addIE, tempbuf, tempLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800503 *addnIELen = tempLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530504 qdf_mem_free(tempbuf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800505 }
506 return eSIR_SUCCESS;
507}
508
509/**
510 * lim_send_probe_rsp_mgmt_frame() - Send probe response
511 *
512 * @mac_ctx: Handle for mac context
513 * @peer_macaddr: Mac address of requesting peer
514 * @ssid: SSID for response
515 * @n_staid: Station ID, currently unused.
516 * @pe_session: PE session id
517 * @keepalive: Keep alive flag. Currently unused.
518 * @preq_p2pie: P2P IE in incoming probe request
519 *
520 * Builds and sends probe response frame to the requesting peer
521 *
522 * Return: void
523 */
524
525void
526lim_send_probe_rsp_mgmt_frame(tpAniSirGlobal mac_ctx,
527 tSirMacAddr peer_macaddr,
528 tpAniSSID ssid,
529 short n_staid,
530 uint8_t keepalive,
531 tpPESession pe_session, uint8_t preq_p2pie)
532{
533 tDot11fProbeResponse *frm;
534 tSirRetStatus sir_status;
535 uint32_t cfg, payload, bytes, status;
536 tpSirMacMgmtHdr mac_hdr;
537 uint8_t *frame;
Arif Hussainfbf50682016-06-15 12:57:43 -0700538 void *packet = NULL;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530539 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800540 uint32_t addn_ie_present = false;
541
542 uint16_t addn_ie_len = 0;
543 uint32_t wps_ap = 0, tmp;
544 uint8_t tx_flag = 0;
545 uint8_t *add_ie = NULL;
546 uint8_t *p2p_ie = NULL;
547 uint8_t noalen = 0;
548 uint8_t total_noalen = 0;
549 uint8_t noa_stream[SIR_MAX_NOA_ATTR_LEN + SIR_P2P_IE_HEADER_LEN];
550 uint8_t noa_ie[SIR_MAX_NOA_ATTR_LEN + SIR_P2P_IE_HEADER_LEN];
551 uint8_t sme_sessionid = 0;
552 bool is_vht_enabled = false;
553 tDot11fIEExtCap extracted_ext_cap;
Selvaraj, Sridhar94ece202016-06-23 20:44:09 +0530554 bool extracted_ext_cap_flag = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800555
556 /* We don't answer requests in this case*/
557 if (ANI_DRIVER_TYPE(mac_ctx) == eDRIVER_TYPE_MFG)
558 return;
559
560 if (NULL == pe_session)
561 return;
562
563 /*
564 * In case when cac timer is running for this SAP session then
565 * avoid sending probe rsp out. It is violation of dfs specification.
566 */
Anurag Chouhan6d760662016-02-20 16:05:43 +0530567 if (((pe_session->pePersona == QDF_SAP_MODE) ||
568 (pe_session->pePersona == QDF_P2P_GO_MODE)) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800569 (true == mac_ctx->sap.SapDfsInfo.is_dfs_cac_timer_running)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530570 QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_INFO,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800571 FL("CAC timer is running, probe response dropped"));
572 return;
573 }
574 sme_sessionid = pe_session->smeSessionId;
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530575 frm = qdf_mem_malloc(sizeof(tDot11fProbeResponse));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800576 if (NULL == frm) {
577 lim_log(mac_ctx, LOGE,
578 FL("Unable to allocate memory"));
579 return;
580 }
581
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530582 qdf_mem_zero(&extracted_ext_cap, sizeof(extracted_ext_cap));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800583
584 /*
585 * Fill out 'frm', after which we'll just hand the struct off to
586 * 'dot11f_pack_probe_response'.
587 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530588 qdf_mem_set((uint8_t *) frm, sizeof(tDot11fProbeResponse), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800589
590 /*
591 * Timestamp to be updated by TFP, below.
592 *
593 * Beacon Interval:
594 */
595 if (LIM_IS_AP_ROLE(pe_session)) {
596 frm->BeaconInterval.interval =
597 mac_ctx->sch.schObject.gSchBeaconInterval;
598 } else {
599 sir_status = wlan_cfg_get_int(mac_ctx,
600 WNI_CFG_BEACON_INTERVAL, &cfg);
601 if (eSIR_SUCCESS != sir_status) {
602 lim_log(mac_ctx, LOGP,
603 FL("Failed to get WNI_CFG_BEACON_INTERVAL (%d)."),
604 sir_status);
605 goto err_ret;
606 }
607 frm->BeaconInterval.interval = (uint16_t) cfg;
608 }
609
610 populate_dot11f_capabilities(mac_ctx, &frm->Capabilities, pe_session);
611 populate_dot11f_ssid(mac_ctx, (tSirMacSSid *) ssid, &frm->SSID);
612 populate_dot11f_supp_rates(mac_ctx, POPULATE_DOT11F_RATES_OPERATIONAL,
613 &frm->SuppRates, pe_session);
614
615 populate_dot11f_ds_params(mac_ctx, &frm->DSParams,
616 pe_session->currentOperChannel);
617 populate_dot11f_ibss_params(mac_ctx, &frm->IBSSParams, pe_session);
618
619 if (LIM_IS_AP_ROLE(pe_session)) {
620 if (pe_session->wps_state != SAP_WPS_DISABLED)
621 populate_dot11f_probe_res_wpsi_es(mac_ctx,
622 &frm->WscProbeRes,
623 pe_session);
624 } else {
625 if (wlan_cfg_get_int(mac_ctx, (uint16_t) WNI_CFG_WPS_ENABLE,
626 &tmp) != eSIR_SUCCESS)
627 lim_log(mac_ctx, LOGP, "Failed to cfg get id %d",
628 WNI_CFG_WPS_ENABLE);
629
630 wps_ap = tmp & WNI_CFG_WPS_ENABLE_AP;
631
632 if (wps_ap)
633 populate_dot11f_wsc_in_probe_res(mac_ctx,
634 &frm->WscProbeRes);
635
636 if (mac_ctx->lim.wscIeInfo.probeRespWscEnrollmentState ==
637 eLIM_WSC_ENROLL_BEGIN) {
638 populate_dot11f_wsc_registrar_info_in_probe_res(mac_ctx,
639 &frm->WscProbeRes);
640 mac_ctx->lim.wscIeInfo.probeRespWscEnrollmentState =
641 eLIM_WSC_ENROLL_IN_PROGRESS;
642 }
643
644 if (mac_ctx->lim.wscIeInfo.wscEnrollmentState ==
645 eLIM_WSC_ENROLL_END) {
646 de_populate_dot11f_wsc_registrar_info_in_probe_res(
647 mac_ctx, &frm->WscProbeRes);
648 mac_ctx->lim.wscIeInfo.probeRespWscEnrollmentState =
649 eLIM_WSC_ENROLL_NOOP;
650 }
651 }
652
653 populate_dot11f_country(mac_ctx, &frm->Country, pe_session);
654 populate_dot11f_edca_param_set(mac_ctx, &frm->EDCAParamSet, pe_session);
655
656 if (pe_session->dot11mode != WNI_CFG_DOT11_MODE_11B)
657 populate_dot11f_erp_info(mac_ctx, &frm->ERPInfo, pe_session);
658
659 populate_dot11f_ext_supp_rates(mac_ctx,
660 POPULATE_DOT11F_RATES_OPERATIONAL,
661 &frm->ExtSuppRates, pe_session);
662
663 /* Populate HT IEs, when operating in 11n */
664 if (pe_session->htCapability) {
665 populate_dot11f_ht_caps(mac_ctx, pe_session, &frm->HTCaps);
666 populate_dot11f_ht_info(mac_ctx, &frm->HTInfo, pe_session);
667 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800668 if (pe_session->vhtCapability) {
669 lim_log(mac_ctx, LOG1, FL("Populate VHT IE in Probe Response"));
670 populate_dot11f_vht_caps(mac_ctx, pe_session, &frm->VHTCaps);
671 populate_dot11f_vht_operation(mac_ctx, pe_session,
672 &frm->VHTOperation);
673 /*
674 * we do not support multi users yet.
675 * populate_dot11f_vht_ext_bss_load( mac_ctx,
676 * &frm.VHTExtBssLoad );
677 */
678 is_vht_enabled = true;
679 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800680
681 populate_dot11f_ext_cap(mac_ctx, is_vht_enabled, &frm->ExtCap,
682 pe_session);
683
684 if (pe_session->pLimStartBssReq) {
685 populate_dot11f_wpa(mac_ctx,
686 &(pe_session->pLimStartBssReq->rsnIE),
687 &frm->WPA);
688 populate_dot11f_rsn_opaque(mac_ctx,
689 &(pe_session->pLimStartBssReq->rsnIE),
690 &frm->RSNOpaque);
691 }
692
693 populate_dot11f_wmm(mac_ctx, &frm->WMMInfoAp, &frm->WMMParams,
694 &frm->WMMCaps, pe_session);
695
696#if defined(FEATURE_WLAN_WAPI)
697 if (pe_session->pLimStartBssReq)
698 populate_dot11f_wapi(mac_ctx,
699 &(pe_session->pLimStartBssReq->rsnIE),
700 &frm->WAPI);
701#endif /* defined(FEATURE_WLAN_WAPI) */
702
703 status = dot11f_get_packed_probe_response_size(mac_ctx, frm, &payload);
704 if (DOT11F_FAILED(status)) {
705 lim_log(mac_ctx, LOGP,
706 FL("Probe Response size error (0x%08x)."),
707 status);
708 /* We'll fall back on the worst case scenario: */
709 payload = sizeof(tDot11fProbeResponse);
710 } else if (DOT11F_WARNED(status)) {
711 lim_log(mac_ctx, LOGW,
712 FL("Probe Response size warning (0x%08x)."),
713 status);
714 }
715
716 bytes = payload + sizeof(tSirMacMgmtHdr);
717
718 if (mac_ctx->lim.gpLimRemainOnChanReq)
719 bytes += (mac_ctx->lim.gpLimRemainOnChanReq->length -
720 sizeof(tSirRemainOnChnReq));
721 else
722 /*
723 * Only use CFG for non-listen mode. This CFG is not working for
724 * concurrency. In listening mode, probe rsp IEs is passed in
725 * the message from SME to PE.
726 */
727 addn_ie_present =
728 (pe_session->addIeParams.probeRespDataLen != 0);
729
730 if (addn_ie_present) {
731
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530732 add_ie = qdf_mem_malloc(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800733 pe_session->addIeParams.probeRespDataLen);
734 if (NULL == add_ie) {
735 lim_log(mac_ctx, LOGE,
736 FL("add_ie allocation failed"));
737 goto err_ret;
738 }
739
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530740 qdf_mem_copy(add_ie,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800741 pe_session->addIeParams.probeRespData_buff,
742 pe_session->addIeParams.probeRespDataLen);
743 addn_ie_len = pe_session->addIeParams.probeRespDataLen;
744
745 if (eSIR_SUCCESS != lim_get_addn_ie_for_probe_resp(mac_ctx,
746 add_ie, &addn_ie_len, preq_p2pie)) {
747 lim_log(mac_ctx, LOGP,
748 FL("Unable to get addn_ie"));
749 goto err_ret;
750 }
751
752 sir_status = lim_strip_extcap_update_struct(mac_ctx,
753 add_ie, &addn_ie_len,
754 &extracted_ext_cap);
755 if (eSIR_SUCCESS != sir_status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800756 lim_log(mac_ctx, LOG1,
757 FL("Unable to strip off ExtCap IE"));
Selvaraj, Sridhar94ece202016-06-23 20:44:09 +0530758 } else {
759 extracted_ext_cap_flag = true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800760 }
761
762 bytes = bytes + addn_ie_len;
763
764 if (preq_p2pie)
765 p2p_ie = limGetP2pIEPtr(mac_ctx, &add_ie[0],
766 addn_ie_len);
767
768 if (p2p_ie != NULL) {
769 /* get NoA attribute stream P2P IE */
770 noalen = lim_get_noa_attr_stream(mac_ctx,
771 noa_stream, pe_session);
772 if (noalen != 0) {
773 total_noalen =
774 lim_build_p2p_ie(mac_ctx, &noa_ie[0],
775 &noa_stream[0], noalen);
776 bytes = bytes + total_noalen;
777 }
778 }
779 }
780
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530781 qdf_status = cds_packet_alloc((uint16_t) bytes, (void **)&frame,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800782 (void **)&packet);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530783 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800784 lim_log(mac_ctx, LOGP, FL("Probe Response allocation failed"));
785 goto err_ret;
786 }
787 /* Paranoia: */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530788 qdf_mem_set(frame, bytes, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800789
790 /* Next, we fill out the buffer descriptor: */
791 lim_populate_mac_header(mac_ctx, frame, SIR_MAC_MGMT_FRAME,
792 SIR_MAC_MGMT_PROBE_RSP, peer_macaddr,
793 pe_session->selfMacAddr);
794
795 mac_hdr = (tpSirMacMgmtHdr) frame;
796
797 sir_copy_mac_addr(mac_hdr->bssId, pe_session->bssId);
798
799 /* merge ExtCap IE */
800 if (extracted_ext_cap_flag)
801 lim_merge_extcap_struct(&frm->ExtCap, &extracted_ext_cap);
802
803 /* That done, pack the Probe Response: */
804 status =
805 dot11f_pack_probe_response(mac_ctx, frm,
806 frame + sizeof(tSirMacMgmtHdr),
807 payload, &payload);
808 if (DOT11F_FAILED(status)) {
809 lim_log(mac_ctx, LOGE,
810 FL("Probe Response pack failure (0x%08x)."),
811 status);
812 goto err_ret;
813 } else if (DOT11F_WARNED(status)) {
814 lim_log(mac_ctx, LOGW,
815 FL("Probe Response pack warning (0x%08x)."),
816 status);
817 }
818
819 lim_log(mac_ctx, LOG3, FL("Sending Probe Response frame to "));
820 lim_print_mac_addr(mac_ctx, peer_macaddr, LOG3);
821
822 mac_ctx->sys.probeRespond++;
823
824 if (mac_ctx->lim.gpLimRemainOnChanReq)
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530825 qdf_mem_copy(frame + sizeof(tSirMacMgmtHdr) + payload,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800826 mac_ctx->lim.gpLimRemainOnChanReq->probeRspIe,
827 (mac_ctx->lim.gpLimRemainOnChanReq->length -
828 sizeof(tSirRemainOnChnReq)));
829
830 if (addn_ie_present)
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530831 qdf_mem_copy(frame + sizeof(tSirMacMgmtHdr) + payload,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800832 &add_ie[0], addn_ie_len);
833
834 if (noalen != 0) {
835 if (total_noalen >
836 (SIR_MAX_NOA_ATTR_LEN + SIR_P2P_IE_HEADER_LEN)) {
837 lim_log(mac_ctx, LOGE,
838 FL("Not able to insert NoA, total len=%d"),
839 total_noalen);
840 goto err_ret;
841 } else {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530842 qdf_mem_copy(&frame[bytes - (total_noalen)],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800843 &noa_ie[0], total_noalen);
844 }
845 }
846
847 if ((SIR_BAND_5_GHZ == lim_get_rf_band(pe_session->currentOperChannel))
Anurag Chouhan6d760662016-02-20 16:05:43 +0530848 || (pe_session->pePersona == QDF_P2P_CLIENT_MODE) ||
849 (pe_session->pePersona == QDF_P2P_GO_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800850 )
851 tx_flag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
852
853 /* Queue Probe Response frame in high priority WQ */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530854 qdf_status = wma_tx_frame((tHalHandle) mac_ctx, packet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800855 (uint16_t) bytes,
856 TXRX_FRM_802_11_MGMT,
857 ANI_TXDIR_TODS,
858 7, lim_tx_complete, frame, tx_flag,
859 sme_sessionid, 0);
860
861 /* Pkt will be freed up by the callback */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530862 if (!QDF_IS_STATUS_SUCCESS(qdf_status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800863 lim_log(mac_ctx, LOGE, FL("Could not send Probe Response."));
864
865 if (add_ie != NULL)
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530866 qdf_mem_free(add_ie);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800867
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530868 qdf_mem_free(frm);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800869 return;
870
871err_ret:
872 if (add_ie != NULL)
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530873 qdf_mem_free(add_ie);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800874 if (frm != NULL)
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530875 qdf_mem_free(frm);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800876 if (packet != NULL)
877 cds_packet_free((void *)packet);
878 return;
879
880} /* End lim_send_probe_rsp_mgmt_frame. */
881
882void
883lim_send_addts_req_action_frame(tpAniSirGlobal pMac,
884 tSirMacAddr peerMacAddr,
885 tSirAddtsReqInfo *pAddTS, tpPESession psessionEntry)
886{
887 uint16_t i;
888 uint8_t *pFrame;
889 tDot11fAddTSRequest AddTSReq;
890 tDot11fWMMAddTSRequest WMMAddTSReq;
891 uint32_t nPayload, nBytes, nStatus;
892 tpSirMacMgmtHdr pMacHdr;
893 void *pPacket;
894#ifdef FEATURE_WLAN_ESE
895 uint32_t phyMode;
896#endif
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530897 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800898 uint8_t txFlag = 0;
899 uint8_t smeSessionId = 0;
900
901 if (NULL == psessionEntry) {
902 return;
903 }
904
905 smeSessionId = psessionEntry->smeSessionId;
906
907 if (!pAddTS->wmeTspecPresent) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530908 qdf_mem_set((uint8_t *) &AddTSReq, sizeof(AddTSReq), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800909
910 AddTSReq.Action.action = SIR_MAC_QOS_ADD_TS_REQ;
911 AddTSReq.DialogToken.token = pAddTS->dialogToken;
912 AddTSReq.Category.category = SIR_MAC_ACTION_QOS_MGMT;
913 if (pAddTS->lleTspecPresent) {
914 populate_dot11f_tspec(&pAddTS->tspec, &AddTSReq.TSPEC);
915 } else {
916 populate_dot11f_wmmtspec(&pAddTS->tspec,
917 &AddTSReq.WMMTSPEC);
918 }
919
920 if (pAddTS->lleTspecPresent) {
921 AddTSReq.num_WMMTCLAS = 0;
922 AddTSReq.num_TCLAS = pAddTS->numTclas;
923 for (i = 0; i < pAddTS->numTclas; ++i) {
924 populate_dot11f_tclas(pMac, &pAddTS->tclasInfo[i],
925 &AddTSReq.TCLAS[i]);
926 }
927 } else {
928 AddTSReq.num_TCLAS = 0;
929 AddTSReq.num_WMMTCLAS = pAddTS->numTclas;
930 for (i = 0; i < pAddTS->numTclas; ++i) {
931 populate_dot11f_wmmtclas(pMac,
932 &pAddTS->tclasInfo[i],
933 &AddTSReq.WMMTCLAS[i]);
934 }
935 }
936
937 if (pAddTS->tclasProcPresent) {
938 if (pAddTS->lleTspecPresent) {
939 AddTSReq.TCLASSPROC.processing =
940 pAddTS->tclasProc;
941 AddTSReq.TCLASSPROC.present = 1;
942 } else {
943 AddTSReq.WMMTCLASPROC.version = 1;
944 AddTSReq.WMMTCLASPROC.processing =
945 pAddTS->tclasProc;
946 AddTSReq.WMMTCLASPROC.present = 1;
947 }
948 }
949
950 nStatus =
951 dot11f_get_packed_add_ts_request_size(pMac, &AddTSReq, &nPayload);
952 if (DOT11F_FAILED(nStatus)) {
953 lim_log(pMac, LOGP,
954 FL("Failed to calculate the packed size f"
955 "or an Add TS Request (0x%08x)."), nStatus);
956 /* We'll fall back on the worst case scenario: */
957 nPayload = sizeof(tDot11fAddTSRequest);
958 } else if (DOT11F_WARNED(nStatus)) {
959 lim_log(pMac, LOGW,
960 FL("There were warnings while calculating"
961 "the packed size for an Add TS Request"
962 " (0x%08x)."), nStatus);
963 }
964 } else {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530965 qdf_mem_set((uint8_t *) &WMMAddTSReq, sizeof(WMMAddTSReq), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800966
967 WMMAddTSReq.Action.action = SIR_MAC_QOS_ADD_TS_REQ;
968 WMMAddTSReq.DialogToken.token = pAddTS->dialogToken;
969 WMMAddTSReq.Category.category = SIR_MAC_ACTION_WME;
970
971 /* WMM spec 2.2.10 - status code is only filled in for ADDTS response */
972 WMMAddTSReq.StatusCode.statusCode = 0;
973
974 populate_dot11f_wmmtspec(&pAddTS->tspec, &WMMAddTSReq.WMMTSPEC);
975#ifdef FEATURE_WLAN_ESE
976 lim_get_phy_mode(pMac, &phyMode, psessionEntry);
977
978 if (phyMode == WNI_CFG_PHY_MODE_11G
979 || phyMode == WNI_CFG_PHY_MODE_11A) {
980 pAddTS->tsrsIE.rates[0] = TSRS_11AG_RATE_6MBPS;
981 } else {
982 pAddTS->tsrsIE.rates[0] = TSRS_11B_RATE_5_5MBPS;
983 }
984 populate_dot11_tsrsie(pMac, &pAddTS->tsrsIE,
985 &WMMAddTSReq.ESETrafStrmRateSet,
986 sizeof(uint8_t));
987#endif
988 /* fillWmeTspecIE */
989
990 nStatus =
991 dot11f_get_packed_wmm_add_ts_request_size(pMac, &WMMAddTSReq,
992 &nPayload);
993 if (DOT11F_FAILED(nStatus)) {
994 lim_log(pMac, LOGP,
995 FL("Failed to calculate the packed size f"
996 "or a WMM Add TS Request (0x%08x)."),
997 nStatus);
998 /* We'll fall back on the worst case scenario: */
999 nPayload = sizeof(tDot11fAddTSRequest);
1000 } else if (DOT11F_WARNED(nStatus)) {
1001 lim_log(pMac, LOGW,
1002 FL("There were warnings while calculating"
1003 "the packed size for a WMM Add TS Requ"
1004 "est (0x%08x)."), nStatus);
1005 }
1006 }
1007
1008 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
1009
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301010 qdf_status = cds_packet_alloc((uint16_t) nBytes, (void **)&pFrame,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001011 (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301012 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001013 lim_log(pMac, LOGP, FL("Failed to allocate %d bytes for an Ad"
1014 "d TS Request."), nBytes);
1015 return;
1016 }
1017 /* Paranoia: */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301018 qdf_mem_set(pFrame, nBytes, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001019
1020 /* Next, we fill out the buffer descriptor: */
1021 lim_populate_mac_header(pMac, pFrame, SIR_MAC_MGMT_FRAME,
1022 SIR_MAC_MGMT_ACTION, peerMacAddr, psessionEntry->selfMacAddr);
1023 pMacHdr = (tpSirMacMgmtHdr) pFrame;
1024
1025 sir_copy_mac_addr(pMacHdr->bssId, psessionEntry->bssId);
1026
1027#ifdef WLAN_FEATURE_11W
1028 lim_set_protected_bit(pMac, psessionEntry, peerMacAddr, pMacHdr);
1029#endif
1030
1031 /* That done, pack the struct: */
1032 if (!pAddTS->wmeTspecPresent) {
1033 nStatus = dot11f_pack_add_ts_request(pMac, &AddTSReq,
1034 pFrame +
1035 sizeof(tSirMacMgmtHdr),
1036 nPayload, &nPayload);
1037 if (DOT11F_FAILED(nStatus)) {
1038 lim_log(pMac, LOGE,
1039 FL("Failed to pack an Add TS Request "
1040 "(0x%08x)."), nStatus);
1041 cds_packet_free((void *)pPacket);
1042 return; /* allocated! */
1043 } else if (DOT11F_WARNED(nStatus)) {
1044 lim_log(pMac, LOGW,
1045 FL("There were warnings while packing "
1046 "an Add TS Request (0x%08x)."), nStatus);
1047 }
1048 } else {
1049 nStatus = dot11f_pack_wmm_add_ts_request(pMac, &WMMAddTSReq,
1050 pFrame +
1051 sizeof(tSirMacMgmtHdr),
1052 nPayload, &nPayload);
1053 if (DOT11F_FAILED(nStatus)) {
1054 lim_log(pMac, LOGE,
1055 FL("Failed to pack a WMM Add TS Reque"
1056 "st (0x%08x)."), nStatus);
1057 cds_packet_free((void *)pPacket);
1058 return; /* allocated! */
1059 } else if (DOT11F_WARNED(nStatus)) {
1060 lim_log(pMac, LOGW,
1061 FL("There were warnings while packing "
1062 "a WMM Add TS Request (0x%08x)."), nStatus);
1063 }
1064 }
1065
1066 PELOG3(lim_log(pMac, LOG3, FL("Sending an Add TS Request frame to "));
1067 lim_print_mac_addr(pMac, peerMacAddr, LOG3);
1068 )
1069
1070 if ((SIR_BAND_5_GHZ ==
1071 lim_get_rf_band(psessionEntry->currentOperChannel))
Anurag Chouhan6d760662016-02-20 16:05:43 +05301072 || (psessionEntry->pePersona == QDF_P2P_CLIENT_MODE)
1073 || (psessionEntry->pePersona == QDF_P2P_GO_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001074 ) {
1075 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
1076 }
1077
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05301078 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001079 psessionEntry->peSessionId, pMacHdr->fc.subType));
1080
1081 /* Queue Addts Response frame in high priority WQ */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301082 qdf_status = wma_tx_frame(pMac, pPacket, (uint16_t) nBytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001083 TXRX_FRM_802_11_MGMT,
1084 ANI_TXDIR_TODS,
1085 7, lim_tx_complete, pFrame, txFlag,
1086 smeSessionId, 0);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05301087 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301088 psessionEntry->peSessionId, qdf_status));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001089
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301090 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001091 lim_log(pMac, LOGE, FL("*** Could not send an Add TS Request"
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301092 " (%X) ***"), qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001093 /* Pkt will be freed up by the callback */
1094 }
1095
1096} /* End lim_send_addts_req_action_frame. */
1097
1098/**
1099 * lim_send_assoc_rsp_mgmt_frame() - Send assoc response
1100 * @mac_ctx: Handle for mac context
1101 * @status_code: Status code for assoc response frame
1102 * @aid: Association ID
1103 * @peer_addr: Mac address of requesting peer
1104 * @subtype: Assoc/Reassoc
1105 * @sta: Pointer to station node
1106 * @pe_session: PE session id.
1107 *
1108 * Builds and sends association response frame to the requesting peer.
1109 *
1110 * Return: void
1111 */
1112
1113void
1114lim_send_assoc_rsp_mgmt_frame(tpAniSirGlobal mac_ctx,
1115 uint16_t status_code, uint16_t aid, tSirMacAddr peer_addr,
1116 uint8_t subtype, tpDphHashNode sta, tpPESession pe_session)
1117{
1118 static tDot11fAssocResponse frm;
1119 uint8_t *frame;
1120 tpSirMacMgmtHdr mac_hdr;
1121 tSirRetStatus sir_status;
1122 uint8_t lle_mode = 0, addts;
1123 tHalBitVal qos_mode, wme_mode;
1124 uint32_t payload, bytes, status;
1125 void *packet;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301126 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001127 tUpdateBeaconParams beacon_params;
1128 uint8_t tx_flag = 0;
1129 uint32_t addn_ie_len = 0;
1130 uint8_t add_ie[WNI_CFG_ASSOC_RSP_ADDNIE_DATA_LEN];
1131 tpSirAssocReq assoc_req = NULL;
1132 uint8_t sme_session = 0;
1133 bool is_vht = false;
1134 uint16_t stripoff_len = 0;
1135 tDot11fIEExtCap extracted_ext_cap;
1136 bool extracted_flag = false;
1137#ifdef WLAN_FEATURE_11W
1138 uint32_t retry_int;
1139 uint32_t max_retries;
1140#endif
1141
1142 if (NULL == pe_session) {
1143 lim_log(mac_ctx, LOGE, FL("pe_session is NULL"));
1144 return;
1145 }
1146
1147 sme_session = pe_session->smeSessionId;
1148
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301149 qdf_mem_set((uint8_t *) &frm, sizeof(frm), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001150
1151 limGetQosMode(pe_session, &qos_mode);
1152 limGetWmeMode(pe_session, &wme_mode);
1153
1154 /*
1155 * An Add TS IE is added only if the AP supports it and
1156 * the requesting STA sent a traffic spec.
1157 */
1158 addts = (qos_mode && sta && sta->qos.addtsPresent) ? 1 : 0;
1159
1160 frm.Status.status = status_code;
1161
1162 frm.AID.associd = aid | LIM_AID_MASK;
1163
1164 if (NULL == sta) {
1165 populate_dot11f_supp_rates(mac_ctx,
1166 POPULATE_DOT11F_RATES_OPERATIONAL,
1167 &frm.SuppRates, pe_session);
1168 populate_dot11f_ext_supp_rates(mac_ctx,
1169 POPULATE_DOT11F_RATES_OPERATIONAL,
1170 &frm.ExtSuppRates, pe_session);
1171 } else {
1172 populate_dot11f_assoc_rsp_rates(mac_ctx, &frm.SuppRates,
1173 &frm.ExtSuppRates,
1174 sta->supportedRates.llbRates,
1175 sta->supportedRates.llaRates);
1176 }
1177
1178 if (LIM_IS_AP_ROLE(pe_session) && sta != NULL &&
1179 eSIR_SUCCESS == status_code) {
1180 assoc_req = (tpSirAssocReq)
1181 pe_session->parsedAssocReq[sta->assocId];
1182 /*
1183 * populate P2P IE in AssocRsp when assocReq from the peer
1184 * includes P2P IE
1185 */
1186 if (assoc_req != NULL && assoc_req->addIEPresent)
1187 populate_dot11_assoc_res_p2p_ie(mac_ctx,
1188 &frm.P2PAssocRes,
1189 assoc_req);
1190 }
1191
1192 if (NULL != sta) {
1193 if (eHAL_SET == qos_mode) {
1194 if (sta->lleEnabled) {
1195 lle_mode = 1;
1196 populate_dot11f_edca_param_set(mac_ctx,
1197 &frm.EDCAParamSet, pe_session);
1198 }
1199 }
1200
1201 if ((!lle_mode) && (eHAL_SET == wme_mode) && sta->wmeEnabled) {
1202 populate_dot11f_wmm_params(mac_ctx, &frm.WMMParams,
1203 pe_session);
1204
1205 if (sta->wsmEnabled)
1206 populate_dot11f_wmm_caps(&frm.WMMCaps);
1207 }
1208
1209 if (sta->mlmStaContext.htCapability &&
1210 pe_session->htCapability) {
1211 lim_log(mac_ctx, LOG1,
1212 FL("Populate HT IEs in Assoc Response"));
1213 populate_dot11f_ht_caps(mac_ctx, pe_session,
1214 &frm.HTCaps);
Krunal Sonief3294b2015-06-12 15:12:19 -07001215 /*
1216 * Check the STA capability and
1217 * update the HTCaps accordingly
1218 */
1219 frm.HTCaps.supportedChannelWidthSet = (
1220 sta->htSupportedChannelWidthSet <
1221 pe_session->htSupportedChannelWidthSet) ?
1222 sta->htSupportedChannelWidthSet :
1223 pe_session->htSupportedChannelWidthSet;
1224 if (!frm.HTCaps.supportedChannelWidthSet)
1225 frm.HTCaps.shortGI40MHz = 0;
1226
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001227 populate_dot11f_ht_info(mac_ctx, &frm.HTInfo,
1228 pe_session);
1229 }
Agrawal Ashishc38e58d2015-09-16 17:17:29 +05301230 lim_log(mac_ctx, LOG1,
1231 FL("SupportedChnlWidth: %d, mimoPS: %d, GF: %d, short GI20:%d, shortGI40: %d, dsssCck: %d, AMPDU Param: %x"),
1232 frm.HTCaps.supportedChannelWidthSet,
1233 frm.HTCaps.mimoPowerSave,
1234 frm.HTCaps.greenField, frm.HTCaps.shortGI20MHz,
1235 frm.HTCaps.shortGI40MHz,
1236 frm.HTCaps.dsssCckMode40MHz,
1237 frm.HTCaps.maxRxAMPDUFactor);
1238
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001239 if (sta->mlmStaContext.vhtCapability &&
1240 pe_session->vhtCapability) {
1241 lim_log(mac_ctx, LOG1,
1242 FL("Populate VHT IEs in Assoc Response"));
1243 populate_dot11f_vht_caps(mac_ctx, pe_session,
1244 &frm.VHTCaps);
1245 populate_dot11f_vht_operation(mac_ctx, pe_session,
1246 &frm.VHTOperation);
1247 is_vht = true;
1248 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001249 populate_dot11f_ext_cap(mac_ctx, is_vht, &frm.ExtCap,
1250 pe_session);
1251
1252#ifdef WLAN_FEATURE_11W
1253 if (eSIR_MAC_TRY_AGAIN_LATER == status_code) {
1254 if (wlan_cfg_get_int
1255 (mac_ctx, WNI_CFG_PMF_SA_QUERY_MAX_RETRIES,
1256 &max_retries) != eSIR_SUCCESS)
1257 lim_log(mac_ctx, LOGE,
1258 FL("get WNI_CFG_PMF_SA_QUERY_MAX_RETRIES failure"));
1259 else if (wlan_cfg_get_int
1260 (mac_ctx,
1261 WNI_CFG_PMF_SA_QUERY_RETRY_INTERVAL,
1262 &retry_int) != eSIR_SUCCESS)
1263 lim_log(mac_ctx, LOGE,
1264 FL("get WNI_CFG_PMF_SA_QUERY_RETRY_INTERVAL failure"));
1265 else
1266 populate_dot11f_timeout_interval(mac_ctx,
1267 &frm.TimeoutInterval,
1268 SIR_MAC_TI_TYPE_ASSOC_COMEBACK,
1269 (max_retries -
1270 sta->pmfSaQueryRetryCount)
1271 * retry_int);
1272 }
1273#endif
1274 }
1275
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301276 qdf_mem_set((uint8_t *) &beacon_params, sizeof(beacon_params), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001277
1278 if (LIM_IS_AP_ROLE(pe_session) &&
1279 (pe_session->gLimProtectionControl !=
1280 WNI_CFG_FORCE_POLICY_PROTECTION_DISABLE))
1281 lim_decide_ap_protection(mac_ctx, peer_addr,
1282 &beacon_params, pe_session);
1283
1284 lim_update_short_preamble(mac_ctx, peer_addr, &beacon_params,
1285 pe_session);
1286 lim_update_short_slot_time(mac_ctx, peer_addr, &beacon_params,
1287 pe_session);
1288
1289 /*
1290 * Populate Do11capabilities after updating session with
1291 * Assos req details
1292 */
1293 populate_dot11f_capabilities(mac_ctx, &frm.Capabilities, pe_session);
1294
1295 beacon_params.bssIdx = pe_session->bssIdx;
1296
1297 /* Send message to HAL about beacon parameter change. */
1298 if ((false == mac_ctx->sap.SapDfsInfo.is_dfs_cac_timer_running)
1299 && beacon_params.paramChangeBitmap) {
1300 sch_set_fixed_beacon_fields(mac_ctx, pe_session);
1301 lim_send_beacon_params(mac_ctx, &beacon_params, pe_session);
1302 }
1303 /* Allocate a buffer for this frame: */
1304 status = dot11f_get_packed_assoc_response_size(mac_ctx, &frm, &payload);
1305 if (DOT11F_FAILED(status)) {
1306 lim_log(mac_ctx, LOGE,
1307 FL("get Association Response size failure (0x%08x)."),
1308 status);
1309 return;
1310 } else if (DOT11F_WARNED(status)) {
1311 lim_log(mac_ctx, LOGW,
1312 FL("get Association Response size warning (0x%08x)."),
1313 status);
1314 }
1315
1316 bytes = sizeof(tSirMacMgmtHdr) + payload;
1317
1318 if (assoc_req != NULL) {
Krishna Kumaar Natarajane4e3a142016-04-01 16:27:51 -07001319 addn_ie_len = pe_session->addIeParams.assocRespDataLen;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001320
1321 /* Nonzero length indicates Assoc rsp IE available */
Krishna Kumaar Natarajane4e3a142016-04-01 16:27:51 -07001322 if (addn_ie_len > 0 &&
1323 addn_ie_len <= WNI_CFG_ASSOC_RSP_ADDNIE_DATA_LEN &&
1324 (bytes + addn_ie_len) <= SIR_MAX_PACKET_SIZE) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301325 qdf_mem_copy(add_ie,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001326 pe_session->addIeParams.assocRespData_buff,
1327 pe_session->addIeParams.assocRespDataLen);
1328
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301329 qdf_mem_set((uint8_t *) &extracted_ext_cap,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001330 sizeof(extracted_ext_cap), 0);
1331
1332 stripoff_len = addn_ie_len;
1333 sir_status =
1334 lim_strip_extcap_update_struct
1335 (mac_ctx, &add_ie[0], &stripoff_len,
1336 &extracted_ext_cap);
1337 if (eSIR_SUCCESS != sir_status) {
1338 lim_log(mac_ctx, LOG1,
1339 FL("strip off extcap IE failed"));
1340 } else {
1341 addn_ie_len = stripoff_len;
1342 extracted_flag = true;
1343 }
1344 bytes = bytes + addn_ie_len;
1345 }
1346 lim_log(mac_ctx, LOG1,
1347 FL("addn_ie_len = %d for Assoc Resp : %d"),
1348 addn_ie_len, assoc_req->addIEPresent);
1349 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301350 qdf_status = cds_packet_alloc((uint16_t) bytes, (void **)&frame,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001351 (void **)&packet);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301352 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001353 lim_log(mac_ctx, LOGP, FL("cds_packet_alloc failed."));
1354 return;
1355 }
1356 /* Paranoia: */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301357 qdf_mem_set(frame, bytes, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001358
1359 /* Next, we fill out the buffer descriptor: */
1360 lim_populate_mac_header(mac_ctx, frame, SIR_MAC_MGMT_FRAME,
1361 (LIM_ASSOC == subtype) ?
1362 SIR_MAC_MGMT_ASSOC_RSP : SIR_MAC_MGMT_REASSOC_RSP,
1363 peer_addr,
1364 pe_session->selfMacAddr);
1365 mac_hdr = (tpSirMacMgmtHdr) frame;
1366
1367 sir_copy_mac_addr(mac_hdr->bssId, pe_session->bssId);
1368
1369 /* merge the ExtCap struct */
1370 if (extracted_flag)
1371 lim_merge_extcap_struct(&(frm.ExtCap), &extracted_ext_cap);
1372 status = dot11f_pack_assoc_response(mac_ctx, &frm,
1373 frame + sizeof(tSirMacMgmtHdr),
1374 payload, &payload);
1375 if (DOT11F_FAILED(status)) {
1376 lim_log(mac_ctx, LOGE,
1377 FL("Association Response pack failure(0x%08x)."),
1378 status);
1379 cds_packet_free((void *)packet);
1380 return;
1381 } else if (DOT11F_WARNED(status)) {
1382 lim_log(mac_ctx, LOGW,
1383 FL("Association Response pack warning (0x%08x)."),
1384 status);
1385 }
1386
1387 if (subtype == LIM_ASSOC)
1388 lim_log(mac_ctx, LOG1,
1389 FL("*** Sending Assoc Resp status %d aid %d to "),
1390 status_code, aid);
1391 else
1392 lim_log(mac_ctx, LOG1,
1393 FL("*** Sending ReAssoc Resp status %d aid %d to "),
1394 status_code, aid);
1395
1396 lim_print_mac_addr(mac_ctx, mac_hdr->da, LOG1);
1397
1398 if (addn_ie_len && addn_ie_len <= WNI_CFG_ASSOC_RSP_ADDNIE_DATA_LEN)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301399 qdf_mem_copy(frame + sizeof(tSirMacMgmtHdr) + payload,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001400 &add_ie[0], addn_ie_len);
1401
1402 if ((SIR_BAND_5_GHZ ==
1403 lim_get_rf_band(pe_session->currentOperChannel)) ||
Anurag Chouhan6d760662016-02-20 16:05:43 +05301404 (pe_session->pePersona == QDF_P2P_CLIENT_MODE) ||
1405 (pe_session->pePersona == QDF_P2P_GO_MODE))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001406 tx_flag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
1407
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05301408 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001409 pe_session->peSessionId, mac_hdr->fc.subType));
1410 /* Queue Association Response frame in high priority WQ */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301411 qdf_status = wma_tx_frame(mac_ctx, packet, (uint16_t) bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001412 TXRX_FRM_802_11_MGMT,
1413 ANI_TXDIR_TODS,
1414 7, lim_tx_complete, frame, tx_flag,
1415 sme_session, 0);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05301416 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301417 pe_session->peSessionId, qdf_status));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001418
1419 /* Pkt will be freed up by the callback */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301420 if (!QDF_IS_STATUS_SUCCESS(qdf_status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001421 lim_log(mac_ctx, LOGE,
1422 FL("*** Could not Send Re/AssocRsp, retCode=%X ***"),
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301423 qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001424
1425 /*
1426 * update the ANI peer station count.
1427 * FIXME_PROTECTION : take care of different type of station
1428 * counter inside this function.
1429 */
1430 lim_util_count_sta_add(mac_ctx, sta, pe_session);
1431
1432}
1433
1434void
1435lim_send_delts_req_action_frame(tpAniSirGlobal pMac,
1436 tSirMacAddr peer,
1437 uint8_t wmmTspecPresent,
1438 tSirMacTSInfo *pTsinfo,
1439 tSirMacTspecIE *pTspecIe, tpPESession psessionEntry)
1440{
1441 uint8_t *pFrame;
1442 tpSirMacMgmtHdr pMacHdr;
1443 tDot11fDelTS DelTS;
1444 tDot11fWMMDelTS WMMDelTS;
1445 uint32_t nBytes, nPayload, nStatus;
1446 void *pPacket;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301447 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001448 uint8_t txFlag = 0;
1449 uint8_t smeSessionId = 0;
1450
1451 if (NULL == psessionEntry) {
1452 return;
1453 }
1454
1455 smeSessionId = psessionEntry->smeSessionId;
1456
1457 if (!wmmTspecPresent) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301458 qdf_mem_set((uint8_t *) &DelTS, sizeof(DelTS), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001459
1460 DelTS.Category.category = SIR_MAC_ACTION_QOS_MGMT;
1461 DelTS.Action.action = SIR_MAC_QOS_DEL_TS_REQ;
1462 populate_dot11f_ts_info(pTsinfo, &DelTS.TSInfo);
1463
1464 nStatus = dot11f_get_packed_del_ts_size(pMac, &DelTS, &nPayload);
1465 if (DOT11F_FAILED(nStatus)) {
1466 lim_log(pMac, LOGP,
1467 FL("Failed to calculate the packed si"
1468 "ze for a Del TS (0x%08x)."), nStatus);
1469 /* We'll fall back on the worst case scenario: */
1470 nPayload = sizeof(tDot11fDelTS);
1471 } else if (DOT11F_WARNED(nStatus)) {
1472 lim_log(pMac, LOGW,
1473 FL("There were warnings while calcula"
1474 "ting the packed size for a Del TS"
1475 " (0x%08x)."), nStatus);
1476 }
1477 } else {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301478 qdf_mem_set((uint8_t *) &WMMDelTS, sizeof(WMMDelTS), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001479
1480 WMMDelTS.Category.category = SIR_MAC_ACTION_WME;
1481 WMMDelTS.Action.action = SIR_MAC_QOS_DEL_TS_REQ;
1482 WMMDelTS.DialogToken.token = 0;
1483 WMMDelTS.StatusCode.statusCode = 0;
1484 populate_dot11f_wmmtspec(pTspecIe, &WMMDelTS.WMMTSPEC);
1485 nStatus =
1486 dot11f_get_packed_wmm_del_ts_size(pMac, &WMMDelTS, &nPayload);
1487 if (DOT11F_FAILED(nStatus)) {
1488 lim_log(pMac, LOGP,
1489 FL("Failed to calculate the packed si"
1490 "ze for a WMM Del TS (0x%08x)."), nStatus);
1491 /* We'll fall back on the worst case scenario: */
1492 nPayload = sizeof(tDot11fDelTS);
1493 } else if (DOT11F_WARNED(nStatus)) {
1494 lim_log(pMac, LOGW,
1495 FL("There were warnings while calcula"
1496 "ting the packed size for a WMM De"
1497 "l TS (0x%08x)."), nStatus);
1498 }
1499 }
1500
1501 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
1502
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301503 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001504 cds_packet_alloc((uint16_t) nBytes, (void **)&pFrame,
1505 (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301506 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001507 lim_log(pMac, LOGP, FL("Failed to allocate %d bytes for an Ad"
1508 "d TS Response."), nBytes);
1509 return;
1510 }
1511 /* Paranoia: */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301512 qdf_mem_set(pFrame, nBytes, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001513
1514 /* Next, we fill out the buffer descriptor: */
1515 lim_populate_mac_header(pMac, pFrame, SIR_MAC_MGMT_FRAME,
1516 SIR_MAC_MGMT_ACTION, peer, psessionEntry->selfMacAddr);
1517 pMacHdr = (tpSirMacMgmtHdr) pFrame;
1518
1519 sir_copy_mac_addr(pMacHdr->bssId, psessionEntry->bssId);
1520
1521#ifdef WLAN_FEATURE_11W
1522 lim_set_protected_bit(pMac, psessionEntry, peer, pMacHdr);
1523#endif
1524
1525 /* That done, pack the struct: */
1526 if (!wmmTspecPresent) {
1527 nStatus = dot11f_pack_del_ts(pMac, &DelTS,
1528 pFrame + sizeof(tSirMacMgmtHdr),
1529 nPayload, &nPayload);
1530 if (DOT11F_FAILED(nStatus)) {
1531 lim_log(pMac, LOGE,
1532 FL("Failed to pack a Del TS frame (0x%08x)."),
1533 nStatus);
1534 cds_packet_free((void *)pPacket);
1535 return; /* allocated! */
1536 } else if (DOT11F_WARNED(nStatus)) {
1537 lim_log(pMac, LOGW,
1538 FL("There were warnings while packing "
1539 "a Del TS frame (0x%08x)."), nStatus);
1540 }
1541 } else {
1542 nStatus = dot11f_pack_wmm_del_ts(pMac, &WMMDelTS,
1543 pFrame + sizeof(tSirMacMgmtHdr),
1544 nPayload, &nPayload);
1545 if (DOT11F_FAILED(nStatus)) {
1546 lim_log(pMac, LOGE,
1547 FL
1548 ("Failed to pack a WMM Del TS frame (0x%08x)."),
1549 nStatus);
1550 cds_packet_free((void *)pPacket);
1551 return; /* allocated! */
1552 } else if (DOT11F_WARNED(nStatus)) {
1553 lim_log(pMac, LOGW,
1554 FL("There were warnings while packing "
1555 "a WMM Del TS frame (0x%08x)."), nStatus);
1556 }
1557 }
1558
1559 PELOG1(lim_log
1560 (pMac, LOG1, FL("Sending DELTS REQ (size %d) to "), nBytes);
1561 lim_print_mac_addr(pMac, pMacHdr->da, LOG1);
1562 )
1563
1564 if ((SIR_BAND_5_GHZ ==
1565 lim_get_rf_band(psessionEntry->currentOperChannel))
Anurag Chouhan6d760662016-02-20 16:05:43 +05301566 || (psessionEntry->pePersona == QDF_P2P_CLIENT_MODE)
1567 || (psessionEntry->pePersona == QDF_P2P_GO_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001568 ) {
1569 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
1570 }
1571
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05301572 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001573 psessionEntry->peSessionId, pMacHdr->fc.subType));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301574 qdf_status = wma_tx_frame(pMac, pPacket, (uint16_t) nBytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001575 TXRX_FRM_802_11_MGMT,
1576 ANI_TXDIR_TODS,
1577 7, lim_tx_complete, pFrame, txFlag,
1578 smeSessionId, 0);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05301579 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301580 psessionEntry->peSessionId, qdf_status));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001581 /* Pkt will be freed up by the callback */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301582 if (!QDF_IS_STATUS_SUCCESS(qdf_status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001583 lim_log(pMac, LOGE, FL("Failed to send Del TS (%X)!"),
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301584 qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001585
1586} /* End lim_send_delts_req_action_frame. */
1587
1588/**
1589 * lim_send_assoc_req_mgmt_frame() - Send association request
1590 * @mac_ctx: Handle to MAC context
1591 * @mlm_assoc_req: Association request information
1592 * @pe_session: PE session information
1593 *
1594 * Builds and transmits association request frame to AP.
1595 *
1596 * Return: Void
1597 */
1598
1599void
1600lim_send_assoc_req_mgmt_frame(tpAniSirGlobal mac_ctx,
1601 tLimMlmAssocReq *mlm_assoc_req,
1602 tpPESession pe_session)
1603{
1604 tDot11fAssocRequest *frm;
1605 uint16_t caps;
1606 uint8_t *frame;
1607 tSirRetStatus sir_status;
1608 tLimMlmAssocCnf assoc_cnf;
1609 uint32_t bytes, payload, status;
1610 uint8_t qos_enabled, wme_enabled, wsm_enabled;
1611 void *packet;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301612 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001613 uint16_t add_ie_len;
1614 uint8_t *add_ie;
1615 uint8_t *wps_ie = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001616 uint8_t power_caps = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001617 uint8_t tx_flag = 0;
1618 uint8_t sme_sessionid = 0;
1619 bool vht_enabled = false;
1620 tDot11fIEExtCap extr_ext_cap;
1621 bool extr_ext_flag = true;
1622 tpSirMacMgmtHdr mac_hdr;
1623
1624 if (NULL == pe_session) {
1625 lim_log(mac_ctx, LOGE, FL("pe_session is NULL"));
1626 return;
1627 }
1628
1629 sme_sessionid = pe_session->smeSessionId;
1630
1631 /* check this early to avoid unncessary operation */
1632 if (NULL == pe_session->pLimJoinReq) {
1633 lim_log(mac_ctx, LOGE, FL("pe_session->pLimJoinReq is NULL"));
1634 return;
1635 }
1636 add_ie_len = pe_session->pLimJoinReq->addIEAssoc.length;
1637 add_ie = pe_session->pLimJoinReq->addIEAssoc.addIEdata;
1638
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301639 frm = qdf_mem_malloc(sizeof(tDot11fAssocRequest));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001640 if (NULL == frm) {
1641 lim_log(mac_ctx, LOGE, FL("Unable to allocate memory"));
1642 return;
1643 }
1644
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301645 qdf_mem_set((uint8_t *) frm, sizeof(tDot11fAssocRequest), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001646
Agrawal Ashish0f94b572016-02-22 13:27:06 +05301647 if (add_ie_len && pe_session->is_ext_caps_present) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301648 qdf_mem_set((uint8_t *) &extr_ext_cap, sizeof(tDot11fIEExtCap),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001649 0);
1650 sir_status = lim_strip_extcap_update_struct(mac_ctx,
1651 add_ie, &add_ie_len, &extr_ext_cap);
1652 if (eSIR_SUCCESS != sir_status) {
1653 extr_ext_flag = false;
1654 lim_log(mac_ctx, LOG1,
1655 FL("Unable to Stripoff ExtCap IE from Assoc Req"));
1656 } else {
1657 struct s_ext_cap *p_ext_cap = (struct s_ext_cap *)
1658 extr_ext_cap.bytes;
1659
1660 if (p_ext_cap->interworking_service)
1661 p_ext_cap->qos_map = 1;
Kapil Guptac03eb072016-08-09 14:01:36 +05301662 extr_ext_flag = lim_is_ext_cap_ie_present(p_ext_cap);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001663 }
1664 } else {
Agrawal Ashish0f94b572016-02-22 13:27:06 +05301665 lim_log(mac_ctx, LOG1,
1666 FL("No addn IE or peer dosen't support addnIE for Assoc Req"));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001667 extr_ext_flag = false;
1668 }
1669
1670 caps = mlm_assoc_req->capabilityInfo;
1671#if defined(FEATURE_WLAN_WAPI)
1672 /*
1673 * According to WAPI standard:
1674 * 7.3.1.4 Capability Information field
1675 * In WAPI, non-AP STAs within an ESS set the Privacy subfield to 0
1676 * in transmitted Association or Reassociation management frames.
1677 * APs ignore the Privacy subfield within received Association and
1678 * Reassociation management frames.
1679 */
1680 if (pe_session->encryptType == eSIR_ED_WPI)
1681 ((tSirMacCapabilityInfo *) &caps)->privacy = 0;
1682#endif
1683 swap_bit_field16(caps, (uint16_t *) &frm->Capabilities);
1684
1685 frm->ListenInterval.interval = mlm_assoc_req->listenInterval;
1686 populate_dot11f_ssid2(mac_ctx, &frm->SSID);
1687 populate_dot11f_supp_rates(mac_ctx, POPULATE_DOT11F_RATES_OPERATIONAL,
1688 &frm->SuppRates, pe_session);
1689
1690 qos_enabled = (pe_session->limQosEnabled) &&
1691 SIR_MAC_GET_QOS(pe_session->limCurrentBssCaps);
1692
1693 wme_enabled = (pe_session->limWmeEnabled) &&
1694 LIM_BSS_CAPS_GET(WME, pe_session->limCurrentBssQosCaps);
1695
1696 /* We prefer .11e asociations: */
1697 if (qos_enabled)
1698 wme_enabled = false;
1699
1700 wsm_enabled = (pe_session->limWsmEnabled) && wme_enabled &&
1701 LIM_BSS_CAPS_GET(WSM, pe_session->limCurrentBssQosCaps);
1702
1703 if (pe_session->lim11hEnable &&
1704 pe_session->pLimJoinReq->spectrumMgtIndicator == eSIR_TRUE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001705 power_caps = true;
1706
1707 populate_dot11f_power_caps(mac_ctx, &frm->PowerCaps,
1708 LIM_ASSOC, pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001709 populate_dot11f_supp_channels(mac_ctx, &frm->SuppChannels,
1710 LIM_ASSOC, pe_session);
1711
1712 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001713 if (mac_ctx->rrm.rrmPEContext.rrmEnable &&
1714 SIR_MAC_GET_RRM(pe_session->limCurrentBssCaps)) {
1715 if (power_caps == false) {
1716 power_caps = true;
1717 populate_dot11f_power_caps(mac_ctx, &frm->PowerCaps,
1718 LIM_ASSOC, pe_session);
1719 }
1720 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001721 if (qos_enabled)
1722 populate_dot11f_qos_caps_station(mac_ctx, &frm->QOSCapsStation);
1723
1724 populate_dot11f_ext_supp_rates(mac_ctx,
1725 POPULATE_DOT11F_RATES_OPERATIONAL, &frm->ExtSuppRates,
1726 pe_session);
1727
Gupta, Kapil54a16992016-01-13 19:34:02 +05301728 if (mac_ctx->rrm.rrmPEContext.rrmEnable &&
1729 SIR_MAC_GET_RRM(pe_session->limCurrentBssCaps))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001730 populate_dot11f_rrm_ie(mac_ctx, &frm->RRMEnabledCap,
1731 pe_session);
Deepak Dhamdhere641bf322016-01-06 15:19:03 -08001732
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001733 /*
1734 * The join request *should* contain zero or one of the WPA and RSN
1735 * IEs. The payload send along with the request is a
1736 * 'tSirSmeJoinReq'; the IE portion is held inside a 'tSirRSNie':
1737 * typedef struct sSirRSNie
1738 * {
1739 * uint16_t length;
1740 * uint8_t rsnIEdata[SIR_MAC_MAX_IE_LENGTH+2];
1741 * } tSirRSNie, *tpSirRSNie;
1742 * So, we should be able to make the following two calls harmlessly,
1743 * since they do nothing if they don't find the given IE in the
1744 * bytestream with which they're provided.
1745 * The net effect of this will be to faithfully transmit whatever
1746 * security IE is in the join request.
1747 * However, if we're associating for the purpose of WPS
1748 * enrollment, and we've been configured to indicate that by
1749 * eliding the WPA or RSN IE, we just skip this:
1750 */
1751 if (add_ie_len && add_ie)
1752 wps_ie = limGetWscIEPtr(mac_ctx, add_ie, add_ie_len);
1753
1754 if (NULL == wps_ie) {
1755 populate_dot11f_rsn_opaque(mac_ctx,
1756 &(pe_session->pLimJoinReq->rsnIE),
1757 &frm->RSNOpaque);
1758 populate_dot11f_wpa_opaque(mac_ctx,
1759 &(pe_session->pLimJoinReq->rsnIE),
1760 &frm->WPAOpaque);
1761#if defined(FEATURE_WLAN_WAPI)
1762 populate_dot11f_wapi_opaque(mac_ctx,
1763 &(pe_session->pLimJoinReq->rsnIE),
1764 &frm->WAPIOpaque);
1765#endif /* defined(FEATURE_WLAN_WAPI) */
1766 }
1767 /* include WME EDCA IE as well */
1768 if (wme_enabled) {
1769 populate_dot11f_wmm_info_station_per_session(mac_ctx,
1770 pe_session, &frm->WMMInfoStation);
1771
1772 if (wsm_enabled)
1773 populate_dot11f_wmm_caps(&frm->WMMCaps);
1774 }
1775
1776 /*
1777 * Populate HT IEs, when operating in 11n and
1778 * when AP is also operating in 11n mode
1779 */
1780 if (pe_session->htCapability &&
1781 mac_ctx->lim.htCapabilityPresentInBeacon) {
1782 lim_log(mac_ctx, LOG1, FL("Populate HT Caps in Assoc Request"));
1783 populate_dot11f_ht_caps(mac_ctx, pe_session, &frm->HTCaps);
Naveen Rawata410c5a2016-09-19 14:22:33 -07001784 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_DEBUG,
1785 &frm->HTCaps, sizeof(frm->HTCaps));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001786 }
Agrawal Ashishc38e58d2015-09-16 17:17:29 +05301787 lim_log(mac_ctx, LOG1,
1788 FL("SupportedChnlWidth: %d, mimoPS: %d, GF: %d, short GI20:%d, shortGI40: %d, dsssCck: %d, AMPDU Param: %x"),
1789 frm->HTCaps.supportedChannelWidthSet,
1790 frm->HTCaps.mimoPowerSave,
1791 frm->HTCaps.greenField, frm->HTCaps.shortGI20MHz,
1792 frm->HTCaps.shortGI40MHz,
1793 frm->HTCaps.dsssCckMode40MHz,
1794 frm->HTCaps.maxRxAMPDUFactor);
1795
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001796 if (pe_session->vhtCapability &&
1797 pe_session->vhtCapabilityPresentInBeacon) {
1798 lim_log(mac_ctx, LOG1, FL("Populate VHT IEs in Assoc Request"));
1799 populate_dot11f_vht_caps(mac_ctx, pe_session, &frm->VHTCaps);
Naveen Rawata410c5a2016-09-19 14:22:33 -07001800 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_DEBUG,
1801 &frm->VHTCaps, sizeof(frm->VHTCaps));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001802 vht_enabled = true;
Kiran Kumar Lokere1d4094e2016-08-31 19:04:04 -07001803 if (pe_session->enableHtSmps &&
1804 !pe_session->supported_nss_1x1) {
1805 lim_log(mac_ctx, LOGE, FL(
1806 "VHT OP mode IE in Assoc Req"));
1807 populate_dot11f_operating_mode(mac_ctx,
1808 &frm->OperatingMode, pe_session);
1809 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001810 }
1811 if (!vht_enabled &&
1812 pe_session->is_vendor_specific_vhtcaps) {
1813 lim_log(mac_ctx, LOG1,
1814 FL("Populate Vendor VHT IEs in Assoc Request"));
1815 frm->vendor2_ie.present = 1;
1816 frm->vendor2_ie.type =
1817 pe_session->vendor_specific_vht_ie_type;
1818 frm->vendor2_ie.sub_type =
1819 pe_session->vendor_specific_vht_ie_sub_type;
1820
1821 frm->vendor2_ie.VHTCaps.present = 1;
1822 populate_dot11f_vht_caps(mac_ctx, pe_session,
1823 &frm->vendor2_ie.VHTCaps);
1824 vht_enabled = true;
1825 }
Agrawal Ashish0f94b572016-02-22 13:27:06 +05301826 if (pe_session->is_ext_caps_present)
1827 populate_dot11f_ext_cap(mac_ctx, vht_enabled,
1828 &frm->ExtCap, pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001829
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001830 if (pe_session->pLimJoinReq->is11Rconnection) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001831 tSirBssDescription *bssdescr;
1832
1833 bssdescr = &pe_session->pLimJoinReq->bssDescription;
1834 lim_log(mac_ctx, LOG1, FL("mdie = %02x %02x %02x"),
1835 (unsigned int) bssdescr->mdie[0],
1836 (unsigned int) bssdescr->mdie[1],
1837 (unsigned int) bssdescr->mdie[2]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001838 populate_mdie(mac_ctx, &frm->MobilityDomain,
1839 pe_session->pLimJoinReq->bssDescription.mdie);
1840 } else {
1841 /* No 11r IEs dont send any MDIE */
1842 lim_log(mac_ctx, LOG1, FL("MDIE not present"));
1843 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001844
1845#ifdef FEATURE_WLAN_ESE
1846 /*
1847 * ESE Version IE will be included in association request
1848 * when ESE is enabled on DUT through ini and it is also
1849 * advertised by the peer AP to which we are trying to
1850 * associate to.
1851 */
1852 if (pe_session->is_ese_version_ie_present &&
1853 mac_ctx->roam.configParam.isEseIniFeatureEnabled)
1854 populate_dot11f_ese_version(&frm->ESEVersion);
1855 /* For ESE Associations fill the ESE IEs */
1856 if (pe_session->isESEconnection &&
1857 pe_session->pLimJoinReq->isESEFeatureIniEnabled) {
1858#ifndef FEATURE_DISABLE_RM
1859 populate_dot11f_ese_rad_mgmt_cap(&frm->ESERadMgmtCap);
1860#endif
1861 }
1862#endif
1863
1864 status = dot11f_get_packed_assoc_request_size(mac_ctx, frm, &payload);
1865 if (DOT11F_FAILED(status)) {
1866 lim_log(mac_ctx, LOGP,
1867 FL("Association Request packet size failure(0x%08x)."),
1868 status);
1869 /* We'll fall back on the worst case scenario: */
1870 payload = sizeof(tDot11fAssocRequest);
1871 } else if (DOT11F_WARNED(status)) {
1872 lim_log(mac_ctx, LOGW,
1873 FL("Association request packet size warning (0x%08x)."),
1874 status);
1875 }
1876
1877 bytes = payload + sizeof(tSirMacMgmtHdr) + add_ie_len;
1878
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301879 qdf_status = cds_packet_alloc((uint16_t) bytes, (void **)&frame,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001880 (void **)&packet);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301881 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001882 lim_log(mac_ctx, LOGP, FL("Failed to allocate %d bytes."),
1883 bytes);
1884
1885 pe_session->limMlmState = pe_session->limPrevMlmState;
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05301886 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_MLM_STATE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001887 pe_session->peSessionId,
1888 pe_session->limMlmState));
1889
1890 /* Update PE session id */
1891 assoc_cnf.sessionId = pe_session->peSessionId;
1892
1893 assoc_cnf.resultCode = eSIR_SME_RESOURCES_UNAVAILABLE;
1894
1895 cds_packet_free((void *)packet);
1896
1897 lim_post_sme_message(mac_ctx, LIM_MLM_ASSOC_CNF,
1898 (uint32_t *) &assoc_cnf);
1899
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301900 qdf_mem_free(frm);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001901 return;
1902 }
1903 /* Paranoia: */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301904 qdf_mem_set(frame, bytes, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001905
1906 /* Next, we fill out the buffer descriptor: */
1907 lim_populate_mac_header(mac_ctx, frame, SIR_MAC_MGMT_FRAME,
1908 SIR_MAC_MGMT_ASSOC_REQ, pe_session->bssId,
1909 pe_session->selfMacAddr);
1910 /* merge the ExtCap struct */
1911 if (extr_ext_flag)
1912 lim_merge_extcap_struct(&frm->ExtCap, &extr_ext_cap);
1913 /* That done, pack the Assoc Request: */
1914 status = dot11f_pack_assoc_request(mac_ctx, frm,
1915 frame + sizeof(tSirMacMgmtHdr), payload, &payload);
1916 if (DOT11F_FAILED(status)) {
1917 lim_log(mac_ctx, LOGE,
1918 FL("Assoc request pack failure (0x%08x)"), status);
1919 cds_packet_free((void *)packet);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301920 qdf_mem_free(frm);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001921 return;
1922 } else if (DOT11F_WARNED(status)) {
1923 lim_log(mac_ctx, LOGW,
1924 FL("Assoc request pack warning (0x%08x)"), status);
1925 }
1926
1927 lim_log(mac_ctx, LOG1,
1928 FL("*** Sending Association Request length %d to "), bytes);
1929 if (pe_session->assocReq != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301930 qdf_mem_free(pe_session->assocReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001931 pe_session->assocReq = NULL;
Naveen Rawat83102ef2015-11-03 10:42:34 -08001932 pe_session->assocReqLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001933 }
1934
1935 if (add_ie_len) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301936 qdf_mem_copy(frame + sizeof(tSirMacMgmtHdr) + payload,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001937 add_ie, add_ie_len);
1938 payload += add_ie_len;
1939 }
1940
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301941 pe_session->assocReq = qdf_mem_malloc(payload);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001942 if (NULL == pe_session->assocReq) {
1943 lim_log(mac_ctx, LOGE, FL("Unable to allocate memory"));
1944 } else {
1945 /*
1946 * Store the Assoc request. This is sent to csr/hdd in
1947 * join cnf response.
1948 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301949 qdf_mem_copy(pe_session->assocReq,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001950 frame + sizeof(tSirMacMgmtHdr), payload);
1951 pe_session->assocReqLen = payload;
1952 }
1953
1954 if ((SIR_BAND_5_GHZ == lim_get_rf_band(pe_session->currentOperChannel))
Anurag Chouhan6d760662016-02-20 16:05:43 +05301955 || (pe_session->pePersona == QDF_P2P_CLIENT_MODE)
1956 || (pe_session->pePersona == QDF_P2P_GO_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001957 )
1958 tx_flag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
1959
Anurag Chouhan6d760662016-02-20 16:05:43 +05301960 if (pe_session->pePersona == QDF_P2P_CLIENT_MODE ||
1961 pe_session->pePersona == QDF_STA_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001962 tx_flag |= HAL_USE_PEER_STA_REQUESTED_MASK;
1963
1964#ifdef FEATURE_WLAN_DIAG_SUPPORT
1965 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_ASSOC_START_EVENT,
1966 pe_session, eSIR_SUCCESS, eSIR_SUCCESS);
1967#endif
1968 mac_hdr = (tpSirMacMgmtHdr) frame;
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05301969 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001970 pe_session->peSessionId, mac_hdr->fc.subType));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301971 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001972 wma_tx_frame(mac_ctx, packet,
1973 (uint16_t) (sizeof(tSirMacMgmtHdr) + payload),
1974 TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS, 7,
1975 lim_tx_complete, frame, tx_flag, sme_sessionid, 0);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05301976 MTRACE(qdf_trace
Anurag Chouhan6d760662016-02-20 16:05:43 +05301977 (QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301978 pe_session->peSessionId, qdf_status));
1979 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001980 lim_log(mac_ctx, LOGE,
1981 FL("Failed to send Association Request (%X)!"),
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301982 qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001983 /* Pkt will be freed up by the callback */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301984 qdf_mem_free(frm);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001985 return;
1986 }
1987 /* Free up buffer allocated for mlm_assoc_req */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301988 qdf_mem_free(mlm_assoc_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001989 mlm_assoc_req = NULL;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301990 qdf_mem_free(frm);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001991 return;
1992}
1993
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001994/**
Abhishek Singh7d3bc3e2016-02-03 17:45:01 +05301995 * lim_auth_tx_complete_cnf()- Confirmation for auth sent over the air
1996 *
1997 * @mac_ctx: pointer to global mac
1998 * @tx_complete : Sent status
1999 *
2000 * Return: This returns QDF_STATUS
2001 */
2002
2003QDF_STATUS lim_auth_tx_complete_cnf(tpAniSirGlobal mac_ctx,
2004 uint32_t tx_complete)
2005{
2006 lim_log(mac_ctx, LOG1,
2007 FL("tx_complete= %d"), tx_complete);
2008 if (tx_complete) {
2009 mac_ctx->auth_ack_status = LIM_AUTH_ACK_RCD_SUCCESS;
2010 /* 'Change' timer for future activations */
2011 lim_deactivate_and_change_timer(mac_ctx, eLIM_AUTH_RETRY_TIMER);
2012 } else {
2013 mac_ctx->auth_ack_status = LIM_AUTH_ACK_RCD_FAILURE;
2014 }
2015 return QDF_STATUS_SUCCESS;
2016}
2017
2018/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002019 * lim_send_auth_mgmt_frame() - Send an Authentication frame
2020 *
2021 * @mac_ctx: Pointer to Global MAC structure
2022 * @auth_frame: Pointer to Authentication frame structure
2023 * @peer_addr: MAC address of destination peer
2024 * @wep_bit: wep bit in frame control for Authentication frame3
2025 * @session: PE session information
2026 *
2027 * This function is called by lim_process_mlm_messages(). Authentication frame
2028 * is formatted and sent when this function is called.
2029 *
2030 * Return: void
2031 */
2032
2033void
2034lim_send_auth_mgmt_frame(tpAniSirGlobal mac_ctx,
2035 tpSirMacAuthFrameBody auth_frame,
2036 tSirMacAddr peer_addr,
Abhishek Singh7d3bc3e2016-02-03 17:45:01 +05302037 uint8_t wep_bit,
2038 tpPESession session, bool wait_for_ack)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002039{
2040 uint8_t *frame, *body;
2041 uint32_t frame_len = 0, body_len = 0;
2042 tpSirMacMgmtHdr mac_hdr;
2043 void *packet;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302044 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002045 uint8_t tx_flag = 0;
2046 uint8_t sme_sessionid = 0;
2047 uint16_t ft_ies_length = 0;
2048
2049 if (NULL == session) {
2050 lim_log(mac_ctx, LOGE, FL("Error: psession Entry is NULL"));
2051 return;
2052 }
2053
2054 sme_sessionid = session->smeSessionId;
2055
Krishna Kumaar Natarajan7e6a23c2016-04-05 14:45:24 -07002056 if (wep_bit == LIM_WEP_IN_FC) {
2057 /*
2058 * Auth frame3 to be sent with encrypted framebody
2059 *
2060 * Allocate buffer for Authenticaton frame of size
2061 * equal to management frame header length plus 2 bytes
2062 * each for auth algorithm number, transaction number,
2063 * status code, 128 bytes for challenge text and
2064 * 4 bytes each for IV & ICV.
2065 */
2066 lim_log(mac_ctx, LOG1,
2067 FL("Sending encrypted auth frame to " MAC_ADDRESS_STR
2068 "- wait_for_ack %d"), MAC_ADDR_ARRAY(peer_addr),
2069 wait_for_ack);
2070
2071 frame_len = sizeof(tSirMacMgmtHdr) + LIM_ENCR_AUTH_BODY_LEN;
2072 body_len = LIM_ENCR_AUTH_BODY_LEN;
2073
2074 goto alloc_packet;
2075 }
2076
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002077 lim_log(mac_ctx, LOG1,
Abhishek Singh7d3bc3e2016-02-03 17:45:01 +05302078 FL("Sending Auth seq# %d status %d (%d) wait_for_ack %d to "
2079 MAC_ADDRESS_STR),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002080 auth_frame->authTransactionSeqNumber,
2081 auth_frame->authStatusCode,
2082 (auth_frame->authStatusCode == eSIR_MAC_SUCCESS_STATUS),
Abhishek Singh7d3bc3e2016-02-03 17:45:01 +05302083 wait_for_ack,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002084 MAC_ADDR_ARRAY(peer_addr));
2085
2086 switch (auth_frame->authTransactionSeqNumber) {
2087 case SIR_MAC_AUTH_FRAME_1:
2088 /*
2089 * Allocate buffer for Authenticaton frame of size
2090 * equal to management frame header length plus 2 bytes
2091 * each for auth algorithm number, transaction number
2092 * and status code.
2093 */
2094
2095 frame_len = sizeof(tSirMacMgmtHdr) +
2096 SIR_MAC_AUTH_CHALLENGE_OFFSET;
2097 body_len = SIR_MAC_AUTH_CHALLENGE_OFFSET;
2098
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002099 if (auth_frame->authAlgoNumber == eSIR_FT_AUTH) {
2100 if (NULL != session->ftPEContext.pFTPreAuthReq &&
2101 0 != session->ftPEContext.pFTPreAuthReq->
2102 ft_ies_length) {
2103 ft_ies_length = session->ftPEContext.
2104 pFTPreAuthReq->ft_ies_length;
2105 frame_len += ft_ies_length;
2106 lim_log(mac_ctx, LOG3,
2107 FL("Auth frame, FTIES length added=%d"),
2108 ft_ies_length);
2109 } else {
2110 lim_log(mac_ctx, LOG3,
2111 FL("Auth frame, Does not contain FTIES!!!"));
2112 frame_len += (2 + SIR_MDIE_SIZE);
2113 }
2114 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002115 break;
2116
2117 case SIR_MAC_AUTH_FRAME_2:
2118 if ((auth_frame->authAlgoNumber == eSIR_OPEN_SYSTEM) ||
2119 ((auth_frame->authAlgoNumber == eSIR_SHARED_KEY) &&
2120 (auth_frame->authStatusCode !=
2121 eSIR_MAC_SUCCESS_STATUS))) {
2122 /*
2123 * Allocate buffer for Authenticaton frame of size
2124 * equal to management frame header length plus
2125 * 2 bytes each for auth algorithm number,
2126 * transaction number and status code.
2127 */
2128
2129 frame_len = sizeof(tSirMacMgmtHdr) +
2130 SIR_MAC_AUTH_CHALLENGE_OFFSET;
2131 body_len = SIR_MAC_AUTH_CHALLENGE_OFFSET;
2132 } else {
2133 /*
2134 * Shared Key algorithm with challenge text
2135 * to be sent.
2136 *
2137 * Allocate buffer for Authenticaton frame of size
2138 * equal to management frame header length plus
2139 * 2 bytes each for auth algorithm number,
2140 * transaction number, status code and 128 bytes
2141 * for challenge text.
2142 */
2143
2144 frame_len = sizeof(tSirMacMgmtHdr) +
2145 sizeof(tSirMacAuthFrame);
2146 body_len = sizeof(tSirMacAuthFrameBody);
2147 }
2148 break;
2149
2150 case SIR_MAC_AUTH_FRAME_3:
Krishna Kumaar Natarajan7e6a23c2016-04-05 14:45:24 -07002151 /*
2152 * Auth frame3 to be sent without encrypted framebody
2153 *
2154 * Allocate buffer for Authenticaton frame of size equal
2155 * to management frame header length plus 2 bytes each
2156 * for auth algorithm number, transaction number and
2157 * status code.
2158 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002159
Krishna Kumaar Natarajan7e6a23c2016-04-05 14:45:24 -07002160 frame_len = sizeof(tSirMacMgmtHdr) +
2161 SIR_MAC_AUTH_CHALLENGE_OFFSET;
2162 body_len = SIR_MAC_AUTH_CHALLENGE_OFFSET;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002163 break;
2164
2165 case SIR_MAC_AUTH_FRAME_4:
2166 /*
2167 * Allocate buffer for Authenticaton frame of size equal
2168 * to management frame header length plus 2 bytes each
2169 * for auth algorithm number, transaction number and
2170 * status code.
2171 */
2172
2173 frame_len = sizeof(tSirMacMgmtHdr) +
2174 SIR_MAC_AUTH_CHALLENGE_OFFSET;
2175 body_len = SIR_MAC_AUTH_CHALLENGE_OFFSET;
2176
2177 break;
Krishna Kumaar Natarajan7e6a23c2016-04-05 14:45:24 -07002178 default:
2179 lim_log(mac_ctx, LOGE, FL("Invalid auth transaction seq num."));
2180 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002181 } /* switch (auth_frame->authTransactionSeqNumber) */
2182
Krishna Kumaar Natarajan7e6a23c2016-04-05 14:45:24 -07002183alloc_packet:
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302184 qdf_status = cds_packet_alloc((uint16_t) frame_len, (void **)&frame,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002185 (void **)&packet);
2186
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302187 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002188 lim_log(mac_ctx, LOGP,
2189 FL("call to bufAlloc failed for AUTH frame"));
2190 return;
2191 }
2192
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302193 qdf_mem_zero(frame, frame_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002194
2195 /* Prepare BD */
2196 lim_populate_mac_header(mac_ctx, frame, SIR_MAC_MGMT_FRAME,
2197 SIR_MAC_MGMT_AUTH, peer_addr, session->selfMacAddr);
2198 mac_hdr = (tpSirMacMgmtHdr) frame;
2199 mac_hdr->fc.wep = wep_bit;
2200
2201 /* Prepare BSSId */
Rajeev Kumarcf835a02016-04-15 15:01:31 -07002202 if (LIM_IS_AP_ROLE(session))
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302203 qdf_mem_copy((uint8_t *) mac_hdr->bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002204 (uint8_t *) session->bssId,
2205 sizeof(tSirMacAddr));
2206
2207 /* Prepare Authentication frame body */
2208 body = frame + sizeof(tSirMacMgmtHdr);
2209
2210 if (wep_bit == LIM_WEP_IN_FC) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302211 qdf_mem_copy(body, (uint8_t *) auth_frame, body_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002212
2213 lim_log(mac_ctx, LOG1,
Krishna Kumaar Natarajan7e6a23c2016-04-05 14:45:24 -07002214 FL("Sending Auth seq# 3 to " MAC_ADDRESS_STR),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002215 MAC_ADDR_ARRAY(mac_hdr->da));
2216
2217 } else {
2218 *((uint16_t *) (body)) =
2219 sir_swap_u16if_needed(auth_frame->authAlgoNumber);
2220 body += sizeof(uint16_t);
2221 body_len -= sizeof(uint16_t);
2222
2223 *((uint16_t *) (body)) =
2224 sir_swap_u16if_needed(
2225 auth_frame->authTransactionSeqNumber);
2226 body += sizeof(uint16_t);
2227 body_len -= sizeof(uint16_t);
2228
2229 *((uint16_t *) (body)) =
2230 sir_swap_u16if_needed(auth_frame->authStatusCode);
2231 body += sizeof(uint16_t);
2232 body_len -= sizeof(uint16_t);
2233 if (body_len <= (sizeof(auth_frame->type) +
2234 sizeof(auth_frame->length) +
2235 sizeof(auth_frame->challengeText)))
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302236 qdf_mem_copy(body, (uint8_t *) &auth_frame->type,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002237 body_len);
2238
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002239 if ((auth_frame->authAlgoNumber == eSIR_FT_AUTH) &&
2240 (auth_frame->authTransactionSeqNumber ==
2241 SIR_MAC_AUTH_FRAME_1) &&
2242 (session->ftPEContext.pFTPreAuthReq != NULL)) {
2243
2244 if (ft_ies_length > 0) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302245 qdf_mem_copy(body,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002246 session->ftPEContext.
2247 pFTPreAuthReq->ft_ies,
2248 ft_ies_length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002249 lim_log(mac_ctx, LOG2,
2250 FL("Auth1 Frame FTIE is: "));
2251 sir_dump_buf(mac_ctx, SIR_LIM_MODULE_ID, LOG2,
2252 (uint8_t *) body,
2253 ft_ies_length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002254 } else if (NULL != session->ftPEContext.
2255 pFTPreAuthReq->pbssDescription) {
2256 /* MDID attr is 54 */
2257 *body = SIR_MDIE_ELEMENT_ID;
2258 body++;
2259 *body = SIR_MDIE_SIZE;
2260 body++;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302261 qdf_mem_copy(body,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002262 &session->ftPEContext.pFTPreAuthReq->
2263 pbssDescription->mdie[0],
2264 SIR_MDIE_SIZE);
2265 }
2266 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002267
2268 lim_log(mac_ctx, LOG1,
2269 FL("*** Sending Auth seq# %d status %d (%d) to "
2270 MAC_ADDRESS_STR),
2271 auth_frame->authTransactionSeqNumber,
2272 auth_frame->authStatusCode,
2273 (auth_frame->authStatusCode ==
2274 eSIR_MAC_SUCCESS_STATUS),
2275 MAC_ADDR_ARRAY(mac_hdr->da));
2276 }
2277 sir_dump_buf(mac_ctx, SIR_LIM_MODULE_ID, LOG2, frame, frame_len);
2278
Deepthi Gowri1de51e32016-09-01 15:47:28 +05302279 if ((NULL != session->ftPEContext.pFTPreAuthReq) &&
2280 (SIR_BAND_5_GHZ == lim_get_rf_band(
2281 session->ftPEContext.pFTPreAuthReq->preAuthchannelNum)))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002282 tx_flag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
Deepthi Gowri1de51e32016-09-01 15:47:28 +05302283 else if ((SIR_BAND_5_GHZ ==
2284 lim_get_rf_band(session->currentOperChannel))
2285 || (session->pePersona == QDF_P2P_CLIENT_MODE)
2286 || (session->pePersona == QDF_P2P_GO_MODE))
2287 tx_flag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002288
Anurag Chouhan6d760662016-02-20 16:05:43 +05302289 if (session->pePersona == QDF_P2P_CLIENT_MODE ||
2290 session->pePersona == QDF_STA_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002291 tx_flag |= HAL_USE_PEER_STA_REQUESTED_MASK;
2292
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302293 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002294 session->peSessionId, mac_hdr->fc.subType));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002295
Abhishek Singh7d3bc3e2016-02-03 17:45:01 +05302296 if (wait_for_ack) {
2297 mac_ctx->auth_ack_status = LIM_AUTH_ACK_NOT_RCD;
2298 qdf_status = wma_tx_frameWithTxComplete(mac_ctx, packet,
2299 (uint16_t)frame_len,
2300 TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS,
2301 7, lim_tx_complete, frame,
2302 lim_auth_tx_complete_cnf,
2303 tx_flag, sme_sessionid, false, 0);
2304 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
2305 session->peSessionId, qdf_status));
2306 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
2307 lim_log(mac_ctx, LOGE,
2308 FL("*** Could not send Auth frame, retCode=%X ***"),
2309 qdf_status);
2310 mac_ctx->auth_ack_status = LIM_AUTH_ACK_RCD_FAILURE;
2311 /* Pkt will be freed up by the callback */
2312 }
2313 } else {
2314 /* Queue Authentication frame in high priority WQ */
2315 qdf_status = wma_tx_frame(mac_ctx, packet, (uint16_t) frame_len,
2316 TXRX_FRM_802_11_MGMT,
2317 ANI_TXDIR_TODS, 7, lim_tx_complete,
2318 frame, tx_flag, sme_sessionid, 0);
2319 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
2320 session->peSessionId, qdf_status));
2321 if (!QDF_IS_STATUS_SUCCESS(qdf_status))
2322 lim_log(mac_ctx, LOGE,
2323 FL("*** Could not send Auth frame, retCode=%X ***"),
2324 qdf_status);
2325 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002326 return;
2327}
2328
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302329QDF_STATUS lim_send_deauth_cnf(tpAniSirGlobal pMac)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002330{
2331 uint16_t aid;
2332 tpDphHashNode pStaDs;
2333 tLimMlmDeauthReq *pMlmDeauthReq;
2334 tLimMlmDeauthCnf mlmDeauthCnf;
2335 tpPESession psessionEntry;
2336
2337 pMlmDeauthReq = pMac->lim.limDisassocDeauthCnfReq.pMlmDeauthReq;
2338 if (pMlmDeauthReq) {
2339 if (tx_timer_running(&pMac->lim.limTimers.gLimDeauthAckTimer)) {
2340 lim_deactivate_and_change_timer(pMac,
2341 eLIM_DEAUTH_ACK_TIMER);
2342 }
2343
2344 psessionEntry = pe_find_session_by_session_id(pMac,
2345 pMlmDeauthReq->sessionId);
2346 if (psessionEntry == NULL) {
2347 PELOGE(lim_log(pMac, LOGE,
2348 FL
2349 ("session does not exist for given sessionId"));
2350 )
2351 mlmDeauthCnf.resultCode =
2352 eSIR_SME_INVALID_PARAMETERS;
2353 goto end;
2354 }
2355
2356 pStaDs =
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002357 dph_lookup_hash_entry(pMac,
2358 pMlmDeauthReq->peer_macaddr.bytes,
2359 &aid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002360 &psessionEntry->dph.dphHashTable);
2361 if (pStaDs == NULL) {
2362 mlmDeauthCnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
2363 goto end;
2364 }
2365
2366 /* / Receive path cleanup with dummy packet */
2367 lim_ft_cleanup_pre_auth_info(pMac, psessionEntry);
2368 lim_cleanup_rx_path(pMac, pStaDs, psessionEntry);
Deepak Dhamdhere262d95a2016-01-10 16:36:53 -08002369 if ((psessionEntry->limSystemRole == eLIM_STA_ROLE) &&
2370 (
Abhishek Singhe0680852015-12-16 14:28:48 +05302371#ifdef FEATURE_WLAN_ESE
Deepak Dhamdhere262d95a2016-01-10 16:36:53 -08002372 (psessionEntry->isESEconnection) ||
Abhishek Singhe0680852015-12-16 14:28:48 +05302373#endif
Deepak Dhamdhere262d95a2016-01-10 16:36:53 -08002374 (psessionEntry->isFastRoamIniFeatureEnabled) ||
2375 (psessionEntry->is11Rconnection))) {
2376 lim_log(pMac, LOGE,
2377 FL("FT Preauth (%p,%d) Deauth rc %d src = %d"),
2378 psessionEntry,
2379 psessionEntry->peSessionId,
2380 pMlmDeauthReq->reasonCode,
2381 pMlmDeauthReq->deauthTrigger);
2382 lim_ft_cleanup(pMac, psessionEntry);
2383 } else {
2384 lim_log(pMac, LOGE,
2385 FL("No FT Preauth Session Cleanup in role %d"
2386#ifdef FEATURE_WLAN_ESE
2387 " isESE %d"
2388#endif
2389 " isLFR %d"
2390 " is11r %d, Deauth reason %d Trigger = %d"),
2391 psessionEntry->limSystemRole,
2392#ifdef FEATURE_WLAN_ESE
2393 psessionEntry->isESEconnection,
2394#endif
2395 psessionEntry->isFastRoamIniFeatureEnabled,
2396 psessionEntry->is11Rconnection,
Abhishek Singhe0680852015-12-16 14:28:48 +05302397 pMlmDeauthReq->reasonCode,
Deepak Dhamdhere262d95a2016-01-10 16:36:53 -08002398 pMlmDeauthReq->deauthTrigger);
2399 }
2400 /* Free up buffer allocated for mlmDeauthReq */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302401 qdf_mem_free(pMlmDeauthReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002402 pMac->lim.limDisassocDeauthCnfReq.pMlmDeauthReq = NULL;
2403 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302404 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002405end:
Anurag Chouhanc5548422016-02-24 18:33:27 +05302406 qdf_copy_macaddr(&mlmDeauthCnf.peer_macaddr,
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002407 &pMlmDeauthReq->peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002408 mlmDeauthCnf.deauthTrigger = pMlmDeauthReq->deauthTrigger;
2409 mlmDeauthCnf.aid = pMlmDeauthReq->aid;
2410 mlmDeauthCnf.sessionId = pMlmDeauthReq->sessionId;
2411
2412 /* Free up buffer allocated */
2413 /* for mlmDeauthReq */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302414 qdf_mem_free(pMlmDeauthReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002415
2416 lim_post_sme_message(pMac,
2417 LIM_MLM_DEAUTH_CNF, (uint32_t *) &mlmDeauthCnf);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302418 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002419}
2420
2421/**
2422 * lim_send_disassoc_cnf() - Send disassoc confirmation to SME
2423 *
2424 * @mac_ctx: Handle to MAC context
2425 *
2426 * Sends disassoc confirmation to SME. Removes disassoc request stored
2427 * in lim.
2428 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302429 * Return: QDF_STATUS_SUCCESS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002430 */
2431
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302432QDF_STATUS lim_send_disassoc_cnf(tpAniSirGlobal mac_ctx)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002433{
2434 uint16_t aid;
2435 tpDphHashNode sta_ds;
2436 tLimMlmDisassocCnf disassoc_cnf;
2437 tpPESession pe_session;
2438 tLimMlmDisassocReq *disassoc_req;
2439
2440 disassoc_req = mac_ctx->lim.limDisassocDeauthCnfReq.pMlmDisassocReq;
2441 if (disassoc_req) {
2442 if (tx_timer_running(
2443 &mac_ctx->lim.limTimers.gLimDisassocAckTimer))
2444 lim_deactivate_and_change_timer(mac_ctx,
2445 eLIM_DISASSOC_ACK_TIMER);
2446
2447 pe_session = pe_find_session_by_session_id(
2448 mac_ctx, disassoc_req->sessionId);
2449 if (pe_session == NULL) {
2450 lim_log(mac_ctx, LOGE,
2451 FL("No session for given sessionId"));
2452 disassoc_cnf.resultCode =
2453 eSIR_SME_INVALID_PARAMETERS;
2454 goto end;
2455 }
2456
2457 sta_ds = dph_lookup_hash_entry(mac_ctx,
Srinivas Girigowdadd3c5132016-01-05 19:41:27 -08002458 disassoc_req->peer_macaddr.bytes, &aid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002459 &pe_session->dph.dphHashTable);
2460 if (sta_ds == NULL) {
2461 lim_log(mac_ctx, LOGE, FL("StaDs Null"));
2462 disassoc_cnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
2463 goto end;
2464 }
2465 /* Receive path cleanup with dummy packet */
2466 if (eSIR_SUCCESS !=
2467 lim_cleanup_rx_path(mac_ctx, sta_ds, pe_session)) {
2468 disassoc_cnf.resultCode =
2469 eSIR_SME_RESOURCES_UNAVAILABLE;
2470 lim_log(mac_ctx, LOGE, FL("cleanup_rx_path error"));
2471 goto end;
2472 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002473 if (LIM_IS_STA_ROLE(pe_session) && (
2474#ifdef FEATURE_WLAN_ESE
2475 (pe_session->isESEconnection) ||
2476#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002477 (pe_session->isFastRoamIniFeatureEnabled) ||
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002478 (pe_session->is11Rconnection)) &&
2479 (disassoc_req->reasonCode !=
2480 eSIR_MAC_DISASSOC_DUE_TO_FTHANDOFF_REASON)) {
Srinivas Girigowdaf2599dd2015-11-16 18:20:46 -08002481 lim_log(mac_ctx, LOG1,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002482 FL("FT Preauth Session (%p,%d) Clean up"),
2483 pe_session, pe_session->peSessionId);
2484
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002485 /* Delete FT session if there exists one */
2486 lim_ft_cleanup_pre_auth_info(mac_ctx, pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002487 } else {
2488 lim_log(mac_ctx, LOGE,
2489 FL("No FT Preauth Session Clean up in role %d"
2490#ifdef FEATURE_WLAN_ESE
2491 " isESE %d"
2492#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002493 " isLFR %d"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002494 " is11r %d reason %d"),
2495 GET_LIM_SYSTEM_ROLE(pe_session),
2496#ifdef FEATURE_WLAN_ESE
2497 pe_session->isESEconnection,
2498#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002499 pe_session->isFastRoamIniFeatureEnabled,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002500 pe_session->is11Rconnection,
2501 disassoc_req->reasonCode);
2502 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002503 /* Free up buffer allocated for mlmDisassocReq */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302504 qdf_mem_free(disassoc_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002505 mac_ctx->lim.limDisassocDeauthCnfReq.pMlmDisassocReq = NULL;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302506 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002507 } else {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302508 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002509 }
2510end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302511 qdf_mem_copy((uint8_t *) &disassoc_cnf.peerMacAddr,
Srinivas Girigowdadd3c5132016-01-05 19:41:27 -08002512 (uint8_t *) disassoc_req->peer_macaddr.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05302513 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002514 disassoc_cnf.aid = disassoc_req->aid;
2515 disassoc_cnf.disassocTrigger = disassoc_req->disassocTrigger;
2516
2517 /* Update PE session ID */
2518 disassoc_cnf.sessionId = disassoc_req->sessionId;
2519
2520 if (disassoc_req != NULL) {
2521 /* / Free up buffer allocated for mlmDisassocReq */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302522 qdf_mem_free(disassoc_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002523 mac_ctx->lim.limDisassocDeauthCnfReq.pMlmDisassocReq = NULL;
2524 }
2525
2526 lim_post_sme_message(mac_ctx, LIM_MLM_DISASSOC_CNF,
2527 (uint32_t *) &disassoc_cnf);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302528 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002529}
2530
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302531QDF_STATUS lim_disassoc_tx_complete_cnf(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002532 uint32_t txCompleteSuccess)
2533{
Mahesh A Saptasagarfb335422016-07-21 18:32:51 +05302534 lim_log(pMac, LOG1,
2535 FL("txCompleteSuccess: %d"), txCompleteSuccess);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002536 return lim_send_disassoc_cnf(pMac);
2537}
2538
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302539QDF_STATUS lim_deauth_tx_complete_cnf(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002540 uint32_t txCompleteSuccess)
2541{
Mahesh A Saptasagarfb335422016-07-21 18:32:51 +05302542 lim_log(pMac, LOG1,
2543 FL("txCompleteSuccess: %d"), txCompleteSuccess);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002544 return lim_send_deauth_cnf(pMac);
2545}
2546
2547/**
2548 * \brief This function is called to send Disassociate frame.
2549 *
2550 *
2551 * \param pMac Pointer to Global MAC structure
2552 *
2553 * \param nReason Indicates the reason that need to be sent in
2554 * Disassociation frame
2555 *
2556 * \param peerMacAddr MAC address of the STA to which Disassociation frame is
2557 * sent
2558 *
2559 *
2560 */
2561
2562void
2563lim_send_disassoc_mgmt_frame(tpAniSirGlobal pMac,
2564 uint16_t nReason,
2565 tSirMacAddr peer,
2566 tpPESession psessionEntry, bool waitForAck)
2567{
2568 tDot11fDisassociation frm;
2569 uint8_t *pFrame;
2570 tpSirMacMgmtHdr pMacHdr;
2571 uint32_t nBytes, nPayload, nStatus;
2572 void *pPacket;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302573 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002574 uint8_t txFlag = 0;
2575 uint32_t val = 0;
2576 uint8_t smeSessionId = 0;
2577 if (NULL == psessionEntry) {
2578 return;
2579 }
2580
2581 /*
2582 * In case when cac timer is running for this SAP session then
2583 * avoid sending disassoc out. It is violation of dfs specification.
2584 */
Anurag Chouhan6d760662016-02-20 16:05:43 +05302585 if (((psessionEntry->pePersona == QDF_SAP_MODE) ||
2586 (psessionEntry->pePersona == QDF_P2P_GO_MODE)) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002587 (true == pMac->sap.SapDfsInfo.is_dfs_cac_timer_running)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302588 QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_INFO,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002589 FL
2590 ("CAC timer is running, drop disassoc from going out"));
2591 return;
2592 }
2593 smeSessionId = psessionEntry->smeSessionId;
2594
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302595 qdf_mem_set((uint8_t *) &frm, sizeof(frm), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002596
2597 frm.Reason.code = nReason;
2598
2599 nStatus = dot11f_get_packed_disassociation_size(pMac, &frm, &nPayload);
2600 if (DOT11F_FAILED(nStatus)) {
2601 lim_log(pMac, LOGP, FL("Failed to calculate the packed size f"
2602 "or a Disassociation (0x%08x)."),
2603 nStatus);
2604 /* We'll fall back on the worst case scenario: */
2605 nPayload = sizeof(tDot11fDisassociation);
2606 } else if (DOT11F_WARNED(nStatus)) {
2607 lim_log(pMac, LOGW, FL("There were warnings while calculating "
2608 "the packed size for a Disassociation "
2609 "(0x%08x)."), nStatus);
2610 }
2611
2612 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
2613
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302614 qdf_status = cds_packet_alloc((uint16_t) nBytes, (void **)&pFrame,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002615 (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302616 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002617 lim_log(pMac, LOGP, FL("Failed to allocate %d bytes for a Dis"
2618 "association."), nBytes);
2619 return;
2620 }
2621 /* Paranoia: */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302622 qdf_mem_set(pFrame, nBytes, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002623
2624 /* Next, we fill out the buffer descriptor: */
2625 lim_populate_mac_header(pMac, pFrame, SIR_MAC_MGMT_FRAME,
2626 SIR_MAC_MGMT_DISASSOC, peer, psessionEntry->selfMacAddr);
2627 pMacHdr = (tpSirMacMgmtHdr) pFrame;
2628
2629 /* Prepare the BSSID */
2630 sir_copy_mac_addr(pMacHdr->bssId, psessionEntry->bssId);
2631
2632#ifdef WLAN_FEATURE_11W
2633 lim_set_protected_bit(pMac, psessionEntry, peer, pMacHdr);
2634#endif
2635
2636 nStatus = dot11f_pack_disassociation(pMac, &frm, pFrame +
2637 sizeof(tSirMacMgmtHdr),
2638 nPayload, &nPayload);
2639 if (DOT11F_FAILED(nStatus)) {
2640 lim_log(pMac, LOGE,
2641 FL("Failed to pack a Disassociation (0x%08x)."),
2642 nStatus);
2643 cds_packet_free((void *)pPacket);
2644 return; /* allocated! */
2645 } else if (DOT11F_WARNED(nStatus)) {
2646 lim_log(pMac, LOGW, FL("There were warnings while packing a D"
2647 "isassociation (0x%08x)."), nStatus);
2648 }
2649
2650 lim_log(pMac, LOG1,
2651 FL("***Sessionid %d Sending Disassociation frame with "
2652 "reason %u and waitForAck %d to " MAC_ADDRESS_STR " ,From "
2653 MAC_ADDRESS_STR), psessionEntry->peSessionId, nReason,
2654 waitForAck, MAC_ADDR_ARRAY(pMacHdr->da),
2655 MAC_ADDR_ARRAY(psessionEntry->selfMacAddr));
2656
2657 if ((SIR_BAND_5_GHZ == lim_get_rf_band(psessionEntry->currentOperChannel))
Anurag Chouhan6d760662016-02-20 16:05:43 +05302658 || (psessionEntry->pePersona == QDF_P2P_CLIENT_MODE) ||
2659 (psessionEntry->pePersona == QDF_P2P_GO_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002660 ) {
2661 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
2662 }
2663
Sushant Kaushik46556062015-12-02 16:57:47 +05302664 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002665
2666 if (waitForAck) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302667 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002668 psessionEntry->peSessionId,
2669 pMacHdr->fc.subType));
2670 /* Queue Disassociation frame in high priority WQ */
2671 /* get the duration from the request */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302672 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002673 wma_tx_frameWithTxComplete(pMac, pPacket, (uint16_t) nBytes,
2674 TXRX_FRM_802_11_MGMT,
2675 ANI_TXDIR_TODS, 7, lim_tx_complete,
2676 pFrame, lim_disassoc_tx_complete_cnf,
2677 txFlag, smeSessionId, false, 0);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302678 MTRACE(qdf_trace
Anurag Chouhan6d760662016-02-20 16:05:43 +05302679 (QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302680 psessionEntry->peSessionId, qdf_status));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002681
2682 val = SYS_MS_TO_TICKS(LIM_DISASSOC_DEAUTH_ACK_TIMEOUT);
2683
2684 if (tx_timer_change
2685 (&pMac->lim.limTimers.gLimDisassocAckTimer, val, 0)
2686 != TX_SUCCESS) {
2687 lim_log(pMac, LOGP,
2688 FL("Unable to change Disassoc ack Timer val"));
2689 return;
2690 } else if (TX_SUCCESS !=
2691 tx_timer_activate(&pMac->lim.limTimers.
2692 gLimDisassocAckTimer)) {
2693 lim_log(pMac, LOGP,
2694 FL("Unable to activate Disassoc ack Timer"));
2695 lim_deactivate_and_change_timer(pMac,
2696 eLIM_DISASSOC_ACK_TIMER);
2697 return;
2698 }
2699 } else {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302700 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002701 psessionEntry->peSessionId,
2702 pMacHdr->fc.subType));
2703 /* Queue Disassociation frame in high priority WQ */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302704 qdf_status = wma_tx_frame(pMac, pPacket, (uint16_t) nBytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002705 TXRX_FRM_802_11_MGMT,
2706 ANI_TXDIR_TODS,
2707 7,
2708 lim_tx_complete, pFrame, txFlag,
2709 smeSessionId, 0);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302710 MTRACE(qdf_trace
Anurag Chouhan6d760662016-02-20 16:05:43 +05302711 (QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302712 psessionEntry->peSessionId, qdf_status));
2713 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002714 lim_log(pMac, LOGE,
2715 FL("Failed to send Disassociation (%X)!"),
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302716 qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002717 /* Pkt will be freed up by the callback */
2718 }
2719 }
2720} /* End lim_send_disassoc_mgmt_frame. */
2721
2722/**
2723 * \brief This function is called to send a Deauthenticate frame
2724 *
2725 *
2726 * \param pMac Pointer to global MAC structure
2727 *
2728 * \param nReason Indicates the reason that need to be sent in the
2729 * Deauthenticate frame
2730 *
2731 * \param peeer address of the STA to which the frame is to be sent
2732 *
2733 *
2734 */
2735
2736void
2737lim_send_deauth_mgmt_frame(tpAniSirGlobal pMac,
2738 uint16_t nReason,
2739 tSirMacAddr peer,
2740 tpPESession psessionEntry, bool waitForAck)
2741{
2742 tDot11fDeAuth frm;
2743 uint8_t *pFrame;
2744 tpSirMacMgmtHdr pMacHdr;
2745 uint32_t nBytes, nPayload, nStatus;
2746 void *pPacket;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302747 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002748 uint8_t txFlag = 0;
2749 uint32_t val = 0;
2750#ifdef FEATURE_WLAN_TDLS
2751 uint16_t aid;
2752 tpDphHashNode pStaDs;
2753#endif
2754 uint8_t smeSessionId = 0;
2755
2756 if (NULL == psessionEntry) {
2757 return;
2758 }
2759
2760 /*
2761 * In case when cac timer is running for this SAP session then
2762 * avoid deauth frame out. It is violation of dfs specification.
2763 */
Anurag Chouhan6d760662016-02-20 16:05:43 +05302764 if (((psessionEntry->pePersona == QDF_SAP_MODE) ||
2765 (psessionEntry->pePersona == QDF_P2P_GO_MODE)) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002766 (true == pMac->sap.SapDfsInfo.is_dfs_cac_timer_running)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302767 QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_INFO,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002768 FL
2769 ("CAC timer is running, drop the deauth from going out"));
2770 return;
2771 }
2772 smeSessionId = psessionEntry->smeSessionId;
2773
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302774 qdf_mem_set((uint8_t *) &frm, sizeof(frm), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002775
2776 frm.Reason.code = nReason;
2777
2778 nStatus = dot11f_get_packed_de_auth_size(pMac, &frm, &nPayload);
2779 if (DOT11F_FAILED(nStatus)) {
2780 lim_log(pMac, LOGP, FL("Failed to calculate the packed size f"
2781 "or a De-Authentication (0x%08x)."),
2782 nStatus);
2783 /* We'll fall back on the worst case scenario: */
2784 nPayload = sizeof(tDot11fDeAuth);
2785 } else if (DOT11F_WARNED(nStatus)) {
2786 lim_log(pMac, LOGW, FL("There were warnings while calculating "
2787 "the packed size for a De-Authentication "
2788 "(0x%08x)."), nStatus);
2789 }
2790
2791 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
2792
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302793 qdf_status = cds_packet_alloc((uint16_t) nBytes, (void **)&pFrame,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002794 (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302795 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002796 lim_log(pMac, LOGP, FL("Failed to allocate %d bytes for a De-"
2797 "Authentication."), nBytes);
2798 return;
2799 }
2800 /* Paranoia: */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302801 qdf_mem_set(pFrame, nBytes, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002802
2803 /* Next, we fill out the buffer descriptor: */
2804 lim_populate_mac_header(pMac, pFrame, SIR_MAC_MGMT_FRAME,
2805 SIR_MAC_MGMT_DEAUTH, peer, psessionEntry->selfMacAddr);
2806 pMacHdr = (tpSirMacMgmtHdr) pFrame;
2807
2808 /* Prepare the BSSID */
2809 sir_copy_mac_addr(pMacHdr->bssId, psessionEntry->bssId);
2810
2811#ifdef WLAN_FEATURE_11W
2812 lim_set_protected_bit(pMac, psessionEntry, peer, pMacHdr);
2813#endif
2814
2815 nStatus = dot11f_pack_de_auth(pMac, &frm, pFrame +
2816 sizeof(tSirMacMgmtHdr), nPayload, &nPayload);
2817 if (DOT11F_FAILED(nStatus)) {
2818 lim_log(pMac, LOGE,
2819 FL("Failed to pack a DeAuthentication (0x%08x)."),
2820 nStatus);
2821 cds_packet_free((void *)pPacket);
2822 return;
2823 } else if (DOT11F_WARNED(nStatus)) {
2824 lim_log(pMac, LOGW, FL("There were warnings while packing a D"
2825 "e-Authentication (0x%08x)."), nStatus);
2826 }
2827 lim_log(pMac, LOG1, FL("***Sessionid %d Sending Deauth frame with "
2828 "reason %u and waitForAck %d to " MAC_ADDRESS_STR
2829 " ,From " MAC_ADDRESS_STR),
2830 psessionEntry->peSessionId, nReason, waitForAck,
2831 MAC_ADDR_ARRAY(pMacHdr->da),
2832 MAC_ADDR_ARRAY(psessionEntry->selfMacAddr));
2833
2834 if ((SIR_BAND_5_GHZ == lim_get_rf_band(psessionEntry->currentOperChannel))
Anurag Chouhan6d760662016-02-20 16:05:43 +05302835 || (psessionEntry->pePersona == QDF_P2P_CLIENT_MODE) ||
2836 (psessionEntry->pePersona == QDF_P2P_GO_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002837 ) {
2838 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
2839 }
2840
Sushant Kaushik46556062015-12-02 16:57:47 +05302841 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002842#ifdef FEATURE_WLAN_TDLS
2843 pStaDs =
2844 dph_lookup_hash_entry(pMac, peer, &aid,
2845 &psessionEntry->dph.dphHashTable);
2846#endif
2847
2848 if (waitForAck) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302849 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002850 psessionEntry->peSessionId,
2851 pMacHdr->fc.subType));
2852 /* Queue Disassociation frame in high priority WQ */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302853 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002854 wma_tx_frameWithTxComplete(pMac, pPacket, (uint16_t) nBytes,
2855 TXRX_FRM_802_11_MGMT,
2856 ANI_TXDIR_TODS, 7, lim_tx_complete,
2857 pFrame, lim_deauth_tx_complete_cnf,
2858 txFlag, smeSessionId, false, 0);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302859 MTRACE(qdf_trace
Anurag Chouhan6d760662016-02-20 16:05:43 +05302860 (QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302861 psessionEntry->peSessionId, qdf_status));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002862 /* Pkt will be freed up by the callback lim_tx_complete */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302863 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002864 lim_log(pMac, LOGE,
2865 FL("Failed to send De-Authentication (%X)!"),
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302866 qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002867
2868 /* Call lim_process_deauth_ack_timeout which will send
2869 * DeauthCnf for this frame
2870 */
2871 lim_process_deauth_ack_timeout(pMac);
2872 return;
2873 }
2874
2875 val = SYS_MS_TO_TICKS(LIM_DISASSOC_DEAUTH_ACK_TIMEOUT);
2876
2877 if (tx_timer_change
2878 (&pMac->lim.limTimers.gLimDeauthAckTimer, val, 0)
2879 != TX_SUCCESS) {
2880 lim_log(pMac, LOGP,
2881 FL("Unable to change Deauth ack Timer val"));
2882 return;
2883 } else if (TX_SUCCESS !=
2884 tx_timer_activate(&pMac->lim.limTimers.
2885 gLimDeauthAckTimer)) {
2886 lim_log(pMac, LOGP,
2887 FL("Unable to activate Deauth ack Timer"));
2888 lim_deactivate_and_change_timer(pMac,
2889 eLIM_DEAUTH_ACK_TIMER);
2890 return;
2891 }
2892 } else {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302893 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002894 psessionEntry->peSessionId,
2895 pMacHdr->fc.subType));
2896#ifdef FEATURE_WLAN_TDLS
2897 if ((NULL != pStaDs)
2898 && (STA_ENTRY_TDLS_PEER == pStaDs->staType)) {
2899 /* Queue Disassociation frame in high priority WQ */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302900 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002901 wma_tx_frame(pMac, pPacket, (uint16_t) nBytes,
2902 TXRX_FRM_802_11_MGMT, ANI_TXDIR_IBSS,
2903 7, lim_tx_complete, pFrame, txFlag,
2904 smeSessionId, 0);
2905 } else {
2906#endif
2907 /* Queue Disassociation frame in high priority WQ */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302908 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002909 wma_tx_frame(pMac, pPacket, (uint16_t) nBytes,
2910 TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS,
2911 7, lim_tx_complete, pFrame, txFlag,
2912 smeSessionId, 0);
2913#ifdef FEATURE_WLAN_TDLS
2914 }
2915#endif
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302916 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302917 psessionEntry->peSessionId, qdf_status));
2918 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002919 lim_log(pMac, LOGE,
2920 FL("Failed to send De-Authentication (%X)!"),
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302921 qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002922 /* Pkt will be freed up by the callback */
2923 }
2924 }
2925
2926} /* End lim_send_deauth_mgmt_frame. */
2927
2928#ifdef ANI_SUPPORT_11H
2929/**
2930 * \brief Send a Measurement Report Action frame
2931 *
2932 *
2933 * \param pMac Pointer to the global MAC structure
2934 *
2935 * \param pMeasReqFrame Address of a tSirMacMeasReqActionFrame
2936 *
2937 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
2938 *
2939 *
2940 */
2941
2942tSirRetStatus
2943lim_send_meas_report_frame(tpAniSirGlobal pMac,
2944 tpSirMacMeasReqActionFrame pMeasReqFrame,
2945 tSirMacAddr peer, tpPESession psessionEntry)
2946{
2947 tDot11fMeasurementReport frm;
2948 uint8_t *pFrame;
2949 tSirRetStatus nSirStatus;
2950 tpSirMacMgmtHdr pMacHdr;
2951 uint32_t nBytes, nPayload, nStatus;
2952 void *pPacket;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302953 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002954
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302955 qdf_mem_set((uint8_t *) &frm, sizeof(frm), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002956
2957 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
2958 frm.Action.action = SIR_MAC_ACTION_MEASURE_REPORT_ID;
2959 frm.DialogToken.token = pMeasReqFrame->actionHeader.dialogToken;
2960
2961 switch (pMeasReqFrame->measReqIE.measType) {
2962 case SIR_MAC_BASIC_MEASUREMENT_TYPE:
2963 nSirStatus =
2964 populate_dot11f_measurement_report0(pMac, pMeasReqFrame,
2965 &frm.MeasurementReport);
2966 break;
2967 case SIR_MAC_CCA_MEASUREMENT_TYPE:
2968 nSirStatus =
2969 populate_dot11f_measurement_report1(pMac, pMeasReqFrame,
2970 &frm.MeasurementReport);
2971 break;
2972 case SIR_MAC_RPI_MEASUREMENT_TYPE:
2973 nSirStatus =
2974 populate_dot11f_measurement_report2(pMac, pMeasReqFrame,
2975 &frm.MeasurementReport);
2976 break;
2977 default:
2978 lim_log(pMac, LOGE, FL("Unknown measurement type %d in limSen"
2979 "dMeasReportFrame."),
2980 pMeasReqFrame->measReqIE.measType);
2981 return eSIR_FAILURE;
2982 }
2983
2984 if (eSIR_SUCCESS != nSirStatus)
2985 return eSIR_FAILURE;
2986
2987 nStatus = dot11f_get_packed_measurement_report_size(pMac, &frm, &nPayload);
2988 if (DOT11F_FAILED(nStatus)) {
2989 lim_log(pMac, LOGP, FL("Failed to calculate the packed size f"
2990 "or a Measurement Report (0x%08x)."),
2991 nStatus);
2992 /* We'll fall back on the worst case scenario: */
2993 nPayload = sizeof(tDot11fMeasurementReport);
2994 } else if (DOT11F_WARNED(nStatus)) {
2995 lim_log(pMac, LOGW, FL("There were warnings while calculating "
2996 "the packed size for a Measurement Rep"
2997 "ort (0x%08x)."), nStatus);
2998 }
2999
3000 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
3001
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303002 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003003 cds_packet_alloc(pMac->hHdd, TXRX_FRM_802_11_MGMT,
3004 (uint16_t) nBytes, (void **)&pFrame,
3005 (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303006 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003007 lim_log(pMac, LOGP, FL("Failed to allocate %d bytes for a De-"
3008 "Authentication."), nBytes);
3009 return eSIR_FAILURE;
3010 }
3011 /* Paranoia: */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303012 qdf_mem_set(pFrame, nBytes, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003013
3014 /* Next, we fill out the buffer descriptor: */
3015 lim_populate_mac_header(pMac, pFrame, SIR_MAC_MGMT_FRAME,
3016 SIR_MAC_MGMT_ACTION, peer);
3017 pMacHdr = (tpSirMacMgmtHdr) pFrame;
3018
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303019 qdf_mem_copy(pMacHdr->bssId, psessionEntry->bssId, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003020
3021#ifdef WLAN_FEATURE_11W
3022 lim_set_protected_bit(pMac, psessionEntry, peer, pMacHdr);
3023#endif
3024
3025 nStatus = dot11f_pack_measurement_report(pMac, &frm, pFrame +
3026 sizeof(tSirMacMgmtHdr),
3027 nPayload, &nPayload);
3028 if (DOT11F_FAILED(nStatus)) {
3029 lim_log(pMac, LOGE,
3030 FL("Failed to pack a Measurement Report (0x%08x)."),
3031 nStatus);
3032 cds_packet_free(pMac->hHdd, TXRX_FRM_802_11_MGMT,
3033 (void *)pFrame, (void *)pPacket);
3034 return eSIR_FAILURE; /* allocated! */
3035 } else if (DOT11F_WARNED(nStatus)) {
3036 lim_log(pMac, LOGW, FL("There were warnings while packing a M"
3037 "easurement Report (0x%08x)."), nStatus);
3038 }
3039
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303040 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003041 ((psessionEntry) ? psessionEntry->
3042 peSessionId : NO_SESSION), pMacHdr->fc.subType));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303043 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003044 wma_tx_frame(pMac, pPacket, (uint16_t) nBytes,
3045 TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS, 7,
3046 lim_tx_complete, pFrame, 0, 0);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303047 MTRACE(qdf_trace
Anurag Chouhan6d760662016-02-20 16:05:43 +05303048 (QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003049 ((psessionEntry) ? psessionEntry->peSessionId : NO_SESSION),
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303050 qdf_status));
3051 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003052 lim_log(pMac, LOGE,
3053 FL("Failed to send a Measurement Report (%X)!"),
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303054 qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003055 /* Pkt will be freed up by the callback */
3056 return eSIR_FAILURE; /* just allocated... */
3057 }
3058
3059 return eSIR_SUCCESS;
3060
3061} /* End lim_send_meas_report_frame. */
3062
3063/**
3064 * \brief Send a TPC Request Action frame
3065 *
3066 *
3067 * \param pMac Pointer to the global MAC datastructure
3068 *
3069 * \param peer MAC address to which the frame should be sent
3070 *
3071 *
3072 */
3073
3074void
3075lim_send_tpc_request_frame(tpAniSirGlobal pMac,
3076 tSirMacAddr peer, tpPESession psessionEntry)
3077{
3078 tDot11fTPCRequest frm;
3079 uint8_t *pFrame;
3080 tpSirMacMgmtHdr pMacHdr;
3081 uint32_t nBytes, nPayload, nStatus;
3082 void *pPacket;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303083 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003084
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303085 qdf_mem_set((uint8_t *) &frm, sizeof(frm), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003086
3087 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
3088 frm.Action.action = SIR_MAC_ACTION_TPC_REQUEST_ID;
3089 frm.DialogToken.token = 1;
3090 frm.TPCRequest.present = 1;
3091
3092 nStatus = dot11f_get_packed_tpc_request_size(pMac, &frm, &nPayload);
3093 if (DOT11F_FAILED(nStatus)) {
3094 lim_log(pMac, LOGP, FL("Failed to calculate the packed size f"
3095 "or a TPC Request (0x%08x)."), nStatus);
3096 /* We'll fall back on the worst case scenario: */
3097 nPayload = sizeof(tDot11fTPCRequest);
3098 } else if (DOT11F_WARNED(nStatus)) {
3099 lim_log(pMac, LOGW, FL("There were warnings while calculating "
3100 "the packed size for a TPC Request (0x"
3101 "%08x)."), nStatus);
3102 }
3103
3104 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
3105
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303106 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003107 cds_packet_alloc(pMac->hHdd, TXRX_FRM_802_11_MGMT,
3108 (uint16_t) nBytes, (void **)&pFrame,
3109 (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303110 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003111 lim_log(pMac, LOGP, FL("Failed to allocate %d bytes for a TPC"
3112 " Request."), nBytes);
3113 return;
3114 }
3115 /* Paranoia: */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303116 qdf_mem_set(pFrame, nBytes, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003117
3118 /* Next, we fill out the buffer descriptor: */
3119 lim_populate_mac_header(pMac, pFrame, SIR_MAC_MGMT_FRAME,
3120 SIR_MAC_MGMT_ACTION, peer);
3121 pMacHdr = (tpSirMacMgmtHdr) pFrame;
3122
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303123 qdf_mem_copy(pMacHdr->bssId, psessionEntry->bssId, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003124
3125#ifdef WLAN_FEATURE_11W
3126 lim_set_protected_bit(pMac, psessionEntry, peer, pMacHdr);
3127#endif
3128
3129 nStatus = dot11f_pack_tpc_request(pMac, &frm, pFrame +
3130 sizeof(tSirMacMgmtHdr),
3131 nPayload, &nPayload);
3132 if (DOT11F_FAILED(nStatus)) {
3133 lim_log(pMac, LOGE, FL("Failed to pack a TPC Request (0x%08x)."),
3134 nStatus);
3135 cds_packet_free(pMac->hHdd, TXRX_FRM_802_11_MGMT,
3136 (void *)pFrame, (void *)pPacket);
3137 return; /* allocated! */
3138 } else if (DOT11F_WARNED(nStatus)) {
3139 lim_log(pMac, LOGW, FL("There were warnings while packing a T"
3140 "PC Request (0x%08x)."), nStatus);
3141 }
3142
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303143 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003144 ((psessionEntry) ? psessionEntry->
3145 peSessionId : NO_SESSION), pMacHdr->fc.subType));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303146 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003147 wma_tx_frame(pMac, pPacket, (uint16_t) nBytes,
3148 TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS, 7,
3149 lim_tx_complete, pFrame, 0, 0);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303150 MTRACE(qdf_trace
Anurag Chouhan6d760662016-02-20 16:05:43 +05303151 (QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003152 ((psessionEntry) ? psessionEntry->peSessionId : NO_SESSION),
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303153 qdf_status));
3154 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003155 lim_log(pMac, LOGE,
3156 FL("Failed to send a TPC Request (%X)!"),
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303157 qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003158 /* Pkt will be freed up by the callback */
3159 }
3160
3161} /* End lim_send_tpc_request_frame. */
3162
3163/**
3164 * \brief Send a TPC Report Action frame
3165 *
3166 *
3167 * \param pMac Pointer to the global MAC datastructure
3168 *
3169 * \param pTpcReqFrame Pointer to the received TPC Request
3170 *
3171 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
3172 *
3173 *
3174 */
3175
3176tSirRetStatus
3177lim_send_tpc_report_frame(tpAniSirGlobal pMac,
3178 tpSirMacTpcReqActionFrame pTpcReqFrame,
3179 tSirMacAddr peer, tpPESession psessionEntry)
3180{
3181 tDot11fTPCReport frm;
3182 uint8_t *pFrame;
3183 tpSirMacMgmtHdr pMacHdr;
3184 uint32_t nBytes, nPayload, nStatus;
3185 void *pPacket;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303186 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003187
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303188 qdf_mem_set((uint8_t *) &frm, sizeof(frm), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003189
3190 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
3191 frm.Action.action = SIR_MAC_ACTION_TPC_REPORT_ID;
3192 frm.DialogToken.token = pTpcReqFrame->actionHeader.dialogToken;
3193
3194 frm.TPCReport.tx_power = 0;
3195 frm.TPCReport.link_margin = 0;
3196 frm.TPCReport.present = 1;
3197
3198 nStatus = dot11f_get_packed_tpc_report_size(pMac, &frm, &nPayload);
3199 if (DOT11F_FAILED(nStatus)) {
3200 lim_log(pMac, LOGP, FL("Failed to calculate the packed size f"
3201 "or a TPC Report (0x%08x)."), nStatus);
3202 /* We'll fall back on the worst case scenario: */
3203 nPayload = sizeof(tDot11fTPCReport);
3204 } else if (DOT11F_WARNED(nStatus)) {
3205 lim_log(pMac, LOGW, FL("There were warnings while calculating "
3206 "the packed size for a TPC Report (0x"
3207 "%08x)."), nStatus);
3208 }
3209
3210 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
3211
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303212 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003213 cds_packet_alloc(pMac->hHdd, TXRX_FRM_802_11_MGMT,
3214 (uint16_t) nBytes, (void **)&pFrame,
3215 (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303216 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003217 lim_log(pMac, LOGP, FL("Failed to allocate %d bytes for a TPC"
3218 " Report."), nBytes);
3219 return eSIR_FAILURE;
3220 }
3221 /* Paranoia: */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303222 qdf_mem_set(pFrame, nBytes, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003223
3224 /* Next, we fill out the buffer descriptor: */
3225 lim_populate_mac_header(pMac, pFrame, SIR_MAC_MGMT_FRAME,
3226 SIR_MAC_MGMT_ACTION, peer);
3227
3228 pMacHdr = (tpSirMacMgmtHdr) pFrame;
3229
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303230 qdf_mem_copy(pMacHdr->bssId, psessionEntry->bssId, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003231
3232#ifdef WLAN_FEATURE_11W
3233 lim_set_protected_bit(pMac, psessionEntry, peer, pMacHdr);
3234#endif
3235
3236 nStatus = dot11f_pack_tpc_report(pMac, &frm, pFrame +
3237 sizeof(tSirMacMgmtHdr),
3238 nPayload, &nPayload);
3239 if (DOT11F_FAILED(nStatus)) {
3240 lim_log(pMac, LOGE, FL("Failed to pack a TPC Report (0x%08x)."),
3241 nStatus);
3242 cds_packet_free(pMac->hHdd, TXRX_FRM_802_11_MGMT,
3243 (void *)pFrame, (void *)pPacket);
3244 return eSIR_FAILURE; /* allocated! */
3245 } else if (DOT11F_WARNED(nStatus)) {
3246 lim_log(pMac, LOGW, FL("There were warnings while packing a T"
3247 "PC Report (0x%08x)."), nStatus);
3248 }
3249
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303250 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003251 ((psessionEntry) ? psessionEntry->
3252 peSessionId : NO_SESSION), pMacHdr->fc.subType));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303253 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003254 wma_tx_frame(pMac, pPacket, (uint16_t) nBytes,
3255 TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS, 7,
3256 lim_tx_complete, pFrame, 0, 0);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303257 MTRACE(qdf_trace
Anurag Chouhan6d760662016-02-20 16:05:43 +05303258 (QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003259 ((psessionEntry) ? psessionEntry->peSessionId : NO_SESSION),
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303260 qdf_status));
3261 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003262 lim_log(pMac, LOGE,
3263 FL("Failed to send a TPC Report (%X)!"),
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303264 qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003265 /* Pkt will be freed up by the callback */
3266 return eSIR_FAILURE; /* just allocated... */
3267 }
3268
3269 return eSIR_SUCCESS;
3270
3271} /* End lim_send_tpc_report_frame. */
3272#endif /* ANI_SUPPORT_11H */
3273
3274/**
3275 * \brief Send a Channel Switch Announcement
3276 *
3277 *
3278 * \param pMac Pointer to the global MAC datastructure
3279 *
3280 * \param peer MAC address to which this frame will be sent
3281 *
3282 * \param nMode
3283 *
3284 * \param nNewChannel
3285 *
3286 * \param nCount
3287 *
3288 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
3289 *
3290 *
3291 */
3292
3293tSirRetStatus
3294lim_send_channel_switch_mgmt_frame(tpAniSirGlobal pMac,
3295 tSirMacAddr peer,
3296 uint8_t nMode,
3297 uint8_t nNewChannel,
3298 uint8_t nCount, tpPESession psessionEntry)
3299{
3300 tDot11fChannelSwitch frm;
3301 uint8_t *pFrame;
3302 tpSirMacMgmtHdr pMacHdr;
3303 uint32_t nBytes, nPayload, nStatus; /* , nCfg; */
3304 void *pPacket;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303305 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003306 uint8_t txFlag = 0;
3307
3308 uint8_t smeSessionId = 0;
3309
3310 if (psessionEntry == NULL) {
3311 PELOGE(lim_log(pMac, LOGE, FL("Session entry is NULL!!!"));)
3312 return eSIR_FAILURE;
3313 }
3314 smeSessionId = psessionEntry->smeSessionId;
3315
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303316 qdf_mem_set((uint8_t *) &frm, sizeof(frm), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003317
3318 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
3319 frm.Action.action = SIR_MAC_ACTION_CHANNEL_SWITCH_ID;
3320 frm.ChanSwitchAnn.switchMode = nMode;
3321 frm.ChanSwitchAnn.newChannel = nNewChannel;
3322 frm.ChanSwitchAnn.switchCount = nCount;
3323 frm.ChanSwitchAnn.present = 1;
3324
3325 nStatus = dot11f_get_packed_channel_switch_size(pMac, &frm, &nPayload);
3326 if (DOT11F_FAILED(nStatus)) {
3327 lim_log(pMac, LOGP, FL("Failed to calculate the packed size f"
3328 "or a Channel Switch (0x%08x)."),
3329 nStatus);
3330 /* We'll fall back on the worst case scenario: */
3331 nPayload = sizeof(tDot11fChannelSwitch);
3332 } else if (DOT11F_WARNED(nStatus)) {
3333 lim_log(pMac, LOGW, FL("There were warnings while calculating "
3334 "the packed size for a Channel Switch (0x"
3335 "%08x)."), nStatus);
3336 }
3337
3338 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
3339
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303340 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003341 cds_packet_alloc((uint16_t) nBytes, (void **)&pFrame,
3342 (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303343 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003344 lim_log(pMac, LOGP, FL("Failed to allocate %d bytes for a TPC"
3345 " Report."), nBytes);
3346 return eSIR_FAILURE;
3347 }
3348 /* Paranoia: */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303349 qdf_mem_set(pFrame, nBytes, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003350
3351 /* Next, we fill out the buffer descriptor: */
3352 lim_populate_mac_header(pMac, pFrame, SIR_MAC_MGMT_FRAME,
3353 SIR_MAC_MGMT_ACTION, peer,
3354 psessionEntry->selfMacAddr);
3355 pMacHdr = (tpSirMacMgmtHdr) pFrame;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303356 qdf_mem_copy((uint8_t *) pMacHdr->bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003357 (uint8_t *) psessionEntry->bssId, sizeof(tSirMacAddr));
3358
3359#ifdef WLAN_FEATURE_11W
3360 lim_set_protected_bit(pMac, psessionEntry, peer, pMacHdr);
3361#endif
3362
3363 nStatus = dot11f_pack_channel_switch(pMac, &frm, pFrame +
3364 sizeof(tSirMacMgmtHdr),
3365 nPayload, &nPayload);
3366 if (DOT11F_FAILED(nStatus)) {
3367 lim_log(pMac, LOGE,
3368 FL("Failed to pack a Channel Switch (0x%08x)."),
3369 nStatus);
3370 cds_packet_free((void *)pPacket);
3371 return eSIR_FAILURE; /* allocated! */
3372 } else if (DOT11F_WARNED(nStatus)) {
3373 lim_log(pMac, LOGW, FL("There were warnings while packing a C"
3374 "hannel Switch (0x%08x)."), nStatus);
3375 }
3376
3377 if ((SIR_BAND_5_GHZ == lim_get_rf_band(psessionEntry->currentOperChannel))
Anurag Chouhan6d760662016-02-20 16:05:43 +05303378 || (psessionEntry->pePersona == QDF_P2P_CLIENT_MODE) ||
3379 (psessionEntry->pePersona == QDF_P2P_GO_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003380 ) {
3381 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
3382 }
3383
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303384 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003385 psessionEntry->peSessionId, pMacHdr->fc.subType));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303386 qdf_status = wma_tx_frame(pMac, pPacket, (uint16_t) nBytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003387 TXRX_FRM_802_11_MGMT,
3388 ANI_TXDIR_TODS,
3389 7, lim_tx_complete, pFrame, txFlag,
3390 smeSessionId, 0);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303391 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303392 psessionEntry->peSessionId, qdf_status));
3393 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003394 lim_log(pMac, LOGE,
3395 FL("Failed to send a Channel Switch (%X)!"),
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303396 qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003397 /* Pkt will be freed up by the callback */
3398 return eSIR_FAILURE;
3399 }
3400
3401 return eSIR_SUCCESS;
3402
3403} /* End lim_send_channel_switch_mgmt_frame. */
3404
Abhishek Singh518323d2015-10-19 17:42:01 +05303405/**
3406 * lim_send_extended_chan_switch_action_frame()- function to send ECSA
3407 * action frame over the air .
3408 * @mac_ctx: pointer to global mac structure
3409 * @peer: Destination mac.
3410 * @mode: channel switch mode
3411 * @new_op_class: new op class
3412 * @new_channel: new channel to switch
3413 * @count: channel switch count
3414 *
3415 * This function is called to send ECSA frame.
3416 *
3417 * Return: success if frame is sent else return failure
3418 */
3419
3420tSirRetStatus
3421lim_send_extended_chan_switch_action_frame(tpAniSirGlobal mac_ctx,
3422 tSirMacAddr peer, uint8_t mode, uint8_t new_op_class,
3423 uint8_t new_channel, uint8_t count, tpPESession session_entry)
3424{
3425 tDot11fext_channel_switch_action_frame frm;
3426 uint8_t *frame;
3427 tpSirMacMgmtHdr mac_hdr;
3428 uint32_t num_bytes, n_payload, status;
3429 void *packet;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303430 QDF_STATUS qdf_status;
Abhishek Singh518323d2015-10-19 17:42:01 +05303431 uint8_t txFlag = 0;
3432 uint8_t sme_session_id = 0;
3433
3434 if (session_entry == NULL) {
3435 lim_log(mac_ctx, LOGE, FL("Session entry is NULL!!!"));
3436 return eSIR_FAILURE;
3437 }
3438
3439 sme_session_id = session_entry->smeSessionId;
3440
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303441 qdf_mem_set(&frm, sizeof(frm), 0);
Abhishek Singh518323d2015-10-19 17:42:01 +05303442
3443 frm.Category.category = SIR_MAC_ACTION_PUBLIC_USAGE;
3444 frm.Action.action = SIR_MAC_ACTION_EXT_CHANNEL_SWITCH_ID;
3445
3446 frm.ext_chan_switch_ann_action.switch_mode = mode;
3447 frm.ext_chan_switch_ann_action.op_class = new_op_class;
3448 frm.ext_chan_switch_ann_action.new_channel = new_channel;
3449 frm.ext_chan_switch_ann_action.switch_count = count;
3450
3451
3452 status = dot11f_get_packed_ext_channel_switch_action_frame_size(mac_ctx,
3453 &frm, &n_payload);
3454 if (DOT11F_FAILED(status)) {
3455 lim_log(mac_ctx, LOGP,
3456 FL("Failed to get packed size for Channel Switch 0x%08x."),
3457 status);
3458 /* We'll fall back on the worst case scenario*/
3459 n_payload = sizeof(tDot11fext_channel_switch_action_frame);
3460 } else if (DOT11F_WARNED(status)) {
3461 lim_log(mac_ctx, LOGW,
3462 FL("There were warnings while calculating the packed size for a Ext Channel Switch (0x%08x)."),
3463 status);
3464 }
3465
3466 num_bytes = n_payload + sizeof(tSirMacMgmtHdr);
3467
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303468 qdf_status = cds_packet_alloc((uint16_t)num_bytes,
Abhishek Singh518323d2015-10-19 17:42:01 +05303469 (void **) &frame, (void **) &packet);
3470
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303471 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Abhishek Singh518323d2015-10-19 17:42:01 +05303472 lim_log(mac_ctx, LOGP,
3473 FL("Failed to allocate %d bytes for a Ext Channel Switch."),
3474 num_bytes);
3475 return eSIR_FAILURE;
3476 }
3477
3478 /* Paranoia*/
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303479 qdf_mem_set(frame, num_bytes, 0);
Abhishek Singh518323d2015-10-19 17:42:01 +05303480
3481 /* Next, we fill out the buffer descriptor */
3482 lim_populate_mac_header(mac_ctx, frame, SIR_MAC_MGMT_FRAME,
3483 SIR_MAC_MGMT_ACTION, peer, session_entry->selfMacAddr);
3484 mac_hdr = (tpSirMacMgmtHdr) frame;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303485 qdf_mem_copy((uint8_t *) mac_hdr->bssId,
Abhishek Singh518323d2015-10-19 17:42:01 +05303486 (uint8_t *) session_entry->bssId,
3487 sizeof(tSirMacAddr));
3488
3489 status = dot11f_pack_ext_channel_switch_action_frame(mac_ctx, &frm,
3490 frame + sizeof(tSirMacMgmtHdr), n_payload, &n_payload);
3491 if (DOT11F_FAILED(status)) {
3492 lim_log(mac_ctx, LOGE,
3493 FL("Failed to pack a Channel Switch 0x%08x."),
3494 status);
3495 cds_packet_free((void *)packet);
3496 return eSIR_FAILURE;
3497 } else if (DOT11F_WARNED(status)) {
3498 lim_log(mac_ctx, LOGW,
3499 FL("There were warnings while packing a Channel Switch 0x%08x."),
3500 status);
3501 }
3502
3503 if ((SIR_BAND_5_GHZ ==
3504 lim_get_rf_band(session_entry->currentOperChannel)) ||
Anurag Chouhan6d760662016-02-20 16:05:43 +05303505 (session_entry->pePersona == QDF_P2P_CLIENT_MODE) ||
3506 (session_entry->pePersona == QDF_P2P_GO_MODE)) {
Abhishek Singh518323d2015-10-19 17:42:01 +05303507 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
3508 }
3509
3510 lim_log(mac_ctx, LOG1,
3511 FL("Send Ext channel Switch to :"MAC_ADDRESS_STR" with swcount %d, swmode %d , newchannel %d newops %d"),
3512 MAC_ADDR_ARRAY(mac_hdr->da),
3513 frm.ext_chan_switch_ann_action.switch_count,
3514 frm.ext_chan_switch_ann_action.switch_mode,
3515 frm.ext_chan_switch_ann_action.new_channel,
3516 frm.ext_chan_switch_ann_action.op_class);
3517
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303518 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Abhishek Singh518323d2015-10-19 17:42:01 +05303519 session_entry->peSessionId, mac_hdr->fc.subType));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303520 qdf_status = wma_tx_frame(mac_ctx, packet, (uint16_t) num_bytes,
Abhishek Singh518323d2015-10-19 17:42:01 +05303521 TXRX_FRM_802_11_MGMT,
3522 ANI_TXDIR_TODS,
3523 7,
3524 lim_tx_complete, frame,
3525 txFlag, sme_session_id, 0);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303526 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303527 session_entry->peSessionId, qdf_status));
3528 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Abhishek Singh518323d2015-10-19 17:42:01 +05303529 lim_log(mac_ctx, LOGE,
3530 FL("Failed to send a Ext Channel Switch %X!"),
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303531 qdf_status);
Abhishek Singh518323d2015-10-19 17:42:01 +05303532 /* Pkt will be freed up by the callback */
3533 return eSIR_FAILURE;
3534 }
3535 return eSIR_SUCCESS;
3536} /* End lim_send_extended_chan_switch_action_frame */
3537
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003538tSirRetStatus
3539lim_send_vht_opmode_notification_frame(tpAniSirGlobal pMac,
3540 tSirMacAddr peer,
3541 uint8_t nMode, tpPESession psessionEntry)
3542{
3543 tDot11fOperatingMode frm;
3544 uint8_t *pFrame;
3545 tpSirMacMgmtHdr pMacHdr;
3546 uint32_t nBytes, nPayload = 0, nStatus; /* , nCfg; */
3547 void *pPacket;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303548 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003549 uint8_t txFlag = 0;
3550
3551 uint8_t smeSessionId = 0;
3552
3553 if (psessionEntry == NULL) {
3554 PELOGE(lim_log(pMac, LOGE, FL("Session entry is NULL!!!"));)
3555 return eSIR_FAILURE;
3556 }
3557 smeSessionId = psessionEntry->smeSessionId;
3558
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303559 qdf_mem_set((uint8_t *) &frm, sizeof(frm), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003560
3561 frm.Category.category = SIR_MAC_ACTION_VHT;
3562 frm.Action.action = SIR_MAC_VHT_OPMODE_NOTIFICATION;
3563 frm.OperatingMode.chanWidth = nMode;
3564 frm.OperatingMode.rxNSS = 0;
3565 frm.OperatingMode.rxNSSType = 0;
3566
3567 nStatus = dot11f_get_packed_operating_mode_size(pMac, &frm, &nPayload);
3568 if (DOT11F_FAILED(nStatus)) {
3569 lim_log(pMac, LOGP, FL("Failed to calculate the packed size f"
3570 "or a Operating Mode (0x%08x)."),
3571 nStatus);
3572 /* We'll fall back on the worst case scenario: */
3573 nPayload = sizeof(tDot11fOperatingMode);
3574 } else if (DOT11F_WARNED(nStatus)) {
3575 lim_log(pMac, LOGW, FL("There were warnings while calculating "
3576 "the packed size for a Operating Mode (0x"
3577 "%08x)."), nStatus);
3578 }
3579
3580 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
3581
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303582 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003583 cds_packet_alloc((uint16_t) nBytes, (void **)&pFrame,
3584 (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303585 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003586 lim_log(pMac, LOGP,
3587 FL("Failed to allocate %d bytes for a Operating Mode"
3588 " Report."), nBytes);
3589 return eSIR_FAILURE;
3590 }
3591 /* Paranoia: */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303592 qdf_mem_set(pFrame, nBytes, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003593
3594 /* Next, we fill out the buffer descriptor: */
Anurag Chouhan6d760662016-02-20 16:05:43 +05303595 if (psessionEntry->pePersona == QDF_SAP_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003596 lim_populate_mac_header(pMac, pFrame, SIR_MAC_MGMT_FRAME,
3597 SIR_MAC_MGMT_ACTION, peer,
3598 psessionEntry->selfMacAddr);
3599 else
3600 lim_populate_mac_header(pMac, pFrame, SIR_MAC_MGMT_FRAME,
3601 SIR_MAC_MGMT_ACTION, psessionEntry->bssId,
3602 psessionEntry->selfMacAddr);
3603 pMacHdr = (tpSirMacMgmtHdr) pFrame;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303604 qdf_mem_copy((uint8_t *) pMacHdr->bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003605 (uint8_t *) psessionEntry->bssId, sizeof(tSirMacAddr));
3606 nStatus = dot11f_pack_operating_mode(pMac, &frm, pFrame +
3607 sizeof(tSirMacMgmtHdr),
3608 nPayload, &nPayload);
3609 if (DOT11F_FAILED(nStatus)) {
3610 lim_log(pMac, LOGE,
3611 FL("Failed to pack a Operating Mode (0x%08x)."),
3612 nStatus);
3613 cds_packet_free((void *)pPacket);
3614 return eSIR_FAILURE; /* allocated! */
3615 } else if (DOT11F_WARNED(nStatus)) {
3616 lim_log(pMac, LOGW,
3617 FL("There were warnings while packing a Operating Mode"
3618 " (0x%08x)."), nStatus);
3619 }
3620 if ((SIR_BAND_5_GHZ == lim_get_rf_band(psessionEntry->currentOperChannel))
Anurag Chouhan6d760662016-02-20 16:05:43 +05303621 || (psessionEntry->pePersona == QDF_P2P_CLIENT_MODE) ||
3622 (psessionEntry->pePersona == QDF_P2P_GO_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003623 ) {
3624 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
3625 }
3626
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303627 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003628 psessionEntry->peSessionId, pMacHdr->fc.subType));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303629 qdf_status = wma_tx_frame(pMac, pPacket, (uint16_t) nBytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003630 TXRX_FRM_802_11_MGMT,
3631 ANI_TXDIR_TODS,
3632 7, lim_tx_complete, pFrame, txFlag,
3633 smeSessionId, 0);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303634 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303635 psessionEntry->peSessionId, qdf_status));
3636 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003637 lim_log(pMac, LOGE,
3638 FL("Failed to send a Channel Switch (%X)!"),
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303639 qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003640 /* Pkt will be freed up by the callback */
3641 return eSIR_FAILURE;
3642 }
3643
3644 return eSIR_SUCCESS;
3645}
3646
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003647/**
3648 * \brief Send a Neighbor Report Request Action frame
3649 *
3650 *
3651 * \param pMac Pointer to the global MAC structure
3652 *
3653 * \param pNeighborReq Address of a tSirMacNeighborReportReq
3654 *
3655 * \param peer mac address of peer station.
3656 *
3657 * \param psessionEntry address of session entry.
3658 *
3659 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
3660 *
3661 *
3662 */
3663
3664tSirRetStatus
3665lim_send_neighbor_report_request_frame(tpAniSirGlobal pMac,
3666 tpSirMacNeighborReportReq pNeighborReq,
3667 tSirMacAddr peer, tpPESession psessionEntry)
3668{
3669 tSirRetStatus statusCode = eSIR_SUCCESS;
3670 tDot11fNeighborReportRequest frm;
3671 uint8_t *pFrame;
3672 tpSirMacMgmtHdr pMacHdr;
3673 uint32_t nBytes, nPayload, nStatus;
3674 void *pPacket;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303675 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003676 uint8_t txFlag = 0;
3677 uint8_t smeSessionId = 0;
3678
3679 if (psessionEntry == NULL) {
3680 lim_log(pMac, LOGE,
3681 FL
3682 ("(psession == NULL) in Request to send Neighbor Report request action frame"));
3683 return eSIR_FAILURE;
3684 }
3685 smeSessionId = psessionEntry->smeSessionId;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303686 qdf_mem_set((uint8_t *) &frm, sizeof(frm), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003687
3688 frm.Category.category = SIR_MAC_ACTION_RRM;
3689 frm.Action.action = SIR_MAC_RRM_NEIGHBOR_REQ;
3690 frm.DialogToken.token = pNeighborReq->dialogToken;
3691
3692 if (pNeighborReq->ssid_present) {
3693 populate_dot11f_ssid(pMac, &pNeighborReq->ssid, &frm.SSID);
3694 }
3695
3696 nStatus =
3697 dot11f_get_packed_neighbor_report_request_size(pMac, &frm, &nPayload);
3698 if (DOT11F_FAILED(nStatus)) {
3699 lim_log(pMac, LOGP, FL("Failed to calculate the packed size f"
3700 "or a Neighbor Report Request(0x%08x)."),
3701 nStatus);
3702 /* We'll fall back on the worst case scenario: */
3703 nPayload = sizeof(tDot11fNeighborReportRequest);
3704 } else if (DOT11F_WARNED(nStatus)) {
3705 lim_log(pMac, LOGW, FL("There were warnings while calculating "
3706 "the packed size for a Neighbor Rep"
3707 "ort Request(0x%08x)."), nStatus);
3708 }
3709
3710 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
3711
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303712 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003713 cds_packet_alloc((uint16_t) nBytes, (void **)&pFrame,
3714 (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303715 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003716 lim_log(pMac, LOGP,
3717 FL("Failed to allocate %d bytes for a Neighbor "
3718 "Report Request."), nBytes);
3719 return eSIR_FAILURE;
3720 }
3721 /* Paranoia: */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303722 qdf_mem_set(pFrame, nBytes, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003723
3724 /* Copy necessary info to BD */
3725 lim_populate_mac_header(pMac, pFrame, SIR_MAC_MGMT_FRAME,
3726 SIR_MAC_MGMT_ACTION, peer, psessionEntry->selfMacAddr);
3727
3728 /* Update A3 with the BSSID */
3729 pMacHdr = (tpSirMacMgmtHdr) pFrame;
3730
3731 sir_copy_mac_addr(pMacHdr->bssId, psessionEntry->bssId);
3732
3733#ifdef WLAN_FEATURE_11W
3734 lim_set_protected_bit(pMac, psessionEntry, peer, pMacHdr);
3735#endif
3736
3737 /* Now, we're ready to "pack" the frames */
3738 nStatus = dot11f_pack_neighbor_report_request(pMac,
3739 &frm,
3740 pFrame +
3741 sizeof(tSirMacMgmtHdr),
3742 nPayload, &nPayload);
3743
3744 if (DOT11F_FAILED(nStatus)) {
3745 lim_log(pMac, LOGE,
3746 FL
3747 ("Failed to pack an Neighbor Report Request (0x%08x)."),
3748 nStatus);
3749
3750 /* FIXME - Need to convert to tSirRetStatus */
3751 statusCode = eSIR_FAILURE;
3752 goto returnAfterError;
3753 } else if (DOT11F_WARNED(nStatus)) {
3754 lim_log(pMac, LOGW,
3755 FL("There were warnings while packing Neighbor Report "
3756 "Request (0x%08x)."), nStatus);
3757 }
3758
3759 lim_log(pMac, LOGW, FL("Sending a Neighbor Report Request to "));
3760 lim_print_mac_addr(pMac, peer, LOGW);
3761
3762 if ((SIR_BAND_5_GHZ == lim_get_rf_band(psessionEntry->currentOperChannel))
Anurag Chouhan6d760662016-02-20 16:05:43 +05303763 || (psessionEntry->pePersona == QDF_P2P_CLIENT_MODE) ||
3764 (psessionEntry->pePersona == QDF_P2P_GO_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003765 ) {
3766 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
3767 }
3768
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303769 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003770 psessionEntry->peSessionId, pMacHdr->fc.subType));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303771 qdf_status = wma_tx_frame(pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003772 pPacket,
3773 (uint16_t) nBytes,
3774 TXRX_FRM_802_11_MGMT,
3775 ANI_TXDIR_TODS,
3776 7, lim_tx_complete, pFrame, txFlag,
3777 smeSessionId, 0);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303778 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303779 psessionEntry->peSessionId, qdf_status));
3780 if (QDF_STATUS_SUCCESS != qdf_status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003781 PELOGE(lim_log
3782 (pMac, LOGE, FL("wma_tx_frame FAILED! Status [%d]"),
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303783 qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003784 )
3785 statusCode = eSIR_FAILURE;
3786 /* Pkt will be freed up by the callback */
3787 return statusCode;
3788 } else
3789 return eSIR_SUCCESS;
3790
3791returnAfterError:
3792 cds_packet_free((void *)pPacket);
3793
3794 return statusCode;
3795} /* End lim_send_neighbor_report_request_frame. */
3796
3797/**
3798 * \brief Send a Link Report Action frame
3799 *
3800 *
3801 * \param pMac Pointer to the global MAC structure
3802 *
3803 * \param pLinkReport Address of a tSirMacLinkReport
3804 *
3805 * \param peer mac address of peer station.
3806 *
3807 * \param psessionEntry address of session entry.
3808 *
3809 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
3810 *
3811 *
3812 */
3813
3814tSirRetStatus
3815lim_send_link_report_action_frame(tpAniSirGlobal pMac,
3816 tpSirMacLinkReport pLinkReport,
3817 tSirMacAddr peer, tpPESession psessionEntry)
3818{
3819 tSirRetStatus statusCode = eSIR_SUCCESS;
3820 tDot11fLinkMeasurementReport frm;
3821 uint8_t *pFrame;
3822 tpSirMacMgmtHdr pMacHdr;
3823 uint32_t nBytes, nPayload, nStatus;
3824 void *pPacket;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303825 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003826 uint8_t txFlag = 0;
3827 uint8_t smeSessionId = 0;
3828
3829 if (psessionEntry == NULL) {
3830 lim_log(pMac, LOGE,
3831 FL
3832 ("(psession == NULL) in Request to send Link Report action frame"));
3833 return eSIR_FAILURE;
3834 }
3835
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303836 qdf_mem_set((uint8_t *) &frm, sizeof(frm), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003837
3838 frm.Category.category = SIR_MAC_ACTION_RRM;
3839 frm.Action.action = SIR_MAC_RRM_LINK_MEASUREMENT_RPT;
3840 frm.DialogToken.token = pLinkReport->dialogToken;
3841
3842 /* IEEE Std. 802.11 7.3.2.18. for the report element. */
3843 /* Even though TPC report an IE, it is represented using fixed fields since it is positioned */
3844 /* in the middle of other fixed fields in the link report frame(IEEE Std. 802.11k section7.4.6.4 */
3845 /* and frame parser always expects IEs to come after all fixed fields. It is easier to handle */
3846 /* such case this way than changing the frame parser. */
3847 frm.TPCEleID.TPCId = SIR_MAC_TPC_RPT_EID;
3848 frm.TPCEleLen.TPCLen = 2;
3849 frm.TxPower.txPower = pLinkReport->txPower;
3850 frm.LinkMargin.linkMargin = 0;
3851
3852 frm.RxAntennaId.antennaId = pLinkReport->rxAntenna;
3853 frm.TxAntennaId.antennaId = pLinkReport->txAntenna;
3854 frm.RCPI.rcpi = pLinkReport->rcpi;
3855 frm.RSNI.rsni = pLinkReport->rsni;
3856
3857 nStatus =
3858 dot11f_get_packed_link_measurement_report_size(pMac, &frm, &nPayload);
3859 if (DOT11F_FAILED(nStatus)) {
3860 lim_log(pMac, LOGP, FL("Failed to calculate the packed size f"
3861 "or a Link Report (0x%08x)."), nStatus);
3862 /* We'll fall back on the worst case scenario: */
3863 nPayload = sizeof(tDot11fLinkMeasurementReport);
3864 } else if (DOT11F_WARNED(nStatus)) {
3865 lim_log(pMac, LOGW, FL("There were warnings while calculating "
3866 "the packed size for a Link Rep"
3867 "ort (0x%08x)."), nStatus);
3868 }
3869
3870 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
3871
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303872 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003873 cds_packet_alloc((uint16_t) nBytes, (void **)&pFrame,
3874 (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303875 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003876 lim_log(pMac, LOGP, FL("Failed to allocate %d bytes for a Link "
3877 "Report."), nBytes);
3878 return eSIR_FAILURE;
3879 }
3880 /* Paranoia: */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303881 qdf_mem_set(pFrame, nBytes, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003882
3883 /* Copy necessary info to BD */
3884 lim_populate_mac_header(pMac, pFrame, SIR_MAC_MGMT_FRAME,
3885 SIR_MAC_MGMT_ACTION, peer, psessionEntry->selfMacAddr);
3886
3887 /* Update A3 with the BSSID */
3888 pMacHdr = (tpSirMacMgmtHdr) pFrame;
3889
3890 sir_copy_mac_addr(pMacHdr->bssId, psessionEntry->bssId);
3891
3892#ifdef WLAN_FEATURE_11W
3893 lim_set_protected_bit(pMac, psessionEntry, peer, pMacHdr);
3894#endif
3895
3896 /* Now, we're ready to "pack" the frames */
3897 nStatus = dot11f_pack_link_measurement_report(pMac,
3898 &frm,
3899 pFrame +
3900 sizeof(tSirMacMgmtHdr),
3901 nPayload, &nPayload);
3902
3903 if (DOT11F_FAILED(nStatus)) {
3904 lim_log(pMac, LOGE,
3905 FL("Failed to pack an Link Report (0x%08x)."), nStatus);
3906
3907 /* FIXME - Need to convert to tSirRetStatus */
3908 statusCode = eSIR_FAILURE;
3909 goto returnAfterError;
3910 } else if (DOT11F_WARNED(nStatus)) {
3911 lim_log(pMac, LOGW,
3912 FL
3913 ("There were warnings while packing Link Report (0x%08x)."),
3914 nStatus);
3915 }
3916
3917 lim_log(pMac, LOGW, FL("Sending a Link Report to "));
3918 lim_print_mac_addr(pMac, peer, LOGW);
3919
3920 if ((SIR_BAND_5_GHZ == lim_get_rf_band(psessionEntry->currentOperChannel))
Anurag Chouhan6d760662016-02-20 16:05:43 +05303921 || (psessionEntry->pePersona == QDF_P2P_CLIENT_MODE) ||
3922 (psessionEntry->pePersona == QDF_P2P_GO_MODE)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003923 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
3924 }
3925
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303926 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003927 psessionEntry->peSessionId, pMacHdr->fc.subType));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303928 qdf_status = wma_tx_frame(pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003929 pPacket,
3930 (uint16_t) nBytes,
3931 TXRX_FRM_802_11_MGMT,
3932 ANI_TXDIR_TODS,
3933 7, lim_tx_complete, pFrame, txFlag,
3934 smeSessionId, 0);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303935 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303936 psessionEntry->peSessionId, qdf_status));
3937 if (QDF_STATUS_SUCCESS != qdf_status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003938 PELOGE(lim_log
3939 (pMac, LOGE, FL("wma_tx_frame FAILED! Status [%d]"),
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303940 qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003941 )
3942 statusCode = eSIR_FAILURE;
3943 /* Pkt will be freed up by the callback */
3944 return statusCode;
3945 } else
3946 return eSIR_SUCCESS;
3947
3948returnAfterError:
3949 cds_packet_free((void *)pPacket);
3950
3951 return statusCode;
3952} /* End lim_send_link_report_action_frame. */
3953
3954/**
3955 * \brief Send a Beacon Report Action frame
3956 *
3957 *
3958 * \param pMac Pointer to the global MAC structure
3959 *
3960 * \param dialog_token dialog token to be used in the action frame.
3961 *
3962 * \param num_report number of reports in pRRMReport.
3963 *
3964 * \param pRRMReport Address of a tSirMacRadioMeasureReport.
3965 *
3966 * \param peer mac address of peer station.
3967 *
3968 * \param psessionEntry address of session entry.
3969 *
3970 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
3971 *
3972 *
3973 */
3974
3975tSirRetStatus
3976lim_send_radio_measure_report_action_frame(tpAniSirGlobal pMac,
3977 uint8_t dialog_token,
3978 uint8_t num_report,
3979 tpSirMacRadioMeasureReport pRRMReport,
3980 tSirMacAddr peer,
3981 tpPESession psessionEntry)
3982{
3983 tSirRetStatus statusCode = eSIR_SUCCESS;
3984 uint8_t *pFrame;
3985 tpSirMacMgmtHdr pMacHdr;
3986 uint32_t nBytes, nPayload, nStatus;
3987 void *pPacket;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303988 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003989 uint8_t i;
3990 uint8_t txFlag = 0;
3991 uint8_t smeSessionId = 0;
3992
3993 tDot11fRadioMeasurementReport *frm =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303994 qdf_mem_malloc(sizeof(tDot11fRadioMeasurementReport));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003995 if (!frm) {
3996 lim_log(pMac, LOGE,
3997 FL
3998 ("Not enough memory to allocate tDot11fRadioMeasurementReport"));
3999 return eSIR_MEM_ALLOC_FAILED;
4000 }
4001
4002 if (psessionEntry == NULL) {
4003 lim_log(pMac, LOGE,
4004 FL
4005 ("(psession == NULL) in Request to send Beacon Report action frame"));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304006 qdf_mem_free(frm);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004007 return eSIR_FAILURE;
4008 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304009 qdf_mem_set((uint8_t *) frm, sizeof(*frm), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004010
4011 frm->Category.category = SIR_MAC_ACTION_RRM;
4012 frm->Action.action = SIR_MAC_RRM_RADIO_MEASURE_RPT;
4013 frm->DialogToken.token = dialog_token;
4014
4015 frm->num_MeasurementReport =
4016 (num_report >
4017 RADIO_REPORTS_MAX_IN_A_FRAME) ? RADIO_REPORTS_MAX_IN_A_FRAME :
4018 num_report;
4019
4020 for (i = 0; i < frm->num_MeasurementReport; i++) {
4021 frm->MeasurementReport[i].type = pRRMReport[i].type;
4022 frm->MeasurementReport[i].token = pRRMReport[i].token;
4023 frm->MeasurementReport[i].late = 0; /* IEEE 802.11k section 7.3.22. (always zero in rrm) */
4024 switch (pRRMReport[i].type) {
4025 case SIR_MAC_RRM_BEACON_TYPE:
4026 populate_dot11f_beacon_report(pMac,
4027 &frm->MeasurementReport[i],
4028 &pRRMReport[i].report.
4029 beaconReport);
4030 frm->MeasurementReport[i].incapable =
4031 pRRMReport[i].incapable;
4032 frm->MeasurementReport[i].refused =
4033 pRRMReport[i].refused;
4034 frm->MeasurementReport[i].present = 1;
4035 break;
4036 default:
4037 frm->MeasurementReport[i].incapable =
4038 pRRMReport[i].incapable;
4039 frm->MeasurementReport[i].refused =
4040 pRRMReport[i].refused;
4041 frm->MeasurementReport[i].present = 1;
4042 break;
4043 }
4044 }
4045
4046 nStatus =
4047 dot11f_get_packed_radio_measurement_report_size(pMac, frm, &nPayload);
4048 if (DOT11F_FAILED(nStatus)) {
4049 lim_log(pMac, LOGP, FL("Failed to calculate the packed size f"
4050 "or a Radio Measure Report (0x%08x)."),
4051 nStatus);
4052 /* We'll fall back on the worst case scenario: */
4053 nPayload = sizeof(tDot11fLinkMeasurementReport);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304054 qdf_mem_free(frm);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004055 return eSIR_FAILURE;
4056 } else if (DOT11F_WARNED(nStatus)) {
4057 lim_log(pMac, LOGW, FL("There were warnings while calculating "
4058 "the packed size for a Radio Measure Rep"
4059 "ort (0x%08x)."), nStatus);
4060 }
4061
4062 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
4063
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304064 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004065 cds_packet_alloc((uint16_t) nBytes, (void **)&pFrame,
4066 (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304067 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004068 lim_log(pMac, LOGP,
4069 FL("Failed to allocate %d bytes for a Radio Measure "
4070 "Report."), nBytes);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304071 qdf_mem_free(frm);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004072 return eSIR_FAILURE;
4073 }
4074 /* Paranoia: */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304075 qdf_mem_set(pFrame, nBytes, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004076
4077 /* Copy necessary info to BD */
4078 lim_populate_mac_header(pMac, pFrame, SIR_MAC_MGMT_FRAME,
4079 SIR_MAC_MGMT_ACTION, peer, psessionEntry->selfMacAddr);
4080
4081 /* Update A3 with the BSSID */
4082 pMacHdr = (tpSirMacMgmtHdr) pFrame;
4083
4084 sir_copy_mac_addr(pMacHdr->bssId, psessionEntry->bssId);
4085
4086#ifdef WLAN_FEATURE_11W
4087 lim_set_protected_bit(pMac, psessionEntry, peer, pMacHdr);
4088#endif
4089
4090 /* Now, we're ready to "pack" the frames */
4091 nStatus = dot11f_pack_radio_measurement_report(pMac,
4092 frm,
4093 pFrame +
4094 sizeof(tSirMacMgmtHdr),
4095 nPayload, &nPayload);
4096
4097 if (DOT11F_FAILED(nStatus)) {
4098 lim_log(pMac, LOGE,
4099 FL("Failed to pack an Radio Measure Report (0x%08x)."),
4100 nStatus);
4101
4102 /* FIXME - Need to convert to tSirRetStatus */
4103 statusCode = eSIR_FAILURE;
4104 goto returnAfterError;
4105 } else if (DOT11F_WARNED(nStatus)) {
4106 lim_log(pMac, LOGW,
4107 FL("There were warnings while packing Radio "
4108 "Measure Report (0x%08x)."), nStatus);
4109 }
4110
4111 lim_log(pMac, LOGW, FL("Sending a Radio Measure Report to "));
4112 lim_print_mac_addr(pMac, peer, LOGW);
4113
4114 if ((SIR_BAND_5_GHZ == lim_get_rf_band(psessionEntry->currentOperChannel))
Anurag Chouhan6d760662016-02-20 16:05:43 +05304115 || (psessionEntry->pePersona == QDF_P2P_CLIENT_MODE) ||
4116 (psessionEntry->pePersona == QDF_P2P_GO_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004117 ) {
4118 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
4119 }
4120
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304121 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004122 psessionEntry->peSessionId, pMacHdr->fc.subType));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304123 qdf_status = wma_tx_frame(pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004124 pPacket,
4125 (uint16_t) nBytes,
4126 TXRX_FRM_802_11_MGMT,
4127 ANI_TXDIR_TODS,
4128 7, lim_tx_complete, pFrame, txFlag,
4129 smeSessionId, 0);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304130 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304131 psessionEntry->peSessionId, qdf_status));
4132 if (QDF_STATUS_SUCCESS != qdf_status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004133 PELOGE(lim_log
4134 (pMac, LOGE, FL("wma_tx_frame FAILED! Status [%d]"),
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304135 qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004136 )
4137 statusCode = eSIR_FAILURE;
4138 /* Pkt will be freed up by the callback */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304139 qdf_mem_free(frm);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004140 return statusCode;
4141 } else {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304142 qdf_mem_free(frm);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004143 return eSIR_SUCCESS;
4144 }
4145
4146returnAfterError:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304147 qdf_mem_free(frm);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004148 cds_packet_free((void *)pPacket);
4149 return statusCode;
4150}
4151
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004152#ifdef WLAN_FEATURE_11W
4153/**
4154 * \brief Send SA query request action frame to peer
4155 *
4156 * \sa lim_send_sa_query_request_frame
4157 *
4158 *
4159 * \param pMac The global tpAniSirGlobal object
4160 *
4161 * \param transId Transaction identifier
4162 *
4163 * \param peer The Mac address of the station to which this action frame is addressed
4164 *
4165 * \param psessionEntry The PE session entry
4166 *
4167 * \return eSIR_SUCCESS if setup completes successfully
4168 * eSIR_FAILURE is some problem is encountered
4169 */
4170
4171tSirRetStatus lim_send_sa_query_request_frame(tpAniSirGlobal pMac, uint8_t *transId,
4172 tSirMacAddr peer,
4173 tpPESession psessionEntry)
4174{
4175
4176 tDot11fSaQueryReq frm; /* SA query request action frame */
4177 uint8_t *pFrame;
4178 tSirRetStatus nSirStatus;
4179 tpSirMacMgmtHdr pMacHdr;
4180 uint32_t nBytes, nPayload, nStatus;
4181 void *pPacket;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304182 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004183 uint8_t txFlag = 0;
4184 uint8_t smeSessionId = 0;
4185
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304186 qdf_mem_set((uint8_t *) &frm, sizeof(frm), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004187 frm.Category.category = SIR_MAC_ACTION_SA_QUERY;
4188 /* 11w action field is :
4189 action: 0 --> SA Query Request action frame
4190 action: 1 --> SA Query Response action frame */
4191 frm.Action.action = SIR_MAC_SA_QUERY_REQ;
4192 /* 11w SA Query Request transId */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304193 qdf_mem_copy(&frm.TransactionId.transId[0], &transId[0], 2);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004194
4195 nStatus = dot11f_get_packed_sa_query_req_size(pMac, &frm, &nPayload);
4196 if (DOT11F_FAILED(nStatus)) {
4197 lim_log(pMac, LOGP, FL("Failed to calculate the packed size "
4198 "for an SA Query Request (0x%08x)."),
4199 nStatus);
4200 /* We'll fall back on the worst case scenario: */
4201 nPayload = sizeof(tDot11fSaQueryReq);
4202 } else if (DOT11F_WARNED(nStatus)) {
4203 lim_log(pMac, LOGW, FL("There were warnings while calculating "
4204 "the packed size for an SA Query Request"
4205 " (0x%08x)."), nStatus);
4206 }
4207
4208 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304209 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004210 cds_packet_alloc(nBytes, (void **)&pFrame, (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304211 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004212 lim_log(pMac, LOGP,
4213 FL("Failed to allocate %d bytes for a SA Query Request "
4214 "action frame"), nBytes);
4215 return eSIR_FAILURE;
4216 }
4217 /* Paranoia: */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304218 qdf_mem_set(pFrame, nBytes, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004219
4220 /* Copy necessary info to BD */
4221 lim_populate_mac_header(pMac, pFrame, SIR_MAC_MGMT_FRAME,
4222 SIR_MAC_MGMT_ACTION, peer, psessionEntry->selfMacAddr);
4223
4224 /* Update A3 with the BSSID */
4225 pMacHdr = (tpSirMacMgmtHdr) pFrame;
4226
4227 sir_copy_mac_addr(pMacHdr->bssId, psessionEntry->bssId);
4228
4229 /* Since this is a SA Query Request, set the "protect" (aka WEP) bit */
4230 /* in the FC */
4231 lim_set_protected_bit(pMac, psessionEntry, peer, pMacHdr);
4232
4233 /* Pack 11w SA Query Request frame */
4234 nStatus = dot11f_pack_sa_query_req(pMac,
4235 &frm,
4236 pFrame + sizeof(tSirMacMgmtHdr),
4237 nPayload, &nPayload);
4238
4239 if (DOT11F_FAILED(nStatus)) {
4240 lim_log(pMac, LOGE,
4241 FL("Failed to pack an SA Query Request (0x%08x)."),
4242 nStatus);
4243 /* FIXME - Need to convert to tSirRetStatus */
4244 nSirStatus = eSIR_FAILURE;
4245 goto returnAfterError;
4246 } else if (DOT11F_WARNED(nStatus)) {
4247 lim_log(pMac, LOGW,
4248 FL
4249 ("There were warnings while packing SA Query Request (0x%08x)."),
4250 nStatus);
4251 }
4252
4253 lim_log(pMac, LOG1, FL("Sending an SA Query Request to "));
4254 lim_print_mac_addr(pMac, peer, LOG1);
4255 lim_log(pMac, LOG1, FL("Sending an SA Query Request from "));
4256 lim_print_mac_addr(pMac, psessionEntry->selfMacAddr, LOG1);
4257
4258 if ((SIR_BAND_5_GHZ == lim_get_rf_band(psessionEntry->currentOperChannel))
4259#ifdef WLAN_FEATURE_P2P
Anurag Chouhan6d760662016-02-20 16:05:43 +05304260 || (psessionEntry->pePersona == QDF_P2P_CLIENT_MODE) ||
4261 (psessionEntry->pePersona == QDF_P2P_GO_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004262#endif
4263 ) {
4264 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
4265 }
4266 smeSessionId = psessionEntry->smeSessionId;
4267
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304268 qdf_status = wma_tx_frame(pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004269 pPacket,
4270 (uint16_t) nBytes,
4271 TXRX_FRM_802_11_MGMT,
4272 ANI_TXDIR_TODS,
4273 7, lim_tx_complete, pFrame, txFlag,
4274 smeSessionId, 0);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304275 if (QDF_STATUS_SUCCESS != qdf_status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004276 PELOGE(lim_log
4277 (pMac, LOGE, FL("wma_tx_frame FAILED! Status [%d]"),
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304278 qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004279 )
4280 nSirStatus = eSIR_FAILURE;
4281 /* Pkt will be freed up by the callback */
4282 return nSirStatus;
4283 } else {
4284 return eSIR_SUCCESS;
4285 }
4286
4287returnAfterError:
4288 cds_packet_free((void *)pPacket);
4289 return nSirStatus;
4290} /* End lim_send_sa_query_request_frame */
4291
4292/**
4293 * \brief Send SA query response action frame to peer
4294 *
4295 * \sa lim_send_sa_query_response_frame
4296 *
4297 *
4298 * \param pMac The global tpAniSirGlobal object
4299 *
4300 * \param transId Transaction identifier received in SA query request action frame
4301 *
4302 * \param peer The Mac address of the AP to which this action frame is addressed
4303 *
4304 * \param psessionEntry The PE session entry
4305 *
4306 * \return eSIR_SUCCESS if setup completes successfully
4307 * eSIR_FAILURE is some problem is encountered
4308 */
4309
4310tSirRetStatus lim_send_sa_query_response_frame(tpAniSirGlobal pMac,
4311 uint8_t *transId, tSirMacAddr peer,
4312 tpPESession psessionEntry)
4313{
4314
4315 tDot11fSaQueryRsp frm; /* SA query reponse action frame */
4316 uint8_t *pFrame;
4317 tSirRetStatus nSirStatus;
4318 tpSirMacMgmtHdr pMacHdr;
4319 uint32_t nBytes, nPayload, nStatus;
4320 void *pPacket;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304321 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004322 uint8_t txFlag = 0;
4323 uint8_t smeSessionId = 0;
4324
4325 smeSessionId = psessionEntry->smeSessionId;
4326
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304327 qdf_mem_set((uint8_t *) &frm, sizeof(frm), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004328 frm.Category.category = SIR_MAC_ACTION_SA_QUERY;
4329 /*11w action field is :
4330 action: 0 --> SA query request action frame
4331 action: 1 --> SA query response action frame */
4332 frm.Action.action = SIR_MAC_SA_QUERY_RSP;
4333 /*11w SA query response transId is same as
4334 SA query request transId */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304335 qdf_mem_copy(&frm.TransactionId.transId[0], &transId[0], 2);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004336
4337 nStatus = dot11f_get_packed_sa_query_rsp_size(pMac, &frm, &nPayload);
4338 if (DOT11F_FAILED(nStatus)) {
4339 lim_log(pMac, LOGP, FL("Failed to calculate the packed size f"
4340 "or a SA Query Response (0x%08x)."),
4341 nStatus);
4342 /* We'll fall back on the worst case scenario: */
4343 nPayload = sizeof(tDot11fSaQueryRsp);
4344 } else if (DOT11F_WARNED(nStatus)) {
4345 lim_log(pMac, LOGW, FL("There were warnings while calculating "
4346 "the packed size for an SA Query Response"
4347 " (0x%08x)."), nStatus);
4348 }
4349
4350 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304351 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004352 cds_packet_alloc(nBytes, (void **)&pFrame, (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304353 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004354 lim_log(pMac, LOGP,
4355 FL("Failed to allocate %d bytes for a SA query response"
4356 " action frame"), nBytes);
4357 return eSIR_FAILURE;
4358 }
4359 /* Paranoia: */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304360 qdf_mem_set(pFrame, nBytes, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004361
4362 /* Copy necessary info to BD */
4363 lim_populate_mac_header(pMac, pFrame, SIR_MAC_MGMT_FRAME,
4364 SIR_MAC_MGMT_ACTION, peer, psessionEntry->selfMacAddr);
4365
4366 /* Update A3 with the BSSID */
4367 pMacHdr = (tpSirMacMgmtHdr) pFrame;
4368
4369 sir_copy_mac_addr(pMacHdr->bssId, psessionEntry->bssId);
4370
4371 /* Since this is a SA Query Response, set the "protect" (aka WEP) bit */
4372 /* in the FC */
4373 lim_set_protected_bit(pMac, psessionEntry, peer, pMacHdr);
4374
4375 /* Pack 11w SA query response frame */
4376 nStatus = dot11f_pack_sa_query_rsp(pMac,
4377 &frm,
4378 pFrame + sizeof(tSirMacMgmtHdr),
4379 nPayload, &nPayload);
4380
4381 if (DOT11F_FAILED(nStatus)) {
4382 lim_log(pMac, LOGE,
4383 FL("Failed to pack an SA Query Response (0x%08x)."),
4384 nStatus);
4385 /* FIXME - Need to convert to tSirRetStatus */
4386 nSirStatus = eSIR_FAILURE;
4387 goto returnAfterError;
4388 } else if (DOT11F_WARNED(nStatus)) {
4389 lim_log(pMac, LOGW,
4390 FL
4391 ("There were warnings while packing SA Query Response (0x%08x)."),
4392 nStatus);
4393 }
4394
4395 lim_log(pMac, LOG1, FL("Sending a SA Query Response to "));
4396 lim_print_mac_addr(pMac, peer, LOGW);
4397
4398 if ((SIR_BAND_5_GHZ == lim_get_rf_band(psessionEntry->currentOperChannel))
4399#ifdef WLAN_FEATURE_P2P
Anurag Chouhan6d760662016-02-20 16:05:43 +05304400 || (psessionEntry->pePersona == QDF_P2P_CLIENT_MODE) ||
4401 (psessionEntry->pePersona == QDF_P2P_GO_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004402#endif
4403 ) {
4404 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
4405 }
4406
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304407 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004408 psessionEntry->peSessionId, pMacHdr->fc.subType));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304409 qdf_status = wma_tx_frame(pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004410 pPacket,
4411 (uint16_t) nBytes,
4412 TXRX_FRM_802_11_MGMT,
4413 ANI_TXDIR_TODS,
4414 7, lim_tx_complete, pFrame, txFlag,
4415 smeSessionId, 0);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304416 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304417 psessionEntry->peSessionId, qdf_status));
4418 if (QDF_STATUS_SUCCESS != qdf_status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004419 PELOGE(lim_log
4420 (pMac, LOGE, FL("wma_tx_frame FAILED! Status [%d]"),
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304421 qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004422 )
4423 nSirStatus = eSIR_FAILURE;
4424 /* Pkt will be freed up by the callback */
4425 return nSirStatus;
4426 } else {
4427 return eSIR_SUCCESS;
4428 }
4429
4430returnAfterError:
4431 cds_packet_free((void *)pPacket);
4432 return nSirStatus;
4433} /* End lim_send_sa_query_response_frame */
4434#endif