blob: 8245887582db04d598ef09a2e490f6346030670d [file] [log] [blame]
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001/*
Alok Kumar2107a962020-01-13 15:35:29 +05302 * Copyright (c) 2011-2020 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"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080030#include "utils_api.h"
31#include "lim_types.h"
32#include "lim_utils.h"
33#include "lim_security_utils.h"
34#include "lim_prop_exts_utils.h"
35#include "dot11f.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080036#include "sch_api.h"
37#include "lim_send_messages.h"
38#include "lim_assoc_utils.h"
39#include "lim_ft.h"
40#ifdef WLAN_FEATURE_11W
41#include "wni_cfg.h"
42#endif
43
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080044#include "lim_ft_defs.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080045#include "lim_session.h"
Anurag Chouhan6d760662016-02-20 16:05:43 +053046#include "qdf_types.h"
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053047#include "qdf_trace.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080048#include "cds_utils.h"
49#include "sme_trace.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080050#include "rrm_api.h"
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +053051#include "qdf_crypto.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080052
53#include "wma_types.h"
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -080054#include <cdp_txrx_cmn.h>
Tushnim Bhattacharyya45ed04f2017-03-15 10:15:05 -070055#include <cdp_txrx_peer_ops.h>
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +053056#include "lim_process_fils.h"
Naveen Rawat08db88f2017-09-08 15:07:48 -070057#include "wlan_utility.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080058
59/**
60 *
61 * \brief This function is called to add the sequence number to the
62 * management frames
63 *
Jeff Johnson99f25042018-11-21 22:49:06 -080064 * \param mac Pointer to Global MAC structure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080065 *
66 * \param pMacHdr Pointer to MAC management header
67 *
68 * The pMacHdr argument points to the MAC management header. The
Jeff Johnson99f25042018-11-21 22:49:06 -080069 * sequence number stored in the mac structure will be incremented
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080070 * and updated to the MAC management header. The start sequence
71 * number is WLAN_HOST_SEQ_NUM_MIN and the end value is
72 * WLAN_HOST_SEQ_NUM_MAX. After reaching the MAX value, the sequence
73 * number will roll over.
74 *
75 */
Jeff Johnson9320c1e2018-12-02 13:09:20 -080076static void lim_add_mgmt_seq_num(struct mac_context *mac, tpSirMacMgmtHdr pMacHdr)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080077{
Jeff Johnson99f25042018-11-21 22:49:06 -080078 if (mac->mgmtSeqNum >= WLAN_HOST_SEQ_NUM_MAX) {
79 mac->mgmtSeqNum = WLAN_HOST_SEQ_NUM_MIN - 1;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080080 }
81
Jeff Johnson99f25042018-11-21 22:49:06 -080082 mac->mgmtSeqNum++;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080083
Jeff Johnson99f25042018-11-21 22:49:06 -080084 pMacHdr->seqControl.seqNumLo = (mac->mgmtSeqNum & LOW_SEQ_NUM_MASK);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080085 pMacHdr->seqControl.seqNumHi =
Jeff Johnson99f25042018-11-21 22:49:06 -080086 ((mac->mgmtSeqNum & HIGH_SEQ_NUM_MASK) >> HIGH_SEQ_NUM_OFFSET);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080087}
88
89/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080090 * lim_populate_mac_header() - Fill in 802.11 header of frame
91 *
92 * @mac_ctx: Pointer to Global MAC structure
93 * @buf: Pointer to the frame buffer that needs to be populate
94 * @type: 802.11 Type of the frame
95 * @sub_type: 802.11 Subtype of the frame
96 * @peer_addr: dst address
97 * @self_mac_addr: local mac address
98 *
99 * This function is called by various LIM modules to prepare the
100 * 802.11 frame MAC header
101 *
102 * The buf argument points to the beginning of the frame buffer to
103 * which - a) The 802.11 MAC header is set b) Following this MAC header
104 * will be the MGMT frame payload The payload itself is populated by the
105 * caller API
106 *
107 * Return: None
108 */
109
Jeff Johnson9320c1e2018-12-02 13:09:20 -0800110void lim_populate_mac_header(struct mac_context *mac_ctx, uint8_t *buf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800111 uint8_t type, uint8_t sub_type, tSirMacAddr peer_addr,
112 tSirMacAddr self_mac_addr)
113{
114 tpSirMacMgmtHdr mac_hdr;
115
116 /* Prepare MAC management header */
117 mac_hdr = (tpSirMacMgmtHdr) (buf);
118
119 /* Prepare FC */
120 mac_hdr->fc.protVer = SIR_MAC_PROTOCOL_VERSION;
121 mac_hdr->fc.type = type;
122 mac_hdr->fc.subType = sub_type;
123
124 /* Prepare Address 1 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530125 qdf_mem_copy((uint8_t *) mac_hdr->da,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800126 (uint8_t *) peer_addr, sizeof(tSirMacAddr));
127
128 /* Prepare Address 2 */
129 sir_copy_mac_addr(mac_hdr->sa, self_mac_addr);
130
131 /* Prepare Address 3 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530132 qdf_mem_copy((uint8_t *) mac_hdr->bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800133 (uint8_t *) peer_addr, sizeof(tSirMacAddr));
134
135 /* Prepare sequence number */
136 lim_add_mgmt_seq_num(mac_ctx, mac_hdr);
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700137 pe_debug("seqNumLo=%d, seqNumHi=%d, mgmtSeqNum=%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800138 mac_hdr->seqControl.seqNumLo,
139 mac_hdr->seqControl.seqNumHi, mac_ctx->mgmtSeqNum);
140}
141
142/**
143 * lim_send_probe_req_mgmt_frame() - send probe request management frame
144 * @mac_ctx: Pointer to Global MAC structure
145 * @ssid: SSID to be sent in Probe Request frame
146 * @bssid: BSSID to be sent in Probe Request frame
147 * @channel: Channel # on which the Probe Request is going out
148 * @self_macaddr: self MAC address
149 * @dot11mode: self dotllmode
150 * @additional_ielen: if non-zero, include additional_ie in the Probe Request
151 * frame
152 * @additional_ie: if additional_ielen is non zero, include this field in the
153 * Probe Request frame
154 *
155 * This function is called by various LIM modules to send Probe Request frame
156 * during active scan/learn phase.
157 * Probe request is sent out in the following scenarios:
158 * --heartbeat failure: session needed
159 * --join req: session needed
160 * --foreground scan: no session
161 * --background scan: no session
162 * --sch_beacon_processing: to get EDCA parameters: session needed
163 *
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700164 * Return: QDF_STATUS (QDF_STATUS_SUCCESS on success and error codes otherwise)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800165 */
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700166QDF_STATUS
Jeff Johnson9320c1e2018-12-02 13:09:20 -0800167lim_send_probe_req_mgmt_frame(struct mac_context *mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800168 tSirMacSSid *ssid,
169 tSirMacAddr bssid,
170 uint8_t channel,
171 tSirMacAddr self_macaddr,
172 uint32_t dot11mode,
Jeff Johnson919f2c32019-01-16 11:22:24 -0800173 uint16_t *additional_ielen,
174 uint8_t *additional_ie)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800175{
176 tDot11fProbeRequest pr;
177 uint32_t status, bytes, payload;
178 uint8_t *frame;
179 void *packet;
Kapil Guptac03eb072016-08-09 14:01:36 +0530180 QDF_STATUS qdf_status;
Jeff Johnsona7815652018-11-18 22:58:30 -0800181 struct pe_session *pesession;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800182 uint8_t sessionid;
Naveen Rawat08db88f2017-09-08 15:07:48 -0700183 const uint8_t *p2pie = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800184 uint8_t txflag = 0;
Abhishek Singhcc02c9b2019-11-25 14:51:30 +0530185 uint8_t vdev_id = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800186 bool is_vht_enabled = false;
187 uint8_t txPower;
Arif Hussain4c265132018-04-23 18:55:26 -0700188 uint16_t addn_ielen = 0;
Kapil Guptac03eb072016-08-09 14:01:36 +0530189 bool extracted_ext_cap_flag = false;
190 tDot11fIEExtCap extracted_ext_cap;
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700191 QDF_STATUS sir_status;
Abhishek Singh67e02bd2017-12-11 10:47:12 +0530192 const uint8_t *qcn_ie = NULL;
Amruta Kulkarni453c4e22019-11-20 10:59:21 -0800193 uint32_t chan_freq;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800194
Arif Hussain4c265132018-04-23 18:55:26 -0700195 if (additional_ielen)
196 addn_ielen = *additional_ielen;
197
Jeff Johnson919f2c32019-01-16 11:22:24 -0800198 /*
199 * The probe req should not send 11ac capabilities if band is
200 * 2.4GHz, unless gEnableVhtFor24GHzBand is enabled in INI. So
201 * if gEnableVhtFor24GHzBand is false and dot11mode is 11ac
202 * set it to 11n.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800203 */
204 if (channel <= SIR_11B_CHANNEL_END &&
Abhinav Kumare057b412018-10-09 17:28:16 +0530205 !mac_ctx->mlme_cfg->vht_caps.vht_cap_info.b24ghz_band &&
gaurank kathpalia0c48d3d2019-01-29 15:03:07 +0530206 (MLME_DOT11_MODE_11AC == dot11mode ||
207 MLME_DOT11_MODE_11AC_ONLY == dot11mode))
208 dot11mode = MLME_DOT11_MODE_11N;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800209 /*
210 * session context may or may not be present, when probe request needs
211 * to be sent out. Following cases exist:
212 * --heartbeat failure: session needed
213 * --join req: session needed
214 * --foreground scan: no session
215 * --background scan: no session
216 * --sch_beacon_processing: to get EDCA parameters: session needed
217 * If session context does not exist, some IEs will be populated from
218 * CFGs, e.g. Supported and Extended rate set IEs
219 */
220 pesession = pe_find_session_by_bssid(mac_ctx, bssid, &sessionid);
221
Jeff Johnson8e9530b2019-03-18 13:41:42 -0700222 if (pesession)
Abhishek Singhcc02c9b2019-11-25 14:51:30 +0530223 vdev_id = pesession->vdev_id;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800224
225 /* The scheme here is to fill out a 'tDot11fProbeRequest' structure */
226 /* and then hand it off to 'dot11f_pack_probe_request' (for */
227 /* serialization). We start by zero-initializing the structure: */
hangtian127c9532019-01-12 13:29:07 +0800228 qdf_mem_zero((uint8_t *) &pr, sizeof(pr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800229
230 /* & delegating to assorted helpers: */
231 populate_dot11f_ssid(mac_ctx, ssid, &pr.SSID);
232
233 if (addn_ielen && additional_ie)
234 p2pie = limGetP2pIEPtr(mac_ctx, additional_ie, addn_ielen);
235
236 /*
237 * Don't include 11b rate if it is a P2P serach or probe request is
238 * sent by P2P Client
239 */
Jeff Johnson8e9530b2019-03-18 13:41:42 -0700240 if ((MLME_DOT11_MODE_11B != dot11mode) && (p2pie) &&
Pragaspathi Thilagaraje64714a2019-05-23 00:46:25 +0530241 ((pesession) && (QDF_P2P_CLIENT_MODE == pesession->opmode))) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800242 /*
243 * In the below API pass channel number > 14, do that it fills
244 * only 11a rates in supported rates
245 */
246 populate_dot11f_supp_rates(mac_ctx, 15, &pr.SuppRates,
247 pesession);
248 } else {
249 populate_dot11f_supp_rates(mac_ctx, channel,
250 &pr.SuppRates, pesession);
251
gaurank kathpalia0c48d3d2019-01-29 15:03:07 +0530252 if (MLME_DOT11_MODE_11B != dot11mode) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800253 populate_dot11f_ext_supp_rates1(mac_ctx, channel,
254 &pr.ExtSuppRates);
255 }
256 }
257
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800258 /*
259 * Table 7-14 in IEEE Std. 802.11k-2008 says
260 * DS params "can" be present in RRM is disabled and "is" present if
261 * RRM is enabled. It should be ok even if we add it into probe req when
262 * RRM is not enabled.
263 */
264 populate_dot11f_ds_params(mac_ctx, &pr.DSParams, channel);
265 /* Call RRM module to get the tx power for management used. */
266 txPower = (uint8_t) rrm_get_mgmt_tx_power(mac_ctx, pesession);
267 populate_dot11f_wfatpc(mac_ctx, &pr.WFATPC, txPower, 0);
268
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800269
Jeff Johnson8e9530b2019-03-18 13:41:42 -0700270 if (pesession) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800271 pesession->htCapability = IS_DOT11_MODE_HT(dot11mode);
272 /* Include HT Capability IE */
273 if (pesession->htCapability)
274 populate_dot11f_ht_caps(mac_ctx, pesession, &pr.HTCaps);
Jeff Johnson8e9530b2019-03-18 13:41:42 -0700275 } else { /* !pesession */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800276 if (IS_DOT11_MODE_HT(dot11mode))
277 populate_dot11f_ht_caps(mac_ctx, NULL, &pr.HTCaps);
278 }
279
280 /*
281 * Set channelbonding information as "disabled" when tunned to a
282 * 2.4 GHz channel
283 */
284 if (channel <= SIR_11B_CHANNEL_END) {
285 if (mac_ctx->roam.configParam.channelBondingMode24GHz
286 == PHY_SINGLE_CHANNEL_CENTERED) {
287 pr.HTCaps.supportedChannelWidthSet =
288 eHT_CHANNEL_WIDTH_20MHZ;
289 pr.HTCaps.shortGI40MHz = 0;
290 } else {
291 pr.HTCaps.supportedChannelWidthSet =
292 eHT_CHANNEL_WIDTH_40MHZ;
293 }
294 }
Jeff Johnson8e9530b2019-03-18 13:41:42 -0700295 if (pesession) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800296 pesession->vhtCapability = IS_DOT11_MODE_VHT(dot11mode);
297 /* Include VHT Capability IE */
298 if (pesession->vhtCapability) {
299 populate_dot11f_vht_caps(mac_ctx, pesession,
300 &pr.VHTCaps);
301 is_vht_enabled = true;
302 }
303 } else {
304 if (IS_DOT11_MODE_VHT(dot11mode)) {
305 populate_dot11f_vht_caps(mac_ctx, pesession,
306 &pr.VHTCaps);
307 is_vht_enabled = true;
308 }
309 }
Jeff Johnson8e9530b2019-03-18 13:41:42 -0700310 if (pesession)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800311 populate_dot11f_ext_cap(mac_ctx, is_vht_enabled, &pr.ExtCap,
312 pesession);
313
Jeff Johnson8e9530b2019-03-18 13:41:42 -0700314 if (IS_DOT11_MODE_HE(dot11mode) && pesession)
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -0800315 lim_update_session_he_capable(mac_ctx, pesession);
316
Srinivas Girigowda28fb0122017-03-26 22:21:20 -0700317 pe_debug("Populate HE IEs");
Naveen Rawatd8feac12017-09-08 15:08:39 -0700318 populate_dot11f_he_caps(mac_ctx, pesession, &pr.he_cap);
Manikandan Mohan8e4491c2019-10-23 16:00:51 -0700319 populate_dot11f_he_6ghz_cap(mac_ctx, pesession,
320 &pr.he_6ghz_band_cap);
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -0800321
Sandeep Puligilla493fea22018-04-30 15:31:17 -0700322 if (addn_ielen && additional_ie) {
Kapil Guptac03eb072016-08-09 14:01:36 +0530323 qdf_mem_zero((uint8_t *)&extracted_ext_cap,
324 sizeof(tDot11fIEExtCap));
325 sir_status = lim_strip_extcap_update_struct(mac_ctx,
326 additional_ie,
327 &addn_ielen,
328 &extracted_ext_cap);
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700329 if (QDF_STATUS_SUCCESS != sir_status) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700330 pe_debug("Unable to Stripoff ExtCap IE from Probe Req");
Kapil Guptac03eb072016-08-09 14:01:36 +0530331 } else {
332 struct s_ext_cap *p_ext_cap =
333 (struct s_ext_cap *)
334 extracted_ext_cap.bytes;
335 if (p_ext_cap->interworking_service)
336 p_ext_cap->qos_map = 1;
Hu Wang411e0cc2016-10-28 14:56:01 +0800337 extracted_ext_cap.num_bytes =
338 lim_compute_ext_cap_ie_length
339 (&extracted_ext_cap);
Kapil Guptac03eb072016-08-09 14:01:36 +0530340 extracted_ext_cap_flag =
Hu Wang411e0cc2016-10-28 14:56:01 +0800341 (extracted_ext_cap.num_bytes > 0);
Arif Hussain4c265132018-04-23 18:55:26 -0700342 if (additional_ielen)
343 *additional_ielen = addn_ielen;
Kapil Guptac03eb072016-08-09 14:01:36 +0530344 }
Abhishek Singh67e02bd2017-12-11 10:47:12 +0530345 qcn_ie = wlan_get_vendor_ie_ptr_from_oui(SIR_MAC_QCN_OUI_TYPE,
346 SIR_MAC_QCN_OUI_TYPE_SIZE,
347 additional_ie, addn_ielen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800348 }
Abhishek Singh67e02bd2017-12-11 10:47:12 +0530349 /* Add qcn_ie only if qcn ie is not present in additional_ie */
Kiran Kumar Lokere89f01f02019-08-06 18:22:39 -0700350 if (!qcn_ie)
351 populate_dot11f_qcn_ie(mac_ctx, &pr.qcn_ie, QCN_IE_ATTR_ID_ALL);
352 else
353 populate_dot11f_qcn_ie(mac_ctx, &pr.qcn_ie,
354 QCN_IE_ATTR_ID_VHT_MCS11);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800355
Hu Wang411e0cc2016-10-28 14:56:01 +0800356 /*
357 * Extcap IE now support variable length, merge Extcap IE from addn_ie
358 * may change the frame size. Therefore, MUST merge ExtCap IE before
359 * dot11f get packed payload size.
360 */
361 if (extracted_ext_cap_flag)
Hu Wangfbd279d2016-10-31 18:24:34 +0800362 lim_merge_extcap_struct(&pr.ExtCap, &extracted_ext_cap, true);
Hu Wang411e0cc2016-10-28 14:56:01 +0800363
364 /* That's it-- now we pack it. First, how much space are we going to */
365 status = dot11f_get_packed_probe_request_size(mac_ctx, &pr, &payload);
366 if (DOT11F_FAILED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700367 pe_err("Failed to calculate the packed size for a Probe Request (0x%08x)",
Hu Wang411e0cc2016-10-28 14:56:01 +0800368 status);
369 /* We'll fall back on the worst case scenario: */
370 payload = sizeof(tDot11fProbeRequest);
371 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700372 pe_warn("There were warnings while calculating the packed size for a Probe Request (0x%08x)",
Hu Wang411e0cc2016-10-28 14:56:01 +0800373 status);
374 }
375
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800376 bytes = payload + sizeof(tSirMacMgmtHdr) + addn_ielen;
377
378 /* Ok-- try to allocate some memory: */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530379 qdf_status = cds_packet_alloc((uint16_t) bytes, (void **)&frame,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800380 (void **)&packet);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530381 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700382 pe_err("Failed to allocate %d bytes for a Probe Request", bytes);
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700383 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800384 }
385 /* Paranoia: */
hangtian127c9532019-01-12 13:29:07 +0800386 qdf_mem_zero(frame, bytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800387
388 /* Next, we fill out the buffer descriptor: */
389 lim_populate_mac_header(mac_ctx, frame, SIR_MAC_MGMT_FRAME,
390 SIR_MAC_MGMT_PROBE_REQ, bssid, self_macaddr);
391
392 /* That done, pack the Probe Request: */
393 status = dot11f_pack_probe_request(mac_ctx, &pr, frame +
394 sizeof(tSirMacMgmtHdr),
395 payload, &payload);
396 if (DOT11F_FAILED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700397 pe_err("Failed to pack a Probe Request (0x%08x)", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800398 cds_packet_free((void *)packet);
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700399 return QDF_STATUS_E_FAILURE; /* allocated! */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800400 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700401 pe_warn("There were warnings while packing a Probe Request (0x%08x)", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800402 }
403 /* Append any AddIE if present. */
404 if (addn_ielen) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530405 qdf_mem_copy(frame + sizeof(tSirMacMgmtHdr) + payload,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800406 additional_ie, addn_ielen);
407 payload += addn_ielen;
408 }
409
Amruta Kulkarni453c4e22019-11-20 10:59:21 -0800410 chan_freq = wlan_reg_chan_to_freq(mac_ctx->pdev, channel);
411
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800412 /* If this probe request is sent during P2P Search State, then we need
413 * to send it at OFDM rate.
414 */
Amruta Kulkarni453c4e22019-11-20 10:59:21 -0800415 if ((REG_BAND_5G == lim_get_rf_band(chan_freq)) ||
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800416 /*
417 * For unicast probe req mgmt from Join function we don't set
418 * above variables. So we need to add one more check whether it
Pragaspathi Thilagaraje64714a2019-05-23 00:46:25 +0530419 * is opmode is P2P_CLIENT or not
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800420 */
Pragaspathi Thilagaraje64714a2019-05-23 00:46:25 +0530421 ((pesession) && (QDF_P2P_CLIENT_MODE == pesession->opmode)))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800422 txflag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800423
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530424 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800425 wma_tx_frame(mac_ctx, packet,
426 (uint16_t) sizeof(tSirMacMgmtHdr) + payload,
427 TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS, 7,
Abhishek Singhcc02c9b2019-11-25 14:51:30 +0530428 lim_tx_complete, frame, txflag, vdev_id,
Naveen Rawat296a5182017-09-25 14:02:48 -0700429 0, RATEID_DEFAULT);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530430 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700431 pe_err("could not send Probe Request frame!");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800432 /* Pkt will be freed up by the callback */
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700433 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800434 }
435
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700436 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800437} /* End lim_send_probe_req_mgmt_frame. */
438
Jeff Johnson9320c1e2018-12-02 13:09:20 -0800439static QDF_STATUS lim_get_addn_ie_for_probe_resp(struct mac_context *mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800440 uint8_t *addIE, uint16_t *addnIELen,
441 uint8_t probeReqP2pIe)
442{
443 /* If Probe request doesn't have P2P IE, then take out P2P IE
444 from additional IE */
445 if (!probeReqP2pIe) {
446 uint8_t *tempbuf = NULL;
447 uint16_t tempLen = 0;
448 int left = *addnIELen;
449 uint8_t *ptr = addIE;
450 uint8_t elem_id, elem_len;
451
Jeff Johnson8e9530b2019-03-18 13:41:42 -0700452 if (!addIE) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700453 pe_err("NULL addIE pointer");
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700454 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800455 }
456
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530457 tempbuf = qdf_mem_malloc(left);
Arif Hussainf5b6c412018-10-10 19:41:09 -0700458 if (!tempbuf)
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700459 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800460
461 while (left >= 2) {
462 elem_id = ptr[0];
463 elem_len = ptr[1];
464 left -= 2;
465 if (elem_len > left) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700466 pe_err("Invalid IEs eid: %d elem_len: %d left: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800467 elem_id, elem_len, left);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530468 qdf_mem_free(tempbuf);
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700469 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800470 }
Srinivas Girigowda61771262019-04-01 11:55:19 -0700471 if (!((WLAN_ELEMID_VENDOR == elem_id) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800472 (memcmp
473 (&ptr[2], SIR_MAC_P2P_OUI,
474 SIR_MAC_P2P_OUI_SIZE) == 0))) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530475 qdf_mem_copy(tempbuf + tempLen, &ptr[0],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800476 elem_len + 2);
477 tempLen += (elem_len + 2);
478 }
479 left -= elem_len;
480 ptr += (elem_len + 2);
481 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530482 qdf_mem_copy(addIE, tempbuf, tempLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800483 *addnIELen = tempLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530484 qdf_mem_free(tempbuf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800485 }
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700486 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800487}
488
Wu Gao88053692019-12-11 12:17:13 +0800489/**
490 * lim_add_additional_ie() - Add additional IE to management frame
491 * @frame: pointer to frame
492 * @frame_offset: current offset of frame
493 * @add_ie: pointer to addtional ie
494 * @add_ie_len: length of addtional ie
495 * @p2p_ie: pointer to p2p ie
496 * @noa_ie: pointer to noa ie, this is seperate p2p ie
497 * @noa_ie_len: length of noa ie
498 * @noa_stream: pointer to noa stream, this is noa attribute only
499 * @noa_stream_len: length of noa stream
500 *
501 * This function adds additional IE to management frame.
502 *
503 * Return: None
504 */
505static void lim_add_additional_ie(uint8_t *frame, uint32_t frame_offset,
506 uint8_t *add_ie, uint32_t add_ie_len,
507 uint8_t *p2p_ie, uint8_t *noa_ie,
508 uint32_t noa_ie_len, uint8_t *noa_stream,
509 uint32_t noa_stream_len) {
510 uint16_t p2p_ie_offset;
511
512 if (!add_ie_len || !add_ie) {
513 pe_debug("no valid addtional ie");
514 return;
515 }
516
517 if (!noa_stream_len) {
518 qdf_mem_copy(frame + frame_offset, &add_ie[0], add_ie_len);
519 return;
520 }
521
522 if (noa_ie_len > (SIR_MAX_NOA_ATTR_LEN + SIR_P2P_IE_HEADER_LEN)) {
523 pe_err("Not able to insert NoA, len=%d", noa_ie_len);
524 return;
525 } else if (noa_ie_len > 0) {
526 pe_debug("new p2p ie for noa attr");
527 qdf_mem_copy(frame + frame_offset, &add_ie[0], add_ie_len);
528 frame_offset += add_ie_len;
529 qdf_mem_copy(frame + frame_offset, &noa_ie[0], noa_ie_len);
530 } else {
531 if (!p2p_ie || (p2p_ie < add_ie) ||
532 (p2p_ie > (add_ie + add_ie_len))) {
533 pe_err("invalid p2p ie");
534 return;
535 }
536 p2p_ie_offset = p2p_ie - add_ie + p2p_ie[1] + 2;
537 if (p2p_ie_offset > add_ie_len) {
538 pe_err("Invalid p2p ie");
539 return;
540 }
541 pe_debug("insert noa attr to existed p2p ie");
542 p2p_ie[1] = p2p_ie[1] + noa_stream_len;
543 qdf_mem_copy(frame + frame_offset, &add_ie[0], p2p_ie_offset);
544 frame_offset += p2p_ie_offset;
545 qdf_mem_copy(frame + frame_offset, &noa_stream[0],
546 noa_stream_len);
547 if (p2p_ie_offset < add_ie_len) {
548 frame_offset += noa_stream_len;
549 qdf_mem_copy(frame + frame_offset,
550 &add_ie[p2p_ie_offset],
551 add_ie_len - p2p_ie_offset);
552 }
553 }
554}
555
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800556void
Jeff Johnson9320c1e2018-12-02 13:09:20 -0800557lim_send_probe_rsp_mgmt_frame(struct mac_context *mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800558 tSirMacAddr peer_macaddr,
559 tpAniSSID ssid,
Jeff Johnson3c08ace2019-03-12 08:50:37 -0700560 struct pe_session *pe_session,
561 uint8_t preq_p2pie)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800562{
563 tDot11fProbeResponse *frm;
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700564 QDF_STATUS sir_status;
Hu Wang411e0cc2016-10-28 14:56:01 +0800565 uint32_t cfg, payload, bytes = 0, status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800566 tpSirMacMgmtHdr mac_hdr;
567 uint8_t *frame;
Arif Hussainfbf50682016-06-15 12:57:43 -0700568 void *packet = NULL;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530569 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800570 uint32_t addn_ie_present = false;
571
572 uint16_t addn_ie_len = 0;
gaurank kathpalia837f6202018-09-14 21:55:32 +0530573 bool wps_ap = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800574 uint8_t tx_flag = 0;
575 uint8_t *add_ie = NULL;
Wu Gao88053692019-12-11 12:17:13 +0800576 uint8_t *p2p_ie = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800577 uint8_t noalen = 0;
578 uint8_t total_noalen = 0;
579 uint8_t noa_stream[SIR_MAX_NOA_ATTR_LEN + SIR_P2P_IE_HEADER_LEN];
580 uint8_t noa_ie[SIR_MAX_NOA_ATTR_LEN + SIR_P2P_IE_HEADER_LEN];
Abhishek Singhcc02c9b2019-11-25 14:51:30 +0530581 uint8_t vdev_id = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800582 bool is_vht_enabled = false;
Padma, Santhosh Kumar92234472017-04-19 18:20:02 +0530583 tDot11fIEExtCap extracted_ext_cap = {0};
Selvaraj, Sridhar94ece202016-06-23 20:44:09 +0530584 bool extracted_ext_cap_flag = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800585
586 /* We don't answer requests in this case*/
Srinivas Girigowda35b00312017-06-27 21:52:03 -0700587 if (ANI_DRIVER_TYPE(mac_ctx) == QDF_DRIVER_TYPE_MFG)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800588 return;
589
Jeff Johnson8e9530b2019-03-18 13:41:42 -0700590 if (!pe_session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800591 return;
592
593 /*
594 * In case when cac timer is running for this SAP session then
595 * avoid sending probe rsp out. It is violation of dfs specification.
596 */
Pragaspathi Thilagaraje64714a2019-05-23 00:46:25 +0530597 if (((pe_session->opmode == QDF_SAP_MODE) ||
598 (pe_session->opmode == QDF_P2P_GO_MODE)) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800599 (true == mac_ctx->sap.SapDfsInfo.is_dfs_cac_timer_running)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530600 QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_INFO,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800601 FL("CAC timer is running, probe response dropped"));
602 return;
603 }
Abhishek Singhcc02c9b2019-11-25 14:51:30 +0530604 vdev_id = pe_session->vdev_id;
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530605 frm = qdf_mem_malloc(sizeof(tDot11fProbeResponse));
Arif Hussainf5b6c412018-10-10 19:41:09 -0700606 if (!frm)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800607 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800608
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800609 /*
610 * Fill out 'frm', after which we'll just hand the struct off to
611 * 'dot11f_pack_probe_response'.
612 */
hangtian127c9532019-01-12 13:29:07 +0800613 qdf_mem_zero((uint8_t *) frm, sizeof(tDot11fProbeResponse));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800614
615 /*
616 * Timestamp to be updated by TFP, below.
617 *
618 * Beacon Interval:
619 */
620 if (LIM_IS_AP_ROLE(pe_session)) {
621 frm->BeaconInterval.interval =
Jeff Johnsonac057412019-01-06 11:08:55 -0800622 mac_ctx->sch.beacon_interval;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800623 } else {
Bala Venkatesh2fde2c62018-09-11 20:33:24 +0530624 cfg = mac_ctx->mlme_cfg->sap_cfg.beacon_interval;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800625 frm->BeaconInterval.interval = (uint16_t) cfg;
626 }
627
628 populate_dot11f_capabilities(mac_ctx, &frm->Capabilities, pe_session);
629 populate_dot11f_ssid(mac_ctx, (tSirMacSSid *) ssid, &frm->SSID);
630 populate_dot11f_supp_rates(mac_ctx, POPULATE_DOT11F_RATES_OPERATIONAL,
631 &frm->SuppRates, pe_session);
632
Liangwei Dong419d7302019-07-15 15:38:28 +0800633 populate_dot11f_ds_params(
634 mac_ctx, &frm->DSParams,
635 wlan_reg_freq_to_chan(mac_ctx->pdev,
636 pe_session->curr_op_freq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800637 populate_dot11f_ibss_params(mac_ctx, &frm->IBSSParams, pe_session);
638
639 if (LIM_IS_AP_ROLE(pe_session)) {
640 if (pe_session->wps_state != SAP_WPS_DISABLED)
641 populate_dot11f_probe_res_wpsi_es(mac_ctx,
642 &frm->WscProbeRes,
643 pe_session);
644 } else {
gaurank kathpalia837f6202018-09-14 21:55:32 +0530645 wps_ap = mac_ctx->mlme_cfg->wps_params.enable_wps &
646 WNI_CFG_WPS_ENABLE_AP;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800647 if (wps_ap)
648 populate_dot11f_wsc_in_probe_res(mac_ctx,
649 &frm->WscProbeRes);
650
651 if (mac_ctx->lim.wscIeInfo.probeRespWscEnrollmentState ==
652 eLIM_WSC_ENROLL_BEGIN) {
653 populate_dot11f_wsc_registrar_info_in_probe_res(mac_ctx,
654 &frm->WscProbeRes);
655 mac_ctx->lim.wscIeInfo.probeRespWscEnrollmentState =
656 eLIM_WSC_ENROLL_IN_PROGRESS;
657 }
658
659 if (mac_ctx->lim.wscIeInfo.wscEnrollmentState ==
660 eLIM_WSC_ENROLL_END) {
661 de_populate_dot11f_wsc_registrar_info_in_probe_res(
662 mac_ctx, &frm->WscProbeRes);
663 mac_ctx->lim.wscIeInfo.probeRespWscEnrollmentState =
664 eLIM_WSC_ENROLL_NOOP;
665 }
666 }
667
668 populate_dot11f_country(mac_ctx, &frm->Country, pe_session);
669 populate_dot11f_edca_param_set(mac_ctx, &frm->EDCAParamSet, pe_session);
670
gaurank kathpalia0c48d3d2019-01-29 15:03:07 +0530671 if (pe_session->dot11mode != MLME_DOT11_MODE_11B)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800672 populate_dot11f_erp_info(mac_ctx, &frm->ERPInfo, pe_session);
673
674 populate_dot11f_ext_supp_rates(mac_ctx,
675 POPULATE_DOT11F_RATES_OPERATIONAL,
676 &frm->ExtSuppRates, pe_session);
677
678 /* Populate HT IEs, when operating in 11n */
679 if (pe_session->htCapability) {
680 populate_dot11f_ht_caps(mac_ctx, pe_session, &frm->HTCaps);
681 populate_dot11f_ht_info(mac_ctx, &frm->HTInfo, pe_session);
682 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800683 if (pe_session->vhtCapability) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700684 pe_debug("Populate VHT IE in Probe Response");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800685 populate_dot11f_vht_caps(mac_ctx, pe_session, &frm->VHTCaps);
686 populate_dot11f_vht_operation(mac_ctx, pe_session,
687 &frm->VHTOperation);
688 /*
689 * we do not support multi users yet.
690 * populate_dot11f_vht_ext_bss_load( mac_ctx,
691 * &frm.VHTExtBssLoad );
692 */
693 is_vht_enabled = true;
694 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800695
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -0800696 if (lim_is_session_he_capable(pe_session)) {
Srinivas Girigowda28fb0122017-03-26 22:21:20 -0700697 pe_debug("Populate HE IEs");
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -0800698 populate_dot11f_he_caps(mac_ctx, pe_session,
Naveen Rawatd8feac12017-09-08 15:08:39 -0700699 &frm->he_cap);
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -0800700 populate_dot11f_he_operation(mac_ctx, pe_session,
Naveen Rawatd8feac12017-09-08 15:08:39 -0700701 &frm->he_op);
Manikandan Mohan8e4491c2019-10-23 16:00:51 -0700702 populate_dot11f_he_6ghz_cap(mac_ctx, pe_session,
703 &frm->he_6ghz_band_cap);
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -0800704 }
705
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800706 populate_dot11f_ext_cap(mac_ctx, is_vht_enabled, &frm->ExtCap,
707 pe_session);
708
709 if (pe_session->pLimStartBssReq) {
710 populate_dot11f_wpa(mac_ctx,
711 &(pe_session->pLimStartBssReq->rsnIE),
712 &frm->WPA);
713 populate_dot11f_rsn_opaque(mac_ctx,
714 &(pe_session->pLimStartBssReq->rsnIE),
715 &frm->RSNOpaque);
716 }
717
718 populate_dot11f_wmm(mac_ctx, &frm->WMMInfoAp, &frm->WMMParams,
719 &frm->WMMCaps, pe_session);
720
721#if defined(FEATURE_WLAN_WAPI)
722 if (pe_session->pLimStartBssReq)
723 populate_dot11f_wapi(mac_ctx,
724 &(pe_session->pLimStartBssReq->rsnIE),
725 &frm->WAPI);
726#endif /* defined(FEATURE_WLAN_WAPI) */
727
Liangwei Dongd7c5e012018-12-16 23:56:50 -0500728 /*
729 * Only use CFG for non-listen mode. This CFG is not working for
730 * concurrency. In listening mode, probe rsp IEs is passed in
731 * the message from SME to PE.
732 */
733 addn_ie_present =
Jeff Johnson21aac3a2019-02-02 14:26:13 -0800734 (pe_session->add_ie_params.probeRespDataLen != 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800735
736 if (addn_ie_present) {
737
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530738 add_ie = qdf_mem_malloc(
Jeff Johnson21aac3a2019-02-02 14:26:13 -0800739 pe_session->add_ie_params.probeRespDataLen);
Arif Hussainf5b6c412018-10-10 19:41:09 -0700740 if (!add_ie)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800741 goto err_ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800742
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530743 qdf_mem_copy(add_ie,
Jeff Johnson21aac3a2019-02-02 14:26:13 -0800744 pe_session->add_ie_params.probeRespData_buff,
745 pe_session->add_ie_params.probeRespDataLen);
746 addn_ie_len = pe_session->add_ie_params.probeRespDataLen;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800747
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700748 if (QDF_STATUS_SUCCESS != lim_get_addn_ie_for_probe_resp(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800749 add_ie, &addn_ie_len, preq_p2pie)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700750 pe_err("Unable to get addn_ie");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800751 goto err_ret;
752 }
753
754 sir_status = lim_strip_extcap_update_struct(mac_ctx,
755 add_ie, &addn_ie_len,
756 &extracted_ext_cap);
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700757 if (QDF_STATUS_SUCCESS != sir_status) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700758 pe_debug("Unable to strip off ExtCap IE");
Selvaraj, Sridhar94ece202016-06-23 20:44:09 +0530759 } else {
760 extracted_ext_cap_flag = true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800761 }
762
763 bytes = bytes + addn_ie_len;
764
765 if (preq_p2pie)
Wu Gao88053692019-12-11 12:17:13 +0800766 p2p_ie = (uint8_t *)limGetP2pIEPtr(mac_ctx, &add_ie[0],
767 addn_ie_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800768
Jeff Johnson8e9530b2019-03-18 13:41:42 -0700769 if (p2p_ie) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800770 /* get NoA attribute stream P2P IE */
771 noalen = lim_get_noa_attr_stream(mac_ctx,
772 noa_stream, pe_session);
Wu Gao88053692019-12-11 12:17:13 +0800773 if (noalen) {
774 if ((p2p_ie[1] + noalen) >
775 WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA_LEN) {
776 total_noalen = lim_build_p2p_ie(
777 mac_ctx,
778 &noa_ie[0],
779 &noa_stream[0],
780 noalen);
781 bytes = bytes + total_noalen;
782 } else {
783 bytes = bytes + noalen;
784 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800785 }
786 }
787 }
788
Hu Wang411e0cc2016-10-28 14:56:01 +0800789 /*
790 * Extcap IE now support variable length, merge Extcap IE from addn_ie
791 * may change the frame size. Therefore, MUST merge ExtCap IE before
792 * dot11f get packed payload size.
793 */
794 if (extracted_ext_cap_flag)
Hu Wangfbd279d2016-10-31 18:24:34 +0800795 lim_merge_extcap_struct(&frm->ExtCap, &extracted_ext_cap,
796 true);
Hu Wang411e0cc2016-10-28 14:56:01 +0800797
798 status = dot11f_get_packed_probe_response_size(mac_ctx, frm, &payload);
799 if (DOT11F_FAILED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700800 pe_err("Probe Response size error (0x%08x)",
Hu Wang411e0cc2016-10-28 14:56:01 +0800801 status);
802 /* We'll fall back on the worst case scenario: */
803 payload = sizeof(tDot11fProbeResponse);
804 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700805 pe_warn("Probe Response size warning (0x%08x)",
Hu Wang411e0cc2016-10-28 14:56:01 +0800806 status);
807 }
808
809 bytes += payload + sizeof(tSirMacMgmtHdr);
810
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530811 qdf_status = cds_packet_alloc((uint16_t) bytes, (void **)&frame,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800812 (void **)&packet);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530813 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700814 pe_err("Probe Response allocation failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800815 goto err_ret;
816 }
817 /* Paranoia: */
hangtian127c9532019-01-12 13:29:07 +0800818 qdf_mem_zero(frame, bytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800819
820 /* Next, we fill out the buffer descriptor: */
821 lim_populate_mac_header(mac_ctx, frame, SIR_MAC_MGMT_FRAME,
822 SIR_MAC_MGMT_PROBE_RSP, peer_macaddr,
Pragaspathi Thilagaraj7fb14222019-06-17 23:26:58 +0530823 pe_session->self_mac_addr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800824
825 mac_hdr = (tpSirMacMgmtHdr) frame;
826
827 sir_copy_mac_addr(mac_hdr->bssId, pe_session->bssId);
828
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800829 /* That done, pack the Probe Response: */
830 status =
831 dot11f_pack_probe_response(mac_ctx, frm,
832 frame + sizeof(tSirMacMgmtHdr),
833 payload, &payload);
834 if (DOT11F_FAILED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700835 pe_err("Probe Response pack failure (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800836 status);
837 goto err_ret;
838 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700839 pe_warn("Probe Response pack warning (0x%08x)", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800840 }
841
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700842 pe_debug("Sending Probe Response frame to");
Nishank Aggarwal46bd31a2017-03-10 16:23:53 +0530843 lim_print_mac_addr(mac_ctx, peer_macaddr, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800844
Wu Gao88053692019-12-11 12:17:13 +0800845 lim_add_additional_ie(frame, sizeof(tSirMacMgmtHdr) + payload, add_ie,
846 addn_ie_len, p2p_ie, noa_ie, total_noalen,
847 noa_stream, noalen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800848
Liangwei Dong419d7302019-07-15 15:38:28 +0800849 if (wlan_reg_is_5ghz_ch_freq(pe_session->curr_op_freq) ||
850 pe_session->opmode == QDF_P2P_CLIENT_MODE ||
851 pe_session->opmode == QDF_P2P_GO_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800852 tx_flag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
853
854 /* Queue Probe Response frame in high priority WQ */
Jeff Johnson59429b02018-11-07 13:53:18 -0800855 qdf_status = wma_tx_frame(mac_ctx, packet,
856 (uint16_t)bytes,
857 TXRX_FRM_802_11_MGMT,
858 ANI_TXDIR_TODS,
859 7, lim_tx_complete, frame, tx_flag,
Abhishek Singhcc02c9b2019-11-25 14:51:30 +0530860 vdev_id, 0, RATEID_DEFAULT);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800861
862 /* Pkt will be freed up by the callback */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530863 if (!QDF_IS_STATUS_SUCCESS(qdf_status))
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700864 pe_err("Could not send Probe Response");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800865
Jeff Johnson8e9530b2019-03-18 13:41:42 -0700866 if (add_ie)
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530867 qdf_mem_free(add_ie);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800868
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530869 qdf_mem_free(frm);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800870 return;
871
872err_ret:
Jeff Johnson8e9530b2019-03-18 13:41:42 -0700873 if (add_ie)
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530874 qdf_mem_free(add_ie);
Jeff Johnson8e9530b2019-03-18 13:41:42 -0700875 if (frm)
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530876 qdf_mem_free(frm);
Jeff Johnson8e9530b2019-03-18 13:41:42 -0700877 if (packet)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800878 cds_packet_free((void *)packet);
879 return;
880
881} /* End lim_send_probe_rsp_mgmt_frame. */
882
883void
Jeff Johnson9320c1e2018-12-02 13:09:20 -0800884lim_send_addts_req_action_frame(struct mac_context *mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800885 tSirMacAddr peerMacAddr,
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800886 tSirAddtsReqInfo *pAddTS, struct pe_session *pe_session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800887{
888 uint16_t i;
889 uint8_t *pFrame;
890 tDot11fAddTSRequest AddTSReq;
891 tDot11fWMMAddTSRequest WMMAddTSReq;
892 uint32_t nPayload, nBytes, nStatus;
893 tpSirMacMgmtHdr pMacHdr;
894 void *pPacket;
895#ifdef FEATURE_WLAN_ESE
896 uint32_t phyMode;
897#endif
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530898 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800899 uint8_t txFlag = 0;
900 uint8_t smeSessionId = 0;
901
Jeff Johnson8e9530b2019-03-18 13:41:42 -0700902 if (!pe_session) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800903 return;
904 }
905
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800906 smeSessionId = pe_session->smeSessionId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800907
908 if (!pAddTS->wmeTspecPresent) {
hangtian127c9532019-01-12 13:29:07 +0800909 qdf_mem_zero((uint8_t *) &AddTSReq, sizeof(AddTSReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800910
Srinivas Girigowda03cebc32019-05-17 16:50:31 -0700911 AddTSReq.Action.action = QOS_ADD_TS_REQ;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800912 AddTSReq.DialogToken.token = pAddTS->dialogToken;
Srinivas Girigowda48bec1c2019-05-17 16:33:30 -0700913 AddTSReq.Category.category = ACTION_CATEGORY_QOS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800914 if (pAddTS->lleTspecPresent) {
915 populate_dot11f_tspec(&pAddTS->tspec, &AddTSReq.TSPEC);
916 } else {
917 populate_dot11f_wmmtspec(&pAddTS->tspec,
918 &AddTSReq.WMMTSPEC);
919 }
920
921 if (pAddTS->lleTspecPresent) {
922 AddTSReq.num_WMMTCLAS = 0;
923 AddTSReq.num_TCLAS = pAddTS->numTclas;
924 for (i = 0; i < pAddTS->numTclas; ++i) {
Jeff Johnson99f25042018-11-21 22:49:06 -0800925 populate_dot11f_tclas(mac, &pAddTS->tclasInfo[i],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800926 &AddTSReq.TCLAS[i]);
927 }
928 } else {
929 AddTSReq.num_TCLAS = 0;
930 AddTSReq.num_WMMTCLAS = pAddTS->numTclas;
931 for (i = 0; i < pAddTS->numTclas; ++i) {
Jeff Johnson99f25042018-11-21 22:49:06 -0800932 populate_dot11f_wmmtclas(mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800933 &pAddTS->tclasInfo[i],
934 &AddTSReq.WMMTCLAS[i]);
935 }
936 }
937
938 if (pAddTS->tclasProcPresent) {
939 if (pAddTS->lleTspecPresent) {
940 AddTSReq.TCLASSPROC.processing =
941 pAddTS->tclasProc;
942 AddTSReq.TCLASSPROC.present = 1;
943 } else {
944 AddTSReq.WMMTCLASPROC.version = 1;
945 AddTSReq.WMMTCLASPROC.processing =
946 pAddTS->tclasProc;
947 AddTSReq.WMMTCLASPROC.present = 1;
948 }
949 }
950
951 nStatus =
Jeff Johnson99f25042018-11-21 22:49:06 -0800952 dot11f_get_packed_add_ts_request_size(mac, &AddTSReq, &nPayload);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800953 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700954 pe_err("Failed to calculate the packed size for an Add TS Request (0x%08x)",
955 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800956 /* We'll fall back on the worst case scenario: */
957 nPayload = sizeof(tDot11fAddTSRequest);
958 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700959 pe_warn("There were warnings while calculating the packed size for an Add TS Request (0x%08x)",
960 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800961 }
962 } else {
hangtian127c9532019-01-12 13:29:07 +0800963 qdf_mem_zero((uint8_t *) &WMMAddTSReq, sizeof(WMMAddTSReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800964
Srinivas Girigowda03cebc32019-05-17 16:50:31 -0700965 WMMAddTSReq.Action.action = QOS_ADD_TS_REQ;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800966 WMMAddTSReq.DialogToken.token = pAddTS->dialogToken;
Srinivas Girigowda48bec1c2019-05-17 16:33:30 -0700967 WMMAddTSReq.Category.category = ACTION_CATEGORY_WMM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800968
969 /* WMM spec 2.2.10 - status code is only filled in for ADDTS response */
970 WMMAddTSReq.StatusCode.statusCode = 0;
971
972 populate_dot11f_wmmtspec(&pAddTS->tspec, &WMMAddTSReq.WMMTSPEC);
973#ifdef FEATURE_WLAN_ESE
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800974 lim_get_phy_mode(mac, &phyMode, pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800975
976 if (phyMode == WNI_CFG_PHY_MODE_11G
977 || phyMode == WNI_CFG_PHY_MODE_11A) {
978 pAddTS->tsrsIE.rates[0] = TSRS_11AG_RATE_6MBPS;
979 } else {
980 pAddTS->tsrsIE.rates[0] = TSRS_11B_RATE_5_5MBPS;
981 }
Jeff Johnson99f25042018-11-21 22:49:06 -0800982 populate_dot11_tsrsie(mac, &pAddTS->tsrsIE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800983 &WMMAddTSReq.ESETrafStrmRateSet,
984 sizeof(uint8_t));
985#endif
986 /* fillWmeTspecIE */
987
988 nStatus =
Jeff Johnson99f25042018-11-21 22:49:06 -0800989 dot11f_get_packed_wmm_add_ts_request_size(mac, &WMMAddTSReq,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800990 &nPayload);
991 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700992 pe_err("Failed to calculate the packed size for a WMM Add TS Request (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800993 nStatus);
994 /* We'll fall back on the worst case scenario: */
995 nPayload = sizeof(tDot11fAddTSRequest);
996 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700997 pe_warn("There were warnings while calculating the packed size for a WMM Add TS Request (0x%08x)",
998 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800999 }
1000 }
1001
1002 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
1003
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301004 qdf_status = cds_packet_alloc((uint16_t) nBytes, (void **)&pFrame,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001005 (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301006 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001007 pe_err("Failed to allocate %d bytes for an Add TS Request",
1008 nBytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001009 return;
1010 }
1011 /* Paranoia: */
hangtian127c9532019-01-12 13:29:07 +08001012 qdf_mem_zero(pFrame, nBytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001013
1014 /* Next, we fill out the buffer descriptor: */
Jeff Johnson99f25042018-11-21 22:49:06 -08001015 lim_populate_mac_header(mac, pFrame, SIR_MAC_MGMT_FRAME,
Pragaspathi Thilagaraj7fb14222019-06-17 23:26:58 +05301016 SIR_MAC_MGMT_ACTION, peerMacAddr, pe_session->self_mac_addr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001017 pMacHdr = (tpSirMacMgmtHdr) pFrame;
1018
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001019 sir_copy_mac_addr(pMacHdr->bssId, pe_session->bssId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001020
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001021 lim_set_protected_bit(mac, pe_session, peerMacAddr, pMacHdr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001022
1023 /* That done, pack the struct: */
1024 if (!pAddTS->wmeTspecPresent) {
Jeff Johnson99f25042018-11-21 22:49:06 -08001025 nStatus = dot11f_pack_add_ts_request(mac, &AddTSReq,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001026 pFrame +
1027 sizeof(tSirMacMgmtHdr),
1028 nPayload, &nPayload);
1029 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001030 pe_err("Failed to pack an Add TS Request "
1031 "(0x%08x)", nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001032 cds_packet_free((void *)pPacket);
1033 return; /* allocated! */
1034 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001035 pe_warn("There were warnings while packing an Add TS Request (0x%08x)",
1036 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001037 }
1038 } else {
Jeff Johnson99f25042018-11-21 22:49:06 -08001039 nStatus = dot11f_pack_wmm_add_ts_request(mac, &WMMAddTSReq,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001040 pFrame +
1041 sizeof(tSirMacMgmtHdr),
1042 nPayload, &nPayload);
1043 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001044 pe_err("Failed to pack a WMM Add TS Request (0x%08x)",
1045 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001046 cds_packet_free((void *)pPacket);
1047 return; /* allocated! */
1048 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001049 pe_warn("There were warnings while packing a WMM Add TS Request (0x%08x)",
1050 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001051 }
1052 }
1053
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001054 pe_debug("Sending an Add TS Request frame to");
Jeff Johnson99f25042018-11-21 22:49:06 -08001055 lim_print_mac_addr(mac, peerMacAddr, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001056
Liangwei Dong419d7302019-07-15 15:38:28 +08001057 if (wlan_reg_is_5ghz_ch_freq(pe_session->curr_op_freq) ||
1058 pe_session->opmode == QDF_P2P_CLIENT_MODE ||
1059 pe_session->opmode == QDF_P2P_GO_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001060 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001061
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05301062 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001063 pe_session->peSessionId, pMacHdr->fc.subType));
Jeff Johnson99f25042018-11-21 22:49:06 -08001064 lim_diag_mgmt_tx_event_report(mac, pMacHdr,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001065 pe_session, QDF_STATUS_SUCCESS,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001066 QDF_STATUS_SUCCESS);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001067
1068 /* Queue Addts Response frame in high priority WQ */
Jeff Johnson99f25042018-11-21 22:49:06 -08001069 qdf_status = wma_tx_frame(mac, 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,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001075 pe_session->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/**
bings85512332019-09-04 17:46:37 +08001083 * lim_assoc_rsp_tx_complete() - Confirmation for assoc rsp OTA
1084 * @context: pointer to global mac
1085 * @buf: buffer which is nothing but entire assoc rsp frame
1086 * @tx_complete : Sent status
1087 * @params; tx completion params
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001088 *
bings85512332019-09-04 17:46:37 +08001089 * Return: This returns QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001090 */
bings85512332019-09-04 17:46:37 +08001091static QDF_STATUS lim_assoc_rsp_tx_complete(
1092 void *context,
1093 qdf_nbuf_t buf,
1094 uint32_t tx_complete,
1095 void *params)
1096{
1097 struct mac_context *mac_ctx = (struct mac_context *)context;
1098 tSirMacMgmtHdr *mac_hdr;
1099 struct pe_session *session_entry;
1100 uint8_t session_id;
1101 tpLimMlmAssocInd lim_assoc_ind;
1102 tpDphHashNode sta_ds;
1103 uint16_t aid;
1104 uint8_t *data;
1105 struct assoc_ind *sme_assoc_ind;
1106 struct scheduler_msg msg;
1107 tpSirAssocReq assoc_req;
1108
1109 if (!buf) {
1110 pe_err("Assoc rsp frame buffer is NULL");
1111 goto null_buf;
1112 }
1113
1114 data = qdf_nbuf_data(buf);
1115
1116 if (!data) {
1117 pe_err("Assoc rsp frame is NULL");
1118 goto end;
1119 }
1120
1121 mac_hdr = (tSirMacMgmtHdr *)data;
1122
1123 session_entry = pe_find_session_by_bssid(
1124 mac_ctx, mac_hdr->sa,
1125 &session_id);
1126 if (!session_entry) {
1127 pe_err("session entry is NULL");
1128 goto end;
1129 }
1130
1131 sta_ds = dph_lookup_hash_entry(mac_ctx,
1132 (uint8_t *)mac_hdr->da, &aid,
1133 &session_entry->dph.dphHashTable);
1134 if (!sta_ds) {
1135 pe_err("sta_ds is NULL");
1136 goto end;
1137 }
1138
1139 /* Get a copy of the already parsed Assoc Request */
1140 assoc_req =
1141 (tpSirAssocReq)session_entry->parsedAssocReq[sta_ds->assocId];
1142
1143 if (!assoc_req) {
1144 pe_err("assoc req for assoc_id:%d is NULL", sta_ds->assocId);
1145 goto end;
1146 }
1147
1148 lim_assoc_ind = qdf_mem_malloc(sizeof(tLimMlmAssocInd));
1149 if (!lim_assoc_ind) {
1150 pe_err("lim assoc ind is NULL");
1151 goto free_assoc_req;
1152 }
1153 if (!lim_fill_lim_assoc_ind_params(lim_assoc_ind, mac_ctx,
1154 sta_ds, session_entry)) {
1155 pe_err("lim assoc ind fill error");
1156 goto lim_assoc_ind;
1157 }
1158
1159 sme_assoc_ind = qdf_mem_malloc(sizeof(struct assoc_ind));
1160 if (!sme_assoc_ind) {
1161 pe_err("sme assoc ind is NULL");
1162 goto lim_assoc_ind;
1163 }
1164 sme_assoc_ind->messageType = eWNI_SME_ASSOC_IND_UPPER_LAYER;
1165 lim_fill_sme_assoc_ind_params(
1166 mac_ctx, lim_assoc_ind,
1167 sme_assoc_ind,
Chaoli Zhou98d1b3e2019-10-10 17:13:44 +08001168 session_entry, true);
bings85512332019-09-04 17:46:37 +08001169
1170 qdf_mem_zero(&msg, sizeof(struct scheduler_msg));
1171 msg.type = eWNI_SME_ASSOC_IND_UPPER_LAYER;
1172 msg.bodyptr = sme_assoc_ind;
1173 msg.bodyval = 0;
bings85512332019-09-04 17:46:37 +08001174 sme_assoc_ind->reassocReq = sta_ds->mlmStaContext.subType;
1175 sme_assoc_ind->timingMeasCap = sta_ds->timingMeasCap;
Chaoli Zhou98d1b3e2019-10-10 17:13:44 +08001176 MTRACE(mac_trace_msg_tx(mac_ctx, session_entry->peSessionId, msg.type));
1177 lim_sys_process_mmh_msg_api(mac_ctx, &msg);
bings85512332019-09-04 17:46:37 +08001178
1179 qdf_mem_free(lim_assoc_ind);
1180 if (assoc_req->assocReqFrame) {
1181 qdf_mem_free(assoc_req->assocReqFrame);
1182 assoc_req->assocReqFrame = NULL;
1183 }
1184 qdf_mem_free(session_entry->parsedAssocReq[sta_ds->assocId]);
1185 session_entry->parsedAssocReq[sta_ds->assocId] = NULL;
1186 qdf_nbuf_free(buf);
1187
1188 return QDF_STATUS_SUCCESS;
1189
1190lim_assoc_ind:
1191 qdf_mem_free(lim_assoc_ind);
1192free_assoc_req:
1193 if (assoc_req->assocReqFrame) {
1194 qdf_mem_free(assoc_req->assocReqFrame);
1195 assoc_req->assocReqFrame = NULL;
1196 }
1197 qdf_mem_free(session_entry->parsedAssocReq[sta_ds->assocId]);
1198 session_entry->parsedAssocReq[sta_ds->assocId] = NULL;
1199end:
1200 qdf_nbuf_free(buf);
1201null_buf:
1202 return QDF_STATUS_E_FAILURE;
1203}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001204
1205void
bings85512332019-09-04 17:46:37 +08001206lim_send_assoc_rsp_mgmt_frame(
1207 struct mac_context *mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001208 uint16_t status_code, uint16_t aid, tSirMacAddr peer_addr,
bings85512332019-09-04 17:46:37 +08001209 uint8_t subtype, tpDphHashNode sta, struct pe_session *pe_session,
1210 bool tx_complete)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001211{
1212 static tDot11fAssocResponse frm;
1213 uint8_t *frame;
1214 tpSirMacMgmtHdr mac_hdr;
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001215 QDF_STATUS sir_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001216 uint8_t lle_mode = 0, addts;
1217 tHalBitVal qos_mode, wme_mode;
Hu Wang411e0cc2016-10-28 14:56:01 +08001218 uint32_t payload, bytes = 0, status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001219 void *packet;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301220 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001221 tUpdateBeaconParams beacon_params;
1222 uint8_t tx_flag = 0;
1223 uint32_t addn_ie_len = 0;
1224 uint8_t add_ie[WNI_CFG_ASSOC_RSP_ADDNIE_DATA_LEN];
1225 tpSirAssocReq assoc_req = NULL;
1226 uint8_t sme_session = 0;
1227 bool is_vht = false;
1228 uint16_t stripoff_len = 0;
1229 tDot11fIEExtCap extracted_ext_cap;
1230 bool extracted_flag = false;
1231#ifdef WLAN_FEATURE_11W
Karthik Kantamneni24f71bc2018-09-11 19:08:38 +05301232 uint8_t retry_int;
1233 uint16_t max_retries;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001234#endif
1235
Jeff Johnson8e9530b2019-03-18 13:41:42 -07001236 if (!pe_session) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001237 pe_err("pe_session is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001238 return;
1239 }
1240
1241 sme_session = pe_session->smeSessionId;
1242
hangtian127c9532019-01-12 13:29:07 +08001243 qdf_mem_zero((uint8_t *) &frm, sizeof(frm));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001244
1245 limGetQosMode(pe_session, &qos_mode);
1246 limGetWmeMode(pe_session, &wme_mode);
1247
1248 /*
1249 * An Add TS IE is added only if the AP supports it and
1250 * the requesting STA sent a traffic spec.
1251 */
1252 addts = (qos_mode && sta && sta->qos.addtsPresent) ? 1 : 0;
1253
1254 frm.Status.status = status_code;
1255
1256 frm.AID.associd = aid | LIM_AID_MASK;
1257
Jeff Johnson8e9530b2019-03-18 13:41:42 -07001258 if (!sta) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001259 populate_dot11f_supp_rates(mac_ctx,
1260 POPULATE_DOT11F_RATES_OPERATIONAL,
1261 &frm.SuppRates, pe_session);
1262 populate_dot11f_ext_supp_rates(mac_ctx,
1263 POPULATE_DOT11F_RATES_OPERATIONAL,
1264 &frm.ExtSuppRates, pe_session);
1265 } else {
1266 populate_dot11f_assoc_rsp_rates(mac_ctx, &frm.SuppRates,
1267 &frm.ExtSuppRates,
1268 sta->supportedRates.llbRates,
1269 sta->supportedRates.llaRates);
1270 }
1271
Jeff Johnson8e9530b2019-03-18 13:41:42 -07001272 if (LIM_IS_AP_ROLE(pe_session) && sta &&
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001273 QDF_STATUS_SUCCESS == status_code) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001274 assoc_req = (tpSirAssocReq)
1275 pe_session->parsedAssocReq[sta->assocId];
1276 /*
Pragaspathi Thilagarajf812ccf2019-06-22 13:07:04 +05301277 * populate P2P IE in AssocRsp when assoc_req from the peer
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001278 * includes P2P IE
1279 */
Jeff Johnson8e9530b2019-03-18 13:41:42 -07001280 if (assoc_req && assoc_req->addIEPresent)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001281 populate_dot11_assoc_res_p2p_ie(mac_ctx,
1282 &frm.P2PAssocRes,
1283 assoc_req);
1284 }
1285
Jeff Johnson8e9530b2019-03-18 13:41:42 -07001286 if (sta) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001287 if (eHAL_SET == qos_mode) {
1288 if (sta->lleEnabled) {
1289 lle_mode = 1;
1290 populate_dot11f_edca_param_set(mac_ctx,
1291 &frm.EDCAParamSet, pe_session);
1292 }
1293 }
1294
1295 if ((!lle_mode) && (eHAL_SET == wme_mode) && sta->wmeEnabled) {
1296 populate_dot11f_wmm_params(mac_ctx, &frm.WMMParams,
1297 pe_session);
1298
1299 if (sta->wsmEnabled)
1300 populate_dot11f_wmm_caps(&frm.WMMCaps);
1301 }
1302
1303 if (sta->mlmStaContext.htCapability &&
1304 pe_session->htCapability) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001305 pe_debug("Populate HT IEs in Assoc Response");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001306 populate_dot11f_ht_caps(mac_ctx, pe_session,
1307 &frm.HTCaps);
Krunal Sonief3294b2015-06-12 15:12:19 -07001308 /*
1309 * Check the STA capability and
1310 * update the HTCaps accordingly
1311 */
1312 frm.HTCaps.supportedChannelWidthSet = (
1313 sta->htSupportedChannelWidthSet <
1314 pe_session->htSupportedChannelWidthSet) ?
1315 sta->htSupportedChannelWidthSet :
1316 pe_session->htSupportedChannelWidthSet;
1317 if (!frm.HTCaps.supportedChannelWidthSet)
1318 frm.HTCaps.shortGI40MHz = 0;
1319
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001320 populate_dot11f_ht_info(mac_ctx, &frm.HTInfo,
Pragaspathi Thilagarajb3472f02019-06-04 14:10:44 +05301321 pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001322 }
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001323 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 +05301324 frm.HTCaps.supportedChannelWidthSet,
1325 frm.HTCaps.mimoPowerSave,
1326 frm.HTCaps.greenField, frm.HTCaps.shortGI20MHz,
1327 frm.HTCaps.shortGI40MHz,
1328 frm.HTCaps.dsssCckMode40MHz,
1329 frm.HTCaps.maxRxAMPDUFactor);
1330
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001331 if (sta->mlmStaContext.vhtCapability &&
1332 pe_session->vhtCapability) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001333 pe_debug("Populate VHT IEs in Assoc Response");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001334 populate_dot11f_vht_caps(mac_ctx, pe_session,
1335 &frm.VHTCaps);
1336 populate_dot11f_vht_operation(mac_ctx, pe_session,
Kapil Gupta4b2efbb2016-10-03 13:07:20 +05301337 &frm.VHTOperation);
1338 is_vht = true;
Pragaspathi Thilagarajb3472f02019-06-04 14:10:44 +05301339 } else if (sta->mlmStaContext.force_1x1 &&
1340 frm.HTCaps.present) {
1341 /*
1342 * WAR: In P2P GO mode, if the P2P client device
1343 * is only HT capable and not VHT capable, but the P2P
1344 * GO device is VHT capable and advertises 2x2 NSS with
1345 * HT capablity client device, which results in IOT
1346 * issues.
1347 * When GO is operating in DBS mode, GO beacons
1348 * advertise 2x2 capability but include OMN IE to
1349 * indicate current operating mode of 1x1. But here
1350 * peer device is only HT capable and will not
1351 * understand OMN IE.
1352 */
1353 frm.HTInfo.basicMCSSet[1] = 0;
1354 frm.HTCaps.supportedMCSSet[1] = 0;
Kapil Gupta4b2efbb2016-10-03 13:07:20 +05301355 }
Naveen Rawat903acca2017-09-15 17:32:13 -07001356
Kapil Gupta4b2efbb2016-10-03 13:07:20 +05301357 if (pe_session->vhtCapability &&
1358 pe_session->vendor_vht_sap &&
Jeff Johnson8e9530b2019-03-18 13:41:42 -07001359 (assoc_req) &&
Kapil Gupta4b2efbb2016-10-03 13:07:20 +05301360 assoc_req->vendor_vht_ie.VHTCaps.present) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001361 pe_debug("Populate Vendor VHT IEs in Assoc Rsponse");
Kapil Gupta4b2efbb2016-10-03 13:07:20 +05301362 frm.vendor_vht_ie.present = 1;
Kiran Kumar Lokere81722632017-09-26 12:11:43 -07001363 frm.vendor_vht_ie.sub_type =
1364 pe_session->vendor_specific_vht_ie_sub_type;
Kapil Gupta4b2efbb2016-10-03 13:07:20 +05301365 frm.vendor_vht_ie.VHTCaps.present = 1;
1366 populate_dot11f_vht_caps(mac_ctx, pe_session,
1367 &frm.vendor_vht_ie.VHTCaps);
Kiran Kumar Lokerecc448682017-07-20 18:08:01 -07001368 populate_dot11f_vht_operation(mac_ctx, pe_session,
1369 &frm.vendor_vht_ie.VHTOperation);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001370 is_vht = true;
Kiran Kumar Lokere89f01f02019-08-06 18:22:39 -07001371 populate_dot11f_qcn_ie(mac_ctx, &frm.qcn_ie,
1372 QCN_IE_ATTR_ID_ALL);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001373 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001374 populate_dot11f_ext_cap(mac_ctx, is_vht, &frm.ExtCap,
1375 pe_session);
1376
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08001377 if (lim_is_sta_he_capable(sta) &&
1378 lim_is_session_he_capable(pe_session)) {
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07001379 pe_debug("Populate HE IEs");
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08001380 populate_dot11f_he_caps(mac_ctx, pe_session,
Naveen Rawatd8feac12017-09-08 15:08:39 -07001381 &frm.he_cap);
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08001382 populate_dot11f_he_operation(mac_ctx, pe_session,
Naveen Rawatd8feac12017-09-08 15:08:39 -07001383 &frm.he_op);
Kiran Kumar Lokereb2ea0272019-08-27 19:16:36 -07001384 populate_dot11f_he_6ghz_cap(mac_ctx, pe_session,
1385 &frm.he_6ghz_band_cap);
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08001386 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001387#ifdef WLAN_FEATURE_11W
1388 if (eSIR_MAC_TRY_AGAIN_LATER == status_code) {
Karthik Kantamneni24f71bc2018-09-11 19:08:38 +05301389 max_retries =
1390 mac_ctx->mlme_cfg->gen.pmf_sa_query_max_retries;
1391 retry_int =
1392 mac_ctx->mlme_cfg->gen.pmf_sa_query_retry_interval;
1393 populate_dot11f_timeout_interval(mac_ctx,
1394 &frm.TimeoutInterval,
1395 SIR_MAC_TI_TYPE_ASSOC_COMEBACK,
1396 (max_retries -
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001397 sta->pmfSaQueryRetryCount)
1398 * retry_int);
1399 }
1400#endif
Arif Hussain0c816922017-04-06 15:04:44 -07001401
1402 if (LIM_IS_AP_ROLE(pe_session) && sta->non_ecsa_capable)
1403 pe_session->lim_non_ecsa_cap_num++;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001404 }
1405
hangtian127c9532019-01-12 13:29:07 +08001406 qdf_mem_zero((uint8_t *) &beacon_params, sizeof(beacon_params));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001407
1408 if (LIM_IS_AP_ROLE(pe_session) &&
Pragaspathi Thilagaraj1ee76002018-09-18 21:38:51 +05301409 (pe_session->gLimProtectionControl !=
1410 MLME_FORCE_POLICY_PROTECTION_DISABLE))
1411 lim_decide_ap_protection(mac_ctx, peer_addr, &beacon_params,
1412 pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001413
1414 lim_update_short_preamble(mac_ctx, peer_addr, &beacon_params,
1415 pe_session);
1416 lim_update_short_slot_time(mac_ctx, peer_addr, &beacon_params,
1417 pe_session);
1418
1419 /*
1420 * Populate Do11capabilities after updating session with
1421 * Assos req details
1422 */
1423 populate_dot11f_capabilities(mac_ctx, &frm.Capabilities, pe_session);
1424
Abhishek Singhc70afa32019-09-19 15:17:21 +05301425 beacon_params.bss_idx = pe_session->vdev_id;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001426
1427 /* Send message to HAL about beacon parameter change. */
1428 if ((false == mac_ctx->sap.SapDfsInfo.is_dfs_cac_timer_running)
1429 && beacon_params.paramChangeBitmap) {
1430 sch_set_fixed_beacon_fields(mac_ctx, pe_session);
1431 lim_send_beacon_params(mac_ctx, &beacon_params, pe_session);
1432 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001433
Arif Hussain1513cb22018-01-05 19:56:31 -08001434 lim_obss_send_detection_cfg(mac_ctx, pe_session, false);
1435
Jeff Johnson8e9530b2019-03-18 13:41:42 -07001436 if (assoc_req) {
Jeff Johnson21aac3a2019-02-02 14:26:13 -08001437 addn_ie_len = pe_session->add_ie_params.assocRespDataLen;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001438
1439 /* Nonzero length indicates Assoc rsp IE available */
Krishna Kumaar Natarajane4e3a142016-04-01 16:27:51 -07001440 if (addn_ie_len > 0 &&
1441 addn_ie_len <= WNI_CFG_ASSOC_RSP_ADDNIE_DATA_LEN &&
1442 (bytes + addn_ie_len) <= SIR_MAX_PACKET_SIZE) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301443 qdf_mem_copy(add_ie,
Jeff Johnson21aac3a2019-02-02 14:26:13 -08001444 pe_session->add_ie_params.assocRespData_buff,
1445 pe_session->add_ie_params.assocRespDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001446
hangtian127c9532019-01-12 13:29:07 +08001447 qdf_mem_zero((uint8_t *) &extracted_ext_cap,
1448 sizeof(extracted_ext_cap));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001449
1450 stripoff_len = addn_ie_len;
1451 sir_status =
1452 lim_strip_extcap_update_struct
1453 (mac_ctx, &add_ie[0], &stripoff_len,
1454 &extracted_ext_cap);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001455 if (QDF_STATUS_SUCCESS != sir_status) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001456 pe_debug("strip off extcap IE failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001457 } else {
1458 addn_ie_len = stripoff_len;
1459 extracted_flag = true;
1460 }
1461 bytes = bytes + addn_ie_len;
1462 }
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001463 pe_debug("addn_ie_len: %d for Assoc Resp: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001464 addn_ie_len, assoc_req->addIEPresent);
1465 }
Hu Wang411e0cc2016-10-28 14:56:01 +08001466
1467 /*
1468 * Extcap IE now support variable length, merge Extcap IE from addn_ie
1469 * may change the frame size. Therefore, MUST merge ExtCap IE before
1470 * dot11f get packed payload size.
1471 */
1472 if (extracted_flag)
Hu Wangfbd279d2016-10-31 18:24:34 +08001473 lim_merge_extcap_struct(&(frm.ExtCap), &extracted_ext_cap,
1474 true);
Hu Wang411e0cc2016-10-28 14:56:01 +08001475
1476 /* Allocate a buffer for this frame: */
1477 status = dot11f_get_packed_assoc_response_size(mac_ctx, &frm, &payload);
1478 if (DOT11F_FAILED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001479 pe_err("get Association Response size failure (0x%08x)",
Hu Wang411e0cc2016-10-28 14:56:01 +08001480 status);
1481 return;
1482 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001483 pe_warn("get Association Response size warning (0x%08x)",
Hu Wang411e0cc2016-10-28 14:56:01 +08001484 status);
1485 }
1486
1487 bytes += sizeof(tSirMacMgmtHdr) + payload;
1488
Min Liu0daa0982019-02-01 17:50:44 +08001489 if (sta)
1490 bytes += sta->mlmStaContext.owe_ie_len;
1491
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301492 qdf_status = cds_packet_alloc((uint16_t) bytes, (void **)&frame,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001493 (void **)&packet);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301494 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001495 pe_err("cds_packet_alloc failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001496 return;
1497 }
1498 /* Paranoia: */
hangtian127c9532019-01-12 13:29:07 +08001499 qdf_mem_zero(frame, bytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001500
1501 /* Next, we fill out the buffer descriptor: */
1502 lim_populate_mac_header(mac_ctx, frame, SIR_MAC_MGMT_FRAME,
1503 (LIM_ASSOC == subtype) ?
1504 SIR_MAC_MGMT_ASSOC_RSP : SIR_MAC_MGMT_REASSOC_RSP,
1505 peer_addr,
Pragaspathi Thilagaraj7fb14222019-06-17 23:26:58 +05301506 pe_session->self_mac_addr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001507 mac_hdr = (tpSirMacMgmtHdr) frame;
1508
1509 sir_copy_mac_addr(mac_hdr->bssId, pe_session->bssId);
1510
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001511 status = dot11f_pack_assoc_response(mac_ctx, &frm,
1512 frame + sizeof(tSirMacMgmtHdr),
1513 payload, &payload);
1514 if (DOT11F_FAILED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001515 pe_err("Association Response pack failure(0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001516 status);
1517 cds_packet_free((void *)packet);
1518 return;
1519 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001520 pe_warn("Association Response pack warning (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001521 status);
1522 }
1523
1524 if (subtype == LIM_ASSOC)
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001525 pe_debug("*** Sending Assoc Resp status %d aid %d to",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001526 status_code, aid);
1527 else
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001528 pe_debug("*** Sending ReAssoc Resp status %d aid %d to",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001529 status_code, aid);
1530
Abhishek Singh5d8d7332017-08-10 15:15:24 +05301531 lim_print_mac_addr(mac_ctx, mac_hdr->da, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001532
1533 if (addn_ie_len && addn_ie_len <= WNI_CFG_ASSOC_RSP_ADDNIE_DATA_LEN)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301534 qdf_mem_copy(frame + sizeof(tSirMacMgmtHdr) + payload,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001535 &add_ie[0], addn_ie_len);
1536
Min Liu0daa0982019-02-01 17:50:44 +08001537 if (sta && sta->mlmStaContext.owe_ie_len)
1538 qdf_mem_copy(frame + sizeof(tSirMacMgmtHdr) + payload
1539 + addn_ie_len,
1540 sta->mlmStaContext.owe_ie,
1541 sta->mlmStaContext.owe_ie_len);
1542
Liangwei Dong419d7302019-07-15 15:38:28 +08001543 if (wlan_reg_is_5ghz_ch_freq(pe_session->curr_op_freq) ||
1544 pe_session->opmode == QDF_P2P_CLIENT_MODE ||
1545 pe_session->opmode == QDF_P2P_GO_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001546 tx_flag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
1547
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05301548 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001549 pe_session->peSessionId, mac_hdr->fc.subType));
Krunal Sonic65fc492018-03-09 15:53:28 -08001550 lim_diag_mgmt_tx_event_report(mac_ctx, mac_hdr,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001551 pe_session, QDF_STATUS_SUCCESS, status_code);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001552 /* Queue Association Response frame in high priority WQ */
bings85512332019-09-04 17:46:37 +08001553 if (tx_complete)
1554 qdf_status = wma_tx_frameWithTxComplete(
1555 mac_ctx, packet, (uint16_t)bytes,
1556 TXRX_FRM_802_11_MGMT,
1557 ANI_TXDIR_TODS,
1558 7, lim_tx_complete, frame,
1559 lim_assoc_rsp_tx_complete, tx_flag,
1560 sme_session, false, 0, RATEID_DEFAULT);
1561 else
1562 qdf_status = wma_tx_frame(
1563 mac_ctx, packet, (uint16_t)bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001564 TXRX_FRM_802_11_MGMT,
1565 ANI_TXDIR_TODS,
1566 7, lim_tx_complete, frame, tx_flag,
Naveen Rawat296a5182017-09-25 14:02:48 -07001567 sme_session, 0, RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05301568 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301569 pe_session->peSessionId, qdf_status));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001570
1571 /* Pkt will be freed up by the callback */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301572 if (!QDF_IS_STATUS_SUCCESS(qdf_status))
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001573 pe_err("Could not Send Re/AssocRsp, retCode=%X",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301574 qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001575
1576 /*
1577 * update the ANI peer station count.
1578 * FIXME_PROTECTION : take care of different type of station
1579 * counter inside this function.
1580 */
1581 lim_util_count_sta_add(mac_ctx, sta, pe_session);
1582
1583}
1584
1585void
Jeff Johnson9320c1e2018-12-02 13:09:20 -08001586lim_send_delts_req_action_frame(struct mac_context *mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001587 tSirMacAddr peer,
1588 uint8_t wmmTspecPresent,
Jeff Johnson312348f2018-12-22 13:33:54 -08001589 struct mac_ts_info *pTsinfo,
Jeff Johnson56471b92018-12-22 14:36:06 -08001590 struct mac_tspec_ie *pTspecIe,
Jeff Johnson312348f2018-12-22 13:33:54 -08001591 struct pe_session *pe_session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001592{
1593 uint8_t *pFrame;
1594 tpSirMacMgmtHdr pMacHdr;
1595 tDot11fDelTS DelTS;
1596 tDot11fWMMDelTS WMMDelTS;
1597 uint32_t nBytes, nPayload, nStatus;
1598 void *pPacket;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301599 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001600 uint8_t txFlag = 0;
1601 uint8_t smeSessionId = 0;
1602
Jeff Johnson312348f2018-12-22 13:33:54 -08001603 if (!pe_session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001604 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001605
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001606 smeSessionId = pe_session->smeSessionId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001607
1608 if (!wmmTspecPresent) {
hangtian127c9532019-01-12 13:29:07 +08001609 qdf_mem_zero((uint8_t *) &DelTS, sizeof(DelTS));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001610
Srinivas Girigowda48bec1c2019-05-17 16:33:30 -07001611 DelTS.Category.category = ACTION_CATEGORY_QOS;
Srinivas Girigowda03cebc32019-05-17 16:50:31 -07001612 DelTS.Action.action = QOS_DEL_TS_REQ;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001613 populate_dot11f_ts_info(pTsinfo, &DelTS.TSInfo);
1614
Jeff Johnson99f25042018-11-21 22:49:06 -08001615 nStatus = dot11f_get_packed_del_ts_size(mac, &DelTS, &nPayload);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001616 if (DOT11F_FAILED(nStatus)) {
Jeff Johnson312348f2018-12-22 13:33:54 -08001617 pe_err("Failed to calculate the packed size for a Del TS (0x%08x)",
1618 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001619 /* We'll fall back on the worst case scenario: */
1620 nPayload = sizeof(tDot11fDelTS);
1621 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001622 pe_warn("There were warnings while calculating the packed size for a Del TS (0x%08x)",
1623 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001624 }
1625 } else {
hangtian127c9532019-01-12 13:29:07 +08001626 qdf_mem_zero((uint8_t *) &WMMDelTS, sizeof(WMMDelTS));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001627
Srinivas Girigowda48bec1c2019-05-17 16:33:30 -07001628 WMMDelTS.Category.category = ACTION_CATEGORY_WMM;
Srinivas Girigowda03cebc32019-05-17 16:50:31 -07001629 WMMDelTS.Action.action = QOS_DEL_TS_REQ;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001630 WMMDelTS.DialogToken.token = 0;
1631 WMMDelTS.StatusCode.statusCode = 0;
1632 populate_dot11f_wmmtspec(pTspecIe, &WMMDelTS.WMMTSPEC);
1633 nStatus =
Jeff Johnson99f25042018-11-21 22:49:06 -08001634 dot11f_get_packed_wmm_del_ts_size(mac, &WMMDelTS, &nPayload);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001635 if (DOT11F_FAILED(nStatus)) {
Jeff Johnson312348f2018-12-22 13:33:54 -08001636 pe_err("Failed to calculate the packed size for a WMM Del TS (0x%08x)",
1637 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001638 /* We'll fall back on the worst case scenario: */
1639 nPayload = sizeof(tDot11fDelTS);
1640 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001641 pe_warn("There were warnings while calculating the packed size for a WMM Del TS (0x%08x)",
1642 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001643 }
1644 }
1645
1646 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
1647
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301648 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001649 cds_packet_alloc((uint16_t) nBytes, (void **)&pFrame,
1650 (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301651 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001652 pe_err("Failed to allocate %d bytes for an Add TS Response",
1653 nBytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001654 return;
1655 }
1656 /* Paranoia: */
hangtian127c9532019-01-12 13:29:07 +08001657 qdf_mem_zero(pFrame, nBytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001658
1659 /* Next, we fill out the buffer descriptor: */
Jeff Johnson99f25042018-11-21 22:49:06 -08001660 lim_populate_mac_header(mac, pFrame, SIR_MAC_MGMT_FRAME,
Pragaspathi Thilagaraj7fb14222019-06-17 23:26:58 +05301661 SIR_MAC_MGMT_ACTION, peer, pe_session->self_mac_addr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001662 pMacHdr = (tpSirMacMgmtHdr) pFrame;
1663
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001664 sir_copy_mac_addr(pMacHdr->bssId, pe_session->bssId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001665
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001666 lim_set_protected_bit(mac, pe_session, peer, pMacHdr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001667
1668 /* That done, pack the struct: */
1669 if (!wmmTspecPresent) {
Jeff Johnson99f25042018-11-21 22:49:06 -08001670 nStatus = dot11f_pack_del_ts(mac, &DelTS,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001671 pFrame + sizeof(tSirMacMgmtHdr),
1672 nPayload, &nPayload);
1673 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001674 pe_err("Failed to pack a Del TS frame (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001675 nStatus);
1676 cds_packet_free((void *)pPacket);
1677 return; /* allocated! */
1678 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001679 pe_warn("There were warnings while packing a Del TS frame (0x%08x)",
1680 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001681 }
1682 } else {
Jeff Johnson99f25042018-11-21 22:49:06 -08001683 nStatus = dot11f_pack_wmm_del_ts(mac, &WMMDelTS,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001684 pFrame + sizeof(tSirMacMgmtHdr),
1685 nPayload, &nPayload);
1686 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001687 pe_err("Failed to pack a WMM Del TS frame (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001688 nStatus);
1689 cds_packet_free((void *)pPacket);
1690 return; /* allocated! */
1691 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001692 pe_warn("There were warnings while packing a WMM Del TS frame (0x%08x)",
1693 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001694 }
1695 }
1696
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001697 pe_debug("Sending DELTS REQ (size %d) to ", nBytes);
Jeff Johnson99f25042018-11-21 22:49:06 -08001698 lim_print_mac_addr(mac, pMacHdr->da, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001699
Liangwei Dong419d7302019-07-15 15:38:28 +08001700 if (wlan_reg_is_5ghz_ch_freq(pe_session->curr_op_freq) ||
1701 pe_session->opmode == QDF_P2P_CLIENT_MODE ||
1702 pe_session->opmode == QDF_P2P_GO_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001703 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001704
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05301705 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001706 pe_session->peSessionId, pMacHdr->fc.subType));
Jeff Johnson99f25042018-11-21 22:49:06 -08001707 lim_diag_mgmt_tx_event_report(mac, pMacHdr,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001708 pe_session, QDF_STATUS_SUCCESS,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001709 QDF_STATUS_SUCCESS);
Jeff Johnson99f25042018-11-21 22:49:06 -08001710 qdf_status = wma_tx_frame(mac, pPacket, (uint16_t) nBytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001711 TXRX_FRM_802_11_MGMT,
1712 ANI_TXDIR_TODS,
1713 7, lim_tx_complete, pFrame, txFlag,
Naveen Rawat296a5182017-09-25 14:02:48 -07001714 smeSessionId, 0, RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05301715 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001716 pe_session->peSessionId, qdf_status));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001717 /* Pkt will be freed up by the callback */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301718 if (!QDF_IS_STATUS_SUCCESS(qdf_status))
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001719 pe_err("Failed to send Del TS (%X)!", qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001720
1721} /* End lim_send_delts_req_action_frame. */
1722
1723/**
Abhishek Singhdd2cb572017-08-11 11:10:19 +05301724 * lim_assoc_tx_complete_cnf()- Confirmation for assoc sent over the air
1725 * @context: pointer to global mac
1726 * @buf: buffer
1727 * @tx_complete : Sent status
1728 * @params; tx completion params
1729 *
1730 * Return: This returns QDF_STATUS
1731 */
1732
1733static QDF_STATUS lim_assoc_tx_complete_cnf(void *context,
1734 qdf_nbuf_t buf,
1735 uint32_t tx_complete,
1736 void *params)
1737{
1738 uint16_t assoc_ack_status;
1739 uint16_t reason_code;
Jeff Johnson9320c1e2018-12-02 13:09:20 -08001740 struct mac_context *mac_ctx = (struct mac_context *)context;
Abhishek Singhdd2cb572017-08-11 11:10:19 +05301741
1742 pe_debug("tx_complete= %d", tx_complete);
Zhu Jianmin5d8e3fe2018-01-04 16:16:20 +08001743 if (tx_complete == WMI_MGMT_TX_COMP_TYPE_COMPLETE_OK) {
Abhishek Singhdd2cb572017-08-11 11:10:19 +05301744 assoc_ack_status = ACKED;
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001745 reason_code = QDF_STATUS_SUCCESS;
Abhishek Singhdd2cb572017-08-11 11:10:19 +05301746 } else {
1747 assoc_ack_status = NOT_ACKED;
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001748 reason_code = QDF_STATUS_E_FAILURE;
Abhishek Singhdd2cb572017-08-11 11:10:19 +05301749 }
1750 if (buf)
1751 qdf_nbuf_free(buf);
1752
1753 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_ASSOC_ACK_EVENT,
1754 NULL, assoc_ack_status, reason_code);
1755 return QDF_STATUS_SUCCESS;
1756}
1757
Pragaspathi Thilagaraj54018e02019-04-25 01:32:17 +05301758#ifdef WLAN_ADAPTIVE_11R
1759/**
1760 * lim_fill_adaptive_11r_ie() - Populate the Vendor secific adaptive 11r
1761 * IE to association request frame
1762 * @pe_session: pointer to PE session
1763 * @ie_buf: buffer to which Adaptive 11r IE will be copied
1764 * @ie_len: length of the Adaptive 11r Vendor specific IE
1765 *
1766 * Return QDF_STATUS
1767 */
1768static QDF_STATUS lim_fill_adaptive_11r_ie(struct pe_session *pe_session,
1769 uint8_t **ie_buf, uint8_t *ie_len)
1770{
1771 uint8_t *buf = NULL, *adaptive_11r_ie = NULL;
1772
1773 if (!pe_session->is_adaptive_11r_connection)
1774 return QDF_STATUS_SUCCESS;
1775
1776 /*
1777 * Vendor specific Adaptive 11r IE to be advertised in Assoc
1778 * req:
1779 * Type 0xDD
1780 * Length 0x0B
1781 * OUI 0x00 0x00 0x0F
1782 * Type 0x22
1783 * subtype 0x00
1784 * Version 0x01
1785 * Length 0x04
1786 * Data 0x00 00 00 01(0th bit is 1 means adaptive 11r is
1787 * supported)
1788 */
1789 adaptive_11r_ie = qdf_mem_malloc(ADAPTIVE_11R_STA_IE_LEN + 2);
1790 if (!adaptive_11r_ie)
1791 return QDF_STATUS_E_FAILURE;
1792
1793 /* Fill the Vendor IE Type (0xDD) */
1794 buf = adaptive_11r_ie;
Srinivas Girigowda8e7ecab2019-05-16 11:31:19 -07001795 *buf = WLAN_ELEMID_VENDOR;
Pragaspathi Thilagaraj54018e02019-04-25 01:32:17 +05301796 buf++;
1797
1798 /* Fill the Vendor IE length (0x0B) */
1799 *buf = ADAPTIVE_11R_STA_IE_LEN;
1800 buf++;
1801
1802 /*
1803 * Fill the Adaptive 11r Vendor specific OUI(0x00 0x00 0x0F 0x22)
1804 */
1805 qdf_mem_copy(buf, ADAPTIVE_11R_STA_OUI, ADAPTIVE_11R_OUI_LEN);
1806 buf += ADAPTIVE_11R_OUI_LEN;
1807
1808 /* Fill Adaptive 11r Vendor specific Subtype (0x00) */
1809 *buf = ADAPTIVE_11R_OUI_SUBTYPE;
1810 buf++;
1811
1812 /* Fill Adaptive 11r Version (0x01) */
1813 *buf = ADAPTIVE_11R_OUI_VERSION;
1814 buf++;
1815
1816 /* Fill Adaptive 11r IE Data length (0x04) */
1817 *buf = ADAPTIVE_11R_DATA_LEN;
1818 buf++;
1819
1820 /* Fill Adaptive 11r IE Data (0x00 0x00 0x00 0x01) */
1821 qdf_mem_copy(buf, ADAPTIVE_11R_OUI_DATA, ADAPTIVE_11R_DATA_LEN);
1822
1823 *ie_len = ADAPTIVE_11R_STA_IE_LEN + 2;
1824 *ie_buf = adaptive_11r_ie;
1825
1826 return QDF_STATUS_SUCCESS;
1827}
1828
1829#else
1830static inline
1831QDF_STATUS lim_fill_adaptive_11r_ie(struct pe_session *pe_session,
1832 uint8_t **ie_buf, uint8_t *ie_len)
1833{
1834 return QDF_STATUS_SUCCESS;
1835}
1836#endif
1837
Abhishek Singhdd2cb572017-08-11 11:10:19 +05301838/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001839 * lim_send_assoc_req_mgmt_frame() - Send association request
1840 * @mac_ctx: Handle to MAC context
1841 * @mlm_assoc_req: Association request information
1842 * @pe_session: PE session information
1843 *
1844 * Builds and transmits association request frame to AP.
1845 *
1846 * Return: Void
1847 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001848void
Jeff Johnson9320c1e2018-12-02 13:09:20 -08001849lim_send_assoc_req_mgmt_frame(struct mac_context *mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001850 tLimMlmAssocReq *mlm_assoc_req,
Jeff Johnsona7815652018-11-18 22:58:30 -08001851 struct pe_session *pe_session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001852{
Naveen Rawat72475db2017-12-13 18:07:35 -08001853 int ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001854 tDot11fAssocRequest *frm;
1855 uint16_t caps;
Pragaspathi Thilagarajc0515882019-10-24 02:59:11 +05301856 uint8_t *frame, *rsnx_ie = NULL;
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001857 QDF_STATUS sir_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001858 tLimMlmAssocCnf assoc_cnf;
Hu Wang411e0cc2016-10-28 14:56:01 +08001859 uint32_t bytes = 0, payload, status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001860 uint8_t qos_enabled, wme_enabled, wsm_enabled;
1861 void *packet;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301862 QDF_STATUS qdf_status;
Srinivas Dasari22397902019-07-29 21:34:10 +05301863 uint16_t add_ie_len, current_len = 0, vendor_ie_len = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001864 uint8_t *add_ie;
Naveen Rawat08db88f2017-09-08 15:07:48 -07001865 const uint8_t *wps_ie = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001866 uint8_t power_caps = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001867 uint8_t tx_flag = 0;
Abhishek Singhcc02c9b2019-11-25 14:51:30 +05301868 uint8_t vdev_id = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001869 bool vht_enabled = false;
1870 tDot11fIEExtCap extr_ext_cap;
Pragaspathi Thilagaraj376ead92019-12-11 19:13:28 +05301871 bool extr_ext_flag = true, is_open_auth = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001872 tpSirMacMgmtHdr mac_hdr;
Hu Wangfbd279d2016-10-31 18:24:34 +08001873 uint32_t ie_offset = 0;
1874 uint8_t *p_ext_cap = NULL;
1875 tDot11fIEExtCap bcn_ext_cap;
1876 uint8_t *bcn_ie = NULL;
1877 uint32_t bcn_ie_len = 0;
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +05301878 uint32_t aes_block_size_len = 0;
Naveen Rawat296a5182017-09-25 14:02:48 -07001879 enum rateid min_rid = RATEID_DEFAULT;
Srinivas Dasari22397902019-07-29 21:34:10 +05301880 uint8_t *mbo_ie = NULL, *adaptive_11r_ie = NULL, *vendor_ies = NULL;
Pragaspathi Thilagarajc0515882019-10-24 02:59:11 +05301881 uint8_t mbo_ie_len = 0, adaptive_11r_ie_len = 0, rsnx_ie_len = 0;
Srinivas Dasari603d4972019-09-20 17:28:44 +05301882 struct wlan_objmgr_peer *peer;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001883
Jeff Johnson8e9530b2019-03-18 13:41:42 -07001884 if (!pe_session) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001885 pe_err("pe_session is NULL");
yeshwanth sriram guntuka07831012017-06-30 12:26:57 +05301886 qdf_mem_free(mlm_assoc_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001887 return;
1888 }
1889
Abhishek Singhcc02c9b2019-11-25 14:51:30 +05301890 vdev_id = pe_session->vdev_id;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001891
1892 /* check this early to avoid unncessary operation */
Pragaspathi Thilagaraj64ae59d2019-06-22 13:00:34 +05301893 if (!pe_session->lim_join_req) {
1894 pe_err("pe_session->lim_join_req is NULL");
yeshwanth sriram guntuka07831012017-06-30 12:26:57 +05301895 qdf_mem_free(mlm_assoc_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001896 return;
1897 }
Pragaspathi Thilagaraj64ae59d2019-06-22 13:00:34 +05301898 add_ie_len = pe_session->lim_join_req->addIEAssoc.length;
1899 add_ie = pe_session->lim_join_req->addIEAssoc.addIEdata;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001900
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301901 frm = qdf_mem_malloc(sizeof(tDot11fAssocRequest));
Arif Hussainf5b6c412018-10-10 19:41:09 -07001902 if (!frm) {
yeshwanth sriram guntuka07831012017-06-30 12:26:57 +05301903 qdf_mem_free(mlm_assoc_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001904 return;
1905 }
hangtian127c9532019-01-12 13:29:07 +08001906 qdf_mem_zero((uint8_t *) frm, sizeof(tDot11fAssocRequest));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001907
Agrawal Ashish0f94b572016-02-22 13:27:06 +05301908 if (add_ie_len && pe_session->is_ext_caps_present) {
hangtian127c9532019-01-12 13:29:07 +08001909 qdf_mem_zero((uint8_t *) &extr_ext_cap,
1910 sizeof(tDot11fIEExtCap));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001911 sir_status = lim_strip_extcap_update_struct(mac_ctx,
1912 add_ie, &add_ie_len, &extr_ext_cap);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001913 if (QDF_STATUS_SUCCESS != sir_status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001914 extr_ext_flag = false;
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001915 pe_debug("Unable to Stripoff ExtCap IE from Assoc Req");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001916 } else {
1917 struct s_ext_cap *p_ext_cap = (struct s_ext_cap *)
1918 extr_ext_cap.bytes;
1919
1920 if (p_ext_cap->interworking_service)
1921 p_ext_cap->qos_map = 1;
Hu Wang411e0cc2016-10-28 14:56:01 +08001922 extr_ext_cap.num_bytes =
1923 lim_compute_ext_cap_ie_length(&extr_ext_cap);
1924 extr_ext_flag = (extr_ext_cap.num_bytes > 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001925 }
1926 } else {
Jeff Johnson47d75242018-05-12 15:58:53 -07001927 pe_debug("No addn IE or peer doesn't support addnIE for Assoc Req");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001928 extr_ext_flag = false;
1929 }
1930
1931 caps = mlm_assoc_req->capabilityInfo;
1932#if defined(FEATURE_WLAN_WAPI)
1933 /*
1934 * According to WAPI standard:
1935 * 7.3.1.4 Capability Information field
1936 * In WAPI, non-AP STAs within an ESS set the Privacy subfield to 0
1937 * in transmitted Association or Reassociation management frames.
1938 * APs ignore the Privacy subfield within received Association and
1939 * Reassociation management frames.
1940 */
1941 if (pe_session->encryptType == eSIR_ED_WPI)
1942 ((tSirMacCapabilityInfo *) &caps)->privacy = 0;
1943#endif
1944 swap_bit_field16(caps, (uint16_t *) &frm->Capabilities);
1945
1946 frm->ListenInterval.interval = mlm_assoc_req->listenInterval;
1947 populate_dot11f_ssid2(mac_ctx, &frm->SSID);
1948 populate_dot11f_supp_rates(mac_ctx, POPULATE_DOT11F_RATES_OPERATIONAL,
1949 &frm->SuppRates, pe_session);
1950
1951 qos_enabled = (pe_session->limQosEnabled) &&
1952 SIR_MAC_GET_QOS(pe_session->limCurrentBssCaps);
1953
1954 wme_enabled = (pe_session->limWmeEnabled) &&
1955 LIM_BSS_CAPS_GET(WME, pe_session->limCurrentBssQosCaps);
1956
1957 /* We prefer .11e asociations: */
1958 if (qos_enabled)
1959 wme_enabled = false;
1960
1961 wsm_enabled = (pe_session->limWsmEnabled) && wme_enabled &&
1962 LIM_BSS_CAPS_GET(WSM, pe_session->limCurrentBssQosCaps);
1963
1964 if (pe_session->lim11hEnable &&
Pragaspathi Thilagaraj64ae59d2019-06-22 13:00:34 +05301965 pe_session->lim_join_req->spectrumMgtIndicator == true) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001966 power_caps = true;
1967
1968 populate_dot11f_power_caps(mac_ctx, &frm->PowerCaps,
1969 LIM_ASSOC, pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001970 populate_dot11f_supp_channels(mac_ctx, &frm->SuppChannels,
1971 LIM_ASSOC, pe_session);
1972
1973 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001974 if (mac_ctx->rrm.rrmPEContext.rrmEnable &&
1975 SIR_MAC_GET_RRM(pe_session->limCurrentBssCaps)) {
1976 if (power_caps == false) {
1977 power_caps = true;
1978 populate_dot11f_power_caps(mac_ctx, &frm->PowerCaps,
1979 LIM_ASSOC, pe_session);
1980 }
1981 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001982 if (qos_enabled)
Naveen Rawatcd118312016-11-22 10:46:21 -08001983 populate_dot11f_qos_caps_station(mac_ctx, pe_session,
1984 &frm->QOSCapsStation);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001985
1986 populate_dot11f_ext_supp_rates(mac_ctx,
1987 POPULATE_DOT11F_RATES_OPERATIONAL, &frm->ExtSuppRates,
1988 pe_session);
1989
Gupta, Kapil54a16992016-01-13 19:34:02 +05301990 if (mac_ctx->rrm.rrmPEContext.rrmEnable &&
1991 SIR_MAC_GET_RRM(pe_session->limCurrentBssCaps))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001992 populate_dot11f_rrm_ie(mac_ctx, &frm->RRMEnabledCap,
1993 pe_session);
Deepak Dhamdhere641bf322016-01-06 15:19:03 -08001994
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001995 /*
1996 * The join request *should* contain zero or one of the WPA and RSN
1997 * IEs. The payload send along with the request is a
Jeff Johnson701444f2019-02-02 22:35:13 -08001998 * 'struct join_req'; the IE portion is held inside a 'tSirRSNie':
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001999 * typedef struct sSirRSNie
2000 * {
2001 * uint16_t length;
Srinivas Girigowdacf161402019-03-14 11:37:33 -07002002 * uint8_t rsnIEdata[WLAN_MAX_IE_LEN+2];
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002003 * } tSirRSNie, *tpSirRSNie;
2004 * So, we should be able to make the following two calls harmlessly,
2005 * since they do nothing if they don't find the given IE in the
2006 * bytestream with which they're provided.
2007 * The net effect of this will be to faithfully transmit whatever
2008 * security IE is in the join request.
2009 * However, if we're associating for the purpose of WPS
2010 * enrollment, and we've been configured to indicate that by
2011 * eliding the WPA or RSN IE, we just skip this:
2012 */
2013 if (add_ie_len && add_ie)
2014 wps_ie = limGetWscIEPtr(mac_ctx, add_ie, add_ie_len);
2015
Jeff Johnson8e9530b2019-03-18 13:41:42 -07002016 if (!wps_ie) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002017 populate_dot11f_rsn_opaque(mac_ctx,
Pragaspathi Thilagaraj64ae59d2019-06-22 13:00:34 +05302018 &pe_session->lim_join_req->rsnIE,
2019 &frm->RSNOpaque);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002020 populate_dot11f_wpa_opaque(mac_ctx,
Pragaspathi Thilagaraj64ae59d2019-06-22 13:00:34 +05302021 &pe_session->lim_join_req->rsnIE,
2022 &frm->WPAOpaque);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002023#if defined(FEATURE_WLAN_WAPI)
2024 populate_dot11f_wapi_opaque(mac_ctx,
Pragaspathi Thilagaraj64ae59d2019-06-22 13:00:34 +05302025 &(pe_session->lim_join_req->rsnIE),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002026 &frm->WAPIOpaque);
2027#endif /* defined(FEATURE_WLAN_WAPI) */
2028 }
2029 /* include WME EDCA IE as well */
2030 if (wme_enabled) {
2031 populate_dot11f_wmm_info_station_per_session(mac_ctx,
2032 pe_session, &frm->WMMInfoStation);
2033
2034 if (wsm_enabled)
2035 populate_dot11f_wmm_caps(&frm->WMMCaps);
2036 }
2037
2038 /*
2039 * Populate HT IEs, when operating in 11n and
2040 * when AP is also operating in 11n mode
2041 */
2042 if (pe_session->htCapability &&
2043 mac_ctx->lim.htCapabilityPresentInBeacon) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002044 pe_debug("Populate HT Caps in Assoc Request");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002045 populate_dot11f_ht_caps(mac_ctx, pe_session, &frm->HTCaps);
Naveen Rawata410c5a2016-09-19 14:22:33 -07002046 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_DEBUG,
2047 &frm->HTCaps, sizeof(frm->HTCaps));
Kiran Kumar Lokere722dccd2018-02-23 13:23:52 -08002048 } else if (pe_session->he_with_wep_tkip) {
2049 pe_debug("Populate HT Caps in Assoc Request with WEP/TKIP");
2050 populate_dot11f_ht_caps(mac_ctx, NULL, &frm->HTCaps);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002051 }
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002052 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 +05302053 frm->HTCaps.supportedChannelWidthSet,
2054 frm->HTCaps.mimoPowerSave,
2055 frm->HTCaps.greenField, frm->HTCaps.shortGI20MHz,
2056 frm->HTCaps.shortGI40MHz,
2057 frm->HTCaps.dsssCckMode40MHz,
2058 frm->HTCaps.maxRxAMPDUFactor);
2059
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002060 if (pe_session->vhtCapability &&
2061 pe_session->vhtCapabilityPresentInBeacon) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002062 pe_debug("Populate VHT IEs in Assoc Request");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002063 populate_dot11f_vht_caps(mac_ctx, pe_session, &frm->VHTCaps);
Naveen Rawata410c5a2016-09-19 14:22:33 -07002064 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_DEBUG,
2065 &frm->VHTCaps, sizeof(frm->VHTCaps));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002066 vht_enabled = true;
Kiran Kumar Lokere1d4094e2016-08-31 19:04:04 -07002067 if (pe_session->enableHtSmps &&
2068 !pe_session->supported_nss_1x1) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002069 pe_err("VHT OP mode IE in Assoc Req");
Kiran Kumar Lokere1d4094e2016-08-31 19:04:04 -07002070 populate_dot11f_operating_mode(mac_ctx,
2071 &frm->OperatingMode, pe_session);
2072 }
Kiran Kumar Lokere722dccd2018-02-23 13:23:52 -08002073 } else if (pe_session->he_with_wep_tkip) {
2074 pe_debug("Populate VHT IEs in Assoc Request with WEP/TKIP");
2075 populate_dot11f_vht_caps(mac_ctx, NULL, &frm->VHTCaps);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002076 }
Kiran Kumar Lokere722dccd2018-02-23 13:23:52 -08002077
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002078 if (!vht_enabled &&
2079 pe_session->is_vendor_specific_vhtcaps) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002080 pe_debug("Populate Vendor VHT IEs in Assoc Request");
Kapil Gupta4b2efbb2016-10-03 13:07:20 +05302081 frm->vendor_vht_ie.present = 1;
Kiran Kumar Lokere81722632017-09-26 12:11:43 -07002082 frm->vendor_vht_ie.sub_type =
2083 pe_session->vendor_specific_vht_ie_sub_type;
Kapil Gupta4b2efbb2016-10-03 13:07:20 +05302084 frm->vendor_vht_ie.VHTCaps.present = 1;
Abhinav Kumarb074f2f2018-09-15 15:32:11 +05302085 if (!mac_ctx->mlme_cfg->vht_caps.vht_cap_info.vendor_vhtie &&
Abhishek Singh68844282018-01-25 16:48:41 +05302086 pe_session->vht_config.su_beam_formee) {
2087 pe_debug("Disable SU beamformee for vendor IE");
2088 pe_session->vht_config.su_beam_formee = 0;
2089 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002090 populate_dot11f_vht_caps(mac_ctx, pe_session,
Kapil Gupta4b2efbb2016-10-03 13:07:20 +05302091 &frm->vendor_vht_ie.VHTCaps);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002092 vht_enabled = true;
2093 }
Agrawal Ashish0f94b572016-02-22 13:27:06 +05302094 if (pe_session->is_ext_caps_present)
2095 populate_dot11f_ext_cap(mac_ctx, vht_enabled,
2096 &frm->ExtCap, pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002097
Kiran Kumar Lokere89f01f02019-08-06 18:22:39 -07002098 populate_dot11f_qcn_ie(mac_ctx, &frm->qcn_ie, QCN_IE_ATTR_ID_ALL);
Selvaraj, Sridhara521aab2017-03-25 16:42:34 +05302099
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08002100 if (lim_is_session_he_capable(pe_session)) {
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07002101 pe_debug("Populate HE IEs");
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08002102 populate_dot11f_he_caps(mac_ctx, pe_session,
Naveen Rawatd8feac12017-09-08 15:08:39 -07002103 &frm->he_cap);
Manikandan Mohan8e4491c2019-10-23 16:00:51 -07002104 populate_dot11f_he_6ghz_cap(mac_ctx, pe_session,
2105 &frm->he_6ghz_band_cap);
Kiran Kumar Lokere722dccd2018-02-23 13:23:52 -08002106 } else if (pe_session->he_with_wep_tkip) {
2107 pe_debug("Populate HE IEs in Assoc Request with WEP/TKIP");
2108 populate_dot11f_he_caps(mac_ctx, NULL, &frm->he_cap);
Manikandan Mohan8e4491c2019-10-23 16:00:51 -07002109 populate_dot11f_he_6ghz_cap(mac_ctx, pe_session,
2110 &frm->he_6ghz_band_cap);
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08002111 }
Selvaraj, Sridharc2fe7a32017-02-02 19:20:16 +05302112
Pragaspathi Thilagaraj64ae59d2019-06-22 13:00:34 +05302113 if (pe_session->lim_join_req->is11Rconnection) {
Pragaspathi Thilagaraj1112c962019-05-23 23:45:38 +05302114 struct bss_description *bssdescr;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002115
Pragaspathi Thilagaraj64ae59d2019-06-22 13:00:34 +05302116 bssdescr = &pe_session->lim_join_req->bssDescription;
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002117 pe_debug("mdie = %02x %02x %02x",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002118 (unsigned int) bssdescr->mdie[0],
2119 (unsigned int) bssdescr->mdie[1],
2120 (unsigned int) bssdescr->mdie[2]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002121 populate_mdie(mac_ctx, &frm->MobilityDomain,
Pragaspathi Thilagaraj64ae59d2019-06-22 13:00:34 +05302122 pe_session->lim_join_req->bssDescription.mdie);
Pragaspathi Thilagaraj03839b92019-03-12 17:45:21 +05302123
2124 /*
2125 * IEEE80211-ai [13.2.4 FT initial mobility domain association
2126 * over FILS in an RSN]
2127 * Populate FT IE in association request. This FT IE should be
2128 * same as the FT IE received in auth response frame during the
2129 * FT-FILS authentication.
2130 */
2131 if (lim_is_fils_connection(pe_session))
2132 populate_fils_ft_info(mac_ctx, &frm->FTInfo,
2133 pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002134 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002135
2136#ifdef FEATURE_WLAN_ESE
2137 /*
2138 * ESE Version IE will be included in association request
2139 * when ESE is enabled on DUT through ini and it is also
2140 * advertised by the peer AP to which we are trying to
2141 * associate to.
2142 */
2143 if (pe_session->is_ese_version_ie_present &&
Wu Gao51a63562018-11-08 16:29:10 +08002144 mac_ctx->mlme_cfg->lfr.ese_enabled)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002145 populate_dot11f_ese_version(&frm->ESEVersion);
2146 /* For ESE Associations fill the ESE IEs */
2147 if (pe_session->isESEconnection &&
Pragaspathi Thilagaraj64ae59d2019-06-22 13:00:34 +05302148 pe_session->lim_join_req->isESEFeatureIniEnabled) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002149#ifndef FEATURE_DISABLE_RM
2150 populate_dot11f_ese_rad_mgmt_cap(&frm->ESERadMgmtCap);
2151#endif
2152 }
2153#endif
2154
Hu Wang411e0cc2016-10-28 14:56:01 +08002155 /*
2156 * Extcap IE now support variable length, merge Extcap IE from addn_ie
2157 * may change the frame size. Therefore, MUST merge ExtCap IE before
2158 * dot11f get packed payload size.
2159 */
2160 if (extr_ext_flag)
Hu Wangfbd279d2016-10-31 18:24:34 +08002161 lim_merge_extcap_struct(&frm->ExtCap, &extr_ext_cap, true);
2162
2163 /* Clear the bits in EXTCAP IE if AP not advertise it in beacon */
2164 if (frm->ExtCap.present && pe_session->is_ext_caps_present) {
2165 ie_offset = DOT11F_FF_TIMESTAMP_LEN +
2166 DOT11F_FF_BEACONINTERVAL_LEN +
2167 DOT11F_FF_CAPABILITIES_LEN;
2168
2169 qdf_mem_zero((uint8_t *)&bcn_ext_cap, sizeof(tDot11fIEExtCap));
2170 if (pe_session->beacon && pe_session->bcnLen > ie_offset) {
2171 bcn_ie = pe_session->beacon + ie_offset;
2172 bcn_ie_len = pe_session->bcnLen - ie_offset;
Naveen Rawat08db88f2017-09-08 15:07:48 -07002173 p_ext_cap = (uint8_t *)wlan_get_ie_ptr_from_eid(
Hu Wangfbd279d2016-10-31 18:24:34 +08002174 DOT11F_EID_EXTCAP,
Naveen Rawat08db88f2017-09-08 15:07:48 -07002175 bcn_ie, bcn_ie_len);
Hu Wangfbd279d2016-10-31 18:24:34 +08002176 lim_update_extcap_struct(mac_ctx, p_ext_cap,
2177 &bcn_ext_cap);
2178 lim_merge_extcap_struct(&frm->ExtCap, &bcn_ext_cap,
2179 false);
2180 }
Varun Reddy Yeturu4f849e52018-06-15 18:08:37 -07002181 /*
2182 * TWT extended capabilities should be populated after the
2183 * intersection of beacon caps and self caps is done because
2184 * the bits for TWT are unique to STA and AP and cannot be
2185 * intersected.
2186 */
2187 populate_dot11f_twt_extended_caps(mac_ctx, pe_session,
2188 &frm->ExtCap);
Hu Wangfbd279d2016-10-31 18:24:34 +08002189 }
Hu Wang411e0cc2016-10-28 14:56:01 +08002190
Jeff Johnson0301ecb2018-06-29 09:36:23 -07002191 if (QDF_STATUS_SUCCESS != lim_strip_supp_op_class_update_struct(mac_ctx,
Arif Hussain6cec6bc2017-02-14 13:46:26 -08002192 add_ie, &add_ie_len, &frm->SuppOperatingClasses))
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002193 pe_debug("Unable to Stripoff supp op classes IE from Assoc Req");
Arif Hussain6cec6bc2017-02-14 13:46:26 -08002194
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +05302195 if (lim_is_fils_connection(pe_session)) {
2196 populate_dot11f_fils_params(mac_ctx, frm, pe_session);
2197 aes_block_size_len = AES_BLOCK_SIZE;
2198 }
2199
Pragaspathi Thilagarajc0515882019-10-24 02:59:11 +05302200 /* RSNX IE for SAE PWE derivation based on H2E */
2201 if (wlan_get_ie_ptr_from_eid(WLAN_ELEMID_RSNXE, add_ie, add_ie_len)) {
2202 rsnx_ie = qdf_mem_malloc(WLAN_MAX_IE_LEN + 2);
2203 if (!rsnx_ie)
2204 goto end;
2205
2206 qdf_status = lim_strip_ie(mac_ctx, add_ie, &add_ie_len,
2207 WLAN_ELEMID_RSNXE, ONE_BYTE,
2208 NULL, 0, rsnx_ie, WLAN_MAX_IE_LEN);
2209 if (QDF_IS_STATUS_ERROR(qdf_status)) {
2210 pe_err("Failed to strip Vendor IEs");
2211 goto end;
2212 }
2213 rsnx_ie_len = rsnx_ie[1] + 2;
2214 pe_debug("RSNX_IE added to association request");
2215 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_DEBUG,
2216 rsnx_ie, rsnx_ie_len);
2217 }
2218
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +05302219 /*
Vignesh Viswanathandada7932018-09-18 12:57:55 +05302220 * MBO IE needs to be appendded at the end of the assoc request
2221 * frame and is not parsed and unpacked by the frame parser
2222 * as the supplicant can send multiple TLVs with same Attribute
2223 * in the MBO IE and the frame parser does not support multiple
2224 * TLVs with same attribute in a single IE.
2225 * Strip off the MBO IE from add_ie and append it at the end.
2226 */
2227 if (wlan_get_vendor_ie_ptr_from_oui(SIR_MAC_MBO_OUI,
2228 SIR_MAC_MBO_OUI_SIZE, add_ie, add_ie_len)) {
2229 mbo_ie = qdf_mem_malloc(DOT11F_IE_MBO_IE_MAX_LEN + 2);
Arif Hussainf5b6c412018-10-10 19:41:09 -07002230 if (!mbo_ie)
Vignesh Viswanathandada7932018-09-18 12:57:55 +05302231 goto end;
Vignesh Viswanathandada7932018-09-18 12:57:55 +05302232
2233 qdf_status = lim_strip_ie(mac_ctx, add_ie, &add_ie_len,
Srinivas Girigowda61771262019-04-01 11:55:19 -07002234 WLAN_ELEMID_VENDOR, ONE_BYTE,
Vignesh Viswanathandada7932018-09-18 12:57:55 +05302235 SIR_MAC_MBO_OUI,
2236 SIR_MAC_MBO_OUI_SIZE,
2237 mbo_ie, DOT11F_IE_MBO_IE_MAX_LEN);
2238 if (QDF_IS_STATUS_ERROR(qdf_status)) {
2239 pe_err("Failed to strip MBO IE");
Srinivas Dasari22397902019-07-29 21:34:10 +05302240 goto end;
Vignesh Viswanathandada7932018-09-18 12:57:55 +05302241 }
2242
2243 /* Include the EID and length fields */
2244 mbo_ie_len = mbo_ie[1] + 2;
Srinivas Dasari603d4972019-09-20 17:28:44 +05302245
Pragaspathi Thilagaraj376ead92019-12-11 19:13:28 +05302246 if (pe_session->connected_akm == ANI_AKM_TYPE_NONE)
2247 is_open_auth = true;
2248
2249 pe_debug("Stripped MBO IE of length %d is_open_auth:%d",
2250 mbo_ie_len, is_open_auth);
2251
2252 if (!is_open_auth) {
2253 peer = wlan_objmgr_get_peer_by_mac(
2254 mac_ctx->psoc,
2255 mlm_assoc_req->peerMacAddr,
2256 WLAN_MBO_ID);
2257 if (peer && !mlme_get_peer_pmf_status(peer)) {
2258 pe_debug("Peer doesn't support PMF, Don't add MBO IE");
2259 qdf_mem_free(mbo_ie);
2260 mbo_ie = NULL;
2261 mbo_ie_len = 0;
2262 }
2263 if (peer)
2264 wlan_objmgr_peer_release_ref(peer, WLAN_MBO_ID);
Srinivas Dasari603d4972019-09-20 17:28:44 +05302265 }
Vignesh Viswanathandada7932018-09-18 12:57:55 +05302266 }
2267
Srinivas Dasari22397902019-07-29 21:34:10 +05302268 /*
2269 * Strip rest of the vendor IEs and append to the assoc request frame.
2270 * Append the IEs just before MBO IEs as MBO IEs have to be at the
2271 * end of the frame.
2272 */
2273 if (wlan_get_ie_ptr_from_eid(WLAN_ELEMID_VENDOR, add_ie, add_ie_len)) {
2274 vendor_ies = qdf_mem_malloc(MAX_VENDOR_IES_LEN + 2);
2275 if (vendor_ies) {
2276 current_len = add_ie_len;
2277 qdf_status = lim_strip_ie(mac_ctx, add_ie, &add_ie_len,
2278 WLAN_ELEMID_VENDOR, ONE_BYTE,
2279 NULL,
2280 0,
2281 vendor_ies,
2282 MAX_VENDOR_IES_LEN);
2283 if (QDF_IS_STATUS_ERROR(qdf_status)) {
2284 pe_err("Failed to strip Vendor IEs");
2285 goto end;
2286 }
2287
2288 vendor_ie_len = current_len - add_ie_len;
2289 pe_debug("Stripped vendor IEs of size: %u",
2290 current_len);
2291 }
2292 }
2293
Pragaspathi Thilagaraj54018e02019-04-25 01:32:17 +05302294 qdf_status = lim_fill_adaptive_11r_ie(pe_session, &adaptive_11r_ie,
2295 &adaptive_11r_ie_len);
2296 if (QDF_IS_STATUS_ERROR(qdf_status)) {
2297 pe_err("Failed to fill adaptive 11r IE");
Srinivas Dasari22397902019-07-29 21:34:10 +05302298 goto end;
Pragaspathi Thilagaraj54018e02019-04-25 01:32:17 +05302299 }
2300
Vignesh Viswanathandada7932018-09-18 12:57:55 +05302301 /*
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +05302302 * Do unpack to populate the add_ie buffer to frm structure
2303 * before packing the frm structure. In this way, the IE ordering
2304 * which the latest 802.11 spec mandates is maintained.
2305 */
Naveen Rawat72475db2017-12-13 18:07:35 -08002306 if (add_ie_len) {
2307 ret = dot11f_unpack_assoc_request(mac_ctx, add_ie,
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +05302308 add_ie_len, frm, true);
Naveen Rawat72475db2017-12-13 18:07:35 -08002309 if (DOT11F_FAILED(ret)) {
2310 pe_err("unpack failed, ret: 0x%x", ret);
2311 goto end;
2312 }
2313 }
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +05302314
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002315 status = dot11f_get_packed_assoc_request_size(mac_ctx, frm, &payload);
2316 if (DOT11F_FAILED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002317 pe_err("Association Request packet size failure(0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002318 status);
2319 /* We'll fall back on the worst case scenario: */
2320 payload = sizeof(tDot11fAssocRequest);
2321 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002322 pe_warn("Association request packet size warning (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002323 status);
2324 }
2325
Pragaspathi Thilagarajc0515882019-10-24 02:59:11 +05302326 bytes = payload + sizeof(tSirMacMgmtHdr) + aes_block_size_len +
2327 rsnx_ie_len + mbo_ie_len + adaptive_11r_ie_len + vendor_ie_len;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002328
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302329 qdf_status = cds_packet_alloc((uint16_t) bytes, (void **)&frame,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002330 (void **)&packet);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302331 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002332 pe_err("Failed to allocate %d bytes", bytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002333
2334 pe_session->limMlmState = pe_session->limPrevMlmState;
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302335 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_MLM_STATE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002336 pe_session->peSessionId,
2337 pe_session->limMlmState));
2338
2339 /* Update PE session id */
2340 assoc_cnf.sessionId = pe_session->peSessionId;
2341
2342 assoc_cnf.resultCode = eSIR_SME_RESOURCES_UNAVAILABLE;
2343
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002344 lim_post_sme_message(mac_ctx, LIM_MLM_ASSOC_CNF,
2345 (uint32_t *) &assoc_cnf);
2346
yeshwanth sriram guntuka07831012017-06-30 12:26:57 +05302347 goto end;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002348 }
2349 /* Paranoia: */
hangtian127c9532019-01-12 13:29:07 +08002350 qdf_mem_zero(frame, bytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002351
2352 /* Next, we fill out the buffer descriptor: */
2353 lim_populate_mac_header(mac_ctx, frame, SIR_MAC_MGMT_FRAME,
2354 SIR_MAC_MGMT_ASSOC_REQ, pe_session->bssId,
Pragaspathi Thilagaraj7fb14222019-06-17 23:26:58 +05302355 pe_session->self_mac_addr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002356 /* That done, pack the Assoc Request: */
2357 status = dot11f_pack_assoc_request(mac_ctx, frm,
2358 frame + sizeof(tSirMacMgmtHdr), payload, &payload);
2359 if (DOT11F_FAILED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002360 pe_err("Assoc request pack failure (0x%08x)", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002361 cds_packet_free((void *)packet);
yeshwanth sriram guntuka07831012017-06-30 12:26:57 +05302362 goto end;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002363 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002364 pe_warn("Assoc request pack warning (0x%08x)", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002365 }
2366
Pragaspathi Thilagarajc0515882019-10-24 02:59:11 +05302367 if (rsnx_ie && rsnx_ie_len) {
2368 qdf_mem_copy(frame + sizeof(tSirMacMgmtHdr) + payload,
2369 rsnx_ie, rsnx_ie_len);
2370 payload = payload + rsnx_ie_len;
2371 }
2372
Srinivas Dasari22397902019-07-29 21:34:10 +05302373 /* Copy the vendor IEs to the end of the frame */
2374 qdf_mem_copy(frame + sizeof(tSirMacMgmtHdr) + payload,
2375 vendor_ies, vendor_ie_len);
2376 payload = payload + vendor_ie_len;
2377
Vignesh Viswanathandada7932018-09-18 12:57:55 +05302378 /* Copy the MBO IE to the end of the frame */
2379 qdf_mem_copy(frame + sizeof(tSirMacMgmtHdr) + payload,
2380 mbo_ie, mbo_ie_len);
2381 payload = payload + mbo_ie_len;
2382
Pragaspathi Thilagaraj54018e02019-04-25 01:32:17 +05302383 /*
2384 * Copy the Vendor specific Adaptive 11r IE to end of the
2385 * assoc request frame
2386 */
2387 qdf_mem_copy(frame + sizeof(tSirMacMgmtHdr) + payload,
2388 adaptive_11r_ie, adaptive_11r_ie_len);
2389 payload = payload + adaptive_11r_ie_len;
2390
Pragaspathi Thilagarajf812ccf2019-06-22 13:07:04 +05302391 if (pe_session->assoc_req) {
2392 qdf_mem_free(pe_session->assoc_req);
2393 pe_session->assoc_req = NULL;
Naveen Rawat83102ef2015-11-03 10:42:34 -08002394 pe_session->assocReqLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002395 }
2396
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +05302397 if (lim_is_fils_connection(pe_session)) {
2398 qdf_status = aead_encrypt_assoc_req(mac_ctx, pe_session,
2399 frame, &payload);
2400 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
2401 cds_packet_free((void *)packet);
Srinivas Dasari22397902019-07-29 21:34:10 +05302402 goto end;
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +05302403 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002404 }
2405
Pragaspathi Thilagarajf812ccf2019-06-22 13:07:04 +05302406 pe_session->assoc_req = qdf_mem_malloc(payload);
2407 if (pe_session->assoc_req) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002408 /*
2409 * Store the Assoc request. This is sent to csr/hdd in
2410 * join cnf response.
2411 */
Pragaspathi Thilagarajf812ccf2019-06-22 13:07:04 +05302412 qdf_mem_copy(pe_session->assoc_req,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002413 frame + sizeof(tSirMacMgmtHdr), payload);
2414 pe_session->assocReqLen = payload;
2415 }
2416
Liangwei Dong419d7302019-07-15 15:38:28 +08002417 if (wlan_reg_is_5ghz_ch_freq(pe_session->curr_op_freq) ||
2418 pe_session->opmode == QDF_P2P_CLIENT_MODE ||
2419 pe_session->opmode == QDF_P2P_GO_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002420 tx_flag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
2421
Pragaspathi Thilagaraje64714a2019-05-23 00:46:25 +05302422 if (pe_session->opmode == QDF_P2P_CLIENT_MODE ||
2423 pe_session->opmode == QDF_STA_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002424 tx_flag |= HAL_USE_PEER_STA_REQUESTED_MASK;
2425
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002426 mac_hdr = (tpSirMacMgmtHdr) frame;
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302427 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002428 pe_session->peSessionId, mac_hdr->fc.subType));
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +05302429
2430 pe_debug("Sending Association Request length %d to ", bytes);
Naveen Rawat296a5182017-09-25 14:02:48 -07002431 min_rid = lim_get_min_session_txrate(pe_session);
Krunal Sonic65fc492018-03-09 15:53:28 -08002432 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_ASSOC_START_EVENT,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07002433 pe_session, QDF_STATUS_SUCCESS, QDF_STATUS_SUCCESS);
Krunal Sonic65fc492018-03-09 15:53:28 -08002434 lim_diag_mgmt_tx_event_report(mac_ctx, mac_hdr,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07002435 pe_session, QDF_STATUS_SUCCESS, QDF_STATUS_SUCCESS);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302436 qdf_status =
Abhishek Singhdd2cb572017-08-11 11:10:19 +05302437 wma_tx_frameWithTxComplete(mac_ctx, packet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002438 (uint16_t) (sizeof(tSirMacMgmtHdr) + payload),
2439 TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS, 7,
Abhishek Singhdd2cb572017-08-11 11:10:19 +05302440 lim_tx_complete, frame, lim_assoc_tx_complete_cnf,
Abhishek Singhcc02c9b2019-11-25 14:51:30 +05302441 tx_flag, vdev_id, false, 0, min_rid);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302442 MTRACE(qdf_trace
Anurag Chouhan6d760662016-02-20 16:05:43 +05302443 (QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302444 pe_session->peSessionId, qdf_status));
Naveen Rawat296a5182017-09-25 14:02:48 -07002445
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302446 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002447 pe_err("Failed to send Association Request (%X)!",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302448 qdf_status);
Abhishek Singhdd2cb572017-08-11 11:10:19 +05302449 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_ASSOC_ACK_EVENT,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07002450 pe_session, SENT_FAIL, QDF_STATUS_E_FAILURE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002451 /* Pkt will be freed up by the callback */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002452 }
Vignesh Viswanathandada7932018-09-18 12:57:55 +05302453
yeshwanth sriram guntuka07831012017-06-30 12:26:57 +05302454end:
Pragaspathi Thilagarajc0515882019-10-24 02:59:11 +05302455 qdf_mem_free(rsnx_ie);
Srinivas Dasari22397902019-07-29 21:34:10 +05302456 qdf_mem_free(vendor_ies);
2457 qdf_mem_free(mbo_ie);
2458
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002459 /* Free up buffer allocated for mlm_assoc_req */
Pragaspathi Thilagaraj54018e02019-04-25 01:32:17 +05302460 qdf_mem_free(adaptive_11r_ie);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302461 qdf_mem_free(mlm_assoc_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002462 mlm_assoc_req = NULL;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302463 qdf_mem_free(frm);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002464 return;
2465}
2466
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002467/**
Krunal Sonid2136c72018-06-01 17:26:39 -07002468 * lim_addba_rsp_tx_complete_cnf() - Confirmation for add BA response OTA
2469 * @context: pointer to global mac
2470 * @buf: buffer which is nothing but entire ADD BA frame
2471 * @tx_complete : Sent status
2472 * @params; tx completion params
2473 *
2474 * Return: This returns QDF_STATUS
2475 */
2476static QDF_STATUS lim_addba_rsp_tx_complete_cnf(void *context,
2477 qdf_nbuf_t buf,
2478 uint32_t tx_complete,
2479 void *params)
2480{
Jeff Johnson9320c1e2018-12-02 13:09:20 -08002481 struct mac_context *mac_ctx = (struct mac_context *)context;
Krunal Sonid2136c72018-06-01 17:26:39 -07002482 tSirMacMgmtHdr *mac_hdr;
2483 tDot11faddba_rsp rsp;
2484 void *soc = cds_get_context(QDF_MODULE_ID_SOC);
Krunal Sonid2136c72018-06-01 17:26:39 -07002485 uint32_t frame_len;
2486 QDF_STATUS status;
2487 uint8_t *data;
Vevek Venkatesan0ac759f2019-10-03 04:14:29 +05302488 struct wmi_mgmt_params *mgmt_params = (struct wmi_mgmt_params *)params;
Krunal Sonid2136c72018-06-01 17:26:39 -07002489
2490 if (tx_complete == WMI_MGMT_TX_COMP_TYPE_COMPLETE_OK)
2491 pe_debug("Add ba response successfully sent");
2492 else
2493 pe_debug("Fail to send add ba response");
2494
2495 if (!buf) {
2496 pe_err("Addba response frame buffer is NULL");
2497 return QDF_STATUS_E_FAILURE;
2498 }
2499
2500 data = qdf_nbuf_data(buf);
2501
2502 if (!data) {
2503 pe_err("Addba response frame is NULL");
2504 return QDF_STATUS_E_FAILURE;
2505 }
2506
2507 mac_hdr = (tSirMacMgmtHdr *)data;
2508 qdf_mem_zero((void *)&rsp, sizeof(tDot11faddba_rsp));
2509 frame_len = sizeof(rsp);
2510 status = dot11f_unpack_addba_rsp(mac_ctx, (uint8_t *)data +
2511 sizeof(*mac_hdr), frame_len,
2512 &rsp, false);
2513
2514 if (DOT11F_FAILED(status)) {
2515 pe_err("Failed to unpack and parse (0x%08x, %d bytes)",
2516 status, frame_len);
2517 goto error;
2518 }
2519
Vevek Venkatesan0ac759f2019-10-03 04:14:29 +05302520 cdp_addba_resp_tx_completion(soc, mac_hdr->da, mgmt_params->vdev_id,
2521 rsp.addba_param_set.tid, tx_complete);
Krunal Sonid2136c72018-06-01 17:26:39 -07002522error:
2523 if (buf)
2524 qdf_nbuf_free(buf);
2525
2526 return QDF_STATUS_SUCCESS;
2527}
2528
2529/**
Abhishek Singh7d3bc3e2016-02-03 17:45:01 +05302530 * lim_auth_tx_complete_cnf()- Confirmation for auth sent over the air
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05302531 * @context: pointer to global mac
2532 * @buf: buffer
Abhishek Singh7d3bc3e2016-02-03 17:45:01 +05302533 * @tx_complete : Sent status
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05302534 * @params; tx completion params
Abhishek Singh7d3bc3e2016-02-03 17:45:01 +05302535 *
2536 * Return: This returns QDF_STATUS
2537 */
2538
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05302539static QDF_STATUS lim_auth_tx_complete_cnf(void *context,
2540 qdf_nbuf_t buf,
2541 uint32_t tx_complete,
2542 void *params)
Abhishek Singh7d3bc3e2016-02-03 17:45:01 +05302543{
Jeff Johnson9320c1e2018-12-02 13:09:20 -08002544 struct mac_context *mac_ctx = (struct mac_context *)context;
Abhishek Singhdd2cb572017-08-11 11:10:19 +05302545 uint16_t auth_ack_status;
2546 uint16_t reason_code;
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05302547
Naveen Rawat684e8b12017-09-20 15:54:44 -07002548 pe_debug("tx_complete = %d %s", tx_complete,
Zhu Jianmin5d8e3fe2018-01-04 16:16:20 +08002549 (tx_complete == WMI_MGMT_TX_COMP_TYPE_COMPLETE_OK) ?
2550 "success" : "fail");
2551 if (tx_complete == WMI_MGMT_TX_COMP_TYPE_COMPLETE_OK) {
Abhishek Singh7d3bc3e2016-02-03 17:45:01 +05302552 mac_ctx->auth_ack_status = LIM_AUTH_ACK_RCD_SUCCESS;
Abhishek Singhdd2cb572017-08-11 11:10:19 +05302553 auth_ack_status = ACKED;
Jeff Johnson0301ecb2018-06-29 09:36:23 -07002554 reason_code = QDF_STATUS_SUCCESS;
Abhishek Singh7d3bc3e2016-02-03 17:45:01 +05302555 /* 'Change' timer for future activations */
2556 lim_deactivate_and_change_timer(mac_ctx, eLIM_AUTH_RETRY_TIMER);
2557 } else {
2558 mac_ctx->auth_ack_status = LIM_AUTH_ACK_RCD_FAILURE;
Abhishek Singhdd2cb572017-08-11 11:10:19 +05302559 auth_ack_status = NOT_ACKED;
Jeff Johnson0301ecb2018-06-29 09:36:23 -07002560 reason_code = QDF_STATUS_E_FAILURE;
Abhishek Singh7d3bc3e2016-02-03 17:45:01 +05302561 }
Himanshu Agarwal8b472bc2017-01-20 20:49:41 +05302562
2563 if (buf)
2564 qdf_nbuf_free(buf);
2565
Abhishek Singhdd2cb572017-08-11 11:10:19 +05302566 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_AUTH_ACK_EVENT,
2567 NULL, auth_ack_status, reason_code);
2568
Abhishek Singh7d3bc3e2016-02-03 17:45:01 +05302569 return QDF_STATUS_SUCCESS;
2570}
2571
2572/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002573 * lim_send_auth_mgmt_frame() - Send an Authentication frame
2574 *
2575 * @mac_ctx: Pointer to Global MAC structure
2576 * @auth_frame: Pointer to Authentication frame structure
2577 * @peer_addr: MAC address of destination peer
2578 * @wep_bit: wep bit in frame control for Authentication frame3
2579 * @session: PE session information
2580 *
2581 * This function is called by lim_process_mlm_messages(). Authentication frame
2582 * is formatted and sent when this function is called.
2583 *
2584 * Return: void
2585 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002586void
Jeff Johnson9320c1e2018-12-02 13:09:20 -08002587lim_send_auth_mgmt_frame(struct mac_context *mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002588 tpSirMacAuthFrameBody auth_frame,
2589 tSirMacAddr peer_addr,
yeshwanth sriram guntuka343a3f22017-07-27 18:30:18 +05302590 uint8_t wep_challenge_len,
Jeff Johnsona7815652018-11-18 22:58:30 -08002591 struct pe_session *session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002592{
2593 uint8_t *frame, *body;
2594 uint32_t frame_len = 0, body_len = 0;
2595 tpSirMacMgmtHdr mac_hdr;
2596 void *packet;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302597 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002598 uint8_t tx_flag = 0;
Abhishek Singhcc02c9b2019-11-25 14:51:30 +05302599 uint8_t vdev_id = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002600 uint16_t ft_ies_length = 0;
Krishna Kumaar Natarajan0517c602017-06-02 14:58:21 -07002601 bool challenge_req = false;
Naveen Rawat296a5182017-09-25 14:02:48 -07002602 enum rateid min_rid = RATEID_DEFAULT;
Rajasekaran Kalidoss7152a352018-11-19 09:58:35 +05302603 uint16_t ch_freq_tx_frame = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002604
Jeff Johnson8e9530b2019-03-18 13:41:42 -07002605 if (!session) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002606 pe_err("Error: psession Entry is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002607 return;
2608 }
2609
Abhishek Singhcc02c9b2019-11-25 14:51:30 +05302610 vdev_id = session->vdev_id;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002611
yeshwanth sriram guntuka343a3f22017-07-27 18:30:18 +05302612 if (wep_challenge_len) {
Krishna Kumaar Natarajan7e6a23c2016-04-05 14:45:24 -07002613 /*
2614 * Auth frame3 to be sent with encrypted framebody
2615 *
2616 * Allocate buffer for Authenticaton frame of size
2617 * equal to management frame header length plus 2 bytes
2618 * each for auth algorithm number, transaction number,
2619 * status code, 128 bytes for challenge text and
2620 * 4 bytes each for IV & ICV.
2621 */
Srinivas Girigowdacb7b8b82019-04-10 14:27:47 -07002622 pe_debug("Sending encrypted auth frame to " QDF_MAC_ADDR_STR,
Srinivas Girigowda34fbba02019-04-08 12:07:44 -07002623 QDF_MAC_ADDR_ARRAY(peer_addr));
Krishna Kumaar Natarajan7e6a23c2016-04-05 14:45:24 -07002624
yeshwanth sriram guntuka343a3f22017-07-27 18:30:18 +05302625 body_len = wep_challenge_len + LIM_ENCR_AUTH_INFO_LEN;
Krishna Kumaar Natarajan0517c602017-06-02 14:58:21 -07002626 frame_len = sizeof(tSirMacMgmtHdr) + body_len;
Krishna Kumaar Natarajan7e6a23c2016-04-05 14:45:24 -07002627
2628 goto alloc_packet;
2629 }
2630
Tushnim Bhattacharyya332b74c2018-08-10 10:55:51 -07002631 pe_debug("Sending Auth seq# %d status %d (%d) to "
Srinivas Girigowdacb7b8b82019-04-10 14:27:47 -07002632 QDF_MAC_ADDR_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002633 auth_frame->authTransactionSeqNumber,
2634 auth_frame->authStatusCode,
2635 (auth_frame->authStatusCode == eSIR_MAC_SUCCESS_STATUS),
Srinivas Girigowda34fbba02019-04-08 12:07:44 -07002636 QDF_MAC_ADDR_ARRAY(peer_addr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002637
2638 switch (auth_frame->authTransactionSeqNumber) {
2639 case SIR_MAC_AUTH_FRAME_1:
2640 /*
2641 * Allocate buffer for Authenticaton frame of size
2642 * equal to management frame header length plus 2 bytes
2643 * each for auth algorithm number, transaction number
2644 * and status code.
2645 */
2646
Krishna Kumaar Natarajan0517c602017-06-02 14:58:21 -07002647 body_len = SIR_MAC_AUTH_FRAME_INFO_LEN;
2648 frame_len = sizeof(tSirMacMgmtHdr) + body_len;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002649
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +05302650 frame_len += lim_create_fils_auth_data(mac_ctx,
2651 auth_frame, session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002652 if (auth_frame->authAlgoNumber == eSIR_FT_AUTH) {
Jeff Johnson8e9530b2019-03-18 13:41:42 -07002653 if (session->ftPEContext.pFTPreAuthReq &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002654 0 != session->ftPEContext.pFTPreAuthReq->
2655 ft_ies_length) {
2656 ft_ies_length = session->ftPEContext.
2657 pFTPreAuthReq->ft_ies_length;
2658 frame_len += ft_ies_length;
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002659 pe_debug("Auth frame, FTIES length added=%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002660 ft_ies_length);
2661 } else {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002662 pe_debug("Auth frame, Does not contain FTIES!");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002663 frame_len += (2 + SIR_MDIE_SIZE);
2664 }
2665 }
Pragaspathi Thilagaraj239883a2019-03-08 00:33:50 +05302666
2667 /* include MDIE in FILS authentication frame */
Pragaspathi Thilagaraj64ae59d2019-06-22 13:00:34 +05302668 if (session->lim_join_req &&
2669 session->lim_join_req->is11Rconnection &&
Pragaspathi Thilagaraj239883a2019-03-08 00:33:50 +05302670 auth_frame->authAlgoNumber == SIR_FILS_SK_WITHOUT_PFS &&
Pragaspathi Thilagaraj64ae59d2019-06-22 13:00:34 +05302671 session->lim_join_req->bssDescription.mdiePresent)
Pragaspathi Thilagaraj239883a2019-03-08 00:33:50 +05302672 frame_len += (2 + SIR_MDIE_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002673 break;
2674
2675 case SIR_MAC_AUTH_FRAME_2:
2676 if ((auth_frame->authAlgoNumber == eSIR_OPEN_SYSTEM) ||
2677 ((auth_frame->authAlgoNumber == eSIR_SHARED_KEY) &&
2678 (auth_frame->authStatusCode !=
2679 eSIR_MAC_SUCCESS_STATUS))) {
2680 /*
2681 * Allocate buffer for Authenticaton frame of size
2682 * equal to management frame header length plus
2683 * 2 bytes each for auth algorithm number,
2684 * transaction number and status code.
2685 */
2686
Krishna Kumaar Natarajan0517c602017-06-02 14:58:21 -07002687 body_len = SIR_MAC_AUTH_FRAME_INFO_LEN;
2688 frame_len = sizeof(tSirMacMgmtHdr) + body_len;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002689 } else {
2690 /*
2691 * Shared Key algorithm with challenge text
2692 * to be sent.
2693 *
2694 * Allocate buffer for Authenticaton frame of size
2695 * equal to management frame header length plus
2696 * 2 bytes each for auth algorithm number,
2697 * transaction number, status code and 128 bytes
2698 * for challenge text.
2699 */
2700
Krishna Kumaar Natarajan0517c602017-06-02 14:58:21 -07002701 challenge_req = true;
2702 body_len = SIR_MAC_AUTH_FRAME_INFO_LEN +
yeshwanth sriram guntuka5c71a292017-08-24 15:51:19 +05302703 SIR_MAC_SAP_AUTH_CHALLENGE_LENGTH +
2704 SIR_MAC_CHALLENGE_ID_LEN;
Krishna Kumaar Natarajan0517c602017-06-02 14:58:21 -07002705 frame_len = sizeof(tSirMacMgmtHdr) + body_len;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002706 }
2707 break;
2708
2709 case SIR_MAC_AUTH_FRAME_3:
Krishna Kumaar Natarajan7e6a23c2016-04-05 14:45:24 -07002710 /*
2711 * Auth frame3 to be sent without encrypted framebody
2712 *
2713 * Allocate buffer for Authenticaton frame of size equal
2714 * to management frame header length plus 2 bytes each
2715 * for auth algorithm number, transaction number and
2716 * status code.
2717 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002718
Krishna Kumaar Natarajan0517c602017-06-02 14:58:21 -07002719 body_len = SIR_MAC_AUTH_FRAME_INFO_LEN;
2720 frame_len = sizeof(tSirMacMgmtHdr) + body_len;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002721 break;
2722
2723 case SIR_MAC_AUTH_FRAME_4:
2724 /*
2725 * Allocate buffer for Authenticaton frame of size equal
2726 * to management frame header length plus 2 bytes each
2727 * for auth algorithm number, transaction number and
2728 * status code.
2729 */
2730
Krishna Kumaar Natarajan0517c602017-06-02 14:58:21 -07002731 body_len = SIR_MAC_AUTH_FRAME_INFO_LEN;
2732 frame_len = sizeof(tSirMacMgmtHdr) + body_len;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002733
2734 break;
Krishna Kumaar Natarajan7e6a23c2016-04-05 14:45:24 -07002735 default:
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002736 pe_err("Invalid auth transaction seq num");
Krishna Kumaar Natarajan7e6a23c2016-04-05 14:45:24 -07002737 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002738 } /* switch (auth_frame->authTransactionSeqNumber) */
2739
Krishna Kumaar Natarajan7e6a23c2016-04-05 14:45:24 -07002740alloc_packet:
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302741 qdf_status = cds_packet_alloc((uint16_t) frame_len, (void **)&frame,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002742 (void **)&packet);
2743
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302744 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002745 pe_err("call to bufAlloc failed for AUTH frame");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002746 return;
2747 }
2748
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302749 qdf_mem_zero(frame, frame_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002750
2751 /* Prepare BD */
2752 lim_populate_mac_header(mac_ctx, frame, SIR_MAC_MGMT_FRAME,
Pragaspathi Thilagaraj7fb14222019-06-17 23:26:58 +05302753 SIR_MAC_MGMT_AUTH, peer_addr, session->self_mac_addr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002754 mac_hdr = (tpSirMacMgmtHdr) frame;
yeshwanth sriram guntuka343a3f22017-07-27 18:30:18 +05302755 if (wep_challenge_len)
2756 mac_hdr->fc.wep = LIM_WEP_IN_FC;
2757 else
2758 mac_hdr->fc.wep = LIM_NO_WEP_IN_FC;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002759
2760 /* Prepare BSSId */
Rajeev Kumarcf835a02016-04-15 15:01:31 -07002761 if (LIM_IS_AP_ROLE(session))
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302762 qdf_mem_copy((uint8_t *) mac_hdr->bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002763 (uint8_t *) session->bssId,
2764 sizeof(tSirMacAddr));
2765
2766 /* Prepare Authentication frame body */
2767 body = frame + sizeof(tSirMacMgmtHdr);
2768
yeshwanth sriram guntuka343a3f22017-07-27 18:30:18 +05302769 if (wep_challenge_len) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302770 qdf_mem_copy(body, (uint8_t *) auth_frame, body_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002771
Srinivas Girigowdacb7b8b82019-04-10 14:27:47 -07002772 pe_debug("Sending Auth seq# 3 to " QDF_MAC_ADDR_STR,
Srinivas Girigowda34fbba02019-04-08 12:07:44 -07002773 QDF_MAC_ADDR_ARRAY(mac_hdr->da));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002774
2775 } else {
2776 *((uint16_t *) (body)) =
2777 sir_swap_u16if_needed(auth_frame->authAlgoNumber);
2778 body += sizeof(uint16_t);
2779 body_len -= sizeof(uint16_t);
2780
2781 *((uint16_t *) (body)) =
2782 sir_swap_u16if_needed(
2783 auth_frame->authTransactionSeqNumber);
2784 body += sizeof(uint16_t);
2785 body_len -= sizeof(uint16_t);
2786
2787 *((uint16_t *) (body)) =
2788 sir_swap_u16if_needed(auth_frame->authStatusCode);
2789 body += sizeof(uint16_t);
2790 body_len -= sizeof(uint16_t);
Krishna Kumaar Natarajan0517c602017-06-02 14:58:21 -07002791
2792 if (challenge_req) {
2793 if (body_len < SIR_MAC_AUTH_CHALLENGE_BODY_LEN) {
Himanshu Agarwalc422ca72017-09-19 11:07:36 +05302794 /* copy challenge IE id, len, challenge text */
2795 *body = auth_frame->type;
2796 body++;
2797 body_len -= sizeof(uint8_t);
2798 *body = auth_frame->length;
2799 body++;
2800 body_len -= sizeof(uint8_t);
2801 qdf_mem_copy(body, auth_frame->challengeText,
Krishna Kumaar Natarajan0517c602017-06-02 14:58:21 -07002802 body_len);
2803 pe_err("Incomplete challenge info: length: %d, expected: %d",
2804 body_len,
2805 SIR_MAC_AUTH_CHALLENGE_BODY_LEN);
2806 body += body_len;
2807 body_len = 0;
2808 } else {
2809 /* copy challenge IE id, len, challenge text */
2810 *body = auth_frame->type;
2811 body++;
2812 *body = auth_frame->length;
2813 body++;
2814 qdf_mem_copy(body, auth_frame->challengeText,
yeshwanth sriram guntuka5c71a292017-08-24 15:51:19 +05302815 SIR_MAC_SAP_AUTH_CHALLENGE_LENGTH);
2816 body += SIR_MAC_SAP_AUTH_CHALLENGE_LENGTH;
Krishna Kumaar Natarajan0517c602017-06-02 14:58:21 -07002817
yeshwanth sriram guntuka5c71a292017-08-24 15:51:19 +05302818 body_len -= SIR_MAC_SAP_AUTH_CHALLENGE_LENGTH +
2819 SIR_MAC_CHALLENGE_ID_LEN;
Krishna Kumaar Natarajan0517c602017-06-02 14:58:21 -07002820 }
2821 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002822
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002823 if ((auth_frame->authAlgoNumber == eSIR_FT_AUTH) &&
2824 (auth_frame->authTransactionSeqNumber ==
2825 SIR_MAC_AUTH_FRAME_1) &&
Jeff Johnson8e9530b2019-03-18 13:41:42 -07002826 (session->ftPEContext.pFTPreAuthReq)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002827
2828 if (ft_ies_length > 0) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302829 qdf_mem_copy(body,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002830 session->ftPEContext.
2831 pFTPreAuthReq->ft_ies,
2832 ft_ies_length);
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002833 pe_debug("Auth1 Frame FTIE is: ");
Srinivas Girigowdab896a562017-03-16 17:41:26 -07002834 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_PE,
2835 QDF_TRACE_LEVEL_DEBUG,
2836 (uint8_t *) body,
2837 ft_ies_length);
Jeff Johnson8e9530b2019-03-18 13:41:42 -07002838 } else if (session->ftPEContext.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002839 pFTPreAuthReq->pbssDescription) {
2840 /* MDID attr is 54 */
Srinivas Girigowda61771262019-04-01 11:55:19 -07002841 *body = WLAN_ELEMID_MOBILITY_DOMAIN;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002842 body++;
2843 *body = SIR_MDIE_SIZE;
2844 body++;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302845 qdf_mem_copy(body,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002846 &session->ftPEContext.pFTPreAuthReq->
2847 pbssDescription->mdie[0],
2848 SIR_MDIE_SIZE);
2849 }
Pragaspathi Thilagaraj239883a2019-03-08 00:33:50 +05302850 } else if ((auth_frame->authAlgoNumber ==
2851 SIR_FILS_SK_WITHOUT_PFS) &&
2852 (auth_frame->authTransactionSeqNumber ==
2853 SIR_MAC_AUTH_FRAME_1)) {
2854 pe_debug("FILS: appending fils Auth data");
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +05302855 lim_add_fils_data_to_auth_frame(session, body);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002856 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002857
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002858 pe_debug("*** Sending Auth seq# %d status %d (%d) to "
Srinivas Girigowdacb7b8b82019-04-10 14:27:47 -07002859 QDF_MAC_ADDR_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002860 auth_frame->authTransactionSeqNumber,
2861 auth_frame->authStatusCode,
2862 (auth_frame->authStatusCode ==
2863 eSIR_MAC_SUCCESS_STATUS),
Srinivas Girigowda34fbba02019-04-08 12:07:44 -07002864 QDF_MAC_ADDR_ARRAY(mac_hdr->da));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002865 }
Srinivas Girigowdab896a562017-03-16 17:41:26 -07002866 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_PE,
2867 QDF_TRACE_LEVEL_DEBUG,
2868 frame, frame_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002869
Jeff Johnson8e9530b2019-03-18 13:41:42 -07002870 if ((session->ftPEContext.pFTPreAuthReq) &&
Wu Gaoceac2852019-11-18 20:13:19 +08002871 (!wlan_reg_is_24ghz_ch_freq(
2872 session->ftPEContext.pFTPreAuthReq->pre_auth_channel_freq)))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002873 tx_flag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
Liangwei Dong419d7302019-07-15 15:38:28 +08002874 else if (wlan_reg_is_5ghz_ch_freq(session->curr_op_freq) ||
2875 session->opmode == QDF_P2P_CLIENT_MODE ||
2876 session->opmode == QDF_P2P_GO_MODE)
Deepthi Gowri1de51e32016-09-01 15:47:28 +05302877 tx_flag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002878
Pragaspathi Thilagaraje64714a2019-05-23 00:46:25 +05302879 if (session->opmode == QDF_P2P_CLIENT_MODE ||
2880 session->opmode == QDF_STA_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002881 tx_flag |= HAL_USE_PEER_STA_REQUESTED_MASK;
2882
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302883 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002884 session->peSessionId, mac_hdr->fc.subType));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002885
Abhishek Singhdd2cb572017-08-11 11:10:19 +05302886 mac_ctx->auth_ack_status = LIM_AUTH_ACK_NOT_RCD;
Naveen Rawat296a5182017-09-25 14:02:48 -07002887 min_rid = lim_get_min_session_txrate(session);
Krunal Sonic65fc492018-03-09 15:53:28 -08002888 lim_diag_mgmt_tx_event_report(mac_ctx, mac_hdr,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07002889 session, QDF_STATUS_SUCCESS, QDF_STATUS_SUCCESS);
Rajasekaran Kalidoss7152a352018-11-19 09:58:35 +05302890
Jeff Johnson8e9530b2019-03-18 13:41:42 -07002891 if (session->ftPEContext.pFTPreAuthReq)
Wu Gaoceac2852019-11-18 20:13:19 +08002892 ch_freq_tx_frame = session->ftPEContext.
2893 pFTPreAuthReq->pre_auth_channel_freq;
Rajasekaran Kalidoss7152a352018-11-19 09:58:35 +05302894
Abhishek Singhdd2cb572017-08-11 11:10:19 +05302895 qdf_status = wma_tx_frameWithTxComplete(mac_ctx, packet,
2896 (uint16_t)frame_len,
2897 TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS,
2898 7, lim_tx_complete, frame,
2899 lim_auth_tx_complete_cnf,
Abhishek Singhcc02c9b2019-11-25 14:51:30 +05302900 tx_flag, vdev_id, false,
Rajasekaran Kalidoss7152a352018-11-19 09:58:35 +05302901 ch_freq_tx_frame, min_rid);
Abhishek Singhdd2cb572017-08-11 11:10:19 +05302902 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
2903 session->peSessionId, qdf_status));
2904 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
2905 pe_err("*** Could not send Auth frame, retCode=%X ***",
2906 qdf_status);
2907 mac_ctx->auth_ack_status = LIM_AUTH_ACK_RCD_FAILURE;
2908 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_AUTH_ACK_EVENT,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07002909 session, SENT_FAIL, QDF_STATUS_E_FAILURE);
Abhishek Singhdd2cb572017-08-11 11:10:19 +05302910 /* Pkt will be freed up by the callback */
Abhishek Singh7d3bc3e2016-02-03 17:45:01 +05302911 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002912 return;
2913}
2914
Jeff Johnson9320c1e2018-12-02 13:09:20 -08002915QDF_STATUS lim_send_deauth_cnf(struct mac_context *mac_ctx)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002916{
2917 uint16_t aid;
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002918 tpDphHashNode sta_ds;
2919 tLimMlmDeauthReq *deauth_req;
2920 tLimMlmDeauthCnf deauth_cnf;
Jeff Johnsona7815652018-11-18 22:58:30 -08002921 struct pe_session *session_entry;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002922
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002923 deauth_req = mac_ctx->lim.limDisassocDeauthCnfReq.pMlmDeauthReq;
2924 if (deauth_req) {
2925 if (tx_timer_running(
Pragaspathi Thilagaraj9f230382019-06-24 11:54:05 +05302926 &mac_ctx->lim.lim_timers.gLimDeauthAckTimer))
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002927 lim_deactivate_and_change_timer(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002928 eLIM_DEAUTH_ACK_TIMER);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002929
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002930 session_entry = pe_find_session_by_session_id(mac_ctx,
2931 deauth_req->sessionId);
Jeff Johnson8e9530b2019-03-18 13:41:42 -07002932 if (!session_entry) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002933 pe_err("session does not exist for given sessionId");
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002934 deauth_cnf.resultCode =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002935 eSIR_SME_INVALID_PARAMETERS;
2936 goto end;
2937 }
2938
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002939 sta_ds =
2940 dph_lookup_hash_entry(mac_ctx,
2941 deauth_req->peer_macaddr.bytes,
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002942 &aid,
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002943 &session_entry->dph.dphHashTable);
Jeff Johnson8e9530b2019-03-18 13:41:42 -07002944 if (!sta_ds) {
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002945 deauth_cnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002946 goto end;
2947 }
2948
2949 /* / Receive path cleanup with dummy packet */
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002950 lim_ft_cleanup_pre_auth_info(mac_ctx, session_entry);
2951 lim_cleanup_rx_path(mac_ctx, sta_ds, session_entry);
2952 if ((session_entry->limSystemRole == eLIM_STA_ROLE) &&
2953 (
Abhishek Singhe0680852015-12-16 14:28:48 +05302954#ifdef FEATURE_WLAN_ESE
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002955 (session_entry->isESEconnection) ||
Abhishek Singhe0680852015-12-16 14:28:48 +05302956#endif
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002957 (session_entry->isFastRoamIniFeatureEnabled) ||
2958 (session_entry->is11Rconnection))) {
Jeff Johnson11bd4f32017-09-18 08:15:17 -07002959 pe_debug("FT Preauth (%pK,%d) Deauth rc %d src = %d",
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002960 session_entry,
2961 session_entry->peSessionId,
2962 deauth_req->reasonCode,
2963 deauth_req->deauthTrigger);
2964 lim_ft_cleanup(mac_ctx, session_entry);
Deepak Dhamdhere262d95a2016-01-10 16:36:53 -08002965 } else {
Deepak Dhamdhere262d95a2016-01-10 16:36:53 -08002966#ifdef FEATURE_WLAN_ESE
Nirav Shahf359dd22019-02-20 10:34:28 +05302967 pe_debug("No FT Preauth Session Cleanup in role %d"
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002968 " isESE %d"
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002969 " isLFR %d"
2970 " is11r %d, Deauth reason %d Trigger = %d",
2971 session_entry->limSystemRole,
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002972 session_entry->isESEconnection,
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002973 session_entry->isFastRoamIniFeatureEnabled,
2974 session_entry->is11Rconnection,
2975 deauth_req->reasonCode,
2976 deauth_req->deauthTrigger);
Nirav Shahf359dd22019-02-20 10:34:28 +05302977#else
2978 pe_debug("No FT Preauth Session Cleanup in role %d"
2979 " isLFR %d"
2980 " is11r %d, Deauth reason %d Trigger = %d",
2981 session_entry->limSystemRole,
2982 session_entry->isFastRoamIniFeatureEnabled,
2983 session_entry->is11Rconnection,
2984 deauth_req->reasonCode,
2985 deauth_req->deauthTrigger);
2986#endif
Deepak Dhamdhere262d95a2016-01-10 16:36:53 -08002987 }
2988 /* Free up buffer allocated for mlmDeauthReq */
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002989 qdf_mem_free(deauth_req);
2990 mac_ctx->lim.limDisassocDeauthCnfReq.pMlmDeauthReq = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002991 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302992 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002993end:
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002994 qdf_copy_macaddr(&deauth_cnf.peer_macaddr,
2995 &deauth_req->peer_macaddr);
2996 deauth_cnf.deauthTrigger = deauth_req->deauthTrigger;
2997 deauth_cnf.aid = deauth_req->aid;
2998 deauth_cnf.sessionId = deauth_req->sessionId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002999
3000 /* Free up buffer allocated */
3001 /* for mlmDeauthReq */
Liangwei Dongc0b2e332017-11-16 06:04:46 -05003002 qdf_mem_free(deauth_req);
3003 mac_ctx->lim.limDisassocDeauthCnfReq.pMlmDeauthReq = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003004
Liangwei Dongc0b2e332017-11-16 06:04:46 -05003005 lim_post_sme_message(mac_ctx,
3006 LIM_MLM_DEAUTH_CNF, (uint32_t *) &deauth_cnf);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303007 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003008}
3009
3010/**
3011 * lim_send_disassoc_cnf() - Send disassoc confirmation to SME
3012 *
3013 * @mac_ctx: Handle to MAC context
3014 *
3015 * Sends disassoc confirmation to SME. Removes disassoc request stored
3016 * in lim.
3017 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303018 * Return: QDF_STATUS_SUCCESS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003019 */
3020
Jeff Johnson9320c1e2018-12-02 13:09:20 -08003021QDF_STATUS lim_send_disassoc_cnf(struct mac_context *mac_ctx)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003022{
3023 uint16_t aid;
3024 tpDphHashNode sta_ds;
3025 tLimMlmDisassocCnf disassoc_cnf;
Jeff Johnsona7815652018-11-18 22:58:30 -08003026 struct pe_session *pe_session;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003027 tLimMlmDisassocReq *disassoc_req;
3028
3029 disassoc_req = mac_ctx->lim.limDisassocDeauthCnfReq.pMlmDisassocReq;
3030 if (disassoc_req) {
3031 if (tx_timer_running(
Pragaspathi Thilagaraj9f230382019-06-24 11:54:05 +05303032 &mac_ctx->lim.lim_timers.gLimDisassocAckTimer))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003033 lim_deactivate_and_change_timer(mac_ctx,
3034 eLIM_DISASSOC_ACK_TIMER);
3035
3036 pe_session = pe_find_session_by_session_id(
3037 mac_ctx, disassoc_req->sessionId);
Jeff Johnson8e9530b2019-03-18 13:41:42 -07003038 if (!pe_session) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003039 pe_err("No session for given sessionId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003040 disassoc_cnf.resultCode =
3041 eSIR_SME_INVALID_PARAMETERS;
3042 goto end;
3043 }
3044
3045 sta_ds = dph_lookup_hash_entry(mac_ctx,
Srinivas Girigowdadd3c5132016-01-05 19:41:27 -08003046 disassoc_req->peer_macaddr.bytes, &aid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003047 &pe_session->dph.dphHashTable);
Jeff Johnson8e9530b2019-03-18 13:41:42 -07003048 if (!sta_ds) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003049 pe_err("StaDs Null");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003050 disassoc_cnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
3051 goto end;
3052 }
3053 /* Receive path cleanup with dummy packet */
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003054 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003055 lim_cleanup_rx_path(mac_ctx, sta_ds, pe_session)) {
3056 disassoc_cnf.resultCode =
3057 eSIR_SME_RESOURCES_UNAVAILABLE;
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003058 pe_err("cleanup_rx_path error");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003059 goto end;
3060 }
Deepak Dhamdhere57c95ff2016-09-30 16:44:44 -07003061 if (LIM_IS_STA_ROLE(pe_session) &&
Liangwei Dongc0b2e332017-11-16 06:04:46 -05003062 (disassoc_req->reasonCode !=
3063 eSIR_MAC_DISASSOC_DUE_TO_FTHANDOFF_REASON)) {
Jeff Johnson11bd4f32017-09-18 08:15:17 -07003064 pe_debug("FT Preauth Session (%pK %d) Clean up",
Liangwei Dongc0b2e332017-11-16 06:04:46 -05003065 pe_session, pe_session->peSessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003066
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003067 /* Delete FT session if there exists one */
3068 lim_ft_cleanup_pre_auth_info(mac_ctx, pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003069 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003070 /* Free up buffer allocated for mlmDisassocReq */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303071 qdf_mem_free(disassoc_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003072 mac_ctx->lim.limDisassocDeauthCnfReq.pMlmDisassocReq = NULL;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303073 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003074 } else {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303075 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003076 }
3077end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303078 qdf_mem_copy((uint8_t *) &disassoc_cnf.peerMacAddr,
Srinivas Girigowdadd3c5132016-01-05 19:41:27 -08003079 (uint8_t *) disassoc_req->peer_macaddr.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05303080 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003081 disassoc_cnf.aid = disassoc_req->aid;
3082 disassoc_cnf.disassocTrigger = disassoc_req->disassocTrigger;
3083
3084 /* Update PE session ID */
3085 disassoc_cnf.sessionId = disassoc_req->sessionId;
3086
Jeff Johnson8e9530b2019-03-18 13:41:42 -07003087 if (disassoc_req) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003088 /* / Free up buffer allocated for mlmDisassocReq */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303089 qdf_mem_free(disassoc_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003090 mac_ctx->lim.limDisassocDeauthCnfReq.pMlmDisassocReq = NULL;
3091 }
3092
3093 lim_post_sme_message(mac_ctx, LIM_MLM_DISASSOC_CNF,
3094 (uint32_t *) &disassoc_cnf);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303095 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003096}
3097
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05303098QDF_STATUS lim_disassoc_tx_complete_cnf(void *context,
Liangwei Dongc0b2e332017-11-16 06:04:46 -05003099 uint32_t tx_success,
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05303100 void *params)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003101{
Jeff Johnson9320c1e2018-12-02 13:09:20 -08003102 struct mac_context *max_ctx = (struct mac_context *)context;
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05303103
Liangwei Dongc0b2e332017-11-16 06:04:46 -05003104 pe_debug("tx_success: %d", tx_success);
3105
3106 return lim_send_disassoc_cnf(max_ctx);
3107}
3108
3109static QDF_STATUS lim_disassoc_tx_complete_cnf_handler(void *context,
3110 qdf_nbuf_t buf,
3111 uint32_t tx_success,
3112 void *params)
3113{
Jeff Johnson9320c1e2018-12-02 13:09:20 -08003114 struct mac_context *max_ctx = (struct mac_context *)context;
Liangwei Dongc0b2e332017-11-16 06:04:46 -05003115 QDF_STATUS status_code;
3116 struct scheduler_msg msg = {0};
3117
3118 pe_debug("tx_success: %d", tx_success);
Himanshu Agarwal8b472bc2017-01-20 20:49:41 +05303119
3120 if (buf)
3121 qdf_nbuf_free(buf);
Liangwei Dongc0b2e332017-11-16 06:04:46 -05003122 msg.type = (uint16_t) WMA_DISASSOC_TX_COMP;
3123 msg.bodyptr = params;
3124 msg.bodyval = tx_success;
Himanshu Agarwal8b472bc2017-01-20 20:49:41 +05303125
Liangwei Dongc0b2e332017-11-16 06:04:46 -05003126 status_code = lim_post_msg_high_priority(max_ctx, &msg);
3127 if (status_code != QDF_STATUS_SUCCESS)
3128 pe_err("posting message: %X to LIM failed, reason: %d",
3129 msg.type, status_code);
3130 return status_code;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003131}
3132
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05303133QDF_STATUS lim_deauth_tx_complete_cnf(void *context,
Liangwei Dongc0b2e332017-11-16 06:04:46 -05003134 uint32_t tx_success,
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05303135 void *params)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003136{
Jeff Johnson9320c1e2018-12-02 13:09:20 -08003137 struct mac_context *mac_ctx = (struct mac_context *)context;
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05303138
Liangwei Dongc0b2e332017-11-16 06:04:46 -05003139 pe_debug("tx_success: %d", tx_success);
3140
3141 return lim_send_deauth_cnf(mac_ctx);
3142}
3143
3144static QDF_STATUS lim_deauth_tx_complete_cnf_handler(void *context,
3145 qdf_nbuf_t buf,
3146 uint32_t tx_success,
3147 void *params)
3148{
Jeff Johnson9320c1e2018-12-02 13:09:20 -08003149 struct mac_context *mac_ctx = (struct mac_context *)context;
Liangwei Dongc0b2e332017-11-16 06:04:46 -05003150 QDF_STATUS status_code;
3151 struct scheduler_msg msg = {0};
3152
3153 pe_debug("tx_success: %d", tx_success);
Himanshu Agarwal8b472bc2017-01-20 20:49:41 +05303154
3155 if (buf)
3156 qdf_nbuf_free(buf);
Liangwei Dongc0b2e332017-11-16 06:04:46 -05003157 msg.type = (uint16_t) WMA_DEAUTH_TX_COMP;
3158 msg.bodyptr = params;
3159 msg.bodyval = tx_success;
Himanshu Agarwal8b472bc2017-01-20 20:49:41 +05303160
Liangwei Dongc0b2e332017-11-16 06:04:46 -05003161 status_code = lim_post_msg_high_priority(mac_ctx, &msg);
3162 if (status_code != QDF_STATUS_SUCCESS)
3163 pe_err("posting message: %X to LIM failed, reason: %d",
3164 msg.type, status_code);
3165 return status_code;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003166}
3167
3168/**
Srinivas Dasarie2ee0942019-06-29 14:34:50 +05303169 * lim_append_ies_to_frame() - Append IEs to the frame
3170 *
3171 * @frame: Pointer to the frame buffer that needs to be populated
3172 * @frame_len: Pointer for current frame length
3173 * @ie: pointer for disconnect IEs
3174 *
3175 * This function is called by lim_send_disassoc_mgmt_frame and
3176 * lim_send_deauth_mgmt_frame APIs as part of disconnection.
3177 * Append IEs and update frame length.
3178 *
3179 * Return: None
3180 */
3181static void
3182lim_append_ies_to_frame(uint8_t *frame, uint32_t *frame_len,
3183 struct wlan_ies *ie)
3184{
3185 if (!ie || !ie->len || !ie->data)
3186 return;
3187 qdf_mem_copy(frame, ie->data, ie->len);
3188 *frame_len += ie->len;
3189 pe_debug("Appended IEs len: %u", ie->len);
3190}
3191
3192/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003193 * \brief This function is called to send Disassociate frame.
3194 *
3195 *
Jeff Johnson99f25042018-11-21 22:49:06 -08003196 * \param mac Pointer to Global MAC structure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003197 *
3198 * \param nReason Indicates the reason that need to be sent in
3199 * Disassociation frame
3200 *
3201 * \param peerMacAddr MAC address of the STA to which Disassociation frame is
3202 * sent
3203 *
3204 *
3205 */
3206
3207void
Jeff Johnson9320c1e2018-12-02 13:09:20 -08003208lim_send_disassoc_mgmt_frame(struct mac_context *mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003209 uint16_t nReason,
3210 tSirMacAddr peer,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003211 struct pe_session *pe_session, bool waitForAck)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003212{
3213 tDot11fDisassociation frm;
3214 uint8_t *pFrame;
3215 tpSirMacMgmtHdr pMacHdr;
3216 uint32_t nBytes, nPayload, nStatus;
3217 void *pPacket;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303218 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003219 uint8_t txFlag = 0;
3220 uint32_t val = 0;
3221 uint8_t smeSessionId = 0;
Srinivas Dasarie2ee0942019-06-29 14:34:50 +05303222 struct wlan_ies *discon_ie;
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07003223
Jeff Johnson8e9530b2019-03-18 13:41:42 -07003224 if (!pe_session) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003225 return;
3226 }
3227
3228 /*
3229 * In case when cac timer is running for this SAP session then
3230 * avoid sending disassoc out. It is violation of dfs specification.
3231 */
Pragaspathi Thilagaraje64714a2019-05-23 00:46:25 +05303232 if (((pe_session->opmode == QDF_SAP_MODE) ||
3233 (pe_session->opmode == QDF_P2P_GO_MODE)) &&
Jeff Johnson99f25042018-11-21 22:49:06 -08003234 (true == mac->sap.SapDfsInfo.is_dfs_cac_timer_running)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303235 QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_INFO,
Pragaspathi Thilagaraje64714a2019-05-23 00:46:25 +05303236 FL("CAC timer is running, drop disassoc from going out"));
Abhishek Singh06522c52019-05-08 12:13:42 +05303237 if (waitForAck)
3238 lim_send_disassoc_cnf(mac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003239 return;
3240 }
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003241 smeSessionId = pe_session->smeSessionId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003242
hangtian127c9532019-01-12 13:29:07 +08003243 qdf_mem_zero((uint8_t *) &frm, sizeof(frm));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003244
3245 frm.Reason.code = nReason;
3246
Jeff Johnson99f25042018-11-21 22:49:06 -08003247 nStatus = dot11f_get_packed_disassociation_size(mac, &frm, &nPayload);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003248 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003249 pe_err("Failed to calculate the packed size for a Disassociation (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003250 nStatus);
3251 /* We'll fall back on the worst case scenario: */
3252 nPayload = sizeof(tDot11fDisassociation);
3253 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003254 pe_warn("There were warnings while calculating the packed size for a Disassociation (0x%08x)",
3255 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003256 }
3257
3258 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
3259
Srinivas Dasarie2ee0942019-06-29 14:34:50 +05303260 discon_ie = mlme_get_self_disconnect_ies(pe_session->vdev);
3261 if (discon_ie && discon_ie->len)
3262 nBytes += discon_ie->len;
3263
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303264 qdf_status = cds_packet_alloc((uint16_t) nBytes, (void **)&pFrame,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003265 (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303266 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003267 pe_err("Failed to allocate %d bytes for a Disassociation",
3268 nBytes);
Abhishek Singh06522c52019-05-08 12:13:42 +05303269 if (waitForAck)
3270 lim_send_disassoc_cnf(mac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003271 return;
3272 }
3273 /* Paranoia: */
hangtian127c9532019-01-12 13:29:07 +08003274 qdf_mem_zero(pFrame, nBytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003275
3276 /* Next, we fill out the buffer descriptor: */
Jeff Johnson99f25042018-11-21 22:49:06 -08003277 lim_populate_mac_header(mac, pFrame, SIR_MAC_MGMT_FRAME,
Pragaspathi Thilagaraj7fb14222019-06-17 23:26:58 +05303278 SIR_MAC_MGMT_DISASSOC, peer, pe_session->self_mac_addr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003279 pMacHdr = (tpSirMacMgmtHdr) pFrame;
3280
3281 /* Prepare the BSSID */
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003282 sir_copy_mac_addr(pMacHdr->bssId, pe_session->bssId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003283
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003284 lim_set_protected_bit(mac, pe_session, peer, pMacHdr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003285
Jeff Johnson99f25042018-11-21 22:49:06 -08003286 nStatus = dot11f_pack_disassociation(mac, &frm, pFrame +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003287 sizeof(tSirMacMgmtHdr),
3288 nPayload, &nPayload);
3289 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003290 pe_err("Failed to pack a Disassociation (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003291 nStatus);
3292 cds_packet_free((void *)pPacket);
Abhishek Singh06522c52019-05-08 12:13:42 +05303293 if (waitForAck)
3294 lim_send_disassoc_cnf(mac);
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003295 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003296 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003297 pe_warn("There were warnings while packing a Disassociation (0x%08x)",
3298 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003299 }
3300
Srinivas Dasarie2ee0942019-06-29 14:34:50 +05303301 /* Copy disconnect IEs to the end of the frame */
3302 lim_append_ies_to_frame(pFrame + sizeof(tSirMacMgmtHdr) + nPayload,
3303 &nPayload, discon_ie);
3304 mlme_free_self_disconnect_ies(pe_session->vdev);
3305
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003306 pe_debug("***Sessionid %d Sending Disassociation frame with "
Srinivas Girigowdacb7b8b82019-04-10 14:27:47 -07003307 "reason %u and waitForAck %d to " QDF_MAC_ADDR_STR " ,From "
3308 QDF_MAC_ADDR_STR, pe_session->peSessionId, nReason,
Srinivas Girigowda34fbba02019-04-08 12:07:44 -07003309 waitForAck, QDF_MAC_ADDR_ARRAY(pMacHdr->da),
Pragaspathi Thilagaraj7fb14222019-06-17 23:26:58 +05303310 QDF_MAC_ADDR_ARRAY(pe_session->self_mac_addr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003311
Liangwei Dong419d7302019-07-15 15:38:28 +08003312 if (wlan_reg_is_5ghz_ch_freq(pe_session->curr_op_freq) ||
3313 pe_session->opmode == QDF_P2P_CLIENT_MODE ||
3314 pe_session->opmode == QDF_P2P_GO_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003315 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003316
Sushant Kaushik46556062015-12-02 16:57:47 +05303317 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003318
3319 if (waitForAck) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303320 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003321 pe_session->peSessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003322 pMacHdr->fc.subType));
Jeff Johnson99f25042018-11-21 22:49:06 -08003323 lim_diag_mgmt_tx_event_report(mac, pMacHdr,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003324 pe_session, QDF_STATUS_SUCCESS,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003325 QDF_STATUS_SUCCESS);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003326 /* Queue Disassociation frame in high priority WQ */
3327 /* get the duration from the request */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303328 qdf_status =
Jeff Johnson99f25042018-11-21 22:49:06 -08003329 wma_tx_frameWithTxComplete(mac, pPacket, (uint16_t) nBytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003330 TXRX_FRM_802_11_MGMT,
3331 ANI_TXDIR_TODS, 7, lim_tx_complete,
Liangwei Dongc0b2e332017-11-16 06:04:46 -05003332 pFrame, lim_disassoc_tx_complete_cnf_handler,
Naveen Rawat296a5182017-09-25 14:02:48 -07003333 txFlag, smeSessionId, false, 0,
3334 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,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003337 pe_session->peSessionId, qdf_status));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003338
3339 val = SYS_MS_TO_TICKS(LIM_DISASSOC_DEAUTH_ACK_TIMEOUT);
3340
3341 if (tx_timer_change
Pragaspathi Thilagaraj9f230382019-06-24 11:54:05 +05303342 (&mac->lim.lim_timers.gLimDisassocAckTimer, val, 0)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003343 != TX_SUCCESS) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003344 pe_err("Unable to change Disassoc ack Timer val");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003345 return;
3346 } else if (TX_SUCCESS !=
Pragaspathi Thilagaraj9f230382019-06-24 11:54:05 +05303347 tx_timer_activate(&mac->lim.lim_timers.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003348 gLimDisassocAckTimer)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003349 pe_err("Unable to activate Disassoc ack Timer");
Jeff Johnson99f25042018-11-21 22:49:06 -08003350 lim_deactivate_and_change_timer(mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003351 eLIM_DISASSOC_ACK_TIMER);
3352 return;
3353 }
3354 } else {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303355 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003356 pe_session->peSessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003357 pMacHdr->fc.subType));
Jeff Johnson99f25042018-11-21 22:49:06 -08003358 lim_diag_mgmt_tx_event_report(mac, pMacHdr,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003359 pe_session,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003360 QDF_STATUS_SUCCESS, QDF_STATUS_SUCCESS);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003361 /* Queue Disassociation frame in high priority WQ */
Jeff Johnson99f25042018-11-21 22:49:06 -08003362 qdf_status = wma_tx_frame(mac, pPacket, (uint16_t) nBytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003363 TXRX_FRM_802_11_MGMT,
3364 ANI_TXDIR_TODS,
3365 7,
3366 lim_tx_complete, pFrame, txFlag,
Naveen Rawat296a5182017-09-25 14:02:48 -07003367 smeSessionId, 0, RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303368 MTRACE(qdf_trace
Anurag Chouhan6d760662016-02-20 16:05:43 +05303369 (QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003370 pe_session->peSessionId, qdf_status));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303371 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003372 pe_err("Failed to send Disassociation (%X)!",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303373 qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003374 /* Pkt will be freed up by the callback */
3375 }
3376 }
3377} /* End lim_send_disassoc_mgmt_frame. */
3378
3379/**
3380 * \brief This function is called to send a Deauthenticate frame
3381 *
3382 *
Jeff Johnson99f25042018-11-21 22:49:06 -08003383 * \param mac Pointer to global MAC structure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003384 *
3385 * \param nReason Indicates the reason that need to be sent in the
3386 * Deauthenticate frame
3387 *
3388 * \param peeer address of the STA to which the frame is to be sent
3389 *
3390 *
3391 */
3392
3393void
Jeff Johnson9320c1e2018-12-02 13:09:20 -08003394lim_send_deauth_mgmt_frame(struct mac_context *mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003395 uint16_t nReason,
3396 tSirMacAddr peer,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003397 struct pe_session *pe_session, bool waitForAck)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003398{
3399 tDot11fDeAuth frm;
3400 uint8_t *pFrame;
3401 tpSirMacMgmtHdr pMacHdr;
3402 uint32_t nBytes, nPayload, nStatus;
3403 void *pPacket;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303404 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003405 uint8_t txFlag = 0;
3406 uint32_t val = 0;
3407#ifdef FEATURE_WLAN_TDLS
3408 uint16_t aid;
Jeff Johnsonbddc03e2019-01-17 15:37:09 -08003409 tpDphHashNode sta;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003410#endif
3411 uint8_t smeSessionId = 0;
Srinivas Dasarie2ee0942019-06-29 14:34:50 +05303412 struct wlan_ies *discon_ie;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003413
Jeff Johnson8e9530b2019-03-18 13:41:42 -07003414 if (!pe_session) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003415 return;
3416 }
3417
3418 /*
3419 * In case when cac timer is running for this SAP session then
3420 * avoid deauth frame out. It is violation of dfs specification.
3421 */
Pragaspathi Thilagaraje64714a2019-05-23 00:46:25 +05303422 if (((pe_session->opmode == QDF_SAP_MODE) ||
3423 (pe_session->opmode == QDF_P2P_GO_MODE)) &&
Jeff Johnson99f25042018-11-21 22:49:06 -08003424 (true == mac->sap.SapDfsInfo.is_dfs_cac_timer_running)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303425 QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_INFO,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003426 FL
3427 ("CAC timer is running, drop the deauth from going out"));
Abhishek Singh06522c52019-05-08 12:13:42 +05303428 if (waitForAck)
3429 lim_send_deauth_cnf(mac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003430 return;
3431 }
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003432 smeSessionId = pe_session->smeSessionId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003433
hangtian127c9532019-01-12 13:29:07 +08003434 qdf_mem_zero((uint8_t *) &frm, sizeof(frm));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003435
3436 frm.Reason.code = nReason;
3437
Jeff Johnson99f25042018-11-21 22:49:06 -08003438 nStatus = dot11f_get_packed_de_auth_size(mac, &frm, &nPayload);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003439 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003440 pe_err("Failed to calculate the packed size for a De-Authentication (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003441 nStatus);
3442 /* We'll fall back on the worst case scenario: */
3443 nPayload = sizeof(tDot11fDeAuth);
3444 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003445 pe_warn("There were warnings while calculating the packed size for a De-Authentication (0x%08x)",
3446 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003447 }
3448
3449 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
Srinivas Dasarie2ee0942019-06-29 14:34:50 +05303450 discon_ie = mlme_get_self_disconnect_ies(pe_session->vdev);
3451 if (discon_ie && discon_ie->len)
3452 nBytes += discon_ie->len;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003453
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303454 qdf_status = cds_packet_alloc((uint16_t) nBytes, (void **)&pFrame,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003455 (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303456 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003457 pe_err("Failed to allocate %d bytes for a De-Authentication",
3458 nBytes);
Abhishek Singh06522c52019-05-08 12:13:42 +05303459 if (waitForAck)
3460 lim_send_deauth_cnf(mac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003461 return;
3462 }
3463 /* Paranoia: */
hangtian127c9532019-01-12 13:29:07 +08003464 qdf_mem_zero(pFrame, nBytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003465
3466 /* Next, we fill out the buffer descriptor: */
Jeff Johnson99f25042018-11-21 22:49:06 -08003467 lim_populate_mac_header(mac, pFrame, SIR_MAC_MGMT_FRAME,
Pragaspathi Thilagaraj7fb14222019-06-17 23:26:58 +05303468 SIR_MAC_MGMT_DEAUTH, peer, pe_session->self_mac_addr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003469 pMacHdr = (tpSirMacMgmtHdr) pFrame;
3470
3471 /* Prepare the BSSID */
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003472 sir_copy_mac_addr(pMacHdr->bssId, pe_session->bssId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003473
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003474 lim_set_protected_bit(mac, pe_session, peer, pMacHdr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003475
Jeff Johnson99f25042018-11-21 22:49:06 -08003476 nStatus = dot11f_pack_de_auth(mac, &frm, pFrame +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003477 sizeof(tSirMacMgmtHdr), nPayload, &nPayload);
3478 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003479 pe_err("Failed to pack a DeAuthentication (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003480 nStatus);
3481 cds_packet_free((void *)pPacket);
Abhishek Singh06522c52019-05-08 12:13:42 +05303482 if (waitForAck)
3483 lim_send_deauth_cnf(mac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003484 return;
3485 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003486 pe_warn("There were warnings while packing a De-Authentication (0x%08x)",
3487 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003488 }
Srinivas Dasarie2ee0942019-06-29 14:34:50 +05303489
3490 /* Copy disconnect IEs to the end of the frame */
3491 lim_append_ies_to_frame(pFrame + sizeof(tSirMacMgmtHdr) + nPayload,
3492 &nPayload, discon_ie);
3493 mlme_free_self_disconnect_ies(pe_session->vdev);
3494
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003495 pe_debug("***Sessionid %d Sending Deauth frame with "
Srinivas Girigowdacb7b8b82019-04-10 14:27:47 -07003496 "reason %u and waitForAck %d to " QDF_MAC_ADDR_STR
3497 " ,From " QDF_MAC_ADDR_STR,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003498 pe_session->peSessionId, nReason, waitForAck,
Srinivas Girigowda34fbba02019-04-08 12:07:44 -07003499 QDF_MAC_ADDR_ARRAY(pMacHdr->da),
Pragaspathi Thilagaraj7fb14222019-06-17 23:26:58 +05303500 QDF_MAC_ADDR_ARRAY(pe_session->self_mac_addr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003501
Liangwei Dong419d7302019-07-15 15:38:28 +08003502 if (wlan_reg_is_5ghz_ch_freq(pe_session->curr_op_freq) ||
3503 pe_session->opmode == QDF_P2P_CLIENT_MODE ||
3504 pe_session->opmode == QDF_P2P_GO_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003505 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003506
Sushant Kaushik46556062015-12-02 16:57:47 +05303507 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003508#ifdef FEATURE_WLAN_TDLS
Jeff Johnsonbddc03e2019-01-17 15:37:09 -08003509 sta =
Jeff Johnson99f25042018-11-21 22:49:06 -08003510 dph_lookup_hash_entry(mac, peer, &aid,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003511 &pe_session->dph.dphHashTable);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003512#endif
3513
3514 if (waitForAck) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303515 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003516 pe_session->peSessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003517 pMacHdr->fc.subType));
Jeff Johnson99f25042018-11-21 22:49:06 -08003518 lim_diag_mgmt_tx_event_report(mac, pMacHdr,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003519 pe_session,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003520 QDF_STATUS_SUCCESS, QDF_STATUS_SUCCESS);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003521 /* Queue Disassociation frame in high priority WQ */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303522 qdf_status =
Jeff Johnson99f25042018-11-21 22:49:06 -08003523 wma_tx_frameWithTxComplete(mac, pPacket, (uint16_t) nBytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003524 TXRX_FRM_802_11_MGMT,
3525 ANI_TXDIR_TODS, 7, lim_tx_complete,
Liangwei Dongc0b2e332017-11-16 06:04:46 -05003526 pFrame, lim_deauth_tx_complete_cnf_handler,
Naveen Rawat296a5182017-09-25 14:02:48 -07003527 txFlag, smeSessionId, false, 0,
3528 RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303529 MTRACE(qdf_trace
Anurag Chouhan6d760662016-02-20 16:05:43 +05303530 (QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003531 pe_session->peSessionId, qdf_status));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003532 /* Pkt will be freed up by the callback lim_tx_complete */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303533 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003534 pe_err("Failed to send De-Authentication (%X)!",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303535 qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003536
3537 /* Call lim_process_deauth_ack_timeout which will send
3538 * DeauthCnf for this frame
3539 */
Jeff Johnson99f25042018-11-21 22:49:06 -08003540 lim_process_deauth_ack_timeout(mac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003541 return;
3542 }
3543
3544 val = SYS_MS_TO_TICKS(LIM_DISASSOC_DEAUTH_ACK_TIMEOUT);
3545
3546 if (tx_timer_change
Pragaspathi Thilagaraj9f230382019-06-24 11:54:05 +05303547 (&mac->lim.lim_timers.gLimDeauthAckTimer, val, 0)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003548 != TX_SUCCESS) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003549 pe_err("Unable to change Deauth ack Timer val");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003550 return;
3551 } else if (TX_SUCCESS !=
Pragaspathi Thilagaraj9f230382019-06-24 11:54:05 +05303552 tx_timer_activate(&mac->lim.lim_timers.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003553 gLimDeauthAckTimer)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003554 pe_err("Unable to activate Deauth ack Timer");
Jeff Johnson99f25042018-11-21 22:49:06 -08003555 lim_deactivate_and_change_timer(mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003556 eLIM_DEAUTH_ACK_TIMER);
3557 return;
3558 }
3559 } else {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303560 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003561 pe_session->peSessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003562 pMacHdr->fc.subType));
3563#ifdef FEATURE_WLAN_TDLS
Jeff Johnson8e9530b2019-03-18 13:41:42 -07003564 if ((sta)
Jeff Johnsonbddc03e2019-01-17 15:37:09 -08003565 && (STA_ENTRY_TDLS_PEER == sta->staType)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003566 /* Queue Disassociation frame in high priority WQ */
Jeff Johnson99f25042018-11-21 22:49:06 -08003567 lim_diag_mgmt_tx_event_report(mac, pMacHdr,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003568 pe_session,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003569 QDF_STATUS_SUCCESS,
3570 QDF_STATUS_SUCCESS);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303571 qdf_status =
Jeff Johnson99f25042018-11-21 22:49:06 -08003572 wma_tx_frame(mac, pPacket, (uint16_t) nBytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003573 TXRX_FRM_802_11_MGMT, ANI_TXDIR_IBSS,
3574 7, lim_tx_complete, pFrame, txFlag,
Naveen Rawat296a5182017-09-25 14:02:48 -07003575 smeSessionId, 0, RATEID_DEFAULT);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003576 } else {
3577#endif
Jeff Johnson99f25042018-11-21 22:49:06 -08003578 lim_diag_mgmt_tx_event_report(mac, pMacHdr,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003579 pe_session,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003580 QDF_STATUS_SUCCESS,
3581 QDF_STATUS_SUCCESS);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003582 /* Queue Disassociation frame in high priority WQ */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303583 qdf_status =
Jeff Johnson99f25042018-11-21 22:49:06 -08003584 wma_tx_frame(mac, pPacket, (uint16_t) nBytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003585 TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS,
3586 7, lim_tx_complete, pFrame, txFlag,
Naveen Rawat296a5182017-09-25 14:02:48 -07003587 smeSessionId, 0, RATEID_DEFAULT);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003588#ifdef FEATURE_WLAN_TDLS
3589 }
3590#endif
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303591 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003592 pe_session->peSessionId, qdf_status));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303593 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003594 pe_err("Failed to send De-Authentication (%X)!",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303595 qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003596 /* Pkt will be freed up by the callback */
3597 }
3598 }
3599
3600} /* End lim_send_deauth_mgmt_frame. */
3601
3602#ifdef ANI_SUPPORT_11H
3603/**
3604 * \brief Send a Measurement Report Action frame
3605 *
3606 *
Jeff Johnson99f25042018-11-21 22:49:06 -08003607 * \param mac Pointer to the global MAC structure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003608 *
3609 * \param pMeasReqFrame Address of a tSirMacMeasReqActionFrame
3610 *
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003611 * \return QDF_STATUS_SUCCESS on success, QDF_STATUS_E_FAILURE else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003612 *
3613 *
3614 */
3615
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003616QDF_STATUS
Jeff Johnson9320c1e2018-12-02 13:09:20 -08003617lim_send_meas_report_frame(struct mac_context *mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003618 tpSirMacMeasReqActionFrame pMeasReqFrame,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003619 tSirMacAddr peer, struct pe_session *pe_session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003620{
3621 tDot11fMeasurementReport frm;
3622 uint8_t *pFrame;
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003623 QDF_STATUS nSirStatus;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003624 tpSirMacMgmtHdr pMacHdr;
3625 uint32_t nBytes, nPayload, nStatus;
3626 void *pPacket;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303627 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003628
hangtian127c9532019-01-12 13:29:07 +08003629 qdf_mem_zero((uint8_t *) &frm, sizeof(frm));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003630
Srinivas Girigowda48bec1c2019-05-17 16:33:30 -07003631 frm.Category.category = ACTION_CATEGORY_SPECTRUM_MGMT;
Srinivas Girigowdaf8e5d2e2019-05-28 11:49:29 -07003632 frm.Action.action = ACTION_SPCT_MSR_RPRT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003633 frm.DialogToken.token = pMeasReqFrame->actionHeader.dialogToken;
3634
3635 switch (pMeasReqFrame->measReqIE.measType) {
3636 case SIR_MAC_BASIC_MEASUREMENT_TYPE:
3637 nSirStatus =
Jeff Johnson99f25042018-11-21 22:49:06 -08003638 populate_dot11f_measurement_report0(mac, pMeasReqFrame,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003639 &frm.MeasurementReport);
3640 break;
3641 case SIR_MAC_CCA_MEASUREMENT_TYPE:
3642 nSirStatus =
Jeff Johnson99f25042018-11-21 22:49:06 -08003643 populate_dot11f_measurement_report1(mac, pMeasReqFrame,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003644 &frm.MeasurementReport);
3645 break;
3646 case SIR_MAC_RPI_MEASUREMENT_TYPE:
3647 nSirStatus =
Jeff Johnson99f25042018-11-21 22:49:06 -08003648 populate_dot11f_measurement_report2(mac, pMeasReqFrame,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003649 &frm.MeasurementReport);
3650 break;
3651 default:
Jeff Johnson0711e272018-12-14 23:16:38 -08003652 pe_err("Unknown measurement type %d in limSendMeasReportFrame",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003653 pMeasReqFrame->measReqIE.measType);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003654 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003655 }
3656
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003657 if (QDF_STATUS_SUCCESS != nSirStatus)
3658 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003659
Jeff Johnson99f25042018-11-21 22:49:06 -08003660 nStatus = dot11f_get_packed_measurement_report_size(mac, &frm, &nPayload);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003661 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003662 pe_err("Failed to calculate the packed size for a Measurement Report (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003663 nStatus);
3664 /* We'll fall back on the worst case scenario: */
3665 nPayload = sizeof(tDot11fMeasurementReport);
3666 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003667 pe_warn("There were warnings while calculating the packed size for a Measurement Report (0x%08x)",
3668 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003669 }
3670
3671 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
3672
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303673 qdf_status =
Jeff Johnson99f25042018-11-21 22:49:06 -08003674 cds_packet_alloc(mac->hdd_handle, TXRX_FRM_802_11_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003675 (uint16_t) nBytes, (void **)&pFrame,
3676 (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303677 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Jeff Johnson0711e272018-12-14 23:16:38 -08003678 pe_err("Failed to allocate %d bytes for a De-Authentication",
3679 nBytes);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003680 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003681 }
3682 /* Paranoia: */
hangtian127c9532019-01-12 13:29:07 +08003683 qdf_mem_zero(pFrame, nBytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003684
3685 /* Next, we fill out the buffer descriptor: */
Jeff Johnson99f25042018-11-21 22:49:06 -08003686 lim_populate_mac_header(mac, pFrame, SIR_MAC_MGMT_FRAME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003687 SIR_MAC_MGMT_ACTION, peer);
3688 pMacHdr = (tpSirMacMgmtHdr) pFrame;
3689
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003690 qdf_mem_copy(pMacHdr->bssId, pe_session->bssId, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003691
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003692 lim_set_protected_bit(mac, pe_session, peer, pMacHdr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003693
Jeff Johnson99f25042018-11-21 22:49:06 -08003694 nStatus = dot11f_pack_measurement_report(mac, &frm, pFrame +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003695 sizeof(tSirMacMgmtHdr),
3696 nPayload, &nPayload);
3697 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003698 pe_err("Failed to pack a Measurement Report (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003699 nStatus);
Jeff Johnson99f25042018-11-21 22:49:06 -08003700 cds_packet_free(mac->hdd_handle, TXRX_FRM_802_11_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003701 (void *)pFrame, (void *)pPacket);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003702 return QDF_STATUS_E_FAILURE; /* allocated! */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003703 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003704 pe_warn("There were warnings while packing a Measurement Report (0x%08x)",
3705 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003706 }
3707
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303708 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003709 ((pe_session) ? pe_session->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003710 peSessionId : NO_SESSION), pMacHdr->fc.subType));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303711 qdf_status =
Jeff Johnson99f25042018-11-21 22:49:06 -08003712 wma_tx_frame(mac, pPacket, (uint16_t) nBytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003713 TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS, 7,
Naveen Rawat296a5182017-09-25 14:02:48 -07003714 lim_tx_complete, pFrame, 0, 0, RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303715 MTRACE(qdf_trace
Anurag Chouhan6d760662016-02-20 16:05:43 +05303716 (QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003717 ((pe_session) ? pe_session->peSessionId : NO_SESSION),
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303718 qdf_status));
3719 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003720 pe_err("Failed to send a Measurement Report (%X)!",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303721 qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003722 /* Pkt will be freed up by the callback */
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003723 return QDF_STATUS_E_FAILURE; /* just allocated... */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003724 }
3725
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003726 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003727
3728} /* End lim_send_meas_report_frame. */
3729
3730/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003731 * \brief Send a TPC Report Action frame
3732 *
3733 *
Jeff Johnson99f25042018-11-21 22:49:06 -08003734 * \param mac Pointer to the global MAC datastructure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003735 *
3736 * \param pTpcReqFrame Pointer to the received TPC Request
3737 *
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003738 * \return QDF_STATUS_SUCCESS on success, QDF_STATUS_E_FAILURE else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003739 *
3740 *
3741 */
3742
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003743QDF_STATUS
Jeff Johnson9320c1e2018-12-02 13:09:20 -08003744lim_send_tpc_report_frame(struct mac_context *mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003745 tpSirMacTpcReqActionFrame pTpcReqFrame,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003746 tSirMacAddr peer, struct pe_session *pe_session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003747{
3748 tDot11fTPCReport frm;
3749 uint8_t *pFrame;
3750 tpSirMacMgmtHdr pMacHdr;
3751 uint32_t nBytes, nPayload, nStatus;
3752 void *pPacket;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303753 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003754
hangtian127c9532019-01-12 13:29:07 +08003755 qdf_mem_zero((uint8_t *) &frm, sizeof(frm));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003756
Srinivas Girigowda48bec1c2019-05-17 16:33:30 -07003757 frm.Category.category = ACTION_CATEGORY_SPECTRUM_MGMT;
Srinivas Girigowdaf8e5d2e2019-05-28 11:49:29 -07003758 frm.Action.action = ACTION_SPCT_TPC_RPRT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003759 frm.DialogToken.token = pTpcReqFrame->actionHeader.dialogToken;
3760
3761 frm.TPCReport.tx_power = 0;
3762 frm.TPCReport.link_margin = 0;
3763 frm.TPCReport.present = 1;
3764
Jeff Johnson99f25042018-11-21 22:49:06 -08003765 nStatus = dot11f_get_packed_tpc_report_size(mac, &frm, &nPayload);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003766 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003767 pe_err("Failed to calculate the packed size for a TPC Report (0x%08x)", nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003768 /* We'll fall back on the worst case scenario: */
3769 nPayload = sizeof(tDot11fTPCReport);
3770 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003771 pe_warn("There were warnings while calculating the packed size for a TPC Report (0x%08x)",
3772 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003773 }
3774
3775 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
3776
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303777 qdf_status =
Jeff Johnson99f25042018-11-21 22:49:06 -08003778 cds_packet_alloc(mac->hdd_handle, TXRX_FRM_802_11_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003779 (uint16_t) nBytes, (void **)&pFrame,
3780 (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303781 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003782 pe_err("Failed to allocate %d bytes for a TPC"
3783 " Report", nBytes);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003784 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003785 }
3786 /* Paranoia: */
hangtian127c9532019-01-12 13:29:07 +08003787 qdf_mem_zero(pFrame, nBytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003788
3789 /* Next, we fill out the buffer descriptor: */
Jeff Johnson99f25042018-11-21 22:49:06 -08003790 lim_populate_mac_header(mac, pFrame, SIR_MAC_MGMT_FRAME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003791 SIR_MAC_MGMT_ACTION, peer);
3792
3793 pMacHdr = (tpSirMacMgmtHdr) pFrame;
3794
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003795 qdf_mem_copy(pMacHdr->bssId, pe_session->bssId, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003796
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003797 lim_set_protected_bit(mac, pe_session, peer, pMacHdr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003798
Jeff Johnson99f25042018-11-21 22:49:06 -08003799 nStatus = dot11f_pack_tpc_report(mac, &frm, pFrame +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003800 sizeof(tSirMacMgmtHdr),
3801 nPayload, &nPayload);
3802 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003803 pe_err("Failed to pack a TPC Report (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003804 nStatus);
Jeff Johnson99f25042018-11-21 22:49:06 -08003805 cds_packet_free(mac->hdd_handle, TXRX_FRM_802_11_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003806 (void *)pFrame, (void *)pPacket);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003807 return QDF_STATUS_E_FAILURE; /* allocated! */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003808 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003809 pe_warn("There were warnings while packing a TPC Report (0x%08x)",
3810 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003811
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303812 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003813 ((pe_session) ? pe_session->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003814 peSessionId : NO_SESSION), pMacHdr->fc.subType));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303815 qdf_status =
Jeff Johnson99f25042018-11-21 22:49:06 -08003816 wma_tx_frame(mac, pPacket, (uint16_t) nBytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003817 TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS, 7,
Naveen Rawat296a5182017-09-25 14:02:48 -07003818 lim_tx_complete, pFrame, 0, 0, RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303819 MTRACE(qdf_trace
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003820 (QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003821 ((pe_session) ? pe_session->peSessionId : NO_SESSION),
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003822 qdf_status));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303823 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003824 pe_err("Failed to send a TPC Report (%X)!",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303825 qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003826 /* Pkt will be freed up by the callback */
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003827 return QDF_STATUS_E_FAILURE; /* just allocated... */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003828 }
3829
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003830 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003831
3832} /* End lim_send_tpc_report_frame. */
3833#endif /* ANI_SUPPORT_11H */
3834
3835/**
3836 * \brief Send a Channel Switch Announcement
3837 *
3838 *
Jeff Johnson99f25042018-11-21 22:49:06 -08003839 * \param mac Pointer to the global MAC datastructure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003840 *
3841 * \param peer MAC address to which this frame will be sent
3842 *
3843 * \param nMode
3844 *
3845 * \param nNewChannel
3846 *
3847 * \param nCount
3848 *
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003849 * \return QDF_STATUS_SUCCESS on success, QDF_STATUS_E_FAILURE else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003850 *
3851 *
3852 */
3853
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003854QDF_STATUS
Jeff Johnson9320c1e2018-12-02 13:09:20 -08003855lim_send_channel_switch_mgmt_frame(struct mac_context *mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003856 tSirMacAddr peer,
3857 uint8_t nMode,
3858 uint8_t nNewChannel,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003859 uint8_t nCount, struct pe_session *pe_session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003860{
3861 tDot11fChannelSwitch frm;
3862 uint8_t *pFrame;
3863 tpSirMacMgmtHdr pMacHdr;
3864 uint32_t nBytes, nPayload, nStatus; /* , nCfg; */
3865 void *pPacket;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303866 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003867 uint8_t txFlag = 0;
3868
3869 uint8_t smeSessionId = 0;
3870
Jeff Johnson8e9530b2019-03-18 13:41:42 -07003871 if (!pe_session) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003872 pe_err("Session entry is NULL!!!");
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003873 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003874 }
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003875 smeSessionId = pe_session->smeSessionId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003876
hangtian127c9532019-01-12 13:29:07 +08003877 qdf_mem_zero((uint8_t *) &frm, sizeof(frm));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003878
Srinivas Girigowda48bec1c2019-05-17 16:33:30 -07003879 frm.Category.category = ACTION_CATEGORY_SPECTRUM_MGMT;
Srinivas Girigowdaf8e5d2e2019-05-28 11:49:29 -07003880 frm.Action.action = ACTION_SPCT_CHL_SWITCH;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003881 frm.ChanSwitchAnn.switchMode = nMode;
3882 frm.ChanSwitchAnn.newChannel = nNewChannel;
3883 frm.ChanSwitchAnn.switchCount = nCount;
3884 frm.ChanSwitchAnn.present = 1;
3885
Jeff Johnson99f25042018-11-21 22:49:06 -08003886 nStatus = dot11f_get_packed_channel_switch_size(mac, &frm, &nPayload);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003887 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003888 pe_err("Failed to calculate the packed size for a Channel Switch (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003889 nStatus);
3890 /* We'll fall back on the worst case scenario: */
3891 nPayload = sizeof(tDot11fChannelSwitch);
3892 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003893 pe_warn("There were warnings while calculating the packed size for a Channel Switch (0x%08x)",
3894 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003895 }
3896
3897 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
3898
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303899 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003900 cds_packet_alloc((uint16_t) nBytes, (void **)&pFrame,
3901 (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303902 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003903 pe_err("Failed to allocate %d bytes for a TPC Report", nBytes);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003904 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003905 }
3906 /* Paranoia: */
hangtian127c9532019-01-12 13:29:07 +08003907 qdf_mem_zero(pFrame, nBytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003908
3909 /* Next, we fill out the buffer descriptor: */
Jeff Johnson99f25042018-11-21 22:49:06 -08003910 lim_populate_mac_header(mac, pFrame, SIR_MAC_MGMT_FRAME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003911 SIR_MAC_MGMT_ACTION, peer,
Pragaspathi Thilagaraj7fb14222019-06-17 23:26:58 +05303912 pe_session->self_mac_addr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003913 pMacHdr = (tpSirMacMgmtHdr) pFrame;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303914 qdf_mem_copy((uint8_t *) pMacHdr->bssId,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003915 (uint8_t *) pe_session->bssId, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003916
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003917 lim_set_protected_bit(mac, pe_session, peer, pMacHdr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003918
Jeff Johnson99f25042018-11-21 22:49:06 -08003919 nStatus = dot11f_pack_channel_switch(mac, &frm, pFrame +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003920 sizeof(tSirMacMgmtHdr),
3921 nPayload, &nPayload);
3922 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003923 pe_err("Failed to pack a Channel Switch (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003924 nStatus);
3925 cds_packet_free((void *)pPacket);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003926 return QDF_STATUS_E_FAILURE; /* allocated! */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003927 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003928 pe_warn("There were warnings while packing a Channel Switch (0x%08x)",
3929 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003930 }
3931
Liangwei Dong419d7302019-07-15 15:38:28 +08003932 if (wlan_reg_is_5ghz_ch_freq(pe_session->curr_op_freq) ||
3933 pe_session->opmode == QDF_P2P_CLIENT_MODE ||
3934 pe_session->opmode == QDF_P2P_GO_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003935 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003936
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303937 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003938 pe_session->peSessionId, pMacHdr->fc.subType));
Jeff Johnson99f25042018-11-21 22:49:06 -08003939 qdf_status = wma_tx_frame(mac, pPacket, (uint16_t) nBytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003940 TXRX_FRM_802_11_MGMT,
3941 ANI_TXDIR_TODS,
3942 7, lim_tx_complete, pFrame, txFlag,
Naveen Rawat296a5182017-09-25 14:02:48 -07003943 smeSessionId, 0, RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303944 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003945 pe_session->peSessionId, qdf_status));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303946 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003947 pe_err("Failed to send a Channel Switch (%X)!",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303948 qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003949 /* Pkt will be freed up by the callback */
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003950 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003951 }
3952
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003953 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003954
3955} /* End lim_send_channel_switch_mgmt_frame. */
3956
Abhishek Singh518323d2015-10-19 17:42:01 +05303957/**
3958 * lim_send_extended_chan_switch_action_frame()- function to send ECSA
3959 * action frame over the air .
3960 * @mac_ctx: pointer to global mac structure
3961 * @peer: Destination mac.
3962 * @mode: channel switch mode
3963 * @new_op_class: new op class
3964 * @new_channel: new channel to switch
3965 * @count: channel switch count
3966 *
3967 * This function is called to send ECSA frame.
3968 *
3969 * Return: success if frame is sent else return failure
3970 */
3971
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003972QDF_STATUS
Jeff Johnson9320c1e2018-12-02 13:09:20 -08003973lim_send_extended_chan_switch_action_frame(struct mac_context *mac_ctx,
Abhishek Singh518323d2015-10-19 17:42:01 +05303974 tSirMacAddr peer, uint8_t mode, uint8_t new_op_class,
Jeff Johnsona7815652018-11-18 22:58:30 -08003975 uint8_t new_channel, uint8_t count, struct pe_session *session_entry)
Abhishek Singh518323d2015-10-19 17:42:01 +05303976{
3977 tDot11fext_channel_switch_action_frame frm;
3978 uint8_t *frame;
3979 tpSirMacMgmtHdr mac_hdr;
3980 uint32_t num_bytes, n_payload, status;
3981 void *packet;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303982 QDF_STATUS qdf_status;
Abhishek Singh518323d2015-10-19 17:42:01 +05303983 uint8_t txFlag = 0;
Abhishek Singh345be412019-11-19 10:59:29 +05303984 uint8_t vdev_id = 0;
Vignesh Viswanathan93b7f702017-12-19 17:48:45 +05303985 uint8_t ch_spacing;
3986 tLimWiderBWChannelSwitchInfo *wide_bw_ie;
Abhishek Singh518323d2015-10-19 17:42:01 +05303987
Jeff Johnson8e9530b2019-03-18 13:41:42 -07003988 if (!session_entry) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003989 pe_err("Session entry is NULL!!!");
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003990 return QDF_STATUS_E_FAILURE;
Abhishek Singh518323d2015-10-19 17:42:01 +05303991 }
3992
Abhishek Singh345be412019-11-19 10:59:29 +05303993 vdev_id = session_entry->smeSessionId;
Abhishek Singh518323d2015-10-19 17:42:01 +05303994
hangtian127c9532019-01-12 13:29:07 +08003995 qdf_mem_zero(&frm, sizeof(frm));
Abhishek Singh518323d2015-10-19 17:42:01 +05303996
Srinivas Girigowda48bec1c2019-05-17 16:33:30 -07003997 frm.Category.category = ACTION_CATEGORY_PUBLIC;
Abhishek Singh518323d2015-10-19 17:42:01 +05303998 frm.Action.action = SIR_MAC_ACTION_EXT_CHANNEL_SWITCH_ID;
3999
4000 frm.ext_chan_switch_ann_action.switch_mode = mode;
4001 frm.ext_chan_switch_ann_action.op_class = new_op_class;
4002 frm.ext_chan_switch_ann_action.new_channel = new_channel;
4003 frm.ext_chan_switch_ann_action.switch_count = count;
4004
Vignesh Viswanathan93b7f702017-12-19 17:48:45 +05304005 ch_spacing = wlan_reg_dmn_get_chanwidth_from_opclass(
4006 mac_ctx->scan.countryCodeCurrent, new_channel,
4007 new_op_class);
4008 pe_debug("wrapper: ch_spacing %hu", ch_spacing);
4009
4010 if ((ch_spacing == 80) || (ch_spacing == 160)) {
4011 wide_bw_ie = &session_entry->gLimWiderBWChannelSwitch;
4012 frm.WiderBWChanSwitchAnn.newChanWidth =
4013 wide_bw_ie->newChanWidth;
4014 frm.WiderBWChanSwitchAnn.newCenterChanFreq0 =
4015 wide_bw_ie->newCenterChanFreq0;
4016 frm.WiderBWChanSwitchAnn.newCenterChanFreq1 =
4017 wide_bw_ie->newCenterChanFreq1;
4018 frm.WiderBWChanSwitchAnn.present = 1;
4019 pe_debug("wrapper: width:%d f0:%d f1:%d",
4020 frm.WiderBWChanSwitchAnn.newChanWidth,
4021 frm.WiderBWChanSwitchAnn.newCenterChanFreq0,
4022 frm.WiderBWChanSwitchAnn.newCenterChanFreq1);
4023 }
Abhishek Singh518323d2015-10-19 17:42:01 +05304024
4025 status = dot11f_get_packed_ext_channel_switch_action_frame_size(mac_ctx,
4026 &frm, &n_payload);
4027 if (DOT11F_FAILED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004028 pe_err("Failed to get packed size for Channel Switch 0x%08x",
Abhishek Singh518323d2015-10-19 17:42:01 +05304029 status);
4030 /* We'll fall back on the worst case scenario*/
4031 n_payload = sizeof(tDot11fext_channel_switch_action_frame);
4032 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004033 pe_warn("There were warnings while calculating the packed size for a Ext Channel Switch (0x%08x)",
Abhishek Singh518323d2015-10-19 17:42:01 +05304034 status);
4035 }
4036
4037 num_bytes = n_payload + sizeof(tSirMacMgmtHdr);
4038
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304039 qdf_status = cds_packet_alloc((uint16_t)num_bytes,
Abhishek Singh518323d2015-10-19 17:42:01 +05304040 (void **) &frame, (void **) &packet);
4041
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304042 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004043 pe_err("Failed to allocate %d bytes for a Ext Channel Switch",
Abhishek Singh518323d2015-10-19 17:42:01 +05304044 num_bytes);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004045 return QDF_STATUS_E_FAILURE;
Abhishek Singh518323d2015-10-19 17:42:01 +05304046 }
4047
4048 /* Paranoia*/
hangtian127c9532019-01-12 13:29:07 +08004049 qdf_mem_zero(frame, num_bytes);
Abhishek Singh518323d2015-10-19 17:42:01 +05304050
4051 /* Next, we fill out the buffer descriptor */
4052 lim_populate_mac_header(mac_ctx, frame, SIR_MAC_MGMT_FRAME,
Pragaspathi Thilagaraj7fb14222019-06-17 23:26:58 +05304053 SIR_MAC_MGMT_ACTION, peer, session_entry->self_mac_addr);
Abhishek Singh518323d2015-10-19 17:42:01 +05304054 mac_hdr = (tpSirMacMgmtHdr) frame;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304055 qdf_mem_copy((uint8_t *) mac_hdr->bssId,
Abhishek Singh518323d2015-10-19 17:42:01 +05304056 (uint8_t *) session_entry->bssId,
4057 sizeof(tSirMacAddr));
4058
gaolez4b62a9e2018-08-16 15:57:50 +08004059 lim_set_protected_bit(mac_ctx, session_entry, peer, mac_hdr);
4060
Abhishek Singh518323d2015-10-19 17:42:01 +05304061 status = dot11f_pack_ext_channel_switch_action_frame(mac_ctx, &frm,
4062 frame + sizeof(tSirMacMgmtHdr), n_payload, &n_payload);
4063 if (DOT11F_FAILED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004064 pe_err("Failed to pack a Channel Switch 0x%08x", status);
Abhishek Singh518323d2015-10-19 17:42:01 +05304065 cds_packet_free((void *)packet);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004066 return QDF_STATUS_E_FAILURE;
Abhishek Singh518323d2015-10-19 17:42:01 +05304067 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004068 pe_warn("There were warnings while packing a Channel Switch 0x%08x",
Abhishek Singh518323d2015-10-19 17:42:01 +05304069 status);
4070 }
4071
Liangwei Dong419d7302019-07-15 15:38:28 +08004072 if (wlan_reg_is_5ghz_ch_freq(session_entry->curr_op_freq) ||
4073 session_entry->opmode == QDF_P2P_CLIENT_MODE ||
4074 session_entry->opmode == QDF_P2P_GO_MODE)
Abhishek Singh518323d2015-10-19 17:42:01 +05304075 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
Abhishek Singh518323d2015-10-19 17:42:01 +05304076
Srinivas Girigowdacb7b8b82019-04-10 14:27:47 -07004077 pe_debug("Send Ext channel Switch to :"QDF_MAC_ADDR_STR" with swcount %d, swmode %d , newchannel %d newops %d",
Srinivas Girigowda34fbba02019-04-08 12:07:44 -07004078 QDF_MAC_ADDR_ARRAY(mac_hdr->da),
Abhishek Singh518323d2015-10-19 17:42:01 +05304079 frm.ext_chan_switch_ann_action.switch_count,
4080 frm.ext_chan_switch_ann_action.switch_mode,
4081 frm.ext_chan_switch_ann_action.new_channel,
4082 frm.ext_chan_switch_ann_action.op_class);
4083
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304084 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Abhishek Singh518323d2015-10-19 17:42:01 +05304085 session_entry->peSessionId, mac_hdr->fc.subType));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304086 qdf_status = wma_tx_frame(mac_ctx, packet, (uint16_t) num_bytes,
Abhishek Singh518323d2015-10-19 17:42:01 +05304087 TXRX_FRM_802_11_MGMT,
4088 ANI_TXDIR_TODS,
4089 7,
4090 lim_tx_complete, frame,
Abhishek Singh345be412019-11-19 10:59:29 +05304091 txFlag, vdev_id, 0,
Naveen Rawat296a5182017-09-25 14:02:48 -07004092 RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304093 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304094 session_entry->peSessionId, qdf_status));
4095 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004096 pe_err("Failed to send a Ext Channel Switch %X!",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304097 qdf_status);
Abhishek Singh518323d2015-10-19 17:42:01 +05304098 /* Pkt will be freed up by the callback */
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004099 return QDF_STATUS_E_FAILURE;
Abhishek Singh518323d2015-10-19 17:42:01 +05304100 }
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004101 return QDF_STATUS_SUCCESS;
Abhishek Singh518323d2015-10-19 17:42:01 +05304102} /* End lim_send_extended_chan_switch_action_frame */
4103
Abhishek Singh5695e2a2016-10-28 10:39:12 +05304104
4105/**
4106 * lim_oper_chan_change_confirm_tx_complete_cnf()- Confirmation for oper_chan_change_confirm
4107 * sent over the air
4108 *
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05304109 * @context: pointer to global mac
4110 * @buf: buffer
Abhishek Singh5695e2a2016-10-28 10:39:12 +05304111 * @tx_complete : Sent status
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05304112 * @params: tx completion params
Abhishek Singh5695e2a2016-10-28 10:39:12 +05304113 *
4114 * Return: This returns QDF_STATUS
4115 */
4116
4117static QDF_STATUS lim_oper_chan_change_confirm_tx_complete_cnf(
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05304118 void *context,
4119 qdf_nbuf_t buf,
4120 uint32_t tx_complete,
4121 void *params)
Abhishek Singh5695e2a2016-10-28 10:39:12 +05304122{
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004123 pe_debug("tx_complete: %d", tx_complete);
Zhu Jianmin83e8b122018-05-18 19:24:45 +08004124 if (buf)
4125 qdf_nbuf_free(buf);
Abhishek Singh5695e2a2016-10-28 10:39:12 +05304126 return QDF_STATUS_SUCCESS;
4127}
4128
4129/**
4130 * lim_p2p_oper_chan_change_confirm_action_frame()- function to send
4131 * p2p oper chan change confirm action frame
4132 * @mac_ctx: pointer to global mac structure
4133 * @peer: Destination mac.
4134 * @session_entry: session entry
4135 *
4136 * This function is called to send p2p oper chan change confirm action frame.
4137 *
4138 * Return: success if frame is sent else return failure
4139 */
4140
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004141QDF_STATUS
Jeff Johnson9320c1e2018-12-02 13:09:20 -08004142lim_p2p_oper_chan_change_confirm_action_frame(struct mac_context *mac_ctx,
Jeff Johnsona7815652018-11-18 22:58:30 -08004143 tSirMacAddr peer, struct pe_session *session_entry)
Abhishek Singh5695e2a2016-10-28 10:39:12 +05304144{
4145 tDot11fp2p_oper_chan_change_confirm frm;
4146 uint8_t *frame;
4147 tpSirMacMgmtHdr mac_hdr;
4148 uint32_t num_bytes, n_payload, status;
4149 void *packet;
4150 QDF_STATUS qdf_status;
4151 uint8_t tx_flag = 0;
Abhishek Singh345be412019-11-19 10:59:29 +05304152 uint8_t vdev_id = 0;
Abhishek Singh5695e2a2016-10-28 10:39:12 +05304153
Jeff Johnson8e9530b2019-03-18 13:41:42 -07004154 if (!session_entry) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004155 pe_err("Session entry is NULL!!!");
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004156 return QDF_STATUS_E_FAILURE;
Abhishek Singh5695e2a2016-10-28 10:39:12 +05304157 }
4158
Abhishek Singh345be412019-11-19 10:59:29 +05304159 vdev_id = session_entry->smeSessionId;
Abhishek Singh5695e2a2016-10-28 10:39:12 +05304160
hangtian127c9532019-01-12 13:29:07 +08004161 qdf_mem_zero(&frm, sizeof(frm));
Abhishek Singh5695e2a2016-10-28 10:39:12 +05304162
4163 frm.Category.category = SIR_MAC_ACTION_VENDOR_SPECIFIC_CATEGORY;
4164
4165 qdf_mem_copy(frm.p2p_action_oui.oui_data,
4166 SIR_MAC_P2P_OUI, SIR_MAC_P2P_OUI_SIZE);
4167 frm.p2p_action_subtype.subtype = 0x04;
4168 frm.DialogToken.token = 0x0;
4169
4170 if (session_entry->htCapability) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004171 pe_debug("Populate HT Caps in Assoc Request");
Abhishek Singh5695e2a2016-10-28 10:39:12 +05304172 populate_dot11f_ht_caps(mac_ctx, session_entry, &frm.HTCaps);
4173 }
4174
4175 if (session_entry->vhtCapability) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004176 pe_debug("Populate VHT Caps in Assoc Request");
Abhishek Singh5695e2a2016-10-28 10:39:12 +05304177 populate_dot11f_vht_caps(mac_ctx, session_entry, &frm.VHTCaps);
4178 populate_dot11f_operating_mode(mac_ctx,
4179 &frm.OperatingMode, session_entry);
4180 }
4181
4182 status = dot11f_get_packed_p2p_oper_chan_change_confirmSize(mac_ctx,
4183 &frm, &n_payload);
4184 if (DOT11F_FAILED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004185 pe_err("Failed to get packed size 0x%08x", status);
Abhishek Singh5695e2a2016-10-28 10:39:12 +05304186 /* We'll fall back on the worst case scenario*/
4187 n_payload = sizeof(tDot11fp2p_oper_chan_change_confirm);
4188 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004189 pe_warn("There were warnings while calculating the packed size (0x%08x)",
4190 status);
Abhishek Singh5695e2a2016-10-28 10:39:12 +05304191 }
4192
4193 num_bytes = n_payload + sizeof(tSirMacMgmtHdr);
4194
4195 qdf_status = cds_packet_alloc((uint16_t)num_bytes,
4196 (void **) &frame, (void **) &packet);
4197
4198 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004199 pe_err("Failed to allocate %d bytes", num_bytes);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004200 return QDF_STATUS_E_FAILURE;
Abhishek Singh5695e2a2016-10-28 10:39:12 +05304201 }
4202
hangtian127c9532019-01-12 13:29:07 +08004203 qdf_mem_zero(frame, num_bytes);
Abhishek Singh5695e2a2016-10-28 10:39:12 +05304204
4205 /* Next, fill out the buffer descriptor */
4206 lim_populate_mac_header(mac_ctx, frame, SIR_MAC_MGMT_FRAME,
Pragaspathi Thilagaraj7fb14222019-06-17 23:26:58 +05304207 SIR_MAC_MGMT_ACTION, peer, session_entry->self_mac_addr);
Abhishek Singh5695e2a2016-10-28 10:39:12 +05304208 mac_hdr = (tpSirMacMgmtHdr) frame;
4209 qdf_mem_copy((uint8_t *) mac_hdr->bssId,
4210 (uint8_t *) session_entry->bssId,
4211 sizeof(tSirMacAddr));
4212
4213 status = dot11f_pack_p2p_oper_chan_change_confirm(mac_ctx, &frm,
4214 frame + sizeof(tSirMacMgmtHdr), n_payload, &n_payload);
4215 if (DOT11F_FAILED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004216 pe_err("Failed to pack 0x%08x", status);
Abhishek Singh5695e2a2016-10-28 10:39:12 +05304217 cds_packet_free((void *)packet);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004218 return QDF_STATUS_E_FAILURE;
Abhishek Singh5695e2a2016-10-28 10:39:12 +05304219 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004220 pe_warn("There were warnings while packing 0x%08x",
Abhishek Singh5695e2a2016-10-28 10:39:12 +05304221 status);
4222 }
4223
Liangwei Dong419d7302019-07-15 15:38:28 +08004224 if (wlan_reg_is_5ghz_ch_freq(session_entry->curr_op_freq) ||
4225 session_entry->opmode == QDF_P2P_CLIENT_MODE ||
4226 session_entry->opmode == QDF_P2P_GO_MODE) {
Abhishek Singh5695e2a2016-10-28 10:39:12 +05304227 tx_flag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
4228 }
Liangwei Dong419d7302019-07-15 15:38:28 +08004229 pe_debug("Send frame on channel freq %d to mac "
4230 QDF_MAC_ADDR_STR, session_entry->curr_op_freq,
Srinivas Girigowda34fbba02019-04-08 12:07:44 -07004231 QDF_MAC_ADDR_ARRAY(peer));
Abhishek Singh5695e2a2016-10-28 10:39:12 +05304232
4233 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
4234 session_entry->peSessionId, mac_hdr->fc.subType));
4235
4236 qdf_status = wma_tx_frameWithTxComplete(mac_ctx, packet,
4237 (uint16_t)num_bytes,
4238 TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS,
4239 7, lim_tx_complete, frame,
4240 lim_oper_chan_change_confirm_tx_complete_cnf,
Abhishek Singh345be412019-11-19 10:59:29 +05304241 tx_flag, vdev_id, false, 0, RATEID_DEFAULT);
Abhishek Singh5695e2a2016-10-28 10:39:12 +05304242
4243 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
4244 session_entry->peSessionId, qdf_status));
4245 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004246 pe_err("Failed to send status %X!", qdf_status);
Abhishek Singh5695e2a2016-10-28 10:39:12 +05304247 /* Pkt will be freed up by the callback */
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004248 return QDF_STATUS_E_FAILURE;
Abhishek Singh5695e2a2016-10-28 10:39:12 +05304249 }
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004250 return QDF_STATUS_SUCCESS;
Abhishek Singh5695e2a2016-10-28 10:39:12 +05304251}
4252
4253
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004254/**
4255 * \brief Send a Neighbor Report Request Action frame
4256 *
4257 *
Jeff Johnson99f25042018-11-21 22:49:06 -08004258 * \param mac Pointer to the global MAC structure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004259 *
4260 * \param pNeighborReq Address of a tSirMacNeighborReportReq
4261 *
4262 * \param peer mac address of peer station.
4263 *
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004264 * \param pe_session address of session entry.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004265 *
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004266 * \return QDF_STATUS_SUCCESS on success, QDF_STATUS_E_FAILURE else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004267 *
4268 *
4269 */
4270
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004271QDF_STATUS
Jeff Johnson9320c1e2018-12-02 13:09:20 -08004272lim_send_neighbor_report_request_frame(struct mac_context *mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004273 tpSirMacNeighborReportReq pNeighborReq,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004274 tSirMacAddr peer, struct pe_session *pe_session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004275{
Pragaspathi Thilagarajd48e6cd2019-05-30 00:52:43 +05304276 QDF_STATUS status_code = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004277 tDot11fNeighborReportRequest frm;
4278 uint8_t *pFrame;
4279 tpSirMacMgmtHdr pMacHdr;
4280 uint32_t nBytes, nPayload, nStatus;
4281 void *pPacket;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304282 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004283 uint8_t txFlag = 0;
4284 uint8_t smeSessionId = 0;
4285
Jeff Johnson8e9530b2019-03-18 13:41:42 -07004286 if (!pe_session) {
4287 pe_err("(!psession) in Request to send Neighbor Report request action frame");
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004288 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004289 }
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004290 smeSessionId = pe_session->smeSessionId;
hangtian127c9532019-01-12 13:29:07 +08004291 qdf_mem_zero((uint8_t *) &frm, sizeof(frm));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004292
Srinivas Girigowda48bec1c2019-05-17 16:33:30 -07004293 frm.Category.category = ACTION_CATEGORY_RRM;
Srinivas Girigowda395addd2019-05-24 14:03:58 -07004294 frm.Action.action = RRM_NEIGHBOR_REQ;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004295 frm.DialogToken.token = pNeighborReq->dialogToken;
4296
4297 if (pNeighborReq->ssid_present) {
Jeff Johnson99f25042018-11-21 22:49:06 -08004298 populate_dot11f_ssid(mac, &pNeighborReq->ssid, &frm.SSID);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004299 }
4300
4301 nStatus =
Jeff Johnson99f25042018-11-21 22:49:06 -08004302 dot11f_get_packed_neighbor_report_request_size(mac, &frm, &nPayload);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004303 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004304 pe_err("Failed to calculate the packed size for a Neighbor Report Request(0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004305 nStatus);
4306 /* We'll fall back on the worst case scenario: */
4307 nPayload = sizeof(tDot11fNeighborReportRequest);
4308 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004309 pe_warn("There were warnings while calculating the packed size for a Neighbor Report Request(0x%08x)",
4310 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004311 }
4312
4313 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
4314
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304315 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004316 cds_packet_alloc((uint16_t) nBytes, (void **)&pFrame,
4317 (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304318 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004319 pe_err("Failed to allocate %d bytes for a Neighbor "
4320 "Report Request", nBytes);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004321 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004322 }
4323 /* Paranoia: */
hangtian127c9532019-01-12 13:29:07 +08004324 qdf_mem_zero(pFrame, nBytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004325
4326 /* Copy necessary info to BD */
Jeff Johnson99f25042018-11-21 22:49:06 -08004327 lim_populate_mac_header(mac, pFrame, SIR_MAC_MGMT_FRAME,
Pragaspathi Thilagaraj7fb14222019-06-17 23:26:58 +05304328 SIR_MAC_MGMT_ACTION, peer, pe_session->self_mac_addr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004329
4330 /* Update A3 with the BSSID */
4331 pMacHdr = (tpSirMacMgmtHdr) pFrame;
4332
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004333 sir_copy_mac_addr(pMacHdr->bssId, pe_session->bssId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004334
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004335 lim_set_protected_bit(mac, pe_session, peer, pMacHdr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004336
4337 /* Now, we're ready to "pack" the frames */
Jeff Johnson99f25042018-11-21 22:49:06 -08004338 nStatus = dot11f_pack_neighbor_report_request(mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004339 &frm,
4340 pFrame +
4341 sizeof(tSirMacMgmtHdr),
4342 nPayload, &nPayload);
4343
4344 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004345 pe_err("Failed to pack an Neighbor Report Request (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004346 nStatus);
4347
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004348 /* FIXME - Need to convert to QDF_STATUS */
Pragaspathi Thilagarajd48e6cd2019-05-30 00:52:43 +05304349 status_code = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004350 goto returnAfterError;
4351 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004352 pe_warn("There were warnings while packing Neighbor Report Request (0x%08x)",
4353 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004354 }
4355
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004356 pe_debug("Sending a Neighbor Report Request to");
Jeff Johnson99f25042018-11-21 22:49:06 -08004357 lim_print_mac_addr(mac, peer, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004358
Liangwei Dong419d7302019-07-15 15:38:28 +08004359 if (wlan_reg_is_5ghz_ch_freq(pe_session->curr_op_freq) ||
4360 pe_session->opmode == QDF_P2P_CLIENT_MODE ||
4361 pe_session->opmode == QDF_P2P_GO_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004362 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004363
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304364 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004365 pe_session->peSessionId, pMacHdr->fc.subType));
Jeff Johnson99f25042018-11-21 22:49:06 -08004366 qdf_status = wma_tx_frame(mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004367 pPacket,
4368 (uint16_t) nBytes,
4369 TXRX_FRM_802_11_MGMT,
4370 ANI_TXDIR_TODS,
4371 7, lim_tx_complete, pFrame, txFlag,
Naveen Rawat296a5182017-09-25 14:02:48 -07004372 smeSessionId, 0, RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304373 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004374 pe_session->peSessionId, qdf_status));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304375 if (QDF_STATUS_SUCCESS != qdf_status) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004376 pe_err("wma_tx_frame FAILED! Status [%d]", qdf_status);
Pragaspathi Thilagarajd48e6cd2019-05-30 00:52:43 +05304377 status_code = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004378 /* Pkt will be freed up by the callback */
Pragaspathi Thilagarajd48e6cd2019-05-30 00:52:43 +05304379 return status_code;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004380 } else
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004381 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004382
4383returnAfterError:
4384 cds_packet_free((void *)pPacket);
4385
Pragaspathi Thilagarajd48e6cd2019-05-30 00:52:43 +05304386 return status_code;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004387} /* End lim_send_neighbor_report_request_frame. */
4388
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004389QDF_STATUS
Jeff Johnson9320c1e2018-12-02 13:09:20 -08004390lim_send_link_report_action_frame(struct mac_context *mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004391 tpSirMacLinkReport pLinkReport,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004392 tSirMacAddr peer, struct pe_session *pe_session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004393{
Pragaspathi Thilagarajd48e6cd2019-05-30 00:52:43 +05304394 QDF_STATUS status_code = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004395 tDot11fLinkMeasurementReport frm;
4396 uint8_t *pFrame;
4397 tpSirMacMgmtHdr pMacHdr;
4398 uint32_t nBytes, nPayload, nStatus;
4399 void *pPacket;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304400 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004401 uint8_t txFlag = 0;
Pragaspathi Thilagaraj683c1cf2019-09-23 18:40:57 +05304402 uint8_t vdev_id = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004403
Jeff Johnson8e9530b2019-03-18 13:41:42 -07004404 if (!pe_session) {
Pragaspathi Thilagaraj683c1cf2019-09-23 18:40:57 +05304405 pe_err("RRM: Send link report: NULL PE session");
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004406 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004407 }
4408
Pragaspathi Thilagaraj683c1cf2019-09-23 18:40:57 +05304409 vdev_id = pe_session->vdev_id;
hangtian127c9532019-01-12 13:29:07 +08004410 qdf_mem_zero((uint8_t *) &frm, sizeof(frm));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004411
Srinivas Girigowda48bec1c2019-05-17 16:33:30 -07004412 frm.Category.category = ACTION_CATEGORY_RRM;
Srinivas Girigowda395addd2019-05-24 14:03:58 -07004413 frm.Action.action = RRM_LINK_MEASUREMENT_RPT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004414 frm.DialogToken.token = pLinkReport->dialogToken;
4415
4416 /* IEEE Std. 802.11 7.3.2.18. for the report element. */
4417 /* Even though TPC report an IE, it is represented using fixed fields since it is positioned */
4418 /* in the middle of other fixed fields in the link report frame(IEEE Std. 802.11k section7.4.6.4 */
4419 /* and frame parser always expects IEs to come after all fixed fields. It is easier to handle */
4420 /* such case this way than changing the frame parser. */
Srinivas Girigowda61771262019-04-01 11:55:19 -07004421 frm.TPCEleID.TPCId = WLAN_ELEMID_TPCREP;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004422 frm.TPCEleLen.TPCLen = 2;
4423 frm.TxPower.txPower = pLinkReport->txPower;
4424 frm.LinkMargin.linkMargin = 0;
4425
4426 frm.RxAntennaId.antennaId = pLinkReport->rxAntenna;
4427 frm.TxAntennaId.antennaId = pLinkReport->txAntenna;
4428 frm.RCPI.rcpi = pLinkReport->rcpi;
4429 frm.RSNI.rsni = pLinkReport->rsni;
4430
4431 nStatus =
Jeff Johnson99f25042018-11-21 22:49:06 -08004432 dot11f_get_packed_link_measurement_report_size(mac, &frm, &nPayload);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004433 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004434 pe_err("Failed to calculate the packed size for a Link Report (0x%08x)", nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004435 /* We'll fall back on the worst case scenario: */
4436 nPayload = sizeof(tDot11fLinkMeasurementReport);
4437 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004438 pe_warn("There were warnings while calculating the packed size for a Link Report (0x%08x)",
4439 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004440 }
4441
4442 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
4443
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304444 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004445 cds_packet_alloc((uint16_t) nBytes, (void **)&pFrame,
4446 (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304447 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004448 pe_err("Failed to allocate %d bytes for a Link "
4449 "Report", nBytes);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004450 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004451 }
4452 /* Paranoia: */
hangtian127c9532019-01-12 13:29:07 +08004453 qdf_mem_zero(pFrame, nBytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004454
4455 /* Copy necessary info to BD */
Jeff Johnson99f25042018-11-21 22:49:06 -08004456 lim_populate_mac_header(mac, pFrame, SIR_MAC_MGMT_FRAME,
Pragaspathi Thilagaraj7fb14222019-06-17 23:26:58 +05304457 SIR_MAC_MGMT_ACTION, peer, pe_session->self_mac_addr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004458
4459 /* Update A3 with the BSSID */
4460 pMacHdr = (tpSirMacMgmtHdr) pFrame;
4461
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004462 sir_copy_mac_addr(pMacHdr->bssId, pe_session->bssId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004463
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004464 lim_set_protected_bit(mac, pe_session, peer, pMacHdr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004465
4466 /* Now, we're ready to "pack" the frames */
Jeff Johnson99f25042018-11-21 22:49:06 -08004467 nStatus = dot11f_pack_link_measurement_report(mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004468 &frm,
4469 pFrame +
4470 sizeof(tSirMacMgmtHdr),
4471 nPayload, &nPayload);
4472
4473 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004474 pe_err("Failed to pack an Link Report (0x%08x)", nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004475
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004476 /* FIXME - Need to convert to QDF_STATUS */
Pragaspathi Thilagarajd48e6cd2019-05-30 00:52:43 +05304477 status_code = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004478 goto returnAfterError;
4479 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004480 pe_warn("There were warnings while packing Link Report (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004481 nStatus);
4482 }
4483
Pragaspathi Thilagaraj683c1cf2019-09-23 18:40:57 +05304484 pe_warn("RRM: Sending Link Report to %pM on vdev[%d]", peer, vdev_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004485
Liangwei Dong419d7302019-07-15 15:38:28 +08004486 if (wlan_reg_is_5ghz_ch_freq(pe_session->curr_op_freq) ||
4487 pe_session->opmode == QDF_P2P_CLIENT_MODE ||
4488 pe_session->opmode == QDF_P2P_GO_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004489 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004490
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304491 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004492 pe_session->peSessionId, pMacHdr->fc.subType));
Jeff Johnson99f25042018-11-21 22:49:06 -08004493 qdf_status = wma_tx_frame(mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004494 pPacket,
4495 (uint16_t) nBytes,
4496 TXRX_FRM_802_11_MGMT,
4497 ANI_TXDIR_TODS,
4498 7, lim_tx_complete, pFrame, txFlag,
Pragaspathi Thilagaraj683c1cf2019-09-23 18:40:57 +05304499 vdev_id, 0, RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304500 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004501 pe_session->peSessionId, qdf_status));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304502 if (QDF_STATUS_SUCCESS != qdf_status) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004503 pe_err("wma_tx_frame FAILED! Status [%d]", qdf_status);
Pragaspathi Thilagarajd48e6cd2019-05-30 00:52:43 +05304504 status_code = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004505 /* Pkt will be freed up by the callback */
Pragaspathi Thilagarajd48e6cd2019-05-30 00:52:43 +05304506 return status_code;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004507 } else
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004508 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004509
4510returnAfterError:
4511 cds_packet_free((void *)pPacket);
4512
Pragaspathi Thilagarajd48e6cd2019-05-30 00:52:43 +05304513 return status_code;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004514} /* End lim_send_link_report_action_frame. */
4515
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004516QDF_STATUS
Jeff Johnson9320c1e2018-12-02 13:09:20 -08004517lim_send_radio_measure_report_action_frame(struct mac_context *mac,
Vignesh Viswanathan3b4bf982018-06-05 15:04:23 +05304518 uint8_t dialog_token,
4519 uint8_t num_report,
Vignesh Viswanathan09bd8f42018-08-14 22:04:36 +05304520 bool is_last_frame,
Vignesh Viswanathan3b4bf982018-06-05 15:04:23 +05304521 tpSirMacRadioMeasureReport pRRMReport,
4522 tSirMacAddr peer,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004523 struct pe_session *pe_session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004524{
Pragaspathi Thilagarajd48e6cd2019-05-30 00:52:43 +05304525 QDF_STATUS status_code = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004526 uint8_t *pFrame;
4527 tpSirMacMgmtHdr pMacHdr;
4528 uint32_t nBytes, nPayload, nStatus;
4529 void *pPacket;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304530 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004531 uint8_t i;
4532 uint8_t txFlag = 0;
4533 uint8_t smeSessionId = 0;
Vignesh Viswanathan793328d2018-11-02 11:32:35 +05304534 bool is_last_report = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004535
4536 tDot11fRadioMeasurementReport *frm =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304537 qdf_mem_malloc(sizeof(tDot11fRadioMeasurementReport));
Arif Hussainf5b6c412018-10-10 19:41:09 -07004538 if (!frm)
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004539 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004540
Jeff Johnson8e9530b2019-03-18 13:41:42 -07004541 if (!pe_session) {
4542 pe_err("(!psession) in Request to send Beacon Report action frame");
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304543 qdf_mem_free(frm);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004544 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004545 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004546
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004547 smeSessionId = pe_session->smeSessionId;
Deepak Dhamdhere6a021482017-04-20 17:59:58 -07004548
Vignesh Viswanathan09bd8f42018-08-14 22:04:36 +05304549 pe_debug("dialog_token %d num_report %d is_last_frame %d",
4550 dialog_token, num_report, is_last_frame);
Padma, Santhosh Kumar93ec7d22016-12-26 15:58:37 +05304551
Srinivas Girigowda48bec1c2019-05-17 16:33:30 -07004552 frm->Category.category = ACTION_CATEGORY_RRM;
Srinivas Girigowda395addd2019-05-24 14:03:58 -07004553 frm->Action.action = RRM_RADIO_MEASURE_RPT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004554 frm->DialogToken.token = dialog_token;
4555
4556 frm->num_MeasurementReport =
4557 (num_report >
4558 RADIO_REPORTS_MAX_IN_A_FRAME) ? RADIO_REPORTS_MAX_IN_A_FRAME :
4559 num_report;
4560
4561 for (i = 0; i < frm->num_MeasurementReport; i++) {
4562 frm->MeasurementReport[i].type = pRRMReport[i].type;
4563 frm->MeasurementReport[i].token = pRRMReport[i].token;
4564 frm->MeasurementReport[i].late = 0; /* IEEE 802.11k section 7.3.22. (always zero in rrm) */
4565 switch (pRRMReport[i].type) {
4566 case SIR_MAC_RRM_BEACON_TYPE:
Vignesh Viswanathan793328d2018-11-02 11:32:35 +05304567 /*
4568 * Last beacon report indication needs to be set to 1
4569 * only for the last report in the last frame
4570 */
4571 if (is_last_frame &&
4572 (i == (frm->num_MeasurementReport - 1)))
4573 is_last_report = true;
4574
Jeff Johnson99f25042018-11-21 22:49:06 -08004575 populate_dot11f_beacon_report(mac,
Vignesh Viswanathan3b4bf982018-06-05 15:04:23 +05304576 &frm->MeasurementReport[i],
4577 &pRRMReport[i].report.
4578 beaconReport,
Vignesh Viswanathan793328d2018-11-02 11:32:35 +05304579 is_last_report);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004580 frm->MeasurementReport[i].incapable =
4581 pRRMReport[i].incapable;
4582 frm->MeasurementReport[i].refused =
4583 pRRMReport[i].refused;
4584 frm->MeasurementReport[i].present = 1;
4585 break;
4586 default:
4587 frm->MeasurementReport[i].incapable =
4588 pRRMReport[i].incapable;
4589 frm->MeasurementReport[i].refused =
4590 pRRMReport[i].refused;
4591 frm->MeasurementReport[i].present = 1;
4592 break;
4593 }
4594 }
4595
4596 nStatus =
Jeff Johnson99f25042018-11-21 22:49:06 -08004597 dot11f_get_packed_radio_measurement_report_size(mac, frm, &nPayload);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004598 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004599 pe_err("Failed to calculate the packed size for a Radio Measure Report (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004600 nStatus);
4601 /* We'll fall back on the worst case scenario: */
4602 nPayload = sizeof(tDot11fLinkMeasurementReport);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304603 qdf_mem_free(frm);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004604 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004605 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004606 pe_warn("There were warnings while calculating the packed size for a Radio Measure Report (0x%08x)",
4607 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004608 }
4609
4610 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
4611
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304612 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004613 cds_packet_alloc((uint16_t) nBytes, (void **)&pFrame,
4614 (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304615 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004616 pe_err("Failed to allocate %d bytes for a Radio Measure "
4617 "Report", nBytes);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304618 qdf_mem_free(frm);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004619 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004620 }
4621 /* Paranoia: */
hangtian127c9532019-01-12 13:29:07 +08004622 qdf_mem_zero(pFrame, nBytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004623
4624 /* Copy necessary info to BD */
Jeff Johnson99f25042018-11-21 22:49:06 -08004625 lim_populate_mac_header(mac, pFrame, SIR_MAC_MGMT_FRAME,
Pragaspathi Thilagaraj7fb14222019-06-17 23:26:58 +05304626 SIR_MAC_MGMT_ACTION, peer, pe_session->self_mac_addr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004627
4628 /* Update A3 with the BSSID */
4629 pMacHdr = (tpSirMacMgmtHdr) pFrame;
4630
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004631 sir_copy_mac_addr(pMacHdr->bssId, pe_session->bssId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004632
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004633 lim_set_protected_bit(mac, pe_session, peer, pMacHdr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004634
4635 /* Now, we're ready to "pack" the frames */
Jeff Johnson99f25042018-11-21 22:49:06 -08004636 nStatus = dot11f_pack_radio_measurement_report(mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004637 frm,
4638 pFrame +
4639 sizeof(tSirMacMgmtHdr),
4640 nPayload, &nPayload);
4641
4642 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004643 pe_err("Failed to pack an Radio Measure Report (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004644 nStatus);
4645
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004646 /* FIXME - Need to convert to QDF_STATUS */
Pragaspathi Thilagarajd48e6cd2019-05-30 00:52:43 +05304647 status_code = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004648 goto returnAfterError;
4649 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004650 pe_warn("There were warnings while packing Radio Measure Report (0x%08x)",
4651 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004652 }
4653
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004654 pe_warn("Sending a Radio Measure Report to");
Jeff Johnson99f25042018-11-21 22:49:06 -08004655 lim_print_mac_addr(mac, peer, LOGW);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004656
Liangwei Dong419d7302019-07-15 15:38:28 +08004657 if (wlan_reg_is_5ghz_ch_freq(pe_session->curr_op_freq) ||
4658 pe_session->opmode == QDF_P2P_CLIENT_MODE ||
4659 pe_session->opmode == QDF_P2P_GO_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004660 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004661
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304662 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004663 pe_session->peSessionId, pMacHdr->fc.subType));
Jeff Johnson99f25042018-11-21 22:49:06 -08004664 qdf_status = wma_tx_frame(mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004665 pPacket,
4666 (uint16_t) nBytes,
4667 TXRX_FRM_802_11_MGMT,
4668 ANI_TXDIR_TODS,
4669 7, lim_tx_complete, pFrame, txFlag,
Naveen Rawat296a5182017-09-25 14:02:48 -07004670 smeSessionId, 0, RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304671 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004672 pe_session->peSessionId, qdf_status));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304673 if (QDF_STATUS_SUCCESS != qdf_status) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004674 pe_err("wma_tx_frame FAILED! Status [%d]", qdf_status);
Pragaspathi Thilagarajd48e6cd2019-05-30 00:52:43 +05304675 status_code = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004676 /* Pkt will be freed up by the callback */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304677 qdf_mem_free(frm);
Pragaspathi Thilagarajd48e6cd2019-05-30 00:52:43 +05304678 return status_code;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004679 } else {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304680 qdf_mem_free(frm);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004681 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004682 }
4683
4684returnAfterError:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304685 qdf_mem_free(frm);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004686 cds_packet_free((void *)pPacket);
Pragaspathi Thilagarajd48e6cd2019-05-30 00:52:43 +05304687 return status_code;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004688}
4689
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004690#ifdef WLAN_FEATURE_11W
4691/**
4692 * \brief Send SA query request action frame to peer
4693 *
4694 * \sa lim_send_sa_query_request_frame
4695 *
4696 *
Jeff Johnson9320c1e2018-12-02 13:09:20 -08004697 * \param mac The global struct mac_context *object
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004698 *
4699 * \param transId Transaction identifier
4700 *
4701 * \param peer The Mac address of the station to which this action frame is addressed
4702 *
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004703 * \param pe_session The PE session entry
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004704 *
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004705 * \return QDF_STATUS_SUCCESS if setup completes successfully
4706 * QDF_STATUS_E_FAILURE is some problem is encountered
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004707 */
4708
Jeff Johnson9320c1e2018-12-02 13:09:20 -08004709QDF_STATUS lim_send_sa_query_request_frame(struct mac_context *mac, uint8_t *transId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004710 tSirMacAddr peer,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004711 struct pe_session *pe_session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004712{
4713
4714 tDot11fSaQueryReq frm; /* SA query request action frame */
4715 uint8_t *pFrame;
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004716 QDF_STATUS nSirStatus;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004717 tpSirMacMgmtHdr pMacHdr;
4718 uint32_t nBytes, nPayload, nStatus;
4719 void *pPacket;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304720 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004721 uint8_t txFlag = 0;
4722 uint8_t smeSessionId = 0;
4723
hangtian127c9532019-01-12 13:29:07 +08004724 qdf_mem_zero((uint8_t *) &frm, sizeof(frm));
Srinivas Girigowda48bec1c2019-05-17 16:33:30 -07004725 frm.Category.category = ACTION_CATEGORY_SA_QUERY;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004726 /* 11w action field is :
4727 action: 0 --> SA Query Request action frame
4728 action: 1 --> SA Query Response action frame */
Srinivas Girigowdafeb23fc2019-06-13 11:12:29 -07004729 frm.Action.action = SA_QUERY_REQUEST;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004730 /* 11w SA Query Request transId */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304731 qdf_mem_copy(&frm.TransactionId.transId[0], &transId[0], 2);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004732
Jeff Johnson99f25042018-11-21 22:49:06 -08004733 nStatus = dot11f_get_packed_sa_query_req_size(mac, &frm, &nPayload);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004734 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004735 pe_err("Failed to calculate the packed size for an SA Query Request (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004736 nStatus);
4737 /* We'll fall back on the worst case scenario: */
4738 nPayload = sizeof(tDot11fSaQueryReq);
4739 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004740 pe_warn("There were warnings while calculating the packed size for an SA Query Request (0x%08x)",
4741 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004742 }
4743
4744 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304745 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004746 cds_packet_alloc(nBytes, (void **)&pFrame, (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304747 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004748 pe_err("Failed to allocate %d bytes for a SA Query Request "
4749 "action frame", nBytes);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004750 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004751 }
4752 /* Paranoia: */
hangtian127c9532019-01-12 13:29:07 +08004753 qdf_mem_zero(pFrame, nBytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004754
4755 /* Copy necessary info to BD */
Jeff Johnson99f25042018-11-21 22:49:06 -08004756 lim_populate_mac_header(mac, pFrame, SIR_MAC_MGMT_FRAME,
Pragaspathi Thilagaraj7fb14222019-06-17 23:26:58 +05304757 SIR_MAC_MGMT_ACTION, peer, pe_session->self_mac_addr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004758
4759 /* Update A3 with the BSSID */
4760 pMacHdr = (tpSirMacMgmtHdr) pFrame;
4761
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004762 sir_copy_mac_addr(pMacHdr->bssId, pe_session->bssId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004763
4764 /* Since this is a SA Query Request, set the "protect" (aka WEP) bit */
4765 /* in the FC */
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004766 lim_set_protected_bit(mac, pe_session, peer, pMacHdr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004767
4768 /* Pack 11w SA Query Request frame */
Jeff Johnson99f25042018-11-21 22:49:06 -08004769 nStatus = dot11f_pack_sa_query_req(mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004770 &frm,
4771 pFrame + sizeof(tSirMacMgmtHdr),
4772 nPayload, &nPayload);
4773
4774 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004775 pe_err("Failed to pack an SA Query Request (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004776 nStatus);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004777 /* FIXME - Need to convert to QDF_STATUS */
4778 nSirStatus = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004779 goto returnAfterError;
4780 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004781 pe_warn("There were warnings while packing SA Query Request (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004782 nStatus);
4783 }
4784
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004785 pe_debug("Sending an SA Query Request to");
Jeff Johnson99f25042018-11-21 22:49:06 -08004786 lim_print_mac_addr(mac, peer, LOGD);
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004787 pe_debug("Sending an SA Query Request from ");
Pragaspathi Thilagaraj7fb14222019-06-17 23:26:58 +05304788 lim_print_mac_addr(mac, pe_session->self_mac_addr, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004789
Liangwei Dong419d7302019-07-15 15:38:28 +08004790 if (wlan_reg_is_5ghz_ch_freq(pe_session->curr_op_freq) ||
4791 pe_session->opmode == QDF_P2P_CLIENT_MODE ||
4792 pe_session->opmode == QDF_P2P_GO_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004793 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
Pragaspathi Thilagaraje64714a2019-05-23 00:46:25 +05304794
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004795 smeSessionId = pe_session->smeSessionId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004796
Jeff Johnson99f25042018-11-21 22:49:06 -08004797 qdf_status = wma_tx_frame(mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004798 pPacket,
4799 (uint16_t) nBytes,
4800 TXRX_FRM_802_11_MGMT,
4801 ANI_TXDIR_TODS,
4802 7, lim_tx_complete, pFrame, txFlag,
Naveen Rawat296a5182017-09-25 14:02:48 -07004803 smeSessionId, 0, RATEID_DEFAULT);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304804 if (QDF_STATUS_SUCCESS != qdf_status) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004805 pe_err("wma_tx_frame FAILED! Status [%d]", qdf_status);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004806 nSirStatus = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004807 /* Pkt will be freed up by the callback */
4808 return nSirStatus;
4809 } else {
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004810 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004811 }
4812
4813returnAfterError:
4814 cds_packet_free((void *)pPacket);
4815 return nSirStatus;
4816} /* End lim_send_sa_query_request_frame */
4817
4818/**
4819 * \brief Send SA query response action frame to peer
4820 *
4821 * \sa lim_send_sa_query_response_frame
4822 *
4823 *
Jeff Johnson9320c1e2018-12-02 13:09:20 -08004824 * \param mac The global struct mac_context *object
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004825 *
4826 * \param transId Transaction identifier received in SA query request action frame
4827 *
4828 * \param peer The Mac address of the AP to which this action frame is addressed
4829 *
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004830 * \param pe_session The PE session entry
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004831 *
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004832 * \return QDF_STATUS_SUCCESS if setup completes successfully
4833 * QDF_STATUS_E_FAILURE is some problem is encountered
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004834 */
4835
Jeff Johnson9320c1e2018-12-02 13:09:20 -08004836QDF_STATUS lim_send_sa_query_response_frame(struct mac_context *mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004837 uint8_t *transId, tSirMacAddr peer,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004838 struct pe_session *pe_session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004839{
4840
Jeff Johnson47d75242018-05-12 15:58:53 -07004841 tDot11fSaQueryRsp frm; /* SA query response action frame */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004842 uint8_t *pFrame;
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004843 QDF_STATUS nSirStatus;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004844 tpSirMacMgmtHdr pMacHdr;
4845 uint32_t nBytes, nPayload, nStatus;
4846 void *pPacket;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304847 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004848 uint8_t txFlag = 0;
4849 uint8_t smeSessionId = 0;
4850
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004851 smeSessionId = pe_session->smeSessionId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004852
hangtian127c9532019-01-12 13:29:07 +08004853 qdf_mem_zero((uint8_t *) &frm, sizeof(frm));
Srinivas Girigowda48bec1c2019-05-17 16:33:30 -07004854 frm.Category.category = ACTION_CATEGORY_SA_QUERY;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004855 /*11w action field is :
4856 action: 0 --> SA query request action frame
4857 action: 1 --> SA query response action frame */
Srinivas Girigowdafeb23fc2019-06-13 11:12:29 -07004858 frm.Action.action = SA_QUERY_RESPONSE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004859 /*11w SA query response transId is same as
4860 SA query request transId */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304861 qdf_mem_copy(&frm.TransactionId.transId[0], &transId[0], 2);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004862
Jeff Johnson99f25042018-11-21 22:49:06 -08004863 nStatus = dot11f_get_packed_sa_query_rsp_size(mac, &frm, &nPayload);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004864 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004865 pe_err("Failed to calculate the packed size for a SA Query Response (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004866 nStatus);
4867 /* We'll fall back on the worst case scenario: */
4868 nPayload = sizeof(tDot11fSaQueryRsp);
4869 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004870 pe_warn("There were warnings while calculating the packed size for an SA Query Response (0x%08x)",
4871 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004872 }
4873
4874 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304875 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004876 cds_packet_alloc(nBytes, (void **)&pFrame, (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304877 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004878 pe_err("Failed to allocate %d bytes for a SA query response"
4879 " action frame", nBytes);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004880 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004881 }
4882 /* Paranoia: */
hangtian127c9532019-01-12 13:29:07 +08004883 qdf_mem_zero(pFrame, nBytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004884
4885 /* Copy necessary info to BD */
Jeff Johnson99f25042018-11-21 22:49:06 -08004886 lim_populate_mac_header(mac, pFrame, SIR_MAC_MGMT_FRAME,
Pragaspathi Thilagaraj7fb14222019-06-17 23:26:58 +05304887 SIR_MAC_MGMT_ACTION, peer, pe_session->self_mac_addr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004888
4889 /* Update A3 with the BSSID */
4890 pMacHdr = (tpSirMacMgmtHdr) pFrame;
4891
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004892 sir_copy_mac_addr(pMacHdr->bssId, pe_session->bssId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004893
4894 /* Since this is a SA Query Response, set the "protect" (aka WEP) bit */
4895 /* in the FC */
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004896 lim_set_protected_bit(mac, pe_session, peer, pMacHdr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004897
4898 /* Pack 11w SA query response frame */
Jeff Johnson99f25042018-11-21 22:49:06 -08004899 nStatus = dot11f_pack_sa_query_rsp(mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004900 &frm,
4901 pFrame + sizeof(tSirMacMgmtHdr),
4902 nPayload, &nPayload);
4903
4904 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004905 pe_err("Failed to pack an SA Query Response (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004906 nStatus);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004907 /* FIXME - Need to convert to QDF_STATUS */
4908 nSirStatus = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004909 goto returnAfterError;
4910 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004911 pe_warn("There were warnings while packing SA Query Response (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004912 nStatus);
4913 }
4914
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004915 pe_debug("Sending a SA Query Response to");
Jeff Johnson99f25042018-11-21 22:49:06 -08004916 lim_print_mac_addr(mac, peer, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004917
Liangwei Dong419d7302019-07-15 15:38:28 +08004918 if (wlan_reg_is_5ghz_ch_freq(pe_session->curr_op_freq) ||
4919 pe_session->opmode == QDF_P2P_CLIENT_MODE ||
4920 pe_session->opmode == QDF_P2P_GO_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004921 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004922
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304923 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004924 pe_session->peSessionId, pMacHdr->fc.subType));
Jeff Johnson99f25042018-11-21 22:49:06 -08004925 qdf_status = wma_tx_frame(mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004926 pPacket,
4927 (uint16_t) nBytes,
4928 TXRX_FRM_802_11_MGMT,
4929 ANI_TXDIR_TODS,
4930 7, lim_tx_complete, pFrame, txFlag,
Naveen Rawat296a5182017-09-25 14:02:48 -07004931 smeSessionId, 0, RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304932 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004933 pe_session->peSessionId, qdf_status));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304934 if (QDF_STATUS_SUCCESS != qdf_status) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004935 pe_err("wma_tx_frame FAILED! Status [%d]", qdf_status);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004936 nSirStatus = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004937 /* Pkt will be freed up by the callback */
4938 return nSirStatus;
4939 } else {
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004940 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004941 }
4942
4943returnAfterError:
4944 cds_packet_free((void *)pPacket);
4945 return nSirStatus;
4946} /* End lim_send_sa_query_response_frame */
4947#endif
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004948
Manjunathappa Prakash458f6fe2019-05-13 18:33:01 -07004949#if defined(QCA_WIFI_QCA6290) || defined(QCA_WIFI_QCA6390) || \
Alok Kumar2107a962020-01-13 15:35:29 +05304950 defined(QCA_WIFI_QCA6490) || defined(QCA_WIFI_QCA6750)
Jinwei Chen332b5cf2019-03-05 13:26:17 +08004951#ifdef WLAN_FEATURE_11AX
Kiran Kumar Lokere9d80ef62019-10-15 17:02:49 -07004952#define IS_PE_SESSION_HE_MODE(_session) ((_session)->he_capable)
Jinwei Chen332b5cf2019-03-05 13:26:17 +08004953#else
Kiran Kumar Lokere9d80ef62019-10-15 17:02:49 -07004954#define IS_PE_SESSION_HE_MODE(_session) false
Jinwei Chen332b5cf2019-03-05 13:26:17 +08004955#endif /* WLAN_FEATURE_11AX */
4956#else
Kiran Kumar Lokere9d80ef62019-10-15 17:02:49 -07004957#define IS_PE_SESSION_HE_MODE(_session) false
Jinwei Chen332b5cf2019-03-05 13:26:17 +08004958#endif
4959
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004960/**
4961 * lim_send_addba_response_frame(): Send ADDBA response action frame to peer
4962 * @mac_ctx: mac context
4963 * @peer_mac: Peer MAC address
4964 * @tid: TID for which addba response is being sent
4965 * @session: PE session entry
Kiran Kumar Lokere40875852018-01-15 12:36:19 -08004966 * @addba_extn_present: ADDBA extension present flag
Kiran Kumar Lokereaee823a2018-03-22 15:27:05 -07004967 * @amsdu_support: amsdu in ampdu support
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004968 *
4969 * This function is called when ADDBA request is successful. ADDBA response is
4970 * setup by calling addba_response_setup API and frame is then sent out OTA.
4971 *
4972 * Return: QDF_STATUS
4973 */
Jeff Johnson9320c1e2018-12-02 13:09:20 -08004974QDF_STATUS lim_send_addba_response_frame(struct mac_context *mac_ctx,
Kiran Kumar Lokere40875852018-01-15 12:36:19 -08004975 tSirMacAddr peer_mac, uint16_t tid,
Jeff Johnsona7815652018-11-18 22:58:30 -08004976 struct pe_session *session, uint8_t addba_extn_present,
Kiran Kumar Lokereaee823a2018-03-22 15:27:05 -07004977 uint8_t amsdu_support)
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004978{
4979
4980 tDot11faddba_rsp frm;
4981 uint8_t *frame_ptr;
4982 tpSirMacMgmtHdr mgmt_hdr;
4983 uint32_t num_bytes, payload_size, status;
Sandeep Puligilla39cec082018-04-30 15:18:45 -07004984 void *pkt_ptr = NULL;
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004985 QDF_STATUS qdf_status;
4986 uint8_t tx_flag = 0;
Abhishek Singhcc02c9b2019-11-25 14:51:30 +05304987 uint8_t vdev_id = 0;
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004988 uint16_t buff_size, status_code, batimeout;
gaurank kathpalia8197e352019-09-11 16:09:53 +05304989 uint8_t dialog_token;
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004990 void *soc = cds_get_context(QDF_MODULE_ID_SOC);
Kiran Kumar Lokere40875852018-01-15 12:36:19 -08004991 uint8_t he_frag = 0;
Yu Wang36d52102019-09-20 12:08:04 +08004992 tpDphHashNode sta_ds;
4993 uint16_t aid;
4994 bool he_cap = false;
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004995
Abhishek Singhcc02c9b2019-11-25 14:51:30 +05304996 vdev_id = session->vdev_id;
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004997
Vevek Venkatesan0ac759f2019-10-03 04:14:29 +05304998 cdp_addba_responsesetup(soc, peer_mac, vdev_id, tid,
4999 &dialog_token, &status_code, &buff_size,
5000 &batimeout);
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08005001
hangtian127c9532019-01-12 13:29:07 +08005002 qdf_mem_zero((uint8_t *) &frm, sizeof(frm));
Srinivas Girigowda48bec1c2019-05-17 16:33:30 -07005003 frm.Category.category = ACTION_CATEGORY_BACK;
Srinivas Girigowdaef0d7142019-05-17 17:07:47 -07005004 frm.Action.action = ADDBA_RESPONSE;
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08005005
5006 frm.DialogToken.token = dialog_token;
5007 frm.Status.status = status_code;
Kiran Kumar Lokere08195ef2018-01-17 19:25:15 -08005008 if (mac_ctx->reject_addba_req) {
5009 frm.Status.status = eSIR_MAC_REQ_DECLINED_STATUS;
5010 pe_err("refused addba req");
5011 }
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08005012 frm.addba_param_set.tid = tid;
Yu Wang36d52102019-09-20 12:08:04 +08005013
5014 if (lim_is_session_he_capable(session)) {
5015 sta_ds = dph_lookup_hash_entry(mac_ctx, peer_mac, &aid,
5016 &session->dph.dphHashTable);
5017 if (sta_ds)
5018 he_cap = lim_is_sta_he_capable(sta_ds);
5019 }
5020
5021 if (he_cap)
Kiran Kumar Lokere22f05d42019-06-28 18:33:43 -07005022 frm.addba_param_set.buff_size = MAX_BA_BUFF_SIZE;
5023 else
5024 frm.addba_param_set.buff_size = SIR_MAC_BA_DEFAULT_BUFF_SIZE;
Yu Wang36d52102019-09-20 12:08:04 +08005025
Kiran Kumar Lokerebc87bec2018-02-27 20:06:42 -08005026 if (mac_ctx->usr_cfg_ba_buff_size)
5027 frm.addba_param_set.buff_size = mac_ctx->usr_cfg_ba_buff_size;
Kiran Kumar Lokereeac7fe92018-07-24 16:56:01 -07005028
5029 if (frm.addba_param_set.buff_size > MAX_BA_BUFF_SIZE)
5030 frm.addba_param_set.buff_size = MAX_BA_BUFF_SIZE;
5031
5032 if (frm.addba_param_set.buff_size > SIR_MAC_BA_DEFAULT_BUFF_SIZE) {
5033 if (session->active_ba_64_session) {
5034 frm.addba_param_set.buff_size =
5035 SIR_MAC_BA_DEFAULT_BUFF_SIZE;
5036 }
5037 } else if (!session->active_ba_64_session) {
5038 session->active_ba_64_session = true;
5039 }
Jinwei Chen332b5cf2019-03-05 13:26:17 +08005040
Kiran Kumar Lokere9d80ef62019-10-15 17:02:49 -07005041 /* Enable RX AMSDU only in HE mode if supported */
Jinwei Chen332b5cf2019-03-05 13:26:17 +08005042 if (mac_ctx->is_usr_cfg_amsdu_enabled &&
Kiran Kumar Lokere9d80ef62019-10-15 17:02:49 -07005043 ((IS_PE_SESSION_HE_MODE(session) &&
5044 WLAN_REG_IS_24GHZ_CH_FREQ(session->curr_op_freq)) ||
5045 WLAN_REG_IS_5GHZ_CH_FREQ(session->curr_op_freq)))
Arif Hussain0e246802018-05-01 18:13:44 -07005046 frm.addba_param_set.amsdu_supp = amsdu_support;
5047 else
5048 frm.addba_param_set.amsdu_supp = 0;
Jinwei Chen332b5cf2019-03-05 13:26:17 +08005049
Kiran Kumar Lokerebc87bec2018-02-27 20:06:42 -08005050 frm.addba_param_set.policy = SIR_MAC_BA_POLICY_IMMEDIATE;
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08005051 frm.ba_timeout.timeout = batimeout;
Kiran Kumar Lokere40875852018-01-15 12:36:19 -08005052 if (addba_extn_present) {
5053 frm.addba_extn_element.present = 1;
5054 frm.addba_extn_element.no_fragmentation = 1;
5055 if (lim_is_session_he_capable(session)) {
5056 he_frag = lim_get_session_he_frag_cap(session);
5057 if (he_frag != 0) {
5058 frm.addba_extn_element.no_fragmentation = 0;
5059 frm.addba_extn_element.he_frag_operation =
5060 he_frag;
5061 }
5062 }
5063 }
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08005064
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07005065 pe_debug("Sending a ADDBA Response from %pM to %pM",
Pragaspathi Thilagaraj7fb14222019-06-17 23:26:58 +05305066 session->self_mac_addr, peer_mac);
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07005067 pe_debug("tid: %d, dialog_token: %d, status: %d, buff_size: %d",
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08005068 tid, frm.DialogToken.token, frm.Status.status,
5069 frm.addba_param_set.buff_size);
Kiran Kumar Lokere40875852018-01-15 12:36:19 -08005070 pe_debug("addba_extn %d he_capable %d no_frag %d he_frag %d",
5071 addba_extn_present,
5072 lim_is_session_he_capable(session),
5073 frm.addba_extn_element.no_fragmentation,
5074 frm.addba_extn_element.he_frag_operation);
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08005075
5076 status = dot11f_get_packed_addba_rsp_size(mac_ctx, &frm, &payload_size);
5077 if (DOT11F_FAILED(status)) {
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07005078 pe_err("Failed to calculate the packed size for a ADDBA Response (0x%08x).",
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08005079 status);
5080 /* We'll fall back on the worst case scenario: */
5081 payload_size = sizeof(tDot11faddba_rsp);
5082 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07005083 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 -08005084 }
5085
5086 num_bytes = payload_size + sizeof(*mgmt_hdr);
5087 qdf_status = cds_packet_alloc(num_bytes, (void **)&frame_ptr,
5088 (void **)&pkt_ptr);
Sandeep Puligilla39cec082018-04-30 15:18:45 -07005089 if (!QDF_IS_STATUS_SUCCESS(qdf_status) || (!pkt_ptr)) {
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07005090 pe_err("Failed to allocate %d bytes for a ADDBA response action frame",
5091 num_bytes);
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08005092 return QDF_STATUS_E_FAILURE;
5093 }
hangtian127c9532019-01-12 13:29:07 +08005094 qdf_mem_zero(frame_ptr, num_bytes);
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08005095
5096 lim_populate_mac_header(mac_ctx, frame_ptr, SIR_MAC_MGMT_FRAME,
Pragaspathi Thilagaraj7fb14222019-06-17 23:26:58 +05305097 SIR_MAC_MGMT_ACTION, peer_mac, session->self_mac_addr);
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08005098
5099 /* Update A3 with the BSSID */
5100 mgmt_hdr = (tpSirMacMgmtHdr) frame_ptr;
5101 sir_copy_mac_addr(mgmt_hdr->bssId, session->bssId);
5102
5103 /* ADDBA Response is a robust mgmt action frame,
5104 * set the "protect" (aka WEP) bit in the FC
5105 */
5106 lim_set_protected_bit(mac_ctx, session, peer_mac, mgmt_hdr);
5107
5108 status = dot11f_pack_addba_rsp(mac_ctx, &frm,
5109 frame_ptr + sizeof(tSirMacMgmtHdr), payload_size,
5110 &payload_size);
5111
5112 if (DOT11F_FAILED(status)) {
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07005113 pe_err("Failed to pack a ADDBA Response (0x%08x)",
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08005114 status);
5115 qdf_status = QDF_STATUS_E_FAILURE;
5116 goto error_addba_rsp;
5117 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07005118 pe_warn("There were warnings while packing ADDBA Response (0x%08x)",
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08005119 status);
5120 }
5121
5122
Liangwei Dong419d7302019-07-15 15:38:28 +08005123 if (wlan_reg_is_5ghz_ch_freq(session->curr_op_freq) ||
5124 session->opmode == QDF_P2P_CLIENT_MODE ||
5125 session->opmode == QDF_P2P_GO_MODE)
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08005126 tx_flag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08005127
5128 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
5129 session->peSessionId, mgmt_hdr->fc.subType));
Krunal Sonid2136c72018-06-01 17:26:39 -07005130 qdf_status = wma_tx_frameWithTxComplete(mac_ctx, pkt_ptr,
5131 (uint16_t)num_bytes,
5132 TXRX_FRM_802_11_MGMT,
5133 ANI_TXDIR_TODS, 7,
5134 NULL, frame_ptr,
5135 lim_addba_rsp_tx_complete_cnf,
Abhishek Singhcc02c9b2019-11-25 14:51:30 +05305136 tx_flag, vdev_id,
Krunal Sonid2136c72018-06-01 17:26:39 -07005137 false, 0, RATEID_DEFAULT);
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08005138 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
5139 session->peSessionId, qdf_status));
5140 if (QDF_STATUS_SUCCESS != qdf_status) {
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07005141 pe_err("wma_tx_frame FAILED! Status [%d]",
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08005142 qdf_status);
chenguo90c68462019-01-24 18:27:01 +08005143 return QDF_STATUS_E_FAILURE;
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08005144 } else {
Tushnim Bhattacharyyad58e4c92018-03-27 13:40:12 -07005145 return QDF_STATUS_SUCCESS;
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08005146 }
5147
5148error_addba_rsp:
5149 cds_packet_free((void *)pkt_ptr);
5150 return qdf_status;
5151}
Padma, Santhosh Kumar22c462c2018-01-16 17:56:44 +05305152
5153/**
5154 * lim_tx_mgmt_frame() - Transmits Auth mgmt frame
5155 * @mac_ctx Pointer to Global MAC structure
5156 * @mb_msg: Received message info
5157 * @msg_len: Received message length
5158 * @packet: Packet to be transmitted
5159 * @frame: Received frame
5160 *
5161 * Return: None
5162 */
Jeff Johnson9320c1e2018-12-02 13:09:20 -08005163static void lim_tx_mgmt_frame(struct mac_context *mac_ctx,
Padma, Santhosh Kumar22c462c2018-01-16 17:56:44 +05305164 struct sir_mgmt_msg *mb_msg, uint32_t msg_len,
5165 void *packet, uint8_t *frame)
5166{
5167 tpSirMacFrameCtl fc = (tpSirMacFrameCtl) mb_msg->data;
5168 QDF_STATUS qdf_status;
Abhishek Singhefe21e62019-09-20 10:03:24 +05305169 uint8_t vdev_id = 0;
Jeff Johnsona7815652018-11-18 22:58:30 -08005170 struct pe_session *session;
Padma, Santhosh Kumar22c462c2018-01-16 17:56:44 +05305171 uint16_t auth_ack_status;
5172 enum rateid min_rid = RATEID_DEFAULT;
5173
Abhishek Singh345be412019-11-19 10:59:29 +05305174 vdev_id = mb_msg->vdev_id;
Abhishek Singhefe21e62019-09-20 10:03:24 +05305175 session = pe_find_session_by_vdev_id(mac_ctx, vdev_id);
Jeff Johnson8e9530b2019-03-18 13:41:42 -07005176 if (!session) {
Wu Gao7c0a23f2019-03-12 14:16:37 +08005177 cds_packet_free((void *)packet);
Abhishek Singhefe21e62019-09-20 10:03:24 +05305178 pe_err("session not found for given vdev_id %d",
5179 vdev_id);
Padma, Santhosh Kumar22c462c2018-01-16 17:56:44 +05305180 return;
5181 }
5182
Ashish Kumar Dhanotiya9f72df02018-07-23 19:20:04 +05305183 qdf_mtrace(QDF_MODULE_ID_PE, QDF_MODULE_ID_WMA, TRACE_CODE_TX_MGMT,
5184 session->peSessionId, 0);
Padma, Santhosh Kumar22c462c2018-01-16 17:56:44 +05305185
5186 mac_ctx->auth_ack_status = LIM_AUTH_ACK_NOT_RCD;
5187 min_rid = lim_get_min_session_txrate(session);
5188
5189 qdf_status = wma_tx_frameWithTxComplete(mac_ctx, packet,
5190 (uint16_t)msg_len,
5191 TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS,
5192 7, lim_tx_complete, frame,
5193 lim_auth_tx_complete_cnf,
Abhishek Singhefe21e62019-09-20 10:03:24 +05305194 0, vdev_id, false, 0, min_rid);
Padma, Santhosh Kumar22c462c2018-01-16 17:56:44 +05305195 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
5196 session->peSessionId, qdf_status));
5197 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Rachit Kankane0baf6e72018-01-19 15:01:50 +05305198 pe_err("*** Could not send Auth frame (subType: %d), retCode=%X ***",
5199 fc->subType, qdf_status);
Padma, Santhosh Kumar22c462c2018-01-16 17:56:44 +05305200 mac_ctx->auth_ack_status = LIM_AUTH_ACK_RCD_FAILURE;
5201 auth_ack_status = SENT_FAIL;
5202 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_AUTH_ACK_EVENT,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07005203 session, auth_ack_status, QDF_STATUS_E_FAILURE);
Padma, Santhosh Kumar22c462c2018-01-16 17:56:44 +05305204 /* Pkt will be freed up by the callback */
5205 }
5206}
5207
Jeff Johnson9320c1e2018-12-02 13:09:20 -08005208void lim_send_mgmt_frame_tx(struct mac_context *mac_ctx,
Padma, Santhosh Kumar22c462c2018-01-16 17:56:44 +05305209 struct scheduler_msg *msg)
5210{
5211 struct sir_mgmt_msg *mb_msg = (struct sir_mgmt_msg *)msg->bodyptr;
5212 uint32_t msg_len;
5213 tpSirMacFrameCtl fc = (tpSirMacFrameCtl) mb_msg->data;
Abhishek Singh345be412019-11-19 10:59:29 +05305214 uint8_t vdev_id;
Padma, Santhosh Kumar22c462c2018-01-16 17:56:44 +05305215 QDF_STATUS qdf_status;
5216 uint8_t *frame;
5217 void *packet;
Srinivas Dasari76218492019-01-22 15:08:20 +05305218 tpSirMacMgmtHdr mac_hdr;
Padma, Santhosh Kumar22c462c2018-01-16 17:56:44 +05305219
5220 msg_len = mb_msg->msg_len - sizeof(*mb_msg);
5221 pe_debug("sending fc->type: %d fc->subType: %d",
5222 fc->type, fc->subType);
5223
Abhishek Singh345be412019-11-19 10:59:29 +05305224 vdev_id = mb_msg->vdev_id;
Srinivas Dasari76218492019-01-22 15:08:20 +05305225 mac_hdr = (tpSirMacMgmtHdr)mb_msg->data;
5226
5227 lim_add_mgmt_seq_num(mac_ctx, mac_hdr);
Padma, Santhosh Kumar22c462c2018-01-16 17:56:44 +05305228
5229 qdf_status = cds_packet_alloc((uint16_t) msg_len, (void **)&frame,
5230 (void **)&packet);
5231 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
5232 pe_err("call to bufAlloc failed for AUTH frame");
5233 return;
5234 }
5235
5236 qdf_mem_copy(frame, mb_msg->data, msg_len);
5237
5238 lim_tx_mgmt_frame(mac_ctx, mb_msg, msg_len, packet, frame);
5239}