1 /* 2 * Copyright (c) 2016-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 /** 21 * DOC: cdp_txrx_ipa.h 22 * Define the host data path IP Acceleraor API functions 23 */ 24 #ifndef _CDP_TXRX_IPA_H_ 25 #define _CDP_TXRX_IPA_H_ 26 27 #ifdef IPA_OFFLOAD 28 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 10, 0)) || \ 29 defined(CONFIG_IPA_WDI_UNIFIED_API) 30 #include <qdf_ipa_wdi3.h> 31 #else 32 #include <qdf_ipa.h> 33 #endif 34 #include <cdp_txrx_cmn.h> 35 #include "cdp_txrx_handle.h" 36 #ifdef IPA_OPT_WIFI_DP 37 #include <target_if.h> 38 #endif 39 40 /** 41 * cdp_ipa_get_resource() - Get allocated WLAN resources for IPA data path 42 * @soc: data path soc handle 43 * @pdev_id: device instance id 44 * 45 * Get allocated WLAN resources for IPA data path 46 * 47 * return QDF_STATUS_SUCCESS 48 */ 49 static inline QDF_STATUS 50 cdp_ipa_get_resource(ol_txrx_soc_handle soc, uint8_t pdev_id) 51 { 52 if (!soc || !soc->ops || !soc->ops->ipa_ops) { 53 QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL, 54 "%s invalid instance", __func__); 55 return QDF_STATUS_E_FAILURE; 56 } 57 58 if (soc->ops->ipa_ops->ipa_get_resource) 59 return soc->ops->ipa_ops->ipa_get_resource(soc, pdev_id); 60 61 return QDF_STATUS_SUCCESS; 62 } 63 64 /** 65 * cdp_ipa_set_doorbell_paddr() - give IPA db paddr to FW 66 * @soc: data path soc handle 67 * @pdev_id: device instance id 68 * 69 * give IPA db paddr to FW 70 * 71 * return QDF_STATUS_SUCCESS 72 */ 73 static inline QDF_STATUS 74 cdp_ipa_set_doorbell_paddr(ol_txrx_soc_handle soc, uint8_t pdev_id) 75 { 76 if (!soc || !soc->ops || !soc->ops->ipa_ops) { 77 QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL, 78 "%s invalid instance", __func__); 79 return QDF_STATUS_E_FAILURE; 80 } 81 82 if (soc->ops->ipa_ops->ipa_set_doorbell_paddr) 83 return soc->ops->ipa_ops->ipa_set_doorbell_paddr(soc, pdev_id); 84 85 return QDF_STATUS_SUCCESS; 86 } 87 88 /** 89 * cdp_ipa_iounmap_doorbell_vaddr() - unmap IPA RX db vaddr 90 * @soc: data path soc handle 91 * @pdev_id: device instance id 92 * 93 * Unmap IPA RX db vaddr 94 * 95 * return QDF_STATUS_SUCCESS 96 */ 97 static inline QDF_STATUS 98 cdp_ipa_iounmap_doorbell_vaddr(ol_txrx_soc_handle soc, uint8_t pdev_id) 99 { 100 if (!soc || !soc->ops || !soc->ops->ipa_ops) { 101 QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL, 102 "%s invalid instance", __func__); 103 return QDF_STATUS_E_FAILURE; 104 } 105 106 if (soc->ops->ipa_ops->ipa_iounmap_doorbell_vaddr) 107 return soc->ops->ipa_ops->ipa_iounmap_doorbell_vaddr( 108 soc, pdev_id); 109 110 return QDF_STATUS_SUCCESS; 111 } 112 113 /** 114 * cdp_ipa_set_active() - activate/de-ctivate IPA offload path 115 * @soc: data path soc handle 116 * @pdev_id: device instance id 117 * @uc_active: activate or de-activate 118 * @is_tx: toggle tx or rx data path 119 * 120 * activate/de-ctivate IPA offload path 121 * 122 * return QDF_STATUS_SUCCESS 123 */ 124 static inline QDF_STATUS 125 cdp_ipa_set_active(ol_txrx_soc_handle soc, uint8_t pdev_id, bool uc_active, 126 bool is_tx) 127 { 128 if (!soc || !soc->ops || !soc->ops->ipa_ops) { 129 QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL, 130 "%s invalid instance", __func__); 131 return QDF_STATUS_E_FAILURE; 132 } 133 134 if (soc->ops->ipa_ops->ipa_set_active) 135 return soc->ops->ipa_ops->ipa_set_active(soc, pdev_id, 136 uc_active, is_tx); 137 138 return QDF_STATUS_SUCCESS; 139 } 140 141 /** 142 * cdp_ipa_op_response() - event handler from FW 143 * @soc: data path soc handle 144 * @pdev_id: device instance id 145 * @op_msg: event contents from firmware 146 * 147 * event handler from FW 148 * 149 * return QDF_STATUS_SUCCESS 150 */ 151 static inline QDF_STATUS 152 cdp_ipa_op_response(ol_txrx_soc_handle soc, uint8_t pdev_id, uint8_t *op_msg) 153 { 154 if (!soc || !soc->ops || !soc->ops->ipa_ops) { 155 QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL, 156 "%s invalid instance", __func__); 157 return QDF_STATUS_E_FAILURE; 158 } 159 160 if (soc->ops->ipa_ops->ipa_op_response) 161 return soc->ops->ipa_ops->ipa_op_response(soc, pdev_id, op_msg); 162 163 return QDF_STATUS_SUCCESS; 164 } 165 166 /** 167 * cdp_ipa_register_op_cb() - register event handler function pointer 168 * @soc: data path soc handle 169 * @pdev_id: device instance id 170 * @op_cb: event handler callback function pointer 171 * @usr_ctxt: user context to registered 172 * 173 * register event handler function pointer 174 * 175 * return QDF_STATUS_SUCCESS 176 */ 177 static inline QDF_STATUS 178 cdp_ipa_register_op_cb(ol_txrx_soc_handle soc, uint8_t pdev_id, 179 ipa_uc_op_cb_type op_cb, void *usr_ctxt) 180 { 181 if (!soc || !soc->ops || !soc->ops->ipa_ops) { 182 QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL, 183 "%s invalid instance", __func__); 184 return QDF_STATUS_E_FAILURE; 185 } 186 187 if (soc->ops->ipa_ops->ipa_register_op_cb) 188 return soc->ops->ipa_ops->ipa_register_op_cb(soc, pdev_id, 189 op_cb, usr_ctxt); 190 191 return QDF_STATUS_SUCCESS; 192 } 193 194 /** 195 * cdp_ipa_deregister_op_cb() - deregister event handler function pointer 196 * @soc: data path soc handle 197 * @pdev_id: device instance id 198 * 199 * Deregister event handler function pointer from pdev 200 * 201 * return QDF_STATUS_SUCCESS 202 */ 203 static inline 204 void cdp_ipa_deregister_op_cb(ol_txrx_soc_handle soc, uint8_t pdev_id) 205 { 206 if (!soc || !soc->ops || !soc->ops->ipa_ops) { 207 QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL, 208 "%s invalid instance", __func__); 209 return; 210 } 211 212 if (soc->ops->ipa_ops->ipa_deregister_op_cb) 213 soc->ops->ipa_ops->ipa_deregister_op_cb(soc, pdev_id); 214 } 215 216 /** 217 * cdp_ipa_get_stat() - get IPA data path stats from FW 218 * @soc: data path soc handle 219 * @pdev_id: device instance id 220 * 221 * get IPA data path stats from FW async 222 * 223 * return QDF_STATUS_SUCCESS 224 */ 225 static inline QDF_STATUS 226 cdp_ipa_get_stat(ol_txrx_soc_handle soc, uint8_t pdev_id) 227 { 228 if (!soc || !soc->ops || !soc->ops->ipa_ops) { 229 QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL, 230 "%s invalid instance", __func__); 231 return QDF_STATUS_E_FAILURE; 232 } 233 234 if (soc->ops->ipa_ops->ipa_get_stat) 235 return soc->ops->ipa_ops->ipa_get_stat(soc, pdev_id); 236 237 return QDF_STATUS_SUCCESS; 238 } 239 240 /** 241 * cdp_ipa_tx_send_data_frame() - send IPA data frame 242 * @soc: data path soc handle 243 * @vdev_id: vdev id 244 * @skb: skb 245 * 246 * Return: skb/ NULL is for success 247 */ 248 static inline qdf_nbuf_t cdp_ipa_tx_send_data_frame(ol_txrx_soc_handle soc, 249 uint8_t vdev_id, 250 qdf_nbuf_t skb) 251 { 252 if (!soc || !soc->ops || !soc->ops->ipa_ops) { 253 QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL, 254 "%s invalid instance", __func__); 255 return skb; 256 } 257 258 if (soc->ops->ipa_ops->ipa_tx_data_frame) 259 return soc->ops->ipa_ops->ipa_tx_data_frame(soc, vdev_id, skb); 260 261 return skb; 262 } 263 264 /** 265 * cdp_ipa_set_uc_tx_partition_base() - set tx packet partition base 266 * @soc: data path soc handle 267 * @cfg_pdev: physical device instance config 268 * @value: partition base value 269 * 270 * Return: QDF_STATUS 271 */ 272 static inline QDF_STATUS 273 cdp_ipa_set_uc_tx_partition_base(ol_txrx_soc_handle soc, 274 struct cdp_cfg *cfg_pdev, uint32_t value) 275 { 276 if (!soc || !soc->ops || !soc->ops->ipa_ops || !cfg_pdev) { 277 QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL, 278 "%s invalid instance", __func__); 279 return QDF_STATUS_E_FAILURE; 280 } 281 282 if (soc->ops->ipa_ops->ipa_set_uc_tx_partition_base) 283 soc->ops->ipa_ops->ipa_set_uc_tx_partition_base(cfg_pdev, 284 value); 285 286 return QDF_STATUS_SUCCESS; 287 } 288 289 #ifdef FEATURE_METERING 290 /** 291 * cdp_ipa_uc_get_share_stats() - get Tx/Rx byte stats from FW 292 * @soc: data path soc handle 293 * @pdev_id: physical device instance number 294 * @value: reset stats 295 * 296 * Return: QDF_STATUS 297 */ 298 static inline QDF_STATUS 299 cdp_ipa_uc_get_share_stats(ol_txrx_soc_handle soc, uint8_t pdev_id, 300 uint8_t value) 301 { 302 if (!soc || !soc->ops || !soc->ops->ipa_ops) { 303 QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL, 304 "%s invalid instance", __func__); 305 return QDF_STATUS_E_FAILURE; 306 } 307 308 if (soc->ops->ipa_ops->ipa_uc_get_share_stats) 309 return soc->ops->ipa_ops->ipa_uc_get_share_stats(soc, pdev_id, 310 value); 311 312 return QDF_STATUS_SUCCESS; 313 } 314 315 /** 316 * cdp_ipa_uc_set_quota() - set quota limit to FW 317 * @soc: data path soc handle 318 * @pdev_id: physical device instance number 319 * @value: quota limit bytes 320 * 321 * Return: QDF_STATUS 322 */ 323 static inline QDF_STATUS 324 cdp_ipa_uc_set_quota(ol_txrx_soc_handle soc, uint8_t pdev_id, uint64_t value) 325 { 326 if (!soc || !soc->ops || !soc->ops->ipa_ops) { 327 QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL, 328 "%s invalid instance", __func__); 329 return QDF_STATUS_E_FAILURE; 330 } 331 332 if (soc->ops->ipa_ops->ipa_uc_set_quota) 333 return soc->ops->ipa_ops->ipa_uc_set_quota(soc, pdev_id, value); 334 335 return QDF_STATUS_SUCCESS; 336 } 337 #endif 338 339 /** 340 * cdp_ipa_enable_autonomy() - Enable autonomy RX data path 341 * @soc: data path soc handle 342 * @pdev_id: physical device instance number 343 * 344 * IPA Data path is enabled and resumed. 345 * All autonomy data path elements are ready to deliver packet 346 * All RX packet should routed to IPA_REO ring, then IPA can receive packet 347 * from WLAN 348 * 349 * Return: QDF_STATUS 350 */ 351 static inline QDF_STATUS 352 cdp_ipa_enable_autonomy(ol_txrx_soc_handle soc, uint8_t pdev_id) 353 { 354 if (!soc || !soc->ops || !soc->ops->ipa_ops) { 355 QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL, 356 "%s invalid instance", __func__); 357 return QDF_STATUS_E_FAILURE; 358 } 359 360 if (soc->ops->ipa_ops->ipa_enable_autonomy) 361 return soc->ops->ipa_ops->ipa_enable_autonomy(soc, pdev_id); 362 363 return QDF_STATUS_SUCCESS; 364 } 365 366 /** 367 * cdp_ipa_disable_autonomy() - Disable autonomy RX data path 368 * @soc: data path soc handle 369 * @pdev_id: physical device instance number 370 * 371 * IPA Data path is enabled and resumed. 372 * All autonomy datapath elements are ready to deliver packet 373 * All RX packet should routed to IPA_REO ring, then IPA can receive packet 374 * from WLAN 375 * 376 * Return: QDF_STATUS 377 */ 378 static inline QDF_STATUS 379 cdp_ipa_disable_autonomy(ol_txrx_soc_handle soc, uint8_t pdev_id) 380 { 381 if (!soc || !soc->ops || !soc->ops->ipa_ops) { 382 QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL, 383 "%s invalid instance", __func__); 384 return QDF_STATUS_E_FAILURE; 385 } 386 if (soc->ops->ipa_ops->ipa_disable_autonomy) 387 return soc->ops->ipa_ops->ipa_disable_autonomy(soc, pdev_id); 388 389 return QDF_STATUS_SUCCESS; 390 } 391 392 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 10, 0)) || \ 393 defined(CONFIG_IPA_WDI_UNIFIED_API) 394 395 /** 396 * cdp_ipa_setup() - Setup and connect IPA pipes 397 * @soc: data path soc handle 398 * @pdev_id: handle to the device instance number 399 * @ipa_i2w_cb: IPA to WLAN callback 400 * @ipa_w2i_cb: WLAN to IPA callback 401 * @ipa_wdi_meter_notifier_cb: IPA WDI metering callback 402 * @ipa_desc_size: IPA descriptor size 403 * @ipa_priv: handle to the HTT instance 404 * @is_rm_enabled: Is IPA RM enabled or not 405 * @tx_pipe_handle: pointer to Tx pipe handle 406 * @rx_pipe_handle: pointer to Rx pipe handle 407 * @is_smmu_enabled: Is SMMU enabled or not 408 * @sys_in: parameters to setup sys pipe in mcc mode 409 * @over_gsi: Is IPA using GSI 410 * @hdl: IPA handle 411 * @id: IPA instance id 412 * @ipa_ast_notify_cb: IPA to WLAN callback for ast create 413 * 414 * Return: QDF_STATUS 415 */ 416 static inline QDF_STATUS 417 cdp_ipa_setup(ol_txrx_soc_handle soc, uint8_t pdev_id, void *ipa_i2w_cb, 418 void *ipa_w2i_cb, void *ipa_wdi_meter_notifier_cb, 419 uint32_t ipa_desc_size, void *ipa_priv, bool is_rm_enabled, 420 uint32_t *tx_pipe_handle, uint32_t *rx_pipe_handle, 421 bool is_smmu_enabled, qdf_ipa_sys_connect_params_t *sys_in, 422 bool over_gsi, qdf_ipa_wdi_hdl_t hdl, qdf_ipa_wdi_hdl_t id, 423 void *ipa_ast_notify_cb) 424 { 425 if (!soc || !soc->ops || !soc->ops->ipa_ops) { 426 QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL, 427 "%s invalid instance", __func__); 428 return QDF_STATUS_E_FAILURE; 429 } 430 431 if (soc->ops->ipa_ops->ipa_setup) 432 return soc->ops->ipa_ops->ipa_setup(soc, pdev_id, ipa_i2w_cb, 433 ipa_w2i_cb, 434 ipa_wdi_meter_notifier_cb, 435 ipa_desc_size, ipa_priv, 436 is_rm_enabled, 437 tx_pipe_handle, 438 rx_pipe_handle, 439 is_smmu_enabled, 440 sys_in, over_gsi, hdl, id, 441 ipa_ast_notify_cb); 442 443 return QDF_STATUS_SUCCESS; 444 } 445 #else /* CONFIG_IPA_WDI_UNIFIED_API */ 446 /** 447 * cdp_ipa_setup() - Setup and connect IPA pipes 448 * @soc: data path soc handle 449 * @pdev_id: handle to the device instance number 450 * @ipa_i2w_cb: IPA to WLAN callback 451 * @ipa_w2i_cb: WLAN to IPA callback 452 * @ipa_wdi_meter_notifier_cb: IPA WDI metering callback 453 * @ipa_desc_size: IPA descriptor size 454 * @ipa_priv: handle to the HTT instance 455 * @is_rm_enabled: Is IPA RM enabled or not 456 * @tx_pipe_handle: pointer to Tx pipe handle 457 * @rx_pipe_handle: pointer to Rx pipe handle 458 * 459 * Return: QDF_STATUS 460 */ 461 static inline QDF_STATUS 462 cdp_ipa_setup(ol_txrx_soc_handle soc, uint8_t pdev_id, void *ipa_i2w_cb, 463 void *ipa_w2i_cb, void *ipa_wdi_meter_notifier_cb, 464 uint32_t ipa_desc_size, void *ipa_priv, bool is_rm_enabled, 465 uint32_t *tx_pipe_handle, uint32_t *rx_pipe_handle) 466 { 467 if (!soc || !soc->ops || !soc->ops->ipa_ops) { 468 QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL, 469 "%s invalid instance", __func__); 470 return QDF_STATUS_E_FAILURE; 471 } 472 473 if (soc->ops->ipa_ops->ipa_setup) 474 return soc->ops->ipa_ops->ipa_setup(soc, pdev_id, ipa_i2w_cb, 475 ipa_w2i_cb, 476 ipa_wdi_meter_notifier_cb, 477 ipa_desc_size, ipa_priv, 478 is_rm_enabled, 479 tx_pipe_handle, 480 rx_pipe_handle); 481 482 return QDF_STATUS_SUCCESS; 483 } 484 #endif /* CONFIG_IPA_WDI_UNIFIED_API */ 485 486 /** 487 * cdp_ipa_cleanup() - Disconnect IPA pipes 488 * @soc: data path soc handle 489 * @pdev_id: handle to the device instance number 490 * @tx_pipe_handle: Tx pipe handle 491 * @rx_pipe_handle: Rx pipe handle 492 * @hdl: IPA handle 493 * 494 * Return: QDF_STATUS 495 */ 496 static inline QDF_STATUS 497 cdp_ipa_cleanup(ol_txrx_soc_handle soc, uint8_t pdev_id, 498 uint32_t tx_pipe_handle, uint32_t rx_pipe_handle, 499 qdf_ipa_wdi_hdl_t hdl) 500 { 501 if (!soc || !soc->ops || !soc->ops->ipa_ops) { 502 QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL, 503 "%s invalid instance", __func__); 504 return QDF_STATUS_E_FAILURE; 505 } 506 507 if (soc->ops->ipa_ops->ipa_cleanup) 508 return soc->ops->ipa_ops->ipa_cleanup(soc, pdev_id, 509 tx_pipe_handle, 510 rx_pipe_handle, hdl); 511 512 return QDF_STATUS_SUCCESS; 513 } 514 515 /** 516 * cdp_ipa_setup_iface() - Setup IPA header and register interface 517 * @soc: data path soc handle 518 * @ifname: Interface name 519 * @mac_addr: Interface MAC address 520 * @prod_client: IPA prod client type 521 * @cons_client: IPA cons client type 522 * @session_id: Session ID 523 * @is_ipv6_enabled: Is IPV6 enabled or not 524 * @hdl: IPA handle 525 * 526 * Return: QDF_STATUS 527 */ 528 static inline QDF_STATUS 529 cdp_ipa_setup_iface(ol_txrx_soc_handle soc, char *ifname, uint8_t *mac_addr, 530 qdf_ipa_client_type_t prod_client, 531 qdf_ipa_client_type_t cons_client, 532 uint8_t session_id, bool is_ipv6_enabled, 533 qdf_ipa_wdi_hdl_t hdl) 534 { 535 if (!soc || !soc->ops || !soc->ops->ipa_ops) { 536 QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL, 537 "%s invalid instance", __func__); 538 return QDF_STATUS_E_FAILURE; 539 } 540 541 if (soc->ops->ipa_ops->ipa_setup_iface) 542 return soc->ops->ipa_ops->ipa_setup_iface(ifname, mac_addr, 543 prod_client, 544 cons_client, 545 session_id, 546 is_ipv6_enabled, 547 hdl); 548 549 return QDF_STATUS_SUCCESS; 550 } 551 552 /** 553 * cdp_ipa_cleanup_iface() - Cleanup IPA header and deregister interface 554 * @soc: data path soc handle 555 * @ifname: Interface name 556 * @is_ipv6_enabled: Is IPV6 enabled or not 557 * @hdl: IPA handle 558 * 559 * Return: QDF_STATUS 560 */ 561 static inline QDF_STATUS 562 cdp_ipa_cleanup_iface(ol_txrx_soc_handle soc, char *ifname, 563 bool is_ipv6_enabled, qdf_ipa_wdi_hdl_t hdl) 564 { 565 if (!soc || !soc->ops || !soc->ops->ipa_ops) { 566 QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL, 567 "%s invalid instance", __func__); 568 return QDF_STATUS_E_FAILURE; 569 } 570 571 if (soc->ops->ipa_ops->ipa_cleanup_iface) 572 return soc->ops->ipa_ops->ipa_cleanup_iface(ifname, 573 is_ipv6_enabled, 574 hdl); 575 576 return QDF_STATUS_SUCCESS; 577 } 578 579 /** 580 * cdp_ipa_uc_enable_pipes() - Enable and resume traffic on Tx/Rx pipes 581 * @soc: data path soc handle 582 * @pdev_id: device instance id 583 * @hdl: IPA handle 584 * 585 * Return: QDF_STATUS 586 */ 587 static inline QDF_STATUS 588 cdp_ipa_enable_pipes(ol_txrx_soc_handle soc, uint8_t pdev_id, 589 qdf_ipa_wdi_hdl_t hdl) 590 { 591 if (!soc || !soc->ops || !soc->ops->ipa_ops) { 592 QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL, 593 "%s invalid instance", __func__); 594 return QDF_STATUS_E_FAILURE; 595 } 596 597 if (soc->ops->ipa_ops->ipa_enable_pipes) 598 return soc->ops->ipa_ops->ipa_enable_pipes(soc, pdev_id, hdl); 599 600 return QDF_STATUS_SUCCESS; 601 } 602 603 /** 604 * cdp_ipa_disable_pipes() - Suspend traffic and disable Tx/Rx pipes 605 * @soc: data path soc handle 606 * @pdev_id: device instance id 607 * @hdl: IPA handle 608 * 609 * Return: QDF_STATUS 610 */ 611 static inline QDF_STATUS 612 cdp_ipa_disable_pipes(ol_txrx_soc_handle soc, uint8_t pdev_id, 613 qdf_ipa_wdi_hdl_t hdl) 614 { 615 if (!soc || !soc->ops || !soc->ops->ipa_ops) { 616 QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL, 617 "%s invalid instance", __func__); 618 return QDF_STATUS_E_FAILURE; 619 } 620 621 if (soc->ops->ipa_ops->ipa_disable_pipes) 622 return soc->ops->ipa_ops->ipa_disable_pipes(soc, pdev_id, hdl); 623 624 return QDF_STATUS_SUCCESS; 625 } 626 627 /** 628 * cdp_ipa_set_perf_level() - Set IPA clock bandwidth based on data rates 629 * @soc: data path soc handle 630 * @client: WLAN Client ID 631 * @max_supported_bw_mbps: Maximum bandwidth needed (in Mbps) 632 * @hdl: IPA handle 633 * 634 * Return: 0 on success, negative errno on error 635 */ 636 static inline QDF_STATUS 637 cdp_ipa_set_perf_level(ol_txrx_soc_handle soc, int client, 638 uint32_t max_supported_bw_mbps, qdf_ipa_wdi_hdl_t hdl) 639 { 640 if (!soc || !soc->ops || !soc->ops->ipa_ops) { 641 QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL, 642 "%s invalid instance", __func__); 643 return QDF_STATUS_E_FAILURE; 644 } 645 646 if (soc->ops->ipa_ops->ipa_set_perf_level) 647 return soc->ops->ipa_ops->ipa_set_perf_level(client, 648 max_supported_bw_mbps, hdl); 649 650 return QDF_STATUS_SUCCESS; 651 } 652 653 /** 654 * cdp_ipa_rx_intrabss_fwd() - Perform intra-bss fwd for IPA RX path 655 * 656 * @soc: data path soc handle 657 * @vdev_id: vdev id 658 * @nbuf: pointer to skb of ethernet packet received from IPA RX path 659 * @fwd_success: pointer to indicate if skb succeeded in intra-bss TX 660 * 661 * This function performs intra-bss forwarding for WDI 3.0 IPA RX path. 662 * 663 * Return: true if packet is intra-bss fwd-ed and no need to pass to 664 * network stack. false if packet needs to be passed to network stack. 665 */ 666 static inline bool 667 cdp_ipa_rx_intrabss_fwd(ol_txrx_soc_handle soc, uint8_t vdev_id, 668 qdf_nbuf_t nbuf, bool *fwd_success) 669 { 670 if (!soc || !soc->ops || !soc->ops->ipa_ops || !fwd_success) { 671 QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL, 672 "%s invalid instance", __func__); 673 return QDF_STATUS_E_FAILURE; 674 } 675 676 if (soc->ops->ipa_ops->ipa_rx_intrabss_fwd) 677 return soc->ops->ipa_ops->ipa_rx_intrabss_fwd(soc, vdev_id, 678 nbuf, 679 fwd_success); 680 681 /* Fall back to pass up to stack */ 682 return false; 683 } 684 685 /** 686 * cdp_ipa_tx_buf_smmu_mapping() - Create SMMU mappings for Tx 687 * buffers allocated to IPA 688 * @soc: data path soc handle 689 * @pdev_id: device instance id 690 * @line: line number 691 * @func: function name 692 * 693 * Create SMMU mappings for Tx buffers allocated to IPA 694 * 695 * return QDF_STATUS_SUCCESS 696 */ 697 static inline QDF_STATUS 698 cdp_ipa_tx_buf_smmu_mapping(ol_txrx_soc_handle soc, uint8_t pdev_id, 699 const char *func, uint32_t line) 700 { 701 if (!soc || !soc->ops || !soc->ops->ipa_ops) { 702 QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL, 703 "%s invalid instance", __func__); 704 return QDF_STATUS_E_FAILURE; 705 } 706 707 if (soc->ops->ipa_ops->ipa_tx_buf_smmu_mapping) 708 return soc->ops->ipa_ops->ipa_tx_buf_smmu_mapping(soc, pdev_id, 709 func, 710 line); 711 712 return QDF_STATUS_SUCCESS; 713 } 714 715 /** 716 * cdp_ipa_tx_buf_smmu_unmapping() - Release SMMU mappings for Tx 717 * buffers allocated to IPA 718 * @soc: data path soc handle 719 * @pdev_id: device instance id 720 * @line: line number 721 * @func: function name 722 * 723 * Release SMMU mappings for Tx buffers allocated to IPA 724 * 725 * return QDF_STATUS_SUCCESS 726 */ 727 static inline QDF_STATUS 728 cdp_ipa_tx_buf_smmu_unmapping(ol_txrx_soc_handle soc, uint8_t pdev_id, 729 const char *func, uint32_t line) 730 { 731 if (!soc || !soc->ops || !soc->ops->ipa_ops) { 732 QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL, 733 "%s invalid instance", __func__); 734 return QDF_STATUS_E_FAILURE; 735 } 736 737 if (soc->ops->ipa_ops->ipa_tx_buf_smmu_unmapping) 738 return soc->ops->ipa_ops->ipa_tx_buf_smmu_unmapping(soc, 739 pdev_id, 740 func, 741 line); 742 743 return QDF_STATUS_SUCCESS; 744 } 745 746 /** 747 * cdp_ipa_rx_buf_smmu_pool_mapping() - Create SMMU mappings for Rx pool 748 * @soc: data path soc handle 749 * @pdev_id: pdev id 750 * @create: Map/unmap 751 * @line: line number 752 * @func: function name 753 * 754 * Create SMMU map/unmap for Rx buffers allocated to IPA 755 * 756 * return QDF_STATUS_SUCCESS 757 */ 758 static inline QDF_STATUS 759 cdp_ipa_rx_buf_smmu_pool_mapping(ol_txrx_soc_handle soc, uint8_t pdev_id, 760 bool create, const char *func, uint32_t line) 761 { 762 if (!soc || !soc->ops || !soc->ops->ipa_ops) { 763 QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL, 764 "%s invalid instance", __func__); 765 return QDF_STATUS_E_FAILURE; 766 } 767 768 if (soc->ops->ipa_ops->ipa_rx_buf_smmu_pool_mapping) 769 return soc->ops->ipa_ops->ipa_rx_buf_smmu_pool_mapping(soc, 770 pdev_id, create, func, line); 771 772 return QDF_STATUS_SUCCESS; 773 } 774 775 static inline QDF_STATUS cdp_ipa_set_smmu_mapped(ol_txrx_soc_handle soc, 776 int val) 777 { 778 if (!soc || !soc->ops || !soc->ops->ipa_ops) { 779 QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL, 780 "%s invalid instance", __func__); 781 return QDF_STATUS_E_FAILURE; 782 } 783 784 if (soc->ops->ipa_ops->ipa_set_smmu_mapped) 785 return soc->ops->ipa_ops->ipa_set_smmu_mapped(soc, val); 786 787 return QDF_STATUS_SUCCESS; 788 } 789 790 static inline int cdp_ipa_get_smmu_mapped(ol_txrx_soc_handle soc) 791 { 792 if (!soc || !soc->ops || !soc->ops->ipa_ops) { 793 QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL, 794 "%s invalid instance", __func__); 795 return QDF_STATUS_E_FAILURE; 796 } 797 798 if (soc->ops->ipa_ops->ipa_get_smmu_mapped) 799 return soc->ops->ipa_ops->ipa_get_smmu_mapped(soc); 800 801 return QDF_STATUS_SUCCESS; 802 } 803 804 #ifdef IPA_WDS_EASYMESH_FEATURE 805 /** 806 * cdp_ipa_ast_create() - Create/update AST entry in AST table 807 * for learning/roaming packets from IPA 808 * @soc: data path soc handle 809 * @data: Structure used for updating the AST table 810 * 811 * Create/update AST entry in AST table for learning/roaming packets from IPA 812 * 813 * Return: QDF_STATUS 814 */ 815 static inline QDF_STATUS 816 cdp_ipa_ast_create(ol_txrx_soc_handle soc, qdf_ipa_ast_info_type_t *data) 817 { 818 if (!soc || !soc->ops || !soc->ops->ipa_ops) { 819 QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL, 820 "%s invalid instance", __func__); 821 return QDF_STATUS_E_FAILURE; 822 } 823 824 if (soc->ops->ipa_ops->ipa_ast_create) 825 return soc->ops->ipa_ops->ipa_ast_create(soc, data); 826 827 return QDF_STATUS_SUCCESS; 828 } 829 #endif 830 831 #ifdef IPA_OPT_WIFI_DP 832 /* 833 * cdp_ipa_pcie_link_up() - Send request to hold PCIe link in L0 834 * @soc - cdp soc handle 835 * 836 * Return: 0 for success, negative for failure 837 */ 838 static inline int 839 cdp_ipa_pcie_link_up(ol_txrx_soc_handle soc) 840 { 841 if (!soc || !soc->ops || !soc->ops->ipa_ops) { 842 QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL, 843 "%s invalid instance", __func__); 844 return QDF_STATUS_E_FAILURE; 845 } 846 847 if (soc->ops->ipa_ops->ipa_pcie_link_up) 848 return soc->ops->ipa_ops->ipa_pcie_link_up(soc); 849 850 return QDF_STATUS_SUCCESS; 851 } 852 853 /* 854 * cdp_ipa_pcie_link_down() - Release request to hold PCIe link in L0 855 * @soc - cdp soc handle 856 * 857 * Return: 0 for success, negative for failure 858 */ 859 static inline int 860 cdp_ipa_pcie_link_down(ol_txrx_soc_handle soc) 861 { 862 if (!soc || !soc->ops || !soc->ops->ipa_ops) { 863 QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL, 864 "%s invalid instance", __func__); 865 return QDF_STATUS_E_FAILURE; 866 } 867 868 if (soc->ops->ipa_ops->ipa_pcie_link_down) 869 soc->ops->ipa_ops->ipa_pcie_link_down(soc); 870 871 return QDF_STATUS_SUCCESS; 872 } 873 #endif 874 875 /** 876 * cdp_ipa_update_peer_rx_stats() - update peer rx stats 877 * @soc: data path soc handle 878 * @vdev_id: vdev id 879 * @peer_mac: Peer Mac Address 880 * @nbuf: pointer to data packet 881 * 882 * Return: QDF_STATUS 883 */ 884 static inline QDF_STATUS 885 cdp_ipa_update_peer_rx_stats(ol_txrx_soc_handle soc, uint8_t vdev_id, 886 uint8_t *peer_mac, qdf_nbuf_t nbuf) 887 { 888 if (!soc || !soc->ops || !soc->ops->ipa_ops) { 889 QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL, 890 "%s invalid instance", __func__); 891 return QDF_STATUS_E_FAILURE; 892 } 893 894 if (soc->ops->ipa_ops->ipa_update_peer_rx_stats) 895 return soc->ops->ipa_ops->ipa_update_peer_rx_stats(soc, 896 vdev_id, 897 peer_mac, 898 nbuf); 899 900 return QDF_STATUS_SUCCESS; 901 } 902 903 #ifdef IPA_OPT_WIFI_DP 904 #define RX_CCE_SUPER_RULE_SETUP_NUM 2 905 struct addr_params { 906 uint8_t valid; 907 uint8_t src_ipv4_addr[4]; 908 uint8_t dst_ipv4_addr[4]; 909 uint8_t src_ipv6_addr[16]; 910 uint8_t dst_ipv6_addr[16]; 911 uint8_t l4_type; 912 uint16_t l3_type; 913 uint16_t src_port; 914 uint16_t dst_port; 915 uint32_t flt_hdl; 916 uint8_t ipa_flt_evnt_required; 917 bool ipa_flt_in_use; 918 }; 919 920 struct wifi_dp_flt_setup { 921 uint8_t pdev_id; 922 uint8_t op; 923 uint8_t num_filters; 924 uint32_t ipa_flt_evnt_response; 925 struct addr_params flt_addr_params[RX_CCE_SUPER_RULE_SETUP_NUM]; 926 }; 927 928 static inline QDF_STATUS 929 cdp_ipa_rx_cce_super_rule_setup(ol_txrx_soc_handle soc, 930 void *flt_params) 931 { 932 if (!soc || !soc->ops || !soc->ops->ipa_ops) { 933 QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL, 934 "%s invalid instance", __func__); 935 return QDF_STATUS_E_FAILURE; 936 } 937 938 if (soc->ops->ipa_ops->ipa_rx_super_rule_setup) 939 return soc->ops->ipa_ops->ipa_rx_super_rule_setup(soc, 940 flt_params); 941 942 return QDF_STATUS_SUCCESS; 943 } 944 945 static inline QDF_STATUS 946 cdp_ipa_opt_dp_enable_disable_low_power_mode(struct wlan_objmgr_pdev *pdev, 947 uint32_t pdev_id, int param_val) 948 { 949 wmi_unified_t wmi_handle; 950 struct wmi_unified *pdev_wmi_handle = NULL; 951 struct wlan_objmgr_psoc *psoc; 952 struct pdev_params pparam; 953 uint32_t vdev_id, val; 954 QDF_STATUS status; 955 956 psoc = wlan_pdev_get_psoc(pdev); 957 wmi_handle = get_wmi_unified_hdl_from_psoc(psoc); 958 if (!wmi_handle) { 959 QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL, 960 "Unable to get wmi handle"); 961 return QDF_STATUS_E_NULL_VALUE; 962 } 963 964 pdev_wmi_handle = pdev->tgt_if_handle->wmi_handle; 965 qdf_mem_set(&pparam, sizeof(pparam), 0); 966 pparam.is_host_pdev_id = false; 967 968 /* Enable-disable IMPS */ 969 pparam.param_id = WMI_PDEV_PARAM_IDLE_PS_CONFIG; 970 pparam.param_value = param_val; 971 status = wmi_unified_pdev_param_send(wmi_handle, 972 &pparam, pdev_id); 973 if (status != QDF_STATUS_SUCCESS) { 974 QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL, 975 "%s Unable to enable/disable:(%d) IMPS", __func__, 976 param_val); 977 return QDF_STATUS_E_FAILURE; 978 } 979 980 /* Enable-disable ILP */ 981 pparam.param_id = WMI_PDEV_PARAM_PCIE_HW_ILP; 982 pparam.param_value = param_val; 983 status = wmi_unified_pdev_param_send(pdev_wmi_handle, 984 &pparam, pdev_id); 985 if (status != QDF_STATUS_SUCCESS) { 986 QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL, 987 "%s Unable to enable/disable:(%d) ILP", __func__, 988 param_val); 989 return QDF_STATUS_E_FAILURE; 990 } 991 992 /* Enable-disable BMPS */ 993 val = param_val; 994 vdev_id = 0; //TODO fix vdev_id 995 status = wmi_unified_set_sta_ps_mode(wmi_handle, vdev_id, val); 996 if (status != QDF_STATUS_SUCCESS) { 997 QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL, 998 "%s Unable to enable/disable:(%d) BMPS", __func__, 999 param_val); 1000 return QDF_STATUS_E_FAILURE; 1001 } 1002 1003 return status; 1004 } 1005 #endif /* IPA_OPT_WIFI_DP */ 1006 1007 /** 1008 * cdp_ipa_get_wdi_version - Get WDI version 1009 * @soc: data path soc handle 1010 * @wdi_ver: Out param for wdi version 1011 * 1012 * Return: None 1013 */ 1014 static inline void 1015 cdp_ipa_get_wdi_version(ol_txrx_soc_handle soc, uint8_t *wdi_ver) 1016 { 1017 if (!soc || !soc->ops || !soc->ops->ipa_ops) { 1018 QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL, 1019 "%s invalid instance", __func__); 1020 return; 1021 } 1022 1023 if (soc->ops->ipa_ops->ipa_get_wdi_version) 1024 soc->ops->ipa_ops->ipa_get_wdi_version(soc, wdi_ver); 1025 } 1026 #endif /* IPA_OFFLOAD */ 1027 #endif /* _CDP_TXRX_IPA_H_ */ 1028