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