1 /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
2 /*
3  * Copyright (c) 2012-2020, The Linux Foundation. All rights reserved.
4  */
5 
6 #ifndef _MSM_IPA_H_
7 #define _MSM_IPA_H_
8 
9 #include <stdio.h>
10 #include <stdint.h>
11 #include <stddef.h>
12 #include <sys/stat.h>
13 #include <linux/ioctl.h>
14 #include <linux/types.h>
15 #include <linux/if_ether.h>
16 
17 /**
18  * unique magic number of the IPA device
19  */
20 #define IPA_IOC_MAGIC 0xCF
21 
22 /**
23  * IPA device full path
24  */
25 #define IPA_DEV_NAME "/dev/ipa"
26 
27 /**
28  * IPA NAT table character device name
29  */
30 #define IPA_NAT_DEV_NAME "ipaNatTable"
31 
32 /**
33  * IPA IPv6CT table character device name
34  */
35 #define IPA_IPV6CT_DEV_NAME "ipaIpv6CTTable"
36 
37 /**
38  * name of the default routing tables for v4 and v6
39  */
40 #define IPA_DFLT_RT_TBL_NAME "ipa_dflt_rt"
41 
42 /**
43  * name for default value of invalid protocol of NAT
44  */
45 #define IPAHAL_NAT_INVALID_PROTOCOL   0xFF
46 
47 /**
48  * commands supported by IPA driver
49  */
50 #define IPA_IOCTL_ADD_HDR                       0
51 #define IPA_IOCTL_DEL_HDR                       1
52 #define IPA_IOCTL_ADD_RT_RULE                   2
53 #define IPA_IOCTL_DEL_RT_RULE                   3
54 #define IPA_IOCTL_ADD_FLT_RULE                  4
55 #define IPA_IOCTL_DEL_FLT_RULE                  5
56 #define IPA_IOCTL_COMMIT_HDR                    6
57 #define IPA_IOCTL_RESET_HDR                     7
58 #define IPA_IOCTL_COMMIT_RT                     8
59 #define IPA_IOCTL_RESET_RT                      9
60 #define IPA_IOCTL_COMMIT_FLT                    10
61 #define IPA_IOCTL_RESET_FLT                     11
62 #define IPA_IOCTL_DUMP                          12
63 #define IPA_IOCTL_GET_RT_TBL                    13
64 #define IPA_IOCTL_PUT_RT_TBL                    14
65 #define IPA_IOCTL_COPY_HDR                      15
66 #define IPA_IOCTL_QUERY_INTF                    16
67 #define IPA_IOCTL_QUERY_INTF_TX_PROPS           17
68 #define IPA_IOCTL_QUERY_INTF_RX_PROPS           18
69 #define IPA_IOCTL_GET_HDR                       19
70 #define IPA_IOCTL_PUT_HDR                       20
71 #define IPA_IOCTL_SET_FLT                       21
72 #define IPA_IOCTL_ALLOC_NAT_MEM                 22
73 #define IPA_IOCTL_V4_INIT_NAT                   23
74 #define IPA_IOCTL_TABLE_DMA_CMD                 24
75 #define IPA_IOCTL_NAT_DMA                       IPA_IOCTL_TABLE_DMA_CMD
76 #define IPA_IOCTL_INIT_IPV6CT_TABLE             25
77 #define IPA_IOCTL_V4_DEL_NAT                    26
78 #define IPA_IOCTL_PULL_MSG                      27
79 #define IPA_IOCTL_GET_NAT_OFFSET                28
80 #define IPA_IOCTL_RM_ADD_DEPENDENCY             29
81 #define IPA_IOCTL_RM_DEL_DEPENDENCY             30
82 #define IPA_IOCTL_GENERATE_FLT_EQ               31
83 #define IPA_IOCTL_QUERY_INTF_EXT_PROPS          32
84 #define IPA_IOCTL_QUERY_EP_MAPPING              33
85 #define IPA_IOCTL_QUERY_RT_TBL_INDEX            34
86 #define IPA_IOCTL_WRITE_QMAPID                  35
87 #define IPA_IOCTL_MDFY_FLT_RULE                 36
88 #define IPA_IOCTL_NOTIFY_WAN_UPSTREAM_ROUTE_ADD 37
89 #define IPA_IOCTL_NOTIFY_WAN_UPSTREAM_ROUTE_DEL 38
90 #define IPA_IOCTL_NOTIFY_WAN_EMBMS_CONNECTED    39
91 #define IPA_IOCTL_ADD_HDR_PROC_CTX              40
92 #define IPA_IOCTL_DEL_HDR_PROC_CTX              41
93 #define IPA_IOCTL_MDFY_RT_RULE                  42
94 #define IPA_IOCTL_ADD_RT_RULE_AFTER             43
95 #define IPA_IOCTL_ADD_FLT_RULE_AFTER            44
96 #define IPA_IOCTL_GET_HW_VERSION                45
97 #define IPA_IOCTL_ADD_RT_RULE_EXT               46
98 #define IPA_IOCTL_ADD_VLAN_IFACE                47
99 #define IPA_IOCTL_DEL_VLAN_IFACE                48
100 #define IPA_IOCTL_ADD_L2TP_VLAN_MAPPING         49
101 #define IPA_IOCTL_DEL_L2TP_VLAN_MAPPING         50
102 #define IPA_IOCTL_NAT_MODIFY_PDN                51
103 #define IPA_IOCTL_ALLOC_NAT_TABLE               52
104 #define IPA_IOCTL_ALLOC_IPV6CT_TABLE            53
105 #define IPA_IOCTL_DEL_NAT_TABLE                 54
106 #define IPA_IOCTL_DEL_IPV6CT_TABLE              55
107 #define IPA_IOCTL_CLEANUP                       56
108 #define IPA_IOCTL_QUERY_WLAN_CLIENT             57
109 #define IPA_IOCTL_GET_VLAN_MODE                 58
110 #define IPA_IOCTL_ADD_BRIDGE_VLAN_MAPPING       59
111 #define IPA_IOCTL_DEL_BRIDGE_VLAN_MAPPING       60
112 #define IPA_IOCTL_ODL_QUERY_ADAPL_EP_INFO       61
113 #define IPA_IOCTL_ODL_GET_AGG_BYTE_LIMIT        62
114 #define IPA_IOCTL_ODL_QUERY_MODEM_CONFIG        63
115 #define IPA_IOCTL_GSB_CONNECT                   64
116 #define IPA_IOCTL_GSB_DISCONNECT                65
117 #define IPA_IOCTL_WIGIG_FST_SWITCH              66
118 #define IPA_IOCTL_ADD_RT_RULE_V2                67
119 #define IPA_IOCTL_ADD_RT_RULE_EXT_V2            68
120 #define IPA_IOCTL_ADD_RT_RULE_AFTER_V2          69
121 #define IPA_IOCTL_MDFY_RT_RULE_V2               70
122 #define IPA_IOCTL_ADD_FLT_RULE_V2               71
123 #define IPA_IOCTL_ADD_FLT_RULE_AFTER_V2         72
124 #define IPA_IOCTL_MDFY_FLT_RULE_V2              73
125 #define IPA_IOCTL_FNR_COUNTER_ALLOC             74
126 #define IPA_IOCTL_FNR_COUNTER_DEALLOC           75
127 #define IPA_IOCTL_FNR_COUNTER_QUERY             76
128 #define IPA_IOCTL_SET_FNR_COUNTER_INFO          77
129 #define IPA_IOCTL_GET_NAT_IN_SRAM_INFO          78
130 #define IPA_IOCTL_APP_CLOCK_VOTE                79
131 
132 /**
133  * max size of the header to be inserted
134  */
135 #define IPA_HDR_MAX_SIZE 64
136 
137 /**
138  * max size of the name of the resource (routing table, header)
139  */
140 #define IPA_RESOURCE_NAME_MAX 32
141 
142 /**
143  * max number of interface properties
144  */
145 #define IPA_NUM_PROPS_MAX 35
146 
147 /**
148  * size of the mac address
149  */
150 #define IPA_MAC_ADDR_SIZE  6
151 
152 /**
153  * max number of mbim streams
154  */
155 #define IPA_MBIM_MAX_STREAM_NUM 8
156 
157 /**
158  *  size of the ipv6 address
159  */
160 #define IPA_WAN_MSG_IPv6_ADDR_GW_LEN 4
161 
162 /**
163  * max number of lan clients supported per device type
164  * for LAN stats via HW.
165  */
166 #define IPA_MAX_NUM_HW_PATH_CLIENTS 16
167 
168 /**
169  * max number of destination pipes possible for a client.
170  */
171 #define QMI_IPA_MAX_CLIENT_DST_PIPES 4
172 
173 /**
174  * MAX number of the FLT_RT stats counter supported.
175  */
176 #define IPA_MAX_FLT_RT_CNT_INDEX (128)
177 #define IPA_FLT_RT_HW_COUNTER (120)
178 #define IPA_FLT_RT_SW_COUNTER \
179 	(IPA_MAX_FLT_RT_CNT_INDEX - IPA_FLT_RT_HW_COUNTER)
180 
181 /**
182  * the attributes of the rule (routing or filtering)
183  */
184 #define IPA_FLT_TOS			(1ul << 0)
185 #define IPA_FLT_PROTOCOL		(1ul << 1)
186 #define IPA_FLT_SRC_ADDR		(1ul << 2)
187 #define IPA_FLT_DST_ADDR		(1ul << 3)
188 #define IPA_FLT_SRC_PORT_RANGE		(1ul << 4)
189 #define IPA_FLT_DST_PORT_RANGE		(1ul << 5)
190 #define IPA_FLT_TYPE			(1ul << 6)
191 #define IPA_FLT_CODE			(1ul << 7)
192 #define IPA_FLT_SPI			(1ul << 8)
193 #define IPA_FLT_SRC_PORT		(1ul << 9)
194 #define IPA_FLT_DST_PORT		(1ul << 10)
195 #define IPA_FLT_TC			(1ul << 11)
196 #define IPA_FLT_FLOW_LABEL		(1ul << 12)
197 #define IPA_FLT_NEXT_HDR		(1ul << 13)
198 #define IPA_FLT_META_DATA		(1ul << 14)
199 #define IPA_FLT_FRAGMENT		(1ul << 15)
200 #define IPA_FLT_TOS_MASKED		(1ul << 16)
201 #define IPA_FLT_MAC_SRC_ADDR_ETHER_II	(1ul << 17)
202 #define IPA_FLT_MAC_DST_ADDR_ETHER_II	(1ul << 18)
203 #define IPA_FLT_MAC_SRC_ADDR_802_3	(1ul << 19)
204 #define IPA_FLT_MAC_DST_ADDR_802_3	(1ul << 20)
205 #define IPA_FLT_MAC_ETHER_TYPE		(1ul << 21)
206 #define IPA_FLT_MAC_DST_ADDR_L2TP	(1ul << 22)
207 #define IPA_FLT_TCP_SYN			(1ul << 23)
208 #define IPA_FLT_TCP_SYN_L2TP		(1ul << 24)
209 #define IPA_FLT_L2TP_INNER_IP_TYPE	(1ul << 25)
210 #define IPA_FLT_L2TP_INNER_IPV4_DST_ADDR (1ul << 26)
211 #define IPA_FLT_IS_PURE_ACK		(1ul << 27)
212 #define IPA_FLT_VLAN_ID			(1ul << 28)
213 #define IPA_FLT_MAC_SRC_ADDR_802_1Q	(1ul << 29)
214 #define IPA_FLT_MAC_DST_ADDR_802_1Q	(1ul << 30)
215 
216 /**
217  * maximal number of NAT PDNs in the PDN config table
218  */
219 #define IPA_MAX_PDN_NUM 5
220 
221 /**
222  * enum ipa_client_type - names for the various IPA "clients"
223  * these are from the perspective of the clients, for e.g.
224  * HSIC1_PROD means HSIC client is the producer and IPA is the
225  * consumer.
226  * PROD clients are always even, and CONS clients are always odd.
227  * Add new clients in the end of the list or replace reserved one,
228  * update IPA_CLIENT_MAX and update the strings array ipa_clients_strings[]
229  * while keeping the ordering of the clients the same
230  */
231 enum ipa_client_type {
232 	IPA_CLIENT_HSIC1_PROD			= 0,
233 	IPA_CLIENT_HSIC1_CONS			= 1,
234 
235 	IPA_CLIENT_HSIC2_PROD			= 2,
236 	IPA_CLIENT_HSIC2_CONS			= 3,
237 
238 	IPA_CLIENT_HSIC3_PROD			= 4,
239 	IPA_CLIENT_HSIC3_CONS			= 5,
240 
241 	IPA_CLIENT_HSIC4_PROD			= 6,
242 	IPA_CLIENT_HSIC4_CONS			= 7,
243 
244 	IPA_CLIENT_HSIC5_PROD			= 8,
245 	IPA_CLIENT_HSIC5_CONS			= 9,
246 
247 	IPA_CLIENT_WLAN1_PROD			= 10,
248 	IPA_CLIENT_WLAN1_CONS			= 11,
249 
250 	IPA_CLIENT_A5_WLAN_AMPDU_PROD		= 12,
251 	IPA_CLIENT_WLAN2_CONS			= 13,
252 
253 	/* RESERVED PROD			= 14, */
254 	IPA_CLIENT_WLAN3_CONS			= 15,
255 
256 	/* RESERVED PROD			= 16, */
257 	IPA_CLIENT_WLAN4_CONS			= 17,
258 
259 	IPA_CLIENT_USB_PROD			= 18,
260 	IPA_CLIENT_USB_CONS			= 19,
261 
262 	IPA_CLIENT_USB2_PROD			= 20,
263 	IPA_CLIENT_USB2_CONS			= 21,
264 
265 	IPA_CLIENT_USB3_PROD			= 22,
266 	IPA_CLIENT_USB3_CONS			= 23,
267 
268 	IPA_CLIENT_USB4_PROD			= 24,
269 	IPA_CLIENT_USB4_CONS			= 25,
270 
271 	IPA_CLIENT_UC_USB_PROD			= 26,
272 	IPA_CLIENT_USB_DPL_CONS			= 27,
273 
274 	IPA_CLIENT_A2_EMBEDDED_PROD		= 28,
275 	IPA_CLIENT_A2_EMBEDDED_CONS		= 29,
276 
277 	IPA_CLIENT_A2_TETHERED_PROD		= 30,
278 	IPA_CLIENT_A2_TETHERED_CONS		= 31,
279 
280 	IPA_CLIENT_APPS_LAN_PROD		= 32,
281 	IPA_CLIENT_APPS_LAN_CONS		= 33,
282 
283 	IPA_CLIENT_APPS_WAN_PROD		= 34,
284 	IPA_CLIENT_APPS_LAN_WAN_PROD = IPA_CLIENT_APPS_WAN_PROD,
285 	IPA_CLIENT_APPS_WAN_CONS		= 35,
286 
287 	IPA_CLIENT_APPS_CMD_PROD		= 36,
288 	IPA_CLIENT_A5_LAN_WAN_CONS		= 37,
289 
290 	IPA_CLIENT_ODU_PROD			= 38,
291 	IPA_CLIENT_ODU_EMB_CONS			= 39,
292 
293 	/* RESERVED PROD			= 40, */
294 	IPA_CLIENT_ODU_TETH_CONS		= 41,
295 
296 	IPA_CLIENT_MHI_PROD			= 42,
297 	IPA_CLIENT_MHI_CONS			= 43,
298 
299 	IPA_CLIENT_MEMCPY_DMA_SYNC_PROD		= 44,
300 	IPA_CLIENT_MEMCPY_DMA_SYNC_CONS		= 45,
301 
302 	IPA_CLIENT_MEMCPY_DMA_ASYNC_PROD	= 46,
303 	IPA_CLIENT_MEMCPY_DMA_ASYNC_CONS	= 47,
304 
305 	IPA_CLIENT_ETHERNET_PROD		= 48,
306 	IPA_CLIENT_ETHERNET_CONS		= 49,
307 
308 	IPA_CLIENT_Q6_LAN_PROD			= 50,
309 	IPA_CLIENT_Q6_LAN_CONS			= 51,
310 
311 	IPA_CLIENT_Q6_WAN_PROD			= 52,
312 	IPA_CLIENT_Q6_WAN_CONS			= 53,
313 
314 	IPA_CLIENT_Q6_CMD_PROD			= 54,
315 	IPA_CLIENT_Q6_DUN_CONS			= 55,
316 
317 	IPA_CLIENT_Q6_DECOMP_PROD		= 56,
318 	IPA_CLIENT_Q6_DECOMP_CONS		= 57,
319 
320 	IPA_CLIENT_Q6_DECOMP2_PROD		= 58,
321 	IPA_CLIENT_Q6_DECOMP2_CONS		= 59,
322 
323 	/* RESERVED PROD			= 60, */
324 	IPA_CLIENT_Q6_LTE_WIFI_AGGR_CONS	= 61,
325 
326 	IPA_CLIENT_TEST_PROD			= 62,
327 	IPA_CLIENT_TEST_CONS			= 63,
328 
329 	IPA_CLIENT_TEST1_PROD			= 64,
330 	IPA_CLIENT_TEST1_CONS			= 65,
331 
332 	IPA_CLIENT_TEST2_PROD			= 66,
333 	IPA_CLIENT_TEST2_CONS			= 67,
334 
335 	IPA_CLIENT_TEST3_PROD			= 68,
336 	IPA_CLIENT_TEST3_CONS			= 69,
337 
338 	IPA_CLIENT_TEST4_PROD			= 70,
339 	IPA_CLIENT_TEST4_CONS			= 71,
340 
341 	/* RESERVED PROD			= 72, */
342 	IPA_CLIENT_DUMMY_CONS			= 73,
343 
344 	IPA_CLIENT_Q6_DL_NLO_DATA_PROD		= 74,
345 	IPA_CLIENT_Q6_UL_NLO_DATA_CONS		= 75,
346 
347 	/* RESERVERD PROD			= 76, */
348 	IPA_CLIENT_Q6_UL_NLO_ACK_CONS		= 77,
349 
350 	/* RESERVERD PROD			= 78, */
351 	IPA_CLIENT_Q6_QBAP_STATUS_CONS		= 79,
352 
353 	/* RESERVERD PROD			= 80, */
354 	IPA_CLIENT_MHI_DPL_CONS			= 81,
355 
356 	/* RESERVERD PROD			= 82, */
357 	IPA_CLIENT_ODL_DPL_CONS			= 83,
358 
359 	IPA_CLIENT_Q6_AUDIO_DMA_MHI_PROD	= 84,
360 	IPA_CLIENT_Q6_AUDIO_DMA_MHI_CONS	= 85,
361 
362 	IPA_CLIENT_WIGIG_PROD			= 86,
363 	IPA_CLIENT_WIGIG1_CONS			= 87,
364 
365 	/* RESERVERD PROD			= 88, */
366 	IPA_CLIENT_WIGIG2_CONS			= 89,
367 
368 	/* RESERVERD PROD			= 90, */
369 	IPA_CLIENT_WIGIG3_CONS			= 91,
370 
371 	/* RESERVERD PROD			= 92, */
372 	IPA_CLIENT_WIGIG4_CONS			= 93,
373 
374 	/* RESERVED PROD			= 94, */
375 	IPA_CLIENT_APPS_WAN_COAL_CONS		= 95,
376 
377 	IPA_CLIENT_MHI_PRIME_TETH_PROD		= 96,
378 	IPA_CLIENT_MHI_PRIME_TETH_CONS		= 97,
379 
380 	IPA_CLIENT_MHI_PRIME_RMNET_PROD		= 98,
381 	IPA_CLIENT_MHI_PRIME_RMNET_CONS		= 99,
382 
383 	IPA_CLIENT_MHI_PRIME_DPL_PROD		= 100,
384 	/* RESERVED CONS                        = 101, */
385 
386 	IPA_CLIENT_AQC_ETHERNET_PROD		= 102,
387 	IPA_CLIENT_AQC_ETHERNET_CONS		= 103,
388 };
389 
390 #define IPA_CLIENT_MAX (IPA_CLIENT_AQC_ETHERNET_CONS + 1)
391 
392 #define IPA_CLIENT_WLAN2_PROD IPA_CLIENT_A5_WLAN_AMPDU_PROD
393 #define IPA_CLIENT_Q6_DL_NLO_DATA_PROD IPA_CLIENT_Q6_DL_NLO_DATA_PROD
394 #define IPA_CLIENT_Q6_UL_NLO_ACK_CONS IPA_CLIENT_Q6_UL_NLO_ACK_CONS
395 #define IPA_CLIENT_Q6_QBAP_STATUS_CONS IPA_CLIENT_Q6_QBAP_STATUS_CONS
396 #define IPA_CLIENT_MHI_DPL_CONS IPA_CLIENT_MHI_DPL_CONS
397 #define IPA_CLIENT_Q6_AUDIO_DMA_MHI_PROD IPA_CLIENT_Q6_AUDIO_DMA_MHI_PROD
398 #define IPA_CLIENT_Q6_AUDIO_DMA_MHI_CONS IPA_CLIENT_Q6_AUDIO_DMA_MHI_CONS
399 #define IPA_CLIENT_WIGIG_PROD IPA_CLIENT_WIGIG_PROD
400 #define IPA_CLIENT_WIGIG1_CONS IPA_CLIENT_WIGIG1_CONS
401 #define IPA_CLIENT_WIGIG2_CONS IPA_CLIENT_WIGIG2_CONS
402 #define IPA_CLIENT_WIGIG3_CONS IPA_CLIENT_WIGIG3_CONS
403 #define IPA_CLIENT_WIGIG4_CONS IPA_CLIENT_WIGIG4_CONS
404 #define IPA_CLIENT_APPS_WAN_COAL_CONS IPA_CLIENT_APPS_WAN_COAL_CONS
405 #define IPA_CLIENT_MHI_PRIME_TETH_PROD IPA_CLIENT_MHI_PRIME_TETH_PROD
406 #define IPA_CLIENT_MHI_PRIME_TETH_CONS IPA_CLIENT_MHI_PRIME_TETH_CONS
407 #define IPA_CLIENT_MHI_PRIME_RMNET_PROD IPA_CLIENT_MHI_PRIME_RMNET_PROD
408 #define IPA_CLIENT_MHI_PRIME_RMNET_CONS IPA_CLIENT_MHI_PRIME_RMNET_CONS
409 #define IPA_CLIENT_MHI_PRIME_DPL_PROD IPA_CLIENT_MHI_PRIME_DPL_PROD
410 #define IPA_CLIENT_AQC_ETHERNET_PROD IPA_CLIENT_AQC_ETHERNET_PROD
411 #define IPA_CLIENT_AQC_ETHERNET_CONS IPA_CLIENT_AQC_ETHERNET_CONS
412 
413 #define IPA_CLIENT_IS_APPS_CONS(client) \
414 	((client) == IPA_CLIENT_APPS_LAN_CONS || \
415 	(client) == IPA_CLIENT_APPS_WAN_CONS || \
416 	(client) == IPA_CLIENT_APPS_WAN_COAL_CONS)
417 
418 #define IPA_CLIENT_IS_APPS_PROD(client) \
419 	((client) == IPA_CLIENT_APPS_LAN_PROD || \
420 	(client) == IPA_CLIENT_APPS_WAN_PROD)
421 
422 #define IPA_CLIENT_IS_USB_CONS(client) \
423 	((client) == IPA_CLIENT_USB_CONS || \
424 	(client) == IPA_CLIENT_USB2_CONS || \
425 	(client) == IPA_CLIENT_USB3_CONS || \
426 	(client) == IPA_CLIENT_USB_DPL_CONS || \
427 	(client) == IPA_CLIENT_USB4_CONS)
428 
429 #define IPA_CLIENT_IS_WAN_CONS(client) \
430 	((client) == IPA_CLIENT_APPS_WAN_CONS || \
431 	(client) == IPA_CLIENT_APPS_WAN_COAL_CONS)
432 
433 #define IPA_CLIENT_IS_WLAN_CONS(client) \
434 	((client) == IPA_CLIENT_WLAN1_CONS || \
435 	(client) == IPA_CLIENT_WLAN2_CONS || \
436 	(client) == IPA_CLIENT_WLAN3_CONS || \
437 	(client) == IPA_CLIENT_WLAN4_CONS)
438 
439 #define IPA_CLIENT_IS_ODU_CONS(client) \
440 	((client) == IPA_CLIENT_ODU_EMB_CONS || \
441 	(client) == IPA_CLIENT_ODU_TETH_CONS)
442 
443 #define IPA_CLIENT_IS_Q6_CONS(client) \
444 	((client) == IPA_CLIENT_Q6_LAN_CONS || \
445 	(client) == IPA_CLIENT_Q6_WAN_CONS || \
446 	(client) == IPA_CLIENT_Q6_DUN_CONS || \
447 	(client) == IPA_CLIENT_Q6_DECOMP_CONS || \
448 	(client) == IPA_CLIENT_Q6_DECOMP2_CONS || \
449 	(client) == IPA_CLIENT_Q6_LTE_WIFI_AGGR_CONS || \
450 	(client) == IPA_CLIENT_Q6_UL_NLO_DATA_CONS || \
451 	(client) == IPA_CLIENT_Q6_UL_NLO_ACK_CONS || \
452 	(client) == IPA_CLIENT_Q6_QBAP_STATUS_CONS || \
453 	(client) == IPA_CLIENT_Q6_AUDIO_DMA_MHI_CONS)
454 
455 #define IPA_CLIENT_IS_Q6_PROD(client) \
456 	((client) == IPA_CLIENT_Q6_LAN_PROD || \
457 	(client) == IPA_CLIENT_Q6_WAN_PROD || \
458 	(client) == IPA_CLIENT_Q6_CMD_PROD || \
459 	(client) == IPA_CLIENT_Q6_DECOMP_PROD || \
460 	(client) == IPA_CLIENT_Q6_DECOMP2_PROD || \
461 	(client) == IPA_CLIENT_Q6_DL_NLO_DATA_PROD || \
462 	(client) == IPA_CLIENT_Q6_AUDIO_DMA_MHI_PROD)
463 
464 #define IPA_CLIENT_IS_Q6_NON_ZIP_CONS(client) \
465 	((client) == IPA_CLIENT_Q6_LAN_CONS || \
466 	(client) == IPA_CLIENT_Q6_WAN_CONS || \
467 	(client) == IPA_CLIENT_Q6_DUN_CONS || \
468 	(client) == IPA_CLIENT_Q6_LTE_WIFI_AGGR_CONS || \
469 	(client) == IPA_CLIENT_Q6_UL_NLO_DATA_CONS || \
470 	(client) == IPA_CLIENT_Q6_UL_NLO_ACK_CONS || \
471 	(client) == IPA_CLIENT_Q6_QBAP_STATUS_CONS || \
472 	(client) == IPA_CLIENT_Q6_AUDIO_DMA_MHI_CONS)
473 
474 #define IPA_CLIENT_IS_Q6_ZIP_CONS(client) \
475 	((client) == IPA_CLIENT_Q6_DECOMP_CONS || \
476 	(client) == IPA_CLIENT_Q6_DECOMP2_CONS)
477 
478 #define IPA_CLIENT_IS_Q6_NON_ZIP_PROD(client) \
479 	((client) == IPA_CLIENT_Q6_LAN_PROD || \
480 	(client) == IPA_CLIENT_Q6_WAN_PROD || \
481 	(client) == IPA_CLIENT_Q6_CMD_PROD || \
482 	(client) == IPA_CLIENT_Q6_DL_NLO_DATA_PROD || \
483 	(client) == IPA_CLIENT_Q6_AUDIO_DMA_MHI_PROD)
484 
485 #define IPA_CLIENT_IS_Q6_ZIP_PROD(client) \
486 	((client) == IPA_CLIENT_Q6_DECOMP_PROD || \
487 	(client) == IPA_CLIENT_Q6_DECOMP2_PROD)
488 
489 #define IPA_CLIENT_IS_MEMCPY_DMA_CONS(client) \
490 	((client) == IPA_CLIENT_MEMCPY_DMA_SYNC_CONS || \
491 	(client) == IPA_CLIENT_MEMCPY_DMA_ASYNC_CONS)
492 
493 #define IPA_CLIENT_IS_MEMCPY_DMA_PROD(client) \
494 	((client) == IPA_CLIENT_MEMCPY_DMA_SYNC_PROD || \
495 	(client) == IPA_CLIENT_MEMCPY_DMA_ASYNC_PROD)
496 
497 #define IPA_CLIENT_IS_MHI_CONS(client) \
498 	((client) == IPA_CLIENT_MHI_CONS || \
499 	(client) == IPA_CLIENT_MHI_DPL_CONS)
500 
501 #define IPA_CLIENT_IS_MHI(client) \
502 	((client) == IPA_CLIENT_MHI_CONS || \
503 	(client) == IPA_CLIENT_MHI_PROD || \
504 	(client) == IPA_CLIENT_MHI_DPL_CONS)
505 
506 #define IPA_CLIENT_IS_TEST_PROD(client) \
507 	((client) == IPA_CLIENT_TEST_PROD || \
508 	(client) == IPA_CLIENT_TEST1_PROD || \
509 	(client) == IPA_CLIENT_TEST2_PROD || \
510 	(client) == IPA_CLIENT_TEST3_PROD || \
511 	(client) == IPA_CLIENT_TEST4_PROD)
512 
513 #define IPA_CLIENT_IS_TEST_CONS(client) \
514 	((client) == IPA_CLIENT_TEST_CONS || \
515 	(client) == IPA_CLIENT_TEST1_CONS || \
516 	(client) == IPA_CLIENT_TEST2_CONS || \
517 	(client) == IPA_CLIENT_TEST3_CONS || \
518 	(client) == IPA_CLIENT_TEST4_CONS)
519 
520 #define IPA_CLIENT_IS_TEST(client) \
521 	(IPA_CLIENT_IS_TEST_PROD(client) || IPA_CLIENT_IS_TEST_CONS(client))
522 
523 /**
524  * The following is used to describe the types of memory NAT can
525  * reside in.
526  *
527  * PLEASE KEEP THE FOLLOWING IN SYNC WITH ipa3_nat_mem_in_as_str()
528  * BELOW.
529  */
530 enum ipa3_nat_mem_in {
531 	IPA_NAT_MEM_IN_DDR  = 0,
532 	IPA_NAT_MEM_IN_SRAM = 1,
533 
534 	IPA_NAT_MEM_IN_MAX
535 };
536 
537 #define IPA_VALID_NAT_MEM_IN(t) \
538 	((t) >= IPA_NAT_MEM_IN_DDR && (t) < IPA_NAT_MEM_IN_MAX)
539 
540 /**
541  * enum ipa_ip_type - Address family: IPv4 or IPv6
542  *
543  * PLEASE KEEP THE FOLLOWING IN SYNC WITH ipa_ip_type_as_str()
544  * BELOW.
545  */
546 enum ipa_ip_type {
547 	IPA_IP_v4,
548 	IPA_IP_v6,
549 	IPA_IP_MAX
550 };
551 
552 #define VALID_IPA_IP_TYPE(t) \
553 	((t) >= IPA_IP_v4 && (t) < IPA_IP_MAX)
554 
555 /**
556  * enum ipa_rule_type - Type of routing or filtering rule
557  * Hashable: Rule will be located at the hashable tables
558  * Non_Hashable: Rule will be located at the non-hashable tables
559  */
560 enum ipa_rule_type {
561 	IPA_RULE_HASHABLE,
562 	IPA_RULE_NON_HASHABLE,
563 };
564 #define IPA_RULE_TYPE_MAX (IPA_RULE_NON_HASHABLE + 1)
565 
566 /**
567  * enum ipa_flt_action - action field of filtering rule
568  *
569  * Pass to routing: 5'd0
570  * Pass to source NAT: 5'd1
571  * Pass to destination NAT: 5'd2
572  * Pass to default output pipe (e.g., Apps or Modem): 5'd3
573  */
574 enum ipa_flt_action {
575 	IPA_PASS_TO_ROUTING,
576 	IPA_PASS_TO_SRC_NAT,
577 	IPA_PASS_TO_DST_NAT,
578 	IPA_PASS_TO_EXCEPTION
579 };
580 
581 /**
582  * enum ipa_wlan_event - Events for wlan client
583  *
584  * wlan client connect: New wlan client connected
585  * wlan client disconnect: wlan client disconnected
586  * wlan client power save: wlan client moved to power save
587  * wlan client normal: wlan client moved out of power save
588  * sw routing enable: ipa routing is disabled
589  * sw routing disable: ipa routing is enabled
590  * wlan ap connect: wlan AP(access point) is up
591  * wlan ap disconnect: wlan AP(access point) is down
592  * wlan sta connect: wlan STA(station) is up
593  * wlan sta disconnect: wlan STA(station) is down
594  * wlan client connect ex: new wlan client connected
595  * wlan scc switch: wlan interfaces in scc mode
596  * wlan mcc switch: wlan interfaces in mcc mode
597  * wlan wdi enable: wdi data path completed
598  * wlan wdi disable: wdi data path teardown
599  */
600 enum ipa_wlan_event {
601 	WLAN_CLIENT_CONNECT,
602 	WLAN_CLIENT_DISCONNECT,
603 	WLAN_CLIENT_POWER_SAVE_MODE,
604 	WLAN_CLIENT_NORMAL_MODE,
605 	SW_ROUTING_ENABLE,
606 	SW_ROUTING_DISABLE,
607 	WLAN_AP_CONNECT,
608 	WLAN_AP_DISCONNECT,
609 	WLAN_STA_CONNECT,
610 	WLAN_STA_DISCONNECT,
611 	WLAN_CLIENT_CONNECT_EX,
612 	WLAN_SWITCH_TO_SCC,
613 	WLAN_SWITCH_TO_MCC,
614 	WLAN_WDI_ENABLE,
615 	WLAN_WDI_DISABLE,
616 	IPA_WLAN_EVENT_MAX
617 };
618 
619 /**
620  * enum ipa_wan_event - Events for wan client
621  *
622  * wan default route add/del
623  * wan embms connect: New wan embms interface connected
624  */
625 enum ipa_wan_event {
626 	WAN_UPSTREAM_ROUTE_ADD = IPA_WLAN_EVENT_MAX,
627 	WAN_UPSTREAM_ROUTE_DEL,
628 	WAN_EMBMS_CONNECT,
629 	WAN_XLAT_CONNECT,
630 	IPA_WAN_EVENT_MAX
631 };
632 
633 enum ipa_ecm_event {
634 	ECM_CONNECT = IPA_WAN_EVENT_MAX,
635 	ECM_DISCONNECT,
636 	IPA_ECM_EVENT_MAX,
637 };
638 
639 enum ipa_tethering_stats_event {
640 	IPA_TETHERING_STATS_UPDATE_STATS = IPA_ECM_EVENT_MAX,
641 	IPA_TETHERING_STATS_UPDATE_NETWORK_STATS,
642 	IPA_TETHERING_STATS_EVENT_MAX,
643 };
644 
645 
646 enum ipa_quota_event {
647 	IPA_QUOTA_REACH = IPA_TETHERING_STATS_EVENT_MAX,
648 	IPA_QUOTA_EVENT_MAX,
649 };
650 
651 enum ipa_ssr_event {
652 	IPA_SSR_BEFORE_SHUTDOWN = IPA_QUOTA_EVENT_MAX,
653 	IPA_SSR_AFTER_POWERUP,
654 	IPA_SSR_EVENT_MAX,
655 };
656 
657 enum ipa_vlan_l2tp_event {
658 	ADD_VLAN_IFACE = IPA_SSR_EVENT_MAX,
659 	DEL_VLAN_IFACE,
660 	ADD_L2TP_VLAN_MAPPING,
661 	DEL_L2TP_VLAN_MAPPING,
662 	IPA_VLAN_L2TP_EVENT_MAX,
663 };
664 
665 enum ipa_per_client_stats_event {
666 	IPA_PER_CLIENT_STATS_CONNECT_EVENT = IPA_VLAN_L2TP_EVENT_MAX,
667 	IPA_PER_CLIENT_STATS_DISCONNECT_EVENT,
668 	IPA_PER_CLIENT_STATS_EVENT_MAX,
669 };
670 
671 enum ipa_vlan_bridge_event {
672 	ADD_BRIDGE_VLAN_MAPPING = IPA_PER_CLIENT_STATS_EVENT_MAX,
673 	DEL_BRIDGE_VLAN_MAPPING,
674 	BRIDGE_VLAN_MAPPING_MAX,
675 };
676 
677 enum ipa_wlan_fw_ssr_event {
678 	WLAN_FWR_SSR_BEFORE_SHUTDOWN = BRIDGE_VLAN_MAPPING_MAX,
679 	IPA_WLAN_FW_SSR_EVENT_MAX,
680 #define IPA_WLAN_FW_SSR_EVENT_MAX IPA_WLAN_FW_SSR_EVENT_MAX
681 };
682 
683 enum ipa_gsb_event {
684 	IPA_GSB_CONNECT = IPA_WLAN_FW_SSR_EVENT_MAX,
685 	IPA_GSB_DISCONNECT,
686 	IPA_GSB_EVENT_MAX,
687 };
688 
689 enum ipa_coalesce_event {
690 	IPA_COALESCE_ENABLE = IPA_GSB_EVENT_MAX,
691 	IPA_COALESCE_DISABLE,
692 	IPA_COALESCE_EVENT_MAX
693 #define IPA_COALESCE_EVENT_MAX IPA_COALESCE_EVENT_MAX
694 };
695 
696 #define WIGIG_CLIENT_CONNECT (IPA_COALESCE_EVENT_MAX)
697 #define WIGIG_FST_SWITCH (WIGIG_CLIENT_CONNECT + 1)
698 #define WIGIG_EVENT_MAX (WIGIG_FST_SWITCH + 1)
699 
700 #define IPA_EVENT_MAX_NUM (WIGIG_EVENT_MAX)
701 #define IPA_EVENT_MAX ((int)IPA_EVENT_MAX_NUM)
702 
703 /**
704  * enum ipa_rm_resource_name - IPA RM clients identification names
705  *
706  * PROD resources are always even, and CONS resources are always odd.
707  * Add new clients in the end of the list and update IPA_RM_RESOURCE_MAX
708  */
709 enum ipa_rm_resource_name {
710 	IPA_RM_RESOURCE_Q6_PROD				= 0,
711 	IPA_RM_RESOURCE_Q6_CONS				= 1,
712 
713 	IPA_RM_RESOURCE_USB_PROD			= 2,
714 	IPA_RM_RESOURCE_USB_CONS			= 3,
715 
716 	IPA_RM_RESOURCE_USB_DPL_DUMMY_PROD		= 4,
717 	IPA_RM_RESOURCE_USB_DPL_CONS			= 5,
718 
719 	IPA_RM_RESOURCE_HSIC_PROD			= 6,
720 	IPA_RM_RESOURCE_HSIC_CONS			= 7,
721 
722 	IPA_RM_RESOURCE_STD_ECM_PROD			= 8,
723 	IPA_RM_RESOURCE_APPS_CONS			= 9,
724 
725 	IPA_RM_RESOURCE_RNDIS_PROD			= 10,
726 	/* RESERVED CONS				= 11, */
727 
728 	IPA_RM_RESOURCE_WWAN_0_PROD			= 12,
729 	/* RESERVED CONS				= 13, */
730 
731 	IPA_RM_RESOURCE_WLAN_PROD			= 14,
732 	IPA_RM_RESOURCE_WLAN_CONS			= 15,
733 
734 	IPA_RM_RESOURCE_ODU_ADAPT_PROD			= 16,
735 	IPA_RM_RESOURCE_ODU_ADAPT_CONS			= 17,
736 
737 	IPA_RM_RESOURCE_MHI_PROD			= 18,
738 	IPA_RM_RESOURCE_MHI_CONS			= 19,
739 
740 	IPA_RM_RESOURCE_ETHERNET_PROD			= 20,
741 	IPA_RM_RESOURCE_ETHERNET_CONS			= 21,
742 };
743 #define IPA_RM_RESOURCE_MAX (IPA_RM_RESOURCE_ETHERNET_CONS + 1)
744 
745 /**
746  * enum ipa_hw_type - IPA hardware version type
747  * @IPA_HW_None: IPA hardware version not defined
748  * @IPA_HW_v1_0: IPA hardware version 1.0
749  * @IPA_HW_v1_1: IPA hardware version 1.1
750  * @IPA_HW_v2_0: IPA hardware version 2.0
751  * @IPA_HW_v2_1: IPA hardware version 2.1
752  * @IPA_HW_v2_5: IPA hardware version 2.5
753  * @IPA_HW_v2_6: IPA hardware version 2.6
754  * @IPA_HW_v2_6L: IPA hardware version 2.6L
755  * @IPA_HW_v3_0: IPA hardware version 3.0
756  * @IPA_HW_v3_1: IPA hardware version 3.1
757  * @IPA_HW_v3_5: IPA hardware version 3.5
758  * @IPA_HW_v3_5_1: IPA hardware version 3.5.1
759  * @IPA_HW_v4_0: IPA hardware version 4.0
760  * @IPA_HW_v4_1: IPA hardware version 4.1
761  * @IPA_HW_v4_2: IPA hardware version 4.2
762  * @IPA_HW_v4_5: IPA hardware version 4.5
763  * @IPA_HW_v4_7: IPA hardware version 4.7
764  */
765 enum ipa_hw_type {
766 	IPA_HW_None = 0,
767 	IPA_HW_v1_0 = 1,
768 	IPA_HW_v1_1 = 2,
769 	IPA_HW_v2_0 = 3,
770 	IPA_HW_v2_1 = 4,
771 	IPA_HW_v2_5 = 5,
772 	IPA_HW_v2_6 = IPA_HW_v2_5,
773 	IPA_HW_v2_6L = 6,
774 	IPA_HW_v3_0 = 10,
775 	IPA_HW_v3_1 = 11,
776 	IPA_HW_v3_5 = 12,
777 	IPA_HW_v3_5_1 = 13,
778 	IPA_HW_v4_0 = 14,
779 	IPA_HW_v4_1 = 15,
780 	IPA_HW_v4_2 = 16,
781 	IPA_HW_v4_5 = 17,
782 	IPA_HW_v4_7 = 18,
783 };
784 #define IPA_HW_MAX (IPA_HW_v4_7 + 1)
785 
786 #define IPA_HW_v4_0 IPA_HW_v4_0
787 #define IPA_HW_v4_1 IPA_HW_v4_1
788 #define IPA_HW_v4_2 IPA_HW_v4_2
789 #define IPA_HW_v4_5 IPA_HW_v4_5
790 #define IPA_HW_v4_7 IPA_HW_v4_7
791 
792 /**
793  * struct ipa_rule_attrib - attributes of a routing/filtering
794  * rule, all in LE
795  * @attrib_mask: what attributes are valid
796  * @src_port_lo: low port of src port range
797  * @src_port_hi: high port of src port range
798  * @dst_port_lo: low port of dst port range
799  * @dst_port_hi: high port of dst port range
800  * @type: ICMP/IGMP type
801  * @code: ICMP/IGMP code
802  * @spi: IPSec SPI
803  * @src_port: exact src port
804  * @dst_port: exact dst port
805  * @meta_data: meta-data val
806  * @meta_data_mask: meta-data mask
807  * @u.v4.tos: type of service
808  * @u.v4.protocol: protocol
809  * @u.v4.src_addr: src address value
810  * @u.v4.src_addr_mask: src address mask
811  * @u.v4.dst_addr: dst address value
812  * @u.v4.dst_addr_mask: dst address mask
813  * @u.v6.tc: traffic class
814  * @u.v6.flow_label: flow label
815  * @u.v6.next_hdr: next header
816  * @u.v6.src_addr: src address val
817  * @u.v6.src_addr_mask: src address mask
818  * @u.v6.dst_addr: dst address val
819  * @u.v6.dst_addr_mask: dst address mask
820  * @vlan_id: vlan id value
821  */
822 struct ipa_rule_attrib {
823 	uint32_t attrib_mask;
824 	uint16_t src_port_lo;
825 	uint16_t src_port_hi;
826 	uint16_t dst_port_lo;
827 	uint16_t dst_port_hi;
828 	uint8_t type;
829 	uint8_t code;
830 	uint8_t tos_value;
831 	uint8_t tos_mask;
832 	uint32_t spi;
833 	uint16_t src_port;
834 	uint16_t dst_port;
835 	uint32_t meta_data;
836 	uint32_t meta_data_mask;
837 	uint8_t src_mac_addr[ETH_ALEN];
838 	uint8_t src_mac_addr_mask[ETH_ALEN];
839 	uint8_t dst_mac_addr[ETH_ALEN];
840 	uint8_t dst_mac_addr_mask[ETH_ALEN];
841 	uint16_t ether_type;
842 	union {
843 		struct {
844 			uint8_t tos;
845 			uint8_t protocol;
846 			uint32_t src_addr;
847 			uint32_t src_addr_mask;
848 			uint32_t dst_addr;
849 			uint32_t dst_addr_mask;
850 		} v4;
851 		struct {
852 			uint8_t tc;
853 			uint32_t flow_label;
854 			uint8_t next_hdr;
855 			uint32_t src_addr[4];
856 			uint32_t src_addr_mask[4];
857 			uint32_t dst_addr[4];
858 			uint32_t dst_addr_mask[4];
859 		} v6;
860 	} u;
861 	uint16_t vlan_id;
862 };
863 
864 /*! @brief The maximum number of Mask Equal 32 Eqns */
865 #define IPA_IPFLTR_NUM_MEQ_32_EQNS 2
866 
867 /*! @brief The maximum number of IHL offset Mask Equal 32 Eqns */
868 #define IPA_IPFLTR_NUM_IHL_MEQ_32_EQNS 2
869 
870 /*! @brief The maximum number of Mask Equal 128 Eqns */
871 #define IPA_IPFLTR_NUM_MEQ_128_EQNS 2
872 
873 /*! @brief The maximum number of IHL offset Range Check 16 Eqns */
874 #define IPA_IPFLTR_NUM_IHL_RANGE_16_EQNS 2
875 
876 /*! @brief Offset and 16 bit comparison equation */
877 struct ipa_ipfltr_eq_16 {
878 	int8_t offset;
879 	uint16_t value;
880 };
881 
882 /*! @brief Offset and 32 bit comparison equation */
883 struct ipa_ipfltr_eq_32 {
884 	int8_t offset;
885 	uint32_t value;
886 };
887 
888 /*! @brief Offset and 128 bit masked comparison equation */
889 struct ipa_ipfltr_mask_eq_128 {
890 	int8_t offset;
891 	uint8_t mask[16];
892 	uint8_t value[16];
893 };
894 
895 /*! @brief Offset and 32 bit masked comparison equation */
896 struct ipa_ipfltr_mask_eq_32 {
897 	int8_t offset;
898 	uint32_t mask;
899 	uint32_t value;
900 };
901 
902 /*! @brief Equation for identifying a range. Ranges are inclusive */
903 struct ipa_ipfltr_range_eq_16 {
904 	int8_t offset;
905 	uint16_t range_low;
906 	uint16_t range_high;
907 };
908 
909 /*! @brief Rule equations which are set according to DS filter installation */
910 struct ipa_ipfltri_rule_eq {
911 	/*! 16-bit Bitmask to indicate how many eqs are valid in this rule  */
912 	uint16_t rule_eq_bitmap;
913 
914 	/*
915 	 * tos_eq_present field has two meanings:
916 	 * IPA ver < 4.5:
917 	 *  specifies if a type of service check rule is present
918 	 *  (as the field name reveals).
919 	 * IPA ver >= 4.5:
920 	 *  specifies if a tcp pure ack check rule is present
921 	 */
922 	uint8_t tos_eq_present;
923 	/*! The value to check against the type of service (ipv4) field */
924 	uint8_t tos_eq;
925 	/*! Specifies if a protocol check rule is present */
926 	uint8_t protocol_eq_present;
927 	/*! The value to check against the protocol (ipv6) field */
928 	uint8_t protocol_eq;
929 	/*! The number of ip header length offset 16 bit range check
930 	 * rules in this rule
931 	 */
932 	uint8_t num_ihl_offset_range_16;
933 	/*! An array of the registered ip header length offset 16 bit
934 	 * range check rules
935 	 */
936 	struct ipa_ipfltr_range_eq_16
937 		ihl_offset_range_16[IPA_IPFLTR_NUM_IHL_RANGE_16_EQNS];
938 	/*! The number of mask equal 32 rules present in this rule */
939 	uint8_t num_offset_meq_32;
940 	/*! An array of all the possible mask equal 32 rules in this rule */
941 	struct ipa_ipfltr_mask_eq_32
942 		offset_meq_32[IPA_IPFLTR_NUM_MEQ_32_EQNS];
943 	/*! Specifies if the traffic class rule is present in this rule */
944 	uint8_t tc_eq_present;
945 	/*! The value to check the traffic class (ipv4) field against */
946 	uint8_t tc_eq;
947 	/*! Specifies if the flow equals rule is present in this rule */
948 	uint8_t fl_eq_present;
949 	/*! The value to check the flow (ipv6) field against */
950 	uint32_t fl_eq;
951 	/*! The number of ip header length offset 16 bit equations in this
952 	 * rule
953 	 */
954 	uint8_t ihl_offset_eq_16_present;
955 	/*! The ip header length offset 16 bit equation */
956 	struct ipa_ipfltr_eq_16 ihl_offset_eq_16;
957 	/*! The number of ip header length offset 32 bit equations in this
958 	 * rule
959 	 */
960 	uint8_t ihl_offset_eq_32_present;
961 	/*! The ip header length offset 32 bit equation */
962 	struct ipa_ipfltr_eq_32 ihl_offset_eq_32;
963 	/*! The number of ip header length offset 32 bit mask equations in
964 	 * this rule
965 	 */
966 	uint8_t num_ihl_offset_meq_32;
967 	/*! The ip header length offset 32 bit mask equation */
968 	struct ipa_ipfltr_mask_eq_32
969 		ihl_offset_meq_32[IPA_IPFLTR_NUM_IHL_MEQ_32_EQNS];
970 	/*! The number of ip header length offset 128 bit equations in this
971 	 * rule
972 	 */
973 	uint8_t num_offset_meq_128;
974 	/*! The ip header length offset 128 bit equation */
975 	struct ipa_ipfltr_mask_eq_128
976 		offset_meq_128[IPA_IPFLTR_NUM_MEQ_128_EQNS];
977 	/*! The metadata 32 bit masked comparison equation present or not */
978 	/* Metadata based rules are added internally by IPA driver */
979 	uint8_t metadata_meq32_present;
980 	/*! The metadata 32 bit masked comparison equation */
981 	struct ipa_ipfltr_mask_eq_32 metadata_meq32;
982 	/*! Specifies if the Fragment equation is present in this rule */
983 	uint8_t ipv4_frag_eq_present;
984 };
985 
986 /**
987  * struct ipa_flt_rule - attributes of a filtering rule
988  * @retain_hdr: bool switch to instruct IPA core to add back to the packet
989  *  the header removed as part of header removal
990  * @to_uc: bool switch to pass packet to micro-controller
991  * @action: action field
992  * @rt_tbl_hdl: handle of table from "get"
993  * @attrib: attributes of the rule
994  * @eq_attrib: attributes of the rule in equation form (valid when
995  * eq_attrib_type is true)
996  * @rt_tbl_idx: index of RT table referred to by filter rule (valid when
997  * eq_attrib_type is true and non-exception action)
998  * @eq_attrib_type: true if equation level form used to specify attributes
999  * @max_prio: bool switch. is this rule with Max priority? meaning on rule hit,
1000  *  IPA will use the rule and will not look for other rules that may have
1001  *  higher priority
1002  * @hashable: bool switch. is this rule hashable or not?
1003  *  ipa uses hashable rules to cache their hit results to be used in
1004  *  consecutive packets
1005  * @rule_id: rule_id to be assigned to the filter rule. In case client specifies
1006  *  rule_id as 0 the driver will assign a new rule_id
1007  * @set_metadata: bool switch. should metadata replacement at the NAT block
1008  *  take place?
1009  * @pdn_idx: if action is "pass to source\destination NAT" then a comparison
1010  * against the PDN index in the matching PDN entry will take place as an
1011  * additional condition for NAT hit.
1012  */
1013 struct ipa_flt_rule {
1014 	uint8_t retain_hdr;
1015 	uint8_t to_uc;
1016 	enum ipa_flt_action action;
1017 	uint32_t rt_tbl_hdl;
1018 	struct ipa_rule_attrib attrib;
1019 	struct ipa_ipfltri_rule_eq eq_attrib;
1020 	uint32_t rt_tbl_idx;
1021 	uint8_t eq_attrib_type;
1022 	uint8_t max_prio;
1023 	uint8_t hashable;
1024 	uint16_t rule_id;
1025 	uint8_t set_metadata;
1026 	uint8_t pdn_idx;
1027 };
1028 
1029 /**
1030  * struct ipa_flt_rule_v2 - attributes of a filtering rule
1031  * @retain_hdr: bool switch to instruct IPA core to add back to the packet
1032  *  the header removed as part of header removal
1033  * @to_uc: bool switch to pass packet to micro-controller
1034  * @action: action field
1035  * @rt_tbl_hdl: handle of table from "get"
1036  * @attrib: attributes of the rule
1037  * @eq_attrib: attributes of the rule in equation form (valid when
1038  * eq_attrib_type is true)
1039  * @rt_tbl_idx: index of RT table referred to by filter rule (valid when
1040  * eq_attrib_type is true and non-exception action)
1041  * @eq_attrib_type: true if equation level form used to specify attributes
1042  * @max_prio: bool switch. is this rule with Max priority? meaning on rule hit,
1043  *  IPA will use the rule and will not look for other rules that may have
1044  *  higher priority
1045  * @hashable: bool switch. is this rule hashable or not?
1046  *  ipa uses hashable rules to cache their hit results to be used in
1047  *  consecutive packets
1048  * @rule_id: rule_id to be assigned to the filter rule. In case client specifies
1049  *  rule_id as 0 the driver will assign a new rule_id
1050  * @set_metadata: bool switch. should metadata replacement at the NAT block
1051  *  take place?
1052  * @pdn_idx: if action is "pass to source\destination NAT" then a comparison
1053  * against the PDN index in the matching PDN entry will take place as an
1054  * additional condition for NAT hit.
1055  * @enable_stats: is true when we want to enable stats for this
1056  * flt rule.
1057  * @cnt_idx: if 0 means disable, otherwise use for index.
1058  * will be assigned by ipa driver.
1059  */
1060 struct ipa_flt_rule_v2 {
1061 	uint8_t retain_hdr;
1062 	uint8_t to_uc;
1063 	enum ipa_flt_action action;
1064 	uint32_t rt_tbl_hdl;
1065 	struct ipa_rule_attrib attrib;
1066 	struct ipa_ipfltri_rule_eq eq_attrib;
1067 	uint32_t rt_tbl_idx;
1068 	uint8_t eq_attrib_type;
1069 	uint8_t max_prio;
1070 	uint8_t hashable;
1071 	uint16_t rule_id;
1072 	uint8_t set_metadata;
1073 	uint8_t pdn_idx;
1074 	uint8_t enable_stats;
1075 	uint8_t cnt_idx;
1076 };
1077 
1078 /**
1079  * enum ipa_hdr_l2_type - L2 header type
1080  * IPA_HDR_L2_NONE: L2 header which isn't Ethernet II and isn't 802_3
1081  * IPA_HDR_L2_ETHERNET_II: L2 header of type Ethernet II
1082  * IPA_HDR_L2_802_3: L2 header of type 802_3
1083  * IPA_HDR_L2_802_1Q: L2 header of type 802_1Q
1084  */
1085 enum ipa_hdr_l2_type {
1086 	IPA_HDR_L2_NONE,
1087 	IPA_HDR_L2_ETHERNET_II,
1088 	IPA_HDR_L2_802_3,
1089 	IPA_HDR_L2_802_1Q,
1090 };
1091 #define IPA_HDR_L2_MAX (IPA_HDR_L2_802_1Q + 1)
1092 
1093 #define IPA_HDR_L2_802_1Q IPA_HDR_L2_802_1Q
1094 
1095 /**
1096  * enum ipa_hdr_l2_type - Processing context type
1097  * IPA_HDR_PROC_NONE: No processing context
1098  * IPA_HDR_PROC_ETHII_TO_ETHII: Process Ethernet II to Ethernet II
1099  * IPA_HDR_PROC_ETHII_TO_802_3: Process Ethernet II to 802_3
1100  * IPA_HDR_PROC_802_3_TO_ETHII: Process 802_3 to Ethernet II
1101  * IPA_HDR_PROC_802_3_TO_802_3: Process 802_3 to 802_3
1102  * IPA_HDR_PROC_ETHII_TO_ETHII_EX: Process Ethernet II to Ethernet II with
1103  *	generic lengths of src and dst headers
1104  */
1105 enum ipa_hdr_proc_type {
1106 	IPA_HDR_PROC_NONE,
1107 	IPA_HDR_PROC_ETHII_TO_ETHII,
1108 	IPA_HDR_PROC_ETHII_TO_802_3,
1109 	IPA_HDR_PROC_802_3_TO_ETHII,
1110 	IPA_HDR_PROC_802_3_TO_802_3,
1111 	IPA_HDR_PROC_L2TP_HEADER_ADD,
1112 	IPA_HDR_PROC_L2TP_HEADER_REMOVE,
1113 	IPA_HDR_PROC_ETHII_TO_ETHII_EX,
1114 	IPA_HDR_PROC_L2TP_UDP_HEADER_ADD,
1115 	IPA_HDR_PROC_L2TP_UDP_HEADER_REMOVE,
1116 	IPA_HDR_PROC_SET_DSCP
1117 };
1118 #define IPA_HDR_PROC_MAX (IPA_HDR_PROC_SET_DSCP + 1)
1119 
1120 /**
1121  * struct ipa_rt_rule - attributes of a routing rule
1122  * @dst: dst "client"
1123  * @hdr_hdl: handle to the dynamic header
1124 	it is not an index or an offset
1125  * @hdr_proc_ctx_hdl: handle to header processing context. if it is provided
1126 	hdr_hdl shall be 0
1127  * @attrib: attributes of the rule
1128  * @max_prio: bool switch. is this rule with Max priority? meaning on rule hit,
1129  *  IPA will use the rule and will not look for other rules that may have
1130  *  higher priority
1131  * @hashable: bool switch. is this rule hashable or not?
1132  *  ipa uses hashable rules to cache their hit results to be used in
1133  *  consecutive packets
1134  * @retain_hdr: bool switch to instruct IPA core to add back to the packet
1135  *  the header removed as part of header removal
1136  * @coalesce: bool to decide whether packets should be coalesced or not
1137  */
1138 struct ipa_rt_rule {
1139 	enum ipa_client_type dst;
1140 	uint32_t hdr_hdl;
1141 	uint32_t hdr_proc_ctx_hdl;
1142 	struct ipa_rule_attrib attrib;
1143 	uint8_t max_prio;
1144 	uint8_t hashable;
1145 	uint8_t retain_hdr;
1146 	uint8_t coalesce;
1147 };
1148 #define IPA_RT_SUPPORT_COAL
1149 
1150 /**
1151  * struct ipa_rt_rule_v2 - attributes of a routing rule
1152  * @dst: dst "client"
1153  * @hdr_hdl: handle to the dynamic header
1154 	it is not an index or an offset
1155  * @hdr_proc_ctx_hdl: handle to header processing context. if it is provided
1156 	hdr_hdl shall be 0
1157  * @attrib: attributes of the rule
1158  * @max_prio: bool switch. is this rule with Max priority? meaning on rule hit,
1159  *  IPA will use the rule and will not look for other rules that may have
1160  *  higher priority
1161  * @hashable: bool switch. is this rule hashable or not?
1162  *  ipa uses hashable rules to cache their hit results to be used in
1163  *  consecutive packets
1164  * @retain_hdr: bool switch to instruct IPA core to add back to the packet
1165  *  the header removed as part of header removal
1166  * @coalesce: bool to decide whether packets should be coalesced or not
1167  * @enable_stats: is true when we want to enable stats for this
1168  * rt rule.
1169  * @cnt_idx: if enable_stats is 1 and cnt_idx is 0, then cnt_idx
1170  * will be assigned by ipa driver.
1171  */
1172 struct ipa_rt_rule_v2 {
1173 	enum ipa_client_type dst;
1174 	uint32_t hdr_hdl;
1175 	uint32_t hdr_proc_ctx_hdl;
1176 	struct ipa_rule_attrib attrib;
1177 	uint8_t max_prio;
1178 	uint8_t hashable;
1179 	uint8_t retain_hdr;
1180 	uint8_t coalesce;
1181 	uint8_t enable_stats;
1182 	uint8_t cnt_idx;
1183 };
1184 
1185 /**
1186  * struct ipa_hdr_add - header descriptor includes in and out
1187  * parameters
1188  * @name: name of the header
1189  * @hdr: actual header to be inserted
1190  * @hdr_len: size of above header
1191  * @type: l2 header type
1192  * @is_partial: header not fully specified
1193  * @hdr_hdl: out parameter, handle to header, valid when status is 0
1194  * @status:	out parameter, status of header add operation,
1195  *		0 for success,
1196  *		-1 for failure
1197  * @is_eth2_ofst_valid: is eth2_ofst field valid?
1198  * @eth2_ofst: offset to start of Ethernet-II/802.3 header
1199  */
1200 struct ipa_hdr_add {
1201 	char name[IPA_RESOURCE_NAME_MAX];
1202 	uint8_t hdr[IPA_HDR_MAX_SIZE];
1203 	uint8_t hdr_len;
1204 	enum ipa_hdr_l2_type type;
1205 	uint8_t is_partial;
1206 	uint32_t hdr_hdl;
1207 	int status;
1208 	uint8_t is_eth2_ofst_valid;
1209 	uint16_t eth2_ofst;
1210 };
1211 
1212 /**
1213  * struct ipa_ioc_add_hdr - header addition parameters (support
1214  * multiple headers and commit)
1215  * @commit: should headers be written to IPA HW also?
1216  * @num_hdrs: num of headers that follow
1217  * @ipa_hdr_add hdr:	all headers need to go here back to
1218  *			back, no pointers
1219  */
1220 struct ipa_ioc_add_hdr {
1221 	uint8_t commit;
1222 	uint8_t num_hdrs;
1223 	struct ipa_hdr_add hdr[0];
1224 };
1225 
1226 /**
1227  * struct ipa_l2tp_header_add_procparams -
1228  * @eth_hdr_retained: Specifies if Ethernet header is retained or not
1229  * @input_ip_version: Specifies if Input header is IPV4(0) or IPV6(1)
1230  * @output_ip_version: Specifies if template header is IPV4(0) or IPV6(1)
1231  */
1232 struct ipa_l2tp_header_add_procparams {
1233 	uint32_t eth_hdr_retained:1;
1234 	uint32_t input_ip_version:1;
1235 	uint32_t output_ip_version:1;
1236 	uint32_t reserved:29;
1237 };
1238 
1239 /**
1240  * struct ipa_l2tp_header_remove_procparams -
1241  * @hdr_len_remove: Specifies how much of the header needs to
1242 		be removed in bytes
1243  * @eth_hdr_retained: Specifies if Ethernet header is retained or not
1244  * @hdr_ofst_pkt_size_valid: Specifies if the Header offset is valid
1245  * @hdr_ofst_pkt_size: If hdr_ofst_pkt_size_valid =1, this indicates where the
1246 		packet size field (2bytes) resides
1247  * @hdr_endianness: 0:little endian, 1:big endian
1248  */
1249 struct ipa_l2tp_header_remove_procparams {
1250 	uint32_t hdr_len_remove:8;
1251 	uint32_t eth_hdr_retained:1;
1252 	/* Following fields are valid if eth_hdr_retained =1 ( bridge mode) */
1253 	uint32_t hdr_ofst_pkt_size_valid:1;
1254 	uint32_t hdr_ofst_pkt_size:6;
1255 	uint32_t hdr_endianness:1;
1256 	uint32_t reserved:15;
1257 };
1258 
1259 /**
1260  * struct ipa_l2tp_hdr_proc_ctx_params -
1261  * @hdr_add_param: parameters for header add
1262  * @hdr_remove_param: parameters for header remove
1263  * @is_dst_pipe_valid: if dst pipe is valid
1264  * @dst_pipe: destination pipe
1265  */
1266 struct ipa_l2tp_hdr_proc_ctx_params {
1267 	struct ipa_l2tp_header_add_procparams hdr_add_param;
1268 	struct ipa_l2tp_header_remove_procparams hdr_remove_param;
1269 	uint8_t is_dst_pipe_valid;
1270 	enum ipa_client_type dst_pipe;
1271 };
1272 
1273 /**
1274  * struct ipa_eth_II_to_eth_II_ex_procparams -
1275  * @input_ethhdr_negative_offset: Specifies where the ethernet hdr offset is
1276  *	(in bytes) from the start of the input IP hdr
1277  * @output_ethhdr_negative_offset: Specifies where the ethernet hdr offset is
1278  *	(in bytes) from the end of the template hdr
1279  * @reserved: for future use
1280  */
1281 struct ipa_eth_II_to_eth_II_ex_procparams {
1282 	uint32_t input_ethhdr_negative_offset : 8;
1283 	uint32_t output_ethhdr_negative_offset : 8;
1284 	uint32_t reserved : 16;
1285 };
1286 
1287 #define L2TP_USER_SPACE_SPECIFY_DST_PIPE
1288 
1289 /**
1290  * struct ipa_hdr_proc_ctx_add - processing context descriptor includes
1291  * in and out parameters
1292  * @type: processing context type
1293  * @hdr_hdl: in parameter, handle to header
1294  * @l2tp_params: l2tp parameters
1295  * @generic_params: generic proc_ctx params
1296  * @proc_ctx_hdl: out parameter, handle to proc_ctx, valid when status is 0
1297  * @status:	out parameter, status of header add operation,
1298  *		0 for success,
1299  *		-1 for failure
1300  */
1301 struct ipa_hdr_proc_ctx_add {
1302 	enum ipa_hdr_proc_type type;
1303 	uint32_t hdr_hdl;
1304 	uint32_t proc_ctx_hdl;
1305 	int status;
1306 	struct ipa_l2tp_hdr_proc_ctx_params l2tp_params;
1307 	struct ipa_eth_II_to_eth_II_ex_procparams generic_params;
1308 };
1309 
1310 #define IPA_L2TP_HDR_PROC_SUPPORT
1311 
1312 /**
1313  * struct ipa_ioc_add_hdr - processing context addition parameters (support
1314  * multiple processing context and commit)
1315  * @commit: should processing context be written to IPA HW also?
1316  * @num_proc_ctxs: num of processing context that follow
1317  * @proc_ctx:	all processing context need to go here back to
1318  *			back, no pointers
1319  */
1320 struct ipa_ioc_add_hdr_proc_ctx {
1321 	uint8_t commit;
1322 	uint8_t num_proc_ctxs;
1323 	struct ipa_hdr_proc_ctx_add proc_ctx[0];
1324 };
1325 
1326 /**
1327  * struct ipa_ioc_copy_hdr - retrieve a copy of the specified
1328  * header - caller can then derive the complete header
1329  * @name: name of the header resource
1330  * @hdr:	out parameter, contents of specified header,
1331  *	valid only when ioctl return val is non-negative
1332  * @hdr_len: out parameter, size of above header
1333  *	valid only when ioctl return val is non-negative
1334  * @type: l2 header type
1335  *	valid only when ioctl return val is non-negative
1336  * @is_partial:	out parameter, indicates whether specified header is partial
1337  *		valid only when ioctl return val is non-negative
1338  * @is_eth2_ofst_valid: is eth2_ofst field valid?
1339  * @eth2_ofst: offset to start of Ethernet-II/802.3 header
1340  */
1341 struct ipa_ioc_copy_hdr {
1342 	char name[IPA_RESOURCE_NAME_MAX];
1343 	uint8_t hdr[IPA_HDR_MAX_SIZE];
1344 	uint8_t hdr_len;
1345 	enum ipa_hdr_l2_type type;
1346 	uint8_t is_partial;
1347 	uint8_t is_eth2_ofst_valid;
1348 	uint16_t eth2_ofst;
1349 };
1350 
1351 /**
1352  * struct ipa_ioc_get_hdr - header entry lookup parameters, if lookup was
1353  * successful caller must call put to release the reference count when done
1354  * @name: name of the header resource
1355  * @hdl:	out parameter, handle of header entry
1356  *		valid only when ioctl return val is non-negative
1357  */
1358 struct ipa_ioc_get_hdr {
1359 	char name[IPA_RESOURCE_NAME_MAX];
1360 	uint32_t hdl;
1361 };
1362 
1363 /**
1364  * struct ipa_hdr_del - header descriptor includes in and out
1365  * parameters
1366  *
1367  * @hdl: handle returned from header add operation
1368  * @status:	out parameter, status of header remove operation,
1369  *		0 for success,
1370  *		-1 for failure
1371  */
1372 struct ipa_hdr_del {
1373 	uint32_t hdl;
1374 	int status;
1375 };
1376 
1377 /**
1378  * struct ipa_ioc_del_hdr - header deletion parameters (support
1379  * multiple headers and commit)
1380  * @commit: should headers be removed from IPA HW also?
1381  * @num_hdls: num of headers being removed
1382  * @ipa_hdr_del hdl: all handles need to go here back to back, no pointers
1383  */
1384 struct ipa_ioc_del_hdr {
1385 	uint8_t commit;
1386 	uint8_t num_hdls;
1387 	struct ipa_hdr_del hdl[0];
1388 };
1389 
1390 /**
1391  * struct ipa_hdr_proc_ctx_del - processing context descriptor includes
1392  * in and out parameters
1393  * @hdl: handle returned from processing context add operation
1394  * @status:	out parameter, status of header remove operation,
1395  *		0 for success,
1396  *		-1 for failure
1397  */
1398 struct ipa_hdr_proc_ctx_del {
1399 	uint32_t hdl;
1400 	int status;
1401 };
1402 
1403 /**
1404  * ipa_ioc_del_hdr_proc_ctx - processing context deletion parameters (support
1405  * multiple headers and commit)
1406  * @commit: should processing contexts be removed from IPA HW also?
1407  * @num_hdls: num of processing contexts being removed
1408  * @ipa_hdr_proc_ctx_del hdl:	all handles need to go here back to back,
1409  *				no pointers
1410  */
1411 struct ipa_ioc_del_hdr_proc_ctx {
1412 	uint8_t commit;
1413 	uint8_t num_hdls;
1414 	struct ipa_hdr_proc_ctx_del hdl[0];
1415 };
1416 
1417 /**
1418  * struct ipa_rt_rule_add - routing rule descriptor includes in
1419  * and out parameters
1420  * @rule: actual rule to be added
1421  * @at_rear:	add at back of routing table, it is NOT possible to add rules at
1422  *		the rear of the "default" routing tables
1423  * @rt_rule_hdl: output parameter, handle to rule, valid when status is 0
1424  * @status:	output parameter, status of routing rule add operation,
1425  *		0 for success,
1426  *		-1 for failure
1427  */
1428 struct ipa_rt_rule_add {
1429 	struct ipa_rt_rule rule;
1430 	uint8_t at_rear;
1431 	uint32_t rt_rule_hdl;
1432 	int status;
1433 };
1434 
1435 /**
1436  * struct ipa_rt_rule_add_v2 - routing rule descriptor includes
1437  * in and out parameters
1438  * @rule: actual rule to be added
1439  * @at_rear:	add at back of routing table, it is NOT possible to add rules at
1440  *		the rear of the "default" routing tables
1441  * @rt_rule_hdl: output parameter, handle to rule, valid when status is 0
1442  * @status:	output parameter, status of routing rule add operation,
1443  *		0 for success,
1444  *		-1 for failure
1445  */
1446 struct ipa_rt_rule_add_v2 {
1447 	uint8_t at_rear;
1448 	uint32_t rt_rule_hdl;
1449 	int status;
1450 	struct ipa_rt_rule_v2 rule;
1451 };
1452 
1453 
1454 /**
1455  * struct ipa_ioc_add_rt_rule - routing rule addition parameters (supports
1456  * multiple rules and commit);
1457  *
1458  * all rules MUST be added to same table
1459  * @commit: should rules be written to IPA HW also?
1460  * @ip: IP family of rule
1461  * @rt_tbl_name: name of routing table resource
1462  * @num_rules: number of routing rules that follow
1463  * @ipa_rt_rule_add rules: all rules need to go back to back here, no pointers
1464  */
1465 struct ipa_ioc_add_rt_rule {
1466 	uint8_t commit;
1467 	enum ipa_ip_type ip;
1468 	char rt_tbl_name[IPA_RESOURCE_NAME_MAX];
1469 	uint8_t num_rules;
1470 	struct ipa_rt_rule_add rules[0];
1471 };
1472 
1473 /**
1474  * struct ipa_ioc_add_rt_rule_v2 - routing rule addition
1475  * parameters (supports multiple rules and commit);
1476  *
1477  * all rules MUST be added to same table
1478  * @commit: should rules be written to IPA HW also?
1479  * @ip: IP family of rule
1480  * @rt_tbl_name: name of routing table resource
1481  * @num_rules: number of routing rules that follow
1482  * @rule_add_size: sizeof(struct ipa_rt_rule_add_v2)
1483  * @reserved1: reserved bits for alignment
1484  * @reserved2: reserved bits for alignment
1485  * @ipa_rt_rule_add rules: all rules need to go back to back here, no pointers
1486  */
1487 struct ipa_ioc_add_rt_rule_v2 {
1488 	uint8_t commit;
1489 	enum ipa_ip_type ip;
1490 	char rt_tbl_name[IPA_RESOURCE_NAME_MAX];
1491 	uint8_t num_rules;
1492 	uint32_t rule_add_size;
1493 	uint32_t reserved1;
1494 	uint8_t reserved2;
1495 	uint64_t rules;
1496 };
1497 
1498 /**
1499  * struct ipa_ioc_add_rt_rule_after - routing rule addition after a specific
1500  * rule parameters(supports multiple rules and commit);
1501  *
1502  * all rules MUST be added to same table
1503  * @commit: should rules be written to IPA HW also?
1504  * @ip: IP family of rule
1505  * @rt_tbl_name: name of routing table resource
1506  * @num_rules: number of routing rules that follow
1507  * @add_after_hdl: the rules will be added after this specific rule
1508  * @ipa_rt_rule_add rules: all rules need to go back to back here, no pointers
1509  *			   at_rear field will be ignored when using this IOCTL
1510  */
1511 struct ipa_ioc_add_rt_rule_after {
1512 	uint8_t commit;
1513 	enum ipa_ip_type ip;
1514 	char rt_tbl_name[IPA_RESOURCE_NAME_MAX];
1515 	uint8_t num_rules;
1516 	uint32_t add_after_hdl;
1517 	struct ipa_rt_rule_add rules[0];
1518 };
1519 
1520 /**
1521  * struct ipa_ioc_add_rt_rule_after_v2 - routing rule addition
1522  * after a specific rule parameters(supports multiple rules and
1523  * commit);
1524  *
1525  * all rules MUST be added to same table
1526  * @commit: should rules be written to IPA HW also?
1527  * @ip: IP family of rule
1528  * @rt_tbl_name: name of routing table resource
1529  * @num_rules: number of routing rules that follow
1530  * @add_after_hdl: the rules will be added after this specific rule
1531  * @rule_add_size: sizeof(struct ipa_rt_rule_add_v2)
1532  * @reserved: reserved bits for alignment
1533  * @ipa_rt_rule_add rules: all rules need to go back to back here, no pointers
1534  *			   at_rear field will be ignored when using this IOCTL
1535  */
1536 struct ipa_ioc_add_rt_rule_after_v2 {
1537 	uint8_t commit;
1538 	enum ipa_ip_type ip;
1539 	char rt_tbl_name[IPA_RESOURCE_NAME_MAX];
1540 	uint8_t num_rules;
1541 	uint32_t add_after_hdl;
1542 	uint32_t rule_add_size;
1543 	uint8_t reserved;
1544 	uint64_t rules;
1545 };
1546 
1547 /**
1548  * struct ipa_rt_rule_mdfy - routing rule descriptor includes
1549  * in and out parameters
1550  * @rule: actual rule to be added
1551  * @rt_rule_hdl: handle to rule which supposed to modify
1552  * @status:	output parameter, status of routing rule modify  operation,
1553  *		0 for success,
1554  *		-1 for failure
1555  *
1556  */
1557 struct ipa_rt_rule_mdfy {
1558 	struct ipa_rt_rule rule;
1559 	uint32_t rt_rule_hdl;
1560 	int status;
1561 };
1562 
1563 /**
1564  * struct ipa_rt_rule_mdfy_v2 - routing rule descriptor includes
1565  * in and out parameters
1566  * @rule: actual rule to be added
1567  * @rt_rule_hdl: handle to rule which supposed to modify
1568  * @status:	output parameter, status of routing rule modify  operation,
1569  *		0 for success,
1570  *		-1 for failure
1571  *
1572  */
1573 struct ipa_rt_rule_mdfy_v2 {
1574 	uint32_t rt_rule_hdl;
1575 	int status;
1576 	struct ipa_rt_rule_v2 rule;
1577 };
1578 
1579 /**
1580  * struct ipa_ioc_mdfy_rt_rule - routing rule modify parameters (supports
1581  * multiple rules and commit)
1582  * @commit: should rules be written to IPA HW also?
1583  * @ip: IP family of rule
1584  * @num_rules: number of routing rules that follow
1585  * @rules: all rules need to go back to back here, no pointers
1586  */
1587 struct ipa_ioc_mdfy_rt_rule {
1588 	uint8_t commit;
1589 	enum ipa_ip_type ip;
1590 	uint8_t num_rules;
1591 	struct ipa_rt_rule_mdfy rules[0];
1592 };
1593 
1594 /**
1595  * struct ipa_ioc_mdfy_rt_rule_v2 - routing rule modify
1596  * parameters (supports multiple rules and commit)
1597  * @commit: should rules be written to IPA HW also?
1598  * @ip: IP family of rule
1599  * @num_rules: number of routing rules that follow
1600  * @rule_mdfy_size: sizeof(struct ipa_rt_rule_mdfy_v2)
1601  * @reserved: reserved bits for alignment
1602  * @rules: all rules need to go back to back here, no pointers
1603  */
1604 struct ipa_ioc_mdfy_rt_rule_v2 {
1605 	uint8_t commit;
1606 	enum ipa_ip_type ip;
1607 	uint8_t num_rules;
1608 	uint32_t rule_mdfy_size;
1609 	uint8_t reserved;
1610 	uint64_t rules;
1611 };
1612 
1613 /**
1614  * struct ipa_rt_rule_del - routing rule descriptor includes in
1615  * and out parameters
1616  * @hdl: handle returned from route rule add operation
1617  * @status:	output parameter, status of route rule delete operation,
1618  *		0 for success,
1619  *		-1 for failure
1620  */
1621 struct ipa_rt_rule_del {
1622 	uint32_t hdl;
1623 	int status;
1624 };
1625 
1626 /**
1627  * struct ipa_rt_rule_add_ext - routing rule descriptor includes in
1628  * and out parameters
1629  * @rule: actual rule to be added
1630  * @at_rear:	add at back of routing table, it is NOT possible to add rules at
1631  *		the rear of the "default" routing tables
1632  * @rt_rule_hdl: output parameter, handle to rule, valid when status is 0
1633  * @status:	output parameter, status of routing rule add operation,
1634  * @rule_id: rule_id to be assigned to the routing rule. In case client
1635  *  specifies rule_id as 0 the driver will assign a new rule_id
1636  *		0 for success,
1637  *		-1 for failure
1638  */
1639 struct ipa_rt_rule_add_ext {
1640 	struct ipa_rt_rule rule;
1641 	uint8_t at_rear;
1642 	uint32_t rt_rule_hdl;
1643 	int status;
1644 	uint16_t rule_id;
1645 };
1646 
1647 /**
1648  * struct ipa_rt_rule_add_ext_v2 - routing rule descriptor
1649  * includes in and out parameters
1650  * @rule: actual rule to be added
1651  * @at_rear:	add at back of routing table, it is NOT possible to add rules at
1652  *		the rear of the "default" routing tables
1653  * @rt_rule_hdl: output parameter, handle to rule, valid when status is 0
1654  * @status:	output parameter, status of routing rule add operation,
1655  * @rule_id: rule_id to be assigned to the routing rule. In case client
1656  *  specifies rule_id as 0 the driver will assign a new rule_id
1657  *		0 for success,
1658  *		-1 for failure
1659  */
1660 struct ipa_rt_rule_add_ext_v2 {
1661 	uint8_t at_rear;
1662 	uint32_t rt_rule_hdl;
1663 	int status;
1664 	uint16_t rule_id;
1665 	struct ipa_rt_rule_v2 rule;
1666 };
1667 
1668 /**
1669  * struct ipa_ioc_add_rt_rule_ext - routing rule addition
1670  * parameters (supports multiple rules and commit with rule_id);
1671  *
1672  * all rules MUST be added to same table
1673  * @commit: should rules be written to IPA HW also?
1674  * @ip: IP family of rule
1675  * @rt_tbl_name: name of routing table resource
1676  * @num_rules: number of routing rules that follow
1677  * @ipa_rt_rule_add_ext rules: all rules need to go back to back here,
1678  *  no pointers
1679  */
1680 struct ipa_ioc_add_rt_rule_ext {
1681 	uint8_t commit;
1682 	enum ipa_ip_type ip;
1683 	char rt_tbl_name[IPA_RESOURCE_NAME_MAX];
1684 	uint8_t num_rules;
1685 	struct ipa_rt_rule_add_ext rules[0];
1686 };
1687 
1688 /**
1689  * struct ipa_ioc_add_rt_rule_ext_v2 - routing rule addition
1690  * parameters (supports multiple rules and commit with rule_id);
1691  *
1692  * all rules MUST be added to same table
1693  * @commit: should rules be written to IPA HW also?
1694  * @ip: IP family of rule
1695  * @rt_tbl_name: name of routing table resource
1696  * @num_rules: number of routing rules that follow
1697  * @rule_add_ext_size: sizeof(struct ipa_rt_rule_add_ext_v2)
1698  * @reserved1: reserved bits for alignment
1699  * @reserved2: reserved bits for alignment
1700  * @ipa_rt_rule_add_ext rules: all rules need to go back to back here,
1701  *  no pointers
1702  */
1703 struct ipa_ioc_add_rt_rule_ext_v2 {
1704 	uint8_t commit;
1705 	enum ipa_ip_type ip;
1706 	char rt_tbl_name[IPA_RESOURCE_NAME_MAX];
1707 	uint8_t num_rules;
1708 	uint32_t rule_add_ext_size;
1709 	uint32_t reserved1;
1710 	uint8_t reserved2;
1711 	uint64_t rules;
1712 };
1713 
1714 
1715 /**
1716  * struct ipa_ioc_del_rt_rule - routing rule deletion parameters (supports
1717  * multiple headers and commit)
1718  * @commit: should rules be removed from IPA HW also?
1719  * @ip: IP family of rules
1720  * @num_hdls: num of rules being removed
1721  * @ipa_rt_rule_del hdl: all handles need to go back to back here, no pointers
1722  */
1723 struct ipa_ioc_del_rt_rule {
1724 	uint8_t commit;
1725 	enum ipa_ip_type ip;
1726 	uint8_t num_hdls;
1727 	struct ipa_rt_rule_del hdl[0];
1728 };
1729 
1730 /**
1731  * struct ipa_ioc_get_rt_tbl_indx - routing table index lookup parameters
1732  * @ip: IP family of table
1733  * @name: name of routing table resource
1734  * @index:	output parameter, routing table index, valid only when ioctl
1735  *		return val is non-negative
1736  */
1737 struct ipa_ioc_get_rt_tbl_indx {
1738 	enum ipa_ip_type ip;
1739 	char name[IPA_RESOURCE_NAME_MAX];
1740 	uint32_t idx;
1741 };
1742 
1743 /**
1744  * struct ipa_flt_rule_add - filtering rule descriptor includes
1745  * in and out parameters
1746  * @rule: actual rule to be added
1747  * @at_rear: add at back of filtering table?
1748  * @flt_rule_hdl: out parameter, handle to rule, valid when status is 0
1749  * @status:	output parameter, status of filtering rule add   operation,
1750  *		0 for success,
1751  *		-1 for failure
1752  *
1753  */
1754 struct ipa_flt_rule_add {
1755 	struct ipa_flt_rule rule;
1756 	uint8_t at_rear;
1757 	uint32_t flt_rule_hdl;
1758 	int status;
1759 };
1760 
1761 /**
1762  * struct ipa_flt_rule_add_v2 - filtering rule descriptor
1763  * includes in and out parameters
1764  * @rule: actual rule to be added
1765  * @at_rear: add at back of filtering table?
1766  * @flt_rule_hdl: out parameter, handle to rule, valid when status is 0
1767  * @status:	output parameter, status of filtering rule add   operation,
1768  *		0 for success,
1769  *		-1 for failure
1770  *
1771  */
1772 struct ipa_flt_rule_add_v2 {
1773 	uint8_t at_rear;
1774 	uint32_t flt_rule_hdl;
1775 	int status;
1776 	struct ipa_flt_rule_v2 rule;
1777 };
1778 
1779 /**
1780  * struct ipa_ioc_add_flt_rule - filtering rule addition parameters (supports
1781  * multiple rules and commit)
1782  * all rules MUST be added to same table
1783  * @commit: should rules be written to IPA HW also?
1784  * @ip: IP family of rule
1785  * @ep:	which "clients" pipe does this rule apply to?
1786  *	valid only when global is 0
1787  * @global: does this apply to global filter table of specific IP family
1788  * @num_rules: number of filtering rules that follow
1789  * @rules: all rules need to go back to back here, no pointers
1790  */
1791 struct ipa_ioc_add_flt_rule {
1792 	uint8_t commit;
1793 	enum ipa_ip_type ip;
1794 	enum ipa_client_type ep;
1795 	uint8_t global;
1796 	uint8_t num_rules;
1797 	struct ipa_flt_rule_add rules[0];
1798 };
1799 
1800 /**
1801  * struct ipa_ioc_add_flt_rule_v2 - filtering rule addition
1802  * parameters (supports multiple rules and commit)
1803  * all rules MUST be added to same table
1804  * @commit: should rules be written to IPA HW also?
1805  * @ip: IP family of rule
1806  * @ep:	which "clients" pipe does this rule apply to?
1807  *	valid only when global is 0
1808  * @global: does this apply to global filter table of specific IP family
1809  * @num_rules: number of filtering rules that follow
1810  * @flt_rule_size: sizeof(struct ipa_flt_rule_add_v2)
1811  * @reserved1: reserved bits for alignment
1812  * @reserved2: reserved bits for alignment
1813  * @reserved3: reserved bits for alignment
1814  * @rules: all rules need to go back to back here, no pointers
1815  */
1816 struct ipa_ioc_add_flt_rule_v2 {
1817 	uint8_t commit;
1818 	enum ipa_ip_type ip;
1819 	enum ipa_client_type ep;
1820 	uint8_t global;
1821 	uint8_t num_rules;
1822 	uint32_t flt_rule_size;
1823 	uint32_t reserved1;
1824 	uint16_t reserved2;
1825 	uint8_t reserved3;
1826 	uint64_t rules;
1827 };
1828 
1829 
1830 /**
1831  * struct ipa_ioc_add_flt_rule_after - filtering rule addition after specific
1832  * rule parameters (supports multiple rules and commit)
1833  * all rules MUST be added to same table
1834  * @commit: should rules be written to IPA HW also?
1835  * @ip: IP family of rule
1836  * @ep:	which "clients" pipe does this rule apply to?
1837  * @num_rules: number of filtering rules that follow
1838  * @add_after_hdl: rules will be added after the rule with this handle
1839  * @rules: all rules need to go back to back here, no pointers. at rear field
1840  *	   is ignored when using this IOCTL
1841  */
1842 struct ipa_ioc_add_flt_rule_after {
1843 	uint8_t commit;
1844 	enum ipa_ip_type ip;
1845 	enum ipa_client_type ep;
1846 	uint8_t num_rules;
1847 	uint32_t add_after_hdl;
1848 	struct ipa_flt_rule_add rules[0];
1849 };
1850 
1851 /**
1852  * struct ipa_ioc_add_flt_rule_after_v2 - filtering rule
1853  * addition after specific rule parameters (supports multiple
1854  * rules and commit) all rules MUST be added to same table
1855  * @commit: should rules be written to IPA HW also?
1856  * @ip: IP family of rule
1857  * @ep:	which "clients" pipe does this rule apply to?
1858  * @num_rules: number of filtering rules that follow
1859  * @add_after_hdl: rules will be added after the rule with this handle
1860  * @flt_rule_size: sizeof(struct ipa_flt_rule_add_v2)
1861  * @reserved: reserved bits for alignment
1862  * @rules: all rules need to go back to back here, no pointers. at rear field
1863  *	   is ignored when using this IOCTL
1864  */
1865 struct ipa_ioc_add_flt_rule_after_v2 {
1866 	uint8_t commit;
1867 	enum ipa_ip_type ip;
1868 	enum ipa_client_type ep;
1869 	uint8_t num_rules;
1870 	uint32_t add_after_hdl;
1871 	uint32_t flt_rule_size;
1872 	uint32_t reserved;
1873 	uint64_t rules;
1874 };
1875 
1876 /**
1877  * struct ipa_flt_rule_mdfy - filtering rule descriptor includes
1878  * in and out parameters
1879  * @rule: actual rule to be added
1880  * @flt_rule_hdl: handle to rule
1881  * @status:	output parameter, status of filtering rule modify  operation,
1882  *		0 for success,
1883  *		-1 for failure
1884  *
1885  */
1886 struct ipa_flt_rule_mdfy {
1887 	struct ipa_flt_rule rule;
1888 	uint32_t rule_hdl;
1889 	int status;
1890 };
1891 
1892 /**
1893  * struct ipa_flt_rule_mdfy_v2 - filtering rule descriptor
1894  * includes in and out parameters
1895  * @rule: actual rule to be added
1896  * @flt_rule_hdl: handle to rule
1897  * @status:	output parameter, status of filtering rule modify  operation,
1898  *		0 for success,
1899  *		-1 for failure
1900  *
1901  */
1902 struct ipa_flt_rule_mdfy_v2 {
1903 	uint32_t rule_hdl;
1904 	int status;
1905 	struct ipa_flt_rule_v2 rule;
1906 };
1907 
1908 /**
1909  * struct ipa_ioc_mdfy_flt_rule - filtering rule modify parameters (supports
1910  * multiple rules and commit)
1911  * @commit: should rules be written to IPA HW also?
1912  * @ip: IP family of rule
1913  * @num_rules: number of filtering rules that follow
1914  * @rules: all rules need to go back to back here, no pointers
1915  */
1916 struct ipa_ioc_mdfy_flt_rule {
1917 	uint8_t commit;
1918 	enum ipa_ip_type ip;
1919 	uint8_t num_rules;
1920 	struct ipa_flt_rule_mdfy rules[0];
1921 };
1922 
1923 /**
1924  * struct ipa_ioc_mdfy_flt_rule_v2 - filtering rule modify
1925  * parameters (supports multiple rules and commit)
1926  * @commit: should rules be written to IPA HW also?
1927  * @ip: IP family of rule
1928  * @num_rules: number of filtering rules that follow
1929  * @rule_mdfy_size: sizeof(struct ipa_flt_rule_mdfy_v2)
1930  * @reserved: reserved bits for alignment
1931  * @rules: all rules need to go back to back here, no pointers
1932  */
1933 struct ipa_ioc_mdfy_flt_rule_v2 {
1934 	uint8_t commit;
1935 	enum ipa_ip_type ip;
1936 	uint8_t num_rules;
1937 	uint32_t rule_mdfy_size;
1938 	uint8_t reserved;
1939 	uint64_t rules;
1940 };
1941 
1942 /**
1943  * struct ipa_flt_rule_del - filtering rule descriptor includes
1944  * in and out parameters
1945  *
1946  * @hdl: handle returned from filtering rule add operation
1947  * @status:	output parameter, status of filtering rule delete operation,
1948  *		0 for success,
1949  *		-1 for failure
1950  */
1951 struct ipa_flt_rule_del {
1952 	uint32_t hdl;
1953 	int status;
1954 };
1955 
1956 /**
1957  * struct ipa_ioc_del_flt_rule - filtering rule deletion parameters (supports
1958  * multiple headers and commit)
1959  * @commit: should rules be removed from IPA HW also?
1960  * @ip: IP family of rules
1961  * @num_hdls: num of rules being removed
1962  * @hdl: all handles need to go back to back here, no pointers
1963  */
1964 struct ipa_ioc_del_flt_rule {
1965 	uint8_t commit;
1966 	enum ipa_ip_type ip;
1967 	uint8_t num_hdls;
1968 	struct ipa_flt_rule_del hdl[0];
1969 };
1970 
1971 /**
1972  * struct ipa_ioc_get_rt_tbl - routing table lookup parameters, if lookup was
1973  * successful caller must call put to release the reference
1974  * count when done
1975  * @ip: IP family of table
1976  * @name: name of routing table resource
1977  * @htl:	output parameter, handle of routing table, valid only when ioctl
1978  *		return val is non-negative
1979  */
1980 struct ipa_ioc_get_rt_tbl {
1981 	enum ipa_ip_type ip;
1982 	char name[IPA_RESOURCE_NAME_MAX];
1983 	uint32_t hdl;
1984 };
1985 
1986 /**
1987  * struct ipa_ioc_query_intf - used to lookup number of tx and
1988  * rx properties of interface
1989  * @name: name of interface
1990  * @num_tx_props:	output parameter, number of tx properties
1991  *			valid only when ioctl return val is non-negative
1992  * @num_rx_props:	output parameter, number of rx properties
1993  *			valid only when ioctl return val is non-negative
1994  * @num_ext_props:	output parameter, number of ext properties
1995  *			valid only when ioctl return val is non-negative
1996  * @excp_pipe:		exception packets of this interface should be
1997  *			routed to this pipe
1998  */
1999 struct ipa_ioc_query_intf {
2000 	char name[IPA_RESOURCE_NAME_MAX];
2001 	uint32_t num_tx_props;
2002 	uint32_t num_rx_props;
2003 	uint32_t num_ext_props;
2004 	enum ipa_client_type excp_pipe;
2005 };
2006 
2007 /**
2008  * struct ipa_ioc_tx_intf_prop - interface tx property
2009  * @ip: IP family of routing rule
2010  * @attrib: routing rule
2011  * @dst_pipe: routing output pipe
2012  * @alt_dst_pipe: alternate routing output pipe
2013  * @hdr_name: name of associated header if any, empty string when no header
2014  * @hdr_l2_type: type of associated header if any, use NONE when no header
2015  */
2016 struct ipa_ioc_tx_intf_prop {
2017 	enum ipa_ip_type ip;
2018 	struct ipa_rule_attrib attrib;
2019 	enum ipa_client_type dst_pipe;
2020 	enum ipa_client_type alt_dst_pipe;
2021 	char hdr_name[IPA_RESOURCE_NAME_MAX];
2022 	enum ipa_hdr_l2_type hdr_l2_type;
2023 };
2024 
2025 /**
2026  * struct ipa_ioc_query_intf_tx_props - interface tx propertie
2027  * @name: name of interface
2028  * @num_tx_props: number of TX properties
2029  * @tx[0]: output parameter, the tx properties go here back to back
2030  */
2031 struct ipa_ioc_query_intf_tx_props {
2032 	char name[IPA_RESOURCE_NAME_MAX];
2033 	uint32_t num_tx_props;
2034 	struct ipa_ioc_tx_intf_prop tx[0];
2035 };
2036 
2037 /**
2038  * struct ipa_ioc_ext_intf_prop - interface extended property
2039  * @ip: IP family of routing rule
2040  * @eq_attrib: attributes of the rule in equation form
2041  * @action: action field
2042  * @rt_tbl_idx: index of RT table referred to by filter rule
2043  * @mux_id: MUX_ID
2044  * @filter_hdl: handle of filter (as specified by provider of filter rule)
2045  * @is_xlat_rule: it is xlat flt rule or not
2046  */
2047 struct ipa_ioc_ext_intf_prop {
2048 	enum ipa_ip_type ip;
2049 	struct ipa_ipfltri_rule_eq eq_attrib;
2050 	enum ipa_flt_action action;
2051 	uint32_t rt_tbl_idx;
2052 	uint8_t mux_id;
2053 	uint32_t filter_hdl;
2054 	uint8_t is_xlat_rule;
2055 	uint32_t rule_id;
2056 	uint8_t is_rule_hashable;
2057 #define IPA_V6_UL_WL_FIREWALL_HANDLE
2058 	uint8_t replicate_needed;
2059 };
2060 
2061 /**
2062  * struct ipa_ioc_query_intf_ext_props - interface ext propertie
2063  * @name: name of interface
2064  * @num_ext_props: number of EXT properties
2065  * @ext[0]: output parameter, the ext properties go here back to back
2066  */
2067 struct ipa_ioc_query_intf_ext_props {
2068 	char name[IPA_RESOURCE_NAME_MAX];
2069 	uint32_t num_ext_props;
2070 	struct ipa_ioc_ext_intf_prop ext[0];
2071 };
2072 
2073 /**
2074  * struct ipa_ioc_rx_intf_prop - interface rx property
2075  * @ip: IP family of filtering rule
2076  * @attrib: filtering rule
2077  * @src_pipe: input pipe
2078  * @hdr_l2_type: type of associated header if any, use NONE when no header
2079  */
2080 struct ipa_ioc_rx_intf_prop {
2081 	enum ipa_ip_type ip;
2082 	struct ipa_rule_attrib attrib;
2083 	enum ipa_client_type src_pipe;
2084 	enum ipa_hdr_l2_type hdr_l2_type;
2085 };
2086 
2087 /**
2088  * struct ipa_ioc_query_intf_rx_props - interface rx propertie
2089  * @name: name of interface
2090  * @num_rx_props: number of RX properties
2091  * @rx: output parameter, the rx properties go here back to back
2092  */
2093 struct ipa_ioc_query_intf_rx_props {
2094 	char name[IPA_RESOURCE_NAME_MAX];
2095 	uint32_t num_rx_props;
2096 	struct ipa_ioc_rx_intf_prop rx[0];
2097 };
2098 
2099 /**
2100  * struct ipa_ioc_nat_alloc_mem - nat table memory allocation
2101  * properties
2102  * @dev_name: input parameter, the name of table
2103  * @size: input parameter, size of table in bytes
2104  * @offset: output parameter, offset into page in case of system memory
2105  */
2106 struct ipa_ioc_nat_alloc_mem {
2107 	char dev_name[IPA_RESOURCE_NAME_MAX];
2108 	size_t size;
2109 	off_t offset;
2110 };
2111 
2112 /**
2113  * struct ipa_ioc_nat_ipv6ct_table_alloc - NAT/IPv6CT table memory allocation
2114  * properties
2115  * @size: input parameter, size of table in bytes
2116  * @offset: output parameter, offset into page in case of system memory
2117  */
2118 struct ipa_ioc_nat_ipv6ct_table_alloc {
2119 	size_t size;
2120 	off_t offset;
2121 };
2122 
2123 /**
2124  * struct ipa_ioc_v4_nat_init - nat table initialization parameters
2125  * @tbl_index: input parameter, index of the table
2126  * @ipv4_rules_offset: input parameter, ipv4 rules address offset
2127  * @expn_rules_offset: input parameter, ipv4 expansion rules address offset
2128  * @index_offset: input parameter, index rules offset
2129  * @index_expn_offset: input parameter, index expansion rules offset
2130  * @table_entries: input parameter, ipv4 rules table number of entries
2131  * @expn_table_entries: input parameter, ipv4 expansion rules table number of
2132  *                      entries
2133  * @ip_addr: input parameter, public ip address
2134  * @mem_type: input parameter, type of memory the table resides in
2135  * @focus_change: input parameter, are we moving to/from sram or ddr
2136  */
2137 struct ipa_ioc_v4_nat_init {
2138 	uint8_t  tbl_index;
2139 	uint32_t ipv4_rules_offset;
2140 	uint32_t expn_rules_offset;
2141 
2142 	uint32_t index_offset;
2143 	uint32_t index_expn_offset;
2144 
2145 	uint16_t table_entries;
2146 	uint16_t expn_table_entries;
2147 	uint32_t ip_addr;
2148 
2149 	uint8_t  mem_type;
2150 	uint8_t  focus_change;
2151 };
2152 
2153 /**
2154  * struct ipa_ioc_ipv6ct_init - IPv6CT table initialization parameters
2155  * @base_table_offset: input parameter, IPv6CT base table address offset
2156  * @expn_table_offset: input parameter, IPv6CT expansion table address offset
2157  * @table_entries: input parameter, IPv6CT table number of entries
2158  * @expn_table_entries: input parameter, IPv6CT expansion table number of
2159  *                      entries
2160  * @tbl_index: input parameter, index of the table
2161  */
2162 struct ipa_ioc_ipv6ct_init {
2163 	uint32_t base_table_offset;
2164 	uint32_t expn_table_offset;
2165 	uint16_t table_entries;
2166 	uint16_t expn_table_entries;
2167 	uint8_t tbl_index;
2168 };
2169 
2170 /**
2171  * struct ipa_ioc_v4_nat_del - nat table delete parameter
2172  * @table_index: input parameter, index of the table
2173  * @public_ip_addr: input parameter, public ip address
2174  */
2175 struct ipa_ioc_v4_nat_del {
2176 	uint8_t table_index;
2177 	uint32_t public_ip_addr;
2178 };
2179 
2180 /**
2181  * struct ipa_ioc_nat_ipv6ct_table_del - NAT/IPv6CT table delete parameter
2182  * @table_index: input parameter, index of the table
2183  * @mem_type: input parameter, type of memory the table resides in
2184  */
2185 struct ipa_ioc_nat_ipv6ct_table_del {
2186 	uint8_t table_index;
2187 	uint8_t mem_type;
2188 };
2189 
2190 /**
2191  * struct ipa_ioc_nat_dma_one - nat/ipv6ct dma command parameter
2192  * @table_index: input parameter, index of the table
2193  * @base_addr:	type of table, from which the base address of the table
2194  *		can be inferred
2195  * @offset: destination offset within the NAT table
2196  * @data: data to be written.
2197  */
2198 struct ipa_ioc_nat_dma_one {
2199 	uint8_t table_index;
2200 	uint8_t base_addr;
2201 
2202 	uint32_t offset;
2203 	uint16_t data;
2204 
2205 };
2206 
2207 /**
2208  * struct ipa_ioc_nat_dma_cmd - To hold multiple nat/ipv6ct dma commands
2209  * @entries: number of dma commands in use
2210  * @dma: data pointer to the dma commands
2211  * @mem_type: input parameter, type of memory the table resides in
2212  */
2213 struct ipa_ioc_nat_dma_cmd {
2214 	uint8_t entries;
2215 	uint8_t mem_type;
2216 	struct ipa_ioc_nat_dma_one dma[0];
2217 };
2218 
2219 /**
2220  * struct ipa_ioc_nat_pdn_entry - PDN entry modification data
2221  * @pdn_index: index of the entry in the PDN config table to be changed
2222  * @public_ip: PDN's public ip
2223  * @src_metadata: PDN's source NAT metadata for metadata replacement
2224  * @dst_metadata: PDN's destination NAT metadata for metadata replacement
2225  */
2226 struct ipa_ioc_nat_pdn_entry {
2227 	uint8_t pdn_index;
2228 	uint32_t public_ip;
2229 	uint32_t src_metadata;
2230 	uint32_t dst_metadata;
2231 };
2232 
2233 /**
2234  * struct ipa_ioc_vlan_iface_info - add vlan interface
2235  * @name: interface name
2236  * @vlan_id: VLAN ID
2237  */
2238 struct ipa_ioc_vlan_iface_info {
2239 	char name[IPA_RESOURCE_NAME_MAX];
2240 	uint8_t vlan_id;
2241 };
2242 
2243 /**
2244  * struct ipa_ioc_l2tp_vlan_mapping_info - l2tp->vlan mapping info
2245  * @iptype: l2tp tunnel IP type
2246  * @l2tp_iface_name: l2tp interface name
2247  * @l2tp_session_id: l2tp session id
2248  * @vlan_iface_name: vlan interface name
2249  */
2250 struct ipa_ioc_l2tp_vlan_mapping_info {
2251 	enum ipa_ip_type iptype;
2252 	char l2tp_iface_name[IPA_RESOURCE_NAME_MAX];
2253 	uint8_t l2tp_session_id;
2254 	char vlan_iface_name[IPA_RESOURCE_NAME_MAX];
2255 };
2256 
2257 /**
2258  * struct ipa_ioc_gsb_info - connect/disconnect
2259  * @name: interface name
2260  */
2261 struct ipa_ioc_gsb_info {
2262 	char name[IPA_RESOURCE_NAME_MAX];
2263 };
2264 
2265 /**
2266  * struct ipa_ioc_wigig_fst_switch - switch between wigig and wlan
2267  * @netdev_name: wigig interface name
2268  * @client_mac_addr: client to switch between netdevs
2269  * @to_wigig: shall wlan client switch to wigig or the opposite?
2270  */
2271 struct ipa_ioc_wigig_fst_switch {
2272 	uint8_t netdev_name[IPA_RESOURCE_NAME_MAX];
2273 	uint8_t client_mac_addr[IPA_MAC_ADDR_SIZE];
2274 	int to_wigig;
2275 };
2276 
2277 /**
2278  * struct ipa_msg_meta - Format of the message meta-data.
2279  * @msg_type: the type of the message
2280  * @rsvd: reserved bits for future use.
2281  * @msg_len: the length of the message in bytes
2282  *
2283  * For push model:
2284  * Client in user-space should issue a read on the device (/dev/ipa) with a
2285  * sufficiently large buffer in a continuous loop, call will block when there is
2286  * no message to read. Upon return, client can read the ipa_msg_meta from start
2287  * of buffer to find out type and length of message
2288  * size of buffer supplied >= (size of largest message + size of metadata)
2289  *
2290  * For pull model:
2291  * Client in user-space can also issue a pull msg IOCTL to device (/dev/ipa)
2292  * with a payload containing space for the ipa_msg_meta and the message specific
2293  * payload length.
2294  * size of buffer supplied == (len of specific message  + size of metadata)
2295  */
2296 struct ipa_msg_meta {
2297 	uint8_t msg_type;
2298 	uint8_t rsvd;
2299 	uint16_t msg_len;
2300 };
2301 
2302 /**
2303  * struct ipa_wlan_msg - To hold information about wlan client
2304  * @name: name of the wlan interface
2305  * @mac_addr: mac address of wlan client
2306  *
2307  * wlan drivers need to pass name of wlan iface and mac address of
2308  * wlan client along with ipa_wlan_event, whenever a wlan client is
2309  * connected/disconnected/moved to power save/come out of power save
2310  */
2311 struct ipa_wlan_msg {
2312 	char name[IPA_RESOURCE_NAME_MAX];
2313 	uint8_t mac_addr[IPA_MAC_ADDR_SIZE];
2314 };
2315 
2316 /**
2317  * enum ipa_wlan_hdr_attrib_type - attribute type
2318  * in wlan client header
2319  *
2320  * WLAN_HDR_ATTRIB_MAC_ADDR: attrib type mac address
2321  * WLAN_HDR_ATTRIB_STA_ID: attrib type station id
2322  */
2323 enum ipa_wlan_hdr_attrib_type {
2324 	WLAN_HDR_ATTRIB_MAC_ADDR,
2325 	WLAN_HDR_ATTRIB_STA_ID
2326 };
2327 
2328 /**
2329  * struct ipa_wlan_hdr_attrib_val - header attribute value
2330  * @attrib_type: type of attribute
2331  * @offset: offset of attribute within header
2332  * @u.mac_addr: mac address
2333  * @u.sta_id: station id
2334  */
2335 struct ipa_wlan_hdr_attrib_val {
2336 	enum ipa_wlan_hdr_attrib_type attrib_type;
2337 	uint8_t offset;
2338 	union {
2339 		uint8_t mac_addr[IPA_MAC_ADDR_SIZE];
2340 		uint8_t sta_id;
2341 	} u;
2342 };
2343 
2344 /**
2345  * struct ipa_wlan_msg_ex - To hold information about wlan client
2346  * @name: name of the wlan interface
2347  * @num_of_attribs: number of attributes
2348  * @attrib_val: holds attribute values
2349  *
2350  * wlan drivers need to pass name of wlan iface and mac address
2351  * of wlan client or station id along with ipa_wlan_event,
2352  * whenever a wlan client is connected/disconnected/moved to
2353  * power save/come out of power save
2354  */
2355 struct ipa_wlan_msg_ex {
2356 	char name[IPA_RESOURCE_NAME_MAX];
2357 	uint8_t num_of_attribs;
2358 	struct ipa_wlan_hdr_attrib_val attribs[0];
2359 };
2360 
2361 /**
2362  * struct ipa_wigig_msg- To hold information about wigig event
2363  * @name: name of the wigig interface
2364  * @client_mac_addr: the relevant wigig client mac address
2365  * @ipa_client: TX pipe associated with the wigig client in case of connect
2366  * @to_wigig: FST switch direction wlan->wigig?
2367  */
2368 struct ipa_wigig_msg {
2369 	char name[IPA_RESOURCE_NAME_MAX];
2370 	uint8_t client_mac_addr[IPA_MAC_ADDR_SIZE];
2371 	union {
2372 		enum ipa_client_type ipa_client;
2373 		uint8_t to_wigig;
2374 	} u;
2375 };
2376 
2377 struct ipa_ecm_msg {
2378 	char name[IPA_RESOURCE_NAME_MAX];
2379 	int ifindex;
2380 };
2381 
2382 /**
2383  * struct ipa_wan_msg - To hold information about wan client
2384  * @name: name of the wan interface
2385  *
2386  * CnE need to pass the name of default wan iface when connected/disconnected.
2387  * CNE need to pass the gw info in wlan AP+STA mode.
2388  * netmgr need to pass the name of wan eMBMS iface when connected.
2389  */
2390 struct ipa_wan_msg {
2391 	char upstream_ifname[IPA_RESOURCE_NAME_MAX];
2392 	char tethered_ifname[IPA_RESOURCE_NAME_MAX];
2393 	enum ipa_ip_type ip;
2394 	uint32_t ipv4_addr_gw;
2395 	uint32_t ipv6_addr_gw[IPA_WAN_MSG_IPv6_ADDR_GW_LEN];
2396 };
2397 
2398 /**
2399  * struct ipa_ioc_rm_dependency - parameters for add/delete dependency
2400  * @resource_name: name of dependent resource
2401  * @depends_on_name: name of its dependency
2402  */
2403 struct ipa_ioc_rm_dependency {
2404 	enum ipa_rm_resource_name resource_name;
2405 	enum ipa_rm_resource_name depends_on_name;
2406 };
2407 
2408 struct ipa_ioc_generate_flt_eq {
2409 	enum ipa_ip_type ip;
2410 	struct ipa_rule_attrib attrib;
2411 	struct ipa_ipfltri_rule_eq eq_attrib;
2412 };
2413 
2414 /**
2415  * struct ipa_ioc_write_qmapid - to write mux id to endpoint meta register
2416  * @mux_id: mux id of wan
2417  */
2418 struct ipa_ioc_write_qmapid {
2419 	enum ipa_client_type client;
2420 	uint8_t qmap_id;
2421 };
2422 
2423 /**
2424  * struct ipa_flt_rt_counter_alloc - flt/rt counter id allocation
2425  * @num_counters: input param, num of counters need to be allocated
2426  * @allow_less: input param, if true, success even few counter than request
2427  * @start_id: output param, allocated start_id, 0 when allocation fails
2428  * @end_id: output param, allocated start_id, 0 when allocation fails
2429  */
2430 struct ipa_flt_rt_counter_alloc {
2431 	uint8_t num_counters;
2432 	uint8_t allow_less;
2433 	uint8_t start_id;
2434 	uint8_t end_id;
2435 };
2436 
2437 /**
2438  * struct ipa_ioc_flt_rt_counter_alloc - flt/rt counter id allocation ioctl
2439  * @hdl: output param, hdl used for deallocation, negative if allocation fails
2440  * @hw_counter: HW counters for HW process
2441  * @sw_counter: SW counters for uC / non-HW process
2442  */
2443 struct ipa_ioc_flt_rt_counter_alloc {
2444 	int hdl;
2445 	struct ipa_flt_rt_counter_alloc hw_counter;
2446 	struct ipa_flt_rt_counter_alloc sw_counter;
2447 };
2448 
2449 /**
2450  * struct ipa_flt_rt_stats - flt/rt stats info
2451  * @num_pkts: number of packets
2452  * @num_pkts_hash: number of packets in hash entry
2453  * @num_bytes: number of bytes
2454  */
2455 struct ipa_flt_rt_stats {
2456 	uint32_t num_pkts;
2457 	uint32_t num_pkts_hash;
2458 	uint64_t num_bytes;
2459 };
2460 
2461 /**
2462  * struct ipa_ioc_flt_rt_query - flt/rt counter id query
2463  * @start_id: start counter id for query
2464  * @end_id: end counter id for query
2465  * @reset: this query need hw counter to be reset or not
2466  * @stats_size: sizeof(ipa_flt_rt_stats)
2467  * @reserved: reserved bits for alignment
2468  * @stats: structure contains the query result
2469  */
2470 struct ipa_ioc_flt_rt_query {
2471 	uint8_t start_id;
2472 	uint8_t end_id;
2473 	uint8_t reset;
2474 	uint32_t stats_size;
2475 	uint8_t reserved;
2476 	uint64_t stats;
2477 };
2478 
2479 enum ipacm_client_enum {
2480 	IPACM_CLIENT_USB = 1,
2481 	IPACM_CLIENT_WLAN,
2482 	IPACM_CLIENT_MAX
2483 };
2484 
2485 #define IPACM_SUPPORT_OF_LAN_STATS_FOR_ODU_CLIENTS
2486 
2487 enum ipacm_per_client_device_type {
2488 	IPACM_CLIENT_DEVICE_TYPE_USB = 0,
2489 	IPACM_CLIENT_DEVICE_TYPE_WLAN = 1,
2490 	IPACM_CLIENT_DEVICE_TYPE_ETH = 2,
2491 	IPACM_CLIENT_DEVICE_TYPE_ODU = 3,
2492 	IPACM_CLIENT_DEVICE_MAX
2493 };
2494 
2495 /**
2496  * max number of device types supported.
2497  */
2498 #define IPACM_MAX_CLIENT_DEVICE_TYPES IPACM_CLIENT_DEVICE_MAX
2499 
2500 /**
2501  * @lanIface - Name of the lan interface
2502  * @mac: Mac address of the client.
2503  */
2504 struct ipa_lan_client_msg {
2505 	char lanIface[IPA_RESOURCE_NAME_MAX];
2506 	uint8_t mac[IPA_MAC_ADDR_SIZE];
2507 };
2508 
2509 /**
2510  * struct ipa_lan_client - lan client data
2511  * @mac: MAC Address of the client.
2512  * @client_idx: Client Index.
2513  * @inited: Bool to indicate whether client info is set.
2514  */
2515 struct ipa_lan_client {
2516 	uint8_t mac[IPA_MAC_ADDR_SIZE];
2517 	int8_t client_idx;
2518 	uint8_t inited;
2519 };
2520 
2521 /**
2522  * struct ipa_tether_device_info - tether device info indicated from IPACM
2523  * @ul_src_pipe: Source pipe of the lan client.
2524  * @hdr_len: Header length of the client.
2525  * @num_clients: Number of clients connected.
2526  */
2527 struct ipa_tether_device_info {
2528 	int32_t ul_src_pipe;
2529 	uint8_t hdr_len;
2530 	uint32_t num_clients;
2531 	struct ipa_lan_client lan_client[IPA_MAX_NUM_HW_PATH_CLIENTS];
2532 };
2533 
2534 /**
2535  * enum ipa_vlan_ifaces - vlan interfaces types
2536  */
2537 enum ipa_vlan_ifaces {
2538 	IPA_VLAN_IF_ETH,
2539 	IPA_VLAN_IF_RNDIS,
2540 	IPA_VLAN_IF_ECM
2541 };
2542 
2543 #define IPA_VLAN_IF_EMAC IPA_VLAN_IF_ETH
2544 #define IPA_VLAN_IF_MAX (IPA_VLAN_IF_ECM + 1)
2545 
2546 /**
2547  * struct ipa_get_vlan_mode - get vlan mode of a Lan interface
2548  * @iface: Lan interface type to be queried.
2549  * @is_vlan_mode: output parameter, is interface in vlan mode, valid only when
2550  *		ioctl return val is non-negative
2551  */
2552 struct ipa_ioc_get_vlan_mode {
2553 	enum ipa_vlan_ifaces iface;
2554 	uint32_t is_vlan_mode;
2555 };
2556 
2557 /**
2558  * struct ipa_ioc_bridge_vlan_mapping_info - vlan to bridge mapping info
2559  * @bridge_name: bridge interface name
2560  * @vlan_id: vlan ID bridge is mapped to
2561  * @bridge_ipv4: bridge interface ipv4 address
2562  * @subnet_mask: bridge interface subnet mask
2563  */
2564 struct ipa_ioc_bridge_vlan_mapping_info {
2565 	char bridge_name[IPA_RESOURCE_NAME_MAX];
2566 	uint16_t vlan_id;
2567 	uint32_t bridge_ipv4;
2568 	uint32_t subnet_mask;
2569 };
2570 
2571 struct ipa_coalesce_info {
2572 	uint8_t qmap_id;
2573 	uint8_t tcp_enable;
2574 	uint8_t udp_enable;
2575 };
2576 
2577 struct ipa_odl_ep_info {
2578 	__u32 cons_pipe_num;
2579 	__u32 prod_pipe_num;
2580 	__u32 peripheral_iface_id;
2581 	__u32 ep_type;
2582 };
2583 
2584 struct odl_agg_pipe_info {
2585 	__u16 agg_byte_limit;
2586 };
2587 
2588 struct ipa_odl_modem_config {
2589 	__u8 config_status;
2590 };
2591 
2592 struct ipa_ioc_fnr_index_info {
2593 	uint8_t hw_counter_offset;
2594 	uint8_t sw_counter_offset;
2595 };
2596 
2597 enum ipacm_hw_index_counter_type {
2598 	UL_HW = 0,
2599 	DL_HW,
2600 	DL_ALL,
2601 	UL_ALL,
2602 };
2603 
2604 enum ipacm_hw_index_counter_virtual_type {
2605 	UL_HW_CACHE = 0,
2606 	DL_HW_CACHE,
2607 	UL_WLAN_TX,
2608 	DL_WLAN_TX
2609 };
2610 
2611 /**
2612  *   actual IOCTLs supported by IPA driver
2613  */
2614 #define IPA_IOC_ADD_HDR _IOWR(IPA_IOC_MAGIC, \
2615 					IPA_IOCTL_ADD_HDR, \
2616 					struct ipa_ioc_add_hdr *)
2617 #define IPA_IOC_DEL_HDR _IOWR(IPA_IOC_MAGIC, \
2618 					IPA_IOCTL_DEL_HDR, \
2619 					struct ipa_ioc_del_hdr *)
2620 #define IPA_IOC_ADD_RT_RULE _IOWR(IPA_IOC_MAGIC, \
2621 					IPA_IOCTL_ADD_RT_RULE, \
2622 					struct ipa_ioc_add_rt_rule *)
2623 #define IPA_IOC_ADD_RT_RULE_V2 _IOWR(IPA_IOC_MAGIC, \
2624 					IPA_IOCTL_ADD_RT_RULE_V2, \
2625 					struct ipa_ioc_add_rt_rule_v2 *)
2626 #define IPA_IOC_ADD_RT_RULE_EXT _IOWR(IPA_IOC_MAGIC, \
2627 					IPA_IOCTL_ADD_RT_RULE_EXT, \
2628 					struct ipa_ioc_add_rt_rule_ext *)
2629 #define IPA_IOC_ADD_RT_RULE_EXT_V2 _IOWR(IPA_IOC_MAGIC, \
2630 					IPA_IOCTL_ADD_RT_RULE_EXT_V2, \
2631 					struct ipa_ioc_add_rt_rule_ext_v2 *)
2632 #define IPA_IOC_ADD_RT_RULE_AFTER _IOWR(IPA_IOC_MAGIC, \
2633 					IPA_IOCTL_ADD_RT_RULE_AFTER, \
2634 					struct ipa_ioc_add_rt_rule_after *)
2635 #define IPA_IOC_ADD_RT_RULE_AFTER_V2 _IOWR(IPA_IOC_MAGIC, \
2636 					IPA_IOCTL_ADD_RT_RULE_AFTER_V2, \
2637 					struct ipa_ioc_add_rt_rule_after_v2 *)
2638 #define IPA_IOC_DEL_RT_RULE _IOWR(IPA_IOC_MAGIC, \
2639 					IPA_IOCTL_DEL_RT_RULE, \
2640 					struct ipa_ioc_del_rt_rule *)
2641 #define IPA_IOC_ADD_FLT_RULE _IOWR(IPA_IOC_MAGIC, \
2642 					IPA_IOCTL_ADD_FLT_RULE, \
2643 					struct ipa_ioc_add_flt_rule *)
2644 #define IPA_IOC_ADD_FLT_RULE_V2 _IOWR(IPA_IOC_MAGIC, \
2645 					IPA_IOCTL_ADD_FLT_RULE_V2, \
2646 					struct ipa_ioc_add_flt_rule_v2 *)
2647 #define IPA_IOC_ADD_FLT_RULE_AFTER _IOWR(IPA_IOC_MAGIC, \
2648 					IPA_IOCTL_ADD_FLT_RULE_AFTER, \
2649 					struct ipa_ioc_add_flt_rule_after *)
2650 #define IPA_IOC_ADD_FLT_RULE_AFTER_V2 _IOWR(IPA_IOC_MAGIC, \
2651 					IPA_IOCTL_ADD_FLT_RULE_AFTER_V2, \
2652 					struct ipa_ioc_add_flt_rule_after_v2 *)
2653 #define IPA_IOC_DEL_FLT_RULE _IOWR(IPA_IOC_MAGIC, \
2654 					IPA_IOCTL_DEL_FLT_RULE, \
2655 					struct ipa_ioc_del_flt_rule *)
2656 #define IPA_IOC_COMMIT_HDR _IO(IPA_IOC_MAGIC,\
2657 					IPA_IOCTL_COMMIT_HDR)
2658 #define IPA_IOC_RESET_HDR _IO(IPA_IOC_MAGIC,\
2659 					IPA_IOCTL_RESET_HDR)
2660 #define IPA_IOC_COMMIT_RT _IOW(IPA_IOC_MAGIC, \
2661 					IPA_IOCTL_COMMIT_RT, \
2662 					enum ipa_ip_type)
2663 #define IPA_IOC_RESET_RT _IOW(IPA_IOC_MAGIC, \
2664 					IPA_IOCTL_RESET_RT, \
2665 					enum ipa_ip_type)
2666 #define IPA_IOC_COMMIT_FLT _IOW(IPA_IOC_MAGIC, \
2667 					IPA_IOCTL_COMMIT_FLT, \
2668 					enum ipa_ip_type)
2669 #define IPA_IOC_RESET_FLT _IOW(IPA_IOC_MAGIC, \
2670 			IPA_IOCTL_RESET_FLT, \
2671 			enum ipa_ip_type)
2672 #define IPA_IOC_DUMP _IO(IPA_IOC_MAGIC, \
2673 			IPA_IOCTL_DUMP)
2674 #define IPA_IOC_GET_RT_TBL _IOWR(IPA_IOC_MAGIC, \
2675 				IPA_IOCTL_GET_RT_TBL, \
2676 				struct ipa_ioc_get_rt_tbl *)
2677 #define IPA_IOC_PUT_RT_TBL _IOW(IPA_IOC_MAGIC, \
2678 				IPA_IOCTL_PUT_RT_TBL, \
2679 				uint32_t)
2680 #define IPA_IOC_COPY_HDR _IOWR(IPA_IOC_MAGIC, \
2681 				IPA_IOCTL_COPY_HDR, \
2682 				struct ipa_ioc_copy_hdr *)
2683 #define IPA_IOC_QUERY_INTF _IOWR(IPA_IOC_MAGIC, \
2684 				IPA_IOCTL_QUERY_INTF, \
2685 				struct ipa_ioc_query_intf *)
2686 #define IPA_IOC_QUERY_INTF_TX_PROPS _IOWR(IPA_IOC_MAGIC, \
2687 				IPA_IOCTL_QUERY_INTF_TX_PROPS, \
2688 				struct ipa_ioc_query_intf_tx_props *)
2689 #define IPA_IOC_QUERY_INTF_RX_PROPS _IOWR(IPA_IOC_MAGIC, \
2690 					IPA_IOCTL_QUERY_INTF_RX_PROPS, \
2691 					struct ipa_ioc_query_intf_rx_props *)
2692 #define IPA_IOC_QUERY_INTF_EXT_PROPS _IOWR(IPA_IOC_MAGIC, \
2693 					IPA_IOCTL_QUERY_INTF_EXT_PROPS, \
2694 					struct ipa_ioc_query_intf_ext_props *)
2695 #define IPA_IOC_GET_HDR _IOWR(IPA_IOC_MAGIC, \
2696 				IPA_IOCTL_GET_HDR, \
2697 				struct ipa_ioc_get_hdr *)
2698 #define IPA_IOC_PUT_HDR _IOW(IPA_IOC_MAGIC, \
2699 				IPA_IOCTL_PUT_HDR, \
2700 				uint32_t)
2701 #define IPA_IOC_ALLOC_NAT_MEM _IOWR(IPA_IOC_MAGIC, \
2702 				IPA_IOCTL_ALLOC_NAT_MEM, \
2703 				struct ipa_ioc_nat_alloc_mem *)
2704 #define IPA_IOC_ALLOC_NAT_TABLE _IOWR(IPA_IOC_MAGIC, \
2705 				IPA_IOCTL_ALLOC_NAT_TABLE, \
2706 				struct ipa_ioc_nat_ipv6ct_table_alloc *)
2707 #define IPA_IOC_ALLOC_IPV6CT_TABLE _IOWR(IPA_IOC_MAGIC, \
2708 				IPA_IOCTL_ALLOC_IPV6CT_TABLE, \
2709 				struct ipa_ioc_nat_ipv6ct_table_alloc *)
2710 #define IPA_IOC_V4_INIT_NAT _IOWR(IPA_IOC_MAGIC, \
2711 				IPA_IOCTL_V4_INIT_NAT, \
2712 				struct ipa_ioc_v4_nat_init *)
2713 #define IPA_IOC_INIT_IPV6CT_TABLE _IOWR(IPA_IOC_MAGIC, \
2714 				IPA_IOCTL_INIT_IPV6CT_TABLE, \
2715 				struct ipa_ioc_ipv6ct_init *)
2716 #define IPA_IOC_NAT_DMA _IOWR(IPA_IOC_MAGIC, \
2717 				IPA_IOCTL_NAT_DMA, \
2718 				struct ipa_ioc_nat_dma_cmd *)
2719 #define IPA_IOC_TABLE_DMA_CMD _IOWR(IPA_IOC_MAGIC, \
2720 				IPA_IOCTL_TABLE_DMA_CMD, \
2721 				struct ipa_ioc_nat_dma_cmd *)
2722 #define IPA_IOC_V4_DEL_NAT _IOWR(IPA_IOC_MAGIC, \
2723 				IPA_IOCTL_V4_DEL_NAT, \
2724 				struct ipa_ioc_v4_nat_del *)
2725 #define IPA_IOC_DEL_NAT_TABLE _IOWR(IPA_IOC_MAGIC, \
2726 				IPA_IOCTL_DEL_NAT_TABLE, \
2727 				struct ipa_ioc_nat_ipv6ct_table_del *)
2728 #define IPA_IOC_DEL_IPV6CT_TABLE _IOWR(IPA_IOC_MAGIC, \
2729 				IPA_IOCTL_DEL_IPV6CT_TABLE, \
2730 				struct ipa_ioc_nat_ipv6ct_table_del *)
2731 #define IPA_IOC_GET_NAT_OFFSET _IOWR(IPA_IOC_MAGIC, \
2732 				IPA_IOCTL_GET_NAT_OFFSET, \
2733 				uint32_t *)
2734 #define IPA_IOC_NAT_MODIFY_PDN _IOWR(IPA_IOC_MAGIC, \
2735 				IPA_IOCTL_NAT_MODIFY_PDN, \
2736 				struct ipa_ioc_nat_pdn_entry *)
2737 #define IPA_IOC_SET_FLT _IOW(IPA_IOC_MAGIC, \
2738 			IPA_IOCTL_SET_FLT, \
2739 			uint32_t)
2740 #define IPA_IOC_PULL_MSG _IOWR(IPA_IOC_MAGIC, \
2741 				IPA_IOCTL_PULL_MSG, \
2742 				struct ipa_msg_meta *)
2743 #define IPA_IOC_RM_ADD_DEPENDENCY _IOWR(IPA_IOC_MAGIC, \
2744 				IPA_IOCTL_RM_ADD_DEPENDENCY, \
2745 				struct ipa_ioc_rm_dependency *)
2746 #define IPA_IOC_RM_DEL_DEPENDENCY _IOWR(IPA_IOC_MAGIC, \
2747 				IPA_IOCTL_RM_DEL_DEPENDENCY, \
2748 				struct ipa_ioc_rm_dependency *)
2749 #define IPA_IOC_GENERATE_FLT_EQ _IOWR(IPA_IOC_MAGIC, \
2750 				IPA_IOCTL_GENERATE_FLT_EQ, \
2751 				struct ipa_ioc_generate_flt_eq *)
2752 #define IPA_IOC_QUERY_EP_MAPPING _IOR(IPA_IOC_MAGIC, \
2753 				IPA_IOCTL_QUERY_EP_MAPPING, \
2754 				uint32_t)
2755 #define IPA_IOC_QUERY_RT_TBL_INDEX _IOWR(IPA_IOC_MAGIC, \
2756 				IPA_IOCTL_QUERY_RT_TBL_INDEX, \
2757 				struct ipa_ioc_get_rt_tbl_indx *)
2758 #define IPA_IOC_WRITE_QMAPID  _IOWR(IPA_IOC_MAGIC, \
2759 				IPA_IOCTL_WRITE_QMAPID, \
2760 				struct ipa_ioc_write_qmapid *)
2761 #define IPA_IOC_MDFY_FLT_RULE _IOWR(IPA_IOC_MAGIC, \
2762 					IPA_IOCTL_MDFY_FLT_RULE, \
2763 					struct ipa_ioc_mdfy_flt_rule *)
2764 #define IPA_IOC_MDFY_FLT_RULE_V2 _IOWR(IPA_IOC_MAGIC, \
2765 					IPA_IOCTL_MDFY_FLT_RULE_V2, \
2766 					struct ipa_ioc_mdfy_flt_rule_v2 *)
2767 #define IPA_IOC_MDFY_RT_RULE _IOWR(IPA_IOC_MAGIC, \
2768 					IPA_IOCTL_MDFY_RT_RULE, \
2769 					struct ipa_ioc_mdfy_rt_rule *)
2770 #define IPA_IOC_MDFY_RT_RULE_V2 _IOWR(IPA_IOC_MAGIC, \
2771 					IPA_IOCTL_MDFY_RT_RULE_V2, \
2772 					struct ipa_ioc_mdfy_rt_rule_v2 *)
2773 
2774 #define IPA_IOC_NOTIFY_WAN_UPSTREAM_ROUTE_ADD _IOWR(IPA_IOC_MAGIC, \
2775 				IPA_IOCTL_NOTIFY_WAN_UPSTREAM_ROUTE_ADD, \
2776 				struct ipa_wan_msg *)
2777 
2778 #define IPA_IOC_NOTIFY_WAN_UPSTREAM_ROUTE_DEL _IOWR(IPA_IOC_MAGIC, \
2779 				IPA_IOCTL_NOTIFY_WAN_UPSTREAM_ROUTE_DEL, \
2780 				struct ipa_wan_msg *)
2781 #define IPA_IOC_NOTIFY_WAN_EMBMS_CONNECTED _IOWR(IPA_IOC_MAGIC, \
2782 				IPA_IOCTL_NOTIFY_WAN_EMBMS_CONNECTED, \
2783 				struct ipa_wan_msg *)
2784 #define IPA_IOC_ADD_HDR_PROC_CTX _IOWR(IPA_IOC_MAGIC, \
2785 				IPA_IOCTL_ADD_HDR_PROC_CTX, \
2786 				struct ipa_ioc_add_hdr_proc_ctx *)
2787 #define IPA_IOC_DEL_HDR_PROC_CTX _IOWR(IPA_IOC_MAGIC, \
2788 				IPA_IOCTL_DEL_HDR_PROC_CTX, \
2789 				struct ipa_ioc_del_hdr_proc_ctx *)
2790 
2791 #define IPA_IOC_GET_HW_VERSION _IOWR(IPA_IOC_MAGIC, \
2792 				IPA_IOCTL_GET_HW_VERSION, \
2793 				enum ipa_hw_type *)
2794 
2795 #define IPA_IOC_ADD_VLAN_IFACE _IOWR(IPA_IOC_MAGIC, \
2796 				IPA_IOCTL_ADD_VLAN_IFACE, \
2797 				struct ipa_ioc_vlan_iface_info *)
2798 
2799 #define IPA_IOC_DEL_VLAN_IFACE _IOWR(IPA_IOC_MAGIC, \
2800 				IPA_IOCTL_DEL_VLAN_IFACE, \
2801 				struct ipa_ioc_vlan_iface_info *)
2802 
2803 #define IPA_IOC_ADD_L2TP_VLAN_MAPPING _IOWR(IPA_IOC_MAGIC, \
2804 				IPA_IOCTL_ADD_L2TP_VLAN_MAPPING, \
2805 				struct ipa_ioc_l2tp_vlan_mapping_info *)
2806 
2807 #define IPA_IOC_DEL_L2TP_VLAN_MAPPING _IOWR(IPA_IOC_MAGIC, \
2808 				IPA_IOCTL_DEL_L2TP_VLAN_MAPPING, \
2809 				struct ipa_ioc_l2tp_vlan_mapping_info *)
2810 #define IPA_IOC_GET_VLAN_MODE _IOWR(IPA_IOC_MAGIC, \
2811 				IPA_IOCTL_GET_VLAN_MODE, \
2812 				struct ipa_ioc_get_vlan_mode *)
2813 #define IPA_IOC_ADD_BRIDGE_VLAN_MAPPING _IOWR(IPA_IOC_MAGIC, \
2814 				IPA_IOCTL_ADD_BRIDGE_VLAN_MAPPING, \
2815 				struct ipa_ioc_bridge_vlan_mapping_info)
2816 
2817 #define IPA_IOC_DEL_BRIDGE_VLAN_MAPPING _IOWR(IPA_IOC_MAGIC, \
2818 				IPA_IOCTL_DEL_BRIDGE_VLAN_MAPPING, \
2819 				struct ipa_ioc_bridge_vlan_mapping_info)
2820 #define IPA_IOC_CLEANUP _IO(IPA_IOC_MAGIC,\
2821 					IPA_IOCTL_CLEANUP)
2822 #define IPA_IOC_QUERY_WLAN_CLIENT _IO(IPA_IOC_MAGIC,\
2823 					IPA_IOCTL_QUERY_WLAN_CLIENT)
2824 
2825 #define IPA_IOC_ODL_QUERY_ADAPL_EP_INFO _IOWR(IPA_IOC_MAGIC, \
2826 				IPA_IOCTL_ODL_QUERY_ADAPL_EP_INFO, \
2827 				struct ipa_odl_ep_info)
2828 #define IPA_IOC_ODL_GET_AGG_BYTE_LIMIT _IOWR(IPA_IOC_MAGIC, \
2829 				IPA_IOCTL_ODL_GET_AGG_BYTE_LIMIT, \
2830 				struct odl_agg_pipe_info)
2831 
2832 #define IPA_IOC_ODL_QUERY_MODEM_CONFIG _IOWR(IPA_IOC_MAGIC, \
2833 				IPA_IOCTL_ODL_QUERY_MODEM_CONFIG, \
2834 				struct ipa_odl_modem_config)
2835 
2836 #define IPA_IOC_GSB_CONNECT _IOWR(IPA_IOC_MAGIC, \
2837 				IPA_IOCTL_GSB_CONNECT, \
2838 				struct ipa_ioc_gsb_info)
2839 
2840 #define IPA_IOC_GSB_DISCONNECT _IOWR(IPA_IOC_MAGIC, \
2841 				IPA_IOCTL_GSB_DISCONNECT, \
2842 				struct ipa_ioc_gsb_info)
2843 
2844 #define IPA_IOC_WIGIG_FST_SWITCH _IOWR(IPA_IOC_MAGIC, \
2845 				IPA_IOCTL_WIGIG_FST_SWITCH, \
2846 				struct ipa_ioc_wigig_fst_switch)
2847 
2848 #define IPA_IOC_FNR_COUNTER_ALLOC _IOWR(IPA_IOC_MAGIC, \
2849 				IPA_IOCTL_FNR_COUNTER_ALLOC, \
2850 				struct ipa_ioc_flt_rt_counter_alloc)
2851 
2852 #define IPA_IOC_FNR_COUNTER_DEALLOC _IOWR(IPA_IOC_MAGIC, \
2853 				IPA_IOCTL_FNR_COUNTER_DEALLOC, \
2854 				int)
2855 
2856 #define IPA_IOC_FNR_COUNTER_QUERY _IOWR(IPA_IOC_MAGIC, \
2857 				IPA_IOCTL_FNR_COUNTER_QUERY, \
2858 				struct ipa_ioc_flt_rt_query)
2859 
2860 #define IPA_IOC_SET_FNR_COUNTER_INFO _IOWR(IPA_IOC_MAGIC, \
2861 				IPA_IOCTL_SET_FNR_COUNTER_INFO, \
2862 				struct ipa_ioc_fnr_index_info)
2863 
2864 #define IPA_IOC_GET_NAT_IN_SRAM_INFO _IOWR(IPA_IOC_MAGIC, \
2865 				IPA_IOCTL_GET_NAT_IN_SRAM_INFO, \
2866 				struct ipa_nat_in_sram_info)
2867 
2868 #define IPA_IOC_APP_CLOCK_VOTE _IOWR(IPA_IOC_MAGIC, \
2869 				IPA_IOCTL_APP_CLOCK_VOTE, \
2870 				uint32_t)
2871 
2872 /*
2873  * unique magic number of the Tethering bridge ioctls
2874  */
2875 #define TETH_BRIDGE_IOC_MAGIC 0xCE
2876 
2877 /*
2878  * Ioctls supported by Tethering bridge driver
2879  */
2880 #define TETH_BRIDGE_IOCTL_SET_BRIDGE_MODE	0
2881 #define TETH_BRIDGE_IOCTL_SET_AGGR_PARAMS	1
2882 #define TETH_BRIDGE_IOCTL_GET_AGGR_PARAMS	2
2883 #define TETH_BRIDGE_IOCTL_GET_AGGR_CAPABILITIES	3
2884 #define TETH_BRIDGE_IOCTL_MAX			4
2885 
2886 
2887 /**
2888  * enum teth_link_protocol_type - link protocol (IP / Ethernet)
2889  */
2890 enum teth_link_protocol_type {
2891 	TETH_LINK_PROTOCOL_IP,
2892 	TETH_LINK_PROTOCOL_ETHERNET,
2893 	TETH_LINK_PROTOCOL_MAX,
2894 };
2895 
2896 /**
2897  * enum teth_aggr_protocol_type - Aggregation protocol (MBIM / TLP)
2898  */
2899 enum teth_aggr_protocol_type {
2900 	TETH_AGGR_PROTOCOL_NONE,
2901 	TETH_AGGR_PROTOCOL_MBIM,
2902 	TETH_AGGR_PROTOCOL_TLP,
2903 	TETH_AGGR_PROTOCOL_MAX,
2904 };
2905 
2906 /**
2907  * struct teth_aggr_params_link - Aggregation parameters for uplink/downlink
2908  * @aggr_prot:			Aggregation protocol (MBIM / TLP)
2909  * @max_transfer_size_byte:	Maximal size of aggregated packet in bytes.
2910  *				Default value is 16*1024.
2911  * @max_datagrams:		Maximal number of IP packets in an aggregated
2912  *				packet. Default value is 16
2913  */
2914 struct teth_aggr_params_link {
2915 	enum teth_aggr_protocol_type aggr_prot;
2916 	uint32_t max_transfer_size_byte;
2917 	uint32_t max_datagrams;
2918 };
2919 
2920 
2921 /**
2922  * struct teth_aggr_params - Aggregation parmeters
2923  * @ul:	Uplink parameters
2924  * @dl: Downlink parmaeters
2925  */
2926 struct teth_aggr_params {
2927 	struct teth_aggr_params_link ul;
2928 	struct teth_aggr_params_link dl;
2929 };
2930 
2931 /**
2932  * struct teth_aggr_capabilities - Aggregation capabilities
2933  * @num_protocols:		Number of protocols described in the array
2934  * @prot_caps[]:		Array of aggregation capabilities per protocol
2935  */
2936 struct teth_aggr_capabilities {
2937 	uint16_t num_protocols;
2938 	struct teth_aggr_params_link prot_caps[0];
2939 };
2940 
2941 /**
2942  * struct teth_ioc_set_bridge_mode
2943  * @link_protocol: link protocol (IP / Ethernet)
2944  * @lcid: logical channel number
2945  */
2946 struct teth_ioc_set_bridge_mode {
2947 	enum teth_link_protocol_type link_protocol;
2948 	uint16_t lcid;
2949 };
2950 
2951 /**
2952  * struct teth_ioc_set_aggr_params
2953  * @aggr_params: Aggregation parmeters
2954  * @lcid: logical channel number
2955  */
2956 struct teth_ioc_aggr_params {
2957 	struct teth_aggr_params aggr_params;
2958 	uint16_t lcid;
2959 };
2960 
2961 /**
2962  * struct ipa_nat_in_sram_info - query for nat in sram particulars
2963  * @sram_mem_available_for_nat: Amount SRAM available to fit nat table
2964  * @nat_table_offset_into_mmap: Offset into mmap'd vm where table will be
2965  * @best_nat_in_sram_size_rqst: The size to request for mmap
2966  *
2967  * The last two elements above are required to deal with situations
2968  * where the SRAM's physical address and size don't play nice with
2969  * mmap'ings page size and boundary attributes.
2970  */
2971 struct ipa_nat_in_sram_info {
2972 	uint32_t sram_mem_available_for_nat;
2973 	uint32_t nat_table_offset_into_mmap;
2974 	uint32_t best_nat_in_sram_size_rqst;
2975 };
2976 
2977 /**
2978  * enum ipa_app_clock_vote_type
2979  *
2980  * The types of votes that can be accepted by the
2981  * IPA_IOC_APP_CLOCK_VOTE ioctl
2982  */
2983 enum ipa_app_clock_vote_type {
2984 	IPA_APP_CLK_DEVOTE     = 0,
2985 	IPA_APP_CLK_VOTE       = 1,
2986 	IPA_APP_CLK_RESET_VOTE = 2,
2987 };
2988 
2989 #define TETH_BRIDGE_IOC_SET_BRIDGE_MODE _IOW(TETH_BRIDGE_IOC_MAGIC, \
2990 				TETH_BRIDGE_IOCTL_SET_BRIDGE_MODE, \
2991 				struct teth_ioc_set_bridge_mode *)
2992 #define TETH_BRIDGE_IOC_SET_AGGR_PARAMS _IOW(TETH_BRIDGE_IOC_MAGIC, \
2993 				TETH_BRIDGE_IOCTL_SET_AGGR_PARAMS, \
2994 				struct teth_ioc_aggr_params *)
2995 #define TETH_BRIDGE_IOC_GET_AGGR_PARAMS _IOR(TETH_BRIDGE_IOC_MAGIC, \
2996 				TETH_BRIDGE_IOCTL_GET_AGGR_PARAMS, \
2997 				struct teth_ioc_aggr_params *)
2998 #define TETH_BRIDGE_IOC_GET_AGGR_CAPABILITIES _IOWR(TETH_BRIDGE_IOC_MAGIC, \
2999 				TETH_BRIDGE_IOCTL_GET_AGGR_CAPABILITIES, \
3000 				struct teth_aggr_capabilities *)
3001 
3002 /*
3003  * unique magic number of the ODU bridge ioctls
3004  */
3005 #define ODU_BRIDGE_IOC_MAGIC 0xCD
3006 
3007 /*
3008  * Ioctls supported by ODU bridge driver
3009  */
3010 #define ODU_BRIDGE_IOCTL_SET_MODE	0
3011 #define ODU_BRIDGE_IOCTL_SET_LLV6_ADDR	1
3012 #define ODU_BRIDGE_IOCTL_MAX		2
3013 
3014 /**
3015  * enum odu_bridge_mode - bridge mode
3016  *			(ROUTER MODE / BRIDGE MODE)
3017  */
3018 enum odu_bridge_mode {
3019 	ODU_BRIDGE_MODE_ROUTER,
3020 	ODU_BRIDGE_MODE_BRIDGE,
3021 	ODU_BRIDGE_MODE_MAX,
3022 };
3023 
3024 #define ODU_BRIDGE_IOC_SET_MODE _IOW(ODU_BRIDGE_IOC_MAGIC, \
3025 				ODU_BRIDGE_IOCTL_SET_MODE, \
3026 				enum odu_bridge_mode)
3027 
3028 #define ODU_BRIDGE_IOC_SET_LLV6_ADDR _IOW(ODU_BRIDGE_IOC_MAGIC, \
3029 				ODU_BRIDGE_IOCTL_SET_LLV6_ADDR, \
3030 				struct in6_addr *)
3031 
3032 #endif /* _MSM_IPA_H_ */
3033