1 /* 2 * Copyright (c) 2013-2021 The Linux Foundation. All rights reserved. 3 * Copyright (c) 2021-2022 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: Declare various struct, macros which are used privately in IPA 22 * component. 23 */ 24 25 #ifndef _WLAN_IPA_PRIV_STRUCT_H_ 26 #define _WLAN_IPA_PRIV_STRUCT_H_ 27 28 #ifdef IPA_OFFLOAD 29 30 #include <linux/version.h> 31 #include <linux/kernel.h> 32 33 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 10, 0)) || \ 34 defined(CONFIG_IPA_WDI_UNIFIED_API) 35 #include <qdf_ipa_wdi3.h> 36 #else 37 #include <qdf_ipa.h> 38 #endif 39 40 #include <qdf_net_types.h> 41 #include <qdf_mc_timer.h> 42 #include <qdf_list.h> 43 #include <qdf_defer.h> 44 #include "qdf_delayed_work.h" 45 #include <qdf_event.h> 46 #include "wlan_ipa_public_struct.h" 47 48 #define WLAN_IPA_RX_INACTIVITY_MSEC_DELAY 1000 49 #define WLAN_IPA_UC_WLAN_8023_HDR_SIZE 14 50 51 #define WLAN_IPA_UC_NUM_WDI_PIPE 2 52 #define WLAN_IPA_UC_MAX_PENDING_EVENT 33 53 54 #define WLAN_IPA_UC_DEBUG_DUMMY_MEM_SIZE 32000 55 #define WLAN_IPA_UC_RT_DEBUG_PERIOD 300 56 #define WLAN_IPA_UC_RT_DEBUG_BUF_COUNT 30 57 #define WLAN_IPA_UC_RT_DEBUG_FILL_INTERVAL 10000 58 59 #define WLAN_IPA_WLAN_HDR_DES_MAC_OFFSET 0 60 #define WLAN_IPA_MAX_IFACE MAX_IPA_IFACE 61 #define WLAN_IPA_CLIENT_MAX_IFACE MAX_IPA_IFACE 62 #define WLAN_IPA_MAX_SYSBAM_PIPE 4 63 64 #ifdef IPA_WDS_EASYMESH_FEATURE 65 #define WLAN_IPA_MAX_SESSION MAX_IPA_IFACE //7 66 #else 67 #define WLAN_IPA_MAX_SESSION 5 68 #endif 69 70 #ifdef WLAN_MAX_CLIENTS_ALLOWED 71 #define WLAN_IPA_MAX_STA_COUNT WLAN_MAX_CLIENTS_ALLOWED 72 #else 73 #define WLAN_IPA_MAX_STA_COUNT 41 74 #endif 75 76 #define WLAN_IPA_RX_PIPE WLAN_IPA_MAX_IFACE 77 #define WLAN_IPA_ENABLE_MASK BIT(0) 78 #define WLAN_IPA_PRE_FILTER_ENABLE_MASK BIT(1) 79 #define WLAN_IPA_IPV6_ENABLE_MASK BIT(2) 80 #define WLAN_IPA_RM_ENABLE_MASK BIT(3) 81 #define WLAN_IPA_CLK_SCALING_ENABLE_MASK BIT(4) 82 #define WLAN_IPA_UC_ENABLE_MASK BIT(5) 83 #define WLAN_IPA_UC_STA_ENABLE_MASK BIT(6) 84 #define WLAN_IPA_REAL_TIME_DEBUGGING BIT(8) 85 86 #ifdef QCA_IPA_LL_TX_FLOW_CONTROL 87 #define WLAN_IPA_MAX_BANDWIDTH 4800 88 #define WLAN_IPA_MAX_BANDWIDTH_2G 1400 89 #else 90 #define WLAN_IPA_MAX_BANDWIDTH 800 91 #endif 92 93 #define WLAN_IPA_MAX_PENDING_EVENT_COUNT 20 94 95 #define IPA_WLAN_RX_SOFTIRQ_THRESH 32 96 97 #define WLAN_IPA_UC_BW_MONITOR_LEVEL 3 98 99 /** 100 * enum - IPA UC operation message 101 * 102 * @WLAN_IPA_UC_OPCODE_TX_SUSPEND: IPA WDI TX pipe suspend 103 * @WLAN_IPA_UC_OPCODE_TX_RESUME: IPA WDI TX pipe resume 104 * @WLAN_IPA_UC_OPCODE_RX_SUSPEND: IPA WDI RX pipe suspend 105 * @WLAN_IPA_UC_OPCODE_RX_RESUME: IPA WDI RX pipe resume 106 * @WLAN_IPA_UC_OPCODE_STATS: IPA UC stats 107 * @WLAN_IPA_UC_OPCODE_SHARING_STATS: IPA UC sharing stats 108 * @WLAN_IPA_UC_OPCODE_QUOTA_RSP: IPA UC quota response 109 * @WLAN_IPA_UC_OPCODE_QUOTA_IND: IPA UC quota indication 110 * @WLAN_IPA_UC_OPCODE_UC_READY: IPA UC ready indication 111 * @WLAN_IPA_UC_OPCODE_MAX: IPA UC max operation code 112 */ 113 enum wlan_ipa_uc_op_code { 114 WLAN_IPA_UC_OPCODE_TX_SUSPEND = 0, 115 WLAN_IPA_UC_OPCODE_TX_RESUME = 1, 116 WLAN_IPA_UC_OPCODE_RX_SUSPEND = 2, 117 WLAN_IPA_UC_OPCODE_RX_RESUME = 3, 118 WLAN_IPA_UC_OPCODE_STATS = 4, 119 #ifdef FEATURE_METERING 120 WLAN_IPA_UC_OPCODE_SHARING_STATS = 5, 121 WLAN_IPA_UC_OPCODE_QUOTA_RSP = 6, 122 WLAN_IPA_UC_OPCODE_QUOTA_IND = 7, 123 #endif 124 WLAN_IPA_UC_OPCODE_UC_READY = 8, 125 /* keep this last */ 126 WLAN_IPA_UC_OPCODE_MAX 127 }; 128 129 /** 130 * enum - Reason codes for stat query 131 * 132 * @WLAN_IPA_UC_STAT_REASON_NONE: Initial value 133 * @WLAN_IPA_UC_STAT_REASON_DEBUG: For debug/info 134 * @WLAN_IPA_UC_STAT_REASON_BW_CAL: For bandwidth calibration 135 * @WLAN_IPA_UC_STAT_REASON_DUMP_INFO: For debug info dump 136 */ 137 enum { 138 WLAN_IPA_UC_STAT_REASON_NONE, 139 WLAN_IPA_UC_STAT_REASON_DEBUG, 140 WLAN_IPA_UC_STAT_REASON_BW_CAL 141 }; 142 143 /** 144 * enum wlan_ipa_rm_state - IPA resource manager state 145 * @WLAN_IPA_RM_RELEASED: PROD pipe resource released 146 * @WLAN_IPA_RM_GRANT_PENDING: PROD pipe resource requested but not granted yet 147 * @WLAN_IPA_RM_GRANTED: PROD pipe resource granted 148 */ 149 enum wlan_ipa_rm_state { 150 WLAN_IPA_RM_RELEASED, 151 WLAN_IPA_RM_GRANT_PENDING, 152 WLAN_IPA_RM_GRANTED, 153 }; 154 155 /** 156 * enum wlan_ipa_forward_type: Type of forward packet received from IPA 157 * @WLAN_IPA_FORWARD_PKT_NONE: No forward packet 158 * @WLAN_IPA_FORWARD_PKT_LOCAL_STACK: Packet forwarded to kernel network stack 159 * @WLAN_IPA_FORWARD_PKT_DISCARD: Discarded packet before sending to kernel 160 */ 161 enum wlan_ipa_forward_type { 162 WLAN_IPA_FORWARD_PKT_NONE = 0, 163 WLAN_IPA_FORWARD_PKT_LOCAL_STACK = 1, 164 WLAN_IPA_FORWARD_PKT_DISCARD = 2 165 }; 166 167 /** 168 * enum wlan_ipa_bw_level -ipa bandwidth level 169 * @WLAN_IPA_BW_LEVEL_LOW: vote for low bandwidth 170 * @WLAN_IPA_BW_LEVEL_MEDIUM: vote for medium bandwidth 171 * @WLAN_IPA_BW_LEVEL_HIGH: vote for high bandwidth 172 */ 173 enum wlan_ipa_bw_level { 174 WLAN_IPA_BW_LEVEL_LOW, 175 WLAN_IPA_BW_LEVEL_MEDIUM, 176 WLAN_IPA_BW_LEVEL_HIGH, 177 }; 178 179 /** 180 * struct llc_snap_hdr - LLC snap header 181 * @dsap: Destination service access point 182 * @ssap: Source service access point 183 * @resv: Reserved for future use 184 * @eth_type: Ether type 185 */ 186 struct llc_snap_hdr { 187 uint8_t dsap; 188 uint8_t ssap; 189 uint8_t resv[4]; 190 qdf_be16_t eth_type; 191 } qdf_packed; 192 193 /** 194 * struct wlan_ipa_tx_hdr - header type which IPA should handle to TX packet 195 * @eth: ether II header 196 * @llc_snap: LLC snap header 197 */ 198 struct wlan_ipa_tx_hdr { 199 qdf_ether_header_t eth; 200 struct llc_snap_hdr llc_snap; 201 } qdf_packed; 202 203 /** 204 * struct frag_header - fragment header type registered to IPA hardware 205 * @length: fragment length 206 * @reserved1: Reserved not used 207 * @reserved2: Reserved not used 208 */ 209 #if defined(QCA_WIFI_QCA6290) || defined(QCA_WIFI_QCA6390) || \ 210 defined(QCA_WIFI_QCA6490) || defined(QCA_WIFI_QCA6750) || \ 211 defined(QCA_WIFI_WCN7850) || defined(QCA_WIFI_QCN9000) || \ 212 defined(QCA_WIFI_KIWI) || defined(QCA_WIFI_KIWI_V2) 213 struct frag_header { 214 uint8_t reserved[0]; 215 }; 216 #elif defined(QCA_WIFI_3_0) 217 struct frag_header { 218 uint16_t length; 219 uint32_t reserved1; 220 uint32_t reserved2; 221 } qdf_packed; 222 #else 223 struct frag_header { 224 uint32_t 225 length:16, 226 reserved16:16; 227 uint32_t reserved2; 228 } qdf_packed; 229 #endif 230 231 /** 232 * struct ipa_header - ipa header type registered to IPA hardware 233 * @vdev_id: vdev id 234 * @reserved: Reserved not used 235 */ 236 237 #if defined(QCA_WIFI_QCA6290) || defined(QCA_WIFI_QCA6390) || \ 238 defined(QCA_WIFI_QCA6490) || defined(QCA_WIFI_QCA6750) || \ 239 defined(QCA_WIFI_WCN7850) || defined(QCA_WIFI_QCN9000) || \ 240 defined(QCA_WIFI_KIWI) || defined(QCA_WIFI_KIWI_V2) 241 struct ipa_header { 242 uint8_t reserved[0]; 243 }; 244 #else 245 struct ipa_header { 246 uint32_t 247 vdev_id:8, /* vdev_id field is LSB of IPA DESC */ 248 reserved:24; 249 } qdf_packed; 250 #endif 251 252 /** 253 * struct wlan_ipa_uc_tx_hdr - full tx header registered to IPA hardware 254 * @frag_hd: fragment header 255 * @ipa_hd: ipa header 256 * @eth: ether II header 257 */ 258 struct wlan_ipa_uc_tx_hdr { 259 struct frag_header frag_hd; 260 struct ipa_header ipa_hd; 261 qdf_ether_header_t eth; 262 } qdf_packed; 263 264 /** 265 * struct wlan_ipa_cld_hdr - IPA CLD Header 266 * @reserved: reserved fields 267 * @iface_id: interface ID 268 * @sta_id: Station ID 269 * 270 * Packed 32-bit structure 271 * +----------+----------+--------------+--------+ 272 * | Reserved | QCMAP ID | interface id | STA ID | 273 * +----------+----------+--------------+--------+ 274 */ 275 struct wlan_ipa_cld_hdr { 276 uint8_t reserved[2]; 277 uint8_t iface_id; 278 uint8_t sta_id; 279 } qdf_packed; 280 281 /** 282 * struct wlan_ipa_rx_hdr - IPA RX header 283 * @cld_hdr: IPA CLD header 284 * @eth: ether II header 285 */ 286 struct wlan_ipa_rx_hdr { 287 struct wlan_ipa_cld_hdr cld_hdr; 288 qdf_ether_header_t eth; 289 } qdf_packed; 290 291 /** 292 * struct wlan_ipa_pm_tx_cb - PM resume TX callback 293 * @exception: Exception packet 294 * @iface_context: Interface context 295 * @ipa_tx_desc: IPA TX descriptor 296 */ 297 struct wlan_ipa_pm_tx_cb { 298 bool exception; 299 struct wlan_ipa_iface_context *iface_context; 300 qdf_ipa_rx_data_t *ipa_tx_desc; 301 }; 302 303 /** 304 * struct wlan_ipa_sys_pipe - IPA system pipe 305 * @conn_hdl: IPA system pipe connection handle 306 * @conn_hdl_valid: IPA system pipe valid flag 307 * @ipa_sys_params: IPA system pipe params 308 */ 309 struct wlan_ipa_sys_pipe { 310 uint32_t conn_hdl; 311 uint8_t conn_hdl_valid; 312 qdf_ipa_sys_connect_params_t ipa_sys_params; 313 }; 314 315 /** 316 * struct wlan_ipa_iface_stats - IPA system pipe 317 * @num_tx: Number of TX packets 318 * @num_tx_drop: Number of TX packet drops 319 * @num_tx_err: Number of TX packet errors 320 * @num_tx_cac_drop: Number of TX packet drop due to CAC 321 * @num_rx_ipa_excep: Number of RX IPA exception packets 322 */ 323 struct wlan_ipa_iface_stats { 324 uint64_t num_tx; 325 uint64_t num_tx_drop; 326 uint64_t num_tx_err; 327 uint64_t num_tx_cac_drop; 328 uint64_t num_rx_ipa_excep; 329 }; 330 331 /* IPA private context structure */ 332 struct wlan_ipa_priv; 333 334 /** 335 * struct wlan_ipa_iface_context - IPA interface context 336 * @ipa_ctx: IPA private context 337 * @cons_client: IPA consumer pipe 338 * @prod_client: IPA producer pipe 339 * @prod_client: IPA producer pipe 340 * @iface_id: IPA interface ID 341 * @dev: Net device structure 342 * @device_mode: Interface device mode 343 * @session_id: Session ID 344 * @interface_lock: Interface lock 345 * @ifa_address: Interface address 346 * @stats: Interface stats 347 * @bssid: BSSID. valid only for sta iface ctx 348 * @is_authenticated: is peer authenticated 349 */ 350 struct wlan_ipa_iface_context { 351 struct wlan_ipa_priv *ipa_ctx; 352 353 qdf_ipa_client_type_t cons_client; 354 qdf_ipa_client_type_t prod_client; 355 356 uint8_t iface_id; /* This iface ID */ 357 qdf_netdev_t dev; 358 enum QDF_OPMODE device_mode; 359 uint8_t mac_addr[QDF_MAC_ADDR_SIZE]; 360 qdf_atomic_t conn_count; 361 qdf_atomic_t disconn_count; 362 uint8_t session_id; 363 qdf_spinlock_t interface_lock; 364 uint32_t ifa_address; 365 struct wlan_ipa_iface_stats stats; 366 struct qdf_mac_addr bssid; 367 uint8_t is_authenticated; 368 }; 369 370 /** 371 * struct wlan_ipa_stats - IPA system stats 372 * @event: WLAN IPA event record 373 * @num_send_msg: Number of sent IPA messages 374 * @num_rm_grant: Number of times IPA RM resource granted 375 * @num_rm_release: Number of times IPA RM resource released 376 * @num_rm_grant_imm: Number of immediate IPA RM granted 377 e @num_cons_perf_req: Number of CONS pipe perf request 378 * @num_prod_perf_req: Number of PROD pipe perf request 379 * @num_rx_drop: Number of RX packet drops 380 * @num_tx_desc_q_cnt: Number of TX descriptor queue count 381 * @num_tx_desc_err: Number of TX descriptor error 382 * @num_tx_comp_cnt: Number of TX qdf_event_t count 383 * @num_tx_queued: Number of TX queued 384 * @num_tx_dequeued: Number of TX dequeued 385 * @num_max_pm_queue: Number of packets in PM queue 386 * @num_rx_excep: Number of RX IPA exception packets 387 * @num_rx_no_iface_eapol: No of EAPOL pkts before iface setup 388 * @num_tx_fwd_ok: Number of TX forward packet success 389 * @num_tx_fwd_err: Number of TX forward packet failures 390 */ 391 struct wlan_ipa_stats { 392 uint32_t event[QDF_IPA_WLAN_EVENT_MAX]; 393 uint64_t num_send_msg; 394 uint64_t num_free_msg; 395 uint64_t num_rm_grant; 396 uint64_t num_rm_release; 397 uint64_t num_rm_grant_imm; 398 uint64_t num_cons_perf_req; 399 uint64_t num_prod_perf_req; 400 uint64_t num_rx_drop; 401 uint64_t num_tx_desc_q_cnt; 402 uint64_t num_tx_desc_error; 403 uint64_t num_tx_comp_cnt; 404 uint64_t num_tx_queued; 405 uint64_t num_tx_dequeued; 406 uint64_t num_max_pm_queue; 407 uint64_t num_rx_excep; 408 uint64_t num_rx_no_iface_eapol; 409 uint64_t num_tx_fwd_ok; 410 uint64_t num_tx_fwd_err; 411 }; 412 413 /** 414 * struct ipa_uc_stas_map - IPA UC assoc station map 415 * @is_reserved: STA reserved flag 416 * @is_authenticated: is peer authenticated 417 * @mac_addr: Station mac address 418 */ 419 struct ipa_uc_stas_map { 420 bool is_reserved; 421 struct qdf_mac_addr mac_addr; 422 uint8_t is_authenticated; 423 }; 424 425 /** 426 * struct op_msg_type - IPA operation message type 427 * @msg_t: Message type 428 * @rsvd: Reserved 429 * @op_code: IPA Operation type 430 * @len: IPA message length 431 * @rsvd_snd: Reserved 432 */ 433 struct op_msg_type { 434 uint8_t msg_t; 435 uint8_t rsvd; 436 uint16_t op_code; 437 uint16_t len; 438 uint16_t rsvd_snd; 439 }; 440 441 /** 442 * struct ipa_uc_fw_stats - IPA FW stats 443 * @tx_comp_ring_size: TX completion ring size 444 * @txcomp_ring_dbell_addr: TX comp ring door bell address 445 * @txcomp_ring_dbell_ind_val: TX cop ring door bell indication 446 * @txcomp_ring_dbell_cached_val: TX cop ring cached value 447 * @txpkts_enqueued: TX packets enqueued 448 * @txpkts_completed: TX packets completed 449 * @tx_is_suspend: TX suspend flag 450 * @tx_reserved: Reserved for TX stat 451 * @rx_ind_ring_base: RX indication ring base address 452 * @rx_ind_ring_size: RX indication ring size 453 * @rx_ind_ring_dbell_addr: RX indication ring doorbell address 454 * @rx_ind_ring_dbell_ind_val: RX indication ring doorbell indication 455 * @rx_ind_ring_dbell_ind_cached_val: RX indication ring doorbell cached value 456 * @rx_ind_ring_rdidx_addr: RX indication ring read index address 457 * @rx_ind_ring_rd_idx_cached_val: RX indication ring read index cached value 458 * @rx_refill_idx: RX ring refill index 459 * @rx_num_pkts_indicated: Number of RX packets indicated 460 * @rx_buf_refilled: Number of RX buffer refilled 461 * @rx_num_ind_drop_no_space: Number of RX indication drops due to no space 462 * @rx_num_ind_drop_no_buf: Number of RX indication drops due to no buffer 463 * @rx_is_suspend: RX suspend flag 464 * @rx_reserved: Reserved for RX stat 465 */ 466 struct ipa_uc_fw_stats { 467 uint32_t tx_comp_ring_base; 468 uint32_t tx_comp_ring_size; 469 uint32_t tx_comp_ring_dbell_addr; 470 uint32_t tx_comp_ring_dbell_ind_val; 471 uint32_t tx_comp_ring_dbell_cached_val; 472 uint32_t tx_pkts_enqueued; 473 uint32_t tx_pkts_completed; 474 uint32_t tx_is_suspend; 475 uint32_t tx_reserved; 476 uint32_t rx_ind_ring_base; 477 uint32_t rx_ind_ring_size; 478 uint32_t rx_ind_ring_dbell_addr; 479 uint32_t rx_ind_ring_dbell_ind_val; 480 uint32_t rx_ind_ring_dbell_ind_cached_val; 481 uint32_t rx_ind_ring_rdidx_addr; 482 uint32_t rx_ind_ring_rd_idx_cached_val; 483 uint32_t rx_refill_idx; 484 uint32_t rx_num_pkts_indicated; 485 uint32_t rx_buf_refilled; 486 uint32_t rx_num_ind_drop_no_space; 487 uint32_t rx_num_ind_drop_no_buf; 488 uint32_t rx_is_suspend; 489 uint32_t rx_reserved; 490 }; 491 492 /** 493 * struct wlan_ipa_uc_pending_event - WLAN IPA UC pending event 494 * @node: Pending event list node 495 * @type: WLAN IPA event type 496 * @device_mode: Device mode 497 * @session_id: Session ID 498 * @mac_addr: Mac address 499 * @is_loading: Driver loading flag 500 * @is_2g_iface: true if interface is operating on 2G band, otherwise false 501 */ 502 struct wlan_ipa_uc_pending_event { 503 qdf_list_node_t node; 504 qdf_ipa_wlan_event type; 505 qdf_netdev_t net_dev; 506 uint8_t device_mode; 507 uint8_t session_id; 508 uint8_t mac_addr[QDF_MAC_ADDR_SIZE]; 509 bool is_loading; 510 bool is_2g_iface; 511 }; 512 513 /** 514 * struct uc_rm_work_struct 515 * @work: uC RM work 516 * @event: IPA RM event 517 */ 518 struct uc_rm_work_struct { 519 qdf_work_t work; 520 qdf_ipa_rm_event_t event; 521 }; 522 523 /** 524 * struct uc_op_work_struct 525 * @work: uC OP work 526 * @msg: OP message 527 * @osdev: pointer to qdf net device, used by osif_psoc_sync_trans_start_wait 528 * @ipa_priv_bp: back pointer to ipa_obj 529 */ 530 struct uc_op_work_struct { 531 qdf_work_t work; 532 struct op_msg_type *msg; 533 qdf_device_t osdev; 534 struct wlan_ipa_priv *ipa_priv_bp; 535 }; 536 537 /** 538 * struct uc_rt_debug_info 539 * @time: system time 540 * @ipa_excep_count: IPA exception packet count 541 * @rx_drop_count: IPA Rx drop packet count 542 * @net_sent_count: IPA Rx packet sent to network stack count 543 * @rx_discard_count: IPA Rx discard packet count 544 * @tx_fwd_ok_count: IPA Tx forward success packet count 545 * @tx_fwd_count: IPA Tx forward packet count 546 * @rx_destructor_call: IPA Rx packet destructor count 547 */ 548 struct uc_rt_debug_info { 549 uint64_t time; 550 uint64_t ipa_excep_count; 551 uint64_t rx_drop_count; 552 uint64_t net_sent_count; 553 uint64_t rx_discard_count; 554 uint64_t tx_fwd_ok_count; 555 uint64_t tx_fwd_count; 556 uint64_t rx_destructor_call; 557 }; 558 559 #ifdef FEATURE_METERING 560 /** 561 * struct ipa_uc_sharing_stats - IPA UC sharing stats 562 * @ipv4_rx_packets: IPv4 RX packets 563 * @ipv4_rx_bytes: IPv4 RX bytes 564 * @ipv6_rx_packets: IPv6 RX packets 565 * @ipv6_rx_bytes: IPv6 RX bytes 566 * @ipv4_tx_packets: IPv4 TX packets 567 * @ipv4_tx_bytes: IPv4 TX bytes 568 * @ipv6_tx_packets: IPv4 TX packets 569 * @ipv6_tx_bytes: IPv6 TX bytes 570 */ 571 struct ipa_uc_sharing_stats { 572 uint64_t ipv4_rx_packets; 573 uint64_t ipv4_rx_bytes; 574 uint64_t ipv6_rx_packets; 575 uint64_t ipv6_rx_bytes; 576 uint64_t ipv4_tx_packets; 577 uint64_t ipv4_tx_bytes; 578 uint64_t ipv6_tx_packets; 579 uint64_t ipv6_tx_bytes; 580 }; 581 582 /** 583 * struct ipa_uc_quota_rsp - IPA UC quota response 584 * @success: Success or fail flag 585 * @reserved[3]: Reserved 586 * @quota_lo: Quota limit low bytes 587 * @quota_hi: Quota limit high bytes 588 */ 589 struct ipa_uc_quota_rsp { 590 uint8_t success; 591 uint8_t reserved[3]; 592 uint32_t quota_lo; 593 uint32_t quota_hi; 594 }; 595 596 /** 597 * struct ipa_uc_quota_ind 598 * @quota_bytes: Quota bytes to set 599 */ 600 struct ipa_uc_quota_ind { 601 uint64_t quota_bytes; 602 }; 603 #endif 604 605 /** 606 * struct wlan_ipa_tx_desc 607 * @node: TX descriptor node 608 * @priv: pointer to priv list entry 609 * @id: Tx desc idex 610 * @ipa_tx_desc_ptr: pointer to IPA Tx descriptor 611 */ 612 struct wlan_ipa_tx_desc { 613 qdf_list_node_t node; 614 void *priv; 615 uint32_t id; 616 qdf_ipa_rx_data_t *ipa_tx_desc_ptr; 617 }; 618 619 typedef QDF_STATUS (*wlan_ipa_softap_xmit)(qdf_nbuf_t nbuf, qdf_netdev_t dev); 620 typedef void (*wlan_ipa_send_to_nw)(qdf_nbuf_t nbuf, qdf_netdev_t dev); 621 typedef bool (*wlan_ipa_driver_unloading)(void); 622 623 /** 624 * typedef wlan_ipa_rps_enable - Enable/disable RPS for adapter using vdev id 625 * @vdev_id: vdev_id of adapter 626 * @enable: Set true to enable RPS 627 */ 628 typedef void (*wlan_ipa_rps_enable)(uint8_t vdev_id, bool enable); 629 630 /* IPA private context structure definition */ 631 struct wlan_ipa_priv { 632 struct wlan_objmgr_pdev *pdev; 633 struct wlan_ipa_sys_pipe sys_pipe[WLAN_IPA_MAX_SYSBAM_PIPE]; 634 struct wlan_ipa_iface_context iface_context[WLAN_IPA_MAX_IFACE]; 635 uint8_t num_iface; 636 void *dp_soc; 637 uint8_t dp_pdev_id; 638 struct wlan_ipa_config *config; 639 enum wlan_ipa_rm_state rm_state; 640 /* 641 * IPA driver can send RM notifications with IRQ disabled so using qdf 642 * APIs as it is taken care gracefully. Without this, kernel would throw 643 * an warning if spin_lock_bh is used while IRQ is disabled 644 */ 645 qdf_spinlock_t rm_lock; 646 struct uc_rm_work_struct uc_rm_work; 647 struct uc_op_work_struct uc_op_work[WLAN_IPA_UC_OPCODE_MAX]; 648 qdf_wake_lock_t wake_lock; 649 struct qdf_delayed_work wake_lock_work; 650 bool wake_lock_released; 651 652 qdf_atomic_t tx_ref_cnt; 653 qdf_nbuf_queue_t pm_queue_head; 654 qdf_work_t pm_work; 655 qdf_spinlock_t pm_lock; 656 bool suspended; 657 qdf_spinlock_t q_lock; 658 qdf_spinlock_t enable_disable_lock; 659 /* Flag to indicate wait on pending TX completions */ 660 qdf_atomic_t waiting_on_pending_tx; 661 /* Timer ticks to keep track of time after which pipes are disabled */ 662 uint64_t pending_tx_start_ticks; 663 /* Indicates if cdp_ipa_disable_autonomy is called for IPA pipes */ 664 qdf_atomic_t autonomy_disabled; 665 /* Indicates if cdp_disable_ipa_pipes has been called for IPA pipes */ 666 qdf_atomic_t pipes_disabled; 667 /* 668 * IPA pipes are considered "down" when both autonomy_disabled and 669 * ipa_pipes_disabled are set 670 */ 671 bool ipa_pipes_down; 672 /* Flag for mutual exclusion during IPA disable pipes */ 673 bool pipes_down_in_progress; 674 /* Flag for mutual exclusion during IPA enable pipes */ 675 bool pipes_enable_in_progress; 676 qdf_list_node_t pend_desc_head; 677 struct wlan_ipa_tx_desc *tx_desc_pool; 678 qdf_list_t tx_desc_free_list; 679 680 struct wlan_ipa_stats stats; 681 682 uint32_t curr_prod_bw; 683 uint32_t curr_cons_bw; 684 685 uint8_t activated_fw_pipe; 686 uint8_t num_sap_connected; 687 uint8_t sap_num_connected_sta; 688 uint8_t sta_connected; 689 uint32_t tx_pipe_handle; 690 uint32_t rx_pipe_handle; 691 bool resource_loading; 692 bool resource_unloading; 693 bool pending_cons_req; 694 struct ipa_uc_stas_map assoc_stas_map[WLAN_IPA_MAX_STA_COUNT]; 695 qdf_list_t pending_event; 696 qdf_mutex_t event_lock; 697 uint32_t ipa_tx_packets_diff; 698 uint32_t ipa_rx_packets_diff; 699 uint32_t ipa_p_tx_packets; 700 uint32_t ipa_p_rx_packets; 701 uint32_t stat_req_reason; 702 uint64_t ipa_tx_forward; 703 uint64_t ipa_rx_discard; 704 uint64_t ipa_rx_net_send_count; 705 uint64_t ipa_rx_internal_drop_count; 706 uint64_t ipa_rx_destructor_count; 707 qdf_mc_timer_t rt_debug_timer; 708 struct uc_rt_debug_info rt_bug_buffer[WLAN_IPA_UC_RT_DEBUG_BUF_COUNT]; 709 unsigned int rt_buf_fill_index; 710 qdf_ipa_wdi_in_params_t cons_pipe_in; 711 qdf_ipa_wdi_in_params_t prod_pipe_in; 712 bool uc_loaded; 713 bool wdi_enabled; 714 bool over_gsi; 715 qdf_mc_timer_t rt_debug_fill_timer; 716 qdf_mutex_t rt_debug_lock; 717 qdf_mutex_t ipa_lock; 718 719 uint8_t vdev_to_iface[WLAN_IPA_MAX_SESSION]; 720 bool vdev_offload_enabled[WLAN_IPA_MAX_SESSION]; 721 bool mcc_mode; 722 qdf_work_t mcc_work; 723 bool disable_intrabss_fwd[WLAN_IPA_MAX_SESSION]; 724 bool dfs_cac_block_tx; 725 #ifdef FEATURE_METERING 726 struct ipa_uc_sharing_stats ipa_sharing_stats; 727 struct ipa_uc_quota_rsp ipa_quota_rsp; 728 struct ipa_uc_quota_ind ipa_quota_ind; 729 qdf_event_t ipa_uc_sharing_stats_comp; 730 qdf_event_t ipa_uc_set_quota_comp; 731 #endif 732 733 wlan_ipa_softap_xmit softap_xmit; 734 wlan_ipa_send_to_nw send_to_nw; 735 736 #ifdef QCA_CONFIG_RPS 737 /*Callback to enable RPS for STA in STA+SAP scenario*/ 738 wlan_ipa_rps_enable rps_enable; 739 #endif 740 wlan_ipa_driver_unloading driver_is_unloading; 741 qdf_event_t ipa_resource_comp; 742 743 uint32_t wdi_version; 744 bool is_smmu_enabled; /* IPA caps returned from ipa_wdi_init */ 745 qdf_atomic_t stats_quota; 746 uint8_t curr_bw_level; 747 qdf_atomic_t deinit_in_prog; 748 uint8_t instance_id; 749 bool handle_initialized; 750 qdf_ipa_wdi_hdl_t hdl; 751 }; 752 753 #define WLAN_IPA_WLAN_FRAG_HEADER sizeof(struct frag_header) 754 #define WLAN_IPA_WLAN_IPA_HEADER sizeof(struct ipa_header) 755 #define WLAN_IPA_WLAN_CLD_HDR_LEN sizeof(struct wlan_ipa_cld_hdr) 756 #define WLAN_IPA_UC_WLAN_CLD_HDR_LEN 0 757 #define WLAN_IPA_WLAN_TX_HDR_LEN sizeof(struct wlan_ipa_tx_hdr) 758 #define WLAN_IPA_UC_WLAN_TX_HDR_LEN sizeof(struct wlan_ipa_uc_tx_hdr) 759 #define WLAN_IPA_WLAN_RX_HDR_LEN sizeof(struct wlan_ipa_rx_hdr) 760 #define WLAN_IPA_UC_WLAN_HDR_DES_MAC_OFFSET \ 761 (WLAN_IPA_WLAN_FRAG_HEADER + WLAN_IPA_WLAN_IPA_HEADER) 762 763 #define WLAN_IPA_GET_IFACE_ID(_data) \ 764 (((struct wlan_ipa_cld_hdr *) (_data))->iface_id) 765 766 #define WLAN_IPA_LOG(LVL, fmt, args ...) \ 767 QDF_TRACE(QDF_MODULE_ID_IPA, LVL, \ 768 "%s:%d: "fmt, __func__, __LINE__, ## args) 769 770 #define WLAN_IPA_IS_CONFIG_ENABLED(_ipa_cfg, _mask) \ 771 (((_ipa_cfg)->ipa_config & (_mask)) == (_mask)) 772 773 #define BW_GET_DIFF(_x, _y) (unsigned long)((ULONG_MAX - (_y)) + (_x) + 1) 774 775 #define IPA_RESOURCE_COMP_WAIT_TIME 500 776 777 #ifdef FEATURE_METERING 778 #define IPA_UC_SHARING_STATES_WAIT_TIME 500 779 #define IPA_UC_SET_QUOTA_WAIT_TIME 500 780 #endif 781 782 /** 783 * wlan_ipa_wlan_event_to_str() - convert IPA WLAN event to string 784 * @event: IPA WLAN event to be converted to a string 785 * 786 * Return: ASCII string representing the IPA WLAN event 787 */ 788 static inline char *wlan_ipa_wlan_event_to_str(qdf_ipa_wlan_event event) 789 { 790 switch (event) { 791 CASE_RETURN_STRING(QDF_IPA_CLIENT_CONNECT); 792 CASE_RETURN_STRING(QDF_IPA_CLIENT_DISCONNECT); 793 CASE_RETURN_STRING(QDF_IPA_AP_CONNECT); 794 CASE_RETURN_STRING(QDF_IPA_AP_DISCONNECT); 795 CASE_RETURN_STRING(QDF_IPA_STA_CONNECT); 796 CASE_RETURN_STRING(QDF_IPA_STA_DISCONNECT); 797 CASE_RETURN_STRING(QDF_IPA_CLIENT_CONNECT_EX); 798 CASE_RETURN_STRING(QDF_SWITCH_TO_SCC); 799 CASE_RETURN_STRING(QDF_SWITCH_TO_MCC); 800 CASE_RETURN_STRING(QDF_WDI_ENABLE); 801 CASE_RETURN_STRING(QDF_WDI_DISABLE); 802 default: 803 return "UNKNOWN"; 804 } 805 } 806 807 /** 808 * wlan_ipa_get_iface() - Get IPA interface 809 * @ipa_ctx: IPA context 810 * @mode: Interface device mode 811 * 812 * Return: IPA interface address 813 */ 814 struct wlan_ipa_iface_context 815 *wlan_ipa_get_iface(struct wlan_ipa_priv *ipa_ctx, uint8_t mode); 816 817 #endif /* IPA_OFFLOAD */ 818 #endif /* _WLAN_IPA_PRIV_STRUCT_H_ */ 819