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_ALREADY_EXISTS: Command already exists in the queue 681 * @WLAN_SER_CMD_DENIED_UNSPECIFIED: Command denied due to unknown reason 682 */ 683 enum wlan_serialization_status { 684 WLAN_SER_CMD_PENDING, 685 WLAN_SER_CMD_ACTIVE, 686 WLAN_SER_CMD_DENIED_RULES_FAILED, 687 WLAN_SER_CMD_DENIED_LIST_FULL, 688 WLAN_SER_CMD_QUEUE_DISABLED, 689 WLAN_SER_CMD_ALREADY_EXISTS, 690 WLAN_SER_CMD_DENIED_UNSPECIFIED, 691 }; 692 693 /** 694 * enum wlan_serialization_cmd_status - Return status for a cancel request 695 * @WLAN_SER_CMD_IN_PENDING_LIST: Command cancelled from pending list 696 * @WLAN_SER_CMD_IN_ACTIVE_LIST: Command cancelled from active list 697 * @WLAN_SER_CMDS_IN_ALL_LISTS: Command cancelled from all lists 698 * @WLAN_SER_CMD_NOT_FOUND: Specified command to be cancelled 699 * not found in the lists 700 */ 701 enum wlan_serialization_cmd_status { 702 WLAN_SER_CMD_IN_PENDING_LIST, 703 WLAN_SER_CMD_IN_ACTIVE_LIST, 704 WLAN_SER_CMDS_IN_ALL_LISTS, 705 WLAN_SER_CMD_MARKED_FOR_ACTIVATION, 706 WLAN_SER_CMD_NOT_FOUND, 707 }; 708 709 /** 710 * struct wlan_serialization_command - Command to be serialized 711 * @wlan_serialization_cmd_type: Type of command 712 * @cmd_id: Command Identifier 713 * @cmd_cb: Command callback 714 * @source: component ID of the source of the command 715 * @is_high_priority: Normal/High Priority at which the cmd has to be queued 716 * @is_blocking: Is the command blocking 717 * @queue_disable: Should the command disable the queues 718 * @activation_reason: reason the activation cb was called 719 * @cmd_timeout_cb: Command timeout callback 720 * @cmd_timeout_duration: Timeout duration in milliseconds 721 * @vdev: VDEV object associated to the command 722 * @umac_cmd: Actual command that needs to be sent to WMI/firmware 723 * 724 * Note: Unnamed union has been used in this structure, so that in future if 725 * somebody wants to add pdev or psoc structure then that person can add without 726 * modifying existing code. 727 */ 728 struct wlan_serialization_command { 729 enum wlan_serialization_cmd_type cmd_type; 730 uint32_t cmd_id; 731 wlan_serialization_cmd_callback cmd_cb; 732 enum wlan_umac_comp_id source; 733 uint8_t is_high_priority:1, 734 is_blocking:1, 735 queue_disable:1, 736 activation_reason:3; 737 uint32_t cmd_timeout_duration; 738 union { 739 struct wlan_objmgr_vdev *vdev; 740 }; 741 void *umac_cmd; 742 }; 743 744 /** 745 * struct wlan_serialization_queued_cmd_info - cmd that has to be cancelled 746 * @requestor: component ID of the source requesting this action 747 * @cmd_type: Command type 748 * @cmd_id: Command ID 749 * @req_type: Commands that need to be cancelled 750 * @vdev: VDEV object associated to the command 751 * @queue_type: Queues from which the command to be cancelled 752 */ 753 struct wlan_serialization_queued_cmd_info { 754 enum wlan_umac_comp_id requestor; 755 enum wlan_serialization_cmd_type cmd_type; 756 uint32_t cmd_id; 757 enum wlan_serialization_cancel_type req_type; 758 union { 759 struct wlan_objmgr_vdev *vdev; 760 }; 761 uint8_t queue_type; 762 }; 763 764 /** 765 * wlan_serialization_cancel_request() - Request to cancel a command 766 * @req: Request information 767 * 768 * This API is used by external components to cancel a command 769 * that is either in the pending or active queue. Based on the 770 * req_type, it is decided whether to use pdev or vdev 771 * object. For all non-scan commands, it will be pdev. 772 * 773 * Return: Status specifying the removal of a command from a certain queue 774 */ 775 enum wlan_serialization_cmd_status 776 wlan_serialization_cancel_request( 777 struct wlan_serialization_queued_cmd_info *req); 778 779 /** 780 * wlan_serialization_remove_cmd() - Request to release a command 781 * @cmd: Command information 782 * 783 * This API is used to release a command sitting in the active 784 * queue upon successful completion of the command 785 * 786 * Return: None 787 */ 788 void wlan_serialization_remove_cmd( 789 struct wlan_serialization_queued_cmd_info *cmd); 790 791 /** 792 * wlan_serialization_flush_cmd() - Request to flush command 793 * @cmd: Command information 794 * 795 * This API is used to flush a cmd sitting in the queue. It 796 * simply flushes the cmd from the queue and does not call 797 * any callbacks in between. If the request is for active 798 * queue, and if the active queue becomes empty upon flush, 799 * then it will pick the next pending cmd and put in the active 800 * queue before returning. 801 * 802 * Return: None 803 */ 804 void wlan_serialization_flush_cmd( 805 struct wlan_serialization_queued_cmd_info *cmd); 806 807 /** 808 * wlan_serialization_update_timer() -Update timer for an active command 809 * @cmd: Command information 810 * 811 * Return: Status of the timer update 812 */ 813 QDF_STATUS 814 wlan_serialization_update_timer(struct wlan_serialization_command *cmd); 815 816 /** 817 * wlan_serialization_request() - Request to serialize a command 818 * @cmd: Command information 819 * 820 * Return: Status of the serialization request 821 */ 822 enum wlan_serialization_status 823 wlan_serialization_request(struct wlan_serialization_command *cmd); 824 825 /** 826 * wlan_serialization_register_comp_info_cb() - Register component's info cb 827 * @psoc: PSOC object information 828 * @comp_id: Component ID 829 * @cmd_type: Command Type 830 * @cb: Callback 831 * 832 * This is called from component during its initialization.It initializes 833 * callback handler for given comp_id/cmd_id in a 2-D array. 834 * 835 * Return: QDF Status 836 */ 837 QDF_STATUS 838 wlan_serialization_register_comp_info_cb( 839 struct wlan_objmgr_psoc *psoc, 840 enum wlan_umac_comp_id comp_id, 841 enum wlan_serialization_cmd_type cmd_type, 842 wlan_serialization_comp_info_cb cb); 843 844 /** 845 * wlan_serialization_deregister_comp_info_cb() - Deregister component's info 846 * callback 847 * @psoc: PSOC object information 848 * @comp_id: Component ID 849 * @cmd_type: Command Type 850 * 851 * This routine is called from other component during its de-initialization. 852 * 853 * Return: QDF Status 854 */ 855 QDF_STATUS 856 wlan_serialization_deregister_comp_info_cb( 857 struct wlan_objmgr_psoc *psoc, 858 enum wlan_umac_comp_id comp_id, 859 enum wlan_serialization_cmd_type cmd_type); 860 861 /** 862 * wlan_serialization_register_apply_rules_cb() - Register component's rules 863 * callback 864 * @psoc: PSOC object information 865 * @cmd_type: Command Type 866 * @cb: Callback 867 * 868 * This is called from component during its initialization.It initializes 869 * callback handler for given cmd_type in a 1-D array. 870 * 871 * Return: QDF Status 872 */ 873 QDF_STATUS 874 wlan_serialization_register_apply_rules_cb( 875 struct wlan_objmgr_psoc *psoc, 876 enum wlan_serialization_cmd_type cmd_type, 877 wlan_serialization_apply_rules_cb apply_rules_cb); 878 879 /** 880 * wlan_serialization_deregister_apply_rules_cb() - Deregister component's rules 881 * callback 882 * @psoc: PSOC object information 883 * @cmd_type: Command Type 884 * 885 * This routine is called from other component during its de-initialization. 886 * 887 * Return: QDF Status 888 */ 889 QDF_STATUS 890 wlan_serialization_deregister_apply_rules_cb( 891 struct wlan_objmgr_psoc *psoc, 892 enum wlan_serialization_cmd_type cmd_type); 893 894 /** 895 * @wlan_serialization_init() - Serialization component initialization routine 896 * 897 * Return - QDF Status 898 */ 899 QDF_STATUS wlan_serialization_init(void); 900 901 /** 902 * @wlan_serialization_deinit() - Serialization component de-init routine 903 * 904 * Return - QDF Status 905 */ 906 QDF_STATUS wlan_serialization_deinit(void); 907 908 /** 909 * @wlan_serialization_psoc_open() - Serialization component open routine 910 * 911 * Return - QDF Status 912 */ 913 QDF_STATUS wlan_serialization_psoc_open(struct wlan_objmgr_psoc *psoc); 914 915 /** 916 * @wlan_serialization_psoc_close() - Serialization component close routine 917 * 918 * Return - QDF Status 919 */ 920 QDF_STATUS wlan_serialization_psoc_close(struct wlan_objmgr_psoc *psoc); 921 922 /** 923 * wlan_serialization_vdev_scan_status() - Return the status of the vdev scan 924 * @vdev: VDEV Object 925 * 926 * Return: Status of the scans for the corresponding vdev 927 */ 928 enum wlan_serialization_cmd_status 929 wlan_serialization_vdev_scan_status(struct wlan_objmgr_vdev *vdev); 930 931 /** 932 * wlan_serialization_pdev_scan_status() - Return the status of the pdev scan 933 * @pdev: PDEV Object 934 * 935 * Return: Status of the scans for the corresponding pdev 936 */ 937 enum wlan_serialization_cmd_status 938 wlan_serialization_pdev_scan_status(struct wlan_objmgr_pdev *pdev); 939 940 /** 941 * wlan_serialization_non_scan_cmd_status() - Return status of pdev non-scan cmd 942 * @pdev: PDEV Object 943 * @cmd_id: ID of the command for which the status has to be checked 944 * 945 * Return: Status of the command for the corresponding pdev 946 */ 947 enum wlan_serialization_cmd_status 948 wlan_serialization_non_scan_cmd_status(struct wlan_objmgr_pdev *pdev, 949 enum wlan_serialization_cmd_type cmd_id); 950 951 /** 952 * wlan_serialization_is_cmd_present_in_pending_queue() - Return if the command 953 * is already present in pending queue 954 * @cmd: pointer to serialization command to check 955 * 956 * This API will check if command is present in pending queue. If present 957 * then return true, so use know that it is duplicated command 958 * 959 * Return: true or false 960 */ 961 bool wlan_serialization_is_cmd_present_in_pending_queue( 962 struct wlan_objmgr_psoc *psoc, 963 struct wlan_serialization_command *cmd); 964 /** 965 * wlan_serialization_is_cmd_present_in_active_queue() - Return if the command 966 * is already present in active queue 967 * @cmd: pointer to serialization command to check 968 * 969 * This API will check if command is present in active queue. If present 970 * then return true, so use know that it is duplicated command 971 * 972 * Return: true or false 973 */ 974 bool wlan_serialization_is_cmd_present_in_active_queue( 975 struct wlan_objmgr_psoc *psoc, 976 struct wlan_serialization_command *cmd); 977 978 /** 979 * wlan_serialization_get_scan_cmd_using_scan_id() - Return command which 980 * matches vdev_id and scan_id 981 * @psoc: pointer to soc 982 * @vdev_id: vdev id to pull vdev object 983 * @scan_id: scan id to match 984 * @is_scan_cmd_from_active_queue: to indicate active or pending queue 985 * 986 * This API fetches vdev/pdev object based on vdev_id, loops through scan 987 * command queue and find the command which matches scan id as well as vdev 988 * object. 989 * 990 * Return: pointer to serialization command 991 */ 992 struct wlan_serialization_command* 993 wlan_serialization_get_scan_cmd_using_scan_id( 994 struct wlan_objmgr_psoc *psoc, 995 uint8_t vdev_id, uint16_t scan_id, 996 uint8_t is_scan_cmd_from_active_queue); 997 /** 998 * wlan_serialization_get_active_cmd() - Return active umac command which 999 * matches vdev and cmd type 1000 * @psoc: pointer to soc 1001 * @vdev_id: vdev id to pull vdev object 1002 * @cmd_type: cmd type to match 1003 * 1004 * This API fetches vdev/pdev object based on vdev_id, loops through active 1005 * command queue and find the active command which matches cmd_type as well 1006 * as vdev object. 1007 * 1008 * Return: Pointer to umac command. NULL is returned if active command of given 1009 * type is not found. 1010 */ 1011 void *wlan_serialization_get_active_cmd( 1012 struct wlan_objmgr_psoc *psoc, 1013 uint8_t vdev_id, 1014 enum wlan_serialization_cmd_type cmd_type); 1015 1016 /** 1017 * wlan_serialization_get_active_cmd() - Return active umac command which 1018 * matches vdev and cmd type 1019 * @vdev: vdev object 1020 * 1021 * This API fetches command type of the command in the vdev active queue 1022 * 1023 * Return: command type of the command in the vdev active queue 1024 */ 1025 1026 enum wlan_serialization_cmd_type 1027 wlan_serialization_get_vdev_active_cmd_type(struct wlan_objmgr_vdev *vdev); 1028 #endif 1029 #endif 1030