1 /* 2 * Copyright (c) 2017-2018 The Linux Foundation. All rights reserved. 3 * 4 * Permission to use, copy, modify, and/or distribute this software for 5 * any purpose with or without fee is hereby granted, provided that the 6 * above copyright notice and this permission notice appear in all 7 * copies. 8 * 9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL 10 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED 11 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE 12 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL 13 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR 14 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER 15 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 16 * PERFORMANCE OF THIS SOFTWARE. 17 */ 18 19 /** 20 * DOC: wlan_serialization_api.h 21 * This file provides prototypes of the routines needed for the 22 * external components to utilize the services provided by the 23 * serialization component. 24 */ 25 26 /* Include files */ 27 #ifndef __WLAN_SERIALIZATION_API_H 28 #define __WLAN_SERIALIZATION_API_H 29 30 #include "qdf_status.h" 31 #include "wlan_objmgr_cmn.h" 32 33 /* Preprocessor Definitions and Constants */ 34 35 /* 36 * struct wlan_serialization_queued_cmd_info member queue_type specifies the 37 * below values to cancel the commands in these queues. Setting both the 38 * bits will cancel the commands in both the queues. 39 */ 40 #define WLAN_SERIALIZATION_ACTIVE_QUEUE 0x1 41 #define WLAN_SERIALIZATION_PENDING_QUEUE 0x2 42 43 /** 44 * enum wlan_serialization_cb_reason - reason for calling the callback 45 * @WLAN_SERIALIZATION_REASON_ACTIVATE_CMD: activate the cmd by sending it to FW 46 * @WLAN_SERIALIZATION_REASON_CANCEL_CMD: Cancel the cmd in the pending list 47 * @WLAN_SERIALIZATION_REASON_RELEASE_MEM_CMD:cmd execution complete. Release 48 * the memory allocated while 49 * building the command 50 * @WLAN_SER_CB_ACTIVE_CMD_TIMEOUT: active cmd has been timeout. 51 */ 52 enum wlan_serialization_cb_reason { 53 WLAN_SER_CB_ACTIVATE_CMD, 54 WLAN_SER_CB_CANCEL_CMD, 55 WLAN_SER_CB_RELEASE_MEM_CMD, 56 WLAN_SER_CB_ACTIVE_CMD_TIMEOUT, 57 }; 58 59 /** 60 * struct wlan_serialization_scan_info - Information needed for scan cmd 61 * @is_cac_in_progress: boolean to check the cac status 62 * @is_tdls_in_progress: boolean to check the tdls status 63 * 64 * This information is needed for scan command from other components 65 * to apply the rules and check whether the cmd is allowed or not 66 */ 67 struct wlan_serialization_scan_info { 68 bool is_cac_in_progress; 69 bool is_tdls_in_progress; 70 }; 71 72 /** 73 * union wlan_serialization_rules_info - union of all rules info structures 74 * @scan_info: information needed to apply rules on scan command 75 */ 76 union wlan_serialization_rules_info { 77 struct wlan_serialization_scan_info scan_info; 78 }; 79 80 /** 81 * wlan_serialization_cmd_callback() - Callback registered by the component 82 * @wlan_cmd: Command passed by the component for serialization 83 * @reason: Reason code for which the callback is being called 84 * 85 * Reason specifies the reason for which the callback is being called. callback 86 * should return success or failure based up on overall success of callback. 87 * if callback returns failure then serialization will remove the command from 88 * active queue and proceed for next pending command. 89 * 90 * Return: QDF_STATUS_SUCCESS or QDF_STATUS_E_FAILURE 91 */ 92 typedef QDF_STATUS (*wlan_serialization_cmd_callback) (void *wlan_cmd, 93 enum wlan_serialization_cb_reason reason); 94 95 /** 96 * wlan_serialization_comp_info_cb() - callback to fill the rules information 97 * @vdev: VDEV object for which the command has been received 98 * @comp_info: Information filled by the component 99 * 100 * This callback is registered dynamically by the component with the 101 * serialization component. Serialization component invokes the callback 102 * while applying the rules for a particular command and the component 103 * fills in the required information to apply the rules 104 * 105 * Return: None 106 */ 107 typedef void (*wlan_serialization_comp_info_cb)(struct wlan_objmgr_vdev *vdev, 108 union wlan_serialization_rules_info *comp_info); 109 110 /** 111 * wlan_serialization_apply_rules_cb() - callback per command to apply rules 112 * @comp_info: information needed to apply the rules 113 * 114 * The rules are applied using this callback and decided whether to 115 * allow or deny the command 116 * 117 * Return: true, if rules are successful and cmd can be queued 118 * false, if rules failed and cmd should not be queued 119 */ 120 typedef bool (*wlan_serialization_apply_rules_cb)( 121 union wlan_serialization_rules_info *comp_info, 122 uint8_t comp_id); 123 124 /** 125 * enum wlan_umac_cmd_id - Command Type 126 * @WLAN_SER_CMD_SCAN: Scan command 127 */ 128 enum wlan_serialization_cmd_type { 129 /* all scan command before non-scan */ 130 WLAN_SER_CMD_SCAN, 131 /* all non-scan command below */ 132 WLAN_SER_CMD_NONSCAN, 133 WLAN_SER_CMD_FORCE_DISASSOC, 134 WLAN_SER_CMD_HDD_ISSUED, 135 WLAN_SER_CMD_LOST_LINK1, 136 WLAN_SER_CMD_LOST_LINK2, 137 WLAN_SER_CMD_LOST_LINK3, 138 WLAN_SER_CMD_FORCE_DISASSOC_MIC_FAIL, 139 WLAN_SER_CMD_HDD_ISSUE_REASSOC_SAME_AP, 140 WLAN_SER_CMD_SME_ISSUE_REASSOC_SAME_AP, 141 WLAN_SER_CMD_FORCE_DEAUTH, 142 WLAN_SER_CMD_SME_ISSUE_DISASSOC_FOR_HANDOFF, 143 WLAN_SER_CMD_SME_ISSUE_ASSOC_TO_SIMILAR_AP, 144 WLAN_SER_CMD_SME_ISSUE_IBSS_JOIN_FAIL, 145 WLAN_SER_CMD_FORCE_IBSS_LEAVE, 146 WLAN_SER_CMD_STOP_BSS, 147 WLAN_SER_CMD_SME_ISSUE_FT_REASSOC, 148 WLAN_SER_CMD_FORCE_DISASSOC_STA, 149 WLAN_SER_CMD_FORCE_DEAUTH_STA, 150 WLAN_SER_CMD_PERFORM_PRE_AUTH, 151 WLAN_SER_CMD_WM_STATUS_CHANGE, 152 WLAN_SER_CMD_SET_KEY, 153 WLAN_SER_CMD_NDP_INIT_REQ, 154 WLAN_SER_CMD_NDP_RESP_REQ, 155 WLAN_SER_CMD_NDP_DATA_END_INIT_REQ, 156 WLAN_SER_CMD_ADDTS, 157 WLAN_SER_CMD_DELTS, 158 WLAN_SER_CMD_TDLS_SEND_MGMT, 159 WLAN_SER_CMD_TDLS_ADD_PEER, 160 WLAN_SER_CMD_TDLS_DEL_PEER, 161 WLAN_SER_CMD_TDLS_LINK_EST, 162 WLAN_SER_CMD_SET_HW_MODE, 163 WLAN_SER_CMD_NSS_UPDATE, 164 WLAN_SER_CMD_SET_DUAL_MAC_CONFIG, 165 WLAN_SER_CMD_SET_ANTENNA_MODE, 166 WLAN_SER_CMD_ENTER_BMPS, 167 WLAN_SER_CMD_EXIT_BMPS, 168 WLAN_SER_CMD_ENTER_UAPSD, 169 WLAN_SER_CMD_EXIT_UAPSD, 170 WLAN_SER_CMD_EXIT_WOWL, 171 WLAN_SER_CMD_MAX 172 }; 173 174 /** 175 * enum wlan_serialization_cancel_type - Type of commands to be cancelled 176 * @WLAN_SER_CANCEL_SINGLE_SCAN: Cancel a single scan with a given ID 177 * @WLAN_SER_CANCEL_PDEV_SCANS: Cancel all the scans on a given pdev 178 * @WLAN_SER_CANCEL_VDEV_SCANS: Cancel all the scans on given vdev 179 * @WLAN_SER_CANCEL_NON_SCAN_CMD: Cancel the given non scan command 180 */ 181 enum wlan_serialization_cancel_type { 182 WLAN_SER_CANCEL_SINGLE_SCAN, 183 WLAN_SER_CANCEL_PDEV_SCANS, 184 WLAN_SER_CANCEL_VDEV_SCANS, 185 WLAN_SER_CANCEL_NON_SCAN_CMD, 186 WLAN_SER_CANCEL_MAX, 187 }; 188 189 /** 190 * enum wlan_serialization_status - Return status of cmd serialization request 191 * @WLAN_SER_CMD_PENDING: Command is put into the pending queue 192 * @WLAN_SER_CMD_ACTIVE: Command is activated and put in active queue 193 * @WLAN_SER_CMD_DENIED_RULES_FAILED: Command denied as the rules fail 194 * @WLAN_SER_CMD_DENIED_LIST_FULL: Command denied as the pending list is full 195 * @WLAN_SER_CMD_DENIED_UNSPECIFIED: Command denied due to unknown reason 196 */ 197 enum wlan_serialization_status { 198 WLAN_SER_CMD_PENDING, 199 WLAN_SER_CMD_ACTIVE, 200 WLAN_SER_CMD_DENIED_RULES_FAILED, 201 WLAN_SER_CMD_DENIED_LIST_FULL, 202 WLAN_SER_CMD_DENIED_UNSPECIFIED, 203 }; 204 205 /** 206 * enum wlan_serialization_cmd_status - Return status for a cancel request 207 * @WLAN_SER_CMD_IN_PENDING_LIST: Command cancelled from pending list 208 * @WLAN_SER_CMD_IN_ACTIVE_LIST: Command cancelled from active list 209 * @WLAN_SER_CMDS_IN_ALL_LISTS: Command cancelled from all lists 210 * @WLAN_SER_CMD_NOT_FOUND: Specified command to be cancelled 211 * not found in the lists 212 */ 213 enum wlan_serialization_cmd_status { 214 WLAN_SER_CMD_IN_PENDING_LIST, 215 WLAN_SER_CMD_IN_ACTIVE_LIST, 216 WLAN_SER_CMDS_IN_ALL_LISTS, 217 WLAN_SER_CMD_NOT_FOUND, 218 }; 219 220 /** 221 * struct wlan_serialization_command - Command to be serialized 222 * @wlan_serialization_cmd_type: Type of command 223 * @cmd_id: Command Identifier 224 * @cmd_cb: Command callback 225 * @source: component ID of the source of the command 226 * @is_high_priority: Normal/High Priority at which the cmd has to be queued 227 * @cmd_timeout_cb: Command timeout callback 228 * @cmd_timeout_duration: Timeout duration in milliseconds 229 * @vdev: VDEV object associated to the command 230 * @umac_cmd: Actual command that needs to be sent to WMI/firmware 231 * 232 * Note: Unnamed union has been used in this structure, so that in future if 233 * somebody wants to add pdev or psoc structure then that person can add without 234 * modifying existing code. 235 */ 236 struct wlan_serialization_command { 237 enum wlan_serialization_cmd_type cmd_type; 238 uint32_t cmd_id; 239 wlan_serialization_cmd_callback cmd_cb; 240 enum wlan_umac_comp_id source; 241 bool is_high_priority; 242 uint16_t cmd_timeout_duration; 243 union { 244 struct wlan_objmgr_vdev *vdev; 245 }; 246 void *umac_cmd; 247 }; 248 249 /** 250 * struct wlan_serialization_queued_cmd_info - cmd that has to be cancelled 251 * @requestor: component ID of the source requesting this action 252 * @cmd_type: Command type 253 * @cmd_id: Command ID 254 * @req_type: Commands that need to be cancelled 255 * @vdev: VDEV object associated to the command 256 * @queue_type: Queues from which the command to be cancelled 257 */ 258 struct wlan_serialization_queued_cmd_info { 259 enum wlan_umac_comp_id requestor; 260 enum wlan_serialization_cmd_type cmd_type; 261 uint32_t cmd_id; 262 enum wlan_serialization_cancel_type req_type; 263 union { 264 struct wlan_objmgr_vdev *vdev; 265 }; 266 uint8_t queue_type; 267 }; 268 269 /** 270 * wlan_serialization_cancel_request() - Request to cancel a command 271 * @req: Request information 272 * 273 * This API is used by external components to cancel a command 274 * that is either in the pending or active queue. Based on the 275 * req_type, it is decided whether to use pdev or vdev 276 * object. For all non-scan commands, it will be pdev. 277 * 278 * Return: Status specifying the removal of a command from a certain queue 279 */ 280 enum wlan_serialization_cmd_status 281 wlan_serialization_cancel_request( 282 struct wlan_serialization_queued_cmd_info *req); 283 284 /** 285 * wlan_serialization_remove_cmd() - Request to release a command 286 * @cmd: Command information 287 * 288 * This API is used to release a command sitting in the active 289 * queue upon successful completion of the command 290 * 291 * Return: None 292 */ 293 void wlan_serialization_remove_cmd( 294 struct wlan_serialization_queued_cmd_info *cmd); 295 296 /** 297 * wlan_serialization_flush_cmd() - Request to flush command 298 * @cmd: Command information 299 * 300 * This API is used to flush a cmd sitting in the queue. It 301 * simply flushes the cmd from the queue and does not call 302 * any callbacks in between. If the request is for active 303 * queue, and if the active queue becomes empty upon flush, 304 * then it will pick the next pending cmd and put in the active 305 * queue before returning. 306 * 307 * Return: None 308 */ 309 void wlan_serialization_flush_cmd( 310 struct wlan_serialization_queued_cmd_info *cmd); 311 /** 312 * wlan_serialization_request() - Request to serialize a command 313 * @cmd: Command information 314 * 315 * Return: Status of the serialization request 316 */ 317 enum wlan_serialization_status 318 wlan_serialization_request(struct wlan_serialization_command *cmd); 319 320 /** 321 * wlan_serialization_register_comp_info_cb() - Register component's info 322 * callback 323 * @psoc: PSOC object information 324 * @comp_id: Component ID 325 * @cmd_type: Command Type 326 * @cb: Callback 327 * 328 * This is called from component during its initialization.It initializes 329 * callback handler for given comp_id/cmd_id in a 2-D array. 330 * 331 * Return: QDF Status 332 */ 333 QDF_STATUS 334 wlan_serialization_register_comp_info_cb(struct wlan_objmgr_psoc *psoc, 335 enum wlan_umac_comp_id comp_id, 336 enum wlan_serialization_cmd_type cmd_type, 337 wlan_serialization_comp_info_cb cb); 338 339 /** 340 * wlan_serialization_deregister_comp_info_cb() - Deregister component's info 341 * callback 342 * @psoc: PSOC object information 343 * @comp_id: Component ID 344 * @cmd_type: Command Type 345 * 346 * This routine is called from other component during its de-initialization. 347 * 348 * Return: QDF Status 349 */ 350 QDF_STATUS 351 wlan_serialization_deregister_comp_info_cb(struct wlan_objmgr_psoc *psoc, 352 enum wlan_umac_comp_id comp_id, 353 enum wlan_serialization_cmd_type cmd_type); 354 355 /** 356 * wlan_serialization_register_apply_rules_cb() - Register component's rules 357 * callback 358 * @psoc: PSOC object information 359 * @cmd_type: Command Type 360 * @cb: Callback 361 * 362 * This is called from component during its initialization.It initializes 363 * callback handler for given cmd_type in a 1-D array. 364 * 365 * Return: QDF Status 366 */ 367 QDF_STATUS 368 wlan_serialization_register_apply_rules_cb(struct wlan_objmgr_psoc *psoc, 369 enum wlan_serialization_cmd_type cmd_type, 370 wlan_serialization_apply_rules_cb apply_rules_cb); 371 372 /** 373 * wlan_serialization_deregister_apply_rules_cb() - Deregister component's rules 374 * callback 375 * @psoc: PSOC object information 376 * @cmd_type: Command Type 377 * 378 * This routine is called from other component during its de-initialization. 379 * 380 * Return: QDF Status 381 */ 382 QDF_STATUS 383 wlan_serialization_deregister_apply_rules_cb(struct wlan_objmgr_psoc *psoc, 384 enum wlan_serialization_cmd_type cmd_type); 385 386 /** 387 * @wlan_serialization_init() - Serialization component initialization routine 388 * 389 * Return - QDF Status 390 */ 391 QDF_STATUS wlan_serialization_init(void); 392 393 /** 394 * @wlan_serialization_deinit() - Serialization component de-init routine 395 * 396 * Return - QDF Status 397 */ 398 QDF_STATUS wlan_serialization_deinit(void); 399 400 /** 401 * @wlan_serialization_psoc_open() - Serialization component open routine 402 * 403 * Return - QDF Status 404 */ 405 QDF_STATUS wlan_serialization_psoc_open(struct wlan_objmgr_psoc *psoc); 406 407 /** 408 * @wlan_serialization_psoc_close() - Serialization component close routine 409 * 410 * Return - QDF Status 411 */ 412 QDF_STATUS wlan_serialization_psoc_close(struct wlan_objmgr_psoc *psoc); 413 414 /** 415 * wlan_serialization_vdev_scan_status() - Return the status of the vdev scan 416 * @vdev: VDEV Object 417 * 418 * Return: Status of the scans for the corresponding vdev 419 */ 420 enum wlan_serialization_cmd_status 421 wlan_serialization_vdev_scan_status(struct wlan_objmgr_vdev *vdev); 422 423 /** 424 * wlan_serialization_pdev_scan_status() - Return the status of the pdev scan 425 * @pdev: PDEV Object 426 * 427 * Return: Status of the scans for the corresponding pdev 428 */ 429 enum wlan_serialization_cmd_status 430 wlan_serialization_pdev_scan_status(struct wlan_objmgr_pdev *pdev); 431 432 /** 433 * wlan_serialization_non_scan_cmd_status() - Return status of pdev non-scan cmd 434 * @pdev: PDEV Object 435 * @cmd_id: ID of the command for which the status has to be checked 436 * 437 * Return: Status of the command for the corresponding pdev 438 */ 439 enum wlan_serialization_cmd_status 440 wlan_serialization_non_scan_cmd_status(struct wlan_objmgr_pdev *pdev, 441 enum wlan_serialization_cmd_type cmd_id); 442 443 /** 444 * wlan_serialization_is_cmd_present_in_pending_queue() - Return if the command 445 * is already present in pending queue 446 * @cmd: pointer to serialization command to check 447 * 448 * This API will check if command is present in pending queue. If present 449 * then return true, so use know that it is duplicated command 450 * 451 * Return: true or false 452 */ 453 bool wlan_serialization_is_cmd_present_in_pending_queue( 454 struct wlan_objmgr_psoc *psoc, 455 struct wlan_serialization_command *cmd); 456 /** 457 * wlan_serialization_is_cmd_present_in_active_queue() - Return if the command 458 * is already present in active queue 459 * @cmd: pointer to serialization command to check 460 * 461 * This API will check if command is present in active queue. If present 462 * then return true, so use know that it is duplicated command 463 * 464 * Return: true or false 465 */ 466 bool wlan_serialization_is_cmd_present_in_active_queue( 467 struct wlan_objmgr_psoc *psoc, 468 struct wlan_serialization_command *cmd); 469 470 /** 471 * wlan_serialization_get_scan_cmd_using_scan_id() - Return command which 472 * matches vdev_id and scan_id 473 * @psoc: pointer to soc 474 * @vdev_id: vdev id to pull vdev object 475 * @scan_id: scan id to match 476 * @is_scan_cmd_from_active_queue: to indicate active or pending queue 477 * 478 * This API fetches vdev/pdev object based on vdev_id, loops through scan 479 * command queue and find the command which matches scan id as well as vdev 480 * object. 481 * 482 * Return: pointer to serialization command 483 */ 484 struct wlan_serialization_command* 485 wlan_serialization_get_scan_cmd_using_scan_id( 486 struct wlan_objmgr_psoc *psoc, 487 uint8_t vdev_id, uint16_t scan_id, 488 uint8_t is_scan_cmd_from_active_queue); 489 490 #endif 491