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