blob: d4723fcbca4e5368af0b8af9e80df089d74c4b8e [file] [log] [blame]
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001/*
Zhu Jianmin5d8e3fe2018-01-04 16:16:20 +08002 * Copyright (c) 2011-2018 The Linux Foundation. All rights reserved.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003 *
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004 * Permission to use, copy, modify, and/or distribute this software for
5 * any purpose with or without fee is hereby granted, provided that the
6 * above copyright notice and this permission notice appear in all
7 * copies.
8 *
9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
10 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
11 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
12 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
13 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
14 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
15 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
16 * PERFORMANCE OF THIS SOFTWARE.
17 */
18
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019/**
20 * \file lim_send_management_frames.c
21 *
22 * \brief Code for preparing and sending 802.11 Management frames
23 *
24 *
25 */
26
27#include "sir_api.h"
28#include "ani_global.h"
29#include "sir_mac_prot_def.h"
30#include "cfg_api.h"
31#include "utils_api.h"
32#include "lim_types.h"
33#include "lim_utils.h"
34#include "lim_security_utils.h"
35#include "lim_prop_exts_utils.h"
36#include "dot11f.h"
37#include "lim_sta_hash_api.h"
38#include "sch_api.h"
39#include "lim_send_messages.h"
40#include "lim_assoc_utils.h"
41#include "lim_ft.h"
42#ifdef WLAN_FEATURE_11W
43#include "wni_cfg.h"
44#endif
45
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080046#include "lim_ft_defs.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080047#include "lim_session.h"
Anurag Chouhan6d760662016-02-20 16:05:43 +053048#include "qdf_types.h"
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053049#include "qdf_trace.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080050#include "cds_utils.h"
51#include "sme_trace.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080052#include "rrm_api.h"
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +053053#include "qdf_crypto.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080054
55#include "wma_types.h"
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -080056#include <cdp_txrx_cmn.h>
Tushnim Bhattacharyya45ed04f2017-03-15 10:15:05 -070057#include <cdp_txrx_peer_ops.h>
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +053058#include "lim_process_fils.h"
Naveen Rawat08db88f2017-09-08 15:07:48 -070059#include "wlan_utility.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080060
61/**
62 *
63 * \brief This function is called to add the sequence number to the
64 * management frames
65 *
66 * \param pMac Pointer to Global MAC structure
67 *
68 * \param pMacHdr Pointer to MAC management header
69 *
70 * The pMacHdr argument points to the MAC management header. The
71 * sequence number stored in the pMac structure will be incremented
72 * and updated to the MAC management header. The start sequence
73 * number is WLAN_HOST_SEQ_NUM_MIN and the end value is
74 * WLAN_HOST_SEQ_NUM_MAX. After reaching the MAX value, the sequence
75 * number will roll over.
76 *
77 */
Jeff Johnson38112a32016-10-07 07:30:50 -070078static void lim_add_mgmt_seq_num(tpAniSirGlobal pMac, tpSirMacMgmtHdr pMacHdr)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080079{
80 if (pMac->mgmtSeqNum >= WLAN_HOST_SEQ_NUM_MAX) {
81 pMac->mgmtSeqNum = WLAN_HOST_SEQ_NUM_MIN - 1;
82 }
83
84 pMac->mgmtSeqNum++;
85
86 pMacHdr->seqControl.seqNumLo = (pMac->mgmtSeqNum & LOW_SEQ_NUM_MASK);
87 pMacHdr->seqControl.seqNumHi =
88 ((pMac->mgmtSeqNum & HIGH_SEQ_NUM_MASK) >> HIGH_SEQ_NUM_OFFSET);
89}
90
91/**
92 *
93 * \brief This function is called before sending a p2p action frame
94 * inorder to add sequence numbers to action packets
95 *
96 * \param pMac Pointer to Global MAC structure
97 *
98 * \param pBD Pointer to the frame buffer that needs to be populate
99 *
100 * The pMacHdr argument points to the MAC management header. The
101 * sequence number stored in the pMac structure will be incremented
102 * and updated to the MAC management header. The start sequence
103 * number is WLAN_HOST_SEQ_NUM_MIN and the end value is
104 * WLAN_HOST_SEQ_NUM_MAX. After reaching the MAX value, the sequence
105 * number will roll over.
106 *
107 */
108void lim_populate_p2p_mac_header(tpAniSirGlobal pMac, uint8_t *pBD)
109{
110 tpSirMacMgmtHdr pMacHdr;
111
112 /* / Prepare MAC management header */
113 pMacHdr = (tpSirMacMgmtHdr) (pBD);
114
115 /* Prepare sequence number */
116 lim_add_mgmt_seq_num(pMac, pMacHdr);
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700117 pe_debug("seqNumLo=%d, seqNumHi=%d, mgmtSeqNum=%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800118 pMacHdr->seqControl.seqNumLo,
119 pMacHdr->seqControl.seqNumHi, pMac->mgmtSeqNum);
120}
121
122/**
123 * lim_populate_mac_header() - Fill in 802.11 header of frame
124 *
125 * @mac_ctx: Pointer to Global MAC structure
126 * @buf: Pointer to the frame buffer that needs to be populate
127 * @type: 802.11 Type of the frame
128 * @sub_type: 802.11 Subtype of the frame
129 * @peer_addr: dst address
130 * @self_mac_addr: local mac address
131 *
132 * This function is called by various LIM modules to prepare the
133 * 802.11 frame MAC header
134 *
135 * The buf argument points to the beginning of the frame buffer to
136 * which - a) The 802.11 MAC header is set b) Following this MAC header
137 * will be the MGMT frame payload The payload itself is populated by the
138 * caller API
139 *
140 * Return: None
141 */
142
143void lim_populate_mac_header(tpAniSirGlobal mac_ctx, uint8_t *buf,
144 uint8_t type, uint8_t sub_type, tSirMacAddr peer_addr,
145 tSirMacAddr self_mac_addr)
146{
147 tpSirMacMgmtHdr mac_hdr;
148
149 /* Prepare MAC management header */
150 mac_hdr = (tpSirMacMgmtHdr) (buf);
151
152 /* Prepare FC */
153 mac_hdr->fc.protVer = SIR_MAC_PROTOCOL_VERSION;
154 mac_hdr->fc.type = type;
155 mac_hdr->fc.subType = sub_type;
156
157 /* Prepare Address 1 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530158 qdf_mem_copy((uint8_t *) mac_hdr->da,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800159 (uint8_t *) peer_addr, sizeof(tSirMacAddr));
160
161 /* Prepare Address 2 */
162 sir_copy_mac_addr(mac_hdr->sa, self_mac_addr);
163
164 /* Prepare Address 3 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530165 qdf_mem_copy((uint8_t *) mac_hdr->bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800166 (uint8_t *) peer_addr, sizeof(tSirMacAddr));
167
168 /* Prepare sequence number */
169 lim_add_mgmt_seq_num(mac_ctx, mac_hdr);
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700170 pe_debug("seqNumLo=%d, seqNumHi=%d, mgmtSeqNum=%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800171 mac_hdr->seqControl.seqNumLo,
172 mac_hdr->seqControl.seqNumHi, mac_ctx->mgmtSeqNum);
173}
174
175/**
176 * lim_send_probe_req_mgmt_frame() - send probe request management frame
177 * @mac_ctx: Pointer to Global MAC structure
178 * @ssid: SSID to be sent in Probe Request frame
179 * @bssid: BSSID to be sent in Probe Request frame
180 * @channel: Channel # on which the Probe Request is going out
181 * @self_macaddr: self MAC address
182 * @dot11mode: self dotllmode
183 * @additional_ielen: if non-zero, include additional_ie in the Probe Request
184 * frame
185 * @additional_ie: if additional_ielen is non zero, include this field in the
186 * Probe Request frame
187 *
188 * This function is called by various LIM modules to send Probe Request frame
189 * during active scan/learn phase.
190 * Probe request is sent out in the following scenarios:
191 * --heartbeat failure: session needed
192 * --join req: session needed
193 * --foreground scan: no session
194 * --background scan: no session
195 * --sch_beacon_processing: to get EDCA parameters: session needed
196 *
197 * Return: tSirRetStatus (eSIR_SUCCESS on success and error codes otherwise)
198 */
199tSirRetStatus
200lim_send_probe_req_mgmt_frame(tpAniSirGlobal mac_ctx,
201 tSirMacSSid *ssid,
202 tSirMacAddr bssid,
203 uint8_t channel,
204 tSirMacAddr self_macaddr,
205 uint32_t dot11mode,
Sandeep Puligilla06ae8902018-04-16 19:02:47 -0700206 uint16_t *additional_ielen, uint8_t *additional_ie)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800207{
208 tDot11fProbeRequest pr;
209 uint32_t status, bytes, payload;
210 uint8_t *frame;
211 void *packet;
Kapil Guptac03eb072016-08-09 14:01:36 +0530212 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800213 tpPESession pesession;
214 uint8_t sessionid;
Naveen Rawat08db88f2017-09-08 15:07:48 -0700215 const uint8_t *p2pie = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800216 uint8_t txflag = 0;
217 uint8_t sme_sessionid = 0;
218 bool is_vht_enabled = false;
219 uint8_t txPower;
Arif Hussain4c265132018-04-23 18:55:26 -0700220 uint16_t addn_ielen = 0;
Kapil Guptac03eb072016-08-09 14:01:36 +0530221 bool extracted_ext_cap_flag = false;
222 tDot11fIEExtCap extracted_ext_cap;
223 tSirRetStatus sir_status;
Abhishek Singh67e02bd2017-12-11 10:47:12 +0530224 const uint8_t *qcn_ie = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800225
Arif Hussain4c265132018-04-23 18:55:26 -0700226 if (additional_ielen)
227 addn_ielen = *additional_ielen;
228
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800229 /* 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) &&
Abhishek Singh221cf992018-02-22 13:44:53 +0530270 ((pesession != NULL) &&
271 (QDF_P2P_CLIENT_MODE == pesession->pePersona))) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800272 /*
273 * In the below API pass channel number > 14, do that it fills
274 * only 11a rates in supported rates
275 */
276 populate_dot11f_supp_rates(mac_ctx, 15, &pr.SuppRates,
277 pesession);
278 } else {
279 populate_dot11f_supp_rates(mac_ctx, channel,
280 &pr.SuppRates, pesession);
281
282 if (WNI_CFG_DOT11_MODE_11B != dot11mode) {
283 populate_dot11f_ext_supp_rates1(mac_ctx, channel,
284 &pr.ExtSuppRates);
285 }
286 }
287
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800288 /*
289 * Table 7-14 in IEEE Std. 802.11k-2008 says
290 * DS params "can" be present in RRM is disabled and "is" present if
291 * RRM is enabled. It should be ok even if we add it into probe req when
292 * RRM is not enabled.
293 */
294 populate_dot11f_ds_params(mac_ctx, &pr.DSParams, channel);
295 /* Call RRM module to get the tx power for management used. */
296 txPower = (uint8_t) rrm_get_mgmt_tx_power(mac_ctx, pesession);
297 populate_dot11f_wfatpc(mac_ctx, &pr.WFATPC, txPower, 0);
298
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800299
300 if (pesession != NULL) {
301 pesession->htCapability = IS_DOT11_MODE_HT(dot11mode);
302 /* Include HT Capability IE */
303 if (pesession->htCapability)
304 populate_dot11f_ht_caps(mac_ctx, pesession, &pr.HTCaps);
305 } else { /* pesession == NULL */
306 if (IS_DOT11_MODE_HT(dot11mode))
307 populate_dot11f_ht_caps(mac_ctx, NULL, &pr.HTCaps);
308 }
309
310 /*
311 * Set channelbonding information as "disabled" when tunned to a
312 * 2.4 GHz channel
313 */
314 if (channel <= SIR_11B_CHANNEL_END) {
315 if (mac_ctx->roam.configParam.channelBondingMode24GHz
316 == PHY_SINGLE_CHANNEL_CENTERED) {
317 pr.HTCaps.supportedChannelWidthSet =
318 eHT_CHANNEL_WIDTH_20MHZ;
319 pr.HTCaps.shortGI40MHz = 0;
320 } else {
321 pr.HTCaps.supportedChannelWidthSet =
322 eHT_CHANNEL_WIDTH_40MHZ;
323 }
324 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800325 if (pesession != NULL) {
326 pesession->vhtCapability = IS_DOT11_MODE_VHT(dot11mode);
327 /* Include VHT Capability IE */
328 if (pesession->vhtCapability) {
329 populate_dot11f_vht_caps(mac_ctx, pesession,
330 &pr.VHTCaps);
331 is_vht_enabled = true;
332 }
333 } else {
334 if (IS_DOT11_MODE_VHT(dot11mode)) {
335 populate_dot11f_vht_caps(mac_ctx, pesession,
336 &pr.VHTCaps);
337 is_vht_enabled = true;
338 }
339 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800340 if (pesession != NULL)
341 populate_dot11f_ext_cap(mac_ctx, is_vht_enabled, &pr.ExtCap,
342 pesession);
343
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -0800344 if (IS_DOT11_MODE_HE(dot11mode) && NULL != pesession)
345 lim_update_session_he_capable(mac_ctx, pesession);
346
Srinivas Girigowda28fb0122017-03-26 22:21:20 -0700347 pe_debug("Populate HE IEs");
Naveen Rawatd8feac12017-09-08 15:08:39 -0700348 populate_dot11f_he_caps(mac_ctx, pesession, &pr.he_cap);
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -0800349
Sandeep Puligilla493fea22018-04-30 15:31:17 -0700350 if (addn_ielen && additional_ie) {
Kapil Guptac03eb072016-08-09 14:01:36 +0530351 qdf_mem_zero((uint8_t *)&extracted_ext_cap,
352 sizeof(tDot11fIEExtCap));
353 sir_status = lim_strip_extcap_update_struct(mac_ctx,
354 additional_ie,
355 &addn_ielen,
356 &extracted_ext_cap);
357 if (eSIR_SUCCESS != sir_status) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700358 pe_debug("Unable to Stripoff ExtCap IE from Probe Req");
Kapil Guptac03eb072016-08-09 14:01:36 +0530359 } else {
360 struct s_ext_cap *p_ext_cap =
361 (struct s_ext_cap *)
362 extracted_ext_cap.bytes;
363 if (p_ext_cap->interworking_service)
364 p_ext_cap->qos_map = 1;
Hu Wang411e0cc2016-10-28 14:56:01 +0800365 extracted_ext_cap.num_bytes =
366 lim_compute_ext_cap_ie_length
367 (&extracted_ext_cap);
Kapil Guptac03eb072016-08-09 14:01:36 +0530368 extracted_ext_cap_flag =
Hu Wang411e0cc2016-10-28 14:56:01 +0800369 (extracted_ext_cap.num_bytes > 0);
Arif Hussain4c265132018-04-23 18:55:26 -0700370 if (additional_ielen)
371 *additional_ielen = addn_ielen;
Kapil Guptac03eb072016-08-09 14:01:36 +0530372 }
Abhishek Singh67e02bd2017-12-11 10:47:12 +0530373 qcn_ie = wlan_get_vendor_ie_ptr_from_oui(SIR_MAC_QCN_OUI_TYPE,
374 SIR_MAC_QCN_OUI_TYPE_SIZE,
375 additional_ie, addn_ielen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800376 }
Abhishek Singh67e02bd2017-12-11 10:47:12 +0530377 /* Add qcn_ie only if qcn ie is not present in additional_ie */
378 if (mac_ctx->roam.configParam.qcn_ie_support && !qcn_ie)
379 populate_dot11f_qcn_ie(&pr.QCN_IE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800380
Hu Wang411e0cc2016-10-28 14:56:01 +0800381 /*
382 * Extcap IE now support variable length, merge Extcap IE from addn_ie
383 * may change the frame size. Therefore, MUST merge ExtCap IE before
384 * dot11f get packed payload size.
385 */
386 if (extracted_ext_cap_flag)
Hu Wangfbd279d2016-10-31 18:24:34 +0800387 lim_merge_extcap_struct(&pr.ExtCap, &extracted_ext_cap, true);
Hu Wang411e0cc2016-10-28 14:56:01 +0800388
389 /* That's it-- now we pack it. First, how much space are we going to */
390 status = dot11f_get_packed_probe_request_size(mac_ctx, &pr, &payload);
391 if (DOT11F_FAILED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700392 pe_err("Failed to calculate the packed size for a Probe Request (0x%08x)",
Hu Wang411e0cc2016-10-28 14:56:01 +0800393 status);
394 /* We'll fall back on the worst case scenario: */
395 payload = sizeof(tDot11fProbeRequest);
396 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700397 pe_warn("There were warnings while calculating the packed size for a Probe Request (0x%08x)",
Hu Wang411e0cc2016-10-28 14:56:01 +0800398 status);
399 }
400
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800401 bytes = payload + sizeof(tSirMacMgmtHdr) + addn_ielen;
402
403 /* Ok-- try to allocate some memory: */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530404 qdf_status = cds_packet_alloc((uint16_t) bytes, (void **)&frame,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800405 (void **)&packet);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530406 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700407 pe_err("Failed to allocate %d bytes for a Probe Request", bytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800408 return eSIR_MEM_ALLOC_FAILED;
409 }
410 /* Paranoia: */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530411 qdf_mem_set(frame, bytes, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800412
413 /* Next, we fill out the buffer descriptor: */
414 lim_populate_mac_header(mac_ctx, frame, SIR_MAC_MGMT_FRAME,
415 SIR_MAC_MGMT_PROBE_REQ, bssid, self_macaddr);
416
417 /* That done, pack the Probe Request: */
418 status = dot11f_pack_probe_request(mac_ctx, &pr, frame +
419 sizeof(tSirMacMgmtHdr),
420 payload, &payload);
421 if (DOT11F_FAILED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700422 pe_err("Failed to pack a Probe Request (0x%08x)", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800423 cds_packet_free((void *)packet);
424 return eSIR_FAILURE; /* allocated! */
425 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700426 pe_warn("There were warnings while packing a Probe Request (0x%08x)", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800427 }
428 /* Append any AddIE if present. */
429 if (addn_ielen) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530430 qdf_mem_copy(frame + sizeof(tSirMacMgmtHdr) + payload,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800431 additional_ie, addn_ielen);
432 payload += addn_ielen;
433 }
434
435 /* If this probe request is sent during P2P Search State, then we need
436 * to send it at OFDM rate.
437 */
Abhishek Singh221cf992018-02-22 13:44:53 +0530438 if ((BAND_5G == lim_get_rf_band(channel)) ||
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800439 /*
440 * For unicast probe req mgmt from Join function we don't set
441 * above variables. So we need to add one more check whether it
442 * is pePersona is P2P_CLIENT or not
443 */
Abhishek Singh221cf992018-02-22 13:44:53 +0530444 ((pesession != NULL) &&
445 (QDF_P2P_CLIENT_MODE == pesession->pePersona))) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800446 txflag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
447 }
448
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530449 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800450 wma_tx_frame(mac_ctx, packet,
451 (uint16_t) sizeof(tSirMacMgmtHdr) + payload,
452 TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS, 7,
453 lim_tx_complete, frame, txflag, sme_sessionid,
Naveen Rawat296a5182017-09-25 14:02:48 -0700454 0, RATEID_DEFAULT);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530455 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700456 pe_err("could not send Probe Request frame!");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800457 /* Pkt will be freed up by the callback */
458 return eSIR_FAILURE;
459 }
460
461 return eSIR_SUCCESS;
462} /* End lim_send_probe_req_mgmt_frame. */
463
Jeff Johnson38112a32016-10-07 07:30:50 -0700464static tSirRetStatus lim_get_addn_ie_for_probe_resp(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800465 uint8_t *addIE, uint16_t *addnIELen,
466 uint8_t probeReqP2pIe)
467{
468 /* If Probe request doesn't have P2P IE, then take out P2P IE
469 from additional IE */
470 if (!probeReqP2pIe) {
471 uint8_t *tempbuf = NULL;
472 uint16_t tempLen = 0;
473 int left = *addnIELen;
474 uint8_t *ptr = addIE;
475 uint8_t elem_id, elem_len;
476
477 if (NULL == addIE) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700478 pe_err("NULL addIE pointer");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800479 return eSIR_FAILURE;
480 }
481
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530482 tempbuf = qdf_mem_malloc(left);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800483 if (NULL == tempbuf) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700484 pe_err("Unable to allocate memory to store addn IE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800485 return eSIR_MEM_ALLOC_FAILED;
486 }
487
488 while (left >= 2) {
489 elem_id = ptr[0];
490 elem_len = ptr[1];
491 left -= 2;
492 if (elem_len > left) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700493 pe_err("Invalid IEs eid: %d elem_len: %d left: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800494 elem_id, elem_len, left);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530495 qdf_mem_free(tempbuf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800496 return eSIR_FAILURE;
497 }
498 if (!((SIR_MAC_EID_VENDOR == elem_id) &&
499 (memcmp
500 (&ptr[2], SIR_MAC_P2P_OUI,
501 SIR_MAC_P2P_OUI_SIZE) == 0))) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530502 qdf_mem_copy(tempbuf + tempLen, &ptr[0],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800503 elem_len + 2);
504 tempLen += (elem_len + 2);
505 }
506 left -= elem_len;
507 ptr += (elem_len + 2);
508 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530509 qdf_mem_copy(addIE, tempbuf, tempLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800510 *addnIELen = tempLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530511 qdf_mem_free(tempbuf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800512 }
513 return eSIR_SUCCESS;
514}
515
516/**
517 * lim_send_probe_rsp_mgmt_frame() - Send probe response
518 *
519 * @mac_ctx: Handle for mac context
520 * @peer_macaddr: Mac address of requesting peer
521 * @ssid: SSID for response
522 * @n_staid: Station ID, currently unused.
523 * @pe_session: PE session id
524 * @keepalive: Keep alive flag. Currently unused.
525 * @preq_p2pie: P2P IE in incoming probe request
526 *
527 * Builds and sends probe response frame to the requesting peer
528 *
529 * Return: void
530 */
531
532void
533lim_send_probe_rsp_mgmt_frame(tpAniSirGlobal mac_ctx,
534 tSirMacAddr peer_macaddr,
535 tpAniSSID ssid,
536 short n_staid,
537 uint8_t keepalive,
538 tpPESession pe_session, uint8_t preq_p2pie)
539{
540 tDot11fProbeResponse *frm;
541 tSirRetStatus sir_status;
Hu Wang411e0cc2016-10-28 14:56:01 +0800542 uint32_t cfg, payload, bytes = 0, status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800543 tpSirMacMgmtHdr mac_hdr;
544 uint8_t *frame;
Arif Hussainfbf50682016-06-15 12:57:43 -0700545 void *packet = NULL;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530546 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800547 uint32_t addn_ie_present = false;
548
549 uint16_t addn_ie_len = 0;
550 uint32_t wps_ap = 0, tmp;
551 uint8_t tx_flag = 0;
552 uint8_t *add_ie = NULL;
Naveen Rawat08db88f2017-09-08 15:07:48 -0700553 const uint8_t *p2p_ie = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800554 uint8_t noalen = 0;
555 uint8_t total_noalen = 0;
556 uint8_t noa_stream[SIR_MAX_NOA_ATTR_LEN + SIR_P2P_IE_HEADER_LEN];
557 uint8_t noa_ie[SIR_MAX_NOA_ATTR_LEN + SIR_P2P_IE_HEADER_LEN];
558 uint8_t sme_sessionid = 0;
559 bool is_vht_enabled = false;
Padma, Santhosh Kumar92234472017-04-19 18:20:02 +0530560 tDot11fIEExtCap extracted_ext_cap = {0};
Selvaraj, Sridhar94ece202016-06-23 20:44:09 +0530561 bool extracted_ext_cap_flag = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800562
563 /* We don't answer requests in this case*/
Srinivas Girigowda35b00312017-06-27 21:52:03 -0700564 if (ANI_DRIVER_TYPE(mac_ctx) == QDF_DRIVER_TYPE_MFG)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800565 return;
566
567 if (NULL == pe_session)
568 return;
569
570 /*
571 * In case when cac timer is running for this SAP session then
572 * avoid sending probe rsp out. It is violation of dfs specification.
573 */
Anurag Chouhan6d760662016-02-20 16:05:43 +0530574 if (((pe_session->pePersona == QDF_SAP_MODE) ||
575 (pe_session->pePersona == QDF_P2P_GO_MODE)) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800576 (true == mac_ctx->sap.SapDfsInfo.is_dfs_cac_timer_running)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530577 QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_INFO,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800578 FL("CAC timer is running, probe response dropped"));
579 return;
580 }
581 sme_sessionid = pe_session->smeSessionId;
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530582 frm = qdf_mem_malloc(sizeof(tDot11fProbeResponse));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800583 if (NULL == frm) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700584 pe_err("Unable to allocate memory");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800585 return;
586 }
587
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800588 /*
589 * Fill out 'frm', after which we'll just hand the struct off to
590 * 'dot11f_pack_probe_response'.
591 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530592 qdf_mem_set((uint8_t *) frm, sizeof(tDot11fProbeResponse), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800593
594 /*
595 * Timestamp to be updated by TFP, below.
596 *
597 * Beacon Interval:
598 */
599 if (LIM_IS_AP_ROLE(pe_session)) {
600 frm->BeaconInterval.interval =
601 mac_ctx->sch.schObject.gSchBeaconInterval;
602 } else {
603 sir_status = wlan_cfg_get_int(mac_ctx,
604 WNI_CFG_BEACON_INTERVAL, &cfg);
605 if (eSIR_SUCCESS != sir_status) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700606 pe_err("Failed to get WNI_CFG_BEACON_INTERVAL (%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800607 sir_status);
608 goto err_ret;
609 }
610 frm->BeaconInterval.interval = (uint16_t) cfg;
611 }
612
613 populate_dot11f_capabilities(mac_ctx, &frm->Capabilities, pe_session);
614 populate_dot11f_ssid(mac_ctx, (tSirMacSSid *) ssid, &frm->SSID);
615 populate_dot11f_supp_rates(mac_ctx, POPULATE_DOT11F_RATES_OPERATIONAL,
616 &frm->SuppRates, pe_session);
617
618 populate_dot11f_ds_params(mac_ctx, &frm->DSParams,
619 pe_session->currentOperChannel);
620 populate_dot11f_ibss_params(mac_ctx, &frm->IBSSParams, pe_session);
621
622 if (LIM_IS_AP_ROLE(pe_session)) {
623 if (pe_session->wps_state != SAP_WPS_DISABLED)
624 populate_dot11f_probe_res_wpsi_es(mac_ctx,
625 &frm->WscProbeRes,
626 pe_session);
627 } else {
628 if (wlan_cfg_get_int(mac_ctx, (uint16_t) WNI_CFG_WPS_ENABLE,
629 &tmp) != eSIR_SUCCESS)
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700630 pe_err("Failed to cfg get id %d", WNI_CFG_WPS_ENABLE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800631
632 wps_ap = tmp & WNI_CFG_WPS_ENABLE_AP;
633
634 if (wps_ap)
635 populate_dot11f_wsc_in_probe_res(mac_ctx,
636 &frm->WscProbeRes);
637
638 if (mac_ctx->lim.wscIeInfo.probeRespWscEnrollmentState ==
639 eLIM_WSC_ENROLL_BEGIN) {
640 populate_dot11f_wsc_registrar_info_in_probe_res(mac_ctx,
641 &frm->WscProbeRes);
642 mac_ctx->lim.wscIeInfo.probeRespWscEnrollmentState =
643 eLIM_WSC_ENROLL_IN_PROGRESS;
644 }
645
646 if (mac_ctx->lim.wscIeInfo.wscEnrollmentState ==
647 eLIM_WSC_ENROLL_END) {
648 de_populate_dot11f_wsc_registrar_info_in_probe_res(
649 mac_ctx, &frm->WscProbeRes);
650 mac_ctx->lim.wscIeInfo.probeRespWscEnrollmentState =
651 eLIM_WSC_ENROLL_NOOP;
652 }
653 }
654
655 populate_dot11f_country(mac_ctx, &frm->Country, pe_session);
656 populate_dot11f_edca_param_set(mac_ctx, &frm->EDCAParamSet, pe_session);
657
658 if (pe_session->dot11mode != WNI_CFG_DOT11_MODE_11B)
659 populate_dot11f_erp_info(mac_ctx, &frm->ERPInfo, pe_session);
660
661 populate_dot11f_ext_supp_rates(mac_ctx,
662 POPULATE_DOT11F_RATES_OPERATIONAL,
663 &frm->ExtSuppRates, pe_session);
664
665 /* Populate HT IEs, when operating in 11n */
666 if (pe_session->htCapability) {
667 populate_dot11f_ht_caps(mac_ctx, pe_session, &frm->HTCaps);
668 populate_dot11f_ht_info(mac_ctx, &frm->HTInfo, pe_session);
669 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800670 if (pe_session->vhtCapability) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700671 pe_debug("Populate VHT IE in Probe Response");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800672 populate_dot11f_vht_caps(mac_ctx, pe_session, &frm->VHTCaps);
673 populate_dot11f_vht_operation(mac_ctx, pe_session,
674 &frm->VHTOperation);
675 /*
676 * we do not support multi users yet.
677 * populate_dot11f_vht_ext_bss_load( mac_ctx,
678 * &frm.VHTExtBssLoad );
679 */
680 is_vht_enabled = true;
681 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800682
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -0800683 if (lim_is_session_he_capable(pe_session)) {
Srinivas Girigowda28fb0122017-03-26 22:21:20 -0700684 pe_debug("Populate HE IEs");
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -0800685 populate_dot11f_he_caps(mac_ctx, pe_session,
Naveen Rawatd8feac12017-09-08 15:08:39 -0700686 &frm->he_cap);
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -0800687 populate_dot11f_he_operation(mac_ctx, pe_session,
Naveen Rawatd8feac12017-09-08 15:08:39 -0700688 &frm->he_op);
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -0800689 }
690
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800691 populate_dot11f_ext_cap(mac_ctx, is_vht_enabled, &frm->ExtCap,
692 pe_session);
693
694 if (pe_session->pLimStartBssReq) {
695 populate_dot11f_wpa(mac_ctx,
696 &(pe_session->pLimStartBssReq->rsnIE),
697 &frm->WPA);
698 populate_dot11f_rsn_opaque(mac_ctx,
699 &(pe_session->pLimStartBssReq->rsnIE),
700 &frm->RSNOpaque);
701 }
702
703 populate_dot11f_wmm(mac_ctx, &frm->WMMInfoAp, &frm->WMMParams,
704 &frm->WMMCaps, pe_session);
705
706#if defined(FEATURE_WLAN_WAPI)
707 if (pe_session->pLimStartBssReq)
708 populate_dot11f_wapi(mac_ctx,
709 &(pe_session->pLimStartBssReq->rsnIE),
710 &frm->WAPI);
711#endif /* defined(FEATURE_WLAN_WAPI) */
712
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800713 if (mac_ctx->lim.gpLimRemainOnChanReq)
714 bytes += (mac_ctx->lim.gpLimRemainOnChanReq->length -
715 sizeof(tSirRemainOnChnReq));
716 else
717 /*
718 * Only use CFG for non-listen mode. This CFG is not working for
719 * concurrency. In listening mode, probe rsp IEs is passed in
720 * the message from SME to PE.
721 */
722 addn_ie_present =
723 (pe_session->addIeParams.probeRespDataLen != 0);
724
725 if (addn_ie_present) {
726
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530727 add_ie = qdf_mem_malloc(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800728 pe_session->addIeParams.probeRespDataLen);
729 if (NULL == add_ie) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700730 pe_err("add_ie allocation failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800731 goto err_ret;
732 }
733
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530734 qdf_mem_copy(add_ie,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800735 pe_session->addIeParams.probeRespData_buff,
736 pe_session->addIeParams.probeRespDataLen);
737 addn_ie_len = pe_session->addIeParams.probeRespDataLen;
738
739 if (eSIR_SUCCESS != lim_get_addn_ie_for_probe_resp(mac_ctx,
740 add_ie, &addn_ie_len, preq_p2pie)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700741 pe_err("Unable to get addn_ie");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800742 goto err_ret;
743 }
744
745 sir_status = lim_strip_extcap_update_struct(mac_ctx,
746 add_ie, &addn_ie_len,
747 &extracted_ext_cap);
748 if (eSIR_SUCCESS != sir_status) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700749 pe_debug("Unable to strip off ExtCap IE");
Selvaraj, Sridhar94ece202016-06-23 20:44:09 +0530750 } else {
751 extracted_ext_cap_flag = true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800752 }
753
754 bytes = bytes + addn_ie_len;
755
756 if (preq_p2pie)
757 p2p_ie = limGetP2pIEPtr(mac_ctx, &add_ie[0],
758 addn_ie_len);
759
760 if (p2p_ie != NULL) {
761 /* get NoA attribute stream P2P IE */
762 noalen = lim_get_noa_attr_stream(mac_ctx,
763 noa_stream, pe_session);
764 if (noalen != 0) {
765 total_noalen =
766 lim_build_p2p_ie(mac_ctx, &noa_ie[0],
767 &noa_stream[0], noalen);
768 bytes = bytes + total_noalen;
769 }
770 }
771 }
772
Hu Wang411e0cc2016-10-28 14:56:01 +0800773 /*
774 * Extcap IE now support variable length, merge Extcap IE from addn_ie
775 * may change the frame size. Therefore, MUST merge ExtCap IE before
776 * dot11f get packed payload size.
777 */
778 if (extracted_ext_cap_flag)
Hu Wangfbd279d2016-10-31 18:24:34 +0800779 lim_merge_extcap_struct(&frm->ExtCap, &extracted_ext_cap,
780 true);
Hu Wang411e0cc2016-10-28 14:56:01 +0800781
782 status = dot11f_get_packed_probe_response_size(mac_ctx, frm, &payload);
783 if (DOT11F_FAILED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700784 pe_err("Probe Response size error (0x%08x)",
Hu Wang411e0cc2016-10-28 14:56:01 +0800785 status);
786 /* We'll fall back on the worst case scenario: */
787 payload = sizeof(tDot11fProbeResponse);
788 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700789 pe_warn("Probe Response size warning (0x%08x)",
Hu Wang411e0cc2016-10-28 14:56:01 +0800790 status);
791 }
792
793 bytes += payload + sizeof(tSirMacMgmtHdr);
794
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530795 qdf_status = cds_packet_alloc((uint16_t) bytes, (void **)&frame,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800796 (void **)&packet);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530797 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700798 pe_err("Probe Response allocation failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800799 goto err_ret;
800 }
801 /* Paranoia: */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530802 qdf_mem_set(frame, bytes, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800803
804 /* Next, we fill out the buffer descriptor: */
805 lim_populate_mac_header(mac_ctx, frame, SIR_MAC_MGMT_FRAME,
806 SIR_MAC_MGMT_PROBE_RSP, peer_macaddr,
807 pe_session->selfMacAddr);
808
809 mac_hdr = (tpSirMacMgmtHdr) frame;
810
811 sir_copy_mac_addr(mac_hdr->bssId, pe_session->bssId);
812
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800813 /* That done, pack the Probe Response: */
814 status =
815 dot11f_pack_probe_response(mac_ctx, frm,
816 frame + sizeof(tSirMacMgmtHdr),
817 payload, &payload);
818 if (DOT11F_FAILED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700819 pe_err("Probe Response pack failure (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800820 status);
821 goto err_ret;
822 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700823 pe_warn("Probe Response pack warning (0x%08x)", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800824 }
825
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700826 pe_debug("Sending Probe Response frame to");
Nishank Aggarwal46bd31a2017-03-10 16:23:53 +0530827 lim_print_mac_addr(mac_ctx, peer_macaddr, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800828
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800829 if (mac_ctx->lim.gpLimRemainOnChanReq)
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530830 qdf_mem_copy(frame + sizeof(tSirMacMgmtHdr) + payload,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800831 mac_ctx->lim.gpLimRemainOnChanReq->probeRspIe,
832 (mac_ctx->lim.gpLimRemainOnChanReq->length -
833 sizeof(tSirRemainOnChnReq)));
834
835 if (addn_ie_present)
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530836 qdf_mem_copy(frame + sizeof(tSirMacMgmtHdr) + payload,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800837 &add_ie[0], addn_ie_len);
838
839 if (noalen != 0) {
840 if (total_noalen >
841 (SIR_MAX_NOA_ATTR_LEN + SIR_P2P_IE_HEADER_LEN)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700842 pe_err("Not able to insert NoA, total len=%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800843 total_noalen);
844 goto err_ret;
845 } else {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530846 qdf_mem_copy(&frame[bytes - (total_noalen)],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800847 &noa_ie[0], total_noalen);
848 }
849 }
850
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -0800851 if ((BAND_5G == lim_get_rf_band(pe_session->currentOperChannel))
Anurag Chouhan6d760662016-02-20 16:05:43 +0530852 || (pe_session->pePersona == QDF_P2P_CLIENT_MODE) ||
853 (pe_session->pePersona == QDF_P2P_GO_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800854 )
855 tx_flag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
856
857 /* Queue Probe Response frame in high priority WQ */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530858 qdf_status = wma_tx_frame((tHalHandle) mac_ctx, packet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800859 (uint16_t) bytes,
860 TXRX_FRM_802_11_MGMT,
861 ANI_TXDIR_TODS,
862 7, lim_tx_complete, frame, tx_flag,
Naveen Rawat296a5182017-09-25 14:02:48 -0700863 sme_sessionid, 0, RATEID_DEFAULT);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800864
865 /* Pkt will be freed up by the callback */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530866 if (!QDF_IS_STATUS_SUCCESS(qdf_status))
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700867 pe_err("Could not send Probe Response");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800868
869 if (add_ie != NULL)
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530870 qdf_mem_free(add_ie);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800871
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530872 qdf_mem_free(frm);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800873 return;
874
875err_ret:
876 if (add_ie != NULL)
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530877 qdf_mem_free(add_ie);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800878 if (frm != NULL)
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530879 qdf_mem_free(frm);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800880 if (packet != NULL)
881 cds_packet_free((void *)packet);
882 return;
883
884} /* End lim_send_probe_rsp_mgmt_frame. */
885
886void
887lim_send_addts_req_action_frame(tpAniSirGlobal pMac,
888 tSirMacAddr peerMacAddr,
889 tSirAddtsReqInfo *pAddTS, tpPESession psessionEntry)
890{
891 uint16_t i;
892 uint8_t *pFrame;
893 tDot11fAddTSRequest AddTSReq;
894 tDot11fWMMAddTSRequest WMMAddTSReq;
895 uint32_t nPayload, nBytes, nStatus;
896 tpSirMacMgmtHdr pMacHdr;
897 void *pPacket;
898#ifdef FEATURE_WLAN_ESE
899 uint32_t phyMode;
900#endif
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530901 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800902 uint8_t txFlag = 0;
903 uint8_t smeSessionId = 0;
904
905 if (NULL == psessionEntry) {
906 return;
907 }
908
909 smeSessionId = psessionEntry->smeSessionId;
910
911 if (!pAddTS->wmeTspecPresent) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530912 qdf_mem_set((uint8_t *) &AddTSReq, sizeof(AddTSReq), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800913
914 AddTSReq.Action.action = SIR_MAC_QOS_ADD_TS_REQ;
915 AddTSReq.DialogToken.token = pAddTS->dialogToken;
916 AddTSReq.Category.category = SIR_MAC_ACTION_QOS_MGMT;
917 if (pAddTS->lleTspecPresent) {
918 populate_dot11f_tspec(&pAddTS->tspec, &AddTSReq.TSPEC);
919 } else {
920 populate_dot11f_wmmtspec(&pAddTS->tspec,
921 &AddTSReq.WMMTSPEC);
922 }
923
924 if (pAddTS->lleTspecPresent) {
925 AddTSReq.num_WMMTCLAS = 0;
926 AddTSReq.num_TCLAS = pAddTS->numTclas;
927 for (i = 0; i < pAddTS->numTclas; ++i) {
928 populate_dot11f_tclas(pMac, &pAddTS->tclasInfo[i],
929 &AddTSReq.TCLAS[i]);
930 }
931 } else {
932 AddTSReq.num_TCLAS = 0;
933 AddTSReq.num_WMMTCLAS = pAddTS->numTclas;
934 for (i = 0; i < pAddTS->numTclas; ++i) {
935 populate_dot11f_wmmtclas(pMac,
936 &pAddTS->tclasInfo[i],
937 &AddTSReq.WMMTCLAS[i]);
938 }
939 }
940
941 if (pAddTS->tclasProcPresent) {
942 if (pAddTS->lleTspecPresent) {
943 AddTSReq.TCLASSPROC.processing =
944 pAddTS->tclasProc;
945 AddTSReq.TCLASSPROC.present = 1;
946 } else {
947 AddTSReq.WMMTCLASPROC.version = 1;
948 AddTSReq.WMMTCLASPROC.processing =
949 pAddTS->tclasProc;
950 AddTSReq.WMMTCLASPROC.present = 1;
951 }
952 }
953
954 nStatus =
955 dot11f_get_packed_add_ts_request_size(pMac, &AddTSReq, &nPayload);
956 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700957 pe_err("Failed to calculate the packed size for an Add TS Request (0x%08x)",
958 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800959 /* We'll fall back on the worst case scenario: */
960 nPayload = sizeof(tDot11fAddTSRequest);
961 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700962 pe_warn("There were warnings while calculating the packed size for an Add TS Request (0x%08x)",
963 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800964 }
965 } else {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530966 qdf_mem_set((uint8_t *) &WMMAddTSReq, sizeof(WMMAddTSReq), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800967
968 WMMAddTSReq.Action.action = SIR_MAC_QOS_ADD_TS_REQ;
969 WMMAddTSReq.DialogToken.token = pAddTS->dialogToken;
970 WMMAddTSReq.Category.category = SIR_MAC_ACTION_WME;
971
972 /* WMM spec 2.2.10 - status code is only filled in for ADDTS response */
973 WMMAddTSReq.StatusCode.statusCode = 0;
974
975 populate_dot11f_wmmtspec(&pAddTS->tspec, &WMMAddTSReq.WMMTSPEC);
976#ifdef FEATURE_WLAN_ESE
977 lim_get_phy_mode(pMac, &phyMode, psessionEntry);
978
979 if (phyMode == WNI_CFG_PHY_MODE_11G
980 || phyMode == WNI_CFG_PHY_MODE_11A) {
981 pAddTS->tsrsIE.rates[0] = TSRS_11AG_RATE_6MBPS;
982 } else {
983 pAddTS->tsrsIE.rates[0] = TSRS_11B_RATE_5_5MBPS;
984 }
985 populate_dot11_tsrsie(pMac, &pAddTS->tsrsIE,
986 &WMMAddTSReq.ESETrafStrmRateSet,
987 sizeof(uint8_t));
988#endif
989 /* fillWmeTspecIE */
990
991 nStatus =
992 dot11f_get_packed_wmm_add_ts_request_size(pMac, &WMMAddTSReq,
993 &nPayload);
994 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700995 pe_err("Failed to calculate the packed size for a WMM Add TS Request (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800996 nStatus);
997 /* We'll fall back on the worst case scenario: */
998 nPayload = sizeof(tDot11fAddTSRequest);
999 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001000 pe_warn("There were warnings while calculating the packed size for a WMM Add TS Request (0x%08x)",
1001 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001002 }
1003 }
1004
1005 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
1006
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301007 qdf_status = cds_packet_alloc((uint16_t) nBytes, (void **)&pFrame,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001008 (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301009 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001010 pe_err("Failed to allocate %d bytes for an Add TS Request",
1011 nBytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001012 return;
1013 }
1014 /* Paranoia: */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301015 qdf_mem_set(pFrame, nBytes, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001016
1017 /* Next, we fill out the buffer descriptor: */
1018 lim_populate_mac_header(pMac, pFrame, SIR_MAC_MGMT_FRAME,
1019 SIR_MAC_MGMT_ACTION, peerMacAddr, psessionEntry->selfMacAddr);
1020 pMacHdr = (tpSirMacMgmtHdr) pFrame;
1021
1022 sir_copy_mac_addr(pMacHdr->bssId, psessionEntry->bssId);
1023
1024#ifdef WLAN_FEATURE_11W
1025 lim_set_protected_bit(pMac, psessionEntry, peerMacAddr, pMacHdr);
1026#endif
1027
1028 /* That done, pack the struct: */
1029 if (!pAddTS->wmeTspecPresent) {
1030 nStatus = dot11f_pack_add_ts_request(pMac, &AddTSReq,
1031 pFrame +
1032 sizeof(tSirMacMgmtHdr),
1033 nPayload, &nPayload);
1034 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001035 pe_err("Failed to pack an Add TS Request "
1036 "(0x%08x)", nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001037 cds_packet_free((void *)pPacket);
1038 return; /* allocated! */
1039 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001040 pe_warn("There were warnings while packing an Add TS Request (0x%08x)",
1041 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001042 }
1043 } else {
1044 nStatus = dot11f_pack_wmm_add_ts_request(pMac, &WMMAddTSReq,
1045 pFrame +
1046 sizeof(tSirMacMgmtHdr),
1047 nPayload, &nPayload);
1048 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001049 pe_err("Failed to pack a WMM Add TS Request (0x%08x)",
1050 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001051 cds_packet_free((void *)pPacket);
1052 return; /* allocated! */
1053 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001054 pe_warn("There were warnings while packing a WMM Add TS Request (0x%08x)",
1055 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001056 }
1057 }
1058
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001059 pe_debug("Sending an Add TS Request frame to");
1060 lim_print_mac_addr(pMac, peerMacAddr, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001061
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08001062 if ((BAND_5G ==
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001063 lim_get_rf_band(psessionEntry->currentOperChannel))
Anurag Chouhan6d760662016-02-20 16:05:43 +05301064 || (psessionEntry->pePersona == QDF_P2P_CLIENT_MODE)
1065 || (psessionEntry->pePersona == QDF_P2P_GO_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001066 ) {
1067 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
1068 }
1069
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05301070 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001071 psessionEntry->peSessionId, pMacHdr->fc.subType));
Krunal Sonic65fc492018-03-09 15:53:28 -08001072 lim_diag_mgmt_tx_event_report(pMac, pMacHdr,
1073 psessionEntry, eSIR_SUCCESS,
1074 eSIR_SUCCESS);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001075
1076 /* Queue Addts Response frame in high priority WQ */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301077 qdf_status = wma_tx_frame(pMac, pPacket, (uint16_t) nBytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001078 TXRX_FRM_802_11_MGMT,
1079 ANI_TXDIR_TODS,
1080 7, lim_tx_complete, pFrame, txFlag,
Naveen Rawat296a5182017-09-25 14:02:48 -07001081 smeSessionId, 0, RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05301082 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301083 psessionEntry->peSessionId, qdf_status));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001084
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001085 if (!QDF_IS_STATUS_SUCCESS(qdf_status))
1086 pe_err("Could not send an Add TS Request (%X",
1087 qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001088} /* End lim_send_addts_req_action_frame. */
1089
1090/**
1091 * lim_send_assoc_rsp_mgmt_frame() - Send assoc response
1092 * @mac_ctx: Handle for mac context
1093 * @status_code: Status code for assoc response frame
1094 * @aid: Association ID
1095 * @peer_addr: Mac address of requesting peer
1096 * @subtype: Assoc/Reassoc
1097 * @sta: Pointer to station node
1098 * @pe_session: PE session id.
1099 *
1100 * Builds and sends association response frame to the requesting peer.
1101 *
1102 * Return: void
1103 */
1104
1105void
1106lim_send_assoc_rsp_mgmt_frame(tpAniSirGlobal mac_ctx,
1107 uint16_t status_code, uint16_t aid, tSirMacAddr peer_addr,
1108 uint8_t subtype, tpDphHashNode sta, tpPESession pe_session)
1109{
1110 static tDot11fAssocResponse frm;
1111 uint8_t *frame;
1112 tpSirMacMgmtHdr mac_hdr;
1113 tSirRetStatus sir_status;
1114 uint8_t lle_mode = 0, addts;
1115 tHalBitVal qos_mode, wme_mode;
Hu Wang411e0cc2016-10-28 14:56:01 +08001116 uint32_t payload, bytes = 0, status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001117 void *packet;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301118 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001119 tUpdateBeaconParams beacon_params;
1120 uint8_t tx_flag = 0;
1121 uint32_t addn_ie_len = 0;
1122 uint8_t add_ie[WNI_CFG_ASSOC_RSP_ADDNIE_DATA_LEN];
1123 tpSirAssocReq assoc_req = NULL;
1124 uint8_t sme_session = 0;
1125 bool is_vht = false;
1126 uint16_t stripoff_len = 0;
1127 tDot11fIEExtCap extracted_ext_cap;
1128 bool extracted_flag = false;
1129#ifdef WLAN_FEATURE_11W
1130 uint32_t retry_int;
1131 uint32_t max_retries;
1132#endif
1133
1134 if (NULL == pe_session) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001135 pe_err("pe_session is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001136 return;
1137 }
1138
1139 sme_session = pe_session->smeSessionId;
1140
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301141 qdf_mem_set((uint8_t *) &frm, sizeof(frm), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001142
1143 limGetQosMode(pe_session, &qos_mode);
1144 limGetWmeMode(pe_session, &wme_mode);
1145
1146 /*
1147 * An Add TS IE is added only if the AP supports it and
1148 * the requesting STA sent a traffic spec.
1149 */
1150 addts = (qos_mode && sta && sta->qos.addtsPresent) ? 1 : 0;
1151
1152 frm.Status.status = status_code;
1153
1154 frm.AID.associd = aid | LIM_AID_MASK;
1155
1156 if (NULL == sta) {
1157 populate_dot11f_supp_rates(mac_ctx,
1158 POPULATE_DOT11F_RATES_OPERATIONAL,
1159 &frm.SuppRates, pe_session);
1160 populate_dot11f_ext_supp_rates(mac_ctx,
1161 POPULATE_DOT11F_RATES_OPERATIONAL,
1162 &frm.ExtSuppRates, pe_session);
1163 } else {
1164 populate_dot11f_assoc_rsp_rates(mac_ctx, &frm.SuppRates,
1165 &frm.ExtSuppRates,
1166 sta->supportedRates.llbRates,
1167 sta->supportedRates.llaRates);
1168 }
1169
1170 if (LIM_IS_AP_ROLE(pe_session) && sta != NULL &&
1171 eSIR_SUCCESS == status_code) {
1172 assoc_req = (tpSirAssocReq)
1173 pe_session->parsedAssocReq[sta->assocId];
1174 /*
1175 * populate P2P IE in AssocRsp when assocReq from the peer
1176 * includes P2P IE
1177 */
1178 if (assoc_req != NULL && assoc_req->addIEPresent)
1179 populate_dot11_assoc_res_p2p_ie(mac_ctx,
1180 &frm.P2PAssocRes,
1181 assoc_req);
1182 }
1183
1184 if (NULL != sta) {
1185 if (eHAL_SET == qos_mode) {
1186 if (sta->lleEnabled) {
1187 lle_mode = 1;
1188 populate_dot11f_edca_param_set(mac_ctx,
1189 &frm.EDCAParamSet, pe_session);
1190 }
1191 }
1192
1193 if ((!lle_mode) && (eHAL_SET == wme_mode) && sta->wmeEnabled) {
1194 populate_dot11f_wmm_params(mac_ctx, &frm.WMMParams,
1195 pe_session);
1196
1197 if (sta->wsmEnabled)
1198 populate_dot11f_wmm_caps(&frm.WMMCaps);
1199 }
1200
1201 if (sta->mlmStaContext.htCapability &&
1202 pe_session->htCapability) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001203 pe_debug("Populate HT IEs in Assoc Response");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001204 populate_dot11f_ht_caps(mac_ctx, pe_session,
1205 &frm.HTCaps);
Krunal Sonief3294b2015-06-12 15:12:19 -07001206 /*
1207 * Check the STA capability and
1208 * update the HTCaps accordingly
1209 */
1210 frm.HTCaps.supportedChannelWidthSet = (
1211 sta->htSupportedChannelWidthSet <
1212 pe_session->htSupportedChannelWidthSet) ?
1213 sta->htSupportedChannelWidthSet :
1214 pe_session->htSupportedChannelWidthSet;
1215 if (!frm.HTCaps.supportedChannelWidthSet)
1216 frm.HTCaps.shortGI40MHz = 0;
1217
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001218 populate_dot11f_ht_info(mac_ctx, &frm.HTInfo,
1219 pe_session);
1220 }
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001221 pe_debug("SupportedChnlWidth: %d, mimoPS: %d, GF: %d, short GI20:%d, shortGI40: %d, dsssCck: %d, AMPDU Param: %x",
Agrawal Ashishc38e58d2015-09-16 17:17:29 +05301222 frm.HTCaps.supportedChannelWidthSet,
1223 frm.HTCaps.mimoPowerSave,
1224 frm.HTCaps.greenField, frm.HTCaps.shortGI20MHz,
1225 frm.HTCaps.shortGI40MHz,
1226 frm.HTCaps.dsssCckMode40MHz,
1227 frm.HTCaps.maxRxAMPDUFactor);
1228
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001229 if (sta->mlmStaContext.vhtCapability &&
1230 pe_session->vhtCapability) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001231 pe_debug("Populate VHT IEs in Assoc Response");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001232 populate_dot11f_vht_caps(mac_ctx, pe_session,
1233 &frm.VHTCaps);
1234 populate_dot11f_vht_operation(mac_ctx, pe_session,
Kapil Gupta4b2efbb2016-10-03 13:07:20 +05301235 &frm.VHTOperation);
1236 is_vht = true;
1237 }
Naveen Rawat903acca2017-09-15 17:32:13 -07001238
Kapil Gupta4b2efbb2016-10-03 13:07:20 +05301239 if (pe_session->vhtCapability &&
1240 pe_session->vendor_vht_sap &&
1241 (assoc_req != NULL) &&
1242 assoc_req->vendor_vht_ie.VHTCaps.present) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001243 pe_debug("Populate Vendor VHT IEs in Assoc Rsponse");
Kapil Gupta4b2efbb2016-10-03 13:07:20 +05301244 frm.vendor_vht_ie.present = 1;
Kiran Kumar Lokere81722632017-09-26 12:11:43 -07001245 frm.vendor_vht_ie.sub_type =
1246 pe_session->vendor_specific_vht_ie_sub_type;
Kapil Gupta4b2efbb2016-10-03 13:07:20 +05301247 frm.vendor_vht_ie.VHTCaps.present = 1;
1248 populate_dot11f_vht_caps(mac_ctx, pe_session,
1249 &frm.vendor_vht_ie.VHTCaps);
Kiran Kumar Lokerecc448682017-07-20 18:08:01 -07001250 populate_dot11f_vht_operation(mac_ctx, pe_session,
1251 &frm.vendor_vht_ie.VHTOperation);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001252 is_vht = true;
1253 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001254 populate_dot11f_ext_cap(mac_ctx, is_vht, &frm.ExtCap,
1255 pe_session);
1256
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08001257 if (lim_is_sta_he_capable(sta) &&
1258 lim_is_session_he_capable(pe_session)) {
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07001259 pe_debug("Populate HE IEs");
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08001260 populate_dot11f_he_caps(mac_ctx, pe_session,
Naveen Rawatd8feac12017-09-08 15:08:39 -07001261 &frm.he_cap);
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08001262 populate_dot11f_he_operation(mac_ctx, pe_session,
Naveen Rawatd8feac12017-09-08 15:08:39 -07001263 &frm.he_op);
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08001264 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001265#ifdef WLAN_FEATURE_11W
1266 if (eSIR_MAC_TRY_AGAIN_LATER == status_code) {
1267 if (wlan_cfg_get_int
1268 (mac_ctx, WNI_CFG_PMF_SA_QUERY_MAX_RETRIES,
1269 &max_retries) != eSIR_SUCCESS)
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001270 pe_err("get WNI_CFG_PMF_SA_QUERY_MAX_RETRIES failure");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001271 else if (wlan_cfg_get_int
1272 (mac_ctx,
1273 WNI_CFG_PMF_SA_QUERY_RETRY_INTERVAL,
1274 &retry_int) != eSIR_SUCCESS)
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001275 pe_err("get WNI_CFG_PMF_SA_QUERY_RETRY_INTERVAL failure");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001276 else
1277 populate_dot11f_timeout_interval(mac_ctx,
1278 &frm.TimeoutInterval,
1279 SIR_MAC_TI_TYPE_ASSOC_COMEBACK,
1280 (max_retries -
1281 sta->pmfSaQueryRetryCount)
1282 * retry_int);
1283 }
1284#endif
Arif Hussain0c816922017-04-06 15:04:44 -07001285
1286 if (LIM_IS_AP_ROLE(pe_session) && sta->non_ecsa_capable)
1287 pe_session->lim_non_ecsa_cap_num++;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001288 }
1289
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301290 qdf_mem_set((uint8_t *) &beacon_params, sizeof(beacon_params), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001291
1292 if (LIM_IS_AP_ROLE(pe_session) &&
1293 (pe_session->gLimProtectionControl !=
1294 WNI_CFG_FORCE_POLICY_PROTECTION_DISABLE))
1295 lim_decide_ap_protection(mac_ctx, peer_addr,
1296 &beacon_params, pe_session);
1297
1298 lim_update_short_preamble(mac_ctx, peer_addr, &beacon_params,
1299 pe_session);
1300 lim_update_short_slot_time(mac_ctx, peer_addr, &beacon_params,
1301 pe_session);
1302
1303 /*
1304 * Populate Do11capabilities after updating session with
1305 * Assos req details
1306 */
1307 populate_dot11f_capabilities(mac_ctx, &frm.Capabilities, pe_session);
1308
1309 beacon_params.bssIdx = pe_session->bssIdx;
1310
1311 /* Send message to HAL about beacon parameter change. */
1312 if ((false == mac_ctx->sap.SapDfsInfo.is_dfs_cac_timer_running)
1313 && beacon_params.paramChangeBitmap) {
1314 sch_set_fixed_beacon_fields(mac_ctx, pe_session);
1315 lim_send_beacon_params(mac_ctx, &beacon_params, pe_session);
1316 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001317
Arif Hussain1513cb22018-01-05 19:56:31 -08001318 lim_obss_send_detection_cfg(mac_ctx, pe_session, false);
1319
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001320 if (assoc_req != NULL) {
Krishna Kumaar Natarajane4e3a142016-04-01 16:27:51 -07001321 addn_ie_len = pe_session->addIeParams.assocRespDataLen;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001322
1323 /* Nonzero length indicates Assoc rsp IE available */
Krishna Kumaar Natarajane4e3a142016-04-01 16:27:51 -07001324 if (addn_ie_len > 0 &&
1325 addn_ie_len <= WNI_CFG_ASSOC_RSP_ADDNIE_DATA_LEN &&
1326 (bytes + addn_ie_len) <= SIR_MAX_PACKET_SIZE) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301327 qdf_mem_copy(add_ie,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001328 pe_session->addIeParams.assocRespData_buff,
1329 pe_session->addIeParams.assocRespDataLen);
1330
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301331 qdf_mem_set((uint8_t *) &extracted_ext_cap,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001332 sizeof(extracted_ext_cap), 0);
1333
1334 stripoff_len = addn_ie_len;
1335 sir_status =
1336 lim_strip_extcap_update_struct
1337 (mac_ctx, &add_ie[0], &stripoff_len,
1338 &extracted_ext_cap);
1339 if (eSIR_SUCCESS != sir_status) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001340 pe_debug("strip off extcap IE failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001341 } else {
1342 addn_ie_len = stripoff_len;
1343 extracted_flag = true;
1344 }
1345 bytes = bytes + addn_ie_len;
1346 }
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001347 pe_debug("addn_ie_len: %d for Assoc Resp: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001348 addn_ie_len, assoc_req->addIEPresent);
1349 }
Hu Wang411e0cc2016-10-28 14:56:01 +08001350
1351 /*
1352 * Extcap IE now support variable length, merge Extcap IE from addn_ie
1353 * may change the frame size. Therefore, MUST merge ExtCap IE before
1354 * dot11f get packed payload size.
1355 */
1356 if (extracted_flag)
Hu Wangfbd279d2016-10-31 18:24:34 +08001357 lim_merge_extcap_struct(&(frm.ExtCap), &extracted_ext_cap,
1358 true);
Hu Wang411e0cc2016-10-28 14:56:01 +08001359
1360 /* Allocate a buffer for this frame: */
1361 status = dot11f_get_packed_assoc_response_size(mac_ctx, &frm, &payload);
1362 if (DOT11F_FAILED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001363 pe_err("get Association Response size failure (0x%08x)",
Hu Wang411e0cc2016-10-28 14:56:01 +08001364 status);
1365 return;
1366 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001367 pe_warn("get Association Response size warning (0x%08x)",
Hu Wang411e0cc2016-10-28 14:56:01 +08001368 status);
1369 }
1370
1371 bytes += sizeof(tSirMacMgmtHdr) + payload;
1372
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301373 qdf_status = cds_packet_alloc((uint16_t) bytes, (void **)&frame,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001374 (void **)&packet);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301375 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001376 pe_err("cds_packet_alloc failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001377 return;
1378 }
1379 /* Paranoia: */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301380 qdf_mem_set(frame, bytes, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001381
1382 /* Next, we fill out the buffer descriptor: */
1383 lim_populate_mac_header(mac_ctx, frame, SIR_MAC_MGMT_FRAME,
1384 (LIM_ASSOC == subtype) ?
1385 SIR_MAC_MGMT_ASSOC_RSP : SIR_MAC_MGMT_REASSOC_RSP,
1386 peer_addr,
1387 pe_session->selfMacAddr);
1388 mac_hdr = (tpSirMacMgmtHdr) frame;
1389
1390 sir_copy_mac_addr(mac_hdr->bssId, pe_session->bssId);
1391
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001392 status = dot11f_pack_assoc_response(mac_ctx, &frm,
1393 frame + sizeof(tSirMacMgmtHdr),
1394 payload, &payload);
1395 if (DOT11F_FAILED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001396 pe_err("Association Response pack failure(0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001397 status);
1398 cds_packet_free((void *)packet);
1399 return;
1400 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001401 pe_warn("Association Response pack warning (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001402 status);
1403 }
1404
1405 if (subtype == LIM_ASSOC)
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001406 pe_debug("*** Sending Assoc Resp status %d aid %d to",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001407 status_code, aid);
1408 else
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001409 pe_debug("*** Sending ReAssoc Resp status %d aid %d to",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001410 status_code, aid);
1411
Abhishek Singh5d8d7332017-08-10 15:15:24 +05301412 lim_print_mac_addr(mac_ctx, mac_hdr->da, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001413
1414 if (addn_ie_len && addn_ie_len <= WNI_CFG_ASSOC_RSP_ADDNIE_DATA_LEN)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301415 qdf_mem_copy(frame + sizeof(tSirMacMgmtHdr) + payload,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001416 &add_ie[0], addn_ie_len);
1417
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08001418 if ((BAND_5G ==
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001419 lim_get_rf_band(pe_session->currentOperChannel)) ||
Anurag Chouhan6d760662016-02-20 16:05:43 +05301420 (pe_session->pePersona == QDF_P2P_CLIENT_MODE) ||
1421 (pe_session->pePersona == QDF_P2P_GO_MODE))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001422 tx_flag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
1423
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05301424 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001425 pe_session->peSessionId, mac_hdr->fc.subType));
Krunal Sonic65fc492018-03-09 15:53:28 -08001426 lim_diag_mgmt_tx_event_report(mac_ctx, mac_hdr,
1427 pe_session, eSIR_SUCCESS, status_code);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001428 /* Queue Association Response frame in high priority WQ */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301429 qdf_status = wma_tx_frame(mac_ctx, packet, (uint16_t) bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001430 TXRX_FRM_802_11_MGMT,
1431 ANI_TXDIR_TODS,
1432 7, lim_tx_complete, frame, tx_flag,
Naveen Rawat296a5182017-09-25 14:02:48 -07001433 sme_session, 0, RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05301434 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301435 pe_session->peSessionId, qdf_status));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001436
1437 /* Pkt will be freed up by the callback */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301438 if (!QDF_IS_STATUS_SUCCESS(qdf_status))
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001439 pe_err("Could not Send Re/AssocRsp, retCode=%X",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301440 qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001441
1442 /*
1443 * update the ANI peer station count.
1444 * FIXME_PROTECTION : take care of different type of station
1445 * counter inside this function.
1446 */
1447 lim_util_count_sta_add(mac_ctx, sta, pe_session);
1448
1449}
1450
1451void
1452lim_send_delts_req_action_frame(tpAniSirGlobal pMac,
1453 tSirMacAddr peer,
1454 uint8_t wmmTspecPresent,
1455 tSirMacTSInfo *pTsinfo,
1456 tSirMacTspecIE *pTspecIe, tpPESession psessionEntry)
1457{
1458 uint8_t *pFrame;
1459 tpSirMacMgmtHdr pMacHdr;
1460 tDot11fDelTS DelTS;
1461 tDot11fWMMDelTS WMMDelTS;
1462 uint32_t nBytes, nPayload, nStatus;
1463 void *pPacket;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301464 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001465 uint8_t txFlag = 0;
1466 uint8_t smeSessionId = 0;
1467
1468 if (NULL == psessionEntry) {
1469 return;
1470 }
1471
1472 smeSessionId = psessionEntry->smeSessionId;
1473
1474 if (!wmmTspecPresent) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301475 qdf_mem_set((uint8_t *) &DelTS, sizeof(DelTS), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001476
1477 DelTS.Category.category = SIR_MAC_ACTION_QOS_MGMT;
1478 DelTS.Action.action = SIR_MAC_QOS_DEL_TS_REQ;
1479 populate_dot11f_ts_info(pTsinfo, &DelTS.TSInfo);
1480
1481 nStatus = dot11f_get_packed_del_ts_size(pMac, &DelTS, &nPayload);
1482 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001483 pe_err("Failed to calculate the packed size for a Del TS (0x%08x)", nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001484 /* We'll fall back on the worst case scenario: */
1485 nPayload = sizeof(tDot11fDelTS);
1486 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001487 pe_warn("There were warnings while calculating the packed size for a Del TS (0x%08x)",
1488 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001489 }
1490 } else {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301491 qdf_mem_set((uint8_t *) &WMMDelTS, sizeof(WMMDelTS), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001492
1493 WMMDelTS.Category.category = SIR_MAC_ACTION_WME;
1494 WMMDelTS.Action.action = SIR_MAC_QOS_DEL_TS_REQ;
1495 WMMDelTS.DialogToken.token = 0;
1496 WMMDelTS.StatusCode.statusCode = 0;
1497 populate_dot11f_wmmtspec(pTspecIe, &WMMDelTS.WMMTSPEC);
1498 nStatus =
1499 dot11f_get_packed_wmm_del_ts_size(pMac, &WMMDelTS, &nPayload);
1500 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001501 pe_err("Failed to calculate the packed size for a WMM Del TS (0x%08x)", nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001502 /* We'll fall back on the worst case scenario: */
1503 nPayload = sizeof(tDot11fDelTS);
1504 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001505 pe_warn("There were warnings while calculating the packed size for a WMM Del TS (0x%08x)",
1506 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001507 }
1508 }
1509
1510 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
1511
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301512 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001513 cds_packet_alloc((uint16_t) nBytes, (void **)&pFrame,
1514 (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301515 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001516 pe_err("Failed to allocate %d bytes for an Add TS Response",
1517 nBytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001518 return;
1519 }
1520 /* Paranoia: */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301521 qdf_mem_set(pFrame, nBytes, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001522
1523 /* Next, we fill out the buffer descriptor: */
1524 lim_populate_mac_header(pMac, pFrame, SIR_MAC_MGMT_FRAME,
1525 SIR_MAC_MGMT_ACTION, peer, psessionEntry->selfMacAddr);
1526 pMacHdr = (tpSirMacMgmtHdr) pFrame;
1527
1528 sir_copy_mac_addr(pMacHdr->bssId, psessionEntry->bssId);
1529
1530#ifdef WLAN_FEATURE_11W
1531 lim_set_protected_bit(pMac, psessionEntry, peer, pMacHdr);
1532#endif
1533
1534 /* That done, pack the struct: */
1535 if (!wmmTspecPresent) {
1536 nStatus = dot11f_pack_del_ts(pMac, &DelTS,
1537 pFrame + sizeof(tSirMacMgmtHdr),
1538 nPayload, &nPayload);
1539 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001540 pe_err("Failed to pack a Del TS frame (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001541 nStatus);
1542 cds_packet_free((void *)pPacket);
1543 return; /* allocated! */
1544 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001545 pe_warn("There were warnings while packing a Del TS frame (0x%08x)",
1546 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001547 }
1548 } else {
1549 nStatus = dot11f_pack_wmm_del_ts(pMac, &WMMDelTS,
1550 pFrame + sizeof(tSirMacMgmtHdr),
1551 nPayload, &nPayload);
1552 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001553 pe_err("Failed to pack a WMM Del TS frame (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001554 nStatus);
1555 cds_packet_free((void *)pPacket);
1556 return; /* allocated! */
1557 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001558 pe_warn("There were warnings while packing a WMM Del TS frame (0x%08x)",
1559 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001560 }
1561 }
1562
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001563 pe_debug("Sending DELTS REQ (size %d) to ", nBytes);
1564 lim_print_mac_addr(pMac, pMacHdr->da, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001565
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08001566 if ((BAND_5G ==
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001567 lim_get_rf_band(psessionEntry->currentOperChannel))
Anurag Chouhan6d760662016-02-20 16:05:43 +05301568 || (psessionEntry->pePersona == QDF_P2P_CLIENT_MODE)
1569 || (psessionEntry->pePersona == QDF_P2P_GO_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001570 ) {
1571 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
1572 }
1573
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05301574 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001575 psessionEntry->peSessionId, pMacHdr->fc.subType));
Krunal Sonic65fc492018-03-09 15:53:28 -08001576 lim_diag_mgmt_tx_event_report(pMac, pMacHdr,
1577 psessionEntry, eSIR_SUCCESS,
1578 eSIR_SUCCESS);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301579 qdf_status = wma_tx_frame(pMac, pPacket, (uint16_t) nBytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001580 TXRX_FRM_802_11_MGMT,
1581 ANI_TXDIR_TODS,
1582 7, lim_tx_complete, pFrame, txFlag,
Naveen Rawat296a5182017-09-25 14:02:48 -07001583 smeSessionId, 0, RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05301584 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301585 psessionEntry->peSessionId, qdf_status));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001586 /* Pkt will be freed up by the callback */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301587 if (!QDF_IS_STATUS_SUCCESS(qdf_status))
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001588 pe_err("Failed to send Del TS (%X)!", qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001589
1590} /* End lim_send_delts_req_action_frame. */
1591
1592/**
Abhishek Singhdd2cb572017-08-11 11:10:19 +05301593 * lim_assoc_tx_complete_cnf()- Confirmation for assoc sent over the air
1594 * @context: pointer to global mac
1595 * @buf: buffer
1596 * @tx_complete : Sent status
1597 * @params; tx completion params
1598 *
1599 * Return: This returns QDF_STATUS
1600 */
1601
1602static QDF_STATUS lim_assoc_tx_complete_cnf(void *context,
1603 qdf_nbuf_t buf,
1604 uint32_t tx_complete,
1605 void *params)
1606{
1607 uint16_t assoc_ack_status;
1608 uint16_t reason_code;
1609 tpAniSirGlobal mac_ctx = (tpAniSirGlobal)context;
1610
1611 pe_debug("tx_complete= %d", tx_complete);
Zhu Jianmin5d8e3fe2018-01-04 16:16:20 +08001612 if (tx_complete == WMI_MGMT_TX_COMP_TYPE_COMPLETE_OK) {
Abhishek Singhdd2cb572017-08-11 11:10:19 +05301613 assoc_ack_status = ACKED;
1614 reason_code = eSIR_SUCCESS;
1615 } else {
1616 assoc_ack_status = NOT_ACKED;
1617 reason_code = eSIR_FAILURE;
1618 }
1619 if (buf)
1620 qdf_nbuf_free(buf);
1621
1622 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_ASSOC_ACK_EVENT,
1623 NULL, assoc_ack_status, reason_code);
1624 return QDF_STATUS_SUCCESS;
1625}
1626
1627/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001628 * lim_send_assoc_req_mgmt_frame() - Send association request
1629 * @mac_ctx: Handle to MAC context
1630 * @mlm_assoc_req: Association request information
1631 * @pe_session: PE session information
1632 *
1633 * Builds and transmits association request frame to AP.
1634 *
1635 * Return: Void
1636 */
1637
1638void
1639lim_send_assoc_req_mgmt_frame(tpAniSirGlobal mac_ctx,
1640 tLimMlmAssocReq *mlm_assoc_req,
1641 tpPESession pe_session)
1642{
Naveen Rawat72475db2017-12-13 18:07:35 -08001643 int ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001644 tDot11fAssocRequest *frm;
1645 uint16_t caps;
1646 uint8_t *frame;
1647 tSirRetStatus sir_status;
1648 tLimMlmAssocCnf assoc_cnf;
Hu Wang411e0cc2016-10-28 14:56:01 +08001649 uint32_t bytes = 0, payload, status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001650 uint8_t qos_enabled, wme_enabled, wsm_enabled;
1651 void *packet;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301652 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001653 uint16_t add_ie_len;
1654 uint8_t *add_ie;
Naveen Rawat08db88f2017-09-08 15:07:48 -07001655 const uint8_t *wps_ie = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001656 uint8_t power_caps = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001657 uint8_t tx_flag = 0;
1658 uint8_t sme_sessionid = 0;
1659 bool vht_enabled = false;
1660 tDot11fIEExtCap extr_ext_cap;
1661 bool extr_ext_flag = true;
1662 tpSirMacMgmtHdr mac_hdr;
Hu Wangfbd279d2016-10-31 18:24:34 +08001663 uint32_t ie_offset = 0;
1664 uint8_t *p_ext_cap = NULL;
1665 tDot11fIEExtCap bcn_ext_cap;
1666 uint8_t *bcn_ie = NULL;
1667 uint32_t bcn_ie_len = 0;
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +05301668 uint32_t aes_block_size_len = 0;
Naveen Rawat296a5182017-09-25 14:02:48 -07001669 enum rateid min_rid = RATEID_DEFAULT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001670
1671 if (NULL == pe_session) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001672 pe_err("pe_session is NULL");
yeshwanth sriram guntuka07831012017-06-30 12:26:57 +05301673 qdf_mem_free(mlm_assoc_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001674 return;
1675 }
1676
1677 sme_sessionid = pe_session->smeSessionId;
1678
1679 /* check this early to avoid unncessary operation */
1680 if (NULL == pe_session->pLimJoinReq) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001681 pe_err("pe_session->pLimJoinReq is NULL");
yeshwanth sriram guntuka07831012017-06-30 12:26:57 +05301682 qdf_mem_free(mlm_assoc_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001683 return;
1684 }
1685 add_ie_len = pe_session->pLimJoinReq->addIEAssoc.length;
1686 add_ie = pe_session->pLimJoinReq->addIEAssoc.addIEdata;
1687
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301688 frm = qdf_mem_malloc(sizeof(tDot11fAssocRequest));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001689 if (NULL == frm) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001690 pe_err("Unable to allocate memory");
yeshwanth sriram guntuka07831012017-06-30 12:26:57 +05301691 qdf_mem_free(mlm_assoc_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001692 return;
1693 }
Hu Wang411e0cc2016-10-28 14:56:01 +08001694 qdf_mem_set((uint8_t *) frm, sizeof(tDot11fAssocRequest), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001695
Agrawal Ashish0f94b572016-02-22 13:27:06 +05301696 if (add_ie_len && pe_session->is_ext_caps_present) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301697 qdf_mem_set((uint8_t *) &extr_ext_cap, sizeof(tDot11fIEExtCap),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001698 0);
1699 sir_status = lim_strip_extcap_update_struct(mac_ctx,
1700 add_ie, &add_ie_len, &extr_ext_cap);
1701 if (eSIR_SUCCESS != sir_status) {
1702 extr_ext_flag = false;
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001703 pe_debug("Unable to Stripoff ExtCap IE from Assoc Req");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001704 } else {
1705 struct s_ext_cap *p_ext_cap = (struct s_ext_cap *)
1706 extr_ext_cap.bytes;
1707
1708 if (p_ext_cap->interworking_service)
1709 p_ext_cap->qos_map = 1;
Hu Wang411e0cc2016-10-28 14:56:01 +08001710 extr_ext_cap.num_bytes =
1711 lim_compute_ext_cap_ie_length(&extr_ext_cap);
1712 extr_ext_flag = (extr_ext_cap.num_bytes > 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001713 }
1714 } else {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001715 pe_debug("No addn IE or peer dosen't support addnIE for Assoc Req");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001716 extr_ext_flag = false;
1717 }
1718
1719 caps = mlm_assoc_req->capabilityInfo;
1720#if defined(FEATURE_WLAN_WAPI)
1721 /*
1722 * According to WAPI standard:
1723 * 7.3.1.4 Capability Information field
1724 * In WAPI, non-AP STAs within an ESS set the Privacy subfield to 0
1725 * in transmitted Association or Reassociation management frames.
1726 * APs ignore the Privacy subfield within received Association and
1727 * Reassociation management frames.
1728 */
1729 if (pe_session->encryptType == eSIR_ED_WPI)
1730 ((tSirMacCapabilityInfo *) &caps)->privacy = 0;
1731#endif
1732 swap_bit_field16(caps, (uint16_t *) &frm->Capabilities);
1733
1734 frm->ListenInterval.interval = mlm_assoc_req->listenInterval;
1735 populate_dot11f_ssid2(mac_ctx, &frm->SSID);
1736 populate_dot11f_supp_rates(mac_ctx, POPULATE_DOT11F_RATES_OPERATIONAL,
1737 &frm->SuppRates, pe_session);
1738
1739 qos_enabled = (pe_session->limQosEnabled) &&
1740 SIR_MAC_GET_QOS(pe_session->limCurrentBssCaps);
1741
1742 wme_enabled = (pe_session->limWmeEnabled) &&
1743 LIM_BSS_CAPS_GET(WME, pe_session->limCurrentBssQosCaps);
1744
1745 /* We prefer .11e asociations: */
1746 if (qos_enabled)
1747 wme_enabled = false;
1748
1749 wsm_enabled = (pe_session->limWsmEnabled) && wme_enabled &&
1750 LIM_BSS_CAPS_GET(WSM, pe_session->limCurrentBssQosCaps);
1751
1752 if (pe_session->lim11hEnable &&
Srinivas Girigowda74a66d62017-06-21 23:28:25 -07001753 pe_session->pLimJoinReq->spectrumMgtIndicator == true) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001754 power_caps = true;
1755
1756 populate_dot11f_power_caps(mac_ctx, &frm->PowerCaps,
1757 LIM_ASSOC, pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001758 populate_dot11f_supp_channels(mac_ctx, &frm->SuppChannels,
1759 LIM_ASSOC, pe_session);
1760
1761 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001762 if (mac_ctx->rrm.rrmPEContext.rrmEnable &&
1763 SIR_MAC_GET_RRM(pe_session->limCurrentBssCaps)) {
1764 if (power_caps == false) {
1765 power_caps = true;
1766 populate_dot11f_power_caps(mac_ctx, &frm->PowerCaps,
1767 LIM_ASSOC, pe_session);
1768 }
1769 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001770 if (qos_enabled)
Naveen Rawatcd118312016-11-22 10:46:21 -08001771 populate_dot11f_qos_caps_station(mac_ctx, pe_session,
1772 &frm->QOSCapsStation);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001773
1774 populate_dot11f_ext_supp_rates(mac_ctx,
1775 POPULATE_DOT11F_RATES_OPERATIONAL, &frm->ExtSuppRates,
1776 pe_session);
1777
Gupta, Kapil54a16992016-01-13 19:34:02 +05301778 if (mac_ctx->rrm.rrmPEContext.rrmEnable &&
1779 SIR_MAC_GET_RRM(pe_session->limCurrentBssCaps))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001780 populate_dot11f_rrm_ie(mac_ctx, &frm->RRMEnabledCap,
1781 pe_session);
Deepak Dhamdhere641bf322016-01-06 15:19:03 -08001782
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001783 /*
1784 * The join request *should* contain zero or one of the WPA and RSN
1785 * IEs. The payload send along with the request is a
1786 * 'tSirSmeJoinReq'; the IE portion is held inside a 'tSirRSNie':
1787 * typedef struct sSirRSNie
1788 * {
1789 * uint16_t length;
1790 * uint8_t rsnIEdata[SIR_MAC_MAX_IE_LENGTH+2];
1791 * } tSirRSNie, *tpSirRSNie;
1792 * So, we should be able to make the following two calls harmlessly,
1793 * since they do nothing if they don't find the given IE in the
1794 * bytestream with which they're provided.
1795 * The net effect of this will be to faithfully transmit whatever
1796 * security IE is in the join request.
1797 * However, if we're associating for the purpose of WPS
1798 * enrollment, and we've been configured to indicate that by
1799 * eliding the WPA or RSN IE, we just skip this:
1800 */
1801 if (add_ie_len && add_ie)
1802 wps_ie = limGetWscIEPtr(mac_ctx, add_ie, add_ie_len);
1803
1804 if (NULL == wps_ie) {
1805 populate_dot11f_rsn_opaque(mac_ctx,
1806 &(pe_session->pLimJoinReq->rsnIE),
1807 &frm->RSNOpaque);
1808 populate_dot11f_wpa_opaque(mac_ctx,
1809 &(pe_session->pLimJoinReq->rsnIE),
1810 &frm->WPAOpaque);
1811#if defined(FEATURE_WLAN_WAPI)
1812 populate_dot11f_wapi_opaque(mac_ctx,
1813 &(pe_session->pLimJoinReq->rsnIE),
1814 &frm->WAPIOpaque);
1815#endif /* defined(FEATURE_WLAN_WAPI) */
1816 }
1817 /* include WME EDCA IE as well */
1818 if (wme_enabled) {
1819 populate_dot11f_wmm_info_station_per_session(mac_ctx,
1820 pe_session, &frm->WMMInfoStation);
1821
1822 if (wsm_enabled)
1823 populate_dot11f_wmm_caps(&frm->WMMCaps);
1824 }
1825
1826 /*
1827 * Populate HT IEs, when operating in 11n and
1828 * when AP is also operating in 11n mode
1829 */
1830 if (pe_session->htCapability &&
1831 mac_ctx->lim.htCapabilityPresentInBeacon) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001832 pe_debug("Populate HT Caps in Assoc Request");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001833 populate_dot11f_ht_caps(mac_ctx, pe_session, &frm->HTCaps);
Naveen Rawata410c5a2016-09-19 14:22:33 -07001834 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_DEBUG,
1835 &frm->HTCaps, sizeof(frm->HTCaps));
Kiran Kumar Lokere722dccd2018-02-23 13:23:52 -08001836 } else if (pe_session->he_with_wep_tkip) {
1837 pe_debug("Populate HT Caps in Assoc Request with WEP/TKIP");
1838 populate_dot11f_ht_caps(mac_ctx, NULL, &frm->HTCaps);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001839 }
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001840 pe_debug("SupportedChnlWidth: %d, mimoPS: %d, GF: %d, short GI20:%d, shortGI40: %d, dsssCck: %d, AMPDU Param: %x",
Agrawal Ashishc38e58d2015-09-16 17:17:29 +05301841 frm->HTCaps.supportedChannelWidthSet,
1842 frm->HTCaps.mimoPowerSave,
1843 frm->HTCaps.greenField, frm->HTCaps.shortGI20MHz,
1844 frm->HTCaps.shortGI40MHz,
1845 frm->HTCaps.dsssCckMode40MHz,
1846 frm->HTCaps.maxRxAMPDUFactor);
1847
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001848 if (pe_session->vhtCapability &&
1849 pe_session->vhtCapabilityPresentInBeacon) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001850 pe_debug("Populate VHT IEs in Assoc Request");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001851 populate_dot11f_vht_caps(mac_ctx, pe_session, &frm->VHTCaps);
Naveen Rawata410c5a2016-09-19 14:22:33 -07001852 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_DEBUG,
1853 &frm->VHTCaps, sizeof(frm->VHTCaps));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001854 vht_enabled = true;
Kiran Kumar Lokere1d4094e2016-08-31 19:04:04 -07001855 if (pe_session->enableHtSmps &&
1856 !pe_session->supported_nss_1x1) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001857 pe_err("VHT OP mode IE in Assoc Req");
Kiran Kumar Lokere1d4094e2016-08-31 19:04:04 -07001858 populate_dot11f_operating_mode(mac_ctx,
1859 &frm->OperatingMode, pe_session);
1860 }
Kiran Kumar Lokere722dccd2018-02-23 13:23:52 -08001861 } else if (pe_session->he_with_wep_tkip) {
1862 pe_debug("Populate VHT IEs in Assoc Request with WEP/TKIP");
1863 populate_dot11f_vht_caps(mac_ctx, NULL, &frm->VHTCaps);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001864 }
Kiran Kumar Lokere722dccd2018-02-23 13:23:52 -08001865
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001866 if (!vht_enabled &&
1867 pe_session->is_vendor_specific_vhtcaps) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001868 pe_debug("Populate Vendor VHT IEs in Assoc Request");
Kapil Gupta4b2efbb2016-10-03 13:07:20 +05301869 frm->vendor_vht_ie.present = 1;
Kiran Kumar Lokere81722632017-09-26 12:11:43 -07001870 frm->vendor_vht_ie.sub_type =
1871 pe_session->vendor_specific_vht_ie_sub_type;
Kapil Gupta4b2efbb2016-10-03 13:07:20 +05301872 frm->vendor_vht_ie.VHTCaps.present = 1;
Abhishek Singh68844282018-01-25 16:48:41 +05301873 if (!mac_ctx->roam.configParam.enable_subfee_vendor_vhtie &&
1874 pe_session->vht_config.su_beam_formee) {
1875 pe_debug("Disable SU beamformee for vendor IE");
1876 pe_session->vht_config.su_beam_formee = 0;
1877 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001878 populate_dot11f_vht_caps(mac_ctx, pe_session,
Kapil Gupta4b2efbb2016-10-03 13:07:20 +05301879 &frm->vendor_vht_ie.VHTCaps);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001880 vht_enabled = true;
1881 }
Agrawal Ashish0f94b572016-02-22 13:27:06 +05301882 if (pe_session->is_ext_caps_present)
1883 populate_dot11f_ext_cap(mac_ctx, vht_enabled,
1884 &frm->ExtCap, pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001885
Selvaraj, Sridhara521aab2017-03-25 16:42:34 +05301886 if (mac_ctx->roam.configParam.qcn_ie_support)
1887 populate_dot11f_qcn_ie(&frm->QCN_IE);
1888
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08001889 if (lim_is_session_he_capable(pe_session)) {
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07001890 pe_debug("Populate HE IEs");
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08001891 populate_dot11f_he_caps(mac_ctx, pe_session,
Naveen Rawatd8feac12017-09-08 15:08:39 -07001892 &frm->he_cap);
Kiran Kumar Lokere722dccd2018-02-23 13:23:52 -08001893 } else if (pe_session->he_with_wep_tkip) {
1894 pe_debug("Populate HE IEs in Assoc Request with WEP/TKIP");
1895 populate_dot11f_he_caps(mac_ctx, NULL, &frm->he_cap);
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08001896 }
Selvaraj, Sridharc2fe7a32017-02-02 19:20:16 +05301897
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001898 if (pe_session->pLimJoinReq->is11Rconnection) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001899 tSirBssDescription *bssdescr;
1900
1901 bssdescr = &pe_session->pLimJoinReq->bssDescription;
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001902 pe_debug("mdie = %02x %02x %02x",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001903 (unsigned int) bssdescr->mdie[0],
1904 (unsigned int) bssdescr->mdie[1],
1905 (unsigned int) bssdescr->mdie[2]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001906 populate_mdie(mac_ctx, &frm->MobilityDomain,
1907 pe_session->pLimJoinReq->bssDescription.mdie);
1908 } else {
1909 /* No 11r IEs dont send any MDIE */
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001910 pe_debug("MDIE not present");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001911 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001912
1913#ifdef FEATURE_WLAN_ESE
1914 /*
1915 * ESE Version IE will be included in association request
1916 * when ESE is enabled on DUT through ini and it is also
1917 * advertised by the peer AP to which we are trying to
1918 * associate to.
1919 */
1920 if (pe_session->is_ese_version_ie_present &&
1921 mac_ctx->roam.configParam.isEseIniFeatureEnabled)
1922 populate_dot11f_ese_version(&frm->ESEVersion);
1923 /* For ESE Associations fill the ESE IEs */
1924 if (pe_session->isESEconnection &&
1925 pe_session->pLimJoinReq->isESEFeatureIniEnabled) {
1926#ifndef FEATURE_DISABLE_RM
1927 populate_dot11f_ese_rad_mgmt_cap(&frm->ESERadMgmtCap);
1928#endif
1929 }
1930#endif
1931
Hu Wang411e0cc2016-10-28 14:56:01 +08001932 /*
1933 * Extcap IE now support variable length, merge Extcap IE from addn_ie
1934 * may change the frame size. Therefore, MUST merge ExtCap IE before
1935 * dot11f get packed payload size.
1936 */
1937 if (extr_ext_flag)
Hu Wangfbd279d2016-10-31 18:24:34 +08001938 lim_merge_extcap_struct(&frm->ExtCap, &extr_ext_cap, true);
1939
1940 /* Clear the bits in EXTCAP IE if AP not advertise it in beacon */
1941 if (frm->ExtCap.present && pe_session->is_ext_caps_present) {
1942 ie_offset = DOT11F_FF_TIMESTAMP_LEN +
1943 DOT11F_FF_BEACONINTERVAL_LEN +
1944 DOT11F_FF_CAPABILITIES_LEN;
1945
1946 qdf_mem_zero((uint8_t *)&bcn_ext_cap, sizeof(tDot11fIEExtCap));
1947 if (pe_session->beacon && pe_session->bcnLen > ie_offset) {
1948 bcn_ie = pe_session->beacon + ie_offset;
1949 bcn_ie_len = pe_session->bcnLen - ie_offset;
Naveen Rawat08db88f2017-09-08 15:07:48 -07001950 p_ext_cap = (uint8_t *)wlan_get_ie_ptr_from_eid(
Hu Wangfbd279d2016-10-31 18:24:34 +08001951 DOT11F_EID_EXTCAP,
Naveen Rawat08db88f2017-09-08 15:07:48 -07001952 bcn_ie, bcn_ie_len);
Hu Wangfbd279d2016-10-31 18:24:34 +08001953 lim_update_extcap_struct(mac_ctx, p_ext_cap,
1954 &bcn_ext_cap);
1955 lim_merge_extcap_struct(&frm->ExtCap, &bcn_ext_cap,
1956 false);
1957 }
1958 }
Hu Wang411e0cc2016-10-28 14:56:01 +08001959
Arif Hussain6cec6bc2017-02-14 13:46:26 -08001960 if (eSIR_SUCCESS != lim_strip_supp_op_class_update_struct(mac_ctx,
1961 add_ie, &add_ie_len, &frm->SuppOperatingClasses))
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001962 pe_debug("Unable to Stripoff supp op classes IE from Assoc Req");
Arif Hussain6cec6bc2017-02-14 13:46:26 -08001963
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +05301964 if (lim_is_fils_connection(pe_session)) {
1965 populate_dot11f_fils_params(mac_ctx, frm, pe_session);
1966 aes_block_size_len = AES_BLOCK_SIZE;
1967 }
1968
1969 /*
1970 * Do unpack to populate the add_ie buffer to frm structure
1971 * before packing the frm structure. In this way, the IE ordering
1972 * which the latest 802.11 spec mandates is maintained.
1973 */
Naveen Rawat72475db2017-12-13 18:07:35 -08001974 if (add_ie_len) {
1975 ret = dot11f_unpack_assoc_request(mac_ctx, add_ie,
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +05301976 add_ie_len, frm, true);
Naveen Rawat72475db2017-12-13 18:07:35 -08001977 if (DOT11F_FAILED(ret)) {
1978 pe_err("unpack failed, ret: 0x%x", ret);
1979 goto end;
1980 }
1981 }
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +05301982
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001983 status = dot11f_get_packed_assoc_request_size(mac_ctx, frm, &payload);
1984 if (DOT11F_FAILED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001985 pe_err("Association Request packet size failure(0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001986 status);
1987 /* We'll fall back on the worst case scenario: */
1988 payload = sizeof(tDot11fAssocRequest);
1989 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001990 pe_warn("Association request packet size warning (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001991 status);
1992 }
1993
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +05301994 bytes = payload + sizeof(tSirMacMgmtHdr) +
1995 aes_block_size_len;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001996
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301997 qdf_status = cds_packet_alloc((uint16_t) bytes, (void **)&frame,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001998 (void **)&packet);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301999 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002000 pe_err("Failed to allocate %d bytes", bytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002001
2002 pe_session->limMlmState = pe_session->limPrevMlmState;
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302003 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_MLM_STATE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002004 pe_session->peSessionId,
2005 pe_session->limMlmState));
2006
2007 /* Update PE session id */
2008 assoc_cnf.sessionId = pe_session->peSessionId;
2009
2010 assoc_cnf.resultCode = eSIR_SME_RESOURCES_UNAVAILABLE;
2011
2012 cds_packet_free((void *)packet);
2013
2014 lim_post_sme_message(mac_ctx, LIM_MLM_ASSOC_CNF,
2015 (uint32_t *) &assoc_cnf);
2016
yeshwanth sriram guntuka07831012017-06-30 12:26:57 +05302017 goto end;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002018 }
2019 /* Paranoia: */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302020 qdf_mem_set(frame, bytes, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002021
2022 /* Next, we fill out the buffer descriptor: */
2023 lim_populate_mac_header(mac_ctx, frame, SIR_MAC_MGMT_FRAME,
2024 SIR_MAC_MGMT_ASSOC_REQ, pe_session->bssId,
2025 pe_session->selfMacAddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002026 /* That done, pack the Assoc Request: */
2027 status = dot11f_pack_assoc_request(mac_ctx, frm,
2028 frame + sizeof(tSirMacMgmtHdr), payload, &payload);
2029 if (DOT11F_FAILED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002030 pe_err("Assoc request pack failure (0x%08x)", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002031 cds_packet_free((void *)packet);
yeshwanth sriram guntuka07831012017-06-30 12:26:57 +05302032 goto end;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002033 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002034 pe_warn("Assoc request pack warning (0x%08x)", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002035 }
2036
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002037 if (pe_session->assocReq != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302038 qdf_mem_free(pe_session->assocReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002039 pe_session->assocReq = NULL;
Naveen Rawat83102ef2015-11-03 10:42:34 -08002040 pe_session->assocReqLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002041 }
2042
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +05302043 if (lim_is_fils_connection(pe_session)) {
2044 qdf_status = aead_encrypt_assoc_req(mac_ctx, pe_session,
2045 frame, &payload);
2046 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
2047 cds_packet_free((void *)packet);
2048 qdf_mem_free(frm);
2049 return;
2050 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002051 }
2052
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302053 pe_session->assocReq = qdf_mem_malloc(payload);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002054 if (NULL == pe_session->assocReq) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002055 pe_err("Unable to allocate memory");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002056 } else {
2057 /*
2058 * Store the Assoc request. This is sent to csr/hdd in
2059 * join cnf response.
2060 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302061 qdf_mem_copy(pe_session->assocReq,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002062 frame + sizeof(tSirMacMgmtHdr), payload);
2063 pe_session->assocReqLen = payload;
2064 }
2065
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08002066 if ((BAND_5G == lim_get_rf_band(pe_session->currentOperChannel))
Anurag Chouhan6d760662016-02-20 16:05:43 +05302067 || (pe_session->pePersona == QDF_P2P_CLIENT_MODE)
2068 || (pe_session->pePersona == QDF_P2P_GO_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002069 )
2070 tx_flag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
2071
Anurag Chouhan6d760662016-02-20 16:05:43 +05302072 if (pe_session->pePersona == QDF_P2P_CLIENT_MODE ||
2073 pe_session->pePersona == QDF_STA_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002074 tx_flag |= HAL_USE_PEER_STA_REQUESTED_MASK;
2075
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002076 mac_hdr = (tpSirMacMgmtHdr) frame;
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302077 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002078 pe_session->peSessionId, mac_hdr->fc.subType));
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +05302079
2080 pe_debug("Sending Association Request length %d to ", bytes);
Naveen Rawat296a5182017-09-25 14:02:48 -07002081 min_rid = lim_get_min_session_txrate(pe_session);
Krunal Sonic65fc492018-03-09 15:53:28 -08002082 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_ASSOC_START_EVENT,
2083 pe_session, eSIR_SUCCESS, eSIR_SUCCESS);
2084 lim_diag_mgmt_tx_event_report(mac_ctx, mac_hdr,
2085 pe_session, eSIR_SUCCESS, eSIR_SUCCESS);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302086 qdf_status =
Abhishek Singhdd2cb572017-08-11 11:10:19 +05302087 wma_tx_frameWithTxComplete(mac_ctx, packet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002088 (uint16_t) (sizeof(tSirMacMgmtHdr) + payload),
2089 TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS, 7,
Abhishek Singhdd2cb572017-08-11 11:10:19 +05302090 lim_tx_complete, frame, lim_assoc_tx_complete_cnf,
Naveen Rawat296a5182017-09-25 14:02:48 -07002091 tx_flag, sme_sessionid, false, 0, min_rid);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302092 MTRACE(qdf_trace
Anurag Chouhan6d760662016-02-20 16:05:43 +05302093 (QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302094 pe_session->peSessionId, qdf_status));
Naveen Rawat296a5182017-09-25 14:02:48 -07002095
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302096 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002097 pe_err("Failed to send Association Request (%X)!",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302098 qdf_status);
Abhishek Singhdd2cb572017-08-11 11:10:19 +05302099 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_ASSOC_ACK_EVENT,
2100 pe_session, SENT_FAIL, eSIR_FAILURE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002101 /* Pkt will be freed up by the callback */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002102 }
yeshwanth sriram guntuka07831012017-06-30 12:26:57 +05302103end:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002104 /* Free up buffer allocated for mlm_assoc_req */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302105 qdf_mem_free(mlm_assoc_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002106 mlm_assoc_req = NULL;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302107 qdf_mem_free(frm);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002108 return;
2109}
2110
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002111/**
Abhishek Singh7d3bc3e2016-02-03 17:45:01 +05302112 * lim_auth_tx_complete_cnf()- Confirmation for auth sent over the air
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05302113 * @context: pointer to global mac
2114 * @buf: buffer
Abhishek Singh7d3bc3e2016-02-03 17:45:01 +05302115 * @tx_complete : Sent status
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05302116 * @params; tx completion params
Abhishek Singh7d3bc3e2016-02-03 17:45:01 +05302117 *
2118 * Return: This returns QDF_STATUS
2119 */
2120
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05302121static QDF_STATUS lim_auth_tx_complete_cnf(void *context,
2122 qdf_nbuf_t buf,
2123 uint32_t tx_complete,
2124 void *params)
Abhishek Singh7d3bc3e2016-02-03 17:45:01 +05302125{
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05302126 tpAniSirGlobal mac_ctx = (tpAniSirGlobal)context;
Abhishek Singhdd2cb572017-08-11 11:10:19 +05302127 uint16_t auth_ack_status;
2128 uint16_t reason_code;
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05302129
Naveen Rawat684e8b12017-09-20 15:54:44 -07002130 pe_debug("tx_complete = %d %s", tx_complete,
Zhu Jianmin5d8e3fe2018-01-04 16:16:20 +08002131 (tx_complete == WMI_MGMT_TX_COMP_TYPE_COMPLETE_OK) ?
2132 "success" : "fail");
2133 if (tx_complete == WMI_MGMT_TX_COMP_TYPE_COMPLETE_OK) {
Abhishek Singh7d3bc3e2016-02-03 17:45:01 +05302134 mac_ctx->auth_ack_status = LIM_AUTH_ACK_RCD_SUCCESS;
Abhishek Singhdd2cb572017-08-11 11:10:19 +05302135 auth_ack_status = ACKED;
2136 reason_code = eSIR_SUCCESS;
Abhishek Singh7d3bc3e2016-02-03 17:45:01 +05302137 /* 'Change' timer for future activations */
2138 lim_deactivate_and_change_timer(mac_ctx, eLIM_AUTH_RETRY_TIMER);
2139 } else {
2140 mac_ctx->auth_ack_status = LIM_AUTH_ACK_RCD_FAILURE;
Abhishek Singhdd2cb572017-08-11 11:10:19 +05302141 auth_ack_status = NOT_ACKED;
2142 reason_code = eSIR_FAILURE;
Abhishek Singh7d3bc3e2016-02-03 17:45:01 +05302143 }
Himanshu Agarwal8b472bc2017-01-20 20:49:41 +05302144
2145 if (buf)
2146 qdf_nbuf_free(buf);
2147
Abhishek Singhdd2cb572017-08-11 11:10:19 +05302148 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_AUTH_ACK_EVENT,
2149 NULL, auth_ack_status, reason_code);
2150
Abhishek Singh7d3bc3e2016-02-03 17:45:01 +05302151 return QDF_STATUS_SUCCESS;
2152}
2153
2154/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002155 * lim_send_auth_mgmt_frame() - Send an Authentication frame
2156 *
2157 * @mac_ctx: Pointer to Global MAC structure
2158 * @auth_frame: Pointer to Authentication frame structure
2159 * @peer_addr: MAC address of destination peer
2160 * @wep_bit: wep bit in frame control for Authentication frame3
2161 * @session: PE session information
2162 *
2163 * This function is called by lim_process_mlm_messages(). Authentication frame
2164 * is formatted and sent when this function is called.
2165 *
2166 * Return: void
2167 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002168void
2169lim_send_auth_mgmt_frame(tpAniSirGlobal mac_ctx,
2170 tpSirMacAuthFrameBody auth_frame,
2171 tSirMacAddr peer_addr,
yeshwanth sriram guntuka343a3f22017-07-27 18:30:18 +05302172 uint8_t wep_challenge_len,
Abhishek Singhdd2cb572017-08-11 11:10:19 +05302173 tpPESession session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002174{
2175 uint8_t *frame, *body;
2176 uint32_t frame_len = 0, body_len = 0;
2177 tpSirMacMgmtHdr mac_hdr;
2178 void *packet;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302179 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002180 uint8_t tx_flag = 0;
2181 uint8_t sme_sessionid = 0;
2182 uint16_t ft_ies_length = 0;
Krishna Kumaar Natarajan0517c602017-06-02 14:58:21 -07002183 bool challenge_req = false;
Naveen Rawat296a5182017-09-25 14:02:48 -07002184 enum rateid min_rid = RATEID_DEFAULT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002185
2186 if (NULL == session) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002187 pe_err("Error: psession Entry is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002188 return;
2189 }
2190
2191 sme_sessionid = session->smeSessionId;
2192
yeshwanth sriram guntuka343a3f22017-07-27 18:30:18 +05302193 if (wep_challenge_len) {
Krishna Kumaar Natarajan7e6a23c2016-04-05 14:45:24 -07002194 /*
2195 * Auth frame3 to be sent with encrypted framebody
2196 *
2197 * Allocate buffer for Authenticaton frame of size
2198 * equal to management frame header length plus 2 bytes
2199 * each for auth algorithm number, transaction number,
2200 * status code, 128 bytes for challenge text and
2201 * 4 bytes each for IV & ICV.
2202 */
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002203 pe_debug("Sending encrypted auth frame to " MAC_ADDRESS_STR,
2204 MAC_ADDR_ARRAY(peer_addr));
Krishna Kumaar Natarajan7e6a23c2016-04-05 14:45:24 -07002205
yeshwanth sriram guntuka343a3f22017-07-27 18:30:18 +05302206 body_len = wep_challenge_len + LIM_ENCR_AUTH_INFO_LEN;
Krishna Kumaar Natarajan0517c602017-06-02 14:58:21 -07002207 frame_len = sizeof(tSirMacMgmtHdr) + body_len;
Krishna Kumaar Natarajan7e6a23c2016-04-05 14:45:24 -07002208
2209 goto alloc_packet;
2210 }
2211
Abhishek Singhdd2cb572017-08-11 11:10:19 +05302212 pe_info("Sending Auth seq# %d status %d (%d) to "
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002213 MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002214 auth_frame->authTransactionSeqNumber,
2215 auth_frame->authStatusCode,
2216 (auth_frame->authStatusCode == eSIR_MAC_SUCCESS_STATUS),
2217 MAC_ADDR_ARRAY(peer_addr));
2218
2219 switch (auth_frame->authTransactionSeqNumber) {
2220 case SIR_MAC_AUTH_FRAME_1:
2221 /*
2222 * Allocate buffer for Authenticaton frame of size
2223 * equal to management frame header length plus 2 bytes
2224 * each for auth algorithm number, transaction number
2225 * and status code.
2226 */
2227
Krishna Kumaar Natarajan0517c602017-06-02 14:58:21 -07002228 body_len = SIR_MAC_AUTH_FRAME_INFO_LEN;
2229 frame_len = sizeof(tSirMacMgmtHdr) + body_len;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002230
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +05302231 frame_len += lim_create_fils_auth_data(mac_ctx,
2232 auth_frame, session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002233 if (auth_frame->authAlgoNumber == eSIR_FT_AUTH) {
2234 if (NULL != session->ftPEContext.pFTPreAuthReq &&
2235 0 != session->ftPEContext.pFTPreAuthReq->
2236 ft_ies_length) {
2237 ft_ies_length = session->ftPEContext.
2238 pFTPreAuthReq->ft_ies_length;
2239 frame_len += ft_ies_length;
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002240 pe_debug("Auth frame, FTIES length added=%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002241 ft_ies_length);
2242 } else {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002243 pe_debug("Auth frame, Does not contain FTIES!");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002244 frame_len += (2 + SIR_MDIE_SIZE);
2245 }
2246 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002247 break;
2248
2249 case SIR_MAC_AUTH_FRAME_2:
2250 if ((auth_frame->authAlgoNumber == eSIR_OPEN_SYSTEM) ||
2251 ((auth_frame->authAlgoNumber == eSIR_SHARED_KEY) &&
2252 (auth_frame->authStatusCode !=
2253 eSIR_MAC_SUCCESS_STATUS))) {
2254 /*
2255 * Allocate buffer for Authenticaton frame of size
2256 * equal to management frame header length plus
2257 * 2 bytes each for auth algorithm number,
2258 * transaction number and status code.
2259 */
2260
Krishna Kumaar Natarajan0517c602017-06-02 14:58:21 -07002261 body_len = SIR_MAC_AUTH_FRAME_INFO_LEN;
2262 frame_len = sizeof(tSirMacMgmtHdr) + body_len;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002263 } else {
2264 /*
2265 * Shared Key algorithm with challenge text
2266 * to be sent.
2267 *
2268 * Allocate buffer for Authenticaton frame of size
2269 * equal to management frame header length plus
2270 * 2 bytes each for auth algorithm number,
2271 * transaction number, status code and 128 bytes
2272 * for challenge text.
2273 */
2274
Krishna Kumaar Natarajan0517c602017-06-02 14:58:21 -07002275 challenge_req = true;
2276 body_len = SIR_MAC_AUTH_FRAME_INFO_LEN +
yeshwanth sriram guntuka5c71a292017-08-24 15:51:19 +05302277 SIR_MAC_SAP_AUTH_CHALLENGE_LENGTH +
2278 SIR_MAC_CHALLENGE_ID_LEN;
Krishna Kumaar Natarajan0517c602017-06-02 14:58:21 -07002279 frame_len = sizeof(tSirMacMgmtHdr) + body_len;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002280 }
2281 break;
2282
2283 case SIR_MAC_AUTH_FRAME_3:
Krishna Kumaar Natarajan7e6a23c2016-04-05 14:45:24 -07002284 /*
2285 * Auth frame3 to be sent without encrypted framebody
2286 *
2287 * Allocate buffer for Authenticaton frame of size equal
2288 * to management frame header length plus 2 bytes each
2289 * for auth algorithm number, transaction number and
2290 * status code.
2291 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002292
Krishna Kumaar Natarajan0517c602017-06-02 14:58:21 -07002293 body_len = SIR_MAC_AUTH_FRAME_INFO_LEN;
2294 frame_len = sizeof(tSirMacMgmtHdr) + body_len;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002295 break;
2296
2297 case SIR_MAC_AUTH_FRAME_4:
2298 /*
2299 * Allocate buffer for Authenticaton frame of size equal
2300 * to management frame header length plus 2 bytes each
2301 * for auth algorithm number, transaction number and
2302 * status code.
2303 */
2304
Krishna Kumaar Natarajan0517c602017-06-02 14:58:21 -07002305 body_len = SIR_MAC_AUTH_FRAME_INFO_LEN;
2306 frame_len = sizeof(tSirMacMgmtHdr) + body_len;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002307
2308 break;
Krishna Kumaar Natarajan7e6a23c2016-04-05 14:45:24 -07002309 default:
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002310 pe_err("Invalid auth transaction seq num");
Krishna Kumaar Natarajan7e6a23c2016-04-05 14:45:24 -07002311 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002312 } /* switch (auth_frame->authTransactionSeqNumber) */
2313
Krishna Kumaar Natarajan7e6a23c2016-04-05 14:45:24 -07002314alloc_packet:
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302315 qdf_status = cds_packet_alloc((uint16_t) frame_len, (void **)&frame,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002316 (void **)&packet);
2317
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302318 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002319 pe_err("call to bufAlloc failed for AUTH frame");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002320 return;
2321 }
2322
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302323 qdf_mem_zero(frame, frame_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002324
2325 /* Prepare BD */
2326 lim_populate_mac_header(mac_ctx, frame, SIR_MAC_MGMT_FRAME,
2327 SIR_MAC_MGMT_AUTH, peer_addr, session->selfMacAddr);
2328 mac_hdr = (tpSirMacMgmtHdr) frame;
yeshwanth sriram guntuka343a3f22017-07-27 18:30:18 +05302329 if (wep_challenge_len)
2330 mac_hdr->fc.wep = LIM_WEP_IN_FC;
2331 else
2332 mac_hdr->fc.wep = LIM_NO_WEP_IN_FC;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002333
2334 /* Prepare BSSId */
Rajeev Kumarcf835a02016-04-15 15:01:31 -07002335 if (LIM_IS_AP_ROLE(session))
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302336 qdf_mem_copy((uint8_t *) mac_hdr->bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002337 (uint8_t *) session->bssId,
2338 sizeof(tSirMacAddr));
2339
2340 /* Prepare Authentication frame body */
2341 body = frame + sizeof(tSirMacMgmtHdr);
2342
yeshwanth sriram guntuka343a3f22017-07-27 18:30:18 +05302343 if (wep_challenge_len) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302344 qdf_mem_copy(body, (uint8_t *) auth_frame, body_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002345
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002346 pe_debug("Sending Auth seq# 3 to " MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002347 MAC_ADDR_ARRAY(mac_hdr->da));
2348
2349 } else {
2350 *((uint16_t *) (body)) =
2351 sir_swap_u16if_needed(auth_frame->authAlgoNumber);
2352 body += sizeof(uint16_t);
2353 body_len -= sizeof(uint16_t);
2354
2355 *((uint16_t *) (body)) =
2356 sir_swap_u16if_needed(
2357 auth_frame->authTransactionSeqNumber);
2358 body += sizeof(uint16_t);
2359 body_len -= sizeof(uint16_t);
2360
2361 *((uint16_t *) (body)) =
2362 sir_swap_u16if_needed(auth_frame->authStatusCode);
2363 body += sizeof(uint16_t);
2364 body_len -= sizeof(uint16_t);
Krishna Kumaar Natarajan0517c602017-06-02 14:58:21 -07002365
2366 if (challenge_req) {
2367 if (body_len < SIR_MAC_AUTH_CHALLENGE_BODY_LEN) {
Himanshu Agarwalc422ca72017-09-19 11:07:36 +05302368 /* copy challenge IE id, len, challenge text */
2369 *body = auth_frame->type;
2370 body++;
2371 body_len -= sizeof(uint8_t);
2372 *body = auth_frame->length;
2373 body++;
2374 body_len -= sizeof(uint8_t);
2375 qdf_mem_copy(body, auth_frame->challengeText,
Krishna Kumaar Natarajan0517c602017-06-02 14:58:21 -07002376 body_len);
2377 pe_err("Incomplete challenge info: length: %d, expected: %d",
2378 body_len,
2379 SIR_MAC_AUTH_CHALLENGE_BODY_LEN);
2380 body += body_len;
2381 body_len = 0;
2382 } else {
2383 /* copy challenge IE id, len, challenge text */
2384 *body = auth_frame->type;
2385 body++;
2386 *body = auth_frame->length;
2387 body++;
2388 qdf_mem_copy(body, auth_frame->challengeText,
yeshwanth sriram guntuka5c71a292017-08-24 15:51:19 +05302389 SIR_MAC_SAP_AUTH_CHALLENGE_LENGTH);
2390 body += SIR_MAC_SAP_AUTH_CHALLENGE_LENGTH;
Krishna Kumaar Natarajan0517c602017-06-02 14:58:21 -07002391
yeshwanth sriram guntuka5c71a292017-08-24 15:51:19 +05302392 body_len -= SIR_MAC_SAP_AUTH_CHALLENGE_LENGTH +
2393 SIR_MAC_CHALLENGE_ID_LEN;
Krishna Kumaar Natarajan0517c602017-06-02 14:58:21 -07002394 }
2395 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002396
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002397 if ((auth_frame->authAlgoNumber == eSIR_FT_AUTH) &&
2398 (auth_frame->authTransactionSeqNumber ==
2399 SIR_MAC_AUTH_FRAME_1) &&
2400 (session->ftPEContext.pFTPreAuthReq != NULL)) {
2401
2402 if (ft_ies_length > 0) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302403 qdf_mem_copy(body,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002404 session->ftPEContext.
2405 pFTPreAuthReq->ft_ies,
2406 ft_ies_length);
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002407 pe_debug("Auth1 Frame FTIE is: ");
Srinivas Girigowdab896a562017-03-16 17:41:26 -07002408 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_PE,
2409 QDF_TRACE_LEVEL_DEBUG,
2410 (uint8_t *) body,
2411 ft_ies_length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002412 } else if (NULL != session->ftPEContext.
2413 pFTPreAuthReq->pbssDescription) {
2414 /* MDID attr is 54 */
2415 *body = SIR_MDIE_ELEMENT_ID;
2416 body++;
2417 *body = SIR_MDIE_SIZE;
2418 body++;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302419 qdf_mem_copy(body,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002420 &session->ftPEContext.pFTPreAuthReq->
2421 pbssDescription->mdie[0],
2422 SIR_MDIE_SIZE);
2423 }
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +05302424 } else if (auth_frame->authAlgoNumber ==
Varun Reddy Yeturu5faa1772017-10-23 11:22:01 -07002425 SIR_FILS_SK_WITHOUT_PFS) {
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +05302426 /* TODO MDIE */
2427 pe_debug("appending fils Auth data");
2428 lim_add_fils_data_to_auth_frame(session, body);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002429 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002430
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002431 pe_debug("*** Sending Auth seq# %d status %d (%d) to "
2432 MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002433 auth_frame->authTransactionSeqNumber,
2434 auth_frame->authStatusCode,
2435 (auth_frame->authStatusCode ==
2436 eSIR_MAC_SUCCESS_STATUS),
2437 MAC_ADDR_ARRAY(mac_hdr->da));
2438 }
Srinivas Girigowdab896a562017-03-16 17:41:26 -07002439 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_PE,
2440 QDF_TRACE_LEVEL_DEBUG,
2441 frame, frame_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002442
Deepthi Gowri1de51e32016-09-01 15:47:28 +05302443 if ((NULL != session->ftPEContext.pFTPreAuthReq) &&
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08002444 (BAND_5G == lim_get_rf_band(
Deepthi Gowri1de51e32016-09-01 15:47:28 +05302445 session->ftPEContext.pFTPreAuthReq->preAuthchannelNum)))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002446 tx_flag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08002447 else if ((BAND_5G ==
Deepthi Gowri1de51e32016-09-01 15:47:28 +05302448 lim_get_rf_band(session->currentOperChannel))
2449 || (session->pePersona == QDF_P2P_CLIENT_MODE)
2450 || (session->pePersona == QDF_P2P_GO_MODE))
2451 tx_flag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002452
Anurag Chouhan6d760662016-02-20 16:05:43 +05302453 if (session->pePersona == QDF_P2P_CLIENT_MODE ||
2454 session->pePersona == QDF_STA_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002455 tx_flag |= HAL_USE_PEER_STA_REQUESTED_MASK;
2456
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302457 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002458 session->peSessionId, mac_hdr->fc.subType));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002459
Abhishek Singhdd2cb572017-08-11 11:10:19 +05302460 mac_ctx->auth_ack_status = LIM_AUTH_ACK_NOT_RCD;
Naveen Rawat296a5182017-09-25 14:02:48 -07002461 min_rid = lim_get_min_session_txrate(session);
Krunal Sonic65fc492018-03-09 15:53:28 -08002462 lim_diag_mgmt_tx_event_report(mac_ctx, mac_hdr,
2463 session, eSIR_SUCCESS, eSIR_SUCCESS);
Abhishek Singhdd2cb572017-08-11 11:10:19 +05302464 qdf_status = wma_tx_frameWithTxComplete(mac_ctx, packet,
2465 (uint16_t)frame_len,
2466 TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS,
2467 7, lim_tx_complete, frame,
2468 lim_auth_tx_complete_cnf,
Naveen Rawat296a5182017-09-25 14:02:48 -07002469 tx_flag, sme_sessionid, false, 0, min_rid);
Abhishek Singhdd2cb572017-08-11 11:10:19 +05302470 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
2471 session->peSessionId, qdf_status));
2472 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
2473 pe_err("*** Could not send Auth frame, retCode=%X ***",
2474 qdf_status);
2475 mac_ctx->auth_ack_status = LIM_AUTH_ACK_RCD_FAILURE;
2476 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_AUTH_ACK_EVENT,
2477 session, SENT_FAIL, eSIR_FAILURE);
2478 /* Pkt will be freed up by the callback */
Abhishek Singh7d3bc3e2016-02-03 17:45:01 +05302479 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002480 return;
2481}
2482
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002483QDF_STATUS lim_send_deauth_cnf(tpAniSirGlobal mac_ctx)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002484{
2485 uint16_t aid;
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002486 tpDphHashNode sta_ds;
2487 tLimMlmDeauthReq *deauth_req;
2488 tLimMlmDeauthCnf deauth_cnf;
2489 tpPESession session_entry;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002490
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002491 deauth_req = mac_ctx->lim.limDisassocDeauthCnfReq.pMlmDeauthReq;
2492 if (deauth_req) {
2493 if (tx_timer_running(
2494 &mac_ctx->lim.limTimers.gLimDeauthAckTimer))
2495 lim_deactivate_and_change_timer(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002496 eLIM_DEAUTH_ACK_TIMER);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002497
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002498 session_entry = pe_find_session_by_session_id(mac_ctx,
2499 deauth_req->sessionId);
2500 if (session_entry == NULL) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002501 pe_err("session does not exist for given sessionId");
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002502 deauth_cnf.resultCode =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002503 eSIR_SME_INVALID_PARAMETERS;
2504 goto end;
2505 }
2506
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002507 sta_ds =
2508 dph_lookup_hash_entry(mac_ctx,
2509 deauth_req->peer_macaddr.bytes,
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002510 &aid,
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002511 &session_entry->dph.dphHashTable);
2512 if (sta_ds == NULL) {
2513 deauth_cnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002514 goto end;
2515 }
2516
2517 /* / Receive path cleanup with dummy packet */
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002518 lim_ft_cleanup_pre_auth_info(mac_ctx, session_entry);
2519 lim_cleanup_rx_path(mac_ctx, sta_ds, session_entry);
2520 if ((session_entry->limSystemRole == eLIM_STA_ROLE) &&
2521 (
Abhishek Singhe0680852015-12-16 14:28:48 +05302522#ifdef FEATURE_WLAN_ESE
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002523 (session_entry->isESEconnection) ||
Abhishek Singhe0680852015-12-16 14:28:48 +05302524#endif
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002525 (session_entry->isFastRoamIniFeatureEnabled) ||
2526 (session_entry->is11Rconnection))) {
Jeff Johnson11bd4f32017-09-18 08:15:17 -07002527 pe_debug("FT Preauth (%pK,%d) Deauth rc %d src = %d",
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002528 session_entry,
2529 session_entry->peSessionId,
2530 deauth_req->reasonCode,
2531 deauth_req->deauthTrigger);
2532 lim_ft_cleanup(mac_ctx, session_entry);
Deepak Dhamdhere262d95a2016-01-10 16:36:53 -08002533 } else {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002534 pe_debug("No FT Preauth Session Cleanup in role %d"
Deepak Dhamdhere262d95a2016-01-10 16:36:53 -08002535#ifdef FEATURE_WLAN_ESE
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002536 " isESE %d"
Deepak Dhamdhere262d95a2016-01-10 16:36:53 -08002537#endif
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002538 " isLFR %d"
2539 " is11r %d, Deauth reason %d Trigger = %d",
2540 session_entry->limSystemRole,
Deepak Dhamdhere262d95a2016-01-10 16:36:53 -08002541#ifdef FEATURE_WLAN_ESE
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002542 session_entry->isESEconnection,
Deepak Dhamdhere262d95a2016-01-10 16:36:53 -08002543#endif
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002544 session_entry->isFastRoamIniFeatureEnabled,
2545 session_entry->is11Rconnection,
2546 deauth_req->reasonCode,
2547 deauth_req->deauthTrigger);
Deepak Dhamdhere262d95a2016-01-10 16:36:53 -08002548 }
2549 /* Free up buffer allocated for mlmDeauthReq */
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002550 qdf_mem_free(deauth_req);
2551 mac_ctx->lim.limDisassocDeauthCnfReq.pMlmDeauthReq = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002552 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302553 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002554end:
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002555 qdf_copy_macaddr(&deauth_cnf.peer_macaddr,
2556 &deauth_req->peer_macaddr);
2557 deauth_cnf.deauthTrigger = deauth_req->deauthTrigger;
2558 deauth_cnf.aid = deauth_req->aid;
2559 deauth_cnf.sessionId = deauth_req->sessionId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002560
2561 /* Free up buffer allocated */
2562 /* for mlmDeauthReq */
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002563 qdf_mem_free(deauth_req);
2564 mac_ctx->lim.limDisassocDeauthCnfReq.pMlmDeauthReq = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002565
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002566 lim_post_sme_message(mac_ctx,
2567 LIM_MLM_DEAUTH_CNF, (uint32_t *) &deauth_cnf);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302568 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002569}
2570
2571/**
2572 * lim_send_disassoc_cnf() - Send disassoc confirmation to SME
2573 *
2574 * @mac_ctx: Handle to MAC context
2575 *
2576 * Sends disassoc confirmation to SME. Removes disassoc request stored
2577 * in lim.
2578 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302579 * Return: QDF_STATUS_SUCCESS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002580 */
2581
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302582QDF_STATUS lim_send_disassoc_cnf(tpAniSirGlobal mac_ctx)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002583{
2584 uint16_t aid;
2585 tpDphHashNode sta_ds;
2586 tLimMlmDisassocCnf disassoc_cnf;
2587 tpPESession pe_session;
2588 tLimMlmDisassocReq *disassoc_req;
2589
2590 disassoc_req = mac_ctx->lim.limDisassocDeauthCnfReq.pMlmDisassocReq;
2591 if (disassoc_req) {
2592 if (tx_timer_running(
2593 &mac_ctx->lim.limTimers.gLimDisassocAckTimer))
2594 lim_deactivate_and_change_timer(mac_ctx,
2595 eLIM_DISASSOC_ACK_TIMER);
2596
2597 pe_session = pe_find_session_by_session_id(
2598 mac_ctx, disassoc_req->sessionId);
2599 if (pe_session == NULL) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002600 pe_err("No session for given sessionId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002601 disassoc_cnf.resultCode =
2602 eSIR_SME_INVALID_PARAMETERS;
2603 goto end;
2604 }
2605
2606 sta_ds = dph_lookup_hash_entry(mac_ctx,
Srinivas Girigowdadd3c5132016-01-05 19:41:27 -08002607 disassoc_req->peer_macaddr.bytes, &aid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002608 &pe_session->dph.dphHashTable);
2609 if (sta_ds == NULL) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002610 pe_err("StaDs Null");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002611 disassoc_cnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
2612 goto end;
2613 }
2614 /* Receive path cleanup with dummy packet */
2615 if (eSIR_SUCCESS !=
2616 lim_cleanup_rx_path(mac_ctx, sta_ds, pe_session)) {
2617 disassoc_cnf.resultCode =
2618 eSIR_SME_RESOURCES_UNAVAILABLE;
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002619 pe_err("cleanup_rx_path error");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002620 goto end;
2621 }
Deepak Dhamdhere57c95ff2016-09-30 16:44:44 -07002622 if (LIM_IS_STA_ROLE(pe_session) &&
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002623 (disassoc_req->reasonCode !=
2624 eSIR_MAC_DISASSOC_DUE_TO_FTHANDOFF_REASON)) {
Jeff Johnson11bd4f32017-09-18 08:15:17 -07002625 pe_debug("FT Preauth Session (%pK %d) Clean up",
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002626 pe_session, pe_session->peSessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002627
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002628 /* Delete FT session if there exists one */
2629 lim_ft_cleanup_pre_auth_info(mac_ctx, pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002630 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002631 /* Free up buffer allocated for mlmDisassocReq */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302632 qdf_mem_free(disassoc_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002633 mac_ctx->lim.limDisassocDeauthCnfReq.pMlmDisassocReq = NULL;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302634 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002635 } else {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302636 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002637 }
2638end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302639 qdf_mem_copy((uint8_t *) &disassoc_cnf.peerMacAddr,
Srinivas Girigowdadd3c5132016-01-05 19:41:27 -08002640 (uint8_t *) disassoc_req->peer_macaddr.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05302641 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002642 disassoc_cnf.aid = disassoc_req->aid;
2643 disassoc_cnf.disassocTrigger = disassoc_req->disassocTrigger;
2644
2645 /* Update PE session ID */
2646 disassoc_cnf.sessionId = disassoc_req->sessionId;
2647
2648 if (disassoc_req != NULL) {
2649 /* / Free up buffer allocated for mlmDisassocReq */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302650 qdf_mem_free(disassoc_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002651 mac_ctx->lim.limDisassocDeauthCnfReq.pMlmDisassocReq = NULL;
2652 }
2653
2654 lim_post_sme_message(mac_ctx, LIM_MLM_DISASSOC_CNF,
2655 (uint32_t *) &disassoc_cnf);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302656 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002657}
2658
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05302659QDF_STATUS lim_disassoc_tx_complete_cnf(void *context,
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002660 uint32_t tx_success,
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05302661 void *params)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002662{
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002663 tpAniSirGlobal max_ctx = (tpAniSirGlobal)context;
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05302664
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002665 pe_debug("tx_success: %d", tx_success);
2666
2667 return lim_send_disassoc_cnf(max_ctx);
2668}
2669
2670static QDF_STATUS lim_disassoc_tx_complete_cnf_handler(void *context,
2671 qdf_nbuf_t buf,
2672 uint32_t tx_success,
2673 void *params)
2674{
2675 tpAniSirGlobal max_ctx = (tpAniSirGlobal)context;
2676 QDF_STATUS status_code;
2677 struct scheduler_msg msg = {0};
2678
2679 pe_debug("tx_success: %d", tx_success);
Himanshu Agarwal8b472bc2017-01-20 20:49:41 +05302680
2681 if (buf)
2682 qdf_nbuf_free(buf);
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002683 msg.type = (uint16_t) WMA_DISASSOC_TX_COMP;
2684 msg.bodyptr = params;
2685 msg.bodyval = tx_success;
Himanshu Agarwal8b472bc2017-01-20 20:49:41 +05302686
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002687 status_code = lim_post_msg_high_priority(max_ctx, &msg);
2688 if (status_code != QDF_STATUS_SUCCESS)
2689 pe_err("posting message: %X to LIM failed, reason: %d",
2690 msg.type, status_code);
2691 return status_code;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002692}
2693
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05302694QDF_STATUS lim_deauth_tx_complete_cnf(void *context,
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002695 uint32_t tx_success,
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05302696 void *params)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002697{
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002698 tpAniSirGlobal mac_ctx = (tpAniSirGlobal)context;
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05302699
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002700 pe_debug("tx_success: %d", tx_success);
2701
2702 return lim_send_deauth_cnf(mac_ctx);
2703}
2704
2705static QDF_STATUS lim_deauth_tx_complete_cnf_handler(void *context,
2706 qdf_nbuf_t buf,
2707 uint32_t tx_success,
2708 void *params)
2709{
2710 tpAniSirGlobal mac_ctx = (tpAniSirGlobal)context;
2711 QDF_STATUS status_code;
2712 struct scheduler_msg msg = {0};
2713
2714 pe_debug("tx_success: %d", tx_success);
Himanshu Agarwal8b472bc2017-01-20 20:49:41 +05302715
2716 if (buf)
2717 qdf_nbuf_free(buf);
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002718 msg.type = (uint16_t) WMA_DEAUTH_TX_COMP;
2719 msg.bodyptr = params;
2720 msg.bodyval = tx_success;
Himanshu Agarwal8b472bc2017-01-20 20:49:41 +05302721
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002722 status_code = lim_post_msg_high_priority(mac_ctx, &msg);
2723 if (status_code != QDF_STATUS_SUCCESS)
2724 pe_err("posting message: %X to LIM failed, reason: %d",
2725 msg.type, status_code);
2726 return status_code;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002727}
2728
2729/**
2730 * \brief This function is called to send Disassociate frame.
2731 *
2732 *
2733 * \param pMac Pointer to Global MAC structure
2734 *
2735 * \param nReason Indicates the reason that need to be sent in
2736 * Disassociation frame
2737 *
2738 * \param peerMacAddr MAC address of the STA to which Disassociation frame is
2739 * sent
2740 *
2741 *
2742 */
2743
2744void
2745lim_send_disassoc_mgmt_frame(tpAniSirGlobal pMac,
2746 uint16_t nReason,
2747 tSirMacAddr peer,
2748 tpPESession psessionEntry, bool waitForAck)
2749{
2750 tDot11fDisassociation frm;
2751 uint8_t *pFrame;
2752 tpSirMacMgmtHdr pMacHdr;
2753 uint32_t nBytes, nPayload, nStatus;
2754 void *pPacket;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302755 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002756 uint8_t txFlag = 0;
2757 uint32_t val = 0;
2758 uint8_t smeSessionId = 0;
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07002759
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002760 if (NULL == psessionEntry) {
2761 return;
2762 }
2763
2764 /*
2765 * In case when cac timer is running for this SAP session then
2766 * avoid sending disassoc out. It is violation of dfs specification.
2767 */
Anurag Chouhan6d760662016-02-20 16:05:43 +05302768 if (((psessionEntry->pePersona == QDF_SAP_MODE) ||
2769 (psessionEntry->pePersona == QDF_P2P_GO_MODE)) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002770 (true == pMac->sap.SapDfsInfo.is_dfs_cac_timer_running)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302771 QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_INFO,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002772 FL
2773 ("CAC timer is running, drop disassoc from going out"));
2774 return;
2775 }
2776 smeSessionId = psessionEntry->smeSessionId;
2777
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302778 qdf_mem_set((uint8_t *) &frm, sizeof(frm), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002779
2780 frm.Reason.code = nReason;
2781
2782 nStatus = dot11f_get_packed_disassociation_size(pMac, &frm, &nPayload);
2783 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002784 pe_err("Failed to calculate the packed size for a Disassociation (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002785 nStatus);
2786 /* We'll fall back on the worst case scenario: */
2787 nPayload = sizeof(tDot11fDisassociation);
2788 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002789 pe_warn("There were warnings while calculating the packed size for a Disassociation (0x%08x)",
2790 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002791 }
2792
2793 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
2794
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302795 qdf_status = cds_packet_alloc((uint16_t) nBytes, (void **)&pFrame,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002796 (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302797 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002798 pe_err("Failed to allocate %d bytes for a Disassociation",
2799 nBytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002800 return;
2801 }
2802 /* Paranoia: */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302803 qdf_mem_set(pFrame, nBytes, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002804
2805 /* Next, we fill out the buffer descriptor: */
2806 lim_populate_mac_header(pMac, pFrame, SIR_MAC_MGMT_FRAME,
2807 SIR_MAC_MGMT_DISASSOC, peer, psessionEntry->selfMacAddr);
2808 pMacHdr = (tpSirMacMgmtHdr) pFrame;
2809
2810 /* Prepare the BSSID */
2811 sir_copy_mac_addr(pMacHdr->bssId, psessionEntry->bssId);
2812
2813#ifdef WLAN_FEATURE_11W
2814 lim_set_protected_bit(pMac, psessionEntry, peer, pMacHdr);
2815#endif
2816
2817 nStatus = dot11f_pack_disassociation(pMac, &frm, pFrame +
2818 sizeof(tSirMacMgmtHdr),
2819 nPayload, &nPayload);
2820 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002821 pe_err("Failed to pack a Disassociation (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002822 nStatus);
2823 cds_packet_free((void *)pPacket);
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002824 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002825 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002826 pe_warn("There were warnings while packing a Disassociation (0x%08x)",
2827 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002828 }
2829
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002830 pe_debug("***Sessionid %d Sending Disassociation frame with "
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002831 "reason %u and waitForAck %d to " MAC_ADDRESS_STR " ,From "
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002832 MAC_ADDRESS_STR, psessionEntry->peSessionId, nReason,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002833 waitForAck, MAC_ADDR_ARRAY(pMacHdr->da),
2834 MAC_ADDR_ARRAY(psessionEntry->selfMacAddr));
2835
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08002836 if ((BAND_5G == lim_get_rf_band(psessionEntry->currentOperChannel))
Anurag Chouhan6d760662016-02-20 16:05:43 +05302837 || (psessionEntry->pePersona == QDF_P2P_CLIENT_MODE) ||
2838 (psessionEntry->pePersona == QDF_P2P_GO_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002839 ) {
2840 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
2841 }
2842
Sushant Kaushik46556062015-12-02 16:57:47 +05302843 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002844
2845 if (waitForAck) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302846 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002847 psessionEntry->peSessionId,
2848 pMacHdr->fc.subType));
Krunal Sonic65fc492018-03-09 15:53:28 -08002849 lim_diag_mgmt_tx_event_report(pMac, pMacHdr,
2850 psessionEntry, eSIR_SUCCESS,
2851 eSIR_SUCCESS);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002852 /* Queue Disassociation frame in high priority WQ */
2853 /* get the duration from the request */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302854 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002855 wma_tx_frameWithTxComplete(pMac, pPacket, (uint16_t) nBytes,
2856 TXRX_FRM_802_11_MGMT,
2857 ANI_TXDIR_TODS, 7, lim_tx_complete,
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002858 pFrame, lim_disassoc_tx_complete_cnf_handler,
Naveen Rawat296a5182017-09-25 14:02:48 -07002859 txFlag, smeSessionId, false, 0,
2860 RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302861 MTRACE(qdf_trace
Anurag Chouhan6d760662016-02-20 16:05:43 +05302862 (QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302863 psessionEntry->peSessionId, qdf_status));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002864
2865 val = SYS_MS_TO_TICKS(LIM_DISASSOC_DEAUTH_ACK_TIMEOUT);
2866
2867 if (tx_timer_change
2868 (&pMac->lim.limTimers.gLimDisassocAckTimer, val, 0)
2869 != TX_SUCCESS) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002870 pe_err("Unable to change Disassoc ack Timer val");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002871 return;
2872 } else if (TX_SUCCESS !=
2873 tx_timer_activate(&pMac->lim.limTimers.
2874 gLimDisassocAckTimer)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002875 pe_err("Unable to activate Disassoc ack Timer");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002876 lim_deactivate_and_change_timer(pMac,
2877 eLIM_DISASSOC_ACK_TIMER);
2878 return;
2879 }
2880 } else {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302881 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002882 psessionEntry->peSessionId,
2883 pMacHdr->fc.subType));
Krunal Sonic65fc492018-03-09 15:53:28 -08002884 lim_diag_mgmt_tx_event_report(pMac, pMacHdr,
2885 psessionEntry,
2886 eSIR_SUCCESS, eSIR_SUCCESS);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002887 /* Queue Disassociation frame in high priority WQ */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302888 qdf_status = wma_tx_frame(pMac, pPacket, (uint16_t) nBytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002889 TXRX_FRM_802_11_MGMT,
2890 ANI_TXDIR_TODS,
2891 7,
2892 lim_tx_complete, pFrame, txFlag,
Naveen Rawat296a5182017-09-25 14:02:48 -07002893 smeSessionId, 0, RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302894 MTRACE(qdf_trace
Anurag Chouhan6d760662016-02-20 16:05:43 +05302895 (QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302896 psessionEntry->peSessionId, qdf_status));
2897 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002898 pe_err("Failed to send Disassociation (%X)!",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302899 qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002900 /* Pkt will be freed up by the callback */
2901 }
2902 }
2903} /* End lim_send_disassoc_mgmt_frame. */
2904
2905/**
2906 * \brief This function is called to send a Deauthenticate frame
2907 *
2908 *
2909 * \param pMac Pointer to global MAC structure
2910 *
2911 * \param nReason Indicates the reason that need to be sent in the
2912 * Deauthenticate frame
2913 *
2914 * \param peeer address of the STA to which the frame is to be sent
2915 *
2916 *
2917 */
2918
2919void
2920lim_send_deauth_mgmt_frame(tpAniSirGlobal pMac,
2921 uint16_t nReason,
2922 tSirMacAddr peer,
2923 tpPESession psessionEntry, bool waitForAck)
2924{
2925 tDot11fDeAuth frm;
2926 uint8_t *pFrame;
2927 tpSirMacMgmtHdr pMacHdr;
2928 uint32_t nBytes, nPayload, nStatus;
2929 void *pPacket;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302930 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002931 uint8_t txFlag = 0;
2932 uint32_t val = 0;
2933#ifdef FEATURE_WLAN_TDLS
2934 uint16_t aid;
2935 tpDphHashNode pStaDs;
2936#endif
2937 uint8_t smeSessionId = 0;
2938
2939 if (NULL == psessionEntry) {
2940 return;
2941 }
2942
2943 /*
2944 * In case when cac timer is running for this SAP session then
2945 * avoid deauth frame out. It is violation of dfs specification.
2946 */
Anurag Chouhan6d760662016-02-20 16:05:43 +05302947 if (((psessionEntry->pePersona == QDF_SAP_MODE) ||
2948 (psessionEntry->pePersona == QDF_P2P_GO_MODE)) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002949 (true == pMac->sap.SapDfsInfo.is_dfs_cac_timer_running)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302950 QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_INFO,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002951 FL
2952 ("CAC timer is running, drop the deauth from going out"));
2953 return;
2954 }
2955 smeSessionId = psessionEntry->smeSessionId;
2956
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302957 qdf_mem_set((uint8_t *) &frm, sizeof(frm), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002958
2959 frm.Reason.code = nReason;
2960
2961 nStatus = dot11f_get_packed_de_auth_size(pMac, &frm, &nPayload);
2962 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002963 pe_err("Failed to calculate the packed size for a De-Authentication (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002964 nStatus);
2965 /* We'll fall back on the worst case scenario: */
2966 nPayload = sizeof(tDot11fDeAuth);
2967 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002968 pe_warn("There were warnings while calculating the packed size for a De-Authentication (0x%08x)",
2969 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002970 }
2971
2972 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
2973
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302974 qdf_status = cds_packet_alloc((uint16_t) nBytes, (void **)&pFrame,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002975 (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302976 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002977 pe_err("Failed to allocate %d bytes for a De-Authentication",
2978 nBytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002979 return;
2980 }
2981 /* Paranoia: */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302982 qdf_mem_set(pFrame, nBytes, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002983
2984 /* Next, we fill out the buffer descriptor: */
2985 lim_populate_mac_header(pMac, pFrame, SIR_MAC_MGMT_FRAME,
2986 SIR_MAC_MGMT_DEAUTH, peer, psessionEntry->selfMacAddr);
2987 pMacHdr = (tpSirMacMgmtHdr) pFrame;
2988
2989 /* Prepare the BSSID */
2990 sir_copy_mac_addr(pMacHdr->bssId, psessionEntry->bssId);
2991
2992#ifdef WLAN_FEATURE_11W
2993 lim_set_protected_bit(pMac, psessionEntry, peer, pMacHdr);
2994#endif
2995
2996 nStatus = dot11f_pack_de_auth(pMac, &frm, pFrame +
2997 sizeof(tSirMacMgmtHdr), nPayload, &nPayload);
2998 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002999 pe_err("Failed to pack a DeAuthentication (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003000 nStatus);
3001 cds_packet_free((void *)pPacket);
3002 return;
3003 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003004 pe_warn("There were warnings while packing a De-Authentication (0x%08x)",
3005 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003006 }
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003007 pe_debug("***Sessionid %d Sending Deauth frame with "
3008 "reason %u and waitForAck %d to " MAC_ADDRESS_STR
3009 " ,From " MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003010 psessionEntry->peSessionId, nReason, waitForAck,
3011 MAC_ADDR_ARRAY(pMacHdr->da),
3012 MAC_ADDR_ARRAY(psessionEntry->selfMacAddr));
3013
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08003014 if ((BAND_5G == lim_get_rf_band(psessionEntry->currentOperChannel))
Anurag Chouhan6d760662016-02-20 16:05:43 +05303015 || (psessionEntry->pePersona == QDF_P2P_CLIENT_MODE) ||
3016 (psessionEntry->pePersona == QDF_P2P_GO_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003017 ) {
3018 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
3019 }
3020
Sushant Kaushik46556062015-12-02 16:57:47 +05303021 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003022#ifdef FEATURE_WLAN_TDLS
3023 pStaDs =
3024 dph_lookup_hash_entry(pMac, peer, &aid,
3025 &psessionEntry->dph.dphHashTable);
3026#endif
3027
3028 if (waitForAck) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303029 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003030 psessionEntry->peSessionId,
3031 pMacHdr->fc.subType));
Krunal Sonic65fc492018-03-09 15:53:28 -08003032 lim_diag_mgmt_tx_event_report(pMac, pMacHdr,
3033 psessionEntry,
3034 eSIR_SUCCESS, eSIR_SUCCESS);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003035 /* Queue Disassociation frame in high priority WQ */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303036 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003037 wma_tx_frameWithTxComplete(pMac, pPacket, (uint16_t) nBytes,
3038 TXRX_FRM_802_11_MGMT,
3039 ANI_TXDIR_TODS, 7, lim_tx_complete,
Liangwei Dongc0b2e332017-11-16 06:04:46 -05003040 pFrame, lim_deauth_tx_complete_cnf_handler,
Naveen Rawat296a5182017-09-25 14:02:48 -07003041 txFlag, smeSessionId, false, 0,
3042 RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303043 MTRACE(qdf_trace
Anurag Chouhan6d760662016-02-20 16:05:43 +05303044 (QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303045 psessionEntry->peSessionId, qdf_status));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003046 /* Pkt will be freed up by the callback lim_tx_complete */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303047 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003048 pe_err("Failed to send De-Authentication (%X)!",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303049 qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003050
3051 /* Call lim_process_deauth_ack_timeout which will send
3052 * DeauthCnf for this frame
3053 */
3054 lim_process_deauth_ack_timeout(pMac);
3055 return;
3056 }
3057
3058 val = SYS_MS_TO_TICKS(LIM_DISASSOC_DEAUTH_ACK_TIMEOUT);
3059
3060 if (tx_timer_change
3061 (&pMac->lim.limTimers.gLimDeauthAckTimer, val, 0)
3062 != TX_SUCCESS) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003063 pe_err("Unable to change Deauth ack Timer val");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003064 return;
3065 } else if (TX_SUCCESS !=
3066 tx_timer_activate(&pMac->lim.limTimers.
3067 gLimDeauthAckTimer)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003068 pe_err("Unable to activate Deauth ack Timer");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003069 lim_deactivate_and_change_timer(pMac,
3070 eLIM_DEAUTH_ACK_TIMER);
3071 return;
3072 }
3073 } else {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303074 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003075 psessionEntry->peSessionId,
3076 pMacHdr->fc.subType));
3077#ifdef FEATURE_WLAN_TDLS
3078 if ((NULL != pStaDs)
3079 && (STA_ENTRY_TDLS_PEER == pStaDs->staType)) {
3080 /* Queue Disassociation frame in high priority WQ */
Krunal Sonic65fc492018-03-09 15:53:28 -08003081 lim_diag_mgmt_tx_event_report(pMac, pMacHdr,
3082 psessionEntry,
3083 eSIR_SUCCESS,
3084 eSIR_SUCCESS);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303085 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003086 wma_tx_frame(pMac, pPacket, (uint16_t) nBytes,
3087 TXRX_FRM_802_11_MGMT, ANI_TXDIR_IBSS,
3088 7, lim_tx_complete, pFrame, txFlag,
Naveen Rawat296a5182017-09-25 14:02:48 -07003089 smeSessionId, 0, RATEID_DEFAULT);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003090 } else {
3091#endif
Krunal Sonic65fc492018-03-09 15:53:28 -08003092 lim_diag_mgmt_tx_event_report(pMac, pMacHdr,
3093 psessionEntry,
3094 eSIR_SUCCESS,
3095 eSIR_SUCCESS);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003096 /* Queue Disassociation frame in high priority WQ */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303097 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003098 wma_tx_frame(pMac, pPacket, (uint16_t) nBytes,
3099 TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS,
3100 7, lim_tx_complete, pFrame, txFlag,
Naveen Rawat296a5182017-09-25 14:02:48 -07003101 smeSessionId, 0, RATEID_DEFAULT);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003102#ifdef FEATURE_WLAN_TDLS
3103 }
3104#endif
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303105 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303106 psessionEntry->peSessionId, qdf_status));
3107 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003108 pe_err("Failed to send De-Authentication (%X)!",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303109 qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003110 /* Pkt will be freed up by the callback */
3111 }
3112 }
3113
3114} /* End lim_send_deauth_mgmt_frame. */
3115
3116#ifdef ANI_SUPPORT_11H
3117/**
3118 * \brief Send a Measurement Report Action frame
3119 *
3120 *
3121 * \param pMac Pointer to the global MAC structure
3122 *
3123 * \param pMeasReqFrame Address of a tSirMacMeasReqActionFrame
3124 *
3125 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
3126 *
3127 *
3128 */
3129
3130tSirRetStatus
3131lim_send_meas_report_frame(tpAniSirGlobal pMac,
3132 tpSirMacMeasReqActionFrame pMeasReqFrame,
3133 tSirMacAddr peer, tpPESession psessionEntry)
3134{
3135 tDot11fMeasurementReport frm;
3136 uint8_t *pFrame;
3137 tSirRetStatus nSirStatus;
3138 tpSirMacMgmtHdr pMacHdr;
3139 uint32_t nBytes, nPayload, nStatus;
3140 void *pPacket;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303141 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003142
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303143 qdf_mem_set((uint8_t *) &frm, sizeof(frm), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003144
3145 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
3146 frm.Action.action = SIR_MAC_ACTION_MEASURE_REPORT_ID;
3147 frm.DialogToken.token = pMeasReqFrame->actionHeader.dialogToken;
3148
3149 switch (pMeasReqFrame->measReqIE.measType) {
3150 case SIR_MAC_BASIC_MEASUREMENT_TYPE:
3151 nSirStatus =
3152 populate_dot11f_measurement_report0(pMac, pMeasReqFrame,
3153 &frm.MeasurementReport);
3154 break;
3155 case SIR_MAC_CCA_MEASUREMENT_TYPE:
3156 nSirStatus =
3157 populate_dot11f_measurement_report1(pMac, pMeasReqFrame,
3158 &frm.MeasurementReport);
3159 break;
3160 case SIR_MAC_RPI_MEASUREMENT_TYPE:
3161 nSirStatus =
3162 populate_dot11f_measurement_report2(pMac, pMeasReqFrame,
3163 &frm.MeasurementReport);
3164 break;
3165 default:
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003166 pe_err("Unknown measurement type %d in limSen"
3167 "dMeasReportFrame",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003168 pMeasReqFrame->measReqIE.measType);
3169 return eSIR_FAILURE;
3170 }
3171
3172 if (eSIR_SUCCESS != nSirStatus)
3173 return eSIR_FAILURE;
3174
3175 nStatus = dot11f_get_packed_measurement_report_size(pMac, &frm, &nPayload);
3176 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003177 pe_err("Failed to calculate the packed size for a Measurement Report (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003178 nStatus);
3179 /* We'll fall back on the worst case scenario: */
3180 nPayload = sizeof(tDot11fMeasurementReport);
3181 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003182 pe_warn("There were warnings while calculating the packed size for a Measurement Report (0x%08x)",
3183 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003184 }
3185
3186 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
3187
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303188 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003189 cds_packet_alloc(pMac->hHdd, TXRX_FRM_802_11_MGMT,
3190 (uint16_t) nBytes, (void **)&pFrame,
3191 (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303192 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003193 pe_err("Failed to allocate %d bytes for a "
3194 "De-Authentication", nBytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003195 return eSIR_FAILURE;
3196 }
3197 /* Paranoia: */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303198 qdf_mem_set(pFrame, nBytes, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003199
3200 /* Next, we fill out the buffer descriptor: */
3201 lim_populate_mac_header(pMac, pFrame, SIR_MAC_MGMT_FRAME,
3202 SIR_MAC_MGMT_ACTION, peer);
3203 pMacHdr = (tpSirMacMgmtHdr) pFrame;
3204
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303205 qdf_mem_copy(pMacHdr->bssId, psessionEntry->bssId, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003206
3207#ifdef WLAN_FEATURE_11W
3208 lim_set_protected_bit(pMac, psessionEntry, peer, pMacHdr);
3209#endif
3210
3211 nStatus = dot11f_pack_measurement_report(pMac, &frm, pFrame +
3212 sizeof(tSirMacMgmtHdr),
3213 nPayload, &nPayload);
3214 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003215 pe_err("Failed to pack a Measurement Report (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003216 nStatus);
3217 cds_packet_free(pMac->hHdd, TXRX_FRM_802_11_MGMT,
3218 (void *)pFrame, (void *)pPacket);
3219 return eSIR_FAILURE; /* allocated! */
3220 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003221 pe_warn("There were warnings while packing a Measurement Report (0x%08x)",
3222 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003223 }
3224
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303225 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003226 ((psessionEntry) ? psessionEntry->
3227 peSessionId : NO_SESSION), pMacHdr->fc.subType));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303228 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003229 wma_tx_frame(pMac, pPacket, (uint16_t) nBytes,
3230 TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS, 7,
Naveen Rawat296a5182017-09-25 14:02:48 -07003231 lim_tx_complete, pFrame, 0, 0, RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303232 MTRACE(qdf_trace
Anurag Chouhan6d760662016-02-20 16:05:43 +05303233 (QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003234 ((psessionEntry) ? psessionEntry->peSessionId : NO_SESSION),
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303235 qdf_status));
3236 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003237 pe_err("Failed to send a Measurement Report (%X)!",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303238 qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003239 /* Pkt will be freed up by the callback */
3240 return eSIR_FAILURE; /* just allocated... */
3241 }
3242
3243 return eSIR_SUCCESS;
3244
3245} /* End lim_send_meas_report_frame. */
3246
3247/**
3248 * \brief Send a TPC Request Action frame
3249 *
3250 *
3251 * \param pMac Pointer to the global MAC datastructure
3252 *
3253 * \param peer MAC address to which the frame should be sent
3254 *
3255 *
3256 */
3257
3258void
3259lim_send_tpc_request_frame(tpAniSirGlobal pMac,
3260 tSirMacAddr peer, tpPESession psessionEntry)
3261{
3262 tDot11fTPCRequest frm;
3263 uint8_t *pFrame;
3264 tpSirMacMgmtHdr pMacHdr;
3265 uint32_t nBytes, nPayload, nStatus;
3266 void *pPacket;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303267 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003268
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303269 qdf_mem_set((uint8_t *) &frm, sizeof(frm), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003270
3271 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
3272 frm.Action.action = SIR_MAC_ACTION_TPC_REQUEST_ID;
3273 frm.DialogToken.token = 1;
3274 frm.TPCRequest.present = 1;
3275
3276 nStatus = dot11f_get_packed_tpc_request_size(pMac, &frm, &nPayload);
3277 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003278 pe_err("Failed to calculate the packed size for a TPC Request (0x%08x)", nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003279 /* We'll fall back on the worst case scenario: */
3280 nPayload = sizeof(tDot11fTPCRequest);
3281 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003282 pe_warn("There were warnings while calculating the packed size for a TPC Request (0x%08x)",
3283 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003284 }
3285
3286 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
3287
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303288 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003289 cds_packet_alloc(pMac->hHdd, TXRX_FRM_802_11_MGMT,
3290 (uint16_t) nBytes, (void **)&pFrame,
3291 (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303292 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003293 pe_err("Failed to allocate %d bytes for a TPC"
3294 " Request", nBytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003295 return;
3296 }
3297 /* Paranoia: */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303298 qdf_mem_set(pFrame, nBytes, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003299
3300 /* Next, we fill out the buffer descriptor: */
3301 lim_populate_mac_header(pMac, pFrame, SIR_MAC_MGMT_FRAME,
3302 SIR_MAC_MGMT_ACTION, peer);
3303 pMacHdr = (tpSirMacMgmtHdr) pFrame;
3304
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303305 qdf_mem_copy(pMacHdr->bssId, psessionEntry->bssId, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003306
3307#ifdef WLAN_FEATURE_11W
3308 lim_set_protected_bit(pMac, psessionEntry, peer, pMacHdr);
3309#endif
3310
3311 nStatus = dot11f_pack_tpc_request(pMac, &frm, pFrame +
3312 sizeof(tSirMacMgmtHdr),
3313 nPayload, &nPayload);
3314 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003315 pe_err("Failed to pack a TPC Request (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003316 nStatus);
3317 cds_packet_free(pMac->hHdd, TXRX_FRM_802_11_MGMT,
3318 (void *)pFrame, (void *)pPacket);
3319 return; /* allocated! */
3320 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003321 pe_warn("There were warnings while packing a TPC Request (0x%08x)",
3322 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003323 }
3324
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303325 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003326 ((psessionEntry) ? psessionEntry->
3327 peSessionId : NO_SESSION), pMacHdr->fc.subType));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303328 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003329 wma_tx_frame(pMac, pPacket, (uint16_t) nBytes,
3330 TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS, 7,
Naveen Rawat296a5182017-09-25 14:02:48 -07003331 lim_tx_complete, pFrame, 0, 0, RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303332 MTRACE(qdf_trace
Anurag Chouhan6d760662016-02-20 16:05:43 +05303333 (QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003334 ((psessionEntry) ? psessionEntry->peSessionId : NO_SESSION),
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303335 qdf_status));
3336 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003337 pe_err("Failed to send a TPC Request (%X)!",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303338 qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003339 /* Pkt will be freed up by the callback */
3340 }
3341
3342} /* End lim_send_tpc_request_frame. */
3343
3344/**
3345 * \brief Send a TPC Report Action frame
3346 *
3347 *
3348 * \param pMac Pointer to the global MAC datastructure
3349 *
3350 * \param pTpcReqFrame Pointer to the received TPC Request
3351 *
3352 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
3353 *
3354 *
3355 */
3356
3357tSirRetStatus
3358lim_send_tpc_report_frame(tpAniSirGlobal pMac,
3359 tpSirMacTpcReqActionFrame pTpcReqFrame,
3360 tSirMacAddr peer, tpPESession psessionEntry)
3361{
3362 tDot11fTPCReport frm;
3363 uint8_t *pFrame;
3364 tpSirMacMgmtHdr pMacHdr;
3365 uint32_t nBytes, nPayload, nStatus;
3366 void *pPacket;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303367 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003368
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303369 qdf_mem_set((uint8_t *) &frm, sizeof(frm), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003370
3371 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
3372 frm.Action.action = SIR_MAC_ACTION_TPC_REPORT_ID;
3373 frm.DialogToken.token = pTpcReqFrame->actionHeader.dialogToken;
3374
3375 frm.TPCReport.tx_power = 0;
3376 frm.TPCReport.link_margin = 0;
3377 frm.TPCReport.present = 1;
3378
3379 nStatus = dot11f_get_packed_tpc_report_size(pMac, &frm, &nPayload);
3380 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003381 pe_err("Failed to calculate the packed size for a TPC Report (0x%08x)", nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003382 /* We'll fall back on the worst case scenario: */
3383 nPayload = sizeof(tDot11fTPCReport);
3384 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003385 pe_warn("There were warnings while calculating the packed size for a TPC Report (0x%08x)",
3386 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003387 }
3388
3389 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
3390
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303391 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003392 cds_packet_alloc(pMac->hHdd, TXRX_FRM_802_11_MGMT,
3393 (uint16_t) nBytes, (void **)&pFrame,
3394 (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303395 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003396 pe_err("Failed to allocate %d bytes for a TPC"
3397 " Report", nBytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003398 return eSIR_FAILURE;
3399 }
3400 /* Paranoia: */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303401 qdf_mem_set(pFrame, nBytes, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003402
3403 /* Next, we fill out the buffer descriptor: */
3404 lim_populate_mac_header(pMac, pFrame, SIR_MAC_MGMT_FRAME,
3405 SIR_MAC_MGMT_ACTION, peer);
3406
3407 pMacHdr = (tpSirMacMgmtHdr) pFrame;
3408
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303409 qdf_mem_copy(pMacHdr->bssId, psessionEntry->bssId, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003410
3411#ifdef WLAN_FEATURE_11W
3412 lim_set_protected_bit(pMac, psessionEntry, peer, pMacHdr);
3413#endif
3414
3415 nStatus = dot11f_pack_tpc_report(pMac, &frm, pFrame +
3416 sizeof(tSirMacMgmtHdr),
3417 nPayload, &nPayload);
3418 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003419 pe_err("Failed to pack a TPC Report (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003420 nStatus);
3421 cds_packet_free(pMac->hHdd, TXRX_FRM_802_11_MGMT,
3422 (void *)pFrame, (void *)pPacket);
3423 return eSIR_FAILURE; /* allocated! */
3424 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003425 pe_warn("There were warnings while packing a TPC Report (0x%08x)",
3426 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003427
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303428 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003429 ((psessionEntry) ? psessionEntry->
3430 peSessionId : NO_SESSION), pMacHdr->fc.subType));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303431 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003432 wma_tx_frame(pMac, pPacket, (uint16_t) nBytes,
3433 TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS, 7,
Naveen Rawat296a5182017-09-25 14:02:48 -07003434 lim_tx_complete, pFrame, 0, 0, RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303435 MTRACE(qdf_trace
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003436 (QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
3437 ((psessionEntry) ? psessionEntry->peSessionId : NO_SESSION),
3438 qdf_status));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303439 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003440 pe_err("Failed to send a TPC Report (%X)!",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303441 qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003442 /* Pkt will be freed up by the callback */
3443 return eSIR_FAILURE; /* just allocated... */
3444 }
3445
3446 return eSIR_SUCCESS;
3447
3448} /* End lim_send_tpc_report_frame. */
3449#endif /* ANI_SUPPORT_11H */
3450
3451/**
3452 * \brief Send a Channel Switch Announcement
3453 *
3454 *
3455 * \param pMac Pointer to the global MAC datastructure
3456 *
3457 * \param peer MAC address to which this frame will be sent
3458 *
3459 * \param nMode
3460 *
3461 * \param nNewChannel
3462 *
3463 * \param nCount
3464 *
3465 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
3466 *
3467 *
3468 */
3469
3470tSirRetStatus
3471lim_send_channel_switch_mgmt_frame(tpAniSirGlobal pMac,
3472 tSirMacAddr peer,
3473 uint8_t nMode,
3474 uint8_t nNewChannel,
3475 uint8_t nCount, tpPESession psessionEntry)
3476{
3477 tDot11fChannelSwitch frm;
3478 uint8_t *pFrame;
3479 tpSirMacMgmtHdr pMacHdr;
3480 uint32_t nBytes, nPayload, nStatus; /* , nCfg; */
3481 void *pPacket;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303482 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003483 uint8_t txFlag = 0;
3484
3485 uint8_t smeSessionId = 0;
3486
3487 if (psessionEntry == NULL) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003488 pe_err("Session entry is NULL!!!");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003489 return eSIR_FAILURE;
3490 }
3491 smeSessionId = psessionEntry->smeSessionId;
3492
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303493 qdf_mem_set((uint8_t *) &frm, sizeof(frm), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003494
3495 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
3496 frm.Action.action = SIR_MAC_ACTION_CHANNEL_SWITCH_ID;
3497 frm.ChanSwitchAnn.switchMode = nMode;
3498 frm.ChanSwitchAnn.newChannel = nNewChannel;
3499 frm.ChanSwitchAnn.switchCount = nCount;
3500 frm.ChanSwitchAnn.present = 1;
3501
3502 nStatus = dot11f_get_packed_channel_switch_size(pMac, &frm, &nPayload);
3503 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003504 pe_err("Failed to calculate the packed size for a Channel Switch (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003505 nStatus);
3506 /* We'll fall back on the worst case scenario: */
3507 nPayload = sizeof(tDot11fChannelSwitch);
3508 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003509 pe_warn("There were warnings while calculating the packed size for a Channel Switch (0x%08x)",
3510 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003511 }
3512
3513 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
3514
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303515 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003516 cds_packet_alloc((uint16_t) nBytes, (void **)&pFrame,
3517 (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303518 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003519 pe_err("Failed to allocate %d bytes for a TPC Report", nBytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003520 return eSIR_FAILURE;
3521 }
3522 /* Paranoia: */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303523 qdf_mem_set(pFrame, nBytes, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003524
3525 /* Next, we fill out the buffer descriptor: */
3526 lim_populate_mac_header(pMac, pFrame, SIR_MAC_MGMT_FRAME,
3527 SIR_MAC_MGMT_ACTION, peer,
3528 psessionEntry->selfMacAddr);
3529 pMacHdr = (tpSirMacMgmtHdr) pFrame;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303530 qdf_mem_copy((uint8_t *) pMacHdr->bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003531 (uint8_t *) psessionEntry->bssId, sizeof(tSirMacAddr));
3532
3533#ifdef WLAN_FEATURE_11W
3534 lim_set_protected_bit(pMac, psessionEntry, peer, pMacHdr);
3535#endif
3536
3537 nStatus = dot11f_pack_channel_switch(pMac, &frm, pFrame +
3538 sizeof(tSirMacMgmtHdr),
3539 nPayload, &nPayload);
3540 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003541 pe_err("Failed to pack a Channel Switch (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003542 nStatus);
3543 cds_packet_free((void *)pPacket);
3544 return eSIR_FAILURE; /* allocated! */
3545 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003546 pe_warn("There were warnings while packing a Channel Switch (0x%08x)",
3547 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003548 }
3549
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08003550 if ((BAND_5G == lim_get_rf_band(psessionEntry->currentOperChannel))
Anurag Chouhan6d760662016-02-20 16:05:43 +05303551 || (psessionEntry->pePersona == QDF_P2P_CLIENT_MODE) ||
3552 (psessionEntry->pePersona == QDF_P2P_GO_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003553 ) {
3554 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
3555 }
3556
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303557 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003558 psessionEntry->peSessionId, pMacHdr->fc.subType));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303559 qdf_status = wma_tx_frame(pMac, pPacket, (uint16_t) nBytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003560 TXRX_FRM_802_11_MGMT,
3561 ANI_TXDIR_TODS,
3562 7, lim_tx_complete, pFrame, txFlag,
Naveen Rawat296a5182017-09-25 14:02:48 -07003563 smeSessionId, 0, RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303564 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303565 psessionEntry->peSessionId, qdf_status));
3566 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003567 pe_err("Failed to send a Channel Switch (%X)!",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303568 qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003569 /* Pkt will be freed up by the callback */
3570 return eSIR_FAILURE;
3571 }
3572
3573 return eSIR_SUCCESS;
3574
3575} /* End lim_send_channel_switch_mgmt_frame. */
3576
Abhishek Singh518323d2015-10-19 17:42:01 +05303577/**
3578 * lim_send_extended_chan_switch_action_frame()- function to send ECSA
3579 * action frame over the air .
3580 * @mac_ctx: pointer to global mac structure
3581 * @peer: Destination mac.
3582 * @mode: channel switch mode
3583 * @new_op_class: new op class
3584 * @new_channel: new channel to switch
3585 * @count: channel switch count
3586 *
3587 * This function is called to send ECSA frame.
3588 *
3589 * Return: success if frame is sent else return failure
3590 */
3591
3592tSirRetStatus
3593lim_send_extended_chan_switch_action_frame(tpAniSirGlobal mac_ctx,
3594 tSirMacAddr peer, uint8_t mode, uint8_t new_op_class,
3595 uint8_t new_channel, uint8_t count, tpPESession session_entry)
3596{
3597 tDot11fext_channel_switch_action_frame frm;
3598 uint8_t *frame;
3599 tpSirMacMgmtHdr mac_hdr;
3600 uint32_t num_bytes, n_payload, status;
3601 void *packet;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303602 QDF_STATUS qdf_status;
Abhishek Singh518323d2015-10-19 17:42:01 +05303603 uint8_t txFlag = 0;
3604 uint8_t sme_session_id = 0;
Vignesh Viswanathan93b7f702017-12-19 17:48:45 +05303605 uint8_t ch_spacing;
3606 tLimWiderBWChannelSwitchInfo *wide_bw_ie;
Abhishek Singh518323d2015-10-19 17:42:01 +05303607
3608 if (session_entry == NULL) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003609 pe_err("Session entry is NULL!!!");
Abhishek Singh518323d2015-10-19 17:42:01 +05303610 return eSIR_FAILURE;
3611 }
3612
3613 sme_session_id = session_entry->smeSessionId;
3614
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303615 qdf_mem_set(&frm, sizeof(frm), 0);
Abhishek Singh518323d2015-10-19 17:42:01 +05303616
3617 frm.Category.category = SIR_MAC_ACTION_PUBLIC_USAGE;
3618 frm.Action.action = SIR_MAC_ACTION_EXT_CHANNEL_SWITCH_ID;
3619
3620 frm.ext_chan_switch_ann_action.switch_mode = mode;
3621 frm.ext_chan_switch_ann_action.op_class = new_op_class;
3622 frm.ext_chan_switch_ann_action.new_channel = new_channel;
3623 frm.ext_chan_switch_ann_action.switch_count = count;
3624
Vignesh Viswanathan93b7f702017-12-19 17:48:45 +05303625 ch_spacing = wlan_reg_dmn_get_chanwidth_from_opclass(
3626 mac_ctx->scan.countryCodeCurrent, new_channel,
3627 new_op_class);
3628 pe_debug("wrapper: ch_spacing %hu", ch_spacing);
3629
3630 if ((ch_spacing == 80) || (ch_spacing == 160)) {
3631 wide_bw_ie = &session_entry->gLimWiderBWChannelSwitch;
3632 frm.WiderBWChanSwitchAnn.newChanWidth =
3633 wide_bw_ie->newChanWidth;
3634 frm.WiderBWChanSwitchAnn.newCenterChanFreq0 =
3635 wide_bw_ie->newCenterChanFreq0;
3636 frm.WiderBWChanSwitchAnn.newCenterChanFreq1 =
3637 wide_bw_ie->newCenterChanFreq1;
3638 frm.WiderBWChanSwitchAnn.present = 1;
3639 pe_debug("wrapper: width:%d f0:%d f1:%d",
3640 frm.WiderBWChanSwitchAnn.newChanWidth,
3641 frm.WiderBWChanSwitchAnn.newCenterChanFreq0,
3642 frm.WiderBWChanSwitchAnn.newCenterChanFreq1);
3643 }
Abhishek Singh518323d2015-10-19 17:42:01 +05303644
3645 status = dot11f_get_packed_ext_channel_switch_action_frame_size(mac_ctx,
3646 &frm, &n_payload);
3647 if (DOT11F_FAILED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003648 pe_err("Failed to get packed size for Channel Switch 0x%08x",
Abhishek Singh518323d2015-10-19 17:42:01 +05303649 status);
3650 /* We'll fall back on the worst case scenario*/
3651 n_payload = sizeof(tDot11fext_channel_switch_action_frame);
3652 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003653 pe_warn("There were warnings while calculating the packed size for a Ext Channel Switch (0x%08x)",
Abhishek Singh518323d2015-10-19 17:42:01 +05303654 status);
3655 }
3656
3657 num_bytes = n_payload + sizeof(tSirMacMgmtHdr);
3658
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303659 qdf_status = cds_packet_alloc((uint16_t)num_bytes,
Abhishek Singh518323d2015-10-19 17:42:01 +05303660 (void **) &frame, (void **) &packet);
3661
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303662 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003663 pe_err("Failed to allocate %d bytes for a Ext Channel Switch",
Abhishek Singh518323d2015-10-19 17:42:01 +05303664 num_bytes);
3665 return eSIR_FAILURE;
3666 }
3667
3668 /* Paranoia*/
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303669 qdf_mem_set(frame, num_bytes, 0);
Abhishek Singh518323d2015-10-19 17:42:01 +05303670
3671 /* Next, we fill out the buffer descriptor */
3672 lim_populate_mac_header(mac_ctx, frame, SIR_MAC_MGMT_FRAME,
3673 SIR_MAC_MGMT_ACTION, peer, session_entry->selfMacAddr);
3674 mac_hdr = (tpSirMacMgmtHdr) frame;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303675 qdf_mem_copy((uint8_t *) mac_hdr->bssId,
Abhishek Singh518323d2015-10-19 17:42:01 +05303676 (uint8_t *) session_entry->bssId,
3677 sizeof(tSirMacAddr));
3678
3679 status = dot11f_pack_ext_channel_switch_action_frame(mac_ctx, &frm,
3680 frame + sizeof(tSirMacMgmtHdr), n_payload, &n_payload);
3681 if (DOT11F_FAILED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003682 pe_err("Failed to pack a Channel Switch 0x%08x", status);
Abhishek Singh518323d2015-10-19 17:42:01 +05303683 cds_packet_free((void *)packet);
3684 return eSIR_FAILURE;
3685 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003686 pe_warn("There were warnings while packing a Channel Switch 0x%08x",
Abhishek Singh518323d2015-10-19 17:42:01 +05303687 status);
3688 }
3689
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08003690 if ((BAND_5G ==
Abhishek Singh518323d2015-10-19 17:42:01 +05303691 lim_get_rf_band(session_entry->currentOperChannel)) ||
Anurag Chouhan6d760662016-02-20 16:05:43 +05303692 (session_entry->pePersona == QDF_P2P_CLIENT_MODE) ||
3693 (session_entry->pePersona == QDF_P2P_GO_MODE)) {
Abhishek Singh518323d2015-10-19 17:42:01 +05303694 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
3695 }
3696
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003697 pe_debug("Send Ext channel Switch to :"MAC_ADDRESS_STR" with swcount %d, swmode %d , newchannel %d newops %d",
Abhishek Singh518323d2015-10-19 17:42:01 +05303698 MAC_ADDR_ARRAY(mac_hdr->da),
3699 frm.ext_chan_switch_ann_action.switch_count,
3700 frm.ext_chan_switch_ann_action.switch_mode,
3701 frm.ext_chan_switch_ann_action.new_channel,
3702 frm.ext_chan_switch_ann_action.op_class);
3703
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303704 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Abhishek Singh518323d2015-10-19 17:42:01 +05303705 session_entry->peSessionId, mac_hdr->fc.subType));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303706 qdf_status = wma_tx_frame(mac_ctx, packet, (uint16_t) num_bytes,
Abhishek Singh518323d2015-10-19 17:42:01 +05303707 TXRX_FRM_802_11_MGMT,
3708 ANI_TXDIR_TODS,
3709 7,
3710 lim_tx_complete, frame,
Naveen Rawat296a5182017-09-25 14:02:48 -07003711 txFlag, sme_session_id, 0,
3712 RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303713 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303714 session_entry->peSessionId, qdf_status));
3715 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003716 pe_err("Failed to send a Ext Channel Switch %X!",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303717 qdf_status);
Abhishek Singh518323d2015-10-19 17:42:01 +05303718 /* Pkt will be freed up by the callback */
3719 return eSIR_FAILURE;
3720 }
3721 return eSIR_SUCCESS;
3722} /* End lim_send_extended_chan_switch_action_frame */
3723
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303724
3725/**
3726 * lim_oper_chan_change_confirm_tx_complete_cnf()- Confirmation for oper_chan_change_confirm
3727 * sent over the air
3728 *
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05303729 * @context: pointer to global mac
3730 * @buf: buffer
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303731 * @tx_complete : Sent status
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05303732 * @params: tx completion params
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303733 *
3734 * Return: This returns QDF_STATUS
3735 */
3736
3737static QDF_STATUS lim_oper_chan_change_confirm_tx_complete_cnf(
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05303738 void *context,
3739 qdf_nbuf_t buf,
3740 uint32_t tx_complete,
3741 void *params)
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303742{
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003743 pe_debug("tx_complete: %d", tx_complete);
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303744 return QDF_STATUS_SUCCESS;
3745}
3746
3747/**
3748 * lim_p2p_oper_chan_change_confirm_action_frame()- function to send
3749 * p2p oper chan change confirm action frame
3750 * @mac_ctx: pointer to global mac structure
3751 * @peer: Destination mac.
3752 * @session_entry: session entry
3753 *
3754 * This function is called to send p2p oper chan change confirm action frame.
3755 *
3756 * Return: success if frame is sent else return failure
3757 */
3758
3759tSirRetStatus
3760lim_p2p_oper_chan_change_confirm_action_frame(tpAniSirGlobal mac_ctx,
3761 tSirMacAddr peer, tpPESession session_entry)
3762{
3763 tDot11fp2p_oper_chan_change_confirm frm;
3764 uint8_t *frame;
3765 tpSirMacMgmtHdr mac_hdr;
3766 uint32_t num_bytes, n_payload, status;
3767 void *packet;
3768 QDF_STATUS qdf_status;
3769 uint8_t tx_flag = 0;
3770 uint8_t sme_session_id = 0;
3771
3772 if (session_entry == NULL) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003773 pe_err("Session entry is NULL!!!");
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303774 return eSIR_FAILURE;
3775 }
3776
3777 sme_session_id = session_entry->smeSessionId;
3778
3779 qdf_mem_set(&frm, sizeof(frm), 0);
3780
3781 frm.Category.category = SIR_MAC_ACTION_VENDOR_SPECIFIC_CATEGORY;
3782
3783 qdf_mem_copy(frm.p2p_action_oui.oui_data,
3784 SIR_MAC_P2P_OUI, SIR_MAC_P2P_OUI_SIZE);
3785 frm.p2p_action_subtype.subtype = 0x04;
3786 frm.DialogToken.token = 0x0;
3787
3788 if (session_entry->htCapability) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003789 pe_debug("Populate HT Caps in Assoc Request");
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303790 populate_dot11f_ht_caps(mac_ctx, session_entry, &frm.HTCaps);
3791 }
3792
3793 if (session_entry->vhtCapability) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003794 pe_debug("Populate VHT Caps in Assoc Request");
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303795 populate_dot11f_vht_caps(mac_ctx, session_entry, &frm.VHTCaps);
3796 populate_dot11f_operating_mode(mac_ctx,
3797 &frm.OperatingMode, session_entry);
3798 }
3799
3800 status = dot11f_get_packed_p2p_oper_chan_change_confirmSize(mac_ctx,
3801 &frm, &n_payload);
3802 if (DOT11F_FAILED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003803 pe_err("Failed to get packed size 0x%08x", status);
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303804 /* We'll fall back on the worst case scenario*/
3805 n_payload = sizeof(tDot11fp2p_oper_chan_change_confirm);
3806 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003807 pe_warn("There were warnings while calculating the packed size (0x%08x)",
3808 status);
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303809 }
3810
3811 num_bytes = n_payload + sizeof(tSirMacMgmtHdr);
3812
3813 qdf_status = cds_packet_alloc((uint16_t)num_bytes,
3814 (void **) &frame, (void **) &packet);
3815
3816 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003817 pe_err("Failed to allocate %d bytes", num_bytes);
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303818 return eSIR_FAILURE;
3819 }
3820
3821 qdf_mem_set(frame, num_bytes, 0);
3822
3823 /* Next, fill out the buffer descriptor */
3824 lim_populate_mac_header(mac_ctx, frame, SIR_MAC_MGMT_FRAME,
3825 SIR_MAC_MGMT_ACTION, peer, session_entry->selfMacAddr);
3826 mac_hdr = (tpSirMacMgmtHdr) frame;
3827 qdf_mem_copy((uint8_t *) mac_hdr->bssId,
3828 (uint8_t *) session_entry->bssId,
3829 sizeof(tSirMacAddr));
3830
3831 status = dot11f_pack_p2p_oper_chan_change_confirm(mac_ctx, &frm,
3832 frame + sizeof(tSirMacMgmtHdr), n_payload, &n_payload);
3833 if (DOT11F_FAILED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003834 pe_err("Failed to pack 0x%08x", status);
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303835 cds_packet_free((void *)packet);
3836 return eSIR_FAILURE;
3837 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003838 pe_warn("There were warnings while packing 0x%08x",
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303839 status);
3840 }
3841
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08003842 if ((BAND_5G ==
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303843 lim_get_rf_band(session_entry->currentOperChannel)) ||
3844 (session_entry->pePersona == QDF_P2P_CLIENT_MODE) ||
3845 (session_entry->pePersona == QDF_P2P_GO_MODE)) {
3846 tx_flag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
3847 }
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003848 pe_debug("Send frame on channel %d to mac "
3849 MAC_ADDRESS_STR, session_entry->currentOperChannel,
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303850 MAC_ADDR_ARRAY(peer));
3851
3852 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
3853 session_entry->peSessionId, mac_hdr->fc.subType));
3854
3855 qdf_status = wma_tx_frameWithTxComplete(mac_ctx, packet,
3856 (uint16_t)num_bytes,
3857 TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS,
3858 7, lim_tx_complete, frame,
3859 lim_oper_chan_change_confirm_tx_complete_cnf,
Naveen Rawat296a5182017-09-25 14:02:48 -07003860 tx_flag, sme_session_id, false, 0, RATEID_DEFAULT);
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303861
3862 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
3863 session_entry->peSessionId, qdf_status));
3864 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003865 pe_err("Failed to send status %X!", qdf_status);
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303866 /* Pkt will be freed up by the callback */
3867 return eSIR_FAILURE;
3868 }
3869 return eSIR_SUCCESS;
3870}
3871
3872
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003873tSirRetStatus
3874lim_send_vht_opmode_notification_frame(tpAniSirGlobal pMac,
3875 tSirMacAddr peer,
3876 uint8_t nMode, tpPESession psessionEntry)
3877{
3878 tDot11fOperatingMode frm;
3879 uint8_t *pFrame;
3880 tpSirMacMgmtHdr pMacHdr;
3881 uint32_t nBytes, nPayload = 0, nStatus; /* , nCfg; */
3882 void *pPacket;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303883 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003884 uint8_t txFlag = 0;
3885
3886 uint8_t smeSessionId = 0;
3887
3888 if (psessionEntry == NULL) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003889 pe_err("Session entry is NULL!!!");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003890 return eSIR_FAILURE;
3891 }
3892 smeSessionId = psessionEntry->smeSessionId;
3893
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303894 qdf_mem_set((uint8_t *) &frm, sizeof(frm), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003895
3896 frm.Category.category = SIR_MAC_ACTION_VHT;
3897 frm.Action.action = SIR_MAC_VHT_OPMODE_NOTIFICATION;
3898 frm.OperatingMode.chanWidth = nMode;
3899 frm.OperatingMode.rxNSS = 0;
3900 frm.OperatingMode.rxNSSType = 0;
3901
3902 nStatus = dot11f_get_packed_operating_mode_size(pMac, &frm, &nPayload);
3903 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003904 pe_err("Failed to calculate the packed size for a Operating Mode (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003905 nStatus);
3906 /* We'll fall back on the worst case scenario: */
3907 nPayload = sizeof(tDot11fOperatingMode);
3908 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003909 pe_warn("There were warnings while calculating the packed size for a Operating Mode (0x%08x)",
3910 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003911 }
3912
3913 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
3914
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303915 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003916 cds_packet_alloc((uint16_t) nBytes, (void **)&pFrame,
3917 (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303918 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003919 pe_err("Failed to allocate %d bytes for a Operating Mode Report",
3920 nBytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003921 return eSIR_FAILURE;
3922 }
3923 /* Paranoia: */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303924 qdf_mem_set(pFrame, nBytes, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003925
3926 /* Next, we fill out the buffer descriptor: */
Anurag Chouhan6d760662016-02-20 16:05:43 +05303927 if (psessionEntry->pePersona == QDF_SAP_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003928 lim_populate_mac_header(pMac, pFrame, SIR_MAC_MGMT_FRAME,
3929 SIR_MAC_MGMT_ACTION, peer,
3930 psessionEntry->selfMacAddr);
3931 else
3932 lim_populate_mac_header(pMac, pFrame, SIR_MAC_MGMT_FRAME,
3933 SIR_MAC_MGMT_ACTION, psessionEntry->bssId,
3934 psessionEntry->selfMacAddr);
3935 pMacHdr = (tpSirMacMgmtHdr) pFrame;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303936 qdf_mem_copy((uint8_t *) pMacHdr->bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003937 (uint8_t *) psessionEntry->bssId, sizeof(tSirMacAddr));
3938 nStatus = dot11f_pack_operating_mode(pMac, &frm, pFrame +
3939 sizeof(tSirMacMgmtHdr),
3940 nPayload, &nPayload);
3941 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003942 pe_err("Failed to pack a Operating Mode (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003943 nStatus);
3944 cds_packet_free((void *)pPacket);
3945 return eSIR_FAILURE; /* allocated! */
3946 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003947 pe_warn("There were warnings while packing a Operating Mode (0x%08x)",
3948 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003949 }
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08003950 if ((BAND_5G == lim_get_rf_band(psessionEntry->currentOperChannel))
Anurag Chouhan6d760662016-02-20 16:05:43 +05303951 || (psessionEntry->pePersona == QDF_P2P_CLIENT_MODE) ||
3952 (psessionEntry->pePersona == QDF_P2P_GO_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003953 ) {
3954 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
3955 }
3956
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303957 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003958 psessionEntry->peSessionId, pMacHdr->fc.subType));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303959 qdf_status = wma_tx_frame(pMac, pPacket, (uint16_t) nBytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003960 TXRX_FRM_802_11_MGMT,
3961 ANI_TXDIR_TODS,
3962 7, lim_tx_complete, pFrame, txFlag,
Naveen Rawat296a5182017-09-25 14:02:48 -07003963 smeSessionId, 0, RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303964 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303965 psessionEntry->peSessionId, qdf_status));
3966 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003967 pe_err("Failed to send a Channel Switch (%X)!",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303968 qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003969 /* Pkt will be freed up by the callback */
3970 return eSIR_FAILURE;
3971 }
3972
3973 return eSIR_SUCCESS;
3974}
3975
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003976/**
3977 * \brief Send a Neighbor Report Request Action frame
3978 *
3979 *
3980 * \param pMac Pointer to the global MAC structure
3981 *
3982 * \param pNeighborReq Address of a tSirMacNeighborReportReq
3983 *
3984 * \param peer mac address of peer station.
3985 *
3986 * \param psessionEntry address of session entry.
3987 *
3988 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
3989 *
3990 *
3991 */
3992
3993tSirRetStatus
3994lim_send_neighbor_report_request_frame(tpAniSirGlobal pMac,
3995 tpSirMacNeighborReportReq pNeighborReq,
3996 tSirMacAddr peer, tpPESession psessionEntry)
3997{
3998 tSirRetStatus statusCode = eSIR_SUCCESS;
3999 tDot11fNeighborReportRequest frm;
4000 uint8_t *pFrame;
4001 tpSirMacMgmtHdr pMacHdr;
4002 uint32_t nBytes, nPayload, nStatus;
4003 void *pPacket;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304004 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004005 uint8_t txFlag = 0;
4006 uint8_t smeSessionId = 0;
4007
4008 if (psessionEntry == NULL) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004009 pe_err("(psession == NULL) in Request to send Neighbor Report request action frame");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004010 return eSIR_FAILURE;
4011 }
4012 smeSessionId = psessionEntry->smeSessionId;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304013 qdf_mem_set((uint8_t *) &frm, sizeof(frm), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004014
4015 frm.Category.category = SIR_MAC_ACTION_RRM;
4016 frm.Action.action = SIR_MAC_RRM_NEIGHBOR_REQ;
4017 frm.DialogToken.token = pNeighborReq->dialogToken;
4018
4019 if (pNeighborReq->ssid_present) {
4020 populate_dot11f_ssid(pMac, &pNeighborReq->ssid, &frm.SSID);
4021 }
4022
4023 nStatus =
4024 dot11f_get_packed_neighbor_report_request_size(pMac, &frm, &nPayload);
4025 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004026 pe_err("Failed to calculate the packed size for a Neighbor Report Request(0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004027 nStatus);
4028 /* We'll fall back on the worst case scenario: */
4029 nPayload = sizeof(tDot11fNeighborReportRequest);
4030 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004031 pe_warn("There were warnings while calculating the packed size for a Neighbor Report Request(0x%08x)",
4032 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004033 }
4034
4035 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
4036
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304037 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004038 cds_packet_alloc((uint16_t) nBytes, (void **)&pFrame,
4039 (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304040 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004041 pe_err("Failed to allocate %d bytes for a Neighbor "
4042 "Report Request", nBytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004043 return eSIR_FAILURE;
4044 }
4045 /* Paranoia: */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304046 qdf_mem_set(pFrame, nBytes, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004047
4048 /* Copy necessary info to BD */
4049 lim_populate_mac_header(pMac, pFrame, SIR_MAC_MGMT_FRAME,
4050 SIR_MAC_MGMT_ACTION, peer, psessionEntry->selfMacAddr);
4051
4052 /* Update A3 with the BSSID */
4053 pMacHdr = (tpSirMacMgmtHdr) pFrame;
4054
4055 sir_copy_mac_addr(pMacHdr->bssId, psessionEntry->bssId);
4056
4057#ifdef WLAN_FEATURE_11W
4058 lim_set_protected_bit(pMac, psessionEntry, peer, pMacHdr);
4059#endif
4060
4061 /* Now, we're ready to "pack" the frames */
4062 nStatus = dot11f_pack_neighbor_report_request(pMac,
4063 &frm,
4064 pFrame +
4065 sizeof(tSirMacMgmtHdr),
4066 nPayload, &nPayload);
4067
4068 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004069 pe_err("Failed to pack an Neighbor Report Request (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004070 nStatus);
4071
4072 /* FIXME - Need to convert to tSirRetStatus */
4073 statusCode = eSIR_FAILURE;
4074 goto returnAfterError;
4075 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004076 pe_warn("There were warnings while packing Neighbor Report Request (0x%08x)",
4077 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004078 }
4079
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004080 pe_debug("Sending a Neighbor Report Request to");
Nishank Aggarwal46bd31a2017-03-10 16:23:53 +05304081 lim_print_mac_addr(pMac, peer, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004082
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08004083 if ((BAND_5G == lim_get_rf_band(psessionEntry->currentOperChannel))
Anurag Chouhan6d760662016-02-20 16:05:43 +05304084 || (psessionEntry->pePersona == QDF_P2P_CLIENT_MODE) ||
4085 (psessionEntry->pePersona == QDF_P2P_GO_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004086 ) {
4087 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
4088 }
4089
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304090 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004091 psessionEntry->peSessionId, pMacHdr->fc.subType));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304092 qdf_status = wma_tx_frame(pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004093 pPacket,
4094 (uint16_t) nBytes,
4095 TXRX_FRM_802_11_MGMT,
4096 ANI_TXDIR_TODS,
4097 7, lim_tx_complete, pFrame, txFlag,
Naveen Rawat296a5182017-09-25 14:02:48 -07004098 smeSessionId, 0, RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304099 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304100 psessionEntry->peSessionId, qdf_status));
4101 if (QDF_STATUS_SUCCESS != qdf_status) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004102 pe_err("wma_tx_frame FAILED! Status [%d]", qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004103 statusCode = eSIR_FAILURE;
4104 /* Pkt will be freed up by the callback */
4105 return statusCode;
4106 } else
4107 return eSIR_SUCCESS;
4108
4109returnAfterError:
4110 cds_packet_free((void *)pPacket);
4111
4112 return statusCode;
4113} /* End lim_send_neighbor_report_request_frame. */
4114
4115/**
4116 * \brief Send a Link Report Action frame
4117 *
4118 *
4119 * \param pMac Pointer to the global MAC structure
4120 *
4121 * \param pLinkReport Address of a tSirMacLinkReport
4122 *
4123 * \param peer mac address of peer station.
4124 *
4125 * \param psessionEntry address of session entry.
4126 *
4127 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
4128 *
4129 *
4130 */
4131
4132tSirRetStatus
4133lim_send_link_report_action_frame(tpAniSirGlobal pMac,
4134 tpSirMacLinkReport pLinkReport,
4135 tSirMacAddr peer, tpPESession psessionEntry)
4136{
4137 tSirRetStatus statusCode = eSIR_SUCCESS;
4138 tDot11fLinkMeasurementReport frm;
4139 uint8_t *pFrame;
4140 tpSirMacMgmtHdr pMacHdr;
4141 uint32_t nBytes, nPayload, nStatus;
4142 void *pPacket;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304143 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004144 uint8_t txFlag = 0;
4145 uint8_t smeSessionId = 0;
4146
4147 if (psessionEntry == NULL) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004148 pe_err("(psession == NULL) in Request to send Link Report action frame");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004149 return eSIR_FAILURE;
4150 }
4151
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304152 qdf_mem_set((uint8_t *) &frm, sizeof(frm), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004153
4154 frm.Category.category = SIR_MAC_ACTION_RRM;
4155 frm.Action.action = SIR_MAC_RRM_LINK_MEASUREMENT_RPT;
4156 frm.DialogToken.token = pLinkReport->dialogToken;
4157
4158 /* IEEE Std. 802.11 7.3.2.18. for the report element. */
4159 /* Even though TPC report an IE, it is represented using fixed fields since it is positioned */
4160 /* in the middle of other fixed fields in the link report frame(IEEE Std. 802.11k section7.4.6.4 */
4161 /* and frame parser always expects IEs to come after all fixed fields. It is easier to handle */
4162 /* such case this way than changing the frame parser. */
4163 frm.TPCEleID.TPCId = SIR_MAC_TPC_RPT_EID;
4164 frm.TPCEleLen.TPCLen = 2;
4165 frm.TxPower.txPower = pLinkReport->txPower;
4166 frm.LinkMargin.linkMargin = 0;
4167
4168 frm.RxAntennaId.antennaId = pLinkReport->rxAntenna;
4169 frm.TxAntennaId.antennaId = pLinkReport->txAntenna;
4170 frm.RCPI.rcpi = pLinkReport->rcpi;
4171 frm.RSNI.rsni = pLinkReport->rsni;
4172
4173 nStatus =
4174 dot11f_get_packed_link_measurement_report_size(pMac, &frm, &nPayload);
4175 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004176 pe_err("Failed to calculate the packed size for a Link Report (0x%08x)", nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004177 /* We'll fall back on the worst case scenario: */
4178 nPayload = sizeof(tDot11fLinkMeasurementReport);
4179 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004180 pe_warn("There were warnings while calculating the packed size for a Link Report (0x%08x)",
4181 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004182 }
4183
4184 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
4185
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304186 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004187 cds_packet_alloc((uint16_t) nBytes, (void **)&pFrame,
4188 (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304189 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004190 pe_err("Failed to allocate %d bytes for a Link "
4191 "Report", nBytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004192 return eSIR_FAILURE;
4193 }
4194 /* Paranoia: */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304195 qdf_mem_set(pFrame, nBytes, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004196
4197 /* Copy necessary info to BD */
4198 lim_populate_mac_header(pMac, pFrame, SIR_MAC_MGMT_FRAME,
4199 SIR_MAC_MGMT_ACTION, peer, psessionEntry->selfMacAddr);
4200
4201 /* Update A3 with the BSSID */
4202 pMacHdr = (tpSirMacMgmtHdr) pFrame;
4203
4204 sir_copy_mac_addr(pMacHdr->bssId, psessionEntry->bssId);
4205
4206#ifdef WLAN_FEATURE_11W
4207 lim_set_protected_bit(pMac, psessionEntry, peer, pMacHdr);
4208#endif
4209
4210 /* Now, we're ready to "pack" the frames */
4211 nStatus = dot11f_pack_link_measurement_report(pMac,
4212 &frm,
4213 pFrame +
4214 sizeof(tSirMacMgmtHdr),
4215 nPayload, &nPayload);
4216
4217 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004218 pe_err("Failed to pack an Link Report (0x%08x)", nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004219
4220 /* FIXME - Need to convert to tSirRetStatus */
4221 statusCode = eSIR_FAILURE;
4222 goto returnAfterError;
4223 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004224 pe_warn("There were warnings while packing Link Report (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004225 nStatus);
4226 }
4227
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004228 pe_warn("Sending a Link Report to");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004229 lim_print_mac_addr(pMac, peer, LOGW);
4230
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08004231 if ((BAND_5G == lim_get_rf_band(psessionEntry->currentOperChannel))
Anurag Chouhan6d760662016-02-20 16:05:43 +05304232 || (psessionEntry->pePersona == QDF_P2P_CLIENT_MODE) ||
4233 (psessionEntry->pePersona == QDF_P2P_GO_MODE)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004234 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
4235 }
4236
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304237 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004238 psessionEntry->peSessionId, pMacHdr->fc.subType));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304239 qdf_status = wma_tx_frame(pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004240 pPacket,
4241 (uint16_t) nBytes,
4242 TXRX_FRM_802_11_MGMT,
4243 ANI_TXDIR_TODS,
4244 7, lim_tx_complete, pFrame, txFlag,
Naveen Rawat296a5182017-09-25 14:02:48 -07004245 smeSessionId, 0, RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304246 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304247 psessionEntry->peSessionId, qdf_status));
4248 if (QDF_STATUS_SUCCESS != qdf_status) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004249 pe_err("wma_tx_frame FAILED! Status [%d]", qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004250 statusCode = eSIR_FAILURE;
4251 /* Pkt will be freed up by the callback */
4252 return statusCode;
4253 } else
4254 return eSIR_SUCCESS;
4255
4256returnAfterError:
4257 cds_packet_free((void *)pPacket);
4258
4259 return statusCode;
4260} /* End lim_send_link_report_action_frame. */
4261
4262/**
4263 * \brief Send a Beacon Report Action frame
4264 *
4265 *
4266 * \param pMac Pointer to the global MAC structure
4267 *
4268 * \param dialog_token dialog token to be used in the action frame.
4269 *
4270 * \param num_report number of reports in pRRMReport.
4271 *
4272 * \param pRRMReport Address of a tSirMacRadioMeasureReport.
4273 *
4274 * \param peer mac address of peer station.
4275 *
4276 * \param psessionEntry address of session entry.
4277 *
4278 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
4279 *
4280 *
4281 */
4282
4283tSirRetStatus
4284lim_send_radio_measure_report_action_frame(tpAniSirGlobal pMac,
4285 uint8_t dialog_token,
4286 uint8_t num_report,
4287 tpSirMacRadioMeasureReport pRRMReport,
4288 tSirMacAddr peer,
4289 tpPESession psessionEntry)
4290{
4291 tSirRetStatus statusCode = eSIR_SUCCESS;
4292 uint8_t *pFrame;
4293 tpSirMacMgmtHdr pMacHdr;
4294 uint32_t nBytes, nPayload, nStatus;
4295 void *pPacket;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304296 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004297 uint8_t i;
4298 uint8_t txFlag = 0;
4299 uint8_t smeSessionId = 0;
4300
4301 tDot11fRadioMeasurementReport *frm =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304302 qdf_mem_malloc(sizeof(tDot11fRadioMeasurementReport));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004303 if (!frm) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004304 pe_err("Not enough memory to allocate tDot11fRadioMeasurementReport");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004305 return eSIR_MEM_ALLOC_FAILED;
4306 }
4307
4308 if (psessionEntry == NULL) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004309 pe_err("(psession == NULL) in Request to send Beacon Report action frame");
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304310 qdf_mem_free(frm);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004311 return eSIR_FAILURE;
4312 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004313
Deepak Dhamdhere6a021482017-04-20 17:59:58 -07004314 smeSessionId = psessionEntry->smeSessionId;
4315
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004316 pe_debug("dialog_token %d num_report %d",
Padma, Santhosh Kumar93ec7d22016-12-26 15:58:37 +05304317 dialog_token, num_report);
4318
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004319 frm->Category.category = SIR_MAC_ACTION_RRM;
4320 frm->Action.action = SIR_MAC_RRM_RADIO_MEASURE_RPT;
4321 frm->DialogToken.token = dialog_token;
4322
4323 frm->num_MeasurementReport =
4324 (num_report >
4325 RADIO_REPORTS_MAX_IN_A_FRAME) ? RADIO_REPORTS_MAX_IN_A_FRAME :
4326 num_report;
4327
4328 for (i = 0; i < frm->num_MeasurementReport; i++) {
4329 frm->MeasurementReport[i].type = pRRMReport[i].type;
4330 frm->MeasurementReport[i].token = pRRMReport[i].token;
4331 frm->MeasurementReport[i].late = 0; /* IEEE 802.11k section 7.3.22. (always zero in rrm) */
4332 switch (pRRMReport[i].type) {
4333 case SIR_MAC_RRM_BEACON_TYPE:
4334 populate_dot11f_beacon_report(pMac,
4335 &frm->MeasurementReport[i],
4336 &pRRMReport[i].report.
4337 beaconReport);
4338 frm->MeasurementReport[i].incapable =
4339 pRRMReport[i].incapable;
4340 frm->MeasurementReport[i].refused =
4341 pRRMReport[i].refused;
4342 frm->MeasurementReport[i].present = 1;
4343 break;
4344 default:
4345 frm->MeasurementReport[i].incapable =
4346 pRRMReport[i].incapable;
4347 frm->MeasurementReport[i].refused =
4348 pRRMReport[i].refused;
4349 frm->MeasurementReport[i].present = 1;
4350 break;
4351 }
4352 }
4353
4354 nStatus =
4355 dot11f_get_packed_radio_measurement_report_size(pMac, frm, &nPayload);
4356 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004357 pe_err("Failed to calculate the packed size for a Radio Measure Report (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004358 nStatus);
4359 /* We'll fall back on the worst case scenario: */
4360 nPayload = sizeof(tDot11fLinkMeasurementReport);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304361 qdf_mem_free(frm);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004362 return eSIR_FAILURE;
4363 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004364 pe_warn("There were warnings while calculating the packed size for a Radio Measure Report (0x%08x)",
4365 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004366 }
4367
4368 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
4369
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304370 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004371 cds_packet_alloc((uint16_t) nBytes, (void **)&pFrame,
4372 (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304373 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004374 pe_err("Failed to allocate %d bytes for a Radio Measure "
4375 "Report", nBytes);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304376 qdf_mem_free(frm);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004377 return eSIR_FAILURE;
4378 }
4379 /* Paranoia: */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304380 qdf_mem_set(pFrame, nBytes, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004381
4382 /* Copy necessary info to BD */
4383 lim_populate_mac_header(pMac, pFrame, SIR_MAC_MGMT_FRAME,
4384 SIR_MAC_MGMT_ACTION, peer, psessionEntry->selfMacAddr);
4385
4386 /* Update A3 with the BSSID */
4387 pMacHdr = (tpSirMacMgmtHdr) pFrame;
4388
4389 sir_copy_mac_addr(pMacHdr->bssId, psessionEntry->bssId);
4390
4391#ifdef WLAN_FEATURE_11W
4392 lim_set_protected_bit(pMac, psessionEntry, peer, pMacHdr);
4393#endif
4394
4395 /* Now, we're ready to "pack" the frames */
4396 nStatus = dot11f_pack_radio_measurement_report(pMac,
4397 frm,
4398 pFrame +
4399 sizeof(tSirMacMgmtHdr),
4400 nPayload, &nPayload);
4401
4402 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004403 pe_err("Failed to pack an Radio Measure Report (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004404 nStatus);
4405
4406 /* FIXME - Need to convert to tSirRetStatus */
4407 statusCode = eSIR_FAILURE;
4408 goto returnAfterError;
4409 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004410 pe_warn("There were warnings while packing Radio Measure Report (0x%08x)",
4411 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004412 }
4413
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004414 pe_warn("Sending a Radio Measure Report to");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004415 lim_print_mac_addr(pMac, peer, LOGW);
4416
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08004417 if ((BAND_5G == lim_get_rf_band(psessionEntry->currentOperChannel))
Anurag Chouhan6d760662016-02-20 16:05:43 +05304418 || (psessionEntry->pePersona == QDF_P2P_CLIENT_MODE) ||
4419 (psessionEntry->pePersona == QDF_P2P_GO_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004420 ) {
4421 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
4422 }
4423
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304424 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004425 psessionEntry->peSessionId, pMacHdr->fc.subType));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304426 qdf_status = wma_tx_frame(pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004427 pPacket,
4428 (uint16_t) nBytes,
4429 TXRX_FRM_802_11_MGMT,
4430 ANI_TXDIR_TODS,
4431 7, lim_tx_complete, pFrame, txFlag,
Naveen Rawat296a5182017-09-25 14:02:48 -07004432 smeSessionId, 0, RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304433 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304434 psessionEntry->peSessionId, qdf_status));
4435 if (QDF_STATUS_SUCCESS != qdf_status) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004436 pe_err("wma_tx_frame FAILED! Status [%d]", qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004437 statusCode = eSIR_FAILURE;
4438 /* Pkt will be freed up by the callback */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304439 qdf_mem_free(frm);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004440 return statusCode;
4441 } else {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304442 qdf_mem_free(frm);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004443 return eSIR_SUCCESS;
4444 }
4445
4446returnAfterError:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304447 qdf_mem_free(frm);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004448 cds_packet_free((void *)pPacket);
4449 return statusCode;
4450}
4451
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004452#ifdef WLAN_FEATURE_11W
4453/**
4454 * \brief Send SA query request action frame to peer
4455 *
4456 * \sa lim_send_sa_query_request_frame
4457 *
4458 *
4459 * \param pMac The global tpAniSirGlobal object
4460 *
4461 * \param transId Transaction identifier
4462 *
4463 * \param peer The Mac address of the station to which this action frame is addressed
4464 *
4465 * \param psessionEntry The PE session entry
4466 *
4467 * \return eSIR_SUCCESS if setup completes successfully
4468 * eSIR_FAILURE is some problem is encountered
4469 */
4470
4471tSirRetStatus lim_send_sa_query_request_frame(tpAniSirGlobal pMac, uint8_t *transId,
4472 tSirMacAddr peer,
4473 tpPESession psessionEntry)
4474{
4475
4476 tDot11fSaQueryReq frm; /* SA query request action frame */
4477 uint8_t *pFrame;
4478 tSirRetStatus nSirStatus;
4479 tpSirMacMgmtHdr pMacHdr;
4480 uint32_t nBytes, nPayload, nStatus;
4481 void *pPacket;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304482 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004483 uint8_t txFlag = 0;
4484 uint8_t smeSessionId = 0;
4485
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304486 qdf_mem_set((uint8_t *) &frm, sizeof(frm), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004487 frm.Category.category = SIR_MAC_ACTION_SA_QUERY;
4488 /* 11w action field is :
4489 action: 0 --> SA Query Request action frame
4490 action: 1 --> SA Query Response action frame */
4491 frm.Action.action = SIR_MAC_SA_QUERY_REQ;
4492 /* 11w SA Query Request transId */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304493 qdf_mem_copy(&frm.TransactionId.transId[0], &transId[0], 2);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004494
4495 nStatus = dot11f_get_packed_sa_query_req_size(pMac, &frm, &nPayload);
4496 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004497 pe_err("Failed to calculate the packed size for an SA Query Request (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004498 nStatus);
4499 /* We'll fall back on the worst case scenario: */
4500 nPayload = sizeof(tDot11fSaQueryReq);
4501 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004502 pe_warn("There were warnings while calculating the packed size for an SA Query Request (0x%08x)",
4503 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004504 }
4505
4506 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304507 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004508 cds_packet_alloc(nBytes, (void **)&pFrame, (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304509 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004510 pe_err("Failed to allocate %d bytes for a SA Query Request "
4511 "action frame", nBytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004512 return eSIR_FAILURE;
4513 }
4514 /* Paranoia: */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304515 qdf_mem_set(pFrame, nBytes, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004516
4517 /* Copy necessary info to BD */
4518 lim_populate_mac_header(pMac, pFrame, SIR_MAC_MGMT_FRAME,
4519 SIR_MAC_MGMT_ACTION, peer, psessionEntry->selfMacAddr);
4520
4521 /* Update A3 with the BSSID */
4522 pMacHdr = (tpSirMacMgmtHdr) pFrame;
4523
4524 sir_copy_mac_addr(pMacHdr->bssId, psessionEntry->bssId);
4525
4526 /* Since this is a SA Query Request, set the "protect" (aka WEP) bit */
4527 /* in the FC */
4528 lim_set_protected_bit(pMac, psessionEntry, peer, pMacHdr);
4529
4530 /* Pack 11w SA Query Request frame */
4531 nStatus = dot11f_pack_sa_query_req(pMac,
4532 &frm,
4533 pFrame + sizeof(tSirMacMgmtHdr),
4534 nPayload, &nPayload);
4535
4536 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004537 pe_err("Failed to pack an SA Query Request (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004538 nStatus);
4539 /* FIXME - Need to convert to tSirRetStatus */
4540 nSirStatus = eSIR_FAILURE;
4541 goto returnAfterError;
4542 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004543 pe_warn("There were warnings while packing SA Query Request (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004544 nStatus);
4545 }
4546
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004547 pe_debug("Sending an SA Query Request to");
4548 lim_print_mac_addr(pMac, peer, LOGD);
4549 pe_debug("Sending an SA Query Request from ");
4550 lim_print_mac_addr(pMac, psessionEntry->selfMacAddr, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004551
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08004552 if ((BAND_5G == lim_get_rf_band(psessionEntry->currentOperChannel))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004553#ifdef WLAN_FEATURE_P2P
Anurag Chouhan6d760662016-02-20 16:05:43 +05304554 || (psessionEntry->pePersona == QDF_P2P_CLIENT_MODE) ||
4555 (psessionEntry->pePersona == QDF_P2P_GO_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004556#endif
4557 ) {
4558 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
4559 }
4560 smeSessionId = psessionEntry->smeSessionId;
4561
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304562 qdf_status = wma_tx_frame(pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004563 pPacket,
4564 (uint16_t) nBytes,
4565 TXRX_FRM_802_11_MGMT,
4566 ANI_TXDIR_TODS,
4567 7, lim_tx_complete, pFrame, txFlag,
Naveen Rawat296a5182017-09-25 14:02:48 -07004568 smeSessionId, 0, RATEID_DEFAULT);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304569 if (QDF_STATUS_SUCCESS != qdf_status) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004570 pe_err("wma_tx_frame FAILED! Status [%d]", qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004571 nSirStatus = eSIR_FAILURE;
4572 /* Pkt will be freed up by the callback */
4573 return nSirStatus;
4574 } else {
4575 return eSIR_SUCCESS;
4576 }
4577
4578returnAfterError:
4579 cds_packet_free((void *)pPacket);
4580 return nSirStatus;
4581} /* End lim_send_sa_query_request_frame */
4582
4583/**
4584 * \brief Send SA query response action frame to peer
4585 *
4586 * \sa lim_send_sa_query_response_frame
4587 *
4588 *
4589 * \param pMac The global tpAniSirGlobal object
4590 *
4591 * \param transId Transaction identifier received in SA query request action frame
4592 *
4593 * \param peer The Mac address of the AP to which this action frame is addressed
4594 *
4595 * \param psessionEntry The PE session entry
4596 *
4597 * \return eSIR_SUCCESS if setup completes successfully
4598 * eSIR_FAILURE is some problem is encountered
4599 */
4600
4601tSirRetStatus lim_send_sa_query_response_frame(tpAniSirGlobal pMac,
4602 uint8_t *transId, tSirMacAddr peer,
4603 tpPESession psessionEntry)
4604{
4605
4606 tDot11fSaQueryRsp frm; /* SA query reponse action frame */
4607 uint8_t *pFrame;
4608 tSirRetStatus nSirStatus;
4609 tpSirMacMgmtHdr pMacHdr;
4610 uint32_t nBytes, nPayload, nStatus;
4611 void *pPacket;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304612 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004613 uint8_t txFlag = 0;
4614 uint8_t smeSessionId = 0;
4615
4616 smeSessionId = psessionEntry->smeSessionId;
4617
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304618 qdf_mem_set((uint8_t *) &frm, sizeof(frm), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004619 frm.Category.category = SIR_MAC_ACTION_SA_QUERY;
4620 /*11w action field is :
4621 action: 0 --> SA query request action frame
4622 action: 1 --> SA query response action frame */
4623 frm.Action.action = SIR_MAC_SA_QUERY_RSP;
4624 /*11w SA query response transId is same as
4625 SA query request transId */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304626 qdf_mem_copy(&frm.TransactionId.transId[0], &transId[0], 2);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004627
4628 nStatus = dot11f_get_packed_sa_query_rsp_size(pMac, &frm, &nPayload);
4629 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004630 pe_err("Failed to calculate the packed size for a SA Query Response (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004631 nStatus);
4632 /* We'll fall back on the worst case scenario: */
4633 nPayload = sizeof(tDot11fSaQueryRsp);
4634 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004635 pe_warn("There were warnings while calculating the packed size for an SA Query Response (0x%08x)",
4636 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004637 }
4638
4639 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304640 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004641 cds_packet_alloc(nBytes, (void **)&pFrame, (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304642 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004643 pe_err("Failed to allocate %d bytes for a SA query response"
4644 " action frame", nBytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004645 return eSIR_FAILURE;
4646 }
4647 /* Paranoia: */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304648 qdf_mem_set(pFrame, nBytes, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004649
4650 /* Copy necessary info to BD */
4651 lim_populate_mac_header(pMac, pFrame, SIR_MAC_MGMT_FRAME,
4652 SIR_MAC_MGMT_ACTION, peer, psessionEntry->selfMacAddr);
4653
4654 /* Update A3 with the BSSID */
4655 pMacHdr = (tpSirMacMgmtHdr) pFrame;
4656
4657 sir_copy_mac_addr(pMacHdr->bssId, psessionEntry->bssId);
4658
4659 /* Since this is a SA Query Response, set the "protect" (aka WEP) bit */
4660 /* in the FC */
4661 lim_set_protected_bit(pMac, psessionEntry, peer, pMacHdr);
4662
4663 /* Pack 11w SA query response frame */
4664 nStatus = dot11f_pack_sa_query_rsp(pMac,
4665 &frm,
4666 pFrame + sizeof(tSirMacMgmtHdr),
4667 nPayload, &nPayload);
4668
4669 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004670 pe_err("Failed to pack an SA Query Response (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004671 nStatus);
4672 /* FIXME - Need to convert to tSirRetStatus */
4673 nSirStatus = eSIR_FAILURE;
4674 goto returnAfterError;
4675 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004676 pe_warn("There were warnings while packing SA Query Response (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004677 nStatus);
4678 }
4679
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004680 pe_debug("Sending a SA Query Response to");
Srinivas Girigowdaf936d822017-03-19 23:23:59 -07004681 lim_print_mac_addr(pMac, peer, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004682
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08004683 if ((BAND_5G == lim_get_rf_band(psessionEntry->currentOperChannel))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004684#ifdef WLAN_FEATURE_P2P
Anurag Chouhan6d760662016-02-20 16:05:43 +05304685 || (psessionEntry->pePersona == QDF_P2P_CLIENT_MODE) ||
4686 (psessionEntry->pePersona == QDF_P2P_GO_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004687#endif
4688 ) {
4689 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
4690 }
4691
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304692 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004693 psessionEntry->peSessionId, pMacHdr->fc.subType));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304694 qdf_status = wma_tx_frame(pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004695 pPacket,
4696 (uint16_t) nBytes,
4697 TXRX_FRM_802_11_MGMT,
4698 ANI_TXDIR_TODS,
4699 7, lim_tx_complete, pFrame, txFlag,
Naveen Rawat296a5182017-09-25 14:02:48 -07004700 smeSessionId, 0, RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304701 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304702 psessionEntry->peSessionId, qdf_status));
4703 if (QDF_STATUS_SUCCESS != qdf_status) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004704 pe_err("wma_tx_frame FAILED! Status [%d]", qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004705 nSirStatus = eSIR_FAILURE;
4706 /* Pkt will be freed up by the callback */
4707 return nSirStatus;
4708 } else {
4709 return eSIR_SUCCESS;
4710 }
4711
4712returnAfterError:
4713 cds_packet_free((void *)pPacket);
4714 return nSirStatus;
4715} /* End lim_send_sa_query_response_frame */
4716#endif
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004717
4718/**
4719 * lim_send_addba_response_frame(): Send ADDBA response action frame to peer
4720 * @mac_ctx: mac context
4721 * @peer_mac: Peer MAC address
4722 * @tid: TID for which addba response is being sent
4723 * @session: PE session entry
Kiran Kumar Lokere40875852018-01-15 12:36:19 -08004724 * @addba_extn_present: ADDBA extension present flag
Kiran Kumar Lokereaee823a2018-03-22 15:27:05 -07004725 * @amsdu_support: amsdu in ampdu support
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004726 *
4727 * This function is called when ADDBA request is successful. ADDBA response is
4728 * setup by calling addba_response_setup API and frame is then sent out OTA.
4729 *
4730 * Return: QDF_STATUS
4731 */
4732QDF_STATUS lim_send_addba_response_frame(tpAniSirGlobal mac_ctx,
Kiran Kumar Lokere40875852018-01-15 12:36:19 -08004733 tSirMacAddr peer_mac, uint16_t tid,
Kiran Kumar Lokereaee823a2018-03-22 15:27:05 -07004734 tpPESession session, uint8_t addba_extn_present,
4735 uint8_t amsdu_support)
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004736{
4737
4738 tDot11faddba_rsp frm;
4739 uint8_t *frame_ptr;
4740 tpSirMacMgmtHdr mgmt_hdr;
4741 uint32_t num_bytes, payload_size, status;
4742 void *pkt_ptr;
4743 QDF_STATUS qdf_status;
4744 uint8_t tx_flag = 0;
4745 uint8_t sme_sessionid = 0;
4746 uint16_t buff_size, status_code, batimeout;
4747 uint8_t peer_id, dialog_token;
4748 void *soc = cds_get_context(QDF_MODULE_ID_SOC);
4749 void *peer, *pdev;
Kiran Kumar Lokere40875852018-01-15 12:36:19 -08004750 uint8_t he_frag = 0;
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004751
4752 sme_sessionid = session->smeSessionId;
4753
4754 pdev = cds_get_context(QDF_MODULE_ID_TXRX);
4755 if (!pdev) {
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004756 pe_err("pdev is NULL");
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004757 return QDF_STATUS_E_FAILURE;
4758 }
4759
Mohit Khannac4c22252017-11-20 11:06:33 -08004760 peer = cdp_peer_get_ref_by_addr(soc, pdev, peer_mac, &peer_id,
4761 PEER_DEBUG_ID_LIM_SEND_ADDBA_RESP);
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004762 if (!peer) {
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004763 pe_err("PEER [%pM] not found", peer_mac);
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004764 return QDF_STATUS_E_FAILURE;
4765 }
4766
4767 cdp_addba_responsesetup(soc, peer, tid, &dialog_token,
4768 &status_code, &buff_size, &batimeout);
4769
Mohit Khannac4c22252017-11-20 11:06:33 -08004770 cdp_peer_release_ref(soc, peer, PEER_DEBUG_ID_LIM_SEND_ADDBA_RESP);
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004771 qdf_mem_set((uint8_t *) &frm, sizeof(frm), 0);
4772 frm.Category.category = SIR_MAC_ACTION_BLKACK;
4773 frm.Action.action = SIR_MAC_ADDBA_RSP;
4774
4775 frm.DialogToken.token = dialog_token;
4776 frm.Status.status = status_code;
Kiran Kumar Lokere08195ef2018-01-17 19:25:15 -08004777 if (mac_ctx->reject_addba_req) {
4778 frm.Status.status = eSIR_MAC_REQ_DECLINED_STATUS;
4779 pe_err("refused addba req");
4780 }
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004781 frm.addba_param_set.tid = tid;
Kiran Kumar Lokere96180e12018-03-12 17:58:23 -07004782 frm.addba_param_set.buff_size = SIR_MAC_BA_DEFAULT_BUFF_SIZE;
Kiran Kumar Lokerebc87bec2018-02-27 20:06:42 -08004783 if (mac_ctx->usr_cfg_ba_buff_size)
4784 frm.addba_param_set.buff_size = mac_ctx->usr_cfg_ba_buff_size;
Kiran Kumar Lokereaee823a2018-03-22 15:27:05 -07004785 frm.addba_param_set.amsdu_supp = amsdu_support;
Kiran Kumar Lokerebc87bec2018-02-27 20:06:42 -08004786 frm.addba_param_set.policy = SIR_MAC_BA_POLICY_IMMEDIATE;
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004787 frm.ba_timeout.timeout = batimeout;
Kiran Kumar Lokere40875852018-01-15 12:36:19 -08004788 if (addba_extn_present) {
4789 frm.addba_extn_element.present = 1;
4790 frm.addba_extn_element.no_fragmentation = 1;
4791 if (lim_is_session_he_capable(session)) {
4792 he_frag = lim_get_session_he_frag_cap(session);
4793 if (he_frag != 0) {
4794 frm.addba_extn_element.no_fragmentation = 0;
4795 frm.addba_extn_element.he_frag_operation =
4796 he_frag;
4797 }
4798 }
4799 }
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004800
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004801 pe_debug("Sending a ADDBA Response from %pM to %pM",
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004802 session->selfMacAddr, peer_mac);
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004803 pe_debug("tid: %d, dialog_token: %d, status: %d, buff_size: %d",
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004804 tid, frm.DialogToken.token, frm.Status.status,
4805 frm.addba_param_set.buff_size);
Kiran Kumar Lokere40875852018-01-15 12:36:19 -08004806 pe_debug("addba_extn %d he_capable %d no_frag %d he_frag %d",
4807 addba_extn_present,
4808 lim_is_session_he_capable(session),
4809 frm.addba_extn_element.no_fragmentation,
4810 frm.addba_extn_element.he_frag_operation);
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004811
4812 status = dot11f_get_packed_addba_rsp_size(mac_ctx, &frm, &payload_size);
4813 if (DOT11F_FAILED(status)) {
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004814 pe_err("Failed to calculate the packed size for a ADDBA Response (0x%08x).",
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004815 status);
4816 /* We'll fall back on the worst case scenario: */
4817 payload_size = sizeof(tDot11faddba_rsp);
4818 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004819 pe_warn("There were warnings while calculating the packed size for a ADDBA Response (0x%08x).", status);
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004820 }
4821
4822 num_bytes = payload_size + sizeof(*mgmt_hdr);
4823 qdf_status = cds_packet_alloc(num_bytes, (void **)&frame_ptr,
4824 (void **)&pkt_ptr);
4825 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004826 pe_err("Failed to allocate %d bytes for a ADDBA response action frame",
4827 num_bytes);
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004828 return QDF_STATUS_E_FAILURE;
4829 }
4830 qdf_mem_set(frame_ptr, num_bytes, 0);
4831
4832 lim_populate_mac_header(mac_ctx, frame_ptr, SIR_MAC_MGMT_FRAME,
4833 SIR_MAC_MGMT_ACTION, peer_mac, session->selfMacAddr);
4834
4835 /* Update A3 with the BSSID */
4836 mgmt_hdr = (tpSirMacMgmtHdr) frame_ptr;
4837 sir_copy_mac_addr(mgmt_hdr->bssId, session->bssId);
4838
4839 /* ADDBA Response is a robust mgmt action frame,
4840 * set the "protect" (aka WEP) bit in the FC
4841 */
4842 lim_set_protected_bit(mac_ctx, session, peer_mac, mgmt_hdr);
4843
4844 status = dot11f_pack_addba_rsp(mac_ctx, &frm,
4845 frame_ptr + sizeof(tSirMacMgmtHdr), payload_size,
4846 &payload_size);
4847
4848 if (DOT11F_FAILED(status)) {
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004849 pe_err("Failed to pack a ADDBA Response (0x%08x)",
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004850 status);
4851 qdf_status = QDF_STATUS_E_FAILURE;
4852 goto error_addba_rsp;
4853 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004854 pe_warn("There were warnings while packing ADDBA Response (0x%08x)",
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004855 status);
4856 }
4857
4858
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08004859 if ((BAND_5G == lim_get_rf_band(session->currentOperChannel))
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004860#ifdef WLAN_FEATURE_P2P
4861 || (session->pePersona == QDF_P2P_CLIENT_MODE) ||
4862 (session->pePersona == QDF_P2P_GO_MODE)
4863#endif
4864 ) {
4865 tx_flag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
4866 }
4867
4868 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
4869 session->peSessionId, mgmt_hdr->fc.subType));
4870 qdf_status = wma_tx_frame(mac_ctx, pkt_ptr, (uint16_t) num_bytes,
4871 TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS, 7,
Naveen Rawat296a5182017-09-25 14:02:48 -07004872 lim_tx_complete, frame_ptr, tx_flag, sme_sessionid, 0,
4873 RATEID_DEFAULT);
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004874 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
4875 session->peSessionId, qdf_status));
4876 if (QDF_STATUS_SUCCESS != qdf_status) {
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004877 pe_err("wma_tx_frame FAILED! Status [%d]",
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004878 qdf_status);
4879 qdf_status = QDF_STATUS_E_FAILURE;
4880 /*
4881 * wma_tx_frame free memory in certain cases, free pkt_ptr
4882 * only if not freed already.
4883 */
4884 if (pkt_ptr)
4885 cds_packet_free((void *)pkt_ptr);
4886 return qdf_status;
4887 } else {
Tushnim Bhattacharyyad58e4c92018-03-27 13:40:12 -07004888 return QDF_STATUS_SUCCESS;
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004889 }
4890
4891error_addba_rsp:
4892 cds_packet_free((void *)pkt_ptr);
4893 return qdf_status;
4894}
Padma, Santhosh Kumar22c462c2018-01-16 17:56:44 +05304895
4896/**
4897 * lim_tx_mgmt_frame() - Transmits Auth mgmt frame
4898 * @mac_ctx Pointer to Global MAC structure
4899 * @mb_msg: Received message info
4900 * @msg_len: Received message length
4901 * @packet: Packet to be transmitted
4902 * @frame: Received frame
4903 *
4904 * Return: None
4905 */
4906static void lim_tx_mgmt_frame(tpAniSirGlobal mac_ctx,
4907 struct sir_mgmt_msg *mb_msg, uint32_t msg_len,
4908 void *packet, uint8_t *frame)
4909{
4910 tpSirMacFrameCtl fc = (tpSirMacFrameCtl) mb_msg->data;
4911 QDF_STATUS qdf_status;
4912 uint8_t sme_session_id = 0;
4913 tpPESession session;
4914 uint16_t auth_ack_status;
4915 enum rateid min_rid = RATEID_DEFAULT;
4916
4917 sme_session_id = mb_msg->session_id;
4918 session = pe_find_session_by_sme_session_id(mac_ctx, sme_session_id);
4919 if (session == NULL) {
4920 pe_err("session not found for given sme session");
4921 return;
4922 }
4923
4924 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
4925 session->peSessionId, fc->subType));
4926
4927 mac_ctx->auth_ack_status = LIM_AUTH_ACK_NOT_RCD;
4928 min_rid = lim_get_min_session_txrate(session);
4929
4930 qdf_status = wma_tx_frameWithTxComplete(mac_ctx, packet,
4931 (uint16_t)msg_len,
4932 TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS,
4933 7, lim_tx_complete, frame,
4934 lim_auth_tx_complete_cnf,
4935 0, sme_session_id, false, 0, min_rid);
4936 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
4937 session->peSessionId, qdf_status));
4938 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Rachit Kankane0baf6e72018-01-19 15:01:50 +05304939 pe_err("*** Could not send Auth frame (subType: %d), retCode=%X ***",
4940 fc->subType, qdf_status);
Padma, Santhosh Kumar22c462c2018-01-16 17:56:44 +05304941 mac_ctx->auth_ack_status = LIM_AUTH_ACK_RCD_FAILURE;
4942 auth_ack_status = SENT_FAIL;
4943 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_AUTH_ACK_EVENT,
4944 session, auth_ack_status, eSIR_FAILURE);
4945 /* Pkt will be freed up by the callback */
4946 }
4947}
4948
4949void lim_send_mgmt_frame_tx(tpAniSirGlobal mac_ctx,
4950 struct scheduler_msg *msg)
4951{
4952 struct sir_mgmt_msg *mb_msg = (struct sir_mgmt_msg *)msg->bodyptr;
4953 uint32_t msg_len;
4954 tpSirMacFrameCtl fc = (tpSirMacFrameCtl) mb_msg->data;
4955 uint8_t sme_session_id;
4956 QDF_STATUS qdf_status;
4957 uint8_t *frame;
4958 void *packet;
4959
4960 msg_len = mb_msg->msg_len - sizeof(*mb_msg);
4961 pe_debug("sending fc->type: %d fc->subType: %d",
4962 fc->type, fc->subType);
4963
4964 sme_session_id = mb_msg->session_id;
4965
4966 qdf_status = cds_packet_alloc((uint16_t) msg_len, (void **)&frame,
4967 (void **)&packet);
4968 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
4969 pe_err("call to bufAlloc failed for AUTH frame");
4970 return;
4971 }
4972
4973 qdf_mem_copy(frame, mb_msg->data, msg_len);
4974
4975 lim_tx_mgmt_frame(mac_ctx, mb_msg, msg_len, packet, frame);
4976}