blob: 141bff117718a766715bcacba2d4a08073c55bca [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 _IPA_I_H_
14#define _IPA_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/msm-sps.h>
26#include <linux/platform_device.h>
27#include <asm/dma-iommu.h>
28#include <linux/iommu.h>
29#include <linux/ipa_uc_offload.h>
30#include "ipa_hw_defs.h"
31#include "ipa_ram_mmap.h"
32#include "ipa_reg.h"
33#include "ipa_qmi_service.h"
34#include "../ipa_api.h"
35#include "../ipa_common_i.h"
36#include "ipa_uc_offload_i.h"
37
38#define DRV_NAME "ipa"
39#define NAT_DEV_NAME "ipaNatTable"
Mohammed Javid93e94ce2017-06-15 15:39:04 +053040
Amir Levy9659e592016-10-27 18:08:27 +030041#define IPA_COOKIE 0x57831603
Mohammed Javid93e94ce2017-06-15 15:39:04 +053042#define IPA_RT_RULE_COOKIE 0x57831604
43#define IPA_RT_TBL_COOKIE 0x57831605
44#define IPA_FLT_COOKIE 0x57831606
45#define IPA_HDR_COOKIE 0x57831607
46#define IPA_PROC_HDR_COOKIE 0x57831608
47
48
Amir Levy9659e592016-10-27 18:08:27 +030049#define MTU_BYTE 1500
50
51#define IPA_MAX_NUM_PIPES 0x14
Amir Levy9659e592016-10-27 18:08:27 +030052#define IPA_SYS_DESC_FIFO_SZ 0x2000
53#define IPA_SYS_TX_DATA_DESC_FIFO_SZ 0x1000
54#define IPA_LAN_RX_HEADER_LENGTH (2)
55#define IPA_QMAP_HEADER_LENGTH (4)
56#define IPA_DL_CHECKSUM_LENGTH (8)
57#define IPA_NUM_DESC_PER_SW_TX (2)
58#define IPA_GENERIC_RX_POOL_SZ 1000
Gidon Studinski3021a6f2016-11-10 12:48:48 +020059#define IPA_UC_FINISH_MAX 6
60#define IPA_UC_WAIT_MIN_SLEEP 1000
61#define IPA_UC_WAII_MAX_SLEEP 1200
Utkarsh Saxena348fac02017-04-28 19:12:30 +053062#define IPA_BAM_STOP_MAX_RETRY 10
Amir Levy9659e592016-10-27 18:08:27 +030063
64#define IPA_MAX_STATUS_STAT_NUM 30
65
66#define IPADBG(fmt, args...) \
67 pr_debug(DRV_NAME " %s:%d " fmt, __func__, __LINE__, ## args)
68#define IPAERR(fmt, args...) \
69 pr_err(DRV_NAME " %s:%d " fmt, __func__, __LINE__, ## args)
70
Utkarsh Saxenae9782812017-05-26 17:20:32 +053071#define IPAERR_RL(fmt, args...) \
72 do { \
73 pr_err_ratelimited(DRV_NAME " %s:%d " fmt, __func__, \
74 __LINE__, ## args);\
75 if (ipa_ctx) { \
76 IPA_IPC_LOGGING(ipa_ctx->logbuf, \
77 DRV_NAME " %s:%d " fmt, ## args); \
78 IPA_IPC_LOGGING(ipa_ctx->logbuf_low, \
79 DRV_NAME " %s:%d " fmt, ## args); \
80 } \
81 } while (0)
82
Amir Levy9659e592016-10-27 18:08:27 +030083#define WLAN_AMPDU_TX_EP 15
84#define WLAN_PROD_TX_EP 19
85#define WLAN1_CONS_RX_EP 14
86#define WLAN2_CONS_RX_EP 16
87#define WLAN3_CONS_RX_EP 17
88#define WLAN4_CONS_RX_EP 18
89
90#define MAX_NUM_EXCP 8
91
92#define IPA_STATS
93
94#ifdef IPA_STATS
95#define IPA_STATS_INC_CNT(val) (++val)
96#define IPA_STATS_DEC_CNT(val) (--val)
97#define IPA_STATS_EXCP_CNT(flags, base) do { \
98 int i; \
99 for (i = 0; i < MAX_NUM_EXCP; i++) \
100 if (flags & BIT(i)) \
101 ++base[i]; \
102 if (flags == 0) \
103 ++base[MAX_NUM_EXCP - 1]; \
104 } while (0)
105#else
106#define IPA_STATS_INC_CNT(x) do { } while (0)
107#define IPA_STATS_DEC_CNT(x)
108#define IPA_STATS_EXCP_CNT(flags, base) do { } while (0)
109#endif
110
111#define IPA_TOS_EQ BIT(0)
112#define IPA_PROTOCOL_EQ BIT(1)
113#define IPA_OFFSET_MEQ32_0 BIT(2)
114#define IPA_OFFSET_MEQ32_1 BIT(3)
115#define IPA_IHL_OFFSET_RANGE16_0 BIT(4)
116#define IPA_IHL_OFFSET_RANGE16_1 BIT(5)
117#define IPA_IHL_OFFSET_EQ_16 BIT(6)
118#define IPA_IHL_OFFSET_EQ_32 BIT(7)
119#define IPA_IHL_OFFSET_MEQ32_0 BIT(8)
120#define IPA_OFFSET_MEQ128_0 BIT(9)
121#define IPA_OFFSET_MEQ128_1 BIT(10)
122#define IPA_TC_EQ BIT(11)
123#define IPA_FL_EQ BIT(12)
124#define IPA_IHL_OFFSET_MEQ32_1 BIT(13)
125#define IPA_METADATA_COMPARE BIT(14)
126#define IPA_IS_FRAG BIT(15)
127
128#define IPA_HDR_BIN0 0
129#define IPA_HDR_BIN1 1
130#define IPA_HDR_BIN2 2
131#define IPA_HDR_BIN3 3
132#define IPA_HDR_BIN4 4
133#define IPA_HDR_BIN_MAX 5
134
135#define IPA_HDR_PROC_CTX_BIN0 0
136#define IPA_HDR_PROC_CTX_BIN1 1
137#define IPA_HDR_PROC_CTX_BIN_MAX 2
138
139#define IPA_EVENT_THRESHOLD 0x10
140
141/*
142 * Due to ZLT issue with USB 3.0 core, IPA BAM threashold need to be set
143 * to max packet size + 1. After setting the threshold, USB core
144 * will not be notified on ZLTs
145 */
146#define IPA_USB_EVENT_THRESHOLD 0x4001
147
148#define IPA_RX_POOL_CEIL 32
149#define IPA_RX_SKB_SIZE 1792
150
151#define IPA_A5_MUX_HDR_NAME "ipa_excp_hdr"
152#define IPA_LAN_RX_HDR_NAME "ipa_lan_hdr"
153#define IPA_INVALID_L4_PROTOCOL 0xFF
154
155#define IPA_SETFIELD(val, shift, mask) (((val) << (shift)) & (mask))
156#define IPA_SETFIELD_IN_REG(reg, val, shift, mask) \
157 (reg |= ((val) << (shift)) & (mask))
158
159#define IPA_HW_TABLE_ALIGNMENT(start_ofst) \
160 (((start_ofst) + 127) & ~127)
Skylar Chang88610112016-10-19 13:30:44 -0700161#define IPA_RT_FLT_HW_RULE_BUF_SIZE (256)
Amir Levy9659e592016-10-27 18:08:27 +0300162
163#define IPA_HDR_PROC_CTX_TABLE_ALIGNMENT_BYTE 8
164#define IPA_HDR_PROC_CTX_TABLE_ALIGNMENT(start_ofst) \
165 (((start_ofst) + IPA_HDR_PROC_CTX_TABLE_ALIGNMENT_BYTE - 1) & \
166 ~(IPA_HDR_PROC_CTX_TABLE_ALIGNMENT_BYTE - 1))
167
168#define MAX_RESOURCE_TO_CLIENTS (IPA_CLIENT_MAX)
169#define IPA_MEM_PART(x_) (ipa_ctx->ctrl->mem_partition.x_)
170
171#define IPA2_ACTIVE_CLIENTS_LOG_BUFFER_SIZE_LINES 120
172#define IPA2_ACTIVE_CLIENTS_LOG_LINE_LEN 96
173#define IPA2_ACTIVE_CLIENTS_LOG_HASHTABLE_SIZE 50
174#define IPA2_ACTIVE_CLIENTS_LOG_NAME_LEN 40
175
176struct ipa2_active_client_htable_entry {
177 struct hlist_node list;
178 char id_string[IPA2_ACTIVE_CLIENTS_LOG_NAME_LEN];
179 int count;
180 enum ipa_active_client_log_type type;
181};
182
183struct ipa2_active_clients_log_ctx {
184 char *log_buffer[IPA2_ACTIVE_CLIENTS_LOG_BUFFER_SIZE_LINES];
185 int log_head;
186 int log_tail;
187 bool log_rdy;
188 struct hlist_head htable[IPA2_ACTIVE_CLIENTS_LOG_HASHTABLE_SIZE];
189};
190
191
192struct ipa_client_names {
193 enum ipa_client_type names[MAX_RESOURCE_TO_CLIENTS];
194 int length;
195};
196
197struct ipa_smmu_cb_ctx {
198 bool valid;
199 struct device *dev;
200 struct dma_iommu_mapping *mapping;
201 struct iommu_domain *iommu;
202 unsigned long next_addr;
203 u32 va_start;
204 u32 va_size;
205 u32 va_end;
206};
207
208/**
209 * struct ipa_flt_entry - IPA filtering table entry
210 * @link: entry's link in global filtering enrties list
211 * @rule: filter rule
212 * @cookie: cookie used for validity check
213 * @tbl: filter table
214 * @rt_tbl: routing table
215 * @hw_len: entry's size
216 */
217struct ipa_flt_entry {
218 struct list_head link;
Amir Levy9659e592016-10-27 18:08:27 +0300219 u32 cookie;
Mohammed Javid93e94ce2017-06-15 15:39:04 +0530220 struct ipa_flt_rule rule;
Amir Levy9659e592016-10-27 18:08:27 +0300221 struct ipa_flt_tbl *tbl;
222 struct ipa_rt_tbl *rt_tbl;
223 u32 hw_len;
224 int id;
225};
226
227/**
228 * struct ipa_rt_tbl - IPA routing table
229 * @link: table's link in global routing tables list
230 * @head_rt_rule_list: head of routing rules list
231 * @name: routing table name
232 * @idx: routing table index
233 * @rule_cnt: number of rules in routing table
234 * @ref_cnt: reference counter of routing table
235 * @set: collection of routing tables
236 * @cookie: cookie used for validity check
237 * @in_sys: flag indicating if the table is located in system memory
238 * @sz: the size of the routing table
239 * @curr_mem: current routing tables block in sys memory
240 * @prev_mem: previous routing table block in sys memory
241 * @id: routing table id
242 */
243struct ipa_rt_tbl {
244 struct list_head link;
Mohammed Javid93e94ce2017-06-15 15:39:04 +0530245 u32 cookie;
Amir Levy9659e592016-10-27 18:08:27 +0300246 struct list_head head_rt_rule_list;
247 char name[IPA_RESOURCE_NAME_MAX];
248 u32 idx;
249 u32 rule_cnt;
250 u32 ref_cnt;
251 struct ipa_rt_tbl_set *set;
Amir Levy9659e592016-10-27 18:08:27 +0300252 bool in_sys;
253 u32 sz;
254 struct ipa_mem_buffer curr_mem;
255 struct ipa_mem_buffer prev_mem;
256 int id;
257};
258
259/**
260 * struct ipa_hdr_entry - IPA header table entry
261 * @link: entry's link in global header table entries list
262 * @hdr: the header
263 * @hdr_len: header length
264 * @name: name of header table entry
265 * @type: l2 header type
266 * @is_partial: flag indicating if header table entry is partial
267 * @is_hdr_proc_ctx: false - hdr entry resides in hdr table,
268 * true - hdr entry resides in DDR and pointed to by proc ctx
269 * @phys_base: physical address of entry in DDR when is_hdr_proc_ctx is true,
270 * else 0
271 * @proc_ctx: processing context header
272 * @offset_entry: entry's offset
273 * @cookie: cookie used for validity check
274 * @ref_cnt: reference counter of routing table
275 * @id: header entry id
276 * @is_eth2_ofst_valid: is eth2_ofst field valid?
277 * @eth2_ofst: offset to start of Ethernet-II/802.3 header
Ghanim Fodi2c8ba072017-01-12 15:14:15 +0200278 * @user_deleted: is the header deleted by the user?
Amir Levy9659e592016-10-27 18:08:27 +0300279 */
280struct ipa_hdr_entry {
281 struct list_head link;
Mohammed Javid93e94ce2017-06-15 15:39:04 +0530282 u32 cookie;
Amir Levy9659e592016-10-27 18:08:27 +0300283 u8 hdr[IPA_HDR_MAX_SIZE];
284 u32 hdr_len;
285 char name[IPA_RESOURCE_NAME_MAX];
286 enum ipa_hdr_l2_type type;
287 u8 is_partial;
288 bool is_hdr_proc_ctx;
289 dma_addr_t phys_base;
290 struct ipa_hdr_proc_ctx_entry *proc_ctx;
291 struct ipa_hdr_offset_entry *offset_entry;
Amir Levy9659e592016-10-27 18:08:27 +0300292 u32 ref_cnt;
293 int id;
294 u8 is_eth2_ofst_valid;
295 u16 eth2_ofst;
Ghanim Fodi2c8ba072017-01-12 15:14:15 +0200296 bool user_deleted;
Amir Levy9659e592016-10-27 18:08:27 +0300297};
298
299/**
300 * struct ipa_hdr_tbl - IPA header table
301 * @head_hdr_entry_list: header entries list
302 * @head_offset_list: header offset list
303 * @head_free_offset_list: header free offset list
304 * @hdr_cnt: number of headers
305 * @end: the last header index
306 */
307struct ipa_hdr_tbl {
308 struct list_head head_hdr_entry_list;
309 struct list_head head_offset_list[IPA_HDR_BIN_MAX];
310 struct list_head head_free_offset_list[IPA_HDR_BIN_MAX];
311 u32 hdr_cnt;
312 u32 end;
313};
314
315/**
316 * struct ipa_hdr_offset_entry - IPA header offset entry
317 * @link: entry's link in global processing context header offset entries list
318 * @offset: the offset
319 * @bin: bin
320 */
321struct ipa_hdr_proc_ctx_offset_entry {
322 struct list_head link;
323 u32 offset;
324 u32 bin;
325};
326
327/**
328 * struct ipa_hdr_proc_ctx_add_hdr_seq -
329 * IPA processing context header - add header sequence
330 * @hdr_add: add header command
331 * @end: tlv end command (cmd.type must be 0)
332 */
333struct ipa_hdr_proc_ctx_add_hdr_seq {
334 struct ipa_hdr_proc_ctx_hdr_add hdr_add;
335 struct ipa_hdr_proc_ctx_tlv end;
336};
337
338/**
339 * struct ipa_hdr_proc_ctx_add_hdr_cmd_seq -
340 * IPA processing context header - process command sequence
341 * @hdr_add: add header command
342 * @cmd: tlv processing command (cmd.type must be 3)
343 * @end: tlv end command (cmd.type must be 0)
344 */
345struct ipa_hdr_proc_ctx_add_hdr_cmd_seq {
346 struct ipa_hdr_proc_ctx_hdr_add hdr_add;
347 struct ipa_hdr_proc_ctx_tlv cmd;
348 struct ipa_hdr_proc_ctx_tlv end;
349};
350
351/**
352 *struct ipa_hdr_proc_ctx_entry - IPA processing context header table entry
353 * @link: entry's link in global header table entries list
354 * @type:
355 * @offset_entry: entry's offset
356 * @hdr: the header
357 * @cookie: cookie used for validity check
358 * @ref_cnt: reference counter of routing table
359 * @id: processing context header entry id
Ghanim Fodi2c8ba072017-01-12 15:14:15 +0200360 * @user_deleted: is the hdr processing context deleted by the user?
Amir Levy9659e592016-10-27 18:08:27 +0300361 */
362struct ipa_hdr_proc_ctx_entry {
363 struct list_head link;
Mohammed Javid93e94ce2017-06-15 15:39:04 +0530364 u32 cookie;
Amir Levy9659e592016-10-27 18:08:27 +0300365 enum ipa_hdr_proc_type type;
366 struct ipa_hdr_proc_ctx_offset_entry *offset_entry;
367 struct ipa_hdr_entry *hdr;
Amir Levy9659e592016-10-27 18:08:27 +0300368 u32 ref_cnt;
369 int id;
Ghanim Fodi2c8ba072017-01-12 15:14:15 +0200370 bool user_deleted;
Amir Levy9659e592016-10-27 18:08:27 +0300371};
372
373/**
374 * struct ipa_hdr_proc_ctx_tbl - IPA processing context header table
375 * @head_proc_ctx_entry_list: header entries list
376 * @head_offset_list: header offset list
377 * @head_free_offset_list: header free offset list
378 * @proc_ctx_cnt: number of processing context headers
379 * @end: the last processing context header index
380 * @start_offset: offset in words of processing context header table
381 */
382struct ipa_hdr_proc_ctx_tbl {
383 struct list_head head_proc_ctx_entry_list;
384 struct list_head head_offset_list[IPA_HDR_PROC_CTX_BIN_MAX];
385 struct list_head head_free_offset_list[IPA_HDR_PROC_CTX_BIN_MAX];
386 u32 proc_ctx_cnt;
387 u32 end;
388 u32 start_offset;
389};
390
391/**
392 * struct ipa_flt_tbl - IPA filter table
393 * @head_flt_rule_list: filter rules list
394 * @rule_cnt: number of filter rules
395 * @in_sys: flag indicating if filter table is located in system memory
396 * @sz: the size of the filter table
397 * @end: the last header index
398 * @curr_mem: current filter tables block in sys memory
399 * @prev_mem: previous filter table block in sys memory
400 */
401struct ipa_flt_tbl {
402 struct list_head head_flt_rule_list;
403 u32 rule_cnt;
404 bool in_sys;
405 u32 sz;
406 struct ipa_mem_buffer curr_mem;
407 struct ipa_mem_buffer prev_mem;
408 bool sticky_rear;
409};
410
411/**
412 * struct ipa_rt_entry - IPA routing table entry
413 * @link: entry's link in global routing table entries list
414 * @rule: routing rule
415 * @cookie: cookie used for validity check
416 * @tbl: routing table
417 * @hdr: header table
418 * @proc_ctx: processing context table
419 * @hw_len: the length of the table
420 */
421struct ipa_rt_entry {
422 struct list_head link;
Amir Levy9659e592016-10-27 18:08:27 +0300423 u32 cookie;
Mohammed Javid93e94ce2017-06-15 15:39:04 +0530424 struct ipa_rt_rule rule;
Amir Levy9659e592016-10-27 18:08:27 +0300425 struct ipa_rt_tbl *tbl;
426 struct ipa_hdr_entry *hdr;
427 struct ipa_hdr_proc_ctx_entry *proc_ctx;
428 u32 hw_len;
429 int id;
430};
431
432/**
433 * struct ipa_rt_tbl_set - collection of routing tables
434 * @head_rt_tbl_list: collection of routing tables
435 * @tbl_cnt: number of routing tables
436 */
437struct ipa_rt_tbl_set {
438 struct list_head head_rt_tbl_list;
439 u32 tbl_cnt;
440};
441
442/**
443 * struct ipa_ep_cfg_status - status configuration in IPA end-point
444 * @status_en: Determines if end point supports Status Indications. SW should
445 * set this bit in order to enable Statuses. Output Pipe - send
446 * Status indications only if bit is set. Input Pipe - forward Status
447 * indication to STATUS_ENDP only if bit is set. Valid for Input
448 * and Output Pipes (IPA Consumer and Producer)
449 * @status_ep: Statuses generated for this endpoint will be forwarded to the
450 * specified Status End Point. Status endpoint needs to be
451 * configured with STATUS_EN=1 Valid only for Input Pipes (IPA
452 * Consumer)
453 */
454struct ipa_ep_cfg_status {
455 bool status_en;
456 u8 status_ep;
457};
458
459/**
460 * struct ipa_wlan_stats - Wlan stats for each wlan endpoint
461 * @rx_pkts_rcvd: Packets sent by wlan driver
462 * @rx_pkts_status_rcvd: Status packets received from ipa hw
463 * @rx_hd_processed: Data Descriptors processed by IPA Driver
464 * @rx_hd_reply: Data Descriptors recycled by wlan driver
465 * @rx_hd_rcvd: Data Descriptors sent by wlan driver
466 * @rx_pkt_leak: Packet count that are not recycled
467 * @rx_dp_fail: Packets failed to transfer to IPA HW
468 * @tx_pkts_rcvd: SKB Buffers received from ipa hw
469 * @tx_pkts_sent: SKB Buffers sent to wlan driver
470 * @tx_pkts_dropped: Dropped packets count
471 */
472struct ipa_wlan_stats {
473 u32 rx_pkts_rcvd;
474 u32 rx_pkts_status_rcvd;
475 u32 rx_hd_processed;
476 u32 rx_hd_reply;
477 u32 rx_hd_rcvd;
478 u32 rx_pkt_leak;
479 u32 rx_dp_fail;
480 u32 tx_pkts_rcvd;
481 u32 tx_pkts_sent;
482 u32 tx_pkts_dropped;
483};
484
485/**
486 * struct ipa_wlan_comm_memb - Wlan comm members
487 * @wlan_spinlock: protects wlan comm buff list and its size
488 * @ipa_tx_mul_spinlock: protects tx dp mul transfer
489 * @wlan_comm_total_cnt: wlan common skb buffers allocated count
490 * @wlan_comm_free_cnt: wlan common skb buffer free count
491 * @total_tx_pkts_freed: Recycled Buffer count
492 * @wlan_comm_desc_list: wlan common skb buffer list
493 */
494struct ipa_wlan_comm_memb {
495 spinlock_t wlan_spinlock;
496 spinlock_t ipa_tx_mul_spinlock;
497 u32 wlan_comm_total_cnt;
498 u32 wlan_comm_free_cnt;
499 u32 total_tx_pkts_freed;
500 struct list_head wlan_comm_desc_list;
501 atomic_t active_clnt_cnt;
502};
503
504struct ipa_status_stats {
505 struct ipa_hw_pkt_status status[IPA_MAX_STATUS_STAT_NUM];
506 int curr;
507};
508
509enum ipa_wakelock_ref_client {
510 IPA_WAKELOCK_REF_CLIENT_TX = 0,
511 IPA_WAKELOCK_REF_CLIENT_LAN_RX = 1,
512 IPA_WAKELOCK_REF_CLIENT_WAN_RX = 2,
513 IPA_WAKELOCK_REF_CLIENT_WLAN_RX = 3,
514 IPA_WAKELOCK_REF_CLIENT_ODU_RX = 4,
515 IPA_WAKELOCK_REF_CLIENT_SPS = 5,
516 IPA_WAKELOCK_REF_CLIENT_MAX
517};
518
519/**
520 * struct ipa_ep_context - IPA end point context
521 * @valid: flag indicating id EP context is valid
522 * @client: EP client type
523 * @ep_hdl: EP's client SPS handle
524 * @cfg: EP cionfiguration
525 * @dst_pipe_index: destination pipe index
526 * @rt_tbl_idx: routing table index
527 * @connect: SPS connect
528 * @priv: user provided information which will forwarded once the user is
529 * notified for new data avail
530 * @client_notify: user provided CB for EP events notification, the event is
531 * data revived.
532 * @desc_fifo_in_pipe_mem: flag indicating if descriptors FIFO uses pipe memory
533 * @data_fifo_in_pipe_mem: flag indicating if data FIFO uses pipe memory
534 * @desc_fifo_pipe_mem_ofst: descriptors FIFO pipe memory offset
535 * @data_fifo_pipe_mem_ofst: data FIFO pipe memory offset
536 * @desc_fifo_client_allocated: if descriptors FIFO was allocated by a client
537 * @data_fifo_client_allocated: if data FIFO was allocated by a client
538 * @skip_ep_cfg: boolean field that determines if EP should be configured
539 * by IPA driver
540 * @keep_ipa_awake: when true, IPA will not be clock gated
541 * @rx_replenish_threshold: Indicates the WM value which requires the RX
542 * descriptors replenish function to be called to
543 * avoid the RX pipe to run out of descriptors
544 * and cause HOLB.
545 * @disconnect_in_progress: Indicates client disconnect in progress.
546 * @qmi_request_sent: Indicates whether QMI request to enable clear data path
547 * request is sent or not.
548 * @napi_enabled: when true, IPA call client callback to start polling
549 */
550struct ipa_ep_context {
551 int valid;
552 enum ipa_client_type client;
553 struct sps_pipe *ep_hdl;
554 struct ipa_ep_cfg cfg;
555 struct ipa_ep_cfg_holb holb;
556 struct ipa_ep_cfg_status status;
557 u32 dst_pipe_index;
558 u32 rt_tbl_idx;
559 struct sps_connect connect;
560 void *priv;
561 void (*client_notify)(void *priv, enum ipa_dp_evt_type evt,
562 unsigned long data);
563 bool desc_fifo_in_pipe_mem;
564 bool data_fifo_in_pipe_mem;
565 u32 desc_fifo_pipe_mem_ofst;
566 u32 data_fifo_pipe_mem_ofst;
567 bool desc_fifo_client_allocated;
568 bool data_fifo_client_allocated;
569 atomic_t avail_fifo_desc;
570 u32 dflt_flt4_rule_hdl;
571 u32 dflt_flt6_rule_hdl;
572 bool skip_ep_cfg;
573 bool keep_ipa_awake;
574 struct ipa_wlan_stats wstats;
575 u32 uc_offload_state;
576 u32 rx_replenish_threshold;
577 bool disconnect_in_progress;
578 u32 qmi_request_sent;
579 enum ipa_wakelock_ref_client wakelock_client;
580 bool napi_enabled;
581 bool switch_to_intr;
582 int inactive_cycles;
583 u32 eot_in_poll_err;
584 bool ep_disabled;
585
586 /* sys MUST be the last element of this struct */
587 struct ipa_sys_context *sys;
588};
589
590enum ipa_sys_pipe_policy {
591 IPA_POLICY_INTR_MODE,
592 IPA_POLICY_NOINTR_MODE,
593 IPA_POLICY_INTR_POLL_MODE,
594};
595
596struct ipa_repl_ctx {
597 struct ipa_rx_pkt_wrapper **cache;
598 atomic_t head_idx;
599 atomic_t tail_idx;
600 u32 capacity;
601};
602
603/**
604 * struct ipa_sys_context - IPA endpoint context for system to BAM pipes
605 * @head_desc_list: header descriptors list
606 * @len: the size of the above list
607 * @spinlock: protects the list and its size
608 * @event: used to request CALLBACK mode from SPS driver
609 * @ep: IPA EP context
610 *
611 * IPA context specific to the system-bam pipes a.k.a LAN IN/OUT and WAN
612 */
613struct ipa_sys_context {
614 u32 len;
615 struct sps_register_event event;
616 atomic_t curr_polling_state;
617 struct delayed_work switch_to_intr_work;
618 enum ipa_sys_pipe_policy policy;
619 int (*pyld_hdlr)(struct sk_buff *skb, struct ipa_sys_context *sys);
620 struct sk_buff * (*get_skb)(unsigned int len, gfp_t flags);
621 void (*free_skb)(struct sk_buff *skb);
622 u32 rx_buff_sz;
623 u32 rx_pool_sz;
624 struct sk_buff *prev_skb;
625 unsigned int len_rem;
626 unsigned int len_pad;
627 unsigned int len_partial;
628 bool drop_packet;
629 struct work_struct work;
630 void (*sps_callback)(struct sps_event_notify *notify);
631 enum sps_option sps_option;
632 struct delayed_work replenish_rx_work;
633 struct work_struct repl_work;
634 void (*repl_hdlr)(struct ipa_sys_context *sys);
635 struct ipa_repl_ctx repl;
636 unsigned int repl_trig_cnt;
637 unsigned int repl_trig_thresh;
638
639 /* ordering is important - mutable fields go above */
640 struct ipa_ep_context *ep;
641 struct list_head head_desc_list;
642 struct list_head rcycl_list;
643 spinlock_t spinlock;
644 struct workqueue_struct *wq;
645 struct workqueue_struct *repl_wq;
646 struct ipa_status_stats *status_stat;
647 /* ordering is important - other immutable fields go below */
648};
649
650/**
651 * enum ipa_desc_type - IPA decriptors type
652 *
653 * IPA decriptors type, IPA supports DD and ICD but no CD
654 */
655enum ipa_desc_type {
656 IPA_DATA_DESC,
657 IPA_DATA_DESC_SKB,
658 IPA_DATA_DESC_SKB_PAGED,
659 IPA_IMM_CMD_DESC
660};
661
662/**
663 * struct ipa_tx_pkt_wrapper - IPA Tx packet wrapper
664 * @type: specify if this packet is for the skb or immediate command
665 * @mem: memory buffer used by this Tx packet
666 * @work: work struct for current Tx packet
667 * @link: linked to the wrappers on that pipe
668 * @callback: IPA client provided callback
669 * @user1: cookie1 for above callback
670 * @user2: cookie2 for above callback
671 * @sys: corresponding IPA sys context
672 * @mult: valid only for first of a "multiple" transfer,
673 * holds info for the "sps_transfer" buffer
674 * @cnt: 1 for single transfers,
675 * >1 and <0xFFFF for first of a "multiple" transfer,
676 * 0xFFFF for last desc, 0 for rest of "multiple' transfer
677 * @bounce: va of bounce buffer
678 * @unmap_dma: in case this is true, the buffer will not be dma unmapped
679 *
680 * This struct can wrap both data packet and immediate command packet.
681 */
682struct ipa_tx_pkt_wrapper {
683 enum ipa_desc_type type;
684 struct ipa_mem_buffer mem;
685 struct work_struct work;
686 struct list_head link;
687 void (*callback)(void *user1, int user2);
688 void *user1;
689 int user2;
690 struct ipa_sys_context *sys;
691 struct ipa_mem_buffer mult;
692 u32 cnt;
693 void *bounce;
694 bool no_unmap_dma;
695};
696
697/**
698 * struct ipa_desc - IPA descriptor
699 * @type: skb or immediate command or plain old data
700 * @pyld: points to skb
701 * @frag: points to paged fragment
702 * or kmalloc'ed immediate command parameters/plain old data
703 * @dma_address: dma mapped address of pyld
704 * @dma_address_valid: valid field for dma_address
705 * @len: length of the pyld
706 * @opcode: for immediate commands
707 * @callback: IPA client provided completion callback
708 * @user1: cookie1 for above callback
709 * @user2: cookie2 for above callback
710 * @xfer_done: completion object for sync completion
711 */
712struct ipa_desc {
713 enum ipa_desc_type type;
714 void *pyld;
715 skb_frag_t *frag;
716 dma_addr_t dma_address;
717 bool dma_address_valid;
718 u16 len;
719 u16 opcode;
720 void (*callback)(void *user1, int user2);
721 void *user1;
722 int user2;
723 struct completion xfer_done;
724};
725
726/**
727 * struct ipa_rx_pkt_wrapper - IPA Rx packet wrapper
728 * @skb: skb
729 * @dma_address: DMA address of this Rx packet
730 * @link: linked to the Rx packets on that pipe
731 * @len: how many bytes are copied into skb's flat buffer
732 */
733struct ipa_rx_pkt_wrapper {
734 struct list_head link;
735 struct ipa_rx_data data;
736 u32 len;
737 struct work_struct work;
738 struct ipa_sys_context *sys;
739};
740
741/**
742 * struct ipa_nat_mem - IPA NAT memory description
743 * @class: pointer to the struct class
744 * @dev: the dev_t of the device
745 * @cdev: cdev of the device
746 * @dev_num: device number
747 * @vaddr: virtual address
748 * @dma_handle: DMA handle
749 * @size: NAT memory size
750 * @is_mapped: flag indicating if NAT memory is mapped
751 * @is_sys_mem: flag indicating if NAT memory is sys memory
752 * @is_dev_init: flag indicating if NAT device is initialized
753 * @lock: NAT memory mutex
754 * @nat_base_address: nat table virutal address
755 * @ipv4_rules_addr: base nat table address
756 * @ipv4_expansion_rules_addr: expansion table address
757 * @index_table_addr: index table address
758 * @index_table_expansion_addr: index expansion table address
759 * @size_base_tables: base table size
760 * @size_expansion_tables: expansion table size
761 * @public_ip_addr: ip address of nat table
762 */
763struct ipa_nat_mem {
764 struct class *class;
765 struct device *dev;
766 struct cdev cdev;
767 dev_t dev_num;
768 void *vaddr;
769 dma_addr_t dma_handle;
770 size_t size;
771 bool is_mapped;
772 bool is_sys_mem;
773 bool is_dev_init;
774 bool is_dev;
775 struct mutex lock;
776 void *nat_base_address;
777 char *ipv4_rules_addr;
778 char *ipv4_expansion_rules_addr;
779 char *index_table_addr;
780 char *index_table_expansion_addr;
781 u32 size_base_tables;
782 u32 size_expansion_tables;
783 u32 public_ip_addr;
784 void *tmp_vaddr;
785 dma_addr_t tmp_dma_handle;
786 bool is_tmp_mem;
787};
788
789/**
790 * enum ipa_hw_mode - IPA hardware mode
791 * @IPA_HW_Normal: Regular IPA hardware
792 * @IPA_HW_Virtual: IPA hardware supporting virtual memory allocation
793 * @IPA_HW_PCIE: IPA hardware supporting memory allocation over PCIE Bridge
794 */
795enum ipa_hw_mode {
796 IPA_HW_MODE_NORMAL = 0,
797 IPA_HW_MODE_VIRTUAL = 1,
798 IPA_HW_MODE_PCIE = 2
799};
800
801enum ipa_config_this_ep {
802 IPA_CONFIGURE_THIS_EP,
803 IPA_DO_NOT_CONFIGURE_THIS_EP,
804};
805
806struct ipa_stats {
807 u32 tx_sw_pkts;
808 u32 tx_hw_pkts;
809 u32 rx_pkts;
810 u32 rx_excp_pkts[MAX_NUM_EXCP];
811 u32 rx_repl_repost;
812 u32 tx_pkts_compl;
813 u32 rx_q_len;
814 u32 msg_w[IPA_EVENT_MAX_NUM];
815 u32 msg_r[IPA_EVENT_MAX_NUM];
816 u32 stat_compl;
817 u32 aggr_close;
818 u32 wan_aggr_close;
819 u32 wan_rx_empty;
820 u32 wan_repl_rx_empty;
821 u32 lan_rx_empty;
822 u32 lan_repl_rx_empty;
823 u32 flow_enable;
824 u32 flow_disable;
825 u32 tx_non_linear;
826};
827
828struct ipa_active_clients {
829 struct mutex mutex;
830 spinlock_t spinlock;
831 bool mutex_locked;
832 int cnt;
833};
834
835struct ipa_wakelock_ref_cnt {
836 spinlock_t spinlock;
837 u32 cnt;
838};
839
840struct ipa_tag_completion {
841 struct completion comp;
842 atomic_t cnt;
843};
844
845struct ipa_controller;
846
847/**
848 * struct ipa_uc_hdlrs - IPA uC callback functions
849 * @ipa_uc_loaded_hdlr: Function handler when uC is loaded
850 * @ipa_uc_event_hdlr: Event handler function
851 * @ipa_uc_response_hdlr: Response handler function
852 * @ipa_uc_event_log_info_hdlr: Log event handler function
853 */
854struct ipa_uc_hdlrs {
855 void (*ipa_uc_loaded_hdlr)(void);
856
857 void (*ipa_uc_event_hdlr)
858 (struct IpaHwSharedMemCommonMapping_t *uc_sram_mmio);
859 int (*ipa_uc_response_hdlr)
860 (struct IpaHwSharedMemCommonMapping_t *uc_sram_mmio,
861 u32 *uc_status);
862 void (*ipa_uc_event_log_info_hdlr)
863 (struct IpaHwEventLogInfoData_t *uc_event_top_mmio);
864};
865
866/**
867 * enum ipa_hw_flags - flags which defines the behavior of HW
868 *
869 * @IPA_HW_FLAG_HALT_SYSTEM_ON_ASSERT_FAILURE: Halt system in case of assert
870 * failure.
871 * @IPA_HW_FLAG_NO_REPORT_MHI_CHANNEL_ERORR: Channel error would be reported
872 * in the event ring only. No event to CPU.
873 * @IPA_HW_FLAG_NO_REPORT_MHI_CHANNEL_WAKE_UP: No need to report event
874 * IPA_HW_2_CPU_EVENT_MHI_WAKE_UP_REQUEST
875 * @IPA_HW_FLAG_WORK_OVER_DDR: Perform all transaction to external addresses by
876 * QMB (avoid memcpy)
877 * @IPA_HW_FLAG_NO_REPORT_OOB: If set do not report that the device is OOB in
878 * IN Channel
879 * @IPA_HW_FLAG_NO_REPORT_DB_MODE: If set, do not report that the device is
880 * entering a mode where it expects a doorbell to be rung for OUT Channel
881 * @IPA_HW_FLAG_NO_START_OOB_TIMER
882 */
883enum ipa_hw_flags {
884 IPA_HW_FLAG_HALT_SYSTEM_ON_ASSERT_FAILURE = 0x01,
885 IPA_HW_FLAG_NO_REPORT_MHI_CHANNEL_ERORR = 0x02,
886 IPA_HW_FLAG_NO_REPORT_MHI_CHANNEL_WAKE_UP = 0x04,
887 IPA_HW_FLAG_WORK_OVER_DDR = 0x08,
888 IPA_HW_FLAG_NO_REPORT_OOB = 0x10,
889 IPA_HW_FLAG_NO_REPORT_DB_MODE = 0x20,
890 IPA_HW_FLAG_NO_START_OOB_TIMER = 0x40
891};
892
893/**
894 * struct ipa_uc_ctx - IPA uC context
895 * @uc_inited: Indicates if uC interface has been initialized
896 * @uc_loaded: Indicates if uC has loaded
897 * @uc_failed: Indicates if uC has failed / returned an error
898 * @uc_lock: uC interface lock to allow only one uC interaction at a time
899 * @uc_completation: Completion mechanism to wait for uC commands
900 * @uc_sram_mmio: Pointer to uC mapped memory
901 * @pending_cmd: The last command sent waiting to be ACKed
902 * @uc_status: The last status provided by the uC
903 * @uc_zip_error: uC has notified the APPS upon a ZIP engine error
904 * @uc_error_type: error type from uC error event
905 */
906struct ipa_uc_ctx {
907 bool uc_inited;
908 bool uc_loaded;
909 bool uc_failed;
910 struct mutex uc_lock;
911 struct completion uc_completion;
912 struct IpaHwSharedMemCommonMapping_t *uc_sram_mmio;
913 struct IpaHwEventLogInfoData_t *uc_event_top_mmio;
914 u32 uc_event_top_ofst;
915 u32 pending_cmd;
916 u32 uc_status;
917 bool uc_zip_error;
918 u32 uc_error_type;
Gidon Studinski3021a6f2016-11-10 12:48:48 +0200919 phys_addr_t rdy_ring_base_pa;
920 phys_addr_t rdy_ring_rp_pa;
921 u32 rdy_ring_size;
922 phys_addr_t rdy_comp_ring_base_pa;
923 phys_addr_t rdy_comp_ring_wp_pa;
924 u32 rdy_comp_ring_size;
925 u32 *rdy_ring_rp_va;
926 u32 *rdy_comp_ring_wp_va;
Amir Levy9659e592016-10-27 18:08:27 +0300927};
928
929/**
930 * struct ipa_uc_wdi_ctx
931 * @wdi_uc_top_ofst:
932 * @wdi_uc_top_mmio:
933 * @wdi_uc_stats_ofst:
934 * @wdi_uc_stats_mmio:
935 */
936struct ipa_uc_wdi_ctx {
937 /* WDI specific fields */
938 u32 wdi_uc_stats_ofst;
939 struct IpaHwStatsWDIInfoData_t *wdi_uc_stats_mmio;
940 void *priv;
941 ipa_uc_ready_cb uc_ready_cb;
Utkarsh Saxenab89ce3a2017-02-16 22:29:56 +0530942 /* for AP+STA stats update */
943#ifdef IPA_WAN_MSG_IPv6_ADDR_GW_LEN
944 ipa_wdi_meter_notifier_cb stats_notify;
945#endif
Amir Levy9659e592016-10-27 18:08:27 +0300946};
947
948/**
949 * struct ipa_sps_pm - SPS power management related members
950 * @dec_clients: true if need to decrease active clients count
951 * @eot_activity: represent EOT interrupt activity to determine to reset
952 * the inactivity timer
953 * @sps_pm_lock: Lock to protect the sps_pm functionality.
954 */
955struct ipa_sps_pm {
956 atomic_t dec_clients;
957 atomic_t eot_activity;
958 struct mutex sps_pm_lock;
959};
960
961/**
962 * struct ipacm_client_info - the client-info indicated from IPACM
963 * @ipacm_client_enum: the enum to indicate tether-client
964 * @ipacm_client_uplink: the bool to indicate pipe for uplink
965 */
966struct ipacm_client_info {
967 enum ipacm_client_enum client_enum;
968 bool uplink;
969};
970
971/**
972 * struct ipa_context - IPA context
973 * @class: pointer to the struct class
974 * @dev_num: device number
975 * @dev: the dev_t of the device
976 * @cdev: cdev of the device
977 * @bam_handle: IPA driver's BAM handle
978 * @ep: list of all end points
979 * @skip_ep_cfg_shadow: state to update filter table correctly across
980 power-save
981 * @resume_on_connect: resume ep on ipa_connect
982 * @flt_tbl: list of all IPA filter tables
983 * @mode: IPA operating mode
984 * @mmio: iomem
985 * @ipa_wrapper_base: IPA wrapper base address
986 * @glob_flt_tbl: global filter table
987 * @hdr_tbl: IPA header table
988 * @hdr_proc_ctx_tbl: IPA processing context table
989 * @rt_tbl_set: list of routing tables each of which is a list of rules
990 * @reap_rt_tbl_set: list of sys mem routing tables waiting to be reaped
991 * @flt_rule_cache: filter rule cache
992 * @rt_rule_cache: routing rule cache
993 * @hdr_cache: header cache
994 * @hdr_offset_cache: header offset cache
995 * @hdr_proc_ctx_cache: processing context cache
996 * @hdr_proc_ctx_offset_cache: processing context offset cache
997 * @rt_tbl_cache: routing table cache
998 * @tx_pkt_wrapper_cache: Tx packets cache
999 * @rx_pkt_wrapper_cache: Rx packets cache
1000 * @rt_idx_bitmap: routing table index bitmap
1001 * @lock: this does NOT protect the linked lists within ipa_sys_context
1002 * @smem_sz: shared memory size available for SW use starting
1003 * from non-restricted bytes
1004 * @smem_restricted_bytes: the bytes that SW should not use in the shared mem
1005 * @nat_mem: NAT memory
1006 * @excp_hdr_hdl: exception header handle
1007 * @dflt_v4_rt_rule_hdl: default v4 routing rule handle
1008 * @dflt_v6_rt_rule_hdl: default v6 routing rule handle
1009 * @aggregation_type: aggregation type used on USB client endpoint
1010 * @aggregation_byte_limit: aggregation byte limit used on USB client endpoint
1011 * @aggregation_time_limit: aggregation time limit used on USB client endpoint
1012 * @hdr_tbl_lcl: where hdr tbl resides 1-local, 0-system
1013 * @hdr_proc_ctx_tbl_lcl: where proc_ctx tbl resides true-local, false-system
1014 * @hdr_mem: header memory
1015 * @hdr_proc_ctx_mem: processing context memory
1016 * @ip4_rt_tbl_lcl: where ip4 rt tables reside 1-local; 0-system
1017 * @ip6_rt_tbl_lcl: where ip6 rt tables reside 1-local; 0-system
1018 * @ip4_flt_tbl_lcl: where ip4 flt tables reside 1-local; 0-system
1019 * @ip6_flt_tbl_lcl: where ip6 flt tables reside 1-local; 0-system
1020 * @empty_rt_tbl_mem: empty routing tables memory
1021 * @power_mgmt_wq: workqueue for power management
1022 * @sps_power_mgmt_wq: workqueue SPS related power management
1023 * @tag_process_before_gating: indicates whether to start tag process before
1024 * gating IPA clocks
1025 * @sps_pm: sps power management related information
1026 * @disconnect_lock: protects LAN_CONS packet receive notification CB
1027 * @pipe_mem_pool: pipe memory pool
1028 * @dma_pool: special purpose DMA pool
1029 * @ipa_active_clients: structure for reference counting connected IPA clients
1030 * @ipa_hw_type: type of IPA HW type (e.g. IPA 1.0, IPA 1.1 etc')
1031 * @ipa_hw_mode: mode of IPA HW mode (e.g. Normal, Virtual or over PCIe)
1032 * @use_ipa_teth_bridge: use tethering bridge driver
1033 * @ipa_bam_remote_mode: ipa bam is in remote mode
1034 * @modem_cfg_emb_pipe_flt: modem configure embedded pipe filtering rules
Gidon Studinski3021a6f2016-11-10 12:48:48 +02001035 * @ipa_wdi2: using wdi-2.0
Amir Levy9659e592016-10-27 18:08:27 +03001036 * @ipa_bus_hdl: msm driver handle for the data path bus
1037 * @ctrl: holds the core specific operations based on
1038 * core version (vtable like)
1039 * @enable_clock_scaling: clock scaling is enabled ?
1040 * @curr_ipa_clk_rate: ipa_clk current rate
1041 * @wcstats: wlan common buffer stats
1042 * @uc_ctx: uC interface context
1043 * @uc_wdi_ctx: WDI specific fields for uC interface
1044 * @ipa_num_pipes: The number of pipes used by IPA HW
1045 * @skip_uc_pipe_reset: Indicates whether pipe reset via uC needs to be avoided
1046 * @ipa_client_apps_wan_cons_agg_gro: RMNET_IOCTL_INGRESS_FORMAT_AGG_DATA
1047 * @w_lock: Indicates the wakeup source.
1048 * @wakelock_ref_cnt: Indicates the number of times wakelock is acquired
1049
1050 * IPA context - holds all relevant info about IPA driver and its state
1051 */
1052struct ipa_context {
1053 struct class *class;
1054 dev_t dev_num;
1055 struct device *dev;
1056 struct cdev cdev;
1057 unsigned long bam_handle;
1058 struct ipa_ep_context ep[IPA_MAX_NUM_PIPES];
1059 bool skip_ep_cfg_shadow[IPA_MAX_NUM_PIPES];
1060 bool resume_on_connect[IPA_CLIENT_MAX];
1061 struct ipa_flt_tbl flt_tbl[IPA_MAX_NUM_PIPES][IPA_IP_MAX];
1062 void __iomem *mmio;
1063 u32 ipa_wrapper_base;
1064 u32 ipa_wrapper_size;
1065 struct ipa_flt_tbl glob_flt_tbl[IPA_IP_MAX];
1066 struct ipa_hdr_tbl hdr_tbl;
1067 struct ipa_hdr_proc_ctx_tbl hdr_proc_ctx_tbl;
1068 struct ipa_rt_tbl_set rt_tbl_set[IPA_IP_MAX];
1069 struct ipa_rt_tbl_set reap_rt_tbl_set[IPA_IP_MAX];
1070 struct kmem_cache *flt_rule_cache;
1071 struct kmem_cache *rt_rule_cache;
1072 struct kmem_cache *hdr_cache;
1073 struct kmem_cache *hdr_offset_cache;
1074 struct kmem_cache *hdr_proc_ctx_cache;
1075 struct kmem_cache *hdr_proc_ctx_offset_cache;
1076 struct kmem_cache *rt_tbl_cache;
1077 struct kmem_cache *tx_pkt_wrapper_cache;
1078 struct kmem_cache *rx_pkt_wrapper_cache;
1079 unsigned long rt_idx_bitmap[IPA_IP_MAX];
1080 struct mutex lock;
1081 u16 smem_sz;
1082 u16 smem_restricted_bytes;
1083 u16 smem_reqd_sz;
1084 struct ipa_nat_mem nat_mem;
1085 u32 excp_hdr_hdl;
1086 u32 dflt_v4_rt_rule_hdl;
1087 u32 dflt_v6_rt_rule_hdl;
1088 uint aggregation_type;
1089 uint aggregation_byte_limit;
1090 uint aggregation_time_limit;
1091 bool hdr_tbl_lcl;
1092 bool hdr_proc_ctx_tbl_lcl;
1093 struct ipa_mem_buffer hdr_mem;
1094 struct ipa_mem_buffer hdr_proc_ctx_mem;
1095 bool ip4_rt_tbl_lcl;
1096 bool ip6_rt_tbl_lcl;
1097 bool ip4_flt_tbl_lcl;
1098 bool ip6_flt_tbl_lcl;
1099 struct ipa_mem_buffer empty_rt_tbl_mem;
1100 struct gen_pool *pipe_mem_pool;
1101 struct dma_pool *dma_pool;
1102 struct ipa_active_clients ipa_active_clients;
1103 struct ipa2_active_clients_log_ctx ipa2_active_clients_logging;
1104 struct workqueue_struct *power_mgmt_wq;
1105 struct workqueue_struct *sps_power_mgmt_wq;
1106 bool tag_process_before_gating;
1107 struct ipa_sps_pm sps_pm;
1108 u32 clnt_hdl_cmd;
1109 u32 clnt_hdl_data_in;
1110 u32 clnt_hdl_data_out;
1111 spinlock_t disconnect_lock;
1112 u8 a5_pipe_index;
1113 struct list_head intf_list;
1114 struct list_head msg_list;
1115 struct list_head pull_msg_list;
1116 struct mutex msg_lock;
1117 wait_queue_head_t msg_waitq;
1118 enum ipa_hw_type ipa_hw_type;
1119 enum ipa_hw_mode ipa_hw_mode;
1120 bool use_ipa_teth_bridge;
1121 bool ipa_bam_remote_mode;
1122 bool modem_cfg_emb_pipe_flt;
Gidon Studinski3021a6f2016-11-10 12:48:48 +02001123 bool ipa_wdi2;
Amir Levy9659e592016-10-27 18:08:27 +03001124 /* featurize if memory footprint becomes a concern */
1125 struct ipa_stats stats;
1126 void *smem_pipe_mem;
1127 u32 ipa_bus_hdl;
1128 struct ipa_controller *ctrl;
1129 struct idr ipa_idr;
1130 struct device *pdev;
1131 struct device *uc_pdev;
1132 spinlock_t idr_lock;
1133 u32 enable_clock_scaling;
1134 u32 curr_ipa_clk_rate;
1135 bool q6_proxy_clk_vote_valid;
1136 u32 ipa_num_pipes;
1137
1138 struct ipa_wlan_comm_memb wc_memb;
1139
1140 struct ipa_uc_ctx uc_ctx;
1141
1142 struct ipa_uc_wdi_ctx uc_wdi_ctx;
1143 struct ipa_uc_ntn_ctx uc_ntn_ctx;
1144 u32 wan_rx_ring_size;
1145 u32 lan_rx_ring_size;
1146 bool skip_uc_pipe_reset;
1147 bool smmu_present;
1148 bool smmu_s1_bypass;
1149 unsigned long peer_bam_iova;
1150 phys_addr_t peer_bam_pa;
1151 u32 peer_bam_map_size;
1152 unsigned long peer_bam_dev;
1153 u32 peer_bam_map_cnt;
1154 u32 wdi_map_cnt;
1155 bool use_dma_zone;
1156 struct wakeup_source w_lock;
1157 struct ipa_wakelock_ref_cnt wakelock_ref_cnt;
1158
1159 /* RMNET_IOCTL_INGRESS_FORMAT_AGG_DATA */
1160 bool ipa_client_apps_wan_cons_agg_gro;
1161 /* M-release support to know client pipes */
1162 struct ipacm_client_info ipacm_client[IPA_MAX_NUM_PIPES];
1163 bool tethered_flow_control;
1164 u32 ipa_rx_min_timeout_usec;
1165 u32 ipa_rx_max_timeout_usec;
1166 u32 ipa_polling_iteration;
1167};
1168
1169/**
1170 * struct ipa_route - IPA route
1171 * @route_dis: route disable
1172 * @route_def_pipe: route default pipe
1173 * @route_def_hdr_table: route default header table
1174 * @route_def_hdr_ofst: route default header offset table
1175 * @route_frag_def_pipe: Default pipe to route fragmented exception
1176 * packets and frag new rule statues, if source pipe does not have
1177 * a notification status pipe defined.
1178 */
1179struct ipa_route {
1180 u32 route_dis;
1181 u32 route_def_pipe;
1182 u32 route_def_hdr_table;
1183 u32 route_def_hdr_ofst;
1184 u8 route_frag_def_pipe;
1185};
1186
1187/**
1188 * enum ipa_pipe_mem_type - IPA pipe memory type
1189 * @IPA_SPS_PIPE_MEM: Default, SPS dedicated pipe memory
1190 * @IPA_PRIVATE_MEM: IPA's private memory
1191 * @IPA_SYSTEM_MEM: System RAM, requires allocation
1192 */
1193enum ipa_pipe_mem_type {
1194 IPA_SPS_PIPE_MEM = 0,
1195 IPA_PRIVATE_MEM = 1,
1196 IPA_SYSTEM_MEM = 2,
1197};
1198
1199struct ipa_plat_drv_res {
1200 bool use_ipa_teth_bridge;
1201 u32 ipa_mem_base;
1202 u32 ipa_mem_size;
1203 u32 bam_mem_base;
1204 u32 bam_mem_size;
1205 u32 ipa_irq;
1206 u32 bam_irq;
1207 u32 ipa_pipe_mem_start_ofst;
1208 u32 ipa_pipe_mem_size;
1209 enum ipa_hw_type ipa_hw_type;
1210 enum ipa_hw_mode ipa_hw_mode;
1211 u32 ee;
1212 bool ipa_bam_remote_mode;
1213 bool modem_cfg_emb_pipe_flt;
Gidon Studinski3021a6f2016-11-10 12:48:48 +02001214 bool ipa_wdi2;
Amir Levy9659e592016-10-27 18:08:27 +03001215 u32 wan_rx_ring_size;
1216 u32 lan_rx_ring_size;
1217 bool skip_uc_pipe_reset;
1218 bool use_dma_zone;
1219 bool tethered_flow_control;
1220 u32 ipa_rx_polling_sleep_msec;
1221 u32 ipa_polling_iteration;
1222};
1223
1224struct ipa_mem_partition {
1225 u16 ofst_start;
1226 u16 nat_ofst;
1227 u16 nat_size;
1228 u16 v4_flt_ofst;
1229 u16 v4_flt_size;
1230 u16 v4_flt_size_ddr;
1231 u16 v6_flt_ofst;
1232 u16 v6_flt_size;
1233 u16 v6_flt_size_ddr;
1234 u16 v4_rt_ofst;
1235 u16 v4_num_index;
1236 u16 v4_modem_rt_index_lo;
1237 u16 v4_modem_rt_index_hi;
1238 u16 v4_apps_rt_index_lo;
1239 u16 v4_apps_rt_index_hi;
1240 u16 v4_rt_size;
1241 u16 v4_rt_size_ddr;
1242 u16 v6_rt_ofst;
1243 u16 v6_num_index;
1244 u16 v6_modem_rt_index_lo;
1245 u16 v6_modem_rt_index_hi;
1246 u16 v6_apps_rt_index_lo;
1247 u16 v6_apps_rt_index_hi;
1248 u16 v6_rt_size;
1249 u16 v6_rt_size_ddr;
1250 u16 modem_hdr_ofst;
1251 u16 modem_hdr_size;
1252 u16 apps_hdr_ofst;
1253 u16 apps_hdr_size;
1254 u16 apps_hdr_size_ddr;
1255 u16 modem_hdr_proc_ctx_ofst;
1256 u16 modem_hdr_proc_ctx_size;
1257 u16 apps_hdr_proc_ctx_ofst;
1258 u16 apps_hdr_proc_ctx_size;
1259 u16 apps_hdr_proc_ctx_size_ddr;
1260 u16 modem_comp_decomp_ofst;
1261 u16 modem_comp_decomp_size;
1262 u16 modem_ofst;
1263 u16 modem_size;
1264 u16 apps_v4_flt_ofst;
1265 u16 apps_v4_flt_size;
1266 u16 apps_v6_flt_ofst;
1267 u16 apps_v6_flt_size;
1268 u16 uc_info_ofst;
1269 u16 uc_info_size;
1270 u16 end_ofst;
1271 u16 apps_v4_rt_ofst;
1272 u16 apps_v4_rt_size;
1273 u16 apps_v6_rt_ofst;
1274 u16 apps_v6_rt_size;
1275};
1276
1277struct ipa_controller {
1278 struct ipa_mem_partition mem_partition;
1279 u32 ipa_clk_rate_turbo;
1280 u32 ipa_clk_rate_nominal;
1281 u32 ipa_clk_rate_svs;
1282 u32 clock_scaling_bw_threshold_turbo;
1283 u32 clock_scaling_bw_threshold_nominal;
1284 u32 ipa_reg_base_ofst;
1285 u32 max_holb_tmr_val;
1286 void (*ipa_sram_read_settings)(void);
1287 int (*ipa_init_sram)(void);
1288 int (*ipa_init_hdr)(void);
1289 int (*ipa_init_rt4)(void);
1290 int (*ipa_init_rt6)(void);
1291 int (*ipa_init_flt4)(void);
1292 int (*ipa_init_flt6)(void);
1293 void (*ipa_cfg_ep_hdr)(u32 pipe_number,
1294 const struct ipa_ep_cfg_hdr *ipa_ep_hdr_cfg);
1295 int (*ipa_cfg_ep_hdr_ext)(u32 pipe_number,
1296 const struct ipa_ep_cfg_hdr_ext *ipa_ep_hdr_ext_cfg);
1297 void (*ipa_cfg_ep_aggr)(u32 pipe_number,
1298 const struct ipa_ep_cfg_aggr *ipa_ep_agrr_cfg);
1299 int (*ipa_cfg_ep_deaggr)(u32 pipe_index,
1300 const struct ipa_ep_cfg_deaggr *ep_deaggr);
1301 void (*ipa_cfg_ep_nat)(u32 pipe_number,
1302 const struct ipa_ep_cfg_nat *ipa_ep_nat_cfg);
1303 void (*ipa_cfg_ep_mode)(u32 pipe_number, u32 dst_pipe_number,
1304 const struct ipa_ep_cfg_mode *ep_mode);
1305 void (*ipa_cfg_ep_route)(u32 pipe_index, u32 rt_tbl_index);
1306 void (*ipa_cfg_ep_holb)(u32 pipe_index,
1307 const struct ipa_ep_cfg_holb *ep_holb);
1308 void (*ipa_cfg_route)(struct ipa_route *route);
1309 int (*ipa_read_gen_reg)(char *buff, int max_len);
1310 int (*ipa_read_ep_reg)(char *buff, int max_len, int pipe);
1311 void (*ipa_write_dbg_cnt)(int option);
1312 int (*ipa_read_dbg_cnt)(char *buf, int max_len);
1313 void (*ipa_cfg_ep_status)(u32 clnt_hdl,
1314 const struct ipa_ep_cfg_status *ep_status);
1315 int (*ipa_commit_flt)(enum ipa_ip_type ip);
1316 int (*ipa_commit_rt)(enum ipa_ip_type ip);
1317 int (*ipa_generate_rt_hw_rule)(enum ipa_ip_type ip,
1318 struct ipa_rt_entry *entry, u8 *buf);
1319 int (*ipa_commit_hdr)(void);
1320 void (*ipa_cfg_ep_cfg)(u32 clnt_hdl,
1321 const struct ipa_ep_cfg_cfg *cfg);
1322 void (*ipa_cfg_ep_metadata_mask)(u32 clnt_hdl,
1323 const struct ipa_ep_cfg_metadata_mask *metadata_mask);
1324 void (*ipa_enable_clks)(void);
1325 void (*ipa_disable_clks)(void);
1326 struct msm_bus_scale_pdata *msm_bus_data_ptr;
1327
1328 void (*ipa_cfg_ep_metadata)(u32 pipe_number,
1329 const struct ipa_ep_cfg_metadata *);
1330};
1331
1332extern struct ipa_context *ipa_ctx;
1333
1334/* public APIs */
1335/*
1336 * Connect / Disconnect
1337 */
1338int ipa2_connect(const struct ipa_connect_params *in,
1339 struct ipa_sps_params *sps, u32 *clnt_hdl);
1340int ipa2_disconnect(u32 clnt_hdl);
1341
1342/*
1343 * Resume / Suspend
1344 */
1345int ipa2_reset_endpoint(u32 clnt_hdl);
1346
1347/*
1348 * Remove ep delay
1349 */
1350int ipa2_clear_endpoint_delay(u32 clnt_hdl);
1351
1352/*
1353 * Disable ep
1354 */
1355int ipa2_disable_endpoint(u32 clnt_hdl);
1356
1357/*
1358 * Configuration
1359 */
1360int ipa2_cfg_ep(u32 clnt_hdl, const struct ipa_ep_cfg *ipa_ep_cfg);
1361
1362int ipa2_cfg_ep_nat(u32 clnt_hdl, const struct ipa_ep_cfg_nat *ipa_ep_cfg);
1363
1364int ipa2_cfg_ep_hdr(u32 clnt_hdl, const struct ipa_ep_cfg_hdr *ipa_ep_cfg);
1365
1366int ipa2_cfg_ep_hdr_ext(u32 clnt_hdl,
1367 const struct ipa_ep_cfg_hdr_ext *ipa_ep_cfg);
1368
1369int ipa2_cfg_ep_mode(u32 clnt_hdl, const struct ipa_ep_cfg_mode *ipa_ep_cfg);
1370
1371int ipa2_cfg_ep_aggr(u32 clnt_hdl, const struct ipa_ep_cfg_aggr *ipa_ep_cfg);
1372
1373int ipa2_cfg_ep_deaggr(u32 clnt_hdl,
1374 const struct ipa_ep_cfg_deaggr *ipa_ep_cfg);
1375
1376int ipa2_cfg_ep_route(u32 clnt_hdl, const struct ipa_ep_cfg_route *ipa_ep_cfg);
1377
1378int ipa2_cfg_ep_holb(u32 clnt_hdl, const struct ipa_ep_cfg_holb *ipa_ep_cfg);
1379
1380int ipa2_cfg_ep_cfg(u32 clnt_hdl, const struct ipa_ep_cfg_cfg *ipa_ep_cfg);
1381
1382int ipa2_cfg_ep_metadata_mask(u32 clnt_hdl,
1383 const struct ipa_ep_cfg_metadata_mask *ipa_ep_cfg);
1384
1385int ipa2_cfg_ep_holb_by_client(enum ipa_client_type client,
1386 const struct ipa_ep_cfg_holb *ipa_ep_cfg);
1387
1388int ipa2_cfg_ep_ctrl(u32 clnt_hdl, const struct ipa_ep_cfg_ctrl *ep_ctrl);
1389
1390/*
1391 * Header removal / addition
1392 */
1393int ipa2_add_hdr(struct ipa_ioc_add_hdr *hdrs);
1394
1395int ipa2_del_hdr(struct ipa_ioc_del_hdr *hdls);
1396
Ghanim Fodi2c8ba072017-01-12 15:14:15 +02001397int ipa2_del_hdr_by_user(struct ipa_ioc_del_hdr *hdls, bool by_user);
1398
Amir Levy9659e592016-10-27 18:08:27 +03001399int ipa2_commit_hdr(void);
1400
1401int ipa2_reset_hdr(void);
1402
1403int ipa2_get_hdr(struct ipa_ioc_get_hdr *lookup);
1404
1405int ipa2_put_hdr(u32 hdr_hdl);
1406
1407int ipa2_copy_hdr(struct ipa_ioc_copy_hdr *copy);
1408
1409/*
1410 * Header Processing Context
1411 */
1412int ipa2_add_hdr_proc_ctx(struct ipa_ioc_add_hdr_proc_ctx *proc_ctxs);
1413
1414int ipa2_del_hdr_proc_ctx(struct ipa_ioc_del_hdr_proc_ctx *hdls);
1415
Ghanim Fodi2c8ba072017-01-12 15:14:15 +02001416int ipa2_del_hdr_proc_ctx_by_user(struct ipa_ioc_del_hdr_proc_ctx *hdls,
1417 bool by_user);
1418
Amir Levy9659e592016-10-27 18:08:27 +03001419/*
1420 * Routing
1421 */
1422int ipa2_add_rt_rule(struct ipa_ioc_add_rt_rule *rules);
1423
1424int ipa2_del_rt_rule(struct ipa_ioc_del_rt_rule *hdls);
1425
1426int ipa2_commit_rt(enum ipa_ip_type ip);
1427
1428int ipa2_reset_rt(enum ipa_ip_type ip);
1429
1430int ipa2_get_rt_tbl(struct ipa_ioc_get_rt_tbl *lookup);
1431
1432int ipa2_put_rt_tbl(u32 rt_tbl_hdl);
1433
1434int ipa2_query_rt_index(struct ipa_ioc_get_rt_tbl_indx *in);
1435
1436int ipa2_mdfy_rt_rule(struct ipa_ioc_mdfy_rt_rule *rules);
1437
1438/*
1439 * Filtering
1440 */
1441int ipa2_add_flt_rule(struct ipa_ioc_add_flt_rule *rules);
1442
1443int ipa2_del_flt_rule(struct ipa_ioc_del_flt_rule *hdls);
1444
1445int ipa2_mdfy_flt_rule(struct ipa_ioc_mdfy_flt_rule *rules);
1446
1447int ipa2_commit_flt(enum ipa_ip_type ip);
1448
1449int ipa2_reset_flt(enum ipa_ip_type ip);
1450
1451/*
1452 * NAT
1453 */
1454int ipa2_allocate_nat_device(struct ipa_ioc_nat_alloc_mem *mem);
1455
1456int ipa2_nat_init_cmd(struct ipa_ioc_v4_nat_init *init);
1457
1458int ipa2_nat_dma_cmd(struct ipa_ioc_nat_dma_cmd *dma);
1459
1460int ipa2_nat_del_cmd(struct ipa_ioc_v4_nat_del *del);
1461
1462/*
1463 * Messaging
1464 */
1465int ipa2_send_msg(struct ipa_msg_meta *meta, void *buff,
1466 ipa_msg_free_fn callback);
1467int ipa2_register_pull_msg(struct ipa_msg_meta *meta, ipa_msg_pull_fn callback);
1468int ipa2_deregister_pull_msg(struct ipa_msg_meta *meta);
1469
1470/*
1471 * Interface
1472 */
1473int ipa2_register_intf(const char *name, const struct ipa_tx_intf *tx,
1474 const struct ipa_rx_intf *rx);
1475int ipa2_register_intf_ext(const char *name, const struct ipa_tx_intf *tx,
1476 const struct ipa_rx_intf *rx,
1477 const struct ipa_ext_intf *ext);
1478int ipa2_deregister_intf(const char *name);
1479
1480/*
1481 * Aggregation
1482 */
1483int ipa2_set_aggr_mode(enum ipa_aggr_mode mode);
1484
1485int ipa2_set_qcncm_ndp_sig(char sig[3]);
1486
1487int ipa2_set_single_ndp_per_mbim(bool enable);
1488
1489/*
1490 * Data path
1491 */
1492int ipa2_tx_dp(enum ipa_client_type dst, struct sk_buff *skb,
1493 struct ipa_tx_meta *metadata);
1494
1495/*
1496 * To transfer multiple data packets
1497 * While passing the data descriptor list, the anchor node
1498 * should be of type struct ipa_tx_data_desc not list_head
1499*/
1500int ipa2_tx_dp_mul(enum ipa_client_type dst,
1501 struct ipa_tx_data_desc *data_desc);
1502
1503void ipa2_free_skb(struct ipa_rx_data *);
1504
1505/*
1506 * System pipes
1507 */
1508int ipa2_setup_sys_pipe(struct ipa_sys_connect_params *sys_in, u32 *clnt_hdl);
1509
1510int ipa2_teardown_sys_pipe(u32 clnt_hdl);
1511
1512int ipa2_sys_setup(struct ipa_sys_connect_params *sys_in,
1513 unsigned long *ipa_bam_hdl,
1514 u32 *ipa_pipe_num, u32 *clnt_hdl, bool en_status);
1515
1516int ipa2_sys_teardown(u32 clnt_hdl);
1517
1518int ipa2_sys_update_gsi_hdls(u32 clnt_hdl, unsigned long gsi_ch_hdl,
1519 unsigned long gsi_ev_hdl);
1520
1521int ipa2_connect_wdi_pipe(struct ipa_wdi_in_params *in,
1522 struct ipa_wdi_out_params *out);
1523int ipa2_disconnect_wdi_pipe(u32 clnt_hdl);
1524int ipa2_enable_wdi_pipe(u32 clnt_hdl);
1525int ipa2_disable_wdi_pipe(u32 clnt_hdl);
1526int ipa2_resume_wdi_pipe(u32 clnt_hdl);
1527int ipa2_suspend_wdi_pipe(u32 clnt_hdl);
1528int ipa2_get_wdi_stats(struct IpaHwStatsWDIInfoData_t *stats);
1529u16 ipa2_get_smem_restr_bytes(void);
Utkarsh Saxenab89ce3a2017-02-16 22:29:56 +05301530int ipa2_broadcast_wdi_quota_reach_ind(uint32_t fid, uint64_t num_bytes);
Amir Levy9659e592016-10-27 18:08:27 +03001531int ipa2_setup_uc_ntn_pipes(struct ipa_ntn_conn_in_params *inp,
1532 ipa_notify_cb notify, void *priv, u8 hdr_len,
1533 struct ipa_ntn_conn_out_params *outp);
1534int ipa2_tear_down_uc_offload_pipes(int ipa_ep_idx_ul, int ipa_ep_idx_dl);
Sunil Paidimarrifbbcd072017-04-04 17:43:50 -07001535int ipa2_ntn_uc_reg_rdyCB(void (*ipauc_ready_cb)(void *), void *priv);
1536void ipa2_ntn_uc_dereg_rdyCB(void);
Amir Levy9659e592016-10-27 18:08:27 +03001537
1538/*
1539 * To retrieve doorbell physical address of
1540 * wlan pipes
1541 */
1542int ipa2_uc_wdi_get_dbpa(struct ipa_wdi_db_params *out);
1543
1544/*
1545 * To register uC ready callback if uC not ready
1546 * and also check uC readiness
1547 * if uC not ready only, register callback
1548 */
1549int ipa2_uc_reg_rdyCB(struct ipa_wdi_uc_ready_params *param);
1550/*
1551 * To de-register uC ready callback
1552 */
1553int ipa2_uc_dereg_rdyCB(void);
1554
1555/*
1556 * Tethering bridge (Rmnet / MBIM)
1557 */
1558int ipa2_teth_bridge_init(struct teth_bridge_init_params *params);
1559
1560int ipa2_teth_bridge_disconnect(enum ipa_client_type client);
1561
1562int ipa2_teth_bridge_connect(struct teth_bridge_connect_params *connect_params);
1563
1564/*
1565 * Tethering client info
1566 */
1567void ipa2_set_client(int index, enum ipacm_client_enum client, bool uplink);
1568
1569enum ipacm_client_enum ipa2_get_client(int pipe_idx);
1570
1571bool ipa2_get_client_uplink(int pipe_idx);
1572
Utkarsh Saxenab89ce3a2017-02-16 22:29:56 +05301573int ipa2_get_wlan_stats(struct ipa_get_wdi_sap_stats *wdi_sap_stats);
1574
1575int ipa2_set_wlan_quota(struct ipa_set_wifi_quota *wdi_quota);
1576
Amir Levy9659e592016-10-27 18:08:27 +03001577/*
1578 * IPADMA
1579 */
1580int ipa2_dma_init(void);
1581
1582int ipa2_dma_enable(void);
1583
1584int ipa2_dma_disable(void);
1585
1586int ipa2_dma_sync_memcpy(u64 dest, u64 src, int len);
1587
1588int ipa2_dma_async_memcpy(u64 dest, u64 src, int len,
1589 void (*user_cb)(void *user1), void *user_param);
1590
1591int ipa2_dma_uc_memcpy(phys_addr_t dest, phys_addr_t src, int len);
1592
1593void ipa2_dma_destroy(void);
1594
1595/*
1596 * MHI APIs for IPA MHI client driver
1597 */
1598int ipa2_init_mhi(struct ipa_mhi_init_params *params);
1599
1600int ipa2_mhi_init_engine(struct ipa_mhi_init_engine *params);
1601
1602int ipa2_connect_mhi_pipe(struct ipa_mhi_connect_params_internal *in,
1603 u32 *clnt_hdl);
1604
1605int ipa2_disconnect_mhi_pipe(u32 clnt_hdl);
1606
1607bool ipa2_mhi_sps_channel_empty(enum ipa_client_type client);
1608
1609int ipa2_disable_sps_pipe(enum ipa_client_type client);
1610
1611int ipa2_mhi_reset_channel_internal(enum ipa_client_type client);
1612
1613int ipa2_mhi_start_channel_internal(enum ipa_client_type client);
1614
1615int ipa2_mhi_suspend_ul_channels(void);
1616
1617int ipa2_mhi_resume_channels_internal(enum ipa_client_type client,
1618 bool LPTransitionRejected, bool brstmode_enabled,
1619 union __packed gsi_channel_scratch ch_scratch, u8 index);
1620
1621/*
1622 * mux id
1623 */
1624int ipa2_write_qmap_id(struct ipa_ioc_write_qmapid *param_in);
1625
1626/*
1627 * interrupts
1628 */
1629int ipa2_add_interrupt_handler(enum ipa_irq_type interrupt,
1630 ipa_irq_handler_t handler,
1631 bool deferred_flag,
1632 void *private_data);
1633
1634int ipa2_remove_interrupt_handler(enum ipa_irq_type interrupt);
1635
1636/*
1637 * Miscellaneous
1638 */
1639void ipa2_bam_reg_dump(void);
1640
1641int ipa2_get_ep_mapping(enum ipa_client_type client);
1642
1643bool ipa2_is_ready(void);
1644
1645void ipa2_proxy_clk_vote(void);
1646void ipa2_proxy_clk_unvote(void);
1647
1648bool ipa2_is_client_handle_valid(u32 clnt_hdl);
1649
1650enum ipa_client_type ipa2_get_client_mapping(int pipe_idx);
1651
1652enum ipa_rm_resource_name ipa2_get_rm_resource_from_ep(int pipe_idx);
1653
1654bool ipa2_get_modem_cfg_emb_pipe_flt(void);
1655
1656/* internal functions */
1657
1658int ipa2_bind_api_controller(enum ipa_hw_type ipa_hw_type,
1659 struct ipa_api_controller *api_ctrl);
1660
1661int ipa_send_one(struct ipa_sys_context *sys, struct ipa_desc *desc,
1662 bool in_atomic);
1663int ipa_send(struct ipa_sys_context *sys, u32 num_desc, struct ipa_desc *desc,
1664 bool in_atomic);
1665int ipa2_get_ep_mapping(enum ipa_client_type client);
1666
1667int ipa_generate_hw_rule(enum ipa_ip_type ip,
1668 const struct ipa_rule_attrib *attrib,
1669 u8 **buf,
1670 u16 *en_rule);
1671int ipa_init_hw(void);
1672struct ipa_rt_tbl *__ipa_find_rt_tbl(enum ipa_ip_type ip, const char *name);
1673int ipa_set_single_ndp_per_mbim(bool);
1674int ipa_set_hw_timer_fix_for_mbim_aggr(bool);
1675void ipa_debugfs_init(void);
1676void ipa_debugfs_remove(void);
1677
1678void ipa_dump_buff_internal(void *base, dma_addr_t phy_base, u32 size);
1679
1680void ipa_rx_timeout_min_max_calc(u32 *min, u32 *max, s8 time);
1681
1682#ifdef IPA_DEBUG
1683#define IPA_DUMP_BUFF(base, phy_base, size) \
1684 ipa_dump_buff_internal(base, phy_base, size)
1685#else
1686#define IPA_DUMP_BUFF(base, phy_base, size)
1687#endif
1688int ipa_controller_static_bind(struct ipa_controller *controller,
1689 enum ipa_hw_type ipa_hw_type);
1690int ipa_cfg_route(struct ipa_route *route);
1691int ipa_send_cmd(u16 num_desc, struct ipa_desc *descr);
1692int ipa_cfg_filter(u32 disable);
1693int ipa_pipe_mem_init(u32 start_ofst, u32 size);
1694int ipa_pipe_mem_alloc(u32 *ofst, u32 size);
1695int ipa_pipe_mem_free(u32 ofst, u32 size);
1696int ipa_straddle_boundary(u32 start, u32 end, u32 boundary);
1697struct ipa_context *ipa_get_ctx(void);
1698void ipa_enable_clks(void);
1699void ipa_disable_clks(void);
1700void ipa2_inc_client_enable_clks(struct ipa_active_client_logging_info *id);
1701int ipa2_inc_client_enable_clks_no_block(struct ipa_active_client_logging_info
1702 *id);
1703void ipa2_dec_client_disable_clks(struct ipa_active_client_logging_info *id);
1704void ipa2_active_clients_log_dec(struct ipa_active_client_logging_info *id,
1705 bool int_ctx);
1706void ipa2_active_clients_log_inc(struct ipa_active_client_logging_info *id,
1707 bool int_ctx);
1708int ipa2_active_clients_log_print_buffer(char *buf, int size);
1709int ipa2_active_clients_log_print_table(char *buf, int size);
1710void ipa2_active_clients_log_clear(void);
1711int ipa_interrupts_init(u32 ipa_irq, u32 ee, struct device *ipa_dev);
1712int __ipa_del_rt_rule(u32 rule_hdl);
Ghanim Fodi2c8ba072017-01-12 15:14:15 +02001713int __ipa_del_hdr(u32 hdr_hdl, bool by_user);
Amir Levy9659e592016-10-27 18:08:27 +03001714int __ipa_release_hdr(u32 hdr_hdl);
1715int __ipa_release_hdr_proc_ctx(u32 proc_ctx_hdl);
1716int _ipa_read_gen_reg_v1_1(char *buff, int max_len);
1717int _ipa_read_gen_reg_v2_0(char *buff, int max_len);
1718int _ipa_read_ep_reg_v1_1(char *buf, int max_len, int pipe);
1719int _ipa_read_ep_reg_v2_0(char *buf, int max_len, int pipe);
1720void _ipa_write_dbg_cnt_v1_1(int option);
1721void _ipa_write_dbg_cnt_v2_0(int option);
1722int _ipa_read_dbg_cnt_v1_1(char *buf, int max_len);
1723int _ipa_read_dbg_cnt_v2_0(char *buf, int max_len);
1724void _ipa_enable_clks_v1_1(void);
1725void _ipa_enable_clks_v2_0(void);
1726void _ipa_disable_clks_v1_1(void);
1727void _ipa_disable_clks_v2_0(void);
1728
1729static inline u32 ipa_read_reg(void *base, u32 offset)
1730{
1731 return ioread32(base + offset);
1732}
1733
1734static inline u32 ipa_read_reg_field(void *base, u32 offset,
1735 u32 mask, u32 shift)
1736{
1737 return (ipa_read_reg(base, offset) & mask) >> shift;
1738}
1739
1740static inline void ipa_write_reg(void *base, u32 offset, u32 val)
1741{
1742 iowrite32(val, base + offset);
1743}
1744
Amir Levy9659e592016-10-27 18:08:27 +03001745ssize_t ipa_read(struct file *filp, char __user *buf, size_t count,
1746 loff_t *f_pos);
1747int ipa_pull_msg(struct ipa_msg_meta *meta, char *buff, size_t count);
1748int ipa_query_intf(struct ipa_ioc_query_intf *lookup);
1749int ipa_query_intf_tx_props(struct ipa_ioc_query_intf_tx_props *tx);
1750int ipa_query_intf_rx_props(struct ipa_ioc_query_intf_rx_props *rx);
1751int ipa_query_intf_ext_props(struct ipa_ioc_query_intf_ext_props *ext);
1752
1753void wwan_cleanup(void);
1754
1755int teth_bridge_driver_init(void);
1756void ipa_lan_rx_cb(void *priv, enum ipa_dp_evt_type evt, unsigned long data);
1757
1758int _ipa_init_sram_v2(void);
1759int _ipa_init_sram_v2_5(void);
1760int _ipa_init_sram_v2_6L(void);
1761int _ipa_init_hdr_v2(void);
1762int _ipa_init_hdr_v2_5(void);
1763int _ipa_init_hdr_v2_6L(void);
1764int _ipa_init_rt4_v2(void);
1765int _ipa_init_rt6_v2(void);
1766int _ipa_init_flt4_v2(void);
1767int _ipa_init_flt6_v2(void);
1768
1769int __ipa_commit_flt_v1_1(enum ipa_ip_type ip);
1770int __ipa_commit_flt_v2(enum ipa_ip_type ip);
1771int __ipa_commit_rt_v1_1(enum ipa_ip_type ip);
1772int __ipa_commit_rt_v2(enum ipa_ip_type ip);
1773int __ipa_generate_rt_hw_rule_v2(enum ipa_ip_type ip,
1774 struct ipa_rt_entry *entry, u8 *buf);
1775int __ipa_generate_rt_hw_rule_v2_5(enum ipa_ip_type ip,
1776 struct ipa_rt_entry *entry, u8 *buf);
1777int __ipa_generate_rt_hw_rule_v2_6L(enum ipa_ip_type ip,
1778 struct ipa_rt_entry *entry, u8 *buf);
1779
1780int __ipa_commit_hdr_v1_1(void);
1781int __ipa_commit_hdr_v2(void);
1782int __ipa_commit_hdr_v2_5(void);
1783int __ipa_commit_hdr_v2_6L(void);
1784int ipa_generate_flt_eq(enum ipa_ip_type ip,
1785 const struct ipa_rule_attrib *attrib,
1786 struct ipa_ipfltri_rule_eq *eq_attrib);
1787void ipa_skb_recycle(struct sk_buff *skb);
1788void ipa_install_dflt_flt_rules(u32 ipa_ep_idx);
1789void ipa_delete_dflt_flt_rules(u32 ipa_ep_idx);
1790
1791int ipa_enable_data_path(u32 clnt_hdl);
1792int ipa_disable_data_path(u32 clnt_hdl);
Utkarsh Saxenadabdca72017-02-08 21:13:24 +05301793int ipa2_enable_force_clear(u32 request_id, bool throttle_source,
1794 u32 source_pipe_bitmask);
1795int ipa2_disable_force_clear(u32 request_id);
Amir Levy9659e592016-10-27 18:08:27 +03001796int ipa_id_alloc(void *ptr);
1797void *ipa_id_find(u32 id);
1798void ipa_id_remove(u32 id);
1799
1800int ipa2_set_required_perf_profile(enum ipa_voltage_level floor_voltage,
1801 u32 bandwidth_mbps);
1802
1803int ipa2_cfg_ep_status(u32 clnt_hdl,
1804 const struct ipa_ep_cfg_status *ipa_ep_cfg);
1805int ipa_cfg_aggr_cntr_granularity(u8 aggr_granularity);
1806int ipa_cfg_eot_coal_cntr_granularity(u8 eot_coal_granularity);
1807
1808int ipa2_suspend_resource_no_block(enum ipa_rm_resource_name name);
1809int ipa2_suspend_resource_sync(enum ipa_rm_resource_name name);
1810int ipa2_resume_resource(enum ipa_rm_resource_name name);
1811bool ipa_should_pipe_be_suspended(enum ipa_client_type client);
1812int ipa_tag_aggr_force_close(int pipe_num);
1813
1814void ipa_active_clients_lock(void);
1815int ipa_active_clients_trylock(unsigned long *flags);
1816void ipa_active_clients_unlock(void);
1817void ipa_active_clients_trylock_unlock(unsigned long *flags);
1818int ipa_wdi_init(void);
1819int ipa_write_qmapid_wdi_pipe(u32 clnt_hdl, u8 qmap_id);
1820int ipa_tag_process(struct ipa_desc *desc, int num_descs,
1821 unsigned long timeout);
1822
1823int ipa_q6_pre_shutdown_cleanup(void);
1824int ipa_q6_post_shutdown_cleanup(void);
1825int ipa_init_q6_smem(void);
1826int ipa_q6_monitor_holb_mitigation(bool enable);
1827
1828int ipa_sps_connect_safe(struct sps_pipe *h, struct sps_connect *connect,
1829 enum ipa_client_type ipa_client);
1830
1831int ipa_uc_interface_init(void);
1832int ipa_uc_reset_pipe(enum ipa_client_type ipa_client);
1833int ipa_uc_monitor_holb(enum ipa_client_type ipa_client, bool enable);
1834int ipa2_uc_state_check(void);
1835int ipa_uc_loaded_check(void);
1836int ipa_uc_send_cmd(u32 cmd, u32 opcode, u32 expected_status,
1837 bool polling_mode, unsigned long timeout_jiffies);
1838void ipa_register_panic_hdlr(void);
1839void ipa_uc_register_handlers(enum ipa_hw_features feature,
1840 struct ipa_uc_hdlrs *hdlrs);
1841int create_nat_device(void);
1842int ipa_uc_notify_clk_state(bool enabled);
1843void ipa_dma_async_memcpy_notify_cb(void *priv,
1844 enum ipa_dp_evt_type evt, unsigned long data);
1845
1846int ipa_uc_update_hw_flags(u32 flags);
1847
1848int ipa2_uc_mhi_init(void (*ready_cb)(void), void (*wakeup_request_cb)(void));
1849void ipa2_uc_mhi_cleanup(void);
1850int ipa2_uc_mhi_send_dl_ul_sync_info(union IpaHwMhiDlUlSyncCmdData_t *cmd);
1851int ipa_uc_mhi_init_engine(struct ipa_mhi_msi_info *msi, u32 mmio_addr,
1852 u32 host_ctrl_addr, u32 host_data_addr, u32 first_ch_idx,
1853 u32 first_evt_idx);
1854int ipa_uc_mhi_init_channel(int ipa_ep_idx, int channelHandle,
1855 int contexArrayIndex, int channelDirection);
1856int ipa2_uc_mhi_reset_channel(int channelHandle);
1857int ipa2_uc_mhi_suspend_channel(int channelHandle);
1858int ipa_uc_mhi_resume_channel(int channelHandle, bool LPTransitionRejected);
1859int ipa2_uc_mhi_stop_event_update_channel(int channelHandle);
1860int ipa2_uc_mhi_print_stats(char *dbg_buff, int size);
1861int ipa_uc_memcpy(phys_addr_t dest, phys_addr_t src, int len);
1862u32 ipa_get_num_pipes(void);
1863u32 ipa_get_sys_yellow_wm(struct ipa_sys_context *sys);
1864struct ipa_smmu_cb_ctx *ipa2_get_smmu_ctx(void);
1865struct ipa_smmu_cb_ctx *ipa2_get_wlan_smmu_ctx(void);
1866struct ipa_smmu_cb_ctx *ipa2_get_uc_smmu_ctx(void);
1867struct iommu_domain *ipa_get_uc_smmu_domain(void);
1868struct iommu_domain *ipa2_get_wlan_smmu_domain(void);
1869int ipa2_ap_suspend(struct device *dev);
1870int ipa2_ap_resume(struct device *dev);
1871struct iommu_domain *ipa2_get_smmu_domain(void);
1872struct device *ipa2_get_dma_dev(void);
1873int ipa2_release_wdi_mapping(u32 num_buffers, struct ipa_wdi_buffer_info *info);
1874int ipa2_create_wdi_mapping(u32 num_buffers, struct ipa_wdi_buffer_info *info);
1875void ipa_suspend_apps_pipes(bool suspend);
1876void ipa_update_repl_threshold(enum ipa_client_type ipa_client);
1877void ipa_flow_control(enum ipa_client_type ipa_client, bool enable,
1878 uint32_t qmap_id);
1879int ipa2_restore_suspend_handler(void);
1880void ipa_sps_irq_control_all(bool enable);
1881void ipa_inc_acquire_wakelock(enum ipa_wakelock_ref_client ref_client);
1882void ipa_dec_release_wakelock(enum ipa_wakelock_ref_client ref_client);
1883int ipa_iommu_map(struct iommu_domain *domain, unsigned long iova,
1884 phys_addr_t paddr, size_t size, int prot);
1885int ipa2_rx_poll(u32 clnt_hdl, int budget);
1886void ipa2_recycle_wan_skb(struct sk_buff *skb);
1887int ipa_ntn_init(void);
1888int ipa2_get_ntn_stats(struct IpaHwStatsNTNInfoData_t *stats);
1889int ipa2_register_ipa_ready_cb(void (*ipa_ready_cb)(void *),
1890 void *user_data);
Amir Levyc4222c92016-11-07 16:14:54 +02001891struct device *ipa2_get_pdev(void);
Amir Levy9659e592016-10-27 18:08:27 +03001892#endif /* _IPA_I_H_ */