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 successfull 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 WLAN_SER_CMD_SCAN_OTHER, 132 WLAN_SER_CMD_SCAN_LOST_LINK1, 133 WLAN_SER_CMD_SCAN_LOST_LINK2, 134 WLAN_SER_CMD_SCAN_LOST_LINK3, 135 WLAN_SER_CMD_SCAN_11D_TYPE1, 136 WLAN_SER_CMD_SCAN_11D_TYPE2, 137 WLAN_SER_CMD_SCAN_11D_DONE, 138 WLAN_SER_CMD_SCAN_USER_REQ, 139 WLAN_SER_CMD_SCAN_FOR_SSID, 140 WLAN_SER_CMD_SCAN_PROBE_BSS, 141 WLAN_SER_CMD_SCAN_ABORT_NORMAL_SCAN, 142 WLAN_SER_CMD_SCAN_P2P_FIND_PEER, 143 WLAN_SER_CMD_SCAN_CANDIDATE_FOUND, 144 WLAN_SER_CMD_REMAIN_ON_CHANNEL, 145 /* all non-scan command below */ 146 WLAN_SER_CMD_NONSCAN, 147 WLAN_SER_CMD_FORCE_DISASSOC, 148 WLAN_SER_CMD_HDD_ISSUED, 149 WLAN_SER_CMD_LOST_LINK1, 150 WLAN_SER_CMD_LOST_LINK2, 151 WLAN_SER_CMD_LOST_LINK3, 152 WLAN_SER_CMD_FORCE_DISASSOC_MIC_FAIL, 153 WLAN_SER_CMD_HDD_ISSUE_REASSOC_SAME_AP, 154 WLAN_SER_CMD_SME_ISSUE_REASSOC_SAME_AP, 155 WLAN_SER_CMD_SME_ISSUE_REASSOC_DIFF_AP, 156 WLAN_SER_CMD_FORCE_DEAUTH, 157 WLAN_SER_CMD_SME_ISSUE_DISASSOC_FOR_HANDOFF, 158 WLAN_SER_CMD_SME_ISSUE_ASSOC_TO_SIMILAR_AP, 159 WLAN_SER_CMD_SME_ISSUE_IBSS_JOIN_FAIL, 160 WLAN_SER_CMD_FORCE_IBSS_LEAVE, 161 WLAN_SER_CMD_STOP_BSS, 162 WLAN_SER_CMD_SME_ISSUE_FT_REASSOC, 163 WLAN_SER_CMD_FORCE_DISASSOC_STA, 164 WLAN_SER_CMD_FORCE_DEAUTH_STA, 165 WLAN_SER_CMD_PERFORM_PRE_AUTH, 166 WLAN_SER_CMD_LOST_LINK1_ABORT, 167 WLAN_SER_CMD_LOST_LINK2_ABORT, 168 WLAN_SER_CMD_LOST_LINK3_ABORT, 169 WLAN_SER_CMD_WM_STATUS_CHANGE, 170 WLAN_SER_CMD_SET_KEY, 171 WLAN_SER_CMD_NDP_INIT_REQ, 172 WLAN_SER_CMD_NDP_RESP_REQ, 173 WLAN_SER_CMD_NDP_DATA_END_INIT_REQ, 174 WLAN_SER_CMD_ENTER_STANDBY, 175 WLAN_SER_CMD_ADDTS, 176 WLAN_SER_CMD_DELTS, 177 WLAN_SER_CMD_TDLS_SEND_MGMT, 178 WLAN_SER_CMD_TDLS_ADD_PEER, 179 WLAN_SER_CMD_TDLS_DEL_PEER, 180 WLAN_SER_CMD_TDLS_LINK_EST, 181 WLAN_SER_CMD_SET_HW_MODE, 182 WLAN_SER_CMD_NSS_UPDATE, 183 WLAN_SER_CMD_SET_DUAL_MAC_CONFIG, 184 WLAN_SER_CMD_SET_ANTENNA_MODE, 185 WLAN_SER_CMD_ENTER_BMPS, 186 WLAN_SER_CMD_EXIT_BMPS, 187 WLAN_SER_CMD_ENTER_UAPSD, 188 WLAN_SER_CMD_EXIT_UAPSD, 189 WLAN_SER_CMD_EXIT_WOWL, 190 WLAN_SER_CMD_MAX 191 }; 192 193 /** 194 * enum wlan_serialization_cancel_type - Type of commands to be cancelled 195 * @WLAN_SER_CANCEL_SINGLE_SCAN: Cancel a single scan with a given ID 196 * @WLAN_SER_CANCEL_PDEV_SCANS: Cancel all the scans on a given pdev 197 * @WLAN_SER_CANCEL_VDEV_SCANS: Cancel all the scans on given vdev 198 * @WLAN_SER_CANCEL_NON_SCAN_CMD: Cancel the given non scan command 199 */ 200 enum wlan_serialization_cancel_type { 201 WLAN_SER_CANCEL_SINGLE_SCAN, 202 WLAN_SER_CANCEL_PDEV_SCANS, 203 WLAN_SER_CANCEL_VDEV_SCANS, 204 WLAN_SER_CANCEL_NON_SCAN_CMD, 205 WLAN_SER_CANCEL_MAX, 206 }; 207 208 /** 209 * enum wlan_serialization_status - Return status of cmd serialization request 210 * @WLAN_SER_CMD_PENDING: Command is put into the pending queue 211 * @WLAN_SER_CMD_ACTIVE: Command is activated and put in active queue 212 * @WLAN_SER_CMD_DENIED_RULES_FAILED: Command denied as the rules fail 213 * @WLAN_SER_CMD_DENIED_LIST_FULL: Command denied as the pending list is full 214 * @WLAN_SER_CMD_DENIED_UNSPECIFIED: Command denied due to unknown reason 215 */ 216 enum wlan_serialization_status { 217 WLAN_SER_CMD_PENDING, 218 WLAN_SER_CMD_ACTIVE, 219 WLAN_SER_CMD_DENIED_RULES_FAILED, 220 WLAN_SER_CMD_DENIED_LIST_FULL, 221 WLAN_SER_CMD_DENIED_UNSPECIFIED, 222 }; 223 224 /** 225 * enum wlan_serialization_cmd_status - Return status for a cancel request 226 * @WLAN_SER_CMD_IN_PENDING_LIST: Command cancelled from pending list 227 * @WLAN_SER_CMD_IN_ACTIVE_LIST: Command cancelled from active list 228 * @WLAN_SER_CMDS_IN_ALL_LISTS: Command cancelled from all lists 229 * @WLAN_SER_CMD_NOT_FOUND: Specified command to be cancelled 230 * not found in the lists 231 */ 232 enum wlan_serialization_cmd_status { 233 WLAN_SER_CMD_IN_PENDING_LIST, 234 WLAN_SER_CMD_IN_ACTIVE_LIST, 235 WLAN_SER_CMDS_IN_ALL_LISTS, 236 WLAN_SER_CMD_NOT_FOUND, 237 }; 238 239 /** 240 * struct wlan_serialization_command - Command to be serialized 241 * @wlan_serialization_cmd_type: Type of command 242 * @cmd_id: Command Identifier 243 * @cmd_cb: Command callback 244 * @source: component ID of the source of the command 245 * @is_high_priority: Normal/High Priority at which the cmd has to be queued 246 * @cmd_timeout_cb: Command timeout callback 247 * @cmd_timeout_duration: Timeout duration in milliseconds 248 * @vdev: VDEV object associated to the command 249 * @umac_cmd: Actual command that needs to be sent to WMI/firmware 250 * 251 * Note: Unnamed union has been used in this structure, so that in future if 252 * somebody wants to add pdev or psoc structure then that person can add without 253 * modifying existing code. 254 */ 255 struct wlan_serialization_command { 256 enum wlan_serialization_cmd_type cmd_type; 257 uint32_t cmd_id; 258 wlan_serialization_cmd_callback cmd_cb; 259 enum wlan_umac_comp_id source; 260 bool is_high_priority; 261 uint16_t cmd_timeout_duration; 262 union { 263 struct wlan_objmgr_vdev *vdev; 264 }; 265 void *umac_cmd; 266 }; 267 268 /** 269 * struct wlan_serialization_queued_cmd_info - cmd that has to be cancelled 270 * @requestor: component ID of the source requesting this action 271 * @cmd_type: Command type 272 * @cmd_id: Command ID 273 * @req_type: Commands that need to be cancelled 274 * @vdev: VDEV object associated to the command 275 * @queue_type: Queues from which the command to be cancelled 276 */ 277 struct wlan_serialization_queued_cmd_info { 278 enum wlan_umac_comp_id requestor; 279 enum wlan_serialization_cmd_type cmd_type; 280 uint32_t cmd_id; 281 enum wlan_serialization_cancel_type req_type; 282 union { 283 struct wlan_objmgr_vdev *vdev; 284 }; 285 uint8_t queue_type; 286 }; 287 288 /** 289 * wlan_serialization_cancel_request() - Request to cancel a command 290 * @req: Request information 291 * 292 * This API is used by external components to cancel a command 293 * that is either in the pending or active queue. Based on the 294 * req_type, it is decided whether to use pdev or vdev 295 * object. For all non-scan commands, it will be pdev. 296 * 297 * Return: Status specifying the removal of a command from a certain queue 298 */ 299 enum wlan_serialization_cmd_status 300 wlan_serialization_cancel_request( 301 struct wlan_serialization_queued_cmd_info *req); 302 303 /** 304 * wlan_serialization_remove_cmd() - Request to release a command 305 * @cmd: Command information 306 * 307 * This API is used to release a command sitting in the active 308 * queue upon successful completion of the command 309 * 310 * Return: None 311 */ 312 void wlan_serialization_remove_cmd( 313 struct wlan_serialization_queued_cmd_info *cmd); 314 315 /** 316 * wlan_serialization_flush_cmd() - Request to flush command 317 * @cmd: Command information 318 * 319 * This API is used to flush a cmd sitting in the queue. It 320 * simply flushes the cmd from the queue and does not call 321 * any callbacks in between. If the request is for active 322 * queue, and if the active queue becomes empty upon flush, 323 * then it will pick the next pending cmd and put in the active 324 * queue before returning. 325 * 326 * Return: None 327 */ 328 void wlan_serialization_flush_cmd( 329 struct wlan_serialization_queued_cmd_info *cmd); 330 /** 331 * wlan_serialization_request() - Request to serialize a command 332 * @cmd: Command information 333 * 334 * Return: Status of the serialization request 335 */ 336 enum wlan_serialization_status 337 wlan_serialization_request(struct wlan_serialization_command *cmd); 338 339 /** 340 * wlan_serialization_register_comp_info_cb() - Register component's info 341 * callback 342 * @psoc: PSOC object information 343 * @comp_id: Component ID 344 * @cmd_type: Command Type 345 * @cb: Callback 346 * 347 * This is called from component during its initialization.It initializes 348 * callback handler for given comp_id/cmd_id in a 2-D array. 349 * 350 * Return: QDF Status 351 */ 352 QDF_STATUS 353 wlan_serialization_register_comp_info_cb(struct wlan_objmgr_psoc *psoc, 354 enum wlan_umac_comp_id comp_id, 355 enum wlan_serialization_cmd_type cmd_type, 356 wlan_serialization_comp_info_cb cb); 357 358 /** 359 * wlan_serialization_deregister_comp_info_cb() - Deregister component's info 360 * callback 361 * @psoc: PSOC object information 362 * @comp_id: Component ID 363 * @cmd_type: Command Type 364 * 365 * This routine is called from other component during its de-initialization. 366 * 367 * Return: QDF Status 368 */ 369 QDF_STATUS 370 wlan_serialization_deregister_comp_info_cb(struct wlan_objmgr_psoc *psoc, 371 enum wlan_umac_comp_id comp_id, 372 enum wlan_serialization_cmd_type cmd_type); 373 374 /** 375 * wlan_serialization_register_apply_rules_cb() - Register component's rules 376 * callback 377 * @psoc: PSOC object information 378 * @cmd_type: Command Type 379 * @cb: Callback 380 * 381 * This is called from component during its initialization.It initializes 382 * callback handler for given cmd_type in a 1-D array. 383 * 384 * Return: QDF Status 385 */ 386 QDF_STATUS 387 wlan_serialization_register_apply_rules_cb(struct wlan_objmgr_psoc *psoc, 388 enum wlan_serialization_cmd_type cmd_type, 389 wlan_serialization_apply_rules_cb apply_rules_cb); 390 391 /** 392 * wlan_serialization_deregister_apply_rules_cb() - Deregister component's rules 393 * callback 394 * @psoc: PSOC object information 395 * @cmd_type: Command Type 396 * 397 * This routine is called from other component during its de-initialization. 398 * 399 * Return: QDF Status 400 */ 401 QDF_STATUS 402 wlan_serialization_deregister_apply_rules_cb(struct wlan_objmgr_psoc *psoc, 403 enum wlan_serialization_cmd_type cmd_type); 404 405 /** 406 * @wlan_serialization_init() - Serialization component initialization routine 407 * 408 * Return - QDF Status 409 */ 410 QDF_STATUS wlan_serialization_init(void); 411 412 /** 413 * @wlan_serialization_deinit() - Serialization component de-init routine 414 * 415 * Return - QDF Status 416 */ 417 QDF_STATUS wlan_serialization_deinit(void); 418 419 /** 420 * @wlan_serialization_psoc_open() - Serialization component open routine 421 * 422 * Return - QDF Status 423 */ 424 QDF_STATUS wlan_serialization_psoc_open(struct wlan_objmgr_psoc *psoc); 425 426 /** 427 * @wlan_serialization_psoc_close() - Serialization component close routine 428 * 429 * Return - QDF Status 430 */ 431 QDF_STATUS wlan_serialization_psoc_close(struct wlan_objmgr_psoc *psoc); 432 433 /** 434 * wlan_serialization_vdev_scan_status() - Return the status of the vdev scan 435 * @vdev: VDEV Object 436 * 437 * Return: Status of the scans for the corresponding vdev 438 */ 439 enum wlan_serialization_cmd_status 440 wlan_serialization_vdev_scan_status(struct wlan_objmgr_vdev *vdev); 441 442 /** 443 * wlan_serialization_pdev_scan_status() - Return the status of the pdev scan 444 * @pdev: PDEV Object 445 * 446 * Return: Status of the scans for the corresponding pdev 447 */ 448 enum wlan_serialization_cmd_status 449 wlan_serialization_pdev_scan_status(struct wlan_objmgr_pdev *pdev); 450 451 /** 452 * wlan_serialization_non_scan_cmd_status() - Return status of pdev non-scan cmd 453 * @pdev: PDEV Object 454 * @cmd_id: ID of the command for which the status has to be checked 455 * 456 * Return: Status of the command for the corresponding pdev 457 */ 458 enum wlan_serialization_cmd_status 459 wlan_serialization_non_scan_cmd_status(struct wlan_objmgr_pdev *pdev, 460 enum wlan_serialization_cmd_type cmd_id); 461 462 /** 463 * wlan_serialization_is_cmd_present_in_pending_queue() - Return if the command 464 * is already present in pending queue 465 * @cmd: pointer to serialization command to check 466 * 467 * This API will check if command is present in pending queue. If present 468 * then return true, so use know that it is duplicated command 469 * 470 * Return: true or false 471 */ 472 bool wlan_serialization_is_cmd_present_in_pending_queue( 473 struct wlan_objmgr_psoc *psoc, 474 struct wlan_serialization_command *cmd); 475 /** 476 * wlan_serialization_is_cmd_present_in_active_queue() - Return if the command 477 * is already present in active queue 478 * @cmd: pointer to serialization command to check 479 * 480 * This API will check if command is present in active queue. If present 481 * then return true, so use know that it is duplicated command 482 * 483 * Return: true or false 484 */ 485 bool wlan_serialization_is_cmd_present_in_active_queue( 486 struct wlan_objmgr_psoc *psoc, 487 struct wlan_serialization_command *cmd); 488 489 /** 490 * wlan_serialization_get_scan_cmd_using_scan_id() - Return command which 491 * matches vdev_id and scan_id 492 * @psoc: pointer to soc 493 * @vdev_id: vdev id to pull vdev object 494 * @scan_id: scan id to match 495 * @is_scan_cmd_from_active_queue: to indicate active or pending queue 496 * 497 * This API fetches vdev/pdev object based on vdev_id, loops through scan 498 * command queue and find the command which matches scan id as well as vdev 499 * object. 500 * 501 * Return: pointer to serialization command 502 */ 503 struct wlan_serialization_command* 504 wlan_serialization_get_scan_cmd_using_scan_id( 505 struct wlan_objmgr_psoc *psoc, 506 uint8_t vdev_id, uint16_t scan_id, 507 uint8_t is_scan_cmd_from_active_queue); 508 509 #endif 510