-
Notifications
You must be signed in to change notification settings - Fork 0
/
\
3124 lines (2770 loc) · 93.1 KB
/
\
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/* SPDX-License-Identifier: GPL-2.0 */
/*
* Copyright (c) 2012-2019, The Linux Foundation. All rights reserved.
*/
#ifndef _IPA3_I_H_
#define _IPA3_I_H_
#include <linux/bitops.h>
#include <linux/cdev.h>
#include <linux/export.h>
#include <linux/idr.h>
#include <linux/list.h>
#include <linux/mutex.h>
#include <linux/skbuff.h>
#include <linux/slab.h>
#include <linux/notifier.h>
#include <linux/interrupt.h>
#include <linux/netdevice.h>
#include <linux/ipa.h>
#include <linux/ipa_usb.h>
#include <asm/dma-iommu.h>
#include <linux/iommu.h>
#include <linux/platform_device.h>
#include <linux/firmware.h>
#include "ipa_qmi_service.h"
#include "../ipa_api.h"
#include "ipahal/ipahal_reg.h"
#include "ipahal/ipahal.h"
#include "ipahal/ipahal_fltrt.h"
#include "ipahal/ipahal_hw_stats.h"
#include "../ipa_common_i.h"
#include "ipa_uc_offload_i.h"
#include "ipa_pm.h"
#include "ipa_defs.h"
#include <linux/mailbox_client.h>
#include <linux/mailbox/qmp.h>
#include <linux/rmnet_ipa_fd_ioctl.h>
#define IPA_DEV_NAME_MAX_LEN 15
#define DRV_NAME "ipa"
#define IPA_COOKIE 0x57831603
#define IPA_RT_RULE_COOKIE 0x57831604
#define IPA_RT_TBL_COOKIE 0x57831605
#define IPA_FLT_COOKIE 0x57831606
#define IPA_HDR_COOKIE 0x57831607
#define IPA_PROC_HDR_COOKIE 0x57831608
#define MTU_BYTE 1500
#define IPA_EP_NOT_ALLOCATED (-1)
#define IPA3_MAX_NUM_PIPES 31
#define IPA_SYS_DESC_FIFO_SZ 0x800
#define IPA_SYS_TX_DATA_DESC_FIFO_SZ 0x1000
#define IPA_COMMON_EVENT_RING_SIZE 0x7C00
#define IPA_LAN_RX_HEADER_LENGTH (2)
#define IPA_QMAP_HEADER_LENGTH (4)
#define IPA_DL_CHECKSUM_LENGTH (8)
#define IPA_NUM_DESC_PER_SW_TX (3)
#define IPA_GENERIC_RX_POOL_SZ 192
#define IPA_UC_FINISH_MAX 6
#define IPA_UC_WAIT_MIN_SLEEP 1000
#define IPA_UC_WAII_MAX_SLEEP 1200
/*
* The transport descriptor size was changed to GSI_CHAN_RE_SIZE_16B, but
* IPA users still use sps_iovec size as FIFO element size.
*/
#define IPA_FIFO_ELEMENT_SIZE 8
#define IPA_MAX_STATUS_STAT_NUM 30
#define IPA_IPC_LOG_PAGES 50
#define IPA_MAX_NUM_REQ_CACHE 10
#define NAPI_WEIGHT 60
#define IPADBG(fmt, args...) \
do { \
pr_debug(DRV_NAME " %s:%d " fmt, __func__, __LINE__, ## args);\
if (ipa3_ctx) { \
IPA_IPC_LOGGING(ipa3_ctx->logbuf, \
DRV_NAME " %s:%d " fmt, ## args); \
IPA_IPC_LOGGING(ipa3_ctx->logbuf_low, \
DRV_NAME " %s:%d " fmt, ## args); \
} \
} while (0)
#define IPADBG_LOW(fmt, args...) \
do { \
pr_debug(DRV_NAME " %s:%d " fmt, __func__, __LINE__, ## args);\
if (ipa3_ctx) \
IPA_IPC_LOGGING(ipa3_ctx->logbuf_low, \
DRV_NAME " %s:%d " fmt, ## args); \
} while (0)
#define IPAERR(fmt, args...) \
do { \
pr_err(DRV_NAME " %s:%d " fmt, __func__, __LINE__, ## args);\
if (ipa3_ctx) { \
IPA_IPC_LOGGING(ipa3_ctx->logbuf, \
DRV_NAME " %s:%d " fmt, ## args); \
IPA_IPC_LOGGING(ipa3_ctx->logbuf_low, \
DRV_NAME " %s:%d " fmt, ## args); \
} \
} while (0)
#define IPAERR_RL(fmt, args...) \
do { \
pr_err_ratelimited_ipa(DRV_NAME " %s:%d " fmt, __func__,\
__LINE__, ## args);\
if (ipa3_ctx) { \
IPA_IPC_LOGGING(ipa3_ctx->logbuf, \
DRV_NAME " %s:%d " fmt, ## args); \
IPA_IPC_LOGGING(ipa3_ctx->logbuf_low, \
DRV_NAME " %s:%d " fmt, ## args); \
} \
} while (0)
#define IPALOG_VnP_ADDRS(ptr) \
do { \
phys_addr_t b = (phys_addr_t) virt_to_phys(ptr); \
IPAERR("%s: VIRT: %pK PHYS: %pa\n", \
#ptr, ptr, &b); \
} while (0)
/* round addresses for closes page per SMMU requirements */
#define IPA_SMMU_ROUND_TO_PAGE(iova, pa, size, iova_p, pa_p, size_p) \
do { \
(iova_p) = rounddown((iova), PAGE_SIZE); \
(pa_p) = rounddown((pa), PAGE_SIZE); \
(size_p) = roundup((size) + (pa) - (pa_p), PAGE_SIZE); \
} while (0)
#define WLAN_AMPDU_TX_EP 15
#define WLAN_PROD_TX_EP 19
#define WLAN1_CONS_RX_EP 14
#define WLAN2_CONS_RX_EP 16
#define WLAN3_CONS_RX_EP 17
#define WLAN4_CONS_RX_EP 18
#define IPA_RAM_NAT_OFST 0
#define IPA_RAM_NAT_SIZE 0
#define IPA_RAM_IPV6CT_OFST 0
#define IPA_RAM_IPV6CT_SIZE 0
#define IPA_MEM_CANARY_VAL 0xdeadbeef
#define IPA_STATS
#ifdef IPA_STATS
#define IPA_STATS_INC_CNT(val) (++val)
#define IPA_STATS_DEC_CNT(val) (--val)
#define IPA_STATS_EXCP_CNT(__excp, __base) do { \
if (__excp < 0 || __excp >= IPAHAL_PKT_STATUS_EXCEPTION_MAX) \
break; \
++__base[__excp]; \
} while (0)
#else
#define IPA_STATS_INC_CNT(x) do { } while (0)
#define IPA_STATS_DEC_CNT(x)
#define IPA_STATS_EXCP_CNT(__excp, __base) do { } while (0)
#endif
#define IPA_HDR_BIN0 0
#define IPA_HDR_BIN1 1
#define IPA_HDR_BIN2 2
#define IPA_HDR_BIN3 3
#define IPA_HDR_BIN4 4
#define IPA_HDR_BIN_MAX 5
#define IPA_HDR_PROC_CTX_BIN0 0
#define IPA_HDR_PROC_CTX_BIN1 1
#define IPA_HDR_PROC_CTX_BIN_MAX 2
#define IPA_RX_POOL_CEIL 32
#define IPA_RX_SKB_SIZE 1792
#define IPA_A5_MUX_HDR_NAME "ipa_excp_hdr"
#define IPA_LAN_RX_HDR_NAME "ipa_lan_hdr"
#define IPA_INVALID_L4_PROTOCOL 0xFF
#define IPA_HDR_PROC_CTX_TABLE_ALIGNMENT_BYTE 8
#define IPA_HDR_PROC_CTX_TABLE_ALIGNMENT(start_ofst) \
(((start_ofst) + IPA_HDR_PROC_CTX_TABLE_ALIGNMENT_BYTE - 1) & \
~(IPA_HDR_PROC_CTX_TABLE_ALIGNMENT_BYTE - 1))
#define MAX_RESOURCE_TO_CLIENTS (IPA_CLIENT_MAX)
#define IPA_MEM_PART(x_) (ipa3_ctx->ctrl->mem_partition->x_)
#define IPA_GSI_CHANNEL_STOP_MAX_RETRY 10
#define IPA_GSI_CHANNEL_STOP_PKT_SIZE 1
#define IPA_GSI_CHANNEL_EMPTY_MAX_RETRY 15
#define IPA_GSI_CHANNEL_EMPTY_SLEEP_MIN_USEC (1000)
#define IPA_GSI_CHANNEL_EMPTY_SLEEP_MAX_USEC (2000)
#define IPA_SLEEP_CLK_RATE_KHZ (32)
#define IPA3_ACTIVE_CLIENTS_LOG_BUFFER_SIZE_LINES 120
#define IPA3_ACTIVE_CLIENTS_LOG_LINE_LEN 96
#define IPA3_ACTIVE_CLIENTS_LOG_HASHTABLE_SIZE 50
#define IPA3_ACTIVE_CLIENTS_LOG_NAME_LEN 40
#define SMEM_IPA_FILTER_TABLE 497
enum {
SMEM_APPS,
SMEM_MODEM,
SMEM_Q6,
SMEM_DSPS,
SMEM_WCNSS,
SMEM_CDSP,
SMEM_RPM,
SMEM_TZ,
SMEM_SPSS,
SMEM_HYP,
NUM_SMEM_SUBSYSTEMS,
};
#define IPA_WDI_RX_RING_RES 0
#define IPA_WDI_RX_RING_RP_RES 1
#define IPA_WDI_RX_COMP_RING_RES 2
#define IPA_WDI_RX_COMP_RING_WP_RES 3
#define IPA_WDI_TX_RING_RES 4
#define IPA_WDI_CE_RING_RES 5
#define IPA_WDI_CE_DB_RES 6
#define IPA_WDI_TX_DB_RES 7
#define IPA_WDI_MAX_RES 8
/* use QMAP header reserved bit to identify tethered traffic */
#define IPA_QMAP_TETH_BIT (1 << 30)
#ifdef CONFIG_ARM64
/* Outer caches unsupported on ARM64 platforms */
# define outer_flush_range(x, y)
# define __cpuc_flush_dcache_area __flush_dcache_area
#endif
#define IPA_SMP2P_OUT_CLK_RSP_CMPLT_IDX 0
#define IPA_SMP2P_OUT_CLK_VOTE_IDX 1
#define IPA_SMP2P_SMEM_STATE_MASK 3
#define IPA_SUMMING_THRESHOLD (0x10)
#define IPA_PIPE_MEM_START_OFST (0x0)
#define IPA_PIPE_MEM_SIZE (0x0)
#define IPA_MOBILE_AP_MODE(x) (x == IPA_MODE_MOBILE_AP_ETH || \
x == IPA_MODE_MOBILE_AP_WAN || \
x == IPA_MODE_MOBILE_AP_WLAN)
#define IPA_CNOC_CLK_RATE (75 * 1000 * 1000UL)
#define IPA_A5_MUX_HEADER_LENGTH (8)
#define IPA_AGGR_MAX_STR_LENGTH (10)
#define CLEANUP_TAG_PROCESS_TIMEOUT 1000
#define IPA_AGGR_STR_IN_BYTES(str) \
(strnlen((str), IPA_AGGR_MAX_STR_LENGTH - 1) + 1)
#define IPA_ADJUST_AGGR_BYTE_HARD_LIMIT(X) (X/1000)
#define IPA_TRANSPORT_PROD_TIMEOUT_MSEC 100
#define IPA3_ACTIVE_CLIENTS_TABLE_BUF_SIZE 4096
#define IPA3_ACTIVE_CLIENT_LOG_TYPE_EP 0
#define IPA3_ACTIVE_CLIENT_LOG_TYPE_SIMPLE 1
#define IPA3_ACTIVE_CLIENT_LOG_TYPE_RESOURCE 2
#define IPA3_ACTIVE_CLIENT_LOG_TYPE_SPECIAL 3
#define IPA_MHI_GSI_EVENT_RING_ID_START 10
#define IPA_MHI_GSI_EVENT_RING_ID_END 12
#define IPA_SMEM_SIZE (8 * 1024)
#define IPA_GSI_CHANNEL_HALT_MIN_SLEEP 5000
#define IPA_GSI_CHANNEL_HALT_MAX_SLEEP 10000
#define IPA_GSI_CHANNEL_HALT_MAX_TRY 10
/* round addresses for closes page per SMMU requirements */
#define IPA_SMMU_ROUND_TO_PAGE(iova, pa, size, iova_p, pa_p, size_p) \
do { \
(iova_p) = rounddown((iova), PAGE_SIZE); \
(pa_p) = rounddown((pa), PAGE_SIZE); \
(size_p) = roundup((size) + (pa) - (pa_p), PAGE_SIZE); \
} while (0)
/* The relative location in /lib/firmware where the FWs will reside */
#define IPA_FWS_PATH "ipa/ipa_fws.elf"
/*
* The following paths below are used when building the system for the
* emulation environment.
*
* As new hardware platforms are added into the emulation environment,
* please add the appropriate paths here for their firmwares.
*/
#define IPA_FWS_PATH_4_0 "ipa/4.0/ipa_fws.elf"
#define IPA_FWS_PATH_3_5_1 "ipa/3.5.1/ipa_fws.elf"
#define IPA_FWS_PATH_4_5 "ipa/4.5/ipa_fws.elf"
/*
* The following will be used for determining/using access control
* policy.
*/
#define USE_SCM 0 /* use scm call to determine policy */
#define OVERRIDE_SCM_TRUE 1 /* override scm call with true */
#define OVERRIDE_SCM_FALSE 2 /* override scm call with false */
#define SD_ENABLED 0 /* secure debug enabled. */
#define SD_DISABLED 1 /* secure debug disabled. */
#define IPA_MEM_INIT_VAL 0xFFFFFFFF
#ifdef CONFIG_COMPAT
#define IPA_IOC_ADD_HDR32 _IOWR(IPA_IOC_MAGIC, \
IPA_IOCTL_ADD_HDR, \
compat_uptr_t)
#define IPA_IOC_DEL_HDR32 _IOWR(IPA_IOC_MAGIC, \
IPA_IOCTL_DEL_HDR, \
compat_uptr_t)
#define IPA_IOC_ADD_RT_RULE32 _IOWR(IPA_IOC_MAGIC, \
IPA_IOCTL_ADD_RT_RULE, \
compat_uptr_t)
#define IPA_IOC_DEL_RT_RULE32 _IOWR(IPA_IOC_MAGIC, \
IPA_IOCTL_DEL_RT_RULE, \
compat_uptr_t)
#define IPA_IOC_ADD_FLT_RULE32 _IOWR(IPA_IOC_MAGIC, \
IPA_IOCTL_ADD_FLT_RULE, \
compat_uptr_t)
#define IPA_IOC_DEL_FLT_RULE32 _IOWR(IPA_IOC_MAGIC, \
IPA_IOCTL_DEL_FLT_RULE, \
compat_uptr_t)
#define IPA_IOC_GET_RT_TBL32 _IOWR(IPA_IOC_MAGIC, \
IPA_IOCTL_GET_RT_TBL, \
compat_uptr_t)
#define IPA_IOC_COPY_HDR32 _IOWR(IPA_IOC_MAGIC, \
IPA_IOCTL_COPY_HDR, \
compat_uptr_t)
#define IPA_IOC_QUERY_INTF32 _IOWR(IPA_IOC_MAGIC, \
IPA_IOCTL_QUERY_INTF, \
compat_uptr_t)
#define IPA_IOC_QUERY_INTF_TX_PROPS32 _IOWR(IPA_IOC_MAGIC, \
IPA_IOCTL_QUERY_INTF_TX_PROPS, \
compat_uptr_t)
#define IPA_IOC_QUERY_INTF_RX_PROPS32 _IOWR(IPA_IOC_MAGIC, \
IPA_IOCTL_QUERY_INTF_RX_PROPS, \
compat_uptr_t)
#define IPA_IOC_QUERY_INTF_EXT_PROPS32 _IOWR(IPA_IOC_MAGIC, \
IPA_IOCTL_QUERY_INTF_EXT_PROPS, \
compat_uptr_t)
#define IPA_IOC_GET_HDR32 _IOWR(IPA_IOC_MAGIC, \
IPA_IOCTL_GET_HDR, \
compat_uptr_t)
#define IPA_IOC_ALLOC_NAT_MEM32 _IOWR(IPA_IOC_MAGIC, \
IPA_IOCTL_ALLOC_NAT_MEM, \
compat_uptr_t)
#define IPA_IOC_ALLOC_NAT_TABLE32 _IOWR(IPA_IOC_MAGIC, \
IPA_IOCTL_ALLOC_NAT_TABLE, \
compat_uptr_t)
#define IPA_IOC_ALLOC_IPV6CT_TABLE32 _IOWR(IPA_IOC_MAGIC, \
IPA_IOCTL_ALLOC_IPV6CT_TABLE, \
compat_uptr_t)
#define IPA_IOC_V4_INIT_NAT32 _IOWR(IPA_IOC_MAGIC, \
IPA_IOCTL_V4_INIT_NAT, \
compat_uptr_t)
#define IPA_IOC_INIT_IPV6CT_TABLE32 _IOWR(IPA_IOC_MAGIC, \
IPA_IOCTL_INIT_IPV6CT_TABLE, \
compat_uptr_t)
#define IPA_IOC_TABLE_DMA_CMD32 _IOWR(IPA_IOC_MAGIC, \
IPA_IOCTL_TABLE_DMA_CMD, \
compat_uptr_t)
#define IPA_IOC_V4_DEL_NAT32 _IOWR(IPA_IOC_MAGIC, \
IPA_IOCTL_V4_DEL_NAT, \
compat_uptr_t)
#define IPA_IOC_DEL_NAT_TABLE32 _IOWR(IPA_IOC_MAGIC, \
IPA_IOCTL_DEL_NAT_TABLE, \
compat_uptr_t)
#define IPA_IOC_DEL_IPV6CT_TABLE32 _IOWR(IPA_IOC_MAGIC, \
IPA_IOCTL_DEL_IPV6CT_TABLE, \
compat_uptr_t)
#define IPA_IOC_NAT_MODIFY_PDN32 _IOWR(IPA_IOC_MAGIC, \
IPA_IOCTL_NAT_MODIFY_PDN, \
compat_uptr_t)
#define IPA_IOC_GET_NAT_OFFSET32 _IOWR(IPA_IOC_MAGIC, \
IPA_IOCTL_GET_NAT_OFFSET, \
compat_uptr_t)
#define IPA_IOC_PULL_MSG32 _IOWR(IPA_IOC_MAGIC, \
IPA_IOCTL_PULL_MSG, \
compat_uptr_t)
#define IPA_IOC_RM_ADD_DEPENDENCY32 _IOWR(IPA_IOC_MAGIC, \
IPA_IOCTL_RM_ADD_DEPENDENCY, \
compat_uptr_t)
#define IPA_IOC_RM_DEL_DEPENDENCY32 _IOWR(IPA_IOC_MAGIC, \
IPA_IOCTL_RM_DEL_DEPENDENCY, \
compat_uptr_t)
#define IPA_IOC_GENERATE_FLT_EQ32 _IOWR(IPA_IOC_MAGIC, \
IPA_IOCTL_GENERATE_FLT_EQ, \
compat_uptr_t)
#define IPA_IOC_QUERY_RT_TBL_INDEX32 _IOWR(IPA_IOC_MAGIC, \
IPA_IOCTL_QUERY_RT_TBL_INDEX, \
compat_uptr_t)
#define IPA_IOC_WRITE_QMAPID32 _IOWR(IPA_IOC_MAGIC, \
IPA_IOCTL_WRITE_QMAPID, \
compat_uptr_t)
#define IPA_IOC_MDFY_FLT_RULE32 _IOWR(IPA_IOC_MAGIC, \
IPA_IOCTL_MDFY_FLT_RULE, \
compat_uptr_t)
#define IPA_IOC_NOTIFY_WAN_UPSTREAM_ROUTE_ADD32 _IOWR(IPA_IOC_MAGIC, \
IPA_IOCTL_NOTIFY_WAN_UPSTREAM_ROUTE_ADD, \
compat_uptr_t)
#define IPA_IOC_NOTIFY_WAN_UPSTREAM_ROUTE_DEL32 _IOWR(IPA_IOC_MAGIC, \
IPA_IOCTL_NOTIFY_WAN_UPSTREAM_ROUTE_DEL, \
compat_uptr_t)
#define IPA_IOC_NOTIFY_WAN_EMBMS_CONNECTED32 _IOWR(IPA_IOC_MAGIC, \
IPA_IOCTL_NOTIFY_WAN_EMBMS_CONNECTED, \
compat_uptr_t)
#define IPA_IOC_ADD_HDR_PROC_CTX32 _IOWR(IPA_IOC_MAGIC, \
IPA_IOCTL_ADD_HDR_PROC_CTX, \
compat_uptr_t)
#define IPA_IOC_DEL_HDR_PROC_CTX32 _IOWR(IPA_IOC_MAGIC, \
IPA_IOCTL_DEL_HDR_PROC_CTX, \
compat_uptr_t)
#define IPA_IOC_MDFY_RT_RULE32 _IOWR(IPA_IOC_MAGIC, \
IPA_IOCTL_MDFY_RT_RULE, \
compat_uptr_t)
#endif /* #ifdef CONFIG_COMPAT */
#define IPA_TZ_UNLOCK_ATTRIBUTE 0x0C0311
#define TZ_MEM_PROTECT_REGION_ID 0x10
#define MBOX_TOUT_MS 100
struct ipa3_active_client_htable_entry {
struct hlist_node list;
char id_string[IPA3_ACTIVE_CLIENTS_LOG_NAME_LEN];
int count;
enum ipa_active_client_log_type type;
};
struct ipa3_active_clients_log_ctx {
spinlock_t lock;
char *log_buffer[IPA3_ACTIVE_CLIENTS_LOG_BUFFER_SIZE_LINES];
int log_head;
int log_tail;
bool log_rdy;
struct hlist_head htable[IPA3_ACTIVE_CLIENTS_LOG_HASHTABLE_SIZE];
};
struct ipa3_client_names {
enum ipa_client_type names[MAX_RESOURCE_TO_CLIENTS];
int length;
};
struct ipa_smmu_cb_ctx {
bool valid;
struct device *dev;
struct iommu_domain *iommu_domain;
unsigned long next_addr;
u32 va_start;
u32 va_size;
u32 va_end;
bool shared;
bool is_cache_coherent;
};
/**
* struct ipa_flt_rule_add_i - filtering rule descriptor
* includes in and out parameters
* @rule: actual rule to be added
* @at_rear: add at back of filtering table?
* @flt_rule_hdl: out parameter, handle to rule, valid when status is 0
* @status: output parameter, status of filtering rule add operation,
* 0 for success,
* -1 for failure
*
*/
struct ipa_flt_rule_add_i {
u8 at_rear;
u32 flt_rule_hdl;
int status;
struct ipa_flt_rule_i rule;
};
/**
* struct ipa_flt_rule_mdfy_i - filtering rule descriptor
* includes in and out parameters
* @rule: actual rule to be added
* @flt_rule_hdl: handle to rule
* @status: output parameter, status of filtering rule modify operation,
* 0 for success,
* -1 for failure
*
*/
struct ipa_flt_rule_mdfy_i {
u32 rule_hdl;
int status;
struct ipa_flt_rule_i rule;
};
/**
* struct ipa_rt_rule_add_i - routing rule descriptor includes
* in and out parameters
* @rule: actual rule to be added
* @at_rear: add at back of routing table, it is NOT possible to add rules at
* the rear of the "default" routing tables
* @rt_rule_hdl: output parameter, handle to rule, valid when status is 0
* @status: output parameter, status of routing rule add operation,
* 0 for success,
* -1 for failure
*/
struct ipa_rt_rule_add_i {
u8 at_rear;
u32 rt_rule_hdl;
int status;
struct ipa_rt_rule_i rule;
};
/**
* struct ipa_rt_rule_mdfy_i - routing rule descriptor includes
* in and out parameters
* @rule: actual rule to be added
* @rt_rule_hdl: handle to rule which supposed to modify
* @status: output parameter, status of routing rule modify operation,
* 0 for success,
* -1 for failure
*
*/
struct ipa_rt_rule_mdfy_i {
u32 rt_rule_hdl;
int status;
struct ipa_rt_rule_i rule;
};
/**
* struct ipa_rt_rule_add_ext_i - routing rule descriptor
* includes in and out parameters
* @rule: actual rule to be added
* @at_rear: add at back of routing table, it is NOT possible to add rules at
* the rear of the "default" routing tables
* @rt_rule_hdl: output parameter, handle to rule, valid when status is 0
* @status: output parameter, status of routing rule add operation,
* @rule_id: rule_id to be assigned to the routing rule. In case client
* specifies rule_id as 0 the driver will assign a new rule_id
* 0 for success,
* -1 for failure
*/
struct ipa_rt_rule_add_ext_i {
uint8_t at_rear;
uint32_t rt_rule_hdl;
int status;
uint16_t rule_id;
struct ipa_rt_rule_i rule;
};
/**
* struct ipa3_flt_entry - IPA filtering table entry
* @link: entry's link in global filtering enrties list
* @rule: filter rule
* @cookie: cookie used for validity check
* @tbl: filter table
* @rt_tbl: routing table
* @hw_len: entry's size
* @id: rule handle - globally unique
* @prio: rule 10bit priority which defines the order of the rule
* among other rules at the same integrated table
* @rule_id: rule 10bit ID to be returned in packet status
* @cnt_idx: stats counter index
* @ipacm_installed: indicate if installed by ipacm
*/
struct ipa3_flt_entry {
struct list_head link;
u32 cookie;
struct ipa_flt_rule_i rule;
struct ipa3_flt_tbl *tbl;
struct ipa3_rt_tbl *rt_tbl;
u32 hw_len;
int id;
u16 prio;
u16 rule_id;
u8 cnt_idx;
bool ipacm_installed;
};
/**
* struct ipa3_rt_tbl - IPA routing table
* @link: table's link in global routing tables list
* @head_rt_rule_list: head of routing rules list
* @name: routing table name
* @idx: routing table index
* @rule_cnt: number of rules in routing table
* @ref_cnt: reference counter of routing table
* @set: collection of routing tables
* @cookie: cookie used for validity check
* @in_sys: flag indicating if the table is located in system memory
* @sz: the size of the routing table
* @curr_mem: current routing tables block in sys memory
* @prev_mem: previous routing table block in sys memory
* @id: routing table id
* @rule_ids: common idr structure that holds the rule_id for each rule
*/
struct ipa3_rt_tbl {
struct list_head link;
u32 cookie;
struct list_head head_rt_rule_list;
char name[IPA_RESOURCE_NAME_MAX];
u32 idx;
u32 rule_cnt;
u32 ref_cnt;
struct ipa3_rt_tbl_set *set;
bool in_sys[IPA_RULE_TYPE_MAX];
u32 sz[IPA_RULE_TYPE_MAX];
struct ipa_mem_buffer curr_mem[IPA_RULE_TYPE_MAX];
struct ipa_mem_buffer prev_mem[IPA_RULE_TYPE_MAX];
int id;
struct idr *rule_ids;
};
/**
* struct ipa3_hdr_entry - IPA header table entry
* @link: entry's link in global header table entries list
* @hdr: the header
* @hdr_len: header length
* @name: name of header table entry
* @type: l2 header type
* @is_partial: flag indicating if header table entry is partial
* @is_hdr_proc_ctx: false - hdr entry resides in hdr table,
* true - hdr entry resides in DDR and pointed to by proc ctx
* @phys_base: physical address of entry in DDR when is_hdr_proc_ctx is true,
* else 0
* @proc_ctx: processing context header
* @offset_entry: entry's offset
* @cookie: cookie used for validity check
* @ref_cnt: reference counter of routing table
* @id: header entry id
* @is_eth2_ofst_valid: is eth2_ofst field valid?
* @eth2_ofst: offset to start of Ethernet-II/802.3 header
* @user_deleted: is the header deleted by the user?
* @ipacm_installed: indicate if installed by ipacm
*/
struct ipa3_hdr_entry {
struct list_head link;
u32 cookie;
u8 hdr[IPA_HDR_MAX_SIZE];
u32 hdr_len;
char name[IPA_RESOURCE_NAME_MAX];
enum ipa_hdr_l2_type type;
u8 is_partial;
bool is_hdr_proc_ctx;
dma_addr_t phys_base;
struct ipa3_hdr_proc_ctx_entry *proc_ctx;
struct ipa_hdr_offset_entry *offset_entry;
u32 ref_cnt;
int id;
u8 is_eth2_ofst_valid;
u16 eth2_ofst;
bool user_deleted;
bool ipacm_installed;
};
/**
* struct ipa3_hdr_tbl - IPA header table
* @head_hdr_entry_list: header entries list
* @head_offset_list: header offset list
* @head_free_offset_list: header free offset list
* @hdr_cnt: number of headers
* @end: the last header index
*/
struct ipa3_hdr_tbl {
struct list_head head_hdr_entry_list;
struct list_head head_offset_list[IPA_HDR_BIN_MAX];
struct list_head head_free_offset_list[IPA_HDR_BIN_MAX];
u32 hdr_cnt;
u32 end;
};
/**
* struct ipa3_hdr_offset_entry - IPA header offset entry
* @link: entry's link in global processing context header offset entries list
* @offset: the offset
* @bin: bin
* @ipacm_installed: indicate if installed by ipacm
*/
struct ipa3_hdr_proc_ctx_offset_entry {
struct list_head link;
u32 offset;
u32 bin;
bool ipacm_installed;
};
/**
* struct ipa3_hdr_proc_ctx_entry - IPA processing context header table entry
* @link: entry's link in global header table entries list
* @type: header processing context type
* @l2tp_params: L2TP parameters
* @generic_params: generic proc_ctx params
* @offset_entry: entry's offset
* @hdr: the header
* @cookie: cookie used for validity check
* @ref_cnt: reference counter of routing table
* @id: processing context header entry id
* @user_deleted: is the hdr processing context deleted by the user?
* @ipacm_installed: indicate if installed by ipacm
*/
struct ipa3_hdr_proc_ctx_entry {
struct list_head link;
u32 cookie;
enum ipa_hdr_proc_type type;
struct ipa_l2tp_hdr_proc_ctx_params l2tp_params;
struct ipa_eth_II_to_eth_II_ex_procparams generic_params;
struct ipa3_hdr_proc_ctx_offset_entry *offset_entry;
struct ipa3_hdr_entry *hdr;
u32 ref_cnt;
int id;
bool user_deleted;
bool ipacm_installed;
};
/**
* struct ipa3_hdr_proc_ctx_tbl - IPA processing context header table
* @head_proc_ctx_entry_list: header entries list
* @head_offset_list: header offset list
* @head_free_offset_list: header free offset list
* @proc_ctx_cnt: number of processing context headers
* @end: the last processing context header index
* @start_offset: offset in words of processing context header table
*/
struct ipa3_hdr_proc_ctx_tbl {
struct list_head head_proc_ctx_entry_list;
struct list_head head_offset_list[IPA_HDR_PROC_CTX_BIN_MAX];
struct list_head head_free_offset_list[IPA_HDR_PROC_CTX_BIN_MAX];
u32 proc_ctx_cnt;
u32 end;
u32 start_offset;
};
/**
* struct ipa3_flt_tbl - IPA filter table
* @head_flt_rule_list: filter rules list
* @rule_cnt: number of filter rules
* @in_sys: flag indicating if filter table is located in system memory
* @sz: the size of the filter tables
* @end: the last header index
* @curr_mem: current filter tables block in sys memory
* @prev_mem: previous filter table block in sys memory
* @rule_ids: common idr structure that holds the rule_id for each rule
*/
struct ipa3_flt_tbl {
struct list_head head_flt_rule_list;
u32 rule_cnt;
bool in_sys[IPA_RULE_TYPE_MAX];
u32 sz[IPA_RULE_TYPE_MAX];
struct ipa_mem_buffer curr_mem[IPA_RULE_TYPE_MAX];
struct ipa_mem_buffer prev_mem[IPA_RULE_TYPE_MAX];
bool sticky_rear;
struct idr *rule_ids;
};
/**
* struct ipa3_rt_entry - IPA routing table entry
* @link: entry's link in global routing table entries list
* @rule: routing rule
* @cookie: cookie used for validity check
* @tbl: routing table
* @hdr: header table
* @proc_ctx: processing context table
* @hw_len: the length of the table
* @id: rule handle - globaly unique
* @prio: rule 10bit priority which defines the order of the rule
* among other rules at the integrated same table
* @rule_id: rule 10bit ID to be returned in packet status
* @rule_id_valid: indicate if rule_id_valid valid or not?
* @cnt_idx: stats counter index
* @ipacm_installed: indicate if installed by ipacm
*/
struct ipa3_rt_entry {
struct list_head link;
u32 cookie;
struct ipa_rt_rule_i rule;
struct ipa3_rt_tbl *tbl;
struct ipa3_hdr_entry *hdr;
struct ipa3_hdr_proc_ctx_entry *proc_ctx;
u32 hw_len;
int id;
u16 prio;
u16 rule_id;
u16 rule_id_valid;
u8 cnt_idx;
bool ipacm_installed;
};
/**
* struct ipa3_rt_tbl_set - collection of routing tables
* @head_rt_tbl_list: collection of routing tables
* @tbl_cnt: number of routing tables
* @rule_ids: idr structure that holds the rule_id for each rule
*/
struct ipa3_rt_tbl_set {
struct list_head head_rt_tbl_list;
u32 tbl_cnt;
struct idr rule_ids;
};
/**
* struct ipa3_wlan_stats - Wlan stats for each wlan endpoint
* @rx_pkts_rcvd: Packets sent by wlan driver
* @rx_pkts_status_rcvd: Status packets received from ipa hw
* @rx_hd_processed: Data Descriptors processed by IPA Driver
* @rx_hd_reply: Data Descriptors recycled by wlan driver
* @rx_hd_rcvd: Data Descriptors sent by wlan driver
* @rx_pkt_leak: Packet count that are not recycled
* @rx_dp_fail: Packets failed to transfer to IPA HW
* @tx_pkts_rcvd: SKB Buffers received from ipa hw
* @tx_pkts_sent: SKB Buffers sent to wlan driver
* @tx_pkts_dropped: Dropped packets count
*/
struct ipa3_wlan_stats {
u32 rx_pkts_rcvd;
u32 rx_pkts_status_rcvd;
u32 rx_hd_processed;
u32 rx_hd_reply;
u32 rx_hd_rcvd;
u32 rx_pkt_leak;
u32 rx_dp_fail;
u32 tx_pkts_rcvd;
u32 tx_pkts_sent;
u32 tx_pkts_dropped;
};
/**
* struct ipa3_wlan_comm_memb - Wlan comm members
* @wlan_spinlock: protects wlan comm buff list and its size
* @ipa_tx_mul_spinlock: protects tx dp mul transfer
* @wlan_comm_total_cnt: wlan common skb buffers allocated count
* @wlan_comm_free_cnt: wlan common skb buffer free count
* @total_tx_pkts_freed: Recycled Buffer count
* @wlan_comm_desc_list: wlan common skb buffer list
*/
struct ipa3_wlan_comm_memb {
spinlock_t wlan_spinlock;
spinlock_t ipa_tx_mul_spinlock;
u32 wlan_comm_total_cnt;
u32 wlan_comm_free_cnt;
u32 total_tx_pkts_freed;
struct list_head wlan_comm_desc_list;
atomic_t active_clnt_cnt;
};
struct ipa_gsi_ep_mem_info {
u16 evt_ring_len;
u64 evt_ring_base_addr;
void *evt_ring_base_vaddr;
u16 chan_ring_len;
u64 chan_ring_base_addr;
void *chan_ring_base_vaddr;
};
struct ipa3_status_stats {
struct ipahal_pkt_status status[IPA_MAX_STATUS_STAT_NUM];
unsigned int curr;
};
/**
* struct ipa3_ep_context - IPA end point context
* @valid: flag indicating id EP context is valid
* @client: EP client type
* @gsi_chan_hdl: EP's GSI channel handle
* @gsi_evt_ring_hdl: EP's GSI channel event ring handle
* @gsi_mem_info: EP's GSI channel rings info
* @chan_scratch: EP's GSI channel scratch info
* @cfg: EP cionfiguration
* @dst_pipe_index: destination pipe index
* @rt_tbl_idx: routing table index
* @priv: user provided information which will forwarded once the user is
* notified for new data avail
* @client_notify: user provided CB for EP events notification, the event is
* data revived.
* @skip_ep_cfg: boolean field that determines if EP should be configured
* by IPA driver
* @keep_ipa_awake: when true, IPA will not be clock gated
* @disconnect_in_progress: Indicates client disconnect in progress.
* @qmi_request_sent: Indicates whether QMI request to enable clear data path
* request is sent or not.
* @client_lock_unlock: callback function to take mutex lock/unlock for USB
* clients
*/
struct ipa3_ep_context {
int valid;
enum ipa_client_type client;
unsigned long gsi_chan_hdl;
unsigned long gsi_evt_ring_hdl;
struct ipa_gsi_ep_mem_info gsi_mem_info;
union __packed gsi_channel_scratch chan_scratch;
struct gsi_chan_xfer_notify xfer_notify;
bool xfer_notify_valid;
struct ipa_ep_cfg cfg;
struct ipa_ep_cfg_holb holb;
struct ipahal_reg_ep_cfg_status status;
u32 dst_pipe_index;
u32 rt_tbl_idx;
void *priv;
void (*client_notify)(void *priv, enum ipa_dp_evt_type evt,
unsigned long data);
atomic_t avail_fifo_desc;
u32 dflt_flt4_rule_hdl;
u32 dflt_flt6_rule_hdl;
bool skip_ep_cfg;
bool keep_ipa_awake;
struct ipa3_wlan_stats wstats;
u32 uc_offload_state;
u32 gsi_offload_state;
bool disconnect_in_progress;
u32 qmi_request_sent;
u32 eot_in_poll_err;
bool ep_delay_set;
/* sys MUST be the last element of this struct */
struct ipa3_sys_context *sys;
};
/**
* ipa_usb_xdci_chan_params - xDCI channel related properties
*
* @ipa_ep_cfg: IPA EP configuration
* @client: type of "client"
* @priv: callback cookie
* @notify: callback
* priv - callback cookie evt - type of event data - data relevant
* to event. May not be valid. See event_type enum for valid
* cases.
* @skip_ep_cfg: boolean field that determines if EP should be
* configured by IPA driver
* @keep_ipa_awake: when true, IPA will not be clock gated
* @evt_ring_params: parameters for the channel's event ring
* @evt_scratch: parameters for the channel's event ring scratch
* @chan_params: parameters for the channel
* @chan_scratch: parameters for the channel's scratch
*
*/
struct ipa_request_gsi_channel_params {
struct ipa_ep_cfg ipa_ep_cfg;
enum ipa_client_type client;
void *priv;
ipa_notify_cb notify;
bool skip_ep_cfg;
bool keep_ipa_awake;
struct gsi_evt_ring_props evt_ring_params;
union __packed gsi_evt_scratch evt_scratch;
struct gsi_chan_props chan_params;
union __packed gsi_channel_scratch chan_scratch;
};
enum ipa3_sys_pipe_policy {
IPA_POLICY_INTR_MODE,
IPA_POLICY_NOINTR_MODE,
IPA_POLICY_INTR_POLL_MODE,
};
struct ipa3_repl_ctx {
struct ipa3_rx_pkt_wrapper **cache;
atomic_t head_idx;
atomic_t tail_idx;
u32 capacity;
atomic_t pending;
};
/**
* struct ipa3_sys_context - IPA GPI pipes context
* @head_desc_list: header descriptors list
* @len: the size of the above list
* @spinlock: protects the list and its size
* @ep: IPA EP context
* @xmit_eot_cnt: count of pending eot for tasklet to process
* @tasklet: tasklet for eot write_done handle (tx_complete)
*
* IPA context specific to the GPI pipes a.k.a LAN IN/OUT and WAN
*/
struct ipa3_sys_context {
u32 len;
atomic_t curr_polling_state;
atomic_t workqueue_flushed;
struct delayed_work switch_to_intr_work;
enum ipa3_sys_pipe_policy policy;
bool use_comm_evt_ring;
bool nop_pending;
int (*pyld_hdlr)(struct sk_buff *skb, struct ipa3_sys_context *sys);
struct sk_buff * (*get_skb)(unsigned int len, gfp_t flags);
void (*free_skb)(struct sk_buff *skb);
void (*free_rx_wrapper)(struct ipa3_rx_pkt_wrapper *rk_pkt);
u32 rx_buff_sz;
u32 rx_pool_sz;
struct sk_buff *prev_skb;
unsigned int len_rem;
unsigned int len_pad;
unsigned int len_partial;
bool drop_packet;
struct work_struct work;
struct delayed_work replenish_rx_work;
struct work_struct repl_work;
void (*repl_hdlr)(struct ipa3_sys_context *sys);