blob: c2f4e61d87ca8d7ca4546be779d9a4d93222f448 [file] [log] [blame]
Ghanim Fodi2c8ba072017-01-12 15:14:15 +02001/* Copyright (c) 2012-2017, The Linux Foundation. All rights reserved.
Amir Levy9659e592016-10-27 18:08:27 +03002 *
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License version 2 and
5 * only version 2 as published by the Free Software Foundation.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 */
12
13#ifndef _IPA3_I_H_
14#define _IPA3_I_H_
15
16#include <linux/bitops.h>
17#include <linux/cdev.h>
18#include <linux/export.h>
19#include <linux/idr.h>
20#include <linux/list.h>
21#include <linux/mutex.h>
22#include <linux/skbuff.h>
23#include <linux/slab.h>
24#include <linux/ipa.h>
25#include <linux/ipa_usb.h>
Amir Levy9659e592016-10-27 18:08:27 +030026#include <asm/dma-iommu.h>
27#include <linux/iommu.h>
28#include <linux/platform_device.h>
29#include <linux/firmware.h>
30#include "ipa_hw_defs.h"
31#include "ipa_qmi_service.h"
32#include "../ipa_api.h"
33#include "ipahal/ipahal_reg.h"
34#include "ipahal/ipahal.h"
35#include "ipahal/ipahal_fltrt.h"
Skylar Chang6f6e3072017-07-28 10:03:47 -070036#include "ipahal/ipahal_hw_stats.h"
Amir Levy9659e592016-10-27 18:08:27 +030037#include "../ipa_common_i.h"
38#include "ipa_uc_offload_i.h"
39
40#define DRV_NAME "ipa"
41#define NAT_DEV_NAME "ipaNatTable"
42#define IPA_COOKIE 0x57831603
Mohammed Javid93e94ce2017-06-15 15:39:04 +053043#define IPA_RT_RULE_COOKIE 0x57831604
44#define IPA_RT_TBL_COOKIE 0x57831605
45#define IPA_FLT_COOKIE 0x57831606
46#define IPA_HDR_COOKIE 0x57831607
47#define IPA_PROC_HDR_COOKIE 0x57831608
48
Amir Levy9659e592016-10-27 18:08:27 +030049#define MTU_BYTE 1500
50
Skylar Chang652ee8e2017-02-10 11:40:30 -080051#define IPA_EP_NOT_ALLOCATED (-1)
Amir Levy9659e592016-10-27 18:08:27 +030052#define IPA3_MAX_NUM_PIPES 31
Amir Levy9659e592016-10-27 18:08:27 +030053#define IPA_SYS_DESC_FIFO_SZ 0x800
54#define IPA_SYS_TX_DATA_DESC_FIFO_SZ 0x1000
Skylar Changd407e592017-03-30 11:25:30 -070055#define IPA_COMMON_EVENT_RING_SIZE 0x7C00
Amir Levy9659e592016-10-27 18:08:27 +030056#define IPA_LAN_RX_HEADER_LENGTH (2)
57#define IPA_QMAP_HEADER_LENGTH (4)
58#define IPA_DL_CHECKSUM_LENGTH (8)
59#define IPA_NUM_DESC_PER_SW_TX (3)
60#define IPA_GENERIC_RX_POOL_SZ 192
61#define IPA_UC_FINISH_MAX 6
62#define IPA_UC_WAIT_MIN_SLEEP 1000
63#define IPA_UC_WAII_MAX_SLEEP 1200
Sunil Paidimarri226cf032016-10-14 13:33:08 -070064/*
65 * The transport descriptor size was changed to GSI_CHAN_RE_SIZE_16B, but
66 * IPA users still use sps_iovec size as FIFO element size.
67 */
68#define IPA_FIFO_ELEMENT_SIZE 8
Amir Levy9659e592016-10-27 18:08:27 +030069
70#define IPA_MAX_STATUS_STAT_NUM 30
71
72#define IPA_IPC_LOG_PAGES 50
73
74#define IPADBG(fmt, args...) \
75 do { \
76 pr_debug(DRV_NAME " %s:%d " fmt, __func__, __LINE__, ## args);\
77 if (ipa3_ctx) { \
78 IPA_IPC_LOGGING(ipa3_ctx->logbuf, \
79 DRV_NAME " %s:%d " fmt, ## args); \
80 IPA_IPC_LOGGING(ipa3_ctx->logbuf_low, \
81 DRV_NAME " %s:%d " fmt, ## args); \
82 } \
83 } while (0)
84
85#define IPADBG_LOW(fmt, args...) \
86 do { \
87 pr_debug(DRV_NAME " %s:%d " fmt, __func__, __LINE__, ## args);\
88 if (ipa3_ctx) \
89 IPA_IPC_LOGGING(ipa3_ctx->logbuf_low, \
90 DRV_NAME " %s:%d " fmt, ## args); \
91 } while (0)
92
93#define IPAERR(fmt, args...) \
94 do { \
95 pr_err(DRV_NAME " %s:%d " fmt, __func__, __LINE__, ## args);\
96 if (ipa3_ctx) { \
97 IPA_IPC_LOGGING(ipa3_ctx->logbuf, \
98 DRV_NAME " %s:%d " fmt, ## args); \
99 IPA_IPC_LOGGING(ipa3_ctx->logbuf_low, \
100 DRV_NAME " %s:%d " fmt, ## args); \
101 } \
102 } while (0)
103
Utkarsh Saxenae9782812017-05-26 17:20:32 +0530104#define IPAERR_RL(fmt, args...) \
105 do { \
106 pr_err_ratelimited(DRV_NAME " %s:%d " fmt, __func__,\
107 __LINE__, ## args);\
108 if (ipa3_ctx) { \
109 IPA_IPC_LOGGING(ipa3_ctx->logbuf, \
110 DRV_NAME " %s:%d " fmt, ## args); \
111 IPA_IPC_LOGGING(ipa3_ctx->logbuf_low, \
112 DRV_NAME " %s:%d " fmt, ## args); \
113 } \
114 } while (0)
115
Amir Levy9659e592016-10-27 18:08:27 +0300116#define WLAN_AMPDU_TX_EP 15
117#define WLAN_PROD_TX_EP 19
118#define WLAN1_CONS_RX_EP 14
119#define WLAN2_CONS_RX_EP 16
120#define WLAN3_CONS_RX_EP 17
121#define WLAN4_CONS_RX_EP 18
122
123#define IPA_RAM_NAT_OFST 0
124#define IPA_RAM_NAT_SIZE 0
125#define IPA_MEM_CANARY_VAL 0xdeadbeef
126
127#define IPA_STATS
128
129#ifdef IPA_STATS
130#define IPA_STATS_INC_CNT(val) (++val)
131#define IPA_STATS_DEC_CNT(val) (--val)
132#define IPA_STATS_EXCP_CNT(__excp, __base) do { \
133 if (__excp < 0 || __excp >= IPAHAL_PKT_STATUS_EXCEPTION_MAX) \
134 break; \
135 ++__base[__excp]; \
136 } while (0)
137#else
138#define IPA_STATS_INC_CNT(x) do { } while (0)
139#define IPA_STATS_DEC_CNT(x)
140#define IPA_STATS_EXCP_CNT(__excp, __base) do { } while (0)
141#endif
142
143#define IPA_HDR_BIN0 0
144#define IPA_HDR_BIN1 1
145#define IPA_HDR_BIN2 2
146#define IPA_HDR_BIN3 3
147#define IPA_HDR_BIN4 4
148#define IPA_HDR_BIN_MAX 5
149
150#define IPA_HDR_PROC_CTX_BIN0 0
151#define IPA_HDR_PROC_CTX_BIN1 1
152#define IPA_HDR_PROC_CTX_BIN_MAX 2
153
Amir Levy9659e592016-10-27 18:08:27 +0300154#define IPA_RX_POOL_CEIL 32
155#define IPA_RX_SKB_SIZE 1792
156
157#define IPA_A5_MUX_HDR_NAME "ipa_excp_hdr"
158#define IPA_LAN_RX_HDR_NAME "ipa_lan_hdr"
159#define IPA_INVALID_L4_PROTOCOL 0xFF
160
Amir Levy9659e592016-10-27 18:08:27 +0300161#define IPA_HDR_PROC_CTX_TABLE_ALIGNMENT_BYTE 8
162#define IPA_HDR_PROC_CTX_TABLE_ALIGNMENT(start_ofst) \
163 (((start_ofst) + IPA_HDR_PROC_CTX_TABLE_ALIGNMENT_BYTE - 1) & \
164 ~(IPA_HDR_PROC_CTX_TABLE_ALIGNMENT_BYTE - 1))
165
166#define MAX_RESOURCE_TO_CLIENTS (IPA_CLIENT_MAX)
167#define IPA_MEM_PART(x_) (ipa3_ctx->ctrl->mem_partition.x_)
168
169#define IPA_GSI_CHANNEL_STOP_MAX_RETRY 10
170#define IPA_GSI_CHANNEL_STOP_PKT_SIZE 1
171
172#define IPA_GSI_CHANNEL_EMPTY_MAX_RETRY 15
173#define IPA_GSI_CHANNEL_EMPTY_SLEEP_MIN_USEC (1000)
174#define IPA_GSI_CHANNEL_EMPTY_SLEEP_MAX_USEC (2000)
175
176#define IPA_SLEEP_CLK_RATE_KHZ (32)
177
178#define IPA3_ACTIVE_CLIENTS_LOG_BUFFER_SIZE_LINES 120
179#define IPA3_ACTIVE_CLIENTS_LOG_LINE_LEN 96
180#define IPA3_ACTIVE_CLIENTS_LOG_HASHTABLE_SIZE 50
181#define IPA3_ACTIVE_CLIENTS_LOG_NAME_LEN 40
182
183struct ipa3_active_client_htable_entry {
184 struct hlist_node list;
185 char id_string[IPA3_ACTIVE_CLIENTS_LOG_NAME_LEN];
186 int count;
187 enum ipa_active_client_log_type type;
188};
189
190struct ipa3_active_clients_log_ctx {
Skylar Chang69ae50e2017-07-31 13:13:29 -0700191 spinlock_t lock;
Amir Levy9659e592016-10-27 18:08:27 +0300192 char *log_buffer[IPA3_ACTIVE_CLIENTS_LOG_BUFFER_SIZE_LINES];
193 int log_head;
194 int log_tail;
195 bool log_rdy;
196 struct hlist_head htable[IPA3_ACTIVE_CLIENTS_LOG_HASHTABLE_SIZE];
197};
198
199struct ipa3_client_names {
200 enum ipa_client_type names[MAX_RESOURCE_TO_CLIENTS];
201 int length;
202};
203
204struct ipa_smmu_cb_ctx {
205 bool valid;
206 struct device *dev;
207 struct dma_iommu_mapping *mapping;
208 struct iommu_domain *iommu;
209 unsigned long next_addr;
210 u32 va_start;
211 u32 va_size;
212 u32 va_end;
213};
214
215/**
216 * struct ipa3_flt_entry - IPA filtering table entry
217 * @link: entry's link in global filtering enrties list
218 * @rule: filter rule
219 * @cookie: cookie used for validity check
220 * @tbl: filter table
221 * @rt_tbl: routing table
222 * @hw_len: entry's size
223 * @id: rule handle - globally unique
224 * @prio: rule 10bit priority which defines the order of the rule
225 * among other rules at the same integrated table
226 * @rule_id: rule 10bit ID to be returned in packet status
227 */
228struct ipa3_flt_entry {
229 struct list_head link;
Amir Levy9659e592016-10-27 18:08:27 +0300230 u32 cookie;
Mohammed Javid93e94ce2017-06-15 15:39:04 +0530231 struct ipa_flt_rule rule;
Amir Levy9659e592016-10-27 18:08:27 +0300232 struct ipa3_flt_tbl *tbl;
233 struct ipa3_rt_tbl *rt_tbl;
234 u32 hw_len;
235 int id;
236 u16 prio;
237 u16 rule_id;
238};
239
240/**
241 * struct ipa3_rt_tbl - IPA routing table
242 * @link: table's link in global routing tables list
243 * @head_rt_rule_list: head of routing rules list
244 * @name: routing table name
245 * @idx: routing table index
246 * @rule_cnt: number of rules in routing table
247 * @ref_cnt: reference counter of routing table
248 * @set: collection of routing tables
249 * @cookie: cookie used for validity check
250 * @in_sys: flag indicating if the table is located in system memory
251 * @sz: the size of the routing table
252 * @curr_mem: current routing tables block in sys memory
253 * @prev_mem: previous routing table block in sys memory
254 * @id: routing table id
Skylar Chang0c37f5f2017-07-24 10:22:53 -0700255 * @rule_ids: common idr structure that holds the rule_id for each rule
Amir Levy9659e592016-10-27 18:08:27 +0300256 */
257struct ipa3_rt_tbl {
258 struct list_head link;
Mohammed Javid93e94ce2017-06-15 15:39:04 +0530259 u32 cookie;
Amir Levy9659e592016-10-27 18:08:27 +0300260 struct list_head head_rt_rule_list;
261 char name[IPA_RESOURCE_NAME_MAX];
262 u32 idx;
263 u32 rule_cnt;
264 u32 ref_cnt;
265 struct ipa3_rt_tbl_set *set;
Amir Levy9659e592016-10-27 18:08:27 +0300266 bool in_sys[IPA_RULE_TYPE_MAX];
267 u32 sz[IPA_RULE_TYPE_MAX];
268 struct ipa_mem_buffer curr_mem[IPA_RULE_TYPE_MAX];
269 struct ipa_mem_buffer prev_mem[IPA_RULE_TYPE_MAX];
270 int id;
Skylar Chang0c37f5f2017-07-24 10:22:53 -0700271 struct idr *rule_ids;
Amir Levy9659e592016-10-27 18:08:27 +0300272};
273
274/**
275 * struct ipa3_hdr_entry - IPA header table entry
276 * @link: entry's link in global header table entries list
277 * @hdr: the header
278 * @hdr_len: header length
279 * @name: name of header table entry
280 * @type: l2 header type
281 * @is_partial: flag indicating if header table entry is partial
282 * @is_hdr_proc_ctx: false - hdr entry resides in hdr table,
283 * true - hdr entry resides in DDR and pointed to by proc ctx
284 * @phys_base: physical address of entry in DDR when is_hdr_proc_ctx is true,
285 * else 0
286 * @proc_ctx: processing context header
287 * @offset_entry: entry's offset
288 * @cookie: cookie used for validity check
289 * @ref_cnt: reference counter of routing table
290 * @id: header entry id
291 * @is_eth2_ofst_valid: is eth2_ofst field valid?
292 * @eth2_ofst: offset to start of Ethernet-II/802.3 header
Ghanim Fodi2c8ba072017-01-12 15:14:15 +0200293 * @user_deleted: is the header deleted by the user?
Amir Levy9659e592016-10-27 18:08:27 +0300294 */
295struct ipa3_hdr_entry {
296 struct list_head link;
Mohammed Javid93e94ce2017-06-15 15:39:04 +0530297 u32 cookie;
Amir Levy9659e592016-10-27 18:08:27 +0300298 u8 hdr[IPA_HDR_MAX_SIZE];
299 u32 hdr_len;
300 char name[IPA_RESOURCE_NAME_MAX];
301 enum ipa_hdr_l2_type type;
302 u8 is_partial;
303 bool is_hdr_proc_ctx;
304 dma_addr_t phys_base;
305 struct ipa3_hdr_proc_ctx_entry *proc_ctx;
306 struct ipa_hdr_offset_entry *offset_entry;
Amir Levy9659e592016-10-27 18:08:27 +0300307 u32 ref_cnt;
308 int id;
309 u8 is_eth2_ofst_valid;
310 u16 eth2_ofst;
Ghanim Fodi2c8ba072017-01-12 15:14:15 +0200311 bool user_deleted;
Amir Levy9659e592016-10-27 18:08:27 +0300312};
313
314/**
315 * struct ipa3_hdr_tbl - IPA header table
316 * @head_hdr_entry_list: header entries list
317 * @head_offset_list: header offset list
318 * @head_free_offset_list: header free offset list
319 * @hdr_cnt: number of headers
320 * @end: the last header index
321 */
322struct ipa3_hdr_tbl {
323 struct list_head head_hdr_entry_list;
324 struct list_head head_offset_list[IPA_HDR_BIN_MAX];
325 struct list_head head_free_offset_list[IPA_HDR_BIN_MAX];
326 u32 hdr_cnt;
327 u32 end;
328};
329
330/**
331 * struct ipa3_hdr_offset_entry - IPA header offset entry
332 * @link: entry's link in global processing context header offset entries list
333 * @offset: the offset
334 * @bin: bin
335 */
336struct ipa3_hdr_proc_ctx_offset_entry {
337 struct list_head link;
338 u32 offset;
339 u32 bin;
340};
341
342/**
343 * struct ipa3_hdr_proc_ctx_entry - IPA processing context header table entry
344 * @link: entry's link in global header table entries list
Skylar Chang7fa22712017-04-03 18:29:21 -0700345 * @type: header processing context type
346 * @l2tp_params: L2TP parameters
Amir Levy9659e592016-10-27 18:08:27 +0300347 * @offset_entry: entry's offset
348 * @hdr: the header
349 * @cookie: cookie used for validity check
350 * @ref_cnt: reference counter of routing table
351 * @id: processing context header entry id
Ghanim Fodi2c8ba072017-01-12 15:14:15 +0200352 * @user_deleted: is the hdr processing context deleted by the user?
Amir Levy9659e592016-10-27 18:08:27 +0300353 */
354struct ipa3_hdr_proc_ctx_entry {
355 struct list_head link;
Mohammed Javid93e94ce2017-06-15 15:39:04 +0530356 u32 cookie;
Amir Levy9659e592016-10-27 18:08:27 +0300357 enum ipa_hdr_proc_type type;
Skylar Chang7fa22712017-04-03 18:29:21 -0700358 union ipa_l2tp_hdr_proc_ctx_params l2tp_params;
Amir Levy9659e592016-10-27 18:08:27 +0300359 struct ipa3_hdr_proc_ctx_offset_entry *offset_entry;
360 struct ipa3_hdr_entry *hdr;
Amir Levy9659e592016-10-27 18:08:27 +0300361 u32 ref_cnt;
362 int id;
Ghanim Fodi2c8ba072017-01-12 15:14:15 +0200363 bool user_deleted;
Amir Levy9659e592016-10-27 18:08:27 +0300364};
365
366/**
367 * struct ipa3_hdr_proc_ctx_tbl - IPA processing context header table
368 * @head_proc_ctx_entry_list: header entries list
369 * @head_offset_list: header offset list
370 * @head_free_offset_list: header free offset list
371 * @proc_ctx_cnt: number of processing context headers
372 * @end: the last processing context header index
373 * @start_offset: offset in words of processing context header table
374 */
375struct ipa3_hdr_proc_ctx_tbl {
376 struct list_head head_proc_ctx_entry_list;
377 struct list_head head_offset_list[IPA_HDR_PROC_CTX_BIN_MAX];
378 struct list_head head_free_offset_list[IPA_HDR_PROC_CTX_BIN_MAX];
379 u32 proc_ctx_cnt;
380 u32 end;
381 u32 start_offset;
382};
383
384/**
385 * struct ipa3_flt_tbl - IPA filter table
386 * @head_flt_rule_list: filter rules list
387 * @rule_cnt: number of filter rules
388 * @in_sys: flag indicating if filter table is located in system memory
389 * @sz: the size of the filter tables
390 * @end: the last header index
391 * @curr_mem: current filter tables block in sys memory
392 * @prev_mem: previous filter table block in sys memory
Skylar Chang0c37f5f2017-07-24 10:22:53 -0700393 * @rule_ids: common idr structure that holds the rule_id for each rule
Amir Levy9659e592016-10-27 18:08:27 +0300394 */
395struct ipa3_flt_tbl {
396 struct list_head head_flt_rule_list;
397 u32 rule_cnt;
398 bool in_sys[IPA_RULE_TYPE_MAX];
399 u32 sz[IPA_RULE_TYPE_MAX];
400 struct ipa_mem_buffer curr_mem[IPA_RULE_TYPE_MAX];
401 struct ipa_mem_buffer prev_mem[IPA_RULE_TYPE_MAX];
402 bool sticky_rear;
Skylar Chang0c37f5f2017-07-24 10:22:53 -0700403 struct idr *rule_ids;
Amir Levy9659e592016-10-27 18:08:27 +0300404};
405
406/**
407 * struct ipa3_rt_entry - IPA routing table entry
408 * @link: entry's link in global routing table entries list
409 * @rule: routing rule
410 * @cookie: cookie used for validity check
411 * @tbl: routing table
412 * @hdr: header table
413 * @proc_ctx: processing context table
414 * @hw_len: the length of the table
415 * @id: rule handle - globaly unique
416 * @prio: rule 10bit priority which defines the order of the rule
417 * among other rules at the integrated same table
418 * @rule_id: rule 10bit ID to be returned in packet status
419 */
420struct ipa3_rt_entry {
421 struct list_head link;
Amir Levy9659e592016-10-27 18:08:27 +0300422 u32 cookie;
Mohammed Javid93e94ce2017-06-15 15:39:04 +0530423 struct ipa_rt_rule rule;
Amir Levy9659e592016-10-27 18:08:27 +0300424 struct ipa3_rt_tbl *tbl;
425 struct ipa3_hdr_entry *hdr;
426 struct ipa3_hdr_proc_ctx_entry *proc_ctx;
427 u32 hw_len;
428 int id;
429 u16 prio;
430 u16 rule_id;
431};
432
433/**
434 * struct ipa3_rt_tbl_set - collection of routing tables
435 * @head_rt_tbl_list: collection of routing tables
436 * @tbl_cnt: number of routing tables
Skylar Chang0c37f5f2017-07-24 10:22:53 -0700437 * @rule_ids: idr structure that holds the rule_id for each rule
Amir Levy9659e592016-10-27 18:08:27 +0300438 */
439struct ipa3_rt_tbl_set {
440 struct list_head head_rt_tbl_list;
441 u32 tbl_cnt;
Skylar Chang0c37f5f2017-07-24 10:22:53 -0700442 struct idr rule_ids;
Amir Levy9659e592016-10-27 18:08:27 +0300443};
444
445/**
446 * struct ipa3_wlan_stats - Wlan stats for each wlan endpoint
447 * @rx_pkts_rcvd: Packets sent by wlan driver
448 * @rx_pkts_status_rcvd: Status packets received from ipa hw
449 * @rx_hd_processed: Data Descriptors processed by IPA Driver
450 * @rx_hd_reply: Data Descriptors recycled by wlan driver
451 * @rx_hd_rcvd: Data Descriptors sent by wlan driver
452 * @rx_pkt_leak: Packet count that are not recycled
453 * @rx_dp_fail: Packets failed to transfer to IPA HW
454 * @tx_pkts_rcvd: SKB Buffers received from ipa hw
455 * @tx_pkts_sent: SKB Buffers sent to wlan driver
456 * @tx_pkts_dropped: Dropped packets count
457 */
458struct ipa3_wlan_stats {
459 u32 rx_pkts_rcvd;
460 u32 rx_pkts_status_rcvd;
461 u32 rx_hd_processed;
462 u32 rx_hd_reply;
463 u32 rx_hd_rcvd;
464 u32 rx_pkt_leak;
465 u32 rx_dp_fail;
466 u32 tx_pkts_rcvd;
467 u32 tx_pkts_sent;
468 u32 tx_pkts_dropped;
469};
470
471/**
472 * struct ipa3_wlan_comm_memb - Wlan comm members
473 * @wlan_spinlock: protects wlan comm buff list and its size
474 * @ipa_tx_mul_spinlock: protects tx dp mul transfer
475 * @wlan_comm_total_cnt: wlan common skb buffers allocated count
476 * @wlan_comm_free_cnt: wlan common skb buffer free count
477 * @total_tx_pkts_freed: Recycled Buffer count
478 * @wlan_comm_desc_list: wlan common skb buffer list
479 */
480struct ipa3_wlan_comm_memb {
481 spinlock_t wlan_spinlock;
482 spinlock_t ipa_tx_mul_spinlock;
483 u32 wlan_comm_total_cnt;
484 u32 wlan_comm_free_cnt;
485 u32 total_tx_pkts_freed;
486 struct list_head wlan_comm_desc_list;
487 atomic_t active_clnt_cnt;
488};
489
490struct ipa_gsi_ep_mem_info {
491 u16 evt_ring_len;
492 u64 evt_ring_base_addr;
493 void *evt_ring_base_vaddr;
494 u16 chan_ring_len;
495 u64 chan_ring_base_addr;
496 void *chan_ring_base_vaddr;
497};
498
499struct ipa3_status_stats {
500 struct ipahal_pkt_status status[IPA_MAX_STATUS_STAT_NUM];
Gidon Studinski3021a6f2016-11-10 12:48:48 +0200501 unsigned int curr;
Amir Levy9659e592016-10-27 18:08:27 +0300502};
503
504/**
505 * struct ipa3_ep_context - IPA end point context
506 * @valid: flag indicating id EP context is valid
507 * @client: EP client type
Amir Levy9659e592016-10-27 18:08:27 +0300508 * @gsi_chan_hdl: EP's GSI channel handle
509 * @gsi_evt_ring_hdl: EP's GSI channel event ring handle
510 * @gsi_mem_info: EP's GSI channel rings info
511 * @chan_scratch: EP's GSI channel scratch info
512 * @cfg: EP cionfiguration
513 * @dst_pipe_index: destination pipe index
514 * @rt_tbl_idx: routing table index
Amir Levy9659e592016-10-27 18:08:27 +0300515 * @priv: user provided information which will forwarded once the user is
516 * notified for new data avail
517 * @client_notify: user provided CB for EP events notification, the event is
518 * data revived.
Amir Levy9659e592016-10-27 18:08:27 +0300519 * @skip_ep_cfg: boolean field that determines if EP should be configured
520 * by IPA driver
521 * @keep_ipa_awake: when true, IPA will not be clock gated
522 * @disconnect_in_progress: Indicates client disconnect in progress.
523 * @qmi_request_sent: Indicates whether QMI request to enable clear data path
524 * request is sent or not.
525 * @napi_enabled: when true, IPA call client callback to start polling
526 */
527struct ipa3_ep_context {
528 int valid;
529 enum ipa_client_type client;
Amir Levy9659e592016-10-27 18:08:27 +0300530 unsigned long gsi_chan_hdl;
531 unsigned long gsi_evt_ring_hdl;
532 struct ipa_gsi_ep_mem_info gsi_mem_info;
533 union __packed gsi_channel_scratch chan_scratch;
534 bool bytes_xfered_valid;
535 u16 bytes_xfered;
536 dma_addr_t phys_base;
537 struct ipa_ep_cfg cfg;
538 struct ipa_ep_cfg_holb holb;
539 struct ipahal_reg_ep_cfg_status status;
540 u32 dst_pipe_index;
541 u32 rt_tbl_idx;
Amir Levy9659e592016-10-27 18:08:27 +0300542 void *priv;
543 void (*client_notify)(void *priv, enum ipa_dp_evt_type evt,
544 unsigned long data);
Amir Levy9659e592016-10-27 18:08:27 +0300545 atomic_t avail_fifo_desc;
546 u32 dflt_flt4_rule_hdl;
547 u32 dflt_flt6_rule_hdl;
548 bool skip_ep_cfg;
549 bool keep_ipa_awake;
550 struct ipa3_wlan_stats wstats;
551 u32 uc_offload_state;
552 bool disconnect_in_progress;
553 u32 qmi_request_sent;
554 bool napi_enabled;
Amir Levy9659e592016-10-27 18:08:27 +0300555 u32 eot_in_poll_err;
556
557 /* sys MUST be the last element of this struct */
558 struct ipa3_sys_context *sys;
559};
560
561/**
562 * ipa_usb_xdci_chan_params - xDCI channel related properties
563 *
564 * @ipa_ep_cfg: IPA EP configuration
565 * @client: type of "client"
566 * @priv: callback cookie
567 * @notify: callback
568 * priv - callback cookie evt - type of event data - data relevant
569 * to event. May not be valid. See event_type enum for valid
570 * cases.
571 * @skip_ep_cfg: boolean field that determines if EP should be
572 * configured by IPA driver
573 * @keep_ipa_awake: when true, IPA will not be clock gated
574 * @evt_ring_params: parameters for the channel's event ring
575 * @evt_scratch: parameters for the channel's event ring scratch
576 * @chan_params: parameters for the channel
577 * @chan_scratch: parameters for the channel's scratch
578 *
579 */
580struct ipa_request_gsi_channel_params {
581 struct ipa_ep_cfg ipa_ep_cfg;
582 enum ipa_client_type client;
583 void *priv;
584 ipa_notify_cb notify;
585 bool skip_ep_cfg;
586 bool keep_ipa_awake;
587 struct gsi_evt_ring_props evt_ring_params;
588 union __packed gsi_evt_scratch evt_scratch;
589 struct gsi_chan_props chan_params;
590 union __packed gsi_channel_scratch chan_scratch;
591};
592
593enum ipa3_sys_pipe_policy {
594 IPA_POLICY_INTR_MODE,
595 IPA_POLICY_NOINTR_MODE,
596 IPA_POLICY_INTR_POLL_MODE,
597};
598
599struct ipa3_repl_ctx {
600 struct ipa3_rx_pkt_wrapper **cache;
601 atomic_t head_idx;
602 atomic_t tail_idx;
603 u32 capacity;
604};
605
606/**
Amir Levya59ed3f2017-03-05 17:30:55 +0200607 * struct ipa3_sys_context - IPA GPI pipes context
Amir Levy9659e592016-10-27 18:08:27 +0300608 * @head_desc_list: header descriptors list
609 * @len: the size of the above list
610 * @spinlock: protects the list and its size
Amir Levy9659e592016-10-27 18:08:27 +0300611 * @ep: IPA EP context
612 *
Amir Levya59ed3f2017-03-05 17:30:55 +0200613 * IPA context specific to the GPI pipes a.k.a LAN IN/OUT and WAN
Amir Levy9659e592016-10-27 18:08:27 +0300614 */
615struct ipa3_sys_context {
616 u32 len;
Skylar Changd407e592017-03-30 11:25:30 -0700617 u32 len_pending_xfer;
Amir Levy9659e592016-10-27 18:08:27 +0300618 atomic_t curr_polling_state;
619 struct delayed_work switch_to_intr_work;
620 enum ipa3_sys_pipe_policy policy;
Skylar Changd407e592017-03-30 11:25:30 -0700621 bool use_comm_evt_ring;
Amir Levy9659e592016-10-27 18:08:27 +0300622 int (*pyld_hdlr)(struct sk_buff *skb, struct ipa3_sys_context *sys);
623 struct sk_buff * (*get_skb)(unsigned int len, gfp_t flags);
624 void (*free_skb)(struct sk_buff *skb);
625 void (*free_rx_wrapper)(struct ipa3_rx_pkt_wrapper *rk_pkt);
626 u32 rx_buff_sz;
627 u32 rx_pool_sz;
628 struct sk_buff *prev_skb;
629 unsigned int len_rem;
630 unsigned int len_pad;
631 unsigned int len_partial;
632 bool drop_packet;
633 struct work_struct work;
Amir Levy9659e592016-10-27 18:08:27 +0300634 struct delayed_work replenish_rx_work;
635 struct work_struct repl_work;
636 void (*repl_hdlr)(struct ipa3_sys_context *sys);
637 struct ipa3_repl_ctx repl;
638
639 /* ordering is important - mutable fields go above */
640 struct ipa3_ep_context *ep;
641 struct list_head head_desc_list;
642 struct list_head rcycl_list;
643 spinlock_t spinlock;
Skylar Changd407e592017-03-30 11:25:30 -0700644 struct hrtimer db_timer;
Amir Levy9659e592016-10-27 18:08:27 +0300645 struct workqueue_struct *wq;
646 struct workqueue_struct *repl_wq;
647 struct ipa3_status_stats *status_stat;
648 /* ordering is important - other immutable fields go below */
649};
650
651/**
652 * enum ipa3_desc_type - IPA decriptors type
653 *
654 * IPA decriptors type, IPA supports DD and ICD but no CD
655 */
656enum ipa3_desc_type {
657 IPA_DATA_DESC,
658 IPA_DATA_DESC_SKB,
659 IPA_DATA_DESC_SKB_PAGED,
660 IPA_IMM_CMD_DESC,
661};
662
663/**
664 * struct ipa3_tx_pkt_wrapper - IPA Tx packet wrapper
665 * @type: specify if this packet is for the skb or immediate command
666 * @mem: memory buffer used by this Tx packet
667 * @work: work struct for current Tx packet
668 * @link: linked to the wrappers on that pipe
669 * @callback: IPA client provided callback
670 * @user1: cookie1 for above callback
671 * @user2: cookie2 for above callback
672 * @sys: corresponding IPA sys context
Amir Levy9659e592016-10-27 18:08:27 +0300673 * @cnt: 1 for single transfers,
674 * >1 and <0xFFFF for first of a "multiple" transfer,
675 * 0xFFFF for last desc, 0 for rest of "multiple' transfer
676 * @bounce: va of bounce buffer
677 * @unmap_dma: in case this is true, the buffer will not be dma unmapped
678 *
679 * This struct can wrap both data packet and immediate command packet.
680 */
681struct ipa3_tx_pkt_wrapper {
682 enum ipa3_desc_type type;
683 struct ipa_mem_buffer mem;
684 struct work_struct work;
685 struct list_head link;
686 void (*callback)(void *user1, int user2);
687 void *user1;
688 int user2;
689 struct ipa3_sys_context *sys;
Amir Levy9659e592016-10-27 18:08:27 +0300690 u32 cnt;
691 void *bounce;
692 bool no_unmap_dma;
693};
694
695/**
696 * struct ipa3_dma_xfer_wrapper - IPADMA transfer descr wrapper
697 * @phys_addr_src: physical address of the source data to copy
698 * @phys_addr_dest: physical address to store the copied data
699 * @len: len in bytes to copy
700 * @link: linked to the wrappers list on the proper(sync/async) cons pipe
701 * @xfer_done: completion object for sync_memcpy completion
702 * @callback: IPADMA client provided completion callback
703 * @user1: cookie1 for above callback
704 *
705 * This struct can wrap both sync and async memcpy transfers descriptors.
706 */
707struct ipa3_dma_xfer_wrapper {
708 u64 phys_addr_src;
709 u64 phys_addr_dest;
710 u16 len;
711 struct list_head link;
712 struct completion xfer_done;
713 void (*callback)(void *user1);
714 void *user1;
715};
716
717/**
718 * struct ipa3_desc - IPA descriptor
719 * @type: skb or immediate command or plain old data
720 * @pyld: points to skb
721 * @frag: points to paged fragment
722 * or kmalloc'ed immediate command parameters/plain old data
723 * @dma_address: dma mapped address of pyld
724 * @dma_address_valid: valid field for dma_address
Michael Adisumartab5d170f2017-05-17 14:34:11 -0700725 * @is_tag_status: flag for IP_PACKET_TAG_STATUS imd cmd
Amir Levy9659e592016-10-27 18:08:27 +0300726 * @len: length of the pyld
727 * @opcode: for immediate commands
728 * @callback: IPA client provided completion callback
729 * @user1: cookie1 for above callback
730 * @user2: cookie2 for above callback
731 * @xfer_done: completion object for sync completion
Skylar Changd407e592017-03-30 11:25:30 -0700732 * @skip_db_ring: specifies whether GSI doorbell should not be rang
Amir Levy9659e592016-10-27 18:08:27 +0300733 */
734struct ipa3_desc {
735 enum ipa3_desc_type type;
736 void *pyld;
737 skb_frag_t *frag;
738 dma_addr_t dma_address;
739 bool dma_address_valid;
Michael Adisumartab5d170f2017-05-17 14:34:11 -0700740 bool is_tag_status;
Amir Levy9659e592016-10-27 18:08:27 +0300741 u16 len;
742 u16 opcode;
743 void (*callback)(void *user1, int user2);
744 void *user1;
745 int user2;
746 struct completion xfer_done;
Skylar Changd407e592017-03-30 11:25:30 -0700747 bool skip_db_ring;
Amir Levy9659e592016-10-27 18:08:27 +0300748};
749
750/**
751 * struct ipa3_rx_pkt_wrapper - IPA Rx packet wrapper
752 * @skb: skb
753 * @dma_address: DMA address of this Rx packet
754 * @link: linked to the Rx packets on that pipe
755 * @len: how many bytes are copied into skb's flat buffer
756 */
757struct ipa3_rx_pkt_wrapper {
758 struct list_head link;
759 struct ipa_rx_data data;
760 u32 len;
761 struct work_struct work;
762 struct ipa3_sys_context *sys;
763};
764
765/**
Amir Levy05fccd02017-06-13 16:25:45 +0300766* struct ipa_pdn_entry - IPA PDN config table entry
767* @public_ip: the PDN's public ip
768* @src_metadata: the PDN's metadata to be replaced for source NAT
769* @dst_metadata: the PDN's metadata to be replaced for destination NAT
770* @resrvd: reserved field
771*/
772struct ipa_pdn_entry {
773 u32 public_ip;
774 u32 src_metadata;
775 u32 dst_metadata;
776 u32 resrvd;
777};
778/**
Amir Levy9659e592016-10-27 18:08:27 +0300779 * struct ipa3_nat_mem - IPA NAT memory description
780 * @class: pointer to the struct class
781 * @dev: the dev_t of the device
782 * @cdev: cdev of the device
783 * @dev_num: device number
784 * @vaddr: virtual address
785 * @dma_handle: DMA handle
786 * @size: NAT memory size
787 * @is_mapped: flag indicating if NAT memory is mapped
788 * @is_sys_mem: flag indicating if NAT memory is sys memory
789 * @is_dev_init: flag indicating if NAT device is initialized
790 * @lock: NAT memory mutex
791 * @nat_base_address: nat table virutal address
792 * @ipv4_rules_addr: base nat table address
793 * @ipv4_expansion_rules_addr: expansion table address
794 * @index_table_addr: index table address
795 * @index_table_expansion_addr: index expansion table address
796 * @size_base_tables: base table size
797 * @size_expansion_tables: expansion table size
798 * @public_ip_addr: ip address of nat table
Amir Levy05fccd02017-06-13 16:25:45 +0300799 * @pdn_mem: pdn config table SW cache memory structure
Amir Levy9659e592016-10-27 18:08:27 +0300800 */
801struct ipa3_nat_mem {
802 struct class *class;
803 struct device *dev;
804 struct cdev cdev;
805 dev_t dev_num;
806 void *vaddr;
807 dma_addr_t dma_handle;
808 size_t size;
809 bool is_mapped;
810 bool is_sys_mem;
811 bool is_dev_init;
812 bool is_dev;
813 struct mutex lock;
814 void *nat_base_address;
815 char *ipv4_rules_addr;
816 char *ipv4_expansion_rules_addr;
817 char *index_table_addr;
818 char *index_table_expansion_addr;
819 u32 size_base_tables;
820 u32 size_expansion_tables;
821 u32 public_ip_addr;
822 void *tmp_vaddr;
823 dma_addr_t tmp_dma_handle;
824 bool is_tmp_mem;
Amir Levy05fccd02017-06-13 16:25:45 +0300825 struct ipa_mem_buffer pdn_mem;
Amir Levy9659e592016-10-27 18:08:27 +0300826};
827
828/**
829 * enum ipa3_hw_mode - IPA hardware mode
830 * @IPA_HW_Normal: Regular IPA hardware
831 * @IPA_HW_Virtual: IPA hardware supporting virtual memory allocation
832 * @IPA_HW_PCIE: IPA hardware supporting memory allocation over PCIE Bridge
833 */
834enum ipa3_hw_mode {
835 IPA_HW_MODE_NORMAL = 0,
836 IPA_HW_MODE_VIRTUAL = 1,
837 IPA_HW_MODE_PCIE = 2
838};
839
840enum ipa3_config_this_ep {
841 IPA_CONFIGURE_THIS_EP,
842 IPA_DO_NOT_CONFIGURE_THIS_EP,
843};
844
845struct ipa3_stats {
846 u32 tx_sw_pkts;
847 u32 tx_hw_pkts;
848 u32 rx_pkts;
849 u32 rx_excp_pkts[IPAHAL_PKT_STATUS_EXCEPTION_MAX];
850 u32 rx_repl_repost;
851 u32 tx_pkts_compl;
852 u32 rx_q_len;
853 u32 msg_w[IPA_EVENT_MAX_NUM];
854 u32 msg_r[IPA_EVENT_MAX_NUM];
855 u32 stat_compl;
856 u32 aggr_close;
857 u32 wan_aggr_close;
858 u32 wan_rx_empty;
859 u32 wan_repl_rx_empty;
860 u32 lan_rx_empty;
861 u32 lan_repl_rx_empty;
862 u32 flow_enable;
863 u32 flow_disable;
864 u32 tx_non_linear;
865};
866
867struct ipa3_active_clients {
868 struct mutex mutex;
Skylar Chang242952b2017-07-20 15:04:05 -0700869 atomic_t cnt;
Amir Levy9659e592016-10-27 18:08:27 +0300870};
871
872struct ipa3_wakelock_ref_cnt {
873 spinlock_t spinlock;
874 int cnt;
875};
876
877struct ipa3_tag_completion {
878 struct completion comp;
879 atomic_t cnt;
880};
881
882struct ipa3_controller;
883
884/**
885 * struct ipa3_uc_hdlrs - IPA uC callback functions
886 * @ipa_uc_loaded_hdlr: Function handler when uC is loaded
887 * @ipa_uc_event_hdlr: Event handler function
888 * @ipa3_uc_response_hdlr: Response handler function
889 * @ipa_uc_event_log_info_hdlr: Log event handler function
890 */
891struct ipa3_uc_hdlrs {
892 void (*ipa_uc_loaded_hdlr)(void);
893
894 void (*ipa_uc_event_hdlr)
895 (struct IpaHwSharedMemCommonMapping_t *uc_sram_mmio);
896
897 int (*ipa3_uc_response_hdlr)
898 (struct IpaHwSharedMemCommonMapping_t *uc_sram_mmio,
899 u32 *uc_status);
900
901 void (*ipa_uc_event_log_info_hdlr)
902 (struct IpaHwEventLogInfoData_t *uc_event_top_mmio);
903};
904
905/**
906 * enum ipa3_hw_flags - flags which defines the behavior of HW
907 *
908 * @IPA_HW_FLAG_HALT_SYSTEM_ON_ASSERT_FAILURE: Halt system in case of assert
909 * failure.
910 * @IPA_HW_FLAG_NO_REPORT_MHI_CHANNEL_ERORR: Channel error would be reported
911 * in the event ring only. No event to CPU.
912 * @IPA_HW_FLAG_NO_REPORT_MHI_CHANNEL_WAKE_UP: No need to report event
913 * IPA_HW_2_CPU_EVENT_MHI_WAKE_UP_REQUEST
914 * @IPA_HW_FLAG_WORK_OVER_DDR: Perform all transaction to external addresses by
915 * QMB (avoid memcpy)
916 * @IPA_HW_FLAG_NO_REPORT_OOB: If set do not report that the device is OOB in
917 * IN Channel
918 * @IPA_HW_FLAG_NO_REPORT_DB_MODE: If set, do not report that the device is
919 * entering a mode where it expects a doorbell to be rung for OUT Channel
920 * @IPA_HW_FLAG_NO_START_OOB_TIMER
921 */
922enum ipa3_hw_flags {
923 IPA_HW_FLAG_HALT_SYSTEM_ON_ASSERT_FAILURE = 0x01,
924 IPA_HW_FLAG_NO_REPORT_MHI_CHANNEL_ERORR = 0x02,
925 IPA_HW_FLAG_NO_REPORT_MHI_CHANNEL_WAKE_UP = 0x04,
926 IPA_HW_FLAG_WORK_OVER_DDR = 0x08,
927 IPA_HW_FLAG_NO_REPORT_OOB = 0x10,
928 IPA_HW_FLAG_NO_REPORT_DB_MODE = 0x20,
929 IPA_HW_FLAG_NO_START_OOB_TIMER = 0x40
930};
931
932/**
933 * struct ipa3_uc_ctx - IPA uC context
934 * @uc_inited: Indicates if uC interface has been initialized
935 * @uc_loaded: Indicates if uC has loaded
936 * @uc_failed: Indicates if uC has failed / returned an error
937 * @uc_lock: uC interface lock to allow only one uC interaction at a time
938 * @uc_spinlock: same as uc_lock but for irq contexts
939 * @uc_completation: Completion mechanism to wait for uC commands
940 * @uc_sram_mmio: Pointer to uC mapped memory
941 * @pending_cmd: The last command sent waiting to be ACKed
942 * @uc_status: The last status provided by the uC
943 * @uc_error_type: error type from uC error event
944 * @uc_error_timestamp: tag timer sampled after uC crashed
945 */
946struct ipa3_uc_ctx {
947 bool uc_inited;
948 bool uc_loaded;
949 bool uc_failed;
950 struct mutex uc_lock;
951 spinlock_t uc_spinlock;
952 struct completion uc_completion;
953 struct IpaHwSharedMemCommonMapping_t *uc_sram_mmio;
954 struct IpaHwEventLogInfoData_t *uc_event_top_mmio;
955 u32 uc_event_top_ofst;
956 u32 pending_cmd;
957 u32 uc_status;
958 u32 uc_error_type;
959 u32 uc_error_timestamp;
960 phys_addr_t rdy_ring_base_pa;
961 phys_addr_t rdy_ring_rp_pa;
962 u32 rdy_ring_size;
963 phys_addr_t rdy_comp_ring_base_pa;
964 phys_addr_t rdy_comp_ring_wp_pa;
965 u32 rdy_comp_ring_size;
966 u32 *rdy_ring_rp_va;
967 u32 *rdy_comp_ring_wp_va;
968};
969
970/**
971 * struct ipa3_uc_wdi_ctx
972 * @wdi_uc_top_ofst:
973 * @wdi_uc_top_mmio:
974 * @wdi_uc_stats_ofst:
975 * @wdi_uc_stats_mmio:
976 */
977struct ipa3_uc_wdi_ctx {
978 /* WDI specific fields */
979 u32 wdi_uc_stats_ofst;
980 struct IpaHwStatsWDIInfoData_t *wdi_uc_stats_mmio;
981 void *priv;
982 ipa_uc_ready_cb uc_ready_cb;
Skylar Chang6b41f8d2016-11-01 12:50:11 -0700983 /* for AP+STA stats update */
984#ifdef IPA_WAN_MSG_IPv6_ADDR_GW_LEN
985 ipa_wdi_meter_notifier_cb stats_notify;
986#endif
Amir Levy9659e592016-10-27 18:08:27 +0300987};
988
989/**
990 * struct ipa3_transport_pm - transport power management related members
Sridhar Ancha99b505b2016-04-21 23:11:10 +0530991 * @transport_pm_mutex: Mutex to protect the transport_pm functionality.
Amir Levy9659e592016-10-27 18:08:27 +0300992 */
993struct ipa3_transport_pm {
Amir Levy9659e592016-10-27 18:08:27 +0300994 atomic_t dec_clients;
995 atomic_t eot_activity;
Sridhar Ancha99b505b2016-04-21 23:11:10 +0530996 struct mutex transport_pm_mutex;
Amir Levy9659e592016-10-27 18:08:27 +0300997};
998
999/**
1000 * struct ipa3cm_client_info - the client-info indicated from IPACM
1001 * @ipacm_client_enum: the enum to indicate tether-client
1002 * @ipacm_client_uplink: the bool to indicate pipe for uplink
1003 */
1004struct ipa3cm_client_info {
1005 enum ipacm_client_enum client_enum;
1006 bool uplink;
1007};
1008
1009struct ipa3_smp2p_info {
1010 u32 out_base_id;
1011 u32 in_base_id;
Skylar Change1209942017-02-02 14:26:38 -08001012 bool ipa_clk_on;
Amir Levy9659e592016-10-27 18:08:27 +03001013 bool res_sent;
1014};
1015
1016/**
1017 * struct ipa3_ready_cb_info - A list of all the registrations
1018 * for an indication of IPA driver readiness
1019 *
1020 * @link: linked list link
1021 * @ready_cb: callback
1022 * @user_data: User data
1023 *
1024 */
1025struct ipa3_ready_cb_info {
1026 struct list_head link;
1027 ipa_ready_cb ready_cb;
1028 void *user_data;
1029};
1030
Gidon Studinski3021a6f2016-11-10 12:48:48 +02001031struct ipa_tz_unlock_reg_info {
1032 u64 reg_addr;
1033 u32 size;
1034};
1035
Skylar Chang6c4bec92017-04-21 16:10:14 -07001036struct ipa_dma_task_info {
1037 struct ipa_mem_buffer mem;
1038 struct ipahal_imm_cmd_pyld *cmd_pyld;
1039};
1040
Skylar Chang6f6e3072017-07-28 10:03:47 -07001041struct ipa_quota_stats {
1042 u64 num_ipv4_bytes;
1043 u64 num_ipv6_bytes;
1044 u32 num_ipv4_pkts;
1045 u32 num_ipv6_pkts;
1046};
1047
1048struct ipa_quota_stats_all {
1049 struct ipa_quota_stats client[IPA_CLIENT_MAX];
1050};
1051
1052struct ipa_drop_stats {
1053 u32 drop_packet_cnt;
1054 u32 drop_byte_cnt;
1055};
1056
1057struct ipa_drop_stats_all {
1058 struct ipa_drop_stats client[IPA_CLIENT_MAX];
1059};
1060
1061struct ipa_hw_stats_quota {
1062 struct ipahal_stats_init_quota init;
1063 struct ipa_quota_stats_all stats;
1064};
1065
1066struct ipa_hw_stats_teth {
1067 struct ipahal_stats_init_tethering init;
1068 struct ipa_quota_stats_all prod_stats[IPA_CLIENT_MAX];
1069};
1070
1071struct ipa_hw_stats_flt_rt {
1072 struct ipahal_stats_init_flt_rt flt_v4_init;
1073 struct ipahal_stats_init_flt_rt flt_v6_init;
1074 struct ipahal_stats_init_flt_rt rt_v4_init;
1075 struct ipahal_stats_init_flt_rt rt_v6_init;
1076};
1077
1078struct ipa_hw_stats_drop {
1079 struct ipahal_stats_init_drop init;
1080 struct ipa_drop_stats_all stats;
1081};
1082
1083struct ipa_hw_stats {
1084 bool enabled;
1085 struct ipa_hw_stats_quota quota;
1086 struct ipa_hw_stats_teth teth;
1087 struct ipa_hw_stats_flt_rt flt_rt;
1088 struct ipa_hw_stats_drop drop;
1089};
1090
Amir Levy9659e592016-10-27 18:08:27 +03001091/**
1092 * struct ipa3_context - IPA context
1093 * @class: pointer to the struct class
1094 * @dev_num: device number
1095 * @dev: the dev_t of the device
1096 * @cdev: cdev of the device
Amir Levy9659e592016-10-27 18:08:27 +03001097 * @ep: list of all end points
1098 * @skip_ep_cfg_shadow: state to update filter table correctly across
1099 power-save
1100 * @ep_flt_bitmap: End-points supporting filtering bitmap
1101 * @ep_flt_num: End-points supporting filtering number
Amir Levya59ed3f2017-03-05 17:30:55 +02001102 * @resume_on_connect: resume ep on ipa connect
Amir Levy9659e592016-10-27 18:08:27 +03001103 * @flt_tbl: list of all IPA filter tables
Skylar Chang0c37f5f2017-07-24 10:22:53 -07001104 * @flt_rule_ids: idr structure that holds the rule_id for each rule
Amir Levy9659e592016-10-27 18:08:27 +03001105 * @mode: IPA operating mode
1106 * @mmio: iomem
1107 * @ipa_wrapper_base: IPA wrapper base address
1108 * @hdr_tbl: IPA header table
1109 * @hdr_proc_ctx_tbl: IPA processing context table
1110 * @rt_tbl_set: list of routing tables each of which is a list of rules
1111 * @reap_rt_tbl_set: list of sys mem routing tables waiting to be reaped
1112 * @flt_rule_cache: filter rule cache
1113 * @rt_rule_cache: routing rule cache
1114 * @hdr_cache: header cache
1115 * @hdr_offset_cache: header offset cache
1116 * @hdr_proc_ctx_cache: processing context cache
1117 * @hdr_proc_ctx_offset_cache: processing context offset cache
1118 * @rt_tbl_cache: routing table cache
1119 * @tx_pkt_wrapper_cache: Tx packets cache
1120 * @rx_pkt_wrapper_cache: Rx packets cache
1121 * @rt_idx_bitmap: routing table index bitmap
1122 * @lock: this does NOT protect the linked lists within ipa3_sys_context
1123 * @smem_sz: shared memory size available for SW use starting
1124 * from non-restricted bytes
1125 * @smem_restricted_bytes: the bytes that SW should not use in the shared mem
1126 * @nat_mem: NAT memory
1127 * @excp_hdr_hdl: exception header handle
1128 * @dflt_v4_rt_rule_hdl: default v4 routing rule handle
1129 * @dflt_v6_rt_rule_hdl: default v6 routing rule handle
1130 * @aggregation_type: aggregation type used on USB client endpoint
1131 * @aggregation_byte_limit: aggregation byte limit used on USB client endpoint
1132 * @aggregation_time_limit: aggregation time limit used on USB client endpoint
1133 * @hdr_tbl_lcl: where hdr tbl resides 1-local, 0-system
1134 * @hdr_proc_ctx_tbl_lcl: where proc_ctx tbl resides true-local, false-system
1135 * @hdr_mem: header memory
1136 * @hdr_proc_ctx_mem: processing context memory
1137 * @ip4_rt_tbl_lcl: where ip4 rt tables reside 1-local; 0-system
1138 * @ip6_rt_tbl_lcl: where ip6 rt tables reside 1-local; 0-system
1139 * @ip4_flt_tbl_lcl: where ip4 flt tables reside 1-local; 0-system
1140 * @ip6_flt_tbl_lcl: where ip6 flt tables reside 1-local; 0-system
1141 * @power_mgmt_wq: workqueue for power management
1142 * @transport_power_mgmt_wq: workqueue transport related power management
1143 * @tag_process_before_gating: indicates whether to start tag process before
1144 * gating IPA clocks
1145 * @transport_pm: transport power management related information
1146 * @disconnect_lock: protects LAN_CONS packet receive notification CB
Amir Levy9659e592016-10-27 18:08:27 +03001147 * @ipa3_active_clients: structure for reference counting connected IPA clients
1148 * @ipa_hw_type: type of IPA HW type (e.g. IPA 1.0, IPA 1.1 etc')
1149 * @ipa3_hw_mode: mode of IPA HW mode (e.g. Normal, Virtual or over PCIe)
1150 * @use_ipa_teth_bridge: use tethering bridge driver
Amir Levy9659e592016-10-27 18:08:27 +03001151 * @modem_cfg_emb_pipe_flt: modem configure embedded pipe filtering rules
1152 * @logbuf: ipc log buffer for high priority messages
1153 * @logbuf_low: ipc log buffer for low priority messages
1154 * @ipa_wdi2: using wdi-2.0
1155 * @use_64_bit_dma_mask: using 64bits dma mask
1156 * @ipa_bus_hdl: msm driver handle for the data path bus
1157 * @ctrl: holds the core specific operations based on
1158 * core version (vtable like)
Michael Adisumartab5d170f2017-05-17 14:34:11 -07001159 * @pkt_init_imm_opcode: opcode for IP_PACKET_INIT imm cmd
Amir Levy9659e592016-10-27 18:08:27 +03001160 * @enable_clock_scaling: clock scaling is enabled ?
Ghanim Fodi6a831342017-03-07 18:19:15 +02001161 * @curr_ipa_clk_rate: IPA current clock rate
Amir Levy9659e592016-10-27 18:08:27 +03001162 * @wcstats: wlan common buffer stats
1163 * @uc_ctx: uC interface context
1164 * @uc_wdi_ctx: WDI specific fields for uC interface
1165 * @ipa_num_pipes: The number of pipes used by IPA HW
1166 * @skip_uc_pipe_reset: Indicates whether pipe reset via uC needs to be avoided
1167 * @ipa_client_apps_wan_cons_agg_gro: RMNET_IOCTL_INGRESS_FORMAT_AGG_DATA
1168 * @apply_rg10_wa: Indicates whether to use register group 10 workaround
1169 * @gsi_ch20_wa: Indicates whether to apply GSI physical channel 20 workaround
1170 * @w_lock: Indicates the wakeup source.
1171 * @wakelock_ref_cnt: Indicates the number of times wakelock is acquired
1172 * @ipa_initialization_complete: Indicates that IPA is fully initialized
1173 * @ipa_ready_cb_list: A list of all the clients who require a CB when IPA
1174 * driver is ready/initialized.
1175 * @init_completion_obj: Completion object to be used in case IPA driver hasn't
1176 * finished initializing. Example of use - IOCTLs to /dev/ipa
1177 * IPA context - holds all relevant info about IPA driver and its state
1178 */
1179struct ipa3_context {
1180 struct class *class;
1181 dev_t dev_num;
1182 struct device *dev;
1183 struct cdev cdev;
Amir Levy9659e592016-10-27 18:08:27 +03001184 struct ipa3_ep_context ep[IPA3_MAX_NUM_PIPES];
1185 bool skip_ep_cfg_shadow[IPA3_MAX_NUM_PIPES];
1186 u32 ep_flt_bitmap;
1187 u32 ep_flt_num;
1188 bool resume_on_connect[IPA_CLIENT_MAX];
1189 struct ipa3_flt_tbl flt_tbl[IPA3_MAX_NUM_PIPES][IPA_IP_MAX];
Skylar Chang0c37f5f2017-07-24 10:22:53 -07001190 struct idr flt_rule_ids[IPA_IP_MAX];
Amir Levy9659e592016-10-27 18:08:27 +03001191 void __iomem *mmio;
1192 u32 ipa_wrapper_base;
1193 u32 ipa_wrapper_size;
1194 struct ipa3_hdr_tbl hdr_tbl;
1195 struct ipa3_hdr_proc_ctx_tbl hdr_proc_ctx_tbl;
1196 struct ipa3_rt_tbl_set rt_tbl_set[IPA_IP_MAX];
1197 struct ipa3_rt_tbl_set reap_rt_tbl_set[IPA_IP_MAX];
1198 struct kmem_cache *flt_rule_cache;
1199 struct kmem_cache *rt_rule_cache;
1200 struct kmem_cache *hdr_cache;
1201 struct kmem_cache *hdr_offset_cache;
1202 struct kmem_cache *hdr_proc_ctx_cache;
1203 struct kmem_cache *hdr_proc_ctx_offset_cache;
1204 struct kmem_cache *rt_tbl_cache;
1205 struct kmem_cache *tx_pkt_wrapper_cache;
1206 struct kmem_cache *rx_pkt_wrapper_cache;
1207 unsigned long rt_idx_bitmap[IPA_IP_MAX];
1208 struct mutex lock;
1209 u16 smem_sz;
1210 u16 smem_restricted_bytes;
1211 u16 smem_reqd_sz;
1212 struct ipa3_nat_mem nat_mem;
1213 u32 excp_hdr_hdl;
1214 u32 dflt_v4_rt_rule_hdl;
1215 u32 dflt_v6_rt_rule_hdl;
1216 uint aggregation_type;
1217 uint aggregation_byte_limit;
1218 uint aggregation_time_limit;
1219 bool hdr_tbl_lcl;
1220 bool hdr_proc_ctx_tbl_lcl;
1221 struct ipa_mem_buffer hdr_mem;
1222 struct ipa_mem_buffer hdr_proc_ctx_mem;
1223 bool ip4_rt_tbl_hash_lcl;
1224 bool ip4_rt_tbl_nhash_lcl;
1225 bool ip6_rt_tbl_hash_lcl;
1226 bool ip6_rt_tbl_nhash_lcl;
1227 bool ip4_flt_tbl_hash_lcl;
1228 bool ip4_flt_tbl_nhash_lcl;
1229 bool ip6_flt_tbl_hash_lcl;
1230 bool ip6_flt_tbl_nhash_lcl;
Amir Levy9659e592016-10-27 18:08:27 +03001231 struct ipa3_active_clients ipa3_active_clients;
1232 struct ipa3_active_clients_log_ctx ipa3_active_clients_logging;
1233 struct workqueue_struct *power_mgmt_wq;
1234 struct workqueue_struct *transport_power_mgmt_wq;
1235 bool tag_process_before_gating;
1236 struct ipa3_transport_pm transport_pm;
Skylar Changd407e592017-03-30 11:25:30 -07001237 unsigned long gsi_evt_comm_hdl;
1238 u32 gsi_evt_comm_ring_rem;
Amir Levy9659e592016-10-27 18:08:27 +03001239 u32 clnt_hdl_cmd;
1240 u32 clnt_hdl_data_in;
1241 u32 clnt_hdl_data_out;
1242 spinlock_t disconnect_lock;
1243 u8 a5_pipe_index;
1244 struct list_head intf_list;
1245 struct list_head msg_list;
1246 struct list_head pull_msg_list;
1247 struct mutex msg_lock;
1248 wait_queue_head_t msg_waitq;
1249 enum ipa_hw_type ipa_hw_type;
1250 enum ipa3_hw_mode ipa3_hw_mode;
Amir Levy54fe4d32017-03-16 11:21:49 +02001251 bool ipa_config_is_mhi;
Amir Levy9659e592016-10-27 18:08:27 +03001252 bool use_ipa_teth_bridge;
Amir Levy9659e592016-10-27 18:08:27 +03001253 bool modem_cfg_emb_pipe_flt;
1254 bool ipa_wdi2;
1255 bool use_64_bit_dma_mask;
1256 /* featurize if memory footprint becomes a concern */
1257 struct ipa3_stats stats;
1258 void *smem_pipe_mem;
1259 void *logbuf;
1260 void *logbuf_low;
1261 u32 ipa_bus_hdl;
1262 struct ipa3_controller *ctrl;
1263 struct idr ipa_idr;
1264 struct device *pdev;
1265 struct device *uc_pdev;
1266 spinlock_t idr_lock;
1267 u32 enable_clock_scaling;
1268 u32 curr_ipa_clk_rate;
1269 bool q6_proxy_clk_vote_valid;
1270 u32 ipa_num_pipes;
Skylar Changcd3902d2017-03-27 18:08:27 -07001271 dma_addr_t pkt_init_imm[IPA3_MAX_NUM_PIPES];
Michael Adisumartab5d170f2017-05-17 14:34:11 -07001272 u32 pkt_init_imm_opcode;
Amir Levy9659e592016-10-27 18:08:27 +03001273
1274 struct ipa3_wlan_comm_memb wc_memb;
1275
1276 struct ipa3_uc_ctx uc_ctx;
1277
1278 struct ipa3_uc_wdi_ctx uc_wdi_ctx;
1279 struct ipa3_uc_ntn_ctx uc_ntn_ctx;
1280 u32 wan_rx_ring_size;
1281 u32 lan_rx_ring_size;
1282 bool skip_uc_pipe_reset;
Amir Levy9659e592016-10-27 18:08:27 +03001283 unsigned long gsi_dev_hdl;
1284 u32 ee;
1285 bool apply_rg10_wa;
1286 bool gsi_ch20_wa;
1287 bool smmu_present;
1288 bool smmu_s1_bypass;
Amir Levy9659e592016-10-27 18:08:27 +03001289 u32 wdi_map_cnt;
1290 struct wakeup_source w_lock;
1291 struct ipa3_wakelock_ref_cnt wakelock_ref_cnt;
1292 /* RMNET_IOCTL_INGRESS_FORMAT_AGG_DATA */
1293 bool ipa_client_apps_wan_cons_agg_gro;
1294 /* M-release support to know client pipes */
1295 struct ipa3cm_client_info ipacm_client[IPA3_MAX_NUM_PIPES];
1296 bool tethered_flow_control;
1297 bool ipa_initialization_complete;
1298 struct list_head ipa_ready_cb_list;
1299 struct completion init_completion_obj;
Skylar Chang0c17c7d2016-10-31 09:57:54 -07001300 struct completion uc_loaded_completion_obj;
Amir Levy9659e592016-10-27 18:08:27 +03001301 struct ipa3_smp2p_info smp2p_info;
Gidon Studinski3021a6f2016-11-10 12:48:48 +02001302 u32 ipa_tz_unlock_reg_num;
1303 struct ipa_tz_unlock_reg_info *ipa_tz_unlock_reg;
Skylar Chang6c4bec92017-04-21 16:10:14 -07001304 struct ipa_dma_task_info dma_task_info;
Skylar Chang6f6e3072017-07-28 10:03:47 -07001305 struct ipa_hw_stats hw_stats;
Amir Levy9659e592016-10-27 18:08:27 +03001306};
1307
Amir Levy9659e592016-10-27 18:08:27 +03001308struct ipa3_plat_drv_res {
1309 bool use_ipa_teth_bridge;
1310 u32 ipa_mem_base;
1311 u32 ipa_mem_size;
1312 u32 transport_mem_base;
1313 u32 transport_mem_size;
1314 u32 ipa_irq;
1315 u32 transport_irq;
1316 u32 ipa_pipe_mem_start_ofst;
1317 u32 ipa_pipe_mem_size;
1318 enum ipa_hw_type ipa_hw_type;
1319 enum ipa3_hw_mode ipa3_hw_mode;
1320 u32 ee;
Amir Levy9659e592016-10-27 18:08:27 +03001321 bool modem_cfg_emb_pipe_flt;
1322 bool ipa_wdi2;
1323 bool use_64_bit_dma_mask;
Ghanim Fodi6a831342017-03-07 18:19:15 +02001324 bool use_bw_vote;
Amir Levy9659e592016-10-27 18:08:27 +03001325 u32 wan_rx_ring_size;
1326 u32 lan_rx_ring_size;
1327 bool skip_uc_pipe_reset;
Amir Levy9659e592016-10-27 18:08:27 +03001328 bool apply_rg10_wa;
1329 bool gsi_ch20_wa;
1330 bool tethered_flow_control;
Gidon Studinski3021a6f2016-11-10 12:48:48 +02001331 u32 ipa_tz_unlock_reg_num;
1332 struct ipa_tz_unlock_reg_info *ipa_tz_unlock_reg;
Amir Levy9659e592016-10-27 18:08:27 +03001333};
1334
1335/**
1336 * struct ipa3_mem_partition - represents IPA RAM Map as read from DTS
1337 * Order and type of members should not be changed without a suitable change
1338 * to DTS file or the code that reads it.
1339 *
Amir Levy7e7a1342017-04-27 15:46:30 +03001340 * IPA SRAM memory layout:
1341 * +-------------------------+
1342 * | UC MEM |
Amir Levy9659e592016-10-27 18:08:27 +03001343 * +-------------------------+
1344 * | UC INFO |
1345 * +-------------------------+
1346 * | CANARY |
1347 * +-------------------------+
1348 * | CANARY |
1349 * +-------------------------+
1350 * | V4 FLT HDR HASHABLE |
1351 * +-------------------------+
1352 * | CANARY |
1353 * +-------------------------+
1354 * | CANARY |
1355 * +-------------------------+
1356 * | V4 FLT HDR NON-HASHABLE |
1357 * +-------------------------+
1358 * | CANARY |
1359 * +-------------------------+
1360 * | CANARY |
1361 * +-------------------------+
1362 * | V6 FLT HDR HASHABLE |
1363 * +-------------------------+
1364 * | CANARY |
1365 * +-------------------------+
1366 * | CANARY |
1367 * +-------------------------+
1368 * | V6 FLT HDR NON-HASHABLE |
1369 * +-------------------------+
1370 * | CANARY |
1371 * +-------------------------+
1372 * | CANARY |
1373 * +-------------------------+
1374 * | V4 RT HDR HASHABLE |
1375 * +-------------------------+
1376 * | CANARY |
1377 * +-------------------------+
1378 * | CANARY |
1379 * +-------------------------+
1380 * | V4 RT HDR NON-HASHABLE |
1381 * +-------------------------+
1382 * | CANARY |
1383 * +-------------------------+
1384 * | CANARY |
1385 * +-------------------------+
1386 * | V6 RT HDR HASHABLE |
1387 * +-------------------------+
1388 * | CANARY |
1389 * +-------------------------+
1390 * | CANARY |
1391 * +-------------------------+
1392 * | V6 RT HDR NON-HASHABLE |
1393 * +-------------------------+
1394 * | CANARY |
1395 * +-------------------------+
1396 * | CANARY |
1397 * +-------------------------+
1398 * | MODEM HDR |
1399 * +-------------------------+
1400 * | CANARY |
1401 * +-------------------------+
1402 * | CANARY |
1403 * +-------------------------+
1404 * | MODEM PROC CTX |
1405 * +-------------------------+
1406 * | APPS PROC CTX |
1407 * +-------------------------+
1408 * | CANARY |
1409 * +-------------------------+
Amir Levy7e7a1342017-04-27 15:46:30 +03001410 * | CANARY |
1411 * +-------------------------+
Michael Adisumarta891a4ff2017-05-16 16:40:06 -07001412 * | PDN CONFIG |
1413 * +-------------------------+
1414 * | CANARY |
1415 * +-------------------------+
1416 * | CANARY |
1417 * +-------------------------+
Skylar Chang6f6e3072017-07-28 10:03:47 -07001418 * | QUOTA STATS |
1419 * +-------------------------+
1420 * | CANARY |
1421 * +-------------------------+
1422 * | CANARY |
1423 * +-------------------------+
1424 * | TETH STATS |
1425 * +-------------------------+
1426 * | CANARY |
1427 * +-------------------------+
1428 * | CANARY |
1429 * +-------------------------+
1430 * | V4 FLT STATS |
1431 * +-------------------------+
1432 * | CANARY |
1433 * +-------------------------+
1434 * | CANARY |
1435 * +-------------------------+
1436 * | V6 FLT STATS |
1437 * +-------------------------+
1438 * | CANARY |
1439 * +-------------------------+
1440 * | CANARY |
1441 * +-------------------------+
1442 * | V4 RT STATS |
1443 * +-------------------------+
1444 * | CANARY |
1445 * +-------------------------+
1446 * | CANARY |
1447 * +-------------------------+
1448 * | V6 RT STATS |
1449 * +-------------------------+
1450 * | CANARY |
1451 * +-------------------------+
1452 * | CANARY |
1453 * +-------------------------+
1454 * | DROP STATS |
1455 * +-------------------------+
1456 * | CANARY |
1457 * +-------------------------+
1458 * | CANARY |
1459 * +-------------------------+
Amir Levy9659e592016-10-27 18:08:27 +03001460 * | MODEM MEM |
1461 * +-------------------------+
1462 * | CANARY |
1463 * +-------------------------+
Amir Levy7e7a1342017-04-27 15:46:30 +03001464 * | UC EVENT RING | From IPA 3.5
1465 * +-------------------------+
Amir Levy9659e592016-10-27 18:08:27 +03001466 */
1467struct ipa3_mem_partition {
1468 u32 ofst_start;
1469 u32 nat_ofst;
1470 u32 nat_size;
1471 u32 v4_flt_hash_ofst;
1472 u32 v4_flt_hash_size;
1473 u32 v4_flt_hash_size_ddr;
1474 u32 v4_flt_nhash_ofst;
1475 u32 v4_flt_nhash_size;
1476 u32 v4_flt_nhash_size_ddr;
1477 u32 v6_flt_hash_ofst;
1478 u32 v6_flt_hash_size;
1479 u32 v6_flt_hash_size_ddr;
1480 u32 v6_flt_nhash_ofst;
1481 u32 v6_flt_nhash_size;
1482 u32 v6_flt_nhash_size_ddr;
1483 u32 v4_rt_num_index;
1484 u32 v4_modem_rt_index_lo;
1485 u32 v4_modem_rt_index_hi;
1486 u32 v4_apps_rt_index_lo;
1487 u32 v4_apps_rt_index_hi;
1488 u32 v4_rt_hash_ofst;
1489 u32 v4_rt_hash_size;
1490 u32 v4_rt_hash_size_ddr;
1491 u32 v4_rt_nhash_ofst;
1492 u32 v4_rt_nhash_size;
1493 u32 v4_rt_nhash_size_ddr;
1494 u32 v6_rt_num_index;
1495 u32 v6_modem_rt_index_lo;
1496 u32 v6_modem_rt_index_hi;
1497 u32 v6_apps_rt_index_lo;
1498 u32 v6_apps_rt_index_hi;
1499 u32 v6_rt_hash_ofst;
1500 u32 v6_rt_hash_size;
1501 u32 v6_rt_hash_size_ddr;
1502 u32 v6_rt_nhash_ofst;
1503 u32 v6_rt_nhash_size;
1504 u32 v6_rt_nhash_size_ddr;
1505 u32 modem_hdr_ofst;
1506 u32 modem_hdr_size;
1507 u32 apps_hdr_ofst;
1508 u32 apps_hdr_size;
1509 u32 apps_hdr_size_ddr;
1510 u32 modem_hdr_proc_ctx_ofst;
1511 u32 modem_hdr_proc_ctx_size;
1512 u32 apps_hdr_proc_ctx_ofst;
1513 u32 apps_hdr_proc_ctx_size;
1514 u32 apps_hdr_proc_ctx_size_ddr;
1515 u32 modem_comp_decomp_ofst;
1516 u32 modem_comp_decomp_size;
1517 u32 modem_ofst;
1518 u32 modem_size;
1519 u32 apps_v4_flt_hash_ofst;
1520 u32 apps_v4_flt_hash_size;
1521 u32 apps_v4_flt_nhash_ofst;
1522 u32 apps_v4_flt_nhash_size;
1523 u32 apps_v6_flt_hash_ofst;
1524 u32 apps_v6_flt_hash_size;
1525 u32 apps_v6_flt_nhash_ofst;
1526 u32 apps_v6_flt_nhash_size;
1527 u32 uc_info_ofst;
1528 u32 uc_info_size;
1529 u32 end_ofst;
1530 u32 apps_v4_rt_hash_ofst;
1531 u32 apps_v4_rt_hash_size;
1532 u32 apps_v4_rt_nhash_ofst;
1533 u32 apps_v4_rt_nhash_size;
1534 u32 apps_v6_rt_hash_ofst;
1535 u32 apps_v6_rt_hash_size;
1536 u32 apps_v6_rt_nhash_ofst;
1537 u32 apps_v6_rt_nhash_size;
Amir Levy9fadeca2017-04-25 10:18:32 +03001538 u32 uc_event_ring_ofst;
1539 u32 uc_event_ring_size;
Michael Adisumarta891a4ff2017-05-16 16:40:06 -07001540 u32 pdn_config_ofst;
1541 u32 pdn_config_size;
Skylar Chang6f6e3072017-07-28 10:03:47 -07001542 u32 stats_quota_ofst;
1543 u32 stats_quota_size;
1544 u32 stats_tethering_ofst;
1545 u32 stats_tethering_size;
1546 u32 stats_flt_v4_ofst;
1547 u32 stats_flt_v4_size;
1548 u32 stats_flt_v6_ofst;
1549 u32 stats_flt_v6_size;
1550 u32 stats_rt_v4_ofst;
1551 u32 stats_rt_v4_size;
1552 u32 stats_rt_v6_ofst;
1553 u32 stats_rt_v6_size;
1554 u32 stats_drop_ofst;
1555 u32 stats_drop_size;
Amir Levy9659e592016-10-27 18:08:27 +03001556};
1557
1558struct ipa3_controller {
1559 struct ipa3_mem_partition mem_partition;
1560 u32 ipa_clk_rate_turbo;
1561 u32 ipa_clk_rate_nominal;
1562 u32 ipa_clk_rate_svs;
Skylar Chang448d8b82017-08-08 17:30:32 -07001563 u32 ipa_clk_rate_svs2;
Amir Levy9659e592016-10-27 18:08:27 +03001564 u32 clock_scaling_bw_threshold_turbo;
1565 u32 clock_scaling_bw_threshold_nominal;
Skylar Chang448d8b82017-08-08 17:30:32 -07001566 u32 clock_scaling_bw_threshold_svs;
Amir Levy9659e592016-10-27 18:08:27 +03001567 u32 ipa_reg_base_ofst;
1568 u32 max_holb_tmr_val;
1569 void (*ipa_sram_read_settings)(void);
1570 int (*ipa_init_sram)(void);
1571 int (*ipa_init_hdr)(void);
1572 int (*ipa_init_rt4)(void);
1573 int (*ipa_init_rt6)(void);
1574 int (*ipa_init_flt4)(void);
1575 int (*ipa_init_flt6)(void);
1576 int (*ipa3_read_ep_reg)(char *buff, int max_len, int pipe);
1577 int (*ipa3_commit_flt)(enum ipa_ip_type ip);
1578 int (*ipa3_commit_rt)(enum ipa_ip_type ip);
1579 int (*ipa3_commit_hdr)(void);
1580 void (*ipa3_enable_clks)(void);
1581 void (*ipa3_disable_clks)(void);
1582 struct msm_bus_scale_pdata *msm_bus_data_ptr;
1583};
1584
1585extern struct ipa3_context *ipa3_ctx;
1586
1587/* public APIs */
Amir Levy9659e592016-10-27 18:08:27 +03001588/* Generic GSI channels functions */
1589int ipa3_request_gsi_channel(struct ipa_request_gsi_channel_params *params,
1590 struct ipa_req_chan_out_params *out_params);
1591
1592int ipa3_release_gsi_channel(u32 clnt_hdl);
1593
1594int ipa3_start_gsi_channel(u32 clnt_hdl);
1595
1596int ipa3_stop_gsi_channel(u32 clnt_hdl);
1597
1598int ipa3_reset_gsi_channel(u32 clnt_hdl);
1599
1600int ipa3_reset_gsi_event_ring(u32 clnt_hdl);
1601
1602/* Specific xDCI channels functions */
1603int ipa3_set_usb_max_packet_size(
1604 enum ipa_usb_max_usb_packet_size usb_max_packet_size);
1605
Ghanim Fodi93a61112016-10-05 11:59:18 +03001606int ipa3_xdci_start(u32 clnt_hdl, u8 xferrscidx, bool xferrscidx_valid);
1607
1608int ipa3_xdci_connect(u32 clnt_hdl);
Amir Levy9659e592016-10-27 18:08:27 +03001609
1610int ipa3_xdci_disconnect(u32 clnt_hdl, bool should_force_clear, u32 qmi_req_id);
1611
1612int ipa3_xdci_suspend(u32 ul_clnt_hdl, u32 dl_clnt_hdl,
1613 bool should_force_clear, u32 qmi_req_id, bool is_dpl);
1614
1615int ipa3_xdci_resume(u32 ul_clnt_hdl, u32 dl_clnt_hdl, bool is_dpl);
1616
1617/*
Amir Levy9659e592016-10-27 18:08:27 +03001618 * Remove ep delay
1619 */
1620int ipa3_clear_endpoint_delay(u32 clnt_hdl);
1621
1622/*
1623 * Configuration
1624 */
1625int ipa3_cfg_ep(u32 clnt_hdl, const struct ipa_ep_cfg *ipa_ep_cfg);
1626
1627int ipa3_cfg_ep_nat(u32 clnt_hdl, const struct ipa_ep_cfg_nat *ipa_ep_cfg);
1628
Amir Levydc65f4c2017-07-06 09:49:50 +03001629int ipa3_cfg_ep_conn_track(u32 clnt_hdl,
1630 const struct ipa_ep_cfg_conn_track *ep_conn_track);
1631
Amir Levy9659e592016-10-27 18:08:27 +03001632int ipa3_cfg_ep_hdr(u32 clnt_hdl, const struct ipa_ep_cfg_hdr *ipa_ep_cfg);
1633
1634int ipa3_cfg_ep_hdr_ext(u32 clnt_hdl,
1635 const struct ipa_ep_cfg_hdr_ext *ipa_ep_cfg);
1636
1637int ipa3_cfg_ep_mode(u32 clnt_hdl, const struct ipa_ep_cfg_mode *ipa_ep_cfg);
1638
1639int ipa3_cfg_ep_aggr(u32 clnt_hdl, const struct ipa_ep_cfg_aggr *ipa_ep_cfg);
1640
1641int ipa3_cfg_ep_deaggr(u32 clnt_hdl,
1642 const struct ipa_ep_cfg_deaggr *ipa_ep_cfg);
1643
1644int ipa3_cfg_ep_route(u32 clnt_hdl, const struct ipa_ep_cfg_route *ipa_ep_cfg);
1645
1646int ipa3_cfg_ep_holb(u32 clnt_hdl, const struct ipa_ep_cfg_holb *ipa_ep_cfg);
1647
1648int ipa3_cfg_ep_cfg(u32 clnt_hdl, const struct ipa_ep_cfg_cfg *ipa_ep_cfg);
1649
1650int ipa3_cfg_ep_metadata_mask(u32 clnt_hdl,
1651 const struct ipa_ep_cfg_metadata_mask *ipa_ep_cfg);
1652
1653int ipa3_cfg_ep_holb_by_client(enum ipa_client_type client,
1654 const struct ipa_ep_cfg_holb *ipa_ep_cfg);
1655
1656int ipa3_cfg_ep_ctrl(u32 clnt_hdl, const struct ipa_ep_cfg_ctrl *ep_ctrl);
1657
1658/*
1659 * Header removal / addition
1660 */
1661int ipa3_add_hdr(struct ipa_ioc_add_hdr *hdrs);
1662
1663int ipa3_del_hdr(struct ipa_ioc_del_hdr *hdls);
1664
Ghanim Fodi2c8ba072017-01-12 15:14:15 +02001665int ipa3_del_hdr_by_user(struct ipa_ioc_del_hdr *hdls, bool by_user);
1666
Amir Levy9659e592016-10-27 18:08:27 +03001667int ipa3_commit_hdr(void);
1668
1669int ipa3_reset_hdr(void);
1670
1671int ipa3_get_hdr(struct ipa_ioc_get_hdr *lookup);
1672
1673int ipa3_put_hdr(u32 hdr_hdl);
1674
1675int ipa3_copy_hdr(struct ipa_ioc_copy_hdr *copy);
1676
1677/*
1678 * Header Processing Context
1679 */
1680int ipa3_add_hdr_proc_ctx(struct ipa_ioc_add_hdr_proc_ctx *proc_ctxs);
1681
1682int ipa3_del_hdr_proc_ctx(struct ipa_ioc_del_hdr_proc_ctx *hdls);
1683
Ghanim Fodi2c8ba072017-01-12 15:14:15 +02001684int ipa3_del_hdr_proc_ctx_by_user(struct ipa_ioc_del_hdr_proc_ctx *hdls,
1685 bool by_user);
1686
Amir Levy9659e592016-10-27 18:08:27 +03001687/*
1688 * Routing
1689 */
1690int ipa3_add_rt_rule(struct ipa_ioc_add_rt_rule *rules);
1691
1692int ipa3_add_rt_rule_after(struct ipa_ioc_add_rt_rule_after *rules);
1693
1694int ipa3_del_rt_rule(struct ipa_ioc_del_rt_rule *hdls);
1695
1696int ipa3_commit_rt(enum ipa_ip_type ip);
1697
1698int ipa3_reset_rt(enum ipa_ip_type ip);
1699
1700int ipa3_get_rt_tbl(struct ipa_ioc_get_rt_tbl *lookup);
1701
1702int ipa3_put_rt_tbl(u32 rt_tbl_hdl);
1703
1704int ipa3_query_rt_index(struct ipa_ioc_get_rt_tbl_indx *in);
1705
1706int ipa3_mdfy_rt_rule(struct ipa_ioc_mdfy_rt_rule *rules);
1707
1708/*
1709 * Filtering
1710 */
1711int ipa3_add_flt_rule(struct ipa_ioc_add_flt_rule *rules);
1712
1713int ipa3_add_flt_rule_after(struct ipa_ioc_add_flt_rule_after *rules);
1714
1715int ipa3_del_flt_rule(struct ipa_ioc_del_flt_rule *hdls);
1716
1717int ipa3_mdfy_flt_rule(struct ipa_ioc_mdfy_flt_rule *rules);
1718
1719int ipa3_commit_flt(enum ipa_ip_type ip);
1720
1721int ipa3_reset_flt(enum ipa_ip_type ip);
1722
1723/*
1724 * NAT
1725 */
1726int ipa3_allocate_nat_device(struct ipa_ioc_nat_alloc_mem *mem);
1727
1728int ipa3_nat_init_cmd(struct ipa_ioc_v4_nat_init *init);
1729
1730int ipa3_nat_dma_cmd(struct ipa_ioc_nat_dma_cmd *dma);
1731
1732int ipa3_nat_del_cmd(struct ipa_ioc_v4_nat_del *del);
1733
Amir Levydc65f4c2017-07-06 09:49:50 +03001734int ipa3_nat_mdfy_pdn(struct ipa_ioc_nat_pdn_entry *mdfy_pdn);
Amir Levy05fccd02017-06-13 16:25:45 +03001735
Amir Levy9659e592016-10-27 18:08:27 +03001736/*
1737 * Messaging
1738 */
1739int ipa3_send_msg(struct ipa_msg_meta *meta, void *buff,
1740 ipa_msg_free_fn callback);
1741int ipa3_register_pull_msg(struct ipa_msg_meta *meta, ipa_msg_pull_fn callback);
1742int ipa3_deregister_pull_msg(struct ipa_msg_meta *meta);
1743
1744/*
1745 * Interface
1746 */
1747int ipa3_register_intf(const char *name, const struct ipa_tx_intf *tx,
1748 const struct ipa_rx_intf *rx);
1749int ipa3_register_intf_ext(const char *name, const struct ipa_tx_intf *tx,
1750 const struct ipa_rx_intf *rx,
1751 const struct ipa_ext_intf *ext);
1752int ipa3_deregister_intf(const char *name);
1753
1754/*
1755 * Aggregation
1756 */
1757int ipa3_set_aggr_mode(enum ipa_aggr_mode mode);
1758
1759int ipa3_set_qcncm_ndp_sig(char sig[3]);
1760
1761int ipa3_set_single_ndp_per_mbim(bool enable);
1762
1763/*
1764 * Data path
1765 */
1766int ipa3_tx_dp(enum ipa_client_type dst, struct sk_buff *skb,
1767 struct ipa_tx_meta *metadata);
1768
1769/*
1770 * To transfer multiple data packets
1771 * While passing the data descriptor list, the anchor node
1772 * should be of type struct ipa_tx_data_desc not list_head
1773*/
1774int ipa3_tx_dp_mul(enum ipa_client_type dst,
1775 struct ipa_tx_data_desc *data_desc);
1776
1777void ipa3_free_skb(struct ipa_rx_data *);
1778
1779/*
1780 * System pipes
1781 */
1782int ipa3_setup_sys_pipe(struct ipa_sys_connect_params *sys_in, u32 *clnt_hdl);
1783
1784int ipa3_teardown_sys_pipe(u32 clnt_hdl);
1785
1786int ipa3_sys_setup(struct ipa_sys_connect_params *sys_in,
Amir Levya59ed3f2017-03-05 17:30:55 +02001787 unsigned long *ipa_transport_hdl,
Amir Levy9659e592016-10-27 18:08:27 +03001788 u32 *ipa_pipe_num, u32 *clnt_hdl, bool en_status);
1789
1790int ipa3_sys_teardown(u32 clnt_hdl);
1791
1792int ipa3_sys_update_gsi_hdls(u32 clnt_hdl, unsigned long gsi_ch_hdl,
1793 unsigned long gsi_ev_hdl);
1794
1795int ipa3_connect_wdi_pipe(struct ipa_wdi_in_params *in,
1796 struct ipa_wdi_out_params *out);
1797int ipa3_disconnect_wdi_pipe(u32 clnt_hdl);
1798int ipa3_enable_wdi_pipe(u32 clnt_hdl);
1799int ipa3_disable_wdi_pipe(u32 clnt_hdl);
1800int ipa3_resume_wdi_pipe(u32 clnt_hdl);
1801int ipa3_suspend_wdi_pipe(u32 clnt_hdl);
1802int ipa3_get_wdi_stats(struct IpaHwStatsWDIInfoData_t *stats);
1803u16 ipa3_get_smem_restr_bytes(void);
Skylar Chang6b41f8d2016-11-01 12:50:11 -07001804int ipa3_broadcast_wdi_quota_reach_ind(uint32_t fid, uint64_t num_bytes);
Amir Levy9659e592016-10-27 18:08:27 +03001805int ipa3_setup_uc_ntn_pipes(struct ipa_ntn_conn_in_params *in,
1806 ipa_notify_cb notify, void *priv, u8 hdr_len,
1807 struct ipa_ntn_conn_out_params *outp);
1808int ipa3_tear_down_uc_offload_pipes(int ipa_ep_idx_ul, int ipa_ep_idx_dl);
Sunil Paidimarrifbbcd072017-04-04 17:43:50 -07001809int ipa3_ntn_uc_reg_rdyCB(void (*ipauc_ready_cb)(void *), void *priv);
1810void ipa3_ntn_uc_dereg_rdyCB(void);
Amir Levy9659e592016-10-27 18:08:27 +03001811
1812/*
1813 * To retrieve doorbell physical address of
1814 * wlan pipes
1815 */
1816int ipa3_uc_wdi_get_dbpa(struct ipa_wdi_db_params *out);
1817
1818/*
1819 * To register uC ready callback if uC not ready
1820 * and also check uC readiness
1821 * if uC not ready only, register callback
1822 */
1823int ipa3_uc_reg_rdyCB(struct ipa_wdi_uc_ready_params *param);
1824/*
1825 * To de-register uC ready callback
1826 */
1827int ipa3_uc_dereg_rdyCB(void);
1828
1829/*
1830 * Tethering bridge (Rmnet / MBIM)
1831 */
1832int ipa3_teth_bridge_init(struct teth_bridge_init_params *params);
1833
1834int ipa3_teth_bridge_disconnect(enum ipa_client_type client);
1835
1836int ipa3_teth_bridge_connect(struct teth_bridge_connect_params *connect_params);
1837
1838/*
1839 * Tethering client info
1840 */
1841void ipa3_set_client(int index, enum ipacm_client_enum client, bool uplink);
1842
1843enum ipacm_client_enum ipa3_get_client(int pipe_idx);
1844
1845bool ipa3_get_client_uplink(int pipe_idx);
1846
Skylar Chang6b41f8d2016-11-01 12:50:11 -07001847int ipa3_get_wlan_stats(struct ipa_get_wdi_sap_stats *wdi_sap_stats);
1848
1849int ipa3_set_wlan_quota(struct ipa_set_wifi_quota *wdi_quota);
Amir Levy9659e592016-10-27 18:08:27 +03001850/*
1851 * IPADMA
1852 */
1853int ipa3_dma_init(void);
1854
1855int ipa3_dma_enable(void);
1856
1857int ipa3_dma_disable(void);
1858
1859int ipa3_dma_sync_memcpy(u64 dest, u64 src, int len);
1860
1861int ipa3_dma_async_memcpy(u64 dest, u64 src, int len,
1862 void (*user_cb)(void *user1), void *user_param);
1863
1864int ipa3_dma_uc_memcpy(phys_addr_t dest, phys_addr_t src, int len);
1865
1866void ipa3_dma_destroy(void);
1867
1868/*
1869 * MHI
1870 */
1871
1872int ipa3_mhi_init_engine(struct ipa_mhi_init_engine *params);
1873
1874int ipa3_connect_mhi_pipe(
1875 struct ipa_mhi_connect_params_internal *in,
1876 u32 *clnt_hdl);
1877
1878int ipa3_disconnect_mhi_pipe(u32 clnt_hdl);
1879
1880bool ipa3_mhi_stop_gsi_channel(enum ipa_client_type client);
1881
1882int ipa3_mhi_reset_channel_internal(enum ipa_client_type client);
1883
1884int ipa3_mhi_start_channel_internal(enum ipa_client_type client);
1885
1886bool ipa3_has_open_aggr_frame(enum ipa_client_type client);
1887
1888int ipa3_mhi_resume_channels_internal(enum ipa_client_type client,
1889 bool LPTransitionRejected, bool brstmode_enabled,
1890 union __packed gsi_channel_scratch ch_scratch, u8 index);
1891
1892int ipa3_mhi_destroy_channel(enum ipa_client_type client);
1893
1894/*
1895 * mux id
1896 */
1897int ipa3_write_qmap_id(struct ipa_ioc_write_qmapid *param_in);
1898
1899/*
1900 * interrupts
1901 */
1902int ipa3_add_interrupt_handler(enum ipa_irq_type interrupt,
1903 ipa_irq_handler_t handler,
1904 bool deferred_flag,
1905 void *private_data);
1906
1907int ipa3_remove_interrupt_handler(enum ipa_irq_type interrupt);
1908
1909/*
1910 * Miscellaneous
1911 */
Amir Levy9659e592016-10-27 18:08:27 +03001912int ipa3_get_ep_mapping(enum ipa_client_type client);
1913
1914bool ipa3_is_ready(void);
1915
1916void ipa3_proxy_clk_vote(void);
1917void ipa3_proxy_clk_unvote(void);
1918
1919bool ipa3_is_client_handle_valid(u32 clnt_hdl);
1920
1921enum ipa_client_type ipa3_get_client_mapping(int pipe_idx);
1922
1923void ipa_init_ep_flt_bitmap(void);
1924
1925bool ipa_is_ep_support_flt(int pipe_idx);
1926
1927enum ipa_rm_resource_name ipa3_get_rm_resource_from_ep(int pipe_idx);
1928
1929bool ipa3_get_modem_cfg_emb_pipe_flt(void);
1930
1931u8 ipa3_get_qmb_master_sel(enum ipa_client_type client);
1932
1933/* internal functions */
1934
1935int ipa3_bind_api_controller(enum ipa_hw_type ipa_hw_type,
1936 struct ipa_api_controller *api_ctrl);
1937
1938bool ipa_is_modem_pipe(int pipe_idx);
1939
1940int ipa3_send_one(struct ipa3_sys_context *sys, struct ipa3_desc *desc,
1941 bool in_atomic);
1942int ipa3_send(struct ipa3_sys_context *sys,
1943 u32 num_desc,
1944 struct ipa3_desc *desc,
1945 bool in_atomic);
1946int ipa3_get_ep_mapping(enum ipa_client_type client);
1947int ipa_get_ep_group(enum ipa_client_type client);
1948
1949int ipa3_generate_hw_rule(enum ipa_ip_type ip,
1950 const struct ipa_rule_attrib *attrib,
1951 u8 **buf,
1952 u16 *en_rule);
1953int ipa3_init_hw(void);
1954struct ipa3_rt_tbl *__ipa3_find_rt_tbl(enum ipa_ip_type ip, const char *name);
1955int ipa3_set_single_ndp_per_mbim(bool);
1956void ipa3_debugfs_init(void);
1957void ipa3_debugfs_remove(void);
1958
1959void ipa3_dump_buff_internal(void *base, dma_addr_t phy_base, u32 size);
1960#ifdef IPA_DEBUG
1961#define IPA_DUMP_BUFF(base, phy_base, size) \
1962 ipa3_dump_buff_internal(base, phy_base, size)
1963#else
1964#define IPA_DUMP_BUFF(base, phy_base, size)
1965#endif
1966int ipa3_init_mem_partition(struct device_node *dev_node);
1967int ipa3_controller_static_bind(struct ipa3_controller *controller,
1968 enum ipa_hw_type ipa_hw_type);
1969int ipa3_cfg_route(struct ipahal_reg_route *route);
Gidon Studinski3021a6f2016-11-10 12:48:48 +02001970int ipa3_send_cmd_timeout(u16 num_desc, struct ipa3_desc *descr, u32 timeout);
Amir Levy9659e592016-10-27 18:08:27 +03001971int ipa3_send_cmd(u16 num_desc, struct ipa3_desc *descr);
1972int ipa3_cfg_filter(u32 disable);
Amir Levy9659e592016-10-27 18:08:27 +03001973int ipa3_straddle_boundary(u32 start, u32 end, u32 boundary);
1974struct ipa3_context *ipa3_get_ctx(void);
1975void ipa3_enable_clks(void);
1976void ipa3_disable_clks(void);
1977void ipa3_inc_client_enable_clks(struct ipa_active_client_logging_info *id);
1978int ipa3_inc_client_enable_clks_no_block(struct ipa_active_client_logging_info
1979 *id);
1980void ipa3_dec_client_disable_clks(struct ipa_active_client_logging_info *id);
Skylar Chang242952b2017-07-20 15:04:05 -07001981void ipa3_dec_client_disable_clks_no_block(
1982 struct ipa_active_client_logging_info *id);
Amir Levy9659e592016-10-27 18:08:27 +03001983void ipa3_active_clients_log_dec(struct ipa_active_client_logging_info *id,
1984 bool int_ctx);
1985void ipa3_active_clients_log_inc(struct ipa_active_client_logging_info *id,
1986 bool int_ctx);
1987int ipa3_active_clients_log_print_buffer(char *buf, int size);
1988int ipa3_active_clients_log_print_table(char *buf, int size);
1989void ipa3_active_clients_log_clear(void);
1990int ipa3_interrupts_init(u32 ipa_irq, u32 ee, struct device *ipa_dev);
1991int __ipa3_del_rt_rule(u32 rule_hdl);
Ghanim Fodi2c8ba072017-01-12 15:14:15 +02001992int __ipa3_del_hdr(u32 hdr_hdl, bool by_user);
Amir Levy9659e592016-10-27 18:08:27 +03001993int __ipa3_release_hdr(u32 hdr_hdl);
1994int __ipa3_release_hdr_proc_ctx(u32 proc_ctx_hdl);
1995int _ipa_read_ep_reg_v3_0(char *buf, int max_len, int pipe);
Michael Adisumarta891a4ff2017-05-16 16:40:06 -07001996int _ipa_read_ep_reg_v4_0(char *buf, int max_len, int pipe);
Amir Levy9659e592016-10-27 18:08:27 +03001997void _ipa_enable_clks_v3_0(void);
1998void _ipa_disable_clks_v3_0(void);
1999struct device *ipa3_get_dma_dev(void);
2000void ipa3_suspend_active_aggr_wa(u32 clnt_hdl);
2001void ipa3_suspend_handler(enum ipa_irq_type interrupt,
2002 void *private_data,
2003 void *interrupt_data);
2004
Amir Levy9659e592016-10-27 18:08:27 +03002005ssize_t ipa3_read(struct file *filp, char __user *buf, size_t count,
2006 loff_t *f_pos);
2007int ipa3_pull_msg(struct ipa_msg_meta *meta, char *buff, size_t count);
2008int ipa3_query_intf(struct ipa_ioc_query_intf *lookup);
2009int ipa3_query_intf_tx_props(struct ipa_ioc_query_intf_tx_props *tx);
2010int ipa3_query_intf_rx_props(struct ipa_ioc_query_intf_rx_props *rx);
2011int ipa3_query_intf_ext_props(struct ipa_ioc_query_intf_ext_props *ext);
2012
2013void wwan_cleanup(void);
2014
2015int ipa3_teth_bridge_driver_init(void);
2016void ipa3_lan_rx_cb(void *priv, enum ipa_dp_evt_type evt, unsigned long data);
2017
Amir Levy9fadeca2017-04-25 10:18:32 +03002018int _ipa_init_sram_v3(void);
Amir Levy9659e592016-10-27 18:08:27 +03002019int _ipa_init_hdr_v3_0(void);
2020int _ipa_init_rt4_v3(void);
2021int _ipa_init_rt6_v3(void);
2022int _ipa_init_flt4_v3(void);
2023int _ipa_init_flt6_v3(void);
2024
2025int __ipa_commit_flt_v3(enum ipa_ip_type ip);
2026int __ipa_commit_rt_v3(enum ipa_ip_type ip);
2027
2028int __ipa_commit_hdr_v3_0(void);
2029void ipa3_skb_recycle(struct sk_buff *skb);
2030void ipa3_install_dflt_flt_rules(u32 ipa_ep_idx);
2031void ipa3_delete_dflt_flt_rules(u32 ipa_ep_idx);
2032
2033int ipa3_enable_data_path(u32 clnt_hdl);
2034int ipa3_disable_data_path(u32 clnt_hdl);
2035int ipa3_alloc_rule_id(struct idr *rule_ids);
2036int ipa3_id_alloc(void *ptr);
2037void *ipa3_id_find(u32 id);
2038void ipa3_id_remove(u32 id);
Skylar Change834a9e612016-12-22 14:20:32 -08002039int ipa3_enable_force_clear(u32 request_id, bool throttle_source,
2040 u32 source_pipe_bitmask);
2041int ipa3_disable_force_clear(u32 request_id);
Amir Levy9659e592016-10-27 18:08:27 +03002042
2043int ipa3_set_required_perf_profile(enum ipa_voltage_level floor_voltage,
2044 u32 bandwidth_mbps);
2045
2046int ipa3_cfg_ep_status(u32 clnt_hdl,
2047 const struct ipahal_reg_ep_cfg_status *ipa_ep_cfg);
2048
2049int ipa3_suspend_resource_no_block(enum ipa_rm_resource_name name);
2050int ipa3_suspend_resource_sync(enum ipa_rm_resource_name name);
2051int ipa3_resume_resource(enum ipa_rm_resource_name name);
2052bool ipa3_should_pipe_be_suspended(enum ipa_client_type client);
2053int ipa3_tag_aggr_force_close(int pipe_num);
2054
Amir Levy9659e592016-10-27 18:08:27 +03002055void ipa3_active_clients_unlock(void);
Amir Levy9659e592016-10-27 18:08:27 +03002056int ipa3_wdi_init(void);
2057int ipa3_write_qmapid_wdi_pipe(u32 clnt_hdl, u8 qmap_id);
2058int ipa3_tag_process(struct ipa3_desc *desc, int num_descs,
2059 unsigned long timeout);
2060
2061void ipa3_q6_pre_shutdown_cleanup(void);
2062void ipa3_q6_post_shutdown_cleanup(void);
2063int ipa3_init_q6_smem(void);
2064
Amir Levy9659e592016-10-27 18:08:27 +03002065int ipa3_mhi_handle_ipa_config_req(struct ipa_config_req_msg_v01 *config_req);
2066int ipa3_mhi_query_ch_info(enum ipa_client_type client,
2067 struct gsi_chan_info *ch_info);
2068
2069int ipa3_uc_interface_init(void);
Amir Levy9659e592016-10-27 18:08:27 +03002070int ipa3_uc_is_gsi_channel_empty(enum ipa_client_type ipa_client);
2071int ipa3_uc_state_check(void);
2072int ipa3_uc_loaded_check(void);
2073void ipa3_uc_load_notify(void);
2074int ipa3_uc_send_cmd(u32 cmd, u32 opcode, u32 expected_status,
2075 bool polling_mode, unsigned long timeout_jiffies);
2076void ipa3_uc_register_handlers(enum ipa3_hw_features feature,
2077 struct ipa3_uc_hdlrs *hdlrs);
2078int ipa3_create_nat_device(void);
2079int ipa3_uc_notify_clk_state(bool enabled);
2080void ipa3_dma_async_memcpy_notify_cb(void *priv,
2081 enum ipa_dp_evt_type evt, unsigned long data);
2082
2083int ipa3_uc_update_hw_flags(u32 flags);
2084
2085int ipa3_uc_mhi_init(void (*ready_cb)(void), void (*wakeup_request_cb)(void));
2086void ipa3_uc_mhi_cleanup(void);
2087int ipa3_uc_mhi_send_dl_ul_sync_info(union IpaHwMhiDlUlSyncCmdData_t *cmd);
2088int ipa3_uc_mhi_init_engine(struct ipa_mhi_msi_info *msi, u32 mmio_addr,
2089 u32 host_ctrl_addr, u32 host_data_addr, u32 first_ch_idx,
2090 u32 first_evt_idx);
2091int ipa3_uc_mhi_init_channel(int ipa_ep_idx, int channelHandle,
2092 int contexArrayIndex, int channelDirection);
2093int ipa3_uc_mhi_reset_channel(int channelHandle);
2094int ipa3_uc_mhi_suspend_channel(int channelHandle);
2095int ipa3_uc_mhi_resume_channel(int channelHandle, bool LPTransitionRejected);
2096int ipa3_uc_mhi_stop_event_update_channel(int channelHandle);
2097int ipa3_uc_mhi_print_stats(char *dbg_buff, int size);
2098int ipa3_uc_memcpy(phys_addr_t dest, phys_addr_t src, int len);
2099void ipa3_tag_destroy_imm(void *user1, int user2);
Amir Levy3be373c2017-03-05 16:31:30 +02002100const struct ipa_gsi_ep_config *ipa3_get_gsi_ep_info
2101 (enum ipa_client_type client);
Amir Levy9659e592016-10-27 18:08:27 +03002102void ipa3_uc_rg10_write_reg(enum ipahal_reg_name reg, u32 n, u32 val);
2103
Skylar Chang6f6e3072017-07-28 10:03:47 -07002104/* Hardware stats */
2105
2106#define IPA_STATS_MAX_PIPE_BIT 32
2107
2108struct ipa_teth_stats_endpoints {
2109 u32 prod_mask;
2110 u32 dst_ep_mask[IPA_STATS_MAX_PIPE_BIT];
2111};
2112
2113struct ipa_flt_rt_stats {
2114 u32 num_pkts;
2115 u32 num_pkts_hash;
2116};
2117
2118int ipa_hw_stats_init(void);
2119
2120int ipa_debugfs_init_stats(struct dentry *parent);
2121
2122int ipa_init_quota_stats(u32 pipe_bitmask);
2123
2124int ipa_get_quota_stats(struct ipa_quota_stats_all *out);
2125
2126int ipa_reset_quota_stats(enum ipa_client_type client);
2127
2128int ipa_reset_all_quota_stats(void);
2129
2130int ipa_init_drop_stats(u32 pipe_bitmask);
2131
2132int ipa_get_drop_stats(struct ipa_drop_stats_all *out);
2133
2134int ipa_reset_drop_stats(enum ipa_client_type client);
2135
2136int ipa_reset_all_drop_stats(void);
2137
2138int ipa_init_teth_stats(struct ipa_teth_stats_endpoints *in);
2139
2140int ipa_get_teth_stats(enum ipa_client_type prod,
2141 struct ipa_quota_stats_all *out);
2142
2143int ipa_reset_teth_stats(enum ipa_client_type prod, enum ipa_client_type cons);
2144
2145int ipa_reset_all_cons_teth_stats(enum ipa_client_type prod);
2146
2147int ipa_reset_all_teth_stats(void);
2148
2149int ipa_flt_rt_stats_add_rule_id(enum ipa_ip_type ip, bool filtering,
2150 u16 rule_id);
2151
2152int ipa_flt_rt_stats_start(enum ipa_ip_type ip, bool filtering);
2153
2154int ipa_flt_rt_stats_clear_rule_ids(enum ipa_ip_type ip, bool filtering);
2155
2156int ipa_get_flt_rt_stats(enum ipa_ip_type ip, bool filtering, u16 rule_id,
2157 struct ipa_flt_rt_stats *out);
2158
2159int ipa_reset_flt_rt_stats(enum ipa_ip_type ip, bool filtering, u16 rule_id);
2160
2161int ipa_reset_all_flt_rt_stats(enum ipa_ip_type ip, bool filtering);
2162
Amir Levy9659e592016-10-27 18:08:27 +03002163u32 ipa3_get_num_pipes(void);
2164struct ipa_smmu_cb_ctx *ipa3_get_smmu_ctx(void);
2165struct ipa_smmu_cb_ctx *ipa3_get_wlan_smmu_ctx(void);
2166struct ipa_smmu_cb_ctx *ipa3_get_uc_smmu_ctx(void);
2167struct iommu_domain *ipa3_get_smmu_domain(void);
2168struct iommu_domain *ipa3_get_uc_smmu_domain(void);
2169struct iommu_domain *ipa3_get_wlan_smmu_domain(void);
2170int ipa3_iommu_map(struct iommu_domain *domain, unsigned long iova,
2171 phys_addr_t paddr, size_t size, int prot);
2172int ipa3_ap_suspend(struct device *dev);
2173int ipa3_ap_resume(struct device *dev);
2174int ipa3_init_interrupts(void);
2175struct iommu_domain *ipa3_get_smmu_domain(void);
2176int ipa3_release_wdi_mapping(u32 num_buffers, struct ipa_wdi_buffer_info *info);
2177int ipa3_create_wdi_mapping(u32 num_buffers, struct ipa_wdi_buffer_info *info);
2178int ipa3_set_flt_tuple_mask(int pipe_idx, struct ipahal_reg_hash_tuple *tuple);
2179int ipa3_set_rt_tuple_mask(int tbl_idx, struct ipahal_reg_hash_tuple *tuple);
2180void ipa3_set_resorce_groups_min_max_limits(void);
2181void ipa3_suspend_apps_pipes(bool suspend);
Amir Levy9659e592016-10-27 18:08:27 +03002182int ipa3_flt_read_tbl_from_hw(u32 pipe_idx,
2183 enum ipa_ip_type ip_type,
2184 bool hashable,
2185 struct ipahal_flt_rule_entry entry[],
2186 int *num_entry);
2187int ipa3_rt_read_tbl_from_hw(u32 tbl_idx,
2188 enum ipa_ip_type ip_type,
2189 bool hashable,
2190 struct ipahal_rt_rule_entry entry[],
2191 int *num_entry);
2192int ipa3_restore_suspend_handler(void);
2193int ipa3_inject_dma_task_for_gsi(void);
2194int ipa3_uc_panic_notifier(struct notifier_block *this,
2195 unsigned long event, void *ptr);
2196void ipa3_inc_acquire_wakelock(void);
2197void ipa3_dec_release_wakelock(void);
Ghanim Fodi37b64952017-01-24 15:42:30 +02002198int ipa3_load_fws(const struct firmware *firmware, phys_addr_t gsi_mem_base);
Amir Levy9659e592016-10-27 18:08:27 +03002199int ipa3_register_ipa_ready_cb(void (*ipa_ready_cb)(void *), void *user_data);
2200const char *ipa_hw_error_str(enum ipa3_hw_errors err_type);
2201int ipa_gsi_ch20_wa(void);
2202int ipa3_rx_poll(u32 clnt_hdl, int budget);
2203void ipa3_recycle_wan_skb(struct sk_buff *skb);
2204int ipa3_smmu_map_peer_reg(phys_addr_t phys_addr, bool map);
2205int ipa3_smmu_map_peer_buff(u64 iova, phys_addr_t phys_addr,
2206 u32 size, bool map);
Skylar Change1209942017-02-02 14:26:38 -08002207void ipa3_reset_freeze_vote(void);
Amir Levy9659e592016-10-27 18:08:27 +03002208int ipa3_ntn_init(void);
2209int ipa3_get_ntn_stats(struct Ipa3HwStatsNTNInfoData_t *stats);
2210struct dentry *ipa_debugfs_get_root(void);
2211bool ipa3_is_msm_device(void);
Amir Levyc4222c92016-11-07 16:14:54 +02002212struct device *ipa3_get_pdev(void);
Amir Levy12ef0912016-08-30 09:27:34 +03002213void ipa3_enable_dcd(void);
Amir Levy3afd94a2017-01-05 10:19:13 +02002214void ipa3_disable_prefetch(enum ipa_client_type client);
Skylar Changd407e592017-03-30 11:25:30 -07002215int ipa3_alloc_common_event_ring(void);
Skylar Chang6c4bec92017-04-21 16:10:14 -07002216int ipa3_allocate_dma_task_for_gsi(void);
2217void ipa3_free_dma_task_for_gsi(void);
Amir Levy9659e592016-10-27 18:08:27 +03002218#endif /* _IPA3_I_H_ */