1 /* 2 * Copyright (c) 2018-2019, 2021 The Linux Foundation. All rights reserved. 3 * Copyright (c) 2021-2024 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 SR_PD_THRESHOLD_MAX -62 40 #define SRG_SPR_ENABLE_POS 30 41 #define SRG_THRESHOLD_MAX_PD_POS 8 42 #define NON_SRG_PD_SR_DISALLOWED 0x02 43 #define HE_SIG_VAL_15_ALLOWED 0x10 44 #define NON_SRG_OFFSET_PRESENT 0x04 45 #define NON_SRG_MAX_PD_OFFSET 20 46 #define SRG_INFO_PRESENT 0x08 47 #define NON_SRG_SPR_ENABLE_POS 31 48 #define NON_SRG_SPR_ENABLE 0x80 49 #define NON_SR_PD_THRESHOLD_DISABLED 0x80 50 #define SR_PADDING_BYTE 8 51 #endif 52 53 54 /** 55 * enum wlan_mlme_peer_param_id - peer param id in mlme layer 56 * @WLAN_MLME_PEER_BW_PUNCTURE: update puncture 20 MHz bitmap 57 * @WLAN_MLME_PEER_MAX: max enumeration 58 */ 59 enum wlan_mlme_peer_param_id { 60 WLAN_MLME_PEER_BW_PUNCTURE, 61 WLAN_MLME_PEER_MAX 62 }; 63 64 /** 65 * wlan_vdev_mlme_get_cmpt_obj - Retrieves MLME component object 66 * from VDEV object 67 * @vdev: pointer to vdev object 68 * 69 * Retrieves MLME component object from VDEV object 70 * 71 * Return: comp handle on SUCCESS 72 * NULL, if it fails to retrieve 73 */ 74 struct vdev_mlme_obj *wlan_vdev_mlme_get_cmpt_obj( 75 struct wlan_objmgr_vdev *vdev); 76 /** 77 * wlan_vdev_mlme_set_ext_hdl - Sets legacy handle 78 * @vdev: pointer to vdev object 79 * @ext_hdl: pointer to legacy handle 80 * 81 * Sets Legacy handle to MLME component object 82 * 83 * Return: 84 */ 85 void wlan_vdev_mlme_set_ext_hdl(struct wlan_objmgr_vdev *vdev, 86 mlme_vdev_ext_t *ext_hdl); 87 88 /** 89 * wlan_vdev_mlme_get_ext_hdl - Returns legacy handle 90 * @vdev: pointer to vdev object 91 * 92 * Retrieves legacy handle from vdev mlme component object 93 * 94 * Return: legacy handle on SUCCESS 95 * NULL, if it fails to retrieve 96 */ 97 mlme_vdev_ext_t *wlan_vdev_mlme_get_ext_hdl(struct wlan_objmgr_vdev *vdev); 98 99 /** 100 * wlan_vdev_mlme_sm_deliver_evt() - Delivers event to VDEV MLME SM 101 * @vdev: Object manager VDEV object 102 * @event: MLME event 103 * @event_data_len: data size 104 * @event_data: event data 105 * 106 * API to dispatch event to VDEV MLME SM with lock acquired 107 * 108 * Return: SUCCESS: on handling event 109 * FAILURE: on ignoring the event 110 */ 111 QDF_STATUS wlan_vdev_mlme_sm_deliver_evt(struct wlan_objmgr_vdev *vdev, 112 enum wlan_vdev_sm_evt event, 113 uint16_t event_data_len, 114 void *event_data); 115 116 /** 117 * wlan_vdev_mlme_sm_deliver_evt_sync() - Delivers event to VDEV MLME SM sync 118 * @vdev: Object manager VDEV object 119 * @event: MLME event 120 * @event_data_len: data size 121 * @event_data: event data 122 * 123 * API to dispatch event to VDEV MLME SM with lock acquired 124 * 125 * Return: SUCCESS: on handling event 126 * FAILURE: on ignoring the event 127 */ 128 QDF_STATUS wlan_vdev_mlme_sm_deliver_evt_sync(struct wlan_objmgr_vdev *vdev, 129 enum wlan_vdev_sm_evt event, 130 uint16_t event_data_len, 131 void *event_data); 132 133 #ifdef SM_ENG_HIST_ENABLE 134 /** 135 * wlan_vdev_mlme_sm_history_print() - Prints SM history 136 * @vdev: Object manager VDEV object 137 * 138 * API to print SM history 139 * 140 * Return: void 141 */ 142 void wlan_vdev_mlme_sm_history_print(struct wlan_objmgr_vdev *vdev); 143 144 #endif 145 146 /** 147 * wlan_vdev_allow_connect_n_tx() - Checks whether VDEV is in operational state 148 * @vdev: Object manager VDEV object 149 * 150 * API to checks the VDEV MLME SM state to allow tx or connections 151 * 152 * Return: SUCCESS: to allow tx or connection 153 * FAILURE: otherwise failure 154 */ 155 QDF_STATUS wlan_vdev_allow_connect_n_tx(struct wlan_objmgr_vdev *vdev); 156 157 /** 158 * wlan_vdev_mlme_is_active() - Checks whether VDEV is in active state 159 * @vdev: Object manager VDEV object 160 * 161 * API to checks the VDEV MLME SM state to check channel is configured in FW 162 * 163 * Return: SUCCESS: valid channel is configured 164 * FAILURE: otherwise failure 165 */ 166 QDF_STATUS wlan_vdev_mlme_is_active(struct wlan_objmgr_vdev *vdev); 167 168 /** 169 * wlan_vdev_chan_config_valid() - Checks whether VDEV chan config valid 170 * @vdev: Object manager VDEV object 171 * 172 * API to checks the VDEV MLME SM state to check channel is configured in Host 173 * 174 * Return: SUCCESS: valid channel is configured 175 * FAILURE: otherwise failure 176 */ 177 QDF_STATUS wlan_vdev_chan_config_valid(struct wlan_objmgr_vdev *vdev); 178 179 /** 180 * wlan_vdev_mlme_is_csa_restart() - Checks whether VDEV MLME SM is in CSA 181 * @vdev: Object manager VDEV object 182 * 183 * API to checks the VDEV MLME SM state for CSA_RESTART substate 184 * 185 * Return: SUCCESS: if it is in CSA_RESTART sub state 186 * FAILURE: otherwise failure 187 */ 188 QDF_STATUS wlan_vdev_mlme_is_csa_restart(struct wlan_objmgr_vdev *vdev); 189 190 /** 191 * wlan_vdev_is_going_down() - Checks whether VDEV is being brought down 192 * @vdev: Object manager VDEV object 193 * 194 * API to checks the VDEV MLME SM state to check VDEV is being brought down 195 * 196 * Return: SUCCESS: valid channel is configured 197 * FAILURE: otherwise failure 198 */ 199 QDF_STATUS wlan_vdev_is_going_down(struct wlan_objmgr_vdev *vdev); 200 201 /** 202 * wlan_vdev_is_mlo_peer_create_allowed() - Checks whether PEER can be created 203 * @vdev: Object manager VDEV object 204 * 205 * API to check the VDEV MLME SM state to allow PEER association in MLD 206 * 207 * Return: SUCCESS: if peer create can be allowed 208 * FAILURE: otherwise failure 209 */ 210 QDF_STATUS wlan_vdev_is_mlo_peer_create_allowed(struct wlan_objmgr_vdev *vdev); 211 212 /** 213 * wlan_vdev_is_restart_progress() - Checks VDEV restart is in progress 214 * @vdev: Object manager VDEV object 215 * 216 * API to check whether restarts is in progress 217 * 218 * Return: SUCCESS: if restart is in progress 219 * FAILURE: otherwise failure 220 */ 221 QDF_STATUS wlan_vdev_is_restart_progress(struct wlan_objmgr_vdev *vdev); 222 223 /** 224 * wlan_vdev_is_dfs_cac_wait() - Checks VDEV is in cac wait state 225 * @vdev: Object manager VDEV object 226 * 227 * API to check whether state is cac wait state 228 * 229 * Return: SUCCESS: if state is cac wait state 230 * FAILURE: otherwise failure 231 */ 232 QDF_STATUS wlan_vdev_is_dfs_cac_wait(struct wlan_objmgr_vdev *vdev); 233 234 /** 235 * wlan_vdev_mlme_cmd_lock - Acquire lock for command queuing atomicity 236 * @vdev: Object manager VDEV object 237 * 238 * API to take VDEV MLME command lock 239 * 240 * Return: void 241 */ 242 void wlan_vdev_mlme_cmd_lock(struct wlan_objmgr_vdev *vdev); 243 244 /** 245 * wlan_vdev_mlme_cmd_unlock - Release lock for command queuing atomicity 246 * @vdev: Object manager VDEV object 247 * 248 * API to release VDEV MLME command lock 249 * 250 * Return: void 251 */ 252 void wlan_vdev_mlme_cmd_unlock(struct wlan_objmgr_vdev *vdev); 253 254 /** 255 * wlan_vdev_mlme_is_scan_allowed() - Checks whether scan is allowed 256 * @vdev: Object manager VDEV object 257 * 258 * API to checks the VDEV MLME SM state to check scan is allowed 259 * 260 * Return: SUCCESS: if scan is allowed 261 * FAILURE: otherwise failure 262 */ 263 QDF_STATUS wlan_vdev_mlme_is_scan_allowed(struct wlan_objmgr_vdev *vdev); 264 265 /** 266 * wlan_vdev_mlme_is_init_state() - Checks whether vdev is in init state 267 * @vdev: Object manager VDEV object 268 * 269 * API to checks the VDEV MLME SM state is in init state or not 270 * 271 * Return: SUCCESS: if vdev is in init state 272 * FAILURE: otherwise failure 273 */ 274 QDF_STATUS wlan_vdev_mlme_is_init_state(struct wlan_objmgr_vdev *vdev); 275 276 /** 277 * wlan_vdev_is_up_active_state() - Checks whether vdev is in up active state 278 * @vdev: Object manager VDEV object 279 * 280 * API to checks the VDEV MLME SM state is in UP ACTIVE state 281 * 282 * Return: SUCCESS: if vdev is in UP ACTIVE state 283 * FAILURE: otherwise failure 284 */ 285 QDF_STATUS wlan_vdev_is_up_active_state(struct wlan_objmgr_vdev *vdev); 286 287 #ifdef WLAN_FEATURE_11BE_MLO 288 /** 289 * wlan_vdev_mlme_get_is_mlo_link() - check if its mlo link vdev 290 * @psoc: PSOC object 291 * @vdev_id: VDEV Id 292 * 293 * Return: True if it is mlo link, otherwise false. 294 */ 295 bool 296 wlan_vdev_mlme_get_is_mlo_link(struct wlan_objmgr_psoc *psoc, 297 uint8_t vdev_id); 298 299 /** 300 * wlan_vdev_mlme_get_is_mlo_vdev() - check if its mlo assoc vdev 301 * @psoc: PSOC object 302 * @vdev_id: VDEV Id 303 * 304 * Return: True if it is mlo link, otherwise false. 305 */ 306 bool 307 wlan_vdev_mlme_get_is_mlo_vdev(struct wlan_objmgr_psoc *psoc, 308 uint8_t vdev_id); 309 #else 310 static inline bool 311 wlan_vdev_mlme_get_is_mlo_link(struct wlan_objmgr_psoc *psoc, 312 uint8_t vdev_id) 313 { 314 return false; 315 } 316 317 static inline bool 318 wlan_vdev_mlme_get_is_mlo_vdev(struct wlan_objmgr_psoc *psoc, 319 uint8_t vdev_id) 320 { 321 return false; 322 } 323 #endif 324 #ifdef WLAN_FEATURE_SR 325 /** 326 * wlan_mlme_update_sr_data() - Updates SR values 327 * @vdev: Object manager VDEV object 328 * @val: SR value 329 * @srg_pd_threshold: SRG PD threshold sent by userspace 330 * @non_srg_pd_threshold: NON SRG PD threshold sent by userspace 331 * @is_sr_enable: SR enable/disable from userspace 332 * 333 * API to Update SR value based on AP advertisement and provided by userspace 334 * 335 * Return: true/flase 336 */ 337 void 338 wlan_mlme_update_sr_data(struct wlan_objmgr_vdev *vdev, int *val, 339 int32_t srg_pd_threshold, int32_t non_srg_pd_threshold, 340 bool is_sr_enable); 341 #else 342 static inline void 343 wlan_mlme_update_sr_data(struct wlan_objmgr_vdev *vdev, int *val, 344 int32_t srg_pd_threshold, int32_t non_srg_pd_threshold, 345 bool is_sr_enable) 346 {} 347 #endif 348 349 /** 350 * wlan_mlme_disable_fd_in_6ghz_band() - Set fd disabled flag in vdev 351 * @vdev: vdev object 352 * @disable_fd: Disable the 6 GHz FD. 353 * 354 * Return: void 355 */ 356 void wlan_mlme_disable_fd_in_6ghz_band(struct wlan_objmgr_vdev *vdev, 357 bool disable_fd); 358 359 /** 360 * wlan_mlme_is_fd_disabled_in_6ghz_band() - Get fd disabled flag fom vdev 361 * @vdev: vdev obj 362 * 363 * Return: true/false 364 */ 365 bool wlan_mlme_is_fd_disabled_in_6ghz_band(struct wlan_objmgr_vdev *vdev); 366 #endif 367