1 /* 2 * Copyright (c) 2018-2019, 2021 The Linux Foundation. All rights reserved. 3 * Copyright (c) 2021-2022 Qualcomm Innovation Center, Inc. All rights reserved. 4 * 5 * Permission to use, copy, modify, and/or distribute this software for any 6 * purpose with or without fee is hereby granted, provided that the above 7 * copyright notice and this permission notice appear in all copies. 8 * 9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 10 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 11 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 12 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 13 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 14 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 15 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 16 */ 17 18 /** 19 * DOC: Define VDEV MLME public APIs 20 */ 21 22 #ifndef _WLAN_VDEV_MLME_API_H_ 23 #define _WLAN_VDEV_MLME_API_H_ 24 25 #include <wlan_ext_mlme_obj_types.h> 26 27 #define WLAN_INVALID_VDEV_ID 255 28 #define WILDCARD_PDEV_ID 0x0 29 30 #ifdef WLAN_FEATURE_SR 31 #define PSR_DISALLOWED 1 32 #define NON_SRG_SPR_ENABLE_SIZE 1 33 #define SR_PARAM_VAL_DBM_UNIT 1 34 #define SR_PARAM_VAL_DBM_POS 29 35 #define NON_SRG_PARAM_VAL_DBM_SIZE 1 36 #define NON_SRG_MAX_PD_OFFSET_POS 0 37 #define NON_SRG_MAX_PD_OFFSET_SIZE 8 38 #define SR_PD_THRESHOLD_MIN -82 39 #define SRG_SPR_ENABLE_POS 30 40 #define SRG_THRESHOLD_MAX_PD_POS 8 41 #define NON_SRG_PD_SR_DISALLOWED 0x02 42 #define HE_SIG_VAL_15_ALLOWED 0x10 43 #define NON_SRG_OFFSET_PRESENT 0x04 44 #define SRG_INFO_PRESENT 0x08 45 #define NON_SRG_SPR_ENABLE_POS 31 46 #define NON_SRG_SPR_ENABLE 0x80 47 #define NON_SR_PD_THRESHOLD_DISABLED 0x80 48 #define SR_PADDING_BYTE 8 49 #endif 50 51 52 /** 53 * enum wlan_mlme_peer_param_id - peer param id in mlme layer 54 * @WLAN_MLME_PEER_BW_PUNCTURE: update puncture 20 MHz bitmap 55 */ 56 enum wlan_mlme_peer_param_id { 57 WLAN_MLME_PEER_BW_PUNCTURE, 58 WLAN_MLME_PEER_MAX 59 }; 60 61 /** 62 * wlan_vdev_mlme_get_cmpt_obj - Retrieves MLME component object 63 * from VDEV object 64 * @vdev: pointer to vdev object 65 * 66 * Retrieves MLME component object from VDEV object 67 * 68 * Return: comp handle on SUCCESS 69 * NULL, if it fails to retrieve 70 */ 71 struct vdev_mlme_obj *wlan_vdev_mlme_get_cmpt_obj( 72 struct wlan_objmgr_vdev *vdev); 73 /** 74 * wlan_vdev_mlme_set_ext_hdl - Sets legacy handle 75 * @vdev: pointer to vdev object 76 * @ext_hdl: pointer to legacy handle 77 * 78 * Sets Legacy handle to MLME component object 79 * 80 * Return: 81 */ 82 void wlan_vdev_mlme_set_ext_hdl(struct wlan_objmgr_vdev *vdev, 83 mlme_vdev_ext_t *ext_hdl); 84 85 /** 86 * wlan_vdev_mlme_get_ext_hdl - Returns legacy handle 87 * @vdev: pointer to vdev object 88 * 89 * Retrieves legacy handle from vdev mlme component object 90 * 91 * Return: legacy handle on SUCCESS 92 * NULL, if it fails to retrieve 93 */ 94 mlme_vdev_ext_t *wlan_vdev_mlme_get_ext_hdl(struct wlan_objmgr_vdev *vdev); 95 96 /** 97 * wlan_vdev_mlme_sm_deliver_evt() - Delivers event to VDEV MLME SM 98 * @vdev: Object manager VDEV object 99 * @event: MLME event 100 * @event_data_len: data size 101 * @event_data: event data 102 * 103 * API to dispatch event to VDEV MLME SM with lock acquired 104 * 105 * Return: SUCCESS: on handling event 106 * FAILURE: on ignoring the event 107 */ 108 QDF_STATUS wlan_vdev_mlme_sm_deliver_evt(struct wlan_objmgr_vdev *vdev, 109 enum wlan_vdev_sm_evt event, 110 uint16_t event_data_len, 111 void *event_data); 112 113 /** 114 * wlan_vdev_mlme_sm_deliver_evt_sync() - Delivers event to VDEV MLME SM sync 115 * @vdev: Object manager VDEV object 116 * @event: MLME event 117 * @event_data_len: data size 118 * @event_data: event data 119 * 120 * API to dispatch event to VDEV MLME SM with lock acquired 121 * 122 * Return: SUCCESS: on handling event 123 * FAILURE: on ignoring the event 124 */ 125 QDF_STATUS wlan_vdev_mlme_sm_deliver_evt_sync(struct wlan_objmgr_vdev *vdev, 126 enum wlan_vdev_sm_evt event, 127 uint16_t event_data_len, 128 void *event_data); 129 130 #ifdef SM_ENG_HIST_ENABLE 131 /** 132 * wlan_vdev_mlme_sm_history_print() - Prints SM history 133 * @vdev: Object manager VDEV object 134 * 135 * API to print SM history 136 * 137 * Return: void 138 */ 139 void wlan_vdev_mlme_sm_history_print(struct wlan_objmgr_vdev *vdev); 140 141 #endif 142 143 /** 144 * wlan_vdev_allow_connect_n_tx() - Checks whether VDEV is in operational state 145 * @vdev: Object manager VDEV object 146 * 147 * API to checks the VDEV MLME SM state to allow tx or connections 148 * 149 * Return: SUCCESS: to allow tx or connection 150 * FAILURE: otherwise failure 151 */ 152 QDF_STATUS wlan_vdev_allow_connect_n_tx(struct wlan_objmgr_vdev *vdev); 153 154 /** 155 * wlan_vdev_mlme_is_active() - Checks whether VDEV is in active state 156 * @vdev: Object manager VDEV object 157 * 158 * API to checks the VDEV MLME SM state to check channel is configured in FW 159 * 160 * Return: SUCCESS: valid channel is configured 161 * FAILURE: otherwise failure 162 */ 163 QDF_STATUS wlan_vdev_mlme_is_active(struct wlan_objmgr_vdev *vdev); 164 165 /** 166 * wlan_vdev_chan_config_valid() - Checks whether VDEV chan config valid 167 * @vdev: Object manager VDEV object 168 * 169 * API to checks the VDEV MLME SM state to check channel is configured in Host 170 * 171 * Return: SUCCESS: valid channel is configured 172 * FAILURE: otherwise failure 173 */ 174 QDF_STATUS wlan_vdev_chan_config_valid(struct wlan_objmgr_vdev *vdev); 175 176 /** 177 * wlan_vdev_mlme_is_csa_restart() - Checks whether VDEV MLME SM is in CSA 178 * @vdev: Object manager VDEV object 179 * 180 * API to checks the VDEV MLME SM state for CSA_RESTART substate 181 * 182 * Return: SUCCESS: if it is in CSA_RESTART sub state 183 * FAILURE: otherwise failure 184 */ 185 QDF_STATUS wlan_vdev_mlme_is_csa_restart(struct wlan_objmgr_vdev *vdev); 186 187 /** 188 * wlan_vdev_is_going_down() - Checks whether VDEV is being brought down 189 * @vdev: Object manager VDEV object 190 * 191 * API to checks the VDEV MLME SM state to check VDEV is being brought down 192 * 193 * Return: SUCCESS: valid channel is configured 194 * FAILURE: otherwise failure 195 */ 196 QDF_STATUS wlan_vdev_is_going_down(struct wlan_objmgr_vdev *vdev); 197 198 /** 199 * wlan_vdev_is_mlo_peer_create_allowed() - Checks whether PEER can be created 200 * @vdev: Object manager VDEV object 201 * 202 * API to check the VDEV MLME SM state to allow PEER association in MLD 203 * 204 * Return: SUCCESS: if peer create can be allowed 205 * FAILURE: otherwise failure 206 */ 207 QDF_STATUS wlan_vdev_is_mlo_peer_create_allowed(struct wlan_objmgr_vdev *vdev); 208 209 /** 210 * wlan_vdev_is_restart_progress() - Checks VDEV restart is in progress 211 * @vdev: Object manager VDEV object 212 * 213 * API to check whether restarts is in progress 214 * 215 * Return: SUCCESS: if restart is in progress 216 * FAILURE: otherwise failure 217 */ 218 QDF_STATUS wlan_vdev_is_restart_progress(struct wlan_objmgr_vdev *vdev); 219 220 /** 221 * wlan_vdev_is_dfs_cac_wait() - Checks VDEV is in cac wait state 222 * @vdev: Object manager VDEV object 223 * 224 * API to check whether state is cac wait state 225 * 226 * Return: SUCCESS: if state is cac wait state 227 * FAILURE: otherwise failure 228 */ 229 QDF_STATUS wlan_vdev_is_dfs_cac_wait(struct wlan_objmgr_vdev *vdev); 230 231 /** 232 * wlan_vdev_mlme_cmd_lock - Acquire lock for command queuing atomicity 233 * vdev: Object manager VDEV object 234 * 235 * API to take VDEV MLME command lock 236 * 237 * Return: void 238 */ 239 void wlan_vdev_mlme_cmd_lock(struct wlan_objmgr_vdev *vdev); 240 241 /** 242 * wlan_vdev_mlme_cmd_unlock - Release lock for command queuing atomicity 243 * vdev: Object manager VDEV object 244 * 245 * API to release VDEV MLME command lock 246 * 247 * Return: void 248 */ 249 void wlan_vdev_mlme_cmd_unlock(struct wlan_objmgr_vdev *vdev); 250 251 /** 252 * wlan_vdev_mlme_is_scan_allowed() - Checks whether scan is allowed 253 * @vdev: Object manager VDEV object 254 * 255 * API to checks the VDEV MLME SM state to check scan is allowed 256 * 257 * Return: SUCCESS: if scan is allowed 258 * FAILURE: otherwise failure 259 */ 260 QDF_STATUS wlan_vdev_mlme_is_scan_allowed(struct wlan_objmgr_vdev *vdev); 261 262 /** 263 * wlan_vdev_mlme_is_init_state() - Checks whether vdev is in init state 264 * @vdev: Object manager VDEV object 265 * 266 * API to checks the VDEV MLME SM state is in init state or not 267 * 268 * Return: SUCCESS: if vdev is in init state 269 * FAILURE: otherwise failure 270 */ 271 QDF_STATUS wlan_vdev_mlme_is_init_state(struct wlan_objmgr_vdev *vdev); 272 273 /** 274 * wlan_vdev_is_up_active_state() - Checks whether vdev is in up active state 275 * @vdev: Object manager VDEV object 276 * 277 * API to checks the VDEV MLME SM state is in UP ACTIVE state 278 * 279 * Return: SUCCESS: if vdev is in UP ACTIVE state 280 * FAILURE: otherwise failure 281 */ 282 QDF_STATUS wlan_vdev_is_up_active_state(struct wlan_objmgr_vdev *vdev); 283 284 #ifdef WLAN_FEATURE_11BE_MLO 285 /** 286 * wlan_vdev_mlme_get_is_mlo_link() - check if its mlo link vdev 287 * @psoc: PSOC object 288 * @vdev_id: VDEV Id 289 * 290 * Return: True if it is mlo link, otherwise false. 291 */ 292 bool 293 wlan_vdev_mlme_get_is_mlo_link(struct wlan_objmgr_psoc *psoc, 294 uint8_t vdev_id); 295 296 /** 297 * wlan_vdev_mlme_get_is_mlo_vdev() - check if its mlo assoc vdev 298 * @psoc: PSOC object 299 * @vdev_id: VDEV Id 300 * 301 * Return: True if it is mlo link, otherwise false. 302 */ 303 bool 304 wlan_vdev_mlme_get_is_mlo_vdev(struct wlan_objmgr_psoc *psoc, 305 uint8_t vdev_id); 306 #else 307 static inline bool 308 wlan_vdev_mlme_get_is_mlo_link(struct wlan_objmgr_psoc *psoc, 309 uint8_t vdev_id) 310 { 311 return false; 312 } 313 314 static inline bool 315 wlan_vdev_mlme_get_is_mlo_vdev(struct wlan_objmgr_psoc *psoc, 316 uint8_t vdev_id) 317 { 318 return false; 319 } 320 #endif 321 #ifdef WLAN_FEATURE_SR 322 /** 323 * wlan_mlme_update_sr_data() - Updates SR values 324 * @vdev: Object manager VDEV object 325 * @val: SR value 326 * @srg_pd_threshold: SRG PD threshold sent by userspace 327 * @non_srg_pd_threshold: NON SRG PD threshold sent by userspace 328 * @is_sr_enable: SR enable/disable from userspace 329 * 330 * API to Update SR value based on AP advertisement and provided by userspace 331 * 332 * Return: true/flase 333 */ 334 void 335 wlan_mlme_update_sr_data(struct wlan_objmgr_vdev *vdev, int *val, 336 int32_t srg_pd_threshold, int32_t non_srg_pd_threshold, 337 bool is_sr_enable); 338 #else 339 static inline void 340 wlan_mlme_update_sr_data(struct wlan_objmgr_vdev *vdev, int *val, 341 int32_t srg_pd_threshold, int32_t non_srg_pd_threshold, 342 bool is_sr_enable) 343 {} 344 #endif 345 #endif 346