blob: f40980640aa216e900eb32b8ffe2e74c17ea1a2a [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"
36#include "lim_sta_hash_api.h"
37#include "sch_api.h"
38#include "lim_send_messages.h"
39#include "lim_assoc_utils.h"
40#include "lim_ft.h"
41#ifdef WLAN_FEATURE_11W
42#include "wni_cfg.h"
43#endif
44
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080045#include "lim_ft_defs.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080046#include "lim_session.h"
Anurag Chouhan6d760662016-02-20 16:05:43 +053047#include "qdf_types.h"
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053048#include "qdf_trace.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080049#include "cds_utils.h"
50#include "sme_trace.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080051#include "rrm_api.h"
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +053052#include "qdf_crypto.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080053
54#include "wma_types.h"
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -080055#include <cdp_txrx_cmn.h>
Tushnim Bhattacharyya45ed04f2017-03-15 10:15:05 -070056#include <cdp_txrx_peer_ops.h>
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +053057#include "lim_process_fils.h"
Naveen Rawat08db88f2017-09-08 15:07:48 -070058#include "wlan_utility.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080059
60/**
61 *
62 * \brief This function is called to add the sequence number to the
63 * management frames
64 *
Jeff Johnson99f25042018-11-21 22:49:06 -080065 * \param mac Pointer to Global MAC structure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080066 *
67 * \param pMacHdr Pointer to MAC management header
68 *
69 * The pMacHdr argument points to the MAC management header. The
Jeff Johnson99f25042018-11-21 22:49:06 -080070 * sequence number stored in the mac structure will be incremented
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080071 * and updated to the MAC management header. The start sequence
72 * number is WLAN_HOST_SEQ_NUM_MIN and the end value is
73 * WLAN_HOST_SEQ_NUM_MAX. After reaching the MAX value, the sequence
74 * number will roll over.
75 *
76 */
Jeff Johnson9320c1e2018-12-02 13:09:20 -080077static void lim_add_mgmt_seq_num(struct mac_context *mac, tpSirMacMgmtHdr pMacHdr)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080078{
Jeff Johnson99f25042018-11-21 22:49:06 -080079 if (mac->mgmtSeqNum >= WLAN_HOST_SEQ_NUM_MAX) {
80 mac->mgmtSeqNum = WLAN_HOST_SEQ_NUM_MIN - 1;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080081 }
82
Jeff Johnson99f25042018-11-21 22:49:06 -080083 mac->mgmtSeqNum++;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080084
Jeff Johnson99f25042018-11-21 22:49:06 -080085 pMacHdr->seqControl.seqNumLo = (mac->mgmtSeqNum & LOW_SEQ_NUM_MASK);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080086 pMacHdr->seqControl.seqNumHi =
Jeff Johnson99f25042018-11-21 22:49:06 -080087 ((mac->mgmtSeqNum & HIGH_SEQ_NUM_MASK) >> HIGH_SEQ_NUM_OFFSET);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080088}
89
90/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080091 * lim_populate_mac_header() - Fill in 802.11 header of frame
92 *
93 * @mac_ctx: Pointer to Global MAC structure
94 * @buf: Pointer to the frame buffer that needs to be populate
95 * @type: 802.11 Type of the frame
96 * @sub_type: 802.11 Subtype of the frame
97 * @peer_addr: dst address
98 * @self_mac_addr: local mac address
99 *
100 * This function is called by various LIM modules to prepare the
101 * 802.11 frame MAC header
102 *
103 * The buf argument points to the beginning of the frame buffer to
104 * which - a) The 802.11 MAC header is set b) Following this MAC header
105 * will be the MGMT frame payload The payload itself is populated by the
106 * caller API
107 *
108 * Return: None
109 */
110
Jeff Johnson9320c1e2018-12-02 13:09:20 -0800111void lim_populate_mac_header(struct mac_context *mac_ctx, uint8_t *buf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800112 uint8_t type, uint8_t sub_type, tSirMacAddr peer_addr,
113 tSirMacAddr self_mac_addr)
114{
115 tpSirMacMgmtHdr mac_hdr;
116
117 /* Prepare MAC management header */
118 mac_hdr = (tpSirMacMgmtHdr) (buf);
119
120 /* Prepare FC */
121 mac_hdr->fc.protVer = SIR_MAC_PROTOCOL_VERSION;
122 mac_hdr->fc.type = type;
123 mac_hdr->fc.subType = sub_type;
124
125 /* Prepare Address 1 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530126 qdf_mem_copy((uint8_t *) mac_hdr->da,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800127 (uint8_t *) peer_addr, sizeof(tSirMacAddr));
128
129 /* Prepare Address 2 */
130 sir_copy_mac_addr(mac_hdr->sa, self_mac_addr);
131
132 /* Prepare Address 3 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530133 qdf_mem_copy((uint8_t *) mac_hdr->bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800134 (uint8_t *) peer_addr, sizeof(tSirMacAddr));
135
136 /* Prepare sequence number */
137 lim_add_mgmt_seq_num(mac_ctx, mac_hdr);
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700138 pe_debug("seqNumLo=%d, seqNumHi=%d, mgmtSeqNum=%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800139 mac_hdr->seqControl.seqNumLo,
140 mac_hdr->seqControl.seqNumHi, mac_ctx->mgmtSeqNum);
141}
142
143/**
144 * lim_send_probe_req_mgmt_frame() - send probe request management frame
145 * @mac_ctx: Pointer to Global MAC structure
146 * @ssid: SSID to be sent in Probe Request frame
147 * @bssid: BSSID to be sent in Probe Request frame
148 * @channel: Channel # on which the Probe Request is going out
149 * @self_macaddr: self MAC address
150 * @dot11mode: self dotllmode
151 * @additional_ielen: if non-zero, include additional_ie in the Probe Request
152 * frame
153 * @additional_ie: if additional_ielen is non zero, include this field in the
154 * Probe Request frame
155 *
156 * This function is called by various LIM modules to send Probe Request frame
157 * during active scan/learn phase.
158 * Probe request is sent out in the following scenarios:
159 * --heartbeat failure: session needed
160 * --join req: session needed
161 * --foreground scan: no session
162 * --background scan: no session
163 * --sch_beacon_processing: to get EDCA parameters: session needed
164 *
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700165 * Return: QDF_STATUS (QDF_STATUS_SUCCESS on success and error codes otherwise)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800166 */
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700167QDF_STATUS
Jeff Johnson9320c1e2018-12-02 13:09:20 -0800168lim_send_probe_req_mgmt_frame(struct mac_context *mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800169 tSirMacSSid *ssid,
170 tSirMacAddr bssid,
171 uint8_t channel,
172 tSirMacAddr self_macaddr,
173 uint32_t dot11mode,
Jeff Johnson919f2c32019-01-16 11:22:24 -0800174 uint16_t *additional_ielen,
175 uint8_t *additional_ie)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800176{
177 tDot11fProbeRequest pr;
178 uint32_t status, bytes, payload;
179 uint8_t *frame;
180 void *packet;
Kapil Guptac03eb072016-08-09 14:01:36 +0530181 QDF_STATUS qdf_status;
Jeff Johnsona7815652018-11-18 22:58:30 -0800182 struct pe_session *pesession;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800183 uint8_t sessionid;
Naveen Rawat08db88f2017-09-08 15:07:48 -0700184 const uint8_t *p2pie = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800185 uint8_t txflag = 0;
186 uint8_t sme_sessionid = 0;
187 bool is_vht_enabled = false;
188 uint8_t txPower;
Arif Hussain4c265132018-04-23 18:55:26 -0700189 uint16_t addn_ielen = 0;
Kapil Guptac03eb072016-08-09 14:01:36 +0530190 bool extracted_ext_cap_flag = false;
191 tDot11fIEExtCap extracted_ext_cap;
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700192 QDF_STATUS sir_status;
Abhishek Singh67e02bd2017-12-11 10:47:12 +0530193 const uint8_t *qcn_ie = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800194
Arif Hussain4c265132018-04-23 18:55:26 -0700195 if (additional_ielen)
196 addn_ielen = *additional_ielen;
197
Jeff Johnson919f2c32019-01-16 11:22:24 -0800198 /*
199 * The probe req should not send 11ac capabilities if band is
200 * 2.4GHz, unless gEnableVhtFor24GHzBand is enabled in INI. So
201 * if gEnableVhtFor24GHzBand is false and dot11mode is 11ac
202 * set it to 11n.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800203 */
204 if (channel <= SIR_11B_CHANNEL_END &&
Abhinav Kumare057b412018-10-09 17:28:16 +0530205 !mac_ctx->mlme_cfg->vht_caps.vht_cap_info.b24ghz_band &&
gaurank kathpalia0c48d3d2019-01-29 15:03:07 +0530206 (MLME_DOT11_MODE_11AC == dot11mode ||
207 MLME_DOT11_MODE_11AC_ONLY == dot11mode))
208 dot11mode = MLME_DOT11_MODE_11N;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800209 /*
210 * session context may or may not be present, when probe request needs
211 * to be sent out. Following cases exist:
212 * --heartbeat failure: session needed
213 * --join req: session needed
214 * --foreground scan: no session
215 * --background scan: no session
216 * --sch_beacon_processing: to get EDCA parameters: session needed
217 * If session context does not exist, some IEs will be populated from
218 * CFGs, e.g. Supported and Extended rate set IEs
219 */
220 pesession = pe_find_session_by_bssid(mac_ctx, bssid, &sessionid);
221
Jeff Johnson8e9530b2019-03-18 13:41:42 -0700222 if (pesession)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800223 sme_sessionid = pesession->smeSessionId;
224
225 /* The scheme here is to fill out a 'tDot11fProbeRequest' structure */
226 /* and then hand it off to 'dot11f_pack_probe_request' (for */
227 /* serialization). We start by zero-initializing the structure: */
hangtian127c9532019-01-12 13:29:07 +0800228 qdf_mem_zero((uint8_t *) &pr, sizeof(pr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800229
230 /* & delegating to assorted helpers: */
231 populate_dot11f_ssid(mac_ctx, ssid, &pr.SSID);
232
233 if (addn_ielen && additional_ie)
234 p2pie = limGetP2pIEPtr(mac_ctx, additional_ie, addn_ielen);
235
236 /*
237 * Don't include 11b rate if it is a P2P serach or probe request is
238 * sent by P2P Client
239 */
Jeff Johnson8e9530b2019-03-18 13:41:42 -0700240 if ((MLME_DOT11_MODE_11B != dot11mode) && (p2pie) &&
Pragaspathi Thilagaraje64714a2019-05-23 00:46:25 +0530241 ((pesession) && (QDF_P2P_CLIENT_MODE == pesession->opmode))) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800242 /*
243 * In the below API pass channel number > 14, do that it fills
244 * only 11a rates in supported rates
245 */
246 populate_dot11f_supp_rates(mac_ctx, 15, &pr.SuppRates,
247 pesession);
248 } else {
249 populate_dot11f_supp_rates(mac_ctx, channel,
250 &pr.SuppRates, pesession);
251
gaurank kathpalia0c48d3d2019-01-29 15:03:07 +0530252 if (MLME_DOT11_MODE_11B != dot11mode) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800253 populate_dot11f_ext_supp_rates1(mac_ctx, channel,
254 &pr.ExtSuppRates);
255 }
256 }
257
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800258 /*
259 * Table 7-14 in IEEE Std. 802.11k-2008 says
260 * DS params "can" be present in RRM is disabled and "is" present if
261 * RRM is enabled. It should be ok even if we add it into probe req when
262 * RRM is not enabled.
263 */
264 populate_dot11f_ds_params(mac_ctx, &pr.DSParams, channel);
265 /* Call RRM module to get the tx power for management used. */
266 txPower = (uint8_t) rrm_get_mgmt_tx_power(mac_ctx, pesession);
267 populate_dot11f_wfatpc(mac_ctx, &pr.WFATPC, txPower, 0);
268
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800269
Jeff Johnson8e9530b2019-03-18 13:41:42 -0700270 if (pesession) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800271 pesession->htCapability = IS_DOT11_MODE_HT(dot11mode);
272 /* Include HT Capability IE */
273 if (pesession->htCapability)
274 populate_dot11f_ht_caps(mac_ctx, pesession, &pr.HTCaps);
Jeff Johnson8e9530b2019-03-18 13:41:42 -0700275 } else { /* !pesession */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800276 if (IS_DOT11_MODE_HT(dot11mode))
277 populate_dot11f_ht_caps(mac_ctx, NULL, &pr.HTCaps);
278 }
279
280 /*
281 * Set channelbonding information as "disabled" when tunned to a
282 * 2.4 GHz channel
283 */
284 if (channel <= SIR_11B_CHANNEL_END) {
285 if (mac_ctx->roam.configParam.channelBondingMode24GHz
286 == PHY_SINGLE_CHANNEL_CENTERED) {
287 pr.HTCaps.supportedChannelWidthSet =
288 eHT_CHANNEL_WIDTH_20MHZ;
289 pr.HTCaps.shortGI40MHz = 0;
290 } else {
291 pr.HTCaps.supportedChannelWidthSet =
292 eHT_CHANNEL_WIDTH_40MHZ;
293 }
294 }
Jeff Johnson8e9530b2019-03-18 13:41:42 -0700295 if (pesession) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800296 pesession->vhtCapability = IS_DOT11_MODE_VHT(dot11mode);
297 /* Include VHT Capability IE */
298 if (pesession->vhtCapability) {
299 populate_dot11f_vht_caps(mac_ctx, pesession,
300 &pr.VHTCaps);
301 is_vht_enabled = true;
302 }
303 } else {
304 if (IS_DOT11_MODE_VHT(dot11mode)) {
305 populate_dot11f_vht_caps(mac_ctx, pesession,
306 &pr.VHTCaps);
307 is_vht_enabled = true;
308 }
309 }
Jeff Johnson8e9530b2019-03-18 13:41:42 -0700310 if (pesession)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800311 populate_dot11f_ext_cap(mac_ctx, is_vht_enabled, &pr.ExtCap,
312 pesession);
313
Jeff Johnson8e9530b2019-03-18 13:41:42 -0700314 if (IS_DOT11_MODE_HE(dot11mode) && pesession)
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -0800315 lim_update_session_he_capable(mac_ctx, pesession);
316
Srinivas Girigowda28fb0122017-03-26 22:21:20 -0700317 pe_debug("Populate HE IEs");
Naveen Rawatd8feac12017-09-08 15:08:39 -0700318 populate_dot11f_he_caps(mac_ctx, pesession, &pr.he_cap);
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -0800319
Sandeep Puligilla493fea22018-04-30 15:31:17 -0700320 if (addn_ielen && additional_ie) {
Kapil Guptac03eb072016-08-09 14:01:36 +0530321 qdf_mem_zero((uint8_t *)&extracted_ext_cap,
322 sizeof(tDot11fIEExtCap));
323 sir_status = lim_strip_extcap_update_struct(mac_ctx,
324 additional_ie,
325 &addn_ielen,
326 &extracted_ext_cap);
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700327 if (QDF_STATUS_SUCCESS != sir_status) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700328 pe_debug("Unable to Stripoff ExtCap IE from Probe Req");
Kapil Guptac03eb072016-08-09 14:01:36 +0530329 } else {
330 struct s_ext_cap *p_ext_cap =
331 (struct s_ext_cap *)
332 extracted_ext_cap.bytes;
333 if (p_ext_cap->interworking_service)
334 p_ext_cap->qos_map = 1;
Hu Wang411e0cc2016-10-28 14:56:01 +0800335 extracted_ext_cap.num_bytes =
336 lim_compute_ext_cap_ie_length
337 (&extracted_ext_cap);
Kapil Guptac03eb072016-08-09 14:01:36 +0530338 extracted_ext_cap_flag =
Hu Wang411e0cc2016-10-28 14:56:01 +0800339 (extracted_ext_cap.num_bytes > 0);
Arif Hussain4c265132018-04-23 18:55:26 -0700340 if (additional_ielen)
341 *additional_ielen = addn_ielen;
Kapil Guptac03eb072016-08-09 14:01:36 +0530342 }
Abhishek Singh67e02bd2017-12-11 10:47:12 +0530343 qcn_ie = wlan_get_vendor_ie_ptr_from_oui(SIR_MAC_QCN_OUI_TYPE,
344 SIR_MAC_QCN_OUI_TYPE_SIZE,
345 additional_ie, addn_ielen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800346 }
Abhishek Singh67e02bd2017-12-11 10:47:12 +0530347 /* Add qcn_ie only if qcn ie is not present in additional_ie */
Wu Gao93816212018-08-31 16:49:54 +0800348 if (mac_ctx->mlme_cfg->sta.qcn_ie_support && !qcn_ie)
Abhishek Singh67e02bd2017-12-11 10:47:12 +0530349 populate_dot11f_qcn_ie(&pr.QCN_IE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800350
Hu Wang411e0cc2016-10-28 14:56:01 +0800351 /*
352 * Extcap IE now support variable length, merge Extcap IE from addn_ie
353 * may change the frame size. Therefore, MUST merge ExtCap IE before
354 * dot11f get packed payload size.
355 */
356 if (extracted_ext_cap_flag)
Hu Wangfbd279d2016-10-31 18:24:34 +0800357 lim_merge_extcap_struct(&pr.ExtCap, &extracted_ext_cap, true);
Hu Wang411e0cc2016-10-28 14:56:01 +0800358
359 /* That's it-- now we pack it. First, how much space are we going to */
360 status = dot11f_get_packed_probe_request_size(mac_ctx, &pr, &payload);
361 if (DOT11F_FAILED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700362 pe_err("Failed to calculate the packed size for a Probe Request (0x%08x)",
Hu Wang411e0cc2016-10-28 14:56:01 +0800363 status);
364 /* We'll fall back on the worst case scenario: */
365 payload = sizeof(tDot11fProbeRequest);
366 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700367 pe_warn("There were warnings while calculating the packed size for a Probe Request (0x%08x)",
Hu Wang411e0cc2016-10-28 14:56:01 +0800368 status);
369 }
370
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800371 bytes = payload + sizeof(tSirMacMgmtHdr) + addn_ielen;
372
373 /* Ok-- try to allocate some memory: */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530374 qdf_status = cds_packet_alloc((uint16_t) bytes, (void **)&frame,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800375 (void **)&packet);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530376 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700377 pe_err("Failed to allocate %d bytes for a Probe Request", bytes);
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700378 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800379 }
380 /* Paranoia: */
hangtian127c9532019-01-12 13:29:07 +0800381 qdf_mem_zero(frame, bytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800382
383 /* Next, we fill out the buffer descriptor: */
384 lim_populate_mac_header(mac_ctx, frame, SIR_MAC_MGMT_FRAME,
385 SIR_MAC_MGMT_PROBE_REQ, bssid, self_macaddr);
386
387 /* That done, pack the Probe Request: */
388 status = dot11f_pack_probe_request(mac_ctx, &pr, frame +
389 sizeof(tSirMacMgmtHdr),
390 payload, &payload);
391 if (DOT11F_FAILED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700392 pe_err("Failed to pack a Probe Request (0x%08x)", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800393 cds_packet_free((void *)packet);
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700394 return QDF_STATUS_E_FAILURE; /* allocated! */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800395 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700396 pe_warn("There were warnings while packing a Probe Request (0x%08x)", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800397 }
398 /* Append any AddIE if present. */
399 if (addn_ielen) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530400 qdf_mem_copy(frame + sizeof(tSirMacMgmtHdr) + payload,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800401 additional_ie, addn_ielen);
402 payload += addn_ielen;
403 }
404
405 /* If this probe request is sent during P2P Search State, then we need
406 * to send it at OFDM rate.
407 */
Abhishek Singh221cf992018-02-22 13:44:53 +0530408 if ((BAND_5G == lim_get_rf_band(channel)) ||
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800409 /*
410 * For unicast probe req mgmt from Join function we don't set
411 * above variables. So we need to add one more check whether it
Pragaspathi Thilagaraje64714a2019-05-23 00:46:25 +0530412 * is opmode is P2P_CLIENT or not
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800413 */
Pragaspathi Thilagaraje64714a2019-05-23 00:46:25 +0530414 ((pesession) && (QDF_P2P_CLIENT_MODE == pesession->opmode)))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800415 txflag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800416
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530417 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800418 wma_tx_frame(mac_ctx, packet,
419 (uint16_t) sizeof(tSirMacMgmtHdr) + payload,
420 TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS, 7,
421 lim_tx_complete, frame, txflag, sme_sessionid,
Naveen Rawat296a5182017-09-25 14:02:48 -0700422 0, RATEID_DEFAULT);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530423 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700424 pe_err("could not send Probe Request frame!");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800425 /* Pkt will be freed up by the callback */
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700426 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800427 }
428
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700429 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800430} /* End lim_send_probe_req_mgmt_frame. */
431
Jeff Johnson9320c1e2018-12-02 13:09:20 -0800432static QDF_STATUS lim_get_addn_ie_for_probe_resp(struct mac_context *mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800433 uint8_t *addIE, uint16_t *addnIELen,
434 uint8_t probeReqP2pIe)
435{
436 /* If Probe request doesn't have P2P IE, then take out P2P IE
437 from additional IE */
438 if (!probeReqP2pIe) {
439 uint8_t *tempbuf = NULL;
440 uint16_t tempLen = 0;
441 int left = *addnIELen;
442 uint8_t *ptr = addIE;
443 uint8_t elem_id, elem_len;
444
Jeff Johnson8e9530b2019-03-18 13:41:42 -0700445 if (!addIE) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700446 pe_err("NULL addIE pointer");
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700447 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800448 }
449
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530450 tempbuf = qdf_mem_malloc(left);
Arif Hussainf5b6c412018-10-10 19:41:09 -0700451 if (!tempbuf)
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700452 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800453
454 while (left >= 2) {
455 elem_id = ptr[0];
456 elem_len = ptr[1];
457 left -= 2;
458 if (elem_len > left) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700459 pe_err("Invalid IEs eid: %d elem_len: %d left: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800460 elem_id, elem_len, left);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530461 qdf_mem_free(tempbuf);
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700462 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800463 }
Srinivas Girigowda61771262019-04-01 11:55:19 -0700464 if (!((WLAN_ELEMID_VENDOR == elem_id) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800465 (memcmp
466 (&ptr[2], SIR_MAC_P2P_OUI,
467 SIR_MAC_P2P_OUI_SIZE) == 0))) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530468 qdf_mem_copy(tempbuf + tempLen, &ptr[0],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800469 elem_len + 2);
470 tempLen += (elem_len + 2);
471 }
472 left -= elem_len;
473 ptr += (elem_len + 2);
474 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530475 qdf_mem_copy(addIE, tempbuf, tempLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800476 *addnIELen = tempLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530477 qdf_mem_free(tempbuf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800478 }
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700479 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800480}
481
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800482void
Jeff Johnson9320c1e2018-12-02 13:09:20 -0800483lim_send_probe_rsp_mgmt_frame(struct mac_context *mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800484 tSirMacAddr peer_macaddr,
485 tpAniSSID ssid,
Jeff Johnson3c08ace2019-03-12 08:50:37 -0700486 struct pe_session *pe_session,
487 uint8_t preq_p2pie)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800488{
489 tDot11fProbeResponse *frm;
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700490 QDF_STATUS sir_status;
Hu Wang411e0cc2016-10-28 14:56:01 +0800491 uint32_t cfg, payload, bytes = 0, status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800492 tpSirMacMgmtHdr mac_hdr;
493 uint8_t *frame;
Arif Hussainfbf50682016-06-15 12:57:43 -0700494 void *packet = NULL;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530495 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800496 uint32_t addn_ie_present = false;
497
498 uint16_t addn_ie_len = 0;
gaurank kathpalia837f6202018-09-14 21:55:32 +0530499 bool wps_ap = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800500 uint8_t tx_flag = 0;
501 uint8_t *add_ie = NULL;
Naveen Rawat08db88f2017-09-08 15:07:48 -0700502 const uint8_t *p2p_ie = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800503 uint8_t noalen = 0;
504 uint8_t total_noalen = 0;
505 uint8_t noa_stream[SIR_MAX_NOA_ATTR_LEN + SIR_P2P_IE_HEADER_LEN];
506 uint8_t noa_ie[SIR_MAX_NOA_ATTR_LEN + SIR_P2P_IE_HEADER_LEN];
507 uint8_t sme_sessionid = 0;
508 bool is_vht_enabled = false;
Padma, Santhosh Kumar92234472017-04-19 18:20:02 +0530509 tDot11fIEExtCap extracted_ext_cap = {0};
Selvaraj, Sridhar94ece202016-06-23 20:44:09 +0530510 bool extracted_ext_cap_flag = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800511
512 /* We don't answer requests in this case*/
Srinivas Girigowda35b00312017-06-27 21:52:03 -0700513 if (ANI_DRIVER_TYPE(mac_ctx) == QDF_DRIVER_TYPE_MFG)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800514 return;
515
Jeff Johnson8e9530b2019-03-18 13:41:42 -0700516 if (!pe_session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800517 return;
518
519 /*
520 * In case when cac timer is running for this SAP session then
521 * avoid sending probe rsp out. It is violation of dfs specification.
522 */
Pragaspathi Thilagaraje64714a2019-05-23 00:46:25 +0530523 if (((pe_session->opmode == QDF_SAP_MODE) ||
524 (pe_session->opmode == QDF_P2P_GO_MODE)) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800525 (true == mac_ctx->sap.SapDfsInfo.is_dfs_cac_timer_running)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530526 QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_INFO,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800527 FL("CAC timer is running, probe response dropped"));
528 return;
529 }
530 sme_sessionid = pe_session->smeSessionId;
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530531 frm = qdf_mem_malloc(sizeof(tDot11fProbeResponse));
Arif Hussainf5b6c412018-10-10 19:41:09 -0700532 if (!frm)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800533 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800534
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800535 /*
536 * Fill out 'frm', after which we'll just hand the struct off to
537 * 'dot11f_pack_probe_response'.
538 */
hangtian127c9532019-01-12 13:29:07 +0800539 qdf_mem_zero((uint8_t *) frm, sizeof(tDot11fProbeResponse));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800540
541 /*
542 * Timestamp to be updated by TFP, below.
543 *
544 * Beacon Interval:
545 */
546 if (LIM_IS_AP_ROLE(pe_session)) {
547 frm->BeaconInterval.interval =
Jeff Johnsonac057412019-01-06 11:08:55 -0800548 mac_ctx->sch.beacon_interval;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800549 } else {
Bala Venkatesh2fde2c62018-09-11 20:33:24 +0530550 cfg = mac_ctx->mlme_cfg->sap_cfg.beacon_interval;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800551 frm->BeaconInterval.interval = (uint16_t) cfg;
552 }
553
554 populate_dot11f_capabilities(mac_ctx, &frm->Capabilities, pe_session);
555 populate_dot11f_ssid(mac_ctx, (tSirMacSSid *) ssid, &frm->SSID);
556 populate_dot11f_supp_rates(mac_ctx, POPULATE_DOT11F_RATES_OPERATIONAL,
557 &frm->SuppRates, pe_session);
558
559 populate_dot11f_ds_params(mac_ctx, &frm->DSParams,
560 pe_session->currentOperChannel);
561 populate_dot11f_ibss_params(mac_ctx, &frm->IBSSParams, pe_session);
562
563 if (LIM_IS_AP_ROLE(pe_session)) {
564 if (pe_session->wps_state != SAP_WPS_DISABLED)
565 populate_dot11f_probe_res_wpsi_es(mac_ctx,
566 &frm->WscProbeRes,
567 pe_session);
568 } else {
gaurank kathpalia837f6202018-09-14 21:55:32 +0530569 wps_ap = mac_ctx->mlme_cfg->wps_params.enable_wps &
570 WNI_CFG_WPS_ENABLE_AP;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800571 if (wps_ap)
572 populate_dot11f_wsc_in_probe_res(mac_ctx,
573 &frm->WscProbeRes);
574
575 if (mac_ctx->lim.wscIeInfo.probeRespWscEnrollmentState ==
576 eLIM_WSC_ENROLL_BEGIN) {
577 populate_dot11f_wsc_registrar_info_in_probe_res(mac_ctx,
578 &frm->WscProbeRes);
579 mac_ctx->lim.wscIeInfo.probeRespWscEnrollmentState =
580 eLIM_WSC_ENROLL_IN_PROGRESS;
581 }
582
583 if (mac_ctx->lim.wscIeInfo.wscEnrollmentState ==
584 eLIM_WSC_ENROLL_END) {
585 de_populate_dot11f_wsc_registrar_info_in_probe_res(
586 mac_ctx, &frm->WscProbeRes);
587 mac_ctx->lim.wscIeInfo.probeRespWscEnrollmentState =
588 eLIM_WSC_ENROLL_NOOP;
589 }
590 }
591
592 populate_dot11f_country(mac_ctx, &frm->Country, pe_session);
593 populate_dot11f_edca_param_set(mac_ctx, &frm->EDCAParamSet, pe_session);
594
gaurank kathpalia0c48d3d2019-01-29 15:03:07 +0530595 if (pe_session->dot11mode != MLME_DOT11_MODE_11B)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800596 populate_dot11f_erp_info(mac_ctx, &frm->ERPInfo, pe_session);
597
598 populate_dot11f_ext_supp_rates(mac_ctx,
599 POPULATE_DOT11F_RATES_OPERATIONAL,
600 &frm->ExtSuppRates, pe_session);
601
602 /* Populate HT IEs, when operating in 11n */
603 if (pe_session->htCapability) {
604 populate_dot11f_ht_caps(mac_ctx, pe_session, &frm->HTCaps);
605 populate_dot11f_ht_info(mac_ctx, &frm->HTInfo, pe_session);
606 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800607 if (pe_session->vhtCapability) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700608 pe_debug("Populate VHT IE in Probe Response");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800609 populate_dot11f_vht_caps(mac_ctx, pe_session, &frm->VHTCaps);
610 populate_dot11f_vht_operation(mac_ctx, pe_session,
611 &frm->VHTOperation);
612 /*
613 * we do not support multi users yet.
614 * populate_dot11f_vht_ext_bss_load( mac_ctx,
615 * &frm.VHTExtBssLoad );
616 */
617 is_vht_enabled = true;
618 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800619
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -0800620 if (lim_is_session_he_capable(pe_session)) {
Srinivas Girigowda28fb0122017-03-26 22:21:20 -0700621 pe_debug("Populate HE IEs");
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -0800622 populate_dot11f_he_caps(mac_ctx, pe_session,
Naveen Rawatd8feac12017-09-08 15:08:39 -0700623 &frm->he_cap);
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -0800624 populate_dot11f_he_operation(mac_ctx, pe_session,
Naveen Rawatd8feac12017-09-08 15:08:39 -0700625 &frm->he_op);
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -0800626 }
627
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800628 populate_dot11f_ext_cap(mac_ctx, is_vht_enabled, &frm->ExtCap,
629 pe_session);
630
631 if (pe_session->pLimStartBssReq) {
632 populate_dot11f_wpa(mac_ctx,
633 &(pe_session->pLimStartBssReq->rsnIE),
634 &frm->WPA);
635 populate_dot11f_rsn_opaque(mac_ctx,
636 &(pe_session->pLimStartBssReq->rsnIE),
637 &frm->RSNOpaque);
638 }
639
640 populate_dot11f_wmm(mac_ctx, &frm->WMMInfoAp, &frm->WMMParams,
641 &frm->WMMCaps, pe_session);
642
643#if defined(FEATURE_WLAN_WAPI)
644 if (pe_session->pLimStartBssReq)
645 populate_dot11f_wapi(mac_ctx,
646 &(pe_session->pLimStartBssReq->rsnIE),
647 &frm->WAPI);
648#endif /* defined(FEATURE_WLAN_WAPI) */
649
Liangwei Dongd7c5e012018-12-16 23:56:50 -0500650 /*
651 * Only use CFG for non-listen mode. This CFG is not working for
652 * concurrency. In listening mode, probe rsp IEs is passed in
653 * the message from SME to PE.
654 */
655 addn_ie_present =
Jeff Johnson21aac3a2019-02-02 14:26:13 -0800656 (pe_session->add_ie_params.probeRespDataLen != 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800657
658 if (addn_ie_present) {
659
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530660 add_ie = qdf_mem_malloc(
Jeff Johnson21aac3a2019-02-02 14:26:13 -0800661 pe_session->add_ie_params.probeRespDataLen);
Arif Hussainf5b6c412018-10-10 19:41:09 -0700662 if (!add_ie)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800663 goto err_ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800664
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530665 qdf_mem_copy(add_ie,
Jeff Johnson21aac3a2019-02-02 14:26:13 -0800666 pe_session->add_ie_params.probeRespData_buff,
667 pe_session->add_ie_params.probeRespDataLen);
668 addn_ie_len = pe_session->add_ie_params.probeRespDataLen;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800669
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700670 if (QDF_STATUS_SUCCESS != lim_get_addn_ie_for_probe_resp(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800671 add_ie, &addn_ie_len, preq_p2pie)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700672 pe_err("Unable to get addn_ie");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800673 goto err_ret;
674 }
675
676 sir_status = lim_strip_extcap_update_struct(mac_ctx,
677 add_ie, &addn_ie_len,
678 &extracted_ext_cap);
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700679 if (QDF_STATUS_SUCCESS != sir_status) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700680 pe_debug("Unable to strip off ExtCap IE");
Selvaraj, Sridhar94ece202016-06-23 20:44:09 +0530681 } else {
682 extracted_ext_cap_flag = true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800683 }
684
685 bytes = bytes + addn_ie_len;
686
687 if (preq_p2pie)
688 p2p_ie = limGetP2pIEPtr(mac_ctx, &add_ie[0],
689 addn_ie_len);
690
Jeff Johnson8e9530b2019-03-18 13:41:42 -0700691 if (p2p_ie) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800692 /* get NoA attribute stream P2P IE */
693 noalen = lim_get_noa_attr_stream(mac_ctx,
694 noa_stream, pe_session);
695 if (noalen != 0) {
696 total_noalen =
697 lim_build_p2p_ie(mac_ctx, &noa_ie[0],
698 &noa_stream[0], noalen);
699 bytes = bytes + total_noalen;
700 }
701 }
702 }
703
Hu Wang411e0cc2016-10-28 14:56:01 +0800704 /*
705 * Extcap IE now support variable length, merge Extcap IE from addn_ie
706 * may change the frame size. Therefore, MUST merge ExtCap IE before
707 * dot11f get packed payload size.
708 */
709 if (extracted_ext_cap_flag)
Hu Wangfbd279d2016-10-31 18:24:34 +0800710 lim_merge_extcap_struct(&frm->ExtCap, &extracted_ext_cap,
711 true);
Hu Wang411e0cc2016-10-28 14:56:01 +0800712
713 status = dot11f_get_packed_probe_response_size(mac_ctx, frm, &payload);
714 if (DOT11F_FAILED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700715 pe_err("Probe Response size error (0x%08x)",
Hu Wang411e0cc2016-10-28 14:56:01 +0800716 status);
717 /* We'll fall back on the worst case scenario: */
718 payload = sizeof(tDot11fProbeResponse);
719 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700720 pe_warn("Probe Response size warning (0x%08x)",
Hu Wang411e0cc2016-10-28 14:56:01 +0800721 status);
722 }
723
724 bytes += payload + sizeof(tSirMacMgmtHdr);
725
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530726 qdf_status = cds_packet_alloc((uint16_t) bytes, (void **)&frame,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800727 (void **)&packet);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530728 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700729 pe_err("Probe Response allocation failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800730 goto err_ret;
731 }
732 /* Paranoia: */
hangtian127c9532019-01-12 13:29:07 +0800733 qdf_mem_zero(frame, bytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800734
735 /* Next, we fill out the buffer descriptor: */
736 lim_populate_mac_header(mac_ctx, frame, SIR_MAC_MGMT_FRAME,
737 SIR_MAC_MGMT_PROBE_RSP, peer_macaddr,
Pragaspathi Thilagaraj7fb14222019-06-17 23:26:58 +0530738 pe_session->self_mac_addr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800739
740 mac_hdr = (tpSirMacMgmtHdr) frame;
741
742 sir_copy_mac_addr(mac_hdr->bssId, pe_session->bssId);
743
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800744 /* That done, pack the Probe Response: */
745 status =
746 dot11f_pack_probe_response(mac_ctx, frm,
747 frame + sizeof(tSirMacMgmtHdr),
748 payload, &payload);
749 if (DOT11F_FAILED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700750 pe_err("Probe Response pack failure (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800751 status);
752 goto err_ret;
753 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700754 pe_warn("Probe Response pack warning (0x%08x)", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800755 }
756
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700757 pe_debug("Sending Probe Response frame to");
Nishank Aggarwal46bd31a2017-03-10 16:23:53 +0530758 lim_print_mac_addr(mac_ctx, peer_macaddr, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800759
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800760 if (addn_ie_present)
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530761 qdf_mem_copy(frame + sizeof(tSirMacMgmtHdr) + payload,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800762 &add_ie[0], addn_ie_len);
763
764 if (noalen != 0) {
765 if (total_noalen >
766 (SIR_MAX_NOA_ATTR_LEN + SIR_P2P_IE_HEADER_LEN)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700767 pe_err("Not able to insert NoA, total len=%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800768 total_noalen);
769 goto err_ret;
770 } else {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530771 qdf_mem_copy(&frame[bytes - (total_noalen)],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800772 &noa_ie[0], total_noalen);
773 }
774 }
775
Pragaspathi Thilagaraje64714a2019-05-23 00:46:25 +0530776 if ((BAND_5G == lim_get_rf_band(pe_session->currentOperChannel)) ||
777 (pe_session->opmode == QDF_P2P_CLIENT_MODE) ||
778 (pe_session->opmode == QDF_P2P_GO_MODE))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800779 tx_flag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
780
781 /* Queue Probe Response frame in high priority WQ */
Jeff Johnson59429b02018-11-07 13:53:18 -0800782 qdf_status = wma_tx_frame(mac_ctx, packet,
783 (uint16_t)bytes,
784 TXRX_FRM_802_11_MGMT,
785 ANI_TXDIR_TODS,
786 7, lim_tx_complete, frame, tx_flag,
787 sme_sessionid, 0, RATEID_DEFAULT);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800788
789 /* Pkt will be freed up by the callback */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530790 if (!QDF_IS_STATUS_SUCCESS(qdf_status))
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700791 pe_err("Could not send Probe Response");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800792
Jeff Johnson8e9530b2019-03-18 13:41:42 -0700793 if (add_ie)
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530794 qdf_mem_free(add_ie);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800795
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530796 qdf_mem_free(frm);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800797 return;
798
799err_ret:
Jeff Johnson8e9530b2019-03-18 13:41:42 -0700800 if (add_ie)
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530801 qdf_mem_free(add_ie);
Jeff Johnson8e9530b2019-03-18 13:41:42 -0700802 if (frm)
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530803 qdf_mem_free(frm);
Jeff Johnson8e9530b2019-03-18 13:41:42 -0700804 if (packet)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800805 cds_packet_free((void *)packet);
806 return;
807
808} /* End lim_send_probe_rsp_mgmt_frame. */
809
810void
Jeff Johnson9320c1e2018-12-02 13:09:20 -0800811lim_send_addts_req_action_frame(struct mac_context *mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800812 tSirMacAddr peerMacAddr,
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800813 tSirAddtsReqInfo *pAddTS, struct pe_session *pe_session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800814{
815 uint16_t i;
816 uint8_t *pFrame;
817 tDot11fAddTSRequest AddTSReq;
818 tDot11fWMMAddTSRequest WMMAddTSReq;
819 uint32_t nPayload, nBytes, nStatus;
820 tpSirMacMgmtHdr pMacHdr;
821 void *pPacket;
822#ifdef FEATURE_WLAN_ESE
823 uint32_t phyMode;
824#endif
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530825 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800826 uint8_t txFlag = 0;
827 uint8_t smeSessionId = 0;
828
Jeff Johnson8e9530b2019-03-18 13:41:42 -0700829 if (!pe_session) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800830 return;
831 }
832
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800833 smeSessionId = pe_session->smeSessionId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800834
835 if (!pAddTS->wmeTspecPresent) {
hangtian127c9532019-01-12 13:29:07 +0800836 qdf_mem_zero((uint8_t *) &AddTSReq, sizeof(AddTSReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800837
Srinivas Girigowda03cebc32019-05-17 16:50:31 -0700838 AddTSReq.Action.action = QOS_ADD_TS_REQ;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800839 AddTSReq.DialogToken.token = pAddTS->dialogToken;
Srinivas Girigowda48bec1c2019-05-17 16:33:30 -0700840 AddTSReq.Category.category = ACTION_CATEGORY_QOS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800841 if (pAddTS->lleTspecPresent) {
842 populate_dot11f_tspec(&pAddTS->tspec, &AddTSReq.TSPEC);
843 } else {
844 populate_dot11f_wmmtspec(&pAddTS->tspec,
845 &AddTSReq.WMMTSPEC);
846 }
847
848 if (pAddTS->lleTspecPresent) {
849 AddTSReq.num_WMMTCLAS = 0;
850 AddTSReq.num_TCLAS = pAddTS->numTclas;
851 for (i = 0; i < pAddTS->numTclas; ++i) {
Jeff Johnson99f25042018-11-21 22:49:06 -0800852 populate_dot11f_tclas(mac, &pAddTS->tclasInfo[i],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800853 &AddTSReq.TCLAS[i]);
854 }
855 } else {
856 AddTSReq.num_TCLAS = 0;
857 AddTSReq.num_WMMTCLAS = pAddTS->numTclas;
858 for (i = 0; i < pAddTS->numTclas; ++i) {
Jeff Johnson99f25042018-11-21 22:49:06 -0800859 populate_dot11f_wmmtclas(mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800860 &pAddTS->tclasInfo[i],
861 &AddTSReq.WMMTCLAS[i]);
862 }
863 }
864
865 if (pAddTS->tclasProcPresent) {
866 if (pAddTS->lleTspecPresent) {
867 AddTSReq.TCLASSPROC.processing =
868 pAddTS->tclasProc;
869 AddTSReq.TCLASSPROC.present = 1;
870 } else {
871 AddTSReq.WMMTCLASPROC.version = 1;
872 AddTSReq.WMMTCLASPROC.processing =
873 pAddTS->tclasProc;
874 AddTSReq.WMMTCLASPROC.present = 1;
875 }
876 }
877
878 nStatus =
Jeff Johnson99f25042018-11-21 22:49:06 -0800879 dot11f_get_packed_add_ts_request_size(mac, &AddTSReq, &nPayload);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800880 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700881 pe_err("Failed to calculate the packed size for an Add TS Request (0x%08x)",
882 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800883 /* We'll fall back on the worst case scenario: */
884 nPayload = sizeof(tDot11fAddTSRequest);
885 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700886 pe_warn("There were warnings while calculating the packed size for an Add TS Request (0x%08x)",
887 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800888 }
889 } else {
hangtian127c9532019-01-12 13:29:07 +0800890 qdf_mem_zero((uint8_t *) &WMMAddTSReq, sizeof(WMMAddTSReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800891
Srinivas Girigowda03cebc32019-05-17 16:50:31 -0700892 WMMAddTSReq.Action.action = QOS_ADD_TS_REQ;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800893 WMMAddTSReq.DialogToken.token = pAddTS->dialogToken;
Srinivas Girigowda48bec1c2019-05-17 16:33:30 -0700894 WMMAddTSReq.Category.category = ACTION_CATEGORY_WMM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800895
896 /* WMM spec 2.2.10 - status code is only filled in for ADDTS response */
897 WMMAddTSReq.StatusCode.statusCode = 0;
898
899 populate_dot11f_wmmtspec(&pAddTS->tspec, &WMMAddTSReq.WMMTSPEC);
900#ifdef FEATURE_WLAN_ESE
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800901 lim_get_phy_mode(mac, &phyMode, pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800902
903 if (phyMode == WNI_CFG_PHY_MODE_11G
904 || phyMode == WNI_CFG_PHY_MODE_11A) {
905 pAddTS->tsrsIE.rates[0] = TSRS_11AG_RATE_6MBPS;
906 } else {
907 pAddTS->tsrsIE.rates[0] = TSRS_11B_RATE_5_5MBPS;
908 }
Jeff Johnson99f25042018-11-21 22:49:06 -0800909 populate_dot11_tsrsie(mac, &pAddTS->tsrsIE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800910 &WMMAddTSReq.ESETrafStrmRateSet,
911 sizeof(uint8_t));
912#endif
913 /* fillWmeTspecIE */
914
915 nStatus =
Jeff Johnson99f25042018-11-21 22:49:06 -0800916 dot11f_get_packed_wmm_add_ts_request_size(mac, &WMMAddTSReq,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800917 &nPayload);
918 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700919 pe_err("Failed to calculate the packed size for a WMM Add TS Request (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800920 nStatus);
921 /* We'll fall back on the worst case scenario: */
922 nPayload = sizeof(tDot11fAddTSRequest);
923 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700924 pe_warn("There were warnings while calculating the packed size for a WMM Add TS Request (0x%08x)",
925 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800926 }
927 }
928
929 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
930
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530931 qdf_status = cds_packet_alloc((uint16_t) nBytes, (void **)&pFrame,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800932 (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530933 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700934 pe_err("Failed to allocate %d bytes for an Add TS Request",
935 nBytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800936 return;
937 }
938 /* Paranoia: */
hangtian127c9532019-01-12 13:29:07 +0800939 qdf_mem_zero(pFrame, nBytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800940
941 /* Next, we fill out the buffer descriptor: */
Jeff Johnson99f25042018-11-21 22:49:06 -0800942 lim_populate_mac_header(mac, pFrame, SIR_MAC_MGMT_FRAME,
Pragaspathi Thilagaraj7fb14222019-06-17 23:26:58 +0530943 SIR_MAC_MGMT_ACTION, peerMacAddr, pe_session->self_mac_addr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800944 pMacHdr = (tpSirMacMgmtHdr) pFrame;
945
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800946 sir_copy_mac_addr(pMacHdr->bssId, pe_session->bssId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800947
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800948 lim_set_protected_bit(mac, pe_session, peerMacAddr, pMacHdr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800949
950 /* That done, pack the struct: */
951 if (!pAddTS->wmeTspecPresent) {
Jeff Johnson99f25042018-11-21 22:49:06 -0800952 nStatus = dot11f_pack_add_ts_request(mac, &AddTSReq,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800953 pFrame +
954 sizeof(tSirMacMgmtHdr),
955 nPayload, &nPayload);
956 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700957 pe_err("Failed to pack an Add TS Request "
958 "(0x%08x)", nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800959 cds_packet_free((void *)pPacket);
960 return; /* allocated! */
961 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700962 pe_warn("There were warnings while packing an Add TS Request (0x%08x)",
963 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800964 }
965 } else {
Jeff Johnson99f25042018-11-21 22:49:06 -0800966 nStatus = dot11f_pack_wmm_add_ts_request(mac, &WMMAddTSReq,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800967 pFrame +
968 sizeof(tSirMacMgmtHdr),
969 nPayload, &nPayload);
970 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700971 pe_err("Failed to pack a WMM Add TS Request (0x%08x)",
972 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800973 cds_packet_free((void *)pPacket);
974 return; /* allocated! */
975 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700976 pe_warn("There were warnings while packing a WMM Add TS Request (0x%08x)",
977 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800978 }
979 }
980
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700981 pe_debug("Sending an Add TS Request frame to");
Jeff Johnson99f25042018-11-21 22:49:06 -0800982 lim_print_mac_addr(mac, peerMacAddr, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800983
Pragaspathi Thilagaraje64714a2019-05-23 00:46:25 +0530984 if ((BAND_5G == lim_get_rf_band(pe_session->currentOperChannel)) ||
985 (pe_session->opmode == QDF_P2P_CLIENT_MODE) ||
986 (pe_session->opmode == QDF_P2P_GO_MODE))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800987 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800988
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530989 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800990 pe_session->peSessionId, pMacHdr->fc.subType));
Jeff Johnson99f25042018-11-21 22:49:06 -0800991 lim_diag_mgmt_tx_event_report(mac, pMacHdr,
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800992 pe_session, QDF_STATUS_SUCCESS,
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700993 QDF_STATUS_SUCCESS);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800994
995 /* Queue Addts Response frame in high priority WQ */
Jeff Johnson99f25042018-11-21 22:49:06 -0800996 qdf_status = wma_tx_frame(mac, pPacket, (uint16_t) nBytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800997 TXRX_FRM_802_11_MGMT,
998 ANI_TXDIR_TODS,
999 7, lim_tx_complete, pFrame, txFlag,
Naveen Rawat296a5182017-09-25 14:02:48 -07001000 smeSessionId, 0, RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05301001 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001002 pe_session->peSessionId, qdf_status));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001003
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001004 if (!QDF_IS_STATUS_SUCCESS(qdf_status))
1005 pe_err("Could not send an Add TS Request (%X",
1006 qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001007} /* End lim_send_addts_req_action_frame. */
1008
1009/**
1010 * lim_send_assoc_rsp_mgmt_frame() - Send assoc response
1011 * @mac_ctx: Handle for mac context
1012 * @status_code: Status code for assoc response frame
1013 * @aid: Association ID
1014 * @peer_addr: Mac address of requesting peer
1015 * @subtype: Assoc/Reassoc
1016 * @sta: Pointer to station node
1017 * @pe_session: PE session id.
1018 *
1019 * Builds and sends association response frame to the requesting peer.
1020 *
1021 * Return: void
1022 */
1023
1024void
Jeff Johnson9320c1e2018-12-02 13:09:20 -08001025lim_send_assoc_rsp_mgmt_frame(struct mac_context *mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001026 uint16_t status_code, uint16_t aid, tSirMacAddr peer_addr,
Jeff Johnsona7815652018-11-18 22:58:30 -08001027 uint8_t subtype, tpDphHashNode sta, struct pe_session *pe_session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001028{
1029 static tDot11fAssocResponse frm;
1030 uint8_t *frame;
1031 tpSirMacMgmtHdr mac_hdr;
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001032 QDF_STATUS sir_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001033 uint8_t lle_mode = 0, addts;
1034 tHalBitVal qos_mode, wme_mode;
Hu Wang411e0cc2016-10-28 14:56:01 +08001035 uint32_t payload, bytes = 0, status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001036 void *packet;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301037 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001038 tUpdateBeaconParams beacon_params;
1039 uint8_t tx_flag = 0;
1040 uint32_t addn_ie_len = 0;
1041 uint8_t add_ie[WNI_CFG_ASSOC_RSP_ADDNIE_DATA_LEN];
1042 tpSirAssocReq assoc_req = NULL;
1043 uint8_t sme_session = 0;
1044 bool is_vht = false;
1045 uint16_t stripoff_len = 0;
1046 tDot11fIEExtCap extracted_ext_cap;
1047 bool extracted_flag = false;
1048#ifdef WLAN_FEATURE_11W
Karthik Kantamneni24f71bc2018-09-11 19:08:38 +05301049 uint8_t retry_int;
1050 uint16_t max_retries;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001051#endif
1052
Jeff Johnson8e9530b2019-03-18 13:41:42 -07001053 if (!pe_session) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001054 pe_err("pe_session is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001055 return;
1056 }
1057
1058 sme_session = pe_session->smeSessionId;
1059
hangtian127c9532019-01-12 13:29:07 +08001060 qdf_mem_zero((uint8_t *) &frm, sizeof(frm));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001061
1062 limGetQosMode(pe_session, &qos_mode);
1063 limGetWmeMode(pe_session, &wme_mode);
1064
1065 /*
1066 * An Add TS IE is added only if the AP supports it and
1067 * the requesting STA sent a traffic spec.
1068 */
1069 addts = (qos_mode && sta && sta->qos.addtsPresent) ? 1 : 0;
1070
1071 frm.Status.status = status_code;
1072
1073 frm.AID.associd = aid | LIM_AID_MASK;
1074
Jeff Johnson8e9530b2019-03-18 13:41:42 -07001075 if (!sta) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001076 populate_dot11f_supp_rates(mac_ctx,
1077 POPULATE_DOT11F_RATES_OPERATIONAL,
1078 &frm.SuppRates, pe_session);
1079 populate_dot11f_ext_supp_rates(mac_ctx,
1080 POPULATE_DOT11F_RATES_OPERATIONAL,
1081 &frm.ExtSuppRates, pe_session);
1082 } else {
1083 populate_dot11f_assoc_rsp_rates(mac_ctx, &frm.SuppRates,
1084 &frm.ExtSuppRates,
1085 sta->supportedRates.llbRates,
1086 sta->supportedRates.llaRates);
1087 }
1088
Jeff Johnson8e9530b2019-03-18 13:41:42 -07001089 if (LIM_IS_AP_ROLE(pe_session) && sta &&
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001090 QDF_STATUS_SUCCESS == status_code) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001091 assoc_req = (tpSirAssocReq)
1092 pe_session->parsedAssocReq[sta->assocId];
1093 /*
1094 * populate P2P IE in AssocRsp when assocReq from the peer
1095 * includes P2P IE
1096 */
Jeff Johnson8e9530b2019-03-18 13:41:42 -07001097 if (assoc_req && assoc_req->addIEPresent)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001098 populate_dot11_assoc_res_p2p_ie(mac_ctx,
1099 &frm.P2PAssocRes,
1100 assoc_req);
1101 }
1102
Jeff Johnson8e9530b2019-03-18 13:41:42 -07001103 if (sta) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001104 if (eHAL_SET == qos_mode) {
1105 if (sta->lleEnabled) {
1106 lle_mode = 1;
1107 populate_dot11f_edca_param_set(mac_ctx,
1108 &frm.EDCAParamSet, pe_session);
1109 }
1110 }
1111
1112 if ((!lle_mode) && (eHAL_SET == wme_mode) && sta->wmeEnabled) {
1113 populate_dot11f_wmm_params(mac_ctx, &frm.WMMParams,
1114 pe_session);
1115
1116 if (sta->wsmEnabled)
1117 populate_dot11f_wmm_caps(&frm.WMMCaps);
1118 }
1119
1120 if (sta->mlmStaContext.htCapability &&
1121 pe_session->htCapability) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001122 pe_debug("Populate HT IEs in Assoc Response");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001123 populate_dot11f_ht_caps(mac_ctx, pe_session,
1124 &frm.HTCaps);
Krunal Sonief3294b2015-06-12 15:12:19 -07001125 /*
1126 * Check the STA capability and
1127 * update the HTCaps accordingly
1128 */
1129 frm.HTCaps.supportedChannelWidthSet = (
1130 sta->htSupportedChannelWidthSet <
1131 pe_session->htSupportedChannelWidthSet) ?
1132 sta->htSupportedChannelWidthSet :
1133 pe_session->htSupportedChannelWidthSet;
1134 if (!frm.HTCaps.supportedChannelWidthSet)
1135 frm.HTCaps.shortGI40MHz = 0;
1136
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001137 populate_dot11f_ht_info(mac_ctx, &frm.HTInfo,
Pragaspathi Thilagarajb3472f02019-06-04 14:10:44 +05301138 pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001139 }
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001140 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 +05301141 frm.HTCaps.supportedChannelWidthSet,
1142 frm.HTCaps.mimoPowerSave,
1143 frm.HTCaps.greenField, frm.HTCaps.shortGI20MHz,
1144 frm.HTCaps.shortGI40MHz,
1145 frm.HTCaps.dsssCckMode40MHz,
1146 frm.HTCaps.maxRxAMPDUFactor);
1147
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001148 if (sta->mlmStaContext.vhtCapability &&
1149 pe_session->vhtCapability) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001150 pe_debug("Populate VHT IEs in Assoc Response");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001151 populate_dot11f_vht_caps(mac_ctx, pe_session,
1152 &frm.VHTCaps);
1153 populate_dot11f_vht_operation(mac_ctx, pe_session,
Kapil Gupta4b2efbb2016-10-03 13:07:20 +05301154 &frm.VHTOperation);
1155 is_vht = true;
Pragaspathi Thilagarajb3472f02019-06-04 14:10:44 +05301156 } else if (sta->mlmStaContext.force_1x1 &&
1157 frm.HTCaps.present) {
1158 /*
1159 * WAR: In P2P GO mode, if the P2P client device
1160 * is only HT capable and not VHT capable, but the P2P
1161 * GO device is VHT capable and advertises 2x2 NSS with
1162 * HT capablity client device, which results in IOT
1163 * issues.
1164 * When GO is operating in DBS mode, GO beacons
1165 * advertise 2x2 capability but include OMN IE to
1166 * indicate current operating mode of 1x1. But here
1167 * peer device is only HT capable and will not
1168 * understand OMN IE.
1169 */
1170 frm.HTInfo.basicMCSSet[1] = 0;
1171 frm.HTCaps.supportedMCSSet[1] = 0;
Kapil Gupta4b2efbb2016-10-03 13:07:20 +05301172 }
Naveen Rawat903acca2017-09-15 17:32:13 -07001173
Kapil Gupta4b2efbb2016-10-03 13:07:20 +05301174 if (pe_session->vhtCapability &&
1175 pe_session->vendor_vht_sap &&
Jeff Johnson8e9530b2019-03-18 13:41:42 -07001176 (assoc_req) &&
Kapil Gupta4b2efbb2016-10-03 13:07:20 +05301177 assoc_req->vendor_vht_ie.VHTCaps.present) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001178 pe_debug("Populate Vendor VHT IEs in Assoc Rsponse");
Kapil Gupta4b2efbb2016-10-03 13:07:20 +05301179 frm.vendor_vht_ie.present = 1;
Kiran Kumar Lokere81722632017-09-26 12:11:43 -07001180 frm.vendor_vht_ie.sub_type =
1181 pe_session->vendor_specific_vht_ie_sub_type;
Kapil Gupta4b2efbb2016-10-03 13:07:20 +05301182 frm.vendor_vht_ie.VHTCaps.present = 1;
1183 populate_dot11f_vht_caps(mac_ctx, pe_session,
1184 &frm.vendor_vht_ie.VHTCaps);
Kiran Kumar Lokerecc448682017-07-20 18:08:01 -07001185 populate_dot11f_vht_operation(mac_ctx, pe_session,
1186 &frm.vendor_vht_ie.VHTOperation);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001187 is_vht = true;
1188 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001189 populate_dot11f_ext_cap(mac_ctx, is_vht, &frm.ExtCap,
1190 pe_session);
1191
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08001192 if (lim_is_sta_he_capable(sta) &&
1193 lim_is_session_he_capable(pe_session)) {
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07001194 pe_debug("Populate HE IEs");
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08001195 populate_dot11f_he_caps(mac_ctx, pe_session,
Naveen Rawatd8feac12017-09-08 15:08:39 -07001196 &frm.he_cap);
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08001197 populate_dot11f_he_operation(mac_ctx, pe_session,
Naveen Rawatd8feac12017-09-08 15:08:39 -07001198 &frm.he_op);
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08001199 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001200#ifdef WLAN_FEATURE_11W
1201 if (eSIR_MAC_TRY_AGAIN_LATER == status_code) {
Karthik Kantamneni24f71bc2018-09-11 19:08:38 +05301202 max_retries =
1203 mac_ctx->mlme_cfg->gen.pmf_sa_query_max_retries;
1204 retry_int =
1205 mac_ctx->mlme_cfg->gen.pmf_sa_query_retry_interval;
1206 populate_dot11f_timeout_interval(mac_ctx,
1207 &frm.TimeoutInterval,
1208 SIR_MAC_TI_TYPE_ASSOC_COMEBACK,
1209 (max_retries -
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001210 sta->pmfSaQueryRetryCount)
1211 * retry_int);
1212 }
1213#endif
Arif Hussain0c816922017-04-06 15:04:44 -07001214
1215 if (LIM_IS_AP_ROLE(pe_session) && sta->non_ecsa_capable)
1216 pe_session->lim_non_ecsa_cap_num++;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001217 }
1218
hangtian127c9532019-01-12 13:29:07 +08001219 qdf_mem_zero((uint8_t *) &beacon_params, sizeof(beacon_params));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001220
1221 if (LIM_IS_AP_ROLE(pe_session) &&
Pragaspathi Thilagaraj1ee76002018-09-18 21:38:51 +05301222 (pe_session->gLimProtectionControl !=
1223 MLME_FORCE_POLICY_PROTECTION_DISABLE))
1224 lim_decide_ap_protection(mac_ctx, peer_addr, &beacon_params,
1225 pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001226
1227 lim_update_short_preamble(mac_ctx, peer_addr, &beacon_params,
1228 pe_session);
1229 lim_update_short_slot_time(mac_ctx, peer_addr, &beacon_params,
1230 pe_session);
1231
1232 /*
1233 * Populate Do11capabilities after updating session with
1234 * Assos req details
1235 */
1236 populate_dot11f_capabilities(mac_ctx, &frm.Capabilities, pe_session);
1237
Pragaspathi Thilagaraje05162d2019-05-23 13:10:46 +05301238 beacon_params.bss_idx = pe_session->bss_idx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001239
1240 /* Send message to HAL about beacon parameter change. */
1241 if ((false == mac_ctx->sap.SapDfsInfo.is_dfs_cac_timer_running)
1242 && beacon_params.paramChangeBitmap) {
1243 sch_set_fixed_beacon_fields(mac_ctx, pe_session);
1244 lim_send_beacon_params(mac_ctx, &beacon_params, pe_session);
1245 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001246
Arif Hussain1513cb22018-01-05 19:56:31 -08001247 lim_obss_send_detection_cfg(mac_ctx, pe_session, false);
1248
Jeff Johnson8e9530b2019-03-18 13:41:42 -07001249 if (assoc_req) {
Jeff Johnson21aac3a2019-02-02 14:26:13 -08001250 addn_ie_len = pe_session->add_ie_params.assocRespDataLen;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001251
1252 /* Nonzero length indicates Assoc rsp IE available */
Krishna Kumaar Natarajane4e3a142016-04-01 16:27:51 -07001253 if (addn_ie_len > 0 &&
1254 addn_ie_len <= WNI_CFG_ASSOC_RSP_ADDNIE_DATA_LEN &&
1255 (bytes + addn_ie_len) <= SIR_MAX_PACKET_SIZE) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301256 qdf_mem_copy(add_ie,
Jeff Johnson21aac3a2019-02-02 14:26:13 -08001257 pe_session->add_ie_params.assocRespData_buff,
1258 pe_session->add_ie_params.assocRespDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001259
hangtian127c9532019-01-12 13:29:07 +08001260 qdf_mem_zero((uint8_t *) &extracted_ext_cap,
1261 sizeof(extracted_ext_cap));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001262
1263 stripoff_len = addn_ie_len;
1264 sir_status =
1265 lim_strip_extcap_update_struct
1266 (mac_ctx, &add_ie[0], &stripoff_len,
1267 &extracted_ext_cap);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001268 if (QDF_STATUS_SUCCESS != sir_status) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001269 pe_debug("strip off extcap IE failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001270 } else {
1271 addn_ie_len = stripoff_len;
1272 extracted_flag = true;
1273 }
1274 bytes = bytes + addn_ie_len;
1275 }
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001276 pe_debug("addn_ie_len: %d for Assoc Resp: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001277 addn_ie_len, assoc_req->addIEPresent);
1278 }
Hu Wang411e0cc2016-10-28 14:56:01 +08001279
1280 /*
1281 * Extcap IE now support variable length, merge Extcap IE from addn_ie
1282 * may change the frame size. Therefore, MUST merge ExtCap IE before
1283 * dot11f get packed payload size.
1284 */
1285 if (extracted_flag)
Hu Wangfbd279d2016-10-31 18:24:34 +08001286 lim_merge_extcap_struct(&(frm.ExtCap), &extracted_ext_cap,
1287 true);
Hu Wang411e0cc2016-10-28 14:56:01 +08001288
1289 /* Allocate a buffer for this frame: */
1290 status = dot11f_get_packed_assoc_response_size(mac_ctx, &frm, &payload);
1291 if (DOT11F_FAILED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001292 pe_err("get Association Response size failure (0x%08x)",
Hu Wang411e0cc2016-10-28 14:56:01 +08001293 status);
1294 return;
1295 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001296 pe_warn("get Association Response size warning (0x%08x)",
Hu Wang411e0cc2016-10-28 14:56:01 +08001297 status);
1298 }
1299
1300 bytes += sizeof(tSirMacMgmtHdr) + payload;
1301
Min Liu0daa0982019-02-01 17:50:44 +08001302 if (sta)
1303 bytes += sta->mlmStaContext.owe_ie_len;
1304
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301305 qdf_status = cds_packet_alloc((uint16_t) bytes, (void **)&frame,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001306 (void **)&packet);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301307 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001308 pe_err("cds_packet_alloc failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001309 return;
1310 }
1311 /* Paranoia: */
hangtian127c9532019-01-12 13:29:07 +08001312 qdf_mem_zero(frame, bytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001313
1314 /* Next, we fill out the buffer descriptor: */
1315 lim_populate_mac_header(mac_ctx, frame, SIR_MAC_MGMT_FRAME,
1316 (LIM_ASSOC == subtype) ?
1317 SIR_MAC_MGMT_ASSOC_RSP : SIR_MAC_MGMT_REASSOC_RSP,
1318 peer_addr,
Pragaspathi Thilagaraj7fb14222019-06-17 23:26:58 +05301319 pe_session->self_mac_addr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001320 mac_hdr = (tpSirMacMgmtHdr) frame;
1321
1322 sir_copy_mac_addr(mac_hdr->bssId, pe_session->bssId);
1323
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001324 status = dot11f_pack_assoc_response(mac_ctx, &frm,
1325 frame + sizeof(tSirMacMgmtHdr),
1326 payload, &payload);
1327 if (DOT11F_FAILED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001328 pe_err("Association Response pack failure(0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001329 status);
1330 cds_packet_free((void *)packet);
1331 return;
1332 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001333 pe_warn("Association Response pack warning (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001334 status);
1335 }
1336
1337 if (subtype == LIM_ASSOC)
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001338 pe_debug("*** Sending Assoc Resp status %d aid %d to",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001339 status_code, aid);
1340 else
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001341 pe_debug("*** Sending ReAssoc Resp status %d aid %d to",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001342 status_code, aid);
1343
Abhishek Singh5d8d7332017-08-10 15:15:24 +05301344 lim_print_mac_addr(mac_ctx, mac_hdr->da, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001345
1346 if (addn_ie_len && addn_ie_len <= WNI_CFG_ASSOC_RSP_ADDNIE_DATA_LEN)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301347 qdf_mem_copy(frame + sizeof(tSirMacMgmtHdr) + payload,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001348 &add_ie[0], addn_ie_len);
1349
Min Liu0daa0982019-02-01 17:50:44 +08001350 if (sta && sta->mlmStaContext.owe_ie_len)
1351 qdf_mem_copy(frame + sizeof(tSirMacMgmtHdr) + payload
1352 + addn_ie_len,
1353 sta->mlmStaContext.owe_ie,
1354 sta->mlmStaContext.owe_ie_len);
1355
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08001356 if ((BAND_5G ==
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001357 lim_get_rf_band(pe_session->currentOperChannel)) ||
Pragaspathi Thilagaraje64714a2019-05-23 00:46:25 +05301358 (pe_session->opmode == QDF_P2P_CLIENT_MODE) ||
1359 (pe_session->opmode == QDF_P2P_GO_MODE))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001360 tx_flag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
1361
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05301362 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001363 pe_session->peSessionId, mac_hdr->fc.subType));
Krunal Sonic65fc492018-03-09 15:53:28 -08001364 lim_diag_mgmt_tx_event_report(mac_ctx, mac_hdr,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001365 pe_session, QDF_STATUS_SUCCESS, status_code);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001366 /* Queue Association Response frame in high priority WQ */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301367 qdf_status = wma_tx_frame(mac_ctx, packet, (uint16_t) bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001368 TXRX_FRM_802_11_MGMT,
1369 ANI_TXDIR_TODS,
1370 7, lim_tx_complete, frame, tx_flag,
Naveen Rawat296a5182017-09-25 14:02:48 -07001371 sme_session, 0, RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05301372 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301373 pe_session->peSessionId, qdf_status));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001374
1375 /* Pkt will be freed up by the callback */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301376 if (!QDF_IS_STATUS_SUCCESS(qdf_status))
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001377 pe_err("Could not Send Re/AssocRsp, retCode=%X",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301378 qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001379
1380 /*
1381 * update the ANI peer station count.
1382 * FIXME_PROTECTION : take care of different type of station
1383 * counter inside this function.
1384 */
1385 lim_util_count_sta_add(mac_ctx, sta, pe_session);
1386
1387}
1388
1389void
Jeff Johnson9320c1e2018-12-02 13:09:20 -08001390lim_send_delts_req_action_frame(struct mac_context *mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001391 tSirMacAddr peer,
1392 uint8_t wmmTspecPresent,
Jeff Johnson312348f2018-12-22 13:33:54 -08001393 struct mac_ts_info *pTsinfo,
Jeff Johnson56471b92018-12-22 14:36:06 -08001394 struct mac_tspec_ie *pTspecIe,
Jeff Johnson312348f2018-12-22 13:33:54 -08001395 struct pe_session *pe_session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001396{
1397 uint8_t *pFrame;
1398 tpSirMacMgmtHdr pMacHdr;
1399 tDot11fDelTS DelTS;
1400 tDot11fWMMDelTS WMMDelTS;
1401 uint32_t nBytes, nPayload, nStatus;
1402 void *pPacket;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301403 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001404 uint8_t txFlag = 0;
1405 uint8_t smeSessionId = 0;
1406
Jeff Johnson312348f2018-12-22 13:33:54 -08001407 if (!pe_session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001408 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001409
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001410 smeSessionId = pe_session->smeSessionId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001411
1412 if (!wmmTspecPresent) {
hangtian127c9532019-01-12 13:29:07 +08001413 qdf_mem_zero((uint8_t *) &DelTS, sizeof(DelTS));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001414
Srinivas Girigowda48bec1c2019-05-17 16:33:30 -07001415 DelTS.Category.category = ACTION_CATEGORY_QOS;
Srinivas Girigowda03cebc32019-05-17 16:50:31 -07001416 DelTS.Action.action = QOS_DEL_TS_REQ;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001417 populate_dot11f_ts_info(pTsinfo, &DelTS.TSInfo);
1418
Jeff Johnson99f25042018-11-21 22:49:06 -08001419 nStatus = dot11f_get_packed_del_ts_size(mac, &DelTS, &nPayload);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001420 if (DOT11F_FAILED(nStatus)) {
Jeff Johnson312348f2018-12-22 13:33:54 -08001421 pe_err("Failed to calculate the packed size for a Del TS (0x%08x)",
1422 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001423 /* We'll fall back on the worst case scenario: */
1424 nPayload = sizeof(tDot11fDelTS);
1425 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001426 pe_warn("There were warnings while calculating the packed size for a Del TS (0x%08x)",
1427 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001428 }
1429 } else {
hangtian127c9532019-01-12 13:29:07 +08001430 qdf_mem_zero((uint8_t *) &WMMDelTS, sizeof(WMMDelTS));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001431
Srinivas Girigowda48bec1c2019-05-17 16:33:30 -07001432 WMMDelTS.Category.category = ACTION_CATEGORY_WMM;
Srinivas Girigowda03cebc32019-05-17 16:50:31 -07001433 WMMDelTS.Action.action = QOS_DEL_TS_REQ;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001434 WMMDelTS.DialogToken.token = 0;
1435 WMMDelTS.StatusCode.statusCode = 0;
1436 populate_dot11f_wmmtspec(pTspecIe, &WMMDelTS.WMMTSPEC);
1437 nStatus =
Jeff Johnson99f25042018-11-21 22:49:06 -08001438 dot11f_get_packed_wmm_del_ts_size(mac, &WMMDelTS, &nPayload);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001439 if (DOT11F_FAILED(nStatus)) {
Jeff Johnson312348f2018-12-22 13:33:54 -08001440 pe_err("Failed to calculate the packed size for a WMM Del TS (0x%08x)",
1441 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001442 /* We'll fall back on the worst case scenario: */
1443 nPayload = sizeof(tDot11fDelTS);
1444 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001445 pe_warn("There were warnings while calculating the packed size for a WMM Del TS (0x%08x)",
1446 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001447 }
1448 }
1449
1450 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
1451
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301452 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001453 cds_packet_alloc((uint16_t) nBytes, (void **)&pFrame,
1454 (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301455 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001456 pe_err("Failed to allocate %d bytes for an Add TS Response",
1457 nBytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001458 return;
1459 }
1460 /* Paranoia: */
hangtian127c9532019-01-12 13:29:07 +08001461 qdf_mem_zero(pFrame, nBytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001462
1463 /* Next, we fill out the buffer descriptor: */
Jeff Johnson99f25042018-11-21 22:49:06 -08001464 lim_populate_mac_header(mac, pFrame, SIR_MAC_MGMT_FRAME,
Pragaspathi Thilagaraj7fb14222019-06-17 23:26:58 +05301465 SIR_MAC_MGMT_ACTION, peer, pe_session->self_mac_addr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001466 pMacHdr = (tpSirMacMgmtHdr) pFrame;
1467
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001468 sir_copy_mac_addr(pMacHdr->bssId, pe_session->bssId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001469
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001470 lim_set_protected_bit(mac, pe_session, peer, pMacHdr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001471
1472 /* That done, pack the struct: */
1473 if (!wmmTspecPresent) {
Jeff Johnson99f25042018-11-21 22:49:06 -08001474 nStatus = dot11f_pack_del_ts(mac, &DelTS,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001475 pFrame + sizeof(tSirMacMgmtHdr),
1476 nPayload, &nPayload);
1477 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001478 pe_err("Failed to pack a Del TS frame (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001479 nStatus);
1480 cds_packet_free((void *)pPacket);
1481 return; /* allocated! */
1482 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001483 pe_warn("There were warnings while packing a Del TS frame (0x%08x)",
1484 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001485 }
1486 } else {
Jeff Johnson99f25042018-11-21 22:49:06 -08001487 nStatus = dot11f_pack_wmm_del_ts(mac, &WMMDelTS,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001488 pFrame + sizeof(tSirMacMgmtHdr),
1489 nPayload, &nPayload);
1490 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001491 pe_err("Failed to pack a WMM Del TS frame (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001492 nStatus);
1493 cds_packet_free((void *)pPacket);
1494 return; /* allocated! */
1495 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001496 pe_warn("There were warnings while packing a WMM Del TS frame (0x%08x)",
1497 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001498 }
1499 }
1500
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001501 pe_debug("Sending DELTS REQ (size %d) to ", nBytes);
Jeff Johnson99f25042018-11-21 22:49:06 -08001502 lim_print_mac_addr(mac, pMacHdr->da, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001503
Pragaspathi Thilagaraje64714a2019-05-23 00:46:25 +05301504 if ((BAND_5G == lim_get_rf_band(pe_session->currentOperChannel)) ||
1505 (pe_session->opmode == QDF_P2P_CLIENT_MODE) ||
1506 (pe_session->opmode == QDF_P2P_GO_MODE))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001507 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001508
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05301509 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001510 pe_session->peSessionId, pMacHdr->fc.subType));
Jeff Johnson99f25042018-11-21 22:49:06 -08001511 lim_diag_mgmt_tx_event_report(mac, pMacHdr,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001512 pe_session, QDF_STATUS_SUCCESS,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001513 QDF_STATUS_SUCCESS);
Jeff Johnson99f25042018-11-21 22:49:06 -08001514 qdf_status = wma_tx_frame(mac, pPacket, (uint16_t) nBytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001515 TXRX_FRM_802_11_MGMT,
1516 ANI_TXDIR_TODS,
1517 7, lim_tx_complete, pFrame, txFlag,
Naveen Rawat296a5182017-09-25 14:02:48 -07001518 smeSessionId, 0, RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05301519 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001520 pe_session->peSessionId, qdf_status));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001521 /* Pkt will be freed up by the callback */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301522 if (!QDF_IS_STATUS_SUCCESS(qdf_status))
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001523 pe_err("Failed to send Del TS (%X)!", qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001524
1525} /* End lim_send_delts_req_action_frame. */
1526
1527/**
Abhishek Singhdd2cb572017-08-11 11:10:19 +05301528 * lim_assoc_tx_complete_cnf()- Confirmation for assoc sent over the air
1529 * @context: pointer to global mac
1530 * @buf: buffer
1531 * @tx_complete : Sent status
1532 * @params; tx completion params
1533 *
1534 * Return: This returns QDF_STATUS
1535 */
1536
1537static QDF_STATUS lim_assoc_tx_complete_cnf(void *context,
1538 qdf_nbuf_t buf,
1539 uint32_t tx_complete,
1540 void *params)
1541{
1542 uint16_t assoc_ack_status;
1543 uint16_t reason_code;
Jeff Johnson9320c1e2018-12-02 13:09:20 -08001544 struct mac_context *mac_ctx = (struct mac_context *)context;
Abhishek Singhdd2cb572017-08-11 11:10:19 +05301545
1546 pe_debug("tx_complete= %d", tx_complete);
Zhu Jianmin5d8e3fe2018-01-04 16:16:20 +08001547 if (tx_complete == WMI_MGMT_TX_COMP_TYPE_COMPLETE_OK) {
Abhishek Singhdd2cb572017-08-11 11:10:19 +05301548 assoc_ack_status = ACKED;
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001549 reason_code = QDF_STATUS_SUCCESS;
Abhishek Singhdd2cb572017-08-11 11:10:19 +05301550 } else {
1551 assoc_ack_status = NOT_ACKED;
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001552 reason_code = QDF_STATUS_E_FAILURE;
Abhishek Singhdd2cb572017-08-11 11:10:19 +05301553 }
1554 if (buf)
1555 qdf_nbuf_free(buf);
1556
1557 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_ASSOC_ACK_EVENT,
1558 NULL, assoc_ack_status, reason_code);
1559 return QDF_STATUS_SUCCESS;
1560}
1561
Pragaspathi Thilagaraj54018e02019-04-25 01:32:17 +05301562#ifdef WLAN_ADAPTIVE_11R
1563/**
1564 * lim_fill_adaptive_11r_ie() - Populate the Vendor secific adaptive 11r
1565 * IE to association request frame
1566 * @pe_session: pointer to PE session
1567 * @ie_buf: buffer to which Adaptive 11r IE will be copied
1568 * @ie_len: length of the Adaptive 11r Vendor specific IE
1569 *
1570 * Return QDF_STATUS
1571 */
1572static QDF_STATUS lim_fill_adaptive_11r_ie(struct pe_session *pe_session,
1573 uint8_t **ie_buf, uint8_t *ie_len)
1574{
1575 uint8_t *buf = NULL, *adaptive_11r_ie = NULL;
1576
1577 if (!pe_session->is_adaptive_11r_connection)
1578 return QDF_STATUS_SUCCESS;
1579
1580 /*
1581 * Vendor specific Adaptive 11r IE to be advertised in Assoc
1582 * req:
1583 * Type 0xDD
1584 * Length 0x0B
1585 * OUI 0x00 0x00 0x0F
1586 * Type 0x22
1587 * subtype 0x00
1588 * Version 0x01
1589 * Length 0x04
1590 * Data 0x00 00 00 01(0th bit is 1 means adaptive 11r is
1591 * supported)
1592 */
1593 adaptive_11r_ie = qdf_mem_malloc(ADAPTIVE_11R_STA_IE_LEN + 2);
1594 if (!adaptive_11r_ie)
1595 return QDF_STATUS_E_FAILURE;
1596
1597 /* Fill the Vendor IE Type (0xDD) */
1598 buf = adaptive_11r_ie;
Srinivas Girigowda8e7ecab2019-05-16 11:31:19 -07001599 *buf = WLAN_ELEMID_VENDOR;
Pragaspathi Thilagaraj54018e02019-04-25 01:32:17 +05301600 buf++;
1601
1602 /* Fill the Vendor IE length (0x0B) */
1603 *buf = ADAPTIVE_11R_STA_IE_LEN;
1604 buf++;
1605
1606 /*
1607 * Fill the Adaptive 11r Vendor specific OUI(0x00 0x00 0x0F 0x22)
1608 */
1609 qdf_mem_copy(buf, ADAPTIVE_11R_STA_OUI, ADAPTIVE_11R_OUI_LEN);
1610 buf += ADAPTIVE_11R_OUI_LEN;
1611
1612 /* Fill Adaptive 11r Vendor specific Subtype (0x00) */
1613 *buf = ADAPTIVE_11R_OUI_SUBTYPE;
1614 buf++;
1615
1616 /* Fill Adaptive 11r Version (0x01) */
1617 *buf = ADAPTIVE_11R_OUI_VERSION;
1618 buf++;
1619
1620 /* Fill Adaptive 11r IE Data length (0x04) */
1621 *buf = ADAPTIVE_11R_DATA_LEN;
1622 buf++;
1623
1624 /* Fill Adaptive 11r IE Data (0x00 0x00 0x00 0x01) */
1625 qdf_mem_copy(buf, ADAPTIVE_11R_OUI_DATA, ADAPTIVE_11R_DATA_LEN);
1626
1627 *ie_len = ADAPTIVE_11R_STA_IE_LEN + 2;
1628 *ie_buf = adaptive_11r_ie;
1629
1630 return QDF_STATUS_SUCCESS;
1631}
1632
1633#else
1634static inline
1635QDF_STATUS lim_fill_adaptive_11r_ie(struct pe_session *pe_session,
1636 uint8_t **ie_buf, uint8_t *ie_len)
1637{
1638 return QDF_STATUS_SUCCESS;
1639}
1640#endif
1641
Abhishek Singhdd2cb572017-08-11 11:10:19 +05301642/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001643 * lim_send_assoc_req_mgmt_frame() - Send association request
1644 * @mac_ctx: Handle to MAC context
1645 * @mlm_assoc_req: Association request information
1646 * @pe_session: PE session information
1647 *
1648 * Builds and transmits association request frame to AP.
1649 *
1650 * Return: Void
1651 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001652void
Jeff Johnson9320c1e2018-12-02 13:09:20 -08001653lim_send_assoc_req_mgmt_frame(struct mac_context *mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001654 tLimMlmAssocReq *mlm_assoc_req,
Jeff Johnsona7815652018-11-18 22:58:30 -08001655 struct pe_session *pe_session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001656{
Naveen Rawat72475db2017-12-13 18:07:35 -08001657 int ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001658 tDot11fAssocRequest *frm;
1659 uint16_t caps;
1660 uint8_t *frame;
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001661 QDF_STATUS sir_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001662 tLimMlmAssocCnf assoc_cnf;
Hu Wang411e0cc2016-10-28 14:56:01 +08001663 uint32_t bytes = 0, payload, status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001664 uint8_t qos_enabled, wme_enabled, wsm_enabled;
1665 void *packet;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301666 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001667 uint16_t add_ie_len;
1668 uint8_t *add_ie;
Naveen Rawat08db88f2017-09-08 15:07:48 -07001669 const uint8_t *wps_ie = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001670 uint8_t power_caps = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001671 uint8_t tx_flag = 0;
1672 uint8_t sme_sessionid = 0;
1673 bool vht_enabled = false;
1674 tDot11fIEExtCap extr_ext_cap;
1675 bool extr_ext_flag = true;
1676 tpSirMacMgmtHdr mac_hdr;
Hu Wangfbd279d2016-10-31 18:24:34 +08001677 uint32_t ie_offset = 0;
1678 uint8_t *p_ext_cap = NULL;
1679 tDot11fIEExtCap bcn_ext_cap;
1680 uint8_t *bcn_ie = NULL;
1681 uint32_t bcn_ie_len = 0;
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +05301682 uint32_t aes_block_size_len = 0;
Naveen Rawat296a5182017-09-25 14:02:48 -07001683 enum rateid min_rid = RATEID_DEFAULT;
Pragaspathi Thilagaraj54018e02019-04-25 01:32:17 +05301684 uint8_t *mbo_ie = NULL, *adaptive_11r_ie = NULL;
1685 uint8_t mbo_ie_len = 0, adaptive_11r_ie_len = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001686
Jeff Johnson8e9530b2019-03-18 13:41:42 -07001687 if (!pe_session) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001688 pe_err("pe_session is NULL");
yeshwanth sriram guntuka07831012017-06-30 12:26:57 +05301689 qdf_mem_free(mlm_assoc_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001690 return;
1691 }
1692
1693 sme_sessionid = pe_session->smeSessionId;
1694
1695 /* check this early to avoid unncessary operation */
Pragaspathi Thilagaraj64ae59d2019-06-22 13:00:34 +05301696 if (!pe_session->lim_join_req) {
1697 pe_err("pe_session->lim_join_req is NULL");
yeshwanth sriram guntuka07831012017-06-30 12:26:57 +05301698 qdf_mem_free(mlm_assoc_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001699 return;
1700 }
Pragaspathi Thilagaraj64ae59d2019-06-22 13:00:34 +05301701 add_ie_len = pe_session->lim_join_req->addIEAssoc.length;
1702 add_ie = pe_session->lim_join_req->addIEAssoc.addIEdata;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001703
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301704 frm = qdf_mem_malloc(sizeof(tDot11fAssocRequest));
Arif Hussainf5b6c412018-10-10 19:41:09 -07001705 if (!frm) {
yeshwanth sriram guntuka07831012017-06-30 12:26:57 +05301706 qdf_mem_free(mlm_assoc_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001707 return;
1708 }
hangtian127c9532019-01-12 13:29:07 +08001709 qdf_mem_zero((uint8_t *) frm, sizeof(tDot11fAssocRequest));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001710
Agrawal Ashish0f94b572016-02-22 13:27:06 +05301711 if (add_ie_len && pe_session->is_ext_caps_present) {
hangtian127c9532019-01-12 13:29:07 +08001712 qdf_mem_zero((uint8_t *) &extr_ext_cap,
1713 sizeof(tDot11fIEExtCap));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001714 sir_status = lim_strip_extcap_update_struct(mac_ctx,
1715 add_ie, &add_ie_len, &extr_ext_cap);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001716 if (QDF_STATUS_SUCCESS != sir_status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001717 extr_ext_flag = false;
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001718 pe_debug("Unable to Stripoff ExtCap IE from Assoc Req");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001719 } else {
1720 struct s_ext_cap *p_ext_cap = (struct s_ext_cap *)
1721 extr_ext_cap.bytes;
1722
1723 if (p_ext_cap->interworking_service)
1724 p_ext_cap->qos_map = 1;
Hu Wang411e0cc2016-10-28 14:56:01 +08001725 extr_ext_cap.num_bytes =
1726 lim_compute_ext_cap_ie_length(&extr_ext_cap);
1727 extr_ext_flag = (extr_ext_cap.num_bytes > 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001728 }
1729 } else {
Jeff Johnson47d75242018-05-12 15:58:53 -07001730 pe_debug("No addn IE or peer doesn't support addnIE for Assoc Req");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001731 extr_ext_flag = false;
1732 }
1733
1734 caps = mlm_assoc_req->capabilityInfo;
1735#if defined(FEATURE_WLAN_WAPI)
1736 /*
1737 * According to WAPI standard:
1738 * 7.3.1.4 Capability Information field
1739 * In WAPI, non-AP STAs within an ESS set the Privacy subfield to 0
1740 * in transmitted Association or Reassociation management frames.
1741 * APs ignore the Privacy subfield within received Association and
1742 * Reassociation management frames.
1743 */
1744 if (pe_session->encryptType == eSIR_ED_WPI)
1745 ((tSirMacCapabilityInfo *) &caps)->privacy = 0;
1746#endif
1747 swap_bit_field16(caps, (uint16_t *) &frm->Capabilities);
1748
1749 frm->ListenInterval.interval = mlm_assoc_req->listenInterval;
1750 populate_dot11f_ssid2(mac_ctx, &frm->SSID);
1751 populate_dot11f_supp_rates(mac_ctx, POPULATE_DOT11F_RATES_OPERATIONAL,
1752 &frm->SuppRates, pe_session);
1753
1754 qos_enabled = (pe_session->limQosEnabled) &&
1755 SIR_MAC_GET_QOS(pe_session->limCurrentBssCaps);
1756
1757 wme_enabled = (pe_session->limWmeEnabled) &&
1758 LIM_BSS_CAPS_GET(WME, pe_session->limCurrentBssQosCaps);
1759
1760 /* We prefer .11e asociations: */
1761 if (qos_enabled)
1762 wme_enabled = false;
1763
1764 wsm_enabled = (pe_session->limWsmEnabled) && wme_enabled &&
1765 LIM_BSS_CAPS_GET(WSM, pe_session->limCurrentBssQosCaps);
1766
1767 if (pe_session->lim11hEnable &&
Pragaspathi Thilagaraj64ae59d2019-06-22 13:00:34 +05301768 pe_session->lim_join_req->spectrumMgtIndicator == true) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001769 power_caps = true;
1770
1771 populate_dot11f_power_caps(mac_ctx, &frm->PowerCaps,
1772 LIM_ASSOC, pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001773 populate_dot11f_supp_channels(mac_ctx, &frm->SuppChannels,
1774 LIM_ASSOC, pe_session);
1775
1776 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001777 if (mac_ctx->rrm.rrmPEContext.rrmEnable &&
1778 SIR_MAC_GET_RRM(pe_session->limCurrentBssCaps)) {
1779 if (power_caps == false) {
1780 power_caps = true;
1781 populate_dot11f_power_caps(mac_ctx, &frm->PowerCaps,
1782 LIM_ASSOC, pe_session);
1783 }
1784 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001785 if (qos_enabled)
Naveen Rawatcd118312016-11-22 10:46:21 -08001786 populate_dot11f_qos_caps_station(mac_ctx, pe_session,
1787 &frm->QOSCapsStation);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001788
1789 populate_dot11f_ext_supp_rates(mac_ctx,
1790 POPULATE_DOT11F_RATES_OPERATIONAL, &frm->ExtSuppRates,
1791 pe_session);
1792
Gupta, Kapil54a16992016-01-13 19:34:02 +05301793 if (mac_ctx->rrm.rrmPEContext.rrmEnable &&
1794 SIR_MAC_GET_RRM(pe_session->limCurrentBssCaps))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001795 populate_dot11f_rrm_ie(mac_ctx, &frm->RRMEnabledCap,
1796 pe_session);
Deepak Dhamdhere641bf322016-01-06 15:19:03 -08001797
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001798 /*
1799 * The join request *should* contain zero or one of the WPA and RSN
1800 * IEs. The payload send along with the request is a
Jeff Johnson701444f2019-02-02 22:35:13 -08001801 * 'struct join_req'; the IE portion is held inside a 'tSirRSNie':
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001802 * typedef struct sSirRSNie
1803 * {
1804 * uint16_t length;
Srinivas Girigowdacf161402019-03-14 11:37:33 -07001805 * uint8_t rsnIEdata[WLAN_MAX_IE_LEN+2];
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001806 * } tSirRSNie, *tpSirRSNie;
1807 * So, we should be able to make the following two calls harmlessly,
1808 * since they do nothing if they don't find the given IE in the
1809 * bytestream with which they're provided.
1810 * The net effect of this will be to faithfully transmit whatever
1811 * security IE is in the join request.
1812 * However, if we're associating for the purpose of WPS
1813 * enrollment, and we've been configured to indicate that by
1814 * eliding the WPA or RSN IE, we just skip this:
1815 */
1816 if (add_ie_len && add_ie)
1817 wps_ie = limGetWscIEPtr(mac_ctx, add_ie, add_ie_len);
1818
Jeff Johnson8e9530b2019-03-18 13:41:42 -07001819 if (!wps_ie) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001820 populate_dot11f_rsn_opaque(mac_ctx,
Pragaspathi Thilagaraj64ae59d2019-06-22 13:00:34 +05301821 &pe_session->lim_join_req->rsnIE,
1822 &frm->RSNOpaque);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001823 populate_dot11f_wpa_opaque(mac_ctx,
Pragaspathi Thilagaraj64ae59d2019-06-22 13:00:34 +05301824 &pe_session->lim_join_req->rsnIE,
1825 &frm->WPAOpaque);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001826#if defined(FEATURE_WLAN_WAPI)
1827 populate_dot11f_wapi_opaque(mac_ctx,
Pragaspathi Thilagaraj64ae59d2019-06-22 13:00:34 +05301828 &(pe_session->lim_join_req->rsnIE),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001829 &frm->WAPIOpaque);
1830#endif /* defined(FEATURE_WLAN_WAPI) */
1831 }
1832 /* include WME EDCA IE as well */
1833 if (wme_enabled) {
1834 populate_dot11f_wmm_info_station_per_session(mac_ctx,
1835 pe_session, &frm->WMMInfoStation);
1836
1837 if (wsm_enabled)
1838 populate_dot11f_wmm_caps(&frm->WMMCaps);
1839 }
1840
1841 /*
1842 * Populate HT IEs, when operating in 11n and
1843 * when AP is also operating in 11n mode
1844 */
1845 if (pe_session->htCapability &&
1846 mac_ctx->lim.htCapabilityPresentInBeacon) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001847 pe_debug("Populate HT Caps in Assoc Request");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001848 populate_dot11f_ht_caps(mac_ctx, pe_session, &frm->HTCaps);
Naveen Rawata410c5a2016-09-19 14:22:33 -07001849 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_DEBUG,
1850 &frm->HTCaps, sizeof(frm->HTCaps));
Kiran Kumar Lokere722dccd2018-02-23 13:23:52 -08001851 } else if (pe_session->he_with_wep_tkip) {
1852 pe_debug("Populate HT Caps in Assoc Request with WEP/TKIP");
1853 populate_dot11f_ht_caps(mac_ctx, NULL, &frm->HTCaps);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001854 }
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001855 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 +05301856 frm->HTCaps.supportedChannelWidthSet,
1857 frm->HTCaps.mimoPowerSave,
1858 frm->HTCaps.greenField, frm->HTCaps.shortGI20MHz,
1859 frm->HTCaps.shortGI40MHz,
1860 frm->HTCaps.dsssCckMode40MHz,
1861 frm->HTCaps.maxRxAMPDUFactor);
1862
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001863 if (pe_session->vhtCapability &&
1864 pe_session->vhtCapabilityPresentInBeacon) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001865 pe_debug("Populate VHT IEs in Assoc Request");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001866 populate_dot11f_vht_caps(mac_ctx, pe_session, &frm->VHTCaps);
Naveen Rawata410c5a2016-09-19 14:22:33 -07001867 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_DEBUG,
1868 &frm->VHTCaps, sizeof(frm->VHTCaps));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001869 vht_enabled = true;
Kiran Kumar Lokere1d4094e2016-08-31 19:04:04 -07001870 if (pe_session->enableHtSmps &&
1871 !pe_session->supported_nss_1x1) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001872 pe_err("VHT OP mode IE in Assoc Req");
Kiran Kumar Lokere1d4094e2016-08-31 19:04:04 -07001873 populate_dot11f_operating_mode(mac_ctx,
1874 &frm->OperatingMode, pe_session);
1875 }
Kiran Kumar Lokere722dccd2018-02-23 13:23:52 -08001876 } else if (pe_session->he_with_wep_tkip) {
1877 pe_debug("Populate VHT IEs in Assoc Request with WEP/TKIP");
1878 populate_dot11f_vht_caps(mac_ctx, NULL, &frm->VHTCaps);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001879 }
Kiran Kumar Lokere722dccd2018-02-23 13:23:52 -08001880
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001881 if (!vht_enabled &&
1882 pe_session->is_vendor_specific_vhtcaps) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001883 pe_debug("Populate Vendor VHT IEs in Assoc Request");
Kapil Gupta4b2efbb2016-10-03 13:07:20 +05301884 frm->vendor_vht_ie.present = 1;
Kiran Kumar Lokere81722632017-09-26 12:11:43 -07001885 frm->vendor_vht_ie.sub_type =
1886 pe_session->vendor_specific_vht_ie_sub_type;
Kapil Gupta4b2efbb2016-10-03 13:07:20 +05301887 frm->vendor_vht_ie.VHTCaps.present = 1;
Abhinav Kumarb074f2f2018-09-15 15:32:11 +05301888 if (!mac_ctx->mlme_cfg->vht_caps.vht_cap_info.vendor_vhtie &&
Abhishek Singh68844282018-01-25 16:48:41 +05301889 pe_session->vht_config.su_beam_formee) {
1890 pe_debug("Disable SU beamformee for vendor IE");
1891 pe_session->vht_config.su_beam_formee = 0;
1892 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001893 populate_dot11f_vht_caps(mac_ctx, pe_session,
Kapil Gupta4b2efbb2016-10-03 13:07:20 +05301894 &frm->vendor_vht_ie.VHTCaps);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001895 vht_enabled = true;
1896 }
Agrawal Ashish0f94b572016-02-22 13:27:06 +05301897 if (pe_session->is_ext_caps_present)
1898 populate_dot11f_ext_cap(mac_ctx, vht_enabled,
1899 &frm->ExtCap, pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001900
Wu Gao93816212018-08-31 16:49:54 +08001901 if (mac_ctx->mlme_cfg->sta.qcn_ie_support)
Selvaraj, Sridhara521aab2017-03-25 16:42:34 +05301902 populate_dot11f_qcn_ie(&frm->QCN_IE);
1903
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08001904 if (lim_is_session_he_capable(pe_session)) {
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07001905 pe_debug("Populate HE IEs");
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08001906 populate_dot11f_he_caps(mac_ctx, pe_session,
Naveen Rawatd8feac12017-09-08 15:08:39 -07001907 &frm->he_cap);
Kiran Kumar Lokere722dccd2018-02-23 13:23:52 -08001908 } else if (pe_session->he_with_wep_tkip) {
1909 pe_debug("Populate HE IEs in Assoc Request with WEP/TKIP");
1910 populate_dot11f_he_caps(mac_ctx, NULL, &frm->he_cap);
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08001911 }
Selvaraj, Sridharc2fe7a32017-02-02 19:20:16 +05301912
Pragaspathi Thilagaraj64ae59d2019-06-22 13:00:34 +05301913 if (pe_session->lim_join_req->is11Rconnection) {
Pragaspathi Thilagaraj1112c962019-05-23 23:45:38 +05301914 struct bss_description *bssdescr;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001915
Pragaspathi Thilagaraj64ae59d2019-06-22 13:00:34 +05301916 bssdescr = &pe_session->lim_join_req->bssDescription;
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001917 pe_debug("mdie = %02x %02x %02x",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001918 (unsigned int) bssdescr->mdie[0],
1919 (unsigned int) bssdescr->mdie[1],
1920 (unsigned int) bssdescr->mdie[2]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001921 populate_mdie(mac_ctx, &frm->MobilityDomain,
Pragaspathi Thilagaraj64ae59d2019-06-22 13:00:34 +05301922 pe_session->lim_join_req->bssDescription.mdie);
Pragaspathi Thilagaraj03839b92019-03-12 17:45:21 +05301923
1924 /*
1925 * IEEE80211-ai [13.2.4 FT initial mobility domain association
1926 * over FILS in an RSN]
1927 * Populate FT IE in association request. This FT IE should be
1928 * same as the FT IE received in auth response frame during the
1929 * FT-FILS authentication.
1930 */
1931 if (lim_is_fils_connection(pe_session))
1932 populate_fils_ft_info(mac_ctx, &frm->FTInfo,
1933 pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001934 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001935
1936#ifdef FEATURE_WLAN_ESE
1937 /*
1938 * ESE Version IE will be included in association request
1939 * when ESE is enabled on DUT through ini and it is also
1940 * advertised by the peer AP to which we are trying to
1941 * associate to.
1942 */
1943 if (pe_session->is_ese_version_ie_present &&
Wu Gao51a63562018-11-08 16:29:10 +08001944 mac_ctx->mlme_cfg->lfr.ese_enabled)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001945 populate_dot11f_ese_version(&frm->ESEVersion);
1946 /* For ESE Associations fill the ESE IEs */
1947 if (pe_session->isESEconnection &&
Pragaspathi Thilagaraj64ae59d2019-06-22 13:00:34 +05301948 pe_session->lim_join_req->isESEFeatureIniEnabled) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001949#ifndef FEATURE_DISABLE_RM
1950 populate_dot11f_ese_rad_mgmt_cap(&frm->ESERadMgmtCap);
1951#endif
1952 }
1953#endif
1954
Hu Wang411e0cc2016-10-28 14:56:01 +08001955 /*
1956 * Extcap IE now support variable length, merge Extcap IE from addn_ie
1957 * may change the frame size. Therefore, MUST merge ExtCap IE before
1958 * dot11f get packed payload size.
1959 */
1960 if (extr_ext_flag)
Hu Wangfbd279d2016-10-31 18:24:34 +08001961 lim_merge_extcap_struct(&frm->ExtCap, &extr_ext_cap, true);
1962
1963 /* Clear the bits in EXTCAP IE if AP not advertise it in beacon */
1964 if (frm->ExtCap.present && pe_session->is_ext_caps_present) {
1965 ie_offset = DOT11F_FF_TIMESTAMP_LEN +
1966 DOT11F_FF_BEACONINTERVAL_LEN +
1967 DOT11F_FF_CAPABILITIES_LEN;
1968
1969 qdf_mem_zero((uint8_t *)&bcn_ext_cap, sizeof(tDot11fIEExtCap));
1970 if (pe_session->beacon && pe_session->bcnLen > ie_offset) {
1971 bcn_ie = pe_session->beacon + ie_offset;
1972 bcn_ie_len = pe_session->bcnLen - ie_offset;
Naveen Rawat08db88f2017-09-08 15:07:48 -07001973 p_ext_cap = (uint8_t *)wlan_get_ie_ptr_from_eid(
Hu Wangfbd279d2016-10-31 18:24:34 +08001974 DOT11F_EID_EXTCAP,
Naveen Rawat08db88f2017-09-08 15:07:48 -07001975 bcn_ie, bcn_ie_len);
Hu Wangfbd279d2016-10-31 18:24:34 +08001976 lim_update_extcap_struct(mac_ctx, p_ext_cap,
1977 &bcn_ext_cap);
1978 lim_merge_extcap_struct(&frm->ExtCap, &bcn_ext_cap,
1979 false);
1980 }
Varun Reddy Yeturu4f849e52018-06-15 18:08:37 -07001981 /*
1982 * TWT extended capabilities should be populated after the
1983 * intersection of beacon caps and self caps is done because
1984 * the bits for TWT are unique to STA and AP and cannot be
1985 * intersected.
1986 */
1987 populate_dot11f_twt_extended_caps(mac_ctx, pe_session,
1988 &frm->ExtCap);
Hu Wangfbd279d2016-10-31 18:24:34 +08001989 }
Hu Wang411e0cc2016-10-28 14:56:01 +08001990
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001991 if (QDF_STATUS_SUCCESS != lim_strip_supp_op_class_update_struct(mac_ctx,
Arif Hussain6cec6bc2017-02-14 13:46:26 -08001992 add_ie, &add_ie_len, &frm->SuppOperatingClasses))
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001993 pe_debug("Unable to Stripoff supp op classes IE from Assoc Req");
Arif Hussain6cec6bc2017-02-14 13:46:26 -08001994
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +05301995 if (lim_is_fils_connection(pe_session)) {
1996 populate_dot11f_fils_params(mac_ctx, frm, pe_session);
1997 aes_block_size_len = AES_BLOCK_SIZE;
1998 }
1999
2000 /*
Vignesh Viswanathandada7932018-09-18 12:57:55 +05302001 * MBO IE needs to be appendded at the end of the assoc request
2002 * frame and is not parsed and unpacked by the frame parser
2003 * as the supplicant can send multiple TLVs with same Attribute
2004 * in the MBO IE and the frame parser does not support multiple
2005 * TLVs with same attribute in a single IE.
2006 * Strip off the MBO IE from add_ie and append it at the end.
2007 */
2008 if (wlan_get_vendor_ie_ptr_from_oui(SIR_MAC_MBO_OUI,
2009 SIR_MAC_MBO_OUI_SIZE, add_ie, add_ie_len)) {
2010 mbo_ie = qdf_mem_malloc(DOT11F_IE_MBO_IE_MAX_LEN + 2);
Arif Hussainf5b6c412018-10-10 19:41:09 -07002011 if (!mbo_ie)
Vignesh Viswanathandada7932018-09-18 12:57:55 +05302012 goto end;
Vignesh Viswanathandada7932018-09-18 12:57:55 +05302013
2014 qdf_status = lim_strip_ie(mac_ctx, add_ie, &add_ie_len,
Srinivas Girigowda61771262019-04-01 11:55:19 -07002015 WLAN_ELEMID_VENDOR, ONE_BYTE,
Vignesh Viswanathandada7932018-09-18 12:57:55 +05302016 SIR_MAC_MBO_OUI,
2017 SIR_MAC_MBO_OUI_SIZE,
2018 mbo_ie, DOT11F_IE_MBO_IE_MAX_LEN);
2019 if (QDF_IS_STATUS_ERROR(qdf_status)) {
2020 pe_err("Failed to strip MBO IE");
2021 goto free_mbo_ie;
2022 }
2023
2024 /* Include the EID and length fields */
2025 mbo_ie_len = mbo_ie[1] + 2;
2026 pe_debug("Stripped MBO IE of length %d", mbo_ie_len);
2027 }
2028
Pragaspathi Thilagaraj54018e02019-04-25 01:32:17 +05302029 qdf_status = lim_fill_adaptive_11r_ie(pe_session, &adaptive_11r_ie,
2030 &adaptive_11r_ie_len);
2031 if (QDF_IS_STATUS_ERROR(qdf_status)) {
2032 pe_err("Failed to fill adaptive 11r IE");
2033 goto free_mbo_ie;
2034 }
2035
Vignesh Viswanathandada7932018-09-18 12:57:55 +05302036 /*
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +05302037 * Do unpack to populate the add_ie buffer to frm structure
2038 * before packing the frm structure. In this way, the IE ordering
2039 * which the latest 802.11 spec mandates is maintained.
2040 */
Naveen Rawat72475db2017-12-13 18:07:35 -08002041 if (add_ie_len) {
2042 ret = dot11f_unpack_assoc_request(mac_ctx, add_ie,
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +05302043 add_ie_len, frm, true);
Naveen Rawat72475db2017-12-13 18:07:35 -08002044 if (DOT11F_FAILED(ret)) {
2045 pe_err("unpack failed, ret: 0x%x", ret);
2046 goto end;
2047 }
2048 }
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +05302049
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002050 status = dot11f_get_packed_assoc_request_size(mac_ctx, frm, &payload);
2051 if (DOT11F_FAILED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002052 pe_err("Association Request packet size failure(0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002053 status);
2054 /* We'll fall back on the worst case scenario: */
2055 payload = sizeof(tDot11fAssocRequest);
2056 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002057 pe_warn("Association request packet size warning (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002058 status);
2059 }
2060
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +05302061 bytes = payload + sizeof(tSirMacMgmtHdr) +
Pragaspathi Thilagaraj54018e02019-04-25 01:32:17 +05302062 aes_block_size_len + mbo_ie_len + adaptive_11r_ie_len;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002063
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302064 qdf_status = cds_packet_alloc((uint16_t) bytes, (void **)&frame,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002065 (void **)&packet);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302066 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002067 pe_err("Failed to allocate %d bytes", bytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002068
2069 pe_session->limMlmState = pe_session->limPrevMlmState;
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302070 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_MLM_STATE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002071 pe_session->peSessionId,
2072 pe_session->limMlmState));
2073
2074 /* Update PE session id */
2075 assoc_cnf.sessionId = pe_session->peSessionId;
2076
2077 assoc_cnf.resultCode = eSIR_SME_RESOURCES_UNAVAILABLE;
2078
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002079 lim_post_sme_message(mac_ctx, LIM_MLM_ASSOC_CNF,
2080 (uint32_t *) &assoc_cnf);
2081
yeshwanth sriram guntuka07831012017-06-30 12:26:57 +05302082 goto end;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002083 }
2084 /* Paranoia: */
hangtian127c9532019-01-12 13:29:07 +08002085 qdf_mem_zero(frame, bytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002086
2087 /* Next, we fill out the buffer descriptor: */
2088 lim_populate_mac_header(mac_ctx, frame, SIR_MAC_MGMT_FRAME,
2089 SIR_MAC_MGMT_ASSOC_REQ, pe_session->bssId,
Pragaspathi Thilagaraj7fb14222019-06-17 23:26:58 +05302090 pe_session->self_mac_addr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002091 /* That done, pack the Assoc Request: */
2092 status = dot11f_pack_assoc_request(mac_ctx, frm,
2093 frame + sizeof(tSirMacMgmtHdr), payload, &payload);
2094 if (DOT11F_FAILED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002095 pe_err("Assoc request pack failure (0x%08x)", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002096 cds_packet_free((void *)packet);
yeshwanth sriram guntuka07831012017-06-30 12:26:57 +05302097 goto end;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002098 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002099 pe_warn("Assoc request pack warning (0x%08x)", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002100 }
2101
Vignesh Viswanathandada7932018-09-18 12:57:55 +05302102 /* Copy the MBO IE to the end of the frame */
2103 qdf_mem_copy(frame + sizeof(tSirMacMgmtHdr) + payload,
2104 mbo_ie, mbo_ie_len);
2105 payload = payload + mbo_ie_len;
2106
Pragaspathi Thilagaraj54018e02019-04-25 01:32:17 +05302107 /*
2108 * Copy the Vendor specific Adaptive 11r IE to end of the
2109 * assoc request frame
2110 */
2111 qdf_mem_copy(frame + sizeof(tSirMacMgmtHdr) + payload,
2112 adaptive_11r_ie, adaptive_11r_ie_len);
2113 payload = payload + adaptive_11r_ie_len;
2114
Jeff Johnson8e9530b2019-03-18 13:41:42 -07002115 if (pe_session->assocReq) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302116 qdf_mem_free(pe_session->assocReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002117 pe_session->assocReq = NULL;
Naveen Rawat83102ef2015-11-03 10:42:34 -08002118 pe_session->assocReqLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002119 }
2120
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +05302121 if (lim_is_fils_connection(pe_session)) {
2122 qdf_status = aead_encrypt_assoc_req(mac_ctx, pe_session,
2123 frame, &payload);
2124 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
2125 cds_packet_free((void *)packet);
2126 qdf_mem_free(frm);
2127 return;
2128 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002129 }
2130
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302131 pe_session->assocReq = qdf_mem_malloc(payload);
Arif Hussainf5b6c412018-10-10 19:41:09 -07002132 if (pe_session->assocReq) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002133 /*
2134 * Store the Assoc request. This is sent to csr/hdd in
2135 * join cnf response.
2136 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302137 qdf_mem_copy(pe_session->assocReq,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002138 frame + sizeof(tSirMacMgmtHdr), payload);
2139 pe_session->assocReqLen = payload;
2140 }
2141
Pragaspathi Thilagaraje64714a2019-05-23 00:46:25 +05302142 if ((BAND_5G == lim_get_rf_band(pe_session->currentOperChannel)) ||
2143 (pe_session->opmode == QDF_P2P_CLIENT_MODE) ||
2144 (pe_session->opmode == QDF_P2P_GO_MODE))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002145 tx_flag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
2146
Pragaspathi Thilagaraje64714a2019-05-23 00:46:25 +05302147 if (pe_session->opmode == QDF_P2P_CLIENT_MODE ||
2148 pe_session->opmode == QDF_STA_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002149 tx_flag |= HAL_USE_PEER_STA_REQUESTED_MASK;
2150
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002151 mac_hdr = (tpSirMacMgmtHdr) frame;
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302152 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002153 pe_session->peSessionId, mac_hdr->fc.subType));
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +05302154
2155 pe_debug("Sending Association Request length %d to ", bytes);
Naveen Rawat296a5182017-09-25 14:02:48 -07002156 min_rid = lim_get_min_session_txrate(pe_session);
Krunal Sonic65fc492018-03-09 15:53:28 -08002157 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_ASSOC_START_EVENT,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07002158 pe_session, QDF_STATUS_SUCCESS, QDF_STATUS_SUCCESS);
Krunal Sonic65fc492018-03-09 15:53:28 -08002159 lim_diag_mgmt_tx_event_report(mac_ctx, mac_hdr,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07002160 pe_session, QDF_STATUS_SUCCESS, QDF_STATUS_SUCCESS);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302161 qdf_status =
Abhishek Singhdd2cb572017-08-11 11:10:19 +05302162 wma_tx_frameWithTxComplete(mac_ctx, packet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002163 (uint16_t) (sizeof(tSirMacMgmtHdr) + payload),
2164 TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS, 7,
Abhishek Singhdd2cb572017-08-11 11:10:19 +05302165 lim_tx_complete, frame, lim_assoc_tx_complete_cnf,
Naveen Rawat296a5182017-09-25 14:02:48 -07002166 tx_flag, sme_sessionid, false, 0, min_rid);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302167 MTRACE(qdf_trace
Anurag Chouhan6d760662016-02-20 16:05:43 +05302168 (QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302169 pe_session->peSessionId, qdf_status));
Naveen Rawat296a5182017-09-25 14:02:48 -07002170
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302171 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002172 pe_err("Failed to send Association Request (%X)!",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302173 qdf_status);
Abhishek Singhdd2cb572017-08-11 11:10:19 +05302174 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_ASSOC_ACK_EVENT,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07002175 pe_session, SENT_FAIL, QDF_STATUS_E_FAILURE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002176 /* Pkt will be freed up by the callback */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002177 }
Vignesh Viswanathandada7932018-09-18 12:57:55 +05302178free_mbo_ie:
2179 if (mbo_ie)
2180 qdf_mem_free(mbo_ie);
2181
yeshwanth sriram guntuka07831012017-06-30 12:26:57 +05302182end:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002183 /* Free up buffer allocated for mlm_assoc_req */
Pragaspathi Thilagaraj54018e02019-04-25 01:32:17 +05302184 qdf_mem_free(adaptive_11r_ie);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302185 qdf_mem_free(mlm_assoc_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002186 mlm_assoc_req = NULL;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302187 qdf_mem_free(frm);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002188 return;
2189}
2190
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002191/**
Krunal Sonid2136c72018-06-01 17:26:39 -07002192 * lim_addba_rsp_tx_complete_cnf() - Confirmation for add BA response OTA
2193 * @context: pointer to global mac
2194 * @buf: buffer which is nothing but entire ADD BA frame
2195 * @tx_complete : Sent status
2196 * @params; tx completion params
2197 *
2198 * Return: This returns QDF_STATUS
2199 */
2200static QDF_STATUS lim_addba_rsp_tx_complete_cnf(void *context,
2201 qdf_nbuf_t buf,
2202 uint32_t tx_complete,
2203 void *params)
2204{
Jeff Johnson9320c1e2018-12-02 13:09:20 -08002205 struct mac_context *mac_ctx = (struct mac_context *)context;
Krunal Sonid2136c72018-06-01 17:26:39 -07002206 tSirMacMgmtHdr *mac_hdr;
2207 tDot11faddba_rsp rsp;
2208 void *soc = cds_get_context(QDF_MODULE_ID_SOC);
2209 void *pdev = cds_get_context(QDF_MODULE_ID_TXRX);
2210 uint8_t peer_id;
2211 void *peer;
2212 uint32_t frame_len;
2213 QDF_STATUS status;
2214 uint8_t *data;
2215
2216 if (tx_complete == WMI_MGMT_TX_COMP_TYPE_COMPLETE_OK)
2217 pe_debug("Add ba response successfully sent");
2218 else
2219 pe_debug("Fail to send add ba response");
2220
2221 if (!buf) {
2222 pe_err("Addba response frame buffer is NULL");
2223 return QDF_STATUS_E_FAILURE;
2224 }
2225
2226 data = qdf_nbuf_data(buf);
2227
2228 if (!data) {
2229 pe_err("Addba response frame is NULL");
2230 return QDF_STATUS_E_FAILURE;
2231 }
2232
2233 mac_hdr = (tSirMacMgmtHdr *)data;
2234 qdf_mem_zero((void *)&rsp, sizeof(tDot11faddba_rsp));
2235 frame_len = sizeof(rsp);
2236 status = dot11f_unpack_addba_rsp(mac_ctx, (uint8_t *)data +
2237 sizeof(*mac_hdr), frame_len,
2238 &rsp, false);
2239
2240 if (DOT11F_FAILED(status)) {
2241 pe_err("Failed to unpack and parse (0x%08x, %d bytes)",
2242 status, frame_len);
2243 goto error;
2244 }
2245
2246 peer = cdp_peer_get_ref_by_addr(soc, pdev, mac_hdr->da, &peer_id,
2247 PEER_DEBUG_ID_WMA_ADDBA_REQ);
2248 if (!peer) {
2249 pe_debug("no PEER found for mac_addr:%pM", mac_hdr->da);
2250 goto error;
2251 }
2252 cdp_addba_resp_tx_completion(soc, peer, rsp.addba_param_set.tid,
2253 tx_complete);
2254 cdp_peer_release_ref(soc, peer, PEER_DEBUG_ID_WMA_ADDBA_REQ);
2255error:
2256 if (buf)
2257 qdf_nbuf_free(buf);
2258
2259 return QDF_STATUS_SUCCESS;
2260}
2261
2262/**
Abhishek Singh7d3bc3e2016-02-03 17:45:01 +05302263 * lim_auth_tx_complete_cnf()- Confirmation for auth sent over the air
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05302264 * @context: pointer to global mac
2265 * @buf: buffer
Abhishek Singh7d3bc3e2016-02-03 17:45:01 +05302266 * @tx_complete : Sent status
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05302267 * @params; tx completion params
Abhishek Singh7d3bc3e2016-02-03 17:45:01 +05302268 *
2269 * Return: This returns QDF_STATUS
2270 */
2271
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05302272static QDF_STATUS lim_auth_tx_complete_cnf(void *context,
2273 qdf_nbuf_t buf,
2274 uint32_t tx_complete,
2275 void *params)
Abhishek Singh7d3bc3e2016-02-03 17:45:01 +05302276{
Jeff Johnson9320c1e2018-12-02 13:09:20 -08002277 struct mac_context *mac_ctx = (struct mac_context *)context;
Abhishek Singhdd2cb572017-08-11 11:10:19 +05302278 uint16_t auth_ack_status;
2279 uint16_t reason_code;
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05302280
Naveen Rawat684e8b12017-09-20 15:54:44 -07002281 pe_debug("tx_complete = %d %s", tx_complete,
Zhu Jianmin5d8e3fe2018-01-04 16:16:20 +08002282 (tx_complete == WMI_MGMT_TX_COMP_TYPE_COMPLETE_OK) ?
2283 "success" : "fail");
2284 if (tx_complete == WMI_MGMT_TX_COMP_TYPE_COMPLETE_OK) {
Abhishek Singh7d3bc3e2016-02-03 17:45:01 +05302285 mac_ctx->auth_ack_status = LIM_AUTH_ACK_RCD_SUCCESS;
Abhishek Singhdd2cb572017-08-11 11:10:19 +05302286 auth_ack_status = ACKED;
Jeff Johnson0301ecb2018-06-29 09:36:23 -07002287 reason_code = QDF_STATUS_SUCCESS;
Abhishek Singh7d3bc3e2016-02-03 17:45:01 +05302288 /* 'Change' timer for future activations */
2289 lim_deactivate_and_change_timer(mac_ctx, eLIM_AUTH_RETRY_TIMER);
2290 } else {
2291 mac_ctx->auth_ack_status = LIM_AUTH_ACK_RCD_FAILURE;
Abhishek Singhdd2cb572017-08-11 11:10:19 +05302292 auth_ack_status = NOT_ACKED;
Jeff Johnson0301ecb2018-06-29 09:36:23 -07002293 reason_code = QDF_STATUS_E_FAILURE;
Abhishek Singh7d3bc3e2016-02-03 17:45:01 +05302294 }
Himanshu Agarwal8b472bc2017-01-20 20:49:41 +05302295
2296 if (buf)
2297 qdf_nbuf_free(buf);
2298
Abhishek Singhdd2cb572017-08-11 11:10:19 +05302299 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_AUTH_ACK_EVENT,
2300 NULL, auth_ack_status, reason_code);
2301
Abhishek Singh7d3bc3e2016-02-03 17:45:01 +05302302 return QDF_STATUS_SUCCESS;
2303}
2304
2305/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002306 * lim_send_auth_mgmt_frame() - Send an Authentication frame
2307 *
2308 * @mac_ctx: Pointer to Global MAC structure
2309 * @auth_frame: Pointer to Authentication frame structure
2310 * @peer_addr: MAC address of destination peer
2311 * @wep_bit: wep bit in frame control for Authentication frame3
2312 * @session: PE session information
2313 *
2314 * This function is called by lim_process_mlm_messages(). Authentication frame
2315 * is formatted and sent when this function is called.
2316 *
2317 * Return: void
2318 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002319void
Jeff Johnson9320c1e2018-12-02 13:09:20 -08002320lim_send_auth_mgmt_frame(struct mac_context *mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002321 tpSirMacAuthFrameBody auth_frame,
2322 tSirMacAddr peer_addr,
yeshwanth sriram guntuka343a3f22017-07-27 18:30:18 +05302323 uint8_t wep_challenge_len,
Jeff Johnsona7815652018-11-18 22:58:30 -08002324 struct pe_session *session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002325{
2326 uint8_t *frame, *body;
2327 uint32_t frame_len = 0, body_len = 0;
2328 tpSirMacMgmtHdr mac_hdr;
2329 void *packet;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302330 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002331 uint8_t tx_flag = 0;
2332 uint8_t sme_sessionid = 0;
2333 uint16_t ft_ies_length = 0;
Krishna Kumaar Natarajan0517c602017-06-02 14:58:21 -07002334 bool challenge_req = false;
Naveen Rawat296a5182017-09-25 14:02:48 -07002335 enum rateid min_rid = RATEID_DEFAULT;
Rajasekaran Kalidoss7152a352018-11-19 09:58:35 +05302336 uint16_t ch_freq_tx_frame = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002337
Jeff Johnson8e9530b2019-03-18 13:41:42 -07002338 if (!session) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002339 pe_err("Error: psession Entry is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002340 return;
2341 }
2342
2343 sme_sessionid = session->smeSessionId;
2344
yeshwanth sriram guntuka343a3f22017-07-27 18:30:18 +05302345 if (wep_challenge_len) {
Krishna Kumaar Natarajan7e6a23c2016-04-05 14:45:24 -07002346 /*
2347 * Auth frame3 to be sent with encrypted framebody
2348 *
2349 * Allocate buffer for Authenticaton frame of size
2350 * equal to management frame header length plus 2 bytes
2351 * each for auth algorithm number, transaction number,
2352 * status code, 128 bytes for challenge text and
2353 * 4 bytes each for IV & ICV.
2354 */
Srinivas Girigowdacb7b8b82019-04-10 14:27:47 -07002355 pe_debug("Sending encrypted auth frame to " QDF_MAC_ADDR_STR,
Srinivas Girigowda34fbba02019-04-08 12:07:44 -07002356 QDF_MAC_ADDR_ARRAY(peer_addr));
Krishna Kumaar Natarajan7e6a23c2016-04-05 14:45:24 -07002357
yeshwanth sriram guntuka343a3f22017-07-27 18:30:18 +05302358 body_len = wep_challenge_len + LIM_ENCR_AUTH_INFO_LEN;
Krishna Kumaar Natarajan0517c602017-06-02 14:58:21 -07002359 frame_len = sizeof(tSirMacMgmtHdr) + body_len;
Krishna Kumaar Natarajan7e6a23c2016-04-05 14:45:24 -07002360
2361 goto alloc_packet;
2362 }
2363
Tushnim Bhattacharyya332b74c2018-08-10 10:55:51 -07002364 pe_debug("Sending Auth seq# %d status %d (%d) to "
Srinivas Girigowdacb7b8b82019-04-10 14:27:47 -07002365 QDF_MAC_ADDR_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002366 auth_frame->authTransactionSeqNumber,
2367 auth_frame->authStatusCode,
2368 (auth_frame->authStatusCode == eSIR_MAC_SUCCESS_STATUS),
Srinivas Girigowda34fbba02019-04-08 12:07:44 -07002369 QDF_MAC_ADDR_ARRAY(peer_addr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002370
2371 switch (auth_frame->authTransactionSeqNumber) {
2372 case SIR_MAC_AUTH_FRAME_1:
2373 /*
2374 * Allocate buffer for Authenticaton frame of size
2375 * equal to management frame header length plus 2 bytes
2376 * each for auth algorithm number, transaction number
2377 * and status code.
2378 */
2379
Krishna Kumaar Natarajan0517c602017-06-02 14:58:21 -07002380 body_len = SIR_MAC_AUTH_FRAME_INFO_LEN;
2381 frame_len = sizeof(tSirMacMgmtHdr) + body_len;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002382
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +05302383 frame_len += lim_create_fils_auth_data(mac_ctx,
2384 auth_frame, session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002385 if (auth_frame->authAlgoNumber == eSIR_FT_AUTH) {
Jeff Johnson8e9530b2019-03-18 13:41:42 -07002386 if (session->ftPEContext.pFTPreAuthReq &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002387 0 != session->ftPEContext.pFTPreAuthReq->
2388 ft_ies_length) {
2389 ft_ies_length = session->ftPEContext.
2390 pFTPreAuthReq->ft_ies_length;
2391 frame_len += ft_ies_length;
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002392 pe_debug("Auth frame, FTIES length added=%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002393 ft_ies_length);
2394 } else {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002395 pe_debug("Auth frame, Does not contain FTIES!");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002396 frame_len += (2 + SIR_MDIE_SIZE);
2397 }
2398 }
Pragaspathi Thilagaraj239883a2019-03-08 00:33:50 +05302399
2400 /* include MDIE in FILS authentication frame */
Pragaspathi Thilagaraj64ae59d2019-06-22 13:00:34 +05302401 if (session->lim_join_req &&
2402 session->lim_join_req->is11Rconnection &&
Pragaspathi Thilagaraj239883a2019-03-08 00:33:50 +05302403 auth_frame->authAlgoNumber == SIR_FILS_SK_WITHOUT_PFS &&
Pragaspathi Thilagaraj64ae59d2019-06-22 13:00:34 +05302404 session->lim_join_req->bssDescription.mdiePresent)
Pragaspathi Thilagaraj239883a2019-03-08 00:33:50 +05302405 frame_len += (2 + SIR_MDIE_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002406 break;
2407
2408 case SIR_MAC_AUTH_FRAME_2:
2409 if ((auth_frame->authAlgoNumber == eSIR_OPEN_SYSTEM) ||
2410 ((auth_frame->authAlgoNumber == eSIR_SHARED_KEY) &&
2411 (auth_frame->authStatusCode !=
2412 eSIR_MAC_SUCCESS_STATUS))) {
2413 /*
2414 * Allocate buffer for Authenticaton frame of size
2415 * equal to management frame header length plus
2416 * 2 bytes each for auth algorithm number,
2417 * transaction number and status code.
2418 */
2419
Krishna Kumaar Natarajan0517c602017-06-02 14:58:21 -07002420 body_len = SIR_MAC_AUTH_FRAME_INFO_LEN;
2421 frame_len = sizeof(tSirMacMgmtHdr) + body_len;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002422 } else {
2423 /*
2424 * Shared Key algorithm with challenge text
2425 * to be sent.
2426 *
2427 * Allocate buffer for Authenticaton frame of size
2428 * equal to management frame header length plus
2429 * 2 bytes each for auth algorithm number,
2430 * transaction number, status code and 128 bytes
2431 * for challenge text.
2432 */
2433
Krishna Kumaar Natarajan0517c602017-06-02 14:58:21 -07002434 challenge_req = true;
2435 body_len = SIR_MAC_AUTH_FRAME_INFO_LEN +
yeshwanth sriram guntuka5c71a292017-08-24 15:51:19 +05302436 SIR_MAC_SAP_AUTH_CHALLENGE_LENGTH +
2437 SIR_MAC_CHALLENGE_ID_LEN;
Krishna Kumaar Natarajan0517c602017-06-02 14:58:21 -07002438 frame_len = sizeof(tSirMacMgmtHdr) + body_len;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002439 }
2440 break;
2441
2442 case SIR_MAC_AUTH_FRAME_3:
Krishna Kumaar Natarajan7e6a23c2016-04-05 14:45:24 -07002443 /*
2444 * Auth frame3 to be sent without encrypted framebody
2445 *
2446 * Allocate buffer for Authenticaton frame of size equal
2447 * to management frame header length plus 2 bytes each
2448 * for auth algorithm number, transaction number and
2449 * status code.
2450 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002451
Krishna Kumaar Natarajan0517c602017-06-02 14:58:21 -07002452 body_len = SIR_MAC_AUTH_FRAME_INFO_LEN;
2453 frame_len = sizeof(tSirMacMgmtHdr) + body_len;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002454 break;
2455
2456 case SIR_MAC_AUTH_FRAME_4:
2457 /*
2458 * Allocate buffer for Authenticaton frame of size equal
2459 * to management frame header length plus 2 bytes each
2460 * for auth algorithm number, transaction number and
2461 * status code.
2462 */
2463
Krishna Kumaar Natarajan0517c602017-06-02 14:58:21 -07002464 body_len = SIR_MAC_AUTH_FRAME_INFO_LEN;
2465 frame_len = sizeof(tSirMacMgmtHdr) + body_len;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002466
2467 break;
Krishna Kumaar Natarajan7e6a23c2016-04-05 14:45:24 -07002468 default:
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002469 pe_err("Invalid auth transaction seq num");
Krishna Kumaar Natarajan7e6a23c2016-04-05 14:45:24 -07002470 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002471 } /* switch (auth_frame->authTransactionSeqNumber) */
2472
Krishna Kumaar Natarajan7e6a23c2016-04-05 14:45:24 -07002473alloc_packet:
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302474 qdf_status = cds_packet_alloc((uint16_t) frame_len, (void **)&frame,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002475 (void **)&packet);
2476
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302477 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002478 pe_err("call to bufAlloc failed for AUTH frame");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002479 return;
2480 }
2481
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302482 qdf_mem_zero(frame, frame_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002483
2484 /* Prepare BD */
2485 lim_populate_mac_header(mac_ctx, frame, SIR_MAC_MGMT_FRAME,
Pragaspathi Thilagaraj7fb14222019-06-17 23:26:58 +05302486 SIR_MAC_MGMT_AUTH, peer_addr, session->self_mac_addr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002487 mac_hdr = (tpSirMacMgmtHdr) frame;
yeshwanth sriram guntuka343a3f22017-07-27 18:30:18 +05302488 if (wep_challenge_len)
2489 mac_hdr->fc.wep = LIM_WEP_IN_FC;
2490 else
2491 mac_hdr->fc.wep = LIM_NO_WEP_IN_FC;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002492
2493 /* Prepare BSSId */
Rajeev Kumarcf835a02016-04-15 15:01:31 -07002494 if (LIM_IS_AP_ROLE(session))
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302495 qdf_mem_copy((uint8_t *) mac_hdr->bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002496 (uint8_t *) session->bssId,
2497 sizeof(tSirMacAddr));
2498
2499 /* Prepare Authentication frame body */
2500 body = frame + sizeof(tSirMacMgmtHdr);
2501
yeshwanth sriram guntuka343a3f22017-07-27 18:30:18 +05302502 if (wep_challenge_len) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302503 qdf_mem_copy(body, (uint8_t *) auth_frame, body_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002504
Srinivas Girigowdacb7b8b82019-04-10 14:27:47 -07002505 pe_debug("Sending Auth seq# 3 to " QDF_MAC_ADDR_STR,
Srinivas Girigowda34fbba02019-04-08 12:07:44 -07002506 QDF_MAC_ADDR_ARRAY(mac_hdr->da));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002507
2508 } else {
2509 *((uint16_t *) (body)) =
2510 sir_swap_u16if_needed(auth_frame->authAlgoNumber);
2511 body += sizeof(uint16_t);
2512 body_len -= sizeof(uint16_t);
2513
2514 *((uint16_t *) (body)) =
2515 sir_swap_u16if_needed(
2516 auth_frame->authTransactionSeqNumber);
2517 body += sizeof(uint16_t);
2518 body_len -= sizeof(uint16_t);
2519
2520 *((uint16_t *) (body)) =
2521 sir_swap_u16if_needed(auth_frame->authStatusCode);
2522 body += sizeof(uint16_t);
2523 body_len -= sizeof(uint16_t);
Krishna Kumaar Natarajan0517c602017-06-02 14:58:21 -07002524
2525 if (challenge_req) {
2526 if (body_len < SIR_MAC_AUTH_CHALLENGE_BODY_LEN) {
Himanshu Agarwalc422ca72017-09-19 11:07:36 +05302527 /* copy challenge IE id, len, challenge text */
2528 *body = auth_frame->type;
2529 body++;
2530 body_len -= sizeof(uint8_t);
2531 *body = auth_frame->length;
2532 body++;
2533 body_len -= sizeof(uint8_t);
2534 qdf_mem_copy(body, auth_frame->challengeText,
Krishna Kumaar Natarajan0517c602017-06-02 14:58:21 -07002535 body_len);
2536 pe_err("Incomplete challenge info: length: %d, expected: %d",
2537 body_len,
2538 SIR_MAC_AUTH_CHALLENGE_BODY_LEN);
2539 body += body_len;
2540 body_len = 0;
2541 } else {
2542 /* copy challenge IE id, len, challenge text */
2543 *body = auth_frame->type;
2544 body++;
2545 *body = auth_frame->length;
2546 body++;
2547 qdf_mem_copy(body, auth_frame->challengeText,
yeshwanth sriram guntuka5c71a292017-08-24 15:51:19 +05302548 SIR_MAC_SAP_AUTH_CHALLENGE_LENGTH);
2549 body += SIR_MAC_SAP_AUTH_CHALLENGE_LENGTH;
Krishna Kumaar Natarajan0517c602017-06-02 14:58:21 -07002550
yeshwanth sriram guntuka5c71a292017-08-24 15:51:19 +05302551 body_len -= SIR_MAC_SAP_AUTH_CHALLENGE_LENGTH +
2552 SIR_MAC_CHALLENGE_ID_LEN;
Krishna Kumaar Natarajan0517c602017-06-02 14:58:21 -07002553 }
2554 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002555
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002556 if ((auth_frame->authAlgoNumber == eSIR_FT_AUTH) &&
2557 (auth_frame->authTransactionSeqNumber ==
2558 SIR_MAC_AUTH_FRAME_1) &&
Jeff Johnson8e9530b2019-03-18 13:41:42 -07002559 (session->ftPEContext.pFTPreAuthReq)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002560
2561 if (ft_ies_length > 0) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302562 qdf_mem_copy(body,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002563 session->ftPEContext.
2564 pFTPreAuthReq->ft_ies,
2565 ft_ies_length);
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002566 pe_debug("Auth1 Frame FTIE is: ");
Srinivas Girigowdab896a562017-03-16 17:41:26 -07002567 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_PE,
2568 QDF_TRACE_LEVEL_DEBUG,
2569 (uint8_t *) body,
2570 ft_ies_length);
Jeff Johnson8e9530b2019-03-18 13:41:42 -07002571 } else if (session->ftPEContext.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002572 pFTPreAuthReq->pbssDescription) {
2573 /* MDID attr is 54 */
Srinivas Girigowda61771262019-04-01 11:55:19 -07002574 *body = WLAN_ELEMID_MOBILITY_DOMAIN;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002575 body++;
2576 *body = SIR_MDIE_SIZE;
2577 body++;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302578 qdf_mem_copy(body,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002579 &session->ftPEContext.pFTPreAuthReq->
2580 pbssDescription->mdie[0],
2581 SIR_MDIE_SIZE);
2582 }
Pragaspathi Thilagaraj239883a2019-03-08 00:33:50 +05302583 } else if ((auth_frame->authAlgoNumber ==
2584 SIR_FILS_SK_WITHOUT_PFS) &&
2585 (auth_frame->authTransactionSeqNumber ==
2586 SIR_MAC_AUTH_FRAME_1)) {
2587 pe_debug("FILS: appending fils Auth data");
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +05302588 lim_add_fils_data_to_auth_frame(session, body);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002589 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002590
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002591 pe_debug("*** Sending Auth seq# %d status %d (%d) to "
Srinivas Girigowdacb7b8b82019-04-10 14:27:47 -07002592 QDF_MAC_ADDR_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002593 auth_frame->authTransactionSeqNumber,
2594 auth_frame->authStatusCode,
2595 (auth_frame->authStatusCode ==
2596 eSIR_MAC_SUCCESS_STATUS),
Srinivas Girigowda34fbba02019-04-08 12:07:44 -07002597 QDF_MAC_ADDR_ARRAY(mac_hdr->da));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002598 }
Srinivas Girigowdab896a562017-03-16 17:41:26 -07002599 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_PE,
2600 QDF_TRACE_LEVEL_DEBUG,
2601 frame, frame_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002602
Jeff Johnson8e9530b2019-03-18 13:41:42 -07002603 if ((session->ftPEContext.pFTPreAuthReq) &&
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08002604 (BAND_5G == lim_get_rf_band(
Deepthi Gowri1de51e32016-09-01 15:47:28 +05302605 session->ftPEContext.pFTPreAuthReq->preAuthchannelNum)))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002606 tx_flag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
Pragaspathi Thilagaraje64714a2019-05-23 00:46:25 +05302607 else if ((BAND_5G == lim_get_rf_band(session->currentOperChannel)) ||
2608 (session->opmode == QDF_P2P_CLIENT_MODE) ||
2609 (session->opmode == QDF_P2P_GO_MODE))
Deepthi Gowri1de51e32016-09-01 15:47:28 +05302610 tx_flag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002611
Pragaspathi Thilagaraje64714a2019-05-23 00:46:25 +05302612 if (session->opmode == QDF_P2P_CLIENT_MODE ||
2613 session->opmode == QDF_STA_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002614 tx_flag |= HAL_USE_PEER_STA_REQUESTED_MASK;
2615
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302616 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002617 session->peSessionId, mac_hdr->fc.subType));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002618
Abhishek Singhdd2cb572017-08-11 11:10:19 +05302619 mac_ctx->auth_ack_status = LIM_AUTH_ACK_NOT_RCD;
Naveen Rawat296a5182017-09-25 14:02:48 -07002620 min_rid = lim_get_min_session_txrate(session);
Krunal Sonic65fc492018-03-09 15:53:28 -08002621 lim_diag_mgmt_tx_event_report(mac_ctx, mac_hdr,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07002622 session, QDF_STATUS_SUCCESS, QDF_STATUS_SUCCESS);
Rajasekaran Kalidoss7152a352018-11-19 09:58:35 +05302623
Jeff Johnson8e9530b2019-03-18 13:41:42 -07002624 if (session->ftPEContext.pFTPreAuthReq)
Rajasekaran Kalidoss7152a352018-11-19 09:58:35 +05302625 ch_freq_tx_frame = cds_chan_to_freq(
2626 session->ftPEContext.pFTPreAuthReq->preAuthchannelNum);
2627
Abhishek Singhdd2cb572017-08-11 11:10:19 +05302628 qdf_status = wma_tx_frameWithTxComplete(mac_ctx, packet,
2629 (uint16_t)frame_len,
2630 TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS,
2631 7, lim_tx_complete, frame,
2632 lim_auth_tx_complete_cnf,
Rajasekaran Kalidoss7152a352018-11-19 09:58:35 +05302633 tx_flag, sme_sessionid, false,
2634 ch_freq_tx_frame, min_rid);
Abhishek Singhdd2cb572017-08-11 11:10:19 +05302635 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
2636 session->peSessionId, qdf_status));
2637 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
2638 pe_err("*** Could not send Auth frame, retCode=%X ***",
2639 qdf_status);
2640 mac_ctx->auth_ack_status = LIM_AUTH_ACK_RCD_FAILURE;
2641 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_AUTH_ACK_EVENT,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07002642 session, SENT_FAIL, QDF_STATUS_E_FAILURE);
Abhishek Singhdd2cb572017-08-11 11:10:19 +05302643 /* Pkt will be freed up by the callback */
Abhishek Singh7d3bc3e2016-02-03 17:45:01 +05302644 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002645 return;
2646}
2647
Jeff Johnson9320c1e2018-12-02 13:09:20 -08002648QDF_STATUS lim_send_deauth_cnf(struct mac_context *mac_ctx)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002649{
2650 uint16_t aid;
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002651 tpDphHashNode sta_ds;
2652 tLimMlmDeauthReq *deauth_req;
2653 tLimMlmDeauthCnf deauth_cnf;
Jeff Johnsona7815652018-11-18 22:58:30 -08002654 struct pe_session *session_entry;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002655
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002656 deauth_req = mac_ctx->lim.limDisassocDeauthCnfReq.pMlmDeauthReq;
2657 if (deauth_req) {
2658 if (tx_timer_running(
2659 &mac_ctx->lim.limTimers.gLimDeauthAckTimer))
2660 lim_deactivate_and_change_timer(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002661 eLIM_DEAUTH_ACK_TIMER);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002662
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002663 session_entry = pe_find_session_by_session_id(mac_ctx,
2664 deauth_req->sessionId);
Jeff Johnson8e9530b2019-03-18 13:41:42 -07002665 if (!session_entry) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002666 pe_err("session does not exist for given sessionId");
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002667 deauth_cnf.resultCode =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002668 eSIR_SME_INVALID_PARAMETERS;
2669 goto end;
2670 }
2671
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002672 sta_ds =
2673 dph_lookup_hash_entry(mac_ctx,
2674 deauth_req->peer_macaddr.bytes,
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002675 &aid,
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002676 &session_entry->dph.dphHashTable);
Jeff Johnson8e9530b2019-03-18 13:41:42 -07002677 if (!sta_ds) {
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002678 deauth_cnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002679 goto end;
2680 }
2681
2682 /* / Receive path cleanup with dummy packet */
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002683 lim_ft_cleanup_pre_auth_info(mac_ctx, session_entry);
2684 lim_cleanup_rx_path(mac_ctx, sta_ds, session_entry);
2685 if ((session_entry->limSystemRole == eLIM_STA_ROLE) &&
2686 (
Abhishek Singhe0680852015-12-16 14:28:48 +05302687#ifdef FEATURE_WLAN_ESE
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002688 (session_entry->isESEconnection) ||
Abhishek Singhe0680852015-12-16 14:28:48 +05302689#endif
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002690 (session_entry->isFastRoamIniFeatureEnabled) ||
2691 (session_entry->is11Rconnection))) {
Jeff Johnson11bd4f32017-09-18 08:15:17 -07002692 pe_debug("FT Preauth (%pK,%d) Deauth rc %d src = %d",
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002693 session_entry,
2694 session_entry->peSessionId,
2695 deauth_req->reasonCode,
2696 deauth_req->deauthTrigger);
2697 lim_ft_cleanup(mac_ctx, session_entry);
Deepak Dhamdhere262d95a2016-01-10 16:36:53 -08002698 } else {
Deepak Dhamdhere262d95a2016-01-10 16:36:53 -08002699#ifdef FEATURE_WLAN_ESE
Nirav Shahf359dd22019-02-20 10:34:28 +05302700 pe_debug("No FT Preauth Session Cleanup in role %d"
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002701 " isESE %d"
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002702 " isLFR %d"
2703 " is11r %d, Deauth reason %d Trigger = %d",
2704 session_entry->limSystemRole,
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002705 session_entry->isESEconnection,
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002706 session_entry->isFastRoamIniFeatureEnabled,
2707 session_entry->is11Rconnection,
2708 deauth_req->reasonCode,
2709 deauth_req->deauthTrigger);
Nirav Shahf359dd22019-02-20 10:34:28 +05302710#else
2711 pe_debug("No FT Preauth Session Cleanup in role %d"
2712 " isLFR %d"
2713 " is11r %d, Deauth reason %d Trigger = %d",
2714 session_entry->limSystemRole,
2715 session_entry->isFastRoamIniFeatureEnabled,
2716 session_entry->is11Rconnection,
2717 deauth_req->reasonCode,
2718 deauth_req->deauthTrigger);
2719#endif
Deepak Dhamdhere262d95a2016-01-10 16:36:53 -08002720 }
2721 /* Free up buffer allocated for mlmDeauthReq */
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002722 qdf_mem_free(deauth_req);
2723 mac_ctx->lim.limDisassocDeauthCnfReq.pMlmDeauthReq = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002724 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302725 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002726end:
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002727 qdf_copy_macaddr(&deauth_cnf.peer_macaddr,
2728 &deauth_req->peer_macaddr);
2729 deauth_cnf.deauthTrigger = deauth_req->deauthTrigger;
2730 deauth_cnf.aid = deauth_req->aid;
2731 deauth_cnf.sessionId = deauth_req->sessionId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002732
2733 /* Free up buffer allocated */
2734 /* for mlmDeauthReq */
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002735 qdf_mem_free(deauth_req);
2736 mac_ctx->lim.limDisassocDeauthCnfReq.pMlmDeauthReq = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002737
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002738 lim_post_sme_message(mac_ctx,
2739 LIM_MLM_DEAUTH_CNF, (uint32_t *) &deauth_cnf);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302740 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002741}
2742
2743/**
2744 * lim_send_disassoc_cnf() - Send disassoc confirmation to SME
2745 *
2746 * @mac_ctx: Handle to MAC context
2747 *
2748 * Sends disassoc confirmation to SME. Removes disassoc request stored
2749 * in lim.
2750 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302751 * Return: QDF_STATUS_SUCCESS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002752 */
2753
Jeff Johnson9320c1e2018-12-02 13:09:20 -08002754QDF_STATUS lim_send_disassoc_cnf(struct mac_context *mac_ctx)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002755{
2756 uint16_t aid;
2757 tpDphHashNode sta_ds;
2758 tLimMlmDisassocCnf disassoc_cnf;
Jeff Johnsona7815652018-11-18 22:58:30 -08002759 struct pe_session *pe_session;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002760 tLimMlmDisassocReq *disassoc_req;
2761
2762 disassoc_req = mac_ctx->lim.limDisassocDeauthCnfReq.pMlmDisassocReq;
2763 if (disassoc_req) {
2764 if (tx_timer_running(
2765 &mac_ctx->lim.limTimers.gLimDisassocAckTimer))
2766 lim_deactivate_and_change_timer(mac_ctx,
2767 eLIM_DISASSOC_ACK_TIMER);
2768
2769 pe_session = pe_find_session_by_session_id(
2770 mac_ctx, disassoc_req->sessionId);
Jeff Johnson8e9530b2019-03-18 13:41:42 -07002771 if (!pe_session) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002772 pe_err("No session for given sessionId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002773 disassoc_cnf.resultCode =
2774 eSIR_SME_INVALID_PARAMETERS;
2775 goto end;
2776 }
2777
2778 sta_ds = dph_lookup_hash_entry(mac_ctx,
Srinivas Girigowdadd3c5132016-01-05 19:41:27 -08002779 disassoc_req->peer_macaddr.bytes, &aid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002780 &pe_session->dph.dphHashTable);
Jeff Johnson8e9530b2019-03-18 13:41:42 -07002781 if (!sta_ds) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002782 pe_err("StaDs Null");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002783 disassoc_cnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
2784 goto end;
2785 }
2786 /* Receive path cleanup with dummy packet */
Jeff Johnson0301ecb2018-06-29 09:36:23 -07002787 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002788 lim_cleanup_rx_path(mac_ctx, sta_ds, pe_session)) {
2789 disassoc_cnf.resultCode =
2790 eSIR_SME_RESOURCES_UNAVAILABLE;
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002791 pe_err("cleanup_rx_path error");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002792 goto end;
2793 }
Deepak Dhamdhere57c95ff2016-09-30 16:44:44 -07002794 if (LIM_IS_STA_ROLE(pe_session) &&
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002795 (disassoc_req->reasonCode !=
2796 eSIR_MAC_DISASSOC_DUE_TO_FTHANDOFF_REASON)) {
Jeff Johnson11bd4f32017-09-18 08:15:17 -07002797 pe_debug("FT Preauth Session (%pK %d) Clean up",
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002798 pe_session, pe_session->peSessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002799
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002800 /* Delete FT session if there exists one */
2801 lim_ft_cleanup_pre_auth_info(mac_ctx, pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002802 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002803 /* Free up buffer allocated for mlmDisassocReq */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302804 qdf_mem_free(disassoc_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002805 mac_ctx->lim.limDisassocDeauthCnfReq.pMlmDisassocReq = NULL;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302806 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002807 } else {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302808 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002809 }
2810end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302811 qdf_mem_copy((uint8_t *) &disassoc_cnf.peerMacAddr,
Srinivas Girigowdadd3c5132016-01-05 19:41:27 -08002812 (uint8_t *) disassoc_req->peer_macaddr.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05302813 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002814 disassoc_cnf.aid = disassoc_req->aid;
2815 disassoc_cnf.disassocTrigger = disassoc_req->disassocTrigger;
2816
2817 /* Update PE session ID */
2818 disassoc_cnf.sessionId = disassoc_req->sessionId;
2819
Jeff Johnson8e9530b2019-03-18 13:41:42 -07002820 if (disassoc_req) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002821 /* / Free up buffer allocated for mlmDisassocReq */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302822 qdf_mem_free(disassoc_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002823 mac_ctx->lim.limDisassocDeauthCnfReq.pMlmDisassocReq = NULL;
2824 }
2825
2826 lim_post_sme_message(mac_ctx, LIM_MLM_DISASSOC_CNF,
2827 (uint32_t *) &disassoc_cnf);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302828 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002829}
2830
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05302831QDF_STATUS lim_disassoc_tx_complete_cnf(void *context,
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002832 uint32_t tx_success,
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05302833 void *params)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002834{
Jeff Johnson9320c1e2018-12-02 13:09:20 -08002835 struct mac_context *max_ctx = (struct mac_context *)context;
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05302836
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002837 pe_debug("tx_success: %d", tx_success);
2838
2839 return lim_send_disassoc_cnf(max_ctx);
2840}
2841
2842static QDF_STATUS lim_disassoc_tx_complete_cnf_handler(void *context,
2843 qdf_nbuf_t buf,
2844 uint32_t tx_success,
2845 void *params)
2846{
Jeff Johnson9320c1e2018-12-02 13:09:20 -08002847 struct mac_context *max_ctx = (struct mac_context *)context;
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002848 QDF_STATUS status_code;
2849 struct scheduler_msg msg = {0};
2850
2851 pe_debug("tx_success: %d", tx_success);
Himanshu Agarwal8b472bc2017-01-20 20:49:41 +05302852
2853 if (buf)
2854 qdf_nbuf_free(buf);
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002855 msg.type = (uint16_t) WMA_DISASSOC_TX_COMP;
2856 msg.bodyptr = params;
2857 msg.bodyval = tx_success;
Himanshu Agarwal8b472bc2017-01-20 20:49:41 +05302858
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002859 status_code = lim_post_msg_high_priority(max_ctx, &msg);
2860 if (status_code != QDF_STATUS_SUCCESS)
2861 pe_err("posting message: %X to LIM failed, reason: %d",
2862 msg.type, status_code);
2863 return status_code;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002864}
2865
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05302866QDF_STATUS lim_deauth_tx_complete_cnf(void *context,
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002867 uint32_t tx_success,
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05302868 void *params)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002869{
Jeff Johnson9320c1e2018-12-02 13:09:20 -08002870 struct mac_context *mac_ctx = (struct mac_context *)context;
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05302871
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002872 pe_debug("tx_success: %d", tx_success);
2873
2874 return lim_send_deauth_cnf(mac_ctx);
2875}
2876
2877static QDF_STATUS lim_deauth_tx_complete_cnf_handler(void *context,
2878 qdf_nbuf_t buf,
2879 uint32_t tx_success,
2880 void *params)
2881{
Jeff Johnson9320c1e2018-12-02 13:09:20 -08002882 struct mac_context *mac_ctx = (struct mac_context *)context;
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002883 QDF_STATUS status_code;
2884 struct scheduler_msg msg = {0};
2885
2886 pe_debug("tx_success: %d", tx_success);
Himanshu Agarwal8b472bc2017-01-20 20:49:41 +05302887
2888 if (buf)
2889 qdf_nbuf_free(buf);
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002890 msg.type = (uint16_t) WMA_DEAUTH_TX_COMP;
2891 msg.bodyptr = params;
2892 msg.bodyval = tx_success;
Himanshu Agarwal8b472bc2017-01-20 20:49:41 +05302893
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002894 status_code = lim_post_msg_high_priority(mac_ctx, &msg);
2895 if (status_code != QDF_STATUS_SUCCESS)
2896 pe_err("posting message: %X to LIM failed, reason: %d",
2897 msg.type, status_code);
2898 return status_code;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002899}
2900
2901/**
Srinivas Dasarie2ee0942019-06-29 14:34:50 +05302902 * lim_append_ies_to_frame() - Append IEs to the frame
2903 *
2904 * @frame: Pointer to the frame buffer that needs to be populated
2905 * @frame_len: Pointer for current frame length
2906 * @ie: pointer for disconnect IEs
2907 *
2908 * This function is called by lim_send_disassoc_mgmt_frame and
2909 * lim_send_deauth_mgmt_frame APIs as part of disconnection.
2910 * Append IEs and update frame length.
2911 *
2912 * Return: None
2913 */
2914static void
2915lim_append_ies_to_frame(uint8_t *frame, uint32_t *frame_len,
2916 struct wlan_ies *ie)
2917{
2918 if (!ie || !ie->len || !ie->data)
2919 return;
2920 qdf_mem_copy(frame, ie->data, ie->len);
2921 *frame_len += ie->len;
2922 pe_debug("Appended IEs len: %u", ie->len);
2923}
2924
2925/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002926 * \brief This function is called to send Disassociate frame.
2927 *
2928 *
Jeff Johnson99f25042018-11-21 22:49:06 -08002929 * \param mac Pointer to Global MAC structure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002930 *
2931 * \param nReason Indicates the reason that need to be sent in
2932 * Disassociation frame
2933 *
2934 * \param peerMacAddr MAC address of the STA to which Disassociation frame is
2935 * sent
2936 *
2937 *
2938 */
2939
2940void
Jeff Johnson9320c1e2018-12-02 13:09:20 -08002941lim_send_disassoc_mgmt_frame(struct mac_context *mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002942 uint16_t nReason,
2943 tSirMacAddr peer,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08002944 struct pe_session *pe_session, bool waitForAck)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002945{
2946 tDot11fDisassociation frm;
2947 uint8_t *pFrame;
2948 tpSirMacMgmtHdr pMacHdr;
2949 uint32_t nBytes, nPayload, nStatus;
2950 void *pPacket;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302951 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002952 uint8_t txFlag = 0;
2953 uint32_t val = 0;
2954 uint8_t smeSessionId = 0;
Srinivas Dasarie2ee0942019-06-29 14:34:50 +05302955 struct wlan_ies *discon_ie;
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07002956
Jeff Johnson8e9530b2019-03-18 13:41:42 -07002957 if (!pe_session) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002958 return;
2959 }
2960
2961 /*
2962 * In case when cac timer is running for this SAP session then
2963 * avoid sending disassoc out. It is violation of dfs specification.
2964 */
Pragaspathi Thilagaraje64714a2019-05-23 00:46:25 +05302965 if (((pe_session->opmode == QDF_SAP_MODE) ||
2966 (pe_session->opmode == QDF_P2P_GO_MODE)) &&
Jeff Johnson99f25042018-11-21 22:49:06 -08002967 (true == mac->sap.SapDfsInfo.is_dfs_cac_timer_running)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302968 QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_INFO,
Pragaspathi Thilagaraje64714a2019-05-23 00:46:25 +05302969 FL("CAC timer is running, drop disassoc from going out"));
Abhishek Singh06522c52019-05-08 12:13:42 +05302970 if (waitForAck)
2971 lim_send_disassoc_cnf(mac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002972 return;
2973 }
Jeff Johnsonb5c13332018-12-03 09:54:51 -08002974 smeSessionId = pe_session->smeSessionId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002975
hangtian127c9532019-01-12 13:29:07 +08002976 qdf_mem_zero((uint8_t *) &frm, sizeof(frm));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002977
2978 frm.Reason.code = nReason;
2979
Jeff Johnson99f25042018-11-21 22:49:06 -08002980 nStatus = dot11f_get_packed_disassociation_size(mac, &frm, &nPayload);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002981 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002982 pe_err("Failed to calculate the packed size for a Disassociation (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002983 nStatus);
2984 /* We'll fall back on the worst case scenario: */
2985 nPayload = sizeof(tDot11fDisassociation);
2986 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002987 pe_warn("There were warnings while calculating the packed size for a Disassociation (0x%08x)",
2988 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002989 }
2990
2991 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
2992
Srinivas Dasarie2ee0942019-06-29 14:34:50 +05302993 discon_ie = mlme_get_self_disconnect_ies(pe_session->vdev);
2994 if (discon_ie && discon_ie->len)
2995 nBytes += discon_ie->len;
2996
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302997 qdf_status = cds_packet_alloc((uint16_t) nBytes, (void **)&pFrame,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002998 (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302999 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003000 pe_err("Failed to allocate %d bytes for a Disassociation",
3001 nBytes);
Abhishek Singh06522c52019-05-08 12:13:42 +05303002 if (waitForAck)
3003 lim_send_disassoc_cnf(mac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003004 return;
3005 }
3006 /* Paranoia: */
hangtian127c9532019-01-12 13:29:07 +08003007 qdf_mem_zero(pFrame, nBytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003008
3009 /* Next, we fill out the buffer descriptor: */
Jeff Johnson99f25042018-11-21 22:49:06 -08003010 lim_populate_mac_header(mac, pFrame, SIR_MAC_MGMT_FRAME,
Pragaspathi Thilagaraj7fb14222019-06-17 23:26:58 +05303011 SIR_MAC_MGMT_DISASSOC, peer, pe_session->self_mac_addr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003012 pMacHdr = (tpSirMacMgmtHdr) pFrame;
3013
3014 /* Prepare the BSSID */
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003015 sir_copy_mac_addr(pMacHdr->bssId, pe_session->bssId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003016
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003017 lim_set_protected_bit(mac, pe_session, peer, pMacHdr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003018
Jeff Johnson99f25042018-11-21 22:49:06 -08003019 nStatus = dot11f_pack_disassociation(mac, &frm, pFrame +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003020 sizeof(tSirMacMgmtHdr),
3021 nPayload, &nPayload);
3022 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003023 pe_err("Failed to pack a Disassociation (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003024 nStatus);
3025 cds_packet_free((void *)pPacket);
Abhishek Singh06522c52019-05-08 12:13:42 +05303026 if (waitForAck)
3027 lim_send_disassoc_cnf(mac);
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003028 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003029 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003030 pe_warn("There were warnings while packing a Disassociation (0x%08x)",
3031 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003032 }
3033
Srinivas Dasarie2ee0942019-06-29 14:34:50 +05303034 /* Copy disconnect IEs to the end of the frame */
3035 lim_append_ies_to_frame(pFrame + sizeof(tSirMacMgmtHdr) + nPayload,
3036 &nPayload, discon_ie);
3037 mlme_free_self_disconnect_ies(pe_session->vdev);
3038
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003039 pe_debug("***Sessionid %d Sending Disassociation frame with "
Srinivas Girigowdacb7b8b82019-04-10 14:27:47 -07003040 "reason %u and waitForAck %d to " QDF_MAC_ADDR_STR " ,From "
3041 QDF_MAC_ADDR_STR, pe_session->peSessionId, nReason,
Srinivas Girigowda34fbba02019-04-08 12:07:44 -07003042 waitForAck, QDF_MAC_ADDR_ARRAY(pMacHdr->da),
Pragaspathi Thilagaraj7fb14222019-06-17 23:26:58 +05303043 QDF_MAC_ADDR_ARRAY(pe_session->self_mac_addr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003044
Pragaspathi Thilagaraje64714a2019-05-23 00:46:25 +05303045 if ((BAND_5G == lim_get_rf_band(pe_session->currentOperChannel)) ||
3046 (pe_session->opmode == QDF_P2P_CLIENT_MODE) ||
3047 (pe_session->opmode == QDF_P2P_GO_MODE))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003048 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003049
Sushant Kaushik46556062015-12-02 16:57:47 +05303050 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003051
3052 if (waitForAck) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303053 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003054 pe_session->peSessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003055 pMacHdr->fc.subType));
Jeff Johnson99f25042018-11-21 22:49:06 -08003056 lim_diag_mgmt_tx_event_report(mac, pMacHdr,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003057 pe_session, QDF_STATUS_SUCCESS,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003058 QDF_STATUS_SUCCESS);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003059 /* Queue Disassociation frame in high priority WQ */
3060 /* get the duration from the request */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303061 qdf_status =
Jeff Johnson99f25042018-11-21 22:49:06 -08003062 wma_tx_frameWithTxComplete(mac, pPacket, (uint16_t) nBytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003063 TXRX_FRM_802_11_MGMT,
3064 ANI_TXDIR_TODS, 7, lim_tx_complete,
Liangwei Dongc0b2e332017-11-16 06:04:46 -05003065 pFrame, lim_disassoc_tx_complete_cnf_handler,
Naveen Rawat296a5182017-09-25 14:02:48 -07003066 txFlag, smeSessionId, false, 0,
3067 RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303068 MTRACE(qdf_trace
Anurag Chouhan6d760662016-02-20 16:05:43 +05303069 (QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003070 pe_session->peSessionId, qdf_status));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003071
3072 val = SYS_MS_TO_TICKS(LIM_DISASSOC_DEAUTH_ACK_TIMEOUT);
3073
3074 if (tx_timer_change
Jeff Johnson99f25042018-11-21 22:49:06 -08003075 (&mac->lim.limTimers.gLimDisassocAckTimer, val, 0)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003076 != TX_SUCCESS) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003077 pe_err("Unable to change Disassoc ack Timer val");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003078 return;
3079 } else if (TX_SUCCESS !=
Jeff Johnson99f25042018-11-21 22:49:06 -08003080 tx_timer_activate(&mac->lim.limTimers.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003081 gLimDisassocAckTimer)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003082 pe_err("Unable to activate Disassoc ack Timer");
Jeff Johnson99f25042018-11-21 22:49:06 -08003083 lim_deactivate_and_change_timer(mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003084 eLIM_DISASSOC_ACK_TIMER);
3085 return;
3086 }
3087 } else {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303088 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003089 pe_session->peSessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003090 pMacHdr->fc.subType));
Jeff Johnson99f25042018-11-21 22:49:06 -08003091 lim_diag_mgmt_tx_event_report(mac, pMacHdr,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003092 pe_session,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003093 QDF_STATUS_SUCCESS, QDF_STATUS_SUCCESS);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003094 /* Queue Disassociation frame in high priority WQ */
Jeff Johnson99f25042018-11-21 22:49:06 -08003095 qdf_status = wma_tx_frame(mac, pPacket, (uint16_t) nBytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003096 TXRX_FRM_802_11_MGMT,
3097 ANI_TXDIR_TODS,
3098 7,
3099 lim_tx_complete, pFrame, txFlag,
Naveen Rawat296a5182017-09-25 14:02:48 -07003100 smeSessionId, 0, RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303101 MTRACE(qdf_trace
Anurag Chouhan6d760662016-02-20 16:05:43 +05303102 (QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003103 pe_session->peSessionId, qdf_status));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303104 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003105 pe_err("Failed to send Disassociation (%X)!",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303106 qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003107 /* Pkt will be freed up by the callback */
3108 }
3109 }
3110} /* End lim_send_disassoc_mgmt_frame. */
3111
3112/**
3113 * \brief This function is called to send a Deauthenticate frame
3114 *
3115 *
Jeff Johnson99f25042018-11-21 22:49:06 -08003116 * \param mac Pointer to global MAC structure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003117 *
3118 * \param nReason Indicates the reason that need to be sent in the
3119 * Deauthenticate frame
3120 *
3121 * \param peeer address of the STA to which the frame is to be sent
3122 *
3123 *
3124 */
3125
3126void
Jeff Johnson9320c1e2018-12-02 13:09:20 -08003127lim_send_deauth_mgmt_frame(struct mac_context *mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003128 uint16_t nReason,
3129 tSirMacAddr peer,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003130 struct pe_session *pe_session, bool waitForAck)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003131{
3132 tDot11fDeAuth frm;
3133 uint8_t *pFrame;
3134 tpSirMacMgmtHdr pMacHdr;
3135 uint32_t nBytes, nPayload, nStatus;
3136 void *pPacket;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303137 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003138 uint8_t txFlag = 0;
3139 uint32_t val = 0;
3140#ifdef FEATURE_WLAN_TDLS
3141 uint16_t aid;
Jeff Johnsonbddc03e2019-01-17 15:37:09 -08003142 tpDphHashNode sta;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003143#endif
3144 uint8_t smeSessionId = 0;
Srinivas Dasarie2ee0942019-06-29 14:34:50 +05303145 struct wlan_ies *discon_ie;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003146
Jeff Johnson8e9530b2019-03-18 13:41:42 -07003147 if (!pe_session) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003148 return;
3149 }
3150
3151 /*
3152 * In case when cac timer is running for this SAP session then
3153 * avoid deauth frame out. It is violation of dfs specification.
3154 */
Pragaspathi Thilagaraje64714a2019-05-23 00:46:25 +05303155 if (((pe_session->opmode == QDF_SAP_MODE) ||
3156 (pe_session->opmode == QDF_P2P_GO_MODE)) &&
Jeff Johnson99f25042018-11-21 22:49:06 -08003157 (true == mac->sap.SapDfsInfo.is_dfs_cac_timer_running)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303158 QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_INFO,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003159 FL
3160 ("CAC timer is running, drop the deauth from going out"));
Abhishek Singh06522c52019-05-08 12:13:42 +05303161 if (waitForAck)
3162 lim_send_deauth_cnf(mac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003163 return;
3164 }
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003165 smeSessionId = pe_session->smeSessionId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003166
hangtian127c9532019-01-12 13:29:07 +08003167 qdf_mem_zero((uint8_t *) &frm, sizeof(frm));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003168
3169 frm.Reason.code = nReason;
3170
Jeff Johnson99f25042018-11-21 22:49:06 -08003171 nStatus = dot11f_get_packed_de_auth_size(mac, &frm, &nPayload);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003172 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003173 pe_err("Failed to calculate the packed size for a De-Authentication (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003174 nStatus);
3175 /* We'll fall back on the worst case scenario: */
3176 nPayload = sizeof(tDot11fDeAuth);
3177 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003178 pe_warn("There were warnings while calculating the packed size for a De-Authentication (0x%08x)",
3179 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003180 }
3181
3182 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
Srinivas Dasarie2ee0942019-06-29 14:34:50 +05303183 discon_ie = mlme_get_self_disconnect_ies(pe_session->vdev);
3184 if (discon_ie && discon_ie->len)
3185 nBytes += discon_ie->len;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003186
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303187 qdf_status = cds_packet_alloc((uint16_t) nBytes, (void **)&pFrame,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003188 (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303189 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003190 pe_err("Failed to allocate %d bytes for a De-Authentication",
3191 nBytes);
Abhishek Singh06522c52019-05-08 12:13:42 +05303192 if (waitForAck)
3193 lim_send_deauth_cnf(mac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003194 return;
3195 }
3196 /* Paranoia: */
hangtian127c9532019-01-12 13:29:07 +08003197 qdf_mem_zero(pFrame, nBytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003198
3199 /* Next, we fill out the buffer descriptor: */
Jeff Johnson99f25042018-11-21 22:49:06 -08003200 lim_populate_mac_header(mac, pFrame, SIR_MAC_MGMT_FRAME,
Pragaspathi Thilagaraj7fb14222019-06-17 23:26:58 +05303201 SIR_MAC_MGMT_DEAUTH, peer, pe_session->self_mac_addr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003202 pMacHdr = (tpSirMacMgmtHdr) pFrame;
3203
3204 /* Prepare the BSSID */
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003205 sir_copy_mac_addr(pMacHdr->bssId, pe_session->bssId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003206
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003207 lim_set_protected_bit(mac, pe_session, peer, pMacHdr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003208
Jeff Johnson99f25042018-11-21 22:49:06 -08003209 nStatus = dot11f_pack_de_auth(mac, &frm, pFrame +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003210 sizeof(tSirMacMgmtHdr), nPayload, &nPayload);
3211 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003212 pe_err("Failed to pack a DeAuthentication (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003213 nStatus);
3214 cds_packet_free((void *)pPacket);
Abhishek Singh06522c52019-05-08 12:13:42 +05303215 if (waitForAck)
3216 lim_send_deauth_cnf(mac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003217 return;
3218 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003219 pe_warn("There were warnings while packing a De-Authentication (0x%08x)",
3220 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003221 }
Srinivas Dasarie2ee0942019-06-29 14:34:50 +05303222
3223 /* Copy disconnect IEs to the end of the frame */
3224 lim_append_ies_to_frame(pFrame + sizeof(tSirMacMgmtHdr) + nPayload,
3225 &nPayload, discon_ie);
3226 mlme_free_self_disconnect_ies(pe_session->vdev);
3227
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003228 pe_debug("***Sessionid %d Sending Deauth frame with "
Srinivas Girigowdacb7b8b82019-04-10 14:27:47 -07003229 "reason %u and waitForAck %d to " QDF_MAC_ADDR_STR
3230 " ,From " QDF_MAC_ADDR_STR,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003231 pe_session->peSessionId, nReason, waitForAck,
Srinivas Girigowda34fbba02019-04-08 12:07:44 -07003232 QDF_MAC_ADDR_ARRAY(pMacHdr->da),
Pragaspathi Thilagaraj7fb14222019-06-17 23:26:58 +05303233 QDF_MAC_ADDR_ARRAY(pe_session->self_mac_addr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003234
Pragaspathi Thilagaraje64714a2019-05-23 00:46:25 +05303235 if ((BAND_5G == lim_get_rf_band(pe_session->currentOperChannel)) ||
3236 (pe_session->opmode == QDF_P2P_CLIENT_MODE) ||
3237 (pe_session->opmode == QDF_P2P_GO_MODE))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003238 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003239
Sushant Kaushik46556062015-12-02 16:57:47 +05303240 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003241#ifdef FEATURE_WLAN_TDLS
Jeff Johnsonbddc03e2019-01-17 15:37:09 -08003242 sta =
Jeff Johnson99f25042018-11-21 22:49:06 -08003243 dph_lookup_hash_entry(mac, peer, &aid,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003244 &pe_session->dph.dphHashTable);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003245#endif
3246
3247 if (waitForAck) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303248 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003249 pe_session->peSessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003250 pMacHdr->fc.subType));
Jeff Johnson99f25042018-11-21 22:49:06 -08003251 lim_diag_mgmt_tx_event_report(mac, pMacHdr,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003252 pe_session,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003253 QDF_STATUS_SUCCESS, QDF_STATUS_SUCCESS);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003254 /* Queue Disassociation frame in high priority WQ */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303255 qdf_status =
Jeff Johnson99f25042018-11-21 22:49:06 -08003256 wma_tx_frameWithTxComplete(mac, pPacket, (uint16_t) nBytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003257 TXRX_FRM_802_11_MGMT,
3258 ANI_TXDIR_TODS, 7, lim_tx_complete,
Liangwei Dongc0b2e332017-11-16 06:04:46 -05003259 pFrame, lim_deauth_tx_complete_cnf_handler,
Naveen Rawat296a5182017-09-25 14:02:48 -07003260 txFlag, smeSessionId, false, 0,
3261 RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303262 MTRACE(qdf_trace
Anurag Chouhan6d760662016-02-20 16:05:43 +05303263 (QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003264 pe_session->peSessionId, qdf_status));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003265 /* Pkt will be freed up by the callback lim_tx_complete */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303266 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003267 pe_err("Failed to send De-Authentication (%X)!",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303268 qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003269
3270 /* Call lim_process_deauth_ack_timeout which will send
3271 * DeauthCnf for this frame
3272 */
Jeff Johnson99f25042018-11-21 22:49:06 -08003273 lim_process_deauth_ack_timeout(mac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003274 return;
3275 }
3276
3277 val = SYS_MS_TO_TICKS(LIM_DISASSOC_DEAUTH_ACK_TIMEOUT);
3278
3279 if (tx_timer_change
Jeff Johnson99f25042018-11-21 22:49:06 -08003280 (&mac->lim.limTimers.gLimDeauthAckTimer, val, 0)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003281 != TX_SUCCESS) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003282 pe_err("Unable to change Deauth ack Timer val");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003283 return;
3284 } else if (TX_SUCCESS !=
Jeff Johnson99f25042018-11-21 22:49:06 -08003285 tx_timer_activate(&mac->lim.limTimers.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003286 gLimDeauthAckTimer)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003287 pe_err("Unable to activate Deauth ack Timer");
Jeff Johnson99f25042018-11-21 22:49:06 -08003288 lim_deactivate_and_change_timer(mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003289 eLIM_DEAUTH_ACK_TIMER);
3290 return;
3291 }
3292 } else {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303293 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003294 pe_session->peSessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003295 pMacHdr->fc.subType));
3296#ifdef FEATURE_WLAN_TDLS
Jeff Johnson8e9530b2019-03-18 13:41:42 -07003297 if ((sta)
Jeff Johnsonbddc03e2019-01-17 15:37:09 -08003298 && (STA_ENTRY_TDLS_PEER == sta->staType)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003299 /* Queue Disassociation frame in high priority WQ */
Jeff Johnson99f25042018-11-21 22:49:06 -08003300 lim_diag_mgmt_tx_event_report(mac, pMacHdr,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003301 pe_session,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003302 QDF_STATUS_SUCCESS,
3303 QDF_STATUS_SUCCESS);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303304 qdf_status =
Jeff Johnson99f25042018-11-21 22:49:06 -08003305 wma_tx_frame(mac, pPacket, (uint16_t) nBytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003306 TXRX_FRM_802_11_MGMT, ANI_TXDIR_IBSS,
3307 7, lim_tx_complete, pFrame, txFlag,
Naveen Rawat296a5182017-09-25 14:02:48 -07003308 smeSessionId, 0, RATEID_DEFAULT);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003309 } else {
3310#endif
Jeff Johnson99f25042018-11-21 22:49:06 -08003311 lim_diag_mgmt_tx_event_report(mac, pMacHdr,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003312 pe_session,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003313 QDF_STATUS_SUCCESS,
3314 QDF_STATUS_SUCCESS);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003315 /* Queue Disassociation frame in high priority WQ */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303316 qdf_status =
Jeff Johnson99f25042018-11-21 22:49:06 -08003317 wma_tx_frame(mac, pPacket, (uint16_t) nBytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003318 TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS,
3319 7, lim_tx_complete, pFrame, txFlag,
Naveen Rawat296a5182017-09-25 14:02:48 -07003320 smeSessionId, 0, RATEID_DEFAULT);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003321#ifdef FEATURE_WLAN_TDLS
3322 }
3323#endif
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303324 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003325 pe_session->peSessionId, qdf_status));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303326 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003327 pe_err("Failed to send De-Authentication (%X)!",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303328 qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003329 /* Pkt will be freed up by the callback */
3330 }
3331 }
3332
3333} /* End lim_send_deauth_mgmt_frame. */
3334
3335#ifdef ANI_SUPPORT_11H
3336/**
3337 * \brief Send a Measurement Report Action frame
3338 *
3339 *
Jeff Johnson99f25042018-11-21 22:49:06 -08003340 * \param mac Pointer to the global MAC structure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003341 *
3342 * \param pMeasReqFrame Address of a tSirMacMeasReqActionFrame
3343 *
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003344 * \return QDF_STATUS_SUCCESS on success, QDF_STATUS_E_FAILURE else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003345 *
3346 *
3347 */
3348
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003349QDF_STATUS
Jeff Johnson9320c1e2018-12-02 13:09:20 -08003350lim_send_meas_report_frame(struct mac_context *mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003351 tpSirMacMeasReqActionFrame pMeasReqFrame,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003352 tSirMacAddr peer, struct pe_session *pe_session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003353{
3354 tDot11fMeasurementReport frm;
3355 uint8_t *pFrame;
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003356 QDF_STATUS nSirStatus;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003357 tpSirMacMgmtHdr pMacHdr;
3358 uint32_t nBytes, nPayload, nStatus;
3359 void *pPacket;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303360 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003361
hangtian127c9532019-01-12 13:29:07 +08003362 qdf_mem_zero((uint8_t *) &frm, sizeof(frm));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003363
Srinivas Girigowda48bec1c2019-05-17 16:33:30 -07003364 frm.Category.category = ACTION_CATEGORY_SPECTRUM_MGMT;
Srinivas Girigowdaf8e5d2e2019-05-28 11:49:29 -07003365 frm.Action.action = ACTION_SPCT_MSR_RPRT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003366 frm.DialogToken.token = pMeasReqFrame->actionHeader.dialogToken;
3367
3368 switch (pMeasReqFrame->measReqIE.measType) {
3369 case SIR_MAC_BASIC_MEASUREMENT_TYPE:
3370 nSirStatus =
Jeff Johnson99f25042018-11-21 22:49:06 -08003371 populate_dot11f_measurement_report0(mac, pMeasReqFrame,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003372 &frm.MeasurementReport);
3373 break;
3374 case SIR_MAC_CCA_MEASUREMENT_TYPE:
3375 nSirStatus =
Jeff Johnson99f25042018-11-21 22:49:06 -08003376 populate_dot11f_measurement_report1(mac, pMeasReqFrame,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003377 &frm.MeasurementReport);
3378 break;
3379 case SIR_MAC_RPI_MEASUREMENT_TYPE:
3380 nSirStatus =
Jeff Johnson99f25042018-11-21 22:49:06 -08003381 populate_dot11f_measurement_report2(mac, pMeasReqFrame,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003382 &frm.MeasurementReport);
3383 break;
3384 default:
Jeff Johnson0711e272018-12-14 23:16:38 -08003385 pe_err("Unknown measurement type %d in limSendMeasReportFrame",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003386 pMeasReqFrame->measReqIE.measType);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003387 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003388 }
3389
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003390 if (QDF_STATUS_SUCCESS != nSirStatus)
3391 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003392
Jeff Johnson99f25042018-11-21 22:49:06 -08003393 nStatus = dot11f_get_packed_measurement_report_size(mac, &frm, &nPayload);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003394 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003395 pe_err("Failed to calculate the packed size for a Measurement Report (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003396 nStatus);
3397 /* We'll fall back on the worst case scenario: */
3398 nPayload = sizeof(tDot11fMeasurementReport);
3399 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003400 pe_warn("There were warnings while calculating the packed size for a Measurement Report (0x%08x)",
3401 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003402 }
3403
3404 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
3405
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303406 qdf_status =
Jeff Johnson99f25042018-11-21 22:49:06 -08003407 cds_packet_alloc(mac->hdd_handle, TXRX_FRM_802_11_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003408 (uint16_t) nBytes, (void **)&pFrame,
3409 (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303410 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Jeff Johnson0711e272018-12-14 23:16:38 -08003411 pe_err("Failed to allocate %d bytes for a De-Authentication",
3412 nBytes);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003413 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003414 }
3415 /* Paranoia: */
hangtian127c9532019-01-12 13:29:07 +08003416 qdf_mem_zero(pFrame, nBytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003417
3418 /* Next, we fill out the buffer descriptor: */
Jeff Johnson99f25042018-11-21 22:49:06 -08003419 lim_populate_mac_header(mac, pFrame, SIR_MAC_MGMT_FRAME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003420 SIR_MAC_MGMT_ACTION, peer);
3421 pMacHdr = (tpSirMacMgmtHdr) pFrame;
3422
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003423 qdf_mem_copy(pMacHdr->bssId, pe_session->bssId, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003424
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003425 lim_set_protected_bit(mac, pe_session, peer, pMacHdr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003426
Jeff Johnson99f25042018-11-21 22:49:06 -08003427 nStatus = dot11f_pack_measurement_report(mac, &frm, pFrame +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003428 sizeof(tSirMacMgmtHdr),
3429 nPayload, &nPayload);
3430 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003431 pe_err("Failed to pack a Measurement Report (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003432 nStatus);
Jeff Johnson99f25042018-11-21 22:49:06 -08003433 cds_packet_free(mac->hdd_handle, TXRX_FRM_802_11_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003434 (void *)pFrame, (void *)pPacket);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003435 return QDF_STATUS_E_FAILURE; /* allocated! */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003436 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003437 pe_warn("There were warnings while packing a Measurement Report (0x%08x)",
3438 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003439 }
3440
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303441 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003442 ((pe_session) ? pe_session->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003443 peSessionId : NO_SESSION), pMacHdr->fc.subType));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303444 qdf_status =
Jeff Johnson99f25042018-11-21 22:49:06 -08003445 wma_tx_frame(mac, pPacket, (uint16_t) nBytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003446 TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS, 7,
Naveen Rawat296a5182017-09-25 14:02:48 -07003447 lim_tx_complete, pFrame, 0, 0, RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303448 MTRACE(qdf_trace
Anurag Chouhan6d760662016-02-20 16:05:43 +05303449 (QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003450 ((pe_session) ? pe_session->peSessionId : NO_SESSION),
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303451 qdf_status));
3452 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003453 pe_err("Failed to send a Measurement Report (%X)!",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303454 qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003455 /* Pkt will be freed up by the callback */
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003456 return QDF_STATUS_E_FAILURE; /* just allocated... */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003457 }
3458
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003459 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003460
3461} /* End lim_send_meas_report_frame. */
3462
3463/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003464 * \brief Send a TPC Report Action frame
3465 *
3466 *
Jeff Johnson99f25042018-11-21 22:49:06 -08003467 * \param mac Pointer to the global MAC datastructure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003468 *
3469 * \param pTpcReqFrame Pointer to the received TPC Request
3470 *
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003471 * \return QDF_STATUS_SUCCESS on success, QDF_STATUS_E_FAILURE else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003472 *
3473 *
3474 */
3475
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003476QDF_STATUS
Jeff Johnson9320c1e2018-12-02 13:09:20 -08003477lim_send_tpc_report_frame(struct mac_context *mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003478 tpSirMacTpcReqActionFrame pTpcReqFrame,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003479 tSirMacAddr peer, struct pe_session *pe_session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003480{
3481 tDot11fTPCReport frm;
3482 uint8_t *pFrame;
3483 tpSirMacMgmtHdr pMacHdr;
3484 uint32_t nBytes, nPayload, nStatus;
3485 void *pPacket;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303486 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003487
hangtian127c9532019-01-12 13:29:07 +08003488 qdf_mem_zero((uint8_t *) &frm, sizeof(frm));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003489
Srinivas Girigowda48bec1c2019-05-17 16:33:30 -07003490 frm.Category.category = ACTION_CATEGORY_SPECTRUM_MGMT;
Srinivas Girigowdaf8e5d2e2019-05-28 11:49:29 -07003491 frm.Action.action = ACTION_SPCT_TPC_RPRT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003492 frm.DialogToken.token = pTpcReqFrame->actionHeader.dialogToken;
3493
3494 frm.TPCReport.tx_power = 0;
3495 frm.TPCReport.link_margin = 0;
3496 frm.TPCReport.present = 1;
3497
Jeff Johnson99f25042018-11-21 22:49:06 -08003498 nStatus = dot11f_get_packed_tpc_report_size(mac, &frm, &nPayload);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003499 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003500 pe_err("Failed to calculate the packed size for a TPC Report (0x%08x)", nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003501 /* We'll fall back on the worst case scenario: */
3502 nPayload = sizeof(tDot11fTPCReport);
3503 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003504 pe_warn("There were warnings while calculating the packed size for a TPC Report (0x%08x)",
3505 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003506 }
3507
3508 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
3509
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303510 qdf_status =
Jeff Johnson99f25042018-11-21 22:49:06 -08003511 cds_packet_alloc(mac->hdd_handle, TXRX_FRM_802_11_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003512 (uint16_t) nBytes, (void **)&pFrame,
3513 (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303514 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003515 pe_err("Failed to allocate %d bytes for a TPC"
3516 " Report", nBytes);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003517 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003518 }
3519 /* Paranoia: */
hangtian127c9532019-01-12 13:29:07 +08003520 qdf_mem_zero(pFrame, nBytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003521
3522 /* Next, we fill out the buffer descriptor: */
Jeff Johnson99f25042018-11-21 22:49:06 -08003523 lim_populate_mac_header(mac, pFrame, SIR_MAC_MGMT_FRAME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003524 SIR_MAC_MGMT_ACTION, peer);
3525
3526 pMacHdr = (tpSirMacMgmtHdr) pFrame;
3527
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003528 qdf_mem_copy(pMacHdr->bssId, pe_session->bssId, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003529
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003530 lim_set_protected_bit(mac, pe_session, peer, pMacHdr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003531
Jeff Johnson99f25042018-11-21 22:49:06 -08003532 nStatus = dot11f_pack_tpc_report(mac, &frm, pFrame +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003533 sizeof(tSirMacMgmtHdr),
3534 nPayload, &nPayload);
3535 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003536 pe_err("Failed to pack a TPC Report (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003537 nStatus);
Jeff Johnson99f25042018-11-21 22:49:06 -08003538 cds_packet_free(mac->hdd_handle, TXRX_FRM_802_11_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003539 (void *)pFrame, (void *)pPacket);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003540 return QDF_STATUS_E_FAILURE; /* allocated! */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003541 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003542 pe_warn("There were warnings while packing a TPC Report (0x%08x)",
3543 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003544
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303545 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003546 ((pe_session) ? pe_session->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003547 peSessionId : NO_SESSION), pMacHdr->fc.subType));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303548 qdf_status =
Jeff Johnson99f25042018-11-21 22:49:06 -08003549 wma_tx_frame(mac, pPacket, (uint16_t) nBytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003550 TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS, 7,
Naveen Rawat296a5182017-09-25 14:02:48 -07003551 lim_tx_complete, pFrame, 0, 0, RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303552 MTRACE(qdf_trace
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003553 (QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003554 ((pe_session) ? pe_session->peSessionId : NO_SESSION),
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003555 qdf_status));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303556 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003557 pe_err("Failed to send a TPC Report (%X)!",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303558 qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003559 /* Pkt will be freed up by the callback */
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003560 return QDF_STATUS_E_FAILURE; /* just allocated... */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003561 }
3562
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003563 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003564
3565} /* End lim_send_tpc_report_frame. */
3566#endif /* ANI_SUPPORT_11H */
3567
3568/**
3569 * \brief Send a Channel Switch Announcement
3570 *
3571 *
Jeff Johnson99f25042018-11-21 22:49:06 -08003572 * \param mac Pointer to the global MAC datastructure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003573 *
3574 * \param peer MAC address to which this frame will be sent
3575 *
3576 * \param nMode
3577 *
3578 * \param nNewChannel
3579 *
3580 * \param nCount
3581 *
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003582 * \return QDF_STATUS_SUCCESS on success, QDF_STATUS_E_FAILURE else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003583 *
3584 *
3585 */
3586
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003587QDF_STATUS
Jeff Johnson9320c1e2018-12-02 13:09:20 -08003588lim_send_channel_switch_mgmt_frame(struct mac_context *mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003589 tSirMacAddr peer,
3590 uint8_t nMode,
3591 uint8_t nNewChannel,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003592 uint8_t nCount, struct pe_session *pe_session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003593{
3594 tDot11fChannelSwitch frm;
3595 uint8_t *pFrame;
3596 tpSirMacMgmtHdr pMacHdr;
3597 uint32_t nBytes, nPayload, nStatus; /* , nCfg; */
3598 void *pPacket;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303599 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003600 uint8_t txFlag = 0;
3601
3602 uint8_t smeSessionId = 0;
3603
Jeff Johnson8e9530b2019-03-18 13:41:42 -07003604 if (!pe_session) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003605 pe_err("Session entry is NULL!!!");
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003606 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003607 }
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003608 smeSessionId = pe_session->smeSessionId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003609
hangtian127c9532019-01-12 13:29:07 +08003610 qdf_mem_zero((uint8_t *) &frm, sizeof(frm));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003611
Srinivas Girigowda48bec1c2019-05-17 16:33:30 -07003612 frm.Category.category = ACTION_CATEGORY_SPECTRUM_MGMT;
Srinivas Girigowdaf8e5d2e2019-05-28 11:49:29 -07003613 frm.Action.action = ACTION_SPCT_CHL_SWITCH;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003614 frm.ChanSwitchAnn.switchMode = nMode;
3615 frm.ChanSwitchAnn.newChannel = nNewChannel;
3616 frm.ChanSwitchAnn.switchCount = nCount;
3617 frm.ChanSwitchAnn.present = 1;
3618
Jeff Johnson99f25042018-11-21 22:49:06 -08003619 nStatus = dot11f_get_packed_channel_switch_size(mac, &frm, &nPayload);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003620 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003621 pe_err("Failed to calculate the packed size for a Channel Switch (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003622 nStatus);
3623 /* We'll fall back on the worst case scenario: */
3624 nPayload = sizeof(tDot11fChannelSwitch);
3625 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003626 pe_warn("There were warnings while calculating the packed size for a Channel Switch (0x%08x)",
3627 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003628 }
3629
3630 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
3631
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303632 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003633 cds_packet_alloc((uint16_t) nBytes, (void **)&pFrame,
3634 (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303635 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003636 pe_err("Failed to allocate %d bytes for a TPC Report", nBytes);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003637 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003638 }
3639 /* Paranoia: */
hangtian127c9532019-01-12 13:29:07 +08003640 qdf_mem_zero(pFrame, nBytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003641
3642 /* Next, we fill out the buffer descriptor: */
Jeff Johnson99f25042018-11-21 22:49:06 -08003643 lim_populate_mac_header(mac, pFrame, SIR_MAC_MGMT_FRAME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003644 SIR_MAC_MGMT_ACTION, peer,
Pragaspathi Thilagaraj7fb14222019-06-17 23:26:58 +05303645 pe_session->self_mac_addr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003646 pMacHdr = (tpSirMacMgmtHdr) pFrame;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303647 qdf_mem_copy((uint8_t *) pMacHdr->bssId,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003648 (uint8_t *) pe_session->bssId, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003649
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003650 lim_set_protected_bit(mac, pe_session, peer, pMacHdr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003651
Jeff Johnson99f25042018-11-21 22:49:06 -08003652 nStatus = dot11f_pack_channel_switch(mac, &frm, pFrame +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003653 sizeof(tSirMacMgmtHdr),
3654 nPayload, &nPayload);
3655 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003656 pe_err("Failed to pack a Channel Switch (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003657 nStatus);
3658 cds_packet_free((void *)pPacket);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003659 return QDF_STATUS_E_FAILURE; /* allocated! */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003660 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003661 pe_warn("There were warnings while packing a Channel Switch (0x%08x)",
3662 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003663 }
3664
Pragaspathi Thilagaraje64714a2019-05-23 00:46:25 +05303665 if ((BAND_5G == lim_get_rf_band(pe_session->currentOperChannel)) ||
3666 (pe_session->opmode == QDF_P2P_CLIENT_MODE) ||
3667 (pe_session->opmode == QDF_P2P_GO_MODE))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003668 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003669
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303670 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003671 pe_session->peSessionId, pMacHdr->fc.subType));
Jeff Johnson99f25042018-11-21 22:49:06 -08003672 qdf_status = wma_tx_frame(mac, pPacket, (uint16_t) nBytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003673 TXRX_FRM_802_11_MGMT,
3674 ANI_TXDIR_TODS,
3675 7, lim_tx_complete, pFrame, txFlag,
Naveen Rawat296a5182017-09-25 14:02:48 -07003676 smeSessionId, 0, RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303677 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003678 pe_session->peSessionId, qdf_status));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303679 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003680 pe_err("Failed to send a Channel Switch (%X)!",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303681 qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003682 /* Pkt will be freed up by the callback */
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003683 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003684 }
3685
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003686 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003687
3688} /* End lim_send_channel_switch_mgmt_frame. */
3689
Abhishek Singh518323d2015-10-19 17:42:01 +05303690/**
3691 * lim_send_extended_chan_switch_action_frame()- function to send ECSA
3692 * action frame over the air .
3693 * @mac_ctx: pointer to global mac structure
3694 * @peer: Destination mac.
3695 * @mode: channel switch mode
3696 * @new_op_class: new op class
3697 * @new_channel: new channel to switch
3698 * @count: channel switch count
3699 *
3700 * This function is called to send ECSA frame.
3701 *
3702 * Return: success if frame is sent else return failure
3703 */
3704
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003705QDF_STATUS
Jeff Johnson9320c1e2018-12-02 13:09:20 -08003706lim_send_extended_chan_switch_action_frame(struct mac_context *mac_ctx,
Abhishek Singh518323d2015-10-19 17:42:01 +05303707 tSirMacAddr peer, uint8_t mode, uint8_t new_op_class,
Jeff Johnsona7815652018-11-18 22:58:30 -08003708 uint8_t new_channel, uint8_t count, struct pe_session *session_entry)
Abhishek Singh518323d2015-10-19 17:42:01 +05303709{
3710 tDot11fext_channel_switch_action_frame frm;
3711 uint8_t *frame;
3712 tpSirMacMgmtHdr mac_hdr;
3713 uint32_t num_bytes, n_payload, status;
3714 void *packet;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303715 QDF_STATUS qdf_status;
Abhishek Singh518323d2015-10-19 17:42:01 +05303716 uint8_t txFlag = 0;
3717 uint8_t sme_session_id = 0;
Vignesh Viswanathan93b7f702017-12-19 17:48:45 +05303718 uint8_t ch_spacing;
3719 tLimWiderBWChannelSwitchInfo *wide_bw_ie;
Abhishek Singh518323d2015-10-19 17:42:01 +05303720
Jeff Johnson8e9530b2019-03-18 13:41:42 -07003721 if (!session_entry) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003722 pe_err("Session entry is NULL!!!");
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003723 return QDF_STATUS_E_FAILURE;
Abhishek Singh518323d2015-10-19 17:42:01 +05303724 }
3725
3726 sme_session_id = session_entry->smeSessionId;
3727
hangtian127c9532019-01-12 13:29:07 +08003728 qdf_mem_zero(&frm, sizeof(frm));
Abhishek Singh518323d2015-10-19 17:42:01 +05303729
Srinivas Girigowda48bec1c2019-05-17 16:33:30 -07003730 frm.Category.category = ACTION_CATEGORY_PUBLIC;
Abhishek Singh518323d2015-10-19 17:42:01 +05303731 frm.Action.action = SIR_MAC_ACTION_EXT_CHANNEL_SWITCH_ID;
3732
3733 frm.ext_chan_switch_ann_action.switch_mode = mode;
3734 frm.ext_chan_switch_ann_action.op_class = new_op_class;
3735 frm.ext_chan_switch_ann_action.new_channel = new_channel;
3736 frm.ext_chan_switch_ann_action.switch_count = count;
3737
Vignesh Viswanathan93b7f702017-12-19 17:48:45 +05303738 ch_spacing = wlan_reg_dmn_get_chanwidth_from_opclass(
3739 mac_ctx->scan.countryCodeCurrent, new_channel,
3740 new_op_class);
3741 pe_debug("wrapper: ch_spacing %hu", ch_spacing);
3742
3743 if ((ch_spacing == 80) || (ch_spacing == 160)) {
3744 wide_bw_ie = &session_entry->gLimWiderBWChannelSwitch;
3745 frm.WiderBWChanSwitchAnn.newChanWidth =
3746 wide_bw_ie->newChanWidth;
3747 frm.WiderBWChanSwitchAnn.newCenterChanFreq0 =
3748 wide_bw_ie->newCenterChanFreq0;
3749 frm.WiderBWChanSwitchAnn.newCenterChanFreq1 =
3750 wide_bw_ie->newCenterChanFreq1;
3751 frm.WiderBWChanSwitchAnn.present = 1;
3752 pe_debug("wrapper: width:%d f0:%d f1:%d",
3753 frm.WiderBWChanSwitchAnn.newChanWidth,
3754 frm.WiderBWChanSwitchAnn.newCenterChanFreq0,
3755 frm.WiderBWChanSwitchAnn.newCenterChanFreq1);
3756 }
Abhishek Singh518323d2015-10-19 17:42:01 +05303757
3758 status = dot11f_get_packed_ext_channel_switch_action_frame_size(mac_ctx,
3759 &frm, &n_payload);
3760 if (DOT11F_FAILED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003761 pe_err("Failed to get packed size for Channel Switch 0x%08x",
Abhishek Singh518323d2015-10-19 17:42:01 +05303762 status);
3763 /* We'll fall back on the worst case scenario*/
3764 n_payload = sizeof(tDot11fext_channel_switch_action_frame);
3765 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003766 pe_warn("There were warnings while calculating the packed size for a Ext Channel Switch (0x%08x)",
Abhishek Singh518323d2015-10-19 17:42:01 +05303767 status);
3768 }
3769
3770 num_bytes = n_payload + sizeof(tSirMacMgmtHdr);
3771
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303772 qdf_status = cds_packet_alloc((uint16_t)num_bytes,
Abhishek Singh518323d2015-10-19 17:42:01 +05303773 (void **) &frame, (void **) &packet);
3774
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303775 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003776 pe_err("Failed to allocate %d bytes for a Ext Channel Switch",
Abhishek Singh518323d2015-10-19 17:42:01 +05303777 num_bytes);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003778 return QDF_STATUS_E_FAILURE;
Abhishek Singh518323d2015-10-19 17:42:01 +05303779 }
3780
3781 /* Paranoia*/
hangtian127c9532019-01-12 13:29:07 +08003782 qdf_mem_zero(frame, num_bytes);
Abhishek Singh518323d2015-10-19 17:42:01 +05303783
3784 /* Next, we fill out the buffer descriptor */
3785 lim_populate_mac_header(mac_ctx, frame, SIR_MAC_MGMT_FRAME,
Pragaspathi Thilagaraj7fb14222019-06-17 23:26:58 +05303786 SIR_MAC_MGMT_ACTION, peer, session_entry->self_mac_addr);
Abhishek Singh518323d2015-10-19 17:42:01 +05303787 mac_hdr = (tpSirMacMgmtHdr) frame;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303788 qdf_mem_copy((uint8_t *) mac_hdr->bssId,
Abhishek Singh518323d2015-10-19 17:42:01 +05303789 (uint8_t *) session_entry->bssId,
3790 sizeof(tSirMacAddr));
3791
gaolez4b62a9e2018-08-16 15:57:50 +08003792 lim_set_protected_bit(mac_ctx, session_entry, peer, mac_hdr);
3793
Abhishek Singh518323d2015-10-19 17:42:01 +05303794 status = dot11f_pack_ext_channel_switch_action_frame(mac_ctx, &frm,
3795 frame + sizeof(tSirMacMgmtHdr), n_payload, &n_payload);
3796 if (DOT11F_FAILED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003797 pe_err("Failed to pack a Channel Switch 0x%08x", status);
Abhishek Singh518323d2015-10-19 17:42:01 +05303798 cds_packet_free((void *)packet);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003799 return QDF_STATUS_E_FAILURE;
Abhishek Singh518323d2015-10-19 17:42:01 +05303800 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003801 pe_warn("There were warnings while packing a Channel Switch 0x%08x",
Abhishek Singh518323d2015-10-19 17:42:01 +05303802 status);
3803 }
3804
Pragaspathi Thilagaraje64714a2019-05-23 00:46:25 +05303805 if ((BAND_5G == lim_get_rf_band(session_entry->currentOperChannel)) ||
3806 (session_entry->opmode == QDF_P2P_CLIENT_MODE) ||
3807 (session_entry->opmode == QDF_P2P_GO_MODE))
Abhishek Singh518323d2015-10-19 17:42:01 +05303808 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
Abhishek Singh518323d2015-10-19 17:42:01 +05303809
Srinivas Girigowdacb7b8b82019-04-10 14:27:47 -07003810 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 -07003811 QDF_MAC_ADDR_ARRAY(mac_hdr->da),
Abhishek Singh518323d2015-10-19 17:42:01 +05303812 frm.ext_chan_switch_ann_action.switch_count,
3813 frm.ext_chan_switch_ann_action.switch_mode,
3814 frm.ext_chan_switch_ann_action.new_channel,
3815 frm.ext_chan_switch_ann_action.op_class);
3816
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303817 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Abhishek Singh518323d2015-10-19 17:42:01 +05303818 session_entry->peSessionId, mac_hdr->fc.subType));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303819 qdf_status = wma_tx_frame(mac_ctx, packet, (uint16_t) num_bytes,
Abhishek Singh518323d2015-10-19 17:42:01 +05303820 TXRX_FRM_802_11_MGMT,
3821 ANI_TXDIR_TODS,
3822 7,
3823 lim_tx_complete, frame,
Naveen Rawat296a5182017-09-25 14:02:48 -07003824 txFlag, sme_session_id, 0,
3825 RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303826 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303827 session_entry->peSessionId, qdf_status));
3828 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003829 pe_err("Failed to send a Ext Channel Switch %X!",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303830 qdf_status);
Abhishek Singh518323d2015-10-19 17:42:01 +05303831 /* Pkt will be freed up by the callback */
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003832 return QDF_STATUS_E_FAILURE;
Abhishek Singh518323d2015-10-19 17:42:01 +05303833 }
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003834 return QDF_STATUS_SUCCESS;
Abhishek Singh518323d2015-10-19 17:42:01 +05303835} /* End lim_send_extended_chan_switch_action_frame */
3836
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303837
3838/**
3839 * lim_oper_chan_change_confirm_tx_complete_cnf()- Confirmation for oper_chan_change_confirm
3840 * sent over the air
3841 *
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05303842 * @context: pointer to global mac
3843 * @buf: buffer
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303844 * @tx_complete : Sent status
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05303845 * @params: tx completion params
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303846 *
3847 * Return: This returns QDF_STATUS
3848 */
3849
3850static QDF_STATUS lim_oper_chan_change_confirm_tx_complete_cnf(
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05303851 void *context,
3852 qdf_nbuf_t buf,
3853 uint32_t tx_complete,
3854 void *params)
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303855{
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003856 pe_debug("tx_complete: %d", tx_complete);
Zhu Jianmin83e8b122018-05-18 19:24:45 +08003857 if (buf)
3858 qdf_nbuf_free(buf);
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303859 return QDF_STATUS_SUCCESS;
3860}
3861
3862/**
3863 * lim_p2p_oper_chan_change_confirm_action_frame()- function to send
3864 * p2p oper chan change confirm action frame
3865 * @mac_ctx: pointer to global mac structure
3866 * @peer: Destination mac.
3867 * @session_entry: session entry
3868 *
3869 * This function is called to send p2p oper chan change confirm action frame.
3870 *
3871 * Return: success if frame is sent else return failure
3872 */
3873
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003874QDF_STATUS
Jeff Johnson9320c1e2018-12-02 13:09:20 -08003875lim_p2p_oper_chan_change_confirm_action_frame(struct mac_context *mac_ctx,
Jeff Johnsona7815652018-11-18 22:58:30 -08003876 tSirMacAddr peer, struct pe_session *session_entry)
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303877{
3878 tDot11fp2p_oper_chan_change_confirm frm;
3879 uint8_t *frame;
3880 tpSirMacMgmtHdr mac_hdr;
3881 uint32_t num_bytes, n_payload, status;
3882 void *packet;
3883 QDF_STATUS qdf_status;
3884 uint8_t tx_flag = 0;
3885 uint8_t sme_session_id = 0;
3886
Jeff Johnson8e9530b2019-03-18 13:41:42 -07003887 if (!session_entry) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003888 pe_err("Session entry is NULL!!!");
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003889 return QDF_STATUS_E_FAILURE;
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303890 }
3891
3892 sme_session_id = session_entry->smeSessionId;
3893
hangtian127c9532019-01-12 13:29:07 +08003894 qdf_mem_zero(&frm, sizeof(frm));
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303895
3896 frm.Category.category = SIR_MAC_ACTION_VENDOR_SPECIFIC_CATEGORY;
3897
3898 qdf_mem_copy(frm.p2p_action_oui.oui_data,
3899 SIR_MAC_P2P_OUI, SIR_MAC_P2P_OUI_SIZE);
3900 frm.p2p_action_subtype.subtype = 0x04;
3901 frm.DialogToken.token = 0x0;
3902
3903 if (session_entry->htCapability) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003904 pe_debug("Populate HT Caps in Assoc Request");
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303905 populate_dot11f_ht_caps(mac_ctx, session_entry, &frm.HTCaps);
3906 }
3907
3908 if (session_entry->vhtCapability) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003909 pe_debug("Populate VHT Caps in Assoc Request");
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303910 populate_dot11f_vht_caps(mac_ctx, session_entry, &frm.VHTCaps);
3911 populate_dot11f_operating_mode(mac_ctx,
3912 &frm.OperatingMode, session_entry);
3913 }
3914
3915 status = dot11f_get_packed_p2p_oper_chan_change_confirmSize(mac_ctx,
3916 &frm, &n_payload);
3917 if (DOT11F_FAILED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003918 pe_err("Failed to get packed size 0x%08x", status);
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303919 /* We'll fall back on the worst case scenario*/
3920 n_payload = sizeof(tDot11fp2p_oper_chan_change_confirm);
3921 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003922 pe_warn("There were warnings while calculating the packed size (0x%08x)",
3923 status);
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303924 }
3925
3926 num_bytes = n_payload + sizeof(tSirMacMgmtHdr);
3927
3928 qdf_status = cds_packet_alloc((uint16_t)num_bytes,
3929 (void **) &frame, (void **) &packet);
3930
3931 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003932 pe_err("Failed to allocate %d bytes", num_bytes);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003933 return QDF_STATUS_E_FAILURE;
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303934 }
3935
hangtian127c9532019-01-12 13:29:07 +08003936 qdf_mem_zero(frame, num_bytes);
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303937
3938 /* Next, fill out the buffer descriptor */
3939 lim_populate_mac_header(mac_ctx, frame, SIR_MAC_MGMT_FRAME,
Pragaspathi Thilagaraj7fb14222019-06-17 23:26:58 +05303940 SIR_MAC_MGMT_ACTION, peer, session_entry->self_mac_addr);
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303941 mac_hdr = (tpSirMacMgmtHdr) frame;
3942 qdf_mem_copy((uint8_t *) mac_hdr->bssId,
3943 (uint8_t *) session_entry->bssId,
3944 sizeof(tSirMacAddr));
3945
3946 status = dot11f_pack_p2p_oper_chan_change_confirm(mac_ctx, &frm,
3947 frame + sizeof(tSirMacMgmtHdr), n_payload, &n_payload);
3948 if (DOT11F_FAILED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003949 pe_err("Failed to pack 0x%08x", status);
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303950 cds_packet_free((void *)packet);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003951 return QDF_STATUS_E_FAILURE;
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303952 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003953 pe_warn("There were warnings while packing 0x%08x",
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303954 status);
3955 }
3956
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08003957 if ((BAND_5G ==
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303958 lim_get_rf_band(session_entry->currentOperChannel)) ||
Pragaspathi Thilagaraje64714a2019-05-23 00:46:25 +05303959 (session_entry->opmode == QDF_P2P_CLIENT_MODE) ||
3960 (session_entry->opmode == QDF_P2P_GO_MODE)) {
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303961 tx_flag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
3962 }
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003963 pe_debug("Send frame on channel %d to mac "
Srinivas Girigowdacb7b8b82019-04-10 14:27:47 -07003964 QDF_MAC_ADDR_STR, session_entry->currentOperChannel,
Srinivas Girigowda34fbba02019-04-08 12:07:44 -07003965 QDF_MAC_ADDR_ARRAY(peer));
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303966
3967 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
3968 session_entry->peSessionId, mac_hdr->fc.subType));
3969
3970 qdf_status = wma_tx_frameWithTxComplete(mac_ctx, packet,
3971 (uint16_t)num_bytes,
3972 TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS,
3973 7, lim_tx_complete, frame,
3974 lim_oper_chan_change_confirm_tx_complete_cnf,
Naveen Rawat296a5182017-09-25 14:02:48 -07003975 tx_flag, sme_session_id, false, 0, RATEID_DEFAULT);
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303976
3977 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
3978 session_entry->peSessionId, qdf_status));
3979 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003980 pe_err("Failed to send status %X!", qdf_status);
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303981 /* Pkt will be freed up by the callback */
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003982 return QDF_STATUS_E_FAILURE;
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303983 }
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003984 return QDF_STATUS_SUCCESS;
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303985}
3986
3987
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003988/**
3989 * \brief Send a Neighbor Report Request Action frame
3990 *
3991 *
Jeff Johnson99f25042018-11-21 22:49:06 -08003992 * \param mac Pointer to the global MAC structure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003993 *
3994 * \param pNeighborReq Address of a tSirMacNeighborReportReq
3995 *
3996 * \param peer mac address of peer station.
3997 *
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003998 * \param pe_session address of session entry.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003999 *
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004000 * \return QDF_STATUS_SUCCESS on success, QDF_STATUS_E_FAILURE else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004001 *
4002 *
4003 */
4004
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004005QDF_STATUS
Jeff Johnson9320c1e2018-12-02 13:09:20 -08004006lim_send_neighbor_report_request_frame(struct mac_context *mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004007 tpSirMacNeighborReportReq pNeighborReq,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004008 tSirMacAddr peer, struct pe_session *pe_session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004009{
Pragaspathi Thilagarajd48e6cd2019-05-30 00:52:43 +05304010 QDF_STATUS status_code = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004011 tDot11fNeighborReportRequest frm;
4012 uint8_t *pFrame;
4013 tpSirMacMgmtHdr pMacHdr;
4014 uint32_t nBytes, nPayload, nStatus;
4015 void *pPacket;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304016 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004017 uint8_t txFlag = 0;
4018 uint8_t smeSessionId = 0;
4019
Jeff Johnson8e9530b2019-03-18 13:41:42 -07004020 if (!pe_session) {
4021 pe_err("(!psession) in Request to send Neighbor Report request action frame");
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004022 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004023 }
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004024 smeSessionId = pe_session->smeSessionId;
hangtian127c9532019-01-12 13:29:07 +08004025 qdf_mem_zero((uint8_t *) &frm, sizeof(frm));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004026
Srinivas Girigowda48bec1c2019-05-17 16:33:30 -07004027 frm.Category.category = ACTION_CATEGORY_RRM;
Srinivas Girigowda395addd2019-05-24 14:03:58 -07004028 frm.Action.action = RRM_NEIGHBOR_REQ;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004029 frm.DialogToken.token = pNeighborReq->dialogToken;
4030
4031 if (pNeighborReq->ssid_present) {
Jeff Johnson99f25042018-11-21 22:49:06 -08004032 populate_dot11f_ssid(mac, &pNeighborReq->ssid, &frm.SSID);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004033 }
4034
4035 nStatus =
Jeff Johnson99f25042018-11-21 22:49:06 -08004036 dot11f_get_packed_neighbor_report_request_size(mac, &frm, &nPayload);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004037 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004038 pe_err("Failed to calculate the packed size for a Neighbor Report Request(0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004039 nStatus);
4040 /* We'll fall back on the worst case scenario: */
4041 nPayload = sizeof(tDot11fNeighborReportRequest);
4042 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004043 pe_warn("There were warnings while calculating the packed size for a Neighbor Report Request(0x%08x)",
4044 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004045 }
4046
4047 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
4048
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304049 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004050 cds_packet_alloc((uint16_t) nBytes, (void **)&pFrame,
4051 (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304052 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004053 pe_err("Failed to allocate %d bytes for a Neighbor "
4054 "Report Request", nBytes);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004055 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004056 }
4057 /* Paranoia: */
hangtian127c9532019-01-12 13:29:07 +08004058 qdf_mem_zero(pFrame, nBytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004059
4060 /* Copy necessary info to BD */
Jeff Johnson99f25042018-11-21 22:49:06 -08004061 lim_populate_mac_header(mac, pFrame, SIR_MAC_MGMT_FRAME,
Pragaspathi Thilagaraj7fb14222019-06-17 23:26:58 +05304062 SIR_MAC_MGMT_ACTION, peer, pe_session->self_mac_addr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004063
4064 /* Update A3 with the BSSID */
4065 pMacHdr = (tpSirMacMgmtHdr) pFrame;
4066
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004067 sir_copy_mac_addr(pMacHdr->bssId, pe_session->bssId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004068
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004069 lim_set_protected_bit(mac, pe_session, peer, pMacHdr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004070
4071 /* Now, we're ready to "pack" the frames */
Jeff Johnson99f25042018-11-21 22:49:06 -08004072 nStatus = dot11f_pack_neighbor_report_request(mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004073 &frm,
4074 pFrame +
4075 sizeof(tSirMacMgmtHdr),
4076 nPayload, &nPayload);
4077
4078 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004079 pe_err("Failed to pack an Neighbor Report Request (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004080 nStatus);
4081
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004082 /* FIXME - Need to convert to QDF_STATUS */
Pragaspathi Thilagarajd48e6cd2019-05-30 00:52:43 +05304083 status_code = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004084 goto returnAfterError;
4085 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004086 pe_warn("There were warnings while packing Neighbor Report Request (0x%08x)",
4087 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004088 }
4089
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004090 pe_debug("Sending a Neighbor Report Request to");
Jeff Johnson99f25042018-11-21 22:49:06 -08004091 lim_print_mac_addr(mac, peer, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004092
Pragaspathi Thilagaraje64714a2019-05-23 00:46:25 +05304093 if ((BAND_5G == lim_get_rf_band(pe_session->currentOperChannel)) ||
4094 (pe_session->opmode == QDF_P2P_CLIENT_MODE) ||
4095 (pe_session->opmode == QDF_P2P_GO_MODE))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004096 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004097
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304098 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004099 pe_session->peSessionId, pMacHdr->fc.subType));
Jeff Johnson99f25042018-11-21 22:49:06 -08004100 qdf_status = wma_tx_frame(mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004101 pPacket,
4102 (uint16_t) nBytes,
4103 TXRX_FRM_802_11_MGMT,
4104 ANI_TXDIR_TODS,
4105 7, lim_tx_complete, pFrame, txFlag,
Naveen Rawat296a5182017-09-25 14:02:48 -07004106 smeSessionId, 0, RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304107 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004108 pe_session->peSessionId, qdf_status));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304109 if (QDF_STATUS_SUCCESS != qdf_status) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004110 pe_err("wma_tx_frame FAILED! Status [%d]", qdf_status);
Pragaspathi Thilagarajd48e6cd2019-05-30 00:52:43 +05304111 status_code = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004112 /* Pkt will be freed up by the callback */
Pragaspathi Thilagarajd48e6cd2019-05-30 00:52:43 +05304113 return status_code;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004114 } else
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004115 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004116
4117returnAfterError:
4118 cds_packet_free((void *)pPacket);
4119
Pragaspathi Thilagarajd48e6cd2019-05-30 00:52:43 +05304120 return status_code;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004121} /* End lim_send_neighbor_report_request_frame. */
4122
4123/**
4124 * \brief Send a Link Report Action frame
4125 *
4126 *
Jeff Johnson99f25042018-11-21 22:49:06 -08004127 * \param mac Pointer to the global MAC structure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004128 *
4129 * \param pLinkReport Address of a tSirMacLinkReport
4130 *
4131 * \param peer mac address of peer station.
4132 *
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004133 * \param pe_session address of session entry.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004134 *
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004135 * \return QDF_STATUS_SUCCESS on success, QDF_STATUS_E_FAILURE else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004136 *
4137 *
4138 */
4139
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004140QDF_STATUS
Jeff Johnson9320c1e2018-12-02 13:09:20 -08004141lim_send_link_report_action_frame(struct mac_context *mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004142 tpSirMacLinkReport pLinkReport,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004143 tSirMacAddr peer, struct pe_session *pe_session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004144{
Pragaspathi Thilagarajd48e6cd2019-05-30 00:52:43 +05304145 QDF_STATUS status_code = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004146 tDot11fLinkMeasurementReport frm;
4147 uint8_t *pFrame;
4148 tpSirMacMgmtHdr pMacHdr;
4149 uint32_t nBytes, nPayload, nStatus;
4150 void *pPacket;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304151 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004152 uint8_t txFlag = 0;
4153 uint8_t smeSessionId = 0;
4154
Jeff Johnson8e9530b2019-03-18 13:41:42 -07004155 if (!pe_session) {
4156 pe_err("(!psession) in Request to send Link Report action frame");
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004157 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004158 }
4159
hangtian127c9532019-01-12 13:29:07 +08004160 qdf_mem_zero((uint8_t *) &frm, sizeof(frm));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004161
Srinivas Girigowda48bec1c2019-05-17 16:33:30 -07004162 frm.Category.category = ACTION_CATEGORY_RRM;
Srinivas Girigowda395addd2019-05-24 14:03:58 -07004163 frm.Action.action = RRM_LINK_MEASUREMENT_RPT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004164 frm.DialogToken.token = pLinkReport->dialogToken;
4165
4166 /* IEEE Std. 802.11 7.3.2.18. for the report element. */
4167 /* Even though TPC report an IE, it is represented using fixed fields since it is positioned */
4168 /* in the middle of other fixed fields in the link report frame(IEEE Std. 802.11k section7.4.6.4 */
4169 /* and frame parser always expects IEs to come after all fixed fields. It is easier to handle */
4170 /* such case this way than changing the frame parser. */
Srinivas Girigowda61771262019-04-01 11:55:19 -07004171 frm.TPCEleID.TPCId = WLAN_ELEMID_TPCREP;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004172 frm.TPCEleLen.TPCLen = 2;
4173 frm.TxPower.txPower = pLinkReport->txPower;
4174 frm.LinkMargin.linkMargin = 0;
4175
4176 frm.RxAntennaId.antennaId = pLinkReport->rxAntenna;
4177 frm.TxAntennaId.antennaId = pLinkReport->txAntenna;
4178 frm.RCPI.rcpi = pLinkReport->rcpi;
4179 frm.RSNI.rsni = pLinkReport->rsni;
4180
4181 nStatus =
Jeff Johnson99f25042018-11-21 22:49:06 -08004182 dot11f_get_packed_link_measurement_report_size(mac, &frm, &nPayload);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004183 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004184 pe_err("Failed to calculate the packed size for a Link Report (0x%08x)", nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004185 /* We'll fall back on the worst case scenario: */
4186 nPayload = sizeof(tDot11fLinkMeasurementReport);
4187 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004188 pe_warn("There were warnings while calculating the packed size for a Link Report (0x%08x)",
4189 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004190 }
4191
4192 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
4193
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304194 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004195 cds_packet_alloc((uint16_t) nBytes, (void **)&pFrame,
4196 (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304197 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004198 pe_err("Failed to allocate %d bytes for a Link "
4199 "Report", nBytes);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004200 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004201 }
4202 /* Paranoia: */
hangtian127c9532019-01-12 13:29:07 +08004203 qdf_mem_zero(pFrame, nBytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004204
4205 /* Copy necessary info to BD */
Jeff Johnson99f25042018-11-21 22:49:06 -08004206 lim_populate_mac_header(mac, pFrame, SIR_MAC_MGMT_FRAME,
Pragaspathi Thilagaraj7fb14222019-06-17 23:26:58 +05304207 SIR_MAC_MGMT_ACTION, peer, pe_session->self_mac_addr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004208
4209 /* Update A3 with the BSSID */
4210 pMacHdr = (tpSirMacMgmtHdr) pFrame;
4211
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004212 sir_copy_mac_addr(pMacHdr->bssId, pe_session->bssId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004213
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004214 lim_set_protected_bit(mac, pe_session, peer, pMacHdr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004215
4216 /* Now, we're ready to "pack" the frames */
Jeff Johnson99f25042018-11-21 22:49:06 -08004217 nStatus = dot11f_pack_link_measurement_report(mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004218 &frm,
4219 pFrame +
4220 sizeof(tSirMacMgmtHdr),
4221 nPayload, &nPayload);
4222
4223 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004224 pe_err("Failed to pack an Link Report (0x%08x)", nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004225
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004226 /* FIXME - Need to convert to QDF_STATUS */
Pragaspathi Thilagarajd48e6cd2019-05-30 00:52:43 +05304227 status_code = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004228 goto returnAfterError;
4229 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004230 pe_warn("There were warnings while packing Link Report (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004231 nStatus);
4232 }
4233
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004234 pe_warn("Sending a Link Report to");
Jeff Johnson99f25042018-11-21 22:49:06 -08004235 lim_print_mac_addr(mac, peer, LOGW);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004236
Pragaspathi Thilagaraje64714a2019-05-23 00:46:25 +05304237 if ((BAND_5G == lim_get_rf_band(pe_session->currentOperChannel)) ||
4238 (pe_session->opmode == QDF_P2P_CLIENT_MODE) ||
4239 (pe_session->opmode == QDF_P2P_GO_MODE))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004240 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004241
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304242 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004243 pe_session->peSessionId, pMacHdr->fc.subType));
Jeff Johnson99f25042018-11-21 22:49:06 -08004244 qdf_status = wma_tx_frame(mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004245 pPacket,
4246 (uint16_t) nBytes,
4247 TXRX_FRM_802_11_MGMT,
4248 ANI_TXDIR_TODS,
4249 7, lim_tx_complete, pFrame, txFlag,
Naveen Rawat296a5182017-09-25 14:02:48 -07004250 smeSessionId, 0, RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304251 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004252 pe_session->peSessionId, qdf_status));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304253 if (QDF_STATUS_SUCCESS != qdf_status) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004254 pe_err("wma_tx_frame FAILED! Status [%d]", qdf_status);
Pragaspathi Thilagarajd48e6cd2019-05-30 00:52:43 +05304255 status_code = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004256 /* Pkt will be freed up by the callback */
Pragaspathi Thilagarajd48e6cd2019-05-30 00:52:43 +05304257 return status_code;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004258 } else
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004259 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004260
4261returnAfterError:
4262 cds_packet_free((void *)pPacket);
4263
Pragaspathi Thilagarajd48e6cd2019-05-30 00:52:43 +05304264 return status_code;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004265} /* End lim_send_link_report_action_frame. */
4266
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004267QDF_STATUS
Jeff Johnson9320c1e2018-12-02 13:09:20 -08004268lim_send_radio_measure_report_action_frame(struct mac_context *mac,
Vignesh Viswanathan3b4bf982018-06-05 15:04:23 +05304269 uint8_t dialog_token,
4270 uint8_t num_report,
Vignesh Viswanathan09bd8f42018-08-14 22:04:36 +05304271 bool is_last_frame,
Vignesh Viswanathan3b4bf982018-06-05 15:04:23 +05304272 tpSirMacRadioMeasureReport pRRMReport,
4273 tSirMacAddr peer,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004274 struct pe_session *pe_session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004275{
Pragaspathi Thilagarajd48e6cd2019-05-30 00:52:43 +05304276 QDF_STATUS status_code = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004277 uint8_t *pFrame;
4278 tpSirMacMgmtHdr pMacHdr;
4279 uint32_t nBytes, nPayload, nStatus;
4280 void *pPacket;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304281 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004282 uint8_t i;
4283 uint8_t txFlag = 0;
4284 uint8_t smeSessionId = 0;
Vignesh Viswanathan793328d2018-11-02 11:32:35 +05304285 bool is_last_report = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004286
4287 tDot11fRadioMeasurementReport *frm =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304288 qdf_mem_malloc(sizeof(tDot11fRadioMeasurementReport));
Arif Hussainf5b6c412018-10-10 19:41:09 -07004289 if (!frm)
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004290 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004291
Jeff Johnson8e9530b2019-03-18 13:41:42 -07004292 if (!pe_session) {
4293 pe_err("(!psession) in Request to send Beacon Report action frame");
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304294 qdf_mem_free(frm);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004295 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004296 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004297
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004298 smeSessionId = pe_session->smeSessionId;
Deepak Dhamdhere6a021482017-04-20 17:59:58 -07004299
Vignesh Viswanathan09bd8f42018-08-14 22:04:36 +05304300 pe_debug("dialog_token %d num_report %d is_last_frame %d",
4301 dialog_token, num_report, is_last_frame);
Padma, Santhosh Kumar93ec7d22016-12-26 15:58:37 +05304302
Srinivas Girigowda48bec1c2019-05-17 16:33:30 -07004303 frm->Category.category = ACTION_CATEGORY_RRM;
Srinivas Girigowda395addd2019-05-24 14:03:58 -07004304 frm->Action.action = RRM_RADIO_MEASURE_RPT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004305 frm->DialogToken.token = dialog_token;
4306
4307 frm->num_MeasurementReport =
4308 (num_report >
4309 RADIO_REPORTS_MAX_IN_A_FRAME) ? RADIO_REPORTS_MAX_IN_A_FRAME :
4310 num_report;
4311
4312 for (i = 0; i < frm->num_MeasurementReport; i++) {
4313 frm->MeasurementReport[i].type = pRRMReport[i].type;
4314 frm->MeasurementReport[i].token = pRRMReport[i].token;
4315 frm->MeasurementReport[i].late = 0; /* IEEE 802.11k section 7.3.22. (always zero in rrm) */
4316 switch (pRRMReport[i].type) {
4317 case SIR_MAC_RRM_BEACON_TYPE:
Vignesh Viswanathan793328d2018-11-02 11:32:35 +05304318 /*
4319 * Last beacon report indication needs to be set to 1
4320 * only for the last report in the last frame
4321 */
4322 if (is_last_frame &&
4323 (i == (frm->num_MeasurementReport - 1)))
4324 is_last_report = true;
4325
Jeff Johnson99f25042018-11-21 22:49:06 -08004326 populate_dot11f_beacon_report(mac,
Vignesh Viswanathan3b4bf982018-06-05 15:04:23 +05304327 &frm->MeasurementReport[i],
4328 &pRRMReport[i].report.
4329 beaconReport,
Vignesh Viswanathan793328d2018-11-02 11:32:35 +05304330 is_last_report);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004331 frm->MeasurementReport[i].incapable =
4332 pRRMReport[i].incapable;
4333 frm->MeasurementReport[i].refused =
4334 pRRMReport[i].refused;
4335 frm->MeasurementReport[i].present = 1;
4336 break;
4337 default:
4338 frm->MeasurementReport[i].incapable =
4339 pRRMReport[i].incapable;
4340 frm->MeasurementReport[i].refused =
4341 pRRMReport[i].refused;
4342 frm->MeasurementReport[i].present = 1;
4343 break;
4344 }
4345 }
4346
4347 nStatus =
Jeff Johnson99f25042018-11-21 22:49:06 -08004348 dot11f_get_packed_radio_measurement_report_size(mac, frm, &nPayload);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004349 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004350 pe_err("Failed to calculate the packed size for a Radio Measure Report (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004351 nStatus);
4352 /* We'll fall back on the worst case scenario: */
4353 nPayload = sizeof(tDot11fLinkMeasurementReport);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304354 qdf_mem_free(frm);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004355 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004356 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004357 pe_warn("There were warnings while calculating the packed size for a Radio Measure Report (0x%08x)",
4358 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004359 }
4360
4361 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
4362
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304363 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004364 cds_packet_alloc((uint16_t) nBytes, (void **)&pFrame,
4365 (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304366 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004367 pe_err("Failed to allocate %d bytes for a Radio Measure "
4368 "Report", nBytes);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304369 qdf_mem_free(frm);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004370 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004371 }
4372 /* Paranoia: */
hangtian127c9532019-01-12 13:29:07 +08004373 qdf_mem_zero(pFrame, nBytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004374
4375 /* Copy necessary info to BD */
Jeff Johnson99f25042018-11-21 22:49:06 -08004376 lim_populate_mac_header(mac, pFrame, SIR_MAC_MGMT_FRAME,
Pragaspathi Thilagaraj7fb14222019-06-17 23:26:58 +05304377 SIR_MAC_MGMT_ACTION, peer, pe_session->self_mac_addr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004378
4379 /* Update A3 with the BSSID */
4380 pMacHdr = (tpSirMacMgmtHdr) pFrame;
4381
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004382 sir_copy_mac_addr(pMacHdr->bssId, pe_session->bssId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004383
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004384 lim_set_protected_bit(mac, pe_session, peer, pMacHdr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004385
4386 /* Now, we're ready to "pack" the frames */
Jeff Johnson99f25042018-11-21 22:49:06 -08004387 nStatus = dot11f_pack_radio_measurement_report(mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004388 frm,
4389 pFrame +
4390 sizeof(tSirMacMgmtHdr),
4391 nPayload, &nPayload);
4392
4393 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004394 pe_err("Failed to pack an Radio Measure Report (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004395 nStatus);
4396
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004397 /* FIXME - Need to convert to QDF_STATUS */
Pragaspathi Thilagarajd48e6cd2019-05-30 00:52:43 +05304398 status_code = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004399 goto returnAfterError;
4400 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004401 pe_warn("There were warnings while packing Radio Measure Report (0x%08x)",
4402 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004403 }
4404
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004405 pe_warn("Sending a Radio Measure Report to");
Jeff Johnson99f25042018-11-21 22:49:06 -08004406 lim_print_mac_addr(mac, peer, LOGW);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004407
Pragaspathi Thilagaraje64714a2019-05-23 00:46:25 +05304408 if ((BAND_5G == lim_get_rf_band(pe_session->currentOperChannel)) ||
4409 (pe_session->opmode == QDF_P2P_CLIENT_MODE) ||
4410 (pe_session->opmode == QDF_P2P_GO_MODE))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004411 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004412
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304413 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004414 pe_session->peSessionId, pMacHdr->fc.subType));
Jeff Johnson99f25042018-11-21 22:49:06 -08004415 qdf_status = wma_tx_frame(mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004416 pPacket,
4417 (uint16_t) nBytes,
4418 TXRX_FRM_802_11_MGMT,
4419 ANI_TXDIR_TODS,
4420 7, lim_tx_complete, pFrame, txFlag,
Naveen Rawat296a5182017-09-25 14:02:48 -07004421 smeSessionId, 0, RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304422 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004423 pe_session->peSessionId, qdf_status));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304424 if (QDF_STATUS_SUCCESS != qdf_status) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004425 pe_err("wma_tx_frame FAILED! Status [%d]", qdf_status);
Pragaspathi Thilagarajd48e6cd2019-05-30 00:52:43 +05304426 status_code = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004427 /* Pkt will be freed up by the callback */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304428 qdf_mem_free(frm);
Pragaspathi Thilagarajd48e6cd2019-05-30 00:52:43 +05304429 return status_code;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004430 } else {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304431 qdf_mem_free(frm);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004432 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004433 }
4434
4435returnAfterError:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304436 qdf_mem_free(frm);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004437 cds_packet_free((void *)pPacket);
Pragaspathi Thilagarajd48e6cd2019-05-30 00:52:43 +05304438 return status_code;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004439}
4440
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004441#ifdef WLAN_FEATURE_11W
4442/**
4443 * \brief Send SA query request action frame to peer
4444 *
4445 * \sa lim_send_sa_query_request_frame
4446 *
4447 *
Jeff Johnson9320c1e2018-12-02 13:09:20 -08004448 * \param mac The global struct mac_context *object
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004449 *
4450 * \param transId Transaction identifier
4451 *
4452 * \param peer The Mac address of the station to which this action frame is addressed
4453 *
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004454 * \param pe_session The PE session entry
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004455 *
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004456 * \return QDF_STATUS_SUCCESS if setup completes successfully
4457 * QDF_STATUS_E_FAILURE is some problem is encountered
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004458 */
4459
Jeff Johnson9320c1e2018-12-02 13:09:20 -08004460QDF_STATUS lim_send_sa_query_request_frame(struct mac_context *mac, uint8_t *transId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004461 tSirMacAddr peer,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004462 struct pe_session *pe_session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004463{
4464
4465 tDot11fSaQueryReq frm; /* SA query request action frame */
4466 uint8_t *pFrame;
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004467 QDF_STATUS nSirStatus;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004468 tpSirMacMgmtHdr pMacHdr;
4469 uint32_t nBytes, nPayload, nStatus;
4470 void *pPacket;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304471 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004472 uint8_t txFlag = 0;
4473 uint8_t smeSessionId = 0;
4474
hangtian127c9532019-01-12 13:29:07 +08004475 qdf_mem_zero((uint8_t *) &frm, sizeof(frm));
Srinivas Girigowda48bec1c2019-05-17 16:33:30 -07004476 frm.Category.category = ACTION_CATEGORY_SA_QUERY;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004477 /* 11w action field is :
4478 action: 0 --> SA Query Request action frame
4479 action: 1 --> SA Query Response action frame */
Srinivas Girigowdafeb23fc2019-06-13 11:12:29 -07004480 frm.Action.action = SA_QUERY_REQUEST;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004481 /* 11w SA Query Request transId */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304482 qdf_mem_copy(&frm.TransactionId.transId[0], &transId[0], 2);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004483
Jeff Johnson99f25042018-11-21 22:49:06 -08004484 nStatus = dot11f_get_packed_sa_query_req_size(mac, &frm, &nPayload);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004485 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004486 pe_err("Failed to calculate the packed size for an SA Query Request (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004487 nStatus);
4488 /* We'll fall back on the worst case scenario: */
4489 nPayload = sizeof(tDot11fSaQueryReq);
4490 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004491 pe_warn("There were warnings while calculating the packed size for an SA Query Request (0x%08x)",
4492 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004493 }
4494
4495 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304496 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004497 cds_packet_alloc(nBytes, (void **)&pFrame, (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304498 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004499 pe_err("Failed to allocate %d bytes for a SA Query Request "
4500 "action frame", nBytes);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004501 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004502 }
4503 /* Paranoia: */
hangtian127c9532019-01-12 13:29:07 +08004504 qdf_mem_zero(pFrame, nBytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004505
4506 /* Copy necessary info to BD */
Jeff Johnson99f25042018-11-21 22:49:06 -08004507 lim_populate_mac_header(mac, pFrame, SIR_MAC_MGMT_FRAME,
Pragaspathi Thilagaraj7fb14222019-06-17 23:26:58 +05304508 SIR_MAC_MGMT_ACTION, peer, pe_session->self_mac_addr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004509
4510 /* Update A3 with the BSSID */
4511 pMacHdr = (tpSirMacMgmtHdr) pFrame;
4512
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004513 sir_copy_mac_addr(pMacHdr->bssId, pe_session->bssId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004514
4515 /* Since this is a SA Query Request, set the "protect" (aka WEP) bit */
4516 /* in the FC */
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004517 lim_set_protected_bit(mac, pe_session, peer, pMacHdr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004518
4519 /* Pack 11w SA Query Request frame */
Jeff Johnson99f25042018-11-21 22:49:06 -08004520 nStatus = dot11f_pack_sa_query_req(mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004521 &frm,
4522 pFrame + sizeof(tSirMacMgmtHdr),
4523 nPayload, &nPayload);
4524
4525 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004526 pe_err("Failed to pack an SA Query Request (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004527 nStatus);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004528 /* FIXME - Need to convert to QDF_STATUS */
4529 nSirStatus = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004530 goto returnAfterError;
4531 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004532 pe_warn("There were warnings while packing SA Query Request (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004533 nStatus);
4534 }
4535
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004536 pe_debug("Sending an SA Query Request to");
Jeff Johnson99f25042018-11-21 22:49:06 -08004537 lim_print_mac_addr(mac, peer, LOGD);
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004538 pe_debug("Sending an SA Query Request from ");
Pragaspathi Thilagaraj7fb14222019-06-17 23:26:58 +05304539 lim_print_mac_addr(mac, pe_session->self_mac_addr, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004540
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004541 if ((BAND_5G == lim_get_rf_band(pe_session->currentOperChannel))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004542#ifdef WLAN_FEATURE_P2P
Pragaspathi Thilagaraje64714a2019-05-23 00:46:25 +05304543 || (pe_session->opmode == QDF_P2P_CLIENT_MODE) ||
4544 (pe_session->opmode == QDF_P2P_GO_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004545#endif
Pragaspathi Thilagaraje64714a2019-05-23 00:46:25 +05304546 )
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004547 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
Pragaspathi Thilagaraje64714a2019-05-23 00:46:25 +05304548
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004549 smeSessionId = pe_session->smeSessionId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004550
Jeff Johnson99f25042018-11-21 22:49:06 -08004551 qdf_status = wma_tx_frame(mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004552 pPacket,
4553 (uint16_t) nBytes,
4554 TXRX_FRM_802_11_MGMT,
4555 ANI_TXDIR_TODS,
4556 7, lim_tx_complete, pFrame, txFlag,
Naveen Rawat296a5182017-09-25 14:02:48 -07004557 smeSessionId, 0, RATEID_DEFAULT);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304558 if (QDF_STATUS_SUCCESS != qdf_status) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004559 pe_err("wma_tx_frame FAILED! Status [%d]", qdf_status);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004560 nSirStatus = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004561 /* Pkt will be freed up by the callback */
4562 return nSirStatus;
4563 } else {
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004564 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004565 }
4566
4567returnAfterError:
4568 cds_packet_free((void *)pPacket);
4569 return nSirStatus;
4570} /* End lim_send_sa_query_request_frame */
4571
4572/**
4573 * \brief Send SA query response action frame to peer
4574 *
4575 * \sa lim_send_sa_query_response_frame
4576 *
4577 *
Jeff Johnson9320c1e2018-12-02 13:09:20 -08004578 * \param mac The global struct mac_context *object
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004579 *
4580 * \param transId Transaction identifier received in SA query request action frame
4581 *
4582 * \param peer The Mac address of the AP to which this action frame is addressed
4583 *
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004584 * \param pe_session The PE session entry
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004585 *
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004586 * \return QDF_STATUS_SUCCESS if setup completes successfully
4587 * QDF_STATUS_E_FAILURE is some problem is encountered
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004588 */
4589
Jeff Johnson9320c1e2018-12-02 13:09:20 -08004590QDF_STATUS lim_send_sa_query_response_frame(struct mac_context *mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004591 uint8_t *transId, tSirMacAddr peer,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004592 struct pe_session *pe_session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004593{
4594
Jeff Johnson47d75242018-05-12 15:58:53 -07004595 tDot11fSaQueryRsp frm; /* SA query response action frame */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004596 uint8_t *pFrame;
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004597 QDF_STATUS nSirStatus;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004598 tpSirMacMgmtHdr pMacHdr;
4599 uint32_t nBytes, nPayload, nStatus;
4600 void *pPacket;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304601 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004602 uint8_t txFlag = 0;
4603 uint8_t smeSessionId = 0;
4604
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004605 smeSessionId = pe_session->smeSessionId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004606
hangtian127c9532019-01-12 13:29:07 +08004607 qdf_mem_zero((uint8_t *) &frm, sizeof(frm));
Srinivas Girigowda48bec1c2019-05-17 16:33:30 -07004608 frm.Category.category = ACTION_CATEGORY_SA_QUERY;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004609 /*11w action field is :
4610 action: 0 --> SA query request action frame
4611 action: 1 --> SA query response action frame */
Srinivas Girigowdafeb23fc2019-06-13 11:12:29 -07004612 frm.Action.action = SA_QUERY_RESPONSE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004613 /*11w SA query response transId is same as
4614 SA query request transId */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304615 qdf_mem_copy(&frm.TransactionId.transId[0], &transId[0], 2);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004616
Jeff Johnson99f25042018-11-21 22:49:06 -08004617 nStatus = dot11f_get_packed_sa_query_rsp_size(mac, &frm, &nPayload);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004618 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004619 pe_err("Failed to calculate the packed size for a SA Query Response (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004620 nStatus);
4621 /* We'll fall back on the worst case scenario: */
4622 nPayload = sizeof(tDot11fSaQueryRsp);
4623 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004624 pe_warn("There were warnings while calculating the packed size for an SA Query Response (0x%08x)",
4625 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004626 }
4627
4628 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304629 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004630 cds_packet_alloc(nBytes, (void **)&pFrame, (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304631 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004632 pe_err("Failed to allocate %d bytes for a SA query response"
4633 " action frame", nBytes);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004634 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004635 }
4636 /* Paranoia: */
hangtian127c9532019-01-12 13:29:07 +08004637 qdf_mem_zero(pFrame, nBytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004638
4639 /* Copy necessary info to BD */
Jeff Johnson99f25042018-11-21 22:49:06 -08004640 lim_populate_mac_header(mac, pFrame, SIR_MAC_MGMT_FRAME,
Pragaspathi Thilagaraj7fb14222019-06-17 23:26:58 +05304641 SIR_MAC_MGMT_ACTION, peer, pe_session->self_mac_addr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004642
4643 /* Update A3 with the BSSID */
4644 pMacHdr = (tpSirMacMgmtHdr) pFrame;
4645
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004646 sir_copy_mac_addr(pMacHdr->bssId, pe_session->bssId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004647
4648 /* Since this is a SA Query Response, set the "protect" (aka WEP) bit */
4649 /* in the FC */
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004650 lim_set_protected_bit(mac, pe_session, peer, pMacHdr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004651
4652 /* Pack 11w SA query response frame */
Jeff Johnson99f25042018-11-21 22:49:06 -08004653 nStatus = dot11f_pack_sa_query_rsp(mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004654 &frm,
4655 pFrame + sizeof(tSirMacMgmtHdr),
4656 nPayload, &nPayload);
4657
4658 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004659 pe_err("Failed to pack an SA Query Response (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004660 nStatus);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004661 /* FIXME - Need to convert to QDF_STATUS */
4662 nSirStatus = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004663 goto returnAfterError;
4664 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004665 pe_warn("There were warnings while packing SA Query Response (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004666 nStatus);
4667 }
4668
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004669 pe_debug("Sending a SA Query Response to");
Jeff Johnson99f25042018-11-21 22:49:06 -08004670 lim_print_mac_addr(mac, peer, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004671
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004672 if ((BAND_5G == lim_get_rf_band(pe_session->currentOperChannel))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004673#ifdef WLAN_FEATURE_P2P
Pragaspathi Thilagaraje64714a2019-05-23 00:46:25 +05304674 || (pe_session->opmode == QDF_P2P_CLIENT_MODE) ||
4675 (pe_session->opmode == QDF_P2P_GO_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004676#endif
Pragaspathi Thilagaraje64714a2019-05-23 00:46:25 +05304677 )
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004678 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004679
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304680 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004681 pe_session->peSessionId, pMacHdr->fc.subType));
Jeff Johnson99f25042018-11-21 22:49:06 -08004682 qdf_status = wma_tx_frame(mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004683 pPacket,
4684 (uint16_t) nBytes,
4685 TXRX_FRM_802_11_MGMT,
4686 ANI_TXDIR_TODS,
4687 7, lim_tx_complete, pFrame, txFlag,
Naveen Rawat296a5182017-09-25 14:02:48 -07004688 smeSessionId, 0, RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304689 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004690 pe_session->peSessionId, qdf_status));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304691 if (QDF_STATUS_SUCCESS != qdf_status) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004692 pe_err("wma_tx_frame FAILED! Status [%d]", qdf_status);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004693 nSirStatus = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004694 /* Pkt will be freed up by the callback */
4695 return nSirStatus;
4696 } else {
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004697 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004698 }
4699
4700returnAfterError:
4701 cds_packet_free((void *)pPacket);
4702 return nSirStatus;
4703} /* End lim_send_sa_query_response_frame */
4704#endif
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004705
Jinwei Chen332b5cf2019-03-05 13:26:17 +08004706#if defined(QCA_WIFI_QCA6290) || defined(QCA_WIFI_QCA6390)
4707#ifdef WLAN_FEATURE_11AX
4708#define IS_PE_SESSION_11N_MODE(_session) \
4709 ((_session)->htCapability && !(_session)->vhtCapability && \
4710 !(_session)->he_capable)
4711#else
4712#define IS_PE_SESSION_11N_MODE(_session) \
4713 ((_session)->htCapability && !(_session)->vhtCapability)
4714#endif /* WLAN_FEATURE_11AX */
4715#else
4716#define IS_PE_SESSION_11N_MODE(_session) false
4717#endif
4718
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004719/**
4720 * lim_send_addba_response_frame(): Send ADDBA response action frame to peer
4721 * @mac_ctx: mac context
4722 * @peer_mac: Peer MAC address
4723 * @tid: TID for which addba response is being sent
4724 * @session: PE session entry
Kiran Kumar Lokere40875852018-01-15 12:36:19 -08004725 * @addba_extn_present: ADDBA extension present flag
Kiran Kumar Lokereaee823a2018-03-22 15:27:05 -07004726 * @amsdu_support: amsdu in ampdu support
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004727 *
4728 * This function is called when ADDBA request is successful. ADDBA response is
4729 * setup by calling addba_response_setup API and frame is then sent out OTA.
4730 *
4731 * Return: QDF_STATUS
4732 */
Jeff Johnson9320c1e2018-12-02 13:09:20 -08004733QDF_STATUS lim_send_addba_response_frame(struct mac_context *mac_ctx,
Kiran Kumar Lokere40875852018-01-15 12:36:19 -08004734 tSirMacAddr peer_mac, uint16_t tid,
Jeff Johnsona7815652018-11-18 22:58:30 -08004735 struct pe_session *session, uint8_t addba_extn_present,
Kiran Kumar Lokereaee823a2018-03-22 15:27:05 -07004736 uint8_t amsdu_support)
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004737{
4738
4739 tDot11faddba_rsp frm;
4740 uint8_t *frame_ptr;
4741 tpSirMacMgmtHdr mgmt_hdr;
4742 uint32_t num_bytes, payload_size, status;
Sandeep Puligilla39cec082018-04-30 15:18:45 -07004743 void *pkt_ptr = NULL;
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004744 QDF_STATUS qdf_status;
4745 uint8_t tx_flag = 0;
4746 uint8_t sme_sessionid = 0;
4747 uint16_t buff_size, status_code, batimeout;
4748 uint8_t peer_id, dialog_token;
4749 void *soc = cds_get_context(QDF_MODULE_ID_SOC);
4750 void *peer, *pdev;
Kiran Kumar Lokere40875852018-01-15 12:36:19 -08004751 uint8_t he_frag = 0;
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004752
4753 sme_sessionid = session->smeSessionId;
4754
4755 pdev = cds_get_context(QDF_MODULE_ID_TXRX);
4756 if (!pdev) {
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004757 pe_err("pdev is NULL");
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004758 return QDF_STATUS_E_FAILURE;
4759 }
4760
Mohit Khannac4c22252017-11-20 11:06:33 -08004761 peer = cdp_peer_get_ref_by_addr(soc, pdev, peer_mac, &peer_id,
4762 PEER_DEBUG_ID_LIM_SEND_ADDBA_RESP);
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004763 if (!peer) {
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004764 pe_err("PEER [%pM] not found", peer_mac);
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004765 return QDF_STATUS_E_FAILURE;
4766 }
4767
4768 cdp_addba_responsesetup(soc, peer, tid, &dialog_token,
4769 &status_code, &buff_size, &batimeout);
4770
Mohit Khannac4c22252017-11-20 11:06:33 -08004771 cdp_peer_release_ref(soc, peer, PEER_DEBUG_ID_LIM_SEND_ADDBA_RESP);
hangtian127c9532019-01-12 13:29:07 +08004772 qdf_mem_zero((uint8_t *) &frm, sizeof(frm));
Srinivas Girigowda48bec1c2019-05-17 16:33:30 -07004773 frm.Category.category = ACTION_CATEGORY_BACK;
Srinivas Girigowdaef0d7142019-05-17 17:07:47 -07004774 frm.Action.action = ADDBA_RESPONSE;
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004775
4776 frm.DialogToken.token = dialog_token;
4777 frm.Status.status = status_code;
Kiran Kumar Lokere08195ef2018-01-17 19:25:15 -08004778 if (mac_ctx->reject_addba_req) {
4779 frm.Status.status = eSIR_MAC_REQ_DECLINED_STATUS;
4780 pe_err("refused addba req");
4781 }
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004782 frm.addba_param_set.tid = tid;
Kiran Kumar Lokere22f05d42019-06-28 18:33:43 -07004783 if (lim_is_session_he_capable(session))
4784 frm.addba_param_set.buff_size = MAX_BA_BUFF_SIZE;
4785 else
4786 frm.addba_param_set.buff_size = SIR_MAC_BA_DEFAULT_BUFF_SIZE;
Kiran Kumar Lokerebc87bec2018-02-27 20:06:42 -08004787 if (mac_ctx->usr_cfg_ba_buff_size)
4788 frm.addba_param_set.buff_size = mac_ctx->usr_cfg_ba_buff_size;
Kiran Kumar Lokereeac7fe92018-07-24 16:56:01 -07004789
4790 if (frm.addba_param_set.buff_size > MAX_BA_BUFF_SIZE)
4791 frm.addba_param_set.buff_size = MAX_BA_BUFF_SIZE;
4792
4793 if (frm.addba_param_set.buff_size > SIR_MAC_BA_DEFAULT_BUFF_SIZE) {
4794 if (session->active_ba_64_session) {
4795 frm.addba_param_set.buff_size =
4796 SIR_MAC_BA_DEFAULT_BUFF_SIZE;
4797 }
4798 } else if (!session->active_ba_64_session) {
4799 session->active_ba_64_session = true;
4800 }
Jinwei Chen332b5cf2019-03-05 13:26:17 +08004801
4802 /* disable 11n RX AMSDU */
4803 if (mac_ctx->is_usr_cfg_amsdu_enabled &&
4804 !IS_PE_SESSION_11N_MODE(session))
Arif Hussain0e246802018-05-01 18:13:44 -07004805 frm.addba_param_set.amsdu_supp = amsdu_support;
4806 else
4807 frm.addba_param_set.amsdu_supp = 0;
Jinwei Chen332b5cf2019-03-05 13:26:17 +08004808
Kiran Kumar Lokerebc87bec2018-02-27 20:06:42 -08004809 frm.addba_param_set.policy = SIR_MAC_BA_POLICY_IMMEDIATE;
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004810 frm.ba_timeout.timeout = batimeout;
Kiran Kumar Lokere40875852018-01-15 12:36:19 -08004811 if (addba_extn_present) {
4812 frm.addba_extn_element.present = 1;
4813 frm.addba_extn_element.no_fragmentation = 1;
4814 if (lim_is_session_he_capable(session)) {
4815 he_frag = lim_get_session_he_frag_cap(session);
4816 if (he_frag != 0) {
4817 frm.addba_extn_element.no_fragmentation = 0;
4818 frm.addba_extn_element.he_frag_operation =
4819 he_frag;
4820 }
4821 }
4822 }
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004823
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004824 pe_debug("Sending a ADDBA Response from %pM to %pM",
Pragaspathi Thilagaraj7fb14222019-06-17 23:26:58 +05304825 session->self_mac_addr, peer_mac);
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004826 pe_debug("tid: %d, dialog_token: %d, status: %d, buff_size: %d",
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004827 tid, frm.DialogToken.token, frm.Status.status,
4828 frm.addba_param_set.buff_size);
Kiran Kumar Lokere40875852018-01-15 12:36:19 -08004829 pe_debug("addba_extn %d he_capable %d no_frag %d he_frag %d",
4830 addba_extn_present,
4831 lim_is_session_he_capable(session),
4832 frm.addba_extn_element.no_fragmentation,
4833 frm.addba_extn_element.he_frag_operation);
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004834
4835 status = dot11f_get_packed_addba_rsp_size(mac_ctx, &frm, &payload_size);
4836 if (DOT11F_FAILED(status)) {
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004837 pe_err("Failed to calculate the packed size for a ADDBA Response (0x%08x).",
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004838 status);
4839 /* We'll fall back on the worst case scenario: */
4840 payload_size = sizeof(tDot11faddba_rsp);
4841 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004842 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 -08004843 }
4844
4845 num_bytes = payload_size + sizeof(*mgmt_hdr);
4846 qdf_status = cds_packet_alloc(num_bytes, (void **)&frame_ptr,
4847 (void **)&pkt_ptr);
Sandeep Puligilla39cec082018-04-30 15:18:45 -07004848 if (!QDF_IS_STATUS_SUCCESS(qdf_status) || (!pkt_ptr)) {
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004849 pe_err("Failed to allocate %d bytes for a ADDBA response action frame",
4850 num_bytes);
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004851 return QDF_STATUS_E_FAILURE;
4852 }
hangtian127c9532019-01-12 13:29:07 +08004853 qdf_mem_zero(frame_ptr, num_bytes);
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004854
4855 lim_populate_mac_header(mac_ctx, frame_ptr, SIR_MAC_MGMT_FRAME,
Pragaspathi Thilagaraj7fb14222019-06-17 23:26:58 +05304856 SIR_MAC_MGMT_ACTION, peer_mac, session->self_mac_addr);
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004857
4858 /* Update A3 with the BSSID */
4859 mgmt_hdr = (tpSirMacMgmtHdr) frame_ptr;
4860 sir_copy_mac_addr(mgmt_hdr->bssId, session->bssId);
4861
4862 /* ADDBA Response is a robust mgmt action frame,
4863 * set the "protect" (aka WEP) bit in the FC
4864 */
4865 lim_set_protected_bit(mac_ctx, session, peer_mac, mgmt_hdr);
4866
4867 status = dot11f_pack_addba_rsp(mac_ctx, &frm,
4868 frame_ptr + sizeof(tSirMacMgmtHdr), payload_size,
4869 &payload_size);
4870
4871 if (DOT11F_FAILED(status)) {
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004872 pe_err("Failed to pack a ADDBA Response (0x%08x)",
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004873 status);
4874 qdf_status = QDF_STATUS_E_FAILURE;
4875 goto error_addba_rsp;
4876 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004877 pe_warn("There were warnings while packing ADDBA Response (0x%08x)",
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004878 status);
4879 }
4880
4881
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08004882 if ((BAND_5G == lim_get_rf_band(session->currentOperChannel))
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004883#ifdef WLAN_FEATURE_P2P
Pragaspathi Thilagaraje64714a2019-05-23 00:46:25 +05304884 || (session->opmode == QDF_P2P_CLIENT_MODE) ||
4885 (session->opmode == QDF_P2P_GO_MODE)
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004886#endif
Pragaspathi Thilagaraje64714a2019-05-23 00:46:25 +05304887 )
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004888 tx_flag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004889
4890 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
4891 session->peSessionId, mgmt_hdr->fc.subType));
Krunal Sonid2136c72018-06-01 17:26:39 -07004892 qdf_status = wma_tx_frameWithTxComplete(mac_ctx, pkt_ptr,
4893 (uint16_t)num_bytes,
4894 TXRX_FRM_802_11_MGMT,
4895 ANI_TXDIR_TODS, 7,
4896 NULL, frame_ptr,
4897 lim_addba_rsp_tx_complete_cnf,
4898 tx_flag, sme_sessionid,
4899 false, 0, RATEID_DEFAULT);
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004900 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
4901 session->peSessionId, qdf_status));
4902 if (QDF_STATUS_SUCCESS != qdf_status) {
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004903 pe_err("wma_tx_frame FAILED! Status [%d]",
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004904 qdf_status);
chenguo90c68462019-01-24 18:27:01 +08004905 return QDF_STATUS_E_FAILURE;
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004906 } else {
Tushnim Bhattacharyyad58e4c92018-03-27 13:40:12 -07004907 return QDF_STATUS_SUCCESS;
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004908 }
4909
4910error_addba_rsp:
4911 cds_packet_free((void *)pkt_ptr);
4912 return qdf_status;
4913}
Padma, Santhosh Kumar22c462c2018-01-16 17:56:44 +05304914
4915/**
4916 * lim_tx_mgmt_frame() - Transmits Auth mgmt frame
4917 * @mac_ctx Pointer to Global MAC structure
4918 * @mb_msg: Received message info
4919 * @msg_len: Received message length
4920 * @packet: Packet to be transmitted
4921 * @frame: Received frame
4922 *
4923 * Return: None
4924 */
Jeff Johnson9320c1e2018-12-02 13:09:20 -08004925static void lim_tx_mgmt_frame(struct mac_context *mac_ctx,
Padma, Santhosh Kumar22c462c2018-01-16 17:56:44 +05304926 struct sir_mgmt_msg *mb_msg, uint32_t msg_len,
4927 void *packet, uint8_t *frame)
4928{
4929 tpSirMacFrameCtl fc = (tpSirMacFrameCtl) mb_msg->data;
4930 QDF_STATUS qdf_status;
4931 uint8_t sme_session_id = 0;
Jeff Johnsona7815652018-11-18 22:58:30 -08004932 struct pe_session *session;
Padma, Santhosh Kumar22c462c2018-01-16 17:56:44 +05304933 uint16_t auth_ack_status;
4934 enum rateid min_rid = RATEID_DEFAULT;
4935
4936 sme_session_id = mb_msg->session_id;
4937 session = pe_find_session_by_sme_session_id(mac_ctx, sme_session_id);
Jeff Johnson8e9530b2019-03-18 13:41:42 -07004938 if (!session) {
Wu Gao7c0a23f2019-03-12 14:16:37 +08004939 cds_packet_free((void *)packet);
4940 pe_err("session not found for given sme session %d",
4941 sme_session_id);
Padma, Santhosh Kumar22c462c2018-01-16 17:56:44 +05304942 return;
4943 }
4944
Ashish Kumar Dhanotiya9f72df02018-07-23 19:20:04 +05304945 qdf_mtrace(QDF_MODULE_ID_PE, QDF_MODULE_ID_WMA, TRACE_CODE_TX_MGMT,
4946 session->peSessionId, 0);
Padma, Santhosh Kumar22c462c2018-01-16 17:56:44 +05304947
4948 mac_ctx->auth_ack_status = LIM_AUTH_ACK_NOT_RCD;
4949 min_rid = lim_get_min_session_txrate(session);
4950
4951 qdf_status = wma_tx_frameWithTxComplete(mac_ctx, packet,
4952 (uint16_t)msg_len,
4953 TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS,
4954 7, lim_tx_complete, frame,
4955 lim_auth_tx_complete_cnf,
4956 0, sme_session_id, false, 0, min_rid);
4957 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
4958 session->peSessionId, qdf_status));
4959 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Rachit Kankane0baf6e72018-01-19 15:01:50 +05304960 pe_err("*** Could not send Auth frame (subType: %d), retCode=%X ***",
4961 fc->subType, qdf_status);
Padma, Santhosh Kumar22c462c2018-01-16 17:56:44 +05304962 mac_ctx->auth_ack_status = LIM_AUTH_ACK_RCD_FAILURE;
4963 auth_ack_status = SENT_FAIL;
4964 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_AUTH_ACK_EVENT,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004965 session, auth_ack_status, QDF_STATUS_E_FAILURE);
Padma, Santhosh Kumar22c462c2018-01-16 17:56:44 +05304966 /* Pkt will be freed up by the callback */
4967 }
4968}
4969
Jeff Johnson9320c1e2018-12-02 13:09:20 -08004970void lim_send_mgmt_frame_tx(struct mac_context *mac_ctx,
Padma, Santhosh Kumar22c462c2018-01-16 17:56:44 +05304971 struct scheduler_msg *msg)
4972{
4973 struct sir_mgmt_msg *mb_msg = (struct sir_mgmt_msg *)msg->bodyptr;
4974 uint32_t msg_len;
4975 tpSirMacFrameCtl fc = (tpSirMacFrameCtl) mb_msg->data;
4976 uint8_t sme_session_id;
4977 QDF_STATUS qdf_status;
4978 uint8_t *frame;
4979 void *packet;
Srinivas Dasari76218492019-01-22 15:08:20 +05304980 tpSirMacMgmtHdr mac_hdr;
Padma, Santhosh Kumar22c462c2018-01-16 17:56:44 +05304981
4982 msg_len = mb_msg->msg_len - sizeof(*mb_msg);
4983 pe_debug("sending fc->type: %d fc->subType: %d",
4984 fc->type, fc->subType);
4985
4986 sme_session_id = mb_msg->session_id;
Srinivas Dasari76218492019-01-22 15:08:20 +05304987 mac_hdr = (tpSirMacMgmtHdr)mb_msg->data;
4988
4989 lim_add_mgmt_seq_num(mac_ctx, mac_hdr);
Padma, Santhosh Kumar22c462c2018-01-16 17:56:44 +05304990
4991 qdf_status = cds_packet_alloc((uint16_t) msg_len, (void **)&frame,
4992 (void **)&packet);
4993 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
4994 pe_err("call to bufAlloc failed for AUTH frame");
4995 return;
4996 }
4997
4998 qdf_mem_copy(frame, mb_msg->data, msg_len);
4999
5000 lim_tx_mgmt_frame(mac_ctx, mb_msg, msg_len, packet, frame);
5001}