1 /* 2 * Copyright (c) 2017-2019 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 #ifdef CONFIG_SERIALIZATION_V1 31 #include "qdf_status.h" 32 #include "wlan_objmgr_cmn.h" 33 34 /* Preprocessor Definitions and Constants */ 35 36 /* 37 * struct wlan_serialization_queued_cmd_info member queue_type specifies the 38 * below values to cancel the commands in these queues. Setting both the 39 * bits will cancel the commands in both the queues. 40 */ 41 #define WLAN_SERIALIZATION_ACTIVE_QUEUE 0x1 42 #define WLAN_SERIALIZATION_PENDING_QUEUE 0x2 43 44 /** 45 * enum wlan_serialization_cb_reason - reason for calling the callback 46 * @WLAN_SERIALIZATION_REASON_ACTIVATE_CMD: activate the cmd by sending it to FW 47 * @WLAN_SERIALIZATION_REASON_CANCEL_CMD: Cancel the cmd in the pending list 48 * @WLAN_SERIALIZATION_REASON_RELEASE_MEM_CMD:cmd execution complete. Release 49 * the memory allocated while 50 * building the command 51 * @WLAN_SER_CB_ACTIVE_CMD_TIMEOUT: active cmd has been timeout. 52 */ 53 enum wlan_serialization_cb_reason { 54 WLAN_SER_CB_ACTIVATE_CMD, 55 WLAN_SER_CB_CANCEL_CMD, 56 WLAN_SER_CB_RELEASE_MEM_CMD, 57 WLAN_SER_CB_ACTIVE_CMD_TIMEOUT, 58 }; 59 60 /** 61 * struct wlan_serialization_scan_info - Information needed for scan cmd 62 * @is_cac_in_progress: boolean to check the cac status 63 * @is_tdls_in_progress: boolean to check the tdls status 64 * 65 * This information is needed for scan command from other components 66 * to apply the rules and check whether the cmd is allowed or not 67 */ 68 struct wlan_serialization_scan_info { 69 bool is_cac_in_progress; 70 bool is_tdls_in_progress; 71 }; 72 73 /** 74 * union wlan_serialization_rules_info - union of all rules info structures 75 * @scan_info: information needed to apply rules on scan command 76 */ 77 union wlan_serialization_rules_info { 78 struct wlan_serialization_scan_info scan_info; 79 }; 80 81 /** 82 * wlan_serialization_cmd_callback() - Callback registered by the component 83 * @wlan_cmd: Command passed by the component for serialization 84 * @reason: Reason code for which the callback is being called 85 * 86 * Reason specifies the reason for which the callback is being called. callback 87 * should return success or failure based up on overall success of callback. 88 * if callback returns failure then serialization will remove the command from 89 * active queue and proceed for next pending command. 90 * 91 * Return: QDF_STATUS_SUCCESS or QDF_STATUS_E_FAILURE 92 */ 93 typedef QDF_STATUS (*wlan_serialization_cmd_callback) (void *wlan_cmd, 94 enum wlan_serialization_cb_reason reason); 95 96 /** 97 * wlan_serialization_comp_info_cb() - callback to fill the rules information 98 * @vdev: VDEV object for which the command has been received 99 * @comp_info: Information filled by the component 100 * 101 * This callback is registered dynamically by the component with the 102 * serialization component. Serialization component invokes the callback 103 * while applying the rules for a particular command and the component 104 * fills in the required information to apply the rules 105 * 106 * Return: None 107 */ 108 typedef void (*wlan_serialization_comp_info_cb)(struct wlan_objmgr_vdev *vdev, 109 union wlan_serialization_rules_info *comp_info); 110 111 /** 112 * wlan_serialization_apply_rules_cb() - callback per command to apply rules 113 * @comp_info: information needed to apply the rules 114 * 115 * The rules are applied using this callback and decided whether to 116 * allow or deny the command 117 * 118 * Return: true, if rules are successful and cmd can be queued 119 * false, if rules failed and cmd should not be queued 120 */ 121 typedef bool (*wlan_serialization_apply_rules_cb)( 122 union wlan_serialization_rules_info *comp_info, 123 uint8_t comp_id); 124 125 /** 126 * enum wlan_umac_cmd_id - Command Type 127 * @WLAN_SER_CMD_SCAN: Scan command 128 */ 129 enum wlan_serialization_cmd_type { 130 /* all scan command before non-scan */ 131 WLAN_SER_CMD_SCAN, 132 /* all non-scan command below */ 133 WLAN_SER_CMD_NONSCAN, 134 WLAN_SER_CMD_FORCE_DISASSOC, 135 WLAN_SER_CMD_HDD_ISSUED, 136 WLAN_SER_CMD_FORCE_DISASSOC_MIC_FAIL, 137 WLAN_SER_CMD_HDD_ISSUE_REASSOC_SAME_AP, 138 WLAN_SER_CMD_SME_ISSUE_REASSOC_SAME_AP, 139 WLAN_SER_CMD_FORCE_DEAUTH, 140 WLAN_SER_CMD_SME_ISSUE_DISASSOC_FOR_HANDOFF, 141 WLAN_SER_CMD_SME_ISSUE_ASSOC_TO_SIMILAR_AP, 142 WLAN_SER_CMD_FORCE_IBSS_LEAVE, 143 WLAN_SER_CMD_STOP_BSS, 144 WLAN_SER_CMD_SME_ISSUE_FT_REASSOC, 145 WLAN_SER_CMD_FORCE_DISASSOC_STA, 146 WLAN_SER_CMD_FORCE_DEAUTH_STA, 147 WLAN_SER_CMD_PERFORM_PRE_AUTH, 148 WLAN_SER_CMD_WM_STATUS_CHANGE, 149 WLAN_SER_CMD_NDP_INIT_REQ, 150 WLAN_SER_CMD_NDP_RESP_REQ, 151 WLAN_SER_CMD_NDP_DATA_END_INIT_REQ, 152 WLAN_SER_CMD_ADDTS, 153 WLAN_SER_CMD_DELTS, 154 WLAN_SER_CMD_TDLS_SEND_MGMT, 155 WLAN_SER_CMD_TDLS_ADD_PEER, 156 WLAN_SER_CMD_TDLS_DEL_PEER, 157 WLAN_SER_CMD_SET_HW_MODE, 158 WLAN_SER_CMD_NSS_UPDATE, 159 WLAN_SER_CMD_SET_DUAL_MAC_CONFIG, 160 WLAN_SER_CMD_SET_ANTENNA_MODE, 161 WLAN_SER_CMD_DEL_STA_SESSION, 162 WLAN_SER_CMD_MAX 163 }; 164 165 /** 166 * enum wlan_serialization_cancel_type - Type of commands to be cancelled 167 * @WLAN_SER_CANCEL_SINGLE_SCAN: Cancel a single scan with a given ID 168 * @WLAN_SER_CANCEL_PDEV_SCANS: Cancel all the scans on a given pdev 169 * @WLAN_SER_CANCEL_VDEV_SCANS: Cancel all the scans on given vdev 170 * @WLAN_SER_CANCEL_NON_SCAN_CMD: Cancel the given non scan command 171 */ 172 enum wlan_serialization_cancel_type { 173 WLAN_SER_CANCEL_SINGLE_SCAN, 174 WLAN_SER_CANCEL_PDEV_SCANS, 175 WLAN_SER_CANCEL_VDEV_SCANS, 176 WLAN_SER_CANCEL_NON_SCAN_CMD, 177 WLAN_SER_CANCEL_MAX, 178 }; 179 180 /** 181 * enum wlan_serialization_status - Return status of cmd serialization request 182 * @WLAN_SER_CMD_PENDING: Command is put into the pending queue 183 * @WLAN_SER_CMD_ACTIVE: Command is activated and put in active queue 184 * @WLAN_SER_CMD_DENIED_RULES_FAILED: Command denied as the rules fail 185 * @WLAN_SER_CMD_DENIED_LIST_FULL: Command denied as the pending list is full 186 * @WLAN_SER_CMD_DENIED_UNSPECIFIED: Command denied due to unknown reason 187 */ 188 enum wlan_serialization_status { 189 WLAN_SER_CMD_PENDING, 190 WLAN_SER_CMD_ACTIVE, 191 WLAN_SER_CMD_DENIED_RULES_FAILED, 192 WLAN_SER_CMD_DENIED_LIST_FULL, 193 WLAN_SER_CMD_DENIED_UNSPECIFIED, 194 }; 195 196 /** 197 * enum wlan_serialization_cmd_status - Return status for a cancel request 198 * @WLAN_SER_CMD_IN_PENDING_LIST: Command cancelled from pending list 199 * @WLAN_SER_CMD_IN_ACTIVE_LIST: Command cancelled from active list 200 * @WLAN_SER_CMDS_IN_ALL_LISTS: Command cancelled from all lists 201 * @WLAN_SER_CMD_NOT_FOUND: Specified command to be cancelled 202 * not found in the lists 203 */ 204 enum wlan_serialization_cmd_status { 205 WLAN_SER_CMD_IN_PENDING_LIST, 206 WLAN_SER_CMD_IN_ACTIVE_LIST, 207 WLAN_SER_CMDS_IN_ALL_LISTS, 208 WLAN_SER_CMD_NOT_FOUND, 209 }; 210 211 /** 212 * struct wlan_serialization_command - Command to be serialized 213 * @wlan_serialization_cmd_type: Type of command 214 * @cmd_id: Command Identifier 215 * @cmd_cb: Command callback 216 * @source: component ID of the source of the command 217 * @is_high_priority: Normal/High Priority at which the cmd has to be queued 218 * @cmd_timeout_cb: Command timeout callback 219 * @cmd_timeout_duration: Timeout duration in milliseconds 220 * @vdev: VDEV object associated to the command 221 * @umac_cmd: Actual command that needs to be sent to WMI/firmware 222 * 223 * Note: Unnamed union has been used in this structure, so that in future if 224 * somebody wants to add pdev or psoc structure then that person can add without 225 * modifying existing code. 226 */ 227 struct wlan_serialization_command { 228 enum wlan_serialization_cmd_type cmd_type; 229 uint32_t cmd_id; 230 wlan_serialization_cmd_callback cmd_cb; 231 enum wlan_umac_comp_id source; 232 bool is_high_priority; 233 uint16_t cmd_timeout_duration; 234 union { 235 struct wlan_objmgr_vdev *vdev; 236 }; 237 void *umac_cmd; 238 }; 239 240 /** 241 * struct wlan_serialization_queued_cmd_info - cmd that has to be cancelled 242 * @requestor: component ID of the source requesting this action 243 * @cmd_type: Command type 244 * @cmd_id: Command ID 245 * @req_type: Commands that need to be cancelled 246 * @vdev: VDEV object associated to the command 247 * @queue_type: Queues from which the command to be cancelled 248 */ 249 struct wlan_serialization_queued_cmd_info { 250 enum wlan_umac_comp_id requestor; 251 enum wlan_serialization_cmd_type cmd_type; 252 uint32_t cmd_id; 253 enum wlan_serialization_cancel_type req_type; 254 union { 255 struct wlan_objmgr_vdev *vdev; 256 }; 257 uint8_t queue_type; 258 }; 259 260 /** 261 * wlan_serialization_cancel_request() - Request to cancel a command 262 * @req: Request information 263 * 264 * This API is used by external components to cancel a command 265 * that is either in the pending or active queue. Based on the 266 * req_type, it is decided whether to use pdev or vdev 267 * object. For all non-scan commands, it will be pdev. 268 * 269 * Return: Status specifying the removal of a command from a certain queue 270 */ 271 enum wlan_serialization_cmd_status 272 wlan_serialization_cancel_request( 273 struct wlan_serialization_queued_cmd_info *req); 274 275 /** 276 * wlan_serialization_remove_cmd() - Request to release a command 277 * @cmd: Command information 278 * 279 * This API is used to release a command sitting in the active 280 * queue upon successful completion of the command 281 * 282 * Return: None 283 */ 284 void wlan_serialization_remove_cmd( 285 struct wlan_serialization_queued_cmd_info *cmd); 286 287 /** 288 * wlan_serialization_flush_cmd() - Request to flush command 289 * @cmd: Command information 290 * 291 * This API is used to flush a cmd sitting in the queue. It 292 * simply flushes the cmd from the queue and does not call 293 * any callbacks in between. If the request is for active 294 * queue, and if the active queue becomes empty upon flush, 295 * then it will pick the next pending cmd and put in the active 296 * queue before returning. 297 * 298 * Return: None 299 */ 300 void wlan_serialization_flush_cmd( 301 struct wlan_serialization_queued_cmd_info *cmd); 302 /** 303 * wlan_serialization_request() - Request to serialize a command 304 * @cmd: Command information 305 * 306 * Return: Status of the serialization request 307 */ 308 enum wlan_serialization_status 309 wlan_serialization_request(struct wlan_serialization_command *cmd); 310 311 /** 312 * wlan_serialization_register_comp_info_cb() - Register component's info 313 * callback 314 * @psoc: PSOC object information 315 * @comp_id: Component ID 316 * @cmd_type: Command Type 317 * @cb: Callback 318 * 319 * This is called from component during its initialization.It initializes 320 * callback handler for given comp_id/cmd_id in a 2-D array. 321 * 322 * Return: QDF Status 323 */ 324 QDF_STATUS 325 wlan_serialization_register_comp_info_cb(struct wlan_objmgr_psoc *psoc, 326 enum wlan_umac_comp_id comp_id, 327 enum wlan_serialization_cmd_type cmd_type, 328 wlan_serialization_comp_info_cb cb); 329 330 /** 331 * wlan_serialization_deregister_comp_info_cb() - Deregister component's info 332 * callback 333 * @psoc: PSOC object information 334 * @comp_id: Component ID 335 * @cmd_type: Command Type 336 * 337 * This routine is called from other component during its de-initialization. 338 * 339 * Return: QDF Status 340 */ 341 QDF_STATUS 342 wlan_serialization_deregister_comp_info_cb(struct wlan_objmgr_psoc *psoc, 343 enum wlan_umac_comp_id comp_id, 344 enum wlan_serialization_cmd_type cmd_type); 345 346 /** 347 * wlan_serialization_register_apply_rules_cb() - Register component's rules 348 * callback 349 * @psoc: PSOC object information 350 * @cmd_type: Command Type 351 * @cb: Callback 352 * 353 * This is called from component during its initialization.It initializes 354 * callback handler for given cmd_type in a 1-D array. 355 * 356 * Return: QDF Status 357 */ 358 QDF_STATUS 359 wlan_serialization_register_apply_rules_cb(struct wlan_objmgr_psoc *psoc, 360 enum wlan_serialization_cmd_type cmd_type, 361 wlan_serialization_apply_rules_cb apply_rules_cb); 362 363 /** 364 * wlan_serialization_deregister_apply_rules_cb() - Deregister component's rules 365 * callback 366 * @psoc: PSOC object information 367 * @cmd_type: Command Type 368 * 369 * This routine is called from other component during its de-initialization. 370 * 371 * Return: QDF Status 372 */ 373 QDF_STATUS 374 wlan_serialization_deregister_apply_rules_cb(struct wlan_objmgr_psoc *psoc, 375 enum wlan_serialization_cmd_type cmd_type); 376 377 /** 378 * @wlan_serialization_init() - Serialization component initialization routine 379 * 380 * Return - QDF Status 381 */ 382 QDF_STATUS wlan_serialization_init(void); 383 384 /** 385 * @wlan_serialization_deinit() - Serialization component de-init routine 386 * 387 * Return - QDF Status 388 */ 389 QDF_STATUS wlan_serialization_deinit(void); 390 391 /** 392 * @wlan_serialization_psoc_open() - Serialization component open routine 393 * 394 * Return - QDF Status 395 */ 396 QDF_STATUS wlan_serialization_psoc_open(struct wlan_objmgr_psoc *psoc); 397 398 /** 399 * @wlan_serialization_psoc_close() - Serialization component close routine 400 * 401 * Return - QDF Status 402 */ 403 QDF_STATUS wlan_serialization_psoc_close(struct wlan_objmgr_psoc *psoc); 404 405 /** 406 * wlan_serialization_vdev_scan_status() - Return the status of the vdev scan 407 * @vdev: VDEV Object 408 * 409 * Return: Status of the scans for the corresponding vdev 410 */ 411 enum wlan_serialization_cmd_status 412 wlan_serialization_vdev_scan_status(struct wlan_objmgr_vdev *vdev); 413 414 /** 415 * wlan_serialization_pdev_scan_status() - Return the status of the pdev scan 416 * @pdev: PDEV Object 417 * 418 * Return: Status of the scans for the corresponding pdev 419 */ 420 enum wlan_serialization_cmd_status 421 wlan_serialization_pdev_scan_status(struct wlan_objmgr_pdev *pdev); 422 423 /** 424 * wlan_serialization_non_scan_cmd_status() - Return status of pdev non-scan cmd 425 * @pdev: PDEV Object 426 * @cmd_id: ID of the command for which the status has to be checked 427 * 428 * Return: Status of the command for the corresponding pdev 429 */ 430 enum wlan_serialization_cmd_status 431 wlan_serialization_non_scan_cmd_status(struct wlan_objmgr_pdev *pdev, 432 enum wlan_serialization_cmd_type cmd_id); 433 434 /** 435 * wlan_serialization_is_cmd_present_in_pending_queue() - Return if the command 436 * is already present in pending queue 437 * @cmd: pointer to serialization command to check 438 * 439 * This API will check if command is present in pending queue. If present 440 * then return true, so use know that it is duplicated command 441 * 442 * Return: true or false 443 */ 444 bool wlan_serialization_is_cmd_present_in_pending_queue( 445 struct wlan_objmgr_psoc *psoc, 446 struct wlan_serialization_command *cmd); 447 /** 448 * wlan_serialization_is_cmd_present_in_active_queue() - Return if the command 449 * is already present in active queue 450 * @cmd: pointer to serialization command to check 451 * 452 * This API will check if command is present in active queue. If present 453 * then return true, so use know that it is duplicated command 454 * 455 * Return: true or false 456 */ 457 bool wlan_serialization_is_cmd_present_in_active_queue( 458 struct wlan_objmgr_psoc *psoc, 459 struct wlan_serialization_command *cmd); 460 461 /** 462 * wlan_serialization_get_scan_cmd_using_scan_id() - Return command which 463 * matches vdev_id and scan_id 464 * @psoc: pointer to soc 465 * @vdev_id: vdev id to pull vdev object 466 * @scan_id: scan id to match 467 * @is_scan_cmd_from_active_queue: to indicate active or pending queue 468 * 469 * This API fetches vdev/pdev object based on vdev_id, loops through scan 470 * command queue and find the command which matches scan id as well as vdev 471 * object. 472 * 473 * Return: pointer to serialization command 474 */ 475 struct wlan_serialization_command* 476 wlan_serialization_get_scan_cmd_using_scan_id( 477 struct wlan_objmgr_psoc *psoc, 478 uint8_t vdev_id, uint16_t scan_id, 479 uint8_t is_scan_cmd_from_active_queue); 480 /** 481 * wlan_serialization_get_active_cmd() - Return active umac command which 482 * matches vdev and cmd type 483 * @psoc: pointer to soc 484 * @vdev_id: vdev id to pull vdev object 485 * @cmd_type: cmd type to match 486 * 487 * This API fetches vdev/pdev object based on vdev_id, loops through active 488 * command queue and find the active command which matches cmd_type as well 489 * as vdev object. 490 * 491 * Return: Pointer to umac command. NULL is returned if active command of given 492 * type is not found. 493 */ 494 void *wlan_serialization_get_active_cmd(struct wlan_objmgr_psoc *psoc, 495 uint8_t vdev_id, 496 enum wlan_serialization_cmd_type cmd_type); 497 #else /* New serialization code*/ 498 #include <qdf_status.h> 499 #include <wlan_objmgr_cmn.h> 500 501 /* Preprocessor Definitions and Constants */ 502 503 /** 504 * enum ser_queue_reason- reason for changes to serialization queue 505 * @: SER_REQUEST: queue updated for serialization request 506 * @: SER_REMOVE : queue updated for serialization remove request 507 * @: SER_CANCEL : queue updated for serialization cancel request 508 * @: SER_TIMEOUT : queue updated for command timeout 509 * @: SER_ACTIVATION_FAILED : queue updated since command activation failed 510 * @: SER_PENDING_TO_ACTIVE : queue updated for pending to active movement 511 */ 512 enum ser_queue_reason { 513 SER_REQUEST, 514 SER_REMOVE, 515 SER_CANCEL, 516 SER_TIMEOUT, 517 SER_ACTIVATION_FAILED, 518 SER_PENDING_TO_ACTIVE, 519 SER_QUEUE_ACTION_MAX, 520 }; 521 522 /* 523 * struct wlan_serialization_queued_cmd_info member queue_type specifies the 524 * below values to cancel the commands in these queues. Setting both the 525 * bits will cancel the commands in both the queues. 526 */ 527 #define WLAN_SERIALIZATION_ACTIVE_QUEUE 0x1 528 #define WLAN_SERIALIZATION_PENDING_QUEUE 0x2 529 530 /** 531 * enum wlan_serialization_cb_reason - reason for calling the callback 532 * @WLAN_SERIALIZATION_REASON_ACTIVATE_CMD: activate the cmd by sending it to FW 533 * @WLAN_SERIALIZATION_REASON_CANCEL_CMD: Cancel the cmd in the pending list 534 * @WLAN_SERIALIZATION_REASON_RELEASE_MEM_CMD:cmd execution complete. Release 535 * the memory allocated while 536 * building the command 537 * @WLAN_SER_CB_ACTIVE_CMD_TIMEOUT: active cmd has been timeout. 538 */ 539 enum wlan_serialization_cb_reason { 540 WLAN_SER_CB_ACTIVATE_CMD, 541 WLAN_SER_CB_CANCEL_CMD, 542 WLAN_SER_CB_RELEASE_MEM_CMD, 543 WLAN_SER_CB_ACTIVE_CMD_TIMEOUT, 544 }; 545 546 /** 547 * struct wlan_serialization_scan_info - Information needed for scan cmd 548 * @is_cac_in_progress: boolean to check the cac status 549 * @is_tdls_in_progress: boolean to check the tdls status 550 * 551 * This information is needed for scan command from other components 552 * to apply the rules and check whether the cmd is allowed or not 553 */ 554 struct wlan_serialization_scan_info { 555 bool is_cac_in_progress; 556 bool is_tdls_in_progress; 557 }; 558 559 /** 560 * union wlan_serialization_rules_info - union of all rules info structures 561 * @scan_info: information needed to apply rules on scan command 562 */ 563 union wlan_serialization_rules_info { 564 struct wlan_serialization_scan_info scan_info; 565 }; 566 567 /** 568 * wlan_serialization_cmd_callback() - Callback registered by the component 569 * @wlan_cmd: Command passed by the component for serialization 570 * @reason: Reason code for which the callback is being called 571 * 572 * Reason specifies the reason for which the callback is being called. callback 573 * should return success or failure based up on overall success of callback. 574 * if callback returns failure then serialization will remove the command from 575 * active queue and proceed for next pending command. 576 * 577 * Return: QDF_STATUS_SUCCESS or QDF_STATUS_E_FAILURE 578 */ 579 typedef QDF_STATUS (*wlan_serialization_cmd_callback)(void *wlan_cmd, 580 enum wlan_serialization_cb_reason reason); 581 582 /** 583 * wlan_serialization_comp_info_cb() - callback to fill the rules information 584 * @vdev: VDEV object for which the command has been received 585 * @comp_info: Information filled by the component 586 * 587 * This callback is registered dynamically by the component with the 588 * serialization component. Serialization component invokes the callback 589 * while applying the rules for a particular command and the component 590 * fills in the required information to apply the rules 591 * 592 * Return: None 593 */ 594 typedef void (*wlan_serialization_comp_info_cb)(struct wlan_objmgr_vdev *vdev, 595 union wlan_serialization_rules_info *comp_info); 596 597 /** 598 * wlan_serialization_apply_rules_cb() - callback per command to apply rules 599 * @comp_info: information needed to apply the rules 600 * 601 * The rules are applied using this callback and decided whether to 602 * allow or deny the command 603 * 604 * Return: true, if rules are successful and cmd can be queued 605 * false, if rules failed and cmd should not be queued 606 */ 607 typedef bool (*wlan_serialization_apply_rules_cb)( 608 union wlan_serialization_rules_info *comp_info, 609 uint8_t comp_id); 610 611 /** 612 * enum wlan_umac_cmd_id - Command Type 613 * @WLAN_SER_CMD_SCAN: Scan command 614 */ 615 enum wlan_serialization_cmd_type { 616 /* all scan command before non-scan */ 617 WLAN_SER_CMD_SCAN, 618 /* all non-scan command below */ 619 WLAN_SER_CMD_NONSCAN, 620 WLAN_SER_CMD_HDD_ISSUE_REASSOC_SAME_AP, 621 WLAN_SER_CMD_SME_ISSUE_REASSOC_SAME_AP, 622 WLAN_SER_CMD_SME_ISSUE_DISASSOC_FOR_HANDOFF, 623 WLAN_SER_CMD_SME_ISSUE_ASSOC_TO_SIMILAR_AP, 624 WLAN_SER_CMD_FORCE_IBSS_LEAVE, 625 WLAN_SER_CMD_SME_ISSUE_FT_REASSOC, 626 WLAN_SER_CMD_FORCE_DISASSOC_STA, 627 WLAN_SER_CMD_FORCE_DEAUTH_STA, 628 WLAN_SER_CMD_PERFORM_PRE_AUTH, 629 WLAN_SER_CMD_WM_STATUS_CHANGE, 630 WLAN_SER_CMD_NDP_INIT_REQ, 631 WLAN_SER_CMD_NDP_RESP_REQ, 632 WLAN_SER_CMD_NDP_DATA_END_INIT_REQ, 633 WLAN_SER_CMD_ADDTS, 634 WLAN_SER_CMD_DELTS, 635 WLAN_SER_CMD_TDLS_SEND_MGMT, 636 WLAN_SER_CMD_TDLS_ADD_PEER, 637 WLAN_SER_CMD_TDLS_DEL_PEER, 638 WLAN_SER_CMD_SET_HW_MODE, 639 WLAN_SER_CMD_NSS_UPDATE, 640 WLAN_SER_CMD_SET_DUAL_MAC_CONFIG, 641 WLAN_SER_CMD_SET_ANTENNA_MODE, 642 WLAN_SER_CMD_DEL_STA_SESSION, 643 WLAN_SER_CMD_VDEV_START_BSS, 644 WLAN_SER_CMD_VDEV_STOP_BSS, 645 WLAN_SER_CMD_VDEV_CONNECT, 646 WLAN_SER_CMD_VDEV_DISCONNECT, 647 WLAN_SER_CMD_VDEV_RESTART, 648 WLAN_SER_CMD_MAX 649 }; 650 651 /** 652 * enum wlan_serialization_cancel_type - Type of commands to be cancelled 653 * @WLAN_SER_CANCEL_SINGLE_SCAN: Cancel a single scan with a given ID 654 * @WLAN_SER_CANCEL_PDEV_SCANS: Cancel all the scans on a given pdev 655 * @WLAN_SER_CANCEL_VDEV_SCANS: Cancel all the scans on given vdev 656 * @WLAN_SER_CANCEL_PDEV_NON_SCAN_CMD: Cancel all non scans on a given pdev 657 * @WLAN_SER_CANCEL_VDEV_NON_SCAN_CMD: Cancel all non scans on a given vdev 658 * @WLAN_SER_CANCEL_VDEV_NON_SCAN_CMD_TYPE: Cancel all non scans on a given vdev 659 * and matching cmd type 660 * @WLAN_SER_CANCEL_NON_SCAN_CMD: Cancel the given non scan command 661 */ 662 enum wlan_serialization_cancel_type { 663 WLAN_SER_CANCEL_SINGLE_SCAN, 664 WLAN_SER_CANCEL_PDEV_SCANS, 665 WLAN_SER_CANCEL_VDEV_SCANS, 666 WLAN_SER_CANCEL_PDEV_NON_SCAN_CMD, 667 WLAN_SER_CANCEL_VDEV_NON_SCAN_CMD, 668 WLAN_SER_CANCEL_VDEV_NON_SCAN_CMD_TYPE, 669 WLAN_SER_CANCEL_NON_SCAN_CMD, 670 WLAN_SER_CANCEL_MAX, 671 }; 672 673 /** 674 * enum wlan_serialization_status - Return status of cmd serialization request 675 * @WLAN_SER_CMD_PENDING: Command is put into the pending queue 676 * @WLAN_SER_CMD_ACTIVE: Command is activated and put in active queue 677 * @WLAN_SER_CMD_DENIED_RULES_FAILED: Command denied as the rules fail 678 * @WLAN_SER_CMD_DENIED_LIST_FULL: Command denied as the pending list is full 679 * @WLAN_SER_CMD_QUEUE_DISABLED: Command denied as the queue is disabled 680 * @WLAN_SER_CMD_DENIED_UNSPECIFIED: Command denied due to unknown reason 681 */ 682 enum wlan_serialization_status { 683 WLAN_SER_CMD_PENDING, 684 WLAN_SER_CMD_ACTIVE, 685 WLAN_SER_CMD_DENIED_RULES_FAILED, 686 WLAN_SER_CMD_DENIED_LIST_FULL, 687 WLAN_SER_CMD_QUEUE_DISABLED, 688 WLAN_SER_CMD_DENIED_UNSPECIFIED, 689 }; 690 691 /** 692 * enum wlan_serialization_cmd_status - Return status for a cancel request 693 * @WLAN_SER_CMD_IN_PENDING_LIST: Command cancelled from pending list 694 * @WLAN_SER_CMD_IN_ACTIVE_LIST: Command cancelled from active list 695 * @WLAN_SER_CMDS_IN_ALL_LISTS: Command cancelled from all lists 696 * @WLAN_SER_CMD_NOT_FOUND: Specified command to be cancelled 697 * not found in the lists 698 */ 699 enum wlan_serialization_cmd_status { 700 WLAN_SER_CMD_IN_PENDING_LIST, 701 WLAN_SER_CMD_IN_ACTIVE_LIST, 702 WLAN_SER_CMDS_IN_ALL_LISTS, 703 WLAN_SER_CMD_MARKED_FOR_ACTIVATION, 704 WLAN_SER_CMD_NOT_FOUND, 705 }; 706 707 /** 708 * struct wlan_serialization_command - Command to be serialized 709 * @wlan_serialization_cmd_type: Type of command 710 * @cmd_id: Command Identifier 711 * @cmd_cb: Command callback 712 * @source: component ID of the source of the command 713 * @is_high_priority: Normal/High Priority at which the cmd has to be queued 714 * @is_blocking: Is the command blocking 715 * @queue_disable: Should the command disable the queues 716 * @activation_reason: reason the activation cb was called 717 * @cmd_timeout_cb: Command timeout callback 718 * @cmd_timeout_duration: Timeout duration in milliseconds 719 * @vdev: VDEV object associated to the command 720 * @umac_cmd: Actual command that needs to be sent to WMI/firmware 721 * 722 * Note: Unnamed union has been used in this structure, so that in future if 723 * somebody wants to add pdev or psoc structure then that person can add without 724 * modifying existing code. 725 */ 726 struct wlan_serialization_command { 727 enum wlan_serialization_cmd_type cmd_type; 728 uint32_t cmd_id; 729 wlan_serialization_cmd_callback cmd_cb; 730 enum wlan_umac_comp_id source; 731 uint8_t is_high_priority:1, 732 is_blocking:1, 733 queue_disable:1, 734 activation_reason:3; 735 uint32_t cmd_timeout_duration; 736 union { 737 struct wlan_objmgr_vdev *vdev; 738 }; 739 void *umac_cmd; 740 }; 741 742 /** 743 * struct wlan_serialization_queued_cmd_info - cmd that has to be cancelled 744 * @requestor: component ID of the source requesting this action 745 * @cmd_type: Command type 746 * @cmd_id: Command ID 747 * @req_type: Commands that need to be cancelled 748 * @vdev: VDEV object associated to the command 749 * @queue_type: Queues from which the command to be cancelled 750 */ 751 struct wlan_serialization_queued_cmd_info { 752 enum wlan_umac_comp_id requestor; 753 enum wlan_serialization_cmd_type cmd_type; 754 uint32_t cmd_id; 755 enum wlan_serialization_cancel_type req_type; 756 union { 757 struct wlan_objmgr_vdev *vdev; 758 }; 759 uint8_t queue_type; 760 }; 761 762 /** 763 * wlan_serialization_cancel_request() - Request to cancel a command 764 * @req: Request information 765 * 766 * This API is used by external components to cancel a command 767 * that is either in the pending or active queue. Based on the 768 * req_type, it is decided whether to use pdev or vdev 769 * object. For all non-scan commands, it will be pdev. 770 * 771 * Return: Status specifying the removal of a command from a certain queue 772 */ 773 enum wlan_serialization_cmd_status 774 wlan_serialization_cancel_request( 775 struct wlan_serialization_queued_cmd_info *req); 776 777 /** 778 * wlan_serialization_remove_cmd() - Request to release a command 779 * @cmd: Command information 780 * 781 * This API is used to release a command sitting in the active 782 * queue upon successful completion of the command 783 * 784 * Return: None 785 */ 786 void wlan_serialization_remove_cmd( 787 struct wlan_serialization_queued_cmd_info *cmd); 788 789 /** 790 * wlan_serialization_flush_cmd() - Request to flush command 791 * @cmd: Command information 792 * 793 * This API is used to flush a cmd sitting in the queue. It 794 * simply flushes the cmd from the queue and does not call 795 * any callbacks in between. If the request is for active 796 * queue, and if the active queue becomes empty upon flush, 797 * then it will pick the next pending cmd and put in the active 798 * queue before returning. 799 * 800 * Return: None 801 */ 802 void wlan_serialization_flush_cmd( 803 struct wlan_serialization_queued_cmd_info *cmd); 804 805 /** 806 * wlan_serialization_update_timer() -Update timer for an active command 807 * @cmd: Command information 808 * 809 * Return: Status of the timer update 810 */ 811 QDF_STATUS 812 wlan_serialization_update_timer(struct wlan_serialization_command *cmd); 813 814 /** 815 * wlan_serialization_request() - Request to serialize a command 816 * @cmd: Command information 817 * 818 * Return: Status of the serialization request 819 */ 820 enum wlan_serialization_status 821 wlan_serialization_request(struct wlan_serialization_command *cmd); 822 823 /** 824 * wlan_serialization_register_comp_info_cb() - Register component's info cb 825 * @psoc: PSOC object information 826 * @comp_id: Component ID 827 * @cmd_type: Command Type 828 * @cb: Callback 829 * 830 * This is called from component during its initialization.It initializes 831 * callback handler for given comp_id/cmd_id in a 2-D array. 832 * 833 * Return: QDF Status 834 */ 835 QDF_STATUS 836 wlan_serialization_register_comp_info_cb( 837 struct wlan_objmgr_psoc *psoc, 838 enum wlan_umac_comp_id comp_id, 839 enum wlan_serialization_cmd_type cmd_type, 840 wlan_serialization_comp_info_cb cb); 841 842 /** 843 * wlan_serialization_deregister_comp_info_cb() - Deregister component's info 844 * callback 845 * @psoc: PSOC object information 846 * @comp_id: Component ID 847 * @cmd_type: Command Type 848 * 849 * This routine is called from other component during its de-initialization. 850 * 851 * Return: QDF Status 852 */ 853 QDF_STATUS 854 wlan_serialization_deregister_comp_info_cb( 855 struct wlan_objmgr_psoc *psoc, 856 enum wlan_umac_comp_id comp_id, 857 enum wlan_serialization_cmd_type cmd_type); 858 859 /** 860 * wlan_serialization_register_apply_rules_cb() - Register component's rules 861 * callback 862 * @psoc: PSOC object information 863 * @cmd_type: Command Type 864 * @cb: Callback 865 * 866 * This is called from component during its initialization.It initializes 867 * callback handler for given cmd_type in a 1-D array. 868 * 869 * Return: QDF Status 870 */ 871 QDF_STATUS 872 wlan_serialization_register_apply_rules_cb( 873 struct wlan_objmgr_psoc *psoc, 874 enum wlan_serialization_cmd_type cmd_type, 875 wlan_serialization_apply_rules_cb apply_rules_cb); 876 877 /** 878 * wlan_serialization_deregister_apply_rules_cb() - Deregister component's rules 879 * callback 880 * @psoc: PSOC object information 881 * @cmd_type: Command Type 882 * 883 * This routine is called from other component during its de-initialization. 884 * 885 * Return: QDF Status 886 */ 887 QDF_STATUS 888 wlan_serialization_deregister_apply_rules_cb( 889 struct wlan_objmgr_psoc *psoc, 890 enum wlan_serialization_cmd_type cmd_type); 891 892 /** 893 * @wlan_serialization_init() - Serialization component initialization routine 894 * 895 * Return - QDF Status 896 */ 897 QDF_STATUS wlan_serialization_init(void); 898 899 /** 900 * @wlan_serialization_deinit() - Serialization component de-init routine 901 * 902 * Return - QDF Status 903 */ 904 QDF_STATUS wlan_serialization_deinit(void); 905 906 /** 907 * @wlan_serialization_psoc_open() - Serialization component open routine 908 * 909 * Return - QDF Status 910 */ 911 QDF_STATUS wlan_serialization_psoc_open(struct wlan_objmgr_psoc *psoc); 912 913 /** 914 * @wlan_serialization_psoc_close() - Serialization component close routine 915 * 916 * Return - QDF Status 917 */ 918 QDF_STATUS wlan_serialization_psoc_close(struct wlan_objmgr_psoc *psoc); 919 920 /** 921 * wlan_serialization_vdev_scan_status() - Return the status of the vdev scan 922 * @vdev: VDEV Object 923 * 924 * Return: Status of the scans for the corresponding vdev 925 */ 926 enum wlan_serialization_cmd_status 927 wlan_serialization_vdev_scan_status(struct wlan_objmgr_vdev *vdev); 928 929 /** 930 * wlan_serialization_pdev_scan_status() - Return the status of the pdev scan 931 * @pdev: PDEV Object 932 * 933 * Return: Status of the scans for the corresponding pdev 934 */ 935 enum wlan_serialization_cmd_status 936 wlan_serialization_pdev_scan_status(struct wlan_objmgr_pdev *pdev); 937 938 /** 939 * wlan_serialization_non_scan_cmd_status() - Return status of pdev non-scan cmd 940 * @pdev: PDEV Object 941 * @cmd_id: ID of the command for which the status has to be checked 942 * 943 * Return: Status of the command for the corresponding pdev 944 */ 945 enum wlan_serialization_cmd_status 946 wlan_serialization_non_scan_cmd_status(struct wlan_objmgr_pdev *pdev, 947 enum wlan_serialization_cmd_type cmd_id); 948 949 /** 950 * wlan_serialization_is_cmd_present_in_pending_queue() - Return if the command 951 * is already present in pending queue 952 * @cmd: pointer to serialization command to check 953 * 954 * This API will check if command is present in pending queue. If present 955 * then return true, so use know that it is duplicated command 956 * 957 * Return: true or false 958 */ 959 bool wlan_serialization_is_cmd_present_in_pending_queue( 960 struct wlan_objmgr_psoc *psoc, 961 struct wlan_serialization_command *cmd); 962 /** 963 * wlan_serialization_is_cmd_present_in_active_queue() - Return if the command 964 * is already present in active queue 965 * @cmd: pointer to serialization command to check 966 * 967 * This API will check if command is present in active queue. If present 968 * then return true, so use know that it is duplicated command 969 * 970 * Return: true or false 971 */ 972 bool wlan_serialization_is_cmd_present_in_active_queue( 973 struct wlan_objmgr_psoc *psoc, 974 struct wlan_serialization_command *cmd); 975 976 /** 977 * wlan_serialization_get_scan_cmd_using_scan_id() - Return command which 978 * matches vdev_id and scan_id 979 * @psoc: pointer to soc 980 * @vdev_id: vdev id to pull vdev object 981 * @scan_id: scan id to match 982 * @is_scan_cmd_from_active_queue: to indicate active or pending queue 983 * 984 * This API fetches vdev/pdev object based on vdev_id, loops through scan 985 * command queue and find the command which matches scan id as well as vdev 986 * object. 987 * 988 * Return: pointer to serialization command 989 */ 990 struct wlan_serialization_command* 991 wlan_serialization_get_scan_cmd_using_scan_id( 992 struct wlan_objmgr_psoc *psoc, 993 uint8_t vdev_id, uint16_t scan_id, 994 uint8_t is_scan_cmd_from_active_queue); 995 /** 996 * wlan_serialization_get_active_cmd() - Return active umac command which 997 * matches vdev and cmd type 998 * @psoc: pointer to soc 999 * @vdev_id: vdev id to pull vdev object 1000 * @cmd_type: cmd type to match 1001 * 1002 * This API fetches vdev/pdev object based on vdev_id, loops through active 1003 * command queue and find the active command which matches cmd_type as well 1004 * as vdev object. 1005 * 1006 * Return: Pointer to umac command. NULL is returned if active command of given 1007 * type is not found. 1008 */ 1009 void *wlan_serialization_get_active_cmd( 1010 struct wlan_objmgr_psoc *psoc, 1011 uint8_t vdev_id, 1012 enum wlan_serialization_cmd_type cmd_type); 1013 1014 /** 1015 * wlan_serialization_get_active_cmd() - Return active umac command which 1016 * matches vdev and cmd type 1017 * @vdev: vdev object 1018 * 1019 * This API fetches command type of the command in the vdev active queue 1020 * 1021 * Return: command type of the command in the vdev active queue 1022 */ 1023 1024 enum wlan_serialization_cmd_type 1025 wlan_serialization_get_vdev_active_cmd_type(struct wlan_objmgr_vdev *vdev); 1026 #endif 1027 #endif 1028