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