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 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 * struct cm_state_sm - connection manager sm 76 * @cm_sm_lock: sm lock 77 * @sm_hdl: sm handlers 78 * @cm_state: current state 79 * @cm_substate: current substate 80 */ 81 struct cm_state_sm { 82 #ifdef WLAN_CM_USE_SPINLOCK 83 qdf_spinlock_t cm_sm_lock; 84 #else 85 qdf_mutex_t cm_sm_lock; 86 #endif 87 struct wlan_sm *sm_hdl; 88 enum wlan_cm_sm_state cm_state; 89 enum wlan_cm_sm_state cm_substate; 90 }; 91 92 /** 93 * struct cm_connect_req - connect req stored in connect manager 94 * @cm_id: Connect manager id 95 * @scan_id: scan id for scan for ssid 96 * @scan_timer: timer for scan for ssid to get completed 97 * @hw_mode_timer: timer for hw mode chane to get completed 98 * @req: connect req from osif 99 * @rsn_ie: rsn_ie in connect req 100 * @candidate_list: candidate list 101 * @cur_candidate: current candidate 102 */ 103 struct cm_connect_req { 104 wlan_cm_id cm_id; 105 wlan_scan_id scan_id; 106 qdf_timer_t scan_timer; 107 qdf_timer_t hw_mode_timer; 108 struct wlan_cm_connect_req req; 109 struct element_info rsn_ie; 110 qdf_list_t *candidate_list; 111 struct scan_cache_node *cur_candidate; 112 }; 113 114 /** 115 * struct cm_disconnect_req - disconnect req 116 * @cm_id: Connect manager id 117 * @req: disconnect connect req from osif 118 */ 119 struct cm_disconnect_req { 120 wlan_cm_id cm_id; 121 struct wlan_cm_disconnect_req req; 122 }; 123 124 /** 125 * struct cm_req - connect manager req 126 * @node: connection manager req node 127 * @source: req source 128 * @cm_id: cm id 129 * @connect_req: connect req 130 * @disconnect_req: disconnect req 131 */ 132 struct cm_req { 133 qdf_list_node_t node; 134 enum wlan_cm_source source; 135 wlan_cm_id cm_id; 136 union { 137 struct cm_connect_req connect_req; 138 struct cm_disconnect_req discon_req; 139 }; 140 }; 141 142 /** 143 * struct connect_ies - connect related ies stored in vdev, set by osif/user 144 * @auth_ft_ies: auth ft ies received during preauth phase 145 * @reassoc_ft_ies: reassoc ft ies received during reassoc phase 146 * @cck_ie: cck ie for cck connection 147 * @discon_ie: disconnect ie to be sent in disassoc/deauth req 148 */ 149 struct connect_ies { 150 struct element_info auth_ft_ies; 151 struct element_info reassoc_ft_ies; 152 #ifdef FEATURE_WLAN_ESE 153 struct element_info cck_ie; 154 #endif 155 struct element_info discon_ie; 156 }; 157 158 /** 159 * struct cnx_mgr - connect manager req 160 * @vdev: vdev back pointer 161 * @sm: state machine 162 * @req_list: connect/disconnect req list 163 * @disconnect_count: disconnect count 164 * @connect_count: connect count 165 * @force_rsne_override: if QCA_WLAN_VENDOR_ATTR_CONFIG_RSN_IE is set by 166 * framework 167 * @req_ie: request ies for connect/disconnect set by osif/user separately from 168 * connect req 169 */ 170 struct cnx_mgr { 171 struct wlan_objmgr_vdev *vdev; 172 struct cm_state_sm sm; 173 qdf_list_t req_list; 174 uint8_t disconnect_count; 175 uint8_t connect_count; 176 bool force_rsne_override; 177 struct connect_ies req_ie; 178 }; 179 180 /** 181 * wlan_cm_init() - Invoke connection manager init 182 * @vdev_mlme_obj: VDEV MLME comp object 183 * 184 * API allocates CM and init 185 * 186 * Return: SUCCESS on successful allocation 187 * FAILURE, if registration fails 188 */ 189 QDF_STATUS wlan_cm_init(struct vdev_mlme_obj *vdev_mlme); 190 191 /** 192 * wlan_cm_deinit() - Invoke connection manager deinit 193 * @vdev_mlme_obj: VDEV MLME comp object 194 * 195 * API destroys CM 196 * 197 * Return: SUCCESS on successful deletion 198 * FAILURE, if deletion fails 199 */ 200 QDF_STATUS wlan_cm_deinit(struct vdev_mlme_obj *vdev_mlme); 201 #else 202 203 static inline QDF_STATUS wlan_cm_init(struct vdev_mlme_obj *vdev_mlme) 204 { 205 return QDF_STATUS_SUCCESS; 206 } 207 208 static inline QDF_STATUS wlan_cm_deinit(struct vdev_mlme_obj *vdev_mlme) 209 { 210 return QDF_STATUS_SUCCESS; 211 } 212 213 #endif /* FEATURE_CM_ENABLE */ 214 215 #endif /* __WLAN_CM_MAIN_H__ */ 216