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