blob: 7939bd497a304d32ae42e52cfdd05ad81e7a72d5 [file] [log] [blame]
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001/*
Jeff Johnson4377eba2018-12-26 21:31:32 -08002 * Copyright (c) 2012-2019 The Linux Foundation. All rights reserved.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003 *
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004 * Permission to use, copy, modify, and/or distribute this software for
5 * any purpose with or without fee is hereby granted, provided that the
6 * above copyright notice and this permission notice appear in all
7 * copies.
8 *
9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
10 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
11 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
12 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
13 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
14 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
15 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
16 * PERFORMANCE OF THIS SOFTWARE.
17 */
18
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"
Karthik Kantamneni24f71bc2018-09-11 19:08:38 +053027#include "cfg_ucfg_api.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080028
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"
Kiran Kumar Lokere4ce40482018-08-30 16:31:00 -070040#include "utils_parser.h"
Pragaspathi Thilagarajb3472f02019-06-04 14:10:44 +053041#include "wlan_p2p_api.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080042
Anurag Chouhan6d760662016-02-20 16:05:43 +053043#include "qdf_types.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080044#include "cds_utils.h"
Naveen Rawat08db88f2017-09-08 15:07:48 -070045#include "wlan_utility.h"
Kiran Kumar Lokere4ce40482018-08-30 16:31:00 -070046#include "wlan_crypto_global_api.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080047
48/**
49 * lim_convert_supported_channels - Parses channel support IE
Krunal Soni99752a12016-04-12 17:44:45 -070050 * @mac_ctx: A pointer to Global MAC structure
51 * @assoc_ind: A pointer to SME ASSOC/REASSOC IND
52 * @assoc_req: A pointer to ASSOC/REASSOC Request frame
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080053 *
54 * This function is called by lim_process_assoc_req_frame() to
55 * parse the channel support IE in the Assoc/Reassoc Request
56 * frame, and send relevant information in the SME_ASSOC_IND
57 *
Krunal Soni99752a12016-04-12 17:44:45 -070058 * Return: None
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080059 */
Jeff Johnson9320c1e2018-12-02 13:09:20 -080060static void lim_convert_supported_channels(struct mac_context *mac_ctx,
Krunal Soni99752a12016-04-12 17:44:45 -070061 tpLimMlmAssocInd assoc_ind,
62 tSirAssocReq *assoc_req)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080063{
64 uint16_t i, j, index = 0;
Naveen Rawatada5fac2016-01-28 16:24:32 -080065 uint8_t first_ch_no;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080066 uint8_t chn_count;
Naveen Rawatada5fac2016-01-28 16:24:32 -080067 uint8_t next_ch_no;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080068 uint8_t channel_offset = 0;
69
70 if (assoc_req->supportedChannels.length >=
71 SIR_MAX_SUPPORTED_CHANNEL_LIST) {
Nishank Aggarwal8935e442017-03-23 19:11:08 +053072 pe_err("Number of supported channels: %d is more than MAX",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080073 assoc_req->supportedChannels.length);
74 assoc_ind->supportedChannels.numChnl = 0;
75 return;
76 }
77
78 for (i = 0; i < (assoc_req->supportedChannels.length); i++) {
79 /* Get First Channel Number */
Naveen Rawatada5fac2016-01-28 16:24:32 -080080 first_ch_no = assoc_req->supportedChannels.supportedChannels[i];
81 assoc_ind->supportedChannels.channelList[index] = first_ch_no;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080082 i++;
83 index++;
84
85 /* Get Number of Channels in a Subband */
Naveen Rawatada5fac2016-01-28 16:24:32 -080086 chn_count = assoc_req->supportedChannels.supportedChannels[i];
Nishank Aggarwal8935e442017-03-23 19:11:08 +053087 pe_debug("Rcv assoc_req: chnl: %d numOfChnl: %d",
Naveen Rawatada5fac2016-01-28 16:24:32 -080088 first_ch_no, chn_count);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080089 if (index >= SIR_MAX_SUPPORTED_CHANNEL_LIST) {
Nishank Aggarwal8935e442017-03-23 19:11:08 +053090 pe_warn("Ch count > max supported: %d", chn_count);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080091 assoc_ind->supportedChannels.numChnl = 0;
92 return;
93 }
94 if (chn_count <= 1)
95 continue;
Naveen Rawatada5fac2016-01-28 16:24:32 -080096 next_ch_no = first_ch_no;
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -080097 if (BAND_5G == lim_get_rf_band(first_ch_no))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080098 channel_offset = SIR_11A_FREQUENCY_OFFSET;
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -080099 else if (BAND_2G == lim_get_rf_band(first_ch_no))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800100 channel_offset = SIR_11B_FREQUENCY_OFFSET;
101 else
102 continue;
103
104 for (j = 1; j < chn_count; j++) {
Naveen Rawatada5fac2016-01-28 16:24:32 -0800105 next_ch_no += channel_offset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800106 assoc_ind->supportedChannels.channelList[index]
Naveen Rawatada5fac2016-01-28 16:24:32 -0800107 = next_ch_no;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800108 index++;
109 if (index >= SIR_MAX_SUPPORTED_CHANNEL_LIST) {
Nishank Aggarwal8935e442017-03-23 19:11:08 +0530110 pe_warn("Ch count > supported: %d", chn_count);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800111 assoc_ind->supportedChannels.numChnl = 0;
112 return;
113 }
114 }
115 }
116
117 assoc_ind->supportedChannels.numChnl = (uint8_t) index;
Nishank Aggarwal8935e442017-03-23 19:11:08 +0530118 pe_debug("Send AssocInd to WSM: minPwr: %d maxPwr: %d numChnl: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800119 assoc_ind->powerCap.minTxPower,
120 assoc_ind->powerCap.maxTxPower,
Naveen Rawatada5fac2016-01-28 16:24:32 -0800121 assoc_ind->supportedChannels.numChnl);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800122}
123
Naveen Rawatada5fac2016-01-28 16:24:32 -0800124/**
125 * lim_check_sta_in_pe_entries() - checks if sta exists in any dph tables.
Krunal Soni99752a12016-04-12 17:44:45 -0700126 * @mac_ctx: Pointer to Global MAC structure
127 * @hdr: A pointer to the MAC header
Poddar, Siddarth7ca1e082016-08-09 19:06:48 +0530128 * @sessionid - session id for which session is initiated
Jianmin Zhufc2cef12019-01-14 21:23:51 +0800129 * @dup_entry: pointer for duplicate entry found
Naveen Rawatada5fac2016-01-28 16:24:32 -0800130 *
131 * This function is called by lim_process_assoc_req_frame() to check if STA
132 * entry already exists in any of the PE entries of the AP. If it exists, deauth
133 * will be sent on that session and the STA deletion will happen. After this,
Jianmin Zhufc2cef12019-01-14 21:23:51 +0800134 * the ASSOC request will be processed. If the STA is already in deleting phase
135 * this will return failure so that assoc req will be rejected till STA is
136 * deleted.
Naveen Rawatada5fac2016-01-28 16:24:32 -0800137 *
Jianmin Zhufc2cef12019-01-14 21:23:51 +0800138 * Return: QDF_STATUS.
Naveen Rawatada5fac2016-01-28 16:24:32 -0800139 */
Jianmin Zhufc2cef12019-01-14 21:23:51 +0800140static QDF_STATUS lim_check_sta_in_pe_entries(struct mac_context *mac_ctx,
141 tpSirMacMgmtHdr hdr,
142 uint16_t sessionid,
143 bool *dup_entry)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800144{
145 uint8_t i;
Naveen Rawatada5fac2016-01-28 16:24:32 -0800146 uint16_t assoc_id = 0;
147 tpDphHashNode sta_ds = NULL;
Jeff Johnsoneac5aad2019-03-19 12:57:04 -0700148 struct pe_session *session;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800149
Jianmin Zhufc2cef12019-01-14 21:23:51 +0800150 *dup_entry = false;
Naveen Rawatada5fac2016-01-28 16:24:32 -0800151 for (i = 0; i < mac_ctx->lim.maxBssId; i++) {
Jeff Johnsoneac5aad2019-03-19 12:57:04 -0700152 session = &mac_ctx->lim.gpSession[i];
153 if (session->valid &&
Pragaspathi Thilagaraje64714a2019-05-23 00:46:25 +0530154 (session->opmode == QDF_SAP_MODE)) {
Naveen Rawatada5fac2016-01-28 16:24:32 -0800155 sta_ds = dph_lookup_hash_entry(mac_ctx, hdr->sa,
156 &assoc_id, &session->dph.dphHashTable);
157 if (sta_ds
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800158#ifdef WLAN_FEATURE_11W
Poddar, Siddarth7ca1e082016-08-09 19:06:48 +0530159 && (!sta_ds->rmfEnabled ||
160 (sessionid != session->peSessionId))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800161#endif
162 ) {
Jianmin Zhufc2cef12019-01-14 21:23:51 +0800163 if (sta_ds->mlmStaContext.mlmState ==
164 eLIM_MLM_WT_DEL_STA_RSP_STATE ||
165 sta_ds->mlmStaContext.mlmState ==
166 eLIM_MLM_WT_DEL_BSS_RSP_STATE ||
167 sta_ds->sta_deletion_in_progress) {
168 pe_debug(
169 "Deletion is in progress (%d) for peer:%pM in mlmState %d",
170 sta_ds->sta_deletion_in_progress,
171 sta_ds->staAddr,
172 sta_ds->mlmStaContext.mlmState);
173 *dup_entry = true;
174 return QDF_STATUS_E_AGAIN;
175 }
176 sta_ds->sta_deletion_in_progress = true;
Nishank Aggarwal8935e442017-03-23 19:11:08 +0530177 pe_err("Sending Disassoc and Deleting existing STA entry:"
Pragaspathi Thilagaraj7fb14222019-06-17 23:26:58 +0530178 QDF_MAC_ADDR_STR,
179 QDF_MAC_ADDR_ARRAY(
180 session->self_mac_addr));
Sandeep Puligilla2eeaf6a2016-07-22 20:02:02 -0700181 lim_send_disassoc_mgmt_frame(mac_ctx,
Naveen Rawatada5fac2016-01-28 16:24:32 -0800182 eSIR_MAC_UNSPEC_FAILURE_REASON,
183 (uint8_t *) hdr->sa, session, false);
Sandeep Puligilla2eeaf6a2016-07-22 20:02:02 -0700184 /*
185 * Cleanup Rx path posts eWNI_SME_DISASSOC_RSP
186 * msg to SME after delete sta which will update
187 * the userspace with disconnect
188 */
Sandeep Puligilla7e3e3c52016-09-02 17:54:21 -0700189 sta_ds->mlmStaContext.cleanupTrigger =
190 eLIM_DUPLICATE_ENTRY;
191 sta_ds->mlmStaContext.disassocReason =
192 eSIR_MAC_DISASSOC_DUE_TO_INACTIVITY_REASON;
193 lim_send_sme_disassoc_ind(mac_ctx, sta_ds,
194 session);
Jianmin Zhufc2cef12019-01-14 21:23:51 +0800195 *dup_entry = true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800196 break;
197 }
198 }
199 }
Jianmin Zhufc2cef12019-01-14 21:23:51 +0800200
201 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800202}
203
Naveen Rawatada5fac2016-01-28 16:24:32 -0800204/**
Krunal Soni99752a12016-04-12 17:44:45 -0700205 * lim_chk_sa_da() - checks source addr to destination addr of assoc req frame
206 * @mac_ctx: pointer to Global MAC structure
207 * @hdr: pointer to the MAC head
208 * @session: pointer to pe session entry
209 * @sub_type: Assoc(=0) or Reassoc(=1) Requestframe
Naveen Rawatada5fac2016-01-28 16:24:32 -0800210 *
Krunal Soni99752a12016-04-12 17:44:45 -0700211 * Checks source addr to destination addr of assoc req frame
Naveen Rawatada5fac2016-01-28 16:24:32 -0800212 *
Ankit Guptaa5076012016-09-14 11:32:19 -0700213 * Return: true if source and destination address are different
Naveen Rawatada5fac2016-01-28 16:24:32 -0800214 */
Jeff Johnson9320c1e2018-12-02 13:09:20 -0800215static bool lim_chk_sa_da(struct mac_context *mac_ctx, tpSirMacMgmtHdr hdr,
Jeff Johnson5b574dd2018-11-19 06:49:34 -0800216 struct pe_session *session, uint8_t sub_type)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800217{
Ankit Guptaa5076012016-09-14 11:32:19 -0700218 if (qdf_mem_cmp((uint8_t *) hdr->sa,
Krunal Soni99752a12016-04-12 17:44:45 -0700219 (uint8_t *) hdr->da,
Ankit Guptaa5076012016-09-14 11:32:19 -0700220 (uint8_t) (sizeof(tSirMacAddr))))
Krunal Soni99752a12016-04-12 17:44:45 -0700221 return true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800222
Nishank Aggarwal8935e442017-03-23 19:11:08 +0530223 pe_err("Assoc Req rejected: wlan.sa = wlan.da");
Krunal Soni99752a12016-04-12 17:44:45 -0700224 lim_send_assoc_rsp_mgmt_frame(mac_ctx, eSIR_MAC_UNSPEC_FAILURE_STATUS,
225 1, hdr->sa, sub_type, 0, session);
226 return false;
227}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800228
Krunal Soni99752a12016-04-12 17:44:45 -0700229/**
230 * lim_chk_tkip() - checks TKIP counter measure is active
231 * @mac_ctx: pointer to Global MAC structure
232 * @hdr: pointer to the MAC head
233 * @session: pointer to pe session entry
234 * @sub_type: Assoc(=0) or Reassoc(=1) Requestframe
235 *
236 * Checks TKIP counter measure is active
237 *
238 * Return: true of no error, false otherwise
239 */
Jeff Johnson9320c1e2018-12-02 13:09:20 -0800240static bool lim_chk_tkip(struct mac_context *mac_ctx, tpSirMacMgmtHdr hdr,
Jeff Johnson5b574dd2018-11-19 06:49:34 -0800241 struct pe_session *session, uint8_t sub_type)
Krunal Soni99752a12016-04-12 17:44:45 -0700242{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800243 /*
Krunal Soni99752a12016-04-12 17:44:45 -0700244 * If TKIP counter measures active send Assoc Rsp frame to station
245 * with eSIR_MAC_MIC_FAILURE_REASON
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800246 */
Krunal Soni99752a12016-04-12 17:44:45 -0700247 if (!(session->bTkipCntrMeasActive && LIM_IS_AP_ROLE(session)))
248 return true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800249
Nishank Aggarwal8935e442017-03-23 19:11:08 +0530250 pe_err("Assoc Req rejected: TKIP counter measure is active");
Krunal Soni99752a12016-04-12 17:44:45 -0700251 lim_send_assoc_rsp_mgmt_frame(mac_ctx, eSIR_MAC_MIC_FAILURE_REASON, 1,
252 hdr->sa, sub_type, 0, session);
253 return false;
254}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800255
Krunal Soni99752a12016-04-12 17:44:45 -0700256/**
257 * lim_chk_assoc_req_parse_error() - checks for error in frame parsing
258 * @mac_ctx: pointer to Global MAC structure
259 * @hdr: pointer to the MAC head
260 * @session: pointer to pe session entry
261 * @assoc_req: pointer to ASSOC/REASSOC Request frame
262 * @sub_type: Assoc(=0) or Reassoc(=1) Requestframe
263 * @frm_body: frame body
264 * @frame_len: frame len
265 *
266 * Checks for error in frame parsing
267 *
268 * Return: true of no error, false otherwise
269 */
Jeff Johnson9320c1e2018-12-02 13:09:20 -0800270static bool lim_chk_assoc_req_parse_error(struct mac_context *mac_ctx,
Krunal Soni99752a12016-04-12 17:44:45 -0700271 tpSirMacMgmtHdr hdr,
Jeff Johnson5b574dd2018-11-19 06:49:34 -0800272 struct pe_session *session,
Krunal Soni99752a12016-04-12 17:44:45 -0700273 tpSirAssocReq assoc_req,
274 uint8_t sub_type, uint8_t *frm_body,
Krishna Kumaar Natarajandb582ec2016-03-08 17:37:04 -0800275 uint32_t frame_len)
Krunal Soni99752a12016-04-12 17:44:45 -0700276{
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700277 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800278
Naveen Rawatada5fac2016-01-28 16:24:32 -0800279 if (sub_type == LIM_ASSOC)
Krunal Soni99752a12016-04-12 17:44:45 -0700280 status = sir_convert_assoc_req_frame2_struct(mac_ctx, frm_body,
Pragaspathi Thilagaraj0bd369d2019-04-08 00:07:53 +0530281 frame_len,
282 assoc_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800283 else
Krunal Soni99752a12016-04-12 17:44:45 -0700284 status = sir_convert_reassoc_req_frame2_struct(mac_ctx,
285 frm_body, frame_len, assoc_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800286
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700287 if (status == QDF_STATUS_SUCCESS)
Krunal Soni99752a12016-04-12 17:44:45 -0700288 return true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800289
Nishank Aggarwal8935e442017-03-23 19:11:08 +0530290 pe_warn("Assoc Req rejected: frame parsing error. source addr:"
Srinivas Girigowdacb7b8b82019-04-10 14:27:47 -0700291 QDF_MAC_ADDR_STR, QDF_MAC_ADDR_ARRAY(hdr->sa));
Krunal Soni99752a12016-04-12 17:44:45 -0700292 lim_send_assoc_rsp_mgmt_frame(mac_ctx, eSIR_MAC_UNSPEC_FAILURE_STATUS,
293 1, hdr->sa, sub_type, 0, session);
294 return false;
295}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800296
Krunal Soni99752a12016-04-12 17:44:45 -0700297/**
298 * lim_chk_capab() - checks for capab match
299 * @mac_ctx: pointer to Global MAC structure
300 * @hdr: pointer to the MAC head
301 * @session: pointer to pe session entry
302 * @assoc_req: pointer to ASSOC/REASSOC Request frame
303 * @sub_type: Assoc(=0) or Reassoc(=1) Requestframe
304 * @local_cap: local capabilities of SAP
305 *
306 * Checks for capab match
307 *
308 * Return: true of no error, false otherwise
309 */
Jeff Johnson9320c1e2018-12-02 13:09:20 -0800310static bool lim_chk_capab(struct mac_context *mac_ctx, tpSirMacMgmtHdr hdr,
Jeff Johnson5b574dd2018-11-19 06:49:34 -0800311 struct pe_session *session, tpSirAssocReq assoc_req,
Krunal Soni99752a12016-04-12 17:44:45 -0700312 uint8_t sub_type, tSirMacCapabilityInfo *local_cap)
313{
314 uint16_t temp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800315
Wu Gao5c3d94b2019-01-17 21:15:54 +0800316 if (lim_get_capability_info(mac_ctx, &temp, session) !=
317 QDF_STATUS_SUCCESS) {
Nishank Aggarwal8935e442017-03-23 19:11:08 +0530318 pe_err("could not retrieve Capabilities");
Krunal Soni99752a12016-04-12 17:44:45 -0700319 return false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800320 }
Krunal Soni99752a12016-04-12 17:44:45 -0700321
322 lim_copy_u16((uint8_t *) local_cap, temp);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800323
Naveen Rawatada5fac2016-01-28 16:24:32 -0800324 if (lim_compare_capabilities(mac_ctx, assoc_req,
Krunal Soni99752a12016-04-12 17:44:45 -0700325 local_cap, session) == false) {
Nishank Aggarwal8935e442017-03-23 19:11:08 +0530326 pe_warn("Rcvd %s Req with unsupported capab from"
Srinivas Girigowdacb7b8b82019-04-10 14:27:47 -0700327 QDF_MAC_ADDR_STR,
Naveen Rawatada5fac2016-01-28 16:24:32 -0800328 (LIM_ASSOC == sub_type) ? "Assoc" : "ReAssoc",
Srinivas Girigowda34fbba02019-04-08 12:07:44 -0700329 QDF_MAC_ADDR_ARRAY(hdr->sa));
Krunal Soni99752a12016-04-12 17:44:45 -0700330 /*
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800331 * Capabilities of requesting STA does not match with
332 * local capabilities. Respond with 'unsupported capabilities'
333 * status code.
334 */
Naveen Rawatada5fac2016-01-28 16:24:32 -0800335 lim_send_assoc_rsp_mgmt_frame(mac_ctx,
Krunal Soni99752a12016-04-12 17:44:45 -0700336 eSIR_MAC_CAPABILITIES_NOT_SUPPORTED_STATUS,
337 1, hdr->sa, sub_type, 0, session);
338 return false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800339 }
Krunal Soni99752a12016-04-12 17:44:45 -0700340 return true;
341}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800342
Krunal Soni99752a12016-04-12 17:44:45 -0700343/**
344 * lim_chk_ssid() - checks for SSID match
345 * @mac_ctx: pointer to Global MAC structure
346 * @hdr: pointer to the MAC head
347 * @session: pointer to pe session entry
348 * @assoc_req: pointer to ASSOC/REASSOC Request frame
349 * @sub_type: Assoc(=0) or Reassoc(=1) Requestframe
350 *
351 * Checks for SSID match
352 *
353 * Return: true of no error, false otherwise
354 */
Jeff Johnson9320c1e2018-12-02 13:09:20 -0800355static bool lim_chk_ssid(struct mac_context *mac_ctx, tpSirMacMgmtHdr hdr,
Jeff Johnson5b574dd2018-11-19 06:49:34 -0800356 struct pe_session *session, tpSirAssocReq assoc_req,
Krunal Soni99752a12016-04-12 17:44:45 -0700357 uint8_t sub_type)
358{
359 if (lim_cmp_ssid(&assoc_req->ssId, session) != true)
360 return true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800361
Nishank Aggarwal8935e442017-03-23 19:11:08 +0530362 pe_err("%s Req with ssid wrong(Rcvd: %.*s self: %.*s) from "
Srinivas Girigowdacb7b8b82019-04-10 14:27:47 -0700363 QDF_MAC_ADDR_STR,
Krunal Soni99752a12016-04-12 17:44:45 -0700364 (LIM_ASSOC == sub_type) ? "Assoc" : "ReAssoc",
365 assoc_req->ssId.length, assoc_req->ssId.ssId,
366 session->ssId.length, session->ssId.ssId,
Srinivas Girigowda34fbba02019-04-08 12:07:44 -0700367 QDF_MAC_ADDR_ARRAY(hdr->sa));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800368
Krunal Soni99752a12016-04-12 17:44:45 -0700369 /*
370 * Received Re/Association Request with either Broadcast SSID OR with
371 * SSID that does not match with local one. Respond with unspecified
372 * status code.
373 */
374 lim_send_assoc_rsp_mgmt_frame(mac_ctx, eSIR_MAC_UNSPEC_FAILURE_STATUS,
375 1, hdr->sa, sub_type, 0, session);
376 return false;
377}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800378
Krunal Soni99752a12016-04-12 17:44:45 -0700379/**
380 * lim_chk_rates() - checks for supported rates
381 * @mac_ctx: pointer to Global MAC structure
382 * @hdr: pointer to the MAC head
383 * @session: pointer to pe session entry
384 * @assoc_req: pointer to ASSOC/REASSOC Request frame
385 * @sub_type: Assoc(=0) or Reassoc(=1) Requestframe
386 *
387 * Checks for supported rates
388 *
389 * Return: true of no error, false otherwise
390 */
Jeff Johnson9320c1e2018-12-02 13:09:20 -0800391static bool lim_chk_rates(struct mac_context *mac_ctx, tpSirMacMgmtHdr hdr,
Jeff Johnson5b574dd2018-11-19 06:49:34 -0800392 struct pe_session *session, tpSirAssocReq assoc_req,
Krunal Soni99752a12016-04-12 17:44:45 -0700393 uint8_t sub_type)
394{
395 uint8_t i = 0, j = 0;
396 tSirMacRateSet basic_rates;
397 /*
398 * Verify if the requested rates are available in supported rate
399 * set or Extended rate set. Some APs are adding basic rates in
400 * Extended rateset IE
401 */
Naveen Rawatada5fac2016-01-28 16:24:32 -0800402 basic_rates.numRates = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800403
Krunal Soni99752a12016-04-12 17:44:45 -0700404 for (i = 0; i < assoc_req->supportedRates.numRates
Srinivas Girigowda61771262019-04-01 11:55:19 -0700405 && (i < WLAN_SUPPORTED_RATES_IE_MAX_LEN); i++) {
Naveen Rawatada5fac2016-01-28 16:24:32 -0800406 basic_rates.rate[i] = assoc_req->supportedRates.rate[i];
407 basic_rates.numRates++;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800408 }
409
Krunal Soni99752a12016-04-12 17:44:45 -0700410 for (j = 0; (j < assoc_req->extendedRates.numRates)
Srinivas Girigowda61771262019-04-01 11:55:19 -0700411 && (i < WLAN_SUPPORTED_RATES_IE_MAX_LEN); i++, j++) {
Naveen Rawatada5fac2016-01-28 16:24:32 -0800412 basic_rates.rate[i] = assoc_req->extendedRates.rate[j];
413 basic_rates.numRates++;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800414 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800415
Krunal Soni99752a12016-04-12 17:44:45 -0700416 if (lim_check_rx_basic_rates(mac_ctx, basic_rates, session) == true)
417 return true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800418
Nishank Aggarwal8935e442017-03-23 19:11:08 +0530419 pe_warn("Assoc Req rejected: unsupported rates, soruce addr: %s"
Srinivas Girigowdacb7b8b82019-04-10 14:27:47 -0700420 QDF_MAC_ADDR_STR,
Krunal Soni99752a12016-04-12 17:44:45 -0700421 (LIM_ASSOC == sub_type) ? "Assoc" : "ReAssoc",
Srinivas Girigowda34fbba02019-04-08 12:07:44 -0700422 QDF_MAC_ADDR_ARRAY(hdr->sa));
Krunal Soni99752a12016-04-12 17:44:45 -0700423 /*
424 * Requesting STA does not support ALL BSS basic rates. Respond with
425 * 'basic rates not supported' status code.
426 */
427 lim_send_assoc_rsp_mgmt_frame(mac_ctx,
428 eSIR_MAC_BASIC_RATES_NOT_SUPPORTED_STATUS, 1,
429 hdr->sa, sub_type, 0, session);
430 return false;
431}
432
433/**
434 * lim_chk_11g_only() - checks for non 11g STA
435 * @mac_ctx: pointer to Global MAC structure
436 * @hdr: pointer to the MAC head
437 * @session: pointer to pe session entry
438 * @assoc_req: pointer to ASSOC/REASSOC Request frame
439 * @sub_type: Assoc(=0) or Reassoc(=1) Requestframe
440 *
441 * Checks for non 11g STA
442 *
443 * Return: true of no error, false otherwise
444 */
Jeff Johnson9320c1e2018-12-02 13:09:20 -0800445static bool lim_chk_11g_only(struct mac_context *mac_ctx, tpSirMacMgmtHdr hdr,
Jeff Johnson5b574dd2018-11-19 06:49:34 -0800446 struct pe_session *session, tpSirAssocReq assoc_req,
Krunal Soni99752a12016-04-12 17:44:45 -0700447 uint8_t sub_type)
448{
Naveen Rawatada5fac2016-01-28 16:24:32 -0800449 if (LIM_IS_AP_ROLE(session) &&
gaurank kathpalia0c48d3d2019-01-29 15:03:07 +0530450 (session->dot11mode == MLME_DOT11_MODE_11G_ONLY) &&
Naveen Rawatada5fac2016-01-28 16:24:32 -0800451 (assoc_req->HTCaps.present)) {
Nishank Aggarwal8935e442017-03-23 19:11:08 +0530452 pe_err("SOFTAP was in 11G only mode, rejecting legacy STA: "
Srinivas Girigowdacb7b8b82019-04-10 14:27:47 -0700453 QDF_MAC_ADDR_STR,
Srinivas Girigowda34fbba02019-04-08 12:07:44 -0700454 QDF_MAC_ADDR_ARRAY(hdr->sa));
Naveen Rawatada5fac2016-01-28 16:24:32 -0800455 lim_send_assoc_rsp_mgmt_frame(mac_ctx,
Krunal Soni99752a12016-04-12 17:44:45 -0700456 eSIR_MAC_CAPABILITIES_NOT_SUPPORTED_STATUS,
457 1, hdr->sa, sub_type, 0, session);
458 return false;
459 }
460 return true;
461}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800462
Krunal Soni99752a12016-04-12 17:44:45 -0700463/**
464 * lim_chk_11n_only() - checks for non 11n STA
465 * @mac_ctx: pointer to Global MAC structure
466 * @hdr: pointer to the MAC head
467 * @session: pointer to pe session entry
468 * @assoc_req: pointer to ASSOC/REASSOC Request frame
469 * @sub_type: Assoc(=0) or Reassoc(=1) Requestframe
470 *
471 * Checks for non 11n STA
472 *
473 * Return: true of no error, false otherwise
474 */
Jeff Johnson9320c1e2018-12-02 13:09:20 -0800475static bool lim_chk_11n_only(struct mac_context *mac_ctx, tpSirMacMgmtHdr hdr,
Jeff Johnson5b574dd2018-11-19 06:49:34 -0800476 struct pe_session *session, tpSirAssocReq assoc_req,
Krunal Soni99752a12016-04-12 17:44:45 -0700477 uint8_t sub_type)
478{
Naveen Rawatada5fac2016-01-28 16:24:32 -0800479 if (LIM_IS_AP_ROLE(session) &&
gaurank kathpalia0c48d3d2019-01-29 15:03:07 +0530480 (session->dot11mode == MLME_DOT11_MODE_11N_ONLY) &&
Naveen Rawatada5fac2016-01-28 16:24:32 -0800481 (!assoc_req->HTCaps.present)) {
Nishank Aggarwal8935e442017-03-23 19:11:08 +0530482 pe_err("SOFTAP was in 11N only mode, rejecting legacy STA: "
Srinivas Girigowdacb7b8b82019-04-10 14:27:47 -0700483 QDF_MAC_ADDR_STR,
Srinivas Girigowda34fbba02019-04-08 12:07:44 -0700484 QDF_MAC_ADDR_ARRAY(hdr->sa));
Naveen Rawatada5fac2016-01-28 16:24:32 -0800485 lim_send_assoc_rsp_mgmt_frame(mac_ctx,
Krunal Soni99752a12016-04-12 17:44:45 -0700486 eSIR_MAC_CAPABILITIES_NOT_SUPPORTED_STATUS,
487 1, hdr->sa, sub_type, 0, session);
488 return false;
489 }
490 return true;
491}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800492
Krunal Soni99752a12016-04-12 17:44:45 -0700493/**
494 * lim_chk_11ac_only() - checks for non 11ac STA
495 * @mac_ctx: pointer to Global MAC structure
496 * @hdr: pointer to the MAC head
497 * @session: pointer to pe session entry
498 * @assoc_req: pointer to ASSOC/REASSOC Request frame
499 * @sub_type: Assoc(=0) or Reassoc(=1) Requestframe
500 *
501 * Checks for non 11ac STA
502 *
503 * Return: true of no error, false otherwise
504 */
Jeff Johnson9320c1e2018-12-02 13:09:20 -0800505static bool lim_chk_11ac_only(struct mac_context *mac_ctx, tpSirMacMgmtHdr hdr,
Jeff Johnson5b574dd2018-11-19 06:49:34 -0800506 struct pe_session *session, tpSirAssocReq assoc_req,
Krunal Soni99752a12016-04-12 17:44:45 -0700507 uint8_t sub_type)
508{
Kapil Gupta4b2efbb2016-10-03 13:07:20 +0530509 tDot11fIEVHTCaps *vht_caps;
510
511 if (assoc_req->VHTCaps.present)
512 vht_caps = &assoc_req->VHTCaps;
513 else if (assoc_req->vendor_vht_ie.VHTCaps.present &&
514 session->vendor_vht_sap)
515 vht_caps = &assoc_req->vendor_vht_ie.VHTCaps;
516 else
517 vht_caps = NULL;
518
Naveen Rawatada5fac2016-01-28 16:24:32 -0800519 if (LIM_IS_AP_ROLE(session) &&
gaurank kathpalia0c48d3d2019-01-29 15:03:07 +0530520 (session->dot11mode == MLME_DOT11_MODE_11AC_ONLY) &&
Jeff Johnson8e9530b2019-03-18 13:41:42 -0700521 ((!vht_caps) || ((vht_caps) && (!vht_caps->present)))) {
Naveen Rawatada5fac2016-01-28 16:24:32 -0800522 lim_send_assoc_rsp_mgmt_frame(mac_ctx,
Krunal Soni99752a12016-04-12 17:44:45 -0700523 eSIR_MAC_CAPABILITIES_NOT_SUPPORTED_STATUS,
524 1, hdr->sa, sub_type, 0, session);
Nishank Aggarwal8935e442017-03-23 19:11:08 +0530525 pe_err("SOFTAP was in 11AC only mode, reject");
Krunal Soni99752a12016-04-12 17:44:45 -0700526 return false;
527 }
528 return true;
529}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800530
Krunal Soni99752a12016-04-12 17:44:45 -0700531/**
Naveen Rawat441bc872017-12-11 17:25:27 -0800532 * lim_chk_11ax_only() - checks for non 11ax STA
533 * @mac_ctx: pointer to Global MAC structure
534 * @hdr: pointer to the MAC head
535 * @session: pointer to pe session entry
536 * @assoc_req: pointer to ASSOC/REASSOC Request frame
537 * @sub_type: Assoc(=0) or Reassoc(=1) Requestframe
538 *
539 * Checks for non 11ax STA
540 *
541 * Return: true of no error, false otherwise
542 */
543#ifdef WLAN_FEATURE_11AX
Jeff Johnson9320c1e2018-12-02 13:09:20 -0800544static bool lim_chk_11ax_only(struct mac_context *mac_ctx, tpSirMacMgmtHdr hdr,
Jeff Johnson5b574dd2018-11-19 06:49:34 -0800545 struct pe_session *session, tpSirAssocReq assoc_req,
Naveen Rawat441bc872017-12-11 17:25:27 -0800546 uint8_t sub_type)
547{
548 if (LIM_IS_AP_ROLE(session) &&
gaurank kathpalia0c48d3d2019-01-29 15:03:07 +0530549 (session->dot11mode == MLME_DOT11_MODE_11AX_ONLY) &&
Naveen Rawat441bc872017-12-11 17:25:27 -0800550 !assoc_req->he_cap.present) {
551 lim_send_assoc_rsp_mgmt_frame(mac_ctx,
552 eSIR_MAC_CAPABILITIES_NOT_SUPPORTED_STATUS,
553 1, hdr->sa, sub_type, 0, session);
554 pe_err("SOFTAP was in 11AX only mode, reject");
555 return false;
556 }
557 return true;
558}
559
560/**
561 * lim_check_11ax_basic_mcs() - checks for 11ax basic MCS rates
562 * @mac_ctx: pointer to Global MAC structure
563 * @hdr: pointer to the MAC head
564 * @session: pointer to pe session entry
565 * @assoc_req: pointer to ASSOC/REASSOC Request frame
566 * @sub_type: Assoc(=0) or Reassoc(=1) Requestframe
567 *
568 * Checks for non 11ax STA
569 *
570 * Return: true of no error, false otherwise
571 */
Jeff Johnson9320c1e2018-12-02 13:09:20 -0800572static bool lim_check_11ax_basic_mcs(struct mac_context *mac_ctx,
Naveen Rawat441bc872017-12-11 17:25:27 -0800573 tpSirMacMgmtHdr hdr,
Jeff Johnson5b574dd2018-11-19 06:49:34 -0800574 struct pe_session *session,
Naveen Rawat441bc872017-12-11 17:25:27 -0800575 tpSirAssocReq assoc_req,
576 uint8_t sub_type)
577{
Naveen Rawat441bc872017-12-11 17:25:27 -0800578 uint16_t basic_mcs, sta_mcs, rx_mcs, tx_mcs, final_mcs;
579
580 if (LIM_IS_AP_ROLE(session) &&
581 assoc_req->he_cap.present) {
582 rx_mcs = assoc_req->he_cap.rx_he_mcs_map_lt_80;
583 tx_mcs = assoc_req->he_cap.tx_he_mcs_map_lt_80;
584 sta_mcs = HE_INTERSECT_MCS(rx_mcs, tx_mcs);
Bala Venkatesh6d537092018-09-25 10:38:36 +0530585 basic_mcs =
586 (uint16_t)mac_ctx->mlme_cfg->he_caps.he_ops_basic_mcs_nss;
Naveen Rawat441bc872017-12-11 17:25:27 -0800587 final_mcs = HE_INTERSECT_MCS(sta_mcs, basic_mcs);
588 if (final_mcs != basic_mcs) {
589 lim_send_assoc_rsp_mgmt_frame(mac_ctx,
590 eSIR_MAC_CAPABILITIES_NOT_SUPPORTED_STATUS,
591 1, hdr->sa, sub_type, 0, session);
Jeff Johnsona642ead2018-05-11 09:26:13 -0700592 pe_err("STA did not support basic MCS required by SAP");
Naveen Rawat441bc872017-12-11 17:25:27 -0800593 return false;
594 }
595 }
596 return true;
597}
Bala Venkatesh6d537092018-09-25 10:38:36 +0530598
Naveen Rawat441bc872017-12-11 17:25:27 -0800599#else
Jeff Johnson9320c1e2018-12-02 13:09:20 -0800600static bool lim_chk_11ax_only(struct mac_context *mac_ctx, tpSirMacMgmtHdr hdr,
Jeff Johnson5b574dd2018-11-19 06:49:34 -0800601 struct pe_session *session, tpSirAssocReq assoc_req,
Naveen Rawat441bc872017-12-11 17:25:27 -0800602 uint8_t sub_type)
603{
604 return true;
605}
606
Jeff Johnson9320c1e2018-12-02 13:09:20 -0800607static bool lim_check_11ax_basic_mcs(struct mac_context *mac_ctx,
Naveen Rawat441bc872017-12-11 17:25:27 -0800608 tpSirMacMgmtHdr hdr,
Jeff Johnson5b574dd2018-11-19 06:49:34 -0800609 struct pe_session *session,
Naveen Rawat441bc872017-12-11 17:25:27 -0800610 tpSirAssocReq assoc_req,
611 uint8_t sub_type)
612{
613 return true;
614}
615#endif
616
617/**
Krunal Soni99752a12016-04-12 17:44:45 -0700618 * lim_process_for_spectrum_mgmt() - process assoc req for spectrum mgmt
619 * @mac_ctx: pointer to Global MAC structure
620 * @hdr: pointer to the MAC head
621 * @session: pointer to pe session entry
622 * @assoc_req: pointer to ASSOC/REASSOC Request frame
623 * @sub_type: Assoc(=0) or Reassoc(=1) Requestframe
624 * @local_cap: local capabilities of SAP
625 *
626 * Checks for SSID match
627 *
628 * process assoc req for spectrum mgmt
629 */
630static void
Jeff Johnson9320c1e2018-12-02 13:09:20 -0800631lim_process_for_spectrum_mgmt(struct mac_context *mac_ctx, tpSirMacMgmtHdr hdr,
Jeff Johnson5b574dd2018-11-19 06:49:34 -0800632 struct pe_session *session, tpSirAssocReq assoc_req,
Krunal Soni99752a12016-04-12 17:44:45 -0700633 uint8_t sub_type, tSirMacCapabilityInfo local_cap)
634{
Naveen Rawatada5fac2016-01-28 16:24:32 -0800635 if (local_cap.spectrumMgt) {
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700636 QDF_STATUS status = QDF_STATUS_SUCCESS;
Krunal Soni99752a12016-04-12 17:44:45 -0700637 /*
638 * If station is 11h capable, then it SHOULD send all mandatory
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800639 * IEs in assoc request frame. Let us verify that
640 */
Naveen Rawatada5fac2016-01-28 16:24:32 -0800641 if (assoc_req->capabilityInfo.spectrumMgt) {
Krunal Soni99752a12016-04-12 17:44:45 -0700642 if (!((assoc_req->powerCapabilityPresent)
Naveen Rawatada5fac2016-01-28 16:24:32 -0800643 && (assoc_req->supportedChannelsPresent))) {
Krunal Soni99752a12016-04-12 17:44:45 -0700644 /*
645 * One or more required information elements are
646 * missing, log the peers error
647 */
Naveen Rawatada5fac2016-01-28 16:24:32 -0800648 if (!assoc_req->powerCapabilityPresent) {
Nishank Aggarwal8935e442017-03-23 19:11:08 +0530649 pe_warn("LIM Info: Missing Power capability IE in %s Req from "
Srinivas Girigowdacb7b8b82019-04-10 14:27:47 -0700650 QDF_MAC_ADDR_STR,
Krunal Soni99752a12016-04-12 17:44:45 -0700651 (LIM_ASSOC == sub_type) ?
652 "Assoc" : "ReAssoc",
Srinivas Girigowda34fbba02019-04-08 12:07:44 -0700653 QDF_MAC_ADDR_ARRAY(hdr->sa));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800654 }
Naveen Rawatada5fac2016-01-28 16:24:32 -0800655 if (!assoc_req->supportedChannelsPresent) {
Nishank Aggarwal8935e442017-03-23 19:11:08 +0530656 pe_warn("LIM Info: Missing Supported channel IE in %s Req from "
Srinivas Girigowdacb7b8b82019-04-10 14:27:47 -0700657 QDF_MAC_ADDR_STR,
Krunal Soni99752a12016-04-12 17:44:45 -0700658 (LIM_ASSOC == sub_type) ?
659 "Assoc" : "ReAssoc",
Srinivas Girigowda34fbba02019-04-08 12:07:44 -0700660 QDF_MAC_ADDR_ARRAY(hdr->sa));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800661 }
662 } else {
663 /* Assoc request has mandatory fields */
664 status =
Krunal Soni99752a12016-04-12 17:44:45 -0700665 lim_is_dot11h_power_capabilities_in_range(
666 mac_ctx, assoc_req, session);
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700667 if (QDF_STATUS_SUCCESS != status) {
Nishank Aggarwal8935e442017-03-23 19:11:08 +0530668 pe_warn("LIM Info: MinTxPower(STA) > MaxTxPower(AP) in %s Req from "
Srinivas Girigowdacb7b8b82019-04-10 14:27:47 -0700669 QDF_MAC_ADDR_STR,
Krunal Soni99752a12016-04-12 17:44:45 -0700670 (LIM_ASSOC == sub_type) ?
671 "Assoc" : "ReAssoc",
Srinivas Girigowda34fbba02019-04-08 12:07:44 -0700672 QDF_MAC_ADDR_ARRAY(hdr->sa));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800673 }
Krunal Soni99752a12016-04-12 17:44:45 -0700674 status = lim_is_dot11h_supported_channels_valid(
675 mac_ctx, assoc_req);
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700676 if (QDF_STATUS_SUCCESS != status) {
Nishank Aggarwal8935e442017-03-23 19:11:08 +0530677 pe_warn("LIM Info: wrong supported channels (STA) in %s Req from "
Srinivas Girigowdacb7b8b82019-04-10 14:27:47 -0700678 QDF_MAC_ADDR_STR,
Krunal Soni99752a12016-04-12 17:44:45 -0700679 (LIM_ASSOC == sub_type) ?
680 "Assoc" : "ReAssoc",
Srinivas Girigowda34fbba02019-04-08 12:07:44 -0700681 QDF_MAC_ADDR_ARRAY(hdr->sa));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800682 }
683 /* IEs are valid, use them if needed */
684 }
685 } /* if(assoc.capabilityInfo.spectrumMgt) */
686 else {
Krunal Soni99752a12016-04-12 17:44:45 -0700687 /*
688 * As per the capabiities, the spectrum management is
689 * not enabled on the station. The AP may allow the
690 * associations to happen even if spectrum management
691 * is not allowed, if the transmit power of station is
692 * below the regulatory maximum
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800693 */
694
Krunal Soni99752a12016-04-12 17:44:45 -0700695 /*
696 * TODO: presently, this is not handled. In the current
Jeff Johnson47d75242018-05-12 15:58:53 -0700697 * implementation, the AP would allow the station to
Krunal Soni99752a12016-04-12 17:44:45 -0700698 * associate even if it doesn't support spectrum
699 * management.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800700 */
701 }
702 } /* end of spectrum management related processing */
Krunal Soni99752a12016-04-12 17:44:45 -0700703}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800704
Krunal Soni99752a12016-04-12 17:44:45 -0700705/**
706 * lim_chk_mcs() - checks for supported MCS
707 * @mac_ctx: pointer to Global MAC structure
708 * @hdr: pointer to the MAC head
709 * @session: pointer to pe session entry
710 * @assoc_req: pointer to ASSOC/REASSOC Request frame
711 * @sub_type: Assoc(=0) or Reassoc(=1) Requestframe
712 *
713 * Checks for supported MCS
714 *
715 * Return: true of no error, false otherwise
716 */
Jeff Johnson9320c1e2018-12-02 13:09:20 -0800717static bool lim_chk_mcs(struct mac_context *mac_ctx, tpSirMacMgmtHdr hdr,
Jeff Johnson5b574dd2018-11-19 06:49:34 -0800718 struct pe_session *session, tpSirAssocReq assoc_req,
Krunal Soni99752a12016-04-12 17:44:45 -0700719 uint8_t sub_type)
720{
721 if ((assoc_req->HTCaps.present) && (lim_check_mcs_set(mac_ctx,
722 assoc_req->HTCaps.supportedMCSSet) == false)) {
Nishank Aggarwal8935e442017-03-23 19:11:08 +0530723 pe_warn("rcvd %s req with unsupported MCS Rate Set from "
Srinivas Girigowdacb7b8b82019-04-10 14:27:47 -0700724 QDF_MAC_ADDR_STR,
Naveen Rawatada5fac2016-01-28 16:24:32 -0800725 (LIM_ASSOC == sub_type) ? "Assoc" : "ReAssoc",
Srinivas Girigowda34fbba02019-04-08 12:07:44 -0700726 QDF_MAC_ADDR_ARRAY(hdr->sa));
Krunal Soni99752a12016-04-12 17:44:45 -0700727 /*
728 * Requesting STA does not support ALL BSS MCS basic Rate set
729 * rates. Spec does not define any status code for this
730 * scenario.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800731 */
Naveen Rawatada5fac2016-01-28 16:24:32 -0800732 lim_send_assoc_rsp_mgmt_frame(mac_ctx,
Krunal Soni99752a12016-04-12 17:44:45 -0700733 eSIR_MAC_OUTSIDE_SCOPE_OF_SPEC_STATUS,
734 1, hdr->sa, sub_type, 0, session);
735 return false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800736 }
Krunal Soni99752a12016-04-12 17:44:45 -0700737 return true;
738}
739
740/**
741 * lim_chk_is_11b_sta_supported() - checks if STA is 11b
742 * @mac_ctx: pointer to Global MAC structure
743 * @hdr: pointer to the MAC head
744 * @session: pointer to pe session entry
745 * @assoc_req: pointer to ASSOC/REASSOC Request frame
746 * @sub_type: Assoc(=0) or Reassoc(=1) Requestframe
747 * @phy_mode: phy mode
748 *
749 * Checks if STA is 11b
750 *
751 * Return: true of no error, false otherwise
752 */
Jeff Johnson9320c1e2018-12-02 13:09:20 -0800753static bool lim_chk_is_11b_sta_supported(struct mac_context *mac_ctx,
Krunal Soni99752a12016-04-12 17:44:45 -0700754 tpSirMacMgmtHdr hdr,
Jeff Johnson5b574dd2018-11-19 06:49:34 -0800755 struct pe_session *session,
Krunal Soni99752a12016-04-12 17:44:45 -0700756 tpSirAssocReq assoc_req,
757 uint8_t sub_type, uint32_t phy_mode)
758{
759 uint32_t cfg_11g_only;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800760
Naveen Rawatada5fac2016-01-28 16:24:32 -0800761 if (phy_mode == WNI_CFG_PHY_MODE_11G) {
Bala Venkatesh2fde2c62018-09-11 20:33:24 +0530762 cfg_11g_only = mac_ctx->mlme_cfg->sap_cfg.sap_11g_policy;
Krunal Soni99752a12016-04-12 17:44:45 -0700763 if (!assoc_req->extendedRatesPresent && cfg_11g_only) {
764 /*
765 * Received Re/Association Request from 11b STA when 11g
766 * only policy option is set. Reject with unspecified
767 * status code.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800768 */
Naveen Rawatada5fac2016-01-28 16:24:32 -0800769 lim_send_assoc_rsp_mgmt_frame(mac_ctx,
Krunal Soni99752a12016-04-12 17:44:45 -0700770 eSIR_MAC_BASIC_RATES_NOT_SUPPORTED_STATUS,
771 1, hdr->sa, sub_type, 0, session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800772
Nishank Aggarwal8935e442017-03-23 19:11:08 +0530773 pe_warn("Rejecting Re/Assoc req from 11b STA:");
Naveen Rawatada5fac2016-01-28 16:24:32 -0800774 lim_print_mac_addr(mac_ctx, hdr->sa, LOGW);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800775
776#ifdef WLAN_DEBUG
Naveen Rawatada5fac2016-01-28 16:24:32 -0800777 mac_ctx->lim.gLim11bStaAssocRejectCount++;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800778#endif
Krunal Soni99752a12016-04-12 17:44:45 -0700779 return false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800780 }
781 }
Krunal Soni99752a12016-04-12 17:44:45 -0700782 return true;
783}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800784
Krunal Soni99752a12016-04-12 17:44:45 -0700785/**
786 * lim_print_ht_cap() - prints HT caps
787 * @mac_ctx: pointer to Global MAC structure
788 * @session: pointer to pe session entry
789 * @assoc_req: pointer to ASSOC/REASSOC Request frame
790 *
791 * Prints HT caps
792 *
793 * Return: void
794 */
Jeff Johnson9320c1e2018-12-02 13:09:20 -0800795static void lim_print_ht_cap(struct mac_context *mac_ctx, struct pe_session *session,
Krunal Soni99752a12016-04-12 17:44:45 -0700796 tpSirAssocReq assoc_req)
797{
798 if (!session->htCapability)
799 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800800
Krunal Soni99752a12016-04-12 17:44:45 -0700801 if (assoc_req->HTCaps.present) {
802 /* The station *does* support 802.11n HT capability... */
Nishank Aggarwal8935e442017-03-23 19:11:08 +0530803 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 -0700804 assoc_req->HTCaps.advCodingCap,
805 assoc_req->HTCaps.supportedChannelWidthSet,
806 assoc_req->HTCaps.mimoPowerSave,
807 assoc_req->HTCaps.greenField,
808 assoc_req->HTCaps.shortGI20MHz,
809 assoc_req->HTCaps.shortGI40MHz,
810 assoc_req->HTCaps.txSTBC,
811 assoc_req->HTCaps.rxSTBC,
812 assoc_req->HTCaps.delayedBA,
813 assoc_req->HTCaps.maximalAMSDUsize,
814 assoc_req->HTCaps.dsssCckMode40MHz,
815 assoc_req->HTCaps.psmp,
816 assoc_req->HTCaps.stbcControlFrame,
817 assoc_req->HTCaps.lsigTXOPProtection);
818 /*
819 * Make sure the STA's caps are compatible with our own:
820 * 11.15.2 Support of DSSS/CCK in 40 MHz the AP shall refuse
821 * association requests from an HT STA that has the DSSS/CCK
822 * Mode in 40 MHz subfield set to 1;
823 */
824 }
825}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800826
Kiran Kumar Lokere4ce40482018-08-30 16:31:00 -0700827#ifdef WLAN_CONV_CRYPTO_IE_SUPPORT
Pragaspathi Thilagarajcb58bbc2019-05-23 15:34:51 +0530828static
829enum mac_status_code lim_check_rsn_ie(struct pe_session *session,
830 struct mac_context *mac_ctx,
831 tpSirAssocReq assoc_req,
832 tDot11fIERSN *rsn,
833 bool *pmf_connection)
Kiran Kumar Lokere4ce40482018-08-30 16:31:00 -0700834{
835 struct wlan_objmgr_vdev *vdev;
836
Srinivas Girigowdacf161402019-03-14 11:37:33 -0700837 uint8_t buffer[WLAN_MAX_IE_LEN];
838 uint32_t dot11f_status, written = 0, nbuffer = WLAN_MAX_IE_LEN;
Kiran Kumar Lokere4ce40482018-08-30 16:31:00 -0700839 tSirMacRsnInfo rsn_ie;
840
841 dot11f_status = dot11f_pack_ie_rsn(mac_ctx, rsn, buffer,
842 nbuffer, &written);
843 if (DOT11F_FAILED(dot11f_status)) {
844 pe_err("Failed to re-pack the RSN IE (0x%0x8)", dot11f_status);
845 return eSIR_MAC_INVALID_IE_STATUS;
846 }
847
848 rsn_ie.length = (uint8_t) written;
849 qdf_mem_copy(&rsn_ie.info[0], buffer, rsn_ie.length);
850 if (wlan_crypto_check_rsn_match(mac_ctx->psoc, session->smeSessionId,
851 &rsn_ie.info[0], rsn_ie.length)) {
852 vdev = wlan_objmgr_get_vdev_by_id_from_psoc(mac_ctx->psoc,
853 session->smeSessionId,
854 WLAN_LEGACY_MAC_ID);
855 if (!vdev) {
856 pe_err("vdev is NULL");
857 return eSIR_MAC_UNSPEC_FAILURE_STATUS;
858 }
859
860 *pmf_connection = wlan_crypto_vdev_is_pmf_enabled(vdev);
861 wlan_objmgr_vdev_release_ref(vdev, WLAN_LEGACY_MAC_ID);
862 } else {
863 return eSIR_MAC_INVALID_IE_STATUS;
864 }
865
866 return eSIR_MAC_SUCCESS_STATUS;
867}
868
Pragaspathi Thilagarajcb58bbc2019-05-23 15:34:51 +0530869static enum mac_status_code lim_check_wpa_ie(struct pe_session *session,
870 struct mac_context *mac_ctx,
871 tpSirAssocReq assoc_req,
872 tDot11fIEWPA *wpa)
Kiran Kumar Lokere4ce40482018-08-30 16:31:00 -0700873{
Srinivas Girigowdacf161402019-03-14 11:37:33 -0700874 uint8_t buffer[WLAN_MAX_IE_LEN];
875 uint32_t dot11f_status, written = 0, nbuffer = WLAN_MAX_IE_LEN;
Kiran Kumar Lokere4ce40482018-08-30 16:31:00 -0700876 tSirMacRsnInfo wpa_ie = {0};
877
878 dot11f_status = dot11f_pack_ie_wpa(mac_ctx, wpa, buffer,
879 nbuffer, &written);
880 if (DOT11F_FAILED(dot11f_status)) {
881 pe_err("Failed to re-pack the RSN IE (0x%0x8)", dot11f_status);
882 return eSIR_MAC_INVALID_IE_STATUS;
883 }
884
885 wpa_ie.length = (uint8_t) written;
886 qdf_mem_copy(&wpa_ie.info[0], buffer, wpa_ie.length);
887 if (wlan_crypto_check_wpa_match(mac_ctx->psoc, session->smeSessionId,
888 &wpa_ie.info[0], wpa_ie.length))
889 return eSIR_MAC_SUCCESS_STATUS;
890
891 return eSIR_MAC_INVALID_IE_STATUS;
892}
893#else
Pragaspathi Thilagarajcb58bbc2019-05-23 15:34:51 +0530894static enum mac_status_code lim_check_rsn_ie(struct pe_session *session,
895 struct mac_context *mac_ctx,
896 tpSirAssocReq assoc_req,
897 tDot11fIERSN *rsn,
898 bool *pmf_connection)
Kiran Kumar Lokere4ce40482018-08-30 16:31:00 -0700899{
900 return lim_check_rx_rsn_ie_match(mac_ctx, rsn, session,
901 assoc_req->HTCaps.present,
902 pmf_connection);
903}
904
Pragaspathi Thilagarajcb58bbc2019-05-23 15:34:51 +0530905static enum mac_status_code lim_check_wpa_ie(struct pe_session *session,
906 struct mac_context *mac_ctx,
907 tpSirAssocReq assoc_req,
908 tDot11fIEWPA *wpa)
Kiran Kumar Lokere4ce40482018-08-30 16:31:00 -0700909{
910 return lim_check_rx_wpa_ie_match(mac_ctx, wpa, session,
911 assoc_req->HTCaps.present);
912}
913#endif
Min Liub3b222a2019-02-22 13:47:45 +0800914
915/**
916 * lim_check_sae_pmf_cap() - check pmf capability for SAE STA
917 * @session: pointer to pe session entry
918 * @rsn: pointer to RSN
919 *
920 * This function checks if SAE STA is pmf capable when SAE SAP is pmf
921 * capable. Reject with eSIR_MAC_ROBUST_MGMT_FRAMES_POLICY_VIOLATION
922 * if SAE STA is pmf disable.
923 *
Pragaspathi Thilagarajcb58bbc2019-05-23 15:34:51 +0530924 * Return: mac_status_code
Min Liub3b222a2019-02-22 13:47:45 +0800925 */
926#ifdef WLAN_FEATURE_SAE
Pragaspathi Thilagarajcb58bbc2019-05-23 15:34:51 +0530927static enum mac_status_code lim_check_sae_pmf_cap(struct pe_session *session,
928 tDot11fIERSN *rsn)
Min Liub3b222a2019-02-22 13:47:45 +0800929{
Pragaspathi Thilagarajcb58bbc2019-05-23 15:34:51 +0530930 enum mac_status_code status = eSIR_MAC_SUCCESS_STATUS;
Min Liub3b222a2019-02-22 13:47:45 +0800931
932 if (session->pLimStartBssReq->pmfCapable &&
933 (rsn->RSN_Cap[0] & WLAN_CRYPTO_RSN_CAP_MFP_ENABLED) == 0)
934 status = eSIR_MAC_ROBUST_MGMT_FRAMES_POLICY_VIOLATION_STATUS;
935
936 return status;
937}
938#else
Pragaspathi Thilagarajcb58bbc2019-05-23 15:34:51 +0530939static enum mac_status_code lim_check_sae_pmf_cap(struct pe_session *session,
940 tDot11fIERSN *rsn)
Min Liub3b222a2019-02-22 13:47:45 +0800941{
942 return eSIR_MAC_SUCCESS_STATUS;
943}
944#endif
945
Krunal Soni99752a12016-04-12 17:44:45 -0700946/**
Pragaspathi Thilagaraj2d1b3112018-07-06 15:54:42 +0530947 * lim_check_wpa_rsn_ie() - wpa and rsn ie related checks
948 * @session: pointer to pe session entry
949 * @mac_ctx: pointer to Global MAC structure
950 * @sub_type: Assoc(=0) or Reassoc(=1) Requestframe
951 * @hdr: pointer to the MAC head
952 * @assoc_req: pointer to ASSOC/REASSOC Request frame
953 * @pmf_connection: flag indicating pmf connection
Min Liuddd23302018-12-05 16:17:48 +0800954 * @akm_type: AKM type
Pragaspathi Thilagaraj2d1b3112018-07-06 15:54:42 +0530955 *
956 * This function checks if wpa/rsn IE is present and validates
957 * ie version, length and mismatch.
958 *
959 * Return: true if no error, false otherwise
960 */
Min Liuddd23302018-12-05 16:17:48 +0800961static bool lim_check_wpa_rsn_ie(struct pe_session *session,
962 struct mac_context *mac_ctx,
Pragaspathi Thilagaraj2d1b3112018-07-06 15:54:42 +0530963 uint8_t sub_type, tpSirMacMgmtHdr hdr,
Min Liuddd23302018-12-05 16:17:48 +0800964 tpSirAssocReq assoc_req, bool *pmf_connection,
965 enum ani_akm_type *akm_type)
Pragaspathi Thilagaraj2d1b3112018-07-06 15:54:42 +0530966{
967 uint32_t ret;
968 tDot11fIEWPA dot11f_ie_wpa = {0};
969 tDot11fIERSN dot11f_ie_rsn = {0};
Pragaspathi Thilagarajcb58bbc2019-05-23 15:34:51 +0530970 enum mac_status_code status = eSIR_MAC_SUCCESS_STATUS;
Pragaspathi Thilagaraj2d1b3112018-07-06 15:54:42 +0530971
972 /*
973 * Clear the buffers so that frame parser knows that there isn't a
974 * previously decoded IE in these buffers
975 */
hangtian127c9532019-01-12 13:29:07 +0800976 qdf_mem_zero((uint8_t *) &dot11f_ie_rsn, sizeof(dot11f_ie_rsn));
977 qdf_mem_zero((uint8_t *) &dot11f_ie_wpa, sizeof(dot11f_ie_wpa));
Pragaspathi Thilagaraj2d1b3112018-07-06 15:54:42 +0530978 pe_err("RSN enabled auth, Re/Assoc req from STA: "
Srinivas Girigowdacb7b8b82019-04-10 14:27:47 -0700979 QDF_MAC_ADDR_STR, QDF_MAC_ADDR_ARRAY(hdr->sa));
Pragaspathi Thilagaraj2d1b3112018-07-06 15:54:42 +0530980
981 if (assoc_req->rsnPresent) {
982 if (!(assoc_req->rsn.length)) {
983 pe_warn("Re/Assoc rejected from: "
Srinivas Girigowdacb7b8b82019-04-10 14:27:47 -0700984 QDF_MAC_ADDR_STR,
Srinivas Girigowda34fbba02019-04-08 12:07:44 -0700985 QDF_MAC_ADDR_ARRAY(hdr->sa));
Pragaspathi Thilagaraj2d1b3112018-07-06 15:54:42 +0530986 /*
987 * rcvd Assoc req frame with RSN IE but
988 * length is zero
989 */
990 lim_send_assoc_rsp_mgmt_frame(mac_ctx,
991 eSIR_MAC_INVALID_IE_STATUS, 1,
992 hdr->sa, sub_type, 0, session);
993 return false;
994 }
995
996 /* Unpack the RSN IE */
997 ret = dot11f_unpack_ie_rsn(mac_ctx,
998 &assoc_req->rsn.info[0],
999 assoc_req->rsn.length,
1000 &dot11f_ie_rsn, false);
1001 if (!DOT11F_SUCCEEDED(ret)) {
1002 pe_err("Invalid RSN IE");
Liangwei Dong433a8db2018-08-14 01:43:23 -04001003 lim_send_assoc_rsp_mgmt_frame(
1004 mac_ctx, eSIR_MAC_INVALID_IE_STATUS, 1,
1005 hdr->sa, sub_type, 0, session);
Pragaspathi Thilagaraj2d1b3112018-07-06 15:54:42 +05301006 return false;
1007 }
1008
1009 /* Check if the RSN version is supported */
1010 if (SIR_MAC_OUI_VERSION_1 == dot11f_ie_rsn.version) {
1011 /* check the groupwise and pairwise cipher suites */
Kiran Kumar Lokere4ce40482018-08-30 16:31:00 -07001012 status = lim_check_rsn_ie(session, mac_ctx, assoc_req,
1013 &dot11f_ie_rsn,
1014 pmf_connection);
1015 if (eSIR_MAC_SUCCESS_STATUS != status) {
Pragaspathi Thilagaraj2d1b3112018-07-06 15:54:42 +05301016 pe_warn("Re/Assoc rejected from: "
Srinivas Girigowdacb7b8b82019-04-10 14:27:47 -07001017 QDF_MAC_ADDR_STR,
Srinivas Girigowda34fbba02019-04-08 12:07:44 -07001018 QDF_MAC_ADDR_ARRAY(hdr->sa));
Pragaspathi Thilagaraj2d1b3112018-07-06 15:54:42 +05301019
1020 lim_send_assoc_rsp_mgmt_frame(mac_ctx, status,
1021 1, hdr->sa, sub_type,
1022 0, session);
1023 return false;
1024 }
1025 } else {
Srinivas Girigowdacb7b8b82019-04-10 14:27:47 -07001026 pe_warn("Re/Assoc rejected from: " QDF_MAC_ADDR_STR,
Srinivas Girigowda34fbba02019-04-08 12:07:44 -07001027 QDF_MAC_ADDR_ARRAY(hdr->sa));
Pragaspathi Thilagaraj2d1b3112018-07-06 15:54:42 +05301028 /*
1029 * rcvd Assoc req frame with RSN IE but
1030 * IE version is wrong
1031 */
1032 lim_send_assoc_rsp_mgmt_frame(mac_ctx,
1033 eSIR_MAC_UNSUPPORTED_RSN_IE_VERSION_STATUS,
1034 1, hdr->sa, sub_type, 0, session);
1035 return false;
1036 }
Min Liuddd23302018-12-05 16:17:48 +08001037 *akm_type = lim_translate_rsn_oui_to_akm_type(
1038 dot11f_ie_rsn.akm_suite[0]);
Min Liub3b222a2019-02-22 13:47:45 +08001039
1040 if (*akm_type == ANI_AKM_TYPE_SAE)
1041 status = lim_check_sae_pmf_cap(session, &dot11f_ie_rsn);
1042 if (eSIR_MAC_SUCCESS_STATUS != status) {
1043 /* Reject pmf disable SAE STA */
Srinivas Girigowdacb7b8b82019-04-10 14:27:47 -07001044 pe_warn("Re/Assoc rejected from: " QDF_MAC_ADDR_STR,
Srinivas Girigowda34fbba02019-04-08 12:07:44 -07001045 QDF_MAC_ADDR_ARRAY(hdr->sa));
Min Liub3b222a2019-02-22 13:47:45 +08001046 lim_send_assoc_rsp_mgmt_frame(mac_ctx, status,
1047 1, hdr->sa, sub_type,
1048 0, session);
1049 return false;
1050 }
1051
Pragaspathi Thilagaraj2d1b3112018-07-06 15:54:42 +05301052 } else if (assoc_req->wpaPresent) {
1053 if (!(assoc_req->wpa.length)) {
1054 pe_warn("Re/Assoc rejected from: "
Srinivas Girigowdacb7b8b82019-04-10 14:27:47 -07001055 QDF_MAC_ADDR_STR,
Srinivas Girigowda34fbba02019-04-08 12:07:44 -07001056 QDF_MAC_ADDR_ARRAY(hdr->sa));
Pragaspathi Thilagaraj2d1b3112018-07-06 15:54:42 +05301057
1058 /* rcvd Assoc req frame with invalid WPA IE length */
1059 lim_send_assoc_rsp_mgmt_frame(mac_ctx,
1060 eSIR_MAC_INVALID_IE_STATUS, 1,
1061 hdr->sa, sub_type, 0, session);
1062 return false;
1063 }
1064 /* Unpack the WPA IE */
1065 ret = dot11f_unpack_ie_wpa(mac_ctx,
1066 &assoc_req->wpa.info[4],
1067 (assoc_req->wpa.length - 4),
1068 &dot11f_ie_wpa, false);
1069 if (!DOT11F_SUCCEEDED(ret)) {
1070 pe_err("Invalid WPA IE");
Liangwei Dong433a8db2018-08-14 01:43:23 -04001071 lim_send_assoc_rsp_mgmt_frame(
1072 mac_ctx, eSIR_MAC_INVALID_IE_STATUS, 1,
1073 hdr->sa, sub_type, 0, session);
Pragaspathi Thilagaraj2d1b3112018-07-06 15:54:42 +05301074 return false;
1075 }
1076
1077 /* check the groupwise and pairwise cipher suites*/
Kiran Kumar Lokere4ce40482018-08-30 16:31:00 -07001078 status = lim_check_wpa_ie(session, mac_ctx, assoc_req,
1079 &dot11f_ie_wpa);
1080 if (eSIR_MAC_SUCCESS_STATUS != status) {
Pragaspathi Thilagaraj2d1b3112018-07-06 15:54:42 +05301081 pe_warn("Re/Assoc rejected from: "
Srinivas Girigowdacb7b8b82019-04-10 14:27:47 -07001082 QDF_MAC_ADDR_STR,
Srinivas Girigowda34fbba02019-04-08 12:07:44 -07001083 QDF_MAC_ADDR_ARRAY(hdr->sa));
Pragaspathi Thilagaraj2d1b3112018-07-06 15:54:42 +05301084 /*
1085 * rcvd Assoc req frame with WPA IE
1086 * but there is mismatch
1087 */
1088 lim_send_assoc_rsp_mgmt_frame(mac_ctx, status, 1,
1089 hdr->sa, sub_type, 0, session);
1090 return false;
1091 }
Min Liuddd23302018-12-05 16:17:48 +08001092 *akm_type = lim_translate_rsn_oui_to_akm_type(
1093 dot11f_ie_wpa.auth_suites[0]);
Pragaspathi Thilagaraj2d1b3112018-07-06 15:54:42 +05301094 }
Pragaspathi Thilagaraj2d1b3112018-07-06 15:54:42 +05301095
Kiran Kumar Lokere4ce40482018-08-30 16:31:00 -07001096 return true;
Pragaspathi Thilagaraj2d1b3112018-07-06 15:54:42 +05301097}
1098
1099/**
Krunal Soni99752a12016-04-12 17:44:45 -07001100 * lim_chk_n_process_wpa_rsn_ie() - wpa ie related checks
1101 * @mac_ctx: pointer to Global MAC structure
1102 * @hdr: pointer to the MAC head
1103 * @session: pointer to pe session entry
1104 * @assoc_req: pointer to ASSOC/REASSOC Request frame
1105 * @sub_type: Assoc(=0) or Reassoc(=1) Requestframe
1106 * @pmf_connection: flag indicating pmf connection
Min Liuddd23302018-12-05 16:17:48 +08001107 * @akm_type: AKM type
Krunal Soni99752a12016-04-12 17:44:45 -07001108 *
1109 * wpa ie related checks
1110 *
Pragaspathi Thilagaraj2d1b3112018-07-06 15:54:42 +05301111 * Return: true if no error, false otherwise
Krunal Soni99752a12016-04-12 17:44:45 -07001112 */
Jeff Johnson9320c1e2018-12-02 13:09:20 -08001113static bool lim_chk_n_process_wpa_rsn_ie(struct mac_context *mac_ctx,
Krunal Soni99752a12016-04-12 17:44:45 -07001114 tpSirMacMgmtHdr hdr,
Jeff Johnson5b574dd2018-11-19 06:49:34 -08001115 struct pe_session *session,
Krunal Soni99752a12016-04-12 17:44:45 -07001116 tpSirAssocReq assoc_req,
Min Liuddd23302018-12-05 16:17:48 +08001117 uint8_t sub_type,
1118 bool *pmf_connection,
1119 enum ani_akm_type *akm_type)
Krunal Soni99752a12016-04-12 17:44:45 -07001120{
Naveen Rawat08db88f2017-09-08 15:07:48 -07001121 const uint8_t *wps_ie = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001122
1123 /* if additional IE is present, check if it has WscIE */
Naveen Rawatada5fac2016-01-28 16:24:32 -08001124 if (assoc_req->addIEPresent && assoc_req->addIE.length)
Krunal Soni99752a12016-04-12 17:44:45 -07001125 wps_ie = limGetWscIEPtr(mac_ctx, assoc_req->addIE.addIEdata,
1126 assoc_req->addIE.length);
1127 else
Nishank Aggarwal8935e442017-03-23 19:11:08 +05301128 pe_debug("Assoc req addIEPresent: %d addIE length: %d",
Pragaspathi Thilagaraj2d1b3112018-07-06 15:54:42 +05301129 assoc_req->addIEPresent, assoc_req->addIE.length);
Krunal Soni99752a12016-04-12 17:44:45 -07001130
Naveen Rawatada5fac2016-01-28 16:24:32 -08001131 /* when wps_ie is present, RSN/WPA IE is ignored */
Jeff Johnson8e9530b2019-03-18 13:41:42 -07001132 if (!wps_ie) {
Pragaspathi Thilagaraj2d1b3112018-07-06 15:54:42 +05301133 /* check whether RSN IE is present */
Naveen Rawatada5fac2016-01-28 16:24:32 -08001134 if (LIM_IS_AP_ROLE(session) &&
1135 session->pLimStartBssReq->privacy &&
Pragaspathi Thilagaraj2d1b3112018-07-06 15:54:42 +05301136 session->pLimStartBssReq->rsnIE.length)
1137 return lim_check_wpa_rsn_ie(session, mac_ctx, sub_type,
Min Liuddd23302018-12-05 16:17:48 +08001138 hdr, assoc_req, pmf_connection,
1139 akm_type);
Pragaspathi Thilagaraj2d1b3112018-07-06 15:54:42 +05301140 } else {
Nishank Aggarwal8935e442017-03-23 19:11:08 +05301141 pe_debug("Assoc req WSE IE is present");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001142 }
Krunal Soni99752a12016-04-12 17:44:45 -07001143 return true;
1144}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001145
Krunal Soni99752a12016-04-12 17:44:45 -07001146/**
1147 * lim_process_assoc_req_no_sta_ctx() - process assoc req for no sta ctx present
1148 * @mac_ctx: pointer to Global MAC structure
1149 * @hdr: pointer to the MAC head
1150 * @session: pointer to pe session entry
1151 * @assoc_req: pointer to ASSOC/REASSOC Request frame
1152 * @sub_type: Assoc(=0) or Reassoc(=1) Requestframe
1153 * @sta_pre_auth_ctx: sta pre auth context
1154 * @sta_ds: station dph entry
1155 * @auth_type: indicates security type
1156 *
1157 * Process assoc req for no sta ctx present
1158 *
1159 * Return: true of no error, false otherwise
1160 */
Jeff Johnson9320c1e2018-12-02 13:09:20 -08001161static bool lim_process_assoc_req_no_sta_ctx(struct mac_context *mac_ctx,
Jeff Johnson5b574dd2018-11-19 06:49:34 -08001162 tpSirMacMgmtHdr hdr, struct pe_session *session,
Krunal Soni99752a12016-04-12 17:44:45 -07001163 tpSirAssocReq assoc_req, uint8_t sub_type,
1164 struct tLimPreAuthNode *sta_pre_auth_ctx,
1165 tpDphHashNode sta_ds, tAniAuthType *auth_type)
1166{
1167 /* Requesting STA is not currently associated */
1168 if (pe_get_current_stas_count(mac_ctx) ==
Bala Venkatesh2fde2c62018-09-11 20:33:24 +05301169 mac_ctx->mlme_cfg->sap_cfg.assoc_sta_limit) {
Krunal Soni99752a12016-04-12 17:44:45 -07001170 /*
1171 * Maximum number of STAs that AP can handle reached.
1172 * Send Association response to peer MAC entity
1173 */
Nishank Aggarwal8935e442017-03-23 19:11:08 +05301174 pe_err("Max Sta count reached : %d",
Krunal Soni99752a12016-04-12 17:44:45 -07001175 mac_ctx->lim.maxStation);
1176 lim_reject_association(mac_ctx, hdr->sa, sub_type, false,
1177 (tAniAuthType) 0, 0, false,
Varun Reddy Yeturu725185d2017-11-17 14:14:55 -08001178 eSIR_MAC_UNSPEC_FAILURE_STATUS,
Krunal Soni99752a12016-04-12 17:44:45 -07001179 session);
1180 return false;
1181 }
1182 /* Check if STA is pre-authenticated. */
Jeff Johnson8e9530b2019-03-18 13:41:42 -07001183 if ((!sta_pre_auth_ctx) || (sta_pre_auth_ctx &&
Krunal Soni99752a12016-04-12 17:44:45 -07001184 (sta_pre_auth_ctx->mlmState != eLIM_MLM_AUTHENTICATED_STATE))) {
1185 /*
1186 * STA is not pre-authenticated yet requesting Re/Association
1187 * before Authentication. OR STA is in the process of getting
1188 * authenticated and sent Re/Association request. Send
1189 * Deauthentication frame with 'prior authentication required'
1190 * reason code.
1191 */
1192 lim_send_deauth_mgmt_frame(mac_ctx,
1193 eSIR_MAC_STA_NOT_PRE_AUTHENTICATED_REASON,
1194 hdr->sa, session, false);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001195
Nishank Aggarwal8935e442017-03-23 19:11:08 +05301196 pe_warn("rcvd %s req, sessionid: %d, without pre-auth ctx"
Srinivas Girigowdacb7b8b82019-04-10 14:27:47 -07001197 QDF_MAC_ADDR_STR,
Krunal Soni99752a12016-04-12 17:44:45 -07001198 (LIM_ASSOC == sub_type) ? "Assoc" : "ReAssoc",
Srinivas Girigowda34fbba02019-04-08 12:07:44 -07001199 session->peSessionId, QDF_MAC_ADDR_ARRAY(hdr->sa));
Krunal Soni99752a12016-04-12 17:44:45 -07001200 return false;
1201 }
1202 /* Delete 'pre-auth' context of STA */
1203 *auth_type = sta_pre_auth_ctx->authType;
Srinivas Dasari5f528202019-02-11 17:29:43 +05301204 if (sta_pre_auth_ctx->authType == eSIR_AUTH_TYPE_SAE)
1205 assoc_req->is_sae_authenticated = true;
Krunal Soni99752a12016-04-12 17:44:45 -07001206 lim_delete_pre_auth_node(mac_ctx, hdr->sa);
1207 /* All is well. Assign AID (after else part) */
1208 return true;
1209}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001210
Krunal Soni99752a12016-04-12 17:44:45 -07001211/**
1212 * lim_process_assoc_req_sta_ctx() - process assoc req for sta context present
1213 * @mac_ctx: pointer to Global MAC structure
1214 * @hdr: pointer to the MAC head
1215 * @session: pointer to pe session entry
1216 * @assoc_req: pointer to ASSOC/REASSOC Request frame
1217 * @sub_type: Assoc(=0) or Reassoc(=1) Requestframe
1218 * @sta_pre_auth_ctx: sta pre auth context
1219 * @sta_ds: station dph entry
1220 * @peer_idx: peer index
1221 * @auth_type: indicates security type
1222 * @update_ctx: indicates if STA context already exist
1223 *
1224 * Process assoc req for sta context present
1225 *
1226 * Return: true of no error, false otherwise
1227 */
Jeff Johnson9320c1e2018-12-02 13:09:20 -08001228static bool lim_process_assoc_req_sta_ctx(struct mac_context *mac_ctx,
Jeff Johnson5b574dd2018-11-19 06:49:34 -08001229 tpSirMacMgmtHdr hdr, struct pe_session *session,
Krunal Soni99752a12016-04-12 17:44:45 -07001230 tpSirAssocReq assoc_req, uint8_t sub_type,
1231 struct tLimPreAuthNode *sta_pre_auth_ctx,
1232 tpDphHashNode sta_ds, uint16_t peer_idx,
1233 tAniAuthType *auth_type, uint8_t *update_ctx)
1234{
1235 /* STA context does exist for this STA */
1236 if (sta_ds->mlmStaContext.mlmState != eLIM_MLM_LINK_ESTABLISHED_STATE) {
1237 /*
1238 * Requesting STA is in some 'transient' state? Ignore the
1239 * Re/Assoc Req frame by incrementing debug counter & logging
1240 * error.
1241 */
1242 if (sub_type == LIM_ASSOC) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001243#ifdef WLAN_DEBUG
Krunal Soni99752a12016-04-12 17:44:45 -07001244 mac_ctx->lim.gLimNumAssocReqDropInvldState++;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001245#endif
Nishank Aggarwal8935e442017-03-23 19:11:08 +05301246 pe_debug("received Assoc req in state: %X from",
Krunal Soni99752a12016-04-12 17:44:45 -07001247 sta_ds->mlmStaContext.mlmState);
1248 } else {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001249#ifdef WLAN_DEBUG
Krunal Soni99752a12016-04-12 17:44:45 -07001250 mac_ctx->lim.gLimNumReassocReqDropInvldState++;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001251#endif
Nishank Aggarwal8935e442017-03-23 19:11:08 +05301252 pe_debug("received ReAssoc req in state: %X from",
Krunal Soni99752a12016-04-12 17:44:45 -07001253 sta_ds->mlmStaContext.mlmState);
1254 }
Nishank Aggarwaled4c1c52017-03-11 14:17:49 +05301255 lim_print_mac_addr(mac_ctx, hdr->sa, LOGD);
1256 lim_print_mlm_state(mac_ctx, LOGD,
Krunal Soni99752a12016-04-12 17:44:45 -07001257 (tLimMlmStates) sta_ds->mlmStaContext.mlmState);
1258 return false;
1259 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001260
Krunal Soni99752a12016-04-12 17:44:45 -07001261 /* STA sent assoc req frame while already in 'associated' state */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001262
1263#ifdef WLAN_FEATURE_11W
Nishank Aggarwal8935e442017-03-23 19:11:08 +05301264 pe_debug("Re/Assoc request from station that is already associated");
1265 pe_debug("PMF enabled: %d, SA Query state: %d",
Krunal Soni99752a12016-04-12 17:44:45 -07001266 sta_ds->rmfEnabled, sta_ds->pmfSaQueryState);
1267 if (sta_ds->rmfEnabled) {
1268 switch (sta_ds->pmfSaQueryState) {
1269 /*
1270 * start SA Query procedure, respond to Association Request with
1271 * try again later
1272 */
1273 case DPH_SA_QUERY_NOT_IN_PROGRESS:
1274 /*
1275 * We should reset the retry counter before we start
1276 * the SA query procedure, otherwise in next set of SA
1277 * query procedure we will end up using the stale value.
1278 */
1279 sta_ds->pmfSaQueryRetryCount = 0;
1280 lim_send_assoc_rsp_mgmt_frame(mac_ctx,
1281 eSIR_MAC_TRY_AGAIN_LATER, 1, hdr->sa,
1282 sub_type, sta_ds, session);
1283 lim_send_sa_query_request_frame(mac_ctx,
1284 (uint8_t *) &(sta_ds->pmfSaQueryCurrentTransId),
1285 hdr->sa, session);
1286 sta_ds->pmfSaQueryStartTransId =
1287 sta_ds->pmfSaQueryCurrentTransId;
1288 sta_ds->pmfSaQueryCurrentTransId++;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001289
Krunal Soni99752a12016-04-12 17:44:45 -07001290 /* start timer for SA Query retry */
1291 if (tx_timer_activate(&sta_ds->pmfSaQueryTimer)
1292 != TX_SUCCESS) {
Nishank Aggarwal8935e442017-03-23 19:11:08 +05301293 pe_err("PMF SA Query timer start failed!");
Krunal Soni99752a12016-04-12 17:44:45 -07001294 return false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001295 }
Krunal Soni99752a12016-04-12 17:44:45 -07001296 sta_ds->pmfSaQueryState = DPH_SA_QUERY_IN_PROGRESS;
1297 return false;
1298 /*
1299 * SA Query procedure still going, respond to Association
1300 * Request with try again later
1301 */
1302 case DPH_SA_QUERY_IN_PROGRESS:
1303 lim_send_assoc_rsp_mgmt_frame(mac_ctx,
1304 eSIR_MAC_TRY_AGAIN_LATER, 1,
1305 hdr->sa, sub_type, 0, session);
1306 return false;
1307
1308 /*
1309 * SA Query procedure timed out, accept Association
1310 * Request normally
1311 */
1312 case DPH_SA_QUERY_TIMED_OUT:
1313 sta_ds->pmfSaQueryState = DPH_SA_QUERY_NOT_IN_PROGRESS;
1314 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001315 }
Krunal Soni99752a12016-04-12 17:44:45 -07001316 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001317#endif
1318
Krunal Soni99752a12016-04-12 17:44:45 -07001319 /* no change in the capability so drop the frame */
1320 if ((sub_type == LIM_ASSOC) &&
Ankit Guptaa5076012016-09-14 11:32:19 -07001321 (!qdf_mem_cmp(&sta_ds->mlmStaContext.capabilityInfo,
Krunal Soni99752a12016-04-12 17:44:45 -07001322 &assoc_req->capabilityInfo,
1323 sizeof(tSirMacCapabilityInfo)))) {
Nishank Aggarwal8935e442017-03-23 19:11:08 +05301324 pe_err("Received Assoc req in state: %X STAid: %d",
Krunal Soni99752a12016-04-12 17:44:45 -07001325 sta_ds->mlmStaContext.mlmState, peer_idx);
1326 return false;
1327 } else {
1328 /*
1329 * STA sent Re/association Request frame while already in
1330 * 'associated' state. Update STA capabilities and send
1331 * Association response frame with same AID
1332 */
Nishank Aggarwal8935e442017-03-23 19:11:08 +05301333 pe_debug("Rcvd Assoc req from STA already connected");
Krunal Soni99752a12016-04-12 17:44:45 -07001334 sta_ds->mlmStaContext.capabilityInfo =
1335 assoc_req->capabilityInfo;
1336 if (sta_pre_auth_ctx && (sta_pre_auth_ctx->mlmState ==
1337 eLIM_MLM_AUTHENTICATED_STATE)) {
1338 /* STA has triggered pre-auth again */
1339 *auth_type = sta_pre_auth_ctx->authType;
1340 lim_delete_pre_auth_node(mac_ctx, hdr->sa);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001341 } else {
Krunal Soni99752a12016-04-12 17:44:45 -07001342 *auth_type = sta_ds->mlmStaContext.authType;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001343 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001344
Krunal Soni99752a12016-04-12 17:44:45 -07001345 *update_ctx = true;
1346 if (dph_init_sta_state(mac_ctx, hdr->sa, peer_idx, true,
1347 &session->dph.dphHashTable) == NULL) {
Nishank Aggarwal8935e442017-03-23 19:11:08 +05301348 pe_err("could not Init STAid: %d", peer_idx);
Krunal Soni99752a12016-04-12 17:44:45 -07001349 return false;
1350 }
1351 }
1352 return true;
1353}
1354
1355/**
1356 * lim_chk_wmm() - wmm related checks
1357 * @mac_ctx: pointer to Global MAC structure
1358 * @hdr: pointer to the MAC head
1359 * @session: pointer to pe session entry
1360 * @assoc_req: pointer to ASSOC/REASSOC Request frame
1361 * @sub_type: Assoc(=0) or Reassoc(=1) Requestframe
1362 * @qos_mode: qos mode
1363 *
1364 * wmm related checks
1365 *
1366 * Return: true of no error, false otherwise
1367 */
Jeff Johnson9320c1e2018-12-02 13:09:20 -08001368static bool lim_chk_wmm(struct mac_context *mac_ctx, tpSirMacMgmtHdr hdr,
Jeff Johnson5b574dd2018-11-19 06:49:34 -08001369 struct pe_session *session, tpSirAssocReq assoc_req,
Krunal Soni99752a12016-04-12 17:44:45 -07001370 uint8_t sub_type, tHalBitVal qos_mode)
1371{
1372 tHalBitVal wme_mode;
Jeff Johnsonc742d8d2017-10-10 16:36:54 -07001373
Naveen Rawatada5fac2016-01-28 16:24:32 -08001374 limGetWmeMode(session, &wme_mode);
1375 if ((qos_mode == eHAL_SET) || (wme_mode == eHAL_SET)) {
Krunal Soni99752a12016-04-12 17:44:45 -07001376 /*
1377 * for a qsta, check if the requested Traffic spec is admissible
1378 * for a non-qsta check if the sta can be admitted
1379 */
Naveen Rawatada5fac2016-01-28 16:24:32 -08001380 if (assoc_req->addtsPresent) {
Krunal Soni99752a12016-04-12 17:44:45 -07001381 uint8_t tspecIdx = 0;
Jeff Johnsonc742d8d2017-10-10 16:36:54 -07001382
Naveen Rawatada5fac2016-01-28 16:24:32 -08001383 if (lim_admit_control_add_ts(mac_ctx, hdr->sa,
Krunal Soni99752a12016-04-12 17:44:45 -07001384 &(assoc_req->addtsReq),
1385 &(assoc_req->qosCapability),
1386 0, false, NULL, &tspecIdx, session) !=
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001387 QDF_STATUS_SUCCESS) {
Nishank Aggarwal8935e442017-03-23 19:11:08 +05301388 pe_warn("AdmitControl: TSPEC rejected");
Naveen Rawatada5fac2016-01-28 16:24:32 -08001389 lim_send_assoc_rsp_mgmt_frame(mac_ctx,
Krunal Soni99752a12016-04-12 17:44:45 -07001390 eSIR_MAC_QAP_NO_BANDWIDTH_REASON,
1391 1, hdr->sa, sub_type, 0, session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001392#ifdef WLAN_DEBUG
Naveen Rawatada5fac2016-01-28 16:24:32 -08001393 mac_ctx->lim.gLimNumAssocReqDropACRejectTS++;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001394#endif
Krunal Soni99752a12016-04-12 17:44:45 -07001395 return false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001396 }
Naveen Rawatada5fac2016-01-28 16:24:32 -08001397 } else if (lim_admit_control_add_sta(mac_ctx, hdr->sa, false)
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001398 != QDF_STATUS_SUCCESS) {
Nishank Aggarwal8935e442017-03-23 19:11:08 +05301399 pe_warn("AdmitControl: Sta rejected");
Naveen Rawatada5fac2016-01-28 16:24:32 -08001400 lim_send_assoc_rsp_mgmt_frame(mac_ctx,
Krunal Soni99752a12016-04-12 17:44:45 -07001401 eSIR_MAC_QAP_NO_BANDWIDTH_REASON, 1,
1402 hdr->sa, sub_type, 0, session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001403#ifdef WLAN_DEBUG
Naveen Rawatada5fac2016-01-28 16:24:32 -08001404 mac_ctx->lim.gLimNumAssocReqDropACRejectSta++;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001405#endif
Krunal Soni99752a12016-04-12 17:44:45 -07001406 return false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001407 }
1408 /* else all ok */
Nishank Aggarwal8935e442017-03-23 19:11:08 +05301409 pe_debug("AdmitControl: Sta OK!");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001410 }
Krunal Soni99752a12016-04-12 17:44:45 -07001411 return true;
1412}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001413
Krunal Soni99752a12016-04-12 17:44:45 -07001414/**
1415 * lim_update_sta_ds() - updates ds dph entry
1416 * @mac_ctx: pointer to Global MAC structure
1417 * @hdr: pointer to the MAC head
1418 * @session: pointer to pe session entry
Abhishek Singh61084982016-12-13 17:24:07 +05301419 * @assoc_req: pointer to ASSOC/REASSOC Request frame pointer
Krunal Soni99752a12016-04-12 17:44:45 -07001420 * @sub_type: Assoc(=0) or Reassoc(=1) Requestframe
1421 * @sta_ds: station dph entry
Krunal Soni99752a12016-04-12 17:44:45 -07001422 * @auth_type: indicates security type
Min Liuddd23302018-12-05 16:17:48 +08001423 * @akm_type: indicates security type in akm
Krunal Soni99752a12016-04-12 17:44:45 -07001424 * @assoc_req_copied: boolean to indicate if assoc req was copied to tmp above
1425 * @peer_idx: peer index
1426 * @qos_mode: qos mode
1427 * @pmf_connection: flag indicating pmf connection
Pragaspathi Thilagarajb3472f02019-06-04 14:10:44 +05301428 * @force_1x1: Flag to check if the HT capable STA needs to be downgraded to 1x1
1429 * nss.
Krunal Soni99752a12016-04-12 17:44:45 -07001430 *
1431 * Updates ds dph entry
1432 *
1433 * Return: true of no error, false otherwise
1434 */
Jeff Johnson9320c1e2018-12-02 13:09:20 -08001435static bool lim_update_sta_ds(struct mac_context *mac_ctx, tpSirMacMgmtHdr hdr,
Min Liuddd23302018-12-05 16:17:48 +08001436 struct pe_session *session,
1437 tpSirAssocReq assoc_req,
Krunal Soni99752a12016-04-12 17:44:45 -07001438 uint8_t sub_type, tpDphHashNode sta_ds,
Krunal Soni99752a12016-04-12 17:44:45 -07001439 tAniAuthType auth_type,
Min Liuddd23302018-12-05 16:17:48 +08001440 enum ani_akm_type akm_type,
Krunal Soni99752a12016-04-12 17:44:45 -07001441 bool *assoc_req_copied, uint16_t peer_idx,
Pragaspathi Thilagarajb3472f02019-06-04 14:10:44 +05301442 tHalBitVal qos_mode, bool pmf_connection,
1443 bool force_1x1)
Krunal Soni99752a12016-04-12 17:44:45 -07001444{
Krunal Soni99752a12016-04-12 17:44:45 -07001445 tHalBitVal wme_mode, wsm_mode;
1446 uint8_t *ht_cap_ie = NULL;
1447#ifdef WLAN_FEATURE_11W
1448 tPmfSaQueryTimerId timer_id;
Karthik Kantamneni24f71bc2018-09-11 19:08:38 +05301449 uint16_t retry_interval;
Krunal Soni99752a12016-04-12 17:44:45 -07001450#endif
Kapil Gupta4b2efbb2016-10-03 13:07:20 +05301451 tDot11fIEVHTCaps *vht_caps;
Abhishek Singh61084982016-12-13 17:24:07 +05301452 tpSirAssocReq tmp_assoc_req;
Kapil Gupta4b2efbb2016-10-03 13:07:20 +05301453
1454 if (assoc_req->VHTCaps.present)
1455 vht_caps = &assoc_req->VHTCaps;
1456 else if (assoc_req->vendor_vht_ie.VHTCaps.present &&
1457 session->vendor_vht_sap)
1458 vht_caps = &assoc_req->vendor_vht_ie.VHTCaps;
1459 else
1460 vht_caps = NULL;
1461
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001462 /*
Krunal Soni99752a12016-04-12 17:44:45 -07001463 * check here if the parsedAssocReq already pointing to the assoc_req
1464 * and free it before assigning this new assoc_req
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001465 */
Jeff Johnson8e9530b2019-03-18 13:41:42 -07001466 if (session->parsedAssocReq) {
Naveen Rawatada5fac2016-01-28 16:24:32 -08001467 tmp_assoc_req = session->parsedAssocReq[sta_ds->assocId];
Jeff Johnson8e9530b2019-03-18 13:41:42 -07001468 if (tmp_assoc_req) {
Naveen Rawatada5fac2016-01-28 16:24:32 -08001469 if (tmp_assoc_req->assocReqFrame) {
1470 qdf_mem_free(tmp_assoc_req->assocReqFrame);
1471 tmp_assoc_req->assocReqFrame = NULL;
1472 tmp_assoc_req->assocReqFrameLength = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001473 }
Naveen Rawatada5fac2016-01-28 16:24:32 -08001474 qdf_mem_free(tmp_assoc_req);
1475 tmp_assoc_req = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001476 }
1477
Naveen Rawatada5fac2016-01-28 16:24:32 -08001478 session->parsedAssocReq[sta_ds->assocId] = assoc_req;
Krunal Soni99752a12016-04-12 17:44:45 -07001479 *assoc_req_copied = true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001480 }
1481
Naveen Rawatada5fac2016-01-28 16:24:32 -08001482 sta_ds->mlmStaContext.htCapability = assoc_req->HTCaps.present;
Jeff Johnson8e9530b2019-03-18 13:41:42 -07001483 if ((vht_caps) && vht_caps->present)
Kapil Gupta4b2efbb2016-10-03 13:07:20 +05301484 sta_ds->mlmStaContext.vhtCapability = vht_caps->present;
1485 else
1486 sta_ds->mlmStaContext.vhtCapability = false;
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08001487 lim_update_stads_he_capable(sta_ds, assoc_req);
Naveen Rawatada5fac2016-01-28 16:24:32 -08001488 sta_ds->qos.addtsPresent =
1489 (assoc_req->addtsPresent == 0) ? false : true;
1490 sta_ds->qos.addts = assoc_req->addtsReq;
1491 sta_ds->qos.capability = assoc_req->qosCapability;
Krunal Soni99752a12016-04-12 17:44:45 -07001492 /*
1493 * short slot and short preamble should be updated before doing
1494 * limaddsta
1495 */
Naveen Rawatada5fac2016-01-28 16:24:32 -08001496 sta_ds->shortPreambleEnabled =
1497 (uint8_t) assoc_req->capabilityInfo.shortPreamble;
1498 sta_ds->shortSlotTimeEnabled =
1499 (uint8_t) assoc_req->capabilityInfo.shortSlotTime;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001500
Naveen Rawatada5fac2016-01-28 16:24:32 -08001501 sta_ds->valid = 0;
1502 sta_ds->mlmStaContext.authType = auth_type;
Min Liuddd23302018-12-05 16:17:48 +08001503 sta_ds->mlmStaContext.akm_type = akm_type;
Naveen Rawatada5fac2016-01-28 16:24:32 -08001504 sta_ds->staType = STA_ENTRY_PEER;
Pragaspathi Thilagarajb3472f02019-06-04 14:10:44 +05301505 sta_ds->mlmStaContext.force_1x1 = force_1x1;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001506
Min Liuddd23302018-12-05 16:17:48 +08001507 pe_debug("auth_type = %d, akm_type = %d", auth_type, akm_type);
1508
Krunal Soni99752a12016-04-12 17:44:45 -07001509 /*
1510 * TODO: If listen interval is more than certain limit, reject the
1511 * association. Need to check customer requirements and then implement.
1512 */
Naveen Rawatada5fac2016-01-28 16:24:32 -08001513 sta_ds->mlmStaContext.listenInterval = assoc_req->listenInterval;
1514 sta_ds->mlmStaContext.capabilityInfo = assoc_req->capabilityInfo;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001515
Naveen Rawatada5fac2016-01-28 16:24:32 -08001516 if (IS_DOT11_MODE_HT(session->dot11mode) &&
1517 assoc_req->HTCaps.present && assoc_req->wmeInfoPresent) {
1518 sta_ds->htGreenfield = (uint8_t) assoc_req->HTCaps.greenField;
1519 sta_ds->htAMpduDensity = assoc_req->HTCaps.mpduDensity;
1520 sta_ds->htDsssCckRate40MHzSupport =
1521 (uint8_t) assoc_req->HTCaps.dsssCckMode40MHz;
1522 sta_ds->htLsigTXOPProtection =
1523 (uint8_t) assoc_req->HTCaps.lsigTXOPProtection;
1524 sta_ds->htMaxAmsduLength =
1525 (uint8_t) assoc_req->HTCaps.maximalAMSDUsize;
1526 sta_ds->htMaxRxAMpduFactor = assoc_req->HTCaps.maxRxAMPDUFactor;
1527 sta_ds->htMIMOPSState = assoc_req->HTCaps.mimoPowerSave;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001528
Krunal Soni99752a12016-04-12 17:44:45 -07001529 /* assoc_req will be copied to session->parsedAssocReq later */
Naveen Rawatada5fac2016-01-28 16:24:32 -08001530 ht_cap_ie = ((uint8_t *) &assoc_req->HTCaps) + 1;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001531
Jeff Johnsonbe119e62019-02-02 12:30:26 -08001532 if (session->ht_config.ht_sgi20) {
Naveen Rawatada5fac2016-01-28 16:24:32 -08001533 sta_ds->htShortGI20Mhz =
Krunal Soni99752a12016-04-12 17:44:45 -07001534 (uint8_t)assoc_req->HTCaps.shortGI20MHz;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001535 } else {
1536 /* Unset htShortGI20Mhz in ht_caps*/
1537 *ht_cap_ie &= ~(1 << SIR_MAC_HT_CAP_SHORTGI20MHZ_S);
Naveen Rawatada5fac2016-01-28 16:24:32 -08001538 sta_ds->htShortGI20Mhz = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001539 }
1540
Jeff Johnsonbe119e62019-02-02 12:30:26 -08001541 if (session->ht_config.ht_sgi40) {
Naveen Rawatada5fac2016-01-28 16:24:32 -08001542 sta_ds->htShortGI40Mhz =
1543 (uint8_t)assoc_req->HTCaps.shortGI40MHz;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001544 } else {
1545 /* Unset htShortGI40Mhz in ht_caps */
1546 *ht_cap_ie &= ~(1 << SIR_MAC_HT_CAP_SHORTGI40MHZ_S);
Naveen Rawatada5fac2016-01-28 16:24:32 -08001547 sta_ds->htShortGI40Mhz = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001548 }
1549
Naveen Rawatada5fac2016-01-28 16:24:32 -08001550 sta_ds->htSupportedChannelWidthSet =
1551 (uint8_t) assoc_req->HTCaps.supportedChannelWidthSet;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001552 /*
1553 * peer just follows AP; so when we are softAP/GO,
1554 * we just store our session entry's secondary channel offset
1555 * here in peer INFRA STA. However, if peer's 40MHz channel
1556 * width support is disabled then secondary channel will be zero
1557 */
Naveen Rawatada5fac2016-01-28 16:24:32 -08001558 sta_ds->htSecondaryChannelOffset =
Krunal Soni99752a12016-04-12 17:44:45 -07001559 (sta_ds->htSupportedChannelWidthSet) ?
1560 session->htSecondaryChannelOffset : 0;
Naveen Rawatada5fac2016-01-28 16:24:32 -08001561 if (assoc_req->operMode.present) {
Abhishek Singh1d8bd622018-11-13 11:43:55 +05301562 enum phy_ch_width ch_width;
1563
1564 ch_width = assoc_req->operMode.chanWidth;
1565 if (session->ch_width < ch_width)
1566 ch_width = session->ch_width;
1567
Naveen Rawatada5fac2016-01-28 16:24:32 -08001568 sta_ds->vhtSupportedChannelWidthSet =
Abhishek Singh1d8bd622018-11-13 11:43:55 +05301569 (uint8_t) ((ch_width == CH_WIDTH_80MHZ) ?
Krunal Soni99752a12016-04-12 17:44:45 -07001570 WNI_CFG_VHT_CHANNEL_WIDTH_80MHZ :
1571 WNI_CFG_VHT_CHANNEL_WIDTH_20_40MHZ);
Naveen Rawatada5fac2016-01-28 16:24:32 -08001572 sta_ds->htSupportedChannelWidthSet =
Abhishek Singh1d8bd622018-11-13 11:43:55 +05301573 (uint8_t) (ch_width ?
Krunal Soni99752a12016-04-12 17:44:45 -07001574 eHT_CHANNEL_WIDTH_40MHZ :
1575 eHT_CHANNEL_WIDTH_20MHZ);
Jeff Johnson8e9530b2019-03-18 13:41:42 -07001576 } else if ((vht_caps) && vht_caps->present) {
Krunal Soni99752a12016-04-12 17:44:45 -07001577 /*
1578 * Check if STA has enabled it's channel bonding mode.
1579 * If channel bonding mode is enabled, we decide based
1580 * on SAP's current configuration. else, we set it to
Jeff Johnsonc742d8d2017-10-10 16:36:54 -07001581 * VHT20.
1582 */
Naveen Rawatada5fac2016-01-28 16:24:32 -08001583 sta_ds->vhtSupportedChannelWidthSet =
Krunal Soni99752a12016-04-12 17:44:45 -07001584 (uint8_t) ((sta_ds->htSupportedChannelWidthSet
1585 == eHT_CHANNEL_WIDTH_20MHZ) ?
1586 WNI_CFG_VHT_CHANNEL_WIDTH_20_40MHZ :
1587 session->ch_width - 1);
Naveen Rawatada5fac2016-01-28 16:24:32 -08001588 sta_ds->htMaxRxAMpduFactor =
Kapil Gupta4b2efbb2016-10-03 13:07:20 +05301589 vht_caps->maxAMPDULenExp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001590 }
1591 /* Lesser among the AP and STA bandwidth of operation. */
Naveen Rawatada5fac2016-01-28 16:24:32 -08001592 sta_ds->htSupportedChannelWidthSet =
1593 (sta_ds->htSupportedChannelWidthSet <
Krunal Soni99752a12016-04-12 17:44:45 -07001594 session->htSupportedChannelWidthSet) ?
1595 sta_ds->htSupportedChannelWidthSet :
1596 session->htSupportedChannelWidthSet;
Abhishek Singh1d8bd622018-11-13 11:43:55 +05301597
1598 if (!sta_ds->htSupportedChannelWidthSet)
1599 sta_ds->vhtSupportedChannelWidthSet =
1600 WNI_CFG_VHT_CHANNEL_WIDTH_20_40MHZ;
1601
Naveen Rawatada5fac2016-01-28 16:24:32 -08001602 sta_ds->htLdpcCapable =
1603 (uint8_t) assoc_req->HTCaps.advCodingCap;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001604 }
1605
Jeff Johnson8e9530b2019-03-18 13:41:42 -07001606 if ((vht_caps) && vht_caps->present &&
Kapil Gupta4b2efbb2016-10-03 13:07:20 +05301607 assoc_req->wmeInfoPresent) {
Naveen Rawatada5fac2016-01-28 16:24:32 -08001608 sta_ds->vhtLdpcCapable =
Kapil Gupta4b2efbb2016-10-03 13:07:20 +05301609 (uint8_t) vht_caps->ldpcCodingCap;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001610 }
1611
gaolez7bb1e742017-03-21 16:37:38 +08001612 if (assoc_req->ExtCap.present)
1613 sta_ds->non_ecsa_capable =
1614 !((struct s_ext_cap *)assoc_req->ExtCap.bytes)->
1615 ext_chan_switch;
1616 else
1617 sta_ds->non_ecsa_capable = 1;
1618
Naveen Rawatada5fac2016-01-28 16:24:32 -08001619 if (!assoc_req->wmeInfoPresent) {
1620 sta_ds->mlmStaContext.htCapability = 0;
1621 sta_ds->mlmStaContext.vhtCapability = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001622 }
Naveen Rawat2eb4c832018-02-15 10:47:38 -08001623
1624 if (sta_ds->mlmStaContext.vhtCapability && vht_caps) {
Krunal Soni53993f72016-07-08 18:20:03 -07001625 if (session->vht_config.su_beam_formee &&
Naveen Rawat2eb4c832018-02-15 10:47:38 -08001626 vht_caps->suBeamFormerCap)
Naveen Rawatada5fac2016-01-28 16:24:32 -08001627 sta_ds->vhtBeamFormerCapable = 1;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001628 else
Naveen Rawatada5fac2016-01-28 16:24:32 -08001629 sta_ds->vhtBeamFormerCapable = 0;
Krunal Soni53993f72016-07-08 18:20:03 -07001630 if (session->vht_config.su_beam_former &&
Naveen Rawat2eb4c832018-02-15 10:47:38 -08001631 vht_caps->suBeamformeeCap)
Naveen Rawatada5fac2016-01-28 16:24:32 -08001632 sta_ds->vht_su_bfee_capable = 1;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001633 else
Naveen Rawatada5fac2016-01-28 16:24:32 -08001634 sta_ds->vht_su_bfee_capable = 0;
Naveen Rawat2eb4c832018-02-15 10:47:38 -08001635
1636 pe_debug("peer_caps: suBformer: %d, suBformee: %d",
1637 vht_caps->suBeamFormerCap,
1638 vht_caps->suBeamformeeCap);
1639 pe_debug("self_cap: suBformer: %d, suBformee: %d",
1640 session->vht_config.su_beam_former,
1641 session->vht_config.su_beam_formee);
1642 pe_debug("connection's final cap: suBformer: %d, suBformee: %d",
1643 sta_ds->vhtBeamFormerCapable,
1644 sta_ds->vht_su_bfee_capable);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001645 }
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08001646
1647 lim_intersect_sta_he_caps(assoc_req, session, sta_ds);
1648
Krunal Soni99752a12016-04-12 17:44:45 -07001649 if (lim_populate_matching_rate_set(mac_ctx, sta_ds,
1650 &(assoc_req->supportedRates),
1651 &(assoc_req->extendedRates),
1652 assoc_req->HTCaps.supportedMCSSet,
Krishna Kumaar Natarajand1cd56e2016-09-30 08:43:03 -07001653 session, vht_caps,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001654 &assoc_req->he_cap) != QDF_STATUS_SUCCESS) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001655 /* Could not update hash table entry at DPH with rateset */
Nishank Aggarwal8935e442017-03-23 19:11:08 +05301656 pe_err("Couldn't update hash entry for aid: %d MacAddr: "
Srinivas Girigowdacb7b8b82019-04-10 14:27:47 -07001657 QDF_MAC_ADDR_STR,
Srinivas Girigowda34fbba02019-04-08 12:07:44 -07001658 peer_idx, QDF_MAC_ADDR_ARRAY(hdr->sa));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001659
1660 /* Release AID */
Naveen Rawatada5fac2016-01-28 16:24:32 -08001661 lim_release_peer_idx(mac_ctx, peer_idx, session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001662
Naveen Rawatada5fac2016-01-28 16:24:32 -08001663 lim_reject_association(mac_ctx, hdr->sa,
Abhishek Singh0bc46d12017-01-09 13:05:54 +05301664 sub_type, true, auth_type, peer_idx, false,
Varun Reddy Yeturu725185d2017-11-17 14:14:55 -08001665 eSIR_MAC_UNSPEC_FAILURE_STATUS,
Krunal Soni99752a12016-04-12 17:44:45 -07001666 session);
Nishank Aggarwal8935e442017-03-23 19:11:08 +05301667 pe_err("Delete dph hash entry");
Abhishek Singh0bc46d12017-01-09 13:05:54 +05301668 if (dph_delete_hash_entry(mac_ctx, hdr->sa, sta_ds->assocId,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001669 &session->dph.dphHashTable) != QDF_STATUS_SUCCESS)
Nishank Aggarwal8935e442017-03-23 19:11:08 +05301670 pe_err("error deleting hash entry");
Krunal Soni99752a12016-04-12 17:44:45 -07001671 return false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001672 }
Naveen Rawatada5fac2016-01-28 16:24:32 -08001673 if (assoc_req->operMode.present) {
1674 sta_ds->vhtSupportedRxNss = assoc_req->operMode.rxNSS + 1;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001675 } else {
Naveen Rawatada5fac2016-01-28 16:24:32 -08001676 sta_ds->vhtSupportedRxNss =
1677 ((sta_ds->supportedRates.vhtRxMCSMap & MCSMAPMASK2x2)
Krunal Soni99752a12016-04-12 17:44:45 -07001678 == MCSMAPMASK2x2) ? 1 : 2;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001679 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001680
Krunal Soni99752a12016-04-12 17:44:45 -07001681 /* Add STA context at MAC HW (BMU, RHP & TFP) */
Naveen Rawatada5fac2016-01-28 16:24:32 -08001682 sta_ds->qosMode = false;
1683 sta_ds->lleEnabled = false;
1684 if (assoc_req->capabilityInfo.qos && (qos_mode == eHAL_SET)) {
1685 sta_ds->lleEnabled = true;
1686 sta_ds->qosMode = true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001687 }
1688
Naveen Rawatada5fac2016-01-28 16:24:32 -08001689 sta_ds->wmeEnabled = false;
1690 sta_ds->wsmEnabled = false;
1691 limGetWmeMode(session, &wme_mode);
1692 if ((!sta_ds->lleEnabled) && assoc_req->wmeInfoPresent
1693 && (wme_mode == eHAL_SET)) {
1694 sta_ds->wmeEnabled = true;
1695 sta_ds->qosMode = true;
1696 limGetWsmMode(session, &wsm_mode);
Krunal Soni99752a12016-04-12 17:44:45 -07001697 /*
1698 * WMM_APSD - WMM_SA related processing should be separate;
1699 * WMM_SA and WMM_APSD can coexist
1700 */
Naveen Rawatada5fac2016-01-28 16:24:32 -08001701 if (assoc_req->WMMInfoStation.present) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001702 /* check whether AP supports or not */
Naveen Rawatada5fac2016-01-28 16:24:32 -08001703 if (LIM_IS_AP_ROLE(session) &&
Krunal Soni99752a12016-04-12 17:44:45 -07001704 (session->apUapsdEnable == 0) &&
1705 (assoc_req->WMMInfoStation.acbe_uapsd ||
1706 assoc_req->WMMInfoStation.acbk_uapsd ||
1707 assoc_req->WMMInfoStation.acvo_uapsd ||
1708 assoc_req->WMMInfoStation.acvi_uapsd)) {
1709 /*
1710 * Rcvd Re/Assoc Req from STA when UPASD is
1711 * not supported.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001712 */
Nishank Aggarwal8935e442017-03-23 19:11:08 +05301713 pe_err("UAPSD not supported, reply accordingly");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001714 /* update UAPSD and send it to LIM to add STA */
Naveen Rawatada5fac2016-01-28 16:24:32 -08001715 sta_ds->qos.capability.qosInfo.acbe_uapsd = 0;
1716 sta_ds->qos.capability.qosInfo.acbk_uapsd = 0;
1717 sta_ds->qos.capability.qosInfo.acvo_uapsd = 0;
1718 sta_ds->qos.capability.qosInfo.acvi_uapsd = 0;
1719 sta_ds->qos.capability.qosInfo.maxSpLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001720 } else {
1721 /* update UAPSD and send it to LIM to add STA */
Naveen Rawatada5fac2016-01-28 16:24:32 -08001722 sta_ds->qos.capability.qosInfo.acbe_uapsd =
1723 assoc_req->WMMInfoStation.acbe_uapsd;
1724 sta_ds->qos.capability.qosInfo.acbk_uapsd =
1725 assoc_req->WMMInfoStation.acbk_uapsd;
1726 sta_ds->qos.capability.qosInfo.acvo_uapsd =
1727 assoc_req->WMMInfoStation.acvo_uapsd;
1728 sta_ds->qos.capability.qosInfo.acvi_uapsd =
1729 assoc_req->WMMInfoStation.acvi_uapsd;
1730 sta_ds->qos.capability.qosInfo.maxSpLen =
1731 assoc_req->WMMInfoStation.max_sp_length;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001732 }
1733 }
Naveen Rawatada5fac2016-01-28 16:24:32 -08001734 if (assoc_req->wsmCapablePresent && (wsm_mode == eHAL_SET))
1735 sta_ds->wsmEnabled = true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001736 }
1737 /* Re/Assoc Response frame to requesting STA */
Naveen Rawatada5fac2016-01-28 16:24:32 -08001738 sta_ds->mlmStaContext.subType = sub_type;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001739
1740#ifdef WLAN_FEATURE_11W
Naveen Rawatada5fac2016-01-28 16:24:32 -08001741 sta_ds->rmfEnabled = (pmf_connection) ? 1 : 0;
1742 sta_ds->pmfSaQueryState = DPH_SA_QUERY_NOT_IN_PROGRESS;
1743 timer_id.fields.sessionId = session->peSessionId;
1744 timer_id.fields.peerIdx = peer_idx;
Karthik Kantamneni24f71bc2018-09-11 19:08:38 +05301745 retry_interval = mac_ctx->mlme_cfg->gen.pmf_sa_query_retry_interval;
1746 if (cfg_min(CFG_PMF_SA_QUERY_RETRY_INTERVAL) > retry_interval) {
1747 retry_interval = cfg_default(CFG_PMF_SA_QUERY_RETRY_INTERVAL);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001748 }
Krunal Sonia59e8a42017-11-19 09:00:56 -08001749 if (sta_ds->rmfEnabled &&
1750 tx_timer_create(mac_ctx, &sta_ds->pmfSaQueryTimer,
Krunal Soni99752a12016-04-12 17:44:45 -07001751 "PMF SA Query timer", lim_pmf_sa_query_timer_handler,
1752 timer_id.value,
1753 SYS_MS_TO_TICKS((retry_interval * 1024) / 1000),
1754 0, TX_NO_ACTIVATE) != TX_SUCCESS) {
Nishank Aggarwal8935e442017-03-23 19:11:08 +05301755 pe_err("could not create PMF SA Query timer");
Krunal Soni99752a12016-04-12 17:44:45 -07001756 lim_reject_association(mac_ctx, hdr->sa, sub_type,
1757 true, auth_type, peer_idx, false,
Varun Reddy Yeturu725185d2017-11-17 14:14:55 -08001758 eSIR_MAC_UNSPEC_FAILURE_STATUS,
Krunal Soni99752a12016-04-12 17:44:45 -07001759 session);
1760 return false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001761 }
Krunal Sonia59e8a42017-11-19 09:00:56 -08001762 if (sta_ds->rmfEnabled)
1763 pe_debug("Created pmf timer sta-idx:%d assoc-id:%d",
1764 sta_ds->staIndex, sta_ds->assocId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001765#endif
1766
Naveen Rawatada5fac2016-01-28 16:24:32 -08001767 if (assoc_req->ExtCap.present) {
1768 lim_set_stads_rtt_cap(sta_ds,
1769 (struct s_ext_cap *) assoc_req->ExtCap.bytes, mac_ctx);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001770 } else {
Naveen Rawatada5fac2016-01-28 16:24:32 -08001771 sta_ds->timingMeasCap = 0;
Nishank Aggarwal8935e442017-03-23 19:11:08 +05301772 pe_debug("ExtCap not present");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001773 }
Krunal Soni99752a12016-04-12 17:44:45 -07001774 return true;
1775}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001776
Krunal Soni99752a12016-04-12 17:44:45 -07001777/**
1778 * lim_update_sta_ctx() - add/del sta depending on connection state machine
1779 * @mac_ctx: pointer to Global MAC structure
1780 * @session: pointer to pe session entry
1781 * @assoc_req: pointer to ASSOC/REASSOC Request frame
1782 * @sub_type: Assoc(=0) or Reassoc(=1) Requestframe
1783 * @sta_ds: station dph entry
1784 * @update_ctx: indicates if STA context already exist
1785 *
1786 * Checks for SSID match
1787 *
1788 * Return: true of no error, false otherwise
1789 */
Jeff Johnson9320c1e2018-12-02 13:09:20 -08001790static bool lim_update_sta_ctx(struct mac_context *mac_ctx, struct pe_session *session,
Krunal Soni99752a12016-04-12 17:44:45 -07001791 tpSirAssocReq assoc_req, uint8_t sub_type,
1792 tpDphHashNode sta_ds, uint8_t update_ctx)
1793{
1794 tLimMlmStates mlm_prev_state;
1795 /*
1796 * BTAMP: If STA context already exist (ie. update_ctx = 1) for this STA
1797 * then we should delete the old one, and add the new STA. This is taken
1798 * care of in the lim_del_sta() routine.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001799 *
Krunal Soni99752a12016-04-12 17:44:45 -07001800 * Prior to BTAMP, we were setting this flag so that when PE receives
1801 * SME_ASSOC_CNF, and if this flag is set, then PE shall delete the old
1802 * station and then add. But now in BTAMP, we're directly adding station
1803 * before waiting for SME_ASSOC_CNF, so we can do this now.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001804 */
Krunal Soni99752a12016-04-12 17:44:45 -07001805 if (!(update_ctx)) {
Naveen Rawatada5fac2016-01-28 16:24:32 -08001806 sta_ds->mlmStaContext.updateContext = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001807
Krunal Soni99752a12016-04-12 17:44:45 -07001808 /*
1809 * BTAMP: Add STA context at HW - issue WMA_ADD_STA_REQ to HAL
1810 */
Naveen Rawatada5fac2016-01-28 16:24:32 -08001811 if (lim_add_sta(mac_ctx, sta_ds, false, session) !=
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001812 QDF_STATUS_SUCCESS) {
Nishank Aggarwal8935e442017-03-23 19:11:08 +05301813 pe_err("could not Add STA with assocId: %d",
Naveen Rawatada5fac2016-01-28 16:24:32 -08001814 sta_ds->assocId);
1815 lim_reject_association(mac_ctx, sta_ds->staAddr,
Krunal Soni99752a12016-04-12 17:44:45 -07001816 sta_ds->mlmStaContext.subType, true,
1817 sta_ds->mlmStaContext.authType,
1818 sta_ds->assocId, true,
Varun Reddy Yeturu725185d2017-11-17 14:14:55 -08001819 eSIR_MAC_UNSPEC_FAILURE_STATUS,
Krunal Soni99752a12016-04-12 17:44:45 -07001820 session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001821
Naveen Rawatada5fac2016-01-28 16:24:32 -08001822 if (session->parsedAssocReq)
Krunal Soni99752a12016-04-12 17:44:45 -07001823 assoc_req =
1824 session->parsedAssocReq[sta_ds->assocId];
1825 return false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001826 }
1827 } else {
Naveen Rawatada5fac2016-01-28 16:24:32 -08001828 sta_ds->mlmStaContext.updateContext = 1;
Naveen Rawatada5fac2016-01-28 16:24:32 -08001829 mlm_prev_state = sta_ds->mlmStaContext.mlmState;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001830
Krunal Soni99752a12016-04-12 17:44:45 -07001831 /*
1832 * As per the HAL/FW needs the reassoc req need not be calling
1833 * lim_del_sta
1834 */
Naveen Rawatada5fac2016-01-28 16:24:32 -08001835 if (sub_type != LIM_REASSOC) {
Krunal Soni99752a12016-04-12 17:44:45 -07001836 /*
1837 * we need to set the mlmState here in order
1838 * differentiate in lim_del_sta.
1839 */
Naveen Rawatada5fac2016-01-28 16:24:32 -08001840 sta_ds->mlmStaContext.mlmState =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001841 eLIM_MLM_WT_ASSOC_DEL_STA_RSP_STATE;
Krunal Soni99752a12016-04-12 17:44:45 -07001842 if (lim_del_sta(mac_ctx, sta_ds, true, session)
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001843 != QDF_STATUS_SUCCESS) {
Nishank Aggarwal8935e442017-03-23 19:11:08 +05301844 pe_err("Couldn't DEL STA, assocId: %d staId: %d",
Naveen Rawatada5fac2016-01-28 16:24:32 -08001845 sta_ds->assocId, sta_ds->staIndex);
1846 lim_reject_association(mac_ctx, sta_ds->staAddr,
Krunal Soni99752a12016-04-12 17:44:45 -07001847 sta_ds->mlmStaContext.subType, true,
1848 sta_ds->mlmStaContext.authType,
1849 sta_ds->assocId, true,
Varun Reddy Yeturu725185d2017-11-17 14:14:55 -08001850 eSIR_MAC_UNSPEC_FAILURE_STATUS,
Krunal Soni99752a12016-04-12 17:44:45 -07001851 session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001852
1853 /* Restoring the state back. */
Naveen Rawatada5fac2016-01-28 16:24:32 -08001854 sta_ds->mlmStaContext.mlmState = mlm_prev_state;
1855 if (session->parsedAssocReq)
Krunal Soni99752a12016-04-12 17:44:45 -07001856 assoc_req = session->parsedAssocReq[
1857 sta_ds->assocId];
1858 return false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001859 }
1860 } else {
Krunal Soni99752a12016-04-12 17:44:45 -07001861 /*
1862 * mlmState is changed in lim_add_sta context use the
1863 * same AID, already allocated
1864 */
1865 if (lim_add_sta(mac_ctx, sta_ds, false, session)
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001866 != QDF_STATUS_SUCCESS) {
Nishank Aggarwal8935e442017-03-23 19:11:08 +05301867 pe_err("UPASD not supported, REASSOC Failed");
Naveen Rawatada5fac2016-01-28 16:24:32 -08001868 lim_reject_association(mac_ctx, sta_ds->staAddr,
Krunal Soni99752a12016-04-12 17:44:45 -07001869 sta_ds->mlmStaContext.subType, true,
1870 sta_ds->mlmStaContext.authType,
1871 sta_ds->assocId, true,
Varun Reddy Yeturu725185d2017-11-17 14:14:55 -08001872 eSIR_MAC_WME_REFUSED_STATUS,
Krunal Soni99752a12016-04-12 17:44:45 -07001873 session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001874
1875 /* Restoring the state back. */
Naveen Rawatada5fac2016-01-28 16:24:32 -08001876 sta_ds->mlmStaContext.mlmState = mlm_prev_state;
1877 if (session->parsedAssocReq)
Krunal Soni99752a12016-04-12 17:44:45 -07001878 assoc_req = session->parsedAssocReq[
Naveen Rawatada5fac2016-01-28 16:24:32 -08001879 sta_ds->assocId];
Krunal Soni99752a12016-04-12 17:44:45 -07001880 return false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001881 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001882 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001883 }
Krunal Soni99752a12016-04-12 17:44:45 -07001884 return true;
1885}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001886
Srinivas Dasari3e54a4a2019-01-28 12:02:35 +05301887void lim_process_assoc_cleanup(struct mac_context *mac_ctx,
1888 struct pe_session *session,
1889 tpSirAssocReq assoc_req,
1890 tpDphHashNode sta_ds,
1891 bool assoc_req_copied)
Krunal Soni99752a12016-04-12 17:44:45 -07001892{
Abhishek Singh61084982016-12-13 17:24:07 +05301893 tpSirAssocReq tmp_assoc_req;
1894
Jeff Johnson8e9530b2019-03-18 13:41:42 -07001895 if (assoc_req) {
Naveen Rawatada5fac2016-01-28 16:24:32 -08001896 if (assoc_req->assocReqFrame) {
1897 qdf_mem_free(assoc_req->assocReqFrame);
1898 assoc_req->assocReqFrame = NULL;
1899 assoc_req->assocReqFrameLength = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001900 }
1901
Naveen Rawatada5fac2016-01-28 16:24:32 -08001902 qdf_mem_free(assoc_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001903 /* to avoid double free */
sheenam mongad756ff12019-04-15 15:43:18 +05301904 if (assoc_req_copied && session->parsedAssocReq && sta_ds)
Naveen Rawatada5fac2016-01-28 16:24:32 -08001905 session->parsedAssocReq[sta_ds->assocId] = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001906 }
1907
1908 /* If it is not duplicate Assoc request then only make to Null */
Jeff Johnson8e9530b2019-03-18 13:41:42 -07001909 if ((sta_ds) &&
Naveen Rawatada5fac2016-01-28 16:24:32 -08001910 (sta_ds->mlmStaContext.mlmState != eLIM_MLM_WT_ADD_STA_RSP_STATE)) {
Jeff Johnson8e9530b2019-03-18 13:41:42 -07001911 if (session->parsedAssocReq) {
Naveen Rawatada5fac2016-01-28 16:24:32 -08001912 tmp_assoc_req =
1913 session->parsedAssocReq[sta_ds->assocId];
Jeff Johnson8e9530b2019-03-18 13:41:42 -07001914 if (tmp_assoc_req) {
Naveen Rawatada5fac2016-01-28 16:24:32 -08001915 if (tmp_assoc_req->assocReqFrame) {
Krunal Soni99752a12016-04-12 17:44:45 -07001916 qdf_mem_free(
1917 tmp_assoc_req->assocReqFrame);
Naveen Rawatada5fac2016-01-28 16:24:32 -08001918 tmp_assoc_req->assocReqFrame = NULL;
1919 tmp_assoc_req->assocReqFrameLength = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001920 }
Naveen Rawatada5fac2016-01-28 16:24:32 -08001921 qdf_mem_free(tmp_assoc_req);
Krunal Soni99752a12016-04-12 17:44:45 -07001922 session->parsedAssocReq[sta_ds->assocId] = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001923 }
1924 }
1925 }
Krunal Soni99752a12016-04-12 17:44:45 -07001926}
1927
1928/**
Srinivas Dasari3e54a4a2019-01-28 12:02:35 +05301929 * lim_defer_sme_indication() - Defer assoc indication to SME
Srinivas Dasari0d9eff12019-01-07 19:46:46 +05301930 * @mac_ctx: Pointer to Global MAC structure
1931 * @session: pe session entry
1932 * @sub_type: Indicates whether it is Association Request(=0) or Reassociation
1933 * Request(=1) frame
1934 * @hdr: A pointer to the MAC header
1935 * @assoc_req: pointer to ASSOC/REASSOC Request frame
1936 * @pmf_connection: flag indicating pmf connection
1937 * @assoc_req_copied: boolean to indicate if assoc req was copied to tmp above
1938 * @dup_entry: flag indicating if duplicate entry found
1939 *
Srinivas Dasari3e54a4a2019-01-28 12:02:35 +05301940 * Defer Initialization of PE data structures and wait for an external event.
1941 * lim_send_assoc_ind_to_sme() will be called to initialize PE data structures
1942 * when the expected event is received.
Srinivas Dasari0d9eff12019-01-07 19:46:46 +05301943 *
Srinivas Dasari3e54a4a2019-01-28 12:02:35 +05301944 * Return: void
Srinivas Dasari0d9eff12019-01-07 19:46:46 +05301945 */
Srinivas Dasari3e54a4a2019-01-28 12:02:35 +05301946static void lim_defer_sme_indication(struct mac_context *mac_ctx,
1947 struct pe_session *session,
1948 uint8_t sub_type,
1949 tpSirMacMgmtHdr hdr,
1950 struct sSirAssocReq *assoc_req,
1951 bool pmf_connection,
1952 bool assoc_req_copied,
1953 bool dup_entry,
1954 struct sDphHashNode *sta_ds)
1955{
1956 struct tLimPreAuthNode *sta_pre_auth_ctx;
1957 /* Extract pre-auth context for the STA, if any. */
1958 sta_pre_auth_ctx = lim_search_pre_auth_list(mac_ctx, hdr->sa);
1959 sta_pre_auth_ctx->assoc_req.present = true;
1960 sta_pre_auth_ctx->assoc_req.sub_type = sub_type;
1961 qdf_mem_copy(&sta_pre_auth_ctx->assoc_req.hdr, hdr,
1962 sizeof(tSirMacMgmtHdr));
1963 sta_pre_auth_ctx->assoc_req.assoc_req = assoc_req;
1964 sta_pre_auth_ctx->assoc_req.pmf_connection = pmf_connection;
1965 sta_pre_auth_ctx->assoc_req.assoc_req_copied = assoc_req_copied;
1966 sta_pre_auth_ctx->assoc_req.dup_entry = dup_entry;
1967 sta_pre_auth_ctx->assoc_req.sta_ds = sta_ds;
1968}
1969
1970bool lim_send_assoc_ind_to_sme(struct mac_context *mac_ctx,
1971 struct pe_session *session,
Pragaspathi Thilagarajb3472f02019-06-04 14:10:44 +05301972 uint8_t sub_type, tpSirMacMgmtHdr hdr,
Srinivas Dasari3e54a4a2019-01-28 12:02:35 +05301973 tpSirAssocReq assoc_req,
Min Liuddd23302018-12-05 16:17:48 +08001974 enum ani_akm_type akm_type,
Pragaspathi Thilagarajb3472f02019-06-04 14:10:44 +05301975 bool pmf_connection, bool *assoc_req_copied,
1976 bool dup_entry, bool force_1x1)
Srinivas Dasari0d9eff12019-01-07 19:46:46 +05301977{
1978 uint16_t peer_idx;
1979 struct tLimPreAuthNode *sta_pre_auth_ctx;
1980 tpDphHashNode sta_ds = NULL;
1981 tHalBitVal qos_mode;
1982 tAniAuthType auth_type;
1983 uint8_t update_ctx = false;
1984
1985 limGetQosMode(session, &qos_mode);
1986 /* Extract 'associated' context for STA, if any. */
1987 sta_ds = dph_lookup_hash_entry(mac_ctx, hdr->sa, &peer_idx,
1988 &session->dph.dphHashTable);
1989
1990 /* Extract pre-auth context for the STA, if any. */
1991 sta_pre_auth_ctx = lim_search_pre_auth_list(mac_ctx, hdr->sa);
1992
1993 if (!sta_ds) {
1994 if (!lim_process_assoc_req_no_sta_ctx(mac_ctx, hdr, session,
1995 assoc_req, sub_type,
1996 sta_pre_auth_ctx, sta_ds,
1997 &auth_type))
1998 return false;
1999 } else {
2000 if (!lim_process_assoc_req_sta_ctx(mac_ctx, hdr, session,
2001 assoc_req, sub_type,
2002 sta_pre_auth_ctx, sta_ds,
2003 peer_idx, &auth_type,
2004 &update_ctx))
2005 return false;
2006 goto send_ind_to_sme;
2007 }
2008
2009 /* check if sta is allowed per QoS AC rules */
2010 if (!lim_chk_wmm(mac_ctx, hdr, session, assoc_req, sub_type, qos_mode))
2011 return false;
2012
2013 /* STA is Associated ! */
Srinivas Girigowdacb7b8b82019-04-10 14:27:47 -07002014 pe_debug("Received: %s Req successful from " QDF_MAC_ADDR_STR,
Srinivas Dasari0d9eff12019-01-07 19:46:46 +05302015 (sub_type == LIM_ASSOC) ? "Assoc" : "ReAssoc",
Srinivas Girigowda34fbba02019-04-08 12:07:44 -07002016 QDF_MAC_ADDR_ARRAY(hdr->sa));
Srinivas Dasari0d9eff12019-01-07 19:46:46 +05302017
2018 /*
2019 * AID for this association will be same as the peer Index used in DPH
2020 * table. Assign unused/least recently used peer Index from perStaDs.
2021 * NOTE: lim_assign_peer_idx() assigns AID values ranging between
2022 * 1 - cfg_item(WNI_CFG_ASSOC_STA_LIMIT)
2023 */
2024
2025 peer_idx = lim_assign_peer_idx(mac_ctx, session);
2026
2027 if (!peer_idx) {
2028 /* Could not assign AID. Reject association */
2029 pe_err("PeerIdx not avaialble. Reject associaton");
2030 lim_reject_association(mac_ctx, hdr->sa, sub_type,
2031 true, auth_type, peer_idx, false,
2032 eSIR_MAC_UNSPEC_FAILURE_STATUS,
2033 session);
2034 return false;
2035 }
2036
2037 /* Add an entry to hash table maintained by DPH module */
2038
2039 sta_ds = dph_add_hash_entry(mac_ctx, hdr->sa, peer_idx,
2040 &session->dph.dphHashTable);
2041
2042 if (!sta_ds) {
2043 /* Could not add hash table entry at DPH */
2044 pe_err("couldn't add hash entry at DPH for aid: %d MacAddr:"
Srinivas Girigowdacb7b8b82019-04-10 14:27:47 -07002045 QDF_MAC_ADDR_STR, peer_idx, QDF_MAC_ADDR_ARRAY(hdr->sa));
Srinivas Dasari0d9eff12019-01-07 19:46:46 +05302046
2047 /* Release AID */
2048 lim_release_peer_idx(mac_ctx, peer_idx, session);
2049
2050 lim_reject_association(mac_ctx, hdr->sa, sub_type,
2051 true, auth_type, peer_idx, false,
2052 eSIR_MAC_UNSPEC_FAILURE_STATUS,
2053 session);
2054 return false;
2055 }
2056
2057send_ind_to_sme:
2058 if (!lim_update_sta_ds(mac_ctx, hdr, session, assoc_req,
Min Liuddd23302018-12-05 16:17:48 +08002059 sub_type, sta_ds, auth_type, akm_type,
Srinivas Dasari0d9eff12019-01-07 19:46:46 +05302060 assoc_req_copied, peer_idx, qos_mode,
Pragaspathi Thilagarajb3472f02019-06-04 14:10:44 +05302061 pmf_connection, force_1x1))
Srinivas Dasari0d9eff12019-01-07 19:46:46 +05302062 return false;
2063
2064 /* BTAMP: Storing the parsed assoc request in the session array */
2065 if (session->parsedAssocReq)
2066 session->parsedAssocReq[sta_ds->assocId] = assoc_req;
2067 *assoc_req_copied = true;
2068
2069 /* If it is duplicate entry wait till the peer is deleted */
2070 if (!dup_entry) {
2071 if (!lim_update_sta_ctx(mac_ctx, session, assoc_req,
2072 sub_type, sta_ds, update_ctx))
2073 return false;
2074 }
2075
2076 /* AddSta is success here */
2077 if (LIM_IS_AP_ROLE(session) && IS_DOT11_MODE_HT(session->dot11mode) &&
2078 assoc_req->HTCaps.present && assoc_req->wmeInfoPresent) {
2079 /*
2080 * Update in the HAL Sta Table for the Update of the Protection
2081 * Mode
2082 */
2083 lim_post_sm_state_update(mac_ctx, sta_ds->staIndex,
2084 sta_ds->htMIMOPSState, sta_ds->staAddr,
2085 session->smeSessionId);
2086 }
2087
2088 return true;
2089}
2090
2091/**
Krunal Soni99752a12016-04-12 17:44:45 -07002092 * lim_process_assoc_req_frame() - Process RE/ASSOC Request frame.
2093 * @mac_ctx: Pointer to Global MAC structure
2094 * @rx_pkt_info: A pointer to Buffer descriptor + associated PDUs
2095 * @sub_type: Indicates whether it is Association Request(=0) or Reassociation
2096 * Request(=1) frame
2097 * @session: pe session entry
2098 *
2099 * This function is called to process RE/ASSOC Request frame.
2100 *
2101 * @Return: void
2102 */
Jeff Johnson9320c1e2018-12-02 13:09:20 -08002103void lim_process_assoc_req_frame(struct mac_context *mac_ctx, uint8_t *rx_pkt_info,
Jeff Johnson5b574dd2018-11-19 06:49:34 -08002104 uint8_t sub_type, struct pe_session *session)
Krunal Soni99752a12016-04-12 17:44:45 -07002105{
2106 bool pmf_connection = false, assoc_req_copied = false;
Srinivas Dasari0d9eff12019-01-07 19:46:46 +05302107 uint8_t *frm_body;
2108 uint16_t assoc_id = 0;
Krishna Kumaar Natarajandb582ec2016-03-08 17:37:04 -08002109 uint32_t frame_len;
Krunal Soni99752a12016-04-12 17:44:45 -07002110 uint32_t phy_mode;
2111 tHalBitVal qos_mode;
2112 tpSirMacMgmtHdr hdr;
Srinivas Dasari3e54a4a2019-01-28 12:02:35 +05302113 struct tLimPreAuthNode *sta_pre_auth_ctx;
Min Liuddd23302018-12-05 16:17:48 +08002114 enum ani_akm_type akm_type = ANI_AKM_TYPE_NONE;
Krunal Soni99752a12016-04-12 17:44:45 -07002115 tSirMacCapabilityInfo local_cap;
2116 tpDphHashNode sta_ds = NULL;
Abhishek Singh61084982016-12-13 17:24:07 +05302117 tpSirAssocReq assoc_req;
Pragaspathi Thilagarajb3472f02019-06-04 14:10:44 +05302118 bool dup_entry = false, force_1x1 = false;
Jianmin Zhufc2cef12019-01-14 21:23:51 +08002119 QDF_STATUS status;
Krunal Soni99752a12016-04-12 17:44:45 -07002120
2121 lim_get_phy_mode(mac_ctx, &phy_mode, session);
2122
2123 limGetQosMode(session, &qos_mode);
2124
2125 hdr = WMA_GET_RX_MAC_HEADER(rx_pkt_info);
2126 frame_len = WMA_GET_RX_PAYLOAD_LEN(rx_pkt_info);
2127
Nishank Aggarwal8935e442017-03-23 19:11:08 +05302128 pe_debug("Rcvd: %s Req Frame sessionid: %d systemrole: %d MlmState: %d from: "
Srinivas Girigowdacb7b8b82019-04-10 14:27:47 -07002129 QDF_MAC_ADDR_STR,
Krunal Soni99752a12016-04-12 17:44:45 -07002130 (LIM_ASSOC == sub_type) ? "Assoc" : "ReAssoc",
2131 session->peSessionId, GET_LIM_SYSTEM_ROLE(session),
Srinivas Girigowda34fbba02019-04-08 12:07:44 -07002132 session->limMlmState, QDF_MAC_ADDR_ARRAY(hdr->sa));
Krunal Soni99752a12016-04-12 17:44:45 -07002133
Rajeev Kumarbe5d7fd2016-04-15 14:35:12 -07002134 if (LIM_IS_STA_ROLE(session)) {
Nishank Aggarwal8935e442017-03-23 19:11:08 +05302135 pe_err("Rcvd unexpected ASSOC REQ, sessionid: %d sys sub_type: %d for role: %d from: "
Srinivas Girigowdacb7b8b82019-04-10 14:27:47 -07002136 QDF_MAC_ADDR_STR,
Krunal Soni99752a12016-04-12 17:44:45 -07002137 session->peSessionId, sub_type,
2138 GET_LIM_SYSTEM_ROLE(session),
Srinivas Girigowda34fbba02019-04-08 12:07:44 -07002139 QDF_MAC_ADDR_ARRAY(hdr->sa));
Srinivas Girigowdab896a562017-03-16 17:41:26 -07002140 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_DEBUG,
2141 WMA_GET_RX_MPDU_DATA(rx_pkt_info),
2142 frame_len);
Krunal Soni99752a12016-04-12 17:44:45 -07002143 return;
2144 }
Liangwei Dong9028d752016-10-17 02:00:17 -04002145 if (session->limMlmState == eLIM_MLM_WT_DEL_BSS_RSP_STATE) {
Nishank Aggarwal8935e442017-03-23 19:11:08 +05302146 pe_err("drop ASSOC REQ on sessionid: %d "
Srinivas Girigowdacb7b8b82019-04-10 14:27:47 -07002147 "role: %d from: "QDF_MAC_ADDR_STR" in limMlmState: %d",
Liangwei Dong9028d752016-10-17 02:00:17 -04002148 session->peSessionId,
2149 GET_LIM_SYSTEM_ROLE(session),
Srinivas Girigowda34fbba02019-04-08 12:07:44 -07002150 QDF_MAC_ADDR_ARRAY(hdr->sa),
Liangwei Dong9028d752016-10-17 02:00:17 -04002151 eLIM_MLM_WT_DEL_BSS_RSP_STATE);
2152 return;
2153 }
Krunal Soni99752a12016-04-12 17:44:45 -07002154
2155 /*
2156 * If a STA is already present in DPH and it is initiating a Assoc
2157 * re-transmit, do not process it. This can happen when first Assoc Req
2158 * frame is received but ACK lost at STA side. The ACK for this dropped
2159 * Assoc Req frame should be sent by HW. Host simply does not process it
2160 * once the entry for the STA is already present in DPH.
2161 */
2162 sta_ds = dph_lookup_hash_entry(mac_ctx, hdr->sa, &assoc_id,
2163 &session->dph.dphHashTable);
Jeff Johnson8e9530b2019-03-18 13:41:42 -07002164 if (sta_ds) {
Krunal Soni99752a12016-04-12 17:44:45 -07002165 if (hdr->fc.retry > 0) {
Nishank Aggarwal8935e442017-03-23 19:11:08 +05302166 pe_err("STA is initiating Assoc Req after ACK lost. Do not process sessionid: %d sys sub_type=%d for role=%d from: "
Srinivas Girigowdacb7b8b82019-04-10 14:27:47 -07002167 QDF_MAC_ADDR_STR, session->peSessionId,
Krunal Soni99752a12016-04-12 17:44:45 -07002168 sub_type, GET_LIM_SYSTEM_ROLE(session),
Srinivas Girigowda34fbba02019-04-08 12:07:44 -07002169 QDF_MAC_ADDR_ARRAY(hdr->sa));
Abhishek Singha0b4dc12017-03-09 15:29:31 +05302170 return;
Krunal Soni17184262017-06-07 16:42:38 -07002171 } else if (!sta_ds->rmfEnabled && (sub_type == LIM_REASSOC)) {
2172 /*
2173 * SAP should send reassoc response with reject code
2174 * to avoid IOT issues. as per the specification SAP
2175 * should do 4-way handshake after reassoc response and
2176 * some STA doesn't like 4way handshake after reassoc
2177 * where some STA does expect 4-way handshake.
2178 */
2179 lim_send_assoc_rsp_mgmt_frame(mac_ctx,
2180 eSIR_MAC_OUTSIDE_SCOPE_OF_SPEC_STATUS,
2181 sta_ds->assocId, sta_ds->staAddr,
2182 sub_type, sta_ds, session);
2183 pe_err("Rejecting reassoc req from STA");
2184 return;
Krunal Soni99752a12016-04-12 17:44:45 -07002185 } else if (!sta_ds->rmfEnabled) {
2186 /*
2187 * Do this only for non PMF case.
2188 * STA might have missed the assoc response, so it is
2189 * sending assoc request frame again.
2190 */
Jeff Johnson0301ecb2018-06-29 09:36:23 -07002191 lim_send_assoc_rsp_mgmt_frame(mac_ctx, QDF_STATUS_SUCCESS,
Krunal Soni99752a12016-04-12 17:44:45 -07002192 sta_ds->assocId, sta_ds->staAddr,
Krunal Soni90ba9542017-03-01 19:45:40 -08002193 sub_type,
Krunal Soni99752a12016-04-12 17:44:45 -07002194 sta_ds, session);
Nishank Aggarwal8935e442017-03-23 19:11:08 +05302195 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: "
Srinivas Girigowdacb7b8b82019-04-10 14:27:47 -07002196 QDF_MAC_ADDR_STR,
Krunal Soni99752a12016-04-12 17:44:45 -07002197 session->peSessionId, sub_type,
2198 session->limSystemRole,
Srinivas Girigowda34fbba02019-04-08 12:07:44 -07002199 QDF_MAC_ADDR_ARRAY(hdr->sa));
Abhishek Singha0b4dc12017-03-09 15:29:31 +05302200 return;
Krunal Soni99752a12016-04-12 17:44:45 -07002201 }
Krunal Soni99752a12016-04-12 17:44:45 -07002202 }
2203
Jianmin Zhufc2cef12019-01-14 21:23:51 +08002204 status = lim_check_sta_in_pe_entries(mac_ctx, hdr, session->peSessionId,
2205 &dup_entry);
2206 if (QDF_IS_STATUS_ERROR(status)) {
2207 pe_err("Reject assoc as duplicate entry is present and is already being deleted, assoc will be accepted once deletion is completed");
2208 /*
2209 * This mean that the duplicate entry is present on other vdev
2210 * and is already being deleted, so reject the assoc and lets
2211 * peer try again to connect, once peer is deleted from
2212 * other vdev.
2213 */
2214 lim_send_assoc_rsp_mgmt_frame(
2215 mac_ctx,
2216 eSIR_MAC_UNSPEC_FAILURE_STATUS,
2217 1, hdr->sa,
2218 sub_type, 0, session);
2219 return;
2220 }
Krunal Soni99752a12016-04-12 17:44:45 -07002221
2222 /* Get pointer to Re/Association Request frame body */
2223 frm_body = WMA_GET_RX_MPDU_DATA(rx_pkt_info);
2224
Srinivas Girigowdab971ba22019-03-04 15:56:28 -08002225 if (IEEE80211_IS_MULTICAST(hdr->sa)) {
Krunal Soni99752a12016-04-12 17:44:45 -07002226 /*
2227 * Rcvd Re/Assoc Req frame from BC/MC address Log error and
2228 * ignore it
2229 */
Nishank Aggarwal8935e442017-03-23 19:11:08 +05302230 pe_err("Rcvd: %s Req, sessionid: %d from a BC/MC address"
Srinivas Girigowdacb7b8b82019-04-10 14:27:47 -07002231 QDF_MAC_ADDR_STR,
Krunal Soni99752a12016-04-12 17:44:45 -07002232 (LIM_ASSOC == sub_type) ? "Assoc" : "ReAssoc",
Srinivas Girigowda34fbba02019-04-08 12:07:44 -07002233 session->peSessionId, QDF_MAC_ADDR_ARRAY(hdr->sa));
Krunal Soni99752a12016-04-12 17:44:45 -07002234 return;
2235 }
2236
Srinivas Girigowdab896a562017-03-16 17:41:26 -07002237 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_DEBUG,
2238 (uint8_t *) frm_body, frame_len);
Krunal Soni99752a12016-04-12 17:44:45 -07002239
2240 if (false == lim_chk_sa_da(mac_ctx, hdr, session, sub_type))
2241 return;
2242
2243 if (false == lim_chk_tkip(mac_ctx, hdr, session, sub_type))
2244 return;
2245
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05302246 /* check for the presence of vendor IE */
2247 if ((session->access_policy_vendor_ie) &&
2248 (session->access_policy ==
2249 LIM_ACCESS_POLICY_RESPOND_IF_IE_IS_PRESENT)) {
Abhinav Kumardb3c6f52018-06-20 15:02:00 +05302250 if (frame_len <= LIM_ASSOC_REQ_IE_OFFSET) {
2251 pe_debug("Received action frame of invalid len %d",
2252 frame_len);
2253 return;
2254 }
Naveen Rawat08db88f2017-09-08 15:07:48 -07002255 if (!wlan_get_vendor_ie_ptr_from_oui(
2256 &session->access_policy_vendor_ie[2],
2257 3, frm_body + LIM_ASSOC_REQ_IE_OFFSET,
Yeshwanth Sriram Guntuka9dea24e2018-06-14 18:44:41 +05302258 frame_len - LIM_ASSOC_REQ_IE_OFFSET)) {
Nishank Aggarwal8935e442017-03-23 19:11:08 +05302259 pe_err("Vendor ie not present and access policy is %x, Rejected association",
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05302260 session->access_policy);
2261 lim_send_assoc_rsp_mgmt_frame(mac_ctx,
2262 eSIR_MAC_UNSPEC_FAILURE_STATUS, 1, hdr->sa,
2263 sub_type, 0, session);
2264 return;
2265 }
2266 }
Krunal Soni99752a12016-04-12 17:44:45 -07002267 /* Allocate memory for the Assoc Request frame */
2268 assoc_req = qdf_mem_malloc(sizeof(*assoc_req));
Arif Hussainf5b6c412018-10-10 19:41:09 -07002269 if (!assoc_req)
Krunal Soni99752a12016-04-12 17:44:45 -07002270 return;
Krunal Soni99752a12016-04-12 17:44:45 -07002271
2272 /* Parse Assoc Request frame */
2273 if (false == lim_chk_assoc_req_parse_error(mac_ctx, hdr, session,
2274 assoc_req, sub_type, frm_body, frame_len))
2275 goto error;
2276
2277 assoc_req->assocReqFrame = qdf_mem_malloc(frame_len);
Arif Hussainf5b6c412018-10-10 19:41:09 -07002278 if (!assoc_req->assocReqFrame)
Krunal Soni99752a12016-04-12 17:44:45 -07002279 goto error;
Krunal Soni99752a12016-04-12 17:44:45 -07002280
2281 qdf_mem_copy((uint8_t *) assoc_req->assocReqFrame,
2282 (uint8_t *) frm_body, frame_len);
2283 assoc_req->assocReqFrameLength = frame_len;
2284
2285 if (false == lim_chk_capab(mac_ctx, hdr, session, assoc_req,
2286 sub_type, &local_cap))
2287 goto error;
2288
Krunal Soni99752a12016-04-12 17:44:45 -07002289 if (false == lim_chk_ssid(mac_ctx, hdr, session, assoc_req, sub_type))
2290 goto error;
2291
2292 if (false == lim_chk_rates(mac_ctx, hdr, session, assoc_req, sub_type))
2293 goto error;
2294
2295 if (false == lim_chk_11g_only(mac_ctx, hdr, session, assoc_req,
2296 sub_type))
2297 goto error;
2298
2299 if (false == lim_chk_11n_only(mac_ctx, hdr, session, assoc_req,
2300 sub_type))
2301 goto error;
2302
2303 if (false == lim_chk_11ac_only(mac_ctx, hdr, session, assoc_req,
2304 sub_type))
2305 goto error;
2306
Naveen Rawat441bc872017-12-11 17:25:27 -08002307 if (false == lim_chk_11ax_only(mac_ctx, hdr, session, assoc_req,
2308 sub_type))
2309 goto error;
2310
2311 if (false == lim_check_11ax_basic_mcs(mac_ctx, hdr, session, assoc_req,
2312 sub_type))
2313 goto error;
2314
Krunal Soni99752a12016-04-12 17:44:45 -07002315 /* Spectrum Management (11h) specific checks */
2316 lim_process_for_spectrum_mgmt(mac_ctx, hdr, session,
2317 assoc_req, sub_type, local_cap);
2318
2319 if (false == lim_chk_mcs(mac_ctx, hdr, session, assoc_req, sub_type))
2320 goto error;
2321
2322 if (false == lim_chk_is_11b_sta_supported(mac_ctx, hdr, session,
2323 assoc_req, sub_type, phy_mode))
2324 goto error;
2325
2326 /*
2327 * Check for 802.11n HT caps compatibility; are HT Capabilities
2328 * turned on in lim?
2329 */
2330 lim_print_ht_cap(mac_ctx, session, assoc_req);
2331
2332 if (false == lim_chk_n_process_wpa_rsn_ie(mac_ctx, hdr, session,
Min Liuddd23302018-12-05 16:17:48 +08002333 assoc_req, sub_type,
2334 &pmf_connection,
2335 &akm_type))
Krunal Soni99752a12016-04-12 17:44:45 -07002336 goto error;
2337
Srinivas Dasari3e54a4a2019-01-28 12:02:35 +05302338 /* Extract pre-auth context for the STA, if any. */
2339 sta_pre_auth_ctx = lim_search_pre_auth_list(mac_ctx, hdr->sa);
2340
2341 /* SAE authentication is offloaded to hostapd. Hostapd sends
2342 * authentication status to driver after completing SAE
2343 * authentication (after sending out 4/4 SAE auth frame).
2344 * There is a possible race condition where driver gets
2345 * assoc request from SAE station before getting authentication
2346 * status from hostapd. Don't reject the association in such
2347 * cases and defer the processing of assoc request frame by caching
2348 * the frame and process it when the auth status is received.
2349 */
2350 if (sta_pre_auth_ctx &&
2351 sta_pre_auth_ctx->authType == eSIR_AUTH_TYPE_SAE &&
2352 sta_pre_auth_ctx->mlmState == eLIM_MLM_WT_SAE_AUTH_STATE) {
2353 pe_debug("Received assoc request frame while SAE authentication is in progress; Defer association request handling till SAE auth status is received");
2354 lim_defer_sme_indication(mac_ctx, session, sub_type, hdr,
2355 assoc_req, pmf_connection,
2356 assoc_req_copied, dup_entry, sta_ds);
2357 return;
2358 }
2359
Pragaspathi Thilagarajb3472f02019-06-04 14:10:44 +05302360 if (session->opmode == QDF_P2P_GO_MODE) {
2361 /*
2362 * WAR: In P2P GO mode, if the P2P client device
2363 * is only HT capable and not VHT capable, but the P2P
2364 * GO device is VHT capable and advertises 2x2 NSS with
2365 * HT capablity client device, which results in IOT
2366 * issues.
2367 * When GO is operating in DBS mode, GO beacons
2368 * advertise 2x2 capability but include OMN IE to
2369 * indicate current operating mode of 1x1. But here
2370 * peer device is only HT capable and will not
2371 * understand OMN IE.
2372 */
2373 force_1x1 = wlan_p2p_check_oui_and_force_1x1(
2374 frm_body + LIM_ASSOC_REQ_IE_OFFSET,
2375 frame_len - LIM_ASSOC_REQ_IE_OFFSET);
2376 }
2377
Srinivas Dasari0d9eff12019-01-07 19:46:46 +05302378 /* Send assoc indication to SME */
2379 if (!lim_send_assoc_ind_to_sme(mac_ctx, session, sub_type, hdr,
Min Liuddd23302018-12-05 16:17:48 +08002380 assoc_req, akm_type, pmf_connection,
Pragaspathi Thilagarajb3472f02019-06-04 14:10:44 +05302381 &assoc_req_copied, dup_entry, force_1x1))
Krunal Soni99752a12016-04-12 17:44:45 -07002382 goto error;
2383
Krunal Soni99752a12016-04-12 17:44:45 -07002384 return;
2385
2386error:
Krunal Soni99752a12016-04-12 17:44:45 -07002387 lim_process_assoc_cleanup(mac_ctx, session, assoc_req, sta_ds,
Srinivas Dasari3e54a4a2019-01-28 12:02:35 +05302388 assoc_req_copied);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002389 return;
Naveen Rawatada5fac2016-01-28 16:24:32 -08002390}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002391
2392#ifdef FEATURE_WLAN_WAPI
2393/**
2394 * lim_fill_assoc_ind_wapi_info()- Updates WAPI data in assoc indication
2395 * @mac_ctx: Global Mac context
2396 * @assoc_req: pointer to association request
2397 * @assoc_ind: Pointer to association indication
2398 * @wpsie: WPS IE
2399 *
2400 * This function updates WAPI meta data in association indication message
2401 * sent to SME.
2402 *
2403 * Return: None
2404 */
Jeff Johnson9320c1e2018-12-02 13:09:20 -08002405static void lim_fill_assoc_ind_wapi_info(struct mac_context *mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002406 tpSirAssocReq assoc_req, tpLimMlmAssocInd assoc_ind,
Naveen Rawat08db88f2017-09-08 15:07:48 -07002407 const uint8_t *wpsie)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002408{
Jeff Johnson8e9530b2019-03-18 13:41:42 -07002409 if (assoc_req->wapiPresent && (!wpsie)) {
Nishank Aggarwal8935e442017-03-23 19:11:08 +05302410 pe_debug("Received WAPI IE length in Assoc Req is %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002411 assoc_req->wapi.length);
Srinivas Girigowda61771262019-04-01 11:55:19 -07002412 assoc_ind->wapiIE.wapiIEdata[0] = WLAN_ELEMID_WAPI;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002413 assoc_ind->wapiIE.wapiIEdata[1] = assoc_req->wapi.length;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302414 qdf_mem_copy(&assoc_ind->wapiIE.wapiIEdata[2],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002415 assoc_req->wapi.info, assoc_req->wapi.length);
2416 assoc_ind->wapiIE.length =
2417 2 + assoc_req->wapi.length;
2418 }
2419 return;
2420}
2421#endif
2422
2423/**
2424 * lim_fill_assoc_ind_vht_info() - Updates VHT information in assoc indication
2425 * @mac_ctx: Global Mac context
2426 * @assoc_req: pointer to association request
2427 * @session_entry: PE session entry
2428 * @assoc_ind: Pointer to association indication
2429 *
2430 * This function updates VHT information in association indication message
2431 * sent to SME.
2432 *
2433 * Return: None
2434 */
Jeff Johnson9320c1e2018-12-02 13:09:20 -08002435static void lim_fill_assoc_ind_vht_info(struct mac_context *mac_ctx,
Jeff Johnson5b574dd2018-11-19 06:49:34 -08002436 struct pe_session *session_entry,
Naveen Rawat6186ff92015-10-12 14:33:53 -07002437 tpSirAssocReq assoc_req,
Ashish Kumar Dhanotiya443d31f2017-10-13 12:41:19 +05302438 tpLimMlmAssocInd assoc_ind,
2439 tpDphHashNode sta_ds)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002440{
2441 uint8_t chan;
Ashish Kumar Dhanotiya443d31f2017-10-13 12:41:19 +05302442 uint8_t i;
2443 bool nw_type_11b = true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002444
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08002445 if (session_entry->limRFBand == BAND_2G) {
Naveen Rawat6186ff92015-10-12 14:33:53 -07002446 if (session_entry->vhtCapability && assoc_req->VHTCaps.present)
Krishna Kumaar Natarajan294da812016-04-28 14:39:30 -07002447 assoc_ind->chan_info.info = MODE_11AC_VHT20_2G;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002448 else if (session_entry->htCapability
Naveen Rawat6186ff92015-10-12 14:33:53 -07002449 && assoc_req->HTCaps.present)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002450 assoc_ind->chan_info.info = MODE_11NG_HT20;
Ashish Kumar Dhanotiya443d31f2017-10-13 12:41:19 +05302451 else {
2452 for (i = 0; i < SIR_NUM_11A_RATES; i++) {
2453 if (sirIsArate(sta_ds->
2454 supportedRates.llaRates[i]
2455 & 0x7F)) {
2456 assoc_ind->chan_info.info = MODE_11G;
2457 nw_type_11b = false;
2458 break;
2459 }
2460 }
2461 if (nw_type_11b)
2462 assoc_ind->chan_info.info = MODE_11B;
2463 }
Naveen Rawat6186ff92015-10-12 14:33:53 -07002464 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002465 }
Naveen Rawat6186ff92015-10-12 14:33:53 -07002466
2467 if (session_entry->vhtCapability && assoc_req->VHTCaps.present) {
2468 if ((session_entry->ch_width > CH_WIDTH_40MHZ)
2469 && assoc_req->HTCaps.supportedChannelWidthSet) {
2470 chan = session_entry->ch_center_freq_seg0;
2471 assoc_ind->chan_info.band_center_freq1 =
2472 cds_chan_to_freq(chan);
2473 assoc_ind->chan_info.info = MODE_11AC_VHT80;
2474 return;
2475 }
2476
2477 if ((session_entry->ch_width == CH_WIDTH_40MHZ)
2478 && assoc_req->HTCaps.supportedChannelWidthSet) {
2479 assoc_ind->chan_info.info = MODE_11AC_VHT40;
2480 if (session_entry->htSecondaryChannelOffset ==
2481 PHY_DOUBLE_CHANNEL_LOW_PRIMARY)
2482 assoc_ind->chan_info.band_center_freq1 += 10;
2483 else
2484 assoc_ind->chan_info.band_center_freq1 -= 10;
2485 return;
2486 }
2487
2488 assoc_ind->chan_info.info = MODE_11AC_VHT20;
2489 return;
2490 }
2491
2492 if (session_entry->htCapability && assoc_req->HTCaps.present) {
2493 if ((session_entry->ch_width == CH_WIDTH_40MHZ)
2494 && assoc_req->HTCaps.supportedChannelWidthSet) {
2495 assoc_ind->chan_info.info = MODE_11NA_HT40;
2496 if (session_entry->htSecondaryChannelOffset ==
2497 PHY_DOUBLE_CHANNEL_LOW_PRIMARY)
2498 assoc_ind->chan_info.band_center_freq1 += 10;
2499 else
2500 assoc_ind->chan_info.band_center_freq1 -= 10;
2501 return;
2502 }
2503
2504 assoc_ind->chan_info.info = MODE_11NA_HT20;
2505 return;
2506 }
2507
2508 assoc_ind->chan_info.info = MODE_11A;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002509 return;
2510}
2511
Will Huang558f8082017-05-31 16:22:24 +08002512static uint8_t lim_get_max_rate_idx(tSirMacRateSet *rateset)
2513{
2514 uint8_t maxidx;
2515 int i;
2516
2517 maxidx = rateset->rate[0] & 0x7f;
2518 for (i = 1; i < rateset->numRates; i++) {
2519 if ((rateset->rate[i] & 0x7f) > maxidx)
2520 maxidx = rateset->rate[i] & 0x7f;
2521 }
2522
2523 return maxidx;
2524}
2525
2526static void fill_mlm_assoc_ind_vht(tpSirAssocReq assocreq,
2527 tpDphHashNode stads,
2528 tpLimMlmAssocInd assocind)
2529{
2530 if (stads->mlmStaContext.vhtCapability) {
2531 /* ampdu */
2532 assocind->ampdu = true;
2533
2534 /* sgi */
2535 if (assocreq->VHTCaps.shortGI80MHz ||
2536 assocreq->VHTCaps.shortGI160and80plus80MHz)
2537 assocind->sgi_enable = true;
2538
2539 /* stbc */
2540 assocind->tx_stbc = assocreq->VHTCaps.txSTBC;
2541 assocind->rx_stbc = assocreq->VHTCaps.rxSTBC;
2542
2543 /* ch width */
2544 assocind->ch_width = stads->vhtSupportedChannelWidthSet ?
2545 eHT_CHANNEL_WIDTH_80MHZ :
2546 stads->htSupportedChannelWidthSet ?
2547 eHT_CHANNEL_WIDTH_40MHZ : eHT_CHANNEL_WIDTH_20MHZ;
2548
2549 /* mode */
2550 assocind->mode = SIR_SME_PHY_MODE_VHT;
2551 assocind->rx_mcs_map = assocreq->VHTCaps.rxMCSMap & 0xff;
2552 assocind->tx_mcs_map = assocreq->VHTCaps.txMCSMap & 0xff;
2553 }
2554}
2555
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002556/**
2557 * lim_send_mlm_assoc_ind() - Sends assoc indication to SME
2558 * @mac_ctx: Global Mac context
2559 * @sta_ds: Station DPH hash entry
2560 * @session_entry: PE session entry
2561 *
2562 * This function sends either LIM_MLM_ASSOC_IND
2563 * or LIM_MLM_REASSOC_IND to SME.
2564 *
2565 * Return: None
2566 */
Jeff Johnson9320c1e2018-12-02 13:09:20 -08002567void lim_send_mlm_assoc_ind(struct mac_context *mac_ctx,
Jeff Johnson5b574dd2018-11-19 06:49:34 -08002568 tpDphHashNode sta_ds, struct pe_session *session_entry)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002569{
2570 tpLimMlmAssocInd assoc_ind = NULL;
2571 tpSirAssocReq assoc_req;
2572 uint16_t temp, rsn_len;
2573 uint32_t phy_mode;
2574 uint8_t sub_type;
Naveen Rawat08db88f2017-09-08 15:07:48 -07002575 const uint8_t *wpsie = NULL;
Will Huang558f8082017-05-31 16:22:24 +08002576 uint8_t maxidx, i;
Pragaspathi Thilagarajec7dc252018-09-06 15:38:49 +05302577 bool wme_enable;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002578
Pragaspathi Thilagarajaba1b5d2018-11-13 14:29:44 +05302579 if (!session_entry->parsedAssocReq) {
2580 pe_err(" Parsed Assoc req is NULL");
2581 return;
2582 }
2583
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002584 /* Get a copy of the already parsed Assoc Request */
2585 assoc_req =
2586 (tpSirAssocReq) session_entry->parsedAssocReq[sta_ds->assocId];
2587
Pragaspathi Thilagarajaba1b5d2018-11-13 14:29:44 +05302588 if (!assoc_req) {
2589 pe_err("assoc req for assoc_id:%d is NULL", sta_ds->assocId);
2590 return;
2591 }
2592
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002593 /* Get the phy_mode */
2594 lim_get_phy_mode(mac_ctx, &phy_mode, session_entry);
2595
2596 /* Determine if its Assoc or ReAssoc Request */
2597 if (assoc_req->reassocRequest == 1)
2598 sub_type = LIM_REASSOC;
2599 else
2600 sub_type = LIM_ASSOC;
2601
Nishank Aggarwal8935e442017-03-23 19:11:08 +05302602 pe_debug("Sessionid: %d ssid: %s sub_type: %d Associd: %d staAddr: "
Srinivas Girigowdacb7b8b82019-04-10 14:27:47 -07002603 QDF_MAC_ADDR_STR, session_entry->peSessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002604 assoc_req->ssId.ssId, sub_type, sta_ds->assocId,
Srinivas Girigowda34fbba02019-04-08 12:07:44 -07002605 QDF_MAC_ADDR_ARRAY(sta_ds->staAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002606
2607 if (sub_type == LIM_ASSOC || sub_type == LIM_REASSOC) {
2608 temp = sizeof(tLimMlmAssocInd);
2609
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302610 assoc_ind = qdf_mem_malloc(temp);
Arif Hussainf5b6c412018-10-10 19:41:09 -07002611 if (!assoc_ind) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002612 lim_release_peer_idx(mac_ctx, sta_ds->assocId,
2613 session_entry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002614 return;
2615 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302616 qdf_mem_copy((uint8_t *) assoc_ind->peerMacAddr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002617 (uint8_t *) sta_ds->staAddr, sizeof(tSirMacAddr));
2618 assoc_ind->aid = sta_ds->assocId;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302619 qdf_mem_copy((uint8_t *) &assoc_ind->ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002620 (uint8_t *) &(assoc_req->ssId),
2621 assoc_req->ssId.length + 1);
2622 assoc_ind->sessionId = session_entry->peSessionId;
2623 assoc_ind->authType = sta_ds->mlmStaContext.authType;
Min Liuddd23302018-12-05 16:17:48 +08002624 assoc_ind->akm_type = sta_ds->mlmStaContext.akm_type;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002625 assoc_ind->capabilityInfo = assoc_req->capabilityInfo;
2626
2627 /* Fill in RSN IE information */
2628 assoc_ind->rsnIE.length = 0;
2629 /* if WPS IE is present, ignore RSN IE */
2630 if (assoc_req->addIEPresent && assoc_req->addIE.length) {
2631 wpsie = limGetWscIEPtr(mac_ctx,
2632 assoc_req->addIE.addIEdata,
2633 assoc_req->addIE.length);
2634 }
Jeff Johnson8e9530b2019-03-18 13:41:42 -07002635 if (assoc_req->rsnPresent && (!wpsie)) {
Nishank Aggarwal8935e442017-03-23 19:11:08 +05302636 pe_debug("Assoc Req RSN IE len: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002637 assoc_req->rsn.length);
2638 assoc_ind->rsnIE.length = 2 + assoc_req->rsn.length;
Srinivas Girigowda61771262019-04-01 11:55:19 -07002639 assoc_ind->rsnIE.rsnIEdata[0] = WLAN_ELEMID_RSN;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002640 assoc_ind->rsnIE.rsnIEdata[1] =
2641 assoc_req->rsn.length;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302642 qdf_mem_copy(&assoc_ind->rsnIE.rsnIEdata[2],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002643 assoc_req->rsn.info,
2644 assoc_req->rsn.length);
2645 }
2646 /* Fill in 802.11h related info */
2647 if (assoc_req->powerCapabilityPresent
2648 && assoc_req->supportedChannelsPresent) {
Srinivas Girigowda74a66d62017-06-21 23:28:25 -07002649 assoc_ind->spectrumMgtIndicator = true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002650 assoc_ind->powerCap.minTxPower =
2651 assoc_req->powerCapability.minTxPower;
2652 assoc_ind->powerCap.maxTxPower =
2653 assoc_req->powerCapability.maxTxPower;
2654 lim_convert_supported_channels(mac_ctx, assoc_ind,
2655 assoc_req);
2656 } else {
Srinivas Girigowda74a66d62017-06-21 23:28:25 -07002657 assoc_ind->spectrumMgtIndicator = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002658 }
2659
2660 /* This check is to avoid extra Sec IEs present incase of WPS */
Jeff Johnson8e9530b2019-03-18 13:41:42 -07002661 if (assoc_req->wpaPresent && (!wpsie)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002662 rsn_len = assoc_ind->rsnIE.length;
2663 if ((rsn_len + assoc_req->wpa.length)
Srinivas Girigowdacf161402019-03-14 11:37:33 -07002664 >= WLAN_MAX_IE_LEN) {
Nishank Aggarwal8935e442017-03-23 19:11:08 +05302665 pe_err("rsnIEdata index out of bounds: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002666 rsn_len);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302667 qdf_mem_free(assoc_ind);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002668 return;
2669 }
2670 assoc_ind->rsnIE.rsnIEdata[rsn_len] =
2671 SIR_MAC_WPA_EID;
2672 assoc_ind->rsnIE.rsnIEdata[rsn_len + 1]
2673 = assoc_req->wpa.length;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302674 qdf_mem_copy(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002675 &assoc_ind->rsnIE.rsnIEdata[rsn_len + 2],
2676 assoc_req->wpa.info, assoc_req->wpa.length);
2677 assoc_ind->rsnIE.length += 2 + assoc_req->wpa.length;
2678 }
2679#ifdef FEATURE_WLAN_WAPI
2680 lim_fill_assoc_ind_wapi_info(mac_ctx, assoc_req, assoc_ind,
2681 wpsie);
2682#endif
2683
2684 assoc_ind->addIE.length = 0;
2685 if (assoc_req->addIEPresent) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302686 qdf_mem_copy(&assoc_ind->addIE.addIEdata,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002687 assoc_req->addIE.addIEdata,
2688 assoc_req->addIE.length);
2689 assoc_ind->addIE.length = assoc_req->addIE.length;
2690 }
2691 /*
2692 * Add HT Capabilities into addIE for OBSS
2693 * processing in hostapd
2694 */
2695 if (assoc_req->HTCaps.present) {
Ashish Kumar Dhanotiya443d31f2017-10-13 12:41:19 +05302696 qdf_mem_copy(&assoc_ind->ht_caps, &assoc_req->HTCaps,
2697 sizeof(tDot11fIEHTCaps));
2698
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002699 rsn_len = assoc_ind->addIE.length;
2700 if (assoc_ind->addIE.length + DOT11F_IE_HTCAPS_MIN_LEN
Srinivas Girigowdacf161402019-03-14 11:37:33 -07002701 + 2 < WLAN_MAX_IE_LEN) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002702 assoc_ind->addIE.addIEdata[rsn_len] =
Srinivas Girigowda61771262019-04-01 11:55:19 -07002703 WLAN_ELEMID_HTCAP_ANA;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002704 assoc_ind->addIE.addIEdata[rsn_len + 1] =
2705 DOT11F_IE_HTCAPS_MIN_LEN;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302706 qdf_mem_copy(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002707 &assoc_ind->addIE.addIEdata[rsn_len+2],
2708 ((uint8_t *)&assoc_req->HTCaps) + 1,
2709 DOT11F_IE_HTCAPS_MIN_LEN);
2710 assoc_ind->addIE.length +=
2711 2 + DOT11F_IE_HTCAPS_MIN_LEN;
2712 } else {
Nishank Aggarwal8935e442017-03-23 19:11:08 +05302713 pe_err("Fail:HT capabilities IE to addIE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002714 }
2715 }
2716
2717 if (assoc_req->wmeInfoPresent) {
Pragaspathi Thilagarajec7dc252018-09-06 15:38:49 +05302718 /* Set whether AP is enabled with WMM or not */
2719 wme_enable = mac_ctx->mlme_cfg->wmm_params.wme_enabled;
2720 assoc_ind->WmmStaInfoPresent = wme_enable;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002721 /*
2722 * Note: we are not rejecting association here
2723 * because IOT will fail
2724 */
2725 }
2726 /* Required for indicating the frames to upper layer */
2727 assoc_ind->assocReqLength = assoc_req->assocReqFrameLength;
2728 assoc_ind->assocReqPtr = assoc_req->assocReqFrame;
2729
2730 assoc_ind->beaconPtr = session_entry->beacon;
2731 assoc_ind->beaconLength = session_entry->bcnLen;
2732
2733 assoc_ind->chan_info.chan_id =
2734 session_entry->currentOperChannel;
2735 assoc_ind->chan_info.mhz =
2736 cds_chan_to_freq(session_entry->currentOperChannel);
2737 assoc_ind->chan_info.band_center_freq1 =
2738 cds_chan_to_freq(session_entry->currentOperChannel);
2739 assoc_ind->chan_info.band_center_freq2 = 0;
2740 assoc_ind->chan_info.reg_info_1 =
2741 (session_entry->maxTxPower << 16);
2742 assoc_ind->chan_info.reg_info_2 =
2743 (session_entry->maxTxPower << 8);
Kanchanapally, Vidyullathae3062812015-05-22 17:28:57 +05302744 assoc_ind->chan_info.nss = sta_ds->nss;
2745 assoc_ind->chan_info.rate_flags =
2746 lim_get_max_rate_flags(mac_ctx, sta_ds);
Will Huang558f8082017-05-31 16:22:24 +08002747 assoc_ind->ampdu = false;
2748 assoc_ind->sgi_enable = false;
2749 assoc_ind->tx_stbc = false;
2750 assoc_ind->rx_stbc = false;
2751 assoc_ind->ch_width = eHT_CHANNEL_WIDTH_20MHZ;
2752 assoc_ind->mode = SIR_SME_PHY_MODE_LEGACY;
2753 assoc_ind->max_supp_idx = 0xff;
2754 assoc_ind->max_ext_idx = 0xff;
2755 assoc_ind->max_mcs_idx = 0xff;
2756 assoc_ind->rx_mcs_map = 0xff;
2757 assoc_ind->tx_mcs_map = 0xff;
2758
2759 if (assoc_req->supportedRates.numRates)
2760 assoc_ind->max_supp_idx =
2761 lim_get_max_rate_idx(
2762 &assoc_req->supportedRates);
2763 if (assoc_req->extendedRates.numRates)
2764 assoc_ind->max_ext_idx =
2765 lim_get_max_rate_idx(
2766 &assoc_req->extendedRates);
2767
2768 if (sta_ds->mlmStaContext.htCapability) {
2769 /* ampdu */
2770 assoc_ind->ampdu = true;
2771
2772 /* sgi */
2773 if (sta_ds->htShortGI20Mhz || sta_ds->htShortGI40Mhz)
2774 assoc_ind->sgi_enable = true;
2775
2776 /* stbc */
2777 assoc_ind->tx_stbc = assoc_req->HTCaps.txSTBC;
2778 assoc_ind->rx_stbc = assoc_req->HTCaps.rxSTBC;
2779
2780 /* ch width */
2781 assoc_ind->ch_width =
2782 sta_ds->htSupportedChannelWidthSet ?
2783 eHT_CHANNEL_WIDTH_40MHZ :
2784 eHT_CHANNEL_WIDTH_20MHZ;
2785
2786 /* mode */
2787 assoc_ind->mode = SIR_SME_PHY_MODE_HT;
2788 maxidx = 0;
2789 for (i = 0; i < 8; i++) {
2790 if (assoc_req->HTCaps.supportedMCSSet[0] &
2791 (1 << i))
2792 maxidx = i;
2793 }
2794 assoc_ind->max_mcs_idx = maxidx;
2795 }
2796 fill_mlm_assoc_ind_vht(assoc_req, sta_ds, assoc_ind);
gaolez7bb1e742017-03-21 16:37:38 +08002797 if (assoc_req->ExtCap.present)
2798 assoc_ind->ecsa_capable =
2799 ((struct s_ext_cap *)assoc_req->ExtCap.bytes)->
2800 ext_chan_switch;
Will Huang558f8082017-05-31 16:22:24 +08002801
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002802 /* updates VHT information in assoc indication */
Ashish Kumar Dhanotiya443d31f2017-10-13 12:41:19 +05302803 qdf_mem_copy(&assoc_ind->vht_caps, &assoc_req->VHTCaps,
2804 sizeof(tDot11fIEVHTCaps));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002805 lim_fill_assoc_ind_vht_info(mac_ctx, session_entry, assoc_req,
Ashish Kumar Dhanotiya443d31f2017-10-13 12:41:19 +05302806 assoc_ind, sta_ds);
Ashish Kumar Dhanotiya6025c702019-03-20 18:48:49 +05302807 assoc_ind->he_caps_present = assoc_req->he_cap.present;
Srinivas Dasari5f528202019-02-11 17:29:43 +05302808 assoc_ind->is_sae_authenticated =
2809 assoc_req->is_sae_authenticated;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002810 lim_post_sme_message(mac_ctx, LIM_MLM_ASSOC_IND,
2811 (uint32_t *) assoc_ind);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302812 qdf_mem_free(assoc_ind);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002813 }
2814 return;
2815}