blob: 0559316839cac99b1a1375b9c6aab228d18bbfff [file] [log] [blame]
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001/*
Rajasekaran Kalidoss7152a352018-11-19 09:58:35 +05302 * Copyright (c) 2011-2019 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;
185 uint8_t sme_sessionid = 0;
186 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;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800193
Arif Hussain4c265132018-04-23 18:55:26 -0700194 if (additional_ielen)
195 addn_ielen = *additional_ielen;
196
Jeff Johnson919f2c32019-01-16 11:22:24 -0800197 /*
198 * The probe req should not send 11ac capabilities if band is
199 * 2.4GHz, unless gEnableVhtFor24GHzBand is enabled in INI. So
200 * if gEnableVhtFor24GHzBand is false and dot11mode is 11ac
201 * set it to 11n.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800202 */
203 if (channel <= SIR_11B_CHANNEL_END &&
Abhinav Kumare057b412018-10-09 17:28:16 +0530204 !mac_ctx->mlme_cfg->vht_caps.vht_cap_info.b24ghz_band &&
gaurank kathpalia0c48d3d2019-01-29 15:03:07 +0530205 (MLME_DOT11_MODE_11AC == dot11mode ||
206 MLME_DOT11_MODE_11AC_ONLY == dot11mode))
207 dot11mode = MLME_DOT11_MODE_11N;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800208 /*
209 * session context may or may not be present, when probe request needs
210 * to be sent out. Following cases exist:
211 * --heartbeat failure: session needed
212 * --join req: session needed
213 * --foreground scan: no session
214 * --background scan: no session
215 * --sch_beacon_processing: to get EDCA parameters: session needed
216 * If session context does not exist, some IEs will be populated from
217 * CFGs, e.g. Supported and Extended rate set IEs
218 */
219 pesession = pe_find_session_by_bssid(mac_ctx, bssid, &sessionid);
220
Jeff Johnson8e9530b2019-03-18 13:41:42 -0700221 if (pesession)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800222 sme_sessionid = pesession->smeSessionId;
223
224 /* The scheme here is to fill out a 'tDot11fProbeRequest' structure */
225 /* and then hand it off to 'dot11f_pack_probe_request' (for */
226 /* serialization). We start by zero-initializing the structure: */
hangtian127c9532019-01-12 13:29:07 +0800227 qdf_mem_zero((uint8_t *) &pr, sizeof(pr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800228
229 /* & delegating to assorted helpers: */
230 populate_dot11f_ssid(mac_ctx, ssid, &pr.SSID);
231
232 if (addn_ielen && additional_ie)
233 p2pie = limGetP2pIEPtr(mac_ctx, additional_ie, addn_ielen);
234
235 /*
236 * Don't include 11b rate if it is a P2P serach or probe request is
237 * sent by P2P Client
238 */
Jeff Johnson8e9530b2019-03-18 13:41:42 -0700239 if ((MLME_DOT11_MODE_11B != dot11mode) && (p2pie) &&
Pragaspathi Thilagaraje64714a2019-05-23 00:46:25 +0530240 ((pesession) && (QDF_P2P_CLIENT_MODE == pesession->opmode))) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800241 /*
242 * In the below API pass channel number > 14, do that it fills
243 * only 11a rates in supported rates
244 */
245 populate_dot11f_supp_rates(mac_ctx, 15, &pr.SuppRates,
246 pesession);
247 } else {
248 populate_dot11f_supp_rates(mac_ctx, channel,
249 &pr.SuppRates, pesession);
250
gaurank kathpalia0c48d3d2019-01-29 15:03:07 +0530251 if (MLME_DOT11_MODE_11B != dot11mode) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800252 populate_dot11f_ext_supp_rates1(mac_ctx, channel,
253 &pr.ExtSuppRates);
254 }
255 }
256
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800257 /*
258 * Table 7-14 in IEEE Std. 802.11k-2008 says
259 * DS params "can" be present in RRM is disabled and "is" present if
260 * RRM is enabled. It should be ok even if we add it into probe req when
261 * RRM is not enabled.
262 */
263 populate_dot11f_ds_params(mac_ctx, &pr.DSParams, channel);
264 /* Call RRM module to get the tx power for management used. */
265 txPower = (uint8_t) rrm_get_mgmt_tx_power(mac_ctx, pesession);
266 populate_dot11f_wfatpc(mac_ctx, &pr.WFATPC, txPower, 0);
267
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800268
Jeff Johnson8e9530b2019-03-18 13:41:42 -0700269 if (pesession) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800270 pesession->htCapability = IS_DOT11_MODE_HT(dot11mode);
271 /* Include HT Capability IE */
272 if (pesession->htCapability)
273 populate_dot11f_ht_caps(mac_ctx, pesession, &pr.HTCaps);
Jeff Johnson8e9530b2019-03-18 13:41:42 -0700274 } else { /* !pesession */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800275 if (IS_DOT11_MODE_HT(dot11mode))
276 populate_dot11f_ht_caps(mac_ctx, NULL, &pr.HTCaps);
277 }
278
279 /*
280 * Set channelbonding information as "disabled" when tunned to a
281 * 2.4 GHz channel
282 */
283 if (channel <= SIR_11B_CHANNEL_END) {
284 if (mac_ctx->roam.configParam.channelBondingMode24GHz
285 == PHY_SINGLE_CHANNEL_CENTERED) {
286 pr.HTCaps.supportedChannelWidthSet =
287 eHT_CHANNEL_WIDTH_20MHZ;
288 pr.HTCaps.shortGI40MHz = 0;
289 } else {
290 pr.HTCaps.supportedChannelWidthSet =
291 eHT_CHANNEL_WIDTH_40MHZ;
292 }
293 }
Jeff Johnson8e9530b2019-03-18 13:41:42 -0700294 if (pesession) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800295 pesession->vhtCapability = IS_DOT11_MODE_VHT(dot11mode);
296 /* Include VHT Capability IE */
297 if (pesession->vhtCapability) {
298 populate_dot11f_vht_caps(mac_ctx, pesession,
299 &pr.VHTCaps);
300 is_vht_enabled = true;
301 }
302 } else {
303 if (IS_DOT11_MODE_VHT(dot11mode)) {
304 populate_dot11f_vht_caps(mac_ctx, pesession,
305 &pr.VHTCaps);
306 is_vht_enabled = true;
307 }
308 }
Jeff Johnson8e9530b2019-03-18 13:41:42 -0700309 if (pesession)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800310 populate_dot11f_ext_cap(mac_ctx, is_vht_enabled, &pr.ExtCap,
311 pesession);
312
Jeff Johnson8e9530b2019-03-18 13:41:42 -0700313 if (IS_DOT11_MODE_HE(dot11mode) && pesession)
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -0800314 lim_update_session_he_capable(mac_ctx, pesession);
315
Srinivas Girigowda28fb0122017-03-26 22:21:20 -0700316 pe_debug("Populate HE IEs");
Naveen Rawatd8feac12017-09-08 15:08:39 -0700317 populate_dot11f_he_caps(mac_ctx, pesession, &pr.he_cap);
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -0800318
Sandeep Puligilla493fea22018-04-30 15:31:17 -0700319 if (addn_ielen && additional_ie) {
Kapil Guptac03eb072016-08-09 14:01:36 +0530320 qdf_mem_zero((uint8_t *)&extracted_ext_cap,
321 sizeof(tDot11fIEExtCap));
322 sir_status = lim_strip_extcap_update_struct(mac_ctx,
323 additional_ie,
324 &addn_ielen,
325 &extracted_ext_cap);
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700326 if (QDF_STATUS_SUCCESS != sir_status) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700327 pe_debug("Unable to Stripoff ExtCap IE from Probe Req");
Kapil Guptac03eb072016-08-09 14:01:36 +0530328 } else {
329 struct s_ext_cap *p_ext_cap =
330 (struct s_ext_cap *)
331 extracted_ext_cap.bytes;
332 if (p_ext_cap->interworking_service)
333 p_ext_cap->qos_map = 1;
Hu Wang411e0cc2016-10-28 14:56:01 +0800334 extracted_ext_cap.num_bytes =
335 lim_compute_ext_cap_ie_length
336 (&extracted_ext_cap);
Kapil Guptac03eb072016-08-09 14:01:36 +0530337 extracted_ext_cap_flag =
Hu Wang411e0cc2016-10-28 14:56:01 +0800338 (extracted_ext_cap.num_bytes > 0);
Arif Hussain4c265132018-04-23 18:55:26 -0700339 if (additional_ielen)
340 *additional_ielen = addn_ielen;
Kapil Guptac03eb072016-08-09 14:01:36 +0530341 }
Abhishek Singh67e02bd2017-12-11 10:47:12 +0530342 qcn_ie = wlan_get_vendor_ie_ptr_from_oui(SIR_MAC_QCN_OUI_TYPE,
343 SIR_MAC_QCN_OUI_TYPE_SIZE,
344 additional_ie, addn_ielen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800345 }
Abhishek Singh67e02bd2017-12-11 10:47:12 +0530346 /* Add qcn_ie only if qcn ie is not present in additional_ie */
Kiran Kumar Lokere89f01f02019-08-06 18:22:39 -0700347 if (!qcn_ie)
348 populate_dot11f_qcn_ie(mac_ctx, &pr.qcn_ie, QCN_IE_ATTR_ID_ALL);
349 else
350 populate_dot11f_qcn_ie(mac_ctx, &pr.qcn_ie,
351 QCN_IE_ATTR_ID_VHT_MCS11);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800352
Hu Wang411e0cc2016-10-28 14:56:01 +0800353 /*
354 * Extcap IE now support variable length, merge Extcap IE from addn_ie
355 * may change the frame size. Therefore, MUST merge ExtCap IE before
356 * dot11f get packed payload size.
357 */
358 if (extracted_ext_cap_flag)
Hu Wangfbd279d2016-10-31 18:24:34 +0800359 lim_merge_extcap_struct(&pr.ExtCap, &extracted_ext_cap, true);
Hu Wang411e0cc2016-10-28 14:56:01 +0800360
361 /* That's it-- now we pack it. First, how much space are we going to */
362 status = dot11f_get_packed_probe_request_size(mac_ctx, &pr, &payload);
363 if (DOT11F_FAILED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700364 pe_err("Failed to calculate the packed size for a Probe Request (0x%08x)",
Hu Wang411e0cc2016-10-28 14:56:01 +0800365 status);
366 /* We'll fall back on the worst case scenario: */
367 payload = sizeof(tDot11fProbeRequest);
368 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700369 pe_warn("There were warnings while calculating the packed size for a Probe Request (0x%08x)",
Hu Wang411e0cc2016-10-28 14:56:01 +0800370 status);
371 }
372
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800373 bytes = payload + sizeof(tSirMacMgmtHdr) + addn_ielen;
374
375 /* Ok-- try to allocate some memory: */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530376 qdf_status = cds_packet_alloc((uint16_t) bytes, (void **)&frame,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800377 (void **)&packet);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530378 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700379 pe_err("Failed to allocate %d bytes for a Probe Request", bytes);
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700380 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800381 }
382 /* Paranoia: */
hangtian127c9532019-01-12 13:29:07 +0800383 qdf_mem_zero(frame, bytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800384
385 /* Next, we fill out the buffer descriptor: */
386 lim_populate_mac_header(mac_ctx, frame, SIR_MAC_MGMT_FRAME,
387 SIR_MAC_MGMT_PROBE_REQ, bssid, self_macaddr);
388
389 /* That done, pack the Probe Request: */
390 status = dot11f_pack_probe_request(mac_ctx, &pr, frame +
391 sizeof(tSirMacMgmtHdr),
392 payload, &payload);
393 if (DOT11F_FAILED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700394 pe_err("Failed to pack a Probe Request (0x%08x)", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800395 cds_packet_free((void *)packet);
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700396 return QDF_STATUS_E_FAILURE; /* allocated! */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800397 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700398 pe_warn("There were warnings while packing a Probe Request (0x%08x)", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800399 }
400 /* Append any AddIE if present. */
401 if (addn_ielen) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530402 qdf_mem_copy(frame + sizeof(tSirMacMgmtHdr) + payload,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800403 additional_ie, addn_ielen);
404 payload += addn_ielen;
405 }
406
407 /* If this probe request is sent during P2P Search State, then we need
408 * to send it at OFDM rate.
409 */
Abhishek Singh221cf992018-02-22 13:44:53 +0530410 if ((BAND_5G == lim_get_rf_band(channel)) ||
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800411 /*
412 * For unicast probe req mgmt from Join function we don't set
413 * above variables. So we need to add one more check whether it
Pragaspathi Thilagaraje64714a2019-05-23 00:46:25 +0530414 * is opmode is P2P_CLIENT or not
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800415 */
Pragaspathi Thilagaraje64714a2019-05-23 00:46:25 +0530416 ((pesession) && (QDF_P2P_CLIENT_MODE == pesession->opmode)))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800417 txflag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800418
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530419 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800420 wma_tx_frame(mac_ctx, packet,
421 (uint16_t) sizeof(tSirMacMgmtHdr) + payload,
422 TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS, 7,
423 lim_tx_complete, frame, txflag, sme_sessionid,
Naveen Rawat296a5182017-09-25 14:02:48 -0700424 0, RATEID_DEFAULT);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530425 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700426 pe_err("could not send Probe Request frame!");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800427 /* Pkt will be freed up by the callback */
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700428 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800429 }
430
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700431 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800432} /* End lim_send_probe_req_mgmt_frame. */
433
Jeff Johnson9320c1e2018-12-02 13:09:20 -0800434static QDF_STATUS lim_get_addn_ie_for_probe_resp(struct mac_context *mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800435 uint8_t *addIE, uint16_t *addnIELen,
436 uint8_t probeReqP2pIe)
437{
438 /* If Probe request doesn't have P2P IE, then take out P2P IE
439 from additional IE */
440 if (!probeReqP2pIe) {
441 uint8_t *tempbuf = NULL;
442 uint16_t tempLen = 0;
443 int left = *addnIELen;
444 uint8_t *ptr = addIE;
445 uint8_t elem_id, elem_len;
446
Jeff Johnson8e9530b2019-03-18 13:41:42 -0700447 if (!addIE) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700448 pe_err("NULL addIE pointer");
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700449 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800450 }
451
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530452 tempbuf = qdf_mem_malloc(left);
Arif Hussainf5b6c412018-10-10 19:41:09 -0700453 if (!tempbuf)
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700454 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800455
456 while (left >= 2) {
457 elem_id = ptr[0];
458 elem_len = ptr[1];
459 left -= 2;
460 if (elem_len > left) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700461 pe_err("Invalid IEs eid: %d elem_len: %d left: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800462 elem_id, elem_len, left);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530463 qdf_mem_free(tempbuf);
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700464 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800465 }
Srinivas Girigowda61771262019-04-01 11:55:19 -0700466 if (!((WLAN_ELEMID_VENDOR == elem_id) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800467 (memcmp
468 (&ptr[2], SIR_MAC_P2P_OUI,
469 SIR_MAC_P2P_OUI_SIZE) == 0))) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530470 qdf_mem_copy(tempbuf + tempLen, &ptr[0],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800471 elem_len + 2);
472 tempLen += (elem_len + 2);
473 }
474 left -= elem_len;
475 ptr += (elem_len + 2);
476 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530477 qdf_mem_copy(addIE, tempbuf, tempLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800478 *addnIELen = tempLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530479 qdf_mem_free(tempbuf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800480 }
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700481 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800482}
483
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800484void
Jeff Johnson9320c1e2018-12-02 13:09:20 -0800485lim_send_probe_rsp_mgmt_frame(struct mac_context *mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800486 tSirMacAddr peer_macaddr,
487 tpAniSSID ssid,
Jeff Johnson3c08ace2019-03-12 08:50:37 -0700488 struct pe_session *pe_session,
489 uint8_t preq_p2pie)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800490{
491 tDot11fProbeResponse *frm;
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700492 QDF_STATUS sir_status;
Hu Wang411e0cc2016-10-28 14:56:01 +0800493 uint32_t cfg, payload, bytes = 0, status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800494 tpSirMacMgmtHdr mac_hdr;
495 uint8_t *frame;
Arif Hussainfbf50682016-06-15 12:57:43 -0700496 void *packet = NULL;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530497 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800498 uint32_t addn_ie_present = false;
499
500 uint16_t addn_ie_len = 0;
gaurank kathpalia837f6202018-09-14 21:55:32 +0530501 bool wps_ap = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800502 uint8_t tx_flag = 0;
503 uint8_t *add_ie = NULL;
Naveen Rawat08db88f2017-09-08 15:07:48 -0700504 const uint8_t *p2p_ie = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800505 uint8_t noalen = 0;
506 uint8_t total_noalen = 0;
507 uint8_t noa_stream[SIR_MAX_NOA_ATTR_LEN + SIR_P2P_IE_HEADER_LEN];
508 uint8_t noa_ie[SIR_MAX_NOA_ATTR_LEN + SIR_P2P_IE_HEADER_LEN];
509 uint8_t sme_sessionid = 0;
510 bool is_vht_enabled = false;
Padma, Santhosh Kumar92234472017-04-19 18:20:02 +0530511 tDot11fIEExtCap extracted_ext_cap = {0};
Selvaraj, Sridhar94ece202016-06-23 20:44:09 +0530512 bool extracted_ext_cap_flag = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800513
514 /* We don't answer requests in this case*/
Srinivas Girigowda35b00312017-06-27 21:52:03 -0700515 if (ANI_DRIVER_TYPE(mac_ctx) == QDF_DRIVER_TYPE_MFG)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800516 return;
517
Jeff Johnson8e9530b2019-03-18 13:41:42 -0700518 if (!pe_session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800519 return;
520
521 /*
522 * In case when cac timer is running for this SAP session then
523 * avoid sending probe rsp out. It is violation of dfs specification.
524 */
Pragaspathi Thilagaraje64714a2019-05-23 00:46:25 +0530525 if (((pe_session->opmode == QDF_SAP_MODE) ||
526 (pe_session->opmode == QDF_P2P_GO_MODE)) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800527 (true == mac_ctx->sap.SapDfsInfo.is_dfs_cac_timer_running)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530528 QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_INFO,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800529 FL("CAC timer is running, probe response dropped"));
530 return;
531 }
532 sme_sessionid = pe_session->smeSessionId;
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530533 frm = qdf_mem_malloc(sizeof(tDot11fProbeResponse));
Arif Hussainf5b6c412018-10-10 19:41:09 -0700534 if (!frm)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800535 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800536
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800537 /*
538 * Fill out 'frm', after which we'll just hand the struct off to
539 * 'dot11f_pack_probe_response'.
540 */
hangtian127c9532019-01-12 13:29:07 +0800541 qdf_mem_zero((uint8_t *) frm, sizeof(tDot11fProbeResponse));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800542
543 /*
544 * Timestamp to be updated by TFP, below.
545 *
546 * Beacon Interval:
547 */
548 if (LIM_IS_AP_ROLE(pe_session)) {
549 frm->BeaconInterval.interval =
Jeff Johnsonac057412019-01-06 11:08:55 -0800550 mac_ctx->sch.beacon_interval;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800551 } else {
Bala Venkatesh2fde2c62018-09-11 20:33:24 +0530552 cfg = mac_ctx->mlme_cfg->sap_cfg.beacon_interval;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800553 frm->BeaconInterval.interval = (uint16_t) cfg;
554 }
555
556 populate_dot11f_capabilities(mac_ctx, &frm->Capabilities, pe_session);
557 populate_dot11f_ssid(mac_ctx, (tSirMacSSid *) ssid, &frm->SSID);
558 populate_dot11f_supp_rates(mac_ctx, POPULATE_DOT11F_RATES_OPERATIONAL,
559 &frm->SuppRates, pe_session);
560
Liangwei Dong419d7302019-07-15 15:38:28 +0800561 populate_dot11f_ds_params(
562 mac_ctx, &frm->DSParams,
563 wlan_reg_freq_to_chan(mac_ctx->pdev,
564 pe_session->curr_op_freq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800565 populate_dot11f_ibss_params(mac_ctx, &frm->IBSSParams, pe_session);
566
567 if (LIM_IS_AP_ROLE(pe_session)) {
568 if (pe_session->wps_state != SAP_WPS_DISABLED)
569 populate_dot11f_probe_res_wpsi_es(mac_ctx,
570 &frm->WscProbeRes,
571 pe_session);
572 } else {
gaurank kathpalia837f6202018-09-14 21:55:32 +0530573 wps_ap = mac_ctx->mlme_cfg->wps_params.enable_wps &
574 WNI_CFG_WPS_ENABLE_AP;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800575 if (wps_ap)
576 populate_dot11f_wsc_in_probe_res(mac_ctx,
577 &frm->WscProbeRes);
578
579 if (mac_ctx->lim.wscIeInfo.probeRespWscEnrollmentState ==
580 eLIM_WSC_ENROLL_BEGIN) {
581 populate_dot11f_wsc_registrar_info_in_probe_res(mac_ctx,
582 &frm->WscProbeRes);
583 mac_ctx->lim.wscIeInfo.probeRespWscEnrollmentState =
584 eLIM_WSC_ENROLL_IN_PROGRESS;
585 }
586
587 if (mac_ctx->lim.wscIeInfo.wscEnrollmentState ==
588 eLIM_WSC_ENROLL_END) {
589 de_populate_dot11f_wsc_registrar_info_in_probe_res(
590 mac_ctx, &frm->WscProbeRes);
591 mac_ctx->lim.wscIeInfo.probeRespWscEnrollmentState =
592 eLIM_WSC_ENROLL_NOOP;
593 }
594 }
595
596 populate_dot11f_country(mac_ctx, &frm->Country, pe_session);
597 populate_dot11f_edca_param_set(mac_ctx, &frm->EDCAParamSet, pe_session);
598
gaurank kathpalia0c48d3d2019-01-29 15:03:07 +0530599 if (pe_session->dot11mode != MLME_DOT11_MODE_11B)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800600 populate_dot11f_erp_info(mac_ctx, &frm->ERPInfo, pe_session);
601
602 populate_dot11f_ext_supp_rates(mac_ctx,
603 POPULATE_DOT11F_RATES_OPERATIONAL,
604 &frm->ExtSuppRates, pe_session);
605
606 /* Populate HT IEs, when operating in 11n */
607 if (pe_session->htCapability) {
608 populate_dot11f_ht_caps(mac_ctx, pe_session, &frm->HTCaps);
609 populate_dot11f_ht_info(mac_ctx, &frm->HTInfo, pe_session);
610 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800611 if (pe_session->vhtCapability) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700612 pe_debug("Populate VHT IE in Probe Response");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800613 populate_dot11f_vht_caps(mac_ctx, pe_session, &frm->VHTCaps);
614 populate_dot11f_vht_operation(mac_ctx, pe_session,
615 &frm->VHTOperation);
616 /*
617 * we do not support multi users yet.
618 * populate_dot11f_vht_ext_bss_load( mac_ctx,
619 * &frm.VHTExtBssLoad );
620 */
621 is_vht_enabled = true;
622 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800623
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -0800624 if (lim_is_session_he_capable(pe_session)) {
Srinivas Girigowda28fb0122017-03-26 22:21:20 -0700625 pe_debug("Populate HE IEs");
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -0800626 populate_dot11f_he_caps(mac_ctx, pe_session,
Naveen Rawatd8feac12017-09-08 15:08:39 -0700627 &frm->he_cap);
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -0800628 populate_dot11f_he_operation(mac_ctx, pe_session,
Naveen Rawatd8feac12017-09-08 15:08:39 -0700629 &frm->he_op);
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -0800630 }
631
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800632 populate_dot11f_ext_cap(mac_ctx, is_vht_enabled, &frm->ExtCap,
633 pe_session);
634
635 if (pe_session->pLimStartBssReq) {
636 populate_dot11f_wpa(mac_ctx,
637 &(pe_session->pLimStartBssReq->rsnIE),
638 &frm->WPA);
639 populate_dot11f_rsn_opaque(mac_ctx,
640 &(pe_session->pLimStartBssReq->rsnIE),
641 &frm->RSNOpaque);
642 }
643
644 populate_dot11f_wmm(mac_ctx, &frm->WMMInfoAp, &frm->WMMParams,
645 &frm->WMMCaps, pe_session);
646
647#if defined(FEATURE_WLAN_WAPI)
648 if (pe_session->pLimStartBssReq)
649 populate_dot11f_wapi(mac_ctx,
650 &(pe_session->pLimStartBssReq->rsnIE),
651 &frm->WAPI);
652#endif /* defined(FEATURE_WLAN_WAPI) */
653
Liangwei Dongd7c5e012018-12-16 23:56:50 -0500654 /*
655 * Only use CFG for non-listen mode. This CFG is not working for
656 * concurrency. In listening mode, probe rsp IEs is passed in
657 * the message from SME to PE.
658 */
659 addn_ie_present =
Jeff Johnson21aac3a2019-02-02 14:26:13 -0800660 (pe_session->add_ie_params.probeRespDataLen != 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800661
662 if (addn_ie_present) {
663
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530664 add_ie = qdf_mem_malloc(
Jeff Johnson21aac3a2019-02-02 14:26:13 -0800665 pe_session->add_ie_params.probeRespDataLen);
Arif Hussainf5b6c412018-10-10 19:41:09 -0700666 if (!add_ie)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800667 goto err_ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800668
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530669 qdf_mem_copy(add_ie,
Jeff Johnson21aac3a2019-02-02 14:26:13 -0800670 pe_session->add_ie_params.probeRespData_buff,
671 pe_session->add_ie_params.probeRespDataLen);
672 addn_ie_len = pe_session->add_ie_params.probeRespDataLen;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800673
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700674 if (QDF_STATUS_SUCCESS != lim_get_addn_ie_for_probe_resp(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800675 add_ie, &addn_ie_len, preq_p2pie)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700676 pe_err("Unable to get addn_ie");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800677 goto err_ret;
678 }
679
680 sir_status = lim_strip_extcap_update_struct(mac_ctx,
681 add_ie, &addn_ie_len,
682 &extracted_ext_cap);
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700683 if (QDF_STATUS_SUCCESS != sir_status) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700684 pe_debug("Unable to strip off ExtCap IE");
Selvaraj, Sridhar94ece202016-06-23 20:44:09 +0530685 } else {
686 extracted_ext_cap_flag = true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800687 }
688
689 bytes = bytes + addn_ie_len;
690
691 if (preq_p2pie)
692 p2p_ie = limGetP2pIEPtr(mac_ctx, &add_ie[0],
693 addn_ie_len);
694
Jeff Johnson8e9530b2019-03-18 13:41:42 -0700695 if (p2p_ie) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800696 /* get NoA attribute stream P2P IE */
697 noalen = lim_get_noa_attr_stream(mac_ctx,
698 noa_stream, pe_session);
699 if (noalen != 0) {
700 total_noalen =
701 lim_build_p2p_ie(mac_ctx, &noa_ie[0],
702 &noa_stream[0], noalen);
703 bytes = bytes + total_noalen;
704 }
705 }
706 }
707
Hu Wang411e0cc2016-10-28 14:56:01 +0800708 /*
709 * Extcap IE now support variable length, merge Extcap IE from addn_ie
710 * may change the frame size. Therefore, MUST merge ExtCap IE before
711 * dot11f get packed payload size.
712 */
713 if (extracted_ext_cap_flag)
Hu Wangfbd279d2016-10-31 18:24:34 +0800714 lim_merge_extcap_struct(&frm->ExtCap, &extracted_ext_cap,
715 true);
Hu Wang411e0cc2016-10-28 14:56:01 +0800716
717 status = dot11f_get_packed_probe_response_size(mac_ctx, frm, &payload);
718 if (DOT11F_FAILED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700719 pe_err("Probe Response size error (0x%08x)",
Hu Wang411e0cc2016-10-28 14:56:01 +0800720 status);
721 /* We'll fall back on the worst case scenario: */
722 payload = sizeof(tDot11fProbeResponse);
723 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700724 pe_warn("Probe Response size warning (0x%08x)",
Hu Wang411e0cc2016-10-28 14:56:01 +0800725 status);
726 }
727
728 bytes += payload + sizeof(tSirMacMgmtHdr);
729
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530730 qdf_status = cds_packet_alloc((uint16_t) bytes, (void **)&frame,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800731 (void **)&packet);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530732 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700733 pe_err("Probe Response allocation failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800734 goto err_ret;
735 }
736 /* Paranoia: */
hangtian127c9532019-01-12 13:29:07 +0800737 qdf_mem_zero(frame, bytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800738
739 /* Next, we fill out the buffer descriptor: */
740 lim_populate_mac_header(mac_ctx, frame, SIR_MAC_MGMT_FRAME,
741 SIR_MAC_MGMT_PROBE_RSP, peer_macaddr,
Pragaspathi Thilagaraj7fb14222019-06-17 23:26:58 +0530742 pe_session->self_mac_addr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800743
744 mac_hdr = (tpSirMacMgmtHdr) frame;
745
746 sir_copy_mac_addr(mac_hdr->bssId, pe_session->bssId);
747
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800748 /* That done, pack the Probe Response: */
749 status =
750 dot11f_pack_probe_response(mac_ctx, frm,
751 frame + sizeof(tSirMacMgmtHdr),
752 payload, &payload);
753 if (DOT11F_FAILED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700754 pe_err("Probe Response pack failure (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800755 status);
756 goto err_ret;
757 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700758 pe_warn("Probe Response pack warning (0x%08x)", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800759 }
760
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700761 pe_debug("Sending Probe Response frame to");
Nishank Aggarwal46bd31a2017-03-10 16:23:53 +0530762 lim_print_mac_addr(mac_ctx, peer_macaddr, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800763
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800764 if (addn_ie_present)
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530765 qdf_mem_copy(frame + sizeof(tSirMacMgmtHdr) + payload,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800766 &add_ie[0], addn_ie_len);
767
768 if (noalen != 0) {
769 if (total_noalen >
770 (SIR_MAX_NOA_ATTR_LEN + SIR_P2P_IE_HEADER_LEN)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700771 pe_err("Not able to insert NoA, total len=%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800772 total_noalen);
773 goto err_ret;
774 } else {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530775 qdf_mem_copy(&frame[bytes - (total_noalen)],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800776 &noa_ie[0], total_noalen);
777 }
778 }
779
Liangwei Dong419d7302019-07-15 15:38:28 +0800780 if (wlan_reg_is_5ghz_ch_freq(pe_session->curr_op_freq) ||
781 pe_session->opmode == QDF_P2P_CLIENT_MODE ||
782 pe_session->opmode == QDF_P2P_GO_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800783 tx_flag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
784
785 /* Queue Probe Response frame in high priority WQ */
Jeff Johnson59429b02018-11-07 13:53:18 -0800786 qdf_status = wma_tx_frame(mac_ctx, packet,
787 (uint16_t)bytes,
788 TXRX_FRM_802_11_MGMT,
789 ANI_TXDIR_TODS,
790 7, lim_tx_complete, frame, tx_flag,
791 sme_sessionid, 0, RATEID_DEFAULT);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800792
793 /* Pkt will be freed up by the callback */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530794 if (!QDF_IS_STATUS_SUCCESS(qdf_status))
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700795 pe_err("Could not send Probe Response");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800796
Jeff Johnson8e9530b2019-03-18 13:41:42 -0700797 if (add_ie)
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530798 qdf_mem_free(add_ie);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800799
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530800 qdf_mem_free(frm);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800801 return;
802
803err_ret:
Jeff Johnson8e9530b2019-03-18 13:41:42 -0700804 if (add_ie)
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530805 qdf_mem_free(add_ie);
Jeff Johnson8e9530b2019-03-18 13:41:42 -0700806 if (frm)
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530807 qdf_mem_free(frm);
Jeff Johnson8e9530b2019-03-18 13:41:42 -0700808 if (packet)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800809 cds_packet_free((void *)packet);
810 return;
811
812} /* End lim_send_probe_rsp_mgmt_frame. */
813
814void
Jeff Johnson9320c1e2018-12-02 13:09:20 -0800815lim_send_addts_req_action_frame(struct mac_context *mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800816 tSirMacAddr peerMacAddr,
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800817 tSirAddtsReqInfo *pAddTS, struct pe_session *pe_session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800818{
819 uint16_t i;
820 uint8_t *pFrame;
821 tDot11fAddTSRequest AddTSReq;
822 tDot11fWMMAddTSRequest WMMAddTSReq;
823 uint32_t nPayload, nBytes, nStatus;
824 tpSirMacMgmtHdr pMacHdr;
825 void *pPacket;
826#ifdef FEATURE_WLAN_ESE
827 uint32_t phyMode;
828#endif
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530829 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800830 uint8_t txFlag = 0;
831 uint8_t smeSessionId = 0;
832
Jeff Johnson8e9530b2019-03-18 13:41:42 -0700833 if (!pe_session) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800834 return;
835 }
836
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800837 smeSessionId = pe_session->smeSessionId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800838
839 if (!pAddTS->wmeTspecPresent) {
hangtian127c9532019-01-12 13:29:07 +0800840 qdf_mem_zero((uint8_t *) &AddTSReq, sizeof(AddTSReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800841
Srinivas Girigowda03cebc32019-05-17 16:50:31 -0700842 AddTSReq.Action.action = QOS_ADD_TS_REQ;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800843 AddTSReq.DialogToken.token = pAddTS->dialogToken;
Srinivas Girigowda48bec1c2019-05-17 16:33:30 -0700844 AddTSReq.Category.category = ACTION_CATEGORY_QOS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800845 if (pAddTS->lleTspecPresent) {
846 populate_dot11f_tspec(&pAddTS->tspec, &AddTSReq.TSPEC);
847 } else {
848 populate_dot11f_wmmtspec(&pAddTS->tspec,
849 &AddTSReq.WMMTSPEC);
850 }
851
852 if (pAddTS->lleTspecPresent) {
853 AddTSReq.num_WMMTCLAS = 0;
854 AddTSReq.num_TCLAS = pAddTS->numTclas;
855 for (i = 0; i < pAddTS->numTclas; ++i) {
Jeff Johnson99f25042018-11-21 22:49:06 -0800856 populate_dot11f_tclas(mac, &pAddTS->tclasInfo[i],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800857 &AddTSReq.TCLAS[i]);
858 }
859 } else {
860 AddTSReq.num_TCLAS = 0;
861 AddTSReq.num_WMMTCLAS = pAddTS->numTclas;
862 for (i = 0; i < pAddTS->numTclas; ++i) {
Jeff Johnson99f25042018-11-21 22:49:06 -0800863 populate_dot11f_wmmtclas(mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800864 &pAddTS->tclasInfo[i],
865 &AddTSReq.WMMTCLAS[i]);
866 }
867 }
868
869 if (pAddTS->tclasProcPresent) {
870 if (pAddTS->lleTspecPresent) {
871 AddTSReq.TCLASSPROC.processing =
872 pAddTS->tclasProc;
873 AddTSReq.TCLASSPROC.present = 1;
874 } else {
875 AddTSReq.WMMTCLASPROC.version = 1;
876 AddTSReq.WMMTCLASPROC.processing =
877 pAddTS->tclasProc;
878 AddTSReq.WMMTCLASPROC.present = 1;
879 }
880 }
881
882 nStatus =
Jeff Johnson99f25042018-11-21 22:49:06 -0800883 dot11f_get_packed_add_ts_request_size(mac, &AddTSReq, &nPayload);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800884 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700885 pe_err("Failed to calculate the packed size for an Add TS Request (0x%08x)",
886 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800887 /* We'll fall back on the worst case scenario: */
888 nPayload = sizeof(tDot11fAddTSRequest);
889 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700890 pe_warn("There were warnings while calculating the packed size for an Add TS Request (0x%08x)",
891 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800892 }
893 } else {
hangtian127c9532019-01-12 13:29:07 +0800894 qdf_mem_zero((uint8_t *) &WMMAddTSReq, sizeof(WMMAddTSReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800895
Srinivas Girigowda03cebc32019-05-17 16:50:31 -0700896 WMMAddTSReq.Action.action = QOS_ADD_TS_REQ;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800897 WMMAddTSReq.DialogToken.token = pAddTS->dialogToken;
Srinivas Girigowda48bec1c2019-05-17 16:33:30 -0700898 WMMAddTSReq.Category.category = ACTION_CATEGORY_WMM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800899
900 /* WMM spec 2.2.10 - status code is only filled in for ADDTS response */
901 WMMAddTSReq.StatusCode.statusCode = 0;
902
903 populate_dot11f_wmmtspec(&pAddTS->tspec, &WMMAddTSReq.WMMTSPEC);
904#ifdef FEATURE_WLAN_ESE
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800905 lim_get_phy_mode(mac, &phyMode, pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800906
907 if (phyMode == WNI_CFG_PHY_MODE_11G
908 || phyMode == WNI_CFG_PHY_MODE_11A) {
909 pAddTS->tsrsIE.rates[0] = TSRS_11AG_RATE_6MBPS;
910 } else {
911 pAddTS->tsrsIE.rates[0] = TSRS_11B_RATE_5_5MBPS;
912 }
Jeff Johnson99f25042018-11-21 22:49:06 -0800913 populate_dot11_tsrsie(mac, &pAddTS->tsrsIE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800914 &WMMAddTSReq.ESETrafStrmRateSet,
915 sizeof(uint8_t));
916#endif
917 /* fillWmeTspecIE */
918
919 nStatus =
Jeff Johnson99f25042018-11-21 22:49:06 -0800920 dot11f_get_packed_wmm_add_ts_request_size(mac, &WMMAddTSReq,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800921 &nPayload);
922 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700923 pe_err("Failed to calculate the packed size for a WMM Add TS Request (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800924 nStatus);
925 /* We'll fall back on the worst case scenario: */
926 nPayload = sizeof(tDot11fAddTSRequest);
927 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700928 pe_warn("There were warnings while calculating the packed size for a WMM Add TS Request (0x%08x)",
929 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800930 }
931 }
932
933 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
934
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530935 qdf_status = cds_packet_alloc((uint16_t) nBytes, (void **)&pFrame,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800936 (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530937 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700938 pe_err("Failed to allocate %d bytes for an Add TS Request",
939 nBytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800940 return;
941 }
942 /* Paranoia: */
hangtian127c9532019-01-12 13:29:07 +0800943 qdf_mem_zero(pFrame, nBytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800944
945 /* Next, we fill out the buffer descriptor: */
Jeff Johnson99f25042018-11-21 22:49:06 -0800946 lim_populate_mac_header(mac, pFrame, SIR_MAC_MGMT_FRAME,
Pragaspathi Thilagaraj7fb14222019-06-17 23:26:58 +0530947 SIR_MAC_MGMT_ACTION, peerMacAddr, pe_session->self_mac_addr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800948 pMacHdr = (tpSirMacMgmtHdr) pFrame;
949
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800950 sir_copy_mac_addr(pMacHdr->bssId, pe_session->bssId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800951
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800952 lim_set_protected_bit(mac, pe_session, peerMacAddr, pMacHdr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800953
954 /* That done, pack the struct: */
955 if (!pAddTS->wmeTspecPresent) {
Jeff Johnson99f25042018-11-21 22:49:06 -0800956 nStatus = dot11f_pack_add_ts_request(mac, &AddTSReq,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800957 pFrame +
958 sizeof(tSirMacMgmtHdr),
959 nPayload, &nPayload);
960 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700961 pe_err("Failed to pack an Add TS Request "
962 "(0x%08x)", nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800963 cds_packet_free((void *)pPacket);
964 return; /* allocated! */
965 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700966 pe_warn("There were warnings while packing an Add TS Request (0x%08x)",
967 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800968 }
969 } else {
Jeff Johnson99f25042018-11-21 22:49:06 -0800970 nStatus = dot11f_pack_wmm_add_ts_request(mac, &WMMAddTSReq,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800971 pFrame +
972 sizeof(tSirMacMgmtHdr),
973 nPayload, &nPayload);
974 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700975 pe_err("Failed to pack a WMM Add TS Request (0x%08x)",
976 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800977 cds_packet_free((void *)pPacket);
978 return; /* allocated! */
979 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700980 pe_warn("There were warnings while packing a WMM Add TS Request (0x%08x)",
981 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800982 }
983 }
984
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700985 pe_debug("Sending an Add TS Request frame to");
Jeff Johnson99f25042018-11-21 22:49:06 -0800986 lim_print_mac_addr(mac, peerMacAddr, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800987
Liangwei Dong419d7302019-07-15 15:38:28 +0800988 if (wlan_reg_is_5ghz_ch_freq(pe_session->curr_op_freq) ||
989 pe_session->opmode == QDF_P2P_CLIENT_MODE ||
990 pe_session->opmode == QDF_P2P_GO_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800991 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800992
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530993 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800994 pe_session->peSessionId, pMacHdr->fc.subType));
Jeff Johnson99f25042018-11-21 22:49:06 -0800995 lim_diag_mgmt_tx_event_report(mac, pMacHdr,
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800996 pe_session, QDF_STATUS_SUCCESS,
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700997 QDF_STATUS_SUCCESS);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800998
999 /* Queue Addts Response frame in high priority WQ */
Jeff Johnson99f25042018-11-21 22:49:06 -08001000 qdf_status = wma_tx_frame(mac, pPacket, (uint16_t) nBytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001001 TXRX_FRM_802_11_MGMT,
1002 ANI_TXDIR_TODS,
1003 7, lim_tx_complete, pFrame, txFlag,
Naveen Rawat296a5182017-09-25 14:02:48 -07001004 smeSessionId, 0, RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05301005 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001006 pe_session->peSessionId, qdf_status));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001007
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001008 if (!QDF_IS_STATUS_SUCCESS(qdf_status))
1009 pe_err("Could not send an Add TS Request (%X",
1010 qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001011} /* End lim_send_addts_req_action_frame. */
1012
1013/**
bings85512332019-09-04 17:46:37 +08001014 * lim_assoc_rsp_tx_complete() - Confirmation for assoc rsp OTA
1015 * @context: pointer to global mac
1016 * @buf: buffer which is nothing but entire assoc rsp frame
1017 * @tx_complete : Sent status
1018 * @params; tx completion params
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001019 *
bings85512332019-09-04 17:46:37 +08001020 * Return: This returns QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001021 */
bings85512332019-09-04 17:46:37 +08001022static QDF_STATUS lim_assoc_rsp_tx_complete(
1023 void *context,
1024 qdf_nbuf_t buf,
1025 uint32_t tx_complete,
1026 void *params)
1027{
1028 struct mac_context *mac_ctx = (struct mac_context *)context;
1029 tSirMacMgmtHdr *mac_hdr;
1030 struct pe_session *session_entry;
1031 uint8_t session_id;
1032 tpLimMlmAssocInd lim_assoc_ind;
1033 tpDphHashNode sta_ds;
1034 uint16_t aid;
1035 uint8_t *data;
1036 struct assoc_ind *sme_assoc_ind;
1037 struct scheduler_msg msg;
1038 tpSirAssocReq assoc_req;
1039
1040 if (!buf) {
1041 pe_err("Assoc rsp frame buffer is NULL");
1042 goto null_buf;
1043 }
1044
1045 data = qdf_nbuf_data(buf);
1046
1047 if (!data) {
1048 pe_err("Assoc rsp frame is NULL");
1049 goto end;
1050 }
1051
1052 mac_hdr = (tSirMacMgmtHdr *)data;
1053
1054 session_entry = pe_find_session_by_bssid(
1055 mac_ctx, mac_hdr->sa,
1056 &session_id);
1057 if (!session_entry) {
1058 pe_err("session entry is NULL");
1059 goto end;
1060 }
1061
1062 sta_ds = dph_lookup_hash_entry(mac_ctx,
1063 (uint8_t *)mac_hdr->da, &aid,
1064 &session_entry->dph.dphHashTable);
1065 if (!sta_ds) {
1066 pe_err("sta_ds is NULL");
1067 goto end;
1068 }
1069
1070 /* Get a copy of the already parsed Assoc Request */
1071 assoc_req =
1072 (tpSirAssocReq)session_entry->parsedAssocReq[sta_ds->assocId];
1073
1074 if (!assoc_req) {
1075 pe_err("assoc req for assoc_id:%d is NULL", sta_ds->assocId);
1076 goto end;
1077 }
1078
1079 lim_assoc_ind = qdf_mem_malloc(sizeof(tLimMlmAssocInd));
1080 if (!lim_assoc_ind) {
1081 pe_err("lim assoc ind is NULL");
1082 goto free_assoc_req;
1083 }
1084 if (!lim_fill_lim_assoc_ind_params(lim_assoc_ind, mac_ctx,
1085 sta_ds, session_entry)) {
1086 pe_err("lim assoc ind fill error");
1087 goto lim_assoc_ind;
1088 }
1089
1090 sme_assoc_ind = qdf_mem_malloc(sizeof(struct assoc_ind));
1091 if (!sme_assoc_ind) {
1092 pe_err("sme assoc ind is NULL");
1093 goto lim_assoc_ind;
1094 }
1095 sme_assoc_ind->messageType = eWNI_SME_ASSOC_IND_UPPER_LAYER;
1096 lim_fill_sme_assoc_ind_params(
1097 mac_ctx, lim_assoc_ind,
1098 sme_assoc_ind,
Chaoli Zhou98d1b3e2019-10-10 17:13:44 +08001099 session_entry, true);
bings85512332019-09-04 17:46:37 +08001100
1101 qdf_mem_zero(&msg, sizeof(struct scheduler_msg));
1102 msg.type = eWNI_SME_ASSOC_IND_UPPER_LAYER;
1103 msg.bodyptr = sme_assoc_ind;
1104 msg.bodyval = 0;
1105 sme_assoc_ind->staId = sta_ds->staIndex;
1106 sme_assoc_ind->reassocReq = sta_ds->mlmStaContext.subType;
1107 sme_assoc_ind->timingMeasCap = sta_ds->timingMeasCap;
Chaoli Zhou98d1b3e2019-10-10 17:13:44 +08001108 MTRACE(mac_trace_msg_tx(mac_ctx, session_entry->peSessionId, msg.type));
1109 lim_sys_process_mmh_msg_api(mac_ctx, &msg);
bings85512332019-09-04 17:46:37 +08001110
1111 qdf_mem_free(lim_assoc_ind);
1112 if (assoc_req->assocReqFrame) {
1113 qdf_mem_free(assoc_req->assocReqFrame);
1114 assoc_req->assocReqFrame = NULL;
1115 }
1116 qdf_mem_free(session_entry->parsedAssocReq[sta_ds->assocId]);
1117 session_entry->parsedAssocReq[sta_ds->assocId] = NULL;
1118 qdf_nbuf_free(buf);
1119
1120 return QDF_STATUS_SUCCESS;
1121
1122lim_assoc_ind:
1123 qdf_mem_free(lim_assoc_ind);
1124free_assoc_req:
1125 if (assoc_req->assocReqFrame) {
1126 qdf_mem_free(assoc_req->assocReqFrame);
1127 assoc_req->assocReqFrame = NULL;
1128 }
1129 qdf_mem_free(session_entry->parsedAssocReq[sta_ds->assocId]);
1130 session_entry->parsedAssocReq[sta_ds->assocId] = NULL;
1131end:
1132 qdf_nbuf_free(buf);
1133null_buf:
1134 return QDF_STATUS_E_FAILURE;
1135}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001136
1137void
bings85512332019-09-04 17:46:37 +08001138lim_send_assoc_rsp_mgmt_frame(
1139 struct mac_context *mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001140 uint16_t status_code, uint16_t aid, tSirMacAddr peer_addr,
bings85512332019-09-04 17:46:37 +08001141 uint8_t subtype, tpDphHashNode sta, struct pe_session *pe_session,
1142 bool tx_complete)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001143{
1144 static tDot11fAssocResponse frm;
1145 uint8_t *frame;
1146 tpSirMacMgmtHdr mac_hdr;
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001147 QDF_STATUS sir_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001148 uint8_t lle_mode = 0, addts;
1149 tHalBitVal qos_mode, wme_mode;
Hu Wang411e0cc2016-10-28 14:56:01 +08001150 uint32_t payload, bytes = 0, status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001151 void *packet;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301152 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001153 tUpdateBeaconParams beacon_params;
1154 uint8_t tx_flag = 0;
1155 uint32_t addn_ie_len = 0;
1156 uint8_t add_ie[WNI_CFG_ASSOC_RSP_ADDNIE_DATA_LEN];
1157 tpSirAssocReq assoc_req = NULL;
1158 uint8_t sme_session = 0;
1159 bool is_vht = false;
1160 uint16_t stripoff_len = 0;
1161 tDot11fIEExtCap extracted_ext_cap;
1162 bool extracted_flag = false;
1163#ifdef WLAN_FEATURE_11W
Karthik Kantamneni24f71bc2018-09-11 19:08:38 +05301164 uint8_t retry_int;
1165 uint16_t max_retries;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001166#endif
1167
Jeff Johnson8e9530b2019-03-18 13:41:42 -07001168 if (!pe_session) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001169 pe_err("pe_session is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001170 return;
1171 }
1172
1173 sme_session = pe_session->smeSessionId;
1174
hangtian127c9532019-01-12 13:29:07 +08001175 qdf_mem_zero((uint8_t *) &frm, sizeof(frm));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001176
1177 limGetQosMode(pe_session, &qos_mode);
1178 limGetWmeMode(pe_session, &wme_mode);
1179
1180 /*
1181 * An Add TS IE is added only if the AP supports it and
1182 * the requesting STA sent a traffic spec.
1183 */
1184 addts = (qos_mode && sta && sta->qos.addtsPresent) ? 1 : 0;
1185
1186 frm.Status.status = status_code;
1187
1188 frm.AID.associd = aid | LIM_AID_MASK;
1189
Jeff Johnson8e9530b2019-03-18 13:41:42 -07001190 if (!sta) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001191 populate_dot11f_supp_rates(mac_ctx,
1192 POPULATE_DOT11F_RATES_OPERATIONAL,
1193 &frm.SuppRates, pe_session);
1194 populate_dot11f_ext_supp_rates(mac_ctx,
1195 POPULATE_DOT11F_RATES_OPERATIONAL,
1196 &frm.ExtSuppRates, pe_session);
1197 } else {
1198 populate_dot11f_assoc_rsp_rates(mac_ctx, &frm.SuppRates,
1199 &frm.ExtSuppRates,
1200 sta->supportedRates.llbRates,
1201 sta->supportedRates.llaRates);
1202 }
1203
Jeff Johnson8e9530b2019-03-18 13:41:42 -07001204 if (LIM_IS_AP_ROLE(pe_session) && sta &&
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001205 QDF_STATUS_SUCCESS == status_code) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001206 assoc_req = (tpSirAssocReq)
1207 pe_session->parsedAssocReq[sta->assocId];
1208 /*
1209 * populate P2P IE in AssocRsp when assocReq from the peer
1210 * includes P2P IE
1211 */
Jeff Johnson8e9530b2019-03-18 13:41:42 -07001212 if (assoc_req && assoc_req->addIEPresent)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001213 populate_dot11_assoc_res_p2p_ie(mac_ctx,
1214 &frm.P2PAssocRes,
1215 assoc_req);
1216 }
1217
Jeff Johnson8e9530b2019-03-18 13:41:42 -07001218 if (sta) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001219 if (eHAL_SET == qos_mode) {
1220 if (sta->lleEnabled) {
1221 lle_mode = 1;
1222 populate_dot11f_edca_param_set(mac_ctx,
1223 &frm.EDCAParamSet, pe_session);
1224 }
1225 }
1226
1227 if ((!lle_mode) && (eHAL_SET == wme_mode) && sta->wmeEnabled) {
1228 populate_dot11f_wmm_params(mac_ctx, &frm.WMMParams,
1229 pe_session);
1230
1231 if (sta->wsmEnabled)
1232 populate_dot11f_wmm_caps(&frm.WMMCaps);
1233 }
1234
1235 if (sta->mlmStaContext.htCapability &&
1236 pe_session->htCapability) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001237 pe_debug("Populate HT IEs in Assoc Response");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001238 populate_dot11f_ht_caps(mac_ctx, pe_session,
1239 &frm.HTCaps);
Krunal Sonief3294b2015-06-12 15:12:19 -07001240 /*
1241 * Check the STA capability and
1242 * update the HTCaps accordingly
1243 */
1244 frm.HTCaps.supportedChannelWidthSet = (
1245 sta->htSupportedChannelWidthSet <
1246 pe_session->htSupportedChannelWidthSet) ?
1247 sta->htSupportedChannelWidthSet :
1248 pe_session->htSupportedChannelWidthSet;
1249 if (!frm.HTCaps.supportedChannelWidthSet)
1250 frm.HTCaps.shortGI40MHz = 0;
1251
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001252 populate_dot11f_ht_info(mac_ctx, &frm.HTInfo,
Pragaspathi Thilagarajb3472f02019-06-04 14:10:44 +05301253 pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001254 }
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001255 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 +05301256 frm.HTCaps.supportedChannelWidthSet,
1257 frm.HTCaps.mimoPowerSave,
1258 frm.HTCaps.greenField, frm.HTCaps.shortGI20MHz,
1259 frm.HTCaps.shortGI40MHz,
1260 frm.HTCaps.dsssCckMode40MHz,
1261 frm.HTCaps.maxRxAMPDUFactor);
1262
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001263 if (sta->mlmStaContext.vhtCapability &&
1264 pe_session->vhtCapability) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001265 pe_debug("Populate VHT IEs in Assoc Response");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001266 populate_dot11f_vht_caps(mac_ctx, pe_session,
1267 &frm.VHTCaps);
1268 populate_dot11f_vht_operation(mac_ctx, pe_session,
Kapil Gupta4b2efbb2016-10-03 13:07:20 +05301269 &frm.VHTOperation);
1270 is_vht = true;
Pragaspathi Thilagarajb3472f02019-06-04 14:10:44 +05301271 } else if (sta->mlmStaContext.force_1x1 &&
1272 frm.HTCaps.present) {
1273 /*
1274 * WAR: In P2P GO mode, if the P2P client device
1275 * is only HT capable and not VHT capable, but the P2P
1276 * GO device is VHT capable and advertises 2x2 NSS with
1277 * HT capablity client device, which results in IOT
1278 * issues.
1279 * When GO is operating in DBS mode, GO beacons
1280 * advertise 2x2 capability but include OMN IE to
1281 * indicate current operating mode of 1x1. But here
1282 * peer device is only HT capable and will not
1283 * understand OMN IE.
1284 */
1285 frm.HTInfo.basicMCSSet[1] = 0;
1286 frm.HTCaps.supportedMCSSet[1] = 0;
Kapil Gupta4b2efbb2016-10-03 13:07:20 +05301287 }
Naveen Rawat903acca2017-09-15 17:32:13 -07001288
Kapil Gupta4b2efbb2016-10-03 13:07:20 +05301289 if (pe_session->vhtCapability &&
1290 pe_session->vendor_vht_sap &&
Jeff Johnson8e9530b2019-03-18 13:41:42 -07001291 (assoc_req) &&
Kapil Gupta4b2efbb2016-10-03 13:07:20 +05301292 assoc_req->vendor_vht_ie.VHTCaps.present) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001293 pe_debug("Populate Vendor VHT IEs in Assoc Rsponse");
Kapil Gupta4b2efbb2016-10-03 13:07:20 +05301294 frm.vendor_vht_ie.present = 1;
Kiran Kumar Lokere81722632017-09-26 12:11:43 -07001295 frm.vendor_vht_ie.sub_type =
1296 pe_session->vendor_specific_vht_ie_sub_type;
Kapil Gupta4b2efbb2016-10-03 13:07:20 +05301297 frm.vendor_vht_ie.VHTCaps.present = 1;
1298 populate_dot11f_vht_caps(mac_ctx, pe_session,
1299 &frm.vendor_vht_ie.VHTCaps);
Kiran Kumar Lokerecc448682017-07-20 18:08:01 -07001300 populate_dot11f_vht_operation(mac_ctx, pe_session,
1301 &frm.vendor_vht_ie.VHTOperation);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001302 is_vht = true;
Kiran Kumar Lokere89f01f02019-08-06 18:22:39 -07001303 populate_dot11f_qcn_ie(mac_ctx, &frm.qcn_ie,
1304 QCN_IE_ATTR_ID_ALL);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001305 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001306 populate_dot11f_ext_cap(mac_ctx, is_vht, &frm.ExtCap,
1307 pe_session);
1308
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08001309 if (lim_is_sta_he_capable(sta) &&
1310 lim_is_session_he_capable(pe_session)) {
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07001311 pe_debug("Populate HE IEs");
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08001312 populate_dot11f_he_caps(mac_ctx, pe_session,
Naveen Rawatd8feac12017-09-08 15:08:39 -07001313 &frm.he_cap);
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08001314 populate_dot11f_he_operation(mac_ctx, pe_session,
Naveen Rawatd8feac12017-09-08 15:08:39 -07001315 &frm.he_op);
Kiran Kumar Lokereb2ea0272019-08-27 19:16:36 -07001316 populate_dot11f_he_6ghz_cap(mac_ctx, pe_session,
1317 &frm.he_6ghz_band_cap);
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08001318 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001319#ifdef WLAN_FEATURE_11W
1320 if (eSIR_MAC_TRY_AGAIN_LATER == status_code) {
Karthik Kantamneni24f71bc2018-09-11 19:08:38 +05301321 max_retries =
1322 mac_ctx->mlme_cfg->gen.pmf_sa_query_max_retries;
1323 retry_int =
1324 mac_ctx->mlme_cfg->gen.pmf_sa_query_retry_interval;
1325 populate_dot11f_timeout_interval(mac_ctx,
1326 &frm.TimeoutInterval,
1327 SIR_MAC_TI_TYPE_ASSOC_COMEBACK,
1328 (max_retries -
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001329 sta->pmfSaQueryRetryCount)
1330 * retry_int);
1331 }
1332#endif
Arif Hussain0c816922017-04-06 15:04:44 -07001333
1334 if (LIM_IS_AP_ROLE(pe_session) && sta->non_ecsa_capable)
1335 pe_session->lim_non_ecsa_cap_num++;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001336 }
1337
hangtian127c9532019-01-12 13:29:07 +08001338 qdf_mem_zero((uint8_t *) &beacon_params, sizeof(beacon_params));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001339
1340 if (LIM_IS_AP_ROLE(pe_session) &&
Pragaspathi Thilagaraj1ee76002018-09-18 21:38:51 +05301341 (pe_session->gLimProtectionControl !=
1342 MLME_FORCE_POLICY_PROTECTION_DISABLE))
1343 lim_decide_ap_protection(mac_ctx, peer_addr, &beacon_params,
1344 pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001345
1346 lim_update_short_preamble(mac_ctx, peer_addr, &beacon_params,
1347 pe_session);
1348 lim_update_short_slot_time(mac_ctx, peer_addr, &beacon_params,
1349 pe_session);
1350
1351 /*
1352 * Populate Do11capabilities after updating session with
1353 * Assos req details
1354 */
1355 populate_dot11f_capabilities(mac_ctx, &frm.Capabilities, pe_session);
1356
Abhishek Singhc70afa32019-09-19 15:17:21 +05301357 beacon_params.bss_idx = pe_session->vdev_id;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001358
1359 /* Send message to HAL about beacon parameter change. */
1360 if ((false == mac_ctx->sap.SapDfsInfo.is_dfs_cac_timer_running)
1361 && beacon_params.paramChangeBitmap) {
1362 sch_set_fixed_beacon_fields(mac_ctx, pe_session);
1363 lim_send_beacon_params(mac_ctx, &beacon_params, pe_session);
1364 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001365
Arif Hussain1513cb22018-01-05 19:56:31 -08001366 lim_obss_send_detection_cfg(mac_ctx, pe_session, false);
1367
Jeff Johnson8e9530b2019-03-18 13:41:42 -07001368 if (assoc_req) {
Jeff Johnson21aac3a2019-02-02 14:26:13 -08001369 addn_ie_len = pe_session->add_ie_params.assocRespDataLen;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001370
1371 /* Nonzero length indicates Assoc rsp IE available */
Krishna Kumaar Natarajane4e3a142016-04-01 16:27:51 -07001372 if (addn_ie_len > 0 &&
1373 addn_ie_len <= WNI_CFG_ASSOC_RSP_ADDNIE_DATA_LEN &&
1374 (bytes + addn_ie_len) <= SIR_MAX_PACKET_SIZE) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301375 qdf_mem_copy(add_ie,
Jeff Johnson21aac3a2019-02-02 14:26:13 -08001376 pe_session->add_ie_params.assocRespData_buff,
1377 pe_session->add_ie_params.assocRespDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001378
hangtian127c9532019-01-12 13:29:07 +08001379 qdf_mem_zero((uint8_t *) &extracted_ext_cap,
1380 sizeof(extracted_ext_cap));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001381
1382 stripoff_len = addn_ie_len;
1383 sir_status =
1384 lim_strip_extcap_update_struct
1385 (mac_ctx, &add_ie[0], &stripoff_len,
1386 &extracted_ext_cap);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001387 if (QDF_STATUS_SUCCESS != sir_status) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001388 pe_debug("strip off extcap IE failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001389 } else {
1390 addn_ie_len = stripoff_len;
1391 extracted_flag = true;
1392 }
1393 bytes = bytes + addn_ie_len;
1394 }
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001395 pe_debug("addn_ie_len: %d for Assoc Resp: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001396 addn_ie_len, assoc_req->addIEPresent);
1397 }
Hu Wang411e0cc2016-10-28 14:56:01 +08001398
1399 /*
1400 * Extcap IE now support variable length, merge Extcap IE from addn_ie
1401 * may change the frame size. Therefore, MUST merge ExtCap IE before
1402 * dot11f get packed payload size.
1403 */
1404 if (extracted_flag)
Hu Wangfbd279d2016-10-31 18:24:34 +08001405 lim_merge_extcap_struct(&(frm.ExtCap), &extracted_ext_cap,
1406 true);
Hu Wang411e0cc2016-10-28 14:56:01 +08001407
1408 /* Allocate a buffer for this frame: */
1409 status = dot11f_get_packed_assoc_response_size(mac_ctx, &frm, &payload);
1410 if (DOT11F_FAILED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001411 pe_err("get Association Response size failure (0x%08x)",
Hu Wang411e0cc2016-10-28 14:56:01 +08001412 status);
1413 return;
1414 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001415 pe_warn("get Association Response size warning (0x%08x)",
Hu Wang411e0cc2016-10-28 14:56:01 +08001416 status);
1417 }
1418
1419 bytes += sizeof(tSirMacMgmtHdr) + payload;
1420
Min Liu0daa0982019-02-01 17:50:44 +08001421 if (sta)
1422 bytes += sta->mlmStaContext.owe_ie_len;
1423
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301424 qdf_status = cds_packet_alloc((uint16_t) bytes, (void **)&frame,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001425 (void **)&packet);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301426 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001427 pe_err("cds_packet_alloc failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001428 return;
1429 }
1430 /* Paranoia: */
hangtian127c9532019-01-12 13:29:07 +08001431 qdf_mem_zero(frame, bytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001432
1433 /* Next, we fill out the buffer descriptor: */
1434 lim_populate_mac_header(mac_ctx, frame, SIR_MAC_MGMT_FRAME,
1435 (LIM_ASSOC == subtype) ?
1436 SIR_MAC_MGMT_ASSOC_RSP : SIR_MAC_MGMT_REASSOC_RSP,
1437 peer_addr,
Pragaspathi Thilagaraj7fb14222019-06-17 23:26:58 +05301438 pe_session->self_mac_addr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001439 mac_hdr = (tpSirMacMgmtHdr) frame;
1440
1441 sir_copy_mac_addr(mac_hdr->bssId, pe_session->bssId);
1442
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001443 status = dot11f_pack_assoc_response(mac_ctx, &frm,
1444 frame + sizeof(tSirMacMgmtHdr),
1445 payload, &payload);
1446 if (DOT11F_FAILED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001447 pe_err("Association Response pack failure(0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001448 status);
1449 cds_packet_free((void *)packet);
1450 return;
1451 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001452 pe_warn("Association Response pack warning (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001453 status);
1454 }
1455
1456 if (subtype == LIM_ASSOC)
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001457 pe_debug("*** Sending Assoc Resp status %d aid %d to",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001458 status_code, aid);
1459 else
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001460 pe_debug("*** Sending ReAssoc Resp status %d aid %d to",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001461 status_code, aid);
1462
Abhishek Singh5d8d7332017-08-10 15:15:24 +05301463 lim_print_mac_addr(mac_ctx, mac_hdr->da, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001464
1465 if (addn_ie_len && addn_ie_len <= WNI_CFG_ASSOC_RSP_ADDNIE_DATA_LEN)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301466 qdf_mem_copy(frame + sizeof(tSirMacMgmtHdr) + payload,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001467 &add_ie[0], addn_ie_len);
1468
Min Liu0daa0982019-02-01 17:50:44 +08001469 if (sta && sta->mlmStaContext.owe_ie_len)
1470 qdf_mem_copy(frame + sizeof(tSirMacMgmtHdr) + payload
1471 + addn_ie_len,
1472 sta->mlmStaContext.owe_ie,
1473 sta->mlmStaContext.owe_ie_len);
1474
Liangwei Dong419d7302019-07-15 15:38:28 +08001475 if (wlan_reg_is_5ghz_ch_freq(pe_session->curr_op_freq) ||
1476 pe_session->opmode == QDF_P2P_CLIENT_MODE ||
1477 pe_session->opmode == QDF_P2P_GO_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001478 tx_flag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
1479
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05301480 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001481 pe_session->peSessionId, mac_hdr->fc.subType));
Krunal Sonic65fc492018-03-09 15:53:28 -08001482 lim_diag_mgmt_tx_event_report(mac_ctx, mac_hdr,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001483 pe_session, QDF_STATUS_SUCCESS, status_code);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001484 /* Queue Association Response frame in high priority WQ */
bings85512332019-09-04 17:46:37 +08001485 if (tx_complete)
1486 qdf_status = wma_tx_frameWithTxComplete(
1487 mac_ctx, packet, (uint16_t)bytes,
1488 TXRX_FRM_802_11_MGMT,
1489 ANI_TXDIR_TODS,
1490 7, lim_tx_complete, frame,
1491 lim_assoc_rsp_tx_complete, tx_flag,
1492 sme_session, false, 0, RATEID_DEFAULT);
1493 else
1494 qdf_status = wma_tx_frame(
1495 mac_ctx, packet, (uint16_t)bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001496 TXRX_FRM_802_11_MGMT,
1497 ANI_TXDIR_TODS,
1498 7, lim_tx_complete, frame, tx_flag,
Naveen Rawat296a5182017-09-25 14:02:48 -07001499 sme_session, 0, RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05301500 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301501 pe_session->peSessionId, qdf_status));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001502
1503 /* Pkt will be freed up by the callback */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301504 if (!QDF_IS_STATUS_SUCCESS(qdf_status))
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001505 pe_err("Could not Send Re/AssocRsp, retCode=%X",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301506 qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001507
1508 /*
1509 * update the ANI peer station count.
1510 * FIXME_PROTECTION : take care of different type of station
1511 * counter inside this function.
1512 */
1513 lim_util_count_sta_add(mac_ctx, sta, pe_session);
1514
1515}
1516
1517void
Jeff Johnson9320c1e2018-12-02 13:09:20 -08001518lim_send_delts_req_action_frame(struct mac_context *mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001519 tSirMacAddr peer,
1520 uint8_t wmmTspecPresent,
Jeff Johnson312348f2018-12-22 13:33:54 -08001521 struct mac_ts_info *pTsinfo,
Jeff Johnson56471b92018-12-22 14:36:06 -08001522 struct mac_tspec_ie *pTspecIe,
Jeff Johnson312348f2018-12-22 13:33:54 -08001523 struct pe_session *pe_session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001524{
1525 uint8_t *pFrame;
1526 tpSirMacMgmtHdr pMacHdr;
1527 tDot11fDelTS DelTS;
1528 tDot11fWMMDelTS WMMDelTS;
1529 uint32_t nBytes, nPayload, nStatus;
1530 void *pPacket;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301531 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001532 uint8_t txFlag = 0;
1533 uint8_t smeSessionId = 0;
1534
Jeff Johnson312348f2018-12-22 13:33:54 -08001535 if (!pe_session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001536 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001537
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001538 smeSessionId = pe_session->smeSessionId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001539
1540 if (!wmmTspecPresent) {
hangtian127c9532019-01-12 13:29:07 +08001541 qdf_mem_zero((uint8_t *) &DelTS, sizeof(DelTS));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001542
Srinivas Girigowda48bec1c2019-05-17 16:33:30 -07001543 DelTS.Category.category = ACTION_CATEGORY_QOS;
Srinivas Girigowda03cebc32019-05-17 16:50:31 -07001544 DelTS.Action.action = QOS_DEL_TS_REQ;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001545 populate_dot11f_ts_info(pTsinfo, &DelTS.TSInfo);
1546
Jeff Johnson99f25042018-11-21 22:49:06 -08001547 nStatus = dot11f_get_packed_del_ts_size(mac, &DelTS, &nPayload);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001548 if (DOT11F_FAILED(nStatus)) {
Jeff Johnson312348f2018-12-22 13:33:54 -08001549 pe_err("Failed to calculate the packed size for a Del TS (0x%08x)",
1550 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001551 /* We'll fall back on the worst case scenario: */
1552 nPayload = sizeof(tDot11fDelTS);
1553 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001554 pe_warn("There were warnings while calculating the packed size for a Del TS (0x%08x)",
1555 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001556 }
1557 } else {
hangtian127c9532019-01-12 13:29:07 +08001558 qdf_mem_zero((uint8_t *) &WMMDelTS, sizeof(WMMDelTS));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001559
Srinivas Girigowda48bec1c2019-05-17 16:33:30 -07001560 WMMDelTS.Category.category = ACTION_CATEGORY_WMM;
Srinivas Girigowda03cebc32019-05-17 16:50:31 -07001561 WMMDelTS.Action.action = QOS_DEL_TS_REQ;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001562 WMMDelTS.DialogToken.token = 0;
1563 WMMDelTS.StatusCode.statusCode = 0;
1564 populate_dot11f_wmmtspec(pTspecIe, &WMMDelTS.WMMTSPEC);
1565 nStatus =
Jeff Johnson99f25042018-11-21 22:49:06 -08001566 dot11f_get_packed_wmm_del_ts_size(mac, &WMMDelTS, &nPayload);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001567 if (DOT11F_FAILED(nStatus)) {
Jeff Johnson312348f2018-12-22 13:33:54 -08001568 pe_err("Failed to calculate the packed size for a WMM Del TS (0x%08x)",
1569 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001570 /* We'll fall back on the worst case scenario: */
1571 nPayload = sizeof(tDot11fDelTS);
1572 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001573 pe_warn("There were warnings while calculating the packed size for a WMM Del TS (0x%08x)",
1574 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001575 }
1576 }
1577
1578 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
1579
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301580 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001581 cds_packet_alloc((uint16_t) nBytes, (void **)&pFrame,
1582 (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301583 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001584 pe_err("Failed to allocate %d bytes for an Add TS Response",
1585 nBytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001586 return;
1587 }
1588 /* Paranoia: */
hangtian127c9532019-01-12 13:29:07 +08001589 qdf_mem_zero(pFrame, nBytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001590
1591 /* Next, we fill out the buffer descriptor: */
Jeff Johnson99f25042018-11-21 22:49:06 -08001592 lim_populate_mac_header(mac, pFrame, SIR_MAC_MGMT_FRAME,
Pragaspathi Thilagaraj7fb14222019-06-17 23:26:58 +05301593 SIR_MAC_MGMT_ACTION, peer, pe_session->self_mac_addr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001594 pMacHdr = (tpSirMacMgmtHdr) pFrame;
1595
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001596 sir_copy_mac_addr(pMacHdr->bssId, pe_session->bssId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001597
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001598 lim_set_protected_bit(mac, pe_session, peer, pMacHdr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001599
1600 /* That done, pack the struct: */
1601 if (!wmmTspecPresent) {
Jeff Johnson99f25042018-11-21 22:49:06 -08001602 nStatus = dot11f_pack_del_ts(mac, &DelTS,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001603 pFrame + sizeof(tSirMacMgmtHdr),
1604 nPayload, &nPayload);
1605 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001606 pe_err("Failed to pack a Del TS frame (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001607 nStatus);
1608 cds_packet_free((void *)pPacket);
1609 return; /* allocated! */
1610 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001611 pe_warn("There were warnings while packing a Del TS frame (0x%08x)",
1612 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001613 }
1614 } else {
Jeff Johnson99f25042018-11-21 22:49:06 -08001615 nStatus = dot11f_pack_wmm_del_ts(mac, &WMMDelTS,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001616 pFrame + sizeof(tSirMacMgmtHdr),
1617 nPayload, &nPayload);
1618 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001619 pe_err("Failed to pack a WMM Del TS frame (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001620 nStatus);
1621 cds_packet_free((void *)pPacket);
1622 return; /* allocated! */
1623 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001624 pe_warn("There were warnings while packing a WMM Del TS frame (0x%08x)",
1625 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001626 }
1627 }
1628
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001629 pe_debug("Sending DELTS REQ (size %d) to ", nBytes);
Jeff Johnson99f25042018-11-21 22:49:06 -08001630 lim_print_mac_addr(mac, pMacHdr->da, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001631
Liangwei Dong419d7302019-07-15 15:38:28 +08001632 if (wlan_reg_is_5ghz_ch_freq(pe_session->curr_op_freq) ||
1633 pe_session->opmode == QDF_P2P_CLIENT_MODE ||
1634 pe_session->opmode == QDF_P2P_GO_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001635 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001636
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05301637 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001638 pe_session->peSessionId, pMacHdr->fc.subType));
Jeff Johnson99f25042018-11-21 22:49:06 -08001639 lim_diag_mgmt_tx_event_report(mac, pMacHdr,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001640 pe_session, QDF_STATUS_SUCCESS,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001641 QDF_STATUS_SUCCESS);
Jeff Johnson99f25042018-11-21 22:49:06 -08001642 qdf_status = wma_tx_frame(mac, pPacket, (uint16_t) nBytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001643 TXRX_FRM_802_11_MGMT,
1644 ANI_TXDIR_TODS,
1645 7, lim_tx_complete, pFrame, txFlag,
Naveen Rawat296a5182017-09-25 14:02:48 -07001646 smeSessionId, 0, RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05301647 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001648 pe_session->peSessionId, qdf_status));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001649 /* Pkt will be freed up by the callback */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301650 if (!QDF_IS_STATUS_SUCCESS(qdf_status))
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001651 pe_err("Failed to send Del TS (%X)!", qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001652
1653} /* End lim_send_delts_req_action_frame. */
1654
1655/**
Abhishek Singhdd2cb572017-08-11 11:10:19 +05301656 * lim_assoc_tx_complete_cnf()- Confirmation for assoc sent over the air
1657 * @context: pointer to global mac
1658 * @buf: buffer
1659 * @tx_complete : Sent status
1660 * @params; tx completion params
1661 *
1662 * Return: This returns QDF_STATUS
1663 */
1664
1665static QDF_STATUS lim_assoc_tx_complete_cnf(void *context,
1666 qdf_nbuf_t buf,
1667 uint32_t tx_complete,
1668 void *params)
1669{
1670 uint16_t assoc_ack_status;
1671 uint16_t reason_code;
Jeff Johnson9320c1e2018-12-02 13:09:20 -08001672 struct mac_context *mac_ctx = (struct mac_context *)context;
Abhishek Singhdd2cb572017-08-11 11:10:19 +05301673
1674 pe_debug("tx_complete= %d", tx_complete);
Zhu Jianmin5d8e3fe2018-01-04 16:16:20 +08001675 if (tx_complete == WMI_MGMT_TX_COMP_TYPE_COMPLETE_OK) {
Abhishek Singhdd2cb572017-08-11 11:10:19 +05301676 assoc_ack_status = ACKED;
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001677 reason_code = QDF_STATUS_SUCCESS;
Abhishek Singhdd2cb572017-08-11 11:10:19 +05301678 } else {
1679 assoc_ack_status = NOT_ACKED;
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001680 reason_code = QDF_STATUS_E_FAILURE;
Abhishek Singhdd2cb572017-08-11 11:10:19 +05301681 }
1682 if (buf)
1683 qdf_nbuf_free(buf);
1684
1685 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_ASSOC_ACK_EVENT,
1686 NULL, assoc_ack_status, reason_code);
1687 return QDF_STATUS_SUCCESS;
1688}
1689
Pragaspathi Thilagaraj54018e02019-04-25 01:32:17 +05301690#ifdef WLAN_ADAPTIVE_11R
1691/**
1692 * lim_fill_adaptive_11r_ie() - Populate the Vendor secific adaptive 11r
1693 * IE to association request frame
1694 * @pe_session: pointer to PE session
1695 * @ie_buf: buffer to which Adaptive 11r IE will be copied
1696 * @ie_len: length of the Adaptive 11r Vendor specific IE
1697 *
1698 * Return QDF_STATUS
1699 */
1700static QDF_STATUS lim_fill_adaptive_11r_ie(struct pe_session *pe_session,
1701 uint8_t **ie_buf, uint8_t *ie_len)
1702{
1703 uint8_t *buf = NULL, *adaptive_11r_ie = NULL;
1704
1705 if (!pe_session->is_adaptive_11r_connection)
1706 return QDF_STATUS_SUCCESS;
1707
1708 /*
1709 * Vendor specific Adaptive 11r IE to be advertised in Assoc
1710 * req:
1711 * Type 0xDD
1712 * Length 0x0B
1713 * OUI 0x00 0x00 0x0F
1714 * Type 0x22
1715 * subtype 0x00
1716 * Version 0x01
1717 * Length 0x04
1718 * Data 0x00 00 00 01(0th bit is 1 means adaptive 11r is
1719 * supported)
1720 */
1721 adaptive_11r_ie = qdf_mem_malloc(ADAPTIVE_11R_STA_IE_LEN + 2);
1722 if (!adaptive_11r_ie)
1723 return QDF_STATUS_E_FAILURE;
1724
1725 /* Fill the Vendor IE Type (0xDD) */
1726 buf = adaptive_11r_ie;
Srinivas Girigowda8e7ecab2019-05-16 11:31:19 -07001727 *buf = WLAN_ELEMID_VENDOR;
Pragaspathi Thilagaraj54018e02019-04-25 01:32:17 +05301728 buf++;
1729
1730 /* Fill the Vendor IE length (0x0B) */
1731 *buf = ADAPTIVE_11R_STA_IE_LEN;
1732 buf++;
1733
1734 /*
1735 * Fill the Adaptive 11r Vendor specific OUI(0x00 0x00 0x0F 0x22)
1736 */
1737 qdf_mem_copy(buf, ADAPTIVE_11R_STA_OUI, ADAPTIVE_11R_OUI_LEN);
1738 buf += ADAPTIVE_11R_OUI_LEN;
1739
1740 /* Fill Adaptive 11r Vendor specific Subtype (0x00) */
1741 *buf = ADAPTIVE_11R_OUI_SUBTYPE;
1742 buf++;
1743
1744 /* Fill Adaptive 11r Version (0x01) */
1745 *buf = ADAPTIVE_11R_OUI_VERSION;
1746 buf++;
1747
1748 /* Fill Adaptive 11r IE Data length (0x04) */
1749 *buf = ADAPTIVE_11R_DATA_LEN;
1750 buf++;
1751
1752 /* Fill Adaptive 11r IE Data (0x00 0x00 0x00 0x01) */
1753 qdf_mem_copy(buf, ADAPTIVE_11R_OUI_DATA, ADAPTIVE_11R_DATA_LEN);
1754
1755 *ie_len = ADAPTIVE_11R_STA_IE_LEN + 2;
1756 *ie_buf = adaptive_11r_ie;
1757
1758 return QDF_STATUS_SUCCESS;
1759}
1760
1761#else
1762static inline
1763QDF_STATUS lim_fill_adaptive_11r_ie(struct pe_session *pe_session,
1764 uint8_t **ie_buf, uint8_t *ie_len)
1765{
1766 return QDF_STATUS_SUCCESS;
1767}
1768#endif
1769
Abhishek Singhdd2cb572017-08-11 11:10:19 +05301770/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001771 * lim_send_assoc_req_mgmt_frame() - Send association request
1772 * @mac_ctx: Handle to MAC context
1773 * @mlm_assoc_req: Association request information
1774 * @pe_session: PE session information
1775 *
1776 * Builds and transmits association request frame to AP.
1777 *
1778 * Return: Void
1779 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001780void
Jeff Johnson9320c1e2018-12-02 13:09:20 -08001781lim_send_assoc_req_mgmt_frame(struct mac_context *mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001782 tLimMlmAssocReq *mlm_assoc_req,
Jeff Johnsona7815652018-11-18 22:58:30 -08001783 struct pe_session *pe_session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001784{
Naveen Rawat72475db2017-12-13 18:07:35 -08001785 int ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001786 tDot11fAssocRequest *frm;
1787 uint16_t caps;
1788 uint8_t *frame;
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001789 QDF_STATUS sir_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001790 tLimMlmAssocCnf assoc_cnf;
Hu Wang411e0cc2016-10-28 14:56:01 +08001791 uint32_t bytes = 0, payload, status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001792 uint8_t qos_enabled, wme_enabled, wsm_enabled;
1793 void *packet;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301794 QDF_STATUS qdf_status;
Srinivas Dasari22397902019-07-29 21:34:10 +05301795 uint16_t add_ie_len, current_len = 0, vendor_ie_len = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001796 uint8_t *add_ie;
Naveen Rawat08db88f2017-09-08 15:07:48 -07001797 const uint8_t *wps_ie = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001798 uint8_t power_caps = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001799 uint8_t tx_flag = 0;
1800 uint8_t sme_sessionid = 0;
1801 bool vht_enabled = false;
1802 tDot11fIEExtCap extr_ext_cap;
1803 bool extr_ext_flag = true;
1804 tpSirMacMgmtHdr mac_hdr;
Hu Wangfbd279d2016-10-31 18:24:34 +08001805 uint32_t ie_offset = 0;
1806 uint8_t *p_ext_cap = NULL;
1807 tDot11fIEExtCap bcn_ext_cap;
1808 uint8_t *bcn_ie = NULL;
1809 uint32_t bcn_ie_len = 0;
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +05301810 uint32_t aes_block_size_len = 0;
Naveen Rawat296a5182017-09-25 14:02:48 -07001811 enum rateid min_rid = RATEID_DEFAULT;
Srinivas Dasari22397902019-07-29 21:34:10 +05301812 uint8_t *mbo_ie = NULL, *adaptive_11r_ie = NULL, *vendor_ies = NULL;
Pragaspathi Thilagaraj54018e02019-04-25 01:32:17 +05301813 uint8_t mbo_ie_len = 0, adaptive_11r_ie_len = 0;
Srinivas Dasari603d4972019-09-20 17:28:44 +05301814 struct wlan_objmgr_peer *peer;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001815
Jeff Johnson8e9530b2019-03-18 13:41:42 -07001816 if (!pe_session) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001817 pe_err("pe_session is NULL");
yeshwanth sriram guntuka07831012017-06-30 12:26:57 +05301818 qdf_mem_free(mlm_assoc_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001819 return;
1820 }
1821
1822 sme_sessionid = pe_session->smeSessionId;
1823
1824 /* check this early to avoid unncessary operation */
Pragaspathi Thilagaraj64ae59d2019-06-22 13:00:34 +05301825 if (!pe_session->lim_join_req) {
1826 pe_err("pe_session->lim_join_req is NULL");
yeshwanth sriram guntuka07831012017-06-30 12:26:57 +05301827 qdf_mem_free(mlm_assoc_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001828 return;
1829 }
Pragaspathi Thilagaraj64ae59d2019-06-22 13:00:34 +05301830 add_ie_len = pe_session->lim_join_req->addIEAssoc.length;
1831 add_ie = pe_session->lim_join_req->addIEAssoc.addIEdata;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001832
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301833 frm = qdf_mem_malloc(sizeof(tDot11fAssocRequest));
Arif Hussainf5b6c412018-10-10 19:41:09 -07001834 if (!frm) {
yeshwanth sriram guntuka07831012017-06-30 12:26:57 +05301835 qdf_mem_free(mlm_assoc_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001836 return;
1837 }
hangtian127c9532019-01-12 13:29:07 +08001838 qdf_mem_zero((uint8_t *) frm, sizeof(tDot11fAssocRequest));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001839
Agrawal Ashish0f94b572016-02-22 13:27:06 +05301840 if (add_ie_len && pe_session->is_ext_caps_present) {
hangtian127c9532019-01-12 13:29:07 +08001841 qdf_mem_zero((uint8_t *) &extr_ext_cap,
1842 sizeof(tDot11fIEExtCap));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001843 sir_status = lim_strip_extcap_update_struct(mac_ctx,
1844 add_ie, &add_ie_len, &extr_ext_cap);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001845 if (QDF_STATUS_SUCCESS != sir_status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001846 extr_ext_flag = false;
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001847 pe_debug("Unable to Stripoff ExtCap IE from Assoc Req");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001848 } else {
1849 struct s_ext_cap *p_ext_cap = (struct s_ext_cap *)
1850 extr_ext_cap.bytes;
1851
1852 if (p_ext_cap->interworking_service)
1853 p_ext_cap->qos_map = 1;
Hu Wang411e0cc2016-10-28 14:56:01 +08001854 extr_ext_cap.num_bytes =
1855 lim_compute_ext_cap_ie_length(&extr_ext_cap);
1856 extr_ext_flag = (extr_ext_cap.num_bytes > 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001857 }
1858 } else {
Jeff Johnson47d75242018-05-12 15:58:53 -07001859 pe_debug("No addn IE or peer doesn't support addnIE for Assoc Req");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001860 extr_ext_flag = false;
1861 }
1862
1863 caps = mlm_assoc_req->capabilityInfo;
1864#if defined(FEATURE_WLAN_WAPI)
1865 /*
1866 * According to WAPI standard:
1867 * 7.3.1.4 Capability Information field
1868 * In WAPI, non-AP STAs within an ESS set the Privacy subfield to 0
1869 * in transmitted Association or Reassociation management frames.
1870 * APs ignore the Privacy subfield within received Association and
1871 * Reassociation management frames.
1872 */
1873 if (pe_session->encryptType == eSIR_ED_WPI)
1874 ((tSirMacCapabilityInfo *) &caps)->privacy = 0;
1875#endif
1876 swap_bit_field16(caps, (uint16_t *) &frm->Capabilities);
1877
1878 frm->ListenInterval.interval = mlm_assoc_req->listenInterval;
1879 populate_dot11f_ssid2(mac_ctx, &frm->SSID);
1880 populate_dot11f_supp_rates(mac_ctx, POPULATE_DOT11F_RATES_OPERATIONAL,
1881 &frm->SuppRates, pe_session);
1882
1883 qos_enabled = (pe_session->limQosEnabled) &&
1884 SIR_MAC_GET_QOS(pe_session->limCurrentBssCaps);
1885
1886 wme_enabled = (pe_session->limWmeEnabled) &&
1887 LIM_BSS_CAPS_GET(WME, pe_session->limCurrentBssQosCaps);
1888
1889 /* We prefer .11e asociations: */
1890 if (qos_enabled)
1891 wme_enabled = false;
1892
1893 wsm_enabled = (pe_session->limWsmEnabled) && wme_enabled &&
1894 LIM_BSS_CAPS_GET(WSM, pe_session->limCurrentBssQosCaps);
1895
1896 if (pe_session->lim11hEnable &&
Pragaspathi Thilagaraj64ae59d2019-06-22 13:00:34 +05301897 pe_session->lim_join_req->spectrumMgtIndicator == true) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001898 power_caps = true;
1899
1900 populate_dot11f_power_caps(mac_ctx, &frm->PowerCaps,
1901 LIM_ASSOC, pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001902 populate_dot11f_supp_channels(mac_ctx, &frm->SuppChannels,
1903 LIM_ASSOC, pe_session);
1904
1905 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001906 if (mac_ctx->rrm.rrmPEContext.rrmEnable &&
1907 SIR_MAC_GET_RRM(pe_session->limCurrentBssCaps)) {
1908 if (power_caps == false) {
1909 power_caps = true;
1910 populate_dot11f_power_caps(mac_ctx, &frm->PowerCaps,
1911 LIM_ASSOC, pe_session);
1912 }
1913 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001914 if (qos_enabled)
Naveen Rawatcd118312016-11-22 10:46:21 -08001915 populate_dot11f_qos_caps_station(mac_ctx, pe_session,
1916 &frm->QOSCapsStation);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001917
1918 populate_dot11f_ext_supp_rates(mac_ctx,
1919 POPULATE_DOT11F_RATES_OPERATIONAL, &frm->ExtSuppRates,
1920 pe_session);
1921
Gupta, Kapil54a16992016-01-13 19:34:02 +05301922 if (mac_ctx->rrm.rrmPEContext.rrmEnable &&
1923 SIR_MAC_GET_RRM(pe_session->limCurrentBssCaps))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001924 populate_dot11f_rrm_ie(mac_ctx, &frm->RRMEnabledCap,
1925 pe_session);
Deepak Dhamdhere641bf322016-01-06 15:19:03 -08001926
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001927 /*
1928 * The join request *should* contain zero or one of the WPA and RSN
1929 * IEs. The payload send along with the request is a
Jeff Johnson701444f2019-02-02 22:35:13 -08001930 * 'struct join_req'; the IE portion is held inside a 'tSirRSNie':
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001931 * typedef struct sSirRSNie
1932 * {
1933 * uint16_t length;
Srinivas Girigowdacf161402019-03-14 11:37:33 -07001934 * uint8_t rsnIEdata[WLAN_MAX_IE_LEN+2];
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001935 * } tSirRSNie, *tpSirRSNie;
1936 * So, we should be able to make the following two calls harmlessly,
1937 * since they do nothing if they don't find the given IE in the
1938 * bytestream with which they're provided.
1939 * The net effect of this will be to faithfully transmit whatever
1940 * security IE is in the join request.
1941 * However, if we're associating for the purpose of WPS
1942 * enrollment, and we've been configured to indicate that by
1943 * eliding the WPA or RSN IE, we just skip this:
1944 */
1945 if (add_ie_len && add_ie)
1946 wps_ie = limGetWscIEPtr(mac_ctx, add_ie, add_ie_len);
1947
Jeff Johnson8e9530b2019-03-18 13:41:42 -07001948 if (!wps_ie) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001949 populate_dot11f_rsn_opaque(mac_ctx,
Pragaspathi Thilagaraj64ae59d2019-06-22 13:00:34 +05301950 &pe_session->lim_join_req->rsnIE,
1951 &frm->RSNOpaque);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001952 populate_dot11f_wpa_opaque(mac_ctx,
Pragaspathi Thilagaraj64ae59d2019-06-22 13:00:34 +05301953 &pe_session->lim_join_req->rsnIE,
1954 &frm->WPAOpaque);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001955#if defined(FEATURE_WLAN_WAPI)
1956 populate_dot11f_wapi_opaque(mac_ctx,
Pragaspathi Thilagaraj64ae59d2019-06-22 13:00:34 +05301957 &(pe_session->lim_join_req->rsnIE),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001958 &frm->WAPIOpaque);
1959#endif /* defined(FEATURE_WLAN_WAPI) */
1960 }
1961 /* include WME EDCA IE as well */
1962 if (wme_enabled) {
1963 populate_dot11f_wmm_info_station_per_session(mac_ctx,
1964 pe_session, &frm->WMMInfoStation);
1965
1966 if (wsm_enabled)
1967 populate_dot11f_wmm_caps(&frm->WMMCaps);
1968 }
1969
1970 /*
1971 * Populate HT IEs, when operating in 11n and
1972 * when AP is also operating in 11n mode
1973 */
1974 if (pe_session->htCapability &&
1975 mac_ctx->lim.htCapabilityPresentInBeacon) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001976 pe_debug("Populate HT Caps in Assoc Request");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001977 populate_dot11f_ht_caps(mac_ctx, pe_session, &frm->HTCaps);
Naveen Rawata410c5a2016-09-19 14:22:33 -07001978 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_DEBUG,
1979 &frm->HTCaps, sizeof(frm->HTCaps));
Kiran Kumar Lokere722dccd2018-02-23 13:23:52 -08001980 } else if (pe_session->he_with_wep_tkip) {
1981 pe_debug("Populate HT Caps in Assoc Request with WEP/TKIP");
1982 populate_dot11f_ht_caps(mac_ctx, NULL, &frm->HTCaps);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001983 }
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001984 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 +05301985 frm->HTCaps.supportedChannelWidthSet,
1986 frm->HTCaps.mimoPowerSave,
1987 frm->HTCaps.greenField, frm->HTCaps.shortGI20MHz,
1988 frm->HTCaps.shortGI40MHz,
1989 frm->HTCaps.dsssCckMode40MHz,
1990 frm->HTCaps.maxRxAMPDUFactor);
1991
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001992 if (pe_session->vhtCapability &&
1993 pe_session->vhtCapabilityPresentInBeacon) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001994 pe_debug("Populate VHT IEs in Assoc Request");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001995 populate_dot11f_vht_caps(mac_ctx, pe_session, &frm->VHTCaps);
Naveen Rawata410c5a2016-09-19 14:22:33 -07001996 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_DEBUG,
1997 &frm->VHTCaps, sizeof(frm->VHTCaps));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001998 vht_enabled = true;
Kiran Kumar Lokere1d4094e2016-08-31 19:04:04 -07001999 if (pe_session->enableHtSmps &&
2000 !pe_session->supported_nss_1x1) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002001 pe_err("VHT OP mode IE in Assoc Req");
Kiran Kumar Lokere1d4094e2016-08-31 19:04:04 -07002002 populate_dot11f_operating_mode(mac_ctx,
2003 &frm->OperatingMode, pe_session);
2004 }
Kiran Kumar Lokere722dccd2018-02-23 13:23:52 -08002005 } else if (pe_session->he_with_wep_tkip) {
2006 pe_debug("Populate VHT IEs in Assoc Request with WEP/TKIP");
2007 populate_dot11f_vht_caps(mac_ctx, NULL, &frm->VHTCaps);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002008 }
Kiran Kumar Lokere722dccd2018-02-23 13:23:52 -08002009
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002010 if (!vht_enabled &&
2011 pe_session->is_vendor_specific_vhtcaps) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002012 pe_debug("Populate Vendor VHT IEs in Assoc Request");
Kapil Gupta4b2efbb2016-10-03 13:07:20 +05302013 frm->vendor_vht_ie.present = 1;
Kiran Kumar Lokere81722632017-09-26 12:11:43 -07002014 frm->vendor_vht_ie.sub_type =
2015 pe_session->vendor_specific_vht_ie_sub_type;
Kapil Gupta4b2efbb2016-10-03 13:07:20 +05302016 frm->vendor_vht_ie.VHTCaps.present = 1;
Abhinav Kumarb074f2f2018-09-15 15:32:11 +05302017 if (!mac_ctx->mlme_cfg->vht_caps.vht_cap_info.vendor_vhtie &&
Abhishek Singh68844282018-01-25 16:48:41 +05302018 pe_session->vht_config.su_beam_formee) {
2019 pe_debug("Disable SU beamformee for vendor IE");
2020 pe_session->vht_config.su_beam_formee = 0;
2021 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002022 populate_dot11f_vht_caps(mac_ctx, pe_session,
Kapil Gupta4b2efbb2016-10-03 13:07:20 +05302023 &frm->vendor_vht_ie.VHTCaps);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002024 vht_enabled = true;
2025 }
Agrawal Ashish0f94b572016-02-22 13:27:06 +05302026 if (pe_session->is_ext_caps_present)
2027 populate_dot11f_ext_cap(mac_ctx, vht_enabled,
2028 &frm->ExtCap, pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002029
Kiran Kumar Lokere89f01f02019-08-06 18:22:39 -07002030 populate_dot11f_qcn_ie(mac_ctx, &frm->qcn_ie, QCN_IE_ATTR_ID_ALL);
Selvaraj, Sridhara521aab2017-03-25 16:42:34 +05302031
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08002032 if (lim_is_session_he_capable(pe_session)) {
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07002033 pe_debug("Populate HE IEs");
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08002034 populate_dot11f_he_caps(mac_ctx, pe_session,
Naveen Rawatd8feac12017-09-08 15:08:39 -07002035 &frm->he_cap);
Kiran Kumar Lokere722dccd2018-02-23 13:23:52 -08002036 } else if (pe_session->he_with_wep_tkip) {
2037 pe_debug("Populate HE IEs in Assoc Request with WEP/TKIP");
2038 populate_dot11f_he_caps(mac_ctx, NULL, &frm->he_cap);
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08002039 }
Selvaraj, Sridharc2fe7a32017-02-02 19:20:16 +05302040
Pragaspathi Thilagaraj64ae59d2019-06-22 13:00:34 +05302041 if (pe_session->lim_join_req->is11Rconnection) {
Pragaspathi Thilagaraj1112c962019-05-23 23:45:38 +05302042 struct bss_description *bssdescr;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002043
Pragaspathi Thilagaraj64ae59d2019-06-22 13:00:34 +05302044 bssdescr = &pe_session->lim_join_req->bssDescription;
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002045 pe_debug("mdie = %02x %02x %02x",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002046 (unsigned int) bssdescr->mdie[0],
2047 (unsigned int) bssdescr->mdie[1],
2048 (unsigned int) bssdescr->mdie[2]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002049 populate_mdie(mac_ctx, &frm->MobilityDomain,
Pragaspathi Thilagaraj64ae59d2019-06-22 13:00:34 +05302050 pe_session->lim_join_req->bssDescription.mdie);
Pragaspathi Thilagaraj03839b92019-03-12 17:45:21 +05302051
2052 /*
2053 * IEEE80211-ai [13.2.4 FT initial mobility domain association
2054 * over FILS in an RSN]
2055 * Populate FT IE in association request. This FT IE should be
2056 * same as the FT IE received in auth response frame during the
2057 * FT-FILS authentication.
2058 */
2059 if (lim_is_fils_connection(pe_session))
2060 populate_fils_ft_info(mac_ctx, &frm->FTInfo,
2061 pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002062 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002063
2064#ifdef FEATURE_WLAN_ESE
2065 /*
2066 * ESE Version IE will be included in association request
2067 * when ESE is enabled on DUT through ini and it is also
2068 * advertised by the peer AP to which we are trying to
2069 * associate to.
2070 */
2071 if (pe_session->is_ese_version_ie_present &&
Wu Gao51a63562018-11-08 16:29:10 +08002072 mac_ctx->mlme_cfg->lfr.ese_enabled)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002073 populate_dot11f_ese_version(&frm->ESEVersion);
2074 /* For ESE Associations fill the ESE IEs */
2075 if (pe_session->isESEconnection &&
Pragaspathi Thilagaraj64ae59d2019-06-22 13:00:34 +05302076 pe_session->lim_join_req->isESEFeatureIniEnabled) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002077#ifndef FEATURE_DISABLE_RM
2078 populate_dot11f_ese_rad_mgmt_cap(&frm->ESERadMgmtCap);
2079#endif
2080 }
2081#endif
2082
Hu Wang411e0cc2016-10-28 14:56:01 +08002083 /*
2084 * Extcap IE now support variable length, merge Extcap IE from addn_ie
2085 * may change the frame size. Therefore, MUST merge ExtCap IE before
2086 * dot11f get packed payload size.
2087 */
2088 if (extr_ext_flag)
Hu Wangfbd279d2016-10-31 18:24:34 +08002089 lim_merge_extcap_struct(&frm->ExtCap, &extr_ext_cap, true);
2090
2091 /* Clear the bits in EXTCAP IE if AP not advertise it in beacon */
2092 if (frm->ExtCap.present && pe_session->is_ext_caps_present) {
2093 ie_offset = DOT11F_FF_TIMESTAMP_LEN +
2094 DOT11F_FF_BEACONINTERVAL_LEN +
2095 DOT11F_FF_CAPABILITIES_LEN;
2096
2097 qdf_mem_zero((uint8_t *)&bcn_ext_cap, sizeof(tDot11fIEExtCap));
2098 if (pe_session->beacon && pe_session->bcnLen > ie_offset) {
2099 bcn_ie = pe_session->beacon + ie_offset;
2100 bcn_ie_len = pe_session->bcnLen - ie_offset;
Naveen Rawat08db88f2017-09-08 15:07:48 -07002101 p_ext_cap = (uint8_t *)wlan_get_ie_ptr_from_eid(
Hu Wangfbd279d2016-10-31 18:24:34 +08002102 DOT11F_EID_EXTCAP,
Naveen Rawat08db88f2017-09-08 15:07:48 -07002103 bcn_ie, bcn_ie_len);
Hu Wangfbd279d2016-10-31 18:24:34 +08002104 lim_update_extcap_struct(mac_ctx, p_ext_cap,
2105 &bcn_ext_cap);
2106 lim_merge_extcap_struct(&frm->ExtCap, &bcn_ext_cap,
2107 false);
2108 }
Varun Reddy Yeturu4f849e52018-06-15 18:08:37 -07002109 /*
2110 * TWT extended capabilities should be populated after the
2111 * intersection of beacon caps and self caps is done because
2112 * the bits for TWT are unique to STA and AP and cannot be
2113 * intersected.
2114 */
2115 populate_dot11f_twt_extended_caps(mac_ctx, pe_session,
2116 &frm->ExtCap);
Hu Wangfbd279d2016-10-31 18:24:34 +08002117 }
Hu Wang411e0cc2016-10-28 14:56:01 +08002118
Jeff Johnson0301ecb2018-06-29 09:36:23 -07002119 if (QDF_STATUS_SUCCESS != lim_strip_supp_op_class_update_struct(mac_ctx,
Arif Hussain6cec6bc2017-02-14 13:46:26 -08002120 add_ie, &add_ie_len, &frm->SuppOperatingClasses))
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002121 pe_debug("Unable to Stripoff supp op classes IE from Assoc Req");
Arif Hussain6cec6bc2017-02-14 13:46:26 -08002122
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +05302123 if (lim_is_fils_connection(pe_session)) {
2124 populate_dot11f_fils_params(mac_ctx, frm, pe_session);
2125 aes_block_size_len = AES_BLOCK_SIZE;
2126 }
2127
2128 /*
Vignesh Viswanathandada7932018-09-18 12:57:55 +05302129 * MBO IE needs to be appendded at the end of the assoc request
2130 * frame and is not parsed and unpacked by the frame parser
2131 * as the supplicant can send multiple TLVs with same Attribute
2132 * in the MBO IE and the frame parser does not support multiple
2133 * TLVs with same attribute in a single IE.
2134 * Strip off the MBO IE from add_ie and append it at the end.
2135 */
2136 if (wlan_get_vendor_ie_ptr_from_oui(SIR_MAC_MBO_OUI,
2137 SIR_MAC_MBO_OUI_SIZE, add_ie, add_ie_len)) {
2138 mbo_ie = qdf_mem_malloc(DOT11F_IE_MBO_IE_MAX_LEN + 2);
Arif Hussainf5b6c412018-10-10 19:41:09 -07002139 if (!mbo_ie)
Vignesh Viswanathandada7932018-09-18 12:57:55 +05302140 goto end;
Vignesh Viswanathandada7932018-09-18 12:57:55 +05302141
2142 qdf_status = lim_strip_ie(mac_ctx, add_ie, &add_ie_len,
Srinivas Girigowda61771262019-04-01 11:55:19 -07002143 WLAN_ELEMID_VENDOR, ONE_BYTE,
Vignesh Viswanathandada7932018-09-18 12:57:55 +05302144 SIR_MAC_MBO_OUI,
2145 SIR_MAC_MBO_OUI_SIZE,
2146 mbo_ie, DOT11F_IE_MBO_IE_MAX_LEN);
2147 if (QDF_IS_STATUS_ERROR(qdf_status)) {
2148 pe_err("Failed to strip MBO IE");
Srinivas Dasari22397902019-07-29 21:34:10 +05302149 goto end;
Vignesh Viswanathandada7932018-09-18 12:57:55 +05302150 }
2151
2152 /* Include the EID and length fields */
2153 mbo_ie_len = mbo_ie[1] + 2;
2154 pe_debug("Stripped MBO IE of length %d", mbo_ie_len);
Srinivas Dasari603d4972019-09-20 17:28:44 +05302155
2156 peer = wlan_objmgr_get_peer_by_mac(mac_ctx->psoc,
2157 mlm_assoc_req->peerMacAddr,
2158 WLAN_MBO_ID);
2159 if (peer && !mlme_get_peer_pmf_status(peer)) {
2160 pe_debug("Peer doesn't support PMF, Don't add MBO IE");
2161 qdf_mem_free(mbo_ie);
2162 mbo_ie = NULL;
2163 mbo_ie_len = 0;
2164 }
2165 if (peer)
2166 wlan_objmgr_peer_release_ref(peer, WLAN_MBO_ID);
Vignesh Viswanathandada7932018-09-18 12:57:55 +05302167 }
2168
Srinivas Dasari22397902019-07-29 21:34:10 +05302169 /*
2170 * Strip rest of the vendor IEs and append to the assoc request frame.
2171 * Append the IEs just before MBO IEs as MBO IEs have to be at the
2172 * end of the frame.
2173 */
2174 if (wlan_get_ie_ptr_from_eid(WLAN_ELEMID_VENDOR, add_ie, add_ie_len)) {
2175 vendor_ies = qdf_mem_malloc(MAX_VENDOR_IES_LEN + 2);
2176 if (vendor_ies) {
2177 current_len = add_ie_len;
2178 qdf_status = lim_strip_ie(mac_ctx, add_ie, &add_ie_len,
2179 WLAN_ELEMID_VENDOR, ONE_BYTE,
2180 NULL,
2181 0,
2182 vendor_ies,
2183 MAX_VENDOR_IES_LEN);
2184 if (QDF_IS_STATUS_ERROR(qdf_status)) {
2185 pe_err("Failed to strip Vendor IEs");
2186 goto end;
2187 }
2188
2189 vendor_ie_len = current_len - add_ie_len;
2190 pe_debug("Stripped vendor IEs of size: %u",
2191 current_len);
2192 }
2193 }
2194
Pragaspathi Thilagaraj54018e02019-04-25 01:32:17 +05302195 qdf_status = lim_fill_adaptive_11r_ie(pe_session, &adaptive_11r_ie,
2196 &adaptive_11r_ie_len);
2197 if (QDF_IS_STATUS_ERROR(qdf_status)) {
2198 pe_err("Failed to fill adaptive 11r IE");
Srinivas Dasari22397902019-07-29 21:34:10 +05302199 goto end;
Pragaspathi Thilagaraj54018e02019-04-25 01:32:17 +05302200 }
2201
Vignesh Viswanathandada7932018-09-18 12:57:55 +05302202 /*
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +05302203 * Do unpack to populate the add_ie buffer to frm structure
2204 * before packing the frm structure. In this way, the IE ordering
2205 * which the latest 802.11 spec mandates is maintained.
2206 */
Naveen Rawat72475db2017-12-13 18:07:35 -08002207 if (add_ie_len) {
2208 ret = dot11f_unpack_assoc_request(mac_ctx, add_ie,
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +05302209 add_ie_len, frm, true);
Naveen Rawat72475db2017-12-13 18:07:35 -08002210 if (DOT11F_FAILED(ret)) {
2211 pe_err("unpack failed, ret: 0x%x", ret);
2212 goto end;
2213 }
2214 }
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +05302215
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002216 status = dot11f_get_packed_assoc_request_size(mac_ctx, frm, &payload);
2217 if (DOT11F_FAILED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002218 pe_err("Association Request packet size failure(0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002219 status);
2220 /* We'll fall back on the worst case scenario: */
2221 payload = sizeof(tDot11fAssocRequest);
2222 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002223 pe_warn("Association request packet size warning (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002224 status);
2225 }
2226
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +05302227 bytes = payload + sizeof(tSirMacMgmtHdr) +
Srinivas Dasari22397902019-07-29 21:34:10 +05302228 aes_block_size_len + mbo_ie_len + adaptive_11r_ie_len +
2229 vendor_ie_len;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002230
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302231 qdf_status = cds_packet_alloc((uint16_t) bytes, (void **)&frame,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002232 (void **)&packet);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302233 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002234 pe_err("Failed to allocate %d bytes", bytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002235
2236 pe_session->limMlmState = pe_session->limPrevMlmState;
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302237 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_MLM_STATE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002238 pe_session->peSessionId,
2239 pe_session->limMlmState));
2240
2241 /* Update PE session id */
2242 assoc_cnf.sessionId = pe_session->peSessionId;
2243
2244 assoc_cnf.resultCode = eSIR_SME_RESOURCES_UNAVAILABLE;
2245
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002246 lim_post_sme_message(mac_ctx, LIM_MLM_ASSOC_CNF,
2247 (uint32_t *) &assoc_cnf);
2248
yeshwanth sriram guntuka07831012017-06-30 12:26:57 +05302249 goto end;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002250 }
2251 /* Paranoia: */
hangtian127c9532019-01-12 13:29:07 +08002252 qdf_mem_zero(frame, bytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002253
2254 /* Next, we fill out the buffer descriptor: */
2255 lim_populate_mac_header(mac_ctx, frame, SIR_MAC_MGMT_FRAME,
2256 SIR_MAC_MGMT_ASSOC_REQ, pe_session->bssId,
Pragaspathi Thilagaraj7fb14222019-06-17 23:26:58 +05302257 pe_session->self_mac_addr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002258 /* That done, pack the Assoc Request: */
2259 status = dot11f_pack_assoc_request(mac_ctx, frm,
2260 frame + sizeof(tSirMacMgmtHdr), payload, &payload);
2261 if (DOT11F_FAILED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002262 pe_err("Assoc request pack failure (0x%08x)", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002263 cds_packet_free((void *)packet);
yeshwanth sriram guntuka07831012017-06-30 12:26:57 +05302264 goto end;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002265 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002266 pe_warn("Assoc request pack warning (0x%08x)", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002267 }
2268
Srinivas Dasari22397902019-07-29 21:34:10 +05302269 /* Copy the vendor IEs to the end of the frame */
2270 qdf_mem_copy(frame + sizeof(tSirMacMgmtHdr) + payload,
2271 vendor_ies, vendor_ie_len);
2272 payload = payload + vendor_ie_len;
2273
Vignesh Viswanathandada7932018-09-18 12:57:55 +05302274 /* Copy the MBO IE to the end of the frame */
2275 qdf_mem_copy(frame + sizeof(tSirMacMgmtHdr) + payload,
2276 mbo_ie, mbo_ie_len);
2277 payload = payload + mbo_ie_len;
2278
Pragaspathi Thilagaraj54018e02019-04-25 01:32:17 +05302279 /*
2280 * Copy the Vendor specific Adaptive 11r IE to end of the
2281 * assoc request frame
2282 */
2283 qdf_mem_copy(frame + sizeof(tSirMacMgmtHdr) + payload,
2284 adaptive_11r_ie, adaptive_11r_ie_len);
2285 payload = payload + adaptive_11r_ie_len;
2286
Jeff Johnson8e9530b2019-03-18 13:41:42 -07002287 if (pe_session->assocReq) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302288 qdf_mem_free(pe_session->assocReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002289 pe_session->assocReq = NULL;
Naveen Rawat83102ef2015-11-03 10:42:34 -08002290 pe_session->assocReqLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002291 }
2292
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +05302293 if (lim_is_fils_connection(pe_session)) {
2294 qdf_status = aead_encrypt_assoc_req(mac_ctx, pe_session,
2295 frame, &payload);
2296 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
2297 cds_packet_free((void *)packet);
Srinivas Dasari22397902019-07-29 21:34:10 +05302298 goto end;
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +05302299 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002300 }
2301
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302302 pe_session->assocReq = qdf_mem_malloc(payload);
Arif Hussainf5b6c412018-10-10 19:41:09 -07002303 if (pe_session->assocReq) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002304 /*
2305 * Store the Assoc request. This is sent to csr/hdd in
2306 * join cnf response.
2307 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302308 qdf_mem_copy(pe_session->assocReq,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002309 frame + sizeof(tSirMacMgmtHdr), payload);
2310 pe_session->assocReqLen = payload;
2311 }
2312
Liangwei Dong419d7302019-07-15 15:38:28 +08002313 if (wlan_reg_is_5ghz_ch_freq(pe_session->curr_op_freq) ||
2314 pe_session->opmode == QDF_P2P_CLIENT_MODE ||
2315 pe_session->opmode == QDF_P2P_GO_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002316 tx_flag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
2317
Pragaspathi Thilagaraje64714a2019-05-23 00:46:25 +05302318 if (pe_session->opmode == QDF_P2P_CLIENT_MODE ||
2319 pe_session->opmode == QDF_STA_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002320 tx_flag |= HAL_USE_PEER_STA_REQUESTED_MASK;
2321
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002322 mac_hdr = (tpSirMacMgmtHdr) frame;
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302323 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002324 pe_session->peSessionId, mac_hdr->fc.subType));
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +05302325
2326 pe_debug("Sending Association Request length %d to ", bytes);
Naveen Rawat296a5182017-09-25 14:02:48 -07002327 min_rid = lim_get_min_session_txrate(pe_session);
Krunal Sonic65fc492018-03-09 15:53:28 -08002328 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_ASSOC_START_EVENT,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07002329 pe_session, QDF_STATUS_SUCCESS, QDF_STATUS_SUCCESS);
Krunal Sonic65fc492018-03-09 15:53:28 -08002330 lim_diag_mgmt_tx_event_report(mac_ctx, mac_hdr,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07002331 pe_session, QDF_STATUS_SUCCESS, QDF_STATUS_SUCCESS);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302332 qdf_status =
Abhishek Singhdd2cb572017-08-11 11:10:19 +05302333 wma_tx_frameWithTxComplete(mac_ctx, packet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002334 (uint16_t) (sizeof(tSirMacMgmtHdr) + payload),
2335 TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS, 7,
Abhishek Singhdd2cb572017-08-11 11:10:19 +05302336 lim_tx_complete, frame, lim_assoc_tx_complete_cnf,
Naveen Rawat296a5182017-09-25 14:02:48 -07002337 tx_flag, sme_sessionid, false, 0, min_rid);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302338 MTRACE(qdf_trace
Anurag Chouhan6d760662016-02-20 16:05:43 +05302339 (QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302340 pe_session->peSessionId, qdf_status));
Naveen Rawat296a5182017-09-25 14:02:48 -07002341
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302342 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002343 pe_err("Failed to send Association Request (%X)!",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302344 qdf_status);
Abhishek Singhdd2cb572017-08-11 11:10:19 +05302345 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_ASSOC_ACK_EVENT,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07002346 pe_session, SENT_FAIL, QDF_STATUS_E_FAILURE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002347 /* Pkt will be freed up by the callback */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002348 }
Vignesh Viswanathandada7932018-09-18 12:57:55 +05302349
yeshwanth sriram guntuka07831012017-06-30 12:26:57 +05302350end:
Srinivas Dasari22397902019-07-29 21:34:10 +05302351 qdf_mem_free(vendor_ies);
2352 qdf_mem_free(mbo_ie);
2353
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002354 /* Free up buffer allocated for mlm_assoc_req */
Pragaspathi Thilagaraj54018e02019-04-25 01:32:17 +05302355 qdf_mem_free(adaptive_11r_ie);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302356 qdf_mem_free(mlm_assoc_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002357 mlm_assoc_req = NULL;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302358 qdf_mem_free(frm);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002359 return;
2360}
2361
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002362/**
Krunal Sonid2136c72018-06-01 17:26:39 -07002363 * lim_addba_rsp_tx_complete_cnf() - Confirmation for add BA response OTA
2364 * @context: pointer to global mac
2365 * @buf: buffer which is nothing but entire ADD BA frame
2366 * @tx_complete : Sent status
2367 * @params; tx completion params
2368 *
2369 * Return: This returns QDF_STATUS
2370 */
2371static QDF_STATUS lim_addba_rsp_tx_complete_cnf(void *context,
2372 qdf_nbuf_t buf,
2373 uint32_t tx_complete,
2374 void *params)
2375{
Jeff Johnson9320c1e2018-12-02 13:09:20 -08002376 struct mac_context *mac_ctx = (struct mac_context *)context;
Krunal Sonid2136c72018-06-01 17:26:39 -07002377 tSirMacMgmtHdr *mac_hdr;
2378 tDot11faddba_rsp rsp;
2379 void *soc = cds_get_context(QDF_MODULE_ID_SOC);
2380 void *pdev = cds_get_context(QDF_MODULE_ID_TXRX);
2381 uint8_t peer_id;
2382 void *peer;
2383 uint32_t frame_len;
2384 QDF_STATUS status;
2385 uint8_t *data;
2386
2387 if (tx_complete == WMI_MGMT_TX_COMP_TYPE_COMPLETE_OK)
2388 pe_debug("Add ba response successfully sent");
2389 else
2390 pe_debug("Fail to send add ba response");
2391
2392 if (!buf) {
2393 pe_err("Addba response frame buffer is NULL");
2394 return QDF_STATUS_E_FAILURE;
2395 }
2396
2397 data = qdf_nbuf_data(buf);
2398
2399 if (!data) {
2400 pe_err("Addba response frame is NULL");
2401 return QDF_STATUS_E_FAILURE;
2402 }
2403
2404 mac_hdr = (tSirMacMgmtHdr *)data;
2405 qdf_mem_zero((void *)&rsp, sizeof(tDot11faddba_rsp));
2406 frame_len = sizeof(rsp);
2407 status = dot11f_unpack_addba_rsp(mac_ctx, (uint8_t *)data +
2408 sizeof(*mac_hdr), frame_len,
2409 &rsp, false);
2410
2411 if (DOT11F_FAILED(status)) {
2412 pe_err("Failed to unpack and parse (0x%08x, %d bytes)",
2413 status, frame_len);
2414 goto error;
2415 }
2416
2417 peer = cdp_peer_get_ref_by_addr(soc, pdev, mac_hdr->da, &peer_id,
2418 PEER_DEBUG_ID_WMA_ADDBA_REQ);
2419 if (!peer) {
2420 pe_debug("no PEER found for mac_addr:%pM", mac_hdr->da);
2421 goto error;
2422 }
2423 cdp_addba_resp_tx_completion(soc, peer, rsp.addba_param_set.tid,
2424 tx_complete);
2425 cdp_peer_release_ref(soc, peer, PEER_DEBUG_ID_WMA_ADDBA_REQ);
2426error:
2427 if (buf)
2428 qdf_nbuf_free(buf);
2429
2430 return QDF_STATUS_SUCCESS;
2431}
2432
2433/**
Abhishek Singh7d3bc3e2016-02-03 17:45:01 +05302434 * lim_auth_tx_complete_cnf()- Confirmation for auth sent over the air
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05302435 * @context: pointer to global mac
2436 * @buf: buffer
Abhishek Singh7d3bc3e2016-02-03 17:45:01 +05302437 * @tx_complete : Sent status
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05302438 * @params; tx completion params
Abhishek Singh7d3bc3e2016-02-03 17:45:01 +05302439 *
2440 * Return: This returns QDF_STATUS
2441 */
2442
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05302443static QDF_STATUS lim_auth_tx_complete_cnf(void *context,
2444 qdf_nbuf_t buf,
2445 uint32_t tx_complete,
2446 void *params)
Abhishek Singh7d3bc3e2016-02-03 17:45:01 +05302447{
Jeff Johnson9320c1e2018-12-02 13:09:20 -08002448 struct mac_context *mac_ctx = (struct mac_context *)context;
Abhishek Singhdd2cb572017-08-11 11:10:19 +05302449 uint16_t auth_ack_status;
2450 uint16_t reason_code;
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05302451
Naveen Rawat684e8b12017-09-20 15:54:44 -07002452 pe_debug("tx_complete = %d %s", tx_complete,
Zhu Jianmin5d8e3fe2018-01-04 16:16:20 +08002453 (tx_complete == WMI_MGMT_TX_COMP_TYPE_COMPLETE_OK) ?
2454 "success" : "fail");
2455 if (tx_complete == WMI_MGMT_TX_COMP_TYPE_COMPLETE_OK) {
Abhishek Singh7d3bc3e2016-02-03 17:45:01 +05302456 mac_ctx->auth_ack_status = LIM_AUTH_ACK_RCD_SUCCESS;
Abhishek Singhdd2cb572017-08-11 11:10:19 +05302457 auth_ack_status = ACKED;
Jeff Johnson0301ecb2018-06-29 09:36:23 -07002458 reason_code = QDF_STATUS_SUCCESS;
Abhishek Singh7d3bc3e2016-02-03 17:45:01 +05302459 /* 'Change' timer for future activations */
2460 lim_deactivate_and_change_timer(mac_ctx, eLIM_AUTH_RETRY_TIMER);
2461 } else {
2462 mac_ctx->auth_ack_status = LIM_AUTH_ACK_RCD_FAILURE;
Abhishek Singhdd2cb572017-08-11 11:10:19 +05302463 auth_ack_status = NOT_ACKED;
Jeff Johnson0301ecb2018-06-29 09:36:23 -07002464 reason_code = QDF_STATUS_E_FAILURE;
Abhishek Singh7d3bc3e2016-02-03 17:45:01 +05302465 }
Himanshu Agarwal8b472bc2017-01-20 20:49:41 +05302466
2467 if (buf)
2468 qdf_nbuf_free(buf);
2469
Abhishek Singhdd2cb572017-08-11 11:10:19 +05302470 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_AUTH_ACK_EVENT,
2471 NULL, auth_ack_status, reason_code);
2472
Abhishek Singh7d3bc3e2016-02-03 17:45:01 +05302473 return QDF_STATUS_SUCCESS;
2474}
2475
2476/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002477 * lim_send_auth_mgmt_frame() - Send an Authentication frame
2478 *
2479 * @mac_ctx: Pointer to Global MAC structure
2480 * @auth_frame: Pointer to Authentication frame structure
2481 * @peer_addr: MAC address of destination peer
2482 * @wep_bit: wep bit in frame control for Authentication frame3
2483 * @session: PE session information
2484 *
2485 * This function is called by lim_process_mlm_messages(). Authentication frame
2486 * is formatted and sent when this function is called.
2487 *
2488 * Return: void
2489 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002490void
Jeff Johnson9320c1e2018-12-02 13:09:20 -08002491lim_send_auth_mgmt_frame(struct mac_context *mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002492 tpSirMacAuthFrameBody auth_frame,
2493 tSirMacAddr peer_addr,
yeshwanth sriram guntuka343a3f22017-07-27 18:30:18 +05302494 uint8_t wep_challenge_len,
Jeff Johnsona7815652018-11-18 22:58:30 -08002495 struct pe_session *session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002496{
2497 uint8_t *frame, *body;
2498 uint32_t frame_len = 0, body_len = 0;
2499 tpSirMacMgmtHdr mac_hdr;
2500 void *packet;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302501 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002502 uint8_t tx_flag = 0;
2503 uint8_t sme_sessionid = 0;
2504 uint16_t ft_ies_length = 0;
Krishna Kumaar Natarajan0517c602017-06-02 14:58:21 -07002505 bool challenge_req = false;
Naveen Rawat296a5182017-09-25 14:02:48 -07002506 enum rateid min_rid = RATEID_DEFAULT;
Rajasekaran Kalidoss7152a352018-11-19 09:58:35 +05302507 uint16_t ch_freq_tx_frame = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002508
Jeff Johnson8e9530b2019-03-18 13:41:42 -07002509 if (!session) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002510 pe_err("Error: psession Entry is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002511 return;
2512 }
2513
2514 sme_sessionid = session->smeSessionId;
2515
yeshwanth sriram guntuka343a3f22017-07-27 18:30:18 +05302516 if (wep_challenge_len) {
Krishna Kumaar Natarajan7e6a23c2016-04-05 14:45:24 -07002517 /*
2518 * Auth frame3 to be sent with encrypted framebody
2519 *
2520 * Allocate buffer for Authenticaton frame of size
2521 * equal to management frame header length plus 2 bytes
2522 * each for auth algorithm number, transaction number,
2523 * status code, 128 bytes for challenge text and
2524 * 4 bytes each for IV & ICV.
2525 */
Srinivas Girigowdacb7b8b82019-04-10 14:27:47 -07002526 pe_debug("Sending encrypted auth frame to " QDF_MAC_ADDR_STR,
Srinivas Girigowda34fbba02019-04-08 12:07:44 -07002527 QDF_MAC_ADDR_ARRAY(peer_addr));
Krishna Kumaar Natarajan7e6a23c2016-04-05 14:45:24 -07002528
yeshwanth sriram guntuka343a3f22017-07-27 18:30:18 +05302529 body_len = wep_challenge_len + LIM_ENCR_AUTH_INFO_LEN;
Krishna Kumaar Natarajan0517c602017-06-02 14:58:21 -07002530 frame_len = sizeof(tSirMacMgmtHdr) + body_len;
Krishna Kumaar Natarajan7e6a23c2016-04-05 14:45:24 -07002531
2532 goto alloc_packet;
2533 }
2534
Tushnim Bhattacharyya332b74c2018-08-10 10:55:51 -07002535 pe_debug("Sending Auth seq# %d status %d (%d) to "
Srinivas Girigowdacb7b8b82019-04-10 14:27:47 -07002536 QDF_MAC_ADDR_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002537 auth_frame->authTransactionSeqNumber,
2538 auth_frame->authStatusCode,
2539 (auth_frame->authStatusCode == eSIR_MAC_SUCCESS_STATUS),
Srinivas Girigowda34fbba02019-04-08 12:07:44 -07002540 QDF_MAC_ADDR_ARRAY(peer_addr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002541
2542 switch (auth_frame->authTransactionSeqNumber) {
2543 case SIR_MAC_AUTH_FRAME_1:
2544 /*
2545 * Allocate buffer for Authenticaton frame of size
2546 * equal to management frame header length plus 2 bytes
2547 * each for auth algorithm number, transaction number
2548 * and status code.
2549 */
2550
Krishna Kumaar Natarajan0517c602017-06-02 14:58:21 -07002551 body_len = SIR_MAC_AUTH_FRAME_INFO_LEN;
2552 frame_len = sizeof(tSirMacMgmtHdr) + body_len;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002553
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +05302554 frame_len += lim_create_fils_auth_data(mac_ctx,
2555 auth_frame, session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002556 if (auth_frame->authAlgoNumber == eSIR_FT_AUTH) {
Jeff Johnson8e9530b2019-03-18 13:41:42 -07002557 if (session->ftPEContext.pFTPreAuthReq &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002558 0 != session->ftPEContext.pFTPreAuthReq->
2559 ft_ies_length) {
2560 ft_ies_length = session->ftPEContext.
2561 pFTPreAuthReq->ft_ies_length;
2562 frame_len += ft_ies_length;
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002563 pe_debug("Auth frame, FTIES length added=%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002564 ft_ies_length);
2565 } else {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002566 pe_debug("Auth frame, Does not contain FTIES!");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002567 frame_len += (2 + SIR_MDIE_SIZE);
2568 }
2569 }
Pragaspathi Thilagaraj239883a2019-03-08 00:33:50 +05302570
2571 /* include MDIE in FILS authentication frame */
Pragaspathi Thilagaraj64ae59d2019-06-22 13:00:34 +05302572 if (session->lim_join_req &&
2573 session->lim_join_req->is11Rconnection &&
Pragaspathi Thilagaraj239883a2019-03-08 00:33:50 +05302574 auth_frame->authAlgoNumber == SIR_FILS_SK_WITHOUT_PFS &&
Pragaspathi Thilagaraj64ae59d2019-06-22 13:00:34 +05302575 session->lim_join_req->bssDescription.mdiePresent)
Pragaspathi Thilagaraj239883a2019-03-08 00:33:50 +05302576 frame_len += (2 + SIR_MDIE_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002577 break;
2578
2579 case SIR_MAC_AUTH_FRAME_2:
2580 if ((auth_frame->authAlgoNumber == eSIR_OPEN_SYSTEM) ||
2581 ((auth_frame->authAlgoNumber == eSIR_SHARED_KEY) &&
2582 (auth_frame->authStatusCode !=
2583 eSIR_MAC_SUCCESS_STATUS))) {
2584 /*
2585 * Allocate buffer for Authenticaton frame of size
2586 * equal to management frame header length plus
2587 * 2 bytes each for auth algorithm number,
2588 * transaction number and status code.
2589 */
2590
Krishna Kumaar Natarajan0517c602017-06-02 14:58:21 -07002591 body_len = SIR_MAC_AUTH_FRAME_INFO_LEN;
2592 frame_len = sizeof(tSirMacMgmtHdr) + body_len;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002593 } else {
2594 /*
2595 * Shared Key algorithm with challenge text
2596 * to be sent.
2597 *
2598 * Allocate buffer for Authenticaton frame of size
2599 * equal to management frame header length plus
2600 * 2 bytes each for auth algorithm number,
2601 * transaction number, status code and 128 bytes
2602 * for challenge text.
2603 */
2604
Krishna Kumaar Natarajan0517c602017-06-02 14:58:21 -07002605 challenge_req = true;
2606 body_len = SIR_MAC_AUTH_FRAME_INFO_LEN +
yeshwanth sriram guntuka5c71a292017-08-24 15:51:19 +05302607 SIR_MAC_SAP_AUTH_CHALLENGE_LENGTH +
2608 SIR_MAC_CHALLENGE_ID_LEN;
Krishna Kumaar Natarajan0517c602017-06-02 14:58:21 -07002609 frame_len = sizeof(tSirMacMgmtHdr) + body_len;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002610 }
2611 break;
2612
2613 case SIR_MAC_AUTH_FRAME_3:
Krishna Kumaar Natarajan7e6a23c2016-04-05 14:45:24 -07002614 /*
2615 * Auth frame3 to be sent without encrypted framebody
2616 *
2617 * Allocate buffer for Authenticaton frame of size equal
2618 * to management frame header length plus 2 bytes each
2619 * for auth algorithm number, transaction number and
2620 * status code.
2621 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002622
Krishna Kumaar Natarajan0517c602017-06-02 14:58:21 -07002623 body_len = SIR_MAC_AUTH_FRAME_INFO_LEN;
2624 frame_len = sizeof(tSirMacMgmtHdr) + body_len;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002625 break;
2626
2627 case SIR_MAC_AUTH_FRAME_4:
2628 /*
2629 * Allocate buffer for Authenticaton frame of size equal
2630 * to management frame header length plus 2 bytes each
2631 * for auth algorithm number, transaction number and
2632 * status code.
2633 */
2634
Krishna Kumaar Natarajan0517c602017-06-02 14:58:21 -07002635 body_len = SIR_MAC_AUTH_FRAME_INFO_LEN;
2636 frame_len = sizeof(tSirMacMgmtHdr) + body_len;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002637
2638 break;
Krishna Kumaar Natarajan7e6a23c2016-04-05 14:45:24 -07002639 default:
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002640 pe_err("Invalid auth transaction seq num");
Krishna Kumaar Natarajan7e6a23c2016-04-05 14:45:24 -07002641 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002642 } /* switch (auth_frame->authTransactionSeqNumber) */
2643
Krishna Kumaar Natarajan7e6a23c2016-04-05 14:45:24 -07002644alloc_packet:
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302645 qdf_status = cds_packet_alloc((uint16_t) frame_len, (void **)&frame,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002646 (void **)&packet);
2647
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302648 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002649 pe_err("call to bufAlloc failed for AUTH frame");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002650 return;
2651 }
2652
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302653 qdf_mem_zero(frame, frame_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002654
2655 /* Prepare BD */
2656 lim_populate_mac_header(mac_ctx, frame, SIR_MAC_MGMT_FRAME,
Pragaspathi Thilagaraj7fb14222019-06-17 23:26:58 +05302657 SIR_MAC_MGMT_AUTH, peer_addr, session->self_mac_addr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002658 mac_hdr = (tpSirMacMgmtHdr) frame;
yeshwanth sriram guntuka343a3f22017-07-27 18:30:18 +05302659 if (wep_challenge_len)
2660 mac_hdr->fc.wep = LIM_WEP_IN_FC;
2661 else
2662 mac_hdr->fc.wep = LIM_NO_WEP_IN_FC;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002663
2664 /* Prepare BSSId */
Rajeev Kumarcf835a02016-04-15 15:01:31 -07002665 if (LIM_IS_AP_ROLE(session))
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302666 qdf_mem_copy((uint8_t *) mac_hdr->bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002667 (uint8_t *) session->bssId,
2668 sizeof(tSirMacAddr));
2669
2670 /* Prepare Authentication frame body */
2671 body = frame + sizeof(tSirMacMgmtHdr);
2672
yeshwanth sriram guntuka343a3f22017-07-27 18:30:18 +05302673 if (wep_challenge_len) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302674 qdf_mem_copy(body, (uint8_t *) auth_frame, body_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002675
Srinivas Girigowdacb7b8b82019-04-10 14:27:47 -07002676 pe_debug("Sending Auth seq# 3 to " QDF_MAC_ADDR_STR,
Srinivas Girigowda34fbba02019-04-08 12:07:44 -07002677 QDF_MAC_ADDR_ARRAY(mac_hdr->da));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002678
2679 } else {
2680 *((uint16_t *) (body)) =
2681 sir_swap_u16if_needed(auth_frame->authAlgoNumber);
2682 body += sizeof(uint16_t);
2683 body_len -= sizeof(uint16_t);
2684
2685 *((uint16_t *) (body)) =
2686 sir_swap_u16if_needed(
2687 auth_frame->authTransactionSeqNumber);
2688 body += sizeof(uint16_t);
2689 body_len -= sizeof(uint16_t);
2690
2691 *((uint16_t *) (body)) =
2692 sir_swap_u16if_needed(auth_frame->authStatusCode);
2693 body += sizeof(uint16_t);
2694 body_len -= sizeof(uint16_t);
Krishna Kumaar Natarajan0517c602017-06-02 14:58:21 -07002695
2696 if (challenge_req) {
2697 if (body_len < SIR_MAC_AUTH_CHALLENGE_BODY_LEN) {
Himanshu Agarwalc422ca72017-09-19 11:07:36 +05302698 /* copy challenge IE id, len, challenge text */
2699 *body = auth_frame->type;
2700 body++;
2701 body_len -= sizeof(uint8_t);
2702 *body = auth_frame->length;
2703 body++;
2704 body_len -= sizeof(uint8_t);
2705 qdf_mem_copy(body, auth_frame->challengeText,
Krishna Kumaar Natarajan0517c602017-06-02 14:58:21 -07002706 body_len);
2707 pe_err("Incomplete challenge info: length: %d, expected: %d",
2708 body_len,
2709 SIR_MAC_AUTH_CHALLENGE_BODY_LEN);
2710 body += body_len;
2711 body_len = 0;
2712 } else {
2713 /* copy challenge IE id, len, challenge text */
2714 *body = auth_frame->type;
2715 body++;
2716 *body = auth_frame->length;
2717 body++;
2718 qdf_mem_copy(body, auth_frame->challengeText,
yeshwanth sriram guntuka5c71a292017-08-24 15:51:19 +05302719 SIR_MAC_SAP_AUTH_CHALLENGE_LENGTH);
2720 body += SIR_MAC_SAP_AUTH_CHALLENGE_LENGTH;
Krishna Kumaar Natarajan0517c602017-06-02 14:58:21 -07002721
yeshwanth sriram guntuka5c71a292017-08-24 15:51:19 +05302722 body_len -= SIR_MAC_SAP_AUTH_CHALLENGE_LENGTH +
2723 SIR_MAC_CHALLENGE_ID_LEN;
Krishna Kumaar Natarajan0517c602017-06-02 14:58:21 -07002724 }
2725 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002726
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002727 if ((auth_frame->authAlgoNumber == eSIR_FT_AUTH) &&
2728 (auth_frame->authTransactionSeqNumber ==
2729 SIR_MAC_AUTH_FRAME_1) &&
Jeff Johnson8e9530b2019-03-18 13:41:42 -07002730 (session->ftPEContext.pFTPreAuthReq)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002731
2732 if (ft_ies_length > 0) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302733 qdf_mem_copy(body,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002734 session->ftPEContext.
2735 pFTPreAuthReq->ft_ies,
2736 ft_ies_length);
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002737 pe_debug("Auth1 Frame FTIE is: ");
Srinivas Girigowdab896a562017-03-16 17:41:26 -07002738 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_PE,
2739 QDF_TRACE_LEVEL_DEBUG,
2740 (uint8_t *) body,
2741 ft_ies_length);
Jeff Johnson8e9530b2019-03-18 13:41:42 -07002742 } else if (session->ftPEContext.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002743 pFTPreAuthReq->pbssDescription) {
2744 /* MDID attr is 54 */
Srinivas Girigowda61771262019-04-01 11:55:19 -07002745 *body = WLAN_ELEMID_MOBILITY_DOMAIN;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002746 body++;
2747 *body = SIR_MDIE_SIZE;
2748 body++;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302749 qdf_mem_copy(body,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002750 &session->ftPEContext.pFTPreAuthReq->
2751 pbssDescription->mdie[0],
2752 SIR_MDIE_SIZE);
2753 }
Pragaspathi Thilagaraj239883a2019-03-08 00:33:50 +05302754 } else if ((auth_frame->authAlgoNumber ==
2755 SIR_FILS_SK_WITHOUT_PFS) &&
2756 (auth_frame->authTransactionSeqNumber ==
2757 SIR_MAC_AUTH_FRAME_1)) {
2758 pe_debug("FILS: appending fils Auth data");
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +05302759 lim_add_fils_data_to_auth_frame(session, body);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002760 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002761
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002762 pe_debug("*** Sending Auth seq# %d status %d (%d) to "
Srinivas Girigowdacb7b8b82019-04-10 14:27:47 -07002763 QDF_MAC_ADDR_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002764 auth_frame->authTransactionSeqNumber,
2765 auth_frame->authStatusCode,
2766 (auth_frame->authStatusCode ==
2767 eSIR_MAC_SUCCESS_STATUS),
Srinivas Girigowda34fbba02019-04-08 12:07:44 -07002768 QDF_MAC_ADDR_ARRAY(mac_hdr->da));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002769 }
Srinivas Girigowdab896a562017-03-16 17:41:26 -07002770 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_PE,
2771 QDF_TRACE_LEVEL_DEBUG,
2772 frame, frame_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002773
Jeff Johnson8e9530b2019-03-18 13:41:42 -07002774 if ((session->ftPEContext.pFTPreAuthReq) &&
Liangwei Dong419d7302019-07-15 15:38:28 +08002775 (lim_get_rf_band(
2776 session->ftPEContext.pFTPreAuthReq->preAuthchannelNum)) ==
2777 BAND_5G)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002778 tx_flag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
Liangwei Dong419d7302019-07-15 15:38:28 +08002779 else if (wlan_reg_is_5ghz_ch_freq(session->curr_op_freq) ||
2780 session->opmode == QDF_P2P_CLIENT_MODE ||
2781 session->opmode == QDF_P2P_GO_MODE)
Deepthi Gowri1de51e32016-09-01 15:47:28 +05302782 tx_flag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002783
Pragaspathi Thilagaraje64714a2019-05-23 00:46:25 +05302784 if (session->opmode == QDF_P2P_CLIENT_MODE ||
2785 session->opmode == QDF_STA_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002786 tx_flag |= HAL_USE_PEER_STA_REQUESTED_MASK;
2787
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302788 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002789 session->peSessionId, mac_hdr->fc.subType));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002790
Abhishek Singhdd2cb572017-08-11 11:10:19 +05302791 mac_ctx->auth_ack_status = LIM_AUTH_ACK_NOT_RCD;
Naveen Rawat296a5182017-09-25 14:02:48 -07002792 min_rid = lim_get_min_session_txrate(session);
Krunal Sonic65fc492018-03-09 15:53:28 -08002793 lim_diag_mgmt_tx_event_report(mac_ctx, mac_hdr,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07002794 session, QDF_STATUS_SUCCESS, QDF_STATUS_SUCCESS);
Rajasekaran Kalidoss7152a352018-11-19 09:58:35 +05302795
Jeff Johnson8e9530b2019-03-18 13:41:42 -07002796 if (session->ftPEContext.pFTPreAuthReq)
Rajasekaran Kalidoss7152a352018-11-19 09:58:35 +05302797 ch_freq_tx_frame = cds_chan_to_freq(
2798 session->ftPEContext.pFTPreAuthReq->preAuthchannelNum);
2799
Abhishek Singhdd2cb572017-08-11 11:10:19 +05302800 qdf_status = wma_tx_frameWithTxComplete(mac_ctx, packet,
2801 (uint16_t)frame_len,
2802 TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS,
2803 7, lim_tx_complete, frame,
2804 lim_auth_tx_complete_cnf,
Rajasekaran Kalidoss7152a352018-11-19 09:58:35 +05302805 tx_flag, sme_sessionid, false,
2806 ch_freq_tx_frame, min_rid);
Abhishek Singhdd2cb572017-08-11 11:10:19 +05302807 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
2808 session->peSessionId, qdf_status));
2809 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
2810 pe_err("*** Could not send Auth frame, retCode=%X ***",
2811 qdf_status);
2812 mac_ctx->auth_ack_status = LIM_AUTH_ACK_RCD_FAILURE;
2813 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_AUTH_ACK_EVENT,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07002814 session, SENT_FAIL, QDF_STATUS_E_FAILURE);
Abhishek Singhdd2cb572017-08-11 11:10:19 +05302815 /* Pkt will be freed up by the callback */
Abhishek Singh7d3bc3e2016-02-03 17:45:01 +05302816 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002817 return;
2818}
2819
Jeff Johnson9320c1e2018-12-02 13:09:20 -08002820QDF_STATUS lim_send_deauth_cnf(struct mac_context *mac_ctx)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002821{
2822 uint16_t aid;
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002823 tpDphHashNode sta_ds;
2824 tLimMlmDeauthReq *deauth_req;
2825 tLimMlmDeauthCnf deauth_cnf;
Jeff Johnsona7815652018-11-18 22:58:30 -08002826 struct pe_session *session_entry;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002827
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002828 deauth_req = mac_ctx->lim.limDisassocDeauthCnfReq.pMlmDeauthReq;
2829 if (deauth_req) {
2830 if (tx_timer_running(
Pragaspathi Thilagaraj9f230382019-06-24 11:54:05 +05302831 &mac_ctx->lim.lim_timers.gLimDeauthAckTimer))
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002832 lim_deactivate_and_change_timer(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002833 eLIM_DEAUTH_ACK_TIMER);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002834
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002835 session_entry = pe_find_session_by_session_id(mac_ctx,
2836 deauth_req->sessionId);
Jeff Johnson8e9530b2019-03-18 13:41:42 -07002837 if (!session_entry) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002838 pe_err("session does not exist for given sessionId");
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002839 deauth_cnf.resultCode =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002840 eSIR_SME_INVALID_PARAMETERS;
2841 goto end;
2842 }
2843
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002844 sta_ds =
2845 dph_lookup_hash_entry(mac_ctx,
2846 deauth_req->peer_macaddr.bytes,
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002847 &aid,
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002848 &session_entry->dph.dphHashTable);
Jeff Johnson8e9530b2019-03-18 13:41:42 -07002849 if (!sta_ds) {
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002850 deauth_cnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002851 goto end;
2852 }
2853
2854 /* / Receive path cleanup with dummy packet */
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002855 lim_ft_cleanup_pre_auth_info(mac_ctx, session_entry);
2856 lim_cleanup_rx_path(mac_ctx, sta_ds, session_entry);
2857 if ((session_entry->limSystemRole == eLIM_STA_ROLE) &&
2858 (
Abhishek Singhe0680852015-12-16 14:28:48 +05302859#ifdef FEATURE_WLAN_ESE
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002860 (session_entry->isESEconnection) ||
Abhishek Singhe0680852015-12-16 14:28:48 +05302861#endif
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002862 (session_entry->isFastRoamIniFeatureEnabled) ||
2863 (session_entry->is11Rconnection))) {
Jeff Johnson11bd4f32017-09-18 08:15:17 -07002864 pe_debug("FT Preauth (%pK,%d) Deauth rc %d src = %d",
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002865 session_entry,
2866 session_entry->peSessionId,
2867 deauth_req->reasonCode,
2868 deauth_req->deauthTrigger);
2869 lim_ft_cleanup(mac_ctx, session_entry);
Deepak Dhamdhere262d95a2016-01-10 16:36:53 -08002870 } else {
Deepak Dhamdhere262d95a2016-01-10 16:36:53 -08002871#ifdef FEATURE_WLAN_ESE
Nirav Shahf359dd22019-02-20 10:34:28 +05302872 pe_debug("No FT Preauth Session Cleanup in role %d"
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002873 " isESE %d"
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002874 " isLFR %d"
2875 " is11r %d, Deauth reason %d Trigger = %d",
2876 session_entry->limSystemRole,
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002877 session_entry->isESEconnection,
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002878 session_entry->isFastRoamIniFeatureEnabled,
2879 session_entry->is11Rconnection,
2880 deauth_req->reasonCode,
2881 deauth_req->deauthTrigger);
Nirav Shahf359dd22019-02-20 10:34:28 +05302882#else
2883 pe_debug("No FT Preauth Session Cleanup in role %d"
2884 " isLFR %d"
2885 " is11r %d, Deauth reason %d Trigger = %d",
2886 session_entry->limSystemRole,
2887 session_entry->isFastRoamIniFeatureEnabled,
2888 session_entry->is11Rconnection,
2889 deauth_req->reasonCode,
2890 deauth_req->deauthTrigger);
2891#endif
Deepak Dhamdhere262d95a2016-01-10 16:36:53 -08002892 }
2893 /* Free up buffer allocated for mlmDeauthReq */
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002894 qdf_mem_free(deauth_req);
2895 mac_ctx->lim.limDisassocDeauthCnfReq.pMlmDeauthReq = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002896 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302897 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002898end:
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002899 qdf_copy_macaddr(&deauth_cnf.peer_macaddr,
2900 &deauth_req->peer_macaddr);
2901 deauth_cnf.deauthTrigger = deauth_req->deauthTrigger;
2902 deauth_cnf.aid = deauth_req->aid;
2903 deauth_cnf.sessionId = deauth_req->sessionId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002904
2905 /* Free up buffer allocated */
2906 /* for mlmDeauthReq */
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002907 qdf_mem_free(deauth_req);
2908 mac_ctx->lim.limDisassocDeauthCnfReq.pMlmDeauthReq = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002909
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002910 lim_post_sme_message(mac_ctx,
2911 LIM_MLM_DEAUTH_CNF, (uint32_t *) &deauth_cnf);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302912 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002913}
2914
2915/**
2916 * lim_send_disassoc_cnf() - Send disassoc confirmation to SME
2917 *
2918 * @mac_ctx: Handle to MAC context
2919 *
2920 * Sends disassoc confirmation to SME. Removes disassoc request stored
2921 * in lim.
2922 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302923 * Return: QDF_STATUS_SUCCESS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002924 */
2925
Jeff Johnson9320c1e2018-12-02 13:09:20 -08002926QDF_STATUS lim_send_disassoc_cnf(struct mac_context *mac_ctx)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002927{
2928 uint16_t aid;
2929 tpDphHashNode sta_ds;
2930 tLimMlmDisassocCnf disassoc_cnf;
Jeff Johnsona7815652018-11-18 22:58:30 -08002931 struct pe_session *pe_session;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002932 tLimMlmDisassocReq *disassoc_req;
2933
2934 disassoc_req = mac_ctx->lim.limDisassocDeauthCnfReq.pMlmDisassocReq;
2935 if (disassoc_req) {
2936 if (tx_timer_running(
Pragaspathi Thilagaraj9f230382019-06-24 11:54:05 +05302937 &mac_ctx->lim.lim_timers.gLimDisassocAckTimer))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002938 lim_deactivate_and_change_timer(mac_ctx,
2939 eLIM_DISASSOC_ACK_TIMER);
2940
2941 pe_session = pe_find_session_by_session_id(
2942 mac_ctx, disassoc_req->sessionId);
Jeff Johnson8e9530b2019-03-18 13:41:42 -07002943 if (!pe_session) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002944 pe_err("No session for given sessionId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002945 disassoc_cnf.resultCode =
2946 eSIR_SME_INVALID_PARAMETERS;
2947 goto end;
2948 }
2949
2950 sta_ds = dph_lookup_hash_entry(mac_ctx,
Srinivas Girigowdadd3c5132016-01-05 19:41:27 -08002951 disassoc_req->peer_macaddr.bytes, &aid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002952 &pe_session->dph.dphHashTable);
Jeff Johnson8e9530b2019-03-18 13:41:42 -07002953 if (!sta_ds) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002954 pe_err("StaDs Null");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002955 disassoc_cnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
2956 goto end;
2957 }
2958 /* Receive path cleanup with dummy packet */
Jeff Johnson0301ecb2018-06-29 09:36:23 -07002959 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002960 lim_cleanup_rx_path(mac_ctx, sta_ds, pe_session)) {
2961 disassoc_cnf.resultCode =
2962 eSIR_SME_RESOURCES_UNAVAILABLE;
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002963 pe_err("cleanup_rx_path error");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002964 goto end;
2965 }
Deepak Dhamdhere57c95ff2016-09-30 16:44:44 -07002966 if (LIM_IS_STA_ROLE(pe_session) &&
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002967 (disassoc_req->reasonCode !=
2968 eSIR_MAC_DISASSOC_DUE_TO_FTHANDOFF_REASON)) {
Jeff Johnson11bd4f32017-09-18 08:15:17 -07002969 pe_debug("FT Preauth Session (%pK %d) Clean up",
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002970 pe_session, pe_session->peSessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002971
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002972 /* Delete FT session if there exists one */
2973 lim_ft_cleanup_pre_auth_info(mac_ctx, pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002974 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002975 /* Free up buffer allocated for mlmDisassocReq */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302976 qdf_mem_free(disassoc_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002977 mac_ctx->lim.limDisassocDeauthCnfReq.pMlmDisassocReq = NULL;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302978 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002979 } else {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302980 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002981 }
2982end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302983 qdf_mem_copy((uint8_t *) &disassoc_cnf.peerMacAddr,
Srinivas Girigowdadd3c5132016-01-05 19:41:27 -08002984 (uint8_t *) disassoc_req->peer_macaddr.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05302985 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002986 disassoc_cnf.aid = disassoc_req->aid;
2987 disassoc_cnf.disassocTrigger = disassoc_req->disassocTrigger;
2988
2989 /* Update PE session ID */
2990 disassoc_cnf.sessionId = disassoc_req->sessionId;
2991
Jeff Johnson8e9530b2019-03-18 13:41:42 -07002992 if (disassoc_req) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002993 /* / Free up buffer allocated for mlmDisassocReq */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302994 qdf_mem_free(disassoc_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002995 mac_ctx->lim.limDisassocDeauthCnfReq.pMlmDisassocReq = NULL;
2996 }
2997
2998 lim_post_sme_message(mac_ctx, LIM_MLM_DISASSOC_CNF,
2999 (uint32_t *) &disassoc_cnf);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303000 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003001}
3002
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05303003QDF_STATUS lim_disassoc_tx_complete_cnf(void *context,
Liangwei Dongc0b2e332017-11-16 06:04:46 -05003004 uint32_t tx_success,
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05303005 void *params)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003006{
Jeff Johnson9320c1e2018-12-02 13:09:20 -08003007 struct mac_context *max_ctx = (struct mac_context *)context;
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05303008
Liangwei Dongc0b2e332017-11-16 06:04:46 -05003009 pe_debug("tx_success: %d", tx_success);
3010
3011 return lim_send_disassoc_cnf(max_ctx);
3012}
3013
3014static QDF_STATUS lim_disassoc_tx_complete_cnf_handler(void *context,
3015 qdf_nbuf_t buf,
3016 uint32_t tx_success,
3017 void *params)
3018{
Jeff Johnson9320c1e2018-12-02 13:09:20 -08003019 struct mac_context *max_ctx = (struct mac_context *)context;
Liangwei Dongc0b2e332017-11-16 06:04:46 -05003020 QDF_STATUS status_code;
3021 struct scheduler_msg msg = {0};
3022
3023 pe_debug("tx_success: %d", tx_success);
Himanshu Agarwal8b472bc2017-01-20 20:49:41 +05303024
3025 if (buf)
3026 qdf_nbuf_free(buf);
Liangwei Dongc0b2e332017-11-16 06:04:46 -05003027 msg.type = (uint16_t) WMA_DISASSOC_TX_COMP;
3028 msg.bodyptr = params;
3029 msg.bodyval = tx_success;
Himanshu Agarwal8b472bc2017-01-20 20:49:41 +05303030
Liangwei Dongc0b2e332017-11-16 06:04:46 -05003031 status_code = lim_post_msg_high_priority(max_ctx, &msg);
3032 if (status_code != QDF_STATUS_SUCCESS)
3033 pe_err("posting message: %X to LIM failed, reason: %d",
3034 msg.type, status_code);
3035 return status_code;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003036}
3037
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05303038QDF_STATUS lim_deauth_tx_complete_cnf(void *context,
Liangwei Dongc0b2e332017-11-16 06:04:46 -05003039 uint32_t tx_success,
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05303040 void *params)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003041{
Jeff Johnson9320c1e2018-12-02 13:09:20 -08003042 struct mac_context *mac_ctx = (struct mac_context *)context;
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05303043
Liangwei Dongc0b2e332017-11-16 06:04:46 -05003044 pe_debug("tx_success: %d", tx_success);
3045
3046 return lim_send_deauth_cnf(mac_ctx);
3047}
3048
3049static QDF_STATUS lim_deauth_tx_complete_cnf_handler(void *context,
3050 qdf_nbuf_t buf,
3051 uint32_t tx_success,
3052 void *params)
3053{
Jeff Johnson9320c1e2018-12-02 13:09:20 -08003054 struct mac_context *mac_ctx = (struct mac_context *)context;
Liangwei Dongc0b2e332017-11-16 06:04:46 -05003055 QDF_STATUS status_code;
3056 struct scheduler_msg msg = {0};
3057
3058 pe_debug("tx_success: %d", tx_success);
Himanshu Agarwal8b472bc2017-01-20 20:49:41 +05303059
3060 if (buf)
3061 qdf_nbuf_free(buf);
Liangwei Dongc0b2e332017-11-16 06:04:46 -05003062 msg.type = (uint16_t) WMA_DEAUTH_TX_COMP;
3063 msg.bodyptr = params;
3064 msg.bodyval = tx_success;
Himanshu Agarwal8b472bc2017-01-20 20:49:41 +05303065
Liangwei Dongc0b2e332017-11-16 06:04:46 -05003066 status_code = lim_post_msg_high_priority(mac_ctx, &msg);
3067 if (status_code != QDF_STATUS_SUCCESS)
3068 pe_err("posting message: %X to LIM failed, reason: %d",
3069 msg.type, status_code);
3070 return status_code;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003071}
3072
3073/**
Srinivas Dasarie2ee0942019-06-29 14:34:50 +05303074 * lim_append_ies_to_frame() - Append IEs to the frame
3075 *
3076 * @frame: Pointer to the frame buffer that needs to be populated
3077 * @frame_len: Pointer for current frame length
3078 * @ie: pointer for disconnect IEs
3079 *
3080 * This function is called by lim_send_disassoc_mgmt_frame and
3081 * lim_send_deauth_mgmt_frame APIs as part of disconnection.
3082 * Append IEs and update frame length.
3083 *
3084 * Return: None
3085 */
3086static void
3087lim_append_ies_to_frame(uint8_t *frame, uint32_t *frame_len,
3088 struct wlan_ies *ie)
3089{
3090 if (!ie || !ie->len || !ie->data)
3091 return;
3092 qdf_mem_copy(frame, ie->data, ie->len);
3093 *frame_len += ie->len;
3094 pe_debug("Appended IEs len: %u", ie->len);
3095}
3096
3097/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003098 * \brief This function is called to send Disassociate frame.
3099 *
3100 *
Jeff Johnson99f25042018-11-21 22:49:06 -08003101 * \param mac Pointer to Global MAC structure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003102 *
3103 * \param nReason Indicates the reason that need to be sent in
3104 * Disassociation frame
3105 *
3106 * \param peerMacAddr MAC address of the STA to which Disassociation frame is
3107 * sent
3108 *
3109 *
3110 */
3111
3112void
Jeff Johnson9320c1e2018-12-02 13:09:20 -08003113lim_send_disassoc_mgmt_frame(struct mac_context *mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003114 uint16_t nReason,
3115 tSirMacAddr peer,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003116 struct pe_session *pe_session, bool waitForAck)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003117{
3118 tDot11fDisassociation frm;
3119 uint8_t *pFrame;
3120 tpSirMacMgmtHdr pMacHdr;
3121 uint32_t nBytes, nPayload, nStatus;
3122 void *pPacket;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303123 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003124 uint8_t txFlag = 0;
3125 uint32_t val = 0;
3126 uint8_t smeSessionId = 0;
Srinivas Dasarie2ee0942019-06-29 14:34:50 +05303127 struct wlan_ies *discon_ie;
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07003128
Jeff Johnson8e9530b2019-03-18 13:41:42 -07003129 if (!pe_session) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003130 return;
3131 }
3132
3133 /*
3134 * In case when cac timer is running for this SAP session then
3135 * avoid sending disassoc out. It is violation of dfs specification.
3136 */
Pragaspathi Thilagaraje64714a2019-05-23 00:46:25 +05303137 if (((pe_session->opmode == QDF_SAP_MODE) ||
3138 (pe_session->opmode == QDF_P2P_GO_MODE)) &&
Jeff Johnson99f25042018-11-21 22:49:06 -08003139 (true == mac->sap.SapDfsInfo.is_dfs_cac_timer_running)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303140 QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_INFO,
Pragaspathi Thilagaraje64714a2019-05-23 00:46:25 +05303141 FL("CAC timer is running, drop disassoc from going out"));
Abhishek Singh06522c52019-05-08 12:13:42 +05303142 if (waitForAck)
3143 lim_send_disassoc_cnf(mac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003144 return;
3145 }
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003146 smeSessionId = pe_session->smeSessionId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003147
hangtian127c9532019-01-12 13:29:07 +08003148 qdf_mem_zero((uint8_t *) &frm, sizeof(frm));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003149
3150 frm.Reason.code = nReason;
3151
Jeff Johnson99f25042018-11-21 22:49:06 -08003152 nStatus = dot11f_get_packed_disassociation_size(mac, &frm, &nPayload);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003153 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003154 pe_err("Failed to calculate the packed size for a Disassociation (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003155 nStatus);
3156 /* We'll fall back on the worst case scenario: */
3157 nPayload = sizeof(tDot11fDisassociation);
3158 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003159 pe_warn("There were warnings while calculating the packed size for a Disassociation (0x%08x)",
3160 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003161 }
3162
3163 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
3164
Srinivas Dasarie2ee0942019-06-29 14:34:50 +05303165 discon_ie = mlme_get_self_disconnect_ies(pe_session->vdev);
3166 if (discon_ie && discon_ie->len)
3167 nBytes += discon_ie->len;
3168
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303169 qdf_status = cds_packet_alloc((uint16_t) nBytes, (void **)&pFrame,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003170 (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303171 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003172 pe_err("Failed to allocate %d bytes for a Disassociation",
3173 nBytes);
Abhishek Singh06522c52019-05-08 12:13:42 +05303174 if (waitForAck)
3175 lim_send_disassoc_cnf(mac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003176 return;
3177 }
3178 /* Paranoia: */
hangtian127c9532019-01-12 13:29:07 +08003179 qdf_mem_zero(pFrame, nBytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003180
3181 /* Next, we fill out the buffer descriptor: */
Jeff Johnson99f25042018-11-21 22:49:06 -08003182 lim_populate_mac_header(mac, pFrame, SIR_MAC_MGMT_FRAME,
Pragaspathi Thilagaraj7fb14222019-06-17 23:26:58 +05303183 SIR_MAC_MGMT_DISASSOC, peer, pe_session->self_mac_addr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003184 pMacHdr = (tpSirMacMgmtHdr) pFrame;
3185
3186 /* Prepare the BSSID */
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003187 sir_copy_mac_addr(pMacHdr->bssId, pe_session->bssId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003188
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003189 lim_set_protected_bit(mac, pe_session, peer, pMacHdr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003190
Jeff Johnson99f25042018-11-21 22:49:06 -08003191 nStatus = dot11f_pack_disassociation(mac, &frm, pFrame +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003192 sizeof(tSirMacMgmtHdr),
3193 nPayload, &nPayload);
3194 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003195 pe_err("Failed to pack a Disassociation (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003196 nStatus);
3197 cds_packet_free((void *)pPacket);
Abhishek Singh06522c52019-05-08 12:13:42 +05303198 if (waitForAck)
3199 lim_send_disassoc_cnf(mac);
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003200 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003201 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003202 pe_warn("There were warnings while packing a Disassociation (0x%08x)",
3203 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003204 }
3205
Srinivas Dasarie2ee0942019-06-29 14:34:50 +05303206 /* Copy disconnect IEs to the end of the frame */
3207 lim_append_ies_to_frame(pFrame + sizeof(tSirMacMgmtHdr) + nPayload,
3208 &nPayload, discon_ie);
3209 mlme_free_self_disconnect_ies(pe_session->vdev);
3210
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003211 pe_debug("***Sessionid %d Sending Disassociation frame with "
Srinivas Girigowdacb7b8b82019-04-10 14:27:47 -07003212 "reason %u and waitForAck %d to " QDF_MAC_ADDR_STR " ,From "
3213 QDF_MAC_ADDR_STR, pe_session->peSessionId, nReason,
Srinivas Girigowda34fbba02019-04-08 12:07:44 -07003214 waitForAck, QDF_MAC_ADDR_ARRAY(pMacHdr->da),
Pragaspathi Thilagaraj7fb14222019-06-17 23:26:58 +05303215 QDF_MAC_ADDR_ARRAY(pe_session->self_mac_addr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003216
Liangwei Dong419d7302019-07-15 15:38:28 +08003217 if (wlan_reg_is_5ghz_ch_freq(pe_session->curr_op_freq) ||
3218 pe_session->opmode == QDF_P2P_CLIENT_MODE ||
3219 pe_session->opmode == QDF_P2P_GO_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003220 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003221
Sushant Kaushik46556062015-12-02 16:57:47 +05303222 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003223
3224 if (waitForAck) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303225 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003226 pe_session->peSessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003227 pMacHdr->fc.subType));
Jeff Johnson99f25042018-11-21 22:49:06 -08003228 lim_diag_mgmt_tx_event_report(mac, pMacHdr,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003229 pe_session, QDF_STATUS_SUCCESS,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003230 QDF_STATUS_SUCCESS);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003231 /* Queue Disassociation frame in high priority WQ */
3232 /* get the duration from the request */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303233 qdf_status =
Jeff Johnson99f25042018-11-21 22:49:06 -08003234 wma_tx_frameWithTxComplete(mac, pPacket, (uint16_t) nBytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003235 TXRX_FRM_802_11_MGMT,
3236 ANI_TXDIR_TODS, 7, lim_tx_complete,
Liangwei Dongc0b2e332017-11-16 06:04:46 -05003237 pFrame, lim_disassoc_tx_complete_cnf_handler,
Naveen Rawat296a5182017-09-25 14:02:48 -07003238 txFlag, smeSessionId, false, 0,
3239 RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303240 MTRACE(qdf_trace
Anurag Chouhan6d760662016-02-20 16:05:43 +05303241 (QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003242 pe_session->peSessionId, qdf_status));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003243
3244 val = SYS_MS_TO_TICKS(LIM_DISASSOC_DEAUTH_ACK_TIMEOUT);
3245
3246 if (tx_timer_change
Pragaspathi Thilagaraj9f230382019-06-24 11:54:05 +05303247 (&mac->lim.lim_timers.gLimDisassocAckTimer, val, 0)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003248 != TX_SUCCESS) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003249 pe_err("Unable to change Disassoc ack Timer val");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003250 return;
3251 } else if (TX_SUCCESS !=
Pragaspathi Thilagaraj9f230382019-06-24 11:54:05 +05303252 tx_timer_activate(&mac->lim.lim_timers.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003253 gLimDisassocAckTimer)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003254 pe_err("Unable to activate Disassoc ack Timer");
Jeff Johnson99f25042018-11-21 22:49:06 -08003255 lim_deactivate_and_change_timer(mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003256 eLIM_DISASSOC_ACK_TIMER);
3257 return;
3258 }
3259 } else {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303260 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003261 pe_session->peSessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003262 pMacHdr->fc.subType));
Jeff Johnson99f25042018-11-21 22:49:06 -08003263 lim_diag_mgmt_tx_event_report(mac, pMacHdr,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003264 pe_session,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003265 QDF_STATUS_SUCCESS, QDF_STATUS_SUCCESS);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003266 /* Queue Disassociation frame in high priority WQ */
Jeff Johnson99f25042018-11-21 22:49:06 -08003267 qdf_status = wma_tx_frame(mac, pPacket, (uint16_t) nBytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003268 TXRX_FRM_802_11_MGMT,
3269 ANI_TXDIR_TODS,
3270 7,
3271 lim_tx_complete, pFrame, txFlag,
Naveen Rawat296a5182017-09-25 14:02:48 -07003272 smeSessionId, 0, RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303273 MTRACE(qdf_trace
Anurag Chouhan6d760662016-02-20 16:05:43 +05303274 (QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003275 pe_session->peSessionId, qdf_status));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303276 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003277 pe_err("Failed to send Disassociation (%X)!",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303278 qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003279 /* Pkt will be freed up by the callback */
3280 }
3281 }
3282} /* End lim_send_disassoc_mgmt_frame. */
3283
3284/**
3285 * \brief This function is called to send a Deauthenticate frame
3286 *
3287 *
Jeff Johnson99f25042018-11-21 22:49:06 -08003288 * \param mac Pointer to global MAC structure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003289 *
3290 * \param nReason Indicates the reason that need to be sent in the
3291 * Deauthenticate frame
3292 *
3293 * \param peeer address of the STA to which the frame is to be sent
3294 *
3295 *
3296 */
3297
3298void
Jeff Johnson9320c1e2018-12-02 13:09:20 -08003299lim_send_deauth_mgmt_frame(struct mac_context *mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003300 uint16_t nReason,
3301 tSirMacAddr peer,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003302 struct pe_session *pe_session, bool waitForAck)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003303{
3304 tDot11fDeAuth frm;
3305 uint8_t *pFrame;
3306 tpSirMacMgmtHdr pMacHdr;
3307 uint32_t nBytes, nPayload, nStatus;
3308 void *pPacket;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303309 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003310 uint8_t txFlag = 0;
3311 uint32_t val = 0;
3312#ifdef FEATURE_WLAN_TDLS
3313 uint16_t aid;
Jeff Johnsonbddc03e2019-01-17 15:37:09 -08003314 tpDphHashNode sta;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003315#endif
3316 uint8_t smeSessionId = 0;
Srinivas Dasarie2ee0942019-06-29 14:34:50 +05303317 struct wlan_ies *discon_ie;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003318
Jeff Johnson8e9530b2019-03-18 13:41:42 -07003319 if (!pe_session) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003320 return;
3321 }
3322
3323 /*
3324 * In case when cac timer is running for this SAP session then
3325 * avoid deauth frame out. It is violation of dfs specification.
3326 */
Pragaspathi Thilagaraje64714a2019-05-23 00:46:25 +05303327 if (((pe_session->opmode == QDF_SAP_MODE) ||
3328 (pe_session->opmode == QDF_P2P_GO_MODE)) &&
Jeff Johnson99f25042018-11-21 22:49:06 -08003329 (true == mac->sap.SapDfsInfo.is_dfs_cac_timer_running)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303330 QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_INFO,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003331 FL
3332 ("CAC timer is running, drop the deauth from going out"));
Abhishek Singh06522c52019-05-08 12:13:42 +05303333 if (waitForAck)
3334 lim_send_deauth_cnf(mac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003335 return;
3336 }
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003337 smeSessionId = pe_session->smeSessionId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003338
hangtian127c9532019-01-12 13:29:07 +08003339 qdf_mem_zero((uint8_t *) &frm, sizeof(frm));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003340
3341 frm.Reason.code = nReason;
3342
Jeff Johnson99f25042018-11-21 22:49:06 -08003343 nStatus = dot11f_get_packed_de_auth_size(mac, &frm, &nPayload);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003344 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003345 pe_err("Failed to calculate the packed size for a De-Authentication (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003346 nStatus);
3347 /* We'll fall back on the worst case scenario: */
3348 nPayload = sizeof(tDot11fDeAuth);
3349 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003350 pe_warn("There were warnings while calculating the packed size for a De-Authentication (0x%08x)",
3351 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003352 }
3353
3354 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
Srinivas Dasarie2ee0942019-06-29 14:34:50 +05303355 discon_ie = mlme_get_self_disconnect_ies(pe_session->vdev);
3356 if (discon_ie && discon_ie->len)
3357 nBytes += discon_ie->len;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003358
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303359 qdf_status = cds_packet_alloc((uint16_t) nBytes, (void **)&pFrame,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003360 (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303361 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003362 pe_err("Failed to allocate %d bytes for a De-Authentication",
3363 nBytes);
Abhishek Singh06522c52019-05-08 12:13:42 +05303364 if (waitForAck)
3365 lim_send_deauth_cnf(mac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003366 return;
3367 }
3368 /* Paranoia: */
hangtian127c9532019-01-12 13:29:07 +08003369 qdf_mem_zero(pFrame, nBytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003370
3371 /* Next, we fill out the buffer descriptor: */
Jeff Johnson99f25042018-11-21 22:49:06 -08003372 lim_populate_mac_header(mac, pFrame, SIR_MAC_MGMT_FRAME,
Pragaspathi Thilagaraj7fb14222019-06-17 23:26:58 +05303373 SIR_MAC_MGMT_DEAUTH, peer, pe_session->self_mac_addr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003374 pMacHdr = (tpSirMacMgmtHdr) pFrame;
3375
3376 /* Prepare the BSSID */
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003377 sir_copy_mac_addr(pMacHdr->bssId, pe_session->bssId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003378
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003379 lim_set_protected_bit(mac, pe_session, peer, pMacHdr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003380
Jeff Johnson99f25042018-11-21 22:49:06 -08003381 nStatus = dot11f_pack_de_auth(mac, &frm, pFrame +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003382 sizeof(tSirMacMgmtHdr), nPayload, &nPayload);
3383 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003384 pe_err("Failed to pack a DeAuthentication (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003385 nStatus);
3386 cds_packet_free((void *)pPacket);
Abhishek Singh06522c52019-05-08 12:13:42 +05303387 if (waitForAck)
3388 lim_send_deauth_cnf(mac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003389 return;
3390 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003391 pe_warn("There were warnings while packing a De-Authentication (0x%08x)",
3392 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003393 }
Srinivas Dasarie2ee0942019-06-29 14:34:50 +05303394
3395 /* Copy disconnect IEs to the end of the frame */
3396 lim_append_ies_to_frame(pFrame + sizeof(tSirMacMgmtHdr) + nPayload,
3397 &nPayload, discon_ie);
3398 mlme_free_self_disconnect_ies(pe_session->vdev);
3399
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003400 pe_debug("***Sessionid %d Sending Deauth frame with "
Srinivas Girigowdacb7b8b82019-04-10 14:27:47 -07003401 "reason %u and waitForAck %d to " QDF_MAC_ADDR_STR
3402 " ,From " QDF_MAC_ADDR_STR,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003403 pe_session->peSessionId, nReason, waitForAck,
Srinivas Girigowda34fbba02019-04-08 12:07:44 -07003404 QDF_MAC_ADDR_ARRAY(pMacHdr->da),
Pragaspathi Thilagaraj7fb14222019-06-17 23:26:58 +05303405 QDF_MAC_ADDR_ARRAY(pe_session->self_mac_addr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003406
Liangwei Dong419d7302019-07-15 15:38:28 +08003407 if (wlan_reg_is_5ghz_ch_freq(pe_session->curr_op_freq) ||
3408 pe_session->opmode == QDF_P2P_CLIENT_MODE ||
3409 pe_session->opmode == QDF_P2P_GO_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003410 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003411
Sushant Kaushik46556062015-12-02 16:57:47 +05303412 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003413#ifdef FEATURE_WLAN_TDLS
Jeff Johnsonbddc03e2019-01-17 15:37:09 -08003414 sta =
Jeff Johnson99f25042018-11-21 22:49:06 -08003415 dph_lookup_hash_entry(mac, peer, &aid,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003416 &pe_session->dph.dphHashTable);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003417#endif
3418
3419 if (waitForAck) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303420 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003421 pe_session->peSessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003422 pMacHdr->fc.subType));
Jeff Johnson99f25042018-11-21 22:49:06 -08003423 lim_diag_mgmt_tx_event_report(mac, pMacHdr,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003424 pe_session,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003425 QDF_STATUS_SUCCESS, QDF_STATUS_SUCCESS);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003426 /* Queue Disassociation frame in high priority WQ */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303427 qdf_status =
Jeff Johnson99f25042018-11-21 22:49:06 -08003428 wma_tx_frameWithTxComplete(mac, pPacket, (uint16_t) nBytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003429 TXRX_FRM_802_11_MGMT,
3430 ANI_TXDIR_TODS, 7, lim_tx_complete,
Liangwei Dongc0b2e332017-11-16 06:04:46 -05003431 pFrame, lim_deauth_tx_complete_cnf_handler,
Naveen Rawat296a5182017-09-25 14:02:48 -07003432 txFlag, smeSessionId, false, 0,
3433 RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303434 MTRACE(qdf_trace
Anurag Chouhan6d760662016-02-20 16:05:43 +05303435 (QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003436 pe_session->peSessionId, qdf_status));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003437 /* Pkt will be freed up by the callback lim_tx_complete */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303438 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003439 pe_err("Failed to send De-Authentication (%X)!",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303440 qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003441
3442 /* Call lim_process_deauth_ack_timeout which will send
3443 * DeauthCnf for this frame
3444 */
Jeff Johnson99f25042018-11-21 22:49:06 -08003445 lim_process_deauth_ack_timeout(mac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003446 return;
3447 }
3448
3449 val = SYS_MS_TO_TICKS(LIM_DISASSOC_DEAUTH_ACK_TIMEOUT);
3450
3451 if (tx_timer_change
Pragaspathi Thilagaraj9f230382019-06-24 11:54:05 +05303452 (&mac->lim.lim_timers.gLimDeauthAckTimer, val, 0)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003453 != TX_SUCCESS) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003454 pe_err("Unable to change Deauth ack Timer val");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003455 return;
3456 } else if (TX_SUCCESS !=
Pragaspathi Thilagaraj9f230382019-06-24 11:54:05 +05303457 tx_timer_activate(&mac->lim.lim_timers.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003458 gLimDeauthAckTimer)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003459 pe_err("Unable to activate Deauth ack Timer");
Jeff Johnson99f25042018-11-21 22:49:06 -08003460 lim_deactivate_and_change_timer(mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003461 eLIM_DEAUTH_ACK_TIMER);
3462 return;
3463 }
3464 } else {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303465 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003466 pe_session->peSessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003467 pMacHdr->fc.subType));
3468#ifdef FEATURE_WLAN_TDLS
Jeff Johnson8e9530b2019-03-18 13:41:42 -07003469 if ((sta)
Jeff Johnsonbddc03e2019-01-17 15:37:09 -08003470 && (STA_ENTRY_TDLS_PEER == sta->staType)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003471 /* Queue Disassociation frame in high priority WQ */
Jeff Johnson99f25042018-11-21 22:49:06 -08003472 lim_diag_mgmt_tx_event_report(mac, pMacHdr,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003473 pe_session,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003474 QDF_STATUS_SUCCESS,
3475 QDF_STATUS_SUCCESS);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303476 qdf_status =
Jeff Johnson99f25042018-11-21 22:49:06 -08003477 wma_tx_frame(mac, pPacket, (uint16_t) nBytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003478 TXRX_FRM_802_11_MGMT, ANI_TXDIR_IBSS,
3479 7, lim_tx_complete, pFrame, txFlag,
Naveen Rawat296a5182017-09-25 14:02:48 -07003480 smeSessionId, 0, RATEID_DEFAULT);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003481 } else {
3482#endif
Jeff Johnson99f25042018-11-21 22:49:06 -08003483 lim_diag_mgmt_tx_event_report(mac, pMacHdr,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003484 pe_session,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003485 QDF_STATUS_SUCCESS,
3486 QDF_STATUS_SUCCESS);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003487 /* Queue Disassociation frame in high priority WQ */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303488 qdf_status =
Jeff Johnson99f25042018-11-21 22:49:06 -08003489 wma_tx_frame(mac, pPacket, (uint16_t) nBytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003490 TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS,
3491 7, lim_tx_complete, pFrame, txFlag,
Naveen Rawat296a5182017-09-25 14:02:48 -07003492 smeSessionId, 0, RATEID_DEFAULT);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003493#ifdef FEATURE_WLAN_TDLS
3494 }
3495#endif
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303496 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003497 pe_session->peSessionId, qdf_status));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303498 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003499 pe_err("Failed to send De-Authentication (%X)!",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303500 qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003501 /* Pkt will be freed up by the callback */
3502 }
3503 }
3504
3505} /* End lim_send_deauth_mgmt_frame. */
3506
3507#ifdef ANI_SUPPORT_11H
3508/**
3509 * \brief Send a Measurement Report Action frame
3510 *
3511 *
Jeff Johnson99f25042018-11-21 22:49:06 -08003512 * \param mac Pointer to the global MAC structure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003513 *
3514 * \param pMeasReqFrame Address of a tSirMacMeasReqActionFrame
3515 *
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003516 * \return QDF_STATUS_SUCCESS on success, QDF_STATUS_E_FAILURE else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003517 *
3518 *
3519 */
3520
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003521QDF_STATUS
Jeff Johnson9320c1e2018-12-02 13:09:20 -08003522lim_send_meas_report_frame(struct mac_context *mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003523 tpSirMacMeasReqActionFrame pMeasReqFrame,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003524 tSirMacAddr peer, struct pe_session *pe_session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003525{
3526 tDot11fMeasurementReport frm;
3527 uint8_t *pFrame;
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003528 QDF_STATUS nSirStatus;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003529 tpSirMacMgmtHdr pMacHdr;
3530 uint32_t nBytes, nPayload, nStatus;
3531 void *pPacket;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303532 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003533
hangtian127c9532019-01-12 13:29:07 +08003534 qdf_mem_zero((uint8_t *) &frm, sizeof(frm));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003535
Srinivas Girigowda48bec1c2019-05-17 16:33:30 -07003536 frm.Category.category = ACTION_CATEGORY_SPECTRUM_MGMT;
Srinivas Girigowdaf8e5d2e2019-05-28 11:49:29 -07003537 frm.Action.action = ACTION_SPCT_MSR_RPRT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003538 frm.DialogToken.token = pMeasReqFrame->actionHeader.dialogToken;
3539
3540 switch (pMeasReqFrame->measReqIE.measType) {
3541 case SIR_MAC_BASIC_MEASUREMENT_TYPE:
3542 nSirStatus =
Jeff Johnson99f25042018-11-21 22:49:06 -08003543 populate_dot11f_measurement_report0(mac, pMeasReqFrame,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003544 &frm.MeasurementReport);
3545 break;
3546 case SIR_MAC_CCA_MEASUREMENT_TYPE:
3547 nSirStatus =
Jeff Johnson99f25042018-11-21 22:49:06 -08003548 populate_dot11f_measurement_report1(mac, pMeasReqFrame,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003549 &frm.MeasurementReport);
3550 break;
3551 case SIR_MAC_RPI_MEASUREMENT_TYPE:
3552 nSirStatus =
Jeff Johnson99f25042018-11-21 22:49:06 -08003553 populate_dot11f_measurement_report2(mac, pMeasReqFrame,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003554 &frm.MeasurementReport);
3555 break;
3556 default:
Jeff Johnson0711e272018-12-14 23:16:38 -08003557 pe_err("Unknown measurement type %d in limSendMeasReportFrame",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003558 pMeasReqFrame->measReqIE.measType);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003559 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003560 }
3561
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003562 if (QDF_STATUS_SUCCESS != nSirStatus)
3563 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003564
Jeff Johnson99f25042018-11-21 22:49:06 -08003565 nStatus = dot11f_get_packed_measurement_report_size(mac, &frm, &nPayload);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003566 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003567 pe_err("Failed to calculate the packed size for a Measurement Report (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003568 nStatus);
3569 /* We'll fall back on the worst case scenario: */
3570 nPayload = sizeof(tDot11fMeasurementReport);
3571 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003572 pe_warn("There were warnings while calculating the packed size for a Measurement Report (0x%08x)",
3573 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003574 }
3575
3576 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
3577
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303578 qdf_status =
Jeff Johnson99f25042018-11-21 22:49:06 -08003579 cds_packet_alloc(mac->hdd_handle, TXRX_FRM_802_11_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003580 (uint16_t) nBytes, (void **)&pFrame,
3581 (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303582 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Jeff Johnson0711e272018-12-14 23:16:38 -08003583 pe_err("Failed to allocate %d bytes for a De-Authentication",
3584 nBytes);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003585 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003586 }
3587 /* Paranoia: */
hangtian127c9532019-01-12 13:29:07 +08003588 qdf_mem_zero(pFrame, nBytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003589
3590 /* Next, we fill out the buffer descriptor: */
Jeff Johnson99f25042018-11-21 22:49:06 -08003591 lim_populate_mac_header(mac, pFrame, SIR_MAC_MGMT_FRAME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003592 SIR_MAC_MGMT_ACTION, peer);
3593 pMacHdr = (tpSirMacMgmtHdr) pFrame;
3594
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003595 qdf_mem_copy(pMacHdr->bssId, pe_session->bssId, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003596
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003597 lim_set_protected_bit(mac, pe_session, peer, pMacHdr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003598
Jeff Johnson99f25042018-11-21 22:49:06 -08003599 nStatus = dot11f_pack_measurement_report(mac, &frm, pFrame +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003600 sizeof(tSirMacMgmtHdr),
3601 nPayload, &nPayload);
3602 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003603 pe_err("Failed to pack a Measurement Report (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003604 nStatus);
Jeff Johnson99f25042018-11-21 22:49:06 -08003605 cds_packet_free(mac->hdd_handle, TXRX_FRM_802_11_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003606 (void *)pFrame, (void *)pPacket);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003607 return QDF_STATUS_E_FAILURE; /* allocated! */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003608 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003609 pe_warn("There were warnings while packing a Measurement Report (0x%08x)",
3610 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003611 }
3612
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303613 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003614 ((pe_session) ? pe_session->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003615 peSessionId : NO_SESSION), pMacHdr->fc.subType));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303616 qdf_status =
Jeff Johnson99f25042018-11-21 22:49:06 -08003617 wma_tx_frame(mac, pPacket, (uint16_t) nBytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003618 TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS, 7,
Naveen Rawat296a5182017-09-25 14:02:48 -07003619 lim_tx_complete, pFrame, 0, 0, RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303620 MTRACE(qdf_trace
Anurag Chouhan6d760662016-02-20 16:05:43 +05303621 (QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003622 ((pe_session) ? pe_session->peSessionId : NO_SESSION),
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303623 qdf_status));
3624 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003625 pe_err("Failed to send a Measurement Report (%X)!",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303626 qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003627 /* Pkt will be freed up by the callback */
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003628 return QDF_STATUS_E_FAILURE; /* just allocated... */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003629 }
3630
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003631 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003632
3633} /* End lim_send_meas_report_frame. */
3634
3635/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003636 * \brief Send a TPC Report Action frame
3637 *
3638 *
Jeff Johnson99f25042018-11-21 22:49:06 -08003639 * \param mac Pointer to the global MAC datastructure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003640 *
3641 * \param pTpcReqFrame Pointer to the received TPC Request
3642 *
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003643 * \return QDF_STATUS_SUCCESS on success, QDF_STATUS_E_FAILURE else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003644 *
3645 *
3646 */
3647
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003648QDF_STATUS
Jeff Johnson9320c1e2018-12-02 13:09:20 -08003649lim_send_tpc_report_frame(struct mac_context *mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003650 tpSirMacTpcReqActionFrame pTpcReqFrame,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003651 tSirMacAddr peer, struct pe_session *pe_session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003652{
3653 tDot11fTPCReport frm;
3654 uint8_t *pFrame;
3655 tpSirMacMgmtHdr pMacHdr;
3656 uint32_t nBytes, nPayload, nStatus;
3657 void *pPacket;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303658 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003659
hangtian127c9532019-01-12 13:29:07 +08003660 qdf_mem_zero((uint8_t *) &frm, sizeof(frm));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003661
Srinivas Girigowda48bec1c2019-05-17 16:33:30 -07003662 frm.Category.category = ACTION_CATEGORY_SPECTRUM_MGMT;
Srinivas Girigowdaf8e5d2e2019-05-28 11:49:29 -07003663 frm.Action.action = ACTION_SPCT_TPC_RPRT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003664 frm.DialogToken.token = pTpcReqFrame->actionHeader.dialogToken;
3665
3666 frm.TPCReport.tx_power = 0;
3667 frm.TPCReport.link_margin = 0;
3668 frm.TPCReport.present = 1;
3669
Jeff Johnson99f25042018-11-21 22:49:06 -08003670 nStatus = dot11f_get_packed_tpc_report_size(mac, &frm, &nPayload);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003671 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003672 pe_err("Failed to calculate the packed size for a TPC Report (0x%08x)", nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003673 /* We'll fall back on the worst case scenario: */
3674 nPayload = sizeof(tDot11fTPCReport);
3675 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003676 pe_warn("There were warnings while calculating the packed size for a TPC Report (0x%08x)",
3677 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003678 }
3679
3680 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
3681
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303682 qdf_status =
Jeff Johnson99f25042018-11-21 22:49:06 -08003683 cds_packet_alloc(mac->hdd_handle, TXRX_FRM_802_11_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003684 (uint16_t) nBytes, (void **)&pFrame,
3685 (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303686 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003687 pe_err("Failed to allocate %d bytes for a TPC"
3688 " Report", nBytes);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003689 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003690 }
3691 /* Paranoia: */
hangtian127c9532019-01-12 13:29:07 +08003692 qdf_mem_zero(pFrame, nBytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003693
3694 /* Next, we fill out the buffer descriptor: */
Jeff Johnson99f25042018-11-21 22:49:06 -08003695 lim_populate_mac_header(mac, pFrame, SIR_MAC_MGMT_FRAME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003696 SIR_MAC_MGMT_ACTION, peer);
3697
3698 pMacHdr = (tpSirMacMgmtHdr) pFrame;
3699
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003700 qdf_mem_copy(pMacHdr->bssId, pe_session->bssId, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003701
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003702 lim_set_protected_bit(mac, pe_session, peer, pMacHdr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003703
Jeff Johnson99f25042018-11-21 22:49:06 -08003704 nStatus = dot11f_pack_tpc_report(mac, &frm, pFrame +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003705 sizeof(tSirMacMgmtHdr),
3706 nPayload, &nPayload);
3707 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003708 pe_err("Failed to pack a TPC Report (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003709 nStatus);
Jeff Johnson99f25042018-11-21 22:49:06 -08003710 cds_packet_free(mac->hdd_handle, TXRX_FRM_802_11_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003711 (void *)pFrame, (void *)pPacket);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003712 return QDF_STATUS_E_FAILURE; /* allocated! */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003713 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003714 pe_warn("There were warnings while packing a TPC Report (0x%08x)",
3715 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003716
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303717 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003718 ((pe_session) ? pe_session->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003719 peSessionId : NO_SESSION), pMacHdr->fc.subType));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303720 qdf_status =
Jeff Johnson99f25042018-11-21 22:49:06 -08003721 wma_tx_frame(mac, pPacket, (uint16_t) nBytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003722 TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS, 7,
Naveen Rawat296a5182017-09-25 14:02:48 -07003723 lim_tx_complete, pFrame, 0, 0, RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303724 MTRACE(qdf_trace
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003725 (QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003726 ((pe_session) ? pe_session->peSessionId : NO_SESSION),
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003727 qdf_status));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303728 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003729 pe_err("Failed to send a TPC Report (%X)!",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303730 qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003731 /* Pkt will be freed up by the callback */
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003732 return QDF_STATUS_E_FAILURE; /* just allocated... */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003733 }
3734
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003735 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003736
3737} /* End lim_send_tpc_report_frame. */
3738#endif /* ANI_SUPPORT_11H */
3739
3740/**
3741 * \brief Send a Channel Switch Announcement
3742 *
3743 *
Jeff Johnson99f25042018-11-21 22:49:06 -08003744 * \param mac Pointer to the global MAC datastructure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003745 *
3746 * \param peer MAC address to which this frame will be sent
3747 *
3748 * \param nMode
3749 *
3750 * \param nNewChannel
3751 *
3752 * \param nCount
3753 *
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003754 * \return QDF_STATUS_SUCCESS on success, QDF_STATUS_E_FAILURE else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003755 *
3756 *
3757 */
3758
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003759QDF_STATUS
Jeff Johnson9320c1e2018-12-02 13:09:20 -08003760lim_send_channel_switch_mgmt_frame(struct mac_context *mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003761 tSirMacAddr peer,
3762 uint8_t nMode,
3763 uint8_t nNewChannel,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003764 uint8_t nCount, struct pe_session *pe_session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003765{
3766 tDot11fChannelSwitch frm;
3767 uint8_t *pFrame;
3768 tpSirMacMgmtHdr pMacHdr;
3769 uint32_t nBytes, nPayload, nStatus; /* , nCfg; */
3770 void *pPacket;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303771 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003772 uint8_t txFlag = 0;
3773
3774 uint8_t smeSessionId = 0;
3775
Jeff Johnson8e9530b2019-03-18 13:41:42 -07003776 if (!pe_session) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003777 pe_err("Session entry is NULL!!!");
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003778 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003779 }
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003780 smeSessionId = pe_session->smeSessionId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003781
hangtian127c9532019-01-12 13:29:07 +08003782 qdf_mem_zero((uint8_t *) &frm, sizeof(frm));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003783
Srinivas Girigowda48bec1c2019-05-17 16:33:30 -07003784 frm.Category.category = ACTION_CATEGORY_SPECTRUM_MGMT;
Srinivas Girigowdaf8e5d2e2019-05-28 11:49:29 -07003785 frm.Action.action = ACTION_SPCT_CHL_SWITCH;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003786 frm.ChanSwitchAnn.switchMode = nMode;
3787 frm.ChanSwitchAnn.newChannel = nNewChannel;
3788 frm.ChanSwitchAnn.switchCount = nCount;
3789 frm.ChanSwitchAnn.present = 1;
3790
Jeff Johnson99f25042018-11-21 22:49:06 -08003791 nStatus = dot11f_get_packed_channel_switch_size(mac, &frm, &nPayload);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003792 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003793 pe_err("Failed to calculate the packed size for a Channel Switch (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003794 nStatus);
3795 /* We'll fall back on the worst case scenario: */
3796 nPayload = sizeof(tDot11fChannelSwitch);
3797 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003798 pe_warn("There were warnings while calculating the packed size for a Channel Switch (0x%08x)",
3799 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003800 }
3801
3802 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
3803
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303804 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003805 cds_packet_alloc((uint16_t) nBytes, (void **)&pFrame,
3806 (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303807 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003808 pe_err("Failed to allocate %d bytes for a TPC Report", nBytes);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003809 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003810 }
3811 /* Paranoia: */
hangtian127c9532019-01-12 13:29:07 +08003812 qdf_mem_zero(pFrame, nBytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003813
3814 /* Next, we fill out the buffer descriptor: */
Jeff Johnson99f25042018-11-21 22:49:06 -08003815 lim_populate_mac_header(mac, pFrame, SIR_MAC_MGMT_FRAME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003816 SIR_MAC_MGMT_ACTION, peer,
Pragaspathi Thilagaraj7fb14222019-06-17 23:26:58 +05303817 pe_session->self_mac_addr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003818 pMacHdr = (tpSirMacMgmtHdr) pFrame;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303819 qdf_mem_copy((uint8_t *) pMacHdr->bssId,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003820 (uint8_t *) pe_session->bssId, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003821
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003822 lim_set_protected_bit(mac, pe_session, peer, pMacHdr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003823
Jeff Johnson99f25042018-11-21 22:49:06 -08003824 nStatus = dot11f_pack_channel_switch(mac, &frm, pFrame +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003825 sizeof(tSirMacMgmtHdr),
3826 nPayload, &nPayload);
3827 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003828 pe_err("Failed to pack a Channel Switch (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003829 nStatus);
3830 cds_packet_free((void *)pPacket);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003831 return QDF_STATUS_E_FAILURE; /* allocated! */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003832 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003833 pe_warn("There were warnings while packing a Channel Switch (0x%08x)",
3834 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003835 }
3836
Liangwei Dong419d7302019-07-15 15:38:28 +08003837 if (wlan_reg_is_5ghz_ch_freq(pe_session->curr_op_freq) ||
3838 pe_session->opmode == QDF_P2P_CLIENT_MODE ||
3839 pe_session->opmode == QDF_P2P_GO_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003840 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003841
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303842 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003843 pe_session->peSessionId, pMacHdr->fc.subType));
Jeff Johnson99f25042018-11-21 22:49:06 -08003844 qdf_status = wma_tx_frame(mac, pPacket, (uint16_t) nBytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003845 TXRX_FRM_802_11_MGMT,
3846 ANI_TXDIR_TODS,
3847 7, lim_tx_complete, pFrame, txFlag,
Naveen Rawat296a5182017-09-25 14:02:48 -07003848 smeSessionId, 0, RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303849 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003850 pe_session->peSessionId, qdf_status));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303851 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003852 pe_err("Failed to send a Channel Switch (%X)!",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303853 qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003854 /* Pkt will be freed up by the callback */
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003855 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003856 }
3857
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003858 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003859
3860} /* End lim_send_channel_switch_mgmt_frame. */
3861
Abhishek Singh518323d2015-10-19 17:42:01 +05303862/**
3863 * lim_send_extended_chan_switch_action_frame()- function to send ECSA
3864 * action frame over the air .
3865 * @mac_ctx: pointer to global mac structure
3866 * @peer: Destination mac.
3867 * @mode: channel switch mode
3868 * @new_op_class: new op class
3869 * @new_channel: new channel to switch
3870 * @count: channel switch count
3871 *
3872 * This function is called to send ECSA frame.
3873 *
3874 * Return: success if frame is sent else return failure
3875 */
3876
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003877QDF_STATUS
Jeff Johnson9320c1e2018-12-02 13:09:20 -08003878lim_send_extended_chan_switch_action_frame(struct mac_context *mac_ctx,
Abhishek Singh518323d2015-10-19 17:42:01 +05303879 tSirMacAddr peer, uint8_t mode, uint8_t new_op_class,
Jeff Johnsona7815652018-11-18 22:58:30 -08003880 uint8_t new_channel, uint8_t count, struct pe_session *session_entry)
Abhishek Singh518323d2015-10-19 17:42:01 +05303881{
3882 tDot11fext_channel_switch_action_frame frm;
3883 uint8_t *frame;
3884 tpSirMacMgmtHdr mac_hdr;
3885 uint32_t num_bytes, n_payload, status;
3886 void *packet;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303887 QDF_STATUS qdf_status;
Abhishek Singh518323d2015-10-19 17:42:01 +05303888 uint8_t txFlag = 0;
3889 uint8_t sme_session_id = 0;
Vignesh Viswanathan93b7f702017-12-19 17:48:45 +05303890 uint8_t ch_spacing;
3891 tLimWiderBWChannelSwitchInfo *wide_bw_ie;
Abhishek Singh518323d2015-10-19 17:42:01 +05303892
Jeff Johnson8e9530b2019-03-18 13:41:42 -07003893 if (!session_entry) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003894 pe_err("Session entry is NULL!!!");
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003895 return QDF_STATUS_E_FAILURE;
Abhishek Singh518323d2015-10-19 17:42:01 +05303896 }
3897
3898 sme_session_id = session_entry->smeSessionId;
3899
hangtian127c9532019-01-12 13:29:07 +08003900 qdf_mem_zero(&frm, sizeof(frm));
Abhishek Singh518323d2015-10-19 17:42:01 +05303901
Srinivas Girigowda48bec1c2019-05-17 16:33:30 -07003902 frm.Category.category = ACTION_CATEGORY_PUBLIC;
Abhishek Singh518323d2015-10-19 17:42:01 +05303903 frm.Action.action = SIR_MAC_ACTION_EXT_CHANNEL_SWITCH_ID;
3904
3905 frm.ext_chan_switch_ann_action.switch_mode = mode;
3906 frm.ext_chan_switch_ann_action.op_class = new_op_class;
3907 frm.ext_chan_switch_ann_action.new_channel = new_channel;
3908 frm.ext_chan_switch_ann_action.switch_count = count;
3909
Vignesh Viswanathan93b7f702017-12-19 17:48:45 +05303910 ch_spacing = wlan_reg_dmn_get_chanwidth_from_opclass(
3911 mac_ctx->scan.countryCodeCurrent, new_channel,
3912 new_op_class);
3913 pe_debug("wrapper: ch_spacing %hu", ch_spacing);
3914
3915 if ((ch_spacing == 80) || (ch_spacing == 160)) {
3916 wide_bw_ie = &session_entry->gLimWiderBWChannelSwitch;
3917 frm.WiderBWChanSwitchAnn.newChanWidth =
3918 wide_bw_ie->newChanWidth;
3919 frm.WiderBWChanSwitchAnn.newCenterChanFreq0 =
3920 wide_bw_ie->newCenterChanFreq0;
3921 frm.WiderBWChanSwitchAnn.newCenterChanFreq1 =
3922 wide_bw_ie->newCenterChanFreq1;
3923 frm.WiderBWChanSwitchAnn.present = 1;
3924 pe_debug("wrapper: width:%d f0:%d f1:%d",
3925 frm.WiderBWChanSwitchAnn.newChanWidth,
3926 frm.WiderBWChanSwitchAnn.newCenterChanFreq0,
3927 frm.WiderBWChanSwitchAnn.newCenterChanFreq1);
3928 }
Abhishek Singh518323d2015-10-19 17:42:01 +05303929
3930 status = dot11f_get_packed_ext_channel_switch_action_frame_size(mac_ctx,
3931 &frm, &n_payload);
3932 if (DOT11F_FAILED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003933 pe_err("Failed to get packed size for Channel Switch 0x%08x",
Abhishek Singh518323d2015-10-19 17:42:01 +05303934 status);
3935 /* We'll fall back on the worst case scenario*/
3936 n_payload = sizeof(tDot11fext_channel_switch_action_frame);
3937 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003938 pe_warn("There were warnings while calculating the packed size for a Ext Channel Switch (0x%08x)",
Abhishek Singh518323d2015-10-19 17:42:01 +05303939 status);
3940 }
3941
3942 num_bytes = n_payload + sizeof(tSirMacMgmtHdr);
3943
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303944 qdf_status = cds_packet_alloc((uint16_t)num_bytes,
Abhishek Singh518323d2015-10-19 17:42:01 +05303945 (void **) &frame, (void **) &packet);
3946
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303947 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003948 pe_err("Failed to allocate %d bytes for a Ext Channel Switch",
Abhishek Singh518323d2015-10-19 17:42:01 +05303949 num_bytes);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003950 return QDF_STATUS_E_FAILURE;
Abhishek Singh518323d2015-10-19 17:42:01 +05303951 }
3952
3953 /* Paranoia*/
hangtian127c9532019-01-12 13:29:07 +08003954 qdf_mem_zero(frame, num_bytes);
Abhishek Singh518323d2015-10-19 17:42:01 +05303955
3956 /* Next, we fill out the buffer descriptor */
3957 lim_populate_mac_header(mac_ctx, frame, SIR_MAC_MGMT_FRAME,
Pragaspathi Thilagaraj7fb14222019-06-17 23:26:58 +05303958 SIR_MAC_MGMT_ACTION, peer, session_entry->self_mac_addr);
Abhishek Singh518323d2015-10-19 17:42:01 +05303959 mac_hdr = (tpSirMacMgmtHdr) frame;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303960 qdf_mem_copy((uint8_t *) mac_hdr->bssId,
Abhishek Singh518323d2015-10-19 17:42:01 +05303961 (uint8_t *) session_entry->bssId,
3962 sizeof(tSirMacAddr));
3963
gaolez4b62a9e2018-08-16 15:57:50 +08003964 lim_set_protected_bit(mac_ctx, session_entry, peer, mac_hdr);
3965
Abhishek Singh518323d2015-10-19 17:42:01 +05303966 status = dot11f_pack_ext_channel_switch_action_frame(mac_ctx, &frm,
3967 frame + sizeof(tSirMacMgmtHdr), n_payload, &n_payload);
3968 if (DOT11F_FAILED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003969 pe_err("Failed to pack a Channel Switch 0x%08x", status);
Abhishek Singh518323d2015-10-19 17:42:01 +05303970 cds_packet_free((void *)packet);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003971 return QDF_STATUS_E_FAILURE;
Abhishek Singh518323d2015-10-19 17:42:01 +05303972 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003973 pe_warn("There were warnings while packing a Channel Switch 0x%08x",
Abhishek Singh518323d2015-10-19 17:42:01 +05303974 status);
3975 }
3976
Liangwei Dong419d7302019-07-15 15:38:28 +08003977 if (wlan_reg_is_5ghz_ch_freq(session_entry->curr_op_freq) ||
3978 session_entry->opmode == QDF_P2P_CLIENT_MODE ||
3979 session_entry->opmode == QDF_P2P_GO_MODE)
Abhishek Singh518323d2015-10-19 17:42:01 +05303980 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
Abhishek Singh518323d2015-10-19 17:42:01 +05303981
Srinivas Girigowdacb7b8b82019-04-10 14:27:47 -07003982 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 -07003983 QDF_MAC_ADDR_ARRAY(mac_hdr->da),
Abhishek Singh518323d2015-10-19 17:42:01 +05303984 frm.ext_chan_switch_ann_action.switch_count,
3985 frm.ext_chan_switch_ann_action.switch_mode,
3986 frm.ext_chan_switch_ann_action.new_channel,
3987 frm.ext_chan_switch_ann_action.op_class);
3988
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303989 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Abhishek Singh518323d2015-10-19 17:42:01 +05303990 session_entry->peSessionId, mac_hdr->fc.subType));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303991 qdf_status = wma_tx_frame(mac_ctx, packet, (uint16_t) num_bytes,
Abhishek Singh518323d2015-10-19 17:42:01 +05303992 TXRX_FRM_802_11_MGMT,
3993 ANI_TXDIR_TODS,
3994 7,
3995 lim_tx_complete, frame,
Naveen Rawat296a5182017-09-25 14:02:48 -07003996 txFlag, sme_session_id, 0,
3997 RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303998 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303999 session_entry->peSessionId, qdf_status));
4000 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004001 pe_err("Failed to send a Ext Channel Switch %X!",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304002 qdf_status);
Abhishek Singh518323d2015-10-19 17:42:01 +05304003 /* Pkt will be freed up by the callback */
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004004 return QDF_STATUS_E_FAILURE;
Abhishek Singh518323d2015-10-19 17:42:01 +05304005 }
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004006 return QDF_STATUS_SUCCESS;
Abhishek Singh518323d2015-10-19 17:42:01 +05304007} /* End lim_send_extended_chan_switch_action_frame */
4008
Abhishek Singh5695e2a2016-10-28 10:39:12 +05304009
4010/**
4011 * lim_oper_chan_change_confirm_tx_complete_cnf()- Confirmation for oper_chan_change_confirm
4012 * sent over the air
4013 *
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05304014 * @context: pointer to global mac
4015 * @buf: buffer
Abhishek Singh5695e2a2016-10-28 10:39:12 +05304016 * @tx_complete : Sent status
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05304017 * @params: tx completion params
Abhishek Singh5695e2a2016-10-28 10:39:12 +05304018 *
4019 * Return: This returns QDF_STATUS
4020 */
4021
4022static QDF_STATUS lim_oper_chan_change_confirm_tx_complete_cnf(
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05304023 void *context,
4024 qdf_nbuf_t buf,
4025 uint32_t tx_complete,
4026 void *params)
Abhishek Singh5695e2a2016-10-28 10:39:12 +05304027{
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004028 pe_debug("tx_complete: %d", tx_complete);
Zhu Jianmin83e8b122018-05-18 19:24:45 +08004029 if (buf)
4030 qdf_nbuf_free(buf);
Abhishek Singh5695e2a2016-10-28 10:39:12 +05304031 return QDF_STATUS_SUCCESS;
4032}
4033
4034/**
4035 * lim_p2p_oper_chan_change_confirm_action_frame()- function to send
4036 * p2p oper chan change confirm action frame
4037 * @mac_ctx: pointer to global mac structure
4038 * @peer: Destination mac.
4039 * @session_entry: session entry
4040 *
4041 * This function is called to send p2p oper chan change confirm action frame.
4042 *
4043 * Return: success if frame is sent else return failure
4044 */
4045
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004046QDF_STATUS
Jeff Johnson9320c1e2018-12-02 13:09:20 -08004047lim_p2p_oper_chan_change_confirm_action_frame(struct mac_context *mac_ctx,
Jeff Johnsona7815652018-11-18 22:58:30 -08004048 tSirMacAddr peer, struct pe_session *session_entry)
Abhishek Singh5695e2a2016-10-28 10:39:12 +05304049{
4050 tDot11fp2p_oper_chan_change_confirm frm;
4051 uint8_t *frame;
4052 tpSirMacMgmtHdr mac_hdr;
4053 uint32_t num_bytes, n_payload, status;
4054 void *packet;
4055 QDF_STATUS qdf_status;
4056 uint8_t tx_flag = 0;
4057 uint8_t sme_session_id = 0;
4058
Jeff Johnson8e9530b2019-03-18 13:41:42 -07004059 if (!session_entry) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004060 pe_err("Session entry is NULL!!!");
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004061 return QDF_STATUS_E_FAILURE;
Abhishek Singh5695e2a2016-10-28 10:39:12 +05304062 }
4063
4064 sme_session_id = session_entry->smeSessionId;
4065
hangtian127c9532019-01-12 13:29:07 +08004066 qdf_mem_zero(&frm, sizeof(frm));
Abhishek Singh5695e2a2016-10-28 10:39:12 +05304067
4068 frm.Category.category = SIR_MAC_ACTION_VENDOR_SPECIFIC_CATEGORY;
4069
4070 qdf_mem_copy(frm.p2p_action_oui.oui_data,
4071 SIR_MAC_P2P_OUI, SIR_MAC_P2P_OUI_SIZE);
4072 frm.p2p_action_subtype.subtype = 0x04;
4073 frm.DialogToken.token = 0x0;
4074
4075 if (session_entry->htCapability) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004076 pe_debug("Populate HT Caps in Assoc Request");
Abhishek Singh5695e2a2016-10-28 10:39:12 +05304077 populate_dot11f_ht_caps(mac_ctx, session_entry, &frm.HTCaps);
4078 }
4079
4080 if (session_entry->vhtCapability) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004081 pe_debug("Populate VHT Caps in Assoc Request");
Abhishek Singh5695e2a2016-10-28 10:39:12 +05304082 populate_dot11f_vht_caps(mac_ctx, session_entry, &frm.VHTCaps);
4083 populate_dot11f_operating_mode(mac_ctx,
4084 &frm.OperatingMode, session_entry);
4085 }
4086
4087 status = dot11f_get_packed_p2p_oper_chan_change_confirmSize(mac_ctx,
4088 &frm, &n_payload);
4089 if (DOT11F_FAILED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004090 pe_err("Failed to get packed size 0x%08x", status);
Abhishek Singh5695e2a2016-10-28 10:39:12 +05304091 /* We'll fall back on the worst case scenario*/
4092 n_payload = sizeof(tDot11fp2p_oper_chan_change_confirm);
4093 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004094 pe_warn("There were warnings while calculating the packed size (0x%08x)",
4095 status);
Abhishek Singh5695e2a2016-10-28 10:39:12 +05304096 }
4097
4098 num_bytes = n_payload + sizeof(tSirMacMgmtHdr);
4099
4100 qdf_status = cds_packet_alloc((uint16_t)num_bytes,
4101 (void **) &frame, (void **) &packet);
4102
4103 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004104 pe_err("Failed to allocate %d bytes", num_bytes);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004105 return QDF_STATUS_E_FAILURE;
Abhishek Singh5695e2a2016-10-28 10:39:12 +05304106 }
4107
hangtian127c9532019-01-12 13:29:07 +08004108 qdf_mem_zero(frame, num_bytes);
Abhishek Singh5695e2a2016-10-28 10:39:12 +05304109
4110 /* Next, fill out the buffer descriptor */
4111 lim_populate_mac_header(mac_ctx, frame, SIR_MAC_MGMT_FRAME,
Pragaspathi Thilagaraj7fb14222019-06-17 23:26:58 +05304112 SIR_MAC_MGMT_ACTION, peer, session_entry->self_mac_addr);
Abhishek Singh5695e2a2016-10-28 10:39:12 +05304113 mac_hdr = (tpSirMacMgmtHdr) frame;
4114 qdf_mem_copy((uint8_t *) mac_hdr->bssId,
4115 (uint8_t *) session_entry->bssId,
4116 sizeof(tSirMacAddr));
4117
4118 status = dot11f_pack_p2p_oper_chan_change_confirm(mac_ctx, &frm,
4119 frame + sizeof(tSirMacMgmtHdr), n_payload, &n_payload);
4120 if (DOT11F_FAILED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004121 pe_err("Failed to pack 0x%08x", status);
Abhishek Singh5695e2a2016-10-28 10:39:12 +05304122 cds_packet_free((void *)packet);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004123 return QDF_STATUS_E_FAILURE;
Abhishek Singh5695e2a2016-10-28 10:39:12 +05304124 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004125 pe_warn("There were warnings while packing 0x%08x",
Abhishek Singh5695e2a2016-10-28 10:39:12 +05304126 status);
4127 }
4128
Liangwei Dong419d7302019-07-15 15:38:28 +08004129 if (wlan_reg_is_5ghz_ch_freq(session_entry->curr_op_freq) ||
4130 session_entry->opmode == QDF_P2P_CLIENT_MODE ||
4131 session_entry->opmode == QDF_P2P_GO_MODE) {
Abhishek Singh5695e2a2016-10-28 10:39:12 +05304132 tx_flag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
4133 }
Liangwei Dong419d7302019-07-15 15:38:28 +08004134 pe_debug("Send frame on channel freq %d to mac "
4135 QDF_MAC_ADDR_STR, session_entry->curr_op_freq,
Srinivas Girigowda34fbba02019-04-08 12:07:44 -07004136 QDF_MAC_ADDR_ARRAY(peer));
Abhishek Singh5695e2a2016-10-28 10:39:12 +05304137
4138 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
4139 session_entry->peSessionId, mac_hdr->fc.subType));
4140
4141 qdf_status = wma_tx_frameWithTxComplete(mac_ctx, packet,
4142 (uint16_t)num_bytes,
4143 TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS,
4144 7, lim_tx_complete, frame,
4145 lim_oper_chan_change_confirm_tx_complete_cnf,
Naveen Rawat296a5182017-09-25 14:02:48 -07004146 tx_flag, sme_session_id, false, 0, RATEID_DEFAULT);
Abhishek Singh5695e2a2016-10-28 10:39:12 +05304147
4148 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
4149 session_entry->peSessionId, qdf_status));
4150 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004151 pe_err("Failed to send status %X!", qdf_status);
Abhishek Singh5695e2a2016-10-28 10:39:12 +05304152 /* Pkt will be freed up by the callback */
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004153 return QDF_STATUS_E_FAILURE;
Abhishek Singh5695e2a2016-10-28 10:39:12 +05304154 }
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004155 return QDF_STATUS_SUCCESS;
Abhishek Singh5695e2a2016-10-28 10:39:12 +05304156}
4157
4158
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004159/**
4160 * \brief Send a Neighbor Report Request Action frame
4161 *
4162 *
Jeff Johnson99f25042018-11-21 22:49:06 -08004163 * \param mac Pointer to the global MAC structure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004164 *
4165 * \param pNeighborReq Address of a tSirMacNeighborReportReq
4166 *
4167 * \param peer mac address of peer station.
4168 *
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004169 * \param pe_session address of session entry.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004170 *
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004171 * \return QDF_STATUS_SUCCESS on success, QDF_STATUS_E_FAILURE else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004172 *
4173 *
4174 */
4175
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004176QDF_STATUS
Jeff Johnson9320c1e2018-12-02 13:09:20 -08004177lim_send_neighbor_report_request_frame(struct mac_context *mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004178 tpSirMacNeighborReportReq pNeighborReq,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004179 tSirMacAddr peer, struct pe_session *pe_session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004180{
Pragaspathi Thilagarajd48e6cd2019-05-30 00:52:43 +05304181 QDF_STATUS status_code = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004182 tDot11fNeighborReportRequest frm;
4183 uint8_t *pFrame;
4184 tpSirMacMgmtHdr pMacHdr;
4185 uint32_t nBytes, nPayload, nStatus;
4186 void *pPacket;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304187 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004188 uint8_t txFlag = 0;
4189 uint8_t smeSessionId = 0;
4190
Jeff Johnson8e9530b2019-03-18 13:41:42 -07004191 if (!pe_session) {
4192 pe_err("(!psession) in Request to send Neighbor Report request action frame");
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004193 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004194 }
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004195 smeSessionId = pe_session->smeSessionId;
hangtian127c9532019-01-12 13:29:07 +08004196 qdf_mem_zero((uint8_t *) &frm, sizeof(frm));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004197
Srinivas Girigowda48bec1c2019-05-17 16:33:30 -07004198 frm.Category.category = ACTION_CATEGORY_RRM;
Srinivas Girigowda395addd2019-05-24 14:03:58 -07004199 frm.Action.action = RRM_NEIGHBOR_REQ;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004200 frm.DialogToken.token = pNeighborReq->dialogToken;
4201
4202 if (pNeighborReq->ssid_present) {
Jeff Johnson99f25042018-11-21 22:49:06 -08004203 populate_dot11f_ssid(mac, &pNeighborReq->ssid, &frm.SSID);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004204 }
4205
4206 nStatus =
Jeff Johnson99f25042018-11-21 22:49:06 -08004207 dot11f_get_packed_neighbor_report_request_size(mac, &frm, &nPayload);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004208 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004209 pe_err("Failed to calculate the packed size for a Neighbor Report Request(0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004210 nStatus);
4211 /* We'll fall back on the worst case scenario: */
4212 nPayload = sizeof(tDot11fNeighborReportRequest);
4213 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004214 pe_warn("There were warnings while calculating the packed size for a Neighbor Report Request(0x%08x)",
4215 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004216 }
4217
4218 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
4219
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304220 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004221 cds_packet_alloc((uint16_t) nBytes, (void **)&pFrame,
4222 (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304223 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004224 pe_err("Failed to allocate %d bytes for a Neighbor "
4225 "Report Request", nBytes);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004226 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004227 }
4228 /* Paranoia: */
hangtian127c9532019-01-12 13:29:07 +08004229 qdf_mem_zero(pFrame, nBytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004230
4231 /* Copy necessary info to BD */
Jeff Johnson99f25042018-11-21 22:49:06 -08004232 lim_populate_mac_header(mac, pFrame, SIR_MAC_MGMT_FRAME,
Pragaspathi Thilagaraj7fb14222019-06-17 23:26:58 +05304233 SIR_MAC_MGMT_ACTION, peer, pe_session->self_mac_addr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004234
4235 /* Update A3 with the BSSID */
4236 pMacHdr = (tpSirMacMgmtHdr) pFrame;
4237
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004238 sir_copy_mac_addr(pMacHdr->bssId, pe_session->bssId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004239
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004240 lim_set_protected_bit(mac, pe_session, peer, pMacHdr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004241
4242 /* Now, we're ready to "pack" the frames */
Jeff Johnson99f25042018-11-21 22:49:06 -08004243 nStatus = dot11f_pack_neighbor_report_request(mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004244 &frm,
4245 pFrame +
4246 sizeof(tSirMacMgmtHdr),
4247 nPayload, &nPayload);
4248
4249 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004250 pe_err("Failed to pack an Neighbor Report Request (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004251 nStatus);
4252
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004253 /* FIXME - Need to convert to QDF_STATUS */
Pragaspathi Thilagarajd48e6cd2019-05-30 00:52:43 +05304254 status_code = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004255 goto returnAfterError;
4256 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004257 pe_warn("There were warnings while packing Neighbor Report Request (0x%08x)",
4258 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004259 }
4260
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004261 pe_debug("Sending a Neighbor Report Request to");
Jeff Johnson99f25042018-11-21 22:49:06 -08004262 lim_print_mac_addr(mac, peer, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004263
Liangwei Dong419d7302019-07-15 15:38:28 +08004264 if (wlan_reg_is_5ghz_ch_freq(pe_session->curr_op_freq) ||
4265 pe_session->opmode == QDF_P2P_CLIENT_MODE ||
4266 pe_session->opmode == QDF_P2P_GO_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004267 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004268
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304269 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004270 pe_session->peSessionId, pMacHdr->fc.subType));
Jeff Johnson99f25042018-11-21 22:49:06 -08004271 qdf_status = wma_tx_frame(mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004272 pPacket,
4273 (uint16_t) nBytes,
4274 TXRX_FRM_802_11_MGMT,
4275 ANI_TXDIR_TODS,
4276 7, lim_tx_complete, pFrame, txFlag,
Naveen Rawat296a5182017-09-25 14:02:48 -07004277 smeSessionId, 0, RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304278 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004279 pe_session->peSessionId, qdf_status));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304280 if (QDF_STATUS_SUCCESS != qdf_status) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004281 pe_err("wma_tx_frame FAILED! Status [%d]", qdf_status);
Pragaspathi Thilagarajd48e6cd2019-05-30 00:52:43 +05304282 status_code = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004283 /* Pkt will be freed up by the callback */
Pragaspathi Thilagarajd48e6cd2019-05-30 00:52:43 +05304284 return status_code;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004285 } else
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004286 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004287
4288returnAfterError:
4289 cds_packet_free((void *)pPacket);
4290
Pragaspathi Thilagarajd48e6cd2019-05-30 00:52:43 +05304291 return status_code;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004292} /* End lim_send_neighbor_report_request_frame. */
4293
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004294QDF_STATUS
Jeff Johnson9320c1e2018-12-02 13:09:20 -08004295lim_send_link_report_action_frame(struct mac_context *mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004296 tpSirMacLinkReport pLinkReport,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004297 tSirMacAddr peer, struct pe_session *pe_session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004298{
Pragaspathi Thilagarajd48e6cd2019-05-30 00:52:43 +05304299 QDF_STATUS status_code = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004300 tDot11fLinkMeasurementReport frm;
4301 uint8_t *pFrame;
4302 tpSirMacMgmtHdr pMacHdr;
4303 uint32_t nBytes, nPayload, nStatus;
4304 void *pPacket;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304305 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004306 uint8_t txFlag = 0;
Pragaspathi Thilagaraj683c1cf2019-09-23 18:40:57 +05304307 uint8_t vdev_id = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004308
Jeff Johnson8e9530b2019-03-18 13:41:42 -07004309 if (!pe_session) {
Pragaspathi Thilagaraj683c1cf2019-09-23 18:40:57 +05304310 pe_err("RRM: Send link report: NULL PE session");
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004311 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004312 }
4313
Pragaspathi Thilagaraj683c1cf2019-09-23 18:40:57 +05304314 vdev_id = pe_session->vdev_id;
hangtian127c9532019-01-12 13:29:07 +08004315 qdf_mem_zero((uint8_t *) &frm, sizeof(frm));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004316
Srinivas Girigowda48bec1c2019-05-17 16:33:30 -07004317 frm.Category.category = ACTION_CATEGORY_RRM;
Srinivas Girigowda395addd2019-05-24 14:03:58 -07004318 frm.Action.action = RRM_LINK_MEASUREMENT_RPT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004319 frm.DialogToken.token = pLinkReport->dialogToken;
4320
4321 /* IEEE Std. 802.11 7.3.2.18. for the report element. */
4322 /* Even though TPC report an IE, it is represented using fixed fields since it is positioned */
4323 /* in the middle of other fixed fields in the link report frame(IEEE Std. 802.11k section7.4.6.4 */
4324 /* and frame parser always expects IEs to come after all fixed fields. It is easier to handle */
4325 /* such case this way than changing the frame parser. */
Srinivas Girigowda61771262019-04-01 11:55:19 -07004326 frm.TPCEleID.TPCId = WLAN_ELEMID_TPCREP;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004327 frm.TPCEleLen.TPCLen = 2;
4328 frm.TxPower.txPower = pLinkReport->txPower;
4329 frm.LinkMargin.linkMargin = 0;
4330
4331 frm.RxAntennaId.antennaId = pLinkReport->rxAntenna;
4332 frm.TxAntennaId.antennaId = pLinkReport->txAntenna;
4333 frm.RCPI.rcpi = pLinkReport->rcpi;
4334 frm.RSNI.rsni = pLinkReport->rsni;
4335
4336 nStatus =
Jeff Johnson99f25042018-11-21 22:49:06 -08004337 dot11f_get_packed_link_measurement_report_size(mac, &frm, &nPayload);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004338 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004339 pe_err("Failed to calculate the packed size for a Link Report (0x%08x)", nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004340 /* We'll fall back on the worst case scenario: */
4341 nPayload = sizeof(tDot11fLinkMeasurementReport);
4342 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004343 pe_warn("There were warnings while calculating the packed size for a Link Report (0x%08x)",
4344 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004345 }
4346
4347 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
4348
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304349 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004350 cds_packet_alloc((uint16_t) nBytes, (void **)&pFrame,
4351 (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304352 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004353 pe_err("Failed to allocate %d bytes for a Link "
4354 "Report", nBytes);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004355 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004356 }
4357 /* Paranoia: */
hangtian127c9532019-01-12 13:29:07 +08004358 qdf_mem_zero(pFrame, nBytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004359
4360 /* Copy necessary info to BD */
Jeff Johnson99f25042018-11-21 22:49:06 -08004361 lim_populate_mac_header(mac, pFrame, SIR_MAC_MGMT_FRAME,
Pragaspathi Thilagaraj7fb14222019-06-17 23:26:58 +05304362 SIR_MAC_MGMT_ACTION, peer, pe_session->self_mac_addr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004363
4364 /* Update A3 with the BSSID */
4365 pMacHdr = (tpSirMacMgmtHdr) pFrame;
4366
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004367 sir_copy_mac_addr(pMacHdr->bssId, pe_session->bssId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004368
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004369 lim_set_protected_bit(mac, pe_session, peer, pMacHdr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004370
4371 /* Now, we're ready to "pack" the frames */
Jeff Johnson99f25042018-11-21 22:49:06 -08004372 nStatus = dot11f_pack_link_measurement_report(mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004373 &frm,
4374 pFrame +
4375 sizeof(tSirMacMgmtHdr),
4376 nPayload, &nPayload);
4377
4378 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004379 pe_err("Failed to pack an Link Report (0x%08x)", nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004380
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004381 /* FIXME - Need to convert to QDF_STATUS */
Pragaspathi Thilagarajd48e6cd2019-05-30 00:52:43 +05304382 status_code = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004383 goto returnAfterError;
4384 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004385 pe_warn("There were warnings while packing Link Report (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004386 nStatus);
4387 }
4388
Pragaspathi Thilagaraj683c1cf2019-09-23 18:40:57 +05304389 pe_warn("RRM: Sending Link Report to %pM on vdev[%d]", peer, vdev_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004390
Liangwei Dong419d7302019-07-15 15:38:28 +08004391 if (wlan_reg_is_5ghz_ch_freq(pe_session->curr_op_freq) ||
4392 pe_session->opmode == QDF_P2P_CLIENT_MODE ||
4393 pe_session->opmode == QDF_P2P_GO_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004394 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004395
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304396 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004397 pe_session->peSessionId, pMacHdr->fc.subType));
Jeff Johnson99f25042018-11-21 22:49:06 -08004398 qdf_status = wma_tx_frame(mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004399 pPacket,
4400 (uint16_t) nBytes,
4401 TXRX_FRM_802_11_MGMT,
4402 ANI_TXDIR_TODS,
4403 7, lim_tx_complete, pFrame, txFlag,
Pragaspathi Thilagaraj683c1cf2019-09-23 18:40:57 +05304404 vdev_id, 0, RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304405 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004406 pe_session->peSessionId, qdf_status));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304407 if (QDF_STATUS_SUCCESS != qdf_status) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004408 pe_err("wma_tx_frame FAILED! Status [%d]", qdf_status);
Pragaspathi Thilagarajd48e6cd2019-05-30 00:52:43 +05304409 status_code = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004410 /* Pkt will be freed up by the callback */
Pragaspathi Thilagarajd48e6cd2019-05-30 00:52:43 +05304411 return status_code;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004412 } else
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004413 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004414
4415returnAfterError:
4416 cds_packet_free((void *)pPacket);
4417
Pragaspathi Thilagarajd48e6cd2019-05-30 00:52:43 +05304418 return status_code;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004419} /* End lim_send_link_report_action_frame. */
4420
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004421QDF_STATUS
Jeff Johnson9320c1e2018-12-02 13:09:20 -08004422lim_send_radio_measure_report_action_frame(struct mac_context *mac,
Vignesh Viswanathan3b4bf982018-06-05 15:04:23 +05304423 uint8_t dialog_token,
4424 uint8_t num_report,
Vignesh Viswanathan09bd8f42018-08-14 22:04:36 +05304425 bool is_last_frame,
Vignesh Viswanathan3b4bf982018-06-05 15:04:23 +05304426 tpSirMacRadioMeasureReport pRRMReport,
4427 tSirMacAddr peer,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004428 struct pe_session *pe_session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004429{
Pragaspathi Thilagarajd48e6cd2019-05-30 00:52:43 +05304430 QDF_STATUS status_code = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004431 uint8_t *pFrame;
4432 tpSirMacMgmtHdr pMacHdr;
4433 uint32_t nBytes, nPayload, nStatus;
4434 void *pPacket;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304435 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004436 uint8_t i;
4437 uint8_t txFlag = 0;
4438 uint8_t smeSessionId = 0;
Vignesh Viswanathan793328d2018-11-02 11:32:35 +05304439 bool is_last_report = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004440
4441 tDot11fRadioMeasurementReport *frm =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304442 qdf_mem_malloc(sizeof(tDot11fRadioMeasurementReport));
Arif Hussainf5b6c412018-10-10 19:41:09 -07004443 if (!frm)
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004444 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004445
Jeff Johnson8e9530b2019-03-18 13:41:42 -07004446 if (!pe_session) {
4447 pe_err("(!psession) in Request to send Beacon Report action frame");
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304448 qdf_mem_free(frm);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004449 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004450 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004451
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004452 smeSessionId = pe_session->smeSessionId;
Deepak Dhamdhere6a021482017-04-20 17:59:58 -07004453
Vignesh Viswanathan09bd8f42018-08-14 22:04:36 +05304454 pe_debug("dialog_token %d num_report %d is_last_frame %d",
4455 dialog_token, num_report, is_last_frame);
Padma, Santhosh Kumar93ec7d22016-12-26 15:58:37 +05304456
Srinivas Girigowda48bec1c2019-05-17 16:33:30 -07004457 frm->Category.category = ACTION_CATEGORY_RRM;
Srinivas Girigowda395addd2019-05-24 14:03:58 -07004458 frm->Action.action = RRM_RADIO_MEASURE_RPT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004459 frm->DialogToken.token = dialog_token;
4460
4461 frm->num_MeasurementReport =
4462 (num_report >
4463 RADIO_REPORTS_MAX_IN_A_FRAME) ? RADIO_REPORTS_MAX_IN_A_FRAME :
4464 num_report;
4465
4466 for (i = 0; i < frm->num_MeasurementReport; i++) {
4467 frm->MeasurementReport[i].type = pRRMReport[i].type;
4468 frm->MeasurementReport[i].token = pRRMReport[i].token;
4469 frm->MeasurementReport[i].late = 0; /* IEEE 802.11k section 7.3.22. (always zero in rrm) */
4470 switch (pRRMReport[i].type) {
4471 case SIR_MAC_RRM_BEACON_TYPE:
Vignesh Viswanathan793328d2018-11-02 11:32:35 +05304472 /*
4473 * Last beacon report indication needs to be set to 1
4474 * only for the last report in the last frame
4475 */
4476 if (is_last_frame &&
4477 (i == (frm->num_MeasurementReport - 1)))
4478 is_last_report = true;
4479
Jeff Johnson99f25042018-11-21 22:49:06 -08004480 populate_dot11f_beacon_report(mac,
Vignesh Viswanathan3b4bf982018-06-05 15:04:23 +05304481 &frm->MeasurementReport[i],
4482 &pRRMReport[i].report.
4483 beaconReport,
Vignesh Viswanathan793328d2018-11-02 11:32:35 +05304484 is_last_report);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004485 frm->MeasurementReport[i].incapable =
4486 pRRMReport[i].incapable;
4487 frm->MeasurementReport[i].refused =
4488 pRRMReport[i].refused;
4489 frm->MeasurementReport[i].present = 1;
4490 break;
4491 default:
4492 frm->MeasurementReport[i].incapable =
4493 pRRMReport[i].incapable;
4494 frm->MeasurementReport[i].refused =
4495 pRRMReport[i].refused;
4496 frm->MeasurementReport[i].present = 1;
4497 break;
4498 }
4499 }
4500
4501 nStatus =
Jeff Johnson99f25042018-11-21 22:49:06 -08004502 dot11f_get_packed_radio_measurement_report_size(mac, frm, &nPayload);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004503 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004504 pe_err("Failed to calculate the packed size for a Radio Measure Report (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004505 nStatus);
4506 /* We'll fall back on the worst case scenario: */
4507 nPayload = sizeof(tDot11fLinkMeasurementReport);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304508 qdf_mem_free(frm);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004509 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004510 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004511 pe_warn("There were warnings while calculating the packed size for a Radio Measure Report (0x%08x)",
4512 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004513 }
4514
4515 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
4516
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304517 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004518 cds_packet_alloc((uint16_t) nBytes, (void **)&pFrame,
4519 (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304520 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004521 pe_err("Failed to allocate %d bytes for a Radio Measure "
4522 "Report", nBytes);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304523 qdf_mem_free(frm);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004524 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004525 }
4526 /* Paranoia: */
hangtian127c9532019-01-12 13:29:07 +08004527 qdf_mem_zero(pFrame, nBytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004528
4529 /* Copy necessary info to BD */
Jeff Johnson99f25042018-11-21 22:49:06 -08004530 lim_populate_mac_header(mac, pFrame, SIR_MAC_MGMT_FRAME,
Pragaspathi Thilagaraj7fb14222019-06-17 23:26:58 +05304531 SIR_MAC_MGMT_ACTION, peer, pe_session->self_mac_addr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004532
4533 /* Update A3 with the BSSID */
4534 pMacHdr = (tpSirMacMgmtHdr) pFrame;
4535
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004536 sir_copy_mac_addr(pMacHdr->bssId, pe_session->bssId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004537
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004538 lim_set_protected_bit(mac, pe_session, peer, pMacHdr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004539
4540 /* Now, we're ready to "pack" the frames */
Jeff Johnson99f25042018-11-21 22:49:06 -08004541 nStatus = dot11f_pack_radio_measurement_report(mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004542 frm,
4543 pFrame +
4544 sizeof(tSirMacMgmtHdr),
4545 nPayload, &nPayload);
4546
4547 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004548 pe_err("Failed to pack an Radio Measure Report (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004549 nStatus);
4550
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004551 /* FIXME - Need to convert to QDF_STATUS */
Pragaspathi Thilagarajd48e6cd2019-05-30 00:52:43 +05304552 status_code = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004553 goto returnAfterError;
4554 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004555 pe_warn("There were warnings while packing Radio Measure Report (0x%08x)",
4556 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004557 }
4558
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004559 pe_warn("Sending a Radio Measure Report to");
Jeff Johnson99f25042018-11-21 22:49:06 -08004560 lim_print_mac_addr(mac, peer, LOGW);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004561
Liangwei Dong419d7302019-07-15 15:38:28 +08004562 if (wlan_reg_is_5ghz_ch_freq(pe_session->curr_op_freq) ||
4563 pe_session->opmode == QDF_P2P_CLIENT_MODE ||
4564 pe_session->opmode == QDF_P2P_GO_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004565 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004566
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304567 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004568 pe_session->peSessionId, pMacHdr->fc.subType));
Jeff Johnson99f25042018-11-21 22:49:06 -08004569 qdf_status = wma_tx_frame(mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004570 pPacket,
4571 (uint16_t) nBytes,
4572 TXRX_FRM_802_11_MGMT,
4573 ANI_TXDIR_TODS,
4574 7, lim_tx_complete, pFrame, txFlag,
Naveen Rawat296a5182017-09-25 14:02:48 -07004575 smeSessionId, 0, RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304576 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004577 pe_session->peSessionId, qdf_status));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304578 if (QDF_STATUS_SUCCESS != qdf_status) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004579 pe_err("wma_tx_frame FAILED! Status [%d]", qdf_status);
Pragaspathi Thilagarajd48e6cd2019-05-30 00:52:43 +05304580 status_code = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004581 /* Pkt will be freed up by the callback */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304582 qdf_mem_free(frm);
Pragaspathi Thilagarajd48e6cd2019-05-30 00:52:43 +05304583 return status_code;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004584 } else {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304585 qdf_mem_free(frm);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004586 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004587 }
4588
4589returnAfterError:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304590 qdf_mem_free(frm);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004591 cds_packet_free((void *)pPacket);
Pragaspathi Thilagarajd48e6cd2019-05-30 00:52:43 +05304592 return status_code;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004593}
4594
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004595#ifdef WLAN_FEATURE_11W
4596/**
4597 * \brief Send SA query request action frame to peer
4598 *
4599 * \sa lim_send_sa_query_request_frame
4600 *
4601 *
Jeff Johnson9320c1e2018-12-02 13:09:20 -08004602 * \param mac The global struct mac_context *object
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004603 *
4604 * \param transId Transaction identifier
4605 *
4606 * \param peer The Mac address of the station to which this action frame is addressed
4607 *
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004608 * \param pe_session The PE session entry
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004609 *
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004610 * \return QDF_STATUS_SUCCESS if setup completes successfully
4611 * QDF_STATUS_E_FAILURE is some problem is encountered
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004612 */
4613
Jeff Johnson9320c1e2018-12-02 13:09:20 -08004614QDF_STATUS lim_send_sa_query_request_frame(struct mac_context *mac, uint8_t *transId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004615 tSirMacAddr peer,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004616 struct pe_session *pe_session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004617{
4618
4619 tDot11fSaQueryReq frm; /* SA query request action frame */
4620 uint8_t *pFrame;
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004621 QDF_STATUS nSirStatus;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004622 tpSirMacMgmtHdr pMacHdr;
4623 uint32_t nBytes, nPayload, nStatus;
4624 void *pPacket;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304625 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004626 uint8_t txFlag = 0;
4627 uint8_t smeSessionId = 0;
4628
hangtian127c9532019-01-12 13:29:07 +08004629 qdf_mem_zero((uint8_t *) &frm, sizeof(frm));
Srinivas Girigowda48bec1c2019-05-17 16:33:30 -07004630 frm.Category.category = ACTION_CATEGORY_SA_QUERY;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004631 /* 11w action field is :
4632 action: 0 --> SA Query Request action frame
4633 action: 1 --> SA Query Response action frame */
Srinivas Girigowdafeb23fc2019-06-13 11:12:29 -07004634 frm.Action.action = SA_QUERY_REQUEST;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004635 /* 11w SA Query Request transId */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304636 qdf_mem_copy(&frm.TransactionId.transId[0], &transId[0], 2);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004637
Jeff Johnson99f25042018-11-21 22:49:06 -08004638 nStatus = dot11f_get_packed_sa_query_req_size(mac, &frm, &nPayload);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004639 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004640 pe_err("Failed to calculate the packed size for an SA Query Request (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004641 nStatus);
4642 /* We'll fall back on the worst case scenario: */
4643 nPayload = sizeof(tDot11fSaQueryReq);
4644 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004645 pe_warn("There were warnings while calculating the packed size for an SA Query Request (0x%08x)",
4646 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004647 }
4648
4649 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304650 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004651 cds_packet_alloc(nBytes, (void **)&pFrame, (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304652 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004653 pe_err("Failed to allocate %d bytes for a SA Query Request "
4654 "action frame", nBytes);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004655 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004656 }
4657 /* Paranoia: */
hangtian127c9532019-01-12 13:29:07 +08004658 qdf_mem_zero(pFrame, nBytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004659
4660 /* Copy necessary info to BD */
Jeff Johnson99f25042018-11-21 22:49:06 -08004661 lim_populate_mac_header(mac, pFrame, SIR_MAC_MGMT_FRAME,
Pragaspathi Thilagaraj7fb14222019-06-17 23:26:58 +05304662 SIR_MAC_MGMT_ACTION, peer, pe_session->self_mac_addr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004663
4664 /* Update A3 with the BSSID */
4665 pMacHdr = (tpSirMacMgmtHdr) pFrame;
4666
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004667 sir_copy_mac_addr(pMacHdr->bssId, pe_session->bssId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004668
4669 /* Since this is a SA Query Request, set the "protect" (aka WEP) bit */
4670 /* in the FC */
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004671 lim_set_protected_bit(mac, pe_session, peer, pMacHdr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004672
4673 /* Pack 11w SA Query Request frame */
Jeff Johnson99f25042018-11-21 22:49:06 -08004674 nStatus = dot11f_pack_sa_query_req(mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004675 &frm,
4676 pFrame + sizeof(tSirMacMgmtHdr),
4677 nPayload, &nPayload);
4678
4679 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004680 pe_err("Failed to pack an SA Query Request (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004681 nStatus);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004682 /* FIXME - Need to convert to QDF_STATUS */
4683 nSirStatus = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004684 goto returnAfterError;
4685 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004686 pe_warn("There were warnings while packing SA Query Request (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004687 nStatus);
4688 }
4689
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004690 pe_debug("Sending an SA Query Request to");
Jeff Johnson99f25042018-11-21 22:49:06 -08004691 lim_print_mac_addr(mac, peer, LOGD);
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004692 pe_debug("Sending an SA Query Request from ");
Pragaspathi Thilagaraj7fb14222019-06-17 23:26:58 +05304693 lim_print_mac_addr(mac, pe_session->self_mac_addr, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004694
Liangwei Dong419d7302019-07-15 15:38:28 +08004695 if (wlan_reg_is_5ghz_ch_freq(pe_session->curr_op_freq) ||
4696 pe_session->opmode == QDF_P2P_CLIENT_MODE ||
4697 pe_session->opmode == QDF_P2P_GO_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004698 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
Pragaspathi Thilagaraje64714a2019-05-23 00:46:25 +05304699
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004700 smeSessionId = pe_session->smeSessionId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004701
Jeff Johnson99f25042018-11-21 22:49:06 -08004702 qdf_status = wma_tx_frame(mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004703 pPacket,
4704 (uint16_t) nBytes,
4705 TXRX_FRM_802_11_MGMT,
4706 ANI_TXDIR_TODS,
4707 7, lim_tx_complete, pFrame, txFlag,
Naveen Rawat296a5182017-09-25 14:02:48 -07004708 smeSessionId, 0, RATEID_DEFAULT);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304709 if (QDF_STATUS_SUCCESS != qdf_status) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004710 pe_err("wma_tx_frame FAILED! Status [%d]", qdf_status);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004711 nSirStatus = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004712 /* Pkt will be freed up by the callback */
4713 return nSirStatus;
4714 } else {
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004715 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004716 }
4717
4718returnAfterError:
4719 cds_packet_free((void *)pPacket);
4720 return nSirStatus;
4721} /* End lim_send_sa_query_request_frame */
4722
4723/**
4724 * \brief Send SA query response action frame to peer
4725 *
4726 * \sa lim_send_sa_query_response_frame
4727 *
4728 *
Jeff Johnson9320c1e2018-12-02 13:09:20 -08004729 * \param mac The global struct mac_context *object
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004730 *
4731 * \param transId Transaction identifier received in SA query request action frame
4732 *
4733 * \param peer The Mac address of the AP to which this action frame is addressed
4734 *
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004735 * \param pe_session The PE session entry
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004736 *
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004737 * \return QDF_STATUS_SUCCESS if setup completes successfully
4738 * QDF_STATUS_E_FAILURE is some problem is encountered
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004739 */
4740
Jeff Johnson9320c1e2018-12-02 13:09:20 -08004741QDF_STATUS lim_send_sa_query_response_frame(struct mac_context *mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004742 uint8_t *transId, tSirMacAddr peer,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004743 struct pe_session *pe_session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004744{
4745
Jeff Johnson47d75242018-05-12 15:58:53 -07004746 tDot11fSaQueryRsp frm; /* SA query response action frame */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004747 uint8_t *pFrame;
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004748 QDF_STATUS nSirStatus;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004749 tpSirMacMgmtHdr pMacHdr;
4750 uint32_t nBytes, nPayload, nStatus;
4751 void *pPacket;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304752 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004753 uint8_t txFlag = 0;
4754 uint8_t smeSessionId = 0;
4755
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004756 smeSessionId = pe_session->smeSessionId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004757
hangtian127c9532019-01-12 13:29:07 +08004758 qdf_mem_zero((uint8_t *) &frm, sizeof(frm));
Srinivas Girigowda48bec1c2019-05-17 16:33:30 -07004759 frm.Category.category = ACTION_CATEGORY_SA_QUERY;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004760 /*11w action field is :
4761 action: 0 --> SA query request action frame
4762 action: 1 --> SA query response action frame */
Srinivas Girigowdafeb23fc2019-06-13 11:12:29 -07004763 frm.Action.action = SA_QUERY_RESPONSE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004764 /*11w SA query response transId is same as
4765 SA query request transId */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304766 qdf_mem_copy(&frm.TransactionId.transId[0], &transId[0], 2);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004767
Jeff Johnson99f25042018-11-21 22:49:06 -08004768 nStatus = dot11f_get_packed_sa_query_rsp_size(mac, &frm, &nPayload);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004769 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004770 pe_err("Failed to calculate the packed size for a SA Query Response (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004771 nStatus);
4772 /* We'll fall back on the worst case scenario: */
4773 nPayload = sizeof(tDot11fSaQueryRsp);
4774 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004775 pe_warn("There were warnings while calculating the packed size for an SA Query Response (0x%08x)",
4776 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004777 }
4778
4779 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304780 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004781 cds_packet_alloc(nBytes, (void **)&pFrame, (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304782 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004783 pe_err("Failed to allocate %d bytes for a SA query response"
4784 " action frame", nBytes);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004785 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004786 }
4787 /* Paranoia: */
hangtian127c9532019-01-12 13:29:07 +08004788 qdf_mem_zero(pFrame, nBytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004789
4790 /* Copy necessary info to BD */
Jeff Johnson99f25042018-11-21 22:49:06 -08004791 lim_populate_mac_header(mac, pFrame, SIR_MAC_MGMT_FRAME,
Pragaspathi Thilagaraj7fb14222019-06-17 23:26:58 +05304792 SIR_MAC_MGMT_ACTION, peer, pe_session->self_mac_addr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004793
4794 /* Update A3 with the BSSID */
4795 pMacHdr = (tpSirMacMgmtHdr) pFrame;
4796
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004797 sir_copy_mac_addr(pMacHdr->bssId, pe_session->bssId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004798
4799 /* Since this is a SA Query Response, set the "protect" (aka WEP) bit */
4800 /* in the FC */
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004801 lim_set_protected_bit(mac, pe_session, peer, pMacHdr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004802
4803 /* Pack 11w SA query response frame */
Jeff Johnson99f25042018-11-21 22:49:06 -08004804 nStatus = dot11f_pack_sa_query_rsp(mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004805 &frm,
4806 pFrame + sizeof(tSirMacMgmtHdr),
4807 nPayload, &nPayload);
4808
4809 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004810 pe_err("Failed to pack an SA Query Response (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004811 nStatus);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004812 /* FIXME - Need to convert to QDF_STATUS */
4813 nSirStatus = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004814 goto returnAfterError;
4815 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004816 pe_warn("There were warnings while packing SA Query Response (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004817 nStatus);
4818 }
4819
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004820 pe_debug("Sending a SA Query Response to");
Jeff Johnson99f25042018-11-21 22:49:06 -08004821 lim_print_mac_addr(mac, peer, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004822
Liangwei Dong419d7302019-07-15 15:38:28 +08004823 if (wlan_reg_is_5ghz_ch_freq(pe_session->curr_op_freq) ||
4824 pe_session->opmode == QDF_P2P_CLIENT_MODE ||
4825 pe_session->opmode == QDF_P2P_GO_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004826 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004827
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304828 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004829 pe_session->peSessionId, pMacHdr->fc.subType));
Jeff Johnson99f25042018-11-21 22:49:06 -08004830 qdf_status = wma_tx_frame(mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004831 pPacket,
4832 (uint16_t) nBytes,
4833 TXRX_FRM_802_11_MGMT,
4834 ANI_TXDIR_TODS,
4835 7, lim_tx_complete, pFrame, txFlag,
Naveen Rawat296a5182017-09-25 14:02:48 -07004836 smeSessionId, 0, RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304837 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004838 pe_session->peSessionId, qdf_status));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304839 if (QDF_STATUS_SUCCESS != qdf_status) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004840 pe_err("wma_tx_frame FAILED! Status [%d]", qdf_status);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004841 nSirStatus = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004842 /* Pkt will be freed up by the callback */
4843 return nSirStatus;
4844 } else {
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004845 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004846 }
4847
4848returnAfterError:
4849 cds_packet_free((void *)pPacket);
4850 return nSirStatus;
4851} /* End lim_send_sa_query_response_frame */
4852#endif
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004853
Manjunathappa Prakash458f6fe2019-05-13 18:33:01 -07004854#if defined(QCA_WIFI_QCA6290) || defined(QCA_WIFI_QCA6390) || \
4855 defined(QCA_WIFI_QCA6490)
Jinwei Chen332b5cf2019-03-05 13:26:17 +08004856#ifdef WLAN_FEATURE_11AX
Kiran Kumar Lokere9d80ef62019-10-15 17:02:49 -07004857#define IS_PE_SESSION_HE_MODE(_session) ((_session)->he_capable)
Jinwei Chen332b5cf2019-03-05 13:26:17 +08004858#else
Kiran Kumar Lokere9d80ef62019-10-15 17:02:49 -07004859#define IS_PE_SESSION_HE_MODE(_session) false
Jinwei Chen332b5cf2019-03-05 13:26:17 +08004860#endif /* WLAN_FEATURE_11AX */
4861#else
Kiran Kumar Lokere9d80ef62019-10-15 17:02:49 -07004862#define IS_PE_SESSION_HE_MODE(_session) false
Jinwei Chen332b5cf2019-03-05 13:26:17 +08004863#endif
4864
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004865/**
4866 * lim_send_addba_response_frame(): Send ADDBA response action frame to peer
4867 * @mac_ctx: mac context
4868 * @peer_mac: Peer MAC address
4869 * @tid: TID for which addba response is being sent
4870 * @session: PE session entry
Kiran Kumar Lokere40875852018-01-15 12:36:19 -08004871 * @addba_extn_present: ADDBA extension present flag
Kiran Kumar Lokereaee823a2018-03-22 15:27:05 -07004872 * @amsdu_support: amsdu in ampdu support
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004873 *
4874 * This function is called when ADDBA request is successful. ADDBA response is
4875 * setup by calling addba_response_setup API and frame is then sent out OTA.
4876 *
4877 * Return: QDF_STATUS
4878 */
Jeff Johnson9320c1e2018-12-02 13:09:20 -08004879QDF_STATUS lim_send_addba_response_frame(struct mac_context *mac_ctx,
Kiran Kumar Lokere40875852018-01-15 12:36:19 -08004880 tSirMacAddr peer_mac, uint16_t tid,
Jeff Johnsona7815652018-11-18 22:58:30 -08004881 struct pe_session *session, uint8_t addba_extn_present,
Kiran Kumar Lokereaee823a2018-03-22 15:27:05 -07004882 uint8_t amsdu_support)
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004883{
4884
4885 tDot11faddba_rsp frm;
4886 uint8_t *frame_ptr;
4887 tpSirMacMgmtHdr mgmt_hdr;
4888 uint32_t num_bytes, payload_size, status;
Sandeep Puligilla39cec082018-04-30 15:18:45 -07004889 void *pkt_ptr = NULL;
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004890 QDF_STATUS qdf_status;
4891 uint8_t tx_flag = 0;
4892 uint8_t sme_sessionid = 0;
4893 uint16_t buff_size, status_code, batimeout;
4894 uint8_t peer_id, dialog_token;
4895 void *soc = cds_get_context(QDF_MODULE_ID_SOC);
4896 void *peer, *pdev;
Kiran Kumar Lokere40875852018-01-15 12:36:19 -08004897 uint8_t he_frag = 0;
Yu Wang36d52102019-09-20 12:08:04 +08004898 tpDphHashNode sta_ds;
4899 uint16_t aid;
4900 bool he_cap = false;
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004901
4902 sme_sessionid = session->smeSessionId;
4903
4904 pdev = cds_get_context(QDF_MODULE_ID_TXRX);
4905 if (!pdev) {
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004906 pe_err("pdev is NULL");
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004907 return QDF_STATUS_E_FAILURE;
4908 }
4909
Mohit Khannac4c22252017-11-20 11:06:33 -08004910 peer = cdp_peer_get_ref_by_addr(soc, pdev, peer_mac, &peer_id,
4911 PEER_DEBUG_ID_LIM_SEND_ADDBA_RESP);
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004912 if (!peer) {
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004913 pe_err("PEER [%pM] not found", peer_mac);
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004914 return QDF_STATUS_E_FAILURE;
4915 }
4916
4917 cdp_addba_responsesetup(soc, peer, tid, &dialog_token,
4918 &status_code, &buff_size, &batimeout);
4919
Mohit Khannac4c22252017-11-20 11:06:33 -08004920 cdp_peer_release_ref(soc, peer, PEER_DEBUG_ID_LIM_SEND_ADDBA_RESP);
hangtian127c9532019-01-12 13:29:07 +08004921 qdf_mem_zero((uint8_t *) &frm, sizeof(frm));
Srinivas Girigowda48bec1c2019-05-17 16:33:30 -07004922 frm.Category.category = ACTION_CATEGORY_BACK;
Srinivas Girigowdaef0d7142019-05-17 17:07:47 -07004923 frm.Action.action = ADDBA_RESPONSE;
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004924
4925 frm.DialogToken.token = dialog_token;
4926 frm.Status.status = status_code;
Kiran Kumar Lokere08195ef2018-01-17 19:25:15 -08004927 if (mac_ctx->reject_addba_req) {
4928 frm.Status.status = eSIR_MAC_REQ_DECLINED_STATUS;
4929 pe_err("refused addba req");
4930 }
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004931 frm.addba_param_set.tid = tid;
Yu Wang36d52102019-09-20 12:08:04 +08004932
4933 if (lim_is_session_he_capable(session)) {
4934 sta_ds = dph_lookup_hash_entry(mac_ctx, peer_mac, &aid,
4935 &session->dph.dphHashTable);
4936 if (sta_ds)
4937 he_cap = lim_is_sta_he_capable(sta_ds);
4938 }
4939
4940 if (he_cap)
Kiran Kumar Lokere22f05d42019-06-28 18:33:43 -07004941 frm.addba_param_set.buff_size = MAX_BA_BUFF_SIZE;
4942 else
4943 frm.addba_param_set.buff_size = SIR_MAC_BA_DEFAULT_BUFF_SIZE;
Yu Wang36d52102019-09-20 12:08:04 +08004944
Kiran Kumar Lokerebc87bec2018-02-27 20:06:42 -08004945 if (mac_ctx->usr_cfg_ba_buff_size)
4946 frm.addba_param_set.buff_size = mac_ctx->usr_cfg_ba_buff_size;
Kiran Kumar Lokereeac7fe92018-07-24 16:56:01 -07004947
4948 if (frm.addba_param_set.buff_size > MAX_BA_BUFF_SIZE)
4949 frm.addba_param_set.buff_size = MAX_BA_BUFF_SIZE;
4950
4951 if (frm.addba_param_set.buff_size > SIR_MAC_BA_DEFAULT_BUFF_SIZE) {
4952 if (session->active_ba_64_session) {
4953 frm.addba_param_set.buff_size =
4954 SIR_MAC_BA_DEFAULT_BUFF_SIZE;
4955 }
4956 } else if (!session->active_ba_64_session) {
4957 session->active_ba_64_session = true;
4958 }
Jinwei Chen332b5cf2019-03-05 13:26:17 +08004959
Kiran Kumar Lokere9d80ef62019-10-15 17:02:49 -07004960 /* Enable RX AMSDU only in HE mode if supported */
Jinwei Chen332b5cf2019-03-05 13:26:17 +08004961 if (mac_ctx->is_usr_cfg_amsdu_enabled &&
Kiran Kumar Lokere9d80ef62019-10-15 17:02:49 -07004962 ((IS_PE_SESSION_HE_MODE(session) &&
4963 WLAN_REG_IS_24GHZ_CH_FREQ(session->curr_op_freq)) ||
4964 WLAN_REG_IS_5GHZ_CH_FREQ(session->curr_op_freq)))
Arif Hussain0e246802018-05-01 18:13:44 -07004965 frm.addba_param_set.amsdu_supp = amsdu_support;
4966 else
4967 frm.addba_param_set.amsdu_supp = 0;
Jinwei Chen332b5cf2019-03-05 13:26:17 +08004968
Kiran Kumar Lokerebc87bec2018-02-27 20:06:42 -08004969 frm.addba_param_set.policy = SIR_MAC_BA_POLICY_IMMEDIATE;
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004970 frm.ba_timeout.timeout = batimeout;
Kiran Kumar Lokere40875852018-01-15 12:36:19 -08004971 if (addba_extn_present) {
4972 frm.addba_extn_element.present = 1;
4973 frm.addba_extn_element.no_fragmentation = 1;
4974 if (lim_is_session_he_capable(session)) {
4975 he_frag = lim_get_session_he_frag_cap(session);
4976 if (he_frag != 0) {
4977 frm.addba_extn_element.no_fragmentation = 0;
4978 frm.addba_extn_element.he_frag_operation =
4979 he_frag;
4980 }
4981 }
4982 }
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004983
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004984 pe_debug("Sending a ADDBA Response from %pM to %pM",
Pragaspathi Thilagaraj7fb14222019-06-17 23:26:58 +05304985 session->self_mac_addr, peer_mac);
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004986 pe_debug("tid: %d, dialog_token: %d, status: %d, buff_size: %d",
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004987 tid, frm.DialogToken.token, frm.Status.status,
4988 frm.addba_param_set.buff_size);
Kiran Kumar Lokere40875852018-01-15 12:36:19 -08004989 pe_debug("addba_extn %d he_capable %d no_frag %d he_frag %d",
4990 addba_extn_present,
4991 lim_is_session_he_capable(session),
4992 frm.addba_extn_element.no_fragmentation,
4993 frm.addba_extn_element.he_frag_operation);
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004994
4995 status = dot11f_get_packed_addba_rsp_size(mac_ctx, &frm, &payload_size);
4996 if (DOT11F_FAILED(status)) {
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004997 pe_err("Failed to calculate the packed size for a ADDBA Response (0x%08x).",
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004998 status);
4999 /* We'll fall back on the worst case scenario: */
5000 payload_size = sizeof(tDot11faddba_rsp);
5001 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07005002 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 -08005003 }
5004
5005 num_bytes = payload_size + sizeof(*mgmt_hdr);
5006 qdf_status = cds_packet_alloc(num_bytes, (void **)&frame_ptr,
5007 (void **)&pkt_ptr);
Sandeep Puligilla39cec082018-04-30 15:18:45 -07005008 if (!QDF_IS_STATUS_SUCCESS(qdf_status) || (!pkt_ptr)) {
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07005009 pe_err("Failed to allocate %d bytes for a ADDBA response action frame",
5010 num_bytes);
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08005011 return QDF_STATUS_E_FAILURE;
5012 }
hangtian127c9532019-01-12 13:29:07 +08005013 qdf_mem_zero(frame_ptr, num_bytes);
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08005014
5015 lim_populate_mac_header(mac_ctx, frame_ptr, SIR_MAC_MGMT_FRAME,
Pragaspathi Thilagaraj7fb14222019-06-17 23:26:58 +05305016 SIR_MAC_MGMT_ACTION, peer_mac, session->self_mac_addr);
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08005017
5018 /* Update A3 with the BSSID */
5019 mgmt_hdr = (tpSirMacMgmtHdr) frame_ptr;
5020 sir_copy_mac_addr(mgmt_hdr->bssId, session->bssId);
5021
5022 /* ADDBA Response is a robust mgmt action frame,
5023 * set the "protect" (aka WEP) bit in the FC
5024 */
5025 lim_set_protected_bit(mac_ctx, session, peer_mac, mgmt_hdr);
5026
5027 status = dot11f_pack_addba_rsp(mac_ctx, &frm,
5028 frame_ptr + sizeof(tSirMacMgmtHdr), payload_size,
5029 &payload_size);
5030
5031 if (DOT11F_FAILED(status)) {
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07005032 pe_err("Failed to pack a ADDBA Response (0x%08x)",
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08005033 status);
5034 qdf_status = QDF_STATUS_E_FAILURE;
5035 goto error_addba_rsp;
5036 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07005037 pe_warn("There were warnings while packing ADDBA Response (0x%08x)",
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08005038 status);
5039 }
5040
5041
Liangwei Dong419d7302019-07-15 15:38:28 +08005042 if (wlan_reg_is_5ghz_ch_freq(session->curr_op_freq) ||
5043 session->opmode == QDF_P2P_CLIENT_MODE ||
5044 session->opmode == QDF_P2P_GO_MODE)
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08005045 tx_flag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08005046
5047 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
5048 session->peSessionId, mgmt_hdr->fc.subType));
Krunal Sonid2136c72018-06-01 17:26:39 -07005049 qdf_status = wma_tx_frameWithTxComplete(mac_ctx, pkt_ptr,
5050 (uint16_t)num_bytes,
5051 TXRX_FRM_802_11_MGMT,
5052 ANI_TXDIR_TODS, 7,
5053 NULL, frame_ptr,
5054 lim_addba_rsp_tx_complete_cnf,
5055 tx_flag, sme_sessionid,
5056 false, 0, RATEID_DEFAULT);
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08005057 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
5058 session->peSessionId, qdf_status));
5059 if (QDF_STATUS_SUCCESS != qdf_status) {
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07005060 pe_err("wma_tx_frame FAILED! Status [%d]",
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08005061 qdf_status);
chenguo90c68462019-01-24 18:27:01 +08005062 return QDF_STATUS_E_FAILURE;
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08005063 } else {
Tushnim Bhattacharyyad58e4c92018-03-27 13:40:12 -07005064 return QDF_STATUS_SUCCESS;
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08005065 }
5066
5067error_addba_rsp:
5068 cds_packet_free((void *)pkt_ptr);
5069 return qdf_status;
5070}
Padma, Santhosh Kumar22c462c2018-01-16 17:56:44 +05305071
5072/**
5073 * lim_tx_mgmt_frame() - Transmits Auth mgmt frame
5074 * @mac_ctx Pointer to Global MAC structure
5075 * @mb_msg: Received message info
5076 * @msg_len: Received message length
5077 * @packet: Packet to be transmitted
5078 * @frame: Received frame
5079 *
5080 * Return: None
5081 */
Jeff Johnson9320c1e2018-12-02 13:09:20 -08005082static void lim_tx_mgmt_frame(struct mac_context *mac_ctx,
Padma, Santhosh Kumar22c462c2018-01-16 17:56:44 +05305083 struct sir_mgmt_msg *mb_msg, uint32_t msg_len,
5084 void *packet, uint8_t *frame)
5085{
5086 tpSirMacFrameCtl fc = (tpSirMacFrameCtl) mb_msg->data;
5087 QDF_STATUS qdf_status;
Abhishek Singhefe21e62019-09-20 10:03:24 +05305088 uint8_t vdev_id = 0;
Jeff Johnsona7815652018-11-18 22:58:30 -08005089 struct pe_session *session;
Padma, Santhosh Kumar22c462c2018-01-16 17:56:44 +05305090 uint16_t auth_ack_status;
5091 enum rateid min_rid = RATEID_DEFAULT;
5092
Abhishek Singhefe21e62019-09-20 10:03:24 +05305093 vdev_id = mb_msg->session_id;
5094 session = pe_find_session_by_vdev_id(mac_ctx, vdev_id);
Jeff Johnson8e9530b2019-03-18 13:41:42 -07005095 if (!session) {
Wu Gao7c0a23f2019-03-12 14:16:37 +08005096 cds_packet_free((void *)packet);
Abhishek Singhefe21e62019-09-20 10:03:24 +05305097 pe_err("session not found for given vdev_id %d",
5098 vdev_id);
Padma, Santhosh Kumar22c462c2018-01-16 17:56:44 +05305099 return;
5100 }
5101
Ashish Kumar Dhanotiya9f72df02018-07-23 19:20:04 +05305102 qdf_mtrace(QDF_MODULE_ID_PE, QDF_MODULE_ID_WMA, TRACE_CODE_TX_MGMT,
5103 session->peSessionId, 0);
Padma, Santhosh Kumar22c462c2018-01-16 17:56:44 +05305104
5105 mac_ctx->auth_ack_status = LIM_AUTH_ACK_NOT_RCD;
5106 min_rid = lim_get_min_session_txrate(session);
5107
5108 qdf_status = wma_tx_frameWithTxComplete(mac_ctx, packet,
5109 (uint16_t)msg_len,
5110 TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS,
5111 7, lim_tx_complete, frame,
5112 lim_auth_tx_complete_cnf,
Abhishek Singhefe21e62019-09-20 10:03:24 +05305113 0, vdev_id, false, 0, min_rid);
Padma, Santhosh Kumar22c462c2018-01-16 17:56:44 +05305114 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
5115 session->peSessionId, qdf_status));
5116 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Rachit Kankane0baf6e72018-01-19 15:01:50 +05305117 pe_err("*** Could not send Auth frame (subType: %d), retCode=%X ***",
5118 fc->subType, qdf_status);
Padma, Santhosh Kumar22c462c2018-01-16 17:56:44 +05305119 mac_ctx->auth_ack_status = LIM_AUTH_ACK_RCD_FAILURE;
5120 auth_ack_status = SENT_FAIL;
5121 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_AUTH_ACK_EVENT,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07005122 session, auth_ack_status, QDF_STATUS_E_FAILURE);
Padma, Santhosh Kumar22c462c2018-01-16 17:56:44 +05305123 /* Pkt will be freed up by the callback */
5124 }
5125}
5126
Jeff Johnson9320c1e2018-12-02 13:09:20 -08005127void lim_send_mgmt_frame_tx(struct mac_context *mac_ctx,
Padma, Santhosh Kumar22c462c2018-01-16 17:56:44 +05305128 struct scheduler_msg *msg)
5129{
5130 struct sir_mgmt_msg *mb_msg = (struct sir_mgmt_msg *)msg->bodyptr;
5131 uint32_t msg_len;
5132 tpSirMacFrameCtl fc = (tpSirMacFrameCtl) mb_msg->data;
5133 uint8_t sme_session_id;
5134 QDF_STATUS qdf_status;
5135 uint8_t *frame;
5136 void *packet;
Srinivas Dasari76218492019-01-22 15:08:20 +05305137 tpSirMacMgmtHdr mac_hdr;
Padma, Santhosh Kumar22c462c2018-01-16 17:56:44 +05305138
5139 msg_len = mb_msg->msg_len - sizeof(*mb_msg);
5140 pe_debug("sending fc->type: %d fc->subType: %d",
5141 fc->type, fc->subType);
5142
5143 sme_session_id = mb_msg->session_id;
Srinivas Dasari76218492019-01-22 15:08:20 +05305144 mac_hdr = (tpSirMacMgmtHdr)mb_msg->data;
5145
5146 lim_add_mgmt_seq_num(mac_ctx, mac_hdr);
Padma, Santhosh Kumar22c462c2018-01-16 17:56:44 +05305147
5148 qdf_status = cds_packet_alloc((uint16_t) msg_len, (void **)&frame,
5149 (void **)&packet);
5150 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
5151 pe_err("call to bufAlloc failed for AUTH frame");
5152 return;
5153 }
5154
5155 qdf_mem_copy(frame, mb_msg->data, msg_len);
5156
5157 lim_tx_mgmt_frame(mac_ctx, mb_msg, msg_len, packet, frame);
5158}