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