1 /* 2 * Copyright (c) 2020, The Linux Foundation. All rights reserved. 3 * 4 * Permission to use, copy, modify, and/or distribute this software for any 5 * purpose with or without fee is hereby granted, provided that the above 6 * copyright notice and this permission notice appear in all copies. 7 * 8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 11 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 13 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15 */ 16 17 /** 18 * DOC: wlan_cm_main.h 19 * 20 * This header file maintain structures required for connection mgr core 21 */ 22 23 #ifndef __WLAN_CM_MAIN_H__ 24 #define __WLAN_CM_MAIN_H__ 25 26 #include "include/wlan_vdev_mlme.h" 27 28 #ifdef FEATURE_CM_ENABLE 29 #include <wlan_cm_public_struct.h> 30 31 /* Max candidate to be tried to connect */ 32 #define CM_MAX_CANDIDATE_TO_BE_TRIED 5 33 /* Max time to wait for scan for SSID */ 34 #define CM_SCAN_MAX_TIME 5000 35 /* Max connect/disconnect/roam req that can be queued at a time */ 36 #define CM_MAX_REQ 5 37 38 /** 39 * enum wlan_cm_sm_state - Connection manager states 40 * @WLAN_CM_S_INIT: Default state, IDLE state 41 * @WLAN_CM_S_CONNECTING: State when connect request comes 42 * @WLAN_CM_S_CONNECTED: State when connect is complete 43 * @WLAN_CM_S_DISCONNECTING: State when disconnect request comes 44 * @WLAN_CM_S_ROAMING: State when roaming is in progress 45 * @WLAN_CM_S_MAX: Max State 46 * @WLAN_CM_SS_IDLE: Idle state (no substate) 47 * @WLAN_CM_SS_JOIN_PENDING: Connect request not serialized 48 * @WLAN_CM_SS_SCAN: Scan for SSID state 49 * @WLAN_CM_SS_JOIN_ACTIVE: Conenct request activated 50 * @WLAN_CM_SS_PREAUTH: Roam substate of preauth stage 51 * @WLAN_CM_SS_REASSOC: Roam substate for reassoc state 52 * @WLAN_CM_SS_ROAM_STARTED: Roaming in progress (LFR 3.0) 53 * @WLAN_CM_SS_ROAM_SYNC: Roam sync indication from FW 54 * @WLAN_CM_SS_MAX: Max Substate 55 */ 56 enum wlan_cm_sm_state { 57 WLAN_CM_S_INIT = 0, 58 WLAN_CM_S_CONNECTING = 1, 59 WLAN_CM_S_CONNECTED = 2, 60 WLAN_CM_S_DISCONNECTING = 3, 61 WLAN_CM_S_ROAMING = 4, 62 WLAN_CM_S_MAX = 5, 63 WLAN_CM_SS_IDLE = 6, 64 WLAN_CM_SS_JOIN_PENDING = 7, 65 WLAN_CM_SS_SCAN = 8, 66 WLAN_CM_SS_JOIN_ACTIVE = 9, 67 WLAN_CM_SS_PREAUTH = 10, 68 WLAN_CM_SS_REASSOC = 11, 69 WLAN_CM_SS_ROAM_STARTED = 12, 70 WLAN_CM_SS_ROAM_SYNC = 13, 71 WLAN_CM_SS_MAX = 14, 72 }; 73 74 /** 75 * enum wlan_cm_sm_evt - connection manager related events 76 * @WLAN_CM_SM_EV_CONNECT_REQ: Connect request event 77 * @WLAN_CM_SM_EV_SCAN_FOR_SSID: Event for scan for SSID 78 * @WLAN_CM_SM_EV_SCAN_FOR_SSID_SUCCESS: Scan for SSID success event 79 * @WLAN_CM_SM_EV_SCAN_FOR_SSID_FAILURE: Scan for SSID fail event 80 * @WLAN_CM_SM_EV_CONNECT_START_REQ: Connect start request after BSSID list 81 * is prepared 82 * @WLAN_CM_SM_EV_CONNECT_START: Connect request for a particular BSSID 83 * @WLAN_CM_SM_EV_CONNECT_SUCCESS: Connect success 84 * @WLAN_CM_SM_EV_CONNECT_NEXT_CANDIDATE: Select next candidate for connection 85 * @WLAN_CM_SM_EV_CONNECT_FAILURE: Connect failed event 86 * @WLAN_CM_SM_EV_DISCONNECT_REQ: Disconnect request event 87 * @WLAN_CM_SM_EV_DISCONNECT_START_REQ: Start disconnect sequence 88 * @WLAN_CM_SM_EV_DISCONNECT_START: Disconnect process start event 89 * @WLAN_CM_SM_EV_DISCONNECT_DONE: Disconnect done event 90 * @WLAN_CM_SM_EV_ROAM_START: Roam start event 91 * @WLAN_CM_SM_EV_ROAM_SYNC: Roam sync event 92 * @WLAN_CM_SM_EV_ROAM_INVOKE_FAIL: Roam invoke fail event 93 * @WLAN_CM_SM_EV_ROAM_HO_FAIL: Hand off failed event 94 * @WLAN_CM_SM_EV_PREAUTH_DONE: Preauth is completed 95 * @WLAN_CM_SM_EV_GET_NEXT_PREAUTH_AP: Get next candidate as preauth failed 96 * @WLAN_CM_SM_EV_PREAUTH_FAIL: Preauth failed for all candidate 97 * @WLAN_CM_SM_EV_START_REASSOC: Start reassoc after preauth done 98 * @WLAN_CM_SM_EV_REASSOC_DONE: Reassoc completed 99 * @WLAN_CM_SM_EV_REASSOC_FAILURE: Reassoc failed 100 * @WLAN_CM_SM_EV_ROAM_COMPLETE: Roaming completed 101 * @WLAN_CM_SM_EV_CONNECT_TIMEOUT: Connect timeout event 102 * @WLAN_CM_SM_EV_CONNECT_SER_FAIL: Connect request failed to serialize 103 * @WLAN_CM_SM_EV_HW_MODE_CHANGE_FAIL: HW mode change failed event 104 * @WLAN_CM_SM_EV_MAX: Max event 105 */ 106 enum wlan_cm_sm_evt { 107 WLAN_CM_SM_EV_CONNECT_REQ = 0, 108 WLAN_CM_SM_EV_SCAN_FOR_SSID = 1, 109 WLAN_CM_SM_EV_SCAN_FOR_SSID_SUCCESS = 2, 110 WLAN_CM_SM_EV_SCAN_FOR_SSID_FAILURE = 3, 111 WLAN_CM_SM_EV_CONNECT_START_REQ = 4, 112 WLAN_CM_SM_EV_CONNECT_START = 5, 113 WLAN_CM_SM_EV_CONNECT_SUCCESS = 6, 114 WLAN_CM_SM_EV_CONNECT_NEXT_CANDIDATE = 7, 115 WLAN_CM_SM_EV_CONNECT_FAILURE = 8, 116 WLAN_CM_SM_EV_DISCONNECT_REQ = 9, 117 WLAN_CM_SM_EV_DISCONNECT_START_REQ = 10, 118 WLAN_CM_SM_EV_DISCONNECT_START = 11, 119 WLAN_CM_SM_EV_DISCONNECT_DONE = 12, 120 WLAN_CM_SM_EV_ROAM_START = 13, 121 WLAN_CM_SM_EV_ROAM_SYNC = 14, 122 WLAN_CM_SM_EV_ROAM_INVOKE_FAIL = 15, 123 WLAN_CM_SM_EV_ROAM_HO_FAIL = 16, 124 WLAN_CM_SM_EV_PREAUTH_DONE = 17, 125 WLAN_CM_SM_EV_GET_NEXT_PREAUTH_AP = 18, 126 WLAN_CM_SM_EV_PREAUTH_FAIL = 19, 127 WLAN_CM_SM_EV_START_REASSOC = 20, 128 WLAN_CM_SM_EV_REASSOC_DONE = 21, 129 WLAN_CM_SM_EV_REASSOC_FAILURE = 22, 130 WLAN_CM_SM_EV_ROAM_COMPLETE = 23, 131 WLAN_CM_SM_EV_CONNECT_TIMEOUT = 24, 132 WLAN_CM_SM_EV_CONNECT_SER_FAIL = 25, 133 WLAN_CM_SM_EV_HW_MODE_CHANGE_FAIL = 26, 134 WLAN_CM_SM_EV_MAX, 135 }; 136 137 /** 138 * struct cm_state_sm - connection manager sm 139 * @cm_sm_lock: sm lock 140 * @sm_hdl: sm handlers 141 * @cm_state: current state 142 * @cm_substate: current substate 143 */ 144 struct cm_state_sm { 145 #ifdef WLAN_CM_USE_SPINLOCK 146 qdf_spinlock_t cm_sm_lock; 147 #else 148 qdf_mutex_t cm_sm_lock; 149 #endif 150 struct wlan_sm *sm_hdl; 151 enum wlan_cm_sm_state cm_state; 152 enum wlan_cm_sm_state cm_substate; 153 }; 154 155 /** 156 * struct cm_connect_req - connect req stored in connect manager 157 * @cm_id: Connect manager id 158 * @scan_id: scan id for scan for ssid 159 * @scan_timer: timer for scan for ssid to get completed 160 * @hw_mode_timer: timer for hw mode chane to get completed 161 * @req: connect req from osif 162 * @candidate_list: candidate list 163 * @cur_candidate: current candidate 164 */ 165 struct cm_connect_req { 166 uint64_t cm_id; 167 uint64_t scan_id; 168 qdf_timer_t scan_timer; 169 qdf_timer_t hw_mode_timer; 170 struct wlan_cm_connect_req req; 171 qdf_list_t candidate_list; 172 struct scan_cache_node *cur_candidate; 173 }; 174 175 /** 176 * struct cm_disconnect_req - disconnect req 177 * @cm_id: Connect manager id 178 * @req: disconnect connect req from osif 179 */ 180 struct cm_disconnect_req { 181 uint64_t cm_id; 182 struct wlan_cm_disconnect_req req; 183 }; 184 185 /** 186 * struct cm_req - connect manager req 187 * @node: connection manager req node 188 * @source: req source 189 * @cm_id: cm id 190 * @connect_req: connect req 191 * @disconnect_req: disconnect req 192 */ 193 struct cm_req { 194 qdf_list_node_t node; 195 enum wlan_cm_source source; 196 uint64_t cm_id; 197 union { 198 struct cm_connect_req connect_req; 199 struct cm_disconnect_req discon_req; 200 }; 201 }; 202 203 /** 204 * struct connect_req_ies - connect req ies stored in vdev 205 * @additional_assoc_ie: assoc req additional IE to be appended to assoc req 206 * @auth_ft_ies: auth ft ies received during preauth phase 207 * @reassoc_ft_ies: reassoc ft ies received during reassoc phase 208 * @cck_ie: cck ie for cck connection 209 * @forced_rsn_ie: set if force_rsne_override is set from the connect IE. This 210 * is used to store the invalid RSN IE from suplicant to enable testbed STA for 211 * cert cases. 212 */ 213 struct connect_req_ies { 214 struct element_info additional_assoc_ie; 215 struct element_info auth_ft_ies; 216 struct element_info reassoc_ft_ies; 217 struct element_info cck_ie; 218 struct element_info forced_rsn_ie; 219 }; 220 221 #ifdef WLAN_FEATURE_FILS_SK 222 #define CM_FILS_MAX_HLP_DATA_LEN 2048 223 #define MAX_KEK_LENGTH 64 224 #define MAX_TK_LENGTH 32 225 #define MAX_GTK_LENGTH 255 226 227 /** 228 * struct fils_connect_rsp_params - fils related connect rsp params 229 * @fils_pmk: fils pmk 230 * @fils_pmk_len: fils pmk length 231 * @fils_pmkid: fils pmkid 232 * @kek: kek 233 * @kek_len: kek length 234 * @tk: tk 235 * @tk_len: tk length 236 * @gtk: gtk 237 * @gtk_len: gtk length 238 * @dst_mac: dst mac 239 * @src_mac: src mac 240 * @hlp_data: hlp data 241 * @hlp_data_len: hlp data length 242 */ 243 struct fils_connect_rsp_params { 244 uint8_t *fils_pmk; 245 uint8_t fils_pmk_len; 246 uint8_t fils_pmkid[PMKID_LEN]; 247 uint8_t kek[MAX_KEK_LENGTH]; 248 uint8_t kek_len; 249 uint8_t tk[MAX_TK_LENGTH]; 250 uint8_t tk_len; 251 uint8_t gtk[MAX_GTK_LENGTH]; 252 uint8_t gtk_len; 253 struct qdf_mac_addr dst_mac; 254 struct qdf_mac_addr src_mac; 255 uint8_t hlp_data[CM_FILS_MAX_HLP_DATA_LEN]; 256 uint16_t hlp_data_len; 257 }; 258 #endif 259 260 /** 261 * struct connect_rsp_ies - connect rsp ies stored in vdev filled during connect 262 * @bcn_probe_rsp: beacon or probe rsp of connected AP 263 * @assoc_req: assoc req send during conenct 264 * @assoc_rsq: assoc rsp received during connection 265 * @ric_resp_ie: ric ie from assoc resp received during connection 266 * @fills_ie: fills connection ie received during connection 267 */ 268 struct connect_rsp_ies { 269 struct element_info bcn_probe_rsp; 270 struct element_info assoc_req; 271 struct element_info assoc_rsp; 272 struct element_info ric_resp_ie; 273 #ifdef WLAN_FEATURE_FILS_SK 274 struct fils_connect_rsp_params fils_ie; 275 #endif 276 }; 277 278 /** 279 * struct disconnect_ies - disconnect ies stored in vdev filled during 280 * disconnect 281 * @peer_discon_ie: disconnect ie sent by peer to be sent to OSIF 282 * @self_discon_ie: disconnect ie to be sent in disassoc/deauth filled by OSIF 283 */ 284 struct disconnect_ies { 285 struct element_info peer_discon_ie; 286 struct element_info self_discon_ie; 287 }; 288 289 /** 290 * struct cnx_mgr - connect manager req 291 * @vdev: vdev back pointer 292 * @sm: state machine 293 * @req_list: connect/disconnect req list 294 * @disconnect_count: disconnect count 295 * @connect_count: connect count 296 * @force_rsne_override: if QCA_WLAN_VENDOR_ATTR_CONFIG_RSN_IE is set by 297 * framework 298 * @req_ie: request ies for connect 299 * @rsp_ie: connect resp ie 300 * @discon_ie: disconnect IE 301 * @fils_info: fils info for the connect req 302 */ 303 struct cnx_mgr { 304 struct wlan_objmgr_vdev *vdev; 305 struct cm_state_sm sm; 306 qdf_list_t req_list; 307 uint8_t disconnect_count; 308 uint8_t connect_count; 309 bool force_rsne_override; 310 struct connect_req_ies req_ie; 311 struct connect_rsp_ies rsp_ie; 312 struct disconnect_ies discon_ie; 313 #ifdef WLAN_FEATURE_FILS_SK 314 struct wlan_fils_con_info fils_info; 315 #endif 316 }; 317 318 /** 319 * mlme_cm_init() - Invoke connection manager init 320 * @vdev_mlme_obj: VDEV MLME comp object 321 * 322 * API allocates CM and init 323 * 324 * Return: SUCCESS on successful allocation 325 * FAILURE, if registration fails 326 */ 327 QDF_STATUS mlme_cm_init(struct vdev_mlme_obj *vdev_mlme); 328 329 /** 330 * mlme_cm_deinit() - Invoke connection manager deinit 331 * @vdev_mlme_obj: VDEV MLME comp object 332 * 333 * API destroys CM 334 * 335 * Return: SUCCESS on successful deletion 336 * FAILURE, if deletion fails 337 */ 338 QDF_STATUS mlme_cm_deinit(struct vdev_mlme_obj *vdev_mlme); 339 #else 340 341 static inline QDF_STATUS mlme_cm_init(struct vdev_mlme_obj *vdev_mlme) 342 { 343 return QDF_STATUS_SUCCESS; 344 } 345 346 static inline QDF_STATUS mlme_cm_deinit(struct vdev_mlme_obj *vdev_mlme) 347 { 348 return QDF_STATUS_SUCCESS; 349 } 350 351 #endif /* FEATURE_CM_ENABLE */ 352 353 #endif /* __WLAN_CM_MAIN_H__ */ 354