1 /* 2 * Copyright (c) 2013-2021 The Linux Foundation. All rights reserved. 3 * Copyright (c) 2021-2023 Qualcomm Innovation Center, Inc. All rights reserved. 4 * 5 * Permission to use, copy, modify, and/or distribute this software for 6 * any purpose with or without fee is hereby granted, provided that the 7 * above copyright notice and this permission notice appear in all 8 * copies. 9 * 10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL 11 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED 12 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE 13 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL 14 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR 15 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER 16 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 17 * PERFORMANCE OF THIS SOFTWARE. 18 */ 19 20 #ifndef _WLAN_IPA_CORE_H_ 21 #define _WLAN_IPA_CORE_H_ 22 23 #ifdef IPA_OFFLOAD 24 25 #include "wlan_ipa_priv.h" 26 #include "wlan_ipa_public_struct.h" 27 28 /** 29 * wlan_ipa_is_enabled() - Is IPA enabled? 30 * @ipa_cfg: IPA config 31 * 32 * Return: true if IPA is enabled, false otherwise 33 */ 34 static inline bool wlan_ipa_is_enabled(struct wlan_ipa_config *ipa_cfg) 35 { 36 return WLAN_IPA_IS_CONFIG_ENABLED(ipa_cfg, WLAN_IPA_ENABLE_MASK); 37 } 38 39 /** 40 * wlan_ipa_uc_is_enabled() - Is IPA UC enabled? 41 * @ipa_cfg: IPA config 42 * 43 * Return: true if IPA UC is enabled, false otherwise 44 */ 45 static inline bool wlan_ipa_uc_is_enabled(struct wlan_ipa_config *ipa_cfg) 46 { 47 return WLAN_IPA_IS_CONFIG_ENABLED(ipa_cfg, WLAN_IPA_UC_ENABLE_MASK); 48 } 49 50 /** 51 * wlan_ipa_is_opt_wifi_dp_enabled() - Is optional wifi dp enabled from WLAN 52 * @ipa_cfg: IPA config 53 * 54 * Return: true if IPA opt wifi dp is enabled, false otherwise 55 */ 56 static inline bool wlan_ipa_is_opt_wifi_dp_enabled( 57 struct wlan_ipa_config *ipa_cfg) 58 { 59 return WLAN_IPA_IS_CONFIG_ENABLED(ipa_cfg, WLAN_IPA_OPT_WIFI_DP); 60 } 61 62 /** 63 * wlan_ipa_is_rt_debugging_enabled() - Is IPA RT debugging enabled? 64 * @ipa_cfg: IPA config 65 * 66 * Return: true if IPA RT debugging is enabled, false otherwise 67 */ 68 static inline 69 bool wlan_ipa_is_rt_debugging_enabled(struct wlan_ipa_config *ipa_cfg) 70 { 71 return WLAN_IPA_IS_CONFIG_ENABLED(ipa_cfg, 72 WLAN_IPA_REAL_TIME_DEBUGGING); 73 } 74 75 /** 76 * wlan_ipa_setup - IPA initialize and setup 77 * @ipa_ctx: IPA priv obj 78 * @ipa_cfg: IPA config 79 * 80 * Return: QDF_STATUS 81 */ 82 QDF_STATUS wlan_ipa_setup(struct wlan_ipa_priv *ipa_ctx, 83 struct wlan_ipa_config *ipa_cfg); 84 85 /** 86 * wlan_ipa_get_obj_context - Get IPA OBJ context 87 * 88 * Return: IPA context 89 */ 90 struct wlan_ipa_priv *wlan_ipa_get_obj_context(void); 91 92 /** 93 * wlan_ipa_cleanup - IPA cleanup 94 * @ipa_ctx: IPA priv obj 95 * 96 * Return: QDF_STATUS 97 */ 98 QDF_STATUS wlan_ipa_cleanup(struct wlan_ipa_priv *ipa_ctx); 99 100 /** 101 * wlan_ipa_uc_enable_pipes() - Enable IPA uC pipes 102 * @ipa_ctx: IPA context 103 * 104 * Return: QDF_STATUS 105 */ 106 QDF_STATUS wlan_ipa_uc_enable_pipes(struct wlan_ipa_priv *ipa_ctx); 107 108 /** 109 * wlan_ipa_uc_disable_pipes() - Disable IPA uC pipes 110 * @ipa_ctx: IPA context 111 * @force_disable: If true, immediately disable IPA pipes. If false, wait for 112 * pending IPA WLAN TX completions 113 * 114 * Return: QDF_STATUS 115 */ 116 QDF_STATUS wlan_ipa_uc_disable_pipes(struct wlan_ipa_priv *ipa_ctx, 117 bool force_disable); 118 119 /** 120 * wlan_ipa_is_tx_pending() - Check if IPA TX Completions are pending 121 * @ipa_ctx: IPA context 122 * 123 * Return: bool 124 */ 125 bool wlan_ipa_is_tx_pending(struct wlan_ipa_priv *ipa_ctx); 126 127 /** 128 * wlan_ipa_set_perf_level() - Set IPA performance level 129 * @ipa_ctx: IPA context 130 * @tx_packets: Number of packets transmitted in the last sample period 131 * @rx_packets: Number of packets received in the last sample period 132 * 133 * Return: QDF STATUS 134 */ 135 QDF_STATUS wlan_ipa_set_perf_level(struct wlan_ipa_priv *ipa_ctx, 136 uint64_t tx_packets, uint64_t rx_packets); 137 138 /** 139 * wlan_ipa_init_perf_level() - Initialize IPA performance level 140 * @ipa_ctx: IPA context 141 * 142 * If IPA clock scaling is disabled, initialize perf level to maximum. 143 * Else set the lowest level to start with. 144 * 145 * Return: QDF STATUS 146 */ 147 QDF_STATUS wlan_ipa_init_perf_level(struct wlan_ipa_priv *ipa_ctx); 148 149 /** 150 * wlan_ipa_get_iface() - Get IPA interface 151 * @ipa_ctx: IPA context 152 * @mode: Interface device mode 153 * 154 * Return: IPA interface address 155 */ 156 struct wlan_ipa_iface_context 157 *wlan_ipa_get_iface(struct wlan_ipa_priv *ipa_ctx, uint8_t mode); 158 159 /** 160 * wlan_ipa_check_iface_netdev_sessid() - Check IPA interface using netdev 161 * and session id 162 * 163 * @ipa_iface: IPA iface 164 * @net_dev: net dev 165 * @session_id: vdev id 166 * 167 * Return: Result if iface is matching or not 168 */ 169 int wlan_ipa_check_iface_netdev_sessid(struct wlan_ipa_iface_context *ipa_iface, 170 qdf_netdev_t net_dev, 171 uint8_t session_id); 172 173 /** 174 * wlan_ipa_get_iface_by_mode_netdev() - Get IPA interface 175 * @ipa_ctx: IPA context 176 * @ndev: Interface netdev pointer 177 * @mode: Interface device mode 178 * @session_id: vdev id 179 * 180 * Return: IPA interface address 181 */ 182 struct wlan_ipa_iface_context * 183 wlan_ipa_get_iface_by_mode_netdev(struct wlan_ipa_priv *ipa_ctx, 184 qdf_netdev_t ndev, uint8_t mode, 185 uint8_t session_id); 186 187 #if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 10, 0)) && \ 188 !defined(CONFIG_IPA_WDI_UNIFIED_API) 189 190 /** 191 * wlan_ipa_is_rm_enabled() - Is IPA RM enabled? 192 * @ipa_cfg: IPA config 193 * 194 * Return: true if IPA RM is enabled, false otherwise 195 */ 196 static inline bool wlan_ipa_is_rm_enabled(struct wlan_ipa_config *ipa_cfg) 197 { 198 return WLAN_IPA_IS_CONFIG_ENABLED(ipa_cfg, WLAN_IPA_RM_ENABLE_MASK); 199 } 200 201 /** 202 * wlan_ipa_is_clk_scaling_enabled() - Is IPA clock scaling enabled? 203 * @ipa_cfg: IPA config 204 * 205 * Return: true if IPA clock scaling is enabled, false otherwise 206 */ 207 static inline 208 bool wlan_ipa_is_clk_scaling_enabled(struct wlan_ipa_config *ipa_cfg) 209 { 210 return WLAN_IPA_IS_CONFIG_ENABLED(ipa_cfg, 211 WLAN_IPA_CLK_SCALING_ENABLE_MASK | 212 WLAN_IPA_RM_ENABLE_MASK); 213 } 214 215 /** 216 * wlan_ipa_wdi_rm_request_resource() - IPA WDI request resource 217 * @ipa_ctx: IPA context 218 * @res_name: IPA RM resource name 219 * 220 * Return: 0 on success, negative errno on error 221 */ 222 static inline 223 int wlan_ipa_wdi_rm_request_resource(struct wlan_ipa_priv *ipa_ctx, 224 qdf_ipa_rm_resource_name_t res_name) 225 { 226 return qdf_ipa_rm_request_resource(res_name); 227 } 228 229 /** 230 * wlan_ipa_wdi_rm_release_resource() - IPA WDI release resource 231 * @ipa_ctx: IPA context 232 * @res_name: IPA RM resource name 233 * 234 * Return: 0 on success, negative errno on error 235 */ 236 static inline 237 int wlan_ipa_wdi_rm_release_resource(struct wlan_ipa_priv *ipa_ctx, 238 qdf_ipa_rm_resource_name_t res_name) 239 { 240 return qdf_ipa_rm_release_resource(res_name); 241 } 242 243 /** 244 * wlan_ipa_wdi_rm_request() - Request resource from IPA 245 * @ipa_ctx: IPA context 246 * 247 * Return: QDF_STATUS 248 */ 249 QDF_STATUS wlan_ipa_wdi_rm_request(struct wlan_ipa_priv *ipa_ctx); 250 251 /** 252 * wlan_ipa_wdi_rm_try_release() - Attempt to release IPA resource 253 * @ipa_ctx: IPA context 254 * 255 * Return: QDF_STATUS 256 */ 257 QDF_STATUS wlan_ipa_wdi_rm_try_release(struct wlan_ipa_priv *ipa_ctx); 258 259 /** 260 * wlan_ipa_wdi_setup_rm() - Setup IPA resource management 261 * @ipa_ctx: IPA context 262 * 263 * Return: QDF_STATUS 264 */ 265 QDF_STATUS wlan_ipa_wdi_setup_rm(struct wlan_ipa_priv *ipa_ctx); 266 267 /** 268 * wlan_ipa_wdi_destroy_rm() - Destroy IPA resources 269 * @ipa_ctx: IPA context 270 * 271 * Destroys all resources associated with the IPA resource manager 272 * 273 * Return: None 274 */ 275 void wlan_ipa_wdi_destroy_rm(struct wlan_ipa_priv *ipa_ctx); 276 277 static inline 278 int wlan_ipa_wdi_rm_notify_completion(qdf_ipa_rm_event_t event, 279 qdf_ipa_rm_resource_name_t res_name) 280 { 281 return qdf_ipa_rm_notify_completion(event, res_name); 282 } 283 284 static inline 285 int wlan_ipa_wdi_rm_inactivity_timer_destroy( 286 qdf_ipa_rm_resource_name_t res_name) 287 { 288 return qdf_ipa_rm_inactivity_timer_destroy(res_name); 289 } 290 291 bool wlan_ipa_is_rm_released(struct wlan_ipa_priv *ipa_ctx); 292 293 #else /* CONFIG_IPA_WDI_UNIFIED_API */ 294 295 /** 296 * wlan_ipa_is_rm_enabled() - Is IPA RM enabled? 297 * @ipa_cfg: IPA config 298 * 299 * IPA RM is deprecated and IPA PM is involved. WLAN driver 300 * has no control over IPA PM and thus we could regard IPA 301 * RM as always enabled for power efficiency. 302 * 303 * Return: true 304 */ 305 static inline bool wlan_ipa_is_rm_enabled(struct wlan_ipa_config *ipa_cfg) 306 { 307 return true; 308 } 309 310 /** 311 * wlan_ipa_is_clk_scaling_enabled() - Is IPA clock scaling enabled? 312 * @ipa_cfg: IPA config 313 * 314 * Return: true if IPA clock scaling is enabled, false otherwise 315 */ 316 static inline 317 bool wlan_ipa_is_clk_scaling_enabled(struct wlan_ipa_config *ipa_cfg) 318 { 319 return WLAN_IPA_IS_CONFIG_ENABLED(ipa_cfg, 320 WLAN_IPA_CLK_SCALING_ENABLE_MASK); 321 } 322 323 static inline int wlan_ipa_wdi_rm_request_resource( 324 struct wlan_ipa_priv *ipa_ctx, 325 qdf_ipa_rm_resource_name_t res_name) 326 { 327 return 0; 328 } 329 330 static inline int wlan_ipa_wdi_rm_release_resource( 331 struct wlan_ipa_priv *ipa_ctx, 332 qdf_ipa_rm_resource_name_t res_name) 333 { 334 return 0; 335 } 336 337 static inline QDF_STATUS wlan_ipa_wdi_setup_rm(struct wlan_ipa_priv *ipa_ctx) 338 { 339 return 0; 340 } 341 342 static inline int wlan_ipa_wdi_destroy_rm(struct wlan_ipa_priv *ipa_ctx) 343 { 344 return 0; 345 } 346 347 static inline QDF_STATUS wlan_ipa_wdi_rm_request(struct wlan_ipa_priv *ipa_ctx) 348 { 349 return QDF_STATUS_SUCCESS; 350 } 351 352 static inline QDF_STATUS wlan_ipa_wdi_rm_try_release(struct wlan_ipa_priv 353 *ipa_ctx) 354 { 355 return QDF_STATUS_SUCCESS; 356 } 357 358 static inline 359 int wlan_ipa_wdi_rm_notify_completion(qdf_ipa_rm_event_t event, 360 qdf_ipa_rm_resource_name_t res_name) 361 { 362 return 0; 363 } 364 365 static inline 366 int wlan_ipa_wdi_rm_inactivity_timer_destroy( 367 qdf_ipa_rm_resource_name_t res_name) 368 { 369 return 0; 370 } 371 372 static inline 373 bool wlan_ipa_is_rm_released(struct wlan_ipa_priv *ipa_ctx) 374 { 375 return true; 376 } 377 378 #endif /* CONFIG_IPA_WDI_UNIFIED_API */ 379 380 #ifdef FEATURE_METERING 381 382 #ifndef WDI3_STATS_UPDATE 383 /** 384 * wlan_ipa_uc_op_metering() - IPA uC operation for stats and quota limit 385 * @ipa_ctx: IPA context 386 * @op_msg: operation message received from firmware 387 * 388 * Return: QDF_STATUS enumeration 389 */ 390 QDF_STATUS wlan_ipa_uc_op_metering(struct wlan_ipa_priv *ipa_ctx, 391 struct op_msg_type *op_msg); 392 #else 393 static inline 394 QDF_STATUS wlan_ipa_uc_op_metering(struct wlan_ipa_priv *ipa_ctx, 395 struct op_msg_type *op_msg) 396 { 397 return QDF_STATUS_SUCCESS; 398 } 399 #endif 400 401 /** 402 * wlan_ipa_wdi_meter_notifier_cb() - SSR wrapper for 403 * __wlan_ipa_wdi_meter_notifier_cb 404 * @evt: the IPA event which triggered the callback 405 * @data: data associated with the event 406 * 407 * Return: None 408 */ 409 void wlan_ipa_wdi_meter_notifier_cb(qdf_ipa_wdi_meter_evt_type_t evt, 410 void *data); 411 412 /** 413 * wlan_ipa_init_metering() - IPA metering stats completion event reset 414 * @ipa_ctx: IPA context 415 * 416 * Return: QDF_STATUS enumeration 417 */ 418 void wlan_ipa_init_metering(struct wlan_ipa_priv *ipa_ctx); 419 420 #ifdef WDI3_STATS_UPDATE 421 /** 422 * wlan_ipa_update_tx_stats() - send embedded tx traffic in bytes to IPA 423 * @ipa_ctx: IPA context 424 * @sta_tx: tx in bytes on sta interface 425 * @sap_tx: tx in bytes on sap interface 426 * 427 * Return: void 428 */ 429 void wlan_ipa_update_tx_stats(struct wlan_ipa_priv *ipa_ctx, uint64_t sta_tx, 430 uint64_t sap_tx); 431 #else 432 static inline void wlan_ipa_update_tx_stats(struct wlan_ipa_priv *ipa_ctx, 433 uint64_t sta_tx, uint64_t sap_tx) 434 { 435 } 436 #endif /* WDI3_STATS_UPDATE */ 437 438 #else 439 440 static inline 441 QDF_STATUS wlan_ipa_uc_op_metering(struct wlan_ipa_priv *ipa_ctx, 442 struct op_msg_type *op_msg) 443 { 444 return QDF_STATUS_SUCCESS; 445 } 446 447 static inline void wlan_ipa_wdi_meter_notifier_cb(void) 448 { 449 } 450 451 static inline void wlan_ipa_init_metering(struct wlan_ipa_priv *ipa_ctx) 452 { 453 } 454 455 static inline void wlan_ipa_update_tx_stats(struct wlan_ipa_priv *ipa_ctx, 456 uint64_t sta_tx, uint64_t sap_tx) 457 { 458 } 459 #endif /* FEATURE_METERING */ 460 461 #ifdef IPA_OPT_WIFI_DP 462 /* 463 * wlan_ipa_add_rem_flt_cb_event() - Set event to get notified when cce 464 * super rule filter is added/removed 465 * @ipa_ctx: IPA context 466 * 467 * Return: None 468 */ 469 void wlan_ipa_add_rem_flt_cb_event(struct wlan_ipa_priv *ipa_ctx); 470 #else 471 static inline void wlan_ipa_add_rem_flt_cb_event(struct wlan_ipa_priv *ipa_ctx) 472 { 473 } 474 #endif /* IPA_OPT_WIFI_DP */ 475 476 /* 477 * wlan_ipa_uc_stat() - Print IPA uC stats 478 * @ipa_ctx: IPA context 479 * 480 * Return: None 481 */ 482 void wlan_ipa_uc_stat(struct wlan_ipa_priv *ipa_ctx); 483 484 /** 485 * wlan_ipa_uc_info() - Print IPA uC resource and session information 486 * @ipa_ctx: IPA context 487 * 488 * Return: None 489 */ 490 void wlan_ipa_uc_info(struct wlan_ipa_priv *ipa_ctx); 491 492 /** 493 * wlan_ipa_print_fw_wdi_stats() - Print FW IPA WDI stats 494 * @ipa_ctx: IPA context 495 * @uc_fw_stat: stats to print 496 * 497 * Return: None 498 */ 499 void wlan_ipa_print_fw_wdi_stats(struct wlan_ipa_priv *ipa_ctx, 500 struct ipa_uc_fw_stats *uc_fw_stat); 501 502 /** 503 * wlan_ipa_uc_stat_request() - Get IPA stats from IPA 504 * @ipa_ctx: IPA context 505 * @reason: STAT REQ Reason 506 * 507 * Return: None 508 */ 509 void wlan_ipa_uc_stat_request(struct wlan_ipa_priv *ipa_ctx, uint8_t reason); 510 511 /** 512 * wlan_ipa_uc_stat_query() - Query the IPA stats 513 * @ipa_ctx: IPA context 514 * @ipa_tx_diff: tx packet count diff from previous tx packet count 515 * @ipa_rx_diff: rx packet count diff from previous rx packet count 516 * 517 * Return: None 518 */ 519 void wlan_ipa_uc_stat_query(struct wlan_ipa_priv *ipa_ctx, 520 uint32_t *ipa_tx_diff, uint32_t *ipa_rx_diff); 521 522 /** 523 * wlan_ipa_dump_info() - dump IPA IPA struct 524 * @ipa_ctx: IPA context 525 * 526 * Dump entire struct ipa_ctx 527 * 528 * Return: none 529 */ 530 void wlan_ipa_dump_info(struct wlan_ipa_priv *ipa_ctx); 531 532 /** 533 * wlan_ipa_uc_rt_debug_host_dump - dump rt debug buffer 534 * @ipa_ctx: IPA context 535 * 536 * If rt debug enabled, dump debug buffer contents based on requirement 537 * 538 * Return: none 539 */ 540 void wlan_ipa_uc_rt_debug_host_dump(struct wlan_ipa_priv *ipa_ctx); 541 542 /** 543 * wlan_ipa_uc_rt_debug_destructor() - called by data packet free 544 * @nbuff: packet pointer 545 * 546 * when free data packet, will be invoked by wlan client and will increase 547 * free counter 548 * 549 * Return: none 550 */ 551 void wlan_ipa_uc_rt_debug_destructor(qdf_nbuf_t nbuff); 552 553 /** 554 * wlan_ipa_uc_rt_debug_deinit() - remove resources to handle rt debugging 555 * @ipa_ctx: IPA context 556 * 557 * free all rt debugging resources 558 * 559 * Return: none 560 */ 561 void wlan_ipa_uc_rt_debug_deinit(struct wlan_ipa_priv *ipa_ctx); 562 563 /** 564 * wlan_ipa_uc_rt_debug_init() - initialize resources to handle rt debugging 565 * @ipa_ctx: IPA context 566 * 567 * alloc and initialize all rt debugging resources 568 * 569 * Return: none 570 */ 571 void wlan_ipa_uc_rt_debug_init(struct wlan_ipa_priv *ipa_ctx); 572 573 /** 574 * wlan_ipa_reg_sap_xmit_cb() - Register upper layer SAP cb to transmit 575 * @ipa_ctx: IPA context 576 * @cb: callback 577 * 578 * Return: None 579 */ 580 static inline 581 void wlan_ipa_reg_sap_xmit_cb(struct wlan_ipa_priv *ipa_ctx, 582 wlan_ipa_softap_xmit cb) 583 { 584 ipa_ctx->softap_xmit = cb; 585 } 586 587 /** 588 * wlan_ipa_reg_is_driver_unloading_cb() - Register cb to check if driver 589 * is unloading 590 * @ipa_ctx: IPA context 591 * @cb: callback 592 * 593 * Return: None 594 */ 595 static inline 596 void wlan_ipa_reg_is_driver_unloading_cb(struct wlan_ipa_priv *ipa_ctx, 597 wlan_ipa_driver_unloading cb) 598 { 599 ipa_ctx->driver_is_unloading = cb; 600 } 601 602 /** 603 * wlan_ipa_reg_send_to_nw_cb() - Register cb to send IPA Rx packet to network 604 * @ipa_ctx: IPA context 605 * @cb: callback 606 * 607 * Return: None 608 */ 609 static inline 610 void wlan_ipa_reg_send_to_nw_cb(struct wlan_ipa_priv *ipa_ctx, 611 wlan_ipa_send_to_nw cb) 612 { 613 ipa_ctx->send_to_nw = cb; 614 } 615 616 #if defined(QCA_CONFIG_RPS) && !defined(MDM_PLATFORM) 617 /** 618 * wlan_ipa_reg_rps_enable_cb() - Register callback to enable RPS 619 * @ipa_ctx: IPA context 620 * @cb: callback 621 * 622 * Return: None 623 */ 624 static inline 625 void wlan_ipa_reg_rps_enable_cb(struct wlan_ipa_priv *ipa_ctx, 626 wlan_ipa_rps_enable cb) 627 { 628 ipa_ctx->rps_enable = cb; 629 } 630 631 /** 632 * ipa_set_rps_per_vdev(): Enable/disable RPS for a specific vdev 633 * @ipa_ctx: IPA context 634 * @vdev_id: vdev id for which RPS needs to be enabled 635 * @enable: Set true to enable RPS 636 * 637 * Return: None 638 */ 639 static inline 640 void ipa_set_rps_per_vdev(struct wlan_ipa_priv *ipa_ctx, uint8_t vdev_id, 641 bool enable) 642 { 643 if (ipa_ctx->rps_enable) 644 ipa_ctx->rps_enable(vdev_id, enable); 645 } 646 647 #else 648 static inline 649 void ipa_set_rps_per_vdev(struct wlan_ipa_priv *ipa_ctx, uint8_t vdev_id, 650 bool enable) 651 { 652 } 653 #endif 654 655 /** 656 * wlan_ipa_set_mcc_mode() - Set MCC mode 657 * @ipa_ctx: IPA context 658 * @mcc_mode: 1=MCC/0=SCC 659 * 660 * Return: void 661 */ 662 void wlan_ipa_set_mcc_mode(struct wlan_ipa_priv *ipa_ctx, bool mcc_mode); 663 664 /** 665 * wlan_ipa_set_dfs_cac_tx() - Set DFS cac tx block 666 * @ipa_ctx: IPA context 667 * @tx_block: dfs cac tx block 668 * 669 * Return: void 670 */ 671 static inline 672 void wlan_ipa_set_dfs_cac_tx(struct wlan_ipa_priv *ipa_ctx, bool tx_block) 673 { 674 ipa_ctx->dfs_cac_block_tx = tx_block; 675 } 676 677 /** 678 * wlan_ipa_set_ap_ibss_fwd() - Set AP intra bss forward 679 * @ipa_ctx: IPA context 680 * @session_id: vdev id 681 * @intra_bss: 1 to disable ap intra bss forward and 0 to enable ap intra bss 682 * forward 683 * 684 * Return: void 685 */ 686 static inline 687 void wlan_ipa_set_ap_ibss_fwd(struct wlan_ipa_priv *ipa_ctx, uint8_t session_id, 688 bool intra_bss) 689 { 690 if (session_id >= WLAN_IPA_MAX_SESSION) 691 return; 692 693 ipa_ctx->disable_intrabss_fwd[session_id] = intra_bss; 694 } 695 696 /** 697 * wlan_ipa_uc_ol_init() - Initialize IPA uC offload 698 * @ipa_ctx: IPA context 699 * @osdev: Parent device instance 700 * 701 * This function is called to update IPA pipe configuration with resources 702 * allocated by wlan driver (cds_pre_enable) before enabling it in FW 703 * 704 * Return: QDF_STATUS 705 */ 706 QDF_STATUS wlan_ipa_uc_ol_init(struct wlan_ipa_priv *ipa_ctx, 707 qdf_device_t osdev); 708 709 /** 710 * wlan_ipa_uc_ol_deinit() - Disconnect IPA TX and RX pipes 711 * @ipa_ctx: IPA context 712 * 713 * Return: QDF_STATUS 714 */ 715 QDF_STATUS wlan_ipa_uc_ol_deinit(struct wlan_ipa_priv *ipa_ctx); 716 717 /** 718 * wlan_ipa_flush() - flush IPA exception path SKB's 719 * @ipa_ctx: IPA context 720 * 721 * Return: None 722 */ 723 void wlan_ipa_flush(struct wlan_ipa_priv *ipa_ctx); 724 725 /** 726 * wlan_ipa_suspend() - Suspend IPA 727 * @ipa_ctx: IPA context 728 * 729 * Return: QDF STATUS 730 */ 731 QDF_STATUS wlan_ipa_suspend(struct wlan_ipa_priv *ipa_ctx); 732 733 /** 734 * wlan_ipa_resume() - Resume IPA 735 * @ipa_ctx: IPA context 736 * 737 * Return: QDF STATUS 738 */ 739 QDF_STATUS wlan_ipa_resume(struct wlan_ipa_priv *ipa_ctx); 740 741 #if !defined(QCA_LL_TX_FLOW_CONTROL_V2) && !defined(QCA_IPA_LL_TX_FLOW_CONTROL) 742 /** 743 * wlan_ipa_send_mcc_scc_msg() - Send IPA WLAN_SWITCH_TO_MCC/SCC message 744 * @ipa_ctx: IPA context 745 * @mcc_mode: 0=MCC/1=SCC 746 * 747 * Return: QDF STATUS 748 */ 749 QDF_STATUS wlan_ipa_send_mcc_scc_msg(struct wlan_ipa_priv *ipa_ctx, 750 bool mcc_mode); 751 #else 752 static inline 753 QDF_STATUS wlan_ipa_send_mcc_scc_msg(struct wlan_ipa_priv *ipa_ctx, 754 bool mcc_mode) 755 { 756 return QDF_STATUS_SUCCESS; 757 } 758 759 static inline void wlan_ipa_mcc_work_handler(void *data) 760 { 761 } 762 #endif 763 764 /** 765 * wlan_ipa_wlan_evt() - IPA event handler 766 * @net_dev: Interface net device 767 * @device_mode: Net interface device mode 768 * @session_id: session id for the event 769 * @ipa_event_type: event enum of type ipa_wlan_event 770 * @mac_addr: MAC address associated with the event 771 * @is_2g_iface: true if interface is operating on 2G band, otherwise false 772 * @ipa_obj: IPA context 773 * 774 * Return: QDF_STATUS 775 */ 776 QDF_STATUS wlan_ipa_wlan_evt(qdf_netdev_t net_dev, uint8_t device_mode, 777 uint8_t session_id, 778 enum wlan_ipa_wlan_event ipa_event_type, 779 const uint8_t *mac_addr, bool is_2g_iface, 780 struct wlan_ipa_priv *ipa_obj); 781 782 /** 783 * wlan_ipa_uc_smmu_map() - Map / Unmap DMA buffer to IPA UC 784 * @map: Map / unmap operation 785 * @num_buf: Number of buffers in array 786 * @buf_arr: Buffer array of DMA mem mapping info 787 * 788 * This API maps/unmaps WLAN-IPA buffers if SMMU S1 translation 789 * is enabled. 790 * 791 * Return: Status of map operation 792 */ 793 int wlan_ipa_uc_smmu_map(bool map, uint32_t num_buf, qdf_mem_info_t *buf_arr); 794 795 /** 796 * wlan_ipa_is_fw_wdi_activated() - Is FW WDI activated? 797 * @ipa_ctx: IPA context 798 * 799 * Return: true if FW WDI activated, false otherwise 800 */ 801 bool wlan_ipa_is_fw_wdi_activated(struct wlan_ipa_priv *ipa_ctx); 802 803 /** 804 * wlan_ipa_uc_cleanup_sta - disconnect and cleanup sta iface 805 * @ipa_ctx: IPA context 806 * @net_dev: Interface net device 807 * @session_id: vdev id 808 * 809 * Send disconnect sta event to IPA driver and cleanup IPA iface 810 * if not yet done 811 * 812 * Return: void 813 */ 814 void wlan_ipa_uc_cleanup_sta(struct wlan_ipa_priv *ipa_ctx, 815 qdf_netdev_t net_dev, uint8_t session_id); 816 817 /** 818 * wlan_ipa_uc_disconnect_ap() - send ap disconnect event 819 * @ipa_ctx: IPA context 820 * @net_dev: Interface net device 821 * 822 * Send disconnect ap event to IPA driver 823 * 824 * Return: QDF_STATUS 825 */ 826 QDF_STATUS wlan_ipa_uc_disconnect_ap(struct wlan_ipa_priv *ipa_ctx, 827 qdf_netdev_t net_dev); 828 829 /** 830 * wlan_ipa_cleanup_dev_iface() - Clean up net dev IPA interface 831 * @ipa_ctx: IPA context 832 * @net_dev: Interface net device 833 * @session_id: vdev id 834 * 835 * Return: None 836 */ 837 void wlan_ipa_cleanup_dev_iface(struct wlan_ipa_priv *ipa_ctx, 838 qdf_netdev_t net_dev, uint8_t session_id); 839 840 /** 841 * wlan_ipa_uc_ssr_cleanup() - handle IPA UC clean up during SSR 842 * @ipa_ctx: IPA context 843 * 844 * Return: None 845 */ 846 void wlan_ipa_uc_ssr_cleanup(struct wlan_ipa_priv *ipa_ctx); 847 848 /** 849 * wlan_ipa_fw_rejuvenate_send_msg() - send fw rejuvenate message to IPA driver 850 * @ipa_ctx: IPA context 851 * 852 * Return: void 853 */ 854 void wlan_ipa_fw_rejuvenate_send_msg(struct wlan_ipa_priv *ipa_ctx); 855 856 /** 857 * wlan_ipa_flush_pending_vdev_events() - flush pending vdev ipa events 858 * @ipa_ctx: IPA context 859 * @vdev_id: vdev id 860 * 861 * This function is to flush vdev wlan ipa pending events 862 * 863 * Return: None 864 */ 865 void wlan_ipa_flush_pending_vdev_events(struct wlan_ipa_priv *ipa_ctx, 866 uint8_t vdev_id); 867 868 #ifdef IPA_OPT_WIFI_DP 869 /** 870 * wlan_ipa_wdi_opt_dpath_flt_rsrv_cb() - reserve cce super rules for Rx filter 871 * @ipa_ctx: ipa_context 872 * @out_params: filter reservation params 873 * 874 * Return:int 0 on success, negative on failure 875 * 876 */ 877 int wlan_ipa_wdi_opt_dpath_flt_rsrv_cb( 878 void *ipa_ctx, 879 struct ipa_wdi_opt_dpath_flt_rsrv_cb_params *out_params); 880 881 /** 882 * wlan_ipa_wdi_opt_dpath_notify_flt_rsvd() - notify filter reservation 883 * response to IPA 884 * @is_success: result of filter reservation 885 * 886 * Return: None 887 */ 888 void wlan_ipa_wdi_opt_dpath_notify_flt_rsvd(bool is_success); 889 890 /** 891 * wlan_ipa_wdi_opt_dpath_flt_add_cb - Add rx filter tuple to cce filter 892 * @ipa_ctx: IPA context 893 * @in_out: filter tuple info 894 * 895 * Return: 0 on success, negative on failure 896 */ 897 int wlan_ipa_wdi_opt_dpath_flt_add_cb( 898 void *ipa_ctx, 899 struct ipa_wdi_opt_dpath_flt_add_cb_params *in_out); 900 901 /** 902 * wlan_ipa_wdi_opt_dpath_flt_rem_cb() - Remove rx filter tuple from cce filter 903 * @ipa_ctx: IPA context 904 * @in: filter tuple info 905 * 906 * Return: 0 on success, negative on failure 907 */ 908 int wlan_ipa_wdi_opt_dpath_flt_rem_cb( 909 void *ipa_ctx, 910 struct ipa_wdi_opt_dpath_flt_rem_cb_params *in); 911 912 /** 913 * wlan_ipa_wdi_opt_dpath_notify_flt_add_rem_cb() - notify filter add/remove 914 * result to IPA 915 * @result0: result of add/remove filter0 916 * @result1: result of add/remove filter1 917 * 918 * Return: void 919 */ 920 void wlan_ipa_wdi_opt_dpath_notify_flt_add_rem_cb(int result0, int result1); 921 922 /** 923 * wlan_ipa_wdi_opt_dpath_flt_rsrv_rel_cb() - cb to release cce super rules 924 * @ipa_ctx: IPA context 925 * 926 * Return: 0 on success, negative on failure 927 * 928 */ 929 int wlan_ipa_wdi_opt_dpath_flt_rsrv_rel_cb(void *ipa_ctx); 930 931 /** 932 * wlan_ipa_wdi_opt_dpath_notify_flt_rlsd() - notify filter release 933 * response to IPA 934 * @result0: result of filter0 release 935 * @result1: result of filter1 release 936 * 937 * Return: void 938 */ 939 void wlan_ipa_wdi_opt_dpath_notify_flt_rlsd(int result0, int result1); 940 941 #endif /* IPA_OPT_WIFI_DP */ 942 943 #ifdef IPA_WDI3_TX_TWO_PIPES 944 /** 945 * wlan_ipa_get_alt_pipe() - Get alt_pipe for vdev_id 946 * @ipa_ctx: IPA context 947 * @vdev_id: vdev_id of the target interface 948 * @alt_pipe: Boolean output to indicate if interface with @vdev_id 949 * is using alternate TX pipe or not. 950 * 951 * Return: QDF_STATUS 952 */ 953 QDF_STATUS wlan_ipa_get_alt_pipe(struct wlan_ipa_priv *ipa_ctx, 954 uint8_t vdev_id, 955 bool *alt_pipe); 956 #else /* !IPA_WDI3_TX_TWO_PIPES */ 957 static inline 958 QDF_STATUS wlan_ipa_get_alt_pipe(struct wlan_ipa_priv *ipa_ctx, 959 uint8_t vdev_id, 960 bool *alt_pipe) 961 { 962 return QDF_STATUS_E_INVAL; 963 } 964 #endif /* IPA_WDI3_TX_TWO_PIPES */ 965 966 #endif /* IPA_OFFLOAD */ 967 #endif /* _WLAN_IPA_CORE_H_ */ 968