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