blob: ee6f43a40c0da56fb9b47123385e963109ab2f1c [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>
26#include <linux/msm-sps.h>
27#include <asm/dma-iommu.h>
28#include <linux/iommu.h>
29#include <linux/platform_device.h>
30#include <linux/firmware.h>
31#include "ipa_hw_defs.h"
32#include "ipa_qmi_service.h"
33#include "../ipa_api.h"
34#include "ipahal/ipahal_reg.h"
35#include "ipahal/ipahal.h"
36#include "ipahal/ipahal_fltrt.h"
37#include "../ipa_common_i.h"
38#include "ipa_uc_offload_i.h"
39
40#define DRV_NAME "ipa"
41#define NAT_DEV_NAME "ipaNatTable"
42#define IPA_COOKIE 0x57831603
43#define MTU_BYTE 1500
44
45#define IPA3_MAX_NUM_PIPES 31
Amir Levy9659e592016-10-27 18:08:27 +030046#define IPA_SYS_DESC_FIFO_SZ 0x800
47#define IPA_SYS_TX_DATA_DESC_FIFO_SZ 0x1000
48#define IPA_LAN_RX_HEADER_LENGTH (2)
49#define IPA_QMAP_HEADER_LENGTH (4)
50#define IPA_DL_CHECKSUM_LENGTH (8)
51#define IPA_NUM_DESC_PER_SW_TX (3)
52#define IPA_GENERIC_RX_POOL_SZ 192
53#define IPA_UC_FINISH_MAX 6
54#define IPA_UC_WAIT_MIN_SLEEP 1000
55#define IPA_UC_WAII_MAX_SLEEP 1200
Gidon Studinski3021a6f2016-11-10 12:48:48 +020056#define IPA_WAN_NAPI_CONS_RX_POOL_SZ (IPA_GENERIC_RX_POOL_SZ*3)
57#define IPA_WAN_CONS_DESC_FIFO_SZ (IPA_SYS_DESC_FIFO_SZ*3)
Amir Levy9659e592016-10-27 18:08:27 +030058
59#define IPA_MAX_STATUS_STAT_NUM 30
60
61#define IPA_IPC_LOG_PAGES 50
62
63#define IPADBG(fmt, args...) \
64 do { \
65 pr_debug(DRV_NAME " %s:%d " fmt, __func__, __LINE__, ## args);\
66 if (ipa3_ctx) { \
67 IPA_IPC_LOGGING(ipa3_ctx->logbuf, \
68 DRV_NAME " %s:%d " fmt, ## args); \
69 IPA_IPC_LOGGING(ipa3_ctx->logbuf_low, \
70 DRV_NAME " %s:%d " fmt, ## args); \
71 } \
72 } while (0)
73
74#define IPADBG_LOW(fmt, args...) \
75 do { \
76 pr_debug(DRV_NAME " %s:%d " fmt, __func__, __LINE__, ## args);\
77 if (ipa3_ctx) \
78 IPA_IPC_LOGGING(ipa3_ctx->logbuf_low, \
79 DRV_NAME " %s:%d " fmt, ## args); \
80 } while (0)
81
82#define IPAERR(fmt, args...) \
83 do { \
84 pr_err(DRV_NAME " %s:%d " fmt, __func__, __LINE__, ## args);\
85 if (ipa3_ctx) { \
86 IPA_IPC_LOGGING(ipa3_ctx->logbuf, \
87 DRV_NAME " %s:%d " fmt, ## args); \
88 IPA_IPC_LOGGING(ipa3_ctx->logbuf_low, \
89 DRV_NAME " %s:%d " fmt, ## args); \
90 } \
91 } while (0)
92
93#define WLAN_AMPDU_TX_EP 15
94#define WLAN_PROD_TX_EP 19
95#define WLAN1_CONS_RX_EP 14
96#define WLAN2_CONS_RX_EP 16
97#define WLAN3_CONS_RX_EP 17
98#define WLAN4_CONS_RX_EP 18
99
100#define IPA_RAM_NAT_OFST 0
101#define IPA_RAM_NAT_SIZE 0
102#define IPA_MEM_CANARY_VAL 0xdeadbeef
103
104#define IPA_STATS
105
106#ifdef IPA_STATS
107#define IPA_STATS_INC_CNT(val) (++val)
108#define IPA_STATS_DEC_CNT(val) (--val)
109#define IPA_STATS_EXCP_CNT(__excp, __base) do { \
110 if (__excp < 0 || __excp >= IPAHAL_PKT_STATUS_EXCEPTION_MAX) \
111 break; \
112 ++__base[__excp]; \
113 } while (0)
114#else
115#define IPA_STATS_INC_CNT(x) do { } while (0)
116#define IPA_STATS_DEC_CNT(x)
117#define IPA_STATS_EXCP_CNT(__excp, __base) do { } while (0)
118#endif
119
120#define IPA_HDR_BIN0 0
121#define IPA_HDR_BIN1 1
122#define IPA_HDR_BIN2 2
123#define IPA_HDR_BIN3 3
124#define IPA_HDR_BIN4 4
125#define IPA_HDR_BIN_MAX 5
126
127#define IPA_HDR_PROC_CTX_BIN0 0
128#define IPA_HDR_PROC_CTX_BIN1 1
129#define IPA_HDR_PROC_CTX_BIN_MAX 2
130
131#define IPA_EVENT_THRESHOLD 0x10
132
133/*
134 * Due to ZLT issue with USB 3.0 core, IPA BAM threashold need to be set
135 * to max packet size + 1. After setting the threshold, USB core
136 * will not be notified on ZLTs
137 */
138#define IPA_USB_EVENT_THRESHOLD 0x4001
139
140#define IPA_RX_POOL_CEIL 32
141#define IPA_RX_SKB_SIZE 1792
142
143#define IPA_A5_MUX_HDR_NAME "ipa_excp_hdr"
144#define IPA_LAN_RX_HDR_NAME "ipa_lan_hdr"
145#define IPA_INVALID_L4_PROTOCOL 0xFF
146
147#define IPA_CLIENT_IS_PROD(x) (x >= IPA_CLIENT_PROD && x < IPA_CLIENT_CONS)
148#define IPA_CLIENT_IS_CONS(x) (x >= IPA_CLIENT_CONS && x < IPA_CLIENT_MAX)
149
150#define IPA_PIPE_MEM_START_OFST_ALIGNMENT(start_ofst) \
151 (((start_ofst) + 127) & ~127)
152
153#define IPA_HDR_PROC_CTX_TABLE_ALIGNMENT_BYTE 8
154#define IPA_HDR_PROC_CTX_TABLE_ALIGNMENT(start_ofst) \
155 (((start_ofst) + IPA_HDR_PROC_CTX_TABLE_ALIGNMENT_BYTE - 1) & \
156 ~(IPA_HDR_PROC_CTX_TABLE_ALIGNMENT_BYTE - 1))
157
158#define MAX_RESOURCE_TO_CLIENTS (IPA_CLIENT_MAX)
159#define IPA_MEM_PART(x_) (ipa3_ctx->ctrl->mem_partition.x_)
160
161#define IPA_GSI_CHANNEL_STOP_MAX_RETRY 10
162#define IPA_GSI_CHANNEL_STOP_PKT_SIZE 1
163
164#define IPA_GSI_CHANNEL_EMPTY_MAX_RETRY 15
165#define IPA_GSI_CHANNEL_EMPTY_SLEEP_MIN_USEC (1000)
166#define IPA_GSI_CHANNEL_EMPTY_SLEEP_MAX_USEC (2000)
167
168#define IPA_SLEEP_CLK_RATE_KHZ (32)
169
170#define IPA3_ACTIVE_CLIENTS_LOG_BUFFER_SIZE_LINES 120
171#define IPA3_ACTIVE_CLIENTS_LOG_LINE_LEN 96
172#define IPA3_ACTIVE_CLIENTS_LOG_HASHTABLE_SIZE 50
173#define IPA3_ACTIVE_CLIENTS_LOG_NAME_LEN 40
174
175struct ipa3_active_client_htable_entry {
176 struct hlist_node list;
177 char id_string[IPA3_ACTIVE_CLIENTS_LOG_NAME_LEN];
178 int count;
179 enum ipa_active_client_log_type type;
180};
181
182struct ipa3_active_clients_log_ctx {
183 char *log_buffer[IPA3_ACTIVE_CLIENTS_LOG_BUFFER_SIZE_LINES];
184 int log_head;
185 int log_tail;
186 bool log_rdy;
187 struct hlist_head htable[IPA3_ACTIVE_CLIENTS_LOG_HASHTABLE_SIZE];
188};
189
190struct ipa3_client_names {
191 enum ipa_client_type names[MAX_RESOURCE_TO_CLIENTS];
192 int length;
193};
194
195struct ipa_smmu_cb_ctx {
196 bool valid;
197 struct device *dev;
198 struct dma_iommu_mapping *mapping;
199 struct iommu_domain *iommu;
200 unsigned long next_addr;
201 u32 va_start;
202 u32 va_size;
203 u32 va_end;
204};
205
206/**
207 * struct ipa3_flt_entry - IPA filtering table entry
208 * @link: entry's link in global filtering enrties list
209 * @rule: filter rule
210 * @cookie: cookie used for validity check
211 * @tbl: filter table
212 * @rt_tbl: routing table
213 * @hw_len: entry's size
214 * @id: rule handle - globally unique
215 * @prio: rule 10bit priority which defines the order of the rule
216 * among other rules at the same integrated table
217 * @rule_id: rule 10bit ID to be returned in packet status
218 */
219struct ipa3_flt_entry {
220 struct list_head link;
221 struct ipa_flt_rule rule;
222 u32 cookie;
223 struct ipa3_flt_tbl *tbl;
224 struct ipa3_rt_tbl *rt_tbl;
225 u32 hw_len;
226 int id;
227 u16 prio;
228 u16 rule_id;
229};
230
231/**
232 * struct ipa3_rt_tbl - IPA routing table
233 * @link: table's link in global routing tables list
234 * @head_rt_rule_list: head of routing rules list
235 * @name: routing table name
236 * @idx: routing table index
237 * @rule_cnt: number of rules in routing table
238 * @ref_cnt: reference counter of routing table
239 * @set: collection of routing tables
240 * @cookie: cookie used for validity check
241 * @in_sys: flag indicating if the table is located in system memory
242 * @sz: the size of the routing table
243 * @curr_mem: current routing tables block in sys memory
244 * @prev_mem: previous routing table block in sys memory
245 * @id: routing table id
246 * @rule_ids: idr structure that holds the rule_id for each rule
247 */
248struct ipa3_rt_tbl {
249 struct list_head link;
250 struct list_head head_rt_rule_list;
251 char name[IPA_RESOURCE_NAME_MAX];
252 u32 idx;
253 u32 rule_cnt;
254 u32 ref_cnt;
255 struct ipa3_rt_tbl_set *set;
256 u32 cookie;
257 bool in_sys[IPA_RULE_TYPE_MAX];
258 u32 sz[IPA_RULE_TYPE_MAX];
259 struct ipa_mem_buffer curr_mem[IPA_RULE_TYPE_MAX];
260 struct ipa_mem_buffer prev_mem[IPA_RULE_TYPE_MAX];
261 int id;
262 struct idr rule_ids;
263};
264
265/**
266 * struct ipa3_hdr_entry - IPA header table entry
267 * @link: entry's link in global header table entries list
268 * @hdr: the header
269 * @hdr_len: header length
270 * @name: name of header table entry
271 * @type: l2 header type
272 * @is_partial: flag indicating if header table entry is partial
273 * @is_hdr_proc_ctx: false - hdr entry resides in hdr table,
274 * true - hdr entry resides in DDR and pointed to by proc ctx
275 * @phys_base: physical address of entry in DDR when is_hdr_proc_ctx is true,
276 * else 0
277 * @proc_ctx: processing context header
278 * @offset_entry: entry's offset
279 * @cookie: cookie used for validity check
280 * @ref_cnt: reference counter of routing table
281 * @id: header entry id
282 * @is_eth2_ofst_valid: is eth2_ofst field valid?
283 * @eth2_ofst: offset to start of Ethernet-II/802.3 header
Ghanim Fodi2c8ba072017-01-12 15:14:15 +0200284 * @user_deleted: is the header deleted by the user?
Amir Levy9659e592016-10-27 18:08:27 +0300285 */
286struct ipa3_hdr_entry {
287 struct list_head link;
288 u8 hdr[IPA_HDR_MAX_SIZE];
289 u32 hdr_len;
290 char name[IPA_RESOURCE_NAME_MAX];
291 enum ipa_hdr_l2_type type;
292 u8 is_partial;
293 bool is_hdr_proc_ctx;
294 dma_addr_t phys_base;
295 struct ipa3_hdr_proc_ctx_entry *proc_ctx;
296 struct ipa_hdr_offset_entry *offset_entry;
297 u32 cookie;
298 u32 ref_cnt;
299 int id;
300 u8 is_eth2_ofst_valid;
301 u16 eth2_ofst;
Ghanim Fodi2c8ba072017-01-12 15:14:15 +0200302 bool user_deleted;
Amir Levy9659e592016-10-27 18:08:27 +0300303};
304
305/**
306 * struct ipa3_hdr_tbl - IPA header table
307 * @head_hdr_entry_list: header entries list
308 * @head_offset_list: header offset list
309 * @head_free_offset_list: header free offset list
310 * @hdr_cnt: number of headers
311 * @end: the last header index
312 */
313struct ipa3_hdr_tbl {
314 struct list_head head_hdr_entry_list;
315 struct list_head head_offset_list[IPA_HDR_BIN_MAX];
316 struct list_head head_free_offset_list[IPA_HDR_BIN_MAX];
317 u32 hdr_cnt;
318 u32 end;
319};
320
321/**
322 * struct ipa3_hdr_offset_entry - IPA header offset entry
323 * @link: entry's link in global processing context header offset entries list
324 * @offset: the offset
325 * @bin: bin
326 */
327struct ipa3_hdr_proc_ctx_offset_entry {
328 struct list_head link;
329 u32 offset;
330 u32 bin;
331};
332
333/**
334 * struct ipa3_hdr_proc_ctx_entry - IPA processing context header table entry
335 * @link: entry's link in global header table entries list
336 * @type:
337 * @offset_entry: entry's offset
338 * @hdr: the header
339 * @cookie: cookie used for validity check
340 * @ref_cnt: reference counter of routing table
341 * @id: processing context header entry id
Ghanim Fodi2c8ba072017-01-12 15:14:15 +0200342 * @user_deleted: is the hdr processing context deleted by the user?
Amir Levy9659e592016-10-27 18:08:27 +0300343 */
344struct ipa3_hdr_proc_ctx_entry {
345 struct list_head link;
346 enum ipa_hdr_proc_type type;
347 struct ipa3_hdr_proc_ctx_offset_entry *offset_entry;
348 struct ipa3_hdr_entry *hdr;
349 u32 cookie;
350 u32 ref_cnt;
351 int id;
Ghanim Fodi2c8ba072017-01-12 15:14:15 +0200352 bool user_deleted;
Amir Levy9659e592016-10-27 18:08:27 +0300353};
354
355/**
356 * struct ipa3_hdr_proc_ctx_tbl - IPA processing context header table
357 * @head_proc_ctx_entry_list: header entries list
358 * @head_offset_list: header offset list
359 * @head_free_offset_list: header free offset list
360 * @proc_ctx_cnt: number of processing context headers
361 * @end: the last processing context header index
362 * @start_offset: offset in words of processing context header table
363 */
364struct ipa3_hdr_proc_ctx_tbl {
365 struct list_head head_proc_ctx_entry_list;
366 struct list_head head_offset_list[IPA_HDR_PROC_CTX_BIN_MAX];
367 struct list_head head_free_offset_list[IPA_HDR_PROC_CTX_BIN_MAX];
368 u32 proc_ctx_cnt;
369 u32 end;
370 u32 start_offset;
371};
372
373/**
374 * struct ipa3_flt_tbl - IPA filter table
375 * @head_flt_rule_list: filter rules list
376 * @rule_cnt: number of filter rules
377 * @in_sys: flag indicating if filter table is located in system memory
378 * @sz: the size of the filter tables
379 * @end: the last header index
380 * @curr_mem: current filter tables block in sys memory
381 * @prev_mem: previous filter table block in sys memory
382 * @rule_ids: idr structure that holds the rule_id for each rule
383 */
384struct ipa3_flt_tbl {
385 struct list_head head_flt_rule_list;
386 u32 rule_cnt;
387 bool in_sys[IPA_RULE_TYPE_MAX];
388 u32 sz[IPA_RULE_TYPE_MAX];
389 struct ipa_mem_buffer curr_mem[IPA_RULE_TYPE_MAX];
390 struct ipa_mem_buffer prev_mem[IPA_RULE_TYPE_MAX];
391 bool sticky_rear;
392 struct idr rule_ids;
393};
394
395/**
396 * struct ipa3_rt_entry - IPA routing table entry
397 * @link: entry's link in global routing table entries list
398 * @rule: routing rule
399 * @cookie: cookie used for validity check
400 * @tbl: routing table
401 * @hdr: header table
402 * @proc_ctx: processing context table
403 * @hw_len: the length of the table
404 * @id: rule handle - globaly unique
405 * @prio: rule 10bit priority which defines the order of the rule
406 * among other rules at the integrated same table
407 * @rule_id: rule 10bit ID to be returned in packet status
408 */
409struct ipa3_rt_entry {
410 struct list_head link;
411 struct ipa_rt_rule rule;
412 u32 cookie;
413 struct ipa3_rt_tbl *tbl;
414 struct ipa3_hdr_entry *hdr;
415 struct ipa3_hdr_proc_ctx_entry *proc_ctx;
416 u32 hw_len;
417 int id;
418 u16 prio;
419 u16 rule_id;
420};
421
422/**
423 * struct ipa3_rt_tbl_set - collection of routing tables
424 * @head_rt_tbl_list: collection of routing tables
425 * @tbl_cnt: number of routing tables
426 */
427struct ipa3_rt_tbl_set {
428 struct list_head head_rt_tbl_list;
429 u32 tbl_cnt;
430};
431
432/**
433 * struct ipa3_wlan_stats - Wlan stats for each wlan endpoint
434 * @rx_pkts_rcvd: Packets sent by wlan driver
435 * @rx_pkts_status_rcvd: Status packets received from ipa hw
436 * @rx_hd_processed: Data Descriptors processed by IPA Driver
437 * @rx_hd_reply: Data Descriptors recycled by wlan driver
438 * @rx_hd_rcvd: Data Descriptors sent by wlan driver
439 * @rx_pkt_leak: Packet count that are not recycled
440 * @rx_dp_fail: Packets failed to transfer to IPA HW
441 * @tx_pkts_rcvd: SKB Buffers received from ipa hw
442 * @tx_pkts_sent: SKB Buffers sent to wlan driver
443 * @tx_pkts_dropped: Dropped packets count
444 */
445struct ipa3_wlan_stats {
446 u32 rx_pkts_rcvd;
447 u32 rx_pkts_status_rcvd;
448 u32 rx_hd_processed;
449 u32 rx_hd_reply;
450 u32 rx_hd_rcvd;
451 u32 rx_pkt_leak;
452 u32 rx_dp_fail;
453 u32 tx_pkts_rcvd;
454 u32 tx_pkts_sent;
455 u32 tx_pkts_dropped;
456};
457
458/**
459 * struct ipa3_wlan_comm_memb - Wlan comm members
460 * @wlan_spinlock: protects wlan comm buff list and its size
461 * @ipa_tx_mul_spinlock: protects tx dp mul transfer
462 * @wlan_comm_total_cnt: wlan common skb buffers allocated count
463 * @wlan_comm_free_cnt: wlan common skb buffer free count
464 * @total_tx_pkts_freed: Recycled Buffer count
465 * @wlan_comm_desc_list: wlan common skb buffer list
466 */
467struct ipa3_wlan_comm_memb {
468 spinlock_t wlan_spinlock;
469 spinlock_t ipa_tx_mul_spinlock;
470 u32 wlan_comm_total_cnt;
471 u32 wlan_comm_free_cnt;
472 u32 total_tx_pkts_freed;
473 struct list_head wlan_comm_desc_list;
474 atomic_t active_clnt_cnt;
475};
476
477struct ipa_gsi_ep_mem_info {
478 u16 evt_ring_len;
479 u64 evt_ring_base_addr;
480 void *evt_ring_base_vaddr;
481 u16 chan_ring_len;
482 u64 chan_ring_base_addr;
483 void *chan_ring_base_vaddr;
484};
485
486struct ipa3_status_stats {
487 struct ipahal_pkt_status status[IPA_MAX_STATUS_STAT_NUM];
Gidon Studinski3021a6f2016-11-10 12:48:48 +0200488 unsigned int curr;
Amir Levy9659e592016-10-27 18:08:27 +0300489};
490
491/**
492 * struct ipa3_ep_context - IPA end point context
493 * @valid: flag indicating id EP context is valid
494 * @client: EP client type
495 * @ep_hdl: EP's client SPS handle
496 * @gsi_chan_hdl: EP's GSI channel handle
497 * @gsi_evt_ring_hdl: EP's GSI channel event ring handle
498 * @gsi_mem_info: EP's GSI channel rings info
499 * @chan_scratch: EP's GSI channel scratch info
500 * @cfg: EP cionfiguration
501 * @dst_pipe_index: destination pipe index
502 * @rt_tbl_idx: routing table index
503 * @connect: SPS connect
504 * @priv: user provided information which will forwarded once the user is
505 * notified for new data avail
506 * @client_notify: user provided CB for EP events notification, the event is
507 * data revived.
508 * @desc_fifo_in_pipe_mem: flag indicating if descriptors FIFO uses pipe memory
509 * @data_fifo_in_pipe_mem: flag indicating if data FIFO uses pipe memory
510 * @desc_fifo_pipe_mem_ofst: descriptors FIFO pipe memory offset
511 * @data_fifo_pipe_mem_ofst: data FIFO pipe memory offset
512 * @desc_fifo_client_allocated: if descriptors FIFO was allocated by a client
513 * @data_fifo_client_allocated: if data FIFO was allocated by a client
514 * @skip_ep_cfg: boolean field that determines if EP should be configured
515 * by IPA driver
516 * @keep_ipa_awake: when true, IPA will not be clock gated
517 * @disconnect_in_progress: Indicates client disconnect in progress.
518 * @qmi_request_sent: Indicates whether QMI request to enable clear data path
519 * request is sent or not.
520 * @napi_enabled: when true, IPA call client callback to start polling
521 */
522struct ipa3_ep_context {
523 int valid;
524 enum ipa_client_type client;
525 struct sps_pipe *ep_hdl;
526 unsigned long gsi_chan_hdl;
527 unsigned long gsi_evt_ring_hdl;
528 struct ipa_gsi_ep_mem_info gsi_mem_info;
529 union __packed gsi_channel_scratch chan_scratch;
530 bool bytes_xfered_valid;
531 u16 bytes_xfered;
532 dma_addr_t phys_base;
533 struct ipa_ep_cfg cfg;
534 struct ipa_ep_cfg_holb holb;
535 struct ipahal_reg_ep_cfg_status status;
536 u32 dst_pipe_index;
537 u32 rt_tbl_idx;
538 struct sps_connect connect;
539 void *priv;
540 void (*client_notify)(void *priv, enum ipa_dp_evt_type evt,
541 unsigned long data);
542 bool desc_fifo_in_pipe_mem;
543 bool data_fifo_in_pipe_mem;
544 u32 desc_fifo_pipe_mem_ofst;
545 u32 data_fifo_pipe_mem_ofst;
546 bool desc_fifo_client_allocated;
547 bool data_fifo_client_allocated;
548 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;
558 bool switch_to_intr;
559 int inactive_cycles;
560 u32 eot_in_poll_err;
561
562 /* sys MUST be the last element of this struct */
563 struct ipa3_sys_context *sys;
564};
565
566/**
567 * ipa_usb_xdci_chan_params - xDCI channel related properties
568 *
569 * @ipa_ep_cfg: IPA EP configuration
570 * @client: type of "client"
571 * @priv: callback cookie
572 * @notify: callback
573 * priv - callback cookie evt - type of event data - data relevant
574 * to event. May not be valid. See event_type enum for valid
575 * cases.
576 * @skip_ep_cfg: boolean field that determines if EP should be
577 * configured by IPA driver
578 * @keep_ipa_awake: when true, IPA will not be clock gated
579 * @evt_ring_params: parameters for the channel's event ring
580 * @evt_scratch: parameters for the channel's event ring scratch
581 * @chan_params: parameters for the channel
582 * @chan_scratch: parameters for the channel's scratch
583 *
584 */
585struct ipa_request_gsi_channel_params {
586 struct ipa_ep_cfg ipa_ep_cfg;
587 enum ipa_client_type client;
588 void *priv;
589 ipa_notify_cb notify;
590 bool skip_ep_cfg;
591 bool keep_ipa_awake;
592 struct gsi_evt_ring_props evt_ring_params;
593 union __packed gsi_evt_scratch evt_scratch;
594 struct gsi_chan_props chan_params;
595 union __packed gsi_channel_scratch chan_scratch;
596};
597
598enum ipa3_sys_pipe_policy {
599 IPA_POLICY_INTR_MODE,
600 IPA_POLICY_NOINTR_MODE,
601 IPA_POLICY_INTR_POLL_MODE,
602};
603
604struct ipa3_repl_ctx {
605 struct ipa3_rx_pkt_wrapper **cache;
606 atomic_t head_idx;
607 atomic_t tail_idx;
608 u32 capacity;
609};
610
611/**
612 * struct ipa3_sys_context - IPA endpoint context for system to BAM pipes
613 * @head_desc_list: header descriptors list
614 * @len: the size of the above list
615 * @spinlock: protects the list and its size
616 * @event: used to request CALLBACK mode from SPS driver
617 * @ep: IPA EP context
618 *
619 * IPA context specific to the system-bam pipes a.k.a LAN IN/OUT and WAN
620 */
621struct ipa3_sys_context {
622 u32 len;
623 struct sps_register_event event;
624 atomic_t curr_polling_state;
625 struct delayed_work switch_to_intr_work;
626 enum ipa3_sys_pipe_policy policy;
627 int (*pyld_hdlr)(struct sk_buff *skb, struct ipa3_sys_context *sys);
628 struct sk_buff * (*get_skb)(unsigned int len, gfp_t flags);
629 void (*free_skb)(struct sk_buff *skb);
630 void (*free_rx_wrapper)(struct ipa3_rx_pkt_wrapper *rk_pkt);
631 u32 rx_buff_sz;
632 u32 rx_pool_sz;
633 struct sk_buff *prev_skb;
634 unsigned int len_rem;
635 unsigned int len_pad;
636 unsigned int len_partial;
637 bool drop_packet;
638 struct work_struct work;
639 void (*sps_callback)(struct sps_event_notify *notify);
640 enum sps_option sps_option;
641 struct delayed_work replenish_rx_work;
642 struct work_struct repl_work;
643 void (*repl_hdlr)(struct ipa3_sys_context *sys);
644 struct ipa3_repl_ctx repl;
645
646 /* ordering is important - mutable fields go above */
647 struct ipa3_ep_context *ep;
648 struct list_head head_desc_list;
649 struct list_head rcycl_list;
650 spinlock_t spinlock;
651 struct workqueue_struct *wq;
652 struct workqueue_struct *repl_wq;
653 struct ipa3_status_stats *status_stat;
654 /* ordering is important - other immutable fields go below */
655};
656
657/**
658 * enum ipa3_desc_type - IPA decriptors type
659 *
660 * IPA decriptors type, IPA supports DD and ICD but no CD
661 */
662enum ipa3_desc_type {
663 IPA_DATA_DESC,
664 IPA_DATA_DESC_SKB,
665 IPA_DATA_DESC_SKB_PAGED,
666 IPA_IMM_CMD_DESC,
667};
668
669/**
670 * struct ipa3_tx_pkt_wrapper - IPA Tx packet wrapper
671 * @type: specify if this packet is for the skb or immediate command
672 * @mem: memory buffer used by this Tx packet
673 * @work: work struct for current Tx packet
674 * @link: linked to the wrappers on that pipe
675 * @callback: IPA client provided callback
676 * @user1: cookie1 for above callback
677 * @user2: cookie2 for above callback
678 * @sys: corresponding IPA sys context
679 * @mult: valid only for first of a "multiple" transfer,
680 * holds info for the "sps_transfer" buffer
681 * @cnt: 1 for single transfers,
682 * >1 and <0xFFFF for first of a "multiple" transfer,
683 * 0xFFFF for last desc, 0 for rest of "multiple' transfer
684 * @bounce: va of bounce buffer
685 * @unmap_dma: in case this is true, the buffer will not be dma unmapped
686 *
687 * This struct can wrap both data packet and immediate command packet.
688 */
689struct ipa3_tx_pkt_wrapper {
690 enum ipa3_desc_type type;
691 struct ipa_mem_buffer mem;
692 struct work_struct work;
693 struct list_head link;
694 void (*callback)(void *user1, int user2);
695 void *user1;
696 int user2;
697 struct ipa3_sys_context *sys;
698 struct ipa_mem_buffer mult;
699 u32 cnt;
700 void *bounce;
701 bool no_unmap_dma;
702};
703
704/**
705 * struct ipa3_dma_xfer_wrapper - IPADMA transfer descr wrapper
706 * @phys_addr_src: physical address of the source data to copy
707 * @phys_addr_dest: physical address to store the copied data
708 * @len: len in bytes to copy
709 * @link: linked to the wrappers list on the proper(sync/async) cons pipe
710 * @xfer_done: completion object for sync_memcpy completion
711 * @callback: IPADMA client provided completion callback
712 * @user1: cookie1 for above callback
713 *
714 * This struct can wrap both sync and async memcpy transfers descriptors.
715 */
716struct ipa3_dma_xfer_wrapper {
717 u64 phys_addr_src;
718 u64 phys_addr_dest;
719 u16 len;
720 struct list_head link;
721 struct completion xfer_done;
722 void (*callback)(void *user1);
723 void *user1;
724};
725
726/**
727 * struct ipa3_desc - IPA descriptor
728 * @type: skb or immediate command or plain old data
729 * @pyld: points to skb
730 * @frag: points to paged fragment
731 * or kmalloc'ed immediate command parameters/plain old data
732 * @dma_address: dma mapped address of pyld
733 * @dma_address_valid: valid field for dma_address
734 * @len: length of the pyld
735 * @opcode: for immediate commands
736 * @callback: IPA client provided completion callback
737 * @user1: cookie1 for above callback
738 * @user2: cookie2 for above callback
739 * @xfer_done: completion object for sync completion
740 */
741struct ipa3_desc {
742 enum ipa3_desc_type type;
743 void *pyld;
744 skb_frag_t *frag;
745 dma_addr_t dma_address;
746 bool dma_address_valid;
747 u16 len;
748 u16 opcode;
749 void (*callback)(void *user1, int user2);
750 void *user1;
751 int user2;
752 struct completion xfer_done;
753};
754
755/**
756 * struct ipa3_rx_pkt_wrapper - IPA Rx packet wrapper
757 * @skb: skb
758 * @dma_address: DMA address of this Rx packet
759 * @link: linked to the Rx packets on that pipe
760 * @len: how many bytes are copied into skb's flat buffer
761 */
762struct ipa3_rx_pkt_wrapper {
763 struct list_head link;
764 struct ipa_rx_data data;
765 u32 len;
766 struct work_struct work;
767 struct ipa3_sys_context *sys;
768};
769
770/**
771 * struct ipa3_nat_mem - IPA NAT memory description
772 * @class: pointer to the struct class
773 * @dev: the dev_t of the device
774 * @cdev: cdev of the device
775 * @dev_num: device number
776 * @vaddr: virtual address
777 * @dma_handle: DMA handle
778 * @size: NAT memory size
779 * @is_mapped: flag indicating if NAT memory is mapped
780 * @is_sys_mem: flag indicating if NAT memory is sys memory
781 * @is_dev_init: flag indicating if NAT device is initialized
782 * @lock: NAT memory mutex
783 * @nat_base_address: nat table virutal address
784 * @ipv4_rules_addr: base nat table address
785 * @ipv4_expansion_rules_addr: expansion table address
786 * @index_table_addr: index table address
787 * @index_table_expansion_addr: index expansion table address
788 * @size_base_tables: base table size
789 * @size_expansion_tables: expansion table size
790 * @public_ip_addr: ip address of nat table
791 */
792struct ipa3_nat_mem {
793 struct class *class;
794 struct device *dev;
795 struct cdev cdev;
796 dev_t dev_num;
797 void *vaddr;
798 dma_addr_t dma_handle;
799 size_t size;
800 bool is_mapped;
801 bool is_sys_mem;
802 bool is_dev_init;
803 bool is_dev;
804 struct mutex lock;
805 void *nat_base_address;
806 char *ipv4_rules_addr;
807 char *ipv4_expansion_rules_addr;
808 char *index_table_addr;
809 char *index_table_expansion_addr;
810 u32 size_base_tables;
811 u32 size_expansion_tables;
812 u32 public_ip_addr;
813 void *tmp_vaddr;
814 dma_addr_t tmp_dma_handle;
815 bool is_tmp_mem;
816};
817
818/**
819 * enum ipa3_hw_mode - IPA hardware mode
820 * @IPA_HW_Normal: Regular IPA hardware
821 * @IPA_HW_Virtual: IPA hardware supporting virtual memory allocation
822 * @IPA_HW_PCIE: IPA hardware supporting memory allocation over PCIE Bridge
823 */
824enum ipa3_hw_mode {
825 IPA_HW_MODE_NORMAL = 0,
826 IPA_HW_MODE_VIRTUAL = 1,
827 IPA_HW_MODE_PCIE = 2
828};
829
830enum ipa3_config_this_ep {
831 IPA_CONFIGURE_THIS_EP,
832 IPA_DO_NOT_CONFIGURE_THIS_EP,
833};
834
835struct ipa3_stats {
836 u32 tx_sw_pkts;
837 u32 tx_hw_pkts;
838 u32 rx_pkts;
839 u32 rx_excp_pkts[IPAHAL_PKT_STATUS_EXCEPTION_MAX];
840 u32 rx_repl_repost;
841 u32 tx_pkts_compl;
842 u32 rx_q_len;
843 u32 msg_w[IPA_EVENT_MAX_NUM];
844 u32 msg_r[IPA_EVENT_MAX_NUM];
845 u32 stat_compl;
846 u32 aggr_close;
847 u32 wan_aggr_close;
848 u32 wan_rx_empty;
849 u32 wan_repl_rx_empty;
850 u32 lan_rx_empty;
851 u32 lan_repl_rx_empty;
852 u32 flow_enable;
853 u32 flow_disable;
854 u32 tx_non_linear;
855};
856
857struct ipa3_active_clients {
858 struct mutex mutex;
859 spinlock_t spinlock;
860 bool mutex_locked;
861 int cnt;
862};
863
864struct ipa3_wakelock_ref_cnt {
865 spinlock_t spinlock;
866 int cnt;
867};
868
869struct ipa3_tag_completion {
870 struct completion comp;
871 atomic_t cnt;
872};
873
874struct ipa3_controller;
875
876/**
877 * struct ipa3_uc_hdlrs - IPA uC callback functions
878 * @ipa_uc_loaded_hdlr: Function handler when uC is loaded
879 * @ipa_uc_event_hdlr: Event handler function
880 * @ipa3_uc_response_hdlr: Response handler function
881 * @ipa_uc_event_log_info_hdlr: Log event handler function
882 */
883struct ipa3_uc_hdlrs {
884 void (*ipa_uc_loaded_hdlr)(void);
885
886 void (*ipa_uc_event_hdlr)
887 (struct IpaHwSharedMemCommonMapping_t *uc_sram_mmio);
888
889 int (*ipa3_uc_response_hdlr)
890 (struct IpaHwSharedMemCommonMapping_t *uc_sram_mmio,
891 u32 *uc_status);
892
893 void (*ipa_uc_event_log_info_hdlr)
894 (struct IpaHwEventLogInfoData_t *uc_event_top_mmio);
895};
896
897/**
898 * enum ipa3_hw_flags - flags which defines the behavior of HW
899 *
900 * @IPA_HW_FLAG_HALT_SYSTEM_ON_ASSERT_FAILURE: Halt system in case of assert
901 * failure.
902 * @IPA_HW_FLAG_NO_REPORT_MHI_CHANNEL_ERORR: Channel error would be reported
903 * in the event ring only. No event to CPU.
904 * @IPA_HW_FLAG_NO_REPORT_MHI_CHANNEL_WAKE_UP: No need to report event
905 * IPA_HW_2_CPU_EVENT_MHI_WAKE_UP_REQUEST
906 * @IPA_HW_FLAG_WORK_OVER_DDR: Perform all transaction to external addresses by
907 * QMB (avoid memcpy)
908 * @IPA_HW_FLAG_NO_REPORT_OOB: If set do not report that the device is OOB in
909 * IN Channel
910 * @IPA_HW_FLAG_NO_REPORT_DB_MODE: If set, do not report that the device is
911 * entering a mode where it expects a doorbell to be rung for OUT Channel
912 * @IPA_HW_FLAG_NO_START_OOB_TIMER
913 */
914enum ipa3_hw_flags {
915 IPA_HW_FLAG_HALT_SYSTEM_ON_ASSERT_FAILURE = 0x01,
916 IPA_HW_FLAG_NO_REPORT_MHI_CHANNEL_ERORR = 0x02,
917 IPA_HW_FLAG_NO_REPORT_MHI_CHANNEL_WAKE_UP = 0x04,
918 IPA_HW_FLAG_WORK_OVER_DDR = 0x08,
919 IPA_HW_FLAG_NO_REPORT_OOB = 0x10,
920 IPA_HW_FLAG_NO_REPORT_DB_MODE = 0x20,
921 IPA_HW_FLAG_NO_START_OOB_TIMER = 0x40
922};
923
924/**
925 * struct ipa3_uc_ctx - IPA uC context
926 * @uc_inited: Indicates if uC interface has been initialized
927 * @uc_loaded: Indicates if uC has loaded
928 * @uc_failed: Indicates if uC has failed / returned an error
929 * @uc_lock: uC interface lock to allow only one uC interaction at a time
930 * @uc_spinlock: same as uc_lock but for irq contexts
931 * @uc_completation: Completion mechanism to wait for uC commands
932 * @uc_sram_mmio: Pointer to uC mapped memory
933 * @pending_cmd: The last command sent waiting to be ACKed
934 * @uc_status: The last status provided by the uC
935 * @uc_error_type: error type from uC error event
936 * @uc_error_timestamp: tag timer sampled after uC crashed
937 */
938struct ipa3_uc_ctx {
939 bool uc_inited;
940 bool uc_loaded;
941 bool uc_failed;
942 struct mutex uc_lock;
943 spinlock_t uc_spinlock;
944 struct completion uc_completion;
945 struct IpaHwSharedMemCommonMapping_t *uc_sram_mmio;
946 struct IpaHwEventLogInfoData_t *uc_event_top_mmio;
947 u32 uc_event_top_ofst;
948 u32 pending_cmd;
949 u32 uc_status;
950 u32 uc_error_type;
951 u32 uc_error_timestamp;
952 phys_addr_t rdy_ring_base_pa;
953 phys_addr_t rdy_ring_rp_pa;
954 u32 rdy_ring_size;
955 phys_addr_t rdy_comp_ring_base_pa;
956 phys_addr_t rdy_comp_ring_wp_pa;
957 u32 rdy_comp_ring_size;
958 u32 *rdy_ring_rp_va;
959 u32 *rdy_comp_ring_wp_va;
960};
961
962/**
963 * struct ipa3_uc_wdi_ctx
964 * @wdi_uc_top_ofst:
965 * @wdi_uc_top_mmio:
966 * @wdi_uc_stats_ofst:
967 * @wdi_uc_stats_mmio:
968 */
969struct ipa3_uc_wdi_ctx {
970 /* WDI specific fields */
971 u32 wdi_uc_stats_ofst;
972 struct IpaHwStatsWDIInfoData_t *wdi_uc_stats_mmio;
973 void *priv;
974 ipa_uc_ready_cb uc_ready_cb;
975};
976
977/**
978 * struct ipa3_transport_pm - transport power management related members
979 * @lock: lock for ensuring atomic operations
980 * @res_granted: true if SPS requested IPA resource and IPA granted it
981 * @res_rel_in_prog: true if releasing IPA resource is in progress
982 */
983struct ipa3_transport_pm {
984 spinlock_t lock;
985 bool res_granted;
986 bool res_rel_in_prog;
987 atomic_t dec_clients;
988 atomic_t eot_activity;
989};
990
991/**
992 * struct ipa3cm_client_info - the client-info indicated from IPACM
993 * @ipacm_client_enum: the enum to indicate tether-client
994 * @ipacm_client_uplink: the bool to indicate pipe for uplink
995 */
996struct ipa3cm_client_info {
997 enum ipacm_client_enum client_enum;
998 bool uplink;
999};
1000
1001struct ipa3_smp2p_info {
1002 u32 out_base_id;
1003 u32 in_base_id;
1004 bool res_sent;
1005};
1006
1007/**
1008 * struct ipa3_ready_cb_info - A list of all the registrations
1009 * for an indication of IPA driver readiness
1010 *
1011 * @link: linked list link
1012 * @ready_cb: callback
1013 * @user_data: User data
1014 *
1015 */
1016struct ipa3_ready_cb_info {
1017 struct list_head link;
1018 ipa_ready_cb ready_cb;
1019 void *user_data;
1020};
1021
Gidon Studinski3021a6f2016-11-10 12:48:48 +02001022struct ipa_tz_unlock_reg_info {
1023 u64 reg_addr;
1024 u32 size;
1025};
1026
Amir Levy9659e592016-10-27 18:08:27 +03001027/**
1028 * struct ipa3_context - IPA context
1029 * @class: pointer to the struct class
1030 * @dev_num: device number
1031 * @dev: the dev_t of the device
1032 * @cdev: cdev of the device
1033 * @bam_handle: IPA driver's BAM handle
1034 * @ep: list of all end points
1035 * @skip_ep_cfg_shadow: state to update filter table correctly across
1036 power-save
1037 * @ep_flt_bitmap: End-points supporting filtering bitmap
1038 * @ep_flt_num: End-points supporting filtering number
1039 * @resume_on_connect: resume ep on ipa3_connect
1040 * @flt_tbl: list of all IPA filter tables
1041 * @mode: IPA operating mode
1042 * @mmio: iomem
1043 * @ipa_wrapper_base: IPA wrapper base address
1044 * @hdr_tbl: IPA header table
1045 * @hdr_proc_ctx_tbl: IPA processing context table
1046 * @rt_tbl_set: list of routing tables each of which is a list of rules
1047 * @reap_rt_tbl_set: list of sys mem routing tables waiting to be reaped
1048 * @flt_rule_cache: filter rule cache
1049 * @rt_rule_cache: routing rule cache
1050 * @hdr_cache: header cache
1051 * @hdr_offset_cache: header offset cache
1052 * @hdr_proc_ctx_cache: processing context cache
1053 * @hdr_proc_ctx_offset_cache: processing context offset cache
1054 * @rt_tbl_cache: routing table cache
1055 * @tx_pkt_wrapper_cache: Tx packets cache
1056 * @rx_pkt_wrapper_cache: Rx packets cache
1057 * @rt_idx_bitmap: routing table index bitmap
1058 * @lock: this does NOT protect the linked lists within ipa3_sys_context
1059 * @smem_sz: shared memory size available for SW use starting
1060 * from non-restricted bytes
1061 * @smem_restricted_bytes: the bytes that SW should not use in the shared mem
1062 * @nat_mem: NAT memory
1063 * @excp_hdr_hdl: exception header handle
1064 * @dflt_v4_rt_rule_hdl: default v4 routing rule handle
1065 * @dflt_v6_rt_rule_hdl: default v6 routing rule handle
1066 * @aggregation_type: aggregation type used on USB client endpoint
1067 * @aggregation_byte_limit: aggregation byte limit used on USB client endpoint
1068 * @aggregation_time_limit: aggregation time limit used on USB client endpoint
1069 * @hdr_tbl_lcl: where hdr tbl resides 1-local, 0-system
1070 * @hdr_proc_ctx_tbl_lcl: where proc_ctx tbl resides true-local, false-system
1071 * @hdr_mem: header memory
1072 * @hdr_proc_ctx_mem: processing context memory
1073 * @ip4_rt_tbl_lcl: where ip4 rt tables reside 1-local; 0-system
1074 * @ip6_rt_tbl_lcl: where ip6 rt tables reside 1-local; 0-system
1075 * @ip4_flt_tbl_lcl: where ip4 flt tables reside 1-local; 0-system
1076 * @ip6_flt_tbl_lcl: where ip6 flt tables reside 1-local; 0-system
1077 * @power_mgmt_wq: workqueue for power management
1078 * @transport_power_mgmt_wq: workqueue transport related power management
1079 * @tag_process_before_gating: indicates whether to start tag process before
1080 * gating IPA clocks
1081 * @transport_pm: transport power management related information
1082 * @disconnect_lock: protects LAN_CONS packet receive notification CB
1083 * @pipe_mem_pool: pipe memory pool
1084 * @dma_pool: special purpose DMA pool
1085 * @ipa3_active_clients: structure for reference counting connected IPA clients
1086 * @ipa_hw_type: type of IPA HW type (e.g. IPA 1.0, IPA 1.1 etc')
1087 * @ipa3_hw_mode: mode of IPA HW mode (e.g. Normal, Virtual or over PCIe)
1088 * @use_ipa_teth_bridge: use tethering bridge driver
1089 * @ipa_bam_remote_mode: ipa bam is in remote mode
1090 * @modem_cfg_emb_pipe_flt: modem configure embedded pipe filtering rules
1091 * @logbuf: ipc log buffer for high priority messages
1092 * @logbuf_low: ipc log buffer for low priority messages
1093 * @ipa_wdi2: using wdi-2.0
1094 * @use_64_bit_dma_mask: using 64bits dma mask
1095 * @ipa_bus_hdl: msm driver handle for the data path bus
1096 * @ctrl: holds the core specific operations based on
1097 * core version (vtable like)
1098 * @enable_clock_scaling: clock scaling is enabled ?
1099 * @curr_ipa_clk_rate: ipa3_clk current rate
1100 * @wcstats: wlan common buffer stats
1101 * @uc_ctx: uC interface context
1102 * @uc_wdi_ctx: WDI specific fields for uC interface
1103 * @ipa_num_pipes: The number of pipes used by IPA HW
1104 * @skip_uc_pipe_reset: Indicates whether pipe reset via uC needs to be avoided
1105 * @ipa_client_apps_wan_cons_agg_gro: RMNET_IOCTL_INGRESS_FORMAT_AGG_DATA
1106 * @apply_rg10_wa: Indicates whether to use register group 10 workaround
1107 * @gsi_ch20_wa: Indicates whether to apply GSI physical channel 20 workaround
1108 * @w_lock: Indicates the wakeup source.
1109 * @wakelock_ref_cnt: Indicates the number of times wakelock is acquired
1110 * @ipa_initialization_complete: Indicates that IPA is fully initialized
1111 * @ipa_ready_cb_list: A list of all the clients who require a CB when IPA
1112 * driver is ready/initialized.
1113 * @init_completion_obj: Completion object to be used in case IPA driver hasn't
1114 * finished initializing. Example of use - IOCTLs to /dev/ipa
1115 * IPA context - holds all relevant info about IPA driver and its state
1116 */
1117struct ipa3_context {
1118 struct class *class;
1119 dev_t dev_num;
1120 struct device *dev;
1121 struct cdev cdev;
1122 unsigned long bam_handle;
1123 struct ipa3_ep_context ep[IPA3_MAX_NUM_PIPES];
1124 bool skip_ep_cfg_shadow[IPA3_MAX_NUM_PIPES];
1125 u32 ep_flt_bitmap;
1126 u32 ep_flt_num;
1127 bool resume_on_connect[IPA_CLIENT_MAX];
1128 struct ipa3_flt_tbl flt_tbl[IPA3_MAX_NUM_PIPES][IPA_IP_MAX];
1129 void __iomem *mmio;
1130 u32 ipa_wrapper_base;
1131 u32 ipa_wrapper_size;
1132 struct ipa3_hdr_tbl hdr_tbl;
1133 struct ipa3_hdr_proc_ctx_tbl hdr_proc_ctx_tbl;
1134 struct ipa3_rt_tbl_set rt_tbl_set[IPA_IP_MAX];
1135 struct ipa3_rt_tbl_set reap_rt_tbl_set[IPA_IP_MAX];
1136 struct kmem_cache *flt_rule_cache;
1137 struct kmem_cache *rt_rule_cache;
1138 struct kmem_cache *hdr_cache;
1139 struct kmem_cache *hdr_offset_cache;
1140 struct kmem_cache *hdr_proc_ctx_cache;
1141 struct kmem_cache *hdr_proc_ctx_offset_cache;
1142 struct kmem_cache *rt_tbl_cache;
1143 struct kmem_cache *tx_pkt_wrapper_cache;
1144 struct kmem_cache *rx_pkt_wrapper_cache;
1145 unsigned long rt_idx_bitmap[IPA_IP_MAX];
1146 struct mutex lock;
1147 u16 smem_sz;
1148 u16 smem_restricted_bytes;
1149 u16 smem_reqd_sz;
1150 struct ipa3_nat_mem nat_mem;
1151 u32 excp_hdr_hdl;
1152 u32 dflt_v4_rt_rule_hdl;
1153 u32 dflt_v6_rt_rule_hdl;
1154 uint aggregation_type;
1155 uint aggregation_byte_limit;
1156 uint aggregation_time_limit;
1157 bool hdr_tbl_lcl;
1158 bool hdr_proc_ctx_tbl_lcl;
1159 struct ipa_mem_buffer hdr_mem;
1160 struct ipa_mem_buffer hdr_proc_ctx_mem;
1161 bool ip4_rt_tbl_hash_lcl;
1162 bool ip4_rt_tbl_nhash_lcl;
1163 bool ip6_rt_tbl_hash_lcl;
1164 bool ip6_rt_tbl_nhash_lcl;
1165 bool ip4_flt_tbl_hash_lcl;
1166 bool ip4_flt_tbl_nhash_lcl;
1167 bool ip6_flt_tbl_hash_lcl;
1168 bool ip6_flt_tbl_nhash_lcl;
1169 struct gen_pool *pipe_mem_pool;
1170 struct dma_pool *dma_pool;
1171 struct ipa3_active_clients ipa3_active_clients;
1172 struct ipa3_active_clients_log_ctx ipa3_active_clients_logging;
1173 struct workqueue_struct *power_mgmt_wq;
1174 struct workqueue_struct *transport_power_mgmt_wq;
1175 bool tag_process_before_gating;
1176 struct ipa3_transport_pm transport_pm;
1177 u32 clnt_hdl_cmd;
1178 u32 clnt_hdl_data_in;
1179 u32 clnt_hdl_data_out;
1180 spinlock_t disconnect_lock;
1181 u8 a5_pipe_index;
1182 struct list_head intf_list;
1183 struct list_head msg_list;
1184 struct list_head pull_msg_list;
1185 struct mutex msg_lock;
1186 wait_queue_head_t msg_waitq;
1187 enum ipa_hw_type ipa_hw_type;
1188 enum ipa3_hw_mode ipa3_hw_mode;
1189 bool use_ipa_teth_bridge;
1190 bool ipa_bam_remote_mode;
1191 bool modem_cfg_emb_pipe_flt;
1192 bool ipa_wdi2;
1193 bool use_64_bit_dma_mask;
1194 /* featurize if memory footprint becomes a concern */
1195 struct ipa3_stats stats;
1196 void *smem_pipe_mem;
1197 void *logbuf;
1198 void *logbuf_low;
1199 u32 ipa_bus_hdl;
1200 struct ipa3_controller *ctrl;
1201 struct idr ipa_idr;
1202 struct device *pdev;
1203 struct device *uc_pdev;
1204 spinlock_t idr_lock;
1205 u32 enable_clock_scaling;
1206 u32 curr_ipa_clk_rate;
1207 bool q6_proxy_clk_vote_valid;
1208 u32 ipa_num_pipes;
1209
1210 struct ipa3_wlan_comm_memb wc_memb;
1211
1212 struct ipa3_uc_ctx uc_ctx;
1213
1214 struct ipa3_uc_wdi_ctx uc_wdi_ctx;
1215 struct ipa3_uc_ntn_ctx uc_ntn_ctx;
1216 u32 wan_rx_ring_size;
1217 u32 lan_rx_ring_size;
1218 bool skip_uc_pipe_reset;
1219 enum ipa_transport_type transport_prototype;
1220 unsigned long gsi_dev_hdl;
1221 u32 ee;
1222 bool apply_rg10_wa;
1223 bool gsi_ch20_wa;
1224 bool smmu_present;
1225 bool smmu_s1_bypass;
1226 unsigned long peer_bam_iova;
1227 phys_addr_t peer_bam_pa;
1228 u32 peer_bam_map_size;
1229 unsigned long peer_bam_dev;
1230 u32 peer_bam_map_cnt;
1231 u32 wdi_map_cnt;
1232 struct wakeup_source w_lock;
1233 struct ipa3_wakelock_ref_cnt wakelock_ref_cnt;
1234 /* RMNET_IOCTL_INGRESS_FORMAT_AGG_DATA */
1235 bool ipa_client_apps_wan_cons_agg_gro;
1236 /* M-release support to know client pipes */
1237 struct ipa3cm_client_info ipacm_client[IPA3_MAX_NUM_PIPES];
1238 bool tethered_flow_control;
1239 bool ipa_initialization_complete;
1240 struct list_head ipa_ready_cb_list;
1241 struct completion init_completion_obj;
Skylar Chang0c17c7d2016-10-31 09:57:54 -07001242 struct completion uc_loaded_completion_obj;
Amir Levy9659e592016-10-27 18:08:27 +03001243 struct ipa3_smp2p_info smp2p_info;
Gidon Studinski3021a6f2016-11-10 12:48:48 +02001244 u32 ipa_tz_unlock_reg_num;
1245 struct ipa_tz_unlock_reg_info *ipa_tz_unlock_reg;
Amir Levy9659e592016-10-27 18:08:27 +03001246};
1247
1248/**
1249 * enum ipa3_pipe_mem_type - IPA pipe memory type
1250 * @IPA_SPS_PIPE_MEM: Default, SPS dedicated pipe memory
1251 * @IPA_PRIVATE_MEM: IPA's private memory
1252 * @IPA_SYSTEM_MEM: System RAM, requires allocation
1253 */
1254enum ipa3_pipe_mem_type {
1255 IPA_SPS_PIPE_MEM = 0,
1256 IPA_PRIVATE_MEM = 1,
1257 IPA_SYSTEM_MEM = 2,
1258};
1259
1260struct ipa3_plat_drv_res {
1261 bool use_ipa_teth_bridge;
1262 u32 ipa_mem_base;
1263 u32 ipa_mem_size;
1264 u32 transport_mem_base;
1265 u32 transport_mem_size;
1266 u32 ipa_irq;
1267 u32 transport_irq;
1268 u32 ipa_pipe_mem_start_ofst;
1269 u32 ipa_pipe_mem_size;
1270 enum ipa_hw_type ipa_hw_type;
1271 enum ipa3_hw_mode ipa3_hw_mode;
1272 u32 ee;
1273 bool ipa_bam_remote_mode;
1274 bool modem_cfg_emb_pipe_flt;
1275 bool ipa_wdi2;
1276 bool use_64_bit_dma_mask;
1277 u32 wan_rx_ring_size;
1278 u32 lan_rx_ring_size;
1279 bool skip_uc_pipe_reset;
1280 enum ipa_transport_type transport_prototype;
1281 bool apply_rg10_wa;
1282 bool gsi_ch20_wa;
1283 bool tethered_flow_control;
Gidon Studinski3021a6f2016-11-10 12:48:48 +02001284 u32 ipa_tz_unlock_reg_num;
1285 struct ipa_tz_unlock_reg_info *ipa_tz_unlock_reg;
Amir Levy9659e592016-10-27 18:08:27 +03001286};
1287
1288/**
1289 * struct ipa3_mem_partition - represents IPA RAM Map as read from DTS
1290 * Order and type of members should not be changed without a suitable change
1291 * to DTS file or the code that reads it.
1292 *
1293 * IPA v3.0 SRAM memory layout:
1294 * +-------------------------+
1295 * | UC INFO |
1296 * +-------------------------+
1297 * | CANARY |
1298 * +-------------------------+
1299 * | CANARY |
1300 * +-------------------------+
1301 * | V4 FLT HDR HASHABLE |
1302 * +-------------------------+
1303 * | CANARY |
1304 * +-------------------------+
1305 * | CANARY |
1306 * +-------------------------+
1307 * | V4 FLT HDR NON-HASHABLE |
1308 * +-------------------------+
1309 * | CANARY |
1310 * +-------------------------+
1311 * | CANARY |
1312 * +-------------------------+
1313 * | V6 FLT HDR HASHABLE |
1314 * +-------------------------+
1315 * | CANARY |
1316 * +-------------------------+
1317 * | CANARY |
1318 * +-------------------------+
1319 * | V6 FLT HDR NON-HASHABLE |
1320 * +-------------------------+
1321 * | CANARY |
1322 * +-------------------------+
1323 * | CANARY |
1324 * +-------------------------+
1325 * | V4 RT HDR HASHABLE |
1326 * +-------------------------+
1327 * | CANARY |
1328 * +-------------------------+
1329 * | CANARY |
1330 * +-------------------------+
1331 * | V4 RT HDR NON-HASHABLE |
1332 * +-------------------------+
1333 * | CANARY |
1334 * +-------------------------+
1335 * | CANARY |
1336 * +-------------------------+
1337 * | V6 RT HDR HASHABLE |
1338 * +-------------------------+
1339 * | CANARY |
1340 * +-------------------------+
1341 * | CANARY |
1342 * +-------------------------+
1343 * | V6 RT HDR NON-HASHABLE |
1344 * +-------------------------+
1345 * | CANARY |
1346 * +-------------------------+
1347 * | CANARY |
1348 * +-------------------------+
1349 * | MODEM HDR |
1350 * +-------------------------+
1351 * | CANARY |
1352 * +-------------------------+
1353 * | CANARY |
1354 * +-------------------------+
1355 * | MODEM PROC CTX |
1356 * +-------------------------+
1357 * | APPS PROC CTX |
1358 * +-------------------------+
1359 * | CANARY |
1360 * +-------------------------+
1361 * | MODEM MEM |
1362 * +-------------------------+
1363 * | CANARY |
1364 * +-------------------------+
1365 */
1366struct ipa3_mem_partition {
1367 u32 ofst_start;
1368 u32 nat_ofst;
1369 u32 nat_size;
1370 u32 v4_flt_hash_ofst;
1371 u32 v4_flt_hash_size;
1372 u32 v4_flt_hash_size_ddr;
1373 u32 v4_flt_nhash_ofst;
1374 u32 v4_flt_nhash_size;
1375 u32 v4_flt_nhash_size_ddr;
1376 u32 v6_flt_hash_ofst;
1377 u32 v6_flt_hash_size;
1378 u32 v6_flt_hash_size_ddr;
1379 u32 v6_flt_nhash_ofst;
1380 u32 v6_flt_nhash_size;
1381 u32 v6_flt_nhash_size_ddr;
1382 u32 v4_rt_num_index;
1383 u32 v4_modem_rt_index_lo;
1384 u32 v4_modem_rt_index_hi;
1385 u32 v4_apps_rt_index_lo;
1386 u32 v4_apps_rt_index_hi;
1387 u32 v4_rt_hash_ofst;
1388 u32 v4_rt_hash_size;
1389 u32 v4_rt_hash_size_ddr;
1390 u32 v4_rt_nhash_ofst;
1391 u32 v4_rt_nhash_size;
1392 u32 v4_rt_nhash_size_ddr;
1393 u32 v6_rt_num_index;
1394 u32 v6_modem_rt_index_lo;
1395 u32 v6_modem_rt_index_hi;
1396 u32 v6_apps_rt_index_lo;
1397 u32 v6_apps_rt_index_hi;
1398 u32 v6_rt_hash_ofst;
1399 u32 v6_rt_hash_size;
1400 u32 v6_rt_hash_size_ddr;
1401 u32 v6_rt_nhash_ofst;
1402 u32 v6_rt_nhash_size;
1403 u32 v6_rt_nhash_size_ddr;
1404 u32 modem_hdr_ofst;
1405 u32 modem_hdr_size;
1406 u32 apps_hdr_ofst;
1407 u32 apps_hdr_size;
1408 u32 apps_hdr_size_ddr;
1409 u32 modem_hdr_proc_ctx_ofst;
1410 u32 modem_hdr_proc_ctx_size;
1411 u32 apps_hdr_proc_ctx_ofst;
1412 u32 apps_hdr_proc_ctx_size;
1413 u32 apps_hdr_proc_ctx_size_ddr;
1414 u32 modem_comp_decomp_ofst;
1415 u32 modem_comp_decomp_size;
1416 u32 modem_ofst;
1417 u32 modem_size;
1418 u32 apps_v4_flt_hash_ofst;
1419 u32 apps_v4_flt_hash_size;
1420 u32 apps_v4_flt_nhash_ofst;
1421 u32 apps_v4_flt_nhash_size;
1422 u32 apps_v6_flt_hash_ofst;
1423 u32 apps_v6_flt_hash_size;
1424 u32 apps_v6_flt_nhash_ofst;
1425 u32 apps_v6_flt_nhash_size;
1426 u32 uc_info_ofst;
1427 u32 uc_info_size;
1428 u32 end_ofst;
1429 u32 apps_v4_rt_hash_ofst;
1430 u32 apps_v4_rt_hash_size;
1431 u32 apps_v4_rt_nhash_ofst;
1432 u32 apps_v4_rt_nhash_size;
1433 u32 apps_v6_rt_hash_ofst;
1434 u32 apps_v6_rt_hash_size;
1435 u32 apps_v6_rt_nhash_ofst;
1436 u32 apps_v6_rt_nhash_size;
1437};
1438
1439struct ipa3_controller {
1440 struct ipa3_mem_partition mem_partition;
1441 u32 ipa_clk_rate_turbo;
1442 u32 ipa_clk_rate_nominal;
1443 u32 ipa_clk_rate_svs;
1444 u32 clock_scaling_bw_threshold_turbo;
1445 u32 clock_scaling_bw_threshold_nominal;
1446 u32 ipa_reg_base_ofst;
1447 u32 max_holb_tmr_val;
1448 void (*ipa_sram_read_settings)(void);
1449 int (*ipa_init_sram)(void);
1450 int (*ipa_init_hdr)(void);
1451 int (*ipa_init_rt4)(void);
1452 int (*ipa_init_rt6)(void);
1453 int (*ipa_init_flt4)(void);
1454 int (*ipa_init_flt6)(void);
1455 int (*ipa3_read_ep_reg)(char *buff, int max_len, int pipe);
1456 int (*ipa3_commit_flt)(enum ipa_ip_type ip);
1457 int (*ipa3_commit_rt)(enum ipa_ip_type ip);
1458 int (*ipa3_commit_hdr)(void);
1459 void (*ipa3_enable_clks)(void);
1460 void (*ipa3_disable_clks)(void);
1461 struct msm_bus_scale_pdata *msm_bus_data_ptr;
1462};
1463
1464extern struct ipa3_context *ipa3_ctx;
1465
1466/* public APIs */
1467/*
1468 * Connect / Disconnect
1469 */
1470int ipa3_connect(const struct ipa_connect_params *in,
1471 struct ipa_sps_params *sps,
1472 u32 *clnt_hdl);
1473int ipa3_disconnect(u32 clnt_hdl);
1474
1475/* Generic GSI channels functions */
1476int ipa3_request_gsi_channel(struct ipa_request_gsi_channel_params *params,
1477 struct ipa_req_chan_out_params *out_params);
1478
1479int ipa3_release_gsi_channel(u32 clnt_hdl);
1480
1481int ipa3_start_gsi_channel(u32 clnt_hdl);
1482
1483int ipa3_stop_gsi_channel(u32 clnt_hdl);
1484
1485int ipa3_reset_gsi_channel(u32 clnt_hdl);
1486
1487int ipa3_reset_gsi_event_ring(u32 clnt_hdl);
1488
1489/* Specific xDCI channels functions */
1490int ipa3_set_usb_max_packet_size(
1491 enum ipa_usb_max_usb_packet_size usb_max_packet_size);
1492
Ghanim Fodi93a61112016-10-05 11:59:18 +03001493int ipa3_xdci_start(u32 clnt_hdl, u8 xferrscidx, bool xferrscidx_valid);
1494
1495int ipa3_xdci_connect(u32 clnt_hdl);
Amir Levy9659e592016-10-27 18:08:27 +03001496
1497int ipa3_xdci_disconnect(u32 clnt_hdl, bool should_force_clear, u32 qmi_req_id);
1498
1499int ipa3_xdci_suspend(u32 ul_clnt_hdl, u32 dl_clnt_hdl,
1500 bool should_force_clear, u32 qmi_req_id, bool is_dpl);
1501
1502int ipa3_xdci_resume(u32 ul_clnt_hdl, u32 dl_clnt_hdl, bool is_dpl);
1503
1504/*
1505 * Resume / Suspend
1506 */
1507int ipa3_reset_endpoint(u32 clnt_hdl);
1508
1509/*
1510 * Remove ep delay
1511 */
1512int ipa3_clear_endpoint_delay(u32 clnt_hdl);
1513
1514/*
1515 * Configuration
1516 */
1517int ipa3_cfg_ep(u32 clnt_hdl, const struct ipa_ep_cfg *ipa_ep_cfg);
1518
1519int ipa3_cfg_ep_nat(u32 clnt_hdl, const struct ipa_ep_cfg_nat *ipa_ep_cfg);
1520
1521int ipa3_cfg_ep_hdr(u32 clnt_hdl, const struct ipa_ep_cfg_hdr *ipa_ep_cfg);
1522
1523int ipa3_cfg_ep_hdr_ext(u32 clnt_hdl,
1524 const struct ipa_ep_cfg_hdr_ext *ipa_ep_cfg);
1525
1526int ipa3_cfg_ep_mode(u32 clnt_hdl, const struct ipa_ep_cfg_mode *ipa_ep_cfg);
1527
1528int ipa3_cfg_ep_aggr(u32 clnt_hdl, const struct ipa_ep_cfg_aggr *ipa_ep_cfg);
1529
1530int ipa3_cfg_ep_deaggr(u32 clnt_hdl,
1531 const struct ipa_ep_cfg_deaggr *ipa_ep_cfg);
1532
1533int ipa3_cfg_ep_route(u32 clnt_hdl, const struct ipa_ep_cfg_route *ipa_ep_cfg);
1534
1535int ipa3_cfg_ep_holb(u32 clnt_hdl, const struct ipa_ep_cfg_holb *ipa_ep_cfg);
1536
1537int ipa3_cfg_ep_cfg(u32 clnt_hdl, const struct ipa_ep_cfg_cfg *ipa_ep_cfg);
1538
1539int ipa3_cfg_ep_metadata_mask(u32 clnt_hdl,
1540 const struct ipa_ep_cfg_metadata_mask *ipa_ep_cfg);
1541
1542int ipa3_cfg_ep_holb_by_client(enum ipa_client_type client,
1543 const struct ipa_ep_cfg_holb *ipa_ep_cfg);
1544
1545int ipa3_cfg_ep_ctrl(u32 clnt_hdl, const struct ipa_ep_cfg_ctrl *ep_ctrl);
1546
1547/*
1548 * Header removal / addition
1549 */
1550int ipa3_add_hdr(struct ipa_ioc_add_hdr *hdrs);
1551
1552int ipa3_del_hdr(struct ipa_ioc_del_hdr *hdls);
1553
Ghanim Fodi2c8ba072017-01-12 15:14:15 +02001554int ipa3_del_hdr_by_user(struct ipa_ioc_del_hdr *hdls, bool by_user);
1555
Amir Levy9659e592016-10-27 18:08:27 +03001556int ipa3_commit_hdr(void);
1557
1558int ipa3_reset_hdr(void);
1559
1560int ipa3_get_hdr(struct ipa_ioc_get_hdr *lookup);
1561
1562int ipa3_put_hdr(u32 hdr_hdl);
1563
1564int ipa3_copy_hdr(struct ipa_ioc_copy_hdr *copy);
1565
1566/*
1567 * Header Processing Context
1568 */
1569int ipa3_add_hdr_proc_ctx(struct ipa_ioc_add_hdr_proc_ctx *proc_ctxs);
1570
1571int ipa3_del_hdr_proc_ctx(struct ipa_ioc_del_hdr_proc_ctx *hdls);
1572
Ghanim Fodi2c8ba072017-01-12 15:14:15 +02001573int ipa3_del_hdr_proc_ctx_by_user(struct ipa_ioc_del_hdr_proc_ctx *hdls,
1574 bool by_user);
1575
Amir Levy9659e592016-10-27 18:08:27 +03001576/*
1577 * Routing
1578 */
1579int ipa3_add_rt_rule(struct ipa_ioc_add_rt_rule *rules);
1580
1581int ipa3_add_rt_rule_after(struct ipa_ioc_add_rt_rule_after *rules);
1582
1583int ipa3_del_rt_rule(struct ipa_ioc_del_rt_rule *hdls);
1584
1585int ipa3_commit_rt(enum ipa_ip_type ip);
1586
1587int ipa3_reset_rt(enum ipa_ip_type ip);
1588
1589int ipa3_get_rt_tbl(struct ipa_ioc_get_rt_tbl *lookup);
1590
1591int ipa3_put_rt_tbl(u32 rt_tbl_hdl);
1592
1593int ipa3_query_rt_index(struct ipa_ioc_get_rt_tbl_indx *in);
1594
1595int ipa3_mdfy_rt_rule(struct ipa_ioc_mdfy_rt_rule *rules);
1596
1597/*
1598 * Filtering
1599 */
1600int ipa3_add_flt_rule(struct ipa_ioc_add_flt_rule *rules);
1601
1602int ipa3_add_flt_rule_after(struct ipa_ioc_add_flt_rule_after *rules);
1603
1604int ipa3_del_flt_rule(struct ipa_ioc_del_flt_rule *hdls);
1605
1606int ipa3_mdfy_flt_rule(struct ipa_ioc_mdfy_flt_rule *rules);
1607
1608int ipa3_commit_flt(enum ipa_ip_type ip);
1609
1610int ipa3_reset_flt(enum ipa_ip_type ip);
1611
1612/*
1613 * NAT
1614 */
1615int ipa3_allocate_nat_device(struct ipa_ioc_nat_alloc_mem *mem);
1616
1617int ipa3_nat_init_cmd(struct ipa_ioc_v4_nat_init *init);
1618
1619int ipa3_nat_dma_cmd(struct ipa_ioc_nat_dma_cmd *dma);
1620
1621int ipa3_nat_del_cmd(struct ipa_ioc_v4_nat_del *del);
1622
1623/*
1624 * Messaging
1625 */
1626int ipa3_send_msg(struct ipa_msg_meta *meta, void *buff,
1627 ipa_msg_free_fn callback);
1628int ipa3_register_pull_msg(struct ipa_msg_meta *meta, ipa_msg_pull_fn callback);
1629int ipa3_deregister_pull_msg(struct ipa_msg_meta *meta);
1630
1631/*
1632 * Interface
1633 */
1634int ipa3_register_intf(const char *name, const struct ipa_tx_intf *tx,
1635 const struct ipa_rx_intf *rx);
1636int ipa3_register_intf_ext(const char *name, const struct ipa_tx_intf *tx,
1637 const struct ipa_rx_intf *rx,
1638 const struct ipa_ext_intf *ext);
1639int ipa3_deregister_intf(const char *name);
1640
1641/*
1642 * Aggregation
1643 */
1644int ipa3_set_aggr_mode(enum ipa_aggr_mode mode);
1645
1646int ipa3_set_qcncm_ndp_sig(char sig[3]);
1647
1648int ipa3_set_single_ndp_per_mbim(bool enable);
1649
1650/*
1651 * Data path
1652 */
1653int ipa3_tx_dp(enum ipa_client_type dst, struct sk_buff *skb,
1654 struct ipa_tx_meta *metadata);
1655
1656/*
1657 * To transfer multiple data packets
1658 * While passing the data descriptor list, the anchor node
1659 * should be of type struct ipa_tx_data_desc not list_head
1660*/
1661int ipa3_tx_dp_mul(enum ipa_client_type dst,
1662 struct ipa_tx_data_desc *data_desc);
1663
1664void ipa3_free_skb(struct ipa_rx_data *);
1665
1666/*
1667 * System pipes
1668 */
1669int ipa3_setup_sys_pipe(struct ipa_sys_connect_params *sys_in, u32 *clnt_hdl);
1670
1671int ipa3_teardown_sys_pipe(u32 clnt_hdl);
1672
1673int ipa3_sys_setup(struct ipa_sys_connect_params *sys_in,
1674 unsigned long *ipa_bam_hdl,
1675 u32 *ipa_pipe_num, u32 *clnt_hdl, bool en_status);
1676
1677int ipa3_sys_teardown(u32 clnt_hdl);
1678
1679int ipa3_sys_update_gsi_hdls(u32 clnt_hdl, unsigned long gsi_ch_hdl,
1680 unsigned long gsi_ev_hdl);
1681
1682int ipa3_connect_wdi_pipe(struct ipa_wdi_in_params *in,
1683 struct ipa_wdi_out_params *out);
1684int ipa3_disconnect_wdi_pipe(u32 clnt_hdl);
1685int ipa3_enable_wdi_pipe(u32 clnt_hdl);
1686int ipa3_disable_wdi_pipe(u32 clnt_hdl);
1687int ipa3_resume_wdi_pipe(u32 clnt_hdl);
1688int ipa3_suspend_wdi_pipe(u32 clnt_hdl);
1689int ipa3_get_wdi_stats(struct IpaHwStatsWDIInfoData_t *stats);
1690u16 ipa3_get_smem_restr_bytes(void);
1691int ipa3_setup_uc_ntn_pipes(struct ipa_ntn_conn_in_params *in,
1692 ipa_notify_cb notify, void *priv, u8 hdr_len,
1693 struct ipa_ntn_conn_out_params *outp);
1694int ipa3_tear_down_uc_offload_pipes(int ipa_ep_idx_ul, int ipa_ep_idx_dl);
1695
1696/*
1697 * To retrieve doorbell physical address of
1698 * wlan pipes
1699 */
1700int ipa3_uc_wdi_get_dbpa(struct ipa_wdi_db_params *out);
1701
1702/*
1703 * To register uC ready callback if uC not ready
1704 * and also check uC readiness
1705 * if uC not ready only, register callback
1706 */
1707int ipa3_uc_reg_rdyCB(struct ipa_wdi_uc_ready_params *param);
1708/*
1709 * To de-register uC ready callback
1710 */
1711int ipa3_uc_dereg_rdyCB(void);
1712
1713/*
1714 * Tethering bridge (Rmnet / MBIM)
1715 */
1716int ipa3_teth_bridge_init(struct teth_bridge_init_params *params);
1717
1718int ipa3_teth_bridge_disconnect(enum ipa_client_type client);
1719
1720int ipa3_teth_bridge_connect(struct teth_bridge_connect_params *connect_params);
1721
1722/*
1723 * Tethering client info
1724 */
1725void ipa3_set_client(int index, enum ipacm_client_enum client, bool uplink);
1726
1727enum ipacm_client_enum ipa3_get_client(int pipe_idx);
1728
1729bool ipa3_get_client_uplink(int pipe_idx);
1730
1731/*
1732 * IPADMA
1733 */
1734int ipa3_dma_init(void);
1735
1736int ipa3_dma_enable(void);
1737
1738int ipa3_dma_disable(void);
1739
1740int ipa3_dma_sync_memcpy(u64 dest, u64 src, int len);
1741
1742int ipa3_dma_async_memcpy(u64 dest, u64 src, int len,
1743 void (*user_cb)(void *user1), void *user_param);
1744
1745int ipa3_dma_uc_memcpy(phys_addr_t dest, phys_addr_t src, int len);
1746
1747void ipa3_dma_destroy(void);
1748
1749/*
1750 * MHI
1751 */
1752
1753int ipa3_mhi_init_engine(struct ipa_mhi_init_engine *params);
1754
1755int ipa3_connect_mhi_pipe(
1756 struct ipa_mhi_connect_params_internal *in,
1757 u32 *clnt_hdl);
1758
1759int ipa3_disconnect_mhi_pipe(u32 clnt_hdl);
1760
1761bool ipa3_mhi_stop_gsi_channel(enum ipa_client_type client);
1762
1763int ipa3_mhi_reset_channel_internal(enum ipa_client_type client);
1764
1765int ipa3_mhi_start_channel_internal(enum ipa_client_type client);
1766
1767bool ipa3_has_open_aggr_frame(enum ipa_client_type client);
1768
1769int ipa3_mhi_resume_channels_internal(enum ipa_client_type client,
1770 bool LPTransitionRejected, bool brstmode_enabled,
1771 union __packed gsi_channel_scratch ch_scratch, u8 index);
1772
1773int ipa3_mhi_destroy_channel(enum ipa_client_type client);
1774
1775/*
1776 * mux id
1777 */
1778int ipa3_write_qmap_id(struct ipa_ioc_write_qmapid *param_in);
1779
1780/*
1781 * interrupts
1782 */
1783int ipa3_add_interrupt_handler(enum ipa_irq_type interrupt,
1784 ipa_irq_handler_t handler,
1785 bool deferred_flag,
1786 void *private_data);
1787
1788int ipa3_remove_interrupt_handler(enum ipa_irq_type interrupt);
1789
1790/*
1791 * Miscellaneous
1792 */
1793void ipa3_bam_reg_dump(void);
1794
1795int ipa3_get_ep_mapping(enum ipa_client_type client);
1796
1797bool ipa3_is_ready(void);
1798
1799void ipa3_proxy_clk_vote(void);
1800void ipa3_proxy_clk_unvote(void);
1801
1802bool ipa3_is_client_handle_valid(u32 clnt_hdl);
1803
1804enum ipa_client_type ipa3_get_client_mapping(int pipe_idx);
1805
1806void ipa_init_ep_flt_bitmap(void);
1807
1808bool ipa_is_ep_support_flt(int pipe_idx);
1809
1810enum ipa_rm_resource_name ipa3_get_rm_resource_from_ep(int pipe_idx);
1811
1812bool ipa3_get_modem_cfg_emb_pipe_flt(void);
1813
1814u8 ipa3_get_qmb_master_sel(enum ipa_client_type client);
1815
1816/* internal functions */
1817
1818int ipa3_bind_api_controller(enum ipa_hw_type ipa_hw_type,
1819 struct ipa_api_controller *api_ctrl);
1820
1821bool ipa_is_modem_pipe(int pipe_idx);
1822
1823int ipa3_send_one(struct ipa3_sys_context *sys, struct ipa3_desc *desc,
1824 bool in_atomic);
1825int ipa3_send(struct ipa3_sys_context *sys,
1826 u32 num_desc,
1827 struct ipa3_desc *desc,
1828 bool in_atomic);
1829int ipa3_get_ep_mapping(enum ipa_client_type client);
1830int ipa_get_ep_group(enum ipa_client_type client);
1831
1832int ipa3_generate_hw_rule(enum ipa_ip_type ip,
1833 const struct ipa_rule_attrib *attrib,
1834 u8 **buf,
1835 u16 *en_rule);
1836int ipa3_init_hw(void);
1837struct ipa3_rt_tbl *__ipa3_find_rt_tbl(enum ipa_ip_type ip, const char *name);
1838int ipa3_set_single_ndp_per_mbim(bool);
1839void ipa3_debugfs_init(void);
1840void ipa3_debugfs_remove(void);
1841
1842void ipa3_dump_buff_internal(void *base, dma_addr_t phy_base, u32 size);
1843#ifdef IPA_DEBUG
1844#define IPA_DUMP_BUFF(base, phy_base, size) \
1845 ipa3_dump_buff_internal(base, phy_base, size)
1846#else
1847#define IPA_DUMP_BUFF(base, phy_base, size)
1848#endif
1849int ipa3_init_mem_partition(struct device_node *dev_node);
1850int ipa3_controller_static_bind(struct ipa3_controller *controller,
1851 enum ipa_hw_type ipa_hw_type);
1852int ipa3_cfg_route(struct ipahal_reg_route *route);
Gidon Studinski3021a6f2016-11-10 12:48:48 +02001853int ipa3_send_cmd_timeout(u16 num_desc, struct ipa3_desc *descr, u32 timeout);
Amir Levy9659e592016-10-27 18:08:27 +03001854int ipa3_send_cmd(u16 num_desc, struct ipa3_desc *descr);
1855int ipa3_cfg_filter(u32 disable);
1856int ipa3_pipe_mem_init(u32 start_ofst, u32 size);
1857int ipa3_pipe_mem_alloc(u32 *ofst, u32 size);
1858int ipa3_pipe_mem_free(u32 ofst, u32 size);
1859int ipa3_straddle_boundary(u32 start, u32 end, u32 boundary);
1860struct ipa3_context *ipa3_get_ctx(void);
1861void ipa3_enable_clks(void);
1862void ipa3_disable_clks(void);
1863void ipa3_inc_client_enable_clks(struct ipa_active_client_logging_info *id);
1864int ipa3_inc_client_enable_clks_no_block(struct ipa_active_client_logging_info
1865 *id);
1866void ipa3_dec_client_disable_clks(struct ipa_active_client_logging_info *id);
1867void ipa3_active_clients_log_dec(struct ipa_active_client_logging_info *id,
1868 bool int_ctx);
1869void ipa3_active_clients_log_inc(struct ipa_active_client_logging_info *id,
1870 bool int_ctx);
1871int ipa3_active_clients_log_print_buffer(char *buf, int size);
1872int ipa3_active_clients_log_print_table(char *buf, int size);
1873void ipa3_active_clients_log_clear(void);
1874int ipa3_interrupts_init(u32 ipa_irq, u32 ee, struct device *ipa_dev);
1875int __ipa3_del_rt_rule(u32 rule_hdl);
Ghanim Fodi2c8ba072017-01-12 15:14:15 +02001876int __ipa3_del_hdr(u32 hdr_hdl, bool by_user);
Amir Levy9659e592016-10-27 18:08:27 +03001877int __ipa3_release_hdr(u32 hdr_hdl);
1878int __ipa3_release_hdr_proc_ctx(u32 proc_ctx_hdl);
1879int _ipa_read_ep_reg_v3_0(char *buf, int max_len, int pipe);
1880void _ipa_enable_clks_v3_0(void);
1881void _ipa_disable_clks_v3_0(void);
1882struct device *ipa3_get_dma_dev(void);
1883void ipa3_suspend_active_aggr_wa(u32 clnt_hdl);
1884void ipa3_suspend_handler(enum ipa_irq_type interrupt,
1885 void *private_data,
1886 void *interrupt_data);
1887
1888
1889int ipa_bridge_init(void);
1890void ipa_bridge_cleanup(void);
1891
1892ssize_t ipa3_read(struct file *filp, char __user *buf, size_t count,
1893 loff_t *f_pos);
1894int ipa3_pull_msg(struct ipa_msg_meta *meta, char *buff, size_t count);
1895int ipa3_query_intf(struct ipa_ioc_query_intf *lookup);
1896int ipa3_query_intf_tx_props(struct ipa_ioc_query_intf_tx_props *tx);
1897int ipa3_query_intf_rx_props(struct ipa_ioc_query_intf_rx_props *rx);
1898int ipa3_query_intf_ext_props(struct ipa_ioc_query_intf_ext_props *ext);
1899
1900void wwan_cleanup(void);
1901
1902int ipa3_teth_bridge_driver_init(void);
1903void ipa3_lan_rx_cb(void *priv, enum ipa_dp_evt_type evt, unsigned long data);
1904
1905int _ipa_init_sram_v3_0(void);
1906int _ipa_init_hdr_v3_0(void);
1907int _ipa_init_rt4_v3(void);
1908int _ipa_init_rt6_v3(void);
1909int _ipa_init_flt4_v3(void);
1910int _ipa_init_flt6_v3(void);
1911
1912int __ipa_commit_flt_v3(enum ipa_ip_type ip);
1913int __ipa_commit_rt_v3(enum ipa_ip_type ip);
1914
1915int __ipa_commit_hdr_v3_0(void);
1916void ipa3_skb_recycle(struct sk_buff *skb);
1917void ipa3_install_dflt_flt_rules(u32 ipa_ep_idx);
1918void ipa3_delete_dflt_flt_rules(u32 ipa_ep_idx);
1919
1920int ipa3_enable_data_path(u32 clnt_hdl);
1921int ipa3_disable_data_path(u32 clnt_hdl);
1922int ipa3_alloc_rule_id(struct idr *rule_ids);
1923int ipa3_id_alloc(void *ptr);
1924void *ipa3_id_find(u32 id);
1925void ipa3_id_remove(u32 id);
1926
1927int ipa3_set_required_perf_profile(enum ipa_voltage_level floor_voltage,
1928 u32 bandwidth_mbps);
1929
1930int ipa3_cfg_ep_status(u32 clnt_hdl,
1931 const struct ipahal_reg_ep_cfg_status *ipa_ep_cfg);
1932
1933int ipa3_suspend_resource_no_block(enum ipa_rm_resource_name name);
1934int ipa3_suspend_resource_sync(enum ipa_rm_resource_name name);
1935int ipa3_resume_resource(enum ipa_rm_resource_name name);
1936bool ipa3_should_pipe_be_suspended(enum ipa_client_type client);
1937int ipa3_tag_aggr_force_close(int pipe_num);
1938
1939void ipa3_active_clients_lock(void);
1940int ipa3_active_clients_trylock(unsigned long *flags);
1941void ipa3_active_clients_unlock(void);
1942void ipa3_active_clients_trylock_unlock(unsigned long *flags);
1943int ipa3_wdi_init(void);
1944int ipa3_write_qmapid_wdi_pipe(u32 clnt_hdl, u8 qmap_id);
1945int ipa3_tag_process(struct ipa3_desc *desc, int num_descs,
1946 unsigned long timeout);
1947
1948void ipa3_q6_pre_shutdown_cleanup(void);
1949void ipa3_q6_post_shutdown_cleanup(void);
1950int ipa3_init_q6_smem(void);
1951
1952int ipa3_sps_connect_safe(struct sps_pipe *h, struct sps_connect *connect,
1953 enum ipa_client_type ipa_client);
1954
1955int ipa3_mhi_handle_ipa_config_req(struct ipa_config_req_msg_v01 *config_req);
1956int ipa3_mhi_query_ch_info(enum ipa_client_type client,
1957 struct gsi_chan_info *ch_info);
1958
1959int ipa3_uc_interface_init(void);
1960int ipa3_uc_reset_pipe(enum ipa_client_type ipa_client);
1961int ipa3_uc_is_gsi_channel_empty(enum ipa_client_type ipa_client);
1962int ipa3_uc_state_check(void);
1963int ipa3_uc_loaded_check(void);
1964void ipa3_uc_load_notify(void);
1965int ipa3_uc_send_cmd(u32 cmd, u32 opcode, u32 expected_status,
1966 bool polling_mode, unsigned long timeout_jiffies);
1967void ipa3_uc_register_handlers(enum ipa3_hw_features feature,
1968 struct ipa3_uc_hdlrs *hdlrs);
1969int ipa3_create_nat_device(void);
1970int ipa3_uc_notify_clk_state(bool enabled);
1971void ipa3_dma_async_memcpy_notify_cb(void *priv,
1972 enum ipa_dp_evt_type evt, unsigned long data);
1973
1974int ipa3_uc_update_hw_flags(u32 flags);
1975
1976int ipa3_uc_mhi_init(void (*ready_cb)(void), void (*wakeup_request_cb)(void));
1977void ipa3_uc_mhi_cleanup(void);
1978int ipa3_uc_mhi_send_dl_ul_sync_info(union IpaHwMhiDlUlSyncCmdData_t *cmd);
1979int ipa3_uc_mhi_init_engine(struct ipa_mhi_msi_info *msi, u32 mmio_addr,
1980 u32 host_ctrl_addr, u32 host_data_addr, u32 first_ch_idx,
1981 u32 first_evt_idx);
1982int ipa3_uc_mhi_init_channel(int ipa_ep_idx, int channelHandle,
1983 int contexArrayIndex, int channelDirection);
1984int ipa3_uc_mhi_reset_channel(int channelHandle);
1985int ipa3_uc_mhi_suspend_channel(int channelHandle);
1986int ipa3_uc_mhi_resume_channel(int channelHandle, bool LPTransitionRejected);
1987int ipa3_uc_mhi_stop_event_update_channel(int channelHandle);
1988int ipa3_uc_mhi_print_stats(char *dbg_buff, int size);
1989int ipa3_uc_memcpy(phys_addr_t dest, phys_addr_t src, int len);
1990void ipa3_tag_destroy_imm(void *user1, int user2);
1991struct ipa_gsi_ep_config *ipa3_get_gsi_ep_info(int ipa_ep_idx);
1992void ipa3_uc_rg10_write_reg(enum ipahal_reg_name reg, u32 n, u32 val);
1993
1994u32 ipa3_get_num_pipes(void);
1995struct ipa_smmu_cb_ctx *ipa3_get_smmu_ctx(void);
1996struct ipa_smmu_cb_ctx *ipa3_get_wlan_smmu_ctx(void);
1997struct ipa_smmu_cb_ctx *ipa3_get_uc_smmu_ctx(void);
1998struct iommu_domain *ipa3_get_smmu_domain(void);
1999struct iommu_domain *ipa3_get_uc_smmu_domain(void);
2000struct iommu_domain *ipa3_get_wlan_smmu_domain(void);
2001int ipa3_iommu_map(struct iommu_domain *domain, unsigned long iova,
2002 phys_addr_t paddr, size_t size, int prot);
2003int ipa3_ap_suspend(struct device *dev);
2004int ipa3_ap_resume(struct device *dev);
2005int ipa3_init_interrupts(void);
2006struct iommu_domain *ipa3_get_smmu_domain(void);
2007int ipa3_release_wdi_mapping(u32 num_buffers, struct ipa_wdi_buffer_info *info);
2008int ipa3_create_wdi_mapping(u32 num_buffers, struct ipa_wdi_buffer_info *info);
2009int ipa3_set_flt_tuple_mask(int pipe_idx, struct ipahal_reg_hash_tuple *tuple);
2010int ipa3_set_rt_tuple_mask(int tbl_idx, struct ipahal_reg_hash_tuple *tuple);
2011void ipa3_set_resorce_groups_min_max_limits(void);
2012void ipa3_suspend_apps_pipes(bool suspend);
2013void ipa3_flow_control(enum ipa_client_type ipa_client, bool enable,
2014 uint32_t qmap_id);
2015int ipa3_flt_read_tbl_from_hw(u32 pipe_idx,
2016 enum ipa_ip_type ip_type,
2017 bool hashable,
2018 struct ipahal_flt_rule_entry entry[],
2019 int *num_entry);
2020int ipa3_rt_read_tbl_from_hw(u32 tbl_idx,
2021 enum ipa_ip_type ip_type,
2022 bool hashable,
2023 struct ipahal_rt_rule_entry entry[],
2024 int *num_entry);
2025int ipa3_restore_suspend_handler(void);
2026int ipa3_inject_dma_task_for_gsi(void);
2027int ipa3_uc_panic_notifier(struct notifier_block *this,
2028 unsigned long event, void *ptr);
2029void ipa3_inc_acquire_wakelock(void);
2030void ipa3_dec_release_wakelock(void);
2031int ipa3_load_fws(const struct firmware *firmware);
2032int ipa3_register_ipa_ready_cb(void (*ipa_ready_cb)(void *), void *user_data);
2033const char *ipa_hw_error_str(enum ipa3_hw_errors err_type);
2034int ipa_gsi_ch20_wa(void);
2035int ipa3_rx_poll(u32 clnt_hdl, int budget);
2036void ipa3_recycle_wan_skb(struct sk_buff *skb);
2037int ipa3_smmu_map_peer_reg(phys_addr_t phys_addr, bool map);
2038int ipa3_smmu_map_peer_buff(u64 iova, phys_addr_t phys_addr,
2039 u32 size, bool map);
2040int ipa3_ntn_init(void);
2041int ipa3_get_ntn_stats(struct Ipa3HwStatsNTNInfoData_t *stats);
2042struct dentry *ipa_debugfs_get_root(void);
2043bool ipa3_is_msm_device(void);
Amir Levyc4222c92016-11-07 16:14:54 +02002044struct device *ipa3_get_pdev(void);
Amir Levy12ef0912016-08-30 09:27:34 +03002045void ipa3_enable_dcd(void);
Amir Levy9659e592016-10-27 18:08:27 +03002046#endif /* _IPA3_I_H_ */