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