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