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