1 /* 2 * Copyright (c) 2012-2015, 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 #include <qdf_event.h> 28 29 #ifdef FEATURE_CM_ENABLE 30 #include <wlan_cm_public_struct.h> 31 32 /* Max candidate/attempts to be tried to connect */ 33 #define CM_MAX_CONNECT_ATTEMPTS 5 34 /* 35 * Default max retry attempts to be tried for a candidate. 36 * In SAE connection this value will be overwritten from the sae_connect_retries 37 * INI 38 */ 39 #define CM_MAX_CANDIDATE_RETRIES 1 40 /* Max time to wait for scan for SSID */ 41 #define CM_SCAN_MAX_TIME 5000 42 /* Max connect/disconnect/roam req that can be queued at a time */ 43 #define CM_MAX_REQ 5 44 45 /** 46 * enum wlan_cm_sm_state - Connection manager states 47 * @WLAN_CM_S_INIT: Default state, IDLE state 48 * @WLAN_CM_S_CONNECTING: State when connect request comes 49 * @WLAN_CM_S_CONNECTED: State when connect is complete 50 * @WLAN_CM_S_DISCONNECTING: State when disconnect request comes 51 * @WLAN_CM_S_ROAMING: State when roaming is in progress 52 * @WLAN_CM_S_MAX: Max State 53 * @WLAN_CM_SS_IDLE: Idle state (no substate) 54 * @WLAN_CM_SS_JOIN_PENDING: Connect request not serialized 55 * @WLAN_CM_SS_SCAN: Scan for SSID state 56 * @WLAN_CM_SS_JOIN_ACTIVE: Conenct request activated 57 * @WLAN_CM_SS_PREAUTH: Roam substate of preauth stage 58 * @WLAN_CM_SS_REASSOC: Roam substate for reassoc state 59 * @WLAN_CM_SS_ROAM_STARTED: Roaming in progress (LFR 3.0) 60 * @WLAN_CM_SS_ROAM_SYNC: Roam sync indication from FW 61 * @WLAN_CM_SS_MAX: Max Substate 62 */ 63 enum wlan_cm_sm_state { 64 WLAN_CM_S_INIT = 0, 65 WLAN_CM_S_CONNECTING = 1, 66 WLAN_CM_S_CONNECTED = 2, 67 WLAN_CM_S_DISCONNECTING = 3, 68 WLAN_CM_S_ROAMING = 4, 69 WLAN_CM_S_MAX = 5, 70 WLAN_CM_SS_IDLE = 6, 71 WLAN_CM_SS_JOIN_PENDING = 7, 72 WLAN_CM_SS_SCAN = 8, 73 WLAN_CM_SS_JOIN_ACTIVE = 9, 74 WLAN_CM_SS_PREAUTH = 10, 75 WLAN_CM_SS_REASSOC = 11, 76 WLAN_CM_SS_ROAM_STARTED = 12, 77 WLAN_CM_SS_ROAM_SYNC = 13, 78 WLAN_CM_SS_MAX = 14, 79 }; 80 81 /** 82 * struct cm_state_sm - connection manager sm 83 * @cm_sm_lock: sm lock 84 * @sm_hdl: sm handlers 85 * @cm_state: current state 86 * @cm_substate: current substate 87 */ 88 struct cm_state_sm { 89 #ifdef WLAN_CM_USE_SPINLOCK 90 qdf_spinlock_t cm_sm_lock; 91 #else 92 qdf_mutex_t cm_sm_lock; 93 #endif 94 struct wlan_sm *sm_hdl; 95 enum wlan_cm_sm_state cm_state; 96 enum wlan_cm_sm_state cm_substate; 97 }; 98 99 /** 100 * struct cm_connect_req - connect req stored in connect manager 101 * @cm_id: Connect manager id 102 * @scan_id: scan id for scan for ssid 103 * @req: connect req from osif 104 * @candidate_list: candidate list 105 * @cur_candidate: current candidate 106 * @cur_candidate_retries: attempts for current candidate 107 * @connect_attempts: number of connect attempts tried 108 */ 109 struct cm_connect_req { 110 wlan_cm_id cm_id; 111 wlan_scan_id scan_id; 112 struct wlan_cm_connect_req req; 113 qdf_list_t *candidate_list; 114 struct scan_cache_node *cur_candidate; 115 uint8_t cur_candidate_retries; 116 uint8_t connect_attempts; 117 }; 118 119 /** 120 * struct cm_disconnect_req - disconnect req 121 * @cm_id: Connect manager id 122 * @req: disconnect connect req from osif 123 */ 124 struct cm_disconnect_req { 125 wlan_cm_id cm_id; 126 struct wlan_cm_disconnect_req req; 127 }; 128 129 /** 130 * struct cm_req - connect manager req 131 * @node: connection manager req node 132 * @cm_id: cm id 133 * @failed_req: set if req failed before serialization, 134 * with a commands pending before it, ie this is the latest command which failed 135 * but still some operation(req) is pending. 136 * @connect_req: connect req 137 * @disconnect_req: disconnect req 138 */ 139 struct cm_req { 140 qdf_list_node_t node; 141 wlan_cm_id cm_id; 142 bool failed_req; 143 union { 144 struct cm_connect_req connect_req; 145 struct cm_disconnect_req discon_req; 146 }; 147 }; 148 149 /** 150 * struct connect_ies - connect related ies stored in vdev, set by osif/user 151 * @auth_ft_ies: auth ft ies received during preauth phase 152 * @reassoc_ft_ies: reassoc ft ies received during reassoc phase 153 * @cck_ie: cck ie for cck connection 154 * @discon_ie: disconnect ie to be sent in disassoc/deauth req 155 */ 156 struct connect_ies { 157 struct element_info auth_ft_ies; 158 struct element_info reassoc_ft_ies; 159 #ifdef FEATURE_WLAN_ESE 160 struct element_info cck_ie; 161 #endif 162 struct element_info discon_ie; 163 }; 164 165 /** 166 * struct cnx_mgr - connect manager req 167 * @vdev: vdev back pointer 168 * @sm: state machine 169 * @active_cm_id: cm_id of the active command, if any active command present 170 * @req_list: connect/disconnect req list 171 * @cm_req_lock: lock to manupulate/read the cm req list 172 * @disconnect_count: disconnect count 173 * @connect_count: connect count 174 * @force_rsne_override: if QCA_WLAN_VENDOR_ATTR_CONFIG_RSN_IE is set by 175 * framework 176 * @req_ie: request ies for connect/disconnect set by osif/user separately from 177 * connect req 178 * @global_cmd_id: global cmd id for getting cm id for connect/disconnect req 179 * @max_connect_attempts: Max attempts to be tried for a connect req 180 * @scan_requester_id: scan requester id. 181 * @disconnect_complete: disconnect completion wait event 182 */ 183 struct cnx_mgr { 184 struct wlan_objmgr_vdev *vdev; 185 struct cm_state_sm sm; 186 wlan_cm_id active_cm_id; 187 qdf_list_t req_list; 188 #ifdef WLAN_CM_USE_SPINLOCK 189 qdf_spinlock_t cm_req_lock; 190 #else 191 qdf_mutex_t cm_req_lock; 192 #endif 193 uint8_t disconnect_count; 194 uint8_t connect_count; 195 bool force_rsne_override; 196 struct connect_ies req_ie; 197 qdf_atomic_t global_cmd_id; 198 uint8_t max_connect_attempts; 199 wlan_scan_requester scan_requester_id; 200 qdf_event_t disconnect_complete; 201 }; 202 203 /** 204 * wlan_cm_init() - Invoke connection manager init 205 * @vdev_mlme_obj: VDEV MLME comp object 206 * 207 * API allocates CM and init 208 * 209 * Return: SUCCESS on successful allocation 210 * FAILURE, if registration fails 211 */ 212 QDF_STATUS wlan_cm_init(struct vdev_mlme_obj *vdev_mlme); 213 214 /** 215 * wlan_cm_deinit() - Invoke connection manager deinit 216 * @vdev_mlme_obj: VDEV MLME comp object 217 * 218 * API destroys CM 219 * 220 * Return: SUCCESS on successful deletion 221 * FAILURE, if deletion fails 222 */ 223 QDF_STATUS wlan_cm_deinit(struct vdev_mlme_obj *vdev_mlme); 224 #else 225 226 static inline QDF_STATUS wlan_cm_init(struct vdev_mlme_obj *vdev_mlme) 227 { 228 return QDF_STATUS_SUCCESS; 229 } 230 231 static inline QDF_STATUS wlan_cm_deinit(struct vdev_mlme_obj *vdev_mlme) 232 { 233 return QDF_STATUS_SUCCESS; 234 } 235 236 #endif /* FEATURE_CM_ENABLE */ 237 238 #endif /* __WLAN_CM_MAIN_H__ */ 239