blob: 8cc48ff342fcbcfdf04e673d28bca76d1765e370 [file] [log] [blame]
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001/*
Ashish Kumar Dhanotiya443d31f2017-10-13 12:41:19 +05302 * Copyright (c) 2012-2018 The Linux Foundation. All rights reserved.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003 *
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004 * Permission to use, copy, modify, and/or distribute this software for
5 * any purpose with or without fee is hereby granted, provided that the
6 * above copyright notice and this permission notice appear in all
7 * copies.
8 *
9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
10 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
11 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
12 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
13 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
14 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
15 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
16 * PERFORMANCE OF THIS SOFTWARE.
17 */
18
19/*
Naveen Rawatada5fac2016-01-28 16:24:32 -080020 * This file lim_process_assoc_req_frame.c contains the code
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080021 * for processing Re/Association Request Frame.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080022 */
23#include "cds_api.h"
24#include "ani_global.h"
25#include "wni_cfg.h"
26#include "sir_api.h"
27#include "cfg_api.h"
28
29#include "sch_api.h"
30#include "utils_api.h"
31#include "lim_types.h"
32#include "lim_utils.h"
33#include "lim_assoc_utils.h"
34#include "lim_security_utils.h"
35#include "lim_ser_des_utils.h"
36#include "lim_sta_hash_api.h"
37#include "lim_admit_control.h"
38#include "cds_packet.h"
39#include "lim_session_utils.h"
40
Anurag Chouhan6d760662016-02-20 16:05:43 +053041#include "qdf_types.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080042#include "cds_utils.h"
Naveen Rawat08db88f2017-09-08 15:07:48 -070043#include "wlan_utility.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080044
45/**
46 * lim_convert_supported_channels - Parses channel support IE
Krunal Soni99752a12016-04-12 17:44:45 -070047 * @mac_ctx: A pointer to Global MAC structure
48 * @assoc_ind: A pointer to SME ASSOC/REASSOC IND
49 * @assoc_req: A pointer to ASSOC/REASSOC Request frame
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080050 *
51 * This function is called by lim_process_assoc_req_frame() to
52 * parse the channel support IE in the Assoc/Reassoc Request
53 * frame, and send relevant information in the SME_ASSOC_IND
54 *
Krunal Soni99752a12016-04-12 17:44:45 -070055 * Return: None
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080056 */
Krunal Soni99752a12016-04-12 17:44:45 -070057static void lim_convert_supported_channels(tpAniSirGlobal mac_ctx,
58 tpLimMlmAssocInd assoc_ind,
59 tSirAssocReq *assoc_req)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080060{
61 uint16_t i, j, index = 0;
Naveen Rawatada5fac2016-01-28 16:24:32 -080062 uint8_t first_ch_no;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080063 uint8_t chn_count;
Naveen Rawatada5fac2016-01-28 16:24:32 -080064 uint8_t next_ch_no;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080065 uint8_t channel_offset = 0;
66
67 if (assoc_req->supportedChannels.length >=
68 SIR_MAX_SUPPORTED_CHANNEL_LIST) {
Nishank Aggarwal8935e442017-03-23 19:11:08 +053069 pe_err("Number of supported channels: %d is more than MAX",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080070 assoc_req->supportedChannels.length);
71 assoc_ind->supportedChannels.numChnl = 0;
72 return;
73 }
74
75 for (i = 0; i < (assoc_req->supportedChannels.length); i++) {
76 /* Get First Channel Number */
Naveen Rawatada5fac2016-01-28 16:24:32 -080077 first_ch_no = assoc_req->supportedChannels.supportedChannels[i];
78 assoc_ind->supportedChannels.channelList[index] = first_ch_no;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080079 i++;
80 index++;
81
82 /* Get Number of Channels in a Subband */
Naveen Rawatada5fac2016-01-28 16:24:32 -080083 chn_count = assoc_req->supportedChannels.supportedChannels[i];
Nishank Aggarwal8935e442017-03-23 19:11:08 +053084 pe_debug("Rcv assoc_req: chnl: %d numOfChnl: %d",
Naveen Rawatada5fac2016-01-28 16:24:32 -080085 first_ch_no, chn_count);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080086 if (index >= SIR_MAX_SUPPORTED_CHANNEL_LIST) {
Nishank Aggarwal8935e442017-03-23 19:11:08 +053087 pe_warn("Ch count > max supported: %d", chn_count);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080088 assoc_ind->supportedChannels.numChnl = 0;
89 return;
90 }
91 if (chn_count <= 1)
92 continue;
Naveen Rawatada5fac2016-01-28 16:24:32 -080093 next_ch_no = first_ch_no;
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -080094 if (BAND_5G == lim_get_rf_band(first_ch_no))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080095 channel_offset = SIR_11A_FREQUENCY_OFFSET;
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -080096 else if (BAND_2G == lim_get_rf_band(first_ch_no))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080097 channel_offset = SIR_11B_FREQUENCY_OFFSET;
98 else
99 continue;
100
101 for (j = 1; j < chn_count; j++) {
Naveen Rawatada5fac2016-01-28 16:24:32 -0800102 next_ch_no += channel_offset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800103 assoc_ind->supportedChannels.channelList[index]
Naveen Rawatada5fac2016-01-28 16:24:32 -0800104 = next_ch_no;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800105 index++;
106 if (index >= SIR_MAX_SUPPORTED_CHANNEL_LIST) {
Nishank Aggarwal8935e442017-03-23 19:11:08 +0530107 pe_warn("Ch count > supported: %d", chn_count);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800108 assoc_ind->supportedChannels.numChnl = 0;
109 return;
110 }
111 }
112 }
113
114 assoc_ind->supportedChannels.numChnl = (uint8_t) index;
Nishank Aggarwal8935e442017-03-23 19:11:08 +0530115 pe_debug("Send AssocInd to WSM: minPwr: %d maxPwr: %d numChnl: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800116 assoc_ind->powerCap.minTxPower,
117 assoc_ind->powerCap.maxTxPower,
Naveen Rawatada5fac2016-01-28 16:24:32 -0800118 assoc_ind->supportedChannels.numChnl);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800119}
120
Naveen Rawatada5fac2016-01-28 16:24:32 -0800121/**
122 * lim_check_sta_in_pe_entries() - checks if sta exists in any dph tables.
Krunal Soni99752a12016-04-12 17:44:45 -0700123 * @mac_ctx: Pointer to Global MAC structure
124 * @hdr: A pointer to the MAC header
Poddar, Siddarth7ca1e082016-08-09 19:06:48 +0530125 * @sessionid - session id for which session is initiated
Naveen Rawatada5fac2016-01-28 16:24:32 -0800126 *
127 * This function is called by lim_process_assoc_req_frame() to check if STA
128 * entry already exists in any of the PE entries of the AP. If it exists, deauth
129 * will be sent on that session and the STA deletion will happen. After this,
130 * the ASSOC request will be processed
131 *
Sandeep Puligilla7e3e3c52016-09-02 17:54:21 -0700132 * Return: True if duplicate entry found; FALSE otherwise.
Naveen Rawatada5fac2016-01-28 16:24:32 -0800133 */
Sandeep Puligilla7e3e3c52016-09-02 17:54:21 -0700134static bool lim_check_sta_in_pe_entries(tpAniSirGlobal mac_ctx, tpSirMacMgmtHdr hdr,
Poddar, Siddarth7ca1e082016-08-09 19:06:48 +0530135 uint16_t sessionid)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800136{
137 uint8_t i;
Naveen Rawatada5fac2016-01-28 16:24:32 -0800138 uint16_t assoc_id = 0;
139 tpDphHashNode sta_ds = NULL;
140 tpPESession session = NULL;
Sandeep Puligilla7e3e3c52016-09-02 17:54:21 -0700141 bool dup_entry = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800142
Naveen Rawatada5fac2016-01-28 16:24:32 -0800143 for (i = 0; i < mac_ctx->lim.maxBssId; i++) {
144 if ((&mac_ctx->lim.gpSession[i] != NULL) &&
145 (mac_ctx->lim.gpSession[i].valid) &&
146 (mac_ctx->lim.gpSession[i].pePersona == QDF_SAP_MODE)) {
147 session = &mac_ctx->lim.gpSession[i];
148 sta_ds = dph_lookup_hash_entry(mac_ctx, hdr->sa,
149 &assoc_id, &session->dph.dphHashTable);
150 if (sta_ds
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800151#ifdef WLAN_FEATURE_11W
Poddar, Siddarth7ca1e082016-08-09 19:06:48 +0530152 && (!sta_ds->rmfEnabled ||
153 (sessionid != session->peSessionId))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800154#endif
155 ) {
Nishank Aggarwal8935e442017-03-23 19:11:08 +0530156 pe_err("Sending Disassoc and Deleting existing STA entry:"
157 MAC_ADDRESS_STR,
Naveen Rawatada5fac2016-01-28 16:24:32 -0800158 MAC_ADDR_ARRAY(session->selfMacAddr));
Sandeep Puligilla2eeaf6a2016-07-22 20:02:02 -0700159 lim_send_disassoc_mgmt_frame(mac_ctx,
Naveen Rawatada5fac2016-01-28 16:24:32 -0800160 eSIR_MAC_UNSPEC_FAILURE_REASON,
161 (uint8_t *) hdr->sa, session, false);
Sandeep Puligilla2eeaf6a2016-07-22 20:02:02 -0700162 /*
163 * Cleanup Rx path posts eWNI_SME_DISASSOC_RSP
164 * msg to SME after delete sta which will update
165 * the userspace with disconnect
166 */
Sandeep Puligilla7e3e3c52016-09-02 17:54:21 -0700167 sta_ds->mlmStaContext.cleanupTrigger =
168 eLIM_DUPLICATE_ENTRY;
169 sta_ds->mlmStaContext.disassocReason =
170 eSIR_MAC_DISASSOC_DUE_TO_INACTIVITY_REASON;
171 lim_send_sme_disassoc_ind(mac_ctx, sta_ds,
172 session);
173 dup_entry = true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800174 break;
175 }
176 }
177 }
Sandeep Puligilla7e3e3c52016-09-02 17:54:21 -0700178 return dup_entry;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800179}
180
Naveen Rawatada5fac2016-01-28 16:24:32 -0800181/**
Krunal Soni99752a12016-04-12 17:44:45 -0700182 * lim_chk_sa_da() - checks source addr to destination addr of assoc req frame
183 * @mac_ctx: pointer to Global MAC structure
184 * @hdr: pointer to the MAC head
185 * @session: pointer to pe session entry
186 * @sub_type: Assoc(=0) or Reassoc(=1) Requestframe
Naveen Rawatada5fac2016-01-28 16:24:32 -0800187 *
Krunal Soni99752a12016-04-12 17:44:45 -0700188 * Checks source addr to destination addr of assoc req frame
Naveen Rawatada5fac2016-01-28 16:24:32 -0800189 *
Ankit Guptaa5076012016-09-14 11:32:19 -0700190 * Return: true if source and destination address are different
Naveen Rawatada5fac2016-01-28 16:24:32 -0800191 */
Krunal Soni99752a12016-04-12 17:44:45 -0700192static bool lim_chk_sa_da(tpAniSirGlobal mac_ctx, tpSirMacMgmtHdr hdr,
193 tpPESession session, uint8_t sub_type)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800194{
Ankit Guptaa5076012016-09-14 11:32:19 -0700195 if (qdf_mem_cmp((uint8_t *) hdr->sa,
Krunal Soni99752a12016-04-12 17:44:45 -0700196 (uint8_t *) hdr->da,
Ankit Guptaa5076012016-09-14 11:32:19 -0700197 (uint8_t) (sizeof(tSirMacAddr))))
Krunal Soni99752a12016-04-12 17:44:45 -0700198 return true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800199
Nishank Aggarwal8935e442017-03-23 19:11:08 +0530200 pe_err("Assoc Req rejected: wlan.sa = wlan.da");
Krunal Soni99752a12016-04-12 17:44:45 -0700201 lim_send_assoc_rsp_mgmt_frame(mac_ctx, eSIR_MAC_UNSPEC_FAILURE_STATUS,
202 1, hdr->sa, sub_type, 0, session);
203 return false;
204}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800205
Krunal Soni99752a12016-04-12 17:44:45 -0700206/**
207 * lim_chk_tkip() - checks TKIP counter measure is active
208 * @mac_ctx: pointer to Global MAC structure
209 * @hdr: pointer to the MAC head
210 * @session: pointer to pe session entry
211 * @sub_type: Assoc(=0) or Reassoc(=1) Requestframe
212 *
213 * Checks TKIP counter measure is active
214 *
215 * Return: true of no error, false otherwise
216 */
217static bool lim_chk_tkip(tpAniSirGlobal mac_ctx, tpSirMacMgmtHdr hdr,
218 tpPESession session, uint8_t sub_type)
219{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800220 /*
Krunal Soni99752a12016-04-12 17:44:45 -0700221 * If TKIP counter measures active send Assoc Rsp frame to station
222 * with eSIR_MAC_MIC_FAILURE_REASON
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800223 */
Krunal Soni99752a12016-04-12 17:44:45 -0700224 if (!(session->bTkipCntrMeasActive && LIM_IS_AP_ROLE(session)))
225 return true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800226
Nishank Aggarwal8935e442017-03-23 19:11:08 +0530227 pe_err("Assoc Req rejected: TKIP counter measure is active");
Krunal Soni99752a12016-04-12 17:44:45 -0700228 lim_send_assoc_rsp_mgmt_frame(mac_ctx, eSIR_MAC_MIC_FAILURE_REASON, 1,
229 hdr->sa, sub_type, 0, session);
230 return false;
231}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800232
Krunal Soni99752a12016-04-12 17:44:45 -0700233/**
234 * lim_chk_assoc_req_parse_error() - checks for error in frame parsing
235 * @mac_ctx: pointer to Global MAC structure
236 * @hdr: pointer to the MAC head
237 * @session: pointer to pe session entry
238 * @assoc_req: pointer to ASSOC/REASSOC Request frame
239 * @sub_type: Assoc(=0) or Reassoc(=1) Requestframe
240 * @frm_body: frame body
241 * @frame_len: frame len
242 *
243 * Checks for error in frame parsing
244 *
245 * Return: true of no error, false otherwise
246 */
247static bool lim_chk_assoc_req_parse_error(tpAniSirGlobal mac_ctx,
248 tpSirMacMgmtHdr hdr,
249 tpPESession session,
250 tpSirAssocReq assoc_req,
251 uint8_t sub_type, uint8_t *frm_body,
Krishna Kumaar Natarajandb582ec2016-03-08 17:37:04 -0800252 uint32_t frame_len)
Krunal Soni99752a12016-04-12 17:44:45 -0700253{
254 tSirRetStatus status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800255
Naveen Rawatada5fac2016-01-28 16:24:32 -0800256 if (sub_type == LIM_ASSOC)
Krunal Soni99752a12016-04-12 17:44:45 -0700257 status = sir_convert_assoc_req_frame2_struct(mac_ctx, frm_body,
258 frame_len, assoc_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800259 else
Krunal Soni99752a12016-04-12 17:44:45 -0700260 status = sir_convert_reassoc_req_frame2_struct(mac_ctx,
261 frm_body, frame_len, assoc_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800262
Krunal Soni99752a12016-04-12 17:44:45 -0700263 if (status == eSIR_SUCCESS)
264 return true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800265
Nishank Aggarwal8935e442017-03-23 19:11:08 +0530266 pe_warn("Assoc Req rejected: frame parsing error. source addr:"
267 MAC_ADDRESS_STR, MAC_ADDR_ARRAY(hdr->sa));
Krunal Soni99752a12016-04-12 17:44:45 -0700268 lim_send_assoc_rsp_mgmt_frame(mac_ctx, eSIR_MAC_UNSPEC_FAILURE_STATUS,
269 1, hdr->sa, sub_type, 0, session);
270 return false;
271}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800272
Krunal Soni99752a12016-04-12 17:44:45 -0700273/**
274 * lim_chk_capab() - checks for capab match
275 * @mac_ctx: pointer to Global MAC structure
276 * @hdr: pointer to the MAC head
277 * @session: pointer to pe session entry
278 * @assoc_req: pointer to ASSOC/REASSOC Request frame
279 * @sub_type: Assoc(=0) or Reassoc(=1) Requestframe
280 * @local_cap: local capabilities of SAP
281 *
282 * Checks for capab match
283 *
284 * Return: true of no error, false otherwise
285 */
286static bool lim_chk_capab(tpAniSirGlobal mac_ctx, tpSirMacMgmtHdr hdr,
287 tpPESession session, tpSirAssocReq assoc_req,
288 uint8_t sub_type, tSirMacCapabilityInfo *local_cap)
289{
290 uint16_t temp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800291
Naveen Rawatada5fac2016-01-28 16:24:32 -0800292 if (cfg_get_capability_info(mac_ctx, &temp, session) != eSIR_SUCCESS) {
Nishank Aggarwal8935e442017-03-23 19:11:08 +0530293 pe_err("could not retrieve Capabilities");
Krunal Soni99752a12016-04-12 17:44:45 -0700294 return false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800295 }
Krunal Soni99752a12016-04-12 17:44:45 -0700296
297 lim_copy_u16((uint8_t *) local_cap, temp);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800298
Naveen Rawatada5fac2016-01-28 16:24:32 -0800299 if (lim_compare_capabilities(mac_ctx, assoc_req,
Krunal Soni99752a12016-04-12 17:44:45 -0700300 local_cap, session) == false) {
Nishank Aggarwal8935e442017-03-23 19:11:08 +0530301 pe_warn("Rcvd %s Req with unsupported capab from"
302 MAC_ADDRESS_STR,
Naveen Rawatada5fac2016-01-28 16:24:32 -0800303 (LIM_ASSOC == sub_type) ? "Assoc" : "ReAssoc",
304 MAC_ADDR_ARRAY(hdr->sa));
Krunal Soni99752a12016-04-12 17:44:45 -0700305 /*
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800306 * Capabilities of requesting STA does not match with
307 * local capabilities. Respond with 'unsupported capabilities'
308 * status code.
309 */
Naveen Rawatada5fac2016-01-28 16:24:32 -0800310 lim_send_assoc_rsp_mgmt_frame(mac_ctx,
Krunal Soni99752a12016-04-12 17:44:45 -0700311 eSIR_MAC_CAPABILITIES_NOT_SUPPORTED_STATUS,
312 1, hdr->sa, sub_type, 0, session);
313 return false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800314 }
Krunal Soni99752a12016-04-12 17:44:45 -0700315 return true;
316}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800317
Krunal Soni99752a12016-04-12 17:44:45 -0700318/**
319 * lim_chk_ssid() - checks for SSID match
320 * @mac_ctx: pointer to Global MAC structure
321 * @hdr: pointer to the MAC head
322 * @session: pointer to pe session entry
323 * @assoc_req: pointer to ASSOC/REASSOC Request frame
324 * @sub_type: Assoc(=0) or Reassoc(=1) Requestframe
325 *
326 * Checks for SSID match
327 *
328 * Return: true of no error, false otherwise
329 */
330static bool lim_chk_ssid(tpAniSirGlobal mac_ctx, tpSirMacMgmtHdr hdr,
331 tpPESession session, tpSirAssocReq assoc_req,
332 uint8_t sub_type)
333{
334 if (lim_cmp_ssid(&assoc_req->ssId, session) != true)
335 return true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800336
Nishank Aggarwal8935e442017-03-23 19:11:08 +0530337 pe_err("%s Req with ssid wrong(Rcvd: %.*s self: %.*s) from "
338 MAC_ADDRESS_STR,
Krunal Soni99752a12016-04-12 17:44:45 -0700339 (LIM_ASSOC == sub_type) ? "Assoc" : "ReAssoc",
340 assoc_req->ssId.length, assoc_req->ssId.ssId,
341 session->ssId.length, session->ssId.ssId,
342 MAC_ADDR_ARRAY(hdr->sa));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800343
Krunal Soni99752a12016-04-12 17:44:45 -0700344 /*
345 * Received Re/Association Request with either Broadcast SSID OR with
346 * SSID that does not match with local one. Respond with unspecified
347 * status code.
348 */
349 lim_send_assoc_rsp_mgmt_frame(mac_ctx, eSIR_MAC_UNSPEC_FAILURE_STATUS,
350 1, hdr->sa, sub_type, 0, session);
351 return false;
352}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800353
Krunal Soni99752a12016-04-12 17:44:45 -0700354/**
355 * lim_chk_rates() - checks for supported rates
356 * @mac_ctx: pointer to Global MAC structure
357 * @hdr: pointer to the MAC head
358 * @session: pointer to pe session entry
359 * @assoc_req: pointer to ASSOC/REASSOC Request frame
360 * @sub_type: Assoc(=0) or Reassoc(=1) Requestframe
361 *
362 * Checks for supported rates
363 *
364 * Return: true of no error, false otherwise
365 */
366static bool lim_chk_rates(tpAniSirGlobal mac_ctx, tpSirMacMgmtHdr hdr,
367 tpPESession session, tpSirAssocReq assoc_req,
368 uint8_t sub_type)
369{
370 uint8_t i = 0, j = 0;
371 tSirMacRateSet basic_rates;
372 /*
373 * Verify if the requested rates are available in supported rate
374 * set or Extended rate set. Some APs are adding basic rates in
375 * Extended rateset IE
376 */
Naveen Rawatada5fac2016-01-28 16:24:32 -0800377 basic_rates.numRates = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800378
Krunal Soni99752a12016-04-12 17:44:45 -0700379 for (i = 0; i < assoc_req->supportedRates.numRates
380 && (i < SIR_MAC_RATESET_EID_MAX); i++) {
Naveen Rawatada5fac2016-01-28 16:24:32 -0800381 basic_rates.rate[i] = assoc_req->supportedRates.rate[i];
382 basic_rates.numRates++;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800383 }
384
Krunal Soni99752a12016-04-12 17:44:45 -0700385 for (j = 0; (j < assoc_req->extendedRates.numRates)
386 && (i < SIR_MAC_RATESET_EID_MAX); i++, j++) {
Naveen Rawatada5fac2016-01-28 16:24:32 -0800387 basic_rates.rate[i] = assoc_req->extendedRates.rate[j];
388 basic_rates.numRates++;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800389 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800390
Krunal Soni99752a12016-04-12 17:44:45 -0700391 if (lim_check_rx_basic_rates(mac_ctx, basic_rates, session) == true)
392 return true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800393
Nishank Aggarwal8935e442017-03-23 19:11:08 +0530394 pe_warn("Assoc Req rejected: unsupported rates, soruce addr: %s"
395 MAC_ADDRESS_STR,
Krunal Soni99752a12016-04-12 17:44:45 -0700396 (LIM_ASSOC == sub_type) ? "Assoc" : "ReAssoc",
397 MAC_ADDR_ARRAY(hdr->sa));
398 /*
399 * Requesting STA does not support ALL BSS basic rates. Respond with
400 * 'basic rates not supported' status code.
401 */
402 lim_send_assoc_rsp_mgmt_frame(mac_ctx,
403 eSIR_MAC_BASIC_RATES_NOT_SUPPORTED_STATUS, 1,
404 hdr->sa, sub_type, 0, session);
405 return false;
406}
407
408/**
409 * lim_chk_11g_only() - checks for non 11g STA
410 * @mac_ctx: pointer to Global MAC structure
411 * @hdr: pointer to the MAC head
412 * @session: pointer to pe session entry
413 * @assoc_req: pointer to ASSOC/REASSOC Request frame
414 * @sub_type: Assoc(=0) or Reassoc(=1) Requestframe
415 *
416 * Checks for non 11g STA
417 *
418 * Return: true of no error, false otherwise
419 */
420static bool lim_chk_11g_only(tpAniSirGlobal mac_ctx, tpSirMacMgmtHdr hdr,
421 tpPESession session, tpSirAssocReq assoc_req,
422 uint8_t sub_type)
423{
Naveen Rawatada5fac2016-01-28 16:24:32 -0800424 if (LIM_IS_AP_ROLE(session) &&
425 (session->dot11mode == WNI_CFG_DOT11_MODE_11G_ONLY) &&
426 (assoc_req->HTCaps.present)) {
Nishank Aggarwal8935e442017-03-23 19:11:08 +0530427 pe_err("SOFTAP was in 11G only mode, rejecting legacy STA: "
428 MAC_ADDRESS_STR,
Krunal Soni99752a12016-04-12 17:44:45 -0700429 MAC_ADDR_ARRAY(hdr->sa));
Naveen Rawatada5fac2016-01-28 16:24:32 -0800430 lim_send_assoc_rsp_mgmt_frame(mac_ctx,
Krunal Soni99752a12016-04-12 17:44:45 -0700431 eSIR_MAC_CAPABILITIES_NOT_SUPPORTED_STATUS,
432 1, hdr->sa, sub_type, 0, session);
433 return false;
434 }
435 return true;
436}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800437
Krunal Soni99752a12016-04-12 17:44:45 -0700438/**
439 * lim_chk_11n_only() - checks for non 11n STA
440 * @mac_ctx: pointer to Global MAC structure
441 * @hdr: pointer to the MAC head
442 * @session: pointer to pe session entry
443 * @assoc_req: pointer to ASSOC/REASSOC Request frame
444 * @sub_type: Assoc(=0) or Reassoc(=1) Requestframe
445 *
446 * Checks for non 11n STA
447 *
448 * Return: true of no error, false otherwise
449 */
450static bool lim_chk_11n_only(tpAniSirGlobal mac_ctx, tpSirMacMgmtHdr hdr,
451 tpPESession session, tpSirAssocReq assoc_req,
452 uint8_t sub_type)
453{
Naveen Rawatada5fac2016-01-28 16:24:32 -0800454 if (LIM_IS_AP_ROLE(session) &&
455 (session->dot11mode == WNI_CFG_DOT11_MODE_11N_ONLY) &&
456 (!assoc_req->HTCaps.present)) {
Nishank Aggarwal8935e442017-03-23 19:11:08 +0530457 pe_err("SOFTAP was in 11N only mode, rejecting legacy STA: "
458 MAC_ADDRESS_STR,
Krunal Soni99752a12016-04-12 17:44:45 -0700459 MAC_ADDR_ARRAY(hdr->sa));
Naveen Rawatada5fac2016-01-28 16:24:32 -0800460 lim_send_assoc_rsp_mgmt_frame(mac_ctx,
Krunal Soni99752a12016-04-12 17:44:45 -0700461 eSIR_MAC_CAPABILITIES_NOT_SUPPORTED_STATUS,
462 1, hdr->sa, sub_type, 0, session);
463 return false;
464 }
465 return true;
466}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800467
Krunal Soni99752a12016-04-12 17:44:45 -0700468/**
469 * lim_chk_11ac_only() - checks for non 11ac STA
470 * @mac_ctx: pointer to Global MAC structure
471 * @hdr: pointer to the MAC head
472 * @session: pointer to pe session entry
473 * @assoc_req: pointer to ASSOC/REASSOC Request frame
474 * @sub_type: Assoc(=0) or Reassoc(=1) Requestframe
475 *
476 * Checks for non 11ac STA
477 *
478 * Return: true of no error, false otherwise
479 */
480static bool lim_chk_11ac_only(tpAniSirGlobal mac_ctx, tpSirMacMgmtHdr hdr,
481 tpPESession session, tpSirAssocReq assoc_req,
482 uint8_t sub_type)
483{
Kapil Gupta4b2efbb2016-10-03 13:07:20 +0530484 tDot11fIEVHTCaps *vht_caps;
485
486 if (assoc_req->VHTCaps.present)
487 vht_caps = &assoc_req->VHTCaps;
488 else if (assoc_req->vendor_vht_ie.VHTCaps.present &&
489 session->vendor_vht_sap)
490 vht_caps = &assoc_req->vendor_vht_ie.VHTCaps;
491 else
492 vht_caps = NULL;
493
Naveen Rawatada5fac2016-01-28 16:24:32 -0800494 if (LIM_IS_AP_ROLE(session) &&
Krunal Soni99752a12016-04-12 17:44:45 -0700495 (session->dot11mode == WNI_CFG_DOT11_MODE_11AC_ONLY) &&
wadesong3e727f62016-11-07 17:51:57 +0800496 ((vht_caps == NULL) || ((vht_caps != NULL) && (!vht_caps->present)))) {
Naveen Rawatada5fac2016-01-28 16:24:32 -0800497 lim_send_assoc_rsp_mgmt_frame(mac_ctx,
Krunal Soni99752a12016-04-12 17:44:45 -0700498 eSIR_MAC_CAPABILITIES_NOT_SUPPORTED_STATUS,
499 1, hdr->sa, sub_type, 0, session);
Nishank Aggarwal8935e442017-03-23 19:11:08 +0530500 pe_err("SOFTAP was in 11AC only mode, reject");
Krunal Soni99752a12016-04-12 17:44:45 -0700501 return false;
502 }
503 return true;
504}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800505
Krunal Soni99752a12016-04-12 17:44:45 -0700506/**
Naveen Rawat441bc872017-12-11 17:25:27 -0800507 * lim_chk_11ax_only() - checks for non 11ax STA
508 * @mac_ctx: pointer to Global MAC structure
509 * @hdr: pointer to the MAC head
510 * @session: pointer to pe session entry
511 * @assoc_req: pointer to ASSOC/REASSOC Request frame
512 * @sub_type: Assoc(=0) or Reassoc(=1) Requestframe
513 *
514 * Checks for non 11ax STA
515 *
516 * Return: true of no error, false otherwise
517 */
518#ifdef WLAN_FEATURE_11AX
519static bool lim_chk_11ax_only(tpAniSirGlobal mac_ctx, tpSirMacMgmtHdr hdr,
520 tpPESession session, tpSirAssocReq assoc_req,
521 uint8_t sub_type)
522{
523 if (LIM_IS_AP_ROLE(session) &&
524 (session->dot11mode == WNI_CFG_DOT11_MODE_11AX_ONLY) &&
525 !assoc_req->he_cap.present) {
526 lim_send_assoc_rsp_mgmt_frame(mac_ctx,
527 eSIR_MAC_CAPABILITIES_NOT_SUPPORTED_STATUS,
528 1, hdr->sa, sub_type, 0, session);
529 pe_err("SOFTAP was in 11AX only mode, reject");
530 return false;
531 }
532 return true;
533}
534
535/**
536 * lim_check_11ax_basic_mcs() - checks for 11ax basic MCS rates
537 * @mac_ctx: pointer to Global MAC structure
538 * @hdr: pointer to the MAC head
539 * @session: pointer to pe session entry
540 * @assoc_req: pointer to ASSOC/REASSOC Request frame
541 * @sub_type: Assoc(=0) or Reassoc(=1) Requestframe
542 *
543 * Checks for non 11ax STA
544 *
545 * Return: true of no error, false otherwise
546 */
547static bool lim_check_11ax_basic_mcs(tpAniSirGlobal mac_ctx,
548 tpSirMacMgmtHdr hdr,
549 tpPESession session,
550 tpSirAssocReq assoc_req,
551 uint8_t sub_type)
552{
553 uint32_t val;
554 uint16_t basic_mcs, sta_mcs, rx_mcs, tx_mcs, final_mcs;
555
556 if (LIM_IS_AP_ROLE(session) &&
557 assoc_req->he_cap.present) {
558 rx_mcs = assoc_req->he_cap.rx_he_mcs_map_lt_80;
559 tx_mcs = assoc_req->he_cap.tx_he_mcs_map_lt_80;
560 sta_mcs = HE_INTERSECT_MCS(rx_mcs, tx_mcs);
561 if (eSIR_SUCCESS != wlan_cfg_get_int(mac_ctx,
562 WNI_CFG_HE_OPS_BASIC_MCS_NSS, &val))
563 val = WNI_CFG_HE_OPS_BASIC_MCS_NSS_DEF;
564 basic_mcs = (uint16_t)val;
565 final_mcs = HE_INTERSECT_MCS(sta_mcs, basic_mcs);
566 if (final_mcs != basic_mcs) {
567 lim_send_assoc_rsp_mgmt_frame(mac_ctx,
568 eSIR_MAC_CAPABILITIES_NOT_SUPPORTED_STATUS,
569 1, hdr->sa, sub_type, 0, session);
Jeff Johnsona642ead2018-05-11 09:26:13 -0700570 pe_err("STA did not support basic MCS required by SAP");
Naveen Rawat441bc872017-12-11 17:25:27 -0800571 return false;
572 }
573 }
574 return true;
575}
576#else
577static bool lim_chk_11ax_only(tpAniSirGlobal mac_ctx, tpSirMacMgmtHdr hdr,
578 tpPESession session, tpSirAssocReq assoc_req,
579 uint8_t sub_type)
580{
581 return true;
582}
583
584static bool lim_check_11ax_basic_mcs(tpAniSirGlobal mac_ctx,
585 tpSirMacMgmtHdr hdr,
586 tpPESession session,
587 tpSirAssocReq assoc_req,
588 uint8_t sub_type)
589{
590 return true;
591}
592#endif
593
594/**
Krunal Soni99752a12016-04-12 17:44:45 -0700595 * lim_process_for_spectrum_mgmt() - process assoc req for spectrum mgmt
596 * @mac_ctx: pointer to Global MAC structure
597 * @hdr: pointer to the MAC head
598 * @session: pointer to pe session entry
599 * @assoc_req: pointer to ASSOC/REASSOC Request frame
600 * @sub_type: Assoc(=0) or Reassoc(=1) Requestframe
601 * @local_cap: local capabilities of SAP
602 *
603 * Checks for SSID match
604 *
605 * process assoc req for spectrum mgmt
606 */
607static void
608lim_process_for_spectrum_mgmt(tpAniSirGlobal mac_ctx, tpSirMacMgmtHdr hdr,
609 tpPESession session, tpSirAssocReq assoc_req,
610 uint8_t sub_type, tSirMacCapabilityInfo local_cap)
611{
Naveen Rawatada5fac2016-01-28 16:24:32 -0800612 if (local_cap.spectrumMgt) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800613 tSirRetStatus status = eSIR_SUCCESS;
Krunal Soni99752a12016-04-12 17:44:45 -0700614 /*
615 * If station is 11h capable, then it SHOULD send all mandatory
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800616 * IEs in assoc request frame. Let us verify that
617 */
Naveen Rawatada5fac2016-01-28 16:24:32 -0800618 if (assoc_req->capabilityInfo.spectrumMgt) {
Krunal Soni99752a12016-04-12 17:44:45 -0700619 if (!((assoc_req->powerCapabilityPresent)
Naveen Rawatada5fac2016-01-28 16:24:32 -0800620 && (assoc_req->supportedChannelsPresent))) {
Krunal Soni99752a12016-04-12 17:44:45 -0700621 /*
622 * One or more required information elements are
623 * missing, log the peers error
624 */
Naveen Rawatada5fac2016-01-28 16:24:32 -0800625 if (!assoc_req->powerCapabilityPresent) {
Nishank Aggarwal8935e442017-03-23 19:11:08 +0530626 pe_warn("LIM Info: Missing Power capability IE in %s Req from "
627 MAC_ADDRESS_STR,
Krunal Soni99752a12016-04-12 17:44:45 -0700628 (LIM_ASSOC == sub_type) ?
629 "Assoc" : "ReAssoc",
Naveen Rawatada5fac2016-01-28 16:24:32 -0800630 MAC_ADDR_ARRAY(hdr->sa));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800631 }
Naveen Rawatada5fac2016-01-28 16:24:32 -0800632 if (!assoc_req->supportedChannelsPresent) {
Nishank Aggarwal8935e442017-03-23 19:11:08 +0530633 pe_warn("LIM Info: Missing Supported channel IE in %s Req from "
634 MAC_ADDRESS_STR,
Krunal Soni99752a12016-04-12 17:44:45 -0700635 (LIM_ASSOC == sub_type) ?
636 "Assoc" : "ReAssoc",
Naveen Rawatada5fac2016-01-28 16:24:32 -0800637 MAC_ADDR_ARRAY(hdr->sa));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800638 }
639 } else {
640 /* Assoc request has mandatory fields */
641 status =
Krunal Soni99752a12016-04-12 17:44:45 -0700642 lim_is_dot11h_power_capabilities_in_range(
643 mac_ctx, assoc_req, session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800644 if (eSIR_SUCCESS != status) {
Nishank Aggarwal8935e442017-03-23 19:11:08 +0530645 pe_warn("LIM Info: MinTxPower(STA) > MaxTxPower(AP) in %s Req from "
646 MAC_ADDRESS_STR,
Krunal Soni99752a12016-04-12 17:44:45 -0700647 (LIM_ASSOC == sub_type) ?
648 "Assoc" : "ReAssoc",
Naveen Rawatada5fac2016-01-28 16:24:32 -0800649 MAC_ADDR_ARRAY(hdr->sa));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800650 }
Krunal Soni99752a12016-04-12 17:44:45 -0700651 status = lim_is_dot11h_supported_channels_valid(
652 mac_ctx, assoc_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800653 if (eSIR_SUCCESS != status) {
Nishank Aggarwal8935e442017-03-23 19:11:08 +0530654 pe_warn("LIM Info: wrong supported channels (STA) in %s Req from "
655 MAC_ADDRESS_STR,
Krunal Soni99752a12016-04-12 17:44:45 -0700656 (LIM_ASSOC == sub_type) ?
657 "Assoc" : "ReAssoc",
Naveen Rawatada5fac2016-01-28 16:24:32 -0800658 MAC_ADDR_ARRAY(hdr->sa));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800659 }
660 /* IEs are valid, use them if needed */
661 }
662 } /* if(assoc.capabilityInfo.spectrumMgt) */
663 else {
Krunal Soni99752a12016-04-12 17:44:45 -0700664 /*
665 * As per the capabiities, the spectrum management is
666 * not enabled on the station. The AP may allow the
667 * associations to happen even if spectrum management
668 * is not allowed, if the transmit power of station is
669 * below the regulatory maximum
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800670 */
671
Krunal Soni99752a12016-04-12 17:44:45 -0700672 /*
673 * TODO: presently, this is not handled. In the current
674 * implemetation, the AP would allow the station to
675 * associate even if it doesn't support spectrum
676 * management.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800677 */
678 }
679 } /* end of spectrum management related processing */
Krunal Soni99752a12016-04-12 17:44:45 -0700680}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800681
Krunal Soni99752a12016-04-12 17:44:45 -0700682/**
683 * lim_chk_mcs() - checks for supported MCS
684 * @mac_ctx: pointer to Global MAC structure
685 * @hdr: pointer to the MAC head
686 * @session: pointer to pe session entry
687 * @assoc_req: pointer to ASSOC/REASSOC Request frame
688 * @sub_type: Assoc(=0) or Reassoc(=1) Requestframe
689 *
690 * Checks for supported MCS
691 *
692 * Return: true of no error, false otherwise
693 */
694static bool lim_chk_mcs(tpAniSirGlobal mac_ctx, tpSirMacMgmtHdr hdr,
695 tpPESession session, tpSirAssocReq assoc_req,
696 uint8_t sub_type)
697{
698 if ((assoc_req->HTCaps.present) && (lim_check_mcs_set(mac_ctx,
699 assoc_req->HTCaps.supportedMCSSet) == false)) {
Nishank Aggarwal8935e442017-03-23 19:11:08 +0530700 pe_warn("rcvd %s req with unsupported MCS Rate Set from "
701 MAC_ADDRESS_STR,
Naveen Rawatada5fac2016-01-28 16:24:32 -0800702 (LIM_ASSOC == sub_type) ? "Assoc" : "ReAssoc",
703 MAC_ADDR_ARRAY(hdr->sa));
Krunal Soni99752a12016-04-12 17:44:45 -0700704 /*
705 * Requesting STA does not support ALL BSS MCS basic Rate set
706 * rates. Spec does not define any status code for this
707 * scenario.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800708 */
Naveen Rawatada5fac2016-01-28 16:24:32 -0800709 lim_send_assoc_rsp_mgmt_frame(mac_ctx,
Krunal Soni99752a12016-04-12 17:44:45 -0700710 eSIR_MAC_OUTSIDE_SCOPE_OF_SPEC_STATUS,
711 1, hdr->sa, sub_type, 0, session);
712 return false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800713 }
Krunal Soni99752a12016-04-12 17:44:45 -0700714 return true;
715}
716
717/**
718 * lim_chk_is_11b_sta_supported() - checks if STA is 11b
719 * @mac_ctx: pointer to Global MAC structure
720 * @hdr: pointer to the MAC head
721 * @session: pointer to pe session entry
722 * @assoc_req: pointer to ASSOC/REASSOC Request frame
723 * @sub_type: Assoc(=0) or Reassoc(=1) Requestframe
724 * @phy_mode: phy mode
725 *
726 * Checks if STA is 11b
727 *
728 * Return: true of no error, false otherwise
729 */
730static bool lim_chk_is_11b_sta_supported(tpAniSirGlobal mac_ctx,
731 tpSirMacMgmtHdr hdr,
732 tpPESession session,
733 tpSirAssocReq assoc_req,
734 uint8_t sub_type, uint32_t phy_mode)
735{
736 uint32_t cfg_11g_only;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800737
Naveen Rawatada5fac2016-01-28 16:24:32 -0800738 if (phy_mode == WNI_CFG_PHY_MODE_11G) {
Krunal Soni99752a12016-04-12 17:44:45 -0700739 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_11G_ONLY_POLICY,
740 &cfg_11g_only) != eSIR_SUCCESS) {
Nishank Aggarwal8935e442017-03-23 19:11:08 +0530741 pe_err("couldn't get 11g-only flag");
Krunal Soni99752a12016-04-12 17:44:45 -0700742 return false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800743 }
744
Krunal Soni99752a12016-04-12 17:44:45 -0700745 if (!assoc_req->extendedRatesPresent && cfg_11g_only) {
746 /*
747 * Received Re/Association Request from 11b STA when 11g
748 * only policy option is set. Reject with unspecified
749 * status code.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800750 */
Naveen Rawatada5fac2016-01-28 16:24:32 -0800751 lim_send_assoc_rsp_mgmt_frame(mac_ctx,
Krunal Soni99752a12016-04-12 17:44:45 -0700752 eSIR_MAC_BASIC_RATES_NOT_SUPPORTED_STATUS,
753 1, hdr->sa, sub_type, 0, session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800754
Nishank Aggarwal8935e442017-03-23 19:11:08 +0530755 pe_warn("Rejecting Re/Assoc req from 11b STA:");
Naveen Rawatada5fac2016-01-28 16:24:32 -0800756 lim_print_mac_addr(mac_ctx, hdr->sa, LOGW);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800757
758#ifdef WLAN_DEBUG
Naveen Rawatada5fac2016-01-28 16:24:32 -0800759 mac_ctx->lim.gLim11bStaAssocRejectCount++;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800760#endif
Krunal Soni99752a12016-04-12 17:44:45 -0700761 return false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800762 }
763 }
Krunal Soni99752a12016-04-12 17:44:45 -0700764 return true;
765}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800766
Krunal Soni99752a12016-04-12 17:44:45 -0700767/**
768 * lim_print_ht_cap() - prints HT caps
769 * @mac_ctx: pointer to Global MAC structure
770 * @session: pointer to pe session entry
771 * @assoc_req: pointer to ASSOC/REASSOC Request frame
772 *
773 * Prints HT caps
774 *
775 * Return: void
776 */
777static void lim_print_ht_cap(tpAniSirGlobal mac_ctx, tpPESession session,
778 tpSirAssocReq assoc_req)
779{
780 if (!session->htCapability)
781 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800782
Krunal Soni99752a12016-04-12 17:44:45 -0700783 if (assoc_req->HTCaps.present) {
784 /* The station *does* support 802.11n HT capability... */
Nishank Aggarwal8935e442017-03-23 19:11:08 +0530785 pe_debug("AdvCodingCap:%d ChaWidthSet:%d PowerSave:%d greenField:%d shortGI20:%d shortGI40:%d txSTBC:%d rxSTBC:%d delayBA:%d maxAMSDUsize:%d DSSS/CCK:%d PSMP:%d stbcCntl:%d lsigTXProt:%d",
Krunal Soni99752a12016-04-12 17:44:45 -0700786 assoc_req->HTCaps.advCodingCap,
787 assoc_req->HTCaps.supportedChannelWidthSet,
788 assoc_req->HTCaps.mimoPowerSave,
789 assoc_req->HTCaps.greenField,
790 assoc_req->HTCaps.shortGI20MHz,
791 assoc_req->HTCaps.shortGI40MHz,
792 assoc_req->HTCaps.txSTBC,
793 assoc_req->HTCaps.rxSTBC,
794 assoc_req->HTCaps.delayedBA,
795 assoc_req->HTCaps.maximalAMSDUsize,
796 assoc_req->HTCaps.dsssCckMode40MHz,
797 assoc_req->HTCaps.psmp,
798 assoc_req->HTCaps.stbcControlFrame,
799 assoc_req->HTCaps.lsigTXOPProtection);
800 /*
801 * Make sure the STA's caps are compatible with our own:
802 * 11.15.2 Support of DSSS/CCK in 40 MHz the AP shall refuse
803 * association requests from an HT STA that has the DSSS/CCK
804 * Mode in 40 MHz subfield set to 1;
805 */
806 }
807}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800808
Krunal Soni99752a12016-04-12 17:44:45 -0700809/**
810 * lim_chk_n_process_wpa_rsn_ie() - wpa ie related checks
811 * @mac_ctx: pointer to Global MAC structure
812 * @hdr: pointer to the MAC head
813 * @session: pointer to pe session entry
814 * @assoc_req: pointer to ASSOC/REASSOC Request frame
815 * @sub_type: Assoc(=0) or Reassoc(=1) Requestframe
816 * @pmf_connection: flag indicating pmf connection
817 *
818 * wpa ie related checks
819 *
820 * Return: true of no error, false otherwise
821 */
822static bool lim_chk_n_process_wpa_rsn_ie(tpAniSirGlobal mac_ctx,
823 tpSirMacMgmtHdr hdr,
824 tpPESession session,
825 tpSirAssocReq assoc_req,
826 uint8_t sub_type, bool *pmf_connection)
827{
Naveen Rawat08db88f2017-09-08 15:07:48 -0700828 const uint8_t *wps_ie = NULL;
Abhishek Singh3f13a812018-01-16 14:24:44 +0530829 tDot11fIEWPA dot11f_ie_wpa = {0};
830 tDot11fIERSN dot11f_ie_rsn = {0};
Krunal Soni99752a12016-04-12 17:44:45 -0700831 tSirRetStatus status = eSIR_SUCCESS;
832 /*
833 * Clear the buffers so that frame parser knows that there isn't a
834 * previously decoded IE in these buffers
835 */
Naveen Rawatada5fac2016-01-28 16:24:32 -0800836 qdf_mem_set((uint8_t *) &dot11f_ie_rsn, sizeof(dot11f_ie_rsn), 0);
837 qdf_mem_set((uint8_t *) &dot11f_ie_wpa, sizeof(dot11f_ie_wpa), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800838
839 /* if additional IE is present, check if it has WscIE */
Naveen Rawatada5fac2016-01-28 16:24:32 -0800840 if (assoc_req->addIEPresent && assoc_req->addIE.length)
Krunal Soni99752a12016-04-12 17:44:45 -0700841 wps_ie = limGetWscIEPtr(mac_ctx, assoc_req->addIE.addIEdata,
842 assoc_req->addIE.length);
843 else
Nishank Aggarwal8935e442017-03-23 19:11:08 +0530844 pe_debug("Assoc req addIEPresent: %d addIE length: %d",
Naveen Rawatada5fac2016-01-28 16:24:32 -0800845 assoc_req->addIEPresent, assoc_req->addIE.length);
Krunal Soni99752a12016-04-12 17:44:45 -0700846
Naveen Rawatada5fac2016-01-28 16:24:32 -0800847 /* when wps_ie is present, RSN/WPA IE is ignored */
848 if (wps_ie == NULL) {
Krunal Soni99752a12016-04-12 17:44:45 -0700849 /* check whether as RSN IE is present */
Naveen Rawatada5fac2016-01-28 16:24:32 -0800850 if (LIM_IS_AP_ROLE(session) &&
851 session->pLimStartBssReq->privacy &&
852 session->pLimStartBssReq->rsnIE.length) {
Nishank Aggarwal8935e442017-03-23 19:11:08 +0530853 pe_err("RSN enabled auth, Re/Assoc req from STA: "
854 MAC_ADDRESS_STR,
Krunal Soni99752a12016-04-12 17:44:45 -0700855 MAC_ADDR_ARRAY(hdr->sa));
Naveen Rawatada5fac2016-01-28 16:24:32 -0800856 if (assoc_req->rsnPresent) {
857 if (assoc_req->rsn.length) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800858 /* Unpack the RSN IE */
Abhishek Singh3f13a812018-01-16 14:24:44 +0530859 if (dot11f_unpack_ie_rsn(mac_ctx,
Krunal Soni99752a12016-04-12 17:44:45 -0700860 &assoc_req->rsn.info[0],
861 assoc_req->rsn.length,
Kapil Gupta98906192017-05-18 12:54:23 +0530862 &dot11f_ie_rsn, false) !=
863 DOT11F_PARSE_SUCCESS) {
864 pe_err("Invalid RSN ie");
865 return false;
866 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800867
Krunal Soni99752a12016-04-12 17:44:45 -0700868 /* Check RSN version is supported */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800869 if (SIR_MAC_OUI_VERSION_1 ==
Krunal Soni99752a12016-04-12 17:44:45 -0700870 dot11f_ie_rsn.version) {
871 /*
872 * check the groupwise and
873 * pairwise cipher suites
874 */
875 status =
876 lim_check_rx_rsn_ie_match(
877 mac_ctx, dot11f_ie_rsn,
878 session,
879 assoc_req->HTCaps.present,
880 pmf_connection);
Anurag Chouhan6d760662016-02-20 16:05:43 +0530881 if (eSIR_SUCCESS != status) {
Nishank Aggarwal8935e442017-03-23 19:11:08 +0530882 pe_warn("Re/Assoc rejected from: " MAC_ADDRESS_STR,
Krunal Soni99752a12016-04-12 17:44:45 -0700883 MAC_ADDR_ARRAY(
884 hdr->sa));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800885
Krunal Soni99752a12016-04-12 17:44:45 -0700886 /*
887 * some IE is not
888 * properly sent
889 * received Association
890 * req frame with RSN IE
891 * but length is 0
892 */
893 lim_send_assoc_rsp_mgmt_frame(
894 mac_ctx,
895 status, 1,
896 hdr->sa,
897 sub_type, 0,
898 session);
899 return false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800900 }
901 } else {
Nishank Aggarwal8935e442017-03-23 19:11:08 +0530902 pe_warn("Re/Assoc rejected from: " MAC_ADDRESS_STR,
Krunal Soni99752a12016-04-12 17:44:45 -0700903 MAC_ADDR_ARRAY(
904 hdr->sa));
905 /*
906 * rcvd Assoc req frame with RSN
907 * IE version wrong
908 */
909 lim_send_assoc_rsp_mgmt_frame(
910 mac_ctx,
911 eSIR_MAC_UNSUPPORTED_RSN_IE_VERSION_STATUS,
912 1, hdr->sa, sub_type, 0,
913 session);
914 return false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800915 }
916 } else {
Nishank Aggarwal8935e442017-03-23 19:11:08 +0530917 pe_warn("Re/Assoc rejected from: "
918 MAC_ADDRESS_STR,
Naveen Rawatada5fac2016-01-28 16:24:32 -0800919 MAC_ADDR_ARRAY(hdr->sa));
Krunal Soni99752a12016-04-12 17:44:45 -0700920 /*
921 * rcvd Assoc req frame with RSN IE but
922 * length is 0
923 */
Naveen Rawatada5fac2016-01-28 16:24:32 -0800924 lim_send_assoc_rsp_mgmt_frame(mac_ctx,
Krunal Soni99752a12016-04-12 17:44:45 -0700925 eSIR_MAC_INVALID_INFORMATION_ELEMENT_STATUS,
926 1, hdr->sa, sub_type, 0,
927 session);
928 return false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800929 }
Will Huang19d322b2017-07-03 17:48:26 +0800930 } /* end - if(assoc_req->rsnPresent) */
931 if ((!assoc_req->rsnPresent) && assoc_req->wpaPresent) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800932 /* Unpack the WPA IE */
Naveen Rawatada5fac2016-01-28 16:24:32 -0800933 if (assoc_req->wpa.length) {
Krunal Soni99752a12016-04-12 17:44:45 -0700934 /* OUI is not taken care */
Kapil Gupta98906192017-05-18 12:54:23 +0530935 if (dot11f_unpack_ie_wpa(mac_ctx,
Krunal Soni99752a12016-04-12 17:44:45 -0700936 &assoc_req->wpa.info[4],
937 assoc_req->wpa.length,
Kapil Gupta98906192017-05-18 12:54:23 +0530938 &dot11f_ie_wpa, false) !=
939 DOT11F_PARSE_SUCCESS) {
940 pe_err("Invalid WPA IE");
941 return false;
942 }
Krunal Soni99752a12016-04-12 17:44:45 -0700943 /*
944 * check the groupwise and pairwise
945 * cipher suites
946 */
947 status = lim_check_rx_wpa_ie_match(
948 mac_ctx, dot11f_ie_wpa,
949 session,
950 assoc_req->HTCaps.present);
Anurag Chouhan6d760662016-02-20 16:05:43 +0530951 if (eSIR_SUCCESS != status) {
Nishank Aggarwal8935e442017-03-23 19:11:08 +0530952 pe_warn("Re/Assoc rejected from: "
953 MAC_ADDRESS_STR,
Krunal Soni99752a12016-04-12 17:44:45 -0700954 MAC_ADDR_ARRAY(
955 hdr->sa));
956 /*
957 * rcvd Assoc req frame with WPA
958 * IE but mismatch
959 */
960 lim_send_assoc_rsp_mgmt_frame(
961 mac_ctx, status, 1,
962 hdr->sa, sub_type, 0,
963 session);
964 return false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800965 }
966 } else {
Nishank Aggarwal8935e442017-03-23 19:11:08 +0530967 pe_warn("Re/Assoc rejected from: "
968 MAC_ADDRESS_STR,
Naveen Rawatada5fac2016-01-28 16:24:32 -0800969 MAC_ADDR_ARRAY(hdr->sa));
Krunal Soni99752a12016-04-12 17:44:45 -0700970 /*
971 * rcvd Assoc req frame with invalid WPA
972 * IE
973 */
Naveen Rawatada5fac2016-01-28 16:24:32 -0800974 lim_send_assoc_rsp_mgmt_frame(mac_ctx,
Krunal Soni99752a12016-04-12 17:44:45 -0700975 eSIR_MAC_INVALID_INFORMATION_ELEMENT_STATUS,
976 1, hdr->sa, sub_type, 0,
977 session);
978 return false;
Naveen Rawatada5fac2016-01-28 16:24:32 -0800979 } /* end - if(assoc_req->wpa.length) */
Will Huang19d322b2017-07-03 17:48:26 +0800980 } /* end - if(assoc_req->wpaPresent) */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800981 }
Krunal Soni99752a12016-04-12 17:44:45 -0700982 /*
983 * end of if(session->pLimStartBssReq->privacy
984 * && session->pLimStartBssReq->rsnIE->length)
985 */
986 } /* end of if( ! assoc_req->wscInfo.present ) */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800987 else {
Nishank Aggarwal8935e442017-03-23 19:11:08 +0530988 pe_debug("Assoc req WSE IE is present");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800989 }
Krunal Soni99752a12016-04-12 17:44:45 -0700990 return true;
991}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800992
Krunal Soni99752a12016-04-12 17:44:45 -0700993/**
994 * lim_process_assoc_req_no_sta_ctx() - process assoc req for no sta ctx present
995 * @mac_ctx: pointer to Global MAC structure
996 * @hdr: pointer to the MAC head
997 * @session: pointer to pe session entry
998 * @assoc_req: pointer to ASSOC/REASSOC Request frame
999 * @sub_type: Assoc(=0) or Reassoc(=1) Requestframe
1000 * @sta_pre_auth_ctx: sta pre auth context
1001 * @sta_ds: station dph entry
1002 * @auth_type: indicates security type
1003 *
1004 * Process assoc req for no sta ctx present
1005 *
1006 * Return: true of no error, false otherwise
1007 */
1008static bool lim_process_assoc_req_no_sta_ctx(tpAniSirGlobal mac_ctx,
1009 tpSirMacMgmtHdr hdr, tpPESession session,
1010 tpSirAssocReq assoc_req, uint8_t sub_type,
1011 struct tLimPreAuthNode *sta_pre_auth_ctx,
1012 tpDphHashNode sta_ds, tAniAuthType *auth_type)
1013{
1014 /* Requesting STA is not currently associated */
1015 if (pe_get_current_stas_count(mac_ctx) ==
1016 mac_ctx->lim.gLimAssocStaLimit) {
1017 /*
1018 * Maximum number of STAs that AP can handle reached.
1019 * Send Association response to peer MAC entity
1020 */
Nishank Aggarwal8935e442017-03-23 19:11:08 +05301021 pe_err("Max Sta count reached : %d",
Krunal Soni99752a12016-04-12 17:44:45 -07001022 mac_ctx->lim.maxStation);
1023 lim_reject_association(mac_ctx, hdr->sa, sub_type, false,
1024 (tAniAuthType) 0, 0, false,
Varun Reddy Yeturu725185d2017-11-17 14:14:55 -08001025 eSIR_MAC_UNSPEC_FAILURE_STATUS,
Krunal Soni99752a12016-04-12 17:44:45 -07001026 session);
1027 return false;
1028 }
1029 /* Check if STA is pre-authenticated. */
1030 if ((sta_pre_auth_ctx == NULL) || (sta_pre_auth_ctx &&
1031 (sta_pre_auth_ctx->mlmState != eLIM_MLM_AUTHENTICATED_STATE))) {
1032 /*
1033 * STA is not pre-authenticated yet requesting Re/Association
1034 * before Authentication. OR STA is in the process of getting
1035 * authenticated and sent Re/Association request. Send
1036 * Deauthentication frame with 'prior authentication required'
1037 * reason code.
1038 */
1039 lim_send_deauth_mgmt_frame(mac_ctx,
1040 eSIR_MAC_STA_NOT_PRE_AUTHENTICATED_REASON,
1041 hdr->sa, session, false);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001042
Nishank Aggarwal8935e442017-03-23 19:11:08 +05301043 pe_warn("rcvd %s req, sessionid: %d, without pre-auth ctx"
1044 MAC_ADDRESS_STR,
Krunal Soni99752a12016-04-12 17:44:45 -07001045 (LIM_ASSOC == sub_type) ? "Assoc" : "ReAssoc",
1046 session->peSessionId, MAC_ADDR_ARRAY(hdr->sa));
1047 return false;
1048 }
1049 /* Delete 'pre-auth' context of STA */
1050 *auth_type = sta_pre_auth_ctx->authType;
1051 lim_delete_pre_auth_node(mac_ctx, hdr->sa);
1052 /* All is well. Assign AID (after else part) */
1053 return true;
1054}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001055
Krunal Soni99752a12016-04-12 17:44:45 -07001056/**
1057 * lim_process_assoc_req_sta_ctx() - process assoc req for sta context present
1058 * @mac_ctx: pointer to Global MAC structure
1059 * @hdr: pointer to the MAC head
1060 * @session: pointer to pe session entry
1061 * @assoc_req: pointer to ASSOC/REASSOC Request frame
1062 * @sub_type: Assoc(=0) or Reassoc(=1) Requestframe
1063 * @sta_pre_auth_ctx: sta pre auth context
1064 * @sta_ds: station dph entry
1065 * @peer_idx: peer index
1066 * @auth_type: indicates security type
1067 * @update_ctx: indicates if STA context already exist
1068 *
1069 * Process assoc req for sta context present
1070 *
1071 * Return: true of no error, false otherwise
1072 */
1073static bool lim_process_assoc_req_sta_ctx(tpAniSirGlobal mac_ctx,
1074 tpSirMacMgmtHdr hdr, tpPESession session,
1075 tpSirAssocReq assoc_req, uint8_t sub_type,
1076 struct tLimPreAuthNode *sta_pre_auth_ctx,
1077 tpDphHashNode sta_ds, uint16_t peer_idx,
1078 tAniAuthType *auth_type, uint8_t *update_ctx)
1079{
1080 /* STA context does exist for this STA */
1081 if (sta_ds->mlmStaContext.mlmState != eLIM_MLM_LINK_ESTABLISHED_STATE) {
1082 /*
1083 * Requesting STA is in some 'transient' state? Ignore the
1084 * Re/Assoc Req frame by incrementing debug counter & logging
1085 * error.
1086 */
1087 if (sub_type == LIM_ASSOC) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001088#ifdef WLAN_DEBUG
Krunal Soni99752a12016-04-12 17:44:45 -07001089 mac_ctx->lim.gLimNumAssocReqDropInvldState++;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001090#endif
Nishank Aggarwal8935e442017-03-23 19:11:08 +05301091 pe_debug("received Assoc req in state: %X from",
Krunal Soni99752a12016-04-12 17:44:45 -07001092 sta_ds->mlmStaContext.mlmState);
1093 } else {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001094#ifdef WLAN_DEBUG
Krunal Soni99752a12016-04-12 17:44:45 -07001095 mac_ctx->lim.gLimNumReassocReqDropInvldState++;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001096#endif
Nishank Aggarwal8935e442017-03-23 19:11:08 +05301097 pe_debug("received ReAssoc req in state: %X from",
Krunal Soni99752a12016-04-12 17:44:45 -07001098 sta_ds->mlmStaContext.mlmState);
1099 }
Nishank Aggarwaled4c1c52017-03-11 14:17:49 +05301100 lim_print_mac_addr(mac_ctx, hdr->sa, LOGD);
1101 lim_print_mlm_state(mac_ctx, LOGD,
Krunal Soni99752a12016-04-12 17:44:45 -07001102 (tLimMlmStates) sta_ds->mlmStaContext.mlmState);
1103 return false;
1104 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001105
Krunal Soni99752a12016-04-12 17:44:45 -07001106 /* STA sent assoc req frame while already in 'associated' state */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001107
1108#ifdef WLAN_FEATURE_11W
Nishank Aggarwal8935e442017-03-23 19:11:08 +05301109 pe_debug("Re/Assoc request from station that is already associated");
1110 pe_debug("PMF enabled: %d, SA Query state: %d",
Krunal Soni99752a12016-04-12 17:44:45 -07001111 sta_ds->rmfEnabled, sta_ds->pmfSaQueryState);
1112 if (sta_ds->rmfEnabled) {
1113 switch (sta_ds->pmfSaQueryState) {
1114 /*
1115 * start SA Query procedure, respond to Association Request with
1116 * try again later
1117 */
1118 case DPH_SA_QUERY_NOT_IN_PROGRESS:
1119 /*
1120 * We should reset the retry counter before we start
1121 * the SA query procedure, otherwise in next set of SA
1122 * query procedure we will end up using the stale value.
1123 */
1124 sta_ds->pmfSaQueryRetryCount = 0;
1125 lim_send_assoc_rsp_mgmt_frame(mac_ctx,
1126 eSIR_MAC_TRY_AGAIN_LATER, 1, hdr->sa,
1127 sub_type, sta_ds, session);
1128 lim_send_sa_query_request_frame(mac_ctx,
1129 (uint8_t *) &(sta_ds->pmfSaQueryCurrentTransId),
1130 hdr->sa, session);
1131 sta_ds->pmfSaQueryStartTransId =
1132 sta_ds->pmfSaQueryCurrentTransId;
1133 sta_ds->pmfSaQueryCurrentTransId++;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001134
Krunal Soni99752a12016-04-12 17:44:45 -07001135 /* start timer for SA Query retry */
1136 if (tx_timer_activate(&sta_ds->pmfSaQueryTimer)
1137 != TX_SUCCESS) {
Nishank Aggarwal8935e442017-03-23 19:11:08 +05301138 pe_err("PMF SA Query timer start failed!");
Krunal Soni99752a12016-04-12 17:44:45 -07001139 return false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001140 }
Krunal Soni99752a12016-04-12 17:44:45 -07001141 sta_ds->pmfSaQueryState = DPH_SA_QUERY_IN_PROGRESS;
1142 return false;
1143 /*
1144 * SA Query procedure still going, respond to Association
1145 * Request with try again later
1146 */
1147 case DPH_SA_QUERY_IN_PROGRESS:
1148 lim_send_assoc_rsp_mgmt_frame(mac_ctx,
1149 eSIR_MAC_TRY_AGAIN_LATER, 1,
1150 hdr->sa, sub_type, 0, session);
1151 return false;
1152
1153 /*
1154 * SA Query procedure timed out, accept Association
1155 * Request normally
1156 */
1157 case DPH_SA_QUERY_TIMED_OUT:
1158 sta_ds->pmfSaQueryState = DPH_SA_QUERY_NOT_IN_PROGRESS;
1159 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001160 }
Krunal Soni99752a12016-04-12 17:44:45 -07001161 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001162#endif
1163
Krunal Soni99752a12016-04-12 17:44:45 -07001164 /* no change in the capability so drop the frame */
1165 if ((sub_type == LIM_ASSOC) &&
Ankit Guptaa5076012016-09-14 11:32:19 -07001166 (!qdf_mem_cmp(&sta_ds->mlmStaContext.capabilityInfo,
Krunal Soni99752a12016-04-12 17:44:45 -07001167 &assoc_req->capabilityInfo,
1168 sizeof(tSirMacCapabilityInfo)))) {
Nishank Aggarwal8935e442017-03-23 19:11:08 +05301169 pe_err("Received Assoc req in state: %X STAid: %d",
Krunal Soni99752a12016-04-12 17:44:45 -07001170 sta_ds->mlmStaContext.mlmState, peer_idx);
1171 return false;
1172 } else {
1173 /*
1174 * STA sent Re/association Request frame while already in
1175 * 'associated' state. Update STA capabilities and send
1176 * Association response frame with same AID
1177 */
Nishank Aggarwal8935e442017-03-23 19:11:08 +05301178 pe_debug("Rcvd Assoc req from STA already connected");
Krunal Soni99752a12016-04-12 17:44:45 -07001179 sta_ds->mlmStaContext.capabilityInfo =
1180 assoc_req->capabilityInfo;
1181 if (sta_pre_auth_ctx && (sta_pre_auth_ctx->mlmState ==
1182 eLIM_MLM_AUTHENTICATED_STATE)) {
1183 /* STA has triggered pre-auth again */
1184 *auth_type = sta_pre_auth_ctx->authType;
1185 lim_delete_pre_auth_node(mac_ctx, hdr->sa);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001186 } else {
Krunal Soni99752a12016-04-12 17:44:45 -07001187 *auth_type = sta_ds->mlmStaContext.authType;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001188 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001189
Krunal Soni99752a12016-04-12 17:44:45 -07001190 *update_ctx = true;
1191 if (dph_init_sta_state(mac_ctx, hdr->sa, peer_idx, true,
1192 &session->dph.dphHashTable) == NULL) {
Nishank Aggarwal8935e442017-03-23 19:11:08 +05301193 pe_err("could not Init STAid: %d", peer_idx);
Krunal Soni99752a12016-04-12 17:44:45 -07001194 return false;
1195 }
1196 }
1197 return true;
1198}
1199
1200/**
1201 * lim_chk_wmm() - wmm related checks
1202 * @mac_ctx: pointer to Global MAC structure
1203 * @hdr: pointer to the MAC head
1204 * @session: pointer to pe session entry
1205 * @assoc_req: pointer to ASSOC/REASSOC Request frame
1206 * @sub_type: Assoc(=0) or Reassoc(=1) Requestframe
1207 * @qos_mode: qos mode
1208 *
1209 * wmm related checks
1210 *
1211 * Return: true of no error, false otherwise
1212 */
1213static bool lim_chk_wmm(tpAniSirGlobal mac_ctx, tpSirMacMgmtHdr hdr,
1214 tpPESession session, tpSirAssocReq assoc_req,
1215 uint8_t sub_type, tHalBitVal qos_mode)
1216{
1217 tHalBitVal wme_mode;
Jeff Johnsonc742d8d2017-10-10 16:36:54 -07001218
Naveen Rawatada5fac2016-01-28 16:24:32 -08001219 limGetWmeMode(session, &wme_mode);
1220 if ((qos_mode == eHAL_SET) || (wme_mode == eHAL_SET)) {
Krunal Soni99752a12016-04-12 17:44:45 -07001221 /*
1222 * for a qsta, check if the requested Traffic spec is admissible
1223 * for a non-qsta check if the sta can be admitted
1224 */
Naveen Rawatada5fac2016-01-28 16:24:32 -08001225 if (assoc_req->addtsPresent) {
Krunal Soni99752a12016-04-12 17:44:45 -07001226 uint8_t tspecIdx = 0;
Jeff Johnsonc742d8d2017-10-10 16:36:54 -07001227
Naveen Rawatada5fac2016-01-28 16:24:32 -08001228 if (lim_admit_control_add_ts(mac_ctx, hdr->sa,
Krunal Soni99752a12016-04-12 17:44:45 -07001229 &(assoc_req->addtsReq),
1230 &(assoc_req->qosCapability),
1231 0, false, NULL, &tspecIdx, session) !=
1232 eSIR_SUCCESS) {
Nishank Aggarwal8935e442017-03-23 19:11:08 +05301233 pe_warn("AdmitControl: TSPEC rejected");
Naveen Rawatada5fac2016-01-28 16:24:32 -08001234 lim_send_assoc_rsp_mgmt_frame(mac_ctx,
Krunal Soni99752a12016-04-12 17:44:45 -07001235 eSIR_MAC_QAP_NO_BANDWIDTH_REASON,
1236 1, hdr->sa, sub_type, 0, session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001237#ifdef WLAN_DEBUG
Naveen Rawatada5fac2016-01-28 16:24:32 -08001238 mac_ctx->lim.gLimNumAssocReqDropACRejectTS++;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001239#endif
Krunal Soni99752a12016-04-12 17:44:45 -07001240 return false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001241 }
Naveen Rawatada5fac2016-01-28 16:24:32 -08001242 } else if (lim_admit_control_add_sta(mac_ctx, hdr->sa, false)
Krunal Soni99752a12016-04-12 17:44:45 -07001243 != eSIR_SUCCESS) {
Nishank Aggarwal8935e442017-03-23 19:11:08 +05301244 pe_warn("AdmitControl: Sta rejected");
Naveen Rawatada5fac2016-01-28 16:24:32 -08001245 lim_send_assoc_rsp_mgmt_frame(mac_ctx,
Krunal Soni99752a12016-04-12 17:44:45 -07001246 eSIR_MAC_QAP_NO_BANDWIDTH_REASON, 1,
1247 hdr->sa, sub_type, 0, session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001248#ifdef WLAN_DEBUG
Naveen Rawatada5fac2016-01-28 16:24:32 -08001249 mac_ctx->lim.gLimNumAssocReqDropACRejectSta++;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001250#endif
Krunal Soni99752a12016-04-12 17:44:45 -07001251 return false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001252 }
1253 /* else all ok */
Nishank Aggarwal8935e442017-03-23 19:11:08 +05301254 pe_debug("AdmitControl: Sta OK!");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001255 }
Krunal Soni99752a12016-04-12 17:44:45 -07001256 return true;
1257}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001258
Krunal Soni99752a12016-04-12 17:44:45 -07001259/**
1260 * lim_update_sta_ds() - updates ds dph entry
1261 * @mac_ctx: pointer to Global MAC structure
1262 * @hdr: pointer to the MAC head
1263 * @session: pointer to pe session entry
Abhishek Singh61084982016-12-13 17:24:07 +05301264 * @assoc_req: pointer to ASSOC/REASSOC Request frame pointer
Krunal Soni99752a12016-04-12 17:44:45 -07001265 * @sub_type: Assoc(=0) or Reassoc(=1) Requestframe
1266 * @sta_ds: station dph entry
Krunal Soni99752a12016-04-12 17:44:45 -07001267 * @auth_type: indicates security type
1268 * @assoc_req_copied: boolean to indicate if assoc req was copied to tmp above
1269 * @peer_idx: peer index
1270 * @qos_mode: qos mode
1271 * @pmf_connection: flag indicating pmf connection
1272 *
1273 * Updates ds dph entry
1274 *
1275 * Return: true of no error, false otherwise
1276 */
1277static bool lim_update_sta_ds(tpAniSirGlobal mac_ctx, tpSirMacMgmtHdr hdr,
Abhishek Singh0bc46d12017-01-09 13:05:54 +05301278 tpPESession session, tpSirAssocReq assoc_req,
Krunal Soni99752a12016-04-12 17:44:45 -07001279 uint8_t sub_type, tpDphHashNode sta_ds,
Krunal Soni99752a12016-04-12 17:44:45 -07001280 tAniAuthType auth_type,
1281 bool *assoc_req_copied, uint16_t peer_idx,
1282 tHalBitVal qos_mode, bool pmf_connection)
1283{
Krunal Soni99752a12016-04-12 17:44:45 -07001284 tHalBitVal wme_mode, wsm_mode;
1285 uint8_t *ht_cap_ie = NULL;
1286#ifdef WLAN_FEATURE_11W
1287 tPmfSaQueryTimerId timer_id;
1288 uint32_t retry_interval;
1289#endif
Kapil Gupta4b2efbb2016-10-03 13:07:20 +05301290 tDot11fIEVHTCaps *vht_caps;
Abhishek Singh61084982016-12-13 17:24:07 +05301291 tpSirAssocReq tmp_assoc_req;
Kapil Gupta4b2efbb2016-10-03 13:07:20 +05301292
1293 if (assoc_req->VHTCaps.present)
1294 vht_caps = &assoc_req->VHTCaps;
1295 else if (assoc_req->vendor_vht_ie.VHTCaps.present &&
1296 session->vendor_vht_sap)
1297 vht_caps = &assoc_req->vendor_vht_ie.VHTCaps;
1298 else
1299 vht_caps = NULL;
1300
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001301 /*
Krunal Soni99752a12016-04-12 17:44:45 -07001302 * check here if the parsedAssocReq already pointing to the assoc_req
1303 * and free it before assigning this new assoc_req
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001304 */
Naveen Rawatada5fac2016-01-28 16:24:32 -08001305 if (session->parsedAssocReq != NULL) {
1306 tmp_assoc_req = session->parsedAssocReq[sta_ds->assocId];
1307 if (tmp_assoc_req != NULL) {
1308 if (tmp_assoc_req->assocReqFrame) {
1309 qdf_mem_free(tmp_assoc_req->assocReqFrame);
1310 tmp_assoc_req->assocReqFrame = NULL;
1311 tmp_assoc_req->assocReqFrameLength = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001312 }
Naveen Rawatada5fac2016-01-28 16:24:32 -08001313 qdf_mem_free(tmp_assoc_req);
1314 tmp_assoc_req = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001315 }
1316
Naveen Rawatada5fac2016-01-28 16:24:32 -08001317 session->parsedAssocReq[sta_ds->assocId] = assoc_req;
Krunal Soni99752a12016-04-12 17:44:45 -07001318 *assoc_req_copied = true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001319 }
1320
Naveen Rawatada5fac2016-01-28 16:24:32 -08001321 sta_ds->mlmStaContext.htCapability = assoc_req->HTCaps.present;
Kapil Gupta4b2efbb2016-10-03 13:07:20 +05301322 if ((vht_caps != NULL) && vht_caps->present)
1323 sta_ds->mlmStaContext.vhtCapability = vht_caps->present;
1324 else
1325 sta_ds->mlmStaContext.vhtCapability = false;
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08001326 lim_update_stads_he_capable(sta_ds, assoc_req);
Naveen Rawatada5fac2016-01-28 16:24:32 -08001327 sta_ds->qos.addtsPresent =
1328 (assoc_req->addtsPresent == 0) ? false : true;
1329 sta_ds->qos.addts = assoc_req->addtsReq;
1330 sta_ds->qos.capability = assoc_req->qosCapability;
1331 sta_ds->versionPresent = 0;
Krunal Soni99752a12016-04-12 17:44:45 -07001332 /*
1333 * short slot and short preamble should be updated before doing
1334 * limaddsta
1335 */
Naveen Rawatada5fac2016-01-28 16:24:32 -08001336 sta_ds->shortPreambleEnabled =
1337 (uint8_t) assoc_req->capabilityInfo.shortPreamble;
1338 sta_ds->shortSlotTimeEnabled =
1339 (uint8_t) assoc_req->capabilityInfo.shortSlotTime;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001340
Naveen Rawatada5fac2016-01-28 16:24:32 -08001341 sta_ds->valid = 0;
1342 sta_ds->mlmStaContext.authType = auth_type;
1343 sta_ds->staType = STA_ENTRY_PEER;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001344
Krunal Soni99752a12016-04-12 17:44:45 -07001345 /*
1346 * TODO: If listen interval is more than certain limit, reject the
1347 * association. Need to check customer requirements and then implement.
1348 */
Naveen Rawatada5fac2016-01-28 16:24:32 -08001349 sta_ds->mlmStaContext.listenInterval = assoc_req->listenInterval;
1350 sta_ds->mlmStaContext.capabilityInfo = assoc_req->capabilityInfo;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001351
Krunal Soni99752a12016-04-12 17:44:45 -07001352 /*
1353 * The following count will be used to knock-off the station if it
1354 * doesn't come back to receive the buffered data. The AP will wait
1355 * for numTimSent number of beacons after sending TIM information for
1356 * the station, before assuming that the station is no more associated
1357 * and disassociates it
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001358 */
1359
Krunal Soni99752a12016-04-12 17:44:45 -07001360 /* timWaitCount used by PMM for monitoring the STA's in PS for LINK */
Naveen Rawatada5fac2016-01-28 16:24:32 -08001361 sta_ds->timWaitCount =
1362 (uint8_t) GET_TIM_WAIT_COUNT(assoc_req->listenInterval);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001363
Krunal Soni99752a12016-04-12 17:44:45 -07001364 /* Init the Current successful MPDU's tranfered to this STA count = 0 */
Naveen Rawatada5fac2016-01-28 16:24:32 -08001365 sta_ds->curTxMpduCnt = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001366
Naveen Rawatada5fac2016-01-28 16:24:32 -08001367 if (IS_DOT11_MODE_HT(session->dot11mode) &&
1368 assoc_req->HTCaps.present && assoc_req->wmeInfoPresent) {
1369 sta_ds->htGreenfield = (uint8_t) assoc_req->HTCaps.greenField;
1370 sta_ds->htAMpduDensity = assoc_req->HTCaps.mpduDensity;
1371 sta_ds->htDsssCckRate40MHzSupport =
1372 (uint8_t) assoc_req->HTCaps.dsssCckMode40MHz;
1373 sta_ds->htLsigTXOPProtection =
1374 (uint8_t) assoc_req->HTCaps.lsigTXOPProtection;
1375 sta_ds->htMaxAmsduLength =
1376 (uint8_t) assoc_req->HTCaps.maximalAMSDUsize;
1377 sta_ds->htMaxRxAMpduFactor = assoc_req->HTCaps.maxRxAMPDUFactor;
1378 sta_ds->htMIMOPSState = assoc_req->HTCaps.mimoPowerSave;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001379
Krunal Soni99752a12016-04-12 17:44:45 -07001380 /* assoc_req will be copied to session->parsedAssocReq later */
Naveen Rawatada5fac2016-01-28 16:24:32 -08001381 ht_cap_ie = ((uint8_t *) &assoc_req->HTCaps) + 1;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001382
Sandeep Puligilla607f34a2016-05-25 14:37:47 -07001383 if (session->htConfig.ht_sgi20) {
Naveen Rawatada5fac2016-01-28 16:24:32 -08001384 sta_ds->htShortGI20Mhz =
Krunal Soni99752a12016-04-12 17:44:45 -07001385 (uint8_t)assoc_req->HTCaps.shortGI20MHz;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001386 } else {
1387 /* Unset htShortGI20Mhz in ht_caps*/
1388 *ht_cap_ie &= ~(1 << SIR_MAC_HT_CAP_SHORTGI20MHZ_S);
Naveen Rawatada5fac2016-01-28 16:24:32 -08001389 sta_ds->htShortGI20Mhz = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001390 }
1391
Sandeep Puligilla607f34a2016-05-25 14:37:47 -07001392 if (session->htConfig.ht_sgi40) {
Naveen Rawatada5fac2016-01-28 16:24:32 -08001393 sta_ds->htShortGI40Mhz =
1394 (uint8_t)assoc_req->HTCaps.shortGI40MHz;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001395 } else {
1396 /* Unset htShortGI40Mhz in ht_caps */
1397 *ht_cap_ie &= ~(1 << SIR_MAC_HT_CAP_SHORTGI40MHZ_S);
Naveen Rawatada5fac2016-01-28 16:24:32 -08001398 sta_ds->htShortGI40Mhz = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001399 }
1400
Naveen Rawatada5fac2016-01-28 16:24:32 -08001401 sta_ds->htSupportedChannelWidthSet =
1402 (uint8_t) assoc_req->HTCaps.supportedChannelWidthSet;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001403 /*
1404 * peer just follows AP; so when we are softAP/GO,
1405 * we just store our session entry's secondary channel offset
1406 * here in peer INFRA STA. However, if peer's 40MHz channel
1407 * width support is disabled then secondary channel will be zero
1408 */
Naveen Rawatada5fac2016-01-28 16:24:32 -08001409 sta_ds->htSecondaryChannelOffset =
Krunal Soni99752a12016-04-12 17:44:45 -07001410 (sta_ds->htSupportedChannelWidthSet) ?
1411 session->htSecondaryChannelOffset : 0;
Naveen Rawatada5fac2016-01-28 16:24:32 -08001412 if (assoc_req->operMode.present) {
1413 sta_ds->vhtSupportedChannelWidthSet =
1414 (uint8_t) ((assoc_req->operMode.chanWidth ==
Krunal Soni99752a12016-04-12 17:44:45 -07001415 eHT_CHANNEL_WIDTH_80MHZ) ?
1416 WNI_CFG_VHT_CHANNEL_WIDTH_80MHZ :
1417 WNI_CFG_VHT_CHANNEL_WIDTH_20_40MHZ);
Naveen Rawatada5fac2016-01-28 16:24:32 -08001418 sta_ds->htSupportedChannelWidthSet =
Krunal Soni99752a12016-04-12 17:44:45 -07001419 (uint8_t) (assoc_req->operMode.chanWidth ?
1420 eHT_CHANNEL_WIDTH_40MHZ :
1421 eHT_CHANNEL_WIDTH_20MHZ);
Kapil Gupta4b2efbb2016-10-03 13:07:20 +05301422 } else if ((vht_caps != NULL) && vht_caps->present) {
Krunal Soni99752a12016-04-12 17:44:45 -07001423 /*
1424 * Check if STA has enabled it's channel bonding mode.
1425 * If channel bonding mode is enabled, we decide based
1426 * on SAP's current configuration. else, we set it to
Jeff Johnsonc742d8d2017-10-10 16:36:54 -07001427 * VHT20.
1428 */
Naveen Rawatada5fac2016-01-28 16:24:32 -08001429 sta_ds->vhtSupportedChannelWidthSet =
Krunal Soni99752a12016-04-12 17:44:45 -07001430 (uint8_t) ((sta_ds->htSupportedChannelWidthSet
1431 == eHT_CHANNEL_WIDTH_20MHZ) ?
1432 WNI_CFG_VHT_CHANNEL_WIDTH_20_40MHZ :
1433 session->ch_width - 1);
Naveen Rawatada5fac2016-01-28 16:24:32 -08001434 sta_ds->htMaxRxAMpduFactor =
Kapil Gupta4b2efbb2016-10-03 13:07:20 +05301435 vht_caps->maxAMPDULenExp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001436 }
1437 /* Lesser among the AP and STA bandwidth of operation. */
Naveen Rawatada5fac2016-01-28 16:24:32 -08001438 sta_ds->htSupportedChannelWidthSet =
1439 (sta_ds->htSupportedChannelWidthSet <
Krunal Soni99752a12016-04-12 17:44:45 -07001440 session->htSupportedChannelWidthSet) ?
1441 sta_ds->htSupportedChannelWidthSet :
1442 session->htSupportedChannelWidthSet;
Naveen Rawatada5fac2016-01-28 16:24:32 -08001443 sta_ds->baPolicyFlag = 0xFF;
1444 sta_ds->htLdpcCapable =
1445 (uint8_t) assoc_req->HTCaps.advCodingCap;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001446 }
1447
Kapil Gupta4b2efbb2016-10-03 13:07:20 +05301448 if ((vht_caps != NULL) && vht_caps->present &&
1449 assoc_req->wmeInfoPresent) {
Naveen Rawatada5fac2016-01-28 16:24:32 -08001450 sta_ds->vhtLdpcCapable =
Kapil Gupta4b2efbb2016-10-03 13:07:20 +05301451 (uint8_t) vht_caps->ldpcCodingCap;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001452 }
1453
gaolez7bb1e742017-03-21 16:37:38 +08001454 if (assoc_req->ExtCap.present)
1455 sta_ds->non_ecsa_capable =
1456 !((struct s_ext_cap *)assoc_req->ExtCap.bytes)->
1457 ext_chan_switch;
1458 else
1459 sta_ds->non_ecsa_capable = 1;
1460
Naveen Rawatada5fac2016-01-28 16:24:32 -08001461 if (!assoc_req->wmeInfoPresent) {
1462 sta_ds->mlmStaContext.htCapability = 0;
1463 sta_ds->mlmStaContext.vhtCapability = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001464 }
Naveen Rawat2eb4c832018-02-15 10:47:38 -08001465
1466 if (sta_ds->mlmStaContext.vhtCapability && vht_caps) {
Krunal Soni53993f72016-07-08 18:20:03 -07001467 if (session->vht_config.su_beam_formee &&
Naveen Rawat2eb4c832018-02-15 10:47:38 -08001468 vht_caps->suBeamFormerCap)
Naveen Rawatada5fac2016-01-28 16:24:32 -08001469 sta_ds->vhtBeamFormerCapable = 1;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001470 else
Naveen Rawatada5fac2016-01-28 16:24:32 -08001471 sta_ds->vhtBeamFormerCapable = 0;
Krunal Soni53993f72016-07-08 18:20:03 -07001472 if (session->vht_config.su_beam_former &&
Naveen Rawat2eb4c832018-02-15 10:47:38 -08001473 vht_caps->suBeamformeeCap)
Naveen Rawatada5fac2016-01-28 16:24:32 -08001474 sta_ds->vht_su_bfee_capable = 1;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001475 else
Naveen Rawatada5fac2016-01-28 16:24:32 -08001476 sta_ds->vht_su_bfee_capable = 0;
Naveen Rawat2eb4c832018-02-15 10:47:38 -08001477
1478 pe_debug("peer_caps: suBformer: %d, suBformee: %d",
1479 vht_caps->suBeamFormerCap,
1480 vht_caps->suBeamformeeCap);
1481 pe_debug("self_cap: suBformer: %d, suBformee: %d",
1482 session->vht_config.su_beam_former,
1483 session->vht_config.su_beam_formee);
1484 pe_debug("connection's final cap: suBformer: %d, suBformee: %d",
1485 sta_ds->vhtBeamFormerCapable,
1486 sta_ds->vht_su_bfee_capable);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001487 }
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08001488
1489 lim_intersect_sta_he_caps(assoc_req, session, sta_ds);
1490
Krunal Soni99752a12016-04-12 17:44:45 -07001491 if (lim_populate_matching_rate_set(mac_ctx, sta_ds,
1492 &(assoc_req->supportedRates),
1493 &(assoc_req->extendedRates),
1494 assoc_req->HTCaps.supportedMCSSet,
Krishna Kumaar Natarajand1cd56e2016-09-30 08:43:03 -07001495 session, vht_caps,
Jeff Johnsonc742d8d2017-10-10 16:36:54 -07001496 &assoc_req->he_cap) != eSIR_SUCCESS) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001497 /* Could not update hash table entry at DPH with rateset */
Nishank Aggarwal8935e442017-03-23 19:11:08 +05301498 pe_err("Couldn't update hash entry for aid: %d MacAddr: "
Jeff Johnsonc742d8d2017-10-10 16:36:54 -07001499 MAC_ADDRESS_STR,
1500 peer_idx, MAC_ADDR_ARRAY(hdr->sa));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001501
1502 /* Release AID */
Naveen Rawatada5fac2016-01-28 16:24:32 -08001503 lim_release_peer_idx(mac_ctx, peer_idx, session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001504
Naveen Rawatada5fac2016-01-28 16:24:32 -08001505 lim_reject_association(mac_ctx, hdr->sa,
Abhishek Singh0bc46d12017-01-09 13:05:54 +05301506 sub_type, true, auth_type, peer_idx, false,
Varun Reddy Yeturu725185d2017-11-17 14:14:55 -08001507 eSIR_MAC_UNSPEC_FAILURE_STATUS,
Krunal Soni99752a12016-04-12 17:44:45 -07001508 session);
Nishank Aggarwal8935e442017-03-23 19:11:08 +05301509 pe_err("Delete dph hash entry");
Abhishek Singh0bc46d12017-01-09 13:05:54 +05301510 if (dph_delete_hash_entry(mac_ctx, hdr->sa, sta_ds->assocId,
1511 &session->dph.dphHashTable) != eSIR_SUCCESS)
Nishank Aggarwal8935e442017-03-23 19:11:08 +05301512 pe_err("error deleting hash entry");
Krunal Soni99752a12016-04-12 17:44:45 -07001513 return false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001514 }
Naveen Rawatada5fac2016-01-28 16:24:32 -08001515 if (assoc_req->operMode.present) {
1516 sta_ds->vhtSupportedRxNss = assoc_req->operMode.rxNSS + 1;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001517 } else {
Naveen Rawatada5fac2016-01-28 16:24:32 -08001518 sta_ds->vhtSupportedRxNss =
1519 ((sta_ds->supportedRates.vhtRxMCSMap & MCSMAPMASK2x2)
Krunal Soni99752a12016-04-12 17:44:45 -07001520 == MCSMAPMASK2x2) ? 1 : 2;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001521 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001522
Krunal Soni99752a12016-04-12 17:44:45 -07001523 /* Add STA context at MAC HW (BMU, RHP & TFP) */
Naveen Rawatada5fac2016-01-28 16:24:32 -08001524 sta_ds->qosMode = false;
1525 sta_ds->lleEnabled = false;
1526 if (assoc_req->capabilityInfo.qos && (qos_mode == eHAL_SET)) {
1527 sta_ds->lleEnabled = true;
1528 sta_ds->qosMode = true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001529 }
1530
Naveen Rawatada5fac2016-01-28 16:24:32 -08001531 sta_ds->wmeEnabled = false;
1532 sta_ds->wsmEnabled = false;
1533 limGetWmeMode(session, &wme_mode);
1534 if ((!sta_ds->lleEnabled) && assoc_req->wmeInfoPresent
1535 && (wme_mode == eHAL_SET)) {
1536 sta_ds->wmeEnabled = true;
1537 sta_ds->qosMode = true;
1538 limGetWsmMode(session, &wsm_mode);
Krunal Soni99752a12016-04-12 17:44:45 -07001539 /*
1540 * WMM_APSD - WMM_SA related processing should be separate;
1541 * WMM_SA and WMM_APSD can coexist
1542 */
Naveen Rawatada5fac2016-01-28 16:24:32 -08001543 if (assoc_req->WMMInfoStation.present) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001544 /* check whether AP supports or not */
Naveen Rawatada5fac2016-01-28 16:24:32 -08001545 if (LIM_IS_AP_ROLE(session) &&
Krunal Soni99752a12016-04-12 17:44:45 -07001546 (session->apUapsdEnable == 0) &&
1547 (assoc_req->WMMInfoStation.acbe_uapsd ||
1548 assoc_req->WMMInfoStation.acbk_uapsd ||
1549 assoc_req->WMMInfoStation.acvo_uapsd ||
1550 assoc_req->WMMInfoStation.acvi_uapsd)) {
1551 /*
1552 * Rcvd Re/Assoc Req from STA when UPASD is
1553 * not supported.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001554 */
Nishank Aggarwal8935e442017-03-23 19:11:08 +05301555 pe_err("UAPSD not supported, reply accordingly");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001556 /* update UAPSD and send it to LIM to add STA */
Naveen Rawatada5fac2016-01-28 16:24:32 -08001557 sta_ds->qos.capability.qosInfo.acbe_uapsd = 0;
1558 sta_ds->qos.capability.qosInfo.acbk_uapsd = 0;
1559 sta_ds->qos.capability.qosInfo.acvo_uapsd = 0;
1560 sta_ds->qos.capability.qosInfo.acvi_uapsd = 0;
1561 sta_ds->qos.capability.qosInfo.maxSpLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001562 } else {
1563 /* update UAPSD and send it to LIM to add STA */
Naveen Rawatada5fac2016-01-28 16:24:32 -08001564 sta_ds->qos.capability.qosInfo.acbe_uapsd =
1565 assoc_req->WMMInfoStation.acbe_uapsd;
1566 sta_ds->qos.capability.qosInfo.acbk_uapsd =
1567 assoc_req->WMMInfoStation.acbk_uapsd;
1568 sta_ds->qos.capability.qosInfo.acvo_uapsd =
1569 assoc_req->WMMInfoStation.acvo_uapsd;
1570 sta_ds->qos.capability.qosInfo.acvi_uapsd =
1571 assoc_req->WMMInfoStation.acvi_uapsd;
1572 sta_ds->qos.capability.qosInfo.maxSpLen =
1573 assoc_req->WMMInfoStation.max_sp_length;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001574 }
1575 }
Naveen Rawatada5fac2016-01-28 16:24:32 -08001576 if (assoc_req->wsmCapablePresent && (wsm_mode == eHAL_SET))
1577 sta_ds->wsmEnabled = true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001578 }
1579 /* Re/Assoc Response frame to requesting STA */
Naveen Rawatada5fac2016-01-28 16:24:32 -08001580 sta_ds->mlmStaContext.subType = sub_type;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001581
1582#ifdef WLAN_FEATURE_11W
Naveen Rawatada5fac2016-01-28 16:24:32 -08001583 sta_ds->rmfEnabled = (pmf_connection) ? 1 : 0;
1584 sta_ds->pmfSaQueryState = DPH_SA_QUERY_NOT_IN_PROGRESS;
1585 timer_id.fields.sessionId = session->peSessionId;
1586 timer_id.fields.peerIdx = peer_idx;
1587 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_PMF_SA_QUERY_RETRY_INTERVAL,
Krunal Soni99752a12016-04-12 17:44:45 -07001588 &retry_interval) != eSIR_SUCCESS) {
Nishank Aggarwal8935e442017-03-23 19:11:08 +05301589 pe_err("Couldn't get PMF SA Query retry interval value");
Krunal Soni99752a12016-04-12 17:44:45 -07001590 lim_reject_association(mac_ctx, hdr->sa, sub_type, true,
1591 auth_type, peer_idx, false,
Varun Reddy Yeturu725185d2017-11-17 14:14:55 -08001592 eSIR_MAC_UNSPEC_FAILURE_STATUS,
Krunal Soni99752a12016-04-12 17:44:45 -07001593 session);
1594 return false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001595 }
Naveen Rawatada5fac2016-01-28 16:24:32 -08001596 if (WNI_CFG_PMF_SA_QUERY_RETRY_INTERVAL_STAMIN > retry_interval) {
1597 retry_interval = WNI_CFG_PMF_SA_QUERY_RETRY_INTERVAL_STADEF;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001598 }
Krunal Sonia59e8a42017-11-19 09:00:56 -08001599 if (sta_ds->rmfEnabled &&
1600 tx_timer_create(mac_ctx, &sta_ds->pmfSaQueryTimer,
Krunal Soni99752a12016-04-12 17:44:45 -07001601 "PMF SA Query timer", lim_pmf_sa_query_timer_handler,
1602 timer_id.value,
1603 SYS_MS_TO_TICKS((retry_interval * 1024) / 1000),
1604 0, TX_NO_ACTIVATE) != TX_SUCCESS) {
Nishank Aggarwal8935e442017-03-23 19:11:08 +05301605 pe_err("could not create PMF SA Query timer");
Krunal Soni99752a12016-04-12 17:44:45 -07001606 lim_reject_association(mac_ctx, hdr->sa, sub_type,
1607 true, auth_type, peer_idx, false,
Varun Reddy Yeturu725185d2017-11-17 14:14:55 -08001608 eSIR_MAC_UNSPEC_FAILURE_STATUS,
Krunal Soni99752a12016-04-12 17:44:45 -07001609 session);
1610 return false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001611 }
Krunal Sonia59e8a42017-11-19 09:00:56 -08001612 if (sta_ds->rmfEnabled)
1613 pe_debug("Created pmf timer sta-idx:%d assoc-id:%d",
1614 sta_ds->staIndex, sta_ds->assocId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001615#endif
1616
Naveen Rawatada5fac2016-01-28 16:24:32 -08001617 if (assoc_req->ExtCap.present) {
1618 lim_set_stads_rtt_cap(sta_ds,
1619 (struct s_ext_cap *) assoc_req->ExtCap.bytes, mac_ctx);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001620 } else {
Naveen Rawatada5fac2016-01-28 16:24:32 -08001621 sta_ds->timingMeasCap = 0;
Nishank Aggarwal8935e442017-03-23 19:11:08 +05301622 pe_debug("ExtCap not present");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001623 }
Krunal Soni99752a12016-04-12 17:44:45 -07001624 return true;
1625}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001626
Krunal Soni99752a12016-04-12 17:44:45 -07001627/**
1628 * lim_update_sta_ctx() - add/del sta depending on connection state machine
1629 * @mac_ctx: pointer to Global MAC structure
1630 * @session: pointer to pe session entry
1631 * @assoc_req: pointer to ASSOC/REASSOC Request frame
1632 * @sub_type: Assoc(=0) or Reassoc(=1) Requestframe
1633 * @sta_ds: station dph entry
1634 * @update_ctx: indicates if STA context already exist
1635 *
1636 * Checks for SSID match
1637 *
1638 * Return: true of no error, false otherwise
1639 */
1640static bool lim_update_sta_ctx(tpAniSirGlobal mac_ctx, tpPESession session,
1641 tpSirAssocReq assoc_req, uint8_t sub_type,
1642 tpDphHashNode sta_ds, uint8_t update_ctx)
1643{
1644 tLimMlmStates mlm_prev_state;
1645 /*
1646 * BTAMP: If STA context already exist (ie. update_ctx = 1) for this STA
1647 * then we should delete the old one, and add the new STA. This is taken
1648 * care of in the lim_del_sta() routine.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001649 *
Krunal Soni99752a12016-04-12 17:44:45 -07001650 * Prior to BTAMP, we were setting this flag so that when PE receives
1651 * SME_ASSOC_CNF, and if this flag is set, then PE shall delete the old
1652 * station and then add. But now in BTAMP, we're directly adding station
1653 * before waiting for SME_ASSOC_CNF, so we can do this now.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001654 */
Krunal Soni99752a12016-04-12 17:44:45 -07001655 if (!(update_ctx)) {
Naveen Rawatada5fac2016-01-28 16:24:32 -08001656 sta_ds->mlmStaContext.updateContext = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001657
Krunal Soni99752a12016-04-12 17:44:45 -07001658 /*
1659 * BTAMP: Add STA context at HW - issue WMA_ADD_STA_REQ to HAL
1660 */
Naveen Rawatada5fac2016-01-28 16:24:32 -08001661 if (lim_add_sta(mac_ctx, sta_ds, false, session) !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001662 eSIR_SUCCESS) {
Nishank Aggarwal8935e442017-03-23 19:11:08 +05301663 pe_err("could not Add STA with assocId: %d",
Naveen Rawatada5fac2016-01-28 16:24:32 -08001664 sta_ds->assocId);
1665 lim_reject_association(mac_ctx, sta_ds->staAddr,
Krunal Soni99752a12016-04-12 17:44:45 -07001666 sta_ds->mlmStaContext.subType, true,
1667 sta_ds->mlmStaContext.authType,
1668 sta_ds->assocId, true,
Varun Reddy Yeturu725185d2017-11-17 14:14:55 -08001669 eSIR_MAC_UNSPEC_FAILURE_STATUS,
Krunal Soni99752a12016-04-12 17:44:45 -07001670 session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001671
Naveen Rawatada5fac2016-01-28 16:24:32 -08001672 if (session->parsedAssocReq)
Krunal Soni99752a12016-04-12 17:44:45 -07001673 assoc_req =
1674 session->parsedAssocReq[sta_ds->assocId];
1675 return false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001676 }
1677 } else {
Naveen Rawatada5fac2016-01-28 16:24:32 -08001678 sta_ds->mlmStaContext.updateContext = 1;
Naveen Rawatada5fac2016-01-28 16:24:32 -08001679 mlm_prev_state = sta_ds->mlmStaContext.mlmState;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001680
Krunal Soni99752a12016-04-12 17:44:45 -07001681 /*
1682 * As per the HAL/FW needs the reassoc req need not be calling
1683 * lim_del_sta
1684 */
Naveen Rawatada5fac2016-01-28 16:24:32 -08001685 if (sub_type != LIM_REASSOC) {
Krunal Soni99752a12016-04-12 17:44:45 -07001686 /*
1687 * we need to set the mlmState here in order
1688 * differentiate in lim_del_sta.
1689 */
Naveen Rawatada5fac2016-01-28 16:24:32 -08001690 sta_ds->mlmStaContext.mlmState =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001691 eLIM_MLM_WT_ASSOC_DEL_STA_RSP_STATE;
Krunal Soni99752a12016-04-12 17:44:45 -07001692 if (lim_del_sta(mac_ctx, sta_ds, true, session)
1693 != eSIR_SUCCESS) {
Nishank Aggarwal8935e442017-03-23 19:11:08 +05301694 pe_err("Couldn't DEL STA, assocId: %d staId: %d",
Naveen Rawatada5fac2016-01-28 16:24:32 -08001695 sta_ds->assocId, sta_ds->staIndex);
1696 lim_reject_association(mac_ctx, sta_ds->staAddr,
Krunal Soni99752a12016-04-12 17:44:45 -07001697 sta_ds->mlmStaContext.subType, true,
1698 sta_ds->mlmStaContext.authType,
1699 sta_ds->assocId, true,
Varun Reddy Yeturu725185d2017-11-17 14:14:55 -08001700 eSIR_MAC_UNSPEC_FAILURE_STATUS,
Krunal Soni99752a12016-04-12 17:44:45 -07001701 session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001702
1703 /* Restoring the state back. */
Naveen Rawatada5fac2016-01-28 16:24:32 -08001704 sta_ds->mlmStaContext.mlmState = mlm_prev_state;
1705 if (session->parsedAssocReq)
Krunal Soni99752a12016-04-12 17:44:45 -07001706 assoc_req = session->parsedAssocReq[
1707 sta_ds->assocId];
1708 return false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001709 }
1710 } else {
Krunal Soni99752a12016-04-12 17:44:45 -07001711 /*
1712 * mlmState is changed in lim_add_sta context use the
1713 * same AID, already allocated
1714 */
1715 if (lim_add_sta(mac_ctx, sta_ds, false, session)
1716 != eSIR_SUCCESS) {
Nishank Aggarwal8935e442017-03-23 19:11:08 +05301717 pe_err("UPASD not supported, REASSOC Failed");
Naveen Rawatada5fac2016-01-28 16:24:32 -08001718 lim_reject_association(mac_ctx, sta_ds->staAddr,
Krunal Soni99752a12016-04-12 17:44:45 -07001719 sta_ds->mlmStaContext.subType, true,
1720 sta_ds->mlmStaContext.authType,
1721 sta_ds->assocId, true,
Varun Reddy Yeturu725185d2017-11-17 14:14:55 -08001722 eSIR_MAC_WME_REFUSED_STATUS,
Krunal Soni99752a12016-04-12 17:44:45 -07001723 session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001724
1725 /* Restoring the state back. */
Naveen Rawatada5fac2016-01-28 16:24:32 -08001726 sta_ds->mlmStaContext.mlmState = mlm_prev_state;
1727 if (session->parsedAssocReq)
Krunal Soni99752a12016-04-12 17:44:45 -07001728 assoc_req = session->parsedAssocReq[
Naveen Rawatada5fac2016-01-28 16:24:32 -08001729 sta_ds->assocId];
Krunal Soni99752a12016-04-12 17:44:45 -07001730 return false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001731 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001732 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001733 }
Krunal Soni99752a12016-04-12 17:44:45 -07001734 return true;
1735}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001736
Krunal Soni99752a12016-04-12 17:44:45 -07001737/**
1738 * lim_process_assoc_cleanup() - frees up resources used in function
1739 * lim_process_assoc_req_frame()
1740 * @mac_ctx: pointer to Global MAC structure
1741 * @session: pointer to pe session entry
1742 * @assoc_req: pointer to ASSOC/REASSOC Request frame
1743 * @sta_ds: station dph entry
1744 * @tmp_assoc_req: pointer to tmp ASSOC/REASSOC Request frame
1745 * @assoc_req_copied: boolean to indicate if assoc req was copied to tmp above
1746 *
1747 * Frees up resources used in function lim_process_assoc_req_frame
1748 *
1749 * Return: void
1750 */
1751static void lim_process_assoc_cleanup(tpAniSirGlobal mac_ctx,
1752 tpPESession session,
1753 tpSirAssocReq assoc_req,
1754 tpDphHashNode sta_ds,
Krunal Soni99752a12016-04-12 17:44:45 -07001755 bool *assoc_req_copied)
1756{
Abhishek Singh61084982016-12-13 17:24:07 +05301757 tpSirAssocReq tmp_assoc_req;
1758
Naveen Rawatada5fac2016-01-28 16:24:32 -08001759 if (assoc_req != NULL) {
1760 if (assoc_req->assocReqFrame) {
1761 qdf_mem_free(assoc_req->assocReqFrame);
1762 assoc_req->assocReqFrame = NULL;
1763 assoc_req->assocReqFrameLength = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001764 }
1765
Naveen Rawatada5fac2016-01-28 16:24:32 -08001766 qdf_mem_free(assoc_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001767 /* to avoid double free */
Krunal Soni99752a12016-04-12 17:44:45 -07001768 if (*assoc_req_copied && session->parsedAssocReq)
Naveen Rawatada5fac2016-01-28 16:24:32 -08001769 session->parsedAssocReq[sta_ds->assocId] = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001770 }
1771
1772 /* If it is not duplicate Assoc request then only make to Null */
Naveen Rawatada5fac2016-01-28 16:24:32 -08001773 if ((sta_ds != NULL) &&
1774 (sta_ds->mlmStaContext.mlmState != eLIM_MLM_WT_ADD_STA_RSP_STATE)) {
1775 if (session->parsedAssocReq != NULL) {
1776 tmp_assoc_req =
1777 session->parsedAssocReq[sta_ds->assocId];
1778 if (tmp_assoc_req != NULL) {
1779 if (tmp_assoc_req->assocReqFrame) {
Krunal Soni99752a12016-04-12 17:44:45 -07001780 qdf_mem_free(
1781 tmp_assoc_req->assocReqFrame);
Naveen Rawatada5fac2016-01-28 16:24:32 -08001782 tmp_assoc_req->assocReqFrame = NULL;
1783 tmp_assoc_req->assocReqFrameLength = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001784 }
Naveen Rawatada5fac2016-01-28 16:24:32 -08001785 qdf_mem_free(tmp_assoc_req);
Krunal Soni99752a12016-04-12 17:44:45 -07001786 session->parsedAssocReq[sta_ds->assocId] = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001787 }
1788 }
1789 }
Krunal Soni99752a12016-04-12 17:44:45 -07001790}
1791
1792/**
1793 * lim_process_assoc_req_frame() - Process RE/ASSOC Request frame.
1794 * @mac_ctx: Pointer to Global MAC structure
1795 * @rx_pkt_info: A pointer to Buffer descriptor + associated PDUs
1796 * @sub_type: Indicates whether it is Association Request(=0) or Reassociation
1797 * Request(=1) frame
1798 * @session: pe session entry
1799 *
1800 * This function is called to process RE/ASSOC Request frame.
1801 *
1802 * @Return: void
1803 */
1804void lim_process_assoc_req_frame(tpAniSirGlobal mac_ctx, uint8_t *rx_pkt_info,
1805 uint8_t sub_type, tpPESession session)
1806{
1807 bool pmf_connection = false, assoc_req_copied = false;
1808 uint8_t update_ctx, *frm_body;
1809 uint16_t peer_idx, assoc_id = 0;
Krishna Kumaar Natarajandb582ec2016-03-08 17:37:04 -08001810 uint32_t frame_len;
Krunal Soni99752a12016-04-12 17:44:45 -07001811 uint32_t phy_mode;
1812 tHalBitVal qos_mode;
1813 tpSirMacMgmtHdr hdr;
1814 struct tLimPreAuthNode *sta_pre_auth_ctx;
1815 tAniAuthType auth_type;
1816 tSirMacCapabilityInfo local_cap;
1817 tpDphHashNode sta_ds = NULL;
Abhishek Singh61084982016-12-13 17:24:07 +05301818 tpSirAssocReq assoc_req;
Sandeep Puligilla7e3e3c52016-09-02 17:54:21 -07001819 bool dup_entry = false;
Krunal Soni99752a12016-04-12 17:44:45 -07001820
1821 lim_get_phy_mode(mac_ctx, &phy_mode, session);
1822
1823 limGetQosMode(session, &qos_mode);
1824
1825 hdr = WMA_GET_RX_MAC_HEADER(rx_pkt_info);
1826 frame_len = WMA_GET_RX_PAYLOAD_LEN(rx_pkt_info);
1827
Nishank Aggarwal8935e442017-03-23 19:11:08 +05301828 pe_debug("Rcvd: %s Req Frame sessionid: %d systemrole: %d MlmState: %d from: "
1829 MAC_ADDRESS_STR,
Krunal Soni99752a12016-04-12 17:44:45 -07001830 (LIM_ASSOC == sub_type) ? "Assoc" : "ReAssoc",
1831 session->peSessionId, GET_LIM_SYSTEM_ROLE(session),
1832 session->limMlmState, MAC_ADDR_ARRAY(hdr->sa));
1833
Rajeev Kumarbe5d7fd2016-04-15 14:35:12 -07001834 if (LIM_IS_STA_ROLE(session)) {
Nishank Aggarwal8935e442017-03-23 19:11:08 +05301835 pe_err("Rcvd unexpected ASSOC REQ, sessionid: %d sys sub_type: %d for role: %d from: "
1836 MAC_ADDRESS_STR,
Krunal Soni99752a12016-04-12 17:44:45 -07001837 session->peSessionId, sub_type,
1838 GET_LIM_SYSTEM_ROLE(session),
1839 MAC_ADDR_ARRAY(hdr->sa));
Srinivas Girigowdab896a562017-03-16 17:41:26 -07001840 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_DEBUG,
1841 WMA_GET_RX_MPDU_DATA(rx_pkt_info),
1842 frame_len);
Krunal Soni99752a12016-04-12 17:44:45 -07001843 return;
1844 }
Liangwei Dong9028d752016-10-17 02:00:17 -04001845 if (session->limMlmState == eLIM_MLM_WT_DEL_BSS_RSP_STATE) {
Nishank Aggarwal8935e442017-03-23 19:11:08 +05301846 pe_err("drop ASSOC REQ on sessionid: %d "
1847 "role: %d from: "MAC_ADDRESS_STR" in limMlmState: %d",
Liangwei Dong9028d752016-10-17 02:00:17 -04001848 session->peSessionId,
1849 GET_LIM_SYSTEM_ROLE(session),
1850 MAC_ADDR_ARRAY(hdr->sa),
1851 eLIM_MLM_WT_DEL_BSS_RSP_STATE);
1852 return;
1853 }
Krunal Soni99752a12016-04-12 17:44:45 -07001854
1855 /*
1856 * If a STA is already present in DPH and it is initiating a Assoc
1857 * re-transmit, do not process it. This can happen when first Assoc Req
1858 * frame is received but ACK lost at STA side. The ACK for this dropped
1859 * Assoc Req frame should be sent by HW. Host simply does not process it
1860 * once the entry for the STA is already present in DPH.
1861 */
1862 sta_ds = dph_lookup_hash_entry(mac_ctx, hdr->sa, &assoc_id,
1863 &session->dph.dphHashTable);
1864 if (NULL != sta_ds) {
1865 if (hdr->fc.retry > 0) {
Nishank Aggarwal8935e442017-03-23 19:11:08 +05301866 pe_err("STA is initiating Assoc Req after ACK lost. Do not process sessionid: %d sys sub_type=%d for role=%d from: "
1867 MAC_ADDRESS_STR, session->peSessionId,
Krunal Soni99752a12016-04-12 17:44:45 -07001868 sub_type, GET_LIM_SYSTEM_ROLE(session),
1869 MAC_ADDR_ARRAY(hdr->sa));
Abhishek Singha0b4dc12017-03-09 15:29:31 +05301870 return;
Krunal Soni17184262017-06-07 16:42:38 -07001871 } else if (!sta_ds->rmfEnabled && (sub_type == LIM_REASSOC)) {
1872 /*
1873 * SAP should send reassoc response with reject code
1874 * to avoid IOT issues. as per the specification SAP
1875 * should do 4-way handshake after reassoc response and
1876 * some STA doesn't like 4way handshake after reassoc
1877 * where some STA does expect 4-way handshake.
1878 */
1879 lim_send_assoc_rsp_mgmt_frame(mac_ctx,
1880 eSIR_MAC_OUTSIDE_SCOPE_OF_SPEC_STATUS,
1881 sta_ds->assocId, sta_ds->staAddr,
1882 sub_type, sta_ds, session);
1883 pe_err("Rejecting reassoc req from STA");
1884 return;
Krunal Soni99752a12016-04-12 17:44:45 -07001885 } else if (!sta_ds->rmfEnabled) {
1886 /*
1887 * Do this only for non PMF case.
1888 * STA might have missed the assoc response, so it is
1889 * sending assoc request frame again.
1890 */
1891 lim_send_assoc_rsp_mgmt_frame(mac_ctx, eSIR_SUCCESS,
1892 sta_ds->assocId, sta_ds->staAddr,
Krunal Soni90ba9542017-03-01 19:45:40 -08001893 sub_type,
Krunal Soni99752a12016-04-12 17:44:45 -07001894 sta_ds, session);
Nishank Aggarwal8935e442017-03-23 19:11:08 +05301895 pe_err("DUT already received an assoc request frame and STA is sending another assoc req.So, do not Process sessionid: %d sys sub_type: %d for role: %d from: "
1896 MAC_ADDRESS_STR,
Krunal Soni99752a12016-04-12 17:44:45 -07001897 session->peSessionId, sub_type,
1898 session->limSystemRole,
1899 MAC_ADDR_ARRAY(hdr->sa));
Abhishek Singha0b4dc12017-03-09 15:29:31 +05301900 return;
Krunal Soni99752a12016-04-12 17:44:45 -07001901 }
Krunal Soni99752a12016-04-12 17:44:45 -07001902 }
1903
Sandeep Puligilla7e3e3c52016-09-02 17:54:21 -07001904 dup_entry = lim_check_sta_in_pe_entries(mac_ctx, hdr,
1905 session->peSessionId);
Krunal Soni99752a12016-04-12 17:44:45 -07001906
1907 /* Get pointer to Re/Association Request frame body */
1908 frm_body = WMA_GET_RX_MPDU_DATA(rx_pkt_info);
1909
1910 if (lim_is_group_addr(hdr->sa)) {
1911 /*
1912 * Rcvd Re/Assoc Req frame from BC/MC address Log error and
1913 * ignore it
1914 */
Nishank Aggarwal8935e442017-03-23 19:11:08 +05301915 pe_err("Rcvd: %s Req, sessionid: %d from a BC/MC address"
1916 MAC_ADDRESS_STR,
Krunal Soni99752a12016-04-12 17:44:45 -07001917 (LIM_ASSOC == sub_type) ? "Assoc" : "ReAssoc",
1918 session->peSessionId, MAC_ADDR_ARRAY(hdr->sa));
1919 return;
1920 }
1921
Srinivas Girigowdab896a562017-03-16 17:41:26 -07001922 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_DEBUG,
1923 (uint8_t *) frm_body, frame_len);
Krunal Soni99752a12016-04-12 17:44:45 -07001924
1925 if (false == lim_chk_sa_da(mac_ctx, hdr, session, sub_type))
1926 return;
1927
1928 if (false == lim_chk_tkip(mac_ctx, hdr, session, sub_type))
1929 return;
1930
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05301931 /* check for the presence of vendor IE */
1932 if ((session->access_policy_vendor_ie) &&
1933 (session->access_policy ==
1934 LIM_ACCESS_POLICY_RESPOND_IF_IE_IS_PRESENT)) {
Naveen Rawat08db88f2017-09-08 15:07:48 -07001935 if (!wlan_get_vendor_ie_ptr_from_oui(
1936 &session->access_policy_vendor_ie[2],
1937 3, frm_body + LIM_ASSOC_REQ_IE_OFFSET,
1938 frame_len)) {
Nishank Aggarwal8935e442017-03-23 19:11:08 +05301939 pe_err("Vendor ie not present and access policy is %x, Rejected association",
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05301940 session->access_policy);
1941 lim_send_assoc_rsp_mgmt_frame(mac_ctx,
1942 eSIR_MAC_UNSPEC_FAILURE_STATUS, 1, hdr->sa,
1943 sub_type, 0, session);
1944 return;
1945 }
1946 }
Krunal Soni99752a12016-04-12 17:44:45 -07001947 /* Allocate memory for the Assoc Request frame */
1948 assoc_req = qdf_mem_malloc(sizeof(*assoc_req));
1949 if (NULL == assoc_req) {
Nishank Aggarwal8935e442017-03-23 19:11:08 +05301950 pe_err("Allocate Memory failed in assoc_req");
Krunal Soni99752a12016-04-12 17:44:45 -07001951 return;
1952 }
Krunal Soni99752a12016-04-12 17:44:45 -07001953
1954 /* Parse Assoc Request frame */
1955 if (false == lim_chk_assoc_req_parse_error(mac_ctx, hdr, session,
1956 assoc_req, sub_type, frm_body, frame_len))
1957 goto error;
1958
1959 assoc_req->assocReqFrame = qdf_mem_malloc(frame_len);
1960 if (NULL == assoc_req->assocReqFrame) {
Nishank Aggarwal8935e442017-03-23 19:11:08 +05301961 pe_err("Memory alloc failed for the assoc req, len: %d",
Krunal Soni99752a12016-04-12 17:44:45 -07001962 frame_len);
1963 goto error;
1964 }
1965
1966 qdf_mem_copy((uint8_t *) assoc_req->assocReqFrame,
1967 (uint8_t *) frm_body, frame_len);
1968 assoc_req->assocReqFrameLength = frame_len;
1969
1970 if (false == lim_chk_capab(mac_ctx, hdr, session, assoc_req,
1971 sub_type, &local_cap))
1972 goto error;
1973
1974 update_ctx = false;
1975
1976 if (false == lim_chk_ssid(mac_ctx, hdr, session, assoc_req, sub_type))
1977 goto error;
1978
1979 if (false == lim_chk_rates(mac_ctx, hdr, session, assoc_req, sub_type))
1980 goto error;
1981
1982 if (false == lim_chk_11g_only(mac_ctx, hdr, session, assoc_req,
1983 sub_type))
1984 goto error;
1985
1986 if (false == lim_chk_11n_only(mac_ctx, hdr, session, assoc_req,
1987 sub_type))
1988 goto error;
1989
1990 if (false == lim_chk_11ac_only(mac_ctx, hdr, session, assoc_req,
1991 sub_type))
1992 goto error;
1993
Naveen Rawat441bc872017-12-11 17:25:27 -08001994 if (false == lim_chk_11ax_only(mac_ctx, hdr, session, assoc_req,
1995 sub_type))
1996 goto error;
1997
1998 if (false == lim_check_11ax_basic_mcs(mac_ctx, hdr, session, assoc_req,
1999 sub_type))
2000 goto error;
2001
Krunal Soni99752a12016-04-12 17:44:45 -07002002 /* Spectrum Management (11h) specific checks */
2003 lim_process_for_spectrum_mgmt(mac_ctx, hdr, session,
2004 assoc_req, sub_type, local_cap);
2005
2006 if (false == lim_chk_mcs(mac_ctx, hdr, session, assoc_req, sub_type))
2007 goto error;
2008
2009 if (false == lim_chk_is_11b_sta_supported(mac_ctx, hdr, session,
2010 assoc_req, sub_type, phy_mode))
2011 goto error;
2012
2013 /*
2014 * Check for 802.11n HT caps compatibility; are HT Capabilities
2015 * turned on in lim?
2016 */
2017 lim_print_ht_cap(mac_ctx, session, assoc_req);
2018
2019 if (false == lim_chk_n_process_wpa_rsn_ie(mac_ctx, hdr, session,
2020 assoc_req, sub_type, &pmf_connection))
2021 goto error;
2022
2023 /* Extract 'associated' context for STA, if any. */
2024 sta_ds = dph_lookup_hash_entry(mac_ctx, hdr->sa, &peer_idx,
2025 &session->dph.dphHashTable);
2026
2027 /* Extract pre-auth context for the STA, if any. */
2028 sta_pre_auth_ctx = lim_search_pre_auth_list(mac_ctx, hdr->sa);
2029
2030 if (sta_ds == NULL) {
2031 if (false == lim_process_assoc_req_no_sta_ctx(mac_ctx, hdr,
2032 session, assoc_req, sub_type, sta_pre_auth_ctx,
2033 sta_ds, &auth_type))
2034 goto error;
2035 } else {
2036 if (false == lim_process_assoc_req_sta_ctx(mac_ctx, hdr,
2037 session, assoc_req, sub_type, sta_pre_auth_ctx,
2038 sta_ds, peer_idx, &auth_type, &update_ctx))
2039 goto error;
2040 goto sendIndToSme;
2041 }
2042
2043 /* check if sta is allowed per QoS AC rules */
2044 if (false == lim_chk_wmm(mac_ctx, hdr, session,
2045 assoc_req, sub_type, qos_mode))
2046 goto error;
2047
2048 /* STA is Associated ! */
Nishank Aggarwal8935e442017-03-23 19:11:08 +05302049 pe_err("Received: %s Req successful from " MAC_ADDRESS_STR,
Krunal Soni99752a12016-04-12 17:44:45 -07002050 (LIM_ASSOC == sub_type) ? "Assoc" : "ReAssoc",
2051 MAC_ADDR_ARRAY(hdr->sa));
2052
2053 /*
2054 * AID for this association will be same as the peer Index used in DPH
2055 * table. Assign unused/least recently used peer Index from perStaDs.
2056 * NOTE: lim_assign_peer_idx() assigns AID values ranging between
2057 * 1 - cfg_item(WNI_CFG_ASSOC_STA_LIMIT)
2058 */
2059
2060 peer_idx = lim_assign_peer_idx(mac_ctx, session);
2061
2062 if (!peer_idx) {
2063 /* Could not assign AID. Reject association */
Nishank Aggarwal8935e442017-03-23 19:11:08 +05302064 pe_err("PeerIdx not avaialble. Reject associaton");
Krunal Soni99752a12016-04-12 17:44:45 -07002065 lim_reject_association(mac_ctx, hdr->sa, sub_type,
2066 true, auth_type, peer_idx, false,
Varun Reddy Yeturu725185d2017-11-17 14:14:55 -08002067 eSIR_MAC_UNSPEC_FAILURE_STATUS,
Krunal Soni99752a12016-04-12 17:44:45 -07002068 session);
2069 goto error;
2070 }
2071
2072 /* Add an entry to hash table maintained by DPH module */
2073
2074 sta_ds = dph_add_hash_entry(mac_ctx, hdr->sa, peer_idx,
2075 &session->dph.dphHashTable);
2076
2077 if (sta_ds == NULL) {
2078 /* Could not add hash table entry at DPH */
Nishank Aggarwal8935e442017-03-23 19:11:08 +05302079 pe_err("couldn't add hash entry at DPH for aid: %d MacAddr:"
2080 MAC_ADDRESS_STR, peer_idx, MAC_ADDR_ARRAY(hdr->sa));
Krunal Soni99752a12016-04-12 17:44:45 -07002081
2082 /* Release AID */
2083 lim_release_peer_idx(mac_ctx, peer_idx, session);
2084
2085 lim_reject_association(mac_ctx, hdr->sa, sub_type,
2086 true, auth_type, peer_idx, false,
Varun Reddy Yeturu725185d2017-11-17 14:14:55 -08002087 eSIR_MAC_UNSPEC_FAILURE_STATUS,
Krunal Soni99752a12016-04-12 17:44:45 -07002088 session);
2089 goto error;
2090 }
2091
2092sendIndToSme:
Abhishek Singh0bc46d12017-01-09 13:05:54 +05302093 if (false == lim_update_sta_ds(mac_ctx, hdr, session, assoc_req,
Abhishek Singh61084982016-12-13 17:24:07 +05302094 sub_type, sta_ds, auth_type,
Krunal Soni99752a12016-04-12 17:44:45 -07002095 &assoc_req_copied, peer_idx, qos_mode,
2096 pmf_connection))
2097 goto error;
2098
Abhishek Singh61084982016-12-13 17:24:07 +05302099
Krunal Soni99752a12016-04-12 17:44:45 -07002100 /* BTAMP: Storing the parsed assoc request in the session array */
2101 if (session->parsedAssocReq)
2102 session->parsedAssocReq[sta_ds->assocId] = assoc_req;
2103 assoc_req_copied = true;
2104
Sandeep Puligilla7e3e3c52016-09-02 17:54:21 -07002105 /* If it is duplicate entry wait till the peer is deleted */
2106 if (dup_entry != true) {
2107 if (false == lim_update_sta_ctx(mac_ctx, session, assoc_req,
Krunal Soni99752a12016-04-12 17:44:45 -07002108 sub_type, sta_ds, update_ctx))
2109 goto error;
Sandeep Puligilla7e3e3c52016-09-02 17:54:21 -07002110 }
Krunal Soni99752a12016-04-12 17:44:45 -07002111
Jeff Johnson5ead5ab2018-05-06 00:11:08 -07002112 /* AddSta is success here */
Krunal Soni99752a12016-04-12 17:44:45 -07002113 if (LIM_IS_AP_ROLE(session) && IS_DOT11_MODE_HT(session->dot11mode) &&
2114 assoc_req->HTCaps.present && assoc_req->wmeInfoPresent) {
2115 /*
2116 * Update in the HAL Sta Table for the Update of the Protection
2117 * Mode
2118 */
2119 lim_post_sm_state_update(mac_ctx, sta_ds->staIndex,
2120 sta_ds->htMIMOPSState, sta_ds->staAddr,
2121 session->smeSessionId);
2122 }
2123
2124 return;
2125
2126error:
Krunal Soni99752a12016-04-12 17:44:45 -07002127 lim_process_assoc_cleanup(mac_ctx, session, assoc_req, sta_ds,
Abhishek Singh61084982016-12-13 17:24:07 +05302128 &assoc_req_copied);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002129 return;
Naveen Rawatada5fac2016-01-28 16:24:32 -08002130}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002131
2132#ifdef FEATURE_WLAN_WAPI
2133/**
2134 * lim_fill_assoc_ind_wapi_info()- Updates WAPI data in assoc indication
2135 * @mac_ctx: Global Mac context
2136 * @assoc_req: pointer to association request
2137 * @assoc_ind: Pointer to association indication
2138 * @wpsie: WPS IE
2139 *
2140 * This function updates WAPI meta data in association indication message
2141 * sent to SME.
2142 *
2143 * Return: None
2144 */
2145static void lim_fill_assoc_ind_wapi_info(tpAniSirGlobal mac_ctx,
2146 tpSirAssocReq assoc_req, tpLimMlmAssocInd assoc_ind,
Naveen Rawat08db88f2017-09-08 15:07:48 -07002147 const uint8_t *wpsie)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002148{
2149 if (assoc_req->wapiPresent && (NULL == wpsie)) {
Nishank Aggarwal8935e442017-03-23 19:11:08 +05302150 pe_debug("Received WAPI IE length in Assoc Req is %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002151 assoc_req->wapi.length);
2152 assoc_ind->wapiIE.wapiIEdata[0] = SIR_MAC_WAPI_EID;
2153 assoc_ind->wapiIE.wapiIEdata[1] = assoc_req->wapi.length;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302154 qdf_mem_copy(&assoc_ind->wapiIE.wapiIEdata[2],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002155 assoc_req->wapi.info, assoc_req->wapi.length);
2156 assoc_ind->wapiIE.length =
2157 2 + assoc_req->wapi.length;
2158 }
2159 return;
2160}
2161#endif
2162
2163/**
2164 * lim_fill_assoc_ind_vht_info() - Updates VHT information in assoc indication
2165 * @mac_ctx: Global Mac context
2166 * @assoc_req: pointer to association request
2167 * @session_entry: PE session entry
2168 * @assoc_ind: Pointer to association indication
2169 *
2170 * This function updates VHT information in association indication message
2171 * sent to SME.
2172 *
2173 * Return: None
2174 */
2175static void lim_fill_assoc_ind_vht_info(tpAniSirGlobal mac_ctx,
Naveen Rawat6186ff92015-10-12 14:33:53 -07002176 tpPESession session_entry,
2177 tpSirAssocReq assoc_req,
Ashish Kumar Dhanotiya443d31f2017-10-13 12:41:19 +05302178 tpLimMlmAssocInd assoc_ind,
2179 tpDphHashNode sta_ds)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002180{
2181 uint8_t chan;
Ashish Kumar Dhanotiya443d31f2017-10-13 12:41:19 +05302182 uint8_t i;
2183 bool nw_type_11b = true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002184
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08002185 if (session_entry->limRFBand == BAND_2G) {
Naveen Rawat6186ff92015-10-12 14:33:53 -07002186 if (session_entry->vhtCapability && assoc_req->VHTCaps.present)
Krishna Kumaar Natarajan294da812016-04-28 14:39:30 -07002187 assoc_ind->chan_info.info = MODE_11AC_VHT20_2G;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002188 else if (session_entry->htCapability
Naveen Rawat6186ff92015-10-12 14:33:53 -07002189 && assoc_req->HTCaps.present)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002190 assoc_ind->chan_info.info = MODE_11NG_HT20;
Ashish Kumar Dhanotiya443d31f2017-10-13 12:41:19 +05302191 else {
2192 for (i = 0; i < SIR_NUM_11A_RATES; i++) {
2193 if (sirIsArate(sta_ds->
2194 supportedRates.llaRates[i]
2195 & 0x7F)) {
2196 assoc_ind->chan_info.info = MODE_11G;
2197 nw_type_11b = false;
2198 break;
2199 }
2200 }
2201 if (nw_type_11b)
2202 assoc_ind->chan_info.info = MODE_11B;
2203 }
Naveen Rawat6186ff92015-10-12 14:33:53 -07002204 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002205 }
Naveen Rawat6186ff92015-10-12 14:33:53 -07002206
2207 if (session_entry->vhtCapability && assoc_req->VHTCaps.present) {
2208 if ((session_entry->ch_width > CH_WIDTH_40MHZ)
2209 && assoc_req->HTCaps.supportedChannelWidthSet) {
2210 chan = session_entry->ch_center_freq_seg0;
2211 assoc_ind->chan_info.band_center_freq1 =
2212 cds_chan_to_freq(chan);
2213 assoc_ind->chan_info.info = MODE_11AC_VHT80;
2214 return;
2215 }
2216
2217 if ((session_entry->ch_width == CH_WIDTH_40MHZ)
2218 && assoc_req->HTCaps.supportedChannelWidthSet) {
2219 assoc_ind->chan_info.info = MODE_11AC_VHT40;
2220 if (session_entry->htSecondaryChannelOffset ==
2221 PHY_DOUBLE_CHANNEL_LOW_PRIMARY)
2222 assoc_ind->chan_info.band_center_freq1 += 10;
2223 else
2224 assoc_ind->chan_info.band_center_freq1 -= 10;
2225 return;
2226 }
2227
2228 assoc_ind->chan_info.info = MODE_11AC_VHT20;
2229 return;
2230 }
2231
2232 if (session_entry->htCapability && assoc_req->HTCaps.present) {
2233 if ((session_entry->ch_width == CH_WIDTH_40MHZ)
2234 && assoc_req->HTCaps.supportedChannelWidthSet) {
2235 assoc_ind->chan_info.info = MODE_11NA_HT40;
2236 if (session_entry->htSecondaryChannelOffset ==
2237 PHY_DOUBLE_CHANNEL_LOW_PRIMARY)
2238 assoc_ind->chan_info.band_center_freq1 += 10;
2239 else
2240 assoc_ind->chan_info.band_center_freq1 -= 10;
2241 return;
2242 }
2243
2244 assoc_ind->chan_info.info = MODE_11NA_HT20;
2245 return;
2246 }
2247
2248 assoc_ind->chan_info.info = MODE_11A;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002249 return;
2250}
2251
Will Huang558f8082017-05-31 16:22:24 +08002252static uint8_t lim_get_max_rate_idx(tSirMacRateSet *rateset)
2253{
2254 uint8_t maxidx;
2255 int i;
2256
2257 maxidx = rateset->rate[0] & 0x7f;
2258 for (i = 1; i < rateset->numRates; i++) {
2259 if ((rateset->rate[i] & 0x7f) > maxidx)
2260 maxidx = rateset->rate[i] & 0x7f;
2261 }
2262
2263 return maxidx;
2264}
2265
2266static void fill_mlm_assoc_ind_vht(tpSirAssocReq assocreq,
2267 tpDphHashNode stads,
2268 tpLimMlmAssocInd assocind)
2269{
2270 if (stads->mlmStaContext.vhtCapability) {
2271 /* ampdu */
2272 assocind->ampdu = true;
2273
2274 /* sgi */
2275 if (assocreq->VHTCaps.shortGI80MHz ||
2276 assocreq->VHTCaps.shortGI160and80plus80MHz)
2277 assocind->sgi_enable = true;
2278
2279 /* stbc */
2280 assocind->tx_stbc = assocreq->VHTCaps.txSTBC;
2281 assocind->rx_stbc = assocreq->VHTCaps.rxSTBC;
2282
2283 /* ch width */
2284 assocind->ch_width = stads->vhtSupportedChannelWidthSet ?
2285 eHT_CHANNEL_WIDTH_80MHZ :
2286 stads->htSupportedChannelWidthSet ?
2287 eHT_CHANNEL_WIDTH_40MHZ : eHT_CHANNEL_WIDTH_20MHZ;
2288
2289 /* mode */
2290 assocind->mode = SIR_SME_PHY_MODE_VHT;
2291 assocind->rx_mcs_map = assocreq->VHTCaps.rxMCSMap & 0xff;
2292 assocind->tx_mcs_map = assocreq->VHTCaps.txMCSMap & 0xff;
2293 }
2294}
2295
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002296/**
2297 * lim_send_mlm_assoc_ind() - Sends assoc indication to SME
2298 * @mac_ctx: Global Mac context
2299 * @sta_ds: Station DPH hash entry
2300 * @session_entry: PE session entry
2301 *
2302 * This function sends either LIM_MLM_ASSOC_IND
2303 * or LIM_MLM_REASSOC_IND to SME.
2304 *
2305 * Return: None
2306 */
2307void lim_send_mlm_assoc_ind(tpAniSirGlobal mac_ctx,
2308 tpDphHashNode sta_ds, tpPESession session_entry)
2309{
2310 tpLimMlmAssocInd assoc_ind = NULL;
2311 tpSirAssocReq assoc_req;
2312 uint16_t temp, rsn_len;
2313 uint32_t phy_mode;
2314 uint8_t sub_type;
Naveen Rawat08db88f2017-09-08 15:07:48 -07002315 const uint8_t *wpsie = NULL;
Will Huang558f8082017-05-31 16:22:24 +08002316 uint8_t maxidx, i;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002317 uint32_t tmp;
2318
2319 /* Get a copy of the already parsed Assoc Request */
2320 assoc_req =
2321 (tpSirAssocReq) session_entry->parsedAssocReq[sta_ds->assocId];
2322
2323 /* Get the phy_mode */
2324 lim_get_phy_mode(mac_ctx, &phy_mode, session_entry);
2325
2326 /* Determine if its Assoc or ReAssoc Request */
2327 if (assoc_req->reassocRequest == 1)
2328 sub_type = LIM_REASSOC;
2329 else
2330 sub_type = LIM_ASSOC;
2331
Nishank Aggarwal8935e442017-03-23 19:11:08 +05302332 pe_debug("Sessionid: %d ssid: %s sub_type: %d Associd: %d staAddr: "
2333 MAC_ADDRESS_STR, session_entry->peSessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002334 assoc_req->ssId.ssId, sub_type, sta_ds->assocId,
2335 MAC_ADDR_ARRAY(sta_ds->staAddr));
2336
2337 if (sub_type == LIM_ASSOC || sub_type == LIM_REASSOC) {
2338 temp = sizeof(tLimMlmAssocInd);
2339
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302340 assoc_ind = qdf_mem_malloc(temp);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002341 if (NULL == assoc_ind) {
2342 lim_release_peer_idx(mac_ctx, sta_ds->assocId,
2343 session_entry);
Nishank Aggarwal8935e442017-03-23 19:11:08 +05302344 pe_err("AllocateMemory failed for assoc_ind");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002345 return;
2346 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302347 qdf_mem_copy((uint8_t *) assoc_ind->peerMacAddr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002348 (uint8_t *) sta_ds->staAddr, sizeof(tSirMacAddr));
2349 assoc_ind->aid = sta_ds->assocId;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302350 qdf_mem_copy((uint8_t *) &assoc_ind->ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002351 (uint8_t *) &(assoc_req->ssId),
2352 assoc_req->ssId.length + 1);
2353 assoc_ind->sessionId = session_entry->peSessionId;
2354 assoc_ind->authType = sta_ds->mlmStaContext.authType;
2355 assoc_ind->capabilityInfo = assoc_req->capabilityInfo;
2356
2357 /* Fill in RSN IE information */
2358 assoc_ind->rsnIE.length = 0;
2359 /* if WPS IE is present, ignore RSN IE */
2360 if (assoc_req->addIEPresent && assoc_req->addIE.length) {
2361 wpsie = limGetWscIEPtr(mac_ctx,
2362 assoc_req->addIE.addIEdata,
2363 assoc_req->addIE.length);
2364 }
2365 if (assoc_req->rsnPresent && (NULL == wpsie)) {
Nishank Aggarwal8935e442017-03-23 19:11:08 +05302366 pe_debug("Assoc Req RSN IE len: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002367 assoc_req->rsn.length);
2368 assoc_ind->rsnIE.length = 2 + assoc_req->rsn.length;
2369 assoc_ind->rsnIE.rsnIEdata[0] = SIR_MAC_RSN_EID;
2370 assoc_ind->rsnIE.rsnIEdata[1] =
2371 assoc_req->rsn.length;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302372 qdf_mem_copy(&assoc_ind->rsnIE.rsnIEdata[2],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002373 assoc_req->rsn.info,
2374 assoc_req->rsn.length);
2375 }
2376 /* Fill in 802.11h related info */
2377 if (assoc_req->powerCapabilityPresent
2378 && assoc_req->supportedChannelsPresent) {
Srinivas Girigowda74a66d62017-06-21 23:28:25 -07002379 assoc_ind->spectrumMgtIndicator = true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002380 assoc_ind->powerCap.minTxPower =
2381 assoc_req->powerCapability.minTxPower;
2382 assoc_ind->powerCap.maxTxPower =
2383 assoc_req->powerCapability.maxTxPower;
2384 lim_convert_supported_channels(mac_ctx, assoc_ind,
2385 assoc_req);
2386 } else {
Srinivas Girigowda74a66d62017-06-21 23:28:25 -07002387 assoc_ind->spectrumMgtIndicator = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002388 }
2389
2390 /* This check is to avoid extra Sec IEs present incase of WPS */
2391 if (assoc_req->wpaPresent && (NULL == wpsie)) {
2392 rsn_len = assoc_ind->rsnIE.length;
2393 if ((rsn_len + assoc_req->wpa.length)
2394 >= SIR_MAC_MAX_IE_LENGTH) {
Nishank Aggarwal8935e442017-03-23 19:11:08 +05302395 pe_err("rsnIEdata index out of bounds: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002396 rsn_len);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302397 qdf_mem_free(assoc_ind);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002398 return;
2399 }
2400 assoc_ind->rsnIE.rsnIEdata[rsn_len] =
2401 SIR_MAC_WPA_EID;
2402 assoc_ind->rsnIE.rsnIEdata[rsn_len + 1]
2403 = assoc_req->wpa.length;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302404 qdf_mem_copy(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002405 &assoc_ind->rsnIE.rsnIEdata[rsn_len + 2],
2406 assoc_req->wpa.info, assoc_req->wpa.length);
2407 assoc_ind->rsnIE.length += 2 + assoc_req->wpa.length;
2408 }
2409#ifdef FEATURE_WLAN_WAPI
2410 lim_fill_assoc_ind_wapi_info(mac_ctx, assoc_req, assoc_ind,
2411 wpsie);
2412#endif
2413
2414 assoc_ind->addIE.length = 0;
2415 if (assoc_req->addIEPresent) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302416 qdf_mem_copy(&assoc_ind->addIE.addIEdata,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002417 assoc_req->addIE.addIEdata,
2418 assoc_req->addIE.length);
2419 assoc_ind->addIE.length = assoc_req->addIE.length;
2420 }
2421 /*
2422 * Add HT Capabilities into addIE for OBSS
2423 * processing in hostapd
2424 */
2425 if (assoc_req->HTCaps.present) {
Ashish Kumar Dhanotiya443d31f2017-10-13 12:41:19 +05302426 qdf_mem_copy(&assoc_ind->ht_caps, &assoc_req->HTCaps,
2427 sizeof(tDot11fIEHTCaps));
2428
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002429 rsn_len = assoc_ind->addIE.length;
2430 if (assoc_ind->addIE.length + DOT11F_IE_HTCAPS_MIN_LEN
2431 + 2 < SIR_MAC_MAX_IE_LENGTH) {
2432 assoc_ind->addIE.addIEdata[rsn_len] =
2433 SIR_MAC_HT_CAPABILITIES_EID;
2434 assoc_ind->addIE.addIEdata[rsn_len + 1] =
2435 DOT11F_IE_HTCAPS_MIN_LEN;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302436 qdf_mem_copy(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002437 &assoc_ind->addIE.addIEdata[rsn_len+2],
2438 ((uint8_t *)&assoc_req->HTCaps) + 1,
2439 DOT11F_IE_HTCAPS_MIN_LEN);
2440 assoc_ind->addIE.length +=
2441 2 + DOT11F_IE_HTCAPS_MIN_LEN;
2442 } else {
Nishank Aggarwal8935e442017-03-23 19:11:08 +05302443 pe_err("Fail:HT capabilities IE to addIE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002444 }
2445 }
2446
2447 if (assoc_req->wmeInfoPresent) {
2448 if (wlan_cfg_get_int (mac_ctx,
2449 (uint16_t) WNI_CFG_WME_ENABLED, &tmp)
2450 != eSIR_SUCCESS)
Nishank Aggarwal8935e442017-03-23 19:11:08 +05302451 pe_err("wlan_cfg_get_int failed for id: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002452 WNI_CFG_WME_ENABLED);
2453
2454 /* check whether AP is enabled with WMM */
2455 if (tmp)
2456 assoc_ind->WmmStaInfoPresent = 1;
2457 else
2458 assoc_ind->WmmStaInfoPresent = 0;
2459 /*
2460 * Note: we are not rejecting association here
2461 * because IOT will fail
2462 */
2463 }
2464 /* Required for indicating the frames to upper layer */
2465 assoc_ind->assocReqLength = assoc_req->assocReqFrameLength;
2466 assoc_ind->assocReqPtr = assoc_req->assocReqFrame;
2467
2468 assoc_ind->beaconPtr = session_entry->beacon;
2469 assoc_ind->beaconLength = session_entry->bcnLen;
2470
2471 assoc_ind->chan_info.chan_id =
2472 session_entry->currentOperChannel;
2473 assoc_ind->chan_info.mhz =
2474 cds_chan_to_freq(session_entry->currentOperChannel);
2475 assoc_ind->chan_info.band_center_freq1 =
2476 cds_chan_to_freq(session_entry->currentOperChannel);
2477 assoc_ind->chan_info.band_center_freq2 = 0;
2478 assoc_ind->chan_info.reg_info_1 =
2479 (session_entry->maxTxPower << 16);
2480 assoc_ind->chan_info.reg_info_2 =
2481 (session_entry->maxTxPower << 8);
Kanchanapally, Vidyullathae3062812015-05-22 17:28:57 +05302482 assoc_ind->chan_info.nss = sta_ds->nss;
2483 assoc_ind->chan_info.rate_flags =
2484 lim_get_max_rate_flags(mac_ctx, sta_ds);
Will Huang558f8082017-05-31 16:22:24 +08002485 assoc_ind->ampdu = false;
2486 assoc_ind->sgi_enable = false;
2487 assoc_ind->tx_stbc = false;
2488 assoc_ind->rx_stbc = false;
2489 assoc_ind->ch_width = eHT_CHANNEL_WIDTH_20MHZ;
2490 assoc_ind->mode = SIR_SME_PHY_MODE_LEGACY;
2491 assoc_ind->max_supp_idx = 0xff;
2492 assoc_ind->max_ext_idx = 0xff;
2493 assoc_ind->max_mcs_idx = 0xff;
2494 assoc_ind->rx_mcs_map = 0xff;
2495 assoc_ind->tx_mcs_map = 0xff;
2496
2497 if (assoc_req->supportedRates.numRates)
2498 assoc_ind->max_supp_idx =
2499 lim_get_max_rate_idx(
2500 &assoc_req->supportedRates);
2501 if (assoc_req->extendedRates.numRates)
2502 assoc_ind->max_ext_idx =
2503 lim_get_max_rate_idx(
2504 &assoc_req->extendedRates);
2505
2506 if (sta_ds->mlmStaContext.htCapability) {
2507 /* ampdu */
2508 assoc_ind->ampdu = true;
2509
2510 /* sgi */
2511 if (sta_ds->htShortGI20Mhz || sta_ds->htShortGI40Mhz)
2512 assoc_ind->sgi_enable = true;
2513
2514 /* stbc */
2515 assoc_ind->tx_stbc = assoc_req->HTCaps.txSTBC;
2516 assoc_ind->rx_stbc = assoc_req->HTCaps.rxSTBC;
2517
2518 /* ch width */
2519 assoc_ind->ch_width =
2520 sta_ds->htSupportedChannelWidthSet ?
2521 eHT_CHANNEL_WIDTH_40MHZ :
2522 eHT_CHANNEL_WIDTH_20MHZ;
2523
2524 /* mode */
2525 assoc_ind->mode = SIR_SME_PHY_MODE_HT;
2526 maxidx = 0;
2527 for (i = 0; i < 8; i++) {
2528 if (assoc_req->HTCaps.supportedMCSSet[0] &
2529 (1 << i))
2530 maxidx = i;
2531 }
2532 assoc_ind->max_mcs_idx = maxidx;
2533 }
2534 fill_mlm_assoc_ind_vht(assoc_req, sta_ds, assoc_ind);
gaolez7bb1e742017-03-21 16:37:38 +08002535 if (assoc_req->ExtCap.present)
2536 assoc_ind->ecsa_capable =
2537 ((struct s_ext_cap *)assoc_req->ExtCap.bytes)->
2538 ext_chan_switch;
Will Huang558f8082017-05-31 16:22:24 +08002539
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002540 /* updates VHT information in assoc indication */
Ashish Kumar Dhanotiya443d31f2017-10-13 12:41:19 +05302541 qdf_mem_copy(&assoc_ind->vht_caps, &assoc_req->VHTCaps,
2542 sizeof(tDot11fIEVHTCaps));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002543 lim_fill_assoc_ind_vht_info(mac_ctx, session_entry, assoc_req,
Ashish Kumar Dhanotiya443d31f2017-10-13 12:41:19 +05302544 assoc_ind, sta_ds);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002545 lim_post_sme_message(mac_ctx, LIM_MLM_ASSOC_IND,
2546 (uint32_t *) assoc_ind);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302547 qdf_mem_free(assoc_ind);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002548 }
2549 return;
2550}