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