blob: e576245f56337212c2e02456835351f8566ae5d1 [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 *
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700197 * Return: QDF_STATUS (QDF_STATUS_SUCCESS on success and error codes otherwise)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800198 */
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700199QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800200lim_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;
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700223 QDF_STATUS 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);
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700357 if (QDF_STATUS_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 */
Wu Gao93816212018-08-31 16:49:54 +0800378 if (mac_ctx->mlme_cfg->sta.qcn_ie_support && !qcn_ie)
Abhishek Singh67e02bd2017-12-11 10:47:12 +0530379 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);
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700408 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800409 }
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);
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700424 return QDF_STATUS_E_FAILURE; /* allocated! */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800425 } 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 */
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700458 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800459 }
460
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700461 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800462} /* End lim_send_probe_req_mgmt_frame. */
463
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700464static QDF_STATUS 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");
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700479 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800480 }
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");
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700485 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800486 }
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);
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700496 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800497 }
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 }
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700513 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800514}
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;
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700541 QDF_STATUS 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 {
Bala Venkatesh2fde2c62018-09-11 20:33:24 +0530603 cfg = mac_ctx->mlme_cfg->sap_cfg.beacon_interval;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800604 frm->BeaconInterval.interval = (uint16_t) cfg;
605 }
606
607 populate_dot11f_capabilities(mac_ctx, &frm->Capabilities, pe_session);
608 populate_dot11f_ssid(mac_ctx, (tSirMacSSid *) ssid, &frm->SSID);
609 populate_dot11f_supp_rates(mac_ctx, POPULATE_DOT11F_RATES_OPERATIONAL,
610 &frm->SuppRates, pe_session);
611
612 populate_dot11f_ds_params(mac_ctx, &frm->DSParams,
613 pe_session->currentOperChannel);
614 populate_dot11f_ibss_params(mac_ctx, &frm->IBSSParams, pe_session);
615
616 if (LIM_IS_AP_ROLE(pe_session)) {
617 if (pe_session->wps_state != SAP_WPS_DISABLED)
618 populate_dot11f_probe_res_wpsi_es(mac_ctx,
619 &frm->WscProbeRes,
620 pe_session);
621 } else {
622 if (wlan_cfg_get_int(mac_ctx, (uint16_t) WNI_CFG_WPS_ENABLE,
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700623 &tmp) != QDF_STATUS_SUCCESS)
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700624 pe_err("Failed to cfg get id %d", WNI_CFG_WPS_ENABLE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800625
626 wps_ap = tmp & WNI_CFG_WPS_ENABLE_AP;
627
628 if (wps_ap)
629 populate_dot11f_wsc_in_probe_res(mac_ctx,
630 &frm->WscProbeRes);
631
632 if (mac_ctx->lim.wscIeInfo.probeRespWscEnrollmentState ==
633 eLIM_WSC_ENROLL_BEGIN) {
634 populate_dot11f_wsc_registrar_info_in_probe_res(mac_ctx,
635 &frm->WscProbeRes);
636 mac_ctx->lim.wscIeInfo.probeRespWscEnrollmentState =
637 eLIM_WSC_ENROLL_IN_PROGRESS;
638 }
639
640 if (mac_ctx->lim.wscIeInfo.wscEnrollmentState ==
641 eLIM_WSC_ENROLL_END) {
642 de_populate_dot11f_wsc_registrar_info_in_probe_res(
643 mac_ctx, &frm->WscProbeRes);
644 mac_ctx->lim.wscIeInfo.probeRespWscEnrollmentState =
645 eLIM_WSC_ENROLL_NOOP;
646 }
647 }
648
649 populate_dot11f_country(mac_ctx, &frm->Country, pe_session);
650 populate_dot11f_edca_param_set(mac_ctx, &frm->EDCAParamSet, pe_session);
651
652 if (pe_session->dot11mode != WNI_CFG_DOT11_MODE_11B)
653 populate_dot11f_erp_info(mac_ctx, &frm->ERPInfo, pe_session);
654
655 populate_dot11f_ext_supp_rates(mac_ctx,
656 POPULATE_DOT11F_RATES_OPERATIONAL,
657 &frm->ExtSuppRates, pe_session);
658
659 /* Populate HT IEs, when operating in 11n */
660 if (pe_session->htCapability) {
661 populate_dot11f_ht_caps(mac_ctx, pe_session, &frm->HTCaps);
662 populate_dot11f_ht_info(mac_ctx, &frm->HTInfo, pe_session);
663 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800664 if (pe_session->vhtCapability) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700665 pe_debug("Populate VHT IE in Probe Response");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800666 populate_dot11f_vht_caps(mac_ctx, pe_session, &frm->VHTCaps);
667 populate_dot11f_vht_operation(mac_ctx, pe_session,
668 &frm->VHTOperation);
669 /*
670 * we do not support multi users yet.
671 * populate_dot11f_vht_ext_bss_load( mac_ctx,
672 * &frm.VHTExtBssLoad );
673 */
674 is_vht_enabled = true;
675 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800676
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -0800677 if (lim_is_session_he_capable(pe_session)) {
Srinivas Girigowda28fb0122017-03-26 22:21:20 -0700678 pe_debug("Populate HE IEs");
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -0800679 populate_dot11f_he_caps(mac_ctx, pe_session,
Naveen Rawatd8feac12017-09-08 15:08:39 -0700680 &frm->he_cap);
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -0800681 populate_dot11f_he_operation(mac_ctx, pe_session,
Naveen Rawatd8feac12017-09-08 15:08:39 -0700682 &frm->he_op);
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -0800683 }
684
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800685 populate_dot11f_ext_cap(mac_ctx, is_vht_enabled, &frm->ExtCap,
686 pe_session);
687
688 if (pe_session->pLimStartBssReq) {
689 populate_dot11f_wpa(mac_ctx,
690 &(pe_session->pLimStartBssReq->rsnIE),
691 &frm->WPA);
692 populate_dot11f_rsn_opaque(mac_ctx,
693 &(pe_session->pLimStartBssReq->rsnIE),
694 &frm->RSNOpaque);
695 }
696
697 populate_dot11f_wmm(mac_ctx, &frm->WMMInfoAp, &frm->WMMParams,
698 &frm->WMMCaps, pe_session);
699
700#if defined(FEATURE_WLAN_WAPI)
701 if (pe_session->pLimStartBssReq)
702 populate_dot11f_wapi(mac_ctx,
703 &(pe_session->pLimStartBssReq->rsnIE),
704 &frm->WAPI);
705#endif /* defined(FEATURE_WLAN_WAPI) */
706
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800707 if (mac_ctx->lim.gpLimRemainOnChanReq)
708 bytes += (mac_ctx->lim.gpLimRemainOnChanReq->length -
709 sizeof(tSirRemainOnChnReq));
710 else
711 /*
712 * Only use CFG for non-listen mode. This CFG is not working for
713 * concurrency. In listening mode, probe rsp IEs is passed in
714 * the message from SME to PE.
715 */
716 addn_ie_present =
717 (pe_session->addIeParams.probeRespDataLen != 0);
718
719 if (addn_ie_present) {
720
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530721 add_ie = qdf_mem_malloc(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800722 pe_session->addIeParams.probeRespDataLen);
723 if (NULL == add_ie) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700724 pe_err("add_ie allocation failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800725 goto err_ret;
726 }
727
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530728 qdf_mem_copy(add_ie,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800729 pe_session->addIeParams.probeRespData_buff,
730 pe_session->addIeParams.probeRespDataLen);
731 addn_ie_len = pe_session->addIeParams.probeRespDataLen;
732
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700733 if (QDF_STATUS_SUCCESS != lim_get_addn_ie_for_probe_resp(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800734 add_ie, &addn_ie_len, preq_p2pie)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700735 pe_err("Unable to get addn_ie");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800736 goto err_ret;
737 }
738
739 sir_status = lim_strip_extcap_update_struct(mac_ctx,
740 add_ie, &addn_ie_len,
741 &extracted_ext_cap);
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700742 if (QDF_STATUS_SUCCESS != sir_status) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700743 pe_debug("Unable to strip off ExtCap IE");
Selvaraj, Sridhar94ece202016-06-23 20:44:09 +0530744 } else {
745 extracted_ext_cap_flag = true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800746 }
747
748 bytes = bytes + addn_ie_len;
749
750 if (preq_p2pie)
751 p2p_ie = limGetP2pIEPtr(mac_ctx, &add_ie[0],
752 addn_ie_len);
753
754 if (p2p_ie != NULL) {
755 /* get NoA attribute stream P2P IE */
756 noalen = lim_get_noa_attr_stream(mac_ctx,
757 noa_stream, pe_session);
758 if (noalen != 0) {
759 total_noalen =
760 lim_build_p2p_ie(mac_ctx, &noa_ie[0],
761 &noa_stream[0], noalen);
762 bytes = bytes + total_noalen;
763 }
764 }
765 }
766
Hu Wang411e0cc2016-10-28 14:56:01 +0800767 /*
768 * Extcap IE now support variable length, merge Extcap IE from addn_ie
769 * may change the frame size. Therefore, MUST merge ExtCap IE before
770 * dot11f get packed payload size.
771 */
772 if (extracted_ext_cap_flag)
Hu Wangfbd279d2016-10-31 18:24:34 +0800773 lim_merge_extcap_struct(&frm->ExtCap, &extracted_ext_cap,
774 true);
Hu Wang411e0cc2016-10-28 14:56:01 +0800775
776 status = dot11f_get_packed_probe_response_size(mac_ctx, frm, &payload);
777 if (DOT11F_FAILED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700778 pe_err("Probe Response size error (0x%08x)",
Hu Wang411e0cc2016-10-28 14:56:01 +0800779 status);
780 /* We'll fall back on the worst case scenario: */
781 payload = sizeof(tDot11fProbeResponse);
782 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700783 pe_warn("Probe Response size warning (0x%08x)",
Hu Wang411e0cc2016-10-28 14:56:01 +0800784 status);
785 }
786
787 bytes += payload + sizeof(tSirMacMgmtHdr);
788
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530789 qdf_status = cds_packet_alloc((uint16_t) bytes, (void **)&frame,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800790 (void **)&packet);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530791 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700792 pe_err("Probe Response allocation failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800793 goto err_ret;
794 }
795 /* Paranoia: */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530796 qdf_mem_set(frame, bytes, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800797
798 /* Next, we fill out the buffer descriptor: */
799 lim_populate_mac_header(mac_ctx, frame, SIR_MAC_MGMT_FRAME,
800 SIR_MAC_MGMT_PROBE_RSP, peer_macaddr,
801 pe_session->selfMacAddr);
802
803 mac_hdr = (tpSirMacMgmtHdr) frame;
804
805 sir_copy_mac_addr(mac_hdr->bssId, pe_session->bssId);
806
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800807 /* That done, pack the Probe Response: */
808 status =
809 dot11f_pack_probe_response(mac_ctx, frm,
810 frame + sizeof(tSirMacMgmtHdr),
811 payload, &payload);
812 if (DOT11F_FAILED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700813 pe_err("Probe Response pack failure (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800814 status);
815 goto err_ret;
816 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700817 pe_warn("Probe Response pack warning (0x%08x)", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800818 }
819
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700820 pe_debug("Sending Probe Response frame to");
Nishank Aggarwal46bd31a2017-03-10 16:23:53 +0530821 lim_print_mac_addr(mac_ctx, peer_macaddr, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800822
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800823 if (mac_ctx->lim.gpLimRemainOnChanReq)
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530824 qdf_mem_copy(frame + sizeof(tSirMacMgmtHdr) + payload,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800825 mac_ctx->lim.gpLimRemainOnChanReq->probeRspIe,
826 (mac_ctx->lim.gpLimRemainOnChanReq->length -
827 sizeof(tSirRemainOnChnReq)));
828
829 if (addn_ie_present)
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530830 qdf_mem_copy(frame + sizeof(tSirMacMgmtHdr) + payload,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800831 &add_ie[0], addn_ie_len);
832
833 if (noalen != 0) {
834 if (total_noalen >
835 (SIR_MAX_NOA_ATTR_LEN + SIR_P2P_IE_HEADER_LEN)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700836 pe_err("Not able to insert NoA, total len=%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800837 total_noalen);
838 goto err_ret;
839 } else {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530840 qdf_mem_copy(&frame[bytes - (total_noalen)],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800841 &noa_ie[0], total_noalen);
842 }
843 }
844
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -0800845 if ((BAND_5G == lim_get_rf_band(pe_session->currentOperChannel))
Anurag Chouhan6d760662016-02-20 16:05:43 +0530846 || (pe_session->pePersona == QDF_P2P_CLIENT_MODE) ||
847 (pe_session->pePersona == QDF_P2P_GO_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800848 )
849 tx_flag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
850
851 /* Queue Probe Response frame in high priority WQ */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530852 qdf_status = wma_tx_frame((tHalHandle) mac_ctx, packet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800853 (uint16_t) bytes,
854 TXRX_FRM_802_11_MGMT,
855 ANI_TXDIR_TODS,
856 7, lim_tx_complete, frame, tx_flag,
Naveen Rawat296a5182017-09-25 14:02:48 -0700857 sme_sessionid, 0, RATEID_DEFAULT);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800858
859 /* Pkt will be freed up by the callback */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530860 if (!QDF_IS_STATUS_SUCCESS(qdf_status))
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700861 pe_err("Could not send Probe Response");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800862
863 if (add_ie != NULL)
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530864 qdf_mem_free(add_ie);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800865
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530866 qdf_mem_free(frm);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800867 return;
868
869err_ret:
870 if (add_ie != NULL)
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530871 qdf_mem_free(add_ie);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800872 if (frm != NULL)
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530873 qdf_mem_free(frm);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800874 if (packet != NULL)
875 cds_packet_free((void *)packet);
876 return;
877
878} /* End lim_send_probe_rsp_mgmt_frame. */
879
880void
881lim_send_addts_req_action_frame(tpAniSirGlobal pMac,
882 tSirMacAddr peerMacAddr,
883 tSirAddtsReqInfo *pAddTS, tpPESession psessionEntry)
884{
885 uint16_t i;
886 uint8_t *pFrame;
887 tDot11fAddTSRequest AddTSReq;
888 tDot11fWMMAddTSRequest WMMAddTSReq;
889 uint32_t nPayload, nBytes, nStatus;
890 tpSirMacMgmtHdr pMacHdr;
891 void *pPacket;
892#ifdef FEATURE_WLAN_ESE
893 uint32_t phyMode;
894#endif
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530895 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800896 uint8_t txFlag = 0;
897 uint8_t smeSessionId = 0;
898
899 if (NULL == psessionEntry) {
900 return;
901 }
902
903 smeSessionId = psessionEntry->smeSessionId;
904
905 if (!pAddTS->wmeTspecPresent) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530906 qdf_mem_set((uint8_t *) &AddTSReq, sizeof(AddTSReq), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800907
908 AddTSReq.Action.action = SIR_MAC_QOS_ADD_TS_REQ;
909 AddTSReq.DialogToken.token = pAddTS->dialogToken;
910 AddTSReq.Category.category = SIR_MAC_ACTION_QOS_MGMT;
911 if (pAddTS->lleTspecPresent) {
912 populate_dot11f_tspec(&pAddTS->tspec, &AddTSReq.TSPEC);
913 } else {
914 populate_dot11f_wmmtspec(&pAddTS->tspec,
915 &AddTSReq.WMMTSPEC);
916 }
917
918 if (pAddTS->lleTspecPresent) {
919 AddTSReq.num_WMMTCLAS = 0;
920 AddTSReq.num_TCLAS = pAddTS->numTclas;
921 for (i = 0; i < pAddTS->numTclas; ++i) {
922 populate_dot11f_tclas(pMac, &pAddTS->tclasInfo[i],
923 &AddTSReq.TCLAS[i]);
924 }
925 } else {
926 AddTSReq.num_TCLAS = 0;
927 AddTSReq.num_WMMTCLAS = pAddTS->numTclas;
928 for (i = 0; i < pAddTS->numTclas; ++i) {
929 populate_dot11f_wmmtclas(pMac,
930 &pAddTS->tclasInfo[i],
931 &AddTSReq.WMMTCLAS[i]);
932 }
933 }
934
935 if (pAddTS->tclasProcPresent) {
936 if (pAddTS->lleTspecPresent) {
937 AddTSReq.TCLASSPROC.processing =
938 pAddTS->tclasProc;
939 AddTSReq.TCLASSPROC.present = 1;
940 } else {
941 AddTSReq.WMMTCLASPROC.version = 1;
942 AddTSReq.WMMTCLASPROC.processing =
943 pAddTS->tclasProc;
944 AddTSReq.WMMTCLASPROC.present = 1;
945 }
946 }
947
948 nStatus =
949 dot11f_get_packed_add_ts_request_size(pMac, &AddTSReq, &nPayload);
950 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700951 pe_err("Failed to calculate the packed size for an Add TS Request (0x%08x)",
952 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800953 /* We'll fall back on the worst case scenario: */
954 nPayload = sizeof(tDot11fAddTSRequest);
955 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700956 pe_warn("There were warnings while calculating the packed size for an Add TS Request (0x%08x)",
957 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800958 }
959 } else {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530960 qdf_mem_set((uint8_t *) &WMMAddTSReq, sizeof(WMMAddTSReq), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800961
962 WMMAddTSReq.Action.action = SIR_MAC_QOS_ADD_TS_REQ;
963 WMMAddTSReq.DialogToken.token = pAddTS->dialogToken;
964 WMMAddTSReq.Category.category = SIR_MAC_ACTION_WME;
965
966 /* WMM spec 2.2.10 - status code is only filled in for ADDTS response */
967 WMMAddTSReq.StatusCode.statusCode = 0;
968
969 populate_dot11f_wmmtspec(&pAddTS->tspec, &WMMAddTSReq.WMMTSPEC);
970#ifdef FEATURE_WLAN_ESE
971 lim_get_phy_mode(pMac, &phyMode, psessionEntry);
972
973 if (phyMode == WNI_CFG_PHY_MODE_11G
974 || phyMode == WNI_CFG_PHY_MODE_11A) {
975 pAddTS->tsrsIE.rates[0] = TSRS_11AG_RATE_6MBPS;
976 } else {
977 pAddTS->tsrsIE.rates[0] = TSRS_11B_RATE_5_5MBPS;
978 }
979 populate_dot11_tsrsie(pMac, &pAddTS->tsrsIE,
980 &WMMAddTSReq.ESETrafStrmRateSet,
981 sizeof(uint8_t));
982#endif
983 /* fillWmeTspecIE */
984
985 nStatus =
986 dot11f_get_packed_wmm_add_ts_request_size(pMac, &WMMAddTSReq,
987 &nPayload);
988 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700989 pe_err("Failed to calculate the packed size for a WMM Add TS Request (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800990 nStatus);
991 /* We'll fall back on the worst case scenario: */
992 nPayload = sizeof(tDot11fAddTSRequest);
993 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700994 pe_warn("There were warnings while calculating the packed size for a WMM Add TS Request (0x%08x)",
995 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800996 }
997 }
998
999 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
1000
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301001 qdf_status = cds_packet_alloc((uint16_t) nBytes, (void **)&pFrame,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001002 (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301003 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001004 pe_err("Failed to allocate %d bytes for an Add TS Request",
1005 nBytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001006 return;
1007 }
1008 /* Paranoia: */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301009 qdf_mem_set(pFrame, nBytes, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001010
1011 /* Next, we fill out the buffer descriptor: */
1012 lim_populate_mac_header(pMac, pFrame, SIR_MAC_MGMT_FRAME,
1013 SIR_MAC_MGMT_ACTION, peerMacAddr, psessionEntry->selfMacAddr);
1014 pMacHdr = (tpSirMacMgmtHdr) pFrame;
1015
1016 sir_copy_mac_addr(pMacHdr->bssId, psessionEntry->bssId);
1017
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001018 lim_set_protected_bit(pMac, psessionEntry, peerMacAddr, pMacHdr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001019
1020 /* That done, pack the struct: */
1021 if (!pAddTS->wmeTspecPresent) {
1022 nStatus = dot11f_pack_add_ts_request(pMac, &AddTSReq,
1023 pFrame +
1024 sizeof(tSirMacMgmtHdr),
1025 nPayload, &nPayload);
1026 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001027 pe_err("Failed to pack an Add TS Request "
1028 "(0x%08x)", nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001029 cds_packet_free((void *)pPacket);
1030 return; /* allocated! */
1031 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001032 pe_warn("There were warnings while packing an Add TS Request (0x%08x)",
1033 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001034 }
1035 } else {
1036 nStatus = dot11f_pack_wmm_add_ts_request(pMac, &WMMAddTSReq,
1037 pFrame +
1038 sizeof(tSirMacMgmtHdr),
1039 nPayload, &nPayload);
1040 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001041 pe_err("Failed to pack a WMM Add TS Request (0x%08x)",
1042 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001043 cds_packet_free((void *)pPacket);
1044 return; /* allocated! */
1045 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001046 pe_warn("There were warnings while packing a WMM Add TS Request (0x%08x)",
1047 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001048 }
1049 }
1050
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001051 pe_debug("Sending an Add TS Request frame to");
1052 lim_print_mac_addr(pMac, peerMacAddr, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001053
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08001054 if ((BAND_5G ==
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001055 lim_get_rf_band(psessionEntry->currentOperChannel))
Anurag Chouhan6d760662016-02-20 16:05:43 +05301056 || (psessionEntry->pePersona == QDF_P2P_CLIENT_MODE)
1057 || (psessionEntry->pePersona == QDF_P2P_GO_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001058 ) {
1059 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
1060 }
1061
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05301062 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001063 psessionEntry->peSessionId, pMacHdr->fc.subType));
Krunal Sonic65fc492018-03-09 15:53:28 -08001064 lim_diag_mgmt_tx_event_report(pMac, pMacHdr,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001065 psessionEntry, QDF_STATUS_SUCCESS,
1066 QDF_STATUS_SUCCESS);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001067
1068 /* Queue Addts Response frame in high priority WQ */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301069 qdf_status = wma_tx_frame(pMac, pPacket, (uint16_t) nBytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001070 TXRX_FRM_802_11_MGMT,
1071 ANI_TXDIR_TODS,
1072 7, lim_tx_complete, pFrame, txFlag,
Naveen Rawat296a5182017-09-25 14:02:48 -07001073 smeSessionId, 0, RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05301074 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301075 psessionEntry->peSessionId, qdf_status));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001076
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001077 if (!QDF_IS_STATUS_SUCCESS(qdf_status))
1078 pe_err("Could not send an Add TS Request (%X",
1079 qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001080} /* End lim_send_addts_req_action_frame. */
1081
1082/**
1083 * lim_send_assoc_rsp_mgmt_frame() - Send assoc response
1084 * @mac_ctx: Handle for mac context
1085 * @status_code: Status code for assoc response frame
1086 * @aid: Association ID
1087 * @peer_addr: Mac address of requesting peer
1088 * @subtype: Assoc/Reassoc
1089 * @sta: Pointer to station node
1090 * @pe_session: PE session id.
1091 *
1092 * Builds and sends association response frame to the requesting peer.
1093 *
1094 * Return: void
1095 */
1096
1097void
1098lim_send_assoc_rsp_mgmt_frame(tpAniSirGlobal mac_ctx,
1099 uint16_t status_code, uint16_t aid, tSirMacAddr peer_addr,
1100 uint8_t subtype, tpDphHashNode sta, tpPESession pe_session)
1101{
1102 static tDot11fAssocResponse frm;
1103 uint8_t *frame;
1104 tpSirMacMgmtHdr mac_hdr;
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001105 QDF_STATUS sir_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001106 uint8_t lle_mode = 0, addts;
1107 tHalBitVal qos_mode, wme_mode;
Hu Wang411e0cc2016-10-28 14:56:01 +08001108 uint32_t payload, bytes = 0, status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001109 void *packet;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301110 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001111 tUpdateBeaconParams beacon_params;
1112 uint8_t tx_flag = 0;
1113 uint32_t addn_ie_len = 0;
1114 uint8_t add_ie[WNI_CFG_ASSOC_RSP_ADDNIE_DATA_LEN];
1115 tpSirAssocReq assoc_req = NULL;
1116 uint8_t sme_session = 0;
1117 bool is_vht = false;
1118 uint16_t stripoff_len = 0;
1119 tDot11fIEExtCap extracted_ext_cap;
1120 bool extracted_flag = false;
1121#ifdef WLAN_FEATURE_11W
1122 uint32_t retry_int;
1123 uint32_t max_retries;
1124#endif
1125
1126 if (NULL == pe_session) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001127 pe_err("pe_session is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001128 return;
1129 }
1130
1131 sme_session = pe_session->smeSessionId;
1132
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301133 qdf_mem_set((uint8_t *) &frm, sizeof(frm), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001134
1135 limGetQosMode(pe_session, &qos_mode);
1136 limGetWmeMode(pe_session, &wme_mode);
1137
1138 /*
1139 * An Add TS IE is added only if the AP supports it and
1140 * the requesting STA sent a traffic spec.
1141 */
1142 addts = (qos_mode && sta && sta->qos.addtsPresent) ? 1 : 0;
1143
1144 frm.Status.status = status_code;
1145
1146 frm.AID.associd = aid | LIM_AID_MASK;
1147
1148 if (NULL == sta) {
1149 populate_dot11f_supp_rates(mac_ctx,
1150 POPULATE_DOT11F_RATES_OPERATIONAL,
1151 &frm.SuppRates, pe_session);
1152 populate_dot11f_ext_supp_rates(mac_ctx,
1153 POPULATE_DOT11F_RATES_OPERATIONAL,
1154 &frm.ExtSuppRates, pe_session);
1155 } else {
1156 populate_dot11f_assoc_rsp_rates(mac_ctx, &frm.SuppRates,
1157 &frm.ExtSuppRates,
1158 sta->supportedRates.llbRates,
1159 sta->supportedRates.llaRates);
1160 }
1161
1162 if (LIM_IS_AP_ROLE(pe_session) && sta != NULL &&
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001163 QDF_STATUS_SUCCESS == status_code) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001164 assoc_req = (tpSirAssocReq)
1165 pe_session->parsedAssocReq[sta->assocId];
1166 /*
1167 * populate P2P IE in AssocRsp when assocReq from the peer
1168 * includes P2P IE
1169 */
1170 if (assoc_req != NULL && assoc_req->addIEPresent)
1171 populate_dot11_assoc_res_p2p_ie(mac_ctx,
1172 &frm.P2PAssocRes,
1173 assoc_req);
1174 }
1175
1176 if (NULL != sta) {
1177 if (eHAL_SET == qos_mode) {
1178 if (sta->lleEnabled) {
1179 lle_mode = 1;
1180 populate_dot11f_edca_param_set(mac_ctx,
1181 &frm.EDCAParamSet, pe_session);
1182 }
1183 }
1184
1185 if ((!lle_mode) && (eHAL_SET == wme_mode) && sta->wmeEnabled) {
1186 populate_dot11f_wmm_params(mac_ctx, &frm.WMMParams,
1187 pe_session);
1188
1189 if (sta->wsmEnabled)
1190 populate_dot11f_wmm_caps(&frm.WMMCaps);
1191 }
1192
1193 if (sta->mlmStaContext.htCapability &&
1194 pe_session->htCapability) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001195 pe_debug("Populate HT IEs in Assoc Response");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001196 populate_dot11f_ht_caps(mac_ctx, pe_session,
1197 &frm.HTCaps);
Krunal Sonief3294b2015-06-12 15:12:19 -07001198 /*
1199 * Check the STA capability and
1200 * update the HTCaps accordingly
1201 */
1202 frm.HTCaps.supportedChannelWidthSet = (
1203 sta->htSupportedChannelWidthSet <
1204 pe_session->htSupportedChannelWidthSet) ?
1205 sta->htSupportedChannelWidthSet :
1206 pe_session->htSupportedChannelWidthSet;
1207 if (!frm.HTCaps.supportedChannelWidthSet)
1208 frm.HTCaps.shortGI40MHz = 0;
1209
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001210 populate_dot11f_ht_info(mac_ctx, &frm.HTInfo,
1211 pe_session);
1212 }
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001213 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 +05301214 frm.HTCaps.supportedChannelWidthSet,
1215 frm.HTCaps.mimoPowerSave,
1216 frm.HTCaps.greenField, frm.HTCaps.shortGI20MHz,
1217 frm.HTCaps.shortGI40MHz,
1218 frm.HTCaps.dsssCckMode40MHz,
1219 frm.HTCaps.maxRxAMPDUFactor);
1220
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001221 if (sta->mlmStaContext.vhtCapability &&
1222 pe_session->vhtCapability) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001223 pe_debug("Populate VHT IEs in Assoc Response");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001224 populate_dot11f_vht_caps(mac_ctx, pe_session,
1225 &frm.VHTCaps);
1226 populate_dot11f_vht_operation(mac_ctx, pe_session,
Kapil Gupta4b2efbb2016-10-03 13:07:20 +05301227 &frm.VHTOperation);
1228 is_vht = true;
1229 }
Naveen Rawat903acca2017-09-15 17:32:13 -07001230
Kapil Gupta4b2efbb2016-10-03 13:07:20 +05301231 if (pe_session->vhtCapability &&
1232 pe_session->vendor_vht_sap &&
1233 (assoc_req != NULL) &&
1234 assoc_req->vendor_vht_ie.VHTCaps.present) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001235 pe_debug("Populate Vendor VHT IEs in Assoc Rsponse");
Kapil Gupta4b2efbb2016-10-03 13:07:20 +05301236 frm.vendor_vht_ie.present = 1;
Kiran Kumar Lokere81722632017-09-26 12:11:43 -07001237 frm.vendor_vht_ie.sub_type =
1238 pe_session->vendor_specific_vht_ie_sub_type;
Kapil Gupta4b2efbb2016-10-03 13:07:20 +05301239 frm.vendor_vht_ie.VHTCaps.present = 1;
1240 populate_dot11f_vht_caps(mac_ctx, pe_session,
1241 &frm.vendor_vht_ie.VHTCaps);
Kiran Kumar Lokerecc448682017-07-20 18:08:01 -07001242 populate_dot11f_vht_operation(mac_ctx, pe_session,
1243 &frm.vendor_vht_ie.VHTOperation);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001244 is_vht = true;
1245 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001246 populate_dot11f_ext_cap(mac_ctx, is_vht, &frm.ExtCap,
1247 pe_session);
1248
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08001249 if (lim_is_sta_he_capable(sta) &&
1250 lim_is_session_he_capable(pe_session)) {
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07001251 pe_debug("Populate HE IEs");
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08001252 populate_dot11f_he_caps(mac_ctx, pe_session,
Naveen Rawatd8feac12017-09-08 15:08:39 -07001253 &frm.he_cap);
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08001254 populate_dot11f_he_operation(mac_ctx, pe_session,
Naveen Rawatd8feac12017-09-08 15:08:39 -07001255 &frm.he_op);
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08001256 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001257#ifdef WLAN_FEATURE_11W
1258 if (eSIR_MAC_TRY_AGAIN_LATER == status_code) {
1259 if (wlan_cfg_get_int
1260 (mac_ctx, WNI_CFG_PMF_SA_QUERY_MAX_RETRIES,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001261 &max_retries) != QDF_STATUS_SUCCESS)
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001262 pe_err("get WNI_CFG_PMF_SA_QUERY_MAX_RETRIES failure");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001263 else if (wlan_cfg_get_int
1264 (mac_ctx,
1265 WNI_CFG_PMF_SA_QUERY_RETRY_INTERVAL,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001266 &retry_int) != QDF_STATUS_SUCCESS)
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001267 pe_err("get WNI_CFG_PMF_SA_QUERY_RETRY_INTERVAL failure");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001268 else
1269 populate_dot11f_timeout_interval(mac_ctx,
1270 &frm.TimeoutInterval,
1271 SIR_MAC_TI_TYPE_ASSOC_COMEBACK,
1272 (max_retries -
1273 sta->pmfSaQueryRetryCount)
1274 * retry_int);
1275 }
1276#endif
Arif Hussain0c816922017-04-06 15:04:44 -07001277
1278 if (LIM_IS_AP_ROLE(pe_session) && sta->non_ecsa_capable)
1279 pe_session->lim_non_ecsa_cap_num++;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001280 }
1281
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301282 qdf_mem_set((uint8_t *) &beacon_params, sizeof(beacon_params), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001283
1284 if (LIM_IS_AP_ROLE(pe_session) &&
1285 (pe_session->gLimProtectionControl !=
1286 WNI_CFG_FORCE_POLICY_PROTECTION_DISABLE))
1287 lim_decide_ap_protection(mac_ctx, peer_addr,
1288 &beacon_params, pe_session);
1289
1290 lim_update_short_preamble(mac_ctx, peer_addr, &beacon_params,
1291 pe_session);
1292 lim_update_short_slot_time(mac_ctx, peer_addr, &beacon_params,
1293 pe_session);
1294
1295 /*
1296 * Populate Do11capabilities after updating session with
1297 * Assos req details
1298 */
1299 populate_dot11f_capabilities(mac_ctx, &frm.Capabilities, pe_session);
1300
1301 beacon_params.bssIdx = pe_session->bssIdx;
1302
1303 /* Send message to HAL about beacon parameter change. */
1304 if ((false == mac_ctx->sap.SapDfsInfo.is_dfs_cac_timer_running)
1305 && beacon_params.paramChangeBitmap) {
1306 sch_set_fixed_beacon_fields(mac_ctx, pe_session);
1307 lim_send_beacon_params(mac_ctx, &beacon_params, pe_session);
1308 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001309
Arif Hussain1513cb22018-01-05 19:56:31 -08001310 lim_obss_send_detection_cfg(mac_ctx, pe_session, false);
1311
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001312 if (assoc_req != NULL) {
Krishna Kumaar Natarajane4e3a142016-04-01 16:27:51 -07001313 addn_ie_len = pe_session->addIeParams.assocRespDataLen;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001314
1315 /* Nonzero length indicates Assoc rsp IE available */
Krishna Kumaar Natarajane4e3a142016-04-01 16:27:51 -07001316 if (addn_ie_len > 0 &&
1317 addn_ie_len <= WNI_CFG_ASSOC_RSP_ADDNIE_DATA_LEN &&
1318 (bytes + addn_ie_len) <= SIR_MAX_PACKET_SIZE) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301319 qdf_mem_copy(add_ie,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001320 pe_session->addIeParams.assocRespData_buff,
1321 pe_session->addIeParams.assocRespDataLen);
1322
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301323 qdf_mem_set((uint8_t *) &extracted_ext_cap,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001324 sizeof(extracted_ext_cap), 0);
1325
1326 stripoff_len = addn_ie_len;
1327 sir_status =
1328 lim_strip_extcap_update_struct
1329 (mac_ctx, &add_ie[0], &stripoff_len,
1330 &extracted_ext_cap);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001331 if (QDF_STATUS_SUCCESS != sir_status) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001332 pe_debug("strip off extcap IE failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001333 } else {
1334 addn_ie_len = stripoff_len;
1335 extracted_flag = true;
1336 }
1337 bytes = bytes + addn_ie_len;
1338 }
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001339 pe_debug("addn_ie_len: %d for Assoc Resp: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001340 addn_ie_len, assoc_req->addIEPresent);
1341 }
Hu Wang411e0cc2016-10-28 14:56:01 +08001342
1343 /*
1344 * Extcap IE now support variable length, merge Extcap IE from addn_ie
1345 * may change the frame size. Therefore, MUST merge ExtCap IE before
1346 * dot11f get packed payload size.
1347 */
1348 if (extracted_flag)
Hu Wangfbd279d2016-10-31 18:24:34 +08001349 lim_merge_extcap_struct(&(frm.ExtCap), &extracted_ext_cap,
1350 true);
Hu Wang411e0cc2016-10-28 14:56:01 +08001351
1352 /* Allocate a buffer for this frame: */
1353 status = dot11f_get_packed_assoc_response_size(mac_ctx, &frm, &payload);
1354 if (DOT11F_FAILED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001355 pe_err("get Association Response size failure (0x%08x)",
Hu Wang411e0cc2016-10-28 14:56:01 +08001356 status);
1357 return;
1358 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001359 pe_warn("get Association Response size warning (0x%08x)",
Hu Wang411e0cc2016-10-28 14:56:01 +08001360 status);
1361 }
1362
1363 bytes += sizeof(tSirMacMgmtHdr) + payload;
1364
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301365 qdf_status = cds_packet_alloc((uint16_t) bytes, (void **)&frame,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001366 (void **)&packet);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301367 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001368 pe_err("cds_packet_alloc failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001369 return;
1370 }
1371 /* Paranoia: */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301372 qdf_mem_set(frame, bytes, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001373
1374 /* Next, we fill out the buffer descriptor: */
1375 lim_populate_mac_header(mac_ctx, frame, SIR_MAC_MGMT_FRAME,
1376 (LIM_ASSOC == subtype) ?
1377 SIR_MAC_MGMT_ASSOC_RSP : SIR_MAC_MGMT_REASSOC_RSP,
1378 peer_addr,
1379 pe_session->selfMacAddr);
1380 mac_hdr = (tpSirMacMgmtHdr) frame;
1381
1382 sir_copy_mac_addr(mac_hdr->bssId, pe_session->bssId);
1383
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001384 status = dot11f_pack_assoc_response(mac_ctx, &frm,
1385 frame + sizeof(tSirMacMgmtHdr),
1386 payload, &payload);
1387 if (DOT11F_FAILED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001388 pe_err("Association Response pack failure(0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001389 status);
1390 cds_packet_free((void *)packet);
1391 return;
1392 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001393 pe_warn("Association Response pack warning (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001394 status);
1395 }
1396
1397 if (subtype == LIM_ASSOC)
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001398 pe_debug("*** Sending Assoc Resp status %d aid %d to",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001399 status_code, aid);
1400 else
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001401 pe_debug("*** Sending ReAssoc Resp status %d aid %d to",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001402 status_code, aid);
1403
Abhishek Singh5d8d7332017-08-10 15:15:24 +05301404 lim_print_mac_addr(mac_ctx, mac_hdr->da, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001405
1406 if (addn_ie_len && addn_ie_len <= WNI_CFG_ASSOC_RSP_ADDNIE_DATA_LEN)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301407 qdf_mem_copy(frame + sizeof(tSirMacMgmtHdr) + payload,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001408 &add_ie[0], addn_ie_len);
1409
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08001410 if ((BAND_5G ==
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001411 lim_get_rf_band(pe_session->currentOperChannel)) ||
Anurag Chouhan6d760662016-02-20 16:05:43 +05301412 (pe_session->pePersona == QDF_P2P_CLIENT_MODE) ||
1413 (pe_session->pePersona == QDF_P2P_GO_MODE))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001414 tx_flag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
1415
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05301416 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001417 pe_session->peSessionId, mac_hdr->fc.subType));
Krunal Sonic65fc492018-03-09 15:53:28 -08001418 lim_diag_mgmt_tx_event_report(mac_ctx, mac_hdr,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001419 pe_session, QDF_STATUS_SUCCESS, status_code);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001420 /* Queue Association Response frame in high priority WQ */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301421 qdf_status = wma_tx_frame(mac_ctx, packet, (uint16_t) bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001422 TXRX_FRM_802_11_MGMT,
1423 ANI_TXDIR_TODS,
1424 7, lim_tx_complete, frame, tx_flag,
Naveen Rawat296a5182017-09-25 14:02:48 -07001425 sme_session, 0, RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05301426 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301427 pe_session->peSessionId, qdf_status));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001428
1429 /* Pkt will be freed up by the callback */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301430 if (!QDF_IS_STATUS_SUCCESS(qdf_status))
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001431 pe_err("Could not Send Re/AssocRsp, retCode=%X",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301432 qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001433
1434 /*
1435 * update the ANI peer station count.
1436 * FIXME_PROTECTION : take care of different type of station
1437 * counter inside this function.
1438 */
1439 lim_util_count_sta_add(mac_ctx, sta, pe_session);
1440
1441}
1442
1443void
1444lim_send_delts_req_action_frame(tpAniSirGlobal pMac,
1445 tSirMacAddr peer,
1446 uint8_t wmmTspecPresent,
1447 tSirMacTSInfo *pTsinfo,
1448 tSirMacTspecIE *pTspecIe, tpPESession psessionEntry)
1449{
1450 uint8_t *pFrame;
1451 tpSirMacMgmtHdr pMacHdr;
1452 tDot11fDelTS DelTS;
1453 tDot11fWMMDelTS WMMDelTS;
1454 uint32_t nBytes, nPayload, nStatus;
1455 void *pPacket;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301456 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001457 uint8_t txFlag = 0;
1458 uint8_t smeSessionId = 0;
1459
1460 if (NULL == psessionEntry) {
1461 return;
1462 }
1463
1464 smeSessionId = psessionEntry->smeSessionId;
1465
1466 if (!wmmTspecPresent) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301467 qdf_mem_set((uint8_t *) &DelTS, sizeof(DelTS), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001468
1469 DelTS.Category.category = SIR_MAC_ACTION_QOS_MGMT;
1470 DelTS.Action.action = SIR_MAC_QOS_DEL_TS_REQ;
1471 populate_dot11f_ts_info(pTsinfo, &DelTS.TSInfo);
1472
1473 nStatus = dot11f_get_packed_del_ts_size(pMac, &DelTS, &nPayload);
1474 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001475 pe_err("Failed to calculate the packed size for a Del TS (0x%08x)", nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001476 /* We'll fall back on the worst case scenario: */
1477 nPayload = sizeof(tDot11fDelTS);
1478 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001479 pe_warn("There were warnings while calculating the packed size for a Del TS (0x%08x)",
1480 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001481 }
1482 } else {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301483 qdf_mem_set((uint8_t *) &WMMDelTS, sizeof(WMMDelTS), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001484
1485 WMMDelTS.Category.category = SIR_MAC_ACTION_WME;
1486 WMMDelTS.Action.action = SIR_MAC_QOS_DEL_TS_REQ;
1487 WMMDelTS.DialogToken.token = 0;
1488 WMMDelTS.StatusCode.statusCode = 0;
1489 populate_dot11f_wmmtspec(pTspecIe, &WMMDelTS.WMMTSPEC);
1490 nStatus =
1491 dot11f_get_packed_wmm_del_ts_size(pMac, &WMMDelTS, &nPayload);
1492 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001493 pe_err("Failed to calculate the packed size for a WMM Del TS (0x%08x)", nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001494 /* We'll fall back on the worst case scenario: */
1495 nPayload = sizeof(tDot11fDelTS);
1496 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001497 pe_warn("There were warnings while calculating the packed size for a WMM Del TS (0x%08x)",
1498 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001499 }
1500 }
1501
1502 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
1503
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301504 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001505 cds_packet_alloc((uint16_t) nBytes, (void **)&pFrame,
1506 (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301507 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001508 pe_err("Failed to allocate %d bytes for an Add TS Response",
1509 nBytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001510 return;
1511 }
1512 /* Paranoia: */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301513 qdf_mem_set(pFrame, nBytes, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001514
1515 /* Next, we fill out the buffer descriptor: */
1516 lim_populate_mac_header(pMac, pFrame, SIR_MAC_MGMT_FRAME,
1517 SIR_MAC_MGMT_ACTION, peer, psessionEntry->selfMacAddr);
1518 pMacHdr = (tpSirMacMgmtHdr) pFrame;
1519
1520 sir_copy_mac_addr(pMacHdr->bssId, psessionEntry->bssId);
1521
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001522 lim_set_protected_bit(pMac, psessionEntry, peer, pMacHdr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001523
1524 /* That done, pack the struct: */
1525 if (!wmmTspecPresent) {
1526 nStatus = dot11f_pack_del_ts(pMac, &DelTS,
1527 pFrame + sizeof(tSirMacMgmtHdr),
1528 nPayload, &nPayload);
1529 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001530 pe_err("Failed to pack a Del TS frame (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001531 nStatus);
1532 cds_packet_free((void *)pPacket);
1533 return; /* allocated! */
1534 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001535 pe_warn("There were warnings while packing a Del TS frame (0x%08x)",
1536 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001537 }
1538 } else {
1539 nStatus = dot11f_pack_wmm_del_ts(pMac, &WMMDelTS,
1540 pFrame + sizeof(tSirMacMgmtHdr),
1541 nPayload, &nPayload);
1542 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001543 pe_err("Failed to pack a WMM Del TS frame (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001544 nStatus);
1545 cds_packet_free((void *)pPacket);
1546 return; /* allocated! */
1547 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001548 pe_warn("There were warnings while packing a WMM Del TS frame (0x%08x)",
1549 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001550 }
1551 }
1552
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001553 pe_debug("Sending DELTS REQ (size %d) to ", nBytes);
1554 lim_print_mac_addr(pMac, pMacHdr->da, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001555
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08001556 if ((BAND_5G ==
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001557 lim_get_rf_band(psessionEntry->currentOperChannel))
Anurag Chouhan6d760662016-02-20 16:05:43 +05301558 || (psessionEntry->pePersona == QDF_P2P_CLIENT_MODE)
1559 || (psessionEntry->pePersona == QDF_P2P_GO_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001560 ) {
1561 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
1562 }
1563
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05301564 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001565 psessionEntry->peSessionId, pMacHdr->fc.subType));
Krunal Sonic65fc492018-03-09 15:53:28 -08001566 lim_diag_mgmt_tx_event_report(pMac, pMacHdr,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001567 psessionEntry, QDF_STATUS_SUCCESS,
1568 QDF_STATUS_SUCCESS);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301569 qdf_status = wma_tx_frame(pMac, pPacket, (uint16_t) nBytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001570 TXRX_FRM_802_11_MGMT,
1571 ANI_TXDIR_TODS,
1572 7, lim_tx_complete, pFrame, txFlag,
Naveen Rawat296a5182017-09-25 14:02:48 -07001573 smeSessionId, 0, RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05301574 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301575 psessionEntry->peSessionId, qdf_status));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001576 /* Pkt will be freed up by the callback */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301577 if (!QDF_IS_STATUS_SUCCESS(qdf_status))
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001578 pe_err("Failed to send Del TS (%X)!", qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001579
1580} /* End lim_send_delts_req_action_frame. */
1581
1582/**
Abhishek Singhdd2cb572017-08-11 11:10:19 +05301583 * lim_assoc_tx_complete_cnf()- Confirmation for assoc sent over the air
1584 * @context: pointer to global mac
1585 * @buf: buffer
1586 * @tx_complete : Sent status
1587 * @params; tx completion params
1588 *
1589 * Return: This returns QDF_STATUS
1590 */
1591
1592static QDF_STATUS lim_assoc_tx_complete_cnf(void *context,
1593 qdf_nbuf_t buf,
1594 uint32_t tx_complete,
1595 void *params)
1596{
1597 uint16_t assoc_ack_status;
1598 uint16_t reason_code;
1599 tpAniSirGlobal mac_ctx = (tpAniSirGlobal)context;
1600
1601 pe_debug("tx_complete= %d", tx_complete);
Zhu Jianmin5d8e3fe2018-01-04 16:16:20 +08001602 if (tx_complete == WMI_MGMT_TX_COMP_TYPE_COMPLETE_OK) {
Abhishek Singhdd2cb572017-08-11 11:10:19 +05301603 assoc_ack_status = ACKED;
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001604 reason_code = QDF_STATUS_SUCCESS;
Abhishek Singhdd2cb572017-08-11 11:10:19 +05301605 } else {
1606 assoc_ack_status = NOT_ACKED;
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001607 reason_code = QDF_STATUS_E_FAILURE;
Abhishek Singhdd2cb572017-08-11 11:10:19 +05301608 }
1609 if (buf)
1610 qdf_nbuf_free(buf);
1611
1612 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_ASSOC_ACK_EVENT,
1613 NULL, assoc_ack_status, reason_code);
1614 return QDF_STATUS_SUCCESS;
1615}
1616
1617/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001618 * lim_send_assoc_req_mgmt_frame() - Send association request
1619 * @mac_ctx: Handle to MAC context
1620 * @mlm_assoc_req: Association request information
1621 * @pe_session: PE session information
1622 *
1623 * Builds and transmits association request frame to AP.
1624 *
1625 * Return: Void
1626 */
1627
1628void
1629lim_send_assoc_req_mgmt_frame(tpAniSirGlobal mac_ctx,
1630 tLimMlmAssocReq *mlm_assoc_req,
1631 tpPESession pe_session)
1632{
Naveen Rawat72475db2017-12-13 18:07:35 -08001633 int ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001634 tDot11fAssocRequest *frm;
1635 uint16_t caps;
1636 uint8_t *frame;
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001637 QDF_STATUS sir_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001638 tLimMlmAssocCnf assoc_cnf;
Hu Wang411e0cc2016-10-28 14:56:01 +08001639 uint32_t bytes = 0, payload, status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001640 uint8_t qos_enabled, wme_enabled, wsm_enabled;
1641 void *packet;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301642 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001643 uint16_t add_ie_len;
1644 uint8_t *add_ie;
Naveen Rawat08db88f2017-09-08 15:07:48 -07001645 const uint8_t *wps_ie = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001646 uint8_t power_caps = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001647 uint8_t tx_flag = 0;
1648 uint8_t sme_sessionid = 0;
1649 bool vht_enabled = false;
1650 tDot11fIEExtCap extr_ext_cap;
1651 bool extr_ext_flag = true;
1652 tpSirMacMgmtHdr mac_hdr;
Hu Wangfbd279d2016-10-31 18:24:34 +08001653 uint32_t ie_offset = 0;
1654 uint8_t *p_ext_cap = NULL;
1655 tDot11fIEExtCap bcn_ext_cap;
1656 uint8_t *bcn_ie = NULL;
1657 uint32_t bcn_ie_len = 0;
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +05301658 uint32_t aes_block_size_len = 0;
Naveen Rawat296a5182017-09-25 14:02:48 -07001659 enum rateid min_rid = RATEID_DEFAULT;
Vignesh Viswanathandada7932018-09-18 12:57:55 +05301660 uint8_t *mbo_ie = NULL;
1661 uint8_t mbo_ie_len = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001662
1663 if (NULL == pe_session) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001664 pe_err("pe_session is NULL");
yeshwanth sriram guntuka07831012017-06-30 12:26:57 +05301665 qdf_mem_free(mlm_assoc_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001666 return;
1667 }
1668
1669 sme_sessionid = pe_session->smeSessionId;
1670
1671 /* check this early to avoid unncessary operation */
1672 if (NULL == pe_session->pLimJoinReq) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001673 pe_err("pe_session->pLimJoinReq is NULL");
yeshwanth sriram guntuka07831012017-06-30 12:26:57 +05301674 qdf_mem_free(mlm_assoc_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001675 return;
1676 }
1677 add_ie_len = pe_session->pLimJoinReq->addIEAssoc.length;
1678 add_ie = pe_session->pLimJoinReq->addIEAssoc.addIEdata;
1679
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301680 frm = qdf_mem_malloc(sizeof(tDot11fAssocRequest));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001681 if (NULL == frm) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001682 pe_err("Unable to allocate memory");
yeshwanth sriram guntuka07831012017-06-30 12:26:57 +05301683 qdf_mem_free(mlm_assoc_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001684 return;
1685 }
Hu Wang411e0cc2016-10-28 14:56:01 +08001686 qdf_mem_set((uint8_t *) frm, sizeof(tDot11fAssocRequest), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001687
Agrawal Ashish0f94b572016-02-22 13:27:06 +05301688 if (add_ie_len && pe_session->is_ext_caps_present) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301689 qdf_mem_set((uint8_t *) &extr_ext_cap, sizeof(tDot11fIEExtCap),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001690 0);
1691 sir_status = lim_strip_extcap_update_struct(mac_ctx,
1692 add_ie, &add_ie_len, &extr_ext_cap);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001693 if (QDF_STATUS_SUCCESS != sir_status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001694 extr_ext_flag = false;
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001695 pe_debug("Unable to Stripoff ExtCap IE from Assoc Req");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001696 } else {
1697 struct s_ext_cap *p_ext_cap = (struct s_ext_cap *)
1698 extr_ext_cap.bytes;
1699
1700 if (p_ext_cap->interworking_service)
1701 p_ext_cap->qos_map = 1;
Hu Wang411e0cc2016-10-28 14:56:01 +08001702 extr_ext_cap.num_bytes =
1703 lim_compute_ext_cap_ie_length(&extr_ext_cap);
1704 extr_ext_flag = (extr_ext_cap.num_bytes > 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001705 }
1706 } else {
Jeff Johnson47d75242018-05-12 15:58:53 -07001707 pe_debug("No addn IE or peer doesn't support addnIE for Assoc Req");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001708 extr_ext_flag = false;
1709 }
1710
1711 caps = mlm_assoc_req->capabilityInfo;
1712#if defined(FEATURE_WLAN_WAPI)
1713 /*
1714 * According to WAPI standard:
1715 * 7.3.1.4 Capability Information field
1716 * In WAPI, non-AP STAs within an ESS set the Privacy subfield to 0
1717 * in transmitted Association or Reassociation management frames.
1718 * APs ignore the Privacy subfield within received Association and
1719 * Reassociation management frames.
1720 */
1721 if (pe_session->encryptType == eSIR_ED_WPI)
1722 ((tSirMacCapabilityInfo *) &caps)->privacy = 0;
1723#endif
1724 swap_bit_field16(caps, (uint16_t *) &frm->Capabilities);
1725
1726 frm->ListenInterval.interval = mlm_assoc_req->listenInterval;
1727 populate_dot11f_ssid2(mac_ctx, &frm->SSID);
1728 populate_dot11f_supp_rates(mac_ctx, POPULATE_DOT11F_RATES_OPERATIONAL,
1729 &frm->SuppRates, pe_session);
1730
1731 qos_enabled = (pe_session->limQosEnabled) &&
1732 SIR_MAC_GET_QOS(pe_session->limCurrentBssCaps);
1733
1734 wme_enabled = (pe_session->limWmeEnabled) &&
1735 LIM_BSS_CAPS_GET(WME, pe_session->limCurrentBssQosCaps);
1736
1737 /* We prefer .11e asociations: */
1738 if (qos_enabled)
1739 wme_enabled = false;
1740
1741 wsm_enabled = (pe_session->limWsmEnabled) && wme_enabled &&
1742 LIM_BSS_CAPS_GET(WSM, pe_session->limCurrentBssQosCaps);
1743
1744 if (pe_session->lim11hEnable &&
Srinivas Girigowda74a66d62017-06-21 23:28:25 -07001745 pe_session->pLimJoinReq->spectrumMgtIndicator == true) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001746 power_caps = true;
1747
1748 populate_dot11f_power_caps(mac_ctx, &frm->PowerCaps,
1749 LIM_ASSOC, pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001750 populate_dot11f_supp_channels(mac_ctx, &frm->SuppChannels,
1751 LIM_ASSOC, pe_session);
1752
1753 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001754 if (mac_ctx->rrm.rrmPEContext.rrmEnable &&
1755 SIR_MAC_GET_RRM(pe_session->limCurrentBssCaps)) {
1756 if (power_caps == false) {
1757 power_caps = true;
1758 populate_dot11f_power_caps(mac_ctx, &frm->PowerCaps,
1759 LIM_ASSOC, pe_session);
1760 }
1761 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001762 if (qos_enabled)
Naveen Rawatcd118312016-11-22 10:46:21 -08001763 populate_dot11f_qos_caps_station(mac_ctx, pe_session,
1764 &frm->QOSCapsStation);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001765
1766 populate_dot11f_ext_supp_rates(mac_ctx,
1767 POPULATE_DOT11F_RATES_OPERATIONAL, &frm->ExtSuppRates,
1768 pe_session);
1769
Gupta, Kapil54a16992016-01-13 19:34:02 +05301770 if (mac_ctx->rrm.rrmPEContext.rrmEnable &&
1771 SIR_MAC_GET_RRM(pe_session->limCurrentBssCaps))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001772 populate_dot11f_rrm_ie(mac_ctx, &frm->RRMEnabledCap,
1773 pe_session);
Deepak Dhamdhere641bf322016-01-06 15:19:03 -08001774
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001775 /*
1776 * The join request *should* contain zero or one of the WPA and RSN
1777 * IEs. The payload send along with the request is a
1778 * 'tSirSmeJoinReq'; the IE portion is held inside a 'tSirRSNie':
1779 * typedef struct sSirRSNie
1780 * {
1781 * uint16_t length;
1782 * uint8_t rsnIEdata[SIR_MAC_MAX_IE_LENGTH+2];
1783 * } tSirRSNie, *tpSirRSNie;
1784 * So, we should be able to make the following two calls harmlessly,
1785 * since they do nothing if they don't find the given IE in the
1786 * bytestream with which they're provided.
1787 * The net effect of this will be to faithfully transmit whatever
1788 * security IE is in the join request.
1789 * However, if we're associating for the purpose of WPS
1790 * enrollment, and we've been configured to indicate that by
1791 * eliding the WPA or RSN IE, we just skip this:
1792 */
1793 if (add_ie_len && add_ie)
1794 wps_ie = limGetWscIEPtr(mac_ctx, add_ie, add_ie_len);
1795
1796 if (NULL == wps_ie) {
1797 populate_dot11f_rsn_opaque(mac_ctx,
1798 &(pe_session->pLimJoinReq->rsnIE),
1799 &frm->RSNOpaque);
1800 populate_dot11f_wpa_opaque(mac_ctx,
1801 &(pe_session->pLimJoinReq->rsnIE),
1802 &frm->WPAOpaque);
1803#if defined(FEATURE_WLAN_WAPI)
1804 populate_dot11f_wapi_opaque(mac_ctx,
1805 &(pe_session->pLimJoinReq->rsnIE),
1806 &frm->WAPIOpaque);
1807#endif /* defined(FEATURE_WLAN_WAPI) */
1808 }
1809 /* include WME EDCA IE as well */
1810 if (wme_enabled) {
1811 populate_dot11f_wmm_info_station_per_session(mac_ctx,
1812 pe_session, &frm->WMMInfoStation);
1813
1814 if (wsm_enabled)
1815 populate_dot11f_wmm_caps(&frm->WMMCaps);
1816 }
1817
1818 /*
1819 * Populate HT IEs, when operating in 11n and
1820 * when AP is also operating in 11n mode
1821 */
1822 if (pe_session->htCapability &&
1823 mac_ctx->lim.htCapabilityPresentInBeacon) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001824 pe_debug("Populate HT Caps in Assoc Request");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001825 populate_dot11f_ht_caps(mac_ctx, pe_session, &frm->HTCaps);
Naveen Rawata410c5a2016-09-19 14:22:33 -07001826 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_DEBUG,
1827 &frm->HTCaps, sizeof(frm->HTCaps));
Kiran Kumar Lokere722dccd2018-02-23 13:23:52 -08001828 } else if (pe_session->he_with_wep_tkip) {
1829 pe_debug("Populate HT Caps in Assoc Request with WEP/TKIP");
1830 populate_dot11f_ht_caps(mac_ctx, NULL, &frm->HTCaps);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001831 }
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001832 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 +05301833 frm->HTCaps.supportedChannelWidthSet,
1834 frm->HTCaps.mimoPowerSave,
1835 frm->HTCaps.greenField, frm->HTCaps.shortGI20MHz,
1836 frm->HTCaps.shortGI40MHz,
1837 frm->HTCaps.dsssCckMode40MHz,
1838 frm->HTCaps.maxRxAMPDUFactor);
1839
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001840 if (pe_session->vhtCapability &&
1841 pe_session->vhtCapabilityPresentInBeacon) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001842 pe_debug("Populate VHT IEs in Assoc Request");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001843 populate_dot11f_vht_caps(mac_ctx, pe_session, &frm->VHTCaps);
Naveen Rawata410c5a2016-09-19 14:22:33 -07001844 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_DEBUG,
1845 &frm->VHTCaps, sizeof(frm->VHTCaps));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001846 vht_enabled = true;
Kiran Kumar Lokere1d4094e2016-08-31 19:04:04 -07001847 if (pe_session->enableHtSmps &&
1848 !pe_session->supported_nss_1x1) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001849 pe_err("VHT OP mode IE in Assoc Req");
Kiran Kumar Lokere1d4094e2016-08-31 19:04:04 -07001850 populate_dot11f_operating_mode(mac_ctx,
1851 &frm->OperatingMode, pe_session);
1852 }
Kiran Kumar Lokere722dccd2018-02-23 13:23:52 -08001853 } else if (pe_session->he_with_wep_tkip) {
1854 pe_debug("Populate VHT IEs in Assoc Request with WEP/TKIP");
1855 populate_dot11f_vht_caps(mac_ctx, NULL, &frm->VHTCaps);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001856 }
Kiran Kumar Lokere722dccd2018-02-23 13:23:52 -08001857
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001858 if (!vht_enabled &&
1859 pe_session->is_vendor_specific_vhtcaps) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001860 pe_debug("Populate Vendor VHT IEs in Assoc Request");
Kapil Gupta4b2efbb2016-10-03 13:07:20 +05301861 frm->vendor_vht_ie.present = 1;
Kiran Kumar Lokere81722632017-09-26 12:11:43 -07001862 frm->vendor_vht_ie.sub_type =
1863 pe_session->vendor_specific_vht_ie_sub_type;
Kapil Gupta4b2efbb2016-10-03 13:07:20 +05301864 frm->vendor_vht_ie.VHTCaps.present = 1;
Abhishek Singh68844282018-01-25 16:48:41 +05301865 if (!mac_ctx->roam.configParam.enable_subfee_vendor_vhtie &&
1866 pe_session->vht_config.su_beam_formee) {
1867 pe_debug("Disable SU beamformee for vendor IE");
1868 pe_session->vht_config.su_beam_formee = 0;
1869 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001870 populate_dot11f_vht_caps(mac_ctx, pe_session,
Kapil Gupta4b2efbb2016-10-03 13:07:20 +05301871 &frm->vendor_vht_ie.VHTCaps);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001872 vht_enabled = true;
1873 }
Agrawal Ashish0f94b572016-02-22 13:27:06 +05301874 if (pe_session->is_ext_caps_present)
1875 populate_dot11f_ext_cap(mac_ctx, vht_enabled,
1876 &frm->ExtCap, pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001877
Wu Gao93816212018-08-31 16:49:54 +08001878 if (mac_ctx->mlme_cfg->sta.qcn_ie_support)
Selvaraj, Sridhara521aab2017-03-25 16:42:34 +05301879 populate_dot11f_qcn_ie(&frm->QCN_IE);
1880
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08001881 if (lim_is_session_he_capable(pe_session)) {
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07001882 pe_debug("Populate HE IEs");
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08001883 populate_dot11f_he_caps(mac_ctx, pe_session,
Naveen Rawatd8feac12017-09-08 15:08:39 -07001884 &frm->he_cap);
Kiran Kumar Lokere722dccd2018-02-23 13:23:52 -08001885 } else if (pe_session->he_with_wep_tkip) {
1886 pe_debug("Populate HE IEs in Assoc Request with WEP/TKIP");
1887 populate_dot11f_he_caps(mac_ctx, NULL, &frm->he_cap);
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08001888 }
Selvaraj, Sridharc2fe7a32017-02-02 19:20:16 +05301889
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001890 if (pe_session->pLimJoinReq->is11Rconnection) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001891 tSirBssDescription *bssdescr;
1892
1893 bssdescr = &pe_session->pLimJoinReq->bssDescription;
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001894 pe_debug("mdie = %02x %02x %02x",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001895 (unsigned int) bssdescr->mdie[0],
1896 (unsigned int) bssdescr->mdie[1],
1897 (unsigned int) bssdescr->mdie[2]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001898 populate_mdie(mac_ctx, &frm->MobilityDomain,
1899 pe_session->pLimJoinReq->bssDescription.mdie);
1900 } else {
1901 /* No 11r IEs dont send any MDIE */
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001902 pe_debug("MDIE not present");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001903 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001904
1905#ifdef FEATURE_WLAN_ESE
1906 /*
1907 * ESE Version IE will be included in association request
1908 * when ESE is enabled on DUT through ini and it is also
1909 * advertised by the peer AP to which we are trying to
1910 * associate to.
1911 */
1912 if (pe_session->is_ese_version_ie_present &&
1913 mac_ctx->roam.configParam.isEseIniFeatureEnabled)
1914 populate_dot11f_ese_version(&frm->ESEVersion);
1915 /* For ESE Associations fill the ESE IEs */
1916 if (pe_session->isESEconnection &&
1917 pe_session->pLimJoinReq->isESEFeatureIniEnabled) {
1918#ifndef FEATURE_DISABLE_RM
1919 populate_dot11f_ese_rad_mgmt_cap(&frm->ESERadMgmtCap);
1920#endif
1921 }
1922#endif
1923
Hu Wang411e0cc2016-10-28 14:56:01 +08001924 /*
1925 * Extcap IE now support variable length, merge Extcap IE from addn_ie
1926 * may change the frame size. Therefore, MUST merge ExtCap IE before
1927 * dot11f get packed payload size.
1928 */
1929 if (extr_ext_flag)
Hu Wangfbd279d2016-10-31 18:24:34 +08001930 lim_merge_extcap_struct(&frm->ExtCap, &extr_ext_cap, true);
1931
1932 /* Clear the bits in EXTCAP IE if AP not advertise it in beacon */
1933 if (frm->ExtCap.present && pe_session->is_ext_caps_present) {
1934 ie_offset = DOT11F_FF_TIMESTAMP_LEN +
1935 DOT11F_FF_BEACONINTERVAL_LEN +
1936 DOT11F_FF_CAPABILITIES_LEN;
1937
1938 qdf_mem_zero((uint8_t *)&bcn_ext_cap, sizeof(tDot11fIEExtCap));
1939 if (pe_session->beacon && pe_session->bcnLen > ie_offset) {
1940 bcn_ie = pe_session->beacon + ie_offset;
1941 bcn_ie_len = pe_session->bcnLen - ie_offset;
Naveen Rawat08db88f2017-09-08 15:07:48 -07001942 p_ext_cap = (uint8_t *)wlan_get_ie_ptr_from_eid(
Hu Wangfbd279d2016-10-31 18:24:34 +08001943 DOT11F_EID_EXTCAP,
Naveen Rawat08db88f2017-09-08 15:07:48 -07001944 bcn_ie, bcn_ie_len);
Hu Wangfbd279d2016-10-31 18:24:34 +08001945 lim_update_extcap_struct(mac_ctx, p_ext_cap,
1946 &bcn_ext_cap);
1947 lim_merge_extcap_struct(&frm->ExtCap, &bcn_ext_cap,
1948 false);
1949 }
Varun Reddy Yeturu4f849e52018-06-15 18:08:37 -07001950 /*
1951 * TWT extended capabilities should be populated after the
1952 * intersection of beacon caps and self caps is done because
1953 * the bits for TWT are unique to STA and AP and cannot be
1954 * intersected.
1955 */
1956 populate_dot11f_twt_extended_caps(mac_ctx, pe_session,
1957 &frm->ExtCap);
Hu Wangfbd279d2016-10-31 18:24:34 +08001958 }
Hu Wang411e0cc2016-10-28 14:56:01 +08001959
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001960 if (QDF_STATUS_SUCCESS != lim_strip_supp_op_class_update_struct(mac_ctx,
Arif Hussain6cec6bc2017-02-14 13:46:26 -08001961 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 /*
Vignesh Viswanathandada7932018-09-18 12:57:55 +05301970 * MBO IE needs to be appendded at the end of the assoc request
1971 * frame and is not parsed and unpacked by the frame parser
1972 * as the supplicant can send multiple TLVs with same Attribute
1973 * in the MBO IE and the frame parser does not support multiple
1974 * TLVs with same attribute in a single IE.
1975 * Strip off the MBO IE from add_ie and append it at the end.
1976 */
1977 if (wlan_get_vendor_ie_ptr_from_oui(SIR_MAC_MBO_OUI,
1978 SIR_MAC_MBO_OUI_SIZE, add_ie, add_ie_len)) {
1979 mbo_ie = qdf_mem_malloc(DOT11F_IE_MBO_IE_MAX_LEN + 2);
1980 if (!mbo_ie) {
1981 pe_err("Failed to allocate mbo_ie");
1982 goto end;
1983 }
1984
1985 qdf_status = lim_strip_ie(mac_ctx, add_ie, &add_ie_len,
1986 SIR_MAC_EID_VENDOR, ONE_BYTE,
1987 SIR_MAC_MBO_OUI,
1988 SIR_MAC_MBO_OUI_SIZE,
1989 mbo_ie, DOT11F_IE_MBO_IE_MAX_LEN);
1990 if (QDF_IS_STATUS_ERROR(qdf_status)) {
1991 pe_err("Failed to strip MBO IE");
1992 goto free_mbo_ie;
1993 }
1994
1995 /* Include the EID and length fields */
1996 mbo_ie_len = mbo_ie[1] + 2;
1997 pe_debug("Stripped MBO IE of length %d", mbo_ie_len);
1998 }
1999
2000 /*
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +05302001 * Do unpack to populate the add_ie buffer to frm structure
2002 * before packing the frm structure. In this way, the IE ordering
2003 * which the latest 802.11 spec mandates is maintained.
2004 */
Naveen Rawat72475db2017-12-13 18:07:35 -08002005 if (add_ie_len) {
2006 ret = dot11f_unpack_assoc_request(mac_ctx, add_ie,
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +05302007 add_ie_len, frm, true);
Naveen Rawat72475db2017-12-13 18:07:35 -08002008 if (DOT11F_FAILED(ret)) {
2009 pe_err("unpack failed, ret: 0x%x", ret);
2010 goto end;
2011 }
2012 }
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +05302013
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002014 status = dot11f_get_packed_assoc_request_size(mac_ctx, frm, &payload);
2015 if (DOT11F_FAILED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002016 pe_err("Association Request packet size failure(0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002017 status);
2018 /* We'll fall back on the worst case scenario: */
2019 payload = sizeof(tDot11fAssocRequest);
2020 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002021 pe_warn("Association request packet size warning (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002022 status);
2023 }
2024
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +05302025 bytes = payload + sizeof(tSirMacMgmtHdr) +
Vignesh Viswanathandada7932018-09-18 12:57:55 +05302026 aes_block_size_len + mbo_ie_len;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002027
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302028 qdf_status = cds_packet_alloc((uint16_t) bytes, (void **)&frame,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002029 (void **)&packet);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302030 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002031 pe_err("Failed to allocate %d bytes", bytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002032
2033 pe_session->limMlmState = pe_session->limPrevMlmState;
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302034 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_MLM_STATE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002035 pe_session->peSessionId,
2036 pe_session->limMlmState));
2037
2038 /* Update PE session id */
2039 assoc_cnf.sessionId = pe_session->peSessionId;
2040
2041 assoc_cnf.resultCode = eSIR_SME_RESOURCES_UNAVAILABLE;
2042
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002043 lim_post_sme_message(mac_ctx, LIM_MLM_ASSOC_CNF,
2044 (uint32_t *) &assoc_cnf);
2045
yeshwanth sriram guntuka07831012017-06-30 12:26:57 +05302046 goto end;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002047 }
2048 /* Paranoia: */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302049 qdf_mem_set(frame, bytes, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002050
2051 /* Next, we fill out the buffer descriptor: */
2052 lim_populate_mac_header(mac_ctx, frame, SIR_MAC_MGMT_FRAME,
2053 SIR_MAC_MGMT_ASSOC_REQ, pe_session->bssId,
2054 pe_session->selfMacAddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002055 /* That done, pack the Assoc Request: */
2056 status = dot11f_pack_assoc_request(mac_ctx, frm,
2057 frame + sizeof(tSirMacMgmtHdr), payload, &payload);
2058 if (DOT11F_FAILED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002059 pe_err("Assoc request pack failure (0x%08x)", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002060 cds_packet_free((void *)packet);
yeshwanth sriram guntuka07831012017-06-30 12:26:57 +05302061 goto end;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002062 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002063 pe_warn("Assoc request pack warning (0x%08x)", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002064 }
2065
Vignesh Viswanathandada7932018-09-18 12:57:55 +05302066 /* Copy the MBO IE to the end of the frame */
2067 qdf_mem_copy(frame + sizeof(tSirMacMgmtHdr) + payload,
2068 mbo_ie, mbo_ie_len);
2069 payload = payload + mbo_ie_len;
2070
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002071 if (pe_session->assocReq != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302072 qdf_mem_free(pe_session->assocReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002073 pe_session->assocReq = NULL;
Naveen Rawat83102ef2015-11-03 10:42:34 -08002074 pe_session->assocReqLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002075 }
2076
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +05302077 if (lim_is_fils_connection(pe_session)) {
2078 qdf_status = aead_encrypt_assoc_req(mac_ctx, pe_session,
2079 frame, &payload);
2080 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
2081 cds_packet_free((void *)packet);
2082 qdf_mem_free(frm);
2083 return;
2084 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002085 }
2086
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302087 pe_session->assocReq = qdf_mem_malloc(payload);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002088 if (NULL == pe_session->assocReq) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002089 pe_err("Unable to allocate memory");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002090 } else {
2091 /*
2092 * Store the Assoc request. This is sent to csr/hdd in
2093 * join cnf response.
2094 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302095 qdf_mem_copy(pe_session->assocReq,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002096 frame + sizeof(tSirMacMgmtHdr), payload);
2097 pe_session->assocReqLen = payload;
2098 }
2099
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08002100 if ((BAND_5G == lim_get_rf_band(pe_session->currentOperChannel))
Anurag Chouhan6d760662016-02-20 16:05:43 +05302101 || (pe_session->pePersona == QDF_P2P_CLIENT_MODE)
2102 || (pe_session->pePersona == QDF_P2P_GO_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002103 )
2104 tx_flag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
2105
Anurag Chouhan6d760662016-02-20 16:05:43 +05302106 if (pe_session->pePersona == QDF_P2P_CLIENT_MODE ||
2107 pe_session->pePersona == QDF_STA_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002108 tx_flag |= HAL_USE_PEER_STA_REQUESTED_MASK;
2109
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002110 mac_hdr = (tpSirMacMgmtHdr) frame;
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302111 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002112 pe_session->peSessionId, mac_hdr->fc.subType));
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +05302113
2114 pe_debug("Sending Association Request length %d to ", bytes);
Naveen Rawat296a5182017-09-25 14:02:48 -07002115 min_rid = lim_get_min_session_txrate(pe_session);
Krunal Sonic65fc492018-03-09 15:53:28 -08002116 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_ASSOC_START_EVENT,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07002117 pe_session, QDF_STATUS_SUCCESS, QDF_STATUS_SUCCESS);
Krunal Sonic65fc492018-03-09 15:53:28 -08002118 lim_diag_mgmt_tx_event_report(mac_ctx, mac_hdr,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07002119 pe_session, QDF_STATUS_SUCCESS, QDF_STATUS_SUCCESS);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302120 qdf_status =
Abhishek Singhdd2cb572017-08-11 11:10:19 +05302121 wma_tx_frameWithTxComplete(mac_ctx, packet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002122 (uint16_t) (sizeof(tSirMacMgmtHdr) + payload),
2123 TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS, 7,
Abhishek Singhdd2cb572017-08-11 11:10:19 +05302124 lim_tx_complete, frame, lim_assoc_tx_complete_cnf,
Naveen Rawat296a5182017-09-25 14:02:48 -07002125 tx_flag, sme_sessionid, false, 0, min_rid);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302126 MTRACE(qdf_trace
Anurag Chouhan6d760662016-02-20 16:05:43 +05302127 (QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302128 pe_session->peSessionId, qdf_status));
Naveen Rawat296a5182017-09-25 14:02:48 -07002129
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302130 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002131 pe_err("Failed to send Association Request (%X)!",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302132 qdf_status);
Abhishek Singhdd2cb572017-08-11 11:10:19 +05302133 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_ASSOC_ACK_EVENT,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07002134 pe_session, SENT_FAIL, QDF_STATUS_E_FAILURE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002135 /* Pkt will be freed up by the callback */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002136 }
Vignesh Viswanathandada7932018-09-18 12:57:55 +05302137free_mbo_ie:
2138 if (mbo_ie)
2139 qdf_mem_free(mbo_ie);
2140
yeshwanth sriram guntuka07831012017-06-30 12:26:57 +05302141end:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002142 /* Free up buffer allocated for mlm_assoc_req */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302143 qdf_mem_free(mlm_assoc_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002144 mlm_assoc_req = NULL;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302145 qdf_mem_free(frm);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002146 return;
2147}
2148
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002149/**
Krunal Sonid2136c72018-06-01 17:26:39 -07002150 * lim_addba_rsp_tx_complete_cnf() - Confirmation for add BA response OTA
2151 * @context: pointer to global mac
2152 * @buf: buffer which is nothing but entire ADD BA frame
2153 * @tx_complete : Sent status
2154 * @params; tx completion params
2155 *
2156 * Return: This returns QDF_STATUS
2157 */
2158static QDF_STATUS lim_addba_rsp_tx_complete_cnf(void *context,
2159 qdf_nbuf_t buf,
2160 uint32_t tx_complete,
2161 void *params)
2162{
2163 tpAniSirGlobal mac_ctx = (tpAniSirGlobal)context;
2164 tSirMacMgmtHdr *mac_hdr;
2165 tDot11faddba_rsp rsp;
2166 void *soc = cds_get_context(QDF_MODULE_ID_SOC);
2167 void *pdev = cds_get_context(QDF_MODULE_ID_TXRX);
2168 uint8_t peer_id;
2169 void *peer;
2170 uint32_t frame_len;
2171 QDF_STATUS status;
2172 uint8_t *data;
2173
2174 if (tx_complete == WMI_MGMT_TX_COMP_TYPE_COMPLETE_OK)
2175 pe_debug("Add ba response successfully sent");
2176 else
2177 pe_debug("Fail to send add ba response");
2178
2179 if (!buf) {
2180 pe_err("Addba response frame buffer is NULL");
2181 return QDF_STATUS_E_FAILURE;
2182 }
2183
2184 data = qdf_nbuf_data(buf);
2185
2186 if (!data) {
2187 pe_err("Addba response frame is NULL");
2188 return QDF_STATUS_E_FAILURE;
2189 }
2190
2191 mac_hdr = (tSirMacMgmtHdr *)data;
2192 qdf_mem_zero((void *)&rsp, sizeof(tDot11faddba_rsp));
2193 frame_len = sizeof(rsp);
2194 status = dot11f_unpack_addba_rsp(mac_ctx, (uint8_t *)data +
2195 sizeof(*mac_hdr), frame_len,
2196 &rsp, false);
2197
2198 if (DOT11F_FAILED(status)) {
2199 pe_err("Failed to unpack and parse (0x%08x, %d bytes)",
2200 status, frame_len);
2201 goto error;
2202 }
2203
2204 peer = cdp_peer_get_ref_by_addr(soc, pdev, mac_hdr->da, &peer_id,
2205 PEER_DEBUG_ID_WMA_ADDBA_REQ);
2206 if (!peer) {
2207 pe_debug("no PEER found for mac_addr:%pM", mac_hdr->da);
2208 goto error;
2209 }
2210 cdp_addba_resp_tx_completion(soc, peer, rsp.addba_param_set.tid,
2211 tx_complete);
2212 cdp_peer_release_ref(soc, peer, PEER_DEBUG_ID_WMA_ADDBA_REQ);
2213error:
2214 if (buf)
2215 qdf_nbuf_free(buf);
2216
2217 return QDF_STATUS_SUCCESS;
2218}
2219
2220/**
Abhishek Singh7d3bc3e2016-02-03 17:45:01 +05302221 * lim_auth_tx_complete_cnf()- Confirmation for auth sent over the air
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05302222 * @context: pointer to global mac
2223 * @buf: buffer
Abhishek Singh7d3bc3e2016-02-03 17:45:01 +05302224 * @tx_complete : Sent status
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05302225 * @params; tx completion params
Abhishek Singh7d3bc3e2016-02-03 17:45:01 +05302226 *
2227 * Return: This returns QDF_STATUS
2228 */
2229
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05302230static QDF_STATUS lim_auth_tx_complete_cnf(void *context,
2231 qdf_nbuf_t buf,
2232 uint32_t tx_complete,
2233 void *params)
Abhishek Singh7d3bc3e2016-02-03 17:45:01 +05302234{
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05302235 tpAniSirGlobal mac_ctx = (tpAniSirGlobal)context;
Abhishek Singhdd2cb572017-08-11 11:10:19 +05302236 uint16_t auth_ack_status;
2237 uint16_t reason_code;
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05302238
Naveen Rawat684e8b12017-09-20 15:54:44 -07002239 pe_debug("tx_complete = %d %s", tx_complete,
Zhu Jianmin5d8e3fe2018-01-04 16:16:20 +08002240 (tx_complete == WMI_MGMT_TX_COMP_TYPE_COMPLETE_OK) ?
2241 "success" : "fail");
2242 if (tx_complete == WMI_MGMT_TX_COMP_TYPE_COMPLETE_OK) {
Abhishek Singh7d3bc3e2016-02-03 17:45:01 +05302243 mac_ctx->auth_ack_status = LIM_AUTH_ACK_RCD_SUCCESS;
Abhishek Singhdd2cb572017-08-11 11:10:19 +05302244 auth_ack_status = ACKED;
Jeff Johnson0301ecb2018-06-29 09:36:23 -07002245 reason_code = QDF_STATUS_SUCCESS;
Abhishek Singh7d3bc3e2016-02-03 17:45:01 +05302246 /* 'Change' timer for future activations */
2247 lim_deactivate_and_change_timer(mac_ctx, eLIM_AUTH_RETRY_TIMER);
2248 } else {
2249 mac_ctx->auth_ack_status = LIM_AUTH_ACK_RCD_FAILURE;
Abhishek Singhdd2cb572017-08-11 11:10:19 +05302250 auth_ack_status = NOT_ACKED;
Jeff Johnson0301ecb2018-06-29 09:36:23 -07002251 reason_code = QDF_STATUS_E_FAILURE;
Abhishek Singh7d3bc3e2016-02-03 17:45:01 +05302252 }
Himanshu Agarwal8b472bc2017-01-20 20:49:41 +05302253
2254 if (buf)
2255 qdf_nbuf_free(buf);
2256
Abhishek Singhdd2cb572017-08-11 11:10:19 +05302257 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_AUTH_ACK_EVENT,
2258 NULL, auth_ack_status, reason_code);
2259
Abhishek Singh7d3bc3e2016-02-03 17:45:01 +05302260 return QDF_STATUS_SUCCESS;
2261}
2262
2263/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002264 * lim_send_auth_mgmt_frame() - Send an Authentication frame
2265 *
2266 * @mac_ctx: Pointer to Global MAC structure
2267 * @auth_frame: Pointer to Authentication frame structure
2268 * @peer_addr: MAC address of destination peer
2269 * @wep_bit: wep bit in frame control for Authentication frame3
2270 * @session: PE session information
2271 *
2272 * This function is called by lim_process_mlm_messages(). Authentication frame
2273 * is formatted and sent when this function is called.
2274 *
2275 * Return: void
2276 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002277void
2278lim_send_auth_mgmt_frame(tpAniSirGlobal mac_ctx,
2279 tpSirMacAuthFrameBody auth_frame,
2280 tSirMacAddr peer_addr,
yeshwanth sriram guntuka343a3f22017-07-27 18:30:18 +05302281 uint8_t wep_challenge_len,
Abhishek Singhdd2cb572017-08-11 11:10:19 +05302282 tpPESession session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002283{
2284 uint8_t *frame, *body;
2285 uint32_t frame_len = 0, body_len = 0;
2286 tpSirMacMgmtHdr mac_hdr;
2287 void *packet;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302288 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002289 uint8_t tx_flag = 0;
2290 uint8_t sme_sessionid = 0;
2291 uint16_t ft_ies_length = 0;
Krishna Kumaar Natarajan0517c602017-06-02 14:58:21 -07002292 bool challenge_req = false;
Naveen Rawat296a5182017-09-25 14:02:48 -07002293 enum rateid min_rid = RATEID_DEFAULT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002294
2295 if (NULL == session) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002296 pe_err("Error: psession Entry is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002297 return;
2298 }
2299
2300 sme_sessionid = session->smeSessionId;
2301
yeshwanth sriram guntuka343a3f22017-07-27 18:30:18 +05302302 if (wep_challenge_len) {
Krishna Kumaar Natarajan7e6a23c2016-04-05 14:45:24 -07002303 /*
2304 * Auth frame3 to be sent with encrypted framebody
2305 *
2306 * Allocate buffer for Authenticaton frame of size
2307 * equal to management frame header length plus 2 bytes
2308 * each for auth algorithm number, transaction number,
2309 * status code, 128 bytes for challenge text and
2310 * 4 bytes each for IV & ICV.
2311 */
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002312 pe_debug("Sending encrypted auth frame to " MAC_ADDRESS_STR,
2313 MAC_ADDR_ARRAY(peer_addr));
Krishna Kumaar Natarajan7e6a23c2016-04-05 14:45:24 -07002314
yeshwanth sriram guntuka343a3f22017-07-27 18:30:18 +05302315 body_len = wep_challenge_len + LIM_ENCR_AUTH_INFO_LEN;
Krishna Kumaar Natarajan0517c602017-06-02 14:58:21 -07002316 frame_len = sizeof(tSirMacMgmtHdr) + body_len;
Krishna Kumaar Natarajan7e6a23c2016-04-05 14:45:24 -07002317
2318 goto alloc_packet;
2319 }
2320
Tushnim Bhattacharyya332b74c2018-08-10 10:55:51 -07002321 pe_debug("Sending Auth seq# %d status %d (%d) to "
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002322 MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002323 auth_frame->authTransactionSeqNumber,
2324 auth_frame->authStatusCode,
2325 (auth_frame->authStatusCode == eSIR_MAC_SUCCESS_STATUS),
2326 MAC_ADDR_ARRAY(peer_addr));
2327
2328 switch (auth_frame->authTransactionSeqNumber) {
2329 case SIR_MAC_AUTH_FRAME_1:
2330 /*
2331 * Allocate buffer for Authenticaton frame of size
2332 * equal to management frame header length plus 2 bytes
2333 * each for auth algorithm number, transaction number
2334 * and status code.
2335 */
2336
Krishna Kumaar Natarajan0517c602017-06-02 14:58:21 -07002337 body_len = SIR_MAC_AUTH_FRAME_INFO_LEN;
2338 frame_len = sizeof(tSirMacMgmtHdr) + body_len;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002339
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +05302340 frame_len += lim_create_fils_auth_data(mac_ctx,
2341 auth_frame, session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002342 if (auth_frame->authAlgoNumber == eSIR_FT_AUTH) {
2343 if (NULL != session->ftPEContext.pFTPreAuthReq &&
2344 0 != session->ftPEContext.pFTPreAuthReq->
2345 ft_ies_length) {
2346 ft_ies_length = session->ftPEContext.
2347 pFTPreAuthReq->ft_ies_length;
2348 frame_len += ft_ies_length;
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002349 pe_debug("Auth frame, FTIES length added=%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002350 ft_ies_length);
2351 } else {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002352 pe_debug("Auth frame, Does not contain FTIES!");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002353 frame_len += (2 + SIR_MDIE_SIZE);
2354 }
2355 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002356 break;
2357
2358 case SIR_MAC_AUTH_FRAME_2:
2359 if ((auth_frame->authAlgoNumber == eSIR_OPEN_SYSTEM) ||
2360 ((auth_frame->authAlgoNumber == eSIR_SHARED_KEY) &&
2361 (auth_frame->authStatusCode !=
2362 eSIR_MAC_SUCCESS_STATUS))) {
2363 /*
2364 * Allocate buffer for Authenticaton frame of size
2365 * equal to management frame header length plus
2366 * 2 bytes each for auth algorithm number,
2367 * transaction number and status code.
2368 */
2369
Krishna Kumaar Natarajan0517c602017-06-02 14:58:21 -07002370 body_len = SIR_MAC_AUTH_FRAME_INFO_LEN;
2371 frame_len = sizeof(tSirMacMgmtHdr) + body_len;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002372 } else {
2373 /*
2374 * Shared Key algorithm with challenge text
2375 * to be sent.
2376 *
2377 * Allocate buffer for Authenticaton frame of size
2378 * equal to management frame header length plus
2379 * 2 bytes each for auth algorithm number,
2380 * transaction number, status code and 128 bytes
2381 * for challenge text.
2382 */
2383
Krishna Kumaar Natarajan0517c602017-06-02 14:58:21 -07002384 challenge_req = true;
2385 body_len = SIR_MAC_AUTH_FRAME_INFO_LEN +
yeshwanth sriram guntuka5c71a292017-08-24 15:51:19 +05302386 SIR_MAC_SAP_AUTH_CHALLENGE_LENGTH +
2387 SIR_MAC_CHALLENGE_ID_LEN;
Krishna Kumaar Natarajan0517c602017-06-02 14:58:21 -07002388 frame_len = sizeof(tSirMacMgmtHdr) + body_len;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002389 }
2390 break;
2391
2392 case SIR_MAC_AUTH_FRAME_3:
Krishna Kumaar Natarajan7e6a23c2016-04-05 14:45:24 -07002393 /*
2394 * Auth frame3 to be sent without encrypted framebody
2395 *
2396 * Allocate buffer for Authenticaton frame of size equal
2397 * to management frame header length plus 2 bytes each
2398 * for auth algorithm number, transaction number and
2399 * status code.
2400 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002401
Krishna Kumaar Natarajan0517c602017-06-02 14:58:21 -07002402 body_len = SIR_MAC_AUTH_FRAME_INFO_LEN;
2403 frame_len = sizeof(tSirMacMgmtHdr) + body_len;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002404 break;
2405
2406 case SIR_MAC_AUTH_FRAME_4:
2407 /*
2408 * Allocate buffer for Authenticaton frame of size equal
2409 * to management frame header length plus 2 bytes each
2410 * for auth algorithm number, transaction number and
2411 * status code.
2412 */
2413
Krishna Kumaar Natarajan0517c602017-06-02 14:58:21 -07002414 body_len = SIR_MAC_AUTH_FRAME_INFO_LEN;
2415 frame_len = sizeof(tSirMacMgmtHdr) + body_len;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002416
2417 break;
Krishna Kumaar Natarajan7e6a23c2016-04-05 14:45:24 -07002418 default:
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002419 pe_err("Invalid auth transaction seq num");
Krishna Kumaar Natarajan7e6a23c2016-04-05 14:45:24 -07002420 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002421 } /* switch (auth_frame->authTransactionSeqNumber) */
2422
Krishna Kumaar Natarajan7e6a23c2016-04-05 14:45:24 -07002423alloc_packet:
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302424 qdf_status = cds_packet_alloc((uint16_t) frame_len, (void **)&frame,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002425 (void **)&packet);
2426
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302427 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002428 pe_err("call to bufAlloc failed for AUTH frame");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002429 return;
2430 }
2431
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302432 qdf_mem_zero(frame, frame_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002433
2434 /* Prepare BD */
2435 lim_populate_mac_header(mac_ctx, frame, SIR_MAC_MGMT_FRAME,
2436 SIR_MAC_MGMT_AUTH, peer_addr, session->selfMacAddr);
2437 mac_hdr = (tpSirMacMgmtHdr) frame;
yeshwanth sriram guntuka343a3f22017-07-27 18:30:18 +05302438 if (wep_challenge_len)
2439 mac_hdr->fc.wep = LIM_WEP_IN_FC;
2440 else
2441 mac_hdr->fc.wep = LIM_NO_WEP_IN_FC;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002442
2443 /* Prepare BSSId */
Rajeev Kumarcf835a02016-04-15 15:01:31 -07002444 if (LIM_IS_AP_ROLE(session))
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302445 qdf_mem_copy((uint8_t *) mac_hdr->bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002446 (uint8_t *) session->bssId,
2447 sizeof(tSirMacAddr));
2448
2449 /* Prepare Authentication frame body */
2450 body = frame + sizeof(tSirMacMgmtHdr);
2451
yeshwanth sriram guntuka343a3f22017-07-27 18:30:18 +05302452 if (wep_challenge_len) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302453 qdf_mem_copy(body, (uint8_t *) auth_frame, body_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002454
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002455 pe_debug("Sending Auth seq# 3 to " MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002456 MAC_ADDR_ARRAY(mac_hdr->da));
2457
2458 } else {
2459 *((uint16_t *) (body)) =
2460 sir_swap_u16if_needed(auth_frame->authAlgoNumber);
2461 body += sizeof(uint16_t);
2462 body_len -= sizeof(uint16_t);
2463
2464 *((uint16_t *) (body)) =
2465 sir_swap_u16if_needed(
2466 auth_frame->authTransactionSeqNumber);
2467 body += sizeof(uint16_t);
2468 body_len -= sizeof(uint16_t);
2469
2470 *((uint16_t *) (body)) =
2471 sir_swap_u16if_needed(auth_frame->authStatusCode);
2472 body += sizeof(uint16_t);
2473 body_len -= sizeof(uint16_t);
Krishna Kumaar Natarajan0517c602017-06-02 14:58:21 -07002474
2475 if (challenge_req) {
2476 if (body_len < SIR_MAC_AUTH_CHALLENGE_BODY_LEN) {
Himanshu Agarwalc422ca72017-09-19 11:07:36 +05302477 /* copy challenge IE id, len, challenge text */
2478 *body = auth_frame->type;
2479 body++;
2480 body_len -= sizeof(uint8_t);
2481 *body = auth_frame->length;
2482 body++;
2483 body_len -= sizeof(uint8_t);
2484 qdf_mem_copy(body, auth_frame->challengeText,
Krishna Kumaar Natarajan0517c602017-06-02 14:58:21 -07002485 body_len);
2486 pe_err("Incomplete challenge info: length: %d, expected: %d",
2487 body_len,
2488 SIR_MAC_AUTH_CHALLENGE_BODY_LEN);
2489 body += body_len;
2490 body_len = 0;
2491 } else {
2492 /* copy challenge IE id, len, challenge text */
2493 *body = auth_frame->type;
2494 body++;
2495 *body = auth_frame->length;
2496 body++;
2497 qdf_mem_copy(body, auth_frame->challengeText,
yeshwanth sriram guntuka5c71a292017-08-24 15:51:19 +05302498 SIR_MAC_SAP_AUTH_CHALLENGE_LENGTH);
2499 body += SIR_MAC_SAP_AUTH_CHALLENGE_LENGTH;
Krishna Kumaar Natarajan0517c602017-06-02 14:58:21 -07002500
yeshwanth sriram guntuka5c71a292017-08-24 15:51:19 +05302501 body_len -= SIR_MAC_SAP_AUTH_CHALLENGE_LENGTH +
2502 SIR_MAC_CHALLENGE_ID_LEN;
Krishna Kumaar Natarajan0517c602017-06-02 14:58:21 -07002503 }
2504 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002505
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002506 if ((auth_frame->authAlgoNumber == eSIR_FT_AUTH) &&
2507 (auth_frame->authTransactionSeqNumber ==
2508 SIR_MAC_AUTH_FRAME_1) &&
2509 (session->ftPEContext.pFTPreAuthReq != NULL)) {
2510
2511 if (ft_ies_length > 0) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302512 qdf_mem_copy(body,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002513 session->ftPEContext.
2514 pFTPreAuthReq->ft_ies,
2515 ft_ies_length);
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002516 pe_debug("Auth1 Frame FTIE is: ");
Srinivas Girigowdab896a562017-03-16 17:41:26 -07002517 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_PE,
2518 QDF_TRACE_LEVEL_DEBUG,
2519 (uint8_t *) body,
2520 ft_ies_length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002521 } else if (NULL != session->ftPEContext.
2522 pFTPreAuthReq->pbssDescription) {
2523 /* MDID attr is 54 */
2524 *body = SIR_MDIE_ELEMENT_ID;
2525 body++;
2526 *body = SIR_MDIE_SIZE;
2527 body++;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302528 qdf_mem_copy(body,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002529 &session->ftPEContext.pFTPreAuthReq->
2530 pbssDescription->mdie[0],
2531 SIR_MDIE_SIZE);
2532 }
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +05302533 } else if (auth_frame->authAlgoNumber ==
Varun Reddy Yeturu5faa1772017-10-23 11:22:01 -07002534 SIR_FILS_SK_WITHOUT_PFS) {
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +05302535 /* TODO MDIE */
2536 pe_debug("appending fils Auth data");
2537 lim_add_fils_data_to_auth_frame(session, body);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002538 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002539
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002540 pe_debug("*** Sending Auth seq# %d status %d (%d) to "
2541 MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002542 auth_frame->authTransactionSeqNumber,
2543 auth_frame->authStatusCode,
2544 (auth_frame->authStatusCode ==
2545 eSIR_MAC_SUCCESS_STATUS),
2546 MAC_ADDR_ARRAY(mac_hdr->da));
2547 }
Srinivas Girigowdab896a562017-03-16 17:41:26 -07002548 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_PE,
2549 QDF_TRACE_LEVEL_DEBUG,
2550 frame, frame_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002551
Deepthi Gowri1de51e32016-09-01 15:47:28 +05302552 if ((NULL != session->ftPEContext.pFTPreAuthReq) &&
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08002553 (BAND_5G == lim_get_rf_band(
Deepthi Gowri1de51e32016-09-01 15:47:28 +05302554 session->ftPEContext.pFTPreAuthReq->preAuthchannelNum)))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002555 tx_flag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08002556 else if ((BAND_5G ==
Deepthi Gowri1de51e32016-09-01 15:47:28 +05302557 lim_get_rf_band(session->currentOperChannel))
2558 || (session->pePersona == QDF_P2P_CLIENT_MODE)
2559 || (session->pePersona == QDF_P2P_GO_MODE))
2560 tx_flag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002561
Anurag Chouhan6d760662016-02-20 16:05:43 +05302562 if (session->pePersona == QDF_P2P_CLIENT_MODE ||
2563 session->pePersona == QDF_STA_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002564 tx_flag |= HAL_USE_PEER_STA_REQUESTED_MASK;
2565
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302566 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002567 session->peSessionId, mac_hdr->fc.subType));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002568
Abhishek Singhdd2cb572017-08-11 11:10:19 +05302569 mac_ctx->auth_ack_status = LIM_AUTH_ACK_NOT_RCD;
Naveen Rawat296a5182017-09-25 14:02:48 -07002570 min_rid = lim_get_min_session_txrate(session);
Krunal Sonic65fc492018-03-09 15:53:28 -08002571 lim_diag_mgmt_tx_event_report(mac_ctx, mac_hdr,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07002572 session, QDF_STATUS_SUCCESS, QDF_STATUS_SUCCESS);
Abhishek Singhdd2cb572017-08-11 11:10:19 +05302573 qdf_status = wma_tx_frameWithTxComplete(mac_ctx, packet,
2574 (uint16_t)frame_len,
2575 TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS,
2576 7, lim_tx_complete, frame,
2577 lim_auth_tx_complete_cnf,
Naveen Rawat296a5182017-09-25 14:02:48 -07002578 tx_flag, sme_sessionid, false, 0, min_rid);
Abhishek Singhdd2cb572017-08-11 11:10:19 +05302579 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
2580 session->peSessionId, qdf_status));
2581 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
2582 pe_err("*** Could not send Auth frame, retCode=%X ***",
2583 qdf_status);
2584 mac_ctx->auth_ack_status = LIM_AUTH_ACK_RCD_FAILURE;
2585 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_AUTH_ACK_EVENT,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07002586 session, SENT_FAIL, QDF_STATUS_E_FAILURE);
Abhishek Singhdd2cb572017-08-11 11:10:19 +05302587 /* Pkt will be freed up by the callback */
Abhishek Singh7d3bc3e2016-02-03 17:45:01 +05302588 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002589 return;
2590}
2591
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002592QDF_STATUS lim_send_deauth_cnf(tpAniSirGlobal mac_ctx)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002593{
2594 uint16_t aid;
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002595 tpDphHashNode sta_ds;
2596 tLimMlmDeauthReq *deauth_req;
2597 tLimMlmDeauthCnf deauth_cnf;
2598 tpPESession session_entry;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002599
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002600 deauth_req = mac_ctx->lim.limDisassocDeauthCnfReq.pMlmDeauthReq;
2601 if (deauth_req) {
2602 if (tx_timer_running(
2603 &mac_ctx->lim.limTimers.gLimDeauthAckTimer))
2604 lim_deactivate_and_change_timer(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002605 eLIM_DEAUTH_ACK_TIMER);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002606
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002607 session_entry = pe_find_session_by_session_id(mac_ctx,
2608 deauth_req->sessionId);
2609 if (session_entry == NULL) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002610 pe_err("session does not exist for given sessionId");
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002611 deauth_cnf.resultCode =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002612 eSIR_SME_INVALID_PARAMETERS;
2613 goto end;
2614 }
2615
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002616 sta_ds =
2617 dph_lookup_hash_entry(mac_ctx,
2618 deauth_req->peer_macaddr.bytes,
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002619 &aid,
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002620 &session_entry->dph.dphHashTable);
2621 if (sta_ds == NULL) {
2622 deauth_cnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002623 goto end;
2624 }
2625
2626 /* / Receive path cleanup with dummy packet */
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002627 lim_ft_cleanup_pre_auth_info(mac_ctx, session_entry);
2628 lim_cleanup_rx_path(mac_ctx, sta_ds, session_entry);
2629 if ((session_entry->limSystemRole == eLIM_STA_ROLE) &&
2630 (
Abhishek Singhe0680852015-12-16 14:28:48 +05302631#ifdef FEATURE_WLAN_ESE
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002632 (session_entry->isESEconnection) ||
Abhishek Singhe0680852015-12-16 14:28:48 +05302633#endif
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002634 (session_entry->isFastRoamIniFeatureEnabled) ||
2635 (session_entry->is11Rconnection))) {
Jeff Johnson11bd4f32017-09-18 08:15:17 -07002636 pe_debug("FT Preauth (%pK,%d) Deauth rc %d src = %d",
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002637 session_entry,
2638 session_entry->peSessionId,
2639 deauth_req->reasonCode,
2640 deauth_req->deauthTrigger);
2641 lim_ft_cleanup(mac_ctx, session_entry);
Deepak Dhamdhere262d95a2016-01-10 16:36:53 -08002642 } else {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002643 pe_debug("No FT Preauth Session Cleanup in role %d"
Deepak Dhamdhere262d95a2016-01-10 16:36:53 -08002644#ifdef FEATURE_WLAN_ESE
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002645 " isESE %d"
Deepak Dhamdhere262d95a2016-01-10 16:36:53 -08002646#endif
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002647 " isLFR %d"
2648 " is11r %d, Deauth reason %d Trigger = %d",
2649 session_entry->limSystemRole,
Deepak Dhamdhere262d95a2016-01-10 16:36:53 -08002650#ifdef FEATURE_WLAN_ESE
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002651 session_entry->isESEconnection,
Deepak Dhamdhere262d95a2016-01-10 16:36:53 -08002652#endif
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002653 session_entry->isFastRoamIniFeatureEnabled,
2654 session_entry->is11Rconnection,
2655 deauth_req->reasonCode,
2656 deauth_req->deauthTrigger);
Deepak Dhamdhere262d95a2016-01-10 16:36:53 -08002657 }
2658 /* Free up buffer allocated for mlmDeauthReq */
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002659 qdf_mem_free(deauth_req);
2660 mac_ctx->lim.limDisassocDeauthCnfReq.pMlmDeauthReq = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002661 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302662 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002663end:
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002664 qdf_copy_macaddr(&deauth_cnf.peer_macaddr,
2665 &deauth_req->peer_macaddr);
2666 deauth_cnf.deauthTrigger = deauth_req->deauthTrigger;
2667 deauth_cnf.aid = deauth_req->aid;
2668 deauth_cnf.sessionId = deauth_req->sessionId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002669
2670 /* Free up buffer allocated */
2671 /* for mlmDeauthReq */
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002672 qdf_mem_free(deauth_req);
2673 mac_ctx->lim.limDisassocDeauthCnfReq.pMlmDeauthReq = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002674
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002675 lim_post_sme_message(mac_ctx,
2676 LIM_MLM_DEAUTH_CNF, (uint32_t *) &deauth_cnf);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302677 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002678}
2679
2680/**
2681 * lim_send_disassoc_cnf() - Send disassoc confirmation to SME
2682 *
2683 * @mac_ctx: Handle to MAC context
2684 *
2685 * Sends disassoc confirmation to SME. Removes disassoc request stored
2686 * in lim.
2687 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302688 * Return: QDF_STATUS_SUCCESS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002689 */
2690
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302691QDF_STATUS lim_send_disassoc_cnf(tpAniSirGlobal mac_ctx)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002692{
2693 uint16_t aid;
2694 tpDphHashNode sta_ds;
2695 tLimMlmDisassocCnf disassoc_cnf;
2696 tpPESession pe_session;
2697 tLimMlmDisassocReq *disassoc_req;
2698
2699 disassoc_req = mac_ctx->lim.limDisassocDeauthCnfReq.pMlmDisassocReq;
2700 if (disassoc_req) {
2701 if (tx_timer_running(
2702 &mac_ctx->lim.limTimers.gLimDisassocAckTimer))
2703 lim_deactivate_and_change_timer(mac_ctx,
2704 eLIM_DISASSOC_ACK_TIMER);
2705
2706 pe_session = pe_find_session_by_session_id(
2707 mac_ctx, disassoc_req->sessionId);
2708 if (pe_session == NULL) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002709 pe_err("No session for given sessionId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002710 disassoc_cnf.resultCode =
2711 eSIR_SME_INVALID_PARAMETERS;
2712 goto end;
2713 }
2714
2715 sta_ds = dph_lookup_hash_entry(mac_ctx,
Srinivas Girigowdadd3c5132016-01-05 19:41:27 -08002716 disassoc_req->peer_macaddr.bytes, &aid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002717 &pe_session->dph.dphHashTable);
2718 if (sta_ds == NULL) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002719 pe_err("StaDs Null");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002720 disassoc_cnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
2721 goto end;
2722 }
2723 /* Receive path cleanup with dummy packet */
Jeff Johnson0301ecb2018-06-29 09:36:23 -07002724 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002725 lim_cleanup_rx_path(mac_ctx, sta_ds, pe_session)) {
2726 disassoc_cnf.resultCode =
2727 eSIR_SME_RESOURCES_UNAVAILABLE;
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002728 pe_err("cleanup_rx_path error");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002729 goto end;
2730 }
Deepak Dhamdhere57c95ff2016-09-30 16:44:44 -07002731 if (LIM_IS_STA_ROLE(pe_session) &&
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002732 (disassoc_req->reasonCode !=
2733 eSIR_MAC_DISASSOC_DUE_TO_FTHANDOFF_REASON)) {
Jeff Johnson11bd4f32017-09-18 08:15:17 -07002734 pe_debug("FT Preauth Session (%pK %d) Clean up",
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002735 pe_session, pe_session->peSessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002736
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002737 /* Delete FT session if there exists one */
2738 lim_ft_cleanup_pre_auth_info(mac_ctx, pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002739 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002740 /* Free up buffer allocated for mlmDisassocReq */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302741 qdf_mem_free(disassoc_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002742 mac_ctx->lim.limDisassocDeauthCnfReq.pMlmDisassocReq = NULL;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302743 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002744 } else {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302745 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002746 }
2747end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302748 qdf_mem_copy((uint8_t *) &disassoc_cnf.peerMacAddr,
Srinivas Girigowdadd3c5132016-01-05 19:41:27 -08002749 (uint8_t *) disassoc_req->peer_macaddr.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05302750 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002751 disassoc_cnf.aid = disassoc_req->aid;
2752 disassoc_cnf.disassocTrigger = disassoc_req->disassocTrigger;
2753
2754 /* Update PE session ID */
2755 disassoc_cnf.sessionId = disassoc_req->sessionId;
2756
2757 if (disassoc_req != NULL) {
2758 /* / Free up buffer allocated for mlmDisassocReq */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302759 qdf_mem_free(disassoc_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002760 mac_ctx->lim.limDisassocDeauthCnfReq.pMlmDisassocReq = NULL;
2761 }
2762
2763 lim_post_sme_message(mac_ctx, LIM_MLM_DISASSOC_CNF,
2764 (uint32_t *) &disassoc_cnf);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302765 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002766}
2767
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05302768QDF_STATUS lim_disassoc_tx_complete_cnf(void *context,
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002769 uint32_t tx_success,
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05302770 void *params)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002771{
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002772 tpAniSirGlobal max_ctx = (tpAniSirGlobal)context;
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05302773
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002774 pe_debug("tx_success: %d", tx_success);
2775
2776 return lim_send_disassoc_cnf(max_ctx);
2777}
2778
2779static QDF_STATUS lim_disassoc_tx_complete_cnf_handler(void *context,
2780 qdf_nbuf_t buf,
2781 uint32_t tx_success,
2782 void *params)
2783{
2784 tpAniSirGlobal max_ctx = (tpAniSirGlobal)context;
2785 QDF_STATUS status_code;
2786 struct scheduler_msg msg = {0};
2787
2788 pe_debug("tx_success: %d", tx_success);
Himanshu Agarwal8b472bc2017-01-20 20:49:41 +05302789
2790 if (buf)
2791 qdf_nbuf_free(buf);
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002792 msg.type = (uint16_t) WMA_DISASSOC_TX_COMP;
2793 msg.bodyptr = params;
2794 msg.bodyval = tx_success;
Himanshu Agarwal8b472bc2017-01-20 20:49:41 +05302795
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002796 status_code = lim_post_msg_high_priority(max_ctx, &msg);
2797 if (status_code != QDF_STATUS_SUCCESS)
2798 pe_err("posting message: %X to LIM failed, reason: %d",
2799 msg.type, status_code);
2800 return status_code;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002801}
2802
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05302803QDF_STATUS lim_deauth_tx_complete_cnf(void *context,
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002804 uint32_t tx_success,
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05302805 void *params)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002806{
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002807 tpAniSirGlobal mac_ctx = (tpAniSirGlobal)context;
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05302808
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002809 pe_debug("tx_success: %d", tx_success);
2810
2811 return lim_send_deauth_cnf(mac_ctx);
2812}
2813
2814static QDF_STATUS lim_deauth_tx_complete_cnf_handler(void *context,
2815 qdf_nbuf_t buf,
2816 uint32_t tx_success,
2817 void *params)
2818{
2819 tpAniSirGlobal mac_ctx = (tpAniSirGlobal)context;
2820 QDF_STATUS status_code;
2821 struct scheduler_msg msg = {0};
2822
2823 pe_debug("tx_success: %d", tx_success);
Himanshu Agarwal8b472bc2017-01-20 20:49:41 +05302824
2825 if (buf)
2826 qdf_nbuf_free(buf);
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002827 msg.type = (uint16_t) WMA_DEAUTH_TX_COMP;
2828 msg.bodyptr = params;
2829 msg.bodyval = tx_success;
Himanshu Agarwal8b472bc2017-01-20 20:49:41 +05302830
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002831 status_code = lim_post_msg_high_priority(mac_ctx, &msg);
2832 if (status_code != QDF_STATUS_SUCCESS)
2833 pe_err("posting message: %X to LIM failed, reason: %d",
2834 msg.type, status_code);
2835 return status_code;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002836}
2837
2838/**
2839 * \brief This function is called to send Disassociate frame.
2840 *
2841 *
2842 * \param pMac Pointer to Global MAC structure
2843 *
2844 * \param nReason Indicates the reason that need to be sent in
2845 * Disassociation frame
2846 *
2847 * \param peerMacAddr MAC address of the STA to which Disassociation frame is
2848 * sent
2849 *
2850 *
2851 */
2852
2853void
2854lim_send_disassoc_mgmt_frame(tpAniSirGlobal pMac,
2855 uint16_t nReason,
2856 tSirMacAddr peer,
2857 tpPESession psessionEntry, bool waitForAck)
2858{
2859 tDot11fDisassociation frm;
2860 uint8_t *pFrame;
2861 tpSirMacMgmtHdr pMacHdr;
2862 uint32_t nBytes, nPayload, nStatus;
2863 void *pPacket;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302864 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002865 uint8_t txFlag = 0;
2866 uint32_t val = 0;
2867 uint8_t smeSessionId = 0;
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07002868
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002869 if (NULL == psessionEntry) {
2870 return;
2871 }
2872
2873 /*
2874 * In case when cac timer is running for this SAP session then
2875 * avoid sending disassoc out. It is violation of dfs specification.
2876 */
Anurag Chouhan6d760662016-02-20 16:05:43 +05302877 if (((psessionEntry->pePersona == QDF_SAP_MODE) ||
2878 (psessionEntry->pePersona == QDF_P2P_GO_MODE)) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002879 (true == pMac->sap.SapDfsInfo.is_dfs_cac_timer_running)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302880 QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_INFO,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002881 FL
2882 ("CAC timer is running, drop disassoc from going out"));
2883 return;
2884 }
2885 smeSessionId = psessionEntry->smeSessionId;
2886
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302887 qdf_mem_set((uint8_t *) &frm, sizeof(frm), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002888
2889 frm.Reason.code = nReason;
2890
2891 nStatus = dot11f_get_packed_disassociation_size(pMac, &frm, &nPayload);
2892 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002893 pe_err("Failed to calculate the packed size for a Disassociation (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002894 nStatus);
2895 /* We'll fall back on the worst case scenario: */
2896 nPayload = sizeof(tDot11fDisassociation);
2897 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002898 pe_warn("There were warnings while calculating the packed size for a Disassociation (0x%08x)",
2899 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002900 }
2901
2902 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
2903
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302904 qdf_status = cds_packet_alloc((uint16_t) nBytes, (void **)&pFrame,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002905 (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302906 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002907 pe_err("Failed to allocate %d bytes for a Disassociation",
2908 nBytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002909 return;
2910 }
2911 /* Paranoia: */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302912 qdf_mem_set(pFrame, nBytes, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002913
2914 /* Next, we fill out the buffer descriptor: */
2915 lim_populate_mac_header(pMac, pFrame, SIR_MAC_MGMT_FRAME,
2916 SIR_MAC_MGMT_DISASSOC, peer, psessionEntry->selfMacAddr);
2917 pMacHdr = (tpSirMacMgmtHdr) pFrame;
2918
2919 /* Prepare the BSSID */
2920 sir_copy_mac_addr(pMacHdr->bssId, psessionEntry->bssId);
2921
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002922 lim_set_protected_bit(pMac, psessionEntry, peer, pMacHdr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002923
2924 nStatus = dot11f_pack_disassociation(pMac, &frm, pFrame +
2925 sizeof(tSirMacMgmtHdr),
2926 nPayload, &nPayload);
2927 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002928 pe_err("Failed to pack a Disassociation (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002929 nStatus);
2930 cds_packet_free((void *)pPacket);
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002931 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002932 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002933 pe_warn("There were warnings while packing a Disassociation (0x%08x)",
2934 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002935 }
2936
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002937 pe_debug("***Sessionid %d Sending Disassociation frame with "
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002938 "reason %u and waitForAck %d to " MAC_ADDRESS_STR " ,From "
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002939 MAC_ADDRESS_STR, psessionEntry->peSessionId, nReason,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002940 waitForAck, MAC_ADDR_ARRAY(pMacHdr->da),
2941 MAC_ADDR_ARRAY(psessionEntry->selfMacAddr));
2942
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08002943 if ((BAND_5G == lim_get_rf_band(psessionEntry->currentOperChannel))
Anurag Chouhan6d760662016-02-20 16:05:43 +05302944 || (psessionEntry->pePersona == QDF_P2P_CLIENT_MODE) ||
2945 (psessionEntry->pePersona == QDF_P2P_GO_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002946 ) {
2947 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
2948 }
2949
Sushant Kaushik46556062015-12-02 16:57:47 +05302950 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002951
2952 if (waitForAck) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302953 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002954 psessionEntry->peSessionId,
2955 pMacHdr->fc.subType));
Krunal Sonic65fc492018-03-09 15:53:28 -08002956 lim_diag_mgmt_tx_event_report(pMac, pMacHdr,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07002957 psessionEntry, QDF_STATUS_SUCCESS,
2958 QDF_STATUS_SUCCESS);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002959 /* Queue Disassociation frame in high priority WQ */
2960 /* get the duration from the request */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302961 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002962 wma_tx_frameWithTxComplete(pMac, pPacket, (uint16_t) nBytes,
2963 TXRX_FRM_802_11_MGMT,
2964 ANI_TXDIR_TODS, 7, lim_tx_complete,
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002965 pFrame, lim_disassoc_tx_complete_cnf_handler,
Naveen Rawat296a5182017-09-25 14:02:48 -07002966 txFlag, smeSessionId, false, 0,
2967 RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302968 MTRACE(qdf_trace
Anurag Chouhan6d760662016-02-20 16:05:43 +05302969 (QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302970 psessionEntry->peSessionId, qdf_status));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002971
2972 val = SYS_MS_TO_TICKS(LIM_DISASSOC_DEAUTH_ACK_TIMEOUT);
2973
2974 if (tx_timer_change
2975 (&pMac->lim.limTimers.gLimDisassocAckTimer, val, 0)
2976 != TX_SUCCESS) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002977 pe_err("Unable to change Disassoc ack Timer val");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002978 return;
2979 } else if (TX_SUCCESS !=
2980 tx_timer_activate(&pMac->lim.limTimers.
2981 gLimDisassocAckTimer)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002982 pe_err("Unable to activate Disassoc ack Timer");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002983 lim_deactivate_and_change_timer(pMac,
2984 eLIM_DISASSOC_ACK_TIMER);
2985 return;
2986 }
2987 } else {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302988 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002989 psessionEntry->peSessionId,
2990 pMacHdr->fc.subType));
Krunal Sonic65fc492018-03-09 15:53:28 -08002991 lim_diag_mgmt_tx_event_report(pMac, pMacHdr,
2992 psessionEntry,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07002993 QDF_STATUS_SUCCESS, QDF_STATUS_SUCCESS);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002994 /* Queue Disassociation frame in high priority WQ */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302995 qdf_status = wma_tx_frame(pMac, pPacket, (uint16_t) nBytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002996 TXRX_FRM_802_11_MGMT,
2997 ANI_TXDIR_TODS,
2998 7,
2999 lim_tx_complete, pFrame, txFlag,
Naveen Rawat296a5182017-09-25 14:02:48 -07003000 smeSessionId, 0, RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303001 MTRACE(qdf_trace
Anurag Chouhan6d760662016-02-20 16:05:43 +05303002 (QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303003 psessionEntry->peSessionId, qdf_status));
3004 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003005 pe_err("Failed to send Disassociation (%X)!",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303006 qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003007 /* Pkt will be freed up by the callback */
3008 }
3009 }
3010} /* End lim_send_disassoc_mgmt_frame. */
3011
3012/**
3013 * \brief This function is called to send a Deauthenticate frame
3014 *
3015 *
3016 * \param pMac Pointer to global MAC structure
3017 *
3018 * \param nReason Indicates the reason that need to be sent in the
3019 * Deauthenticate frame
3020 *
3021 * \param peeer address of the STA to which the frame is to be sent
3022 *
3023 *
3024 */
3025
3026void
3027lim_send_deauth_mgmt_frame(tpAniSirGlobal pMac,
3028 uint16_t nReason,
3029 tSirMacAddr peer,
3030 tpPESession psessionEntry, bool waitForAck)
3031{
3032 tDot11fDeAuth frm;
3033 uint8_t *pFrame;
3034 tpSirMacMgmtHdr pMacHdr;
3035 uint32_t nBytes, nPayload, nStatus;
3036 void *pPacket;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303037 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003038 uint8_t txFlag = 0;
3039 uint32_t val = 0;
3040#ifdef FEATURE_WLAN_TDLS
3041 uint16_t aid;
3042 tpDphHashNode pStaDs;
3043#endif
3044 uint8_t smeSessionId = 0;
3045
3046 if (NULL == psessionEntry) {
3047 return;
3048 }
3049
3050 /*
3051 * In case when cac timer is running for this SAP session then
3052 * avoid deauth frame out. It is violation of dfs specification.
3053 */
Anurag Chouhan6d760662016-02-20 16:05:43 +05303054 if (((psessionEntry->pePersona == QDF_SAP_MODE) ||
3055 (psessionEntry->pePersona == QDF_P2P_GO_MODE)) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003056 (true == pMac->sap.SapDfsInfo.is_dfs_cac_timer_running)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303057 QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_INFO,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003058 FL
3059 ("CAC timer is running, drop the deauth from going out"));
3060 return;
3061 }
3062 smeSessionId = psessionEntry->smeSessionId;
3063
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303064 qdf_mem_set((uint8_t *) &frm, sizeof(frm), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003065
3066 frm.Reason.code = nReason;
3067
3068 nStatus = dot11f_get_packed_de_auth_size(pMac, &frm, &nPayload);
3069 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003070 pe_err("Failed to calculate the packed size for a De-Authentication (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003071 nStatus);
3072 /* We'll fall back on the worst case scenario: */
3073 nPayload = sizeof(tDot11fDeAuth);
3074 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003075 pe_warn("There were warnings while calculating the packed size for a De-Authentication (0x%08x)",
3076 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003077 }
3078
3079 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
3080
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303081 qdf_status = cds_packet_alloc((uint16_t) nBytes, (void **)&pFrame,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003082 (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303083 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003084 pe_err("Failed to allocate %d bytes for a De-Authentication",
3085 nBytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003086 return;
3087 }
3088 /* Paranoia: */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303089 qdf_mem_set(pFrame, nBytes, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003090
3091 /* Next, we fill out the buffer descriptor: */
3092 lim_populate_mac_header(pMac, pFrame, SIR_MAC_MGMT_FRAME,
3093 SIR_MAC_MGMT_DEAUTH, peer, psessionEntry->selfMacAddr);
3094 pMacHdr = (tpSirMacMgmtHdr) pFrame;
3095
3096 /* Prepare the BSSID */
3097 sir_copy_mac_addr(pMacHdr->bssId, psessionEntry->bssId);
3098
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003099 lim_set_protected_bit(pMac, psessionEntry, peer, pMacHdr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003100
3101 nStatus = dot11f_pack_de_auth(pMac, &frm, pFrame +
3102 sizeof(tSirMacMgmtHdr), nPayload, &nPayload);
3103 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003104 pe_err("Failed to pack a DeAuthentication (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003105 nStatus);
3106 cds_packet_free((void *)pPacket);
3107 return;
3108 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003109 pe_warn("There were warnings while packing a De-Authentication (0x%08x)",
3110 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003111 }
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003112 pe_debug("***Sessionid %d Sending Deauth frame with "
3113 "reason %u and waitForAck %d to " MAC_ADDRESS_STR
3114 " ,From " MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003115 psessionEntry->peSessionId, nReason, waitForAck,
3116 MAC_ADDR_ARRAY(pMacHdr->da),
3117 MAC_ADDR_ARRAY(psessionEntry->selfMacAddr));
3118
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08003119 if ((BAND_5G == lim_get_rf_band(psessionEntry->currentOperChannel))
Anurag Chouhan6d760662016-02-20 16:05:43 +05303120 || (psessionEntry->pePersona == QDF_P2P_CLIENT_MODE) ||
3121 (psessionEntry->pePersona == QDF_P2P_GO_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003122 ) {
3123 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
3124 }
3125
Sushant Kaushik46556062015-12-02 16:57:47 +05303126 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003127#ifdef FEATURE_WLAN_TDLS
3128 pStaDs =
3129 dph_lookup_hash_entry(pMac, peer, &aid,
3130 &psessionEntry->dph.dphHashTable);
3131#endif
3132
3133 if (waitForAck) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303134 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003135 psessionEntry->peSessionId,
3136 pMacHdr->fc.subType));
Krunal Sonic65fc492018-03-09 15:53:28 -08003137 lim_diag_mgmt_tx_event_report(pMac, pMacHdr,
3138 psessionEntry,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003139 QDF_STATUS_SUCCESS, QDF_STATUS_SUCCESS);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003140 /* Queue Disassociation frame in high priority WQ */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303141 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003142 wma_tx_frameWithTxComplete(pMac, pPacket, (uint16_t) nBytes,
3143 TXRX_FRM_802_11_MGMT,
3144 ANI_TXDIR_TODS, 7, lim_tx_complete,
Liangwei Dongc0b2e332017-11-16 06:04:46 -05003145 pFrame, lim_deauth_tx_complete_cnf_handler,
Naveen Rawat296a5182017-09-25 14:02:48 -07003146 txFlag, smeSessionId, false, 0,
3147 RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303148 MTRACE(qdf_trace
Anurag Chouhan6d760662016-02-20 16:05:43 +05303149 (QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303150 psessionEntry->peSessionId, qdf_status));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003151 /* Pkt will be freed up by the callback lim_tx_complete */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303152 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003153 pe_err("Failed to send De-Authentication (%X)!",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303154 qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003155
3156 /* Call lim_process_deauth_ack_timeout which will send
3157 * DeauthCnf for this frame
3158 */
3159 lim_process_deauth_ack_timeout(pMac);
3160 return;
3161 }
3162
3163 val = SYS_MS_TO_TICKS(LIM_DISASSOC_DEAUTH_ACK_TIMEOUT);
3164
3165 if (tx_timer_change
3166 (&pMac->lim.limTimers.gLimDeauthAckTimer, val, 0)
3167 != TX_SUCCESS) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003168 pe_err("Unable to change Deauth ack Timer val");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003169 return;
3170 } else if (TX_SUCCESS !=
3171 tx_timer_activate(&pMac->lim.limTimers.
3172 gLimDeauthAckTimer)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003173 pe_err("Unable to activate Deauth ack Timer");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003174 lim_deactivate_and_change_timer(pMac,
3175 eLIM_DEAUTH_ACK_TIMER);
3176 return;
3177 }
3178 } else {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303179 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003180 psessionEntry->peSessionId,
3181 pMacHdr->fc.subType));
3182#ifdef FEATURE_WLAN_TDLS
3183 if ((NULL != pStaDs)
3184 && (STA_ENTRY_TDLS_PEER == pStaDs->staType)) {
3185 /* Queue Disassociation frame in high priority WQ */
Krunal Sonic65fc492018-03-09 15:53:28 -08003186 lim_diag_mgmt_tx_event_report(pMac, pMacHdr,
3187 psessionEntry,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003188 QDF_STATUS_SUCCESS,
3189 QDF_STATUS_SUCCESS);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303190 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003191 wma_tx_frame(pMac, pPacket, (uint16_t) nBytes,
3192 TXRX_FRM_802_11_MGMT, ANI_TXDIR_IBSS,
3193 7, lim_tx_complete, pFrame, txFlag,
Naveen Rawat296a5182017-09-25 14:02:48 -07003194 smeSessionId, 0, RATEID_DEFAULT);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003195 } else {
3196#endif
Krunal Sonic65fc492018-03-09 15:53:28 -08003197 lim_diag_mgmt_tx_event_report(pMac, pMacHdr,
3198 psessionEntry,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003199 QDF_STATUS_SUCCESS,
3200 QDF_STATUS_SUCCESS);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003201 /* Queue Disassociation frame in high priority WQ */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303202 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003203 wma_tx_frame(pMac, pPacket, (uint16_t) nBytes,
3204 TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS,
3205 7, lim_tx_complete, pFrame, txFlag,
Naveen Rawat296a5182017-09-25 14:02:48 -07003206 smeSessionId, 0, RATEID_DEFAULT);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003207#ifdef FEATURE_WLAN_TDLS
3208 }
3209#endif
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303210 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303211 psessionEntry->peSessionId, qdf_status));
3212 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003213 pe_err("Failed to send De-Authentication (%X)!",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303214 qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003215 /* Pkt will be freed up by the callback */
3216 }
3217 }
3218
3219} /* End lim_send_deauth_mgmt_frame. */
3220
3221#ifdef ANI_SUPPORT_11H
3222/**
3223 * \brief Send a Measurement Report Action frame
3224 *
3225 *
3226 * \param pMac Pointer to the global MAC structure
3227 *
3228 * \param pMeasReqFrame Address of a tSirMacMeasReqActionFrame
3229 *
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003230 * \return QDF_STATUS_SUCCESS on success, QDF_STATUS_E_FAILURE else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003231 *
3232 *
3233 */
3234
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003235QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003236lim_send_meas_report_frame(tpAniSirGlobal pMac,
3237 tpSirMacMeasReqActionFrame pMeasReqFrame,
3238 tSirMacAddr peer, tpPESession psessionEntry)
3239{
3240 tDot11fMeasurementReport frm;
3241 uint8_t *pFrame;
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003242 QDF_STATUS nSirStatus;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003243 tpSirMacMgmtHdr pMacHdr;
3244 uint32_t nBytes, nPayload, nStatus;
3245 void *pPacket;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303246 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003247
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303248 qdf_mem_set((uint8_t *) &frm, sizeof(frm), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003249
3250 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
3251 frm.Action.action = SIR_MAC_ACTION_MEASURE_REPORT_ID;
3252 frm.DialogToken.token = pMeasReqFrame->actionHeader.dialogToken;
3253
3254 switch (pMeasReqFrame->measReqIE.measType) {
3255 case SIR_MAC_BASIC_MEASUREMENT_TYPE:
3256 nSirStatus =
3257 populate_dot11f_measurement_report0(pMac, pMeasReqFrame,
3258 &frm.MeasurementReport);
3259 break;
3260 case SIR_MAC_CCA_MEASUREMENT_TYPE:
3261 nSirStatus =
3262 populate_dot11f_measurement_report1(pMac, pMeasReqFrame,
3263 &frm.MeasurementReport);
3264 break;
3265 case SIR_MAC_RPI_MEASUREMENT_TYPE:
3266 nSirStatus =
3267 populate_dot11f_measurement_report2(pMac, pMeasReqFrame,
3268 &frm.MeasurementReport);
3269 break;
3270 default:
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003271 pe_err("Unknown measurement type %d in limSen"
3272 "dMeasReportFrame",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003273 pMeasReqFrame->measReqIE.measType);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003274 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003275 }
3276
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003277 if (QDF_STATUS_SUCCESS != nSirStatus)
3278 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003279
3280 nStatus = dot11f_get_packed_measurement_report_size(pMac, &frm, &nPayload);
3281 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003282 pe_err("Failed to calculate the packed size for a Measurement Report (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003283 nStatus);
3284 /* We'll fall back on the worst case scenario: */
3285 nPayload = sizeof(tDot11fMeasurementReport);
3286 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003287 pe_warn("There were warnings while calculating the packed size for a Measurement Report (0x%08x)",
3288 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003289 }
3290
3291 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
3292
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303293 qdf_status =
Jeff Johnson6aaaa992018-06-30 10:43:04 -07003294 cds_packet_alloc(pMac->hdd_handle, TXRX_FRM_802_11_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003295 (uint16_t) nBytes, (void **)&pFrame,
3296 (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303297 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003298 pe_err("Failed to allocate %d bytes for a "
3299 "De-Authentication", nBytes);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003300 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003301 }
3302 /* Paranoia: */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303303 qdf_mem_set(pFrame, nBytes, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003304
3305 /* Next, we fill out the buffer descriptor: */
3306 lim_populate_mac_header(pMac, pFrame, SIR_MAC_MGMT_FRAME,
3307 SIR_MAC_MGMT_ACTION, peer);
3308 pMacHdr = (tpSirMacMgmtHdr) pFrame;
3309
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303310 qdf_mem_copy(pMacHdr->bssId, psessionEntry->bssId, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003311
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003312 lim_set_protected_bit(pMac, psessionEntry, peer, pMacHdr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003313
3314 nStatus = dot11f_pack_measurement_report(pMac, &frm, pFrame +
3315 sizeof(tSirMacMgmtHdr),
3316 nPayload, &nPayload);
3317 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003318 pe_err("Failed to pack a Measurement Report (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003319 nStatus);
Jeff Johnson6aaaa992018-06-30 10:43:04 -07003320 cds_packet_free(pMac->hdd_handle, TXRX_FRM_802_11_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003321 (void *)pFrame, (void *)pPacket);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003322 return QDF_STATUS_E_FAILURE; /* allocated! */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003323 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003324 pe_warn("There were warnings while packing a Measurement Report (0x%08x)",
3325 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003326 }
3327
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303328 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003329 ((psessionEntry) ? psessionEntry->
3330 peSessionId : NO_SESSION), pMacHdr->fc.subType));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303331 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003332 wma_tx_frame(pMac, pPacket, (uint16_t) nBytes,
3333 TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS, 7,
Naveen Rawat296a5182017-09-25 14:02:48 -07003334 lim_tx_complete, pFrame, 0, 0, RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303335 MTRACE(qdf_trace
Anurag Chouhan6d760662016-02-20 16:05:43 +05303336 (QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003337 ((psessionEntry) ? psessionEntry->peSessionId : NO_SESSION),
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303338 qdf_status));
3339 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003340 pe_err("Failed to send a Measurement Report (%X)!",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303341 qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003342 /* Pkt will be freed up by the callback */
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003343 return QDF_STATUS_E_FAILURE; /* just allocated... */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003344 }
3345
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003346 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003347
3348} /* End lim_send_meas_report_frame. */
3349
3350/**
3351 * \brief Send a TPC Request Action frame
3352 *
3353 *
3354 * \param pMac Pointer to the global MAC datastructure
3355 *
3356 * \param peer MAC address to which the frame should be sent
3357 *
3358 *
3359 */
3360
3361void
3362lim_send_tpc_request_frame(tpAniSirGlobal pMac,
3363 tSirMacAddr peer, tpPESession psessionEntry)
3364{
3365 tDot11fTPCRequest frm;
3366 uint8_t *pFrame;
3367 tpSirMacMgmtHdr pMacHdr;
3368 uint32_t nBytes, nPayload, nStatus;
3369 void *pPacket;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303370 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003371
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303372 qdf_mem_set((uint8_t *) &frm, sizeof(frm), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003373
3374 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
3375 frm.Action.action = SIR_MAC_ACTION_TPC_REQUEST_ID;
3376 frm.DialogToken.token = 1;
3377 frm.TPCRequest.present = 1;
3378
3379 nStatus = dot11f_get_packed_tpc_request_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 Request (0x%08x)", nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003382 /* We'll fall back on the worst case scenario: */
3383 nPayload = sizeof(tDot11fTPCRequest);
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 Request (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 =
Jeff Johnson6aaaa992018-06-30 10:43:04 -07003392 cds_packet_alloc(pMac->hdd_handle, TXRX_FRM_802_11_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003393 (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 " Request", nBytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003398 return;
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 pMacHdr = (tpSirMacMgmtHdr) pFrame;
3407
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303408 qdf_mem_copy(pMacHdr->bssId, psessionEntry->bssId, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003409
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003410 lim_set_protected_bit(pMac, psessionEntry, peer, pMacHdr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003411
3412 nStatus = dot11f_pack_tpc_request(pMac, &frm, pFrame +
3413 sizeof(tSirMacMgmtHdr),
3414 nPayload, &nPayload);
3415 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003416 pe_err("Failed to pack a TPC Request (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003417 nStatus);
Jeff Johnson6aaaa992018-06-30 10:43:04 -07003418 cds_packet_free(pMac->hdd_handle, TXRX_FRM_802_11_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003419 (void *)pFrame, (void *)pPacket);
3420 return; /* allocated! */
3421 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003422 pe_warn("There were warnings while packing a TPC Request (0x%08x)",
3423 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003424 }
3425
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303426 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003427 ((psessionEntry) ? psessionEntry->
3428 peSessionId : NO_SESSION), pMacHdr->fc.subType));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303429 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003430 wma_tx_frame(pMac, pPacket, (uint16_t) nBytes,
3431 TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS, 7,
Naveen Rawat296a5182017-09-25 14:02:48 -07003432 lim_tx_complete, pFrame, 0, 0, RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303433 MTRACE(qdf_trace
Anurag Chouhan6d760662016-02-20 16:05:43 +05303434 (QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003435 ((psessionEntry) ? psessionEntry->peSessionId : NO_SESSION),
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303436 qdf_status));
3437 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003438 pe_err("Failed to send a TPC Request (%X)!",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303439 qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003440 /* Pkt will be freed up by the callback */
3441 }
3442
3443} /* End lim_send_tpc_request_frame. */
3444
3445/**
3446 * \brief Send a TPC Report Action frame
3447 *
3448 *
3449 * \param pMac Pointer to the global MAC datastructure
3450 *
3451 * \param pTpcReqFrame Pointer to the received TPC Request
3452 *
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003453 * \return QDF_STATUS_SUCCESS on success, QDF_STATUS_E_FAILURE else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003454 *
3455 *
3456 */
3457
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003458QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003459lim_send_tpc_report_frame(tpAniSirGlobal pMac,
3460 tpSirMacTpcReqActionFrame pTpcReqFrame,
3461 tSirMacAddr peer, tpPESession psessionEntry)
3462{
3463 tDot11fTPCReport frm;
3464 uint8_t *pFrame;
3465 tpSirMacMgmtHdr pMacHdr;
3466 uint32_t nBytes, nPayload, nStatus;
3467 void *pPacket;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303468 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003469
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303470 qdf_mem_set((uint8_t *) &frm, sizeof(frm), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003471
3472 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
3473 frm.Action.action = SIR_MAC_ACTION_TPC_REPORT_ID;
3474 frm.DialogToken.token = pTpcReqFrame->actionHeader.dialogToken;
3475
3476 frm.TPCReport.tx_power = 0;
3477 frm.TPCReport.link_margin = 0;
3478 frm.TPCReport.present = 1;
3479
3480 nStatus = dot11f_get_packed_tpc_report_size(pMac, &frm, &nPayload);
3481 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003482 pe_err("Failed to calculate the packed size for a TPC Report (0x%08x)", nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003483 /* We'll fall back on the worst case scenario: */
3484 nPayload = sizeof(tDot11fTPCReport);
3485 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003486 pe_warn("There were warnings while calculating the packed size for a TPC Report (0x%08x)",
3487 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003488 }
3489
3490 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
3491
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303492 qdf_status =
Jeff Johnson6aaaa992018-06-30 10:43:04 -07003493 cds_packet_alloc(pMac->hdd_handle, TXRX_FRM_802_11_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003494 (uint16_t) nBytes, (void **)&pFrame,
3495 (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303496 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003497 pe_err("Failed to allocate %d bytes for a TPC"
3498 " Report", nBytes);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003499 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003500 }
3501 /* Paranoia: */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303502 qdf_mem_set(pFrame, nBytes, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003503
3504 /* Next, we fill out the buffer descriptor: */
3505 lim_populate_mac_header(pMac, pFrame, SIR_MAC_MGMT_FRAME,
3506 SIR_MAC_MGMT_ACTION, peer);
3507
3508 pMacHdr = (tpSirMacMgmtHdr) pFrame;
3509
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303510 qdf_mem_copy(pMacHdr->bssId, psessionEntry->bssId, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003511
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003512 lim_set_protected_bit(pMac, psessionEntry, peer, pMacHdr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003513
3514 nStatus = dot11f_pack_tpc_report(pMac, &frm, pFrame +
3515 sizeof(tSirMacMgmtHdr),
3516 nPayload, &nPayload);
3517 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003518 pe_err("Failed to pack a TPC Report (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003519 nStatus);
Jeff Johnson6aaaa992018-06-30 10:43:04 -07003520 cds_packet_free(pMac->hdd_handle, TXRX_FRM_802_11_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003521 (void *)pFrame, (void *)pPacket);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003522 return QDF_STATUS_E_FAILURE; /* allocated! */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003523 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003524 pe_warn("There were warnings while packing a TPC Report (0x%08x)",
3525 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003526
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303527 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003528 ((psessionEntry) ? psessionEntry->
3529 peSessionId : NO_SESSION), pMacHdr->fc.subType));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303530 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003531 wma_tx_frame(pMac, pPacket, (uint16_t) nBytes,
3532 TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS, 7,
Naveen Rawat296a5182017-09-25 14:02:48 -07003533 lim_tx_complete, pFrame, 0, 0, RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303534 MTRACE(qdf_trace
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003535 (QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
3536 ((psessionEntry) ? psessionEntry->peSessionId : NO_SESSION),
3537 qdf_status));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303538 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003539 pe_err("Failed to send a TPC Report (%X)!",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303540 qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003541 /* Pkt will be freed up by the callback */
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003542 return QDF_STATUS_E_FAILURE; /* just allocated... */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003543 }
3544
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003545 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003546
3547} /* End lim_send_tpc_report_frame. */
3548#endif /* ANI_SUPPORT_11H */
3549
3550/**
3551 * \brief Send a Channel Switch Announcement
3552 *
3553 *
3554 * \param pMac Pointer to the global MAC datastructure
3555 *
3556 * \param peer MAC address to which this frame will be sent
3557 *
3558 * \param nMode
3559 *
3560 * \param nNewChannel
3561 *
3562 * \param nCount
3563 *
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003564 * \return QDF_STATUS_SUCCESS on success, QDF_STATUS_E_FAILURE else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003565 *
3566 *
3567 */
3568
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003569QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003570lim_send_channel_switch_mgmt_frame(tpAniSirGlobal pMac,
3571 tSirMacAddr peer,
3572 uint8_t nMode,
3573 uint8_t nNewChannel,
3574 uint8_t nCount, tpPESession psessionEntry)
3575{
3576 tDot11fChannelSwitch frm;
3577 uint8_t *pFrame;
3578 tpSirMacMgmtHdr pMacHdr;
3579 uint32_t nBytes, nPayload, nStatus; /* , nCfg; */
3580 void *pPacket;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303581 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003582 uint8_t txFlag = 0;
3583
3584 uint8_t smeSessionId = 0;
3585
3586 if (psessionEntry == NULL) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003587 pe_err("Session entry is NULL!!!");
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003588 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003589 }
3590 smeSessionId = psessionEntry->smeSessionId;
3591
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303592 qdf_mem_set((uint8_t *) &frm, sizeof(frm), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003593
3594 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
3595 frm.Action.action = SIR_MAC_ACTION_CHANNEL_SWITCH_ID;
3596 frm.ChanSwitchAnn.switchMode = nMode;
3597 frm.ChanSwitchAnn.newChannel = nNewChannel;
3598 frm.ChanSwitchAnn.switchCount = nCount;
3599 frm.ChanSwitchAnn.present = 1;
3600
3601 nStatus = dot11f_get_packed_channel_switch_size(pMac, &frm, &nPayload);
3602 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003603 pe_err("Failed to calculate the packed size for a Channel Switch (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003604 nStatus);
3605 /* We'll fall back on the worst case scenario: */
3606 nPayload = sizeof(tDot11fChannelSwitch);
3607 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003608 pe_warn("There were warnings while calculating the packed size for a Channel Switch (0x%08x)",
3609 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003610 }
3611
3612 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
3613
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303614 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003615 cds_packet_alloc((uint16_t) nBytes, (void **)&pFrame,
3616 (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303617 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003618 pe_err("Failed to allocate %d bytes for a TPC Report", nBytes);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003619 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003620 }
3621 /* Paranoia: */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303622 qdf_mem_set(pFrame, nBytes, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003623
3624 /* Next, we fill out the buffer descriptor: */
3625 lim_populate_mac_header(pMac, pFrame, SIR_MAC_MGMT_FRAME,
3626 SIR_MAC_MGMT_ACTION, peer,
3627 psessionEntry->selfMacAddr);
3628 pMacHdr = (tpSirMacMgmtHdr) pFrame;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303629 qdf_mem_copy((uint8_t *) pMacHdr->bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003630 (uint8_t *) psessionEntry->bssId, sizeof(tSirMacAddr));
3631
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003632 lim_set_protected_bit(pMac, psessionEntry, peer, pMacHdr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003633
3634 nStatus = dot11f_pack_channel_switch(pMac, &frm, pFrame +
3635 sizeof(tSirMacMgmtHdr),
3636 nPayload, &nPayload);
3637 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003638 pe_err("Failed to pack a Channel Switch (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003639 nStatus);
3640 cds_packet_free((void *)pPacket);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003641 return QDF_STATUS_E_FAILURE; /* allocated! */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003642 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003643 pe_warn("There were warnings while packing a Channel Switch (0x%08x)",
3644 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003645 }
3646
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08003647 if ((BAND_5G == lim_get_rf_band(psessionEntry->currentOperChannel))
Anurag Chouhan6d760662016-02-20 16:05:43 +05303648 || (psessionEntry->pePersona == QDF_P2P_CLIENT_MODE) ||
3649 (psessionEntry->pePersona == QDF_P2P_GO_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003650 ) {
3651 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
3652 }
3653
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303654 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003655 psessionEntry->peSessionId, pMacHdr->fc.subType));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303656 qdf_status = wma_tx_frame(pMac, pPacket, (uint16_t) nBytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003657 TXRX_FRM_802_11_MGMT,
3658 ANI_TXDIR_TODS,
3659 7, lim_tx_complete, pFrame, txFlag,
Naveen Rawat296a5182017-09-25 14:02:48 -07003660 smeSessionId, 0, RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303661 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303662 psessionEntry->peSessionId, qdf_status));
3663 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003664 pe_err("Failed to send a Channel Switch (%X)!",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303665 qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003666 /* Pkt will be freed up by the callback */
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003667 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003668 }
3669
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003670 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003671
3672} /* End lim_send_channel_switch_mgmt_frame. */
3673
Abhishek Singh518323d2015-10-19 17:42:01 +05303674/**
3675 * lim_send_extended_chan_switch_action_frame()- function to send ECSA
3676 * action frame over the air .
3677 * @mac_ctx: pointer to global mac structure
3678 * @peer: Destination mac.
3679 * @mode: channel switch mode
3680 * @new_op_class: new op class
3681 * @new_channel: new channel to switch
3682 * @count: channel switch count
3683 *
3684 * This function is called to send ECSA frame.
3685 *
3686 * Return: success if frame is sent else return failure
3687 */
3688
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003689QDF_STATUS
Abhishek Singh518323d2015-10-19 17:42:01 +05303690lim_send_extended_chan_switch_action_frame(tpAniSirGlobal mac_ctx,
3691 tSirMacAddr peer, uint8_t mode, uint8_t new_op_class,
3692 uint8_t new_channel, uint8_t count, tpPESession session_entry)
3693{
3694 tDot11fext_channel_switch_action_frame frm;
3695 uint8_t *frame;
3696 tpSirMacMgmtHdr mac_hdr;
3697 uint32_t num_bytes, n_payload, status;
3698 void *packet;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303699 QDF_STATUS qdf_status;
Abhishek Singh518323d2015-10-19 17:42:01 +05303700 uint8_t txFlag = 0;
3701 uint8_t sme_session_id = 0;
Vignesh Viswanathan93b7f702017-12-19 17:48:45 +05303702 uint8_t ch_spacing;
3703 tLimWiderBWChannelSwitchInfo *wide_bw_ie;
Abhishek Singh518323d2015-10-19 17:42:01 +05303704
3705 if (session_entry == NULL) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003706 pe_err("Session entry is NULL!!!");
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003707 return QDF_STATUS_E_FAILURE;
Abhishek Singh518323d2015-10-19 17:42:01 +05303708 }
3709
3710 sme_session_id = session_entry->smeSessionId;
3711
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303712 qdf_mem_set(&frm, sizeof(frm), 0);
Abhishek Singh518323d2015-10-19 17:42:01 +05303713
3714 frm.Category.category = SIR_MAC_ACTION_PUBLIC_USAGE;
3715 frm.Action.action = SIR_MAC_ACTION_EXT_CHANNEL_SWITCH_ID;
3716
3717 frm.ext_chan_switch_ann_action.switch_mode = mode;
3718 frm.ext_chan_switch_ann_action.op_class = new_op_class;
3719 frm.ext_chan_switch_ann_action.new_channel = new_channel;
3720 frm.ext_chan_switch_ann_action.switch_count = count;
3721
Vignesh Viswanathan93b7f702017-12-19 17:48:45 +05303722 ch_spacing = wlan_reg_dmn_get_chanwidth_from_opclass(
3723 mac_ctx->scan.countryCodeCurrent, new_channel,
3724 new_op_class);
3725 pe_debug("wrapper: ch_spacing %hu", ch_spacing);
3726
3727 if ((ch_spacing == 80) || (ch_spacing == 160)) {
3728 wide_bw_ie = &session_entry->gLimWiderBWChannelSwitch;
3729 frm.WiderBWChanSwitchAnn.newChanWidth =
3730 wide_bw_ie->newChanWidth;
3731 frm.WiderBWChanSwitchAnn.newCenterChanFreq0 =
3732 wide_bw_ie->newCenterChanFreq0;
3733 frm.WiderBWChanSwitchAnn.newCenterChanFreq1 =
3734 wide_bw_ie->newCenterChanFreq1;
3735 frm.WiderBWChanSwitchAnn.present = 1;
3736 pe_debug("wrapper: width:%d f0:%d f1:%d",
3737 frm.WiderBWChanSwitchAnn.newChanWidth,
3738 frm.WiderBWChanSwitchAnn.newCenterChanFreq0,
3739 frm.WiderBWChanSwitchAnn.newCenterChanFreq1);
3740 }
Abhishek Singh518323d2015-10-19 17:42:01 +05303741
3742 status = dot11f_get_packed_ext_channel_switch_action_frame_size(mac_ctx,
3743 &frm, &n_payload);
3744 if (DOT11F_FAILED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003745 pe_err("Failed to get packed size for Channel Switch 0x%08x",
Abhishek Singh518323d2015-10-19 17:42:01 +05303746 status);
3747 /* We'll fall back on the worst case scenario*/
3748 n_payload = sizeof(tDot11fext_channel_switch_action_frame);
3749 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003750 pe_warn("There were warnings while calculating the packed size for a Ext Channel Switch (0x%08x)",
Abhishek Singh518323d2015-10-19 17:42:01 +05303751 status);
3752 }
3753
3754 num_bytes = n_payload + sizeof(tSirMacMgmtHdr);
3755
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303756 qdf_status = cds_packet_alloc((uint16_t)num_bytes,
Abhishek Singh518323d2015-10-19 17:42:01 +05303757 (void **) &frame, (void **) &packet);
3758
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303759 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003760 pe_err("Failed to allocate %d bytes for a Ext Channel Switch",
Abhishek Singh518323d2015-10-19 17:42:01 +05303761 num_bytes);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003762 return QDF_STATUS_E_FAILURE;
Abhishek Singh518323d2015-10-19 17:42:01 +05303763 }
3764
3765 /* Paranoia*/
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303766 qdf_mem_set(frame, num_bytes, 0);
Abhishek Singh518323d2015-10-19 17:42:01 +05303767
3768 /* Next, we fill out the buffer descriptor */
3769 lim_populate_mac_header(mac_ctx, frame, SIR_MAC_MGMT_FRAME,
3770 SIR_MAC_MGMT_ACTION, peer, session_entry->selfMacAddr);
3771 mac_hdr = (tpSirMacMgmtHdr) frame;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303772 qdf_mem_copy((uint8_t *) mac_hdr->bssId,
Abhishek Singh518323d2015-10-19 17:42:01 +05303773 (uint8_t *) session_entry->bssId,
3774 sizeof(tSirMacAddr));
3775
gaolez4b62a9e2018-08-16 15:57:50 +08003776 lim_set_protected_bit(mac_ctx, session_entry, peer, mac_hdr);
3777
Abhishek Singh518323d2015-10-19 17:42:01 +05303778 status = dot11f_pack_ext_channel_switch_action_frame(mac_ctx, &frm,
3779 frame + sizeof(tSirMacMgmtHdr), n_payload, &n_payload);
3780 if (DOT11F_FAILED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003781 pe_err("Failed to pack a Channel Switch 0x%08x", status);
Abhishek Singh518323d2015-10-19 17:42:01 +05303782 cds_packet_free((void *)packet);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003783 return QDF_STATUS_E_FAILURE;
Abhishek Singh518323d2015-10-19 17:42:01 +05303784 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003785 pe_warn("There were warnings while packing a Channel Switch 0x%08x",
Abhishek Singh518323d2015-10-19 17:42:01 +05303786 status);
3787 }
3788
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08003789 if ((BAND_5G ==
Abhishek Singh518323d2015-10-19 17:42:01 +05303790 lim_get_rf_band(session_entry->currentOperChannel)) ||
Anurag Chouhan6d760662016-02-20 16:05:43 +05303791 (session_entry->pePersona == QDF_P2P_CLIENT_MODE) ||
3792 (session_entry->pePersona == QDF_P2P_GO_MODE)) {
Abhishek Singh518323d2015-10-19 17:42:01 +05303793 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
3794 }
3795
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003796 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 +05303797 MAC_ADDR_ARRAY(mac_hdr->da),
3798 frm.ext_chan_switch_ann_action.switch_count,
3799 frm.ext_chan_switch_ann_action.switch_mode,
3800 frm.ext_chan_switch_ann_action.new_channel,
3801 frm.ext_chan_switch_ann_action.op_class);
3802
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303803 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Abhishek Singh518323d2015-10-19 17:42:01 +05303804 session_entry->peSessionId, mac_hdr->fc.subType));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303805 qdf_status = wma_tx_frame(mac_ctx, packet, (uint16_t) num_bytes,
Abhishek Singh518323d2015-10-19 17:42:01 +05303806 TXRX_FRM_802_11_MGMT,
3807 ANI_TXDIR_TODS,
3808 7,
3809 lim_tx_complete, frame,
Naveen Rawat296a5182017-09-25 14:02:48 -07003810 txFlag, sme_session_id, 0,
3811 RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303812 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303813 session_entry->peSessionId, qdf_status));
3814 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003815 pe_err("Failed to send a Ext Channel Switch %X!",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303816 qdf_status);
Abhishek Singh518323d2015-10-19 17:42:01 +05303817 /* Pkt will be freed up by the callback */
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003818 return QDF_STATUS_E_FAILURE;
Abhishek Singh518323d2015-10-19 17:42:01 +05303819 }
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003820 return QDF_STATUS_SUCCESS;
Abhishek Singh518323d2015-10-19 17:42:01 +05303821} /* End lim_send_extended_chan_switch_action_frame */
3822
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303823
3824/**
3825 * lim_oper_chan_change_confirm_tx_complete_cnf()- Confirmation for oper_chan_change_confirm
3826 * sent over the air
3827 *
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05303828 * @context: pointer to global mac
3829 * @buf: buffer
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303830 * @tx_complete : Sent status
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05303831 * @params: tx completion params
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303832 *
3833 * Return: This returns QDF_STATUS
3834 */
3835
3836static QDF_STATUS lim_oper_chan_change_confirm_tx_complete_cnf(
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05303837 void *context,
3838 qdf_nbuf_t buf,
3839 uint32_t tx_complete,
3840 void *params)
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303841{
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003842 pe_debug("tx_complete: %d", tx_complete);
Zhu Jianmin83e8b122018-05-18 19:24:45 +08003843 if (buf)
3844 qdf_nbuf_free(buf);
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303845 return QDF_STATUS_SUCCESS;
3846}
3847
3848/**
3849 * lim_p2p_oper_chan_change_confirm_action_frame()- function to send
3850 * p2p oper chan change confirm action frame
3851 * @mac_ctx: pointer to global mac structure
3852 * @peer: Destination mac.
3853 * @session_entry: session entry
3854 *
3855 * This function is called to send p2p oper chan change confirm action frame.
3856 *
3857 * Return: success if frame is sent else return failure
3858 */
3859
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003860QDF_STATUS
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303861lim_p2p_oper_chan_change_confirm_action_frame(tpAniSirGlobal mac_ctx,
3862 tSirMacAddr peer, tpPESession session_entry)
3863{
3864 tDot11fp2p_oper_chan_change_confirm frm;
3865 uint8_t *frame;
3866 tpSirMacMgmtHdr mac_hdr;
3867 uint32_t num_bytes, n_payload, status;
3868 void *packet;
3869 QDF_STATUS qdf_status;
3870 uint8_t tx_flag = 0;
3871 uint8_t sme_session_id = 0;
3872
3873 if (session_entry == NULL) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003874 pe_err("Session entry is NULL!!!");
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003875 return QDF_STATUS_E_FAILURE;
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303876 }
3877
3878 sme_session_id = session_entry->smeSessionId;
3879
3880 qdf_mem_set(&frm, sizeof(frm), 0);
3881
3882 frm.Category.category = SIR_MAC_ACTION_VENDOR_SPECIFIC_CATEGORY;
3883
3884 qdf_mem_copy(frm.p2p_action_oui.oui_data,
3885 SIR_MAC_P2P_OUI, SIR_MAC_P2P_OUI_SIZE);
3886 frm.p2p_action_subtype.subtype = 0x04;
3887 frm.DialogToken.token = 0x0;
3888
3889 if (session_entry->htCapability) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003890 pe_debug("Populate HT Caps in Assoc Request");
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303891 populate_dot11f_ht_caps(mac_ctx, session_entry, &frm.HTCaps);
3892 }
3893
3894 if (session_entry->vhtCapability) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003895 pe_debug("Populate VHT Caps in Assoc Request");
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303896 populate_dot11f_vht_caps(mac_ctx, session_entry, &frm.VHTCaps);
3897 populate_dot11f_operating_mode(mac_ctx,
3898 &frm.OperatingMode, session_entry);
3899 }
3900
3901 status = dot11f_get_packed_p2p_oper_chan_change_confirmSize(mac_ctx,
3902 &frm, &n_payload);
3903 if (DOT11F_FAILED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003904 pe_err("Failed to get packed size 0x%08x", status);
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303905 /* We'll fall back on the worst case scenario*/
3906 n_payload = sizeof(tDot11fp2p_oper_chan_change_confirm);
3907 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003908 pe_warn("There were warnings while calculating the packed size (0x%08x)",
3909 status);
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303910 }
3911
3912 num_bytes = n_payload + sizeof(tSirMacMgmtHdr);
3913
3914 qdf_status = cds_packet_alloc((uint16_t)num_bytes,
3915 (void **) &frame, (void **) &packet);
3916
3917 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003918 pe_err("Failed to allocate %d bytes", num_bytes);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003919 return QDF_STATUS_E_FAILURE;
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303920 }
3921
3922 qdf_mem_set(frame, num_bytes, 0);
3923
3924 /* Next, fill out the buffer descriptor */
3925 lim_populate_mac_header(mac_ctx, frame, SIR_MAC_MGMT_FRAME,
3926 SIR_MAC_MGMT_ACTION, peer, session_entry->selfMacAddr);
3927 mac_hdr = (tpSirMacMgmtHdr) frame;
3928 qdf_mem_copy((uint8_t *) mac_hdr->bssId,
3929 (uint8_t *) session_entry->bssId,
3930 sizeof(tSirMacAddr));
3931
3932 status = dot11f_pack_p2p_oper_chan_change_confirm(mac_ctx, &frm,
3933 frame + sizeof(tSirMacMgmtHdr), n_payload, &n_payload);
3934 if (DOT11F_FAILED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003935 pe_err("Failed to pack 0x%08x", status);
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303936 cds_packet_free((void *)packet);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003937 return QDF_STATUS_E_FAILURE;
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303938 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003939 pe_warn("There were warnings while packing 0x%08x",
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303940 status);
3941 }
3942
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08003943 if ((BAND_5G ==
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303944 lim_get_rf_band(session_entry->currentOperChannel)) ||
3945 (session_entry->pePersona == QDF_P2P_CLIENT_MODE) ||
3946 (session_entry->pePersona == QDF_P2P_GO_MODE)) {
3947 tx_flag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
3948 }
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003949 pe_debug("Send frame on channel %d to mac "
3950 MAC_ADDRESS_STR, session_entry->currentOperChannel,
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303951 MAC_ADDR_ARRAY(peer));
3952
3953 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
3954 session_entry->peSessionId, mac_hdr->fc.subType));
3955
3956 qdf_status = wma_tx_frameWithTxComplete(mac_ctx, packet,
3957 (uint16_t)num_bytes,
3958 TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS,
3959 7, lim_tx_complete, frame,
3960 lim_oper_chan_change_confirm_tx_complete_cnf,
Naveen Rawat296a5182017-09-25 14:02:48 -07003961 tx_flag, sme_session_id, false, 0, RATEID_DEFAULT);
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303962
3963 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
3964 session_entry->peSessionId, qdf_status));
3965 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003966 pe_err("Failed to send status %X!", qdf_status);
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303967 /* Pkt will be freed up by the callback */
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003968 return QDF_STATUS_E_FAILURE;
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303969 }
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003970 return QDF_STATUS_SUCCESS;
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303971}
3972
3973
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003974QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003975lim_send_vht_opmode_notification_frame(tpAniSirGlobal pMac,
3976 tSirMacAddr peer,
3977 uint8_t nMode, tpPESession psessionEntry)
3978{
3979 tDot11fOperatingMode frm;
3980 uint8_t *pFrame;
3981 tpSirMacMgmtHdr pMacHdr;
3982 uint32_t nBytes, nPayload = 0, nStatus; /* , nCfg; */
3983 void *pPacket;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303984 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003985 uint8_t txFlag = 0;
3986
3987 uint8_t smeSessionId = 0;
3988
3989 if (psessionEntry == NULL) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003990 pe_err("Session entry is NULL!!!");
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003991 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003992 }
3993 smeSessionId = psessionEntry->smeSessionId;
3994
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303995 qdf_mem_set((uint8_t *) &frm, sizeof(frm), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003996
3997 frm.Category.category = SIR_MAC_ACTION_VHT;
3998 frm.Action.action = SIR_MAC_VHT_OPMODE_NOTIFICATION;
3999 frm.OperatingMode.chanWidth = nMode;
4000 frm.OperatingMode.rxNSS = 0;
4001 frm.OperatingMode.rxNSSType = 0;
4002
4003 nStatus = dot11f_get_packed_operating_mode_size(pMac, &frm, &nPayload);
4004 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004005 pe_err("Failed to calculate the packed size for a Operating Mode (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004006 nStatus);
4007 /* We'll fall back on the worst case scenario: */
4008 nPayload = sizeof(tDot11fOperatingMode);
4009 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004010 pe_warn("There were warnings while calculating the packed size for a Operating Mode (0x%08x)",
4011 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004012 }
4013
4014 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
4015
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304016 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004017 cds_packet_alloc((uint16_t) nBytes, (void **)&pFrame,
4018 (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304019 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004020 pe_err("Failed to allocate %d bytes for a Operating Mode Report",
4021 nBytes);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004022 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004023 }
4024 /* Paranoia: */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304025 qdf_mem_set(pFrame, nBytes, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004026
4027 /* Next, we fill out the buffer descriptor: */
Anurag Chouhan6d760662016-02-20 16:05:43 +05304028 if (psessionEntry->pePersona == QDF_SAP_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004029 lim_populate_mac_header(pMac, pFrame, SIR_MAC_MGMT_FRAME,
4030 SIR_MAC_MGMT_ACTION, peer,
4031 psessionEntry->selfMacAddr);
4032 else
4033 lim_populate_mac_header(pMac, pFrame, SIR_MAC_MGMT_FRAME,
4034 SIR_MAC_MGMT_ACTION, psessionEntry->bssId,
4035 psessionEntry->selfMacAddr);
4036 pMacHdr = (tpSirMacMgmtHdr) pFrame;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304037 qdf_mem_copy((uint8_t *) pMacHdr->bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004038 (uint8_t *) psessionEntry->bssId, sizeof(tSirMacAddr));
4039 nStatus = dot11f_pack_operating_mode(pMac, &frm, pFrame +
4040 sizeof(tSirMacMgmtHdr),
4041 nPayload, &nPayload);
4042 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004043 pe_err("Failed to pack a Operating Mode (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004044 nStatus);
4045 cds_packet_free((void *)pPacket);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004046 return QDF_STATUS_E_FAILURE; /* allocated! */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004047 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004048 pe_warn("There were warnings while packing a Operating Mode (0x%08x)",
4049 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004050 }
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08004051 if ((BAND_5G == lim_get_rf_band(psessionEntry->currentOperChannel))
Anurag Chouhan6d760662016-02-20 16:05:43 +05304052 || (psessionEntry->pePersona == QDF_P2P_CLIENT_MODE) ||
4053 (psessionEntry->pePersona == QDF_P2P_GO_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004054 ) {
4055 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
4056 }
4057
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304058 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004059 psessionEntry->peSessionId, pMacHdr->fc.subType));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304060 qdf_status = wma_tx_frame(pMac, pPacket, (uint16_t) nBytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004061 TXRX_FRM_802_11_MGMT,
4062 ANI_TXDIR_TODS,
4063 7, lim_tx_complete, pFrame, txFlag,
Naveen Rawat296a5182017-09-25 14:02:48 -07004064 smeSessionId, 0, RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304065 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304066 psessionEntry->peSessionId, qdf_status));
4067 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004068 pe_err("Failed to send a Channel Switch (%X)!",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304069 qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004070 /* Pkt will be freed up by the callback */
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004071 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004072 }
4073
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004074 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004075}
4076
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004077/**
4078 * \brief Send a Neighbor Report Request Action frame
4079 *
4080 *
4081 * \param pMac Pointer to the global MAC structure
4082 *
4083 * \param pNeighborReq Address of a tSirMacNeighborReportReq
4084 *
4085 * \param peer mac address of peer station.
4086 *
4087 * \param psessionEntry address of session entry.
4088 *
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004089 * \return QDF_STATUS_SUCCESS on success, QDF_STATUS_E_FAILURE else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004090 *
4091 *
4092 */
4093
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004094QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004095lim_send_neighbor_report_request_frame(tpAniSirGlobal pMac,
4096 tpSirMacNeighborReportReq pNeighborReq,
4097 tSirMacAddr peer, tpPESession psessionEntry)
4098{
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004099 QDF_STATUS statusCode = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004100 tDot11fNeighborReportRequest frm;
4101 uint8_t *pFrame;
4102 tpSirMacMgmtHdr pMacHdr;
4103 uint32_t nBytes, nPayload, nStatus;
4104 void *pPacket;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304105 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004106 uint8_t txFlag = 0;
4107 uint8_t smeSessionId = 0;
4108
4109 if (psessionEntry == NULL) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004110 pe_err("(psession == NULL) in Request to send Neighbor Report request action frame");
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004111 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004112 }
4113 smeSessionId = psessionEntry->smeSessionId;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304114 qdf_mem_set((uint8_t *) &frm, sizeof(frm), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004115
4116 frm.Category.category = SIR_MAC_ACTION_RRM;
4117 frm.Action.action = SIR_MAC_RRM_NEIGHBOR_REQ;
4118 frm.DialogToken.token = pNeighborReq->dialogToken;
4119
4120 if (pNeighborReq->ssid_present) {
4121 populate_dot11f_ssid(pMac, &pNeighborReq->ssid, &frm.SSID);
4122 }
4123
4124 nStatus =
4125 dot11f_get_packed_neighbor_report_request_size(pMac, &frm, &nPayload);
4126 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004127 pe_err("Failed to calculate the packed size for a Neighbor Report Request(0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004128 nStatus);
4129 /* We'll fall back on the worst case scenario: */
4130 nPayload = sizeof(tDot11fNeighborReportRequest);
4131 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004132 pe_warn("There were warnings while calculating the packed size for a Neighbor Report Request(0x%08x)",
4133 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004134 }
4135
4136 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
4137
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304138 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004139 cds_packet_alloc((uint16_t) nBytes, (void **)&pFrame,
4140 (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304141 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004142 pe_err("Failed to allocate %d bytes for a Neighbor "
4143 "Report Request", nBytes);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004144 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004145 }
4146 /* Paranoia: */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304147 qdf_mem_set(pFrame, nBytes, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004148
4149 /* Copy necessary info to BD */
4150 lim_populate_mac_header(pMac, pFrame, SIR_MAC_MGMT_FRAME,
4151 SIR_MAC_MGMT_ACTION, peer, psessionEntry->selfMacAddr);
4152
4153 /* Update A3 with the BSSID */
4154 pMacHdr = (tpSirMacMgmtHdr) pFrame;
4155
4156 sir_copy_mac_addr(pMacHdr->bssId, psessionEntry->bssId);
4157
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004158 lim_set_protected_bit(pMac, psessionEntry, peer, pMacHdr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004159
4160 /* Now, we're ready to "pack" the frames */
4161 nStatus = dot11f_pack_neighbor_report_request(pMac,
4162 &frm,
4163 pFrame +
4164 sizeof(tSirMacMgmtHdr),
4165 nPayload, &nPayload);
4166
4167 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004168 pe_err("Failed to pack an Neighbor Report Request (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004169 nStatus);
4170
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004171 /* FIXME - Need to convert to QDF_STATUS */
4172 statusCode = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004173 goto returnAfterError;
4174 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004175 pe_warn("There were warnings while packing Neighbor Report Request (0x%08x)",
4176 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004177 }
4178
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004179 pe_debug("Sending a Neighbor Report Request to");
Nishank Aggarwal46bd31a2017-03-10 16:23:53 +05304180 lim_print_mac_addr(pMac, peer, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004181
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08004182 if ((BAND_5G == lim_get_rf_band(psessionEntry->currentOperChannel))
Anurag Chouhan6d760662016-02-20 16:05:43 +05304183 || (psessionEntry->pePersona == QDF_P2P_CLIENT_MODE) ||
4184 (psessionEntry->pePersona == QDF_P2P_GO_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004185 ) {
4186 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
4187 }
4188
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304189 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004190 psessionEntry->peSessionId, pMacHdr->fc.subType));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304191 qdf_status = wma_tx_frame(pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004192 pPacket,
4193 (uint16_t) nBytes,
4194 TXRX_FRM_802_11_MGMT,
4195 ANI_TXDIR_TODS,
4196 7, lim_tx_complete, pFrame, txFlag,
Naveen Rawat296a5182017-09-25 14:02:48 -07004197 smeSessionId, 0, RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304198 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304199 psessionEntry->peSessionId, qdf_status));
4200 if (QDF_STATUS_SUCCESS != qdf_status) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004201 pe_err("wma_tx_frame FAILED! Status [%d]", qdf_status);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004202 statusCode = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004203 /* Pkt will be freed up by the callback */
4204 return statusCode;
4205 } else
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004206 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004207
4208returnAfterError:
4209 cds_packet_free((void *)pPacket);
4210
4211 return statusCode;
4212} /* End lim_send_neighbor_report_request_frame. */
4213
4214/**
4215 * \brief Send a Link Report Action frame
4216 *
4217 *
4218 * \param pMac Pointer to the global MAC structure
4219 *
4220 * \param pLinkReport Address of a tSirMacLinkReport
4221 *
4222 * \param peer mac address of peer station.
4223 *
4224 * \param psessionEntry address of session entry.
4225 *
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004226 * \return QDF_STATUS_SUCCESS on success, QDF_STATUS_E_FAILURE else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004227 *
4228 *
4229 */
4230
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004231QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004232lim_send_link_report_action_frame(tpAniSirGlobal pMac,
4233 tpSirMacLinkReport pLinkReport,
4234 tSirMacAddr peer, tpPESession psessionEntry)
4235{
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004236 QDF_STATUS statusCode = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004237 tDot11fLinkMeasurementReport frm;
4238 uint8_t *pFrame;
4239 tpSirMacMgmtHdr pMacHdr;
4240 uint32_t nBytes, nPayload, nStatus;
4241 void *pPacket;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304242 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004243 uint8_t txFlag = 0;
4244 uint8_t smeSessionId = 0;
4245
4246 if (psessionEntry == NULL) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004247 pe_err("(psession == NULL) in Request to send Link Report action frame");
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004248 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004249 }
4250
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304251 qdf_mem_set((uint8_t *) &frm, sizeof(frm), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004252
4253 frm.Category.category = SIR_MAC_ACTION_RRM;
4254 frm.Action.action = SIR_MAC_RRM_LINK_MEASUREMENT_RPT;
4255 frm.DialogToken.token = pLinkReport->dialogToken;
4256
4257 /* IEEE Std. 802.11 7.3.2.18. for the report element. */
4258 /* Even though TPC report an IE, it is represented using fixed fields since it is positioned */
4259 /* in the middle of other fixed fields in the link report frame(IEEE Std. 802.11k section7.4.6.4 */
4260 /* and frame parser always expects IEs to come after all fixed fields. It is easier to handle */
4261 /* such case this way than changing the frame parser. */
4262 frm.TPCEleID.TPCId = SIR_MAC_TPC_RPT_EID;
4263 frm.TPCEleLen.TPCLen = 2;
4264 frm.TxPower.txPower = pLinkReport->txPower;
4265 frm.LinkMargin.linkMargin = 0;
4266
4267 frm.RxAntennaId.antennaId = pLinkReport->rxAntenna;
4268 frm.TxAntennaId.antennaId = pLinkReport->txAntenna;
4269 frm.RCPI.rcpi = pLinkReport->rcpi;
4270 frm.RSNI.rsni = pLinkReport->rsni;
4271
4272 nStatus =
4273 dot11f_get_packed_link_measurement_report_size(pMac, &frm, &nPayload);
4274 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004275 pe_err("Failed to calculate the packed size for a Link Report (0x%08x)", nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004276 /* We'll fall back on the worst case scenario: */
4277 nPayload = sizeof(tDot11fLinkMeasurementReport);
4278 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004279 pe_warn("There were warnings while calculating the packed size for a Link Report (0x%08x)",
4280 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004281 }
4282
4283 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
4284
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304285 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004286 cds_packet_alloc((uint16_t) nBytes, (void **)&pFrame,
4287 (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304288 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004289 pe_err("Failed to allocate %d bytes for a Link "
4290 "Report", nBytes);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004291 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004292 }
4293 /* Paranoia: */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304294 qdf_mem_set(pFrame, nBytes, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004295
4296 /* Copy necessary info to BD */
4297 lim_populate_mac_header(pMac, pFrame, SIR_MAC_MGMT_FRAME,
4298 SIR_MAC_MGMT_ACTION, peer, psessionEntry->selfMacAddr);
4299
4300 /* Update A3 with the BSSID */
4301 pMacHdr = (tpSirMacMgmtHdr) pFrame;
4302
4303 sir_copy_mac_addr(pMacHdr->bssId, psessionEntry->bssId);
4304
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004305 lim_set_protected_bit(pMac, psessionEntry, peer, pMacHdr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004306
4307 /* Now, we're ready to "pack" the frames */
4308 nStatus = dot11f_pack_link_measurement_report(pMac,
4309 &frm,
4310 pFrame +
4311 sizeof(tSirMacMgmtHdr),
4312 nPayload, &nPayload);
4313
4314 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004315 pe_err("Failed to pack an Link Report (0x%08x)", nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004316
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004317 /* FIXME - Need to convert to QDF_STATUS */
4318 statusCode = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004319 goto returnAfterError;
4320 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004321 pe_warn("There were warnings while packing Link Report (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004322 nStatus);
4323 }
4324
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004325 pe_warn("Sending a Link Report to");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004326 lim_print_mac_addr(pMac, peer, LOGW);
4327
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08004328 if ((BAND_5G == lim_get_rf_band(psessionEntry->currentOperChannel))
Anurag Chouhan6d760662016-02-20 16:05:43 +05304329 || (psessionEntry->pePersona == QDF_P2P_CLIENT_MODE) ||
4330 (psessionEntry->pePersona == QDF_P2P_GO_MODE)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004331 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
4332 }
4333
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304334 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004335 psessionEntry->peSessionId, pMacHdr->fc.subType));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304336 qdf_status = wma_tx_frame(pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004337 pPacket,
4338 (uint16_t) nBytes,
4339 TXRX_FRM_802_11_MGMT,
4340 ANI_TXDIR_TODS,
4341 7, lim_tx_complete, pFrame, txFlag,
Naveen Rawat296a5182017-09-25 14:02:48 -07004342 smeSessionId, 0, RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304343 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304344 psessionEntry->peSessionId, qdf_status));
4345 if (QDF_STATUS_SUCCESS != qdf_status) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004346 pe_err("wma_tx_frame FAILED! Status [%d]", qdf_status);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004347 statusCode = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004348 /* Pkt will be freed up by the callback */
4349 return statusCode;
4350 } else
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004351 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004352
4353returnAfterError:
4354 cds_packet_free((void *)pPacket);
4355
4356 return statusCode;
4357} /* End lim_send_link_report_action_frame. */
4358
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004359QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004360lim_send_radio_measure_report_action_frame(tpAniSirGlobal pMac,
Vignesh Viswanathan3b4bf982018-06-05 15:04:23 +05304361 uint8_t dialog_token,
4362 uint8_t num_report,
4363 struct rrm_beacon_report_last_beacon_params
4364 *last_beacon_report_params,
4365 tpSirMacRadioMeasureReport pRRMReport,
4366 tSirMacAddr peer,
4367 tpPESession psessionEntry)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004368{
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004369 QDF_STATUS statusCode = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004370 uint8_t *pFrame;
4371 tpSirMacMgmtHdr pMacHdr;
4372 uint32_t nBytes, nPayload, nStatus;
4373 void *pPacket;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304374 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004375 uint8_t i;
4376 uint8_t txFlag = 0;
4377 uint8_t smeSessionId = 0;
4378
4379 tDot11fRadioMeasurementReport *frm =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304380 qdf_mem_malloc(sizeof(tDot11fRadioMeasurementReport));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004381 if (!frm) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004382 pe_err("Not enough memory to allocate tDot11fRadioMeasurementReport");
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004383 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004384 }
4385
4386 if (psessionEntry == NULL) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004387 pe_err("(psession == NULL) in Request to send Beacon Report action frame");
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304388 qdf_mem_free(frm);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004389 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004390 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004391
Deepak Dhamdhere6a021482017-04-20 17:59:58 -07004392 smeSessionId = psessionEntry->smeSessionId;
4393
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004394 pe_debug("dialog_token %d num_report %d",
Padma, Santhosh Kumar93ec7d22016-12-26 15:58:37 +05304395 dialog_token, num_report);
4396
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004397 frm->Category.category = SIR_MAC_ACTION_RRM;
4398 frm->Action.action = SIR_MAC_RRM_RADIO_MEASURE_RPT;
4399 frm->DialogToken.token = dialog_token;
4400
4401 frm->num_MeasurementReport =
4402 (num_report >
4403 RADIO_REPORTS_MAX_IN_A_FRAME) ? RADIO_REPORTS_MAX_IN_A_FRAME :
4404 num_report;
4405
4406 for (i = 0; i < frm->num_MeasurementReport; i++) {
4407 frm->MeasurementReport[i].type = pRRMReport[i].type;
4408 frm->MeasurementReport[i].token = pRRMReport[i].token;
4409 frm->MeasurementReport[i].late = 0; /* IEEE 802.11k section 7.3.22. (always zero in rrm) */
4410 switch (pRRMReport[i].type) {
4411 case SIR_MAC_RRM_BEACON_TYPE:
4412 populate_dot11f_beacon_report(pMac,
Vignesh Viswanathan3b4bf982018-06-05 15:04:23 +05304413 &frm->MeasurementReport[i],
4414 &pRRMReport[i].report.
4415 beaconReport,
4416 last_beacon_report_params);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004417 frm->MeasurementReport[i].incapable =
4418 pRRMReport[i].incapable;
4419 frm->MeasurementReport[i].refused =
4420 pRRMReport[i].refused;
4421 frm->MeasurementReport[i].present = 1;
4422 break;
4423 default:
4424 frm->MeasurementReport[i].incapable =
4425 pRRMReport[i].incapable;
4426 frm->MeasurementReport[i].refused =
4427 pRRMReport[i].refused;
4428 frm->MeasurementReport[i].present = 1;
4429 break;
4430 }
4431 }
4432
4433 nStatus =
4434 dot11f_get_packed_radio_measurement_report_size(pMac, frm, &nPayload);
4435 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004436 pe_err("Failed to calculate the packed size for a Radio Measure Report (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004437 nStatus);
4438 /* We'll fall back on the worst case scenario: */
4439 nPayload = sizeof(tDot11fLinkMeasurementReport);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304440 qdf_mem_free(frm);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004441 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004442 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004443 pe_warn("There were warnings while calculating the packed size for a Radio Measure Report (0x%08x)",
4444 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004445 }
4446
4447 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
4448
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304449 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004450 cds_packet_alloc((uint16_t) nBytes, (void **)&pFrame,
4451 (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304452 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004453 pe_err("Failed to allocate %d bytes for a Radio Measure "
4454 "Report", nBytes);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304455 qdf_mem_free(frm);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004456 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004457 }
4458 /* Paranoia: */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304459 qdf_mem_set(pFrame, nBytes, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004460
4461 /* Copy necessary info to BD */
4462 lim_populate_mac_header(pMac, pFrame, SIR_MAC_MGMT_FRAME,
4463 SIR_MAC_MGMT_ACTION, peer, psessionEntry->selfMacAddr);
4464
4465 /* Update A3 with the BSSID */
4466 pMacHdr = (tpSirMacMgmtHdr) pFrame;
4467
4468 sir_copy_mac_addr(pMacHdr->bssId, psessionEntry->bssId);
4469
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004470 lim_set_protected_bit(pMac, psessionEntry, peer, pMacHdr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004471
4472 /* Now, we're ready to "pack" the frames */
4473 nStatus = dot11f_pack_radio_measurement_report(pMac,
4474 frm,
4475 pFrame +
4476 sizeof(tSirMacMgmtHdr),
4477 nPayload, &nPayload);
4478
4479 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004480 pe_err("Failed to pack an Radio Measure Report (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004481 nStatus);
4482
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004483 /* FIXME - Need to convert to QDF_STATUS */
4484 statusCode = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004485 goto returnAfterError;
4486 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004487 pe_warn("There were warnings while packing Radio Measure Report (0x%08x)",
4488 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004489 }
4490
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004491 pe_warn("Sending a Radio Measure Report to");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004492 lim_print_mac_addr(pMac, peer, LOGW);
4493
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08004494 if ((BAND_5G == lim_get_rf_band(psessionEntry->currentOperChannel))
Anurag Chouhan6d760662016-02-20 16:05:43 +05304495 || (psessionEntry->pePersona == QDF_P2P_CLIENT_MODE) ||
4496 (psessionEntry->pePersona == QDF_P2P_GO_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004497 ) {
4498 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
4499 }
4500
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304501 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004502 psessionEntry->peSessionId, pMacHdr->fc.subType));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304503 qdf_status = wma_tx_frame(pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004504 pPacket,
4505 (uint16_t) nBytes,
4506 TXRX_FRM_802_11_MGMT,
4507 ANI_TXDIR_TODS,
4508 7, lim_tx_complete, pFrame, txFlag,
Naveen Rawat296a5182017-09-25 14:02:48 -07004509 smeSessionId, 0, RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304510 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304511 psessionEntry->peSessionId, qdf_status));
4512 if (QDF_STATUS_SUCCESS != qdf_status) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004513 pe_err("wma_tx_frame FAILED! Status [%d]", qdf_status);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004514 statusCode = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004515 /* Pkt will be freed up by the callback */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304516 qdf_mem_free(frm);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004517 return statusCode;
4518 } else {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304519 qdf_mem_free(frm);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004520 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004521 }
4522
4523returnAfterError:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304524 qdf_mem_free(frm);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004525 cds_packet_free((void *)pPacket);
4526 return statusCode;
4527}
4528
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004529#ifdef WLAN_FEATURE_11W
4530/**
4531 * \brief Send SA query request action frame to peer
4532 *
4533 * \sa lim_send_sa_query_request_frame
4534 *
4535 *
4536 * \param pMac The global tpAniSirGlobal object
4537 *
4538 * \param transId Transaction identifier
4539 *
4540 * \param peer The Mac address of the station to which this action frame is addressed
4541 *
4542 * \param psessionEntry The PE session entry
4543 *
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004544 * \return QDF_STATUS_SUCCESS if setup completes successfully
4545 * QDF_STATUS_E_FAILURE is some problem is encountered
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004546 */
4547
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004548QDF_STATUS lim_send_sa_query_request_frame(tpAniSirGlobal pMac, uint8_t *transId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004549 tSirMacAddr peer,
4550 tpPESession psessionEntry)
4551{
4552
4553 tDot11fSaQueryReq frm; /* SA query request action frame */
4554 uint8_t *pFrame;
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004555 QDF_STATUS nSirStatus;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004556 tpSirMacMgmtHdr pMacHdr;
4557 uint32_t nBytes, nPayload, nStatus;
4558 void *pPacket;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304559 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004560 uint8_t txFlag = 0;
4561 uint8_t smeSessionId = 0;
4562
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304563 qdf_mem_set((uint8_t *) &frm, sizeof(frm), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004564 frm.Category.category = SIR_MAC_ACTION_SA_QUERY;
4565 /* 11w action field is :
4566 action: 0 --> SA Query Request action frame
4567 action: 1 --> SA Query Response action frame */
4568 frm.Action.action = SIR_MAC_SA_QUERY_REQ;
4569 /* 11w SA Query Request transId */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304570 qdf_mem_copy(&frm.TransactionId.transId[0], &transId[0], 2);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004571
4572 nStatus = dot11f_get_packed_sa_query_req_size(pMac, &frm, &nPayload);
4573 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004574 pe_err("Failed to calculate the packed size for an SA Query Request (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004575 nStatus);
4576 /* We'll fall back on the worst case scenario: */
4577 nPayload = sizeof(tDot11fSaQueryReq);
4578 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004579 pe_warn("There were warnings while calculating the packed size for an SA Query Request (0x%08x)",
4580 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004581 }
4582
4583 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304584 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004585 cds_packet_alloc(nBytes, (void **)&pFrame, (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304586 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004587 pe_err("Failed to allocate %d bytes for a SA Query Request "
4588 "action frame", nBytes);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004589 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004590 }
4591 /* Paranoia: */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304592 qdf_mem_set(pFrame, nBytes, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004593
4594 /* Copy necessary info to BD */
4595 lim_populate_mac_header(pMac, pFrame, SIR_MAC_MGMT_FRAME,
4596 SIR_MAC_MGMT_ACTION, peer, psessionEntry->selfMacAddr);
4597
4598 /* Update A3 with the BSSID */
4599 pMacHdr = (tpSirMacMgmtHdr) pFrame;
4600
4601 sir_copy_mac_addr(pMacHdr->bssId, psessionEntry->bssId);
4602
4603 /* Since this is a SA Query Request, set the "protect" (aka WEP) bit */
4604 /* in the FC */
4605 lim_set_protected_bit(pMac, psessionEntry, peer, pMacHdr);
4606
4607 /* Pack 11w SA Query Request frame */
4608 nStatus = dot11f_pack_sa_query_req(pMac,
4609 &frm,
4610 pFrame + sizeof(tSirMacMgmtHdr),
4611 nPayload, &nPayload);
4612
4613 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004614 pe_err("Failed to pack an SA Query Request (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004615 nStatus);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004616 /* FIXME - Need to convert to QDF_STATUS */
4617 nSirStatus = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004618 goto returnAfterError;
4619 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004620 pe_warn("There were warnings while packing SA Query Request (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004621 nStatus);
4622 }
4623
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004624 pe_debug("Sending an SA Query Request to");
4625 lim_print_mac_addr(pMac, peer, LOGD);
4626 pe_debug("Sending an SA Query Request from ");
4627 lim_print_mac_addr(pMac, psessionEntry->selfMacAddr, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004628
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08004629 if ((BAND_5G == lim_get_rf_band(psessionEntry->currentOperChannel))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004630#ifdef WLAN_FEATURE_P2P
Anurag Chouhan6d760662016-02-20 16:05:43 +05304631 || (psessionEntry->pePersona == QDF_P2P_CLIENT_MODE) ||
4632 (psessionEntry->pePersona == QDF_P2P_GO_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004633#endif
4634 ) {
4635 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
4636 }
4637 smeSessionId = psessionEntry->smeSessionId;
4638
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304639 qdf_status = wma_tx_frame(pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004640 pPacket,
4641 (uint16_t) nBytes,
4642 TXRX_FRM_802_11_MGMT,
4643 ANI_TXDIR_TODS,
4644 7, lim_tx_complete, pFrame, txFlag,
Naveen Rawat296a5182017-09-25 14:02:48 -07004645 smeSessionId, 0, RATEID_DEFAULT);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304646 if (QDF_STATUS_SUCCESS != qdf_status) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004647 pe_err("wma_tx_frame FAILED! Status [%d]", qdf_status);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004648 nSirStatus = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004649 /* Pkt will be freed up by the callback */
4650 return nSirStatus;
4651 } else {
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004652 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004653 }
4654
4655returnAfterError:
4656 cds_packet_free((void *)pPacket);
4657 return nSirStatus;
4658} /* End lim_send_sa_query_request_frame */
4659
4660/**
4661 * \brief Send SA query response action frame to peer
4662 *
4663 * \sa lim_send_sa_query_response_frame
4664 *
4665 *
4666 * \param pMac The global tpAniSirGlobal object
4667 *
4668 * \param transId Transaction identifier received in SA query request action frame
4669 *
4670 * \param peer The Mac address of the AP to which this action frame is addressed
4671 *
4672 * \param psessionEntry The PE session entry
4673 *
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004674 * \return QDF_STATUS_SUCCESS if setup completes successfully
4675 * QDF_STATUS_E_FAILURE is some problem is encountered
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004676 */
4677
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004678QDF_STATUS lim_send_sa_query_response_frame(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004679 uint8_t *transId, tSirMacAddr peer,
4680 tpPESession psessionEntry)
4681{
4682
Jeff Johnson47d75242018-05-12 15:58:53 -07004683 tDot11fSaQueryRsp frm; /* SA query response action frame */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004684 uint8_t *pFrame;
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004685 QDF_STATUS nSirStatus;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004686 tpSirMacMgmtHdr pMacHdr;
4687 uint32_t nBytes, nPayload, nStatus;
4688 void *pPacket;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304689 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004690 uint8_t txFlag = 0;
4691 uint8_t smeSessionId = 0;
4692
4693 smeSessionId = psessionEntry->smeSessionId;
4694
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304695 qdf_mem_set((uint8_t *) &frm, sizeof(frm), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004696 frm.Category.category = SIR_MAC_ACTION_SA_QUERY;
4697 /*11w action field is :
4698 action: 0 --> SA query request action frame
4699 action: 1 --> SA query response action frame */
4700 frm.Action.action = SIR_MAC_SA_QUERY_RSP;
4701 /*11w SA query response transId is same as
4702 SA query request transId */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304703 qdf_mem_copy(&frm.TransactionId.transId[0], &transId[0], 2);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004704
4705 nStatus = dot11f_get_packed_sa_query_rsp_size(pMac, &frm, &nPayload);
4706 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004707 pe_err("Failed to calculate the packed size for a SA Query Response (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004708 nStatus);
4709 /* We'll fall back on the worst case scenario: */
4710 nPayload = sizeof(tDot11fSaQueryRsp);
4711 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004712 pe_warn("There were warnings while calculating the packed size for an SA Query Response (0x%08x)",
4713 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004714 }
4715
4716 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304717 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004718 cds_packet_alloc(nBytes, (void **)&pFrame, (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304719 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004720 pe_err("Failed to allocate %d bytes for a SA query response"
4721 " action frame", nBytes);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004722 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004723 }
4724 /* Paranoia: */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304725 qdf_mem_set(pFrame, nBytes, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004726
4727 /* Copy necessary info to BD */
4728 lim_populate_mac_header(pMac, pFrame, SIR_MAC_MGMT_FRAME,
4729 SIR_MAC_MGMT_ACTION, peer, psessionEntry->selfMacAddr);
4730
4731 /* Update A3 with the BSSID */
4732 pMacHdr = (tpSirMacMgmtHdr) pFrame;
4733
4734 sir_copy_mac_addr(pMacHdr->bssId, psessionEntry->bssId);
4735
4736 /* Since this is a SA Query Response, set the "protect" (aka WEP) bit */
4737 /* in the FC */
4738 lim_set_protected_bit(pMac, psessionEntry, peer, pMacHdr);
4739
4740 /* Pack 11w SA query response frame */
4741 nStatus = dot11f_pack_sa_query_rsp(pMac,
4742 &frm,
4743 pFrame + sizeof(tSirMacMgmtHdr),
4744 nPayload, &nPayload);
4745
4746 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004747 pe_err("Failed to pack an SA Query Response (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004748 nStatus);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004749 /* FIXME - Need to convert to QDF_STATUS */
4750 nSirStatus = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004751 goto returnAfterError;
4752 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004753 pe_warn("There were warnings while packing SA Query Response (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004754 nStatus);
4755 }
4756
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004757 pe_debug("Sending a SA Query Response to");
Srinivas Girigowdaf936d822017-03-19 23:23:59 -07004758 lim_print_mac_addr(pMac, peer, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004759
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08004760 if ((BAND_5G == lim_get_rf_band(psessionEntry->currentOperChannel))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004761#ifdef WLAN_FEATURE_P2P
Anurag Chouhan6d760662016-02-20 16:05:43 +05304762 || (psessionEntry->pePersona == QDF_P2P_CLIENT_MODE) ||
4763 (psessionEntry->pePersona == QDF_P2P_GO_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004764#endif
4765 ) {
4766 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
4767 }
4768
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304769 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004770 psessionEntry->peSessionId, pMacHdr->fc.subType));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304771 qdf_status = wma_tx_frame(pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004772 pPacket,
4773 (uint16_t) nBytes,
4774 TXRX_FRM_802_11_MGMT,
4775 ANI_TXDIR_TODS,
4776 7, lim_tx_complete, pFrame, txFlag,
Naveen Rawat296a5182017-09-25 14:02:48 -07004777 smeSessionId, 0, RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304778 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304779 psessionEntry->peSessionId, qdf_status));
4780 if (QDF_STATUS_SUCCESS != qdf_status) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004781 pe_err("wma_tx_frame FAILED! Status [%d]", qdf_status);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004782 nSirStatus = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004783 /* Pkt will be freed up by the callback */
4784 return nSirStatus;
4785 } else {
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004786 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004787 }
4788
4789returnAfterError:
4790 cds_packet_free((void *)pPacket);
4791 return nSirStatus;
4792} /* End lim_send_sa_query_response_frame */
4793#endif
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004794
4795/**
4796 * lim_send_addba_response_frame(): Send ADDBA response action frame to peer
4797 * @mac_ctx: mac context
4798 * @peer_mac: Peer MAC address
4799 * @tid: TID for which addba response is being sent
4800 * @session: PE session entry
Kiran Kumar Lokere40875852018-01-15 12:36:19 -08004801 * @addba_extn_present: ADDBA extension present flag
Kiran Kumar Lokereaee823a2018-03-22 15:27:05 -07004802 * @amsdu_support: amsdu in ampdu support
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004803 *
4804 * This function is called when ADDBA request is successful. ADDBA response is
4805 * setup by calling addba_response_setup API and frame is then sent out OTA.
4806 *
4807 * Return: QDF_STATUS
4808 */
4809QDF_STATUS lim_send_addba_response_frame(tpAniSirGlobal mac_ctx,
Kiran Kumar Lokere40875852018-01-15 12:36:19 -08004810 tSirMacAddr peer_mac, uint16_t tid,
Kiran Kumar Lokereaee823a2018-03-22 15:27:05 -07004811 tpPESession session, uint8_t addba_extn_present,
4812 uint8_t amsdu_support)
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004813{
4814
4815 tDot11faddba_rsp frm;
4816 uint8_t *frame_ptr;
4817 tpSirMacMgmtHdr mgmt_hdr;
4818 uint32_t num_bytes, payload_size, status;
Sandeep Puligilla39cec082018-04-30 15:18:45 -07004819 void *pkt_ptr = NULL;
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004820 QDF_STATUS qdf_status;
4821 uint8_t tx_flag = 0;
4822 uint8_t sme_sessionid = 0;
4823 uint16_t buff_size, status_code, batimeout;
4824 uint8_t peer_id, dialog_token;
4825 void *soc = cds_get_context(QDF_MODULE_ID_SOC);
4826 void *peer, *pdev;
Kiran Kumar Lokere40875852018-01-15 12:36:19 -08004827 uint8_t he_frag = 0;
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004828
4829 sme_sessionid = session->smeSessionId;
4830
4831 pdev = cds_get_context(QDF_MODULE_ID_TXRX);
4832 if (!pdev) {
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004833 pe_err("pdev is NULL");
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004834 return QDF_STATUS_E_FAILURE;
4835 }
4836
Mohit Khannac4c22252017-11-20 11:06:33 -08004837 peer = cdp_peer_get_ref_by_addr(soc, pdev, peer_mac, &peer_id,
4838 PEER_DEBUG_ID_LIM_SEND_ADDBA_RESP);
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004839 if (!peer) {
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004840 pe_err("PEER [%pM] not found", peer_mac);
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004841 return QDF_STATUS_E_FAILURE;
4842 }
4843
4844 cdp_addba_responsesetup(soc, peer, tid, &dialog_token,
4845 &status_code, &buff_size, &batimeout);
4846
Mohit Khannac4c22252017-11-20 11:06:33 -08004847 cdp_peer_release_ref(soc, peer, PEER_DEBUG_ID_LIM_SEND_ADDBA_RESP);
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004848 qdf_mem_set((uint8_t *) &frm, sizeof(frm), 0);
4849 frm.Category.category = SIR_MAC_ACTION_BLKACK;
4850 frm.Action.action = SIR_MAC_ADDBA_RSP;
4851
4852 frm.DialogToken.token = dialog_token;
4853 frm.Status.status = status_code;
Kiran Kumar Lokere08195ef2018-01-17 19:25:15 -08004854 if (mac_ctx->reject_addba_req) {
4855 frm.Status.status = eSIR_MAC_REQ_DECLINED_STATUS;
4856 pe_err("refused addba req");
4857 }
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004858 frm.addba_param_set.tid = tid;
Kiran Kumar Lokere96180e12018-03-12 17:58:23 -07004859 frm.addba_param_set.buff_size = SIR_MAC_BA_DEFAULT_BUFF_SIZE;
Kiran Kumar Lokerebc87bec2018-02-27 20:06:42 -08004860 if (mac_ctx->usr_cfg_ba_buff_size)
4861 frm.addba_param_set.buff_size = mac_ctx->usr_cfg_ba_buff_size;
Kiran Kumar Lokereeac7fe92018-07-24 16:56:01 -07004862
4863 if (frm.addba_param_set.buff_size > MAX_BA_BUFF_SIZE)
4864 frm.addba_param_set.buff_size = MAX_BA_BUFF_SIZE;
4865
4866 if (frm.addba_param_set.buff_size > SIR_MAC_BA_DEFAULT_BUFF_SIZE) {
4867 if (session->active_ba_64_session) {
4868 frm.addba_param_set.buff_size =
4869 SIR_MAC_BA_DEFAULT_BUFF_SIZE;
4870 }
4871 } else if (!session->active_ba_64_session) {
4872 session->active_ba_64_session = true;
4873 }
Arif Hussain0e246802018-05-01 18:13:44 -07004874 if (mac_ctx->is_usr_cfg_amsdu_enabled)
4875 frm.addba_param_set.amsdu_supp = amsdu_support;
4876 else
4877 frm.addba_param_set.amsdu_supp = 0;
Kiran Kumar Lokerebc87bec2018-02-27 20:06:42 -08004878 frm.addba_param_set.policy = SIR_MAC_BA_POLICY_IMMEDIATE;
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004879 frm.ba_timeout.timeout = batimeout;
Kiran Kumar Lokere40875852018-01-15 12:36:19 -08004880 if (addba_extn_present) {
4881 frm.addba_extn_element.present = 1;
4882 frm.addba_extn_element.no_fragmentation = 1;
4883 if (lim_is_session_he_capable(session)) {
4884 he_frag = lim_get_session_he_frag_cap(session);
4885 if (he_frag != 0) {
4886 frm.addba_extn_element.no_fragmentation = 0;
4887 frm.addba_extn_element.he_frag_operation =
4888 he_frag;
4889 }
4890 }
4891 }
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004892
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004893 pe_debug("Sending a ADDBA Response from %pM to %pM",
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004894 session->selfMacAddr, peer_mac);
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004895 pe_debug("tid: %d, dialog_token: %d, status: %d, buff_size: %d",
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004896 tid, frm.DialogToken.token, frm.Status.status,
4897 frm.addba_param_set.buff_size);
Kiran Kumar Lokere40875852018-01-15 12:36:19 -08004898 pe_debug("addba_extn %d he_capable %d no_frag %d he_frag %d",
4899 addba_extn_present,
4900 lim_is_session_he_capable(session),
4901 frm.addba_extn_element.no_fragmentation,
4902 frm.addba_extn_element.he_frag_operation);
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004903
4904 status = dot11f_get_packed_addba_rsp_size(mac_ctx, &frm, &payload_size);
4905 if (DOT11F_FAILED(status)) {
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004906 pe_err("Failed to calculate the packed size for a ADDBA Response (0x%08x).",
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004907 status);
4908 /* We'll fall back on the worst case scenario: */
4909 payload_size = sizeof(tDot11faddba_rsp);
4910 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004911 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 -08004912 }
4913
4914 num_bytes = payload_size + sizeof(*mgmt_hdr);
4915 qdf_status = cds_packet_alloc(num_bytes, (void **)&frame_ptr,
4916 (void **)&pkt_ptr);
Sandeep Puligilla39cec082018-04-30 15:18:45 -07004917 if (!QDF_IS_STATUS_SUCCESS(qdf_status) || (!pkt_ptr)) {
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004918 pe_err("Failed to allocate %d bytes for a ADDBA response action frame",
4919 num_bytes);
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004920 return QDF_STATUS_E_FAILURE;
4921 }
4922 qdf_mem_set(frame_ptr, num_bytes, 0);
4923
4924 lim_populate_mac_header(mac_ctx, frame_ptr, SIR_MAC_MGMT_FRAME,
4925 SIR_MAC_MGMT_ACTION, peer_mac, session->selfMacAddr);
4926
4927 /* Update A3 with the BSSID */
4928 mgmt_hdr = (tpSirMacMgmtHdr) frame_ptr;
4929 sir_copy_mac_addr(mgmt_hdr->bssId, session->bssId);
4930
4931 /* ADDBA Response is a robust mgmt action frame,
4932 * set the "protect" (aka WEP) bit in the FC
4933 */
4934 lim_set_protected_bit(mac_ctx, session, peer_mac, mgmt_hdr);
4935
4936 status = dot11f_pack_addba_rsp(mac_ctx, &frm,
4937 frame_ptr + sizeof(tSirMacMgmtHdr), payload_size,
4938 &payload_size);
4939
4940 if (DOT11F_FAILED(status)) {
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004941 pe_err("Failed to pack a ADDBA Response (0x%08x)",
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004942 status);
4943 qdf_status = QDF_STATUS_E_FAILURE;
4944 goto error_addba_rsp;
4945 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004946 pe_warn("There were warnings while packing ADDBA Response (0x%08x)",
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004947 status);
4948 }
4949
4950
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08004951 if ((BAND_5G == lim_get_rf_band(session->currentOperChannel))
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004952#ifdef WLAN_FEATURE_P2P
4953 || (session->pePersona == QDF_P2P_CLIENT_MODE) ||
4954 (session->pePersona == QDF_P2P_GO_MODE)
4955#endif
4956 ) {
4957 tx_flag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
4958 }
4959
4960 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
4961 session->peSessionId, mgmt_hdr->fc.subType));
Krunal Sonid2136c72018-06-01 17:26:39 -07004962 qdf_status = wma_tx_frameWithTxComplete(mac_ctx, pkt_ptr,
4963 (uint16_t)num_bytes,
4964 TXRX_FRM_802_11_MGMT,
4965 ANI_TXDIR_TODS, 7,
4966 NULL, frame_ptr,
4967 lim_addba_rsp_tx_complete_cnf,
4968 tx_flag, sme_sessionid,
4969 false, 0, RATEID_DEFAULT);
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004970 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
4971 session->peSessionId, qdf_status));
4972 if (QDF_STATUS_SUCCESS != qdf_status) {
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004973 pe_err("wma_tx_frame FAILED! Status [%d]",
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004974 qdf_status);
4975 qdf_status = QDF_STATUS_E_FAILURE;
4976 /*
4977 * wma_tx_frame free memory in certain cases, free pkt_ptr
4978 * only if not freed already.
4979 */
4980 if (pkt_ptr)
4981 cds_packet_free((void *)pkt_ptr);
4982 return qdf_status;
4983 } else {
Tushnim Bhattacharyyad58e4c92018-03-27 13:40:12 -07004984 return QDF_STATUS_SUCCESS;
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004985 }
4986
4987error_addba_rsp:
4988 cds_packet_free((void *)pkt_ptr);
4989 return qdf_status;
4990}
Padma, Santhosh Kumar22c462c2018-01-16 17:56:44 +05304991
4992/**
4993 * lim_tx_mgmt_frame() - Transmits Auth mgmt frame
4994 * @mac_ctx Pointer to Global MAC structure
4995 * @mb_msg: Received message info
4996 * @msg_len: Received message length
4997 * @packet: Packet to be transmitted
4998 * @frame: Received frame
4999 *
5000 * Return: None
5001 */
5002static void lim_tx_mgmt_frame(tpAniSirGlobal mac_ctx,
5003 struct sir_mgmt_msg *mb_msg, uint32_t msg_len,
5004 void *packet, uint8_t *frame)
5005{
5006 tpSirMacFrameCtl fc = (tpSirMacFrameCtl) mb_msg->data;
5007 QDF_STATUS qdf_status;
5008 uint8_t sme_session_id = 0;
5009 tpPESession session;
5010 uint16_t auth_ack_status;
5011 enum rateid min_rid = RATEID_DEFAULT;
5012
5013 sme_session_id = mb_msg->session_id;
5014 session = pe_find_session_by_sme_session_id(mac_ctx, sme_session_id);
5015 if (session == NULL) {
5016 pe_err("session not found for given sme session");
5017 return;
5018 }
5019
Ashish Kumar Dhanotiya9f72df02018-07-23 19:20:04 +05305020 qdf_mtrace(QDF_MODULE_ID_PE, QDF_MODULE_ID_WMA, TRACE_CODE_TX_MGMT,
5021 session->peSessionId, 0);
Padma, Santhosh Kumar22c462c2018-01-16 17:56:44 +05305022
5023 mac_ctx->auth_ack_status = LIM_AUTH_ACK_NOT_RCD;
5024 min_rid = lim_get_min_session_txrate(session);
5025
5026 qdf_status = wma_tx_frameWithTxComplete(mac_ctx, packet,
5027 (uint16_t)msg_len,
5028 TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS,
5029 7, lim_tx_complete, frame,
5030 lim_auth_tx_complete_cnf,
5031 0, sme_session_id, false, 0, min_rid);
5032 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
5033 session->peSessionId, qdf_status));
5034 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Rachit Kankane0baf6e72018-01-19 15:01:50 +05305035 pe_err("*** Could not send Auth frame (subType: %d), retCode=%X ***",
5036 fc->subType, qdf_status);
Padma, Santhosh Kumar22c462c2018-01-16 17:56:44 +05305037 mac_ctx->auth_ack_status = LIM_AUTH_ACK_RCD_FAILURE;
5038 auth_ack_status = SENT_FAIL;
5039 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_AUTH_ACK_EVENT,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07005040 session, auth_ack_status, QDF_STATUS_E_FAILURE);
Padma, Santhosh Kumar22c462c2018-01-16 17:56:44 +05305041 /* Pkt will be freed up by the callback */
5042 }
5043}
5044
5045void lim_send_mgmt_frame_tx(tpAniSirGlobal mac_ctx,
5046 struct scheduler_msg *msg)
5047{
5048 struct sir_mgmt_msg *mb_msg = (struct sir_mgmt_msg *)msg->bodyptr;
5049 uint32_t msg_len;
5050 tpSirMacFrameCtl fc = (tpSirMacFrameCtl) mb_msg->data;
5051 uint8_t sme_session_id;
5052 QDF_STATUS qdf_status;
5053 uint8_t *frame;
5054 void *packet;
5055
5056 msg_len = mb_msg->msg_len - sizeof(*mb_msg);
5057 pe_debug("sending fc->type: %d fc->subType: %d",
5058 fc->type, fc->subType);
5059
5060 sme_session_id = mb_msg->session_id;
5061
5062 qdf_status = cds_packet_alloc((uint16_t) msg_len, (void **)&frame,
5063 (void **)&packet);
5064 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
5065 pe_err("call to bufAlloc failed for AUTH frame");
5066 return;
5067 }
5068
5069 qdf_mem_copy(frame, mb_msg->data, msg_len);
5070
5071 lim_tx_mgmt_frame(mac_ctx, mb_msg, msg_len, packet, frame);
5072}