• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 };
1115 #define IPA_HDR_PROC_MAX (IPA_HDR_PROC_ETHII_TO_ETHII_EX + 1)
1116 
1117 /**
1118  * struct ipa_rt_rule - attributes of a routing rule
1119  * @dst: dst "client"
1120  * @hdr_hdl: handle to the dynamic header
1121 	it is not an index or an offset
1122  * @hdr_proc_ctx_hdl: handle to header processing context. if it is provided
1123 	hdr_hdl shall be 0
1124  * @attrib: attributes of the rule
1125  * @max_prio: bool switch. is this rule with Max priority? meaning on rule hit,
1126  *  IPA will use the rule and will not look for other rules that may have
1127  *  higher priority
1128  * @hashable: bool switch. is this rule hashable or not?
1129  *  ipa uses hashable rules to cache their hit results to be used in
1130  *  consecutive packets
1131  * @retain_hdr: bool switch to instruct IPA core to add back to the packet
1132  *  the header removed as part of header removal
1133  * @coalesce: bool to decide whether packets should be coalesced or not
1134  */
1135 struct ipa_rt_rule {
1136 	enum ipa_client_type dst;
1137 	uint32_t hdr_hdl;
1138 	uint32_t hdr_proc_ctx_hdl;
1139 	struct ipa_rule_attrib attrib;
1140 	uint8_t max_prio;
1141 	uint8_t hashable;
1142 	uint8_t retain_hdr;
1143 	uint8_t coalesce;
1144 };
1145 #define IPA_RT_SUPPORT_COAL
1146 
1147 /**
1148  * struct ipa_rt_rule_v2 - attributes of a routing rule
1149  * @dst: dst "client"
1150  * @hdr_hdl: handle to the dynamic header
1151 	it is not an index or an offset
1152  * @hdr_proc_ctx_hdl: handle to header processing context. if it is provided
1153 	hdr_hdl shall be 0
1154  * @attrib: attributes of the rule
1155  * @max_prio: bool switch. is this rule with Max priority? meaning on rule hit,
1156  *  IPA will use the rule and will not look for other rules that may have
1157  *  higher priority
1158  * @hashable: bool switch. is this rule hashable or not?
1159  *  ipa uses hashable rules to cache their hit results to be used in
1160  *  consecutive packets
1161  * @retain_hdr: bool switch to instruct IPA core to add back to the packet
1162  *  the header removed as part of header removal
1163  * @coalesce: bool to decide whether packets should be coalesced or not
1164  * @enable_stats: is true when we want to enable stats for this
1165  * rt rule.
1166  * @cnt_idx: if enable_stats is 1 and cnt_idx is 0, then cnt_idx
1167  * will be assigned by ipa driver.
1168  */
1169 struct ipa_rt_rule_v2 {
1170 	enum ipa_client_type dst;
1171 	uint32_t hdr_hdl;
1172 	uint32_t hdr_proc_ctx_hdl;
1173 	struct ipa_rule_attrib attrib;
1174 	uint8_t max_prio;
1175 	uint8_t hashable;
1176 	uint8_t retain_hdr;
1177 	uint8_t coalesce;
1178 	uint8_t enable_stats;
1179 	uint8_t cnt_idx;
1180 };
1181 
1182 /**
1183  * struct ipa_hdr_add - header descriptor includes in and out
1184  * parameters
1185  * @name: name of the header
1186  * @hdr: actual header to be inserted
1187  * @hdr_len: size of above header
1188  * @type: l2 header type
1189  * @is_partial: header not fully specified
1190  * @hdr_hdl: out parameter, handle to header, valid when status is 0
1191  * @status:	out parameter, status of header add operation,
1192  *		0 for success,
1193  *		-1 for failure
1194  * @is_eth2_ofst_valid: is eth2_ofst field valid?
1195  * @eth2_ofst: offset to start of Ethernet-II/802.3 header
1196  */
1197 struct ipa_hdr_add {
1198 	char name[IPA_RESOURCE_NAME_MAX];
1199 	uint8_t hdr[IPA_HDR_MAX_SIZE];
1200 	uint8_t hdr_len;
1201 	enum ipa_hdr_l2_type type;
1202 	uint8_t is_partial;
1203 	uint32_t hdr_hdl;
1204 	int status;
1205 	uint8_t is_eth2_ofst_valid;
1206 	uint16_t eth2_ofst;
1207 };
1208 
1209 /**
1210  * struct ipa_ioc_add_hdr - header addition parameters (support
1211  * multiple headers and commit)
1212  * @commit: should headers be written to IPA HW also?
1213  * @num_hdrs: num of headers that follow
1214  * @ipa_hdr_add hdr:	all headers need to go here back to
1215  *			back, no pointers
1216  */
1217 struct ipa_ioc_add_hdr {
1218 	uint8_t commit;
1219 	uint8_t num_hdrs;
1220 	struct ipa_hdr_add hdr[0];
1221 };
1222 
1223 /**
1224  * struct ipa_l2tp_header_add_procparams -
1225  * @eth_hdr_retained: Specifies if Ethernet header is retained or not
1226  * @input_ip_version: Specifies if Input header is IPV4(0) or IPV6(1)
1227  * @output_ip_version: Specifies if template header is IPV4(0) or IPV6(1)
1228  */
1229 struct ipa_l2tp_header_add_procparams {
1230 	uint32_t eth_hdr_retained:1;
1231 	uint32_t input_ip_version:1;
1232 	uint32_t output_ip_version:1;
1233 	uint32_t reserved:29;
1234 };
1235 
1236 /**
1237  * struct ipa_l2tp_header_remove_procparams -
1238  * @hdr_len_remove: Specifies how much of the header needs to
1239 		be removed in bytes
1240  * @eth_hdr_retained: Specifies if Ethernet header is retained or not
1241  * @hdr_ofst_pkt_size_valid: Specifies if the Header offset is valid
1242  * @hdr_ofst_pkt_size: If hdr_ofst_pkt_size_valid =1, this indicates where the
1243 		packet size field (2bytes) resides
1244  * @hdr_endianness: 0:little endian, 1:big endian
1245  */
1246 struct ipa_l2tp_header_remove_procparams {
1247 	uint32_t hdr_len_remove:8;
1248 	uint32_t eth_hdr_retained:1;
1249 	/* Following fields are valid if eth_hdr_retained =1 ( bridge mode) */
1250 	uint32_t hdr_ofst_pkt_size_valid:1;
1251 	uint32_t hdr_ofst_pkt_size:6;
1252 	uint32_t hdr_endianness:1;
1253 	uint32_t reserved:15;
1254 };
1255 
1256 /**
1257  * struct ipa_l2tp_hdr_proc_ctx_params -
1258  * @hdr_add_param: parameters for header add
1259  * @hdr_remove_param: parameters for header remove
1260  * @is_dst_pipe_valid: if dst pipe is valid
1261  * @dst_pipe: destination pipe
1262  */
1263 struct ipa_l2tp_hdr_proc_ctx_params {
1264 	struct ipa_l2tp_header_add_procparams hdr_add_param;
1265 	struct ipa_l2tp_header_remove_procparams hdr_remove_param;
1266 	uint8_t is_dst_pipe_valid;
1267 	enum ipa_client_type dst_pipe;
1268 };
1269 
1270 /**
1271  * struct ipa_eth_II_to_eth_II_ex_procparams -
1272  * @input_ethhdr_negative_offset: Specifies where the ethernet hdr offset is
1273  *	(in bytes) from the start of the input IP hdr
1274  * @output_ethhdr_negative_offset: Specifies where the ethernet hdr offset is
1275  *	(in bytes) from the end of the template hdr
1276  * @reserved: for future use
1277  */
1278 struct ipa_eth_II_to_eth_II_ex_procparams {
1279 	uint32_t input_ethhdr_negative_offset : 8;
1280 	uint32_t output_ethhdr_negative_offset : 8;
1281 	uint32_t reserved : 16;
1282 };
1283 
1284 #define L2TP_USER_SPACE_SPECIFY_DST_PIPE
1285 
1286 /**
1287  * struct ipa_hdr_proc_ctx_add - processing context descriptor includes
1288  * in and out parameters
1289  * @type: processing context type
1290  * @hdr_hdl: in parameter, handle to header
1291  * @l2tp_params: l2tp parameters
1292  * @generic_params: generic proc_ctx params
1293  * @proc_ctx_hdl: out parameter, handle to proc_ctx, valid when status is 0
1294  * @status:	out parameter, status of header add operation,
1295  *		0 for success,
1296  *		-1 for failure
1297  */
1298 struct ipa_hdr_proc_ctx_add {
1299 	enum ipa_hdr_proc_type type;
1300 	uint32_t hdr_hdl;
1301 	uint32_t proc_ctx_hdl;
1302 	int status;
1303 	struct ipa_l2tp_hdr_proc_ctx_params l2tp_params;
1304 	struct ipa_eth_II_to_eth_II_ex_procparams generic_params;
1305 };
1306 
1307 #define IPA_L2TP_HDR_PROC_SUPPORT
1308 
1309 /**
1310  * struct ipa_ioc_add_hdr - processing context addition parameters (support
1311  * multiple processing context and commit)
1312  * @commit: should processing context be written to IPA HW also?
1313  * @num_proc_ctxs: num of processing context that follow
1314  * @proc_ctx:	all processing context need to go here back to
1315  *			back, no pointers
1316  */
1317 struct ipa_ioc_add_hdr_proc_ctx {
1318 	uint8_t commit;
1319 	uint8_t num_proc_ctxs;
1320 	struct ipa_hdr_proc_ctx_add proc_ctx[0];
1321 };
1322 
1323 /**
1324  * struct ipa_ioc_copy_hdr - retrieve a copy of the specified
1325  * header - caller can then derive the complete header
1326  * @name: name of the header resource
1327  * @hdr:	out parameter, contents of specified header,
1328  *	valid only when ioctl return val is non-negative
1329  * @hdr_len: out parameter, size of above header
1330  *	valid only when ioctl return val is non-negative
1331  * @type: l2 header type
1332  *	valid only when ioctl return val is non-negative
1333  * @is_partial:	out parameter, indicates whether specified header is partial
1334  *		valid only when ioctl return val is non-negative
1335  * @is_eth2_ofst_valid: is eth2_ofst field valid?
1336  * @eth2_ofst: offset to start of Ethernet-II/802.3 header
1337  */
1338 struct ipa_ioc_copy_hdr {
1339 	char name[IPA_RESOURCE_NAME_MAX];
1340 	uint8_t hdr[IPA_HDR_MAX_SIZE];
1341 	uint8_t hdr_len;
1342 	enum ipa_hdr_l2_type type;
1343 	uint8_t is_partial;
1344 	uint8_t is_eth2_ofst_valid;
1345 	uint16_t eth2_ofst;
1346 };
1347 
1348 /**
1349  * struct ipa_ioc_get_hdr - header entry lookup parameters, if lookup was
1350  * successful caller must call put to release the reference count when done
1351  * @name: name of the header resource
1352  * @hdl:	out parameter, handle of header entry
1353  *		valid only when ioctl return val is non-negative
1354  */
1355 struct ipa_ioc_get_hdr {
1356 	char name[IPA_RESOURCE_NAME_MAX];
1357 	uint32_t hdl;
1358 };
1359 
1360 /**
1361  * struct ipa_hdr_del - header descriptor includes in and out
1362  * parameters
1363  *
1364  * @hdl: handle returned from header add operation
1365  * @status:	out parameter, status of header remove operation,
1366  *		0 for success,
1367  *		-1 for failure
1368  */
1369 struct ipa_hdr_del {
1370 	uint32_t hdl;
1371 	int status;
1372 };
1373 
1374 /**
1375  * struct ipa_ioc_del_hdr - header deletion parameters (support
1376  * multiple headers and commit)
1377  * @commit: should headers be removed from IPA HW also?
1378  * @num_hdls: num of headers being removed
1379  * @ipa_hdr_del hdl: all handles need to go here back to back, no pointers
1380  */
1381 struct ipa_ioc_del_hdr {
1382 	uint8_t commit;
1383 	uint8_t num_hdls;
1384 	struct ipa_hdr_del hdl[0];
1385 };
1386 
1387 /**
1388  * struct ipa_hdr_proc_ctx_del - processing context descriptor includes
1389  * in and out parameters
1390  * @hdl: handle returned from processing context add operation
1391  * @status:	out parameter, status of header remove operation,
1392  *		0 for success,
1393  *		-1 for failure
1394  */
1395 struct ipa_hdr_proc_ctx_del {
1396 	uint32_t hdl;
1397 	int status;
1398 };
1399 
1400 /**
1401  * ipa_ioc_del_hdr_proc_ctx - processing context deletion parameters (support
1402  * multiple headers and commit)
1403  * @commit: should processing contexts be removed from IPA HW also?
1404  * @num_hdls: num of processing contexts being removed
1405  * @ipa_hdr_proc_ctx_del hdl:	all handles need to go here back to back,
1406  *				no pointers
1407  */
1408 struct ipa_ioc_del_hdr_proc_ctx {
1409 	uint8_t commit;
1410 	uint8_t num_hdls;
1411 	struct ipa_hdr_proc_ctx_del hdl[0];
1412 };
1413 
1414 /**
1415  * struct ipa_rt_rule_add - routing rule descriptor includes in
1416  * and out parameters
1417  * @rule: actual rule to be added
1418  * @at_rear:	add at back of routing table, it is NOT possible to add rules at
1419  *		the rear of the "default" routing tables
1420  * @rt_rule_hdl: output parameter, handle to rule, valid when status is 0
1421  * @status:	output parameter, status of routing rule add operation,
1422  *		0 for success,
1423  *		-1 for failure
1424  */
1425 struct ipa_rt_rule_add {
1426 	struct ipa_rt_rule rule;
1427 	uint8_t at_rear;
1428 	uint32_t rt_rule_hdl;
1429 	int status;
1430 };
1431 
1432 /**
1433  * struct ipa_rt_rule_add_v2 - routing rule descriptor includes
1434  * in and out parameters
1435  * @rule: actual rule to be added
1436  * @at_rear:	add at back of routing table, it is NOT possible to add rules at
1437  *		the rear of the "default" routing tables
1438  * @rt_rule_hdl: output parameter, handle to rule, valid when status is 0
1439  * @status:	output parameter, status of routing rule add operation,
1440  *		0 for success,
1441  *		-1 for failure
1442  */
1443 struct ipa_rt_rule_add_v2 {
1444 	uint8_t at_rear;
1445 	uint32_t rt_rule_hdl;
1446 	int status;
1447 	struct ipa_rt_rule_v2 rule;
1448 };
1449 
1450 
1451 /**
1452  * struct ipa_ioc_add_rt_rule - routing rule addition parameters (supports
1453  * multiple rules and commit);
1454  *
1455  * all rules MUST be added to same table
1456  * @commit: should rules be written to IPA HW also?
1457  * @ip: IP family of rule
1458  * @rt_tbl_name: name of routing table resource
1459  * @num_rules: number of routing rules that follow
1460  * @ipa_rt_rule_add rules: all rules need to go back to back here, no pointers
1461  */
1462 struct ipa_ioc_add_rt_rule {
1463 	uint8_t commit;
1464 	enum ipa_ip_type ip;
1465 	char rt_tbl_name[IPA_RESOURCE_NAME_MAX];
1466 	uint8_t num_rules;
1467 	struct ipa_rt_rule_add rules[0];
1468 };
1469 
1470 /**
1471  * struct ipa_ioc_add_rt_rule_v2 - routing rule addition
1472  * parameters (supports multiple rules and commit);
1473  *
1474  * all rules MUST be added to same table
1475  * @commit: should rules be written to IPA HW also?
1476  * @ip: IP family of rule
1477  * @rt_tbl_name: name of routing table resource
1478  * @num_rules: number of routing rules that follow
1479  * @rule_add_size: sizeof(struct ipa_rt_rule_add_v2)
1480  * @reserved1: reserved bits for alignment
1481  * @reserved2: reserved bits for alignment
1482  * @ipa_rt_rule_add rules: all rules need to go back to back here, no pointers
1483  */
1484 struct ipa_ioc_add_rt_rule_v2 {
1485 	uint8_t commit;
1486 	enum ipa_ip_type ip;
1487 	char rt_tbl_name[IPA_RESOURCE_NAME_MAX];
1488 	uint8_t num_rules;
1489 	uint32_t rule_add_size;
1490 	uint32_t reserved1;
1491 	uint8_t reserved2;
1492 	uint64_t rules;
1493 };
1494 
1495 /**
1496  * struct ipa_ioc_add_rt_rule_after - routing rule addition after a specific
1497  * rule parameters(supports multiple rules and commit);
1498  *
1499  * all rules MUST be added to same table
1500  * @commit: should rules be written to IPA HW also?
1501  * @ip: IP family of rule
1502  * @rt_tbl_name: name of routing table resource
1503  * @num_rules: number of routing rules that follow
1504  * @add_after_hdl: the rules will be added after this specific rule
1505  * @ipa_rt_rule_add rules: all rules need to go back to back here, no pointers
1506  *			   at_rear field will be ignored when using this IOCTL
1507  */
1508 struct ipa_ioc_add_rt_rule_after {
1509 	uint8_t commit;
1510 	enum ipa_ip_type ip;
1511 	char rt_tbl_name[IPA_RESOURCE_NAME_MAX];
1512 	uint8_t num_rules;
1513 	uint32_t add_after_hdl;
1514 	struct ipa_rt_rule_add rules[0];
1515 };
1516 
1517 /**
1518  * struct ipa_ioc_add_rt_rule_after_v2 - routing rule addition
1519  * after a specific rule parameters(supports multiple rules and
1520  * commit);
1521  *
1522  * all rules MUST be added to same table
1523  * @commit: should rules be written to IPA HW also?
1524  * @ip: IP family of rule
1525  * @rt_tbl_name: name of routing table resource
1526  * @num_rules: number of routing rules that follow
1527  * @add_after_hdl: the rules will be added after this specific rule
1528  * @rule_add_size: sizeof(struct ipa_rt_rule_add_v2)
1529  * @reserved: reserved bits for alignment
1530  * @ipa_rt_rule_add rules: all rules need to go back to back here, no pointers
1531  *			   at_rear field will be ignored when using this IOCTL
1532  */
1533 struct ipa_ioc_add_rt_rule_after_v2 {
1534 	uint8_t commit;
1535 	enum ipa_ip_type ip;
1536 	char rt_tbl_name[IPA_RESOURCE_NAME_MAX];
1537 	uint8_t num_rules;
1538 	uint32_t add_after_hdl;
1539 	uint32_t rule_add_size;
1540 	uint8_t reserved;
1541 	uint64_t rules;
1542 };
1543 
1544 /**
1545  * struct ipa_rt_rule_mdfy - routing rule descriptor includes
1546  * in and out parameters
1547  * @rule: actual rule to be added
1548  * @rt_rule_hdl: handle to rule which supposed to modify
1549  * @status:	output parameter, status of routing rule modify  operation,
1550  *		0 for success,
1551  *		-1 for failure
1552  *
1553  */
1554 struct ipa_rt_rule_mdfy {
1555 	struct ipa_rt_rule rule;
1556 	uint32_t rt_rule_hdl;
1557 	int status;
1558 };
1559 
1560 /**
1561  * struct ipa_rt_rule_mdfy_v2 - routing rule descriptor includes
1562  * in and out parameters
1563  * @rule: actual rule to be added
1564  * @rt_rule_hdl: handle to rule which supposed to modify
1565  * @status:	output parameter, status of routing rule modify  operation,
1566  *		0 for success,
1567  *		-1 for failure
1568  *
1569  */
1570 struct ipa_rt_rule_mdfy_v2 {
1571 	uint32_t rt_rule_hdl;
1572 	int status;
1573 	struct ipa_rt_rule_v2 rule;
1574 };
1575 
1576 /**
1577  * struct ipa_ioc_mdfy_rt_rule - routing rule modify parameters (supports
1578  * multiple rules and commit)
1579  * @commit: should rules be written to IPA HW also?
1580  * @ip: IP family of rule
1581  * @num_rules: number of routing rules that follow
1582  * @rules: all rules need to go back to back here, no pointers
1583  */
1584 struct ipa_ioc_mdfy_rt_rule {
1585 	uint8_t commit;
1586 	enum ipa_ip_type ip;
1587 	uint8_t num_rules;
1588 	struct ipa_rt_rule_mdfy rules[0];
1589 };
1590 
1591 /**
1592  * struct ipa_ioc_mdfy_rt_rule_v2 - routing rule modify
1593  * parameters (supports multiple rules and commit)
1594  * @commit: should rules be written to IPA HW also?
1595  * @ip: IP family of rule
1596  * @num_rules: number of routing rules that follow
1597  * @rule_mdfy_size: sizeof(struct ipa_rt_rule_mdfy_v2)
1598  * @reserved: reserved bits for alignment
1599  * @rules: all rules need to go back to back here, no pointers
1600  */
1601 struct ipa_ioc_mdfy_rt_rule_v2 {
1602 	uint8_t commit;
1603 	enum ipa_ip_type ip;
1604 	uint8_t num_rules;
1605 	uint32_t rule_mdfy_size;
1606 	uint8_t reserved;
1607 	uint64_t rules;
1608 };
1609 
1610 /**
1611  * struct ipa_rt_rule_del - routing rule descriptor includes in
1612  * and out parameters
1613  * @hdl: handle returned from route rule add operation
1614  * @status:	output parameter, status of route rule delete operation,
1615  *		0 for success,
1616  *		-1 for failure
1617  */
1618 struct ipa_rt_rule_del {
1619 	uint32_t hdl;
1620 	int status;
1621 };
1622 
1623 /**
1624  * struct ipa_rt_rule_add_ext - routing rule descriptor includes in
1625  * and out parameters
1626  * @rule: actual rule to be added
1627  * @at_rear:	add at back of routing table, it is NOT possible to add rules at
1628  *		the rear of the "default" routing tables
1629  * @rt_rule_hdl: output parameter, handle to rule, valid when status is 0
1630  * @status:	output parameter, status of routing rule add operation,
1631  * @rule_id: rule_id to be assigned to the routing rule. In case client
1632  *  specifies rule_id as 0 the driver will assign a new rule_id
1633  *		0 for success,
1634  *		-1 for failure
1635  */
1636 struct ipa_rt_rule_add_ext {
1637 	struct ipa_rt_rule rule;
1638 	uint8_t at_rear;
1639 	uint32_t rt_rule_hdl;
1640 	int status;
1641 	uint16_t rule_id;
1642 };
1643 
1644 /**
1645  * struct ipa_rt_rule_add_ext_v2 - routing rule descriptor
1646  * includes in and out parameters
1647  * @rule: actual rule to be added
1648  * @at_rear:	add at back of routing table, it is NOT possible to add rules at
1649  *		the rear of the "default" routing tables
1650  * @rt_rule_hdl: output parameter, handle to rule, valid when status is 0
1651  * @status:	output parameter, status of routing rule add operation,
1652  * @rule_id: rule_id to be assigned to the routing rule. In case client
1653  *  specifies rule_id as 0 the driver will assign a new rule_id
1654  *		0 for success,
1655  *		-1 for failure
1656  */
1657 struct ipa_rt_rule_add_ext_v2 {
1658 	uint8_t at_rear;
1659 	uint32_t rt_rule_hdl;
1660 	int status;
1661 	uint16_t rule_id;
1662 	struct ipa_rt_rule_v2 rule;
1663 };
1664 
1665 /**
1666  * struct ipa_ioc_add_rt_rule_ext - routing rule addition
1667  * parameters (supports multiple rules and commit with rule_id);
1668  *
1669  * all rules MUST be added to same table
1670  * @commit: should rules be written to IPA HW also?
1671  * @ip: IP family of rule
1672  * @rt_tbl_name: name of routing table resource
1673  * @num_rules: number of routing rules that follow
1674  * @ipa_rt_rule_add_ext rules: all rules need to go back to back here,
1675  *  no pointers
1676  */
1677 struct ipa_ioc_add_rt_rule_ext {
1678 	uint8_t commit;
1679 	enum ipa_ip_type ip;
1680 	char rt_tbl_name[IPA_RESOURCE_NAME_MAX];
1681 	uint8_t num_rules;
1682 	struct ipa_rt_rule_add_ext rules[0];
1683 };
1684 
1685 /**
1686  * struct ipa_ioc_add_rt_rule_ext_v2 - routing rule addition
1687  * parameters (supports multiple rules and commit with rule_id);
1688  *
1689  * all rules MUST be added to same table
1690  * @commit: should rules be written to IPA HW also?
1691  * @ip: IP family of rule
1692  * @rt_tbl_name: name of routing table resource
1693  * @num_rules: number of routing rules that follow
1694  * @rule_add_ext_size: sizeof(struct ipa_rt_rule_add_ext_v2)
1695  * @reserved1: reserved bits for alignment
1696  * @reserved2: reserved bits for alignment
1697  * @ipa_rt_rule_add_ext rules: all rules need to go back to back here,
1698  *  no pointers
1699  */
1700 struct ipa_ioc_add_rt_rule_ext_v2 {
1701 	uint8_t commit;
1702 	enum ipa_ip_type ip;
1703 	char rt_tbl_name[IPA_RESOURCE_NAME_MAX];
1704 	uint8_t num_rules;
1705 	uint32_t rule_add_ext_size;
1706 	uint32_t reserved1;
1707 	uint8_t reserved2;
1708 	uint64_t rules;
1709 };
1710 
1711 
1712 /**
1713  * struct ipa_ioc_del_rt_rule - routing rule deletion parameters (supports
1714  * multiple headers and commit)
1715  * @commit: should rules be removed from IPA HW also?
1716  * @ip: IP family of rules
1717  * @num_hdls: num of rules being removed
1718  * @ipa_rt_rule_del hdl: all handles need to go back to back here, no pointers
1719  */
1720 struct ipa_ioc_del_rt_rule {
1721 	uint8_t commit;
1722 	enum ipa_ip_type ip;
1723 	uint8_t num_hdls;
1724 	struct ipa_rt_rule_del hdl[0];
1725 };
1726 
1727 /**
1728  * struct ipa_ioc_get_rt_tbl_indx - routing table index lookup parameters
1729  * @ip: IP family of table
1730  * @name: name of routing table resource
1731  * @index:	output parameter, routing table index, valid only when ioctl
1732  *		return val is non-negative
1733  */
1734 struct ipa_ioc_get_rt_tbl_indx {
1735 	enum ipa_ip_type ip;
1736 	char name[IPA_RESOURCE_NAME_MAX];
1737 	uint32_t idx;
1738 };
1739 
1740 /**
1741  * struct ipa_flt_rule_add - filtering rule descriptor includes
1742  * in and out parameters
1743  * @rule: actual rule to be added
1744  * @at_rear: add at back of filtering table?
1745  * @flt_rule_hdl: out parameter, handle to rule, valid when status is 0
1746  * @status:	output parameter, status of filtering rule add   operation,
1747  *		0 for success,
1748  *		-1 for failure
1749  *
1750  */
1751 struct ipa_flt_rule_add {
1752 	struct ipa_flt_rule rule;
1753 	uint8_t at_rear;
1754 	uint32_t flt_rule_hdl;
1755 	int status;
1756 };
1757 
1758 /**
1759  * struct ipa_flt_rule_add_v2 - filtering rule descriptor
1760  * includes in and out parameters
1761  * @rule: actual rule to be added
1762  * @at_rear: add at back of filtering table?
1763  * @flt_rule_hdl: out parameter, handle to rule, valid when status is 0
1764  * @status:	output parameter, status of filtering rule add   operation,
1765  *		0 for success,
1766  *		-1 for failure
1767  *
1768  */
1769 struct ipa_flt_rule_add_v2 {
1770 	uint8_t at_rear;
1771 	uint32_t flt_rule_hdl;
1772 	int status;
1773 	struct ipa_flt_rule_v2 rule;
1774 };
1775 
1776 /**
1777  * struct ipa_ioc_add_flt_rule - filtering rule addition parameters (supports
1778  * multiple rules and commit)
1779  * all rules MUST be added to same table
1780  * @commit: should rules be written to IPA HW also?
1781  * @ip: IP family of rule
1782  * @ep:	which "clients" pipe does this rule apply to?
1783  *	valid only when global is 0
1784  * @global: does this apply to global filter table of specific IP family
1785  * @num_rules: number of filtering rules that follow
1786  * @rules: all rules need to go back to back here, no pointers
1787  */
1788 struct ipa_ioc_add_flt_rule {
1789 	uint8_t commit;
1790 	enum ipa_ip_type ip;
1791 	enum ipa_client_type ep;
1792 	uint8_t global;
1793 	uint8_t num_rules;
1794 	struct ipa_flt_rule_add rules[0];
1795 };
1796 
1797 /**
1798  * struct ipa_ioc_add_flt_rule_v2 - filtering rule addition
1799  * parameters (supports multiple rules and commit)
1800  * all rules MUST be added to same table
1801  * @commit: should rules be written to IPA HW also?
1802  * @ip: IP family of rule
1803  * @ep:	which "clients" pipe does this rule apply to?
1804  *	valid only when global is 0
1805  * @global: does this apply to global filter table of specific IP family
1806  * @num_rules: number of filtering rules that follow
1807  * @flt_rule_size: sizeof(struct ipa_flt_rule_add_v2)
1808  * @reserved1: reserved bits for alignment
1809  * @reserved2: reserved bits for alignment
1810  * @reserved3: reserved bits for alignment
1811  * @rules: all rules need to go back to back here, no pointers
1812  */
1813 struct ipa_ioc_add_flt_rule_v2 {
1814 	uint8_t commit;
1815 	enum ipa_ip_type ip;
1816 	enum ipa_client_type ep;
1817 	uint8_t global;
1818 	uint8_t num_rules;
1819 	uint32_t flt_rule_size;
1820 	uint32_t reserved1;
1821 	uint16_t reserved2;
1822 	uint8_t reserved3;
1823 	uint64_t rules;
1824 };
1825 
1826 
1827 /**
1828  * struct ipa_ioc_add_flt_rule_after - filtering rule addition after specific
1829  * rule parameters (supports multiple rules and commit)
1830  * all rules MUST be added to same table
1831  * @commit: should rules be written to IPA HW also?
1832  * @ip: IP family of rule
1833  * @ep:	which "clients" pipe does this rule apply to?
1834  * @num_rules: number of filtering rules that follow
1835  * @add_after_hdl: rules will be added after the rule with this handle
1836  * @rules: all rules need to go back to back here, no pointers. at rear field
1837  *	   is ignored when using this IOCTL
1838  */
1839 struct ipa_ioc_add_flt_rule_after {
1840 	uint8_t commit;
1841 	enum ipa_ip_type ip;
1842 	enum ipa_client_type ep;
1843 	uint8_t num_rules;
1844 	uint32_t add_after_hdl;
1845 	struct ipa_flt_rule_add rules[0];
1846 };
1847 
1848 /**
1849  * struct ipa_ioc_add_flt_rule_after_v2 - filtering rule
1850  * addition after specific rule parameters (supports multiple
1851  * rules and commit) all rules MUST be added to same table
1852  * @commit: should rules be written to IPA HW also?
1853  * @ip: IP family of rule
1854  * @ep:	which "clients" pipe does this rule apply to?
1855  * @num_rules: number of filtering rules that follow
1856  * @add_after_hdl: rules will be added after the rule with this handle
1857  * @flt_rule_size: sizeof(struct ipa_flt_rule_add_v2)
1858  * @reserved: reserved bits for alignment
1859  * @rules: all rules need to go back to back here, no pointers. at rear field
1860  *	   is ignored when using this IOCTL
1861  */
1862 struct ipa_ioc_add_flt_rule_after_v2 {
1863 	uint8_t commit;
1864 	enum ipa_ip_type ip;
1865 	enum ipa_client_type ep;
1866 	uint8_t num_rules;
1867 	uint32_t add_after_hdl;
1868 	uint32_t flt_rule_size;
1869 	uint32_t reserved;
1870 	uint64_t rules;
1871 };
1872 
1873 /**
1874  * struct ipa_flt_rule_mdfy - filtering rule descriptor includes
1875  * in and out parameters
1876  * @rule: actual rule to be added
1877  * @flt_rule_hdl: handle to rule
1878  * @status:	output parameter, status of filtering rule modify  operation,
1879  *		0 for success,
1880  *		-1 for failure
1881  *
1882  */
1883 struct ipa_flt_rule_mdfy {
1884 	struct ipa_flt_rule rule;
1885 	uint32_t rule_hdl;
1886 	int status;
1887 };
1888 
1889 /**
1890  * struct ipa_flt_rule_mdfy_v2 - filtering rule descriptor
1891  * includes in and out parameters
1892  * @rule: actual rule to be added
1893  * @flt_rule_hdl: handle to rule
1894  * @status:	output parameter, status of filtering rule modify  operation,
1895  *		0 for success,
1896  *		-1 for failure
1897  *
1898  */
1899 struct ipa_flt_rule_mdfy_v2 {
1900 	uint32_t rule_hdl;
1901 	int status;
1902 	struct ipa_flt_rule_v2 rule;
1903 };
1904 
1905 /**
1906  * struct ipa_ioc_mdfy_flt_rule - filtering rule modify parameters (supports
1907  * multiple rules and commit)
1908  * @commit: should rules be written to IPA HW also?
1909  * @ip: IP family of rule
1910  * @num_rules: number of filtering rules that follow
1911  * @rules: all rules need to go back to back here, no pointers
1912  */
1913 struct ipa_ioc_mdfy_flt_rule {
1914 	uint8_t commit;
1915 	enum ipa_ip_type ip;
1916 	uint8_t num_rules;
1917 	struct ipa_flt_rule_mdfy rules[0];
1918 };
1919 
1920 /**
1921  * struct ipa_ioc_mdfy_flt_rule_v2 - filtering rule modify
1922  * parameters (supports multiple rules and commit)
1923  * @commit: should rules be written to IPA HW also?
1924  * @ip: IP family of rule
1925  * @num_rules: number of filtering rules that follow
1926  * @rule_mdfy_size: sizeof(struct ipa_flt_rule_mdfy_v2)
1927  * @reserved: reserved bits for alignment
1928  * @rules: all rules need to go back to back here, no pointers
1929  */
1930 struct ipa_ioc_mdfy_flt_rule_v2 {
1931 	uint8_t commit;
1932 	enum ipa_ip_type ip;
1933 	uint8_t num_rules;
1934 	uint32_t rule_mdfy_size;
1935 	uint8_t reserved;
1936 	uint64_t rules;
1937 };
1938 
1939 /**
1940  * struct ipa_flt_rule_del - filtering rule descriptor includes
1941  * in and out parameters
1942  *
1943  * @hdl: handle returned from filtering rule add operation
1944  * @status:	output parameter, status of filtering rule delete operation,
1945  *		0 for success,
1946  *		-1 for failure
1947  */
1948 struct ipa_flt_rule_del {
1949 	uint32_t hdl;
1950 	int status;
1951 };
1952 
1953 /**
1954  * struct ipa_ioc_del_flt_rule - filtering rule deletion parameters (supports
1955  * multiple headers and commit)
1956  * @commit: should rules be removed from IPA HW also?
1957  * @ip: IP family of rules
1958  * @num_hdls: num of rules being removed
1959  * @hdl: all handles need to go back to back here, no pointers
1960  */
1961 struct ipa_ioc_del_flt_rule {
1962 	uint8_t commit;
1963 	enum ipa_ip_type ip;
1964 	uint8_t num_hdls;
1965 	struct ipa_flt_rule_del hdl[0];
1966 };
1967 
1968 /**
1969  * struct ipa_ioc_get_rt_tbl - routing table lookup parameters, if lookup was
1970  * successful caller must call put to release the reference
1971  * count when done
1972  * @ip: IP family of table
1973  * @name: name of routing table resource
1974  * @htl:	output parameter, handle of routing table, valid only when ioctl
1975  *		return val is non-negative
1976  */
1977 struct ipa_ioc_get_rt_tbl {
1978 	enum ipa_ip_type ip;
1979 	char name[IPA_RESOURCE_NAME_MAX];
1980 	uint32_t hdl;
1981 };
1982 
1983 /**
1984  * struct ipa_ioc_query_intf - used to lookup number of tx and
1985  * rx properties of interface
1986  * @name: name of interface
1987  * @num_tx_props:	output parameter, number of tx properties
1988  *			valid only when ioctl return val is non-negative
1989  * @num_rx_props:	output parameter, number of rx properties
1990  *			valid only when ioctl return val is non-negative
1991  * @num_ext_props:	output parameter, number of ext properties
1992  *			valid only when ioctl return val is non-negative
1993  * @excp_pipe:		exception packets of this interface should be
1994  *			routed to this pipe
1995  */
1996 struct ipa_ioc_query_intf {
1997 	char name[IPA_RESOURCE_NAME_MAX];
1998 	uint32_t num_tx_props;
1999 	uint32_t num_rx_props;
2000 	uint32_t num_ext_props;
2001 	enum ipa_client_type excp_pipe;
2002 };
2003 
2004 /**
2005  * struct ipa_ioc_tx_intf_prop - interface tx property
2006  * @ip: IP family of routing rule
2007  * @attrib: routing rule
2008  * @dst_pipe: routing output pipe
2009  * @alt_dst_pipe: alternate routing output pipe
2010  * @hdr_name: name of associated header if any, empty string when no header
2011  * @hdr_l2_type: type of associated header if any, use NONE when no header
2012  */
2013 struct ipa_ioc_tx_intf_prop {
2014 	enum ipa_ip_type ip;
2015 	struct ipa_rule_attrib attrib;
2016 	enum ipa_client_type dst_pipe;
2017 	enum ipa_client_type alt_dst_pipe;
2018 	char hdr_name[IPA_RESOURCE_NAME_MAX];
2019 	enum ipa_hdr_l2_type hdr_l2_type;
2020 };
2021 
2022 /**
2023  * struct ipa_ioc_query_intf_tx_props - interface tx propertie
2024  * @name: name of interface
2025  * @num_tx_props: number of TX properties
2026  * @tx[0]: output parameter, the tx properties go here back to back
2027  */
2028 struct ipa_ioc_query_intf_tx_props {
2029 	char name[IPA_RESOURCE_NAME_MAX];
2030 	uint32_t num_tx_props;
2031 	struct ipa_ioc_tx_intf_prop tx[0];
2032 };
2033 
2034 /**
2035  * struct ipa_ioc_ext_intf_prop - interface extended property
2036  * @ip: IP family of routing rule
2037  * @eq_attrib: attributes of the rule in equation form
2038  * @action: action field
2039  * @rt_tbl_idx: index of RT table referred to by filter rule
2040  * @mux_id: MUX_ID
2041  * @filter_hdl: handle of filter (as specified by provider of filter rule)
2042  * @is_xlat_rule: it is xlat flt rule or not
2043  */
2044 struct ipa_ioc_ext_intf_prop {
2045 	enum ipa_ip_type ip;
2046 	struct ipa_ipfltri_rule_eq eq_attrib;
2047 	enum ipa_flt_action action;
2048 	uint32_t rt_tbl_idx;
2049 	uint8_t mux_id;
2050 	uint32_t filter_hdl;
2051 	uint8_t is_xlat_rule;
2052 	uint32_t rule_id;
2053 	uint8_t is_rule_hashable;
2054 #define IPA_V6_UL_WL_FIREWALL_HANDLE
2055 	uint8_t replicate_needed;
2056 };
2057 
2058 /**
2059  * struct ipa_ioc_query_intf_ext_props - interface ext propertie
2060  * @name: name of interface
2061  * @num_ext_props: number of EXT properties
2062  * @ext[0]: output parameter, the ext properties go here back to back
2063  */
2064 struct ipa_ioc_query_intf_ext_props {
2065 	char name[IPA_RESOURCE_NAME_MAX];
2066 	uint32_t num_ext_props;
2067 	struct ipa_ioc_ext_intf_prop ext[0];
2068 };
2069 
2070 /**
2071  * struct ipa_ioc_rx_intf_prop - interface rx property
2072  * @ip: IP family of filtering rule
2073  * @attrib: filtering rule
2074  * @src_pipe: input pipe
2075  * @hdr_l2_type: type of associated header if any, use NONE when no header
2076  */
2077 struct ipa_ioc_rx_intf_prop {
2078 	enum ipa_ip_type ip;
2079 	struct ipa_rule_attrib attrib;
2080 	enum ipa_client_type src_pipe;
2081 	enum ipa_hdr_l2_type hdr_l2_type;
2082 };
2083 
2084 /**
2085  * struct ipa_ioc_query_intf_rx_props - interface rx propertie
2086  * @name: name of interface
2087  * @num_rx_props: number of RX properties
2088  * @rx: output parameter, the rx properties go here back to back
2089  */
2090 struct ipa_ioc_query_intf_rx_props {
2091 	char name[IPA_RESOURCE_NAME_MAX];
2092 	uint32_t num_rx_props;
2093 	struct ipa_ioc_rx_intf_prop rx[0];
2094 };
2095 
2096 /**
2097  * struct ipa_ioc_nat_alloc_mem - nat table memory allocation
2098  * properties
2099  * @dev_name: input parameter, the name of table
2100  * @size: input parameter, size of table in bytes
2101  * @offset: output parameter, offset into page in case of system memory
2102  */
2103 struct ipa_ioc_nat_alloc_mem {
2104 	char dev_name[IPA_RESOURCE_NAME_MAX];
2105 	size_t size;
2106 	off_t offset;
2107 };
2108 
2109 /**
2110  * struct ipa_ioc_nat_ipv6ct_table_alloc - NAT/IPv6CT table memory allocation
2111  * properties
2112  * @size: input parameter, size of table in bytes
2113  * @offset: output parameter, offset into page in case of system memory
2114  */
2115 struct ipa_ioc_nat_ipv6ct_table_alloc {
2116 	size_t size;
2117 	off_t offset;
2118 };
2119 
2120 /**
2121  * struct ipa_ioc_v4_nat_init - nat table initialization parameters
2122  * @tbl_index: input parameter, index of the table
2123  * @ipv4_rules_offset: input parameter, ipv4 rules address offset
2124  * @expn_rules_offset: input parameter, ipv4 expansion rules address offset
2125  * @index_offset: input parameter, index rules offset
2126  * @index_expn_offset: input parameter, index expansion rules offset
2127  * @table_entries: input parameter, ipv4 rules table number of entries
2128  * @expn_table_entries: input parameter, ipv4 expansion rules table number of
2129  *                      entries
2130  * @ip_addr: input parameter, public ip address
2131  * @mem_type: input parameter, type of memory the table resides in
2132  * @focus_change: input parameter, are we moving to/from sram or ddr
2133  */
2134 struct ipa_ioc_v4_nat_init {
2135 	uint8_t  tbl_index;
2136 	uint32_t ipv4_rules_offset;
2137 	uint32_t expn_rules_offset;
2138 
2139 	uint32_t index_offset;
2140 	uint32_t index_expn_offset;
2141 
2142 	uint16_t table_entries;
2143 	uint16_t expn_table_entries;
2144 	uint32_t ip_addr;
2145 
2146 	uint8_t  mem_type;
2147 	uint8_t  focus_change;
2148 };
2149 
2150 /**
2151  * struct ipa_ioc_ipv6ct_init - IPv6CT table initialization parameters
2152  * @base_table_offset: input parameter, IPv6CT base table address offset
2153  * @expn_table_offset: input parameter, IPv6CT expansion table address offset
2154  * @table_entries: input parameter, IPv6CT table number of entries
2155  * @expn_table_entries: input parameter, IPv6CT expansion table number of
2156  *                      entries
2157  * @tbl_index: input parameter, index of the table
2158  */
2159 struct ipa_ioc_ipv6ct_init {
2160 	uint32_t base_table_offset;
2161 	uint32_t expn_table_offset;
2162 	uint16_t table_entries;
2163 	uint16_t expn_table_entries;
2164 	uint8_t tbl_index;
2165 };
2166 
2167 /**
2168  * struct ipa_ioc_v4_nat_del - nat table delete parameter
2169  * @table_index: input parameter, index of the table
2170  * @public_ip_addr: input parameter, public ip address
2171  */
2172 struct ipa_ioc_v4_nat_del {
2173 	uint8_t table_index;
2174 	uint32_t public_ip_addr;
2175 };
2176 
2177 /**
2178  * struct ipa_ioc_nat_ipv6ct_table_del - NAT/IPv6CT table delete parameter
2179  * @table_index: input parameter, index of the table
2180  * @mem_type: input parameter, type of memory the table resides in
2181  */
2182 struct ipa_ioc_nat_ipv6ct_table_del {
2183 	uint8_t table_index;
2184 	uint8_t mem_type;
2185 };
2186 
2187 /**
2188  * struct ipa_ioc_nat_dma_one - nat/ipv6ct dma command parameter
2189  * @table_index: input parameter, index of the table
2190  * @base_addr:	type of table, from which the base address of the table
2191  *		can be inferred
2192  * @offset: destination offset within the NAT table
2193  * @data: data to be written.
2194  */
2195 struct ipa_ioc_nat_dma_one {
2196 	uint8_t table_index;
2197 	uint8_t base_addr;
2198 
2199 	uint32_t offset;
2200 	uint16_t data;
2201 
2202 };
2203 
2204 /**
2205  * struct ipa_ioc_nat_dma_cmd - To hold multiple nat/ipv6ct dma commands
2206  * @entries: number of dma commands in use
2207  * @dma: data pointer to the dma commands
2208  * @mem_type: input parameter, type of memory the table resides in
2209  */
2210 struct ipa_ioc_nat_dma_cmd {
2211 	uint8_t entries;
2212 	uint8_t mem_type;
2213 	struct ipa_ioc_nat_dma_one dma[0];
2214 };
2215 
2216 /**
2217  * struct ipa_ioc_nat_pdn_entry - PDN entry modification data
2218  * @pdn_index: index of the entry in the PDN config table to be changed
2219  * @public_ip: PDN's public ip
2220  * @src_metadata: PDN's source NAT metadata for metadata replacement
2221  * @dst_metadata: PDN's destination NAT metadata for metadata replacement
2222  */
2223 struct ipa_ioc_nat_pdn_entry {
2224 	uint8_t pdn_index;
2225 	uint32_t public_ip;
2226 	uint32_t src_metadata;
2227 	uint32_t dst_metadata;
2228 };
2229 
2230 /**
2231  * struct ipa_ioc_vlan_iface_info - add vlan interface
2232  * @name: interface name
2233  * @vlan_id: VLAN ID
2234  */
2235 struct ipa_ioc_vlan_iface_info {
2236 	char name[IPA_RESOURCE_NAME_MAX];
2237 	uint8_t vlan_id;
2238 };
2239 
2240 /**
2241  * struct ipa_ioc_l2tp_vlan_mapping_info - l2tp->vlan mapping info
2242  * @iptype: l2tp tunnel IP type
2243  * @l2tp_iface_name: l2tp interface name
2244  * @l2tp_session_id: l2tp session id
2245  * @vlan_iface_name: vlan interface name
2246  */
2247 struct ipa_ioc_l2tp_vlan_mapping_info {
2248 	enum ipa_ip_type iptype;
2249 	char l2tp_iface_name[IPA_RESOURCE_NAME_MAX];
2250 	uint8_t l2tp_session_id;
2251 	char vlan_iface_name[IPA_RESOURCE_NAME_MAX];
2252 };
2253 
2254 /**
2255  * struct ipa_ioc_gsb_info - connect/disconnect
2256  * @name: interface name
2257  */
2258 struct ipa_ioc_gsb_info {
2259 	char name[IPA_RESOURCE_NAME_MAX];
2260 };
2261 
2262 /**
2263  * struct ipa_ioc_wigig_fst_switch - switch between wigig and wlan
2264  * @netdev_name: wigig interface name
2265  * @client_mac_addr: client to switch between netdevs
2266  * @to_wigig: shall wlan client switch to wigig or the opposite?
2267  */
2268 struct ipa_ioc_wigig_fst_switch {
2269 	uint8_t netdev_name[IPA_RESOURCE_NAME_MAX];
2270 	uint8_t client_mac_addr[IPA_MAC_ADDR_SIZE];
2271 	int to_wigig;
2272 };
2273 
2274 /**
2275  * struct ipa_msg_meta - Format of the message meta-data.
2276  * @msg_type: the type of the message
2277  * @rsvd: reserved bits for future use.
2278  * @msg_len: the length of the message in bytes
2279  *
2280  * For push model:
2281  * Client in user-space should issue a read on the device (/dev/ipa) with a
2282  * sufficiently large buffer in a continuous loop, call will block when there is
2283  * no message to read. Upon return, client can read the ipa_msg_meta from start
2284  * of buffer to find out type and length of message
2285  * size of buffer supplied >= (size of largest message + size of metadata)
2286  *
2287  * For pull model:
2288  * Client in user-space can also issue a pull msg IOCTL to device (/dev/ipa)
2289  * with a payload containing space for the ipa_msg_meta and the message specific
2290  * payload length.
2291  * size of buffer supplied == (len of specific message  + size of metadata)
2292  */
2293 struct ipa_msg_meta {
2294 	uint8_t msg_type;
2295 	uint8_t rsvd;
2296 	uint16_t msg_len;
2297 };
2298 
2299 /**
2300  * struct ipa_wlan_msg - To hold information about wlan client
2301  * @name: name of the wlan interface
2302  * @mac_addr: mac address of wlan client
2303  *
2304  * wlan drivers need to pass name of wlan iface and mac address of
2305  * wlan client along with ipa_wlan_event, whenever a wlan client is
2306  * connected/disconnected/moved to power save/come out of power save
2307  */
2308 struct ipa_wlan_msg {
2309 	char name[IPA_RESOURCE_NAME_MAX];
2310 	uint8_t mac_addr[IPA_MAC_ADDR_SIZE];
2311 };
2312 
2313 /**
2314  * enum ipa_wlan_hdr_attrib_type - attribute type
2315  * in wlan client header
2316  *
2317  * WLAN_HDR_ATTRIB_MAC_ADDR: attrib type mac address
2318  * WLAN_HDR_ATTRIB_STA_ID: attrib type station id
2319  */
2320 enum ipa_wlan_hdr_attrib_type {
2321 	WLAN_HDR_ATTRIB_MAC_ADDR,
2322 	WLAN_HDR_ATTRIB_STA_ID
2323 };
2324 
2325 /**
2326  * struct ipa_wlan_hdr_attrib_val - header attribute value
2327  * @attrib_type: type of attribute
2328  * @offset: offset of attribute within header
2329  * @u.mac_addr: mac address
2330  * @u.sta_id: station id
2331  */
2332 struct ipa_wlan_hdr_attrib_val {
2333 	enum ipa_wlan_hdr_attrib_type attrib_type;
2334 	uint8_t offset;
2335 	union {
2336 		uint8_t mac_addr[IPA_MAC_ADDR_SIZE];
2337 		uint8_t sta_id;
2338 	} u;
2339 };
2340 
2341 /**
2342  * struct ipa_wlan_msg_ex - To hold information about wlan client
2343  * @name: name of the wlan interface
2344  * @num_of_attribs: number of attributes
2345  * @attrib_val: holds attribute values
2346  *
2347  * wlan drivers need to pass name of wlan iface and mac address
2348  * of wlan client or station id along with ipa_wlan_event,
2349  * whenever a wlan client is connected/disconnected/moved to
2350  * power save/come out of power save
2351  */
2352 struct ipa_wlan_msg_ex {
2353 	char name[IPA_RESOURCE_NAME_MAX];
2354 	uint8_t num_of_attribs;
2355 	struct ipa_wlan_hdr_attrib_val attribs[0];
2356 };
2357 
2358 /**
2359  * struct ipa_wigig_msg- To hold information about wigig event
2360  * @name: name of the wigig interface
2361  * @client_mac_addr: the relevant wigig client mac address
2362  * @ipa_client: TX pipe associated with the wigig client in case of connect
2363  * @to_wigig: FST switch direction wlan->wigig?
2364  */
2365 struct ipa_wigig_msg {
2366 	char name[IPA_RESOURCE_NAME_MAX];
2367 	uint8_t client_mac_addr[IPA_MAC_ADDR_SIZE];
2368 	union {
2369 		enum ipa_client_type ipa_client;
2370 		uint8_t to_wigig;
2371 	} u;
2372 };
2373 
2374 struct ipa_ecm_msg {
2375 	char name[IPA_RESOURCE_NAME_MAX];
2376 	int ifindex;
2377 };
2378 
2379 /**
2380  * struct ipa_wan_msg - To hold information about wan client
2381  * @name: name of the wan interface
2382  *
2383  * CnE need to pass the name of default wan iface when connected/disconnected.
2384  * CNE need to pass the gw info in wlan AP+STA mode.
2385  * netmgr need to pass the name of wan eMBMS iface when connected.
2386  */
2387 struct ipa_wan_msg {
2388 	char upstream_ifname[IPA_RESOURCE_NAME_MAX];
2389 	char tethered_ifname[IPA_RESOURCE_NAME_MAX];
2390 	enum ipa_ip_type ip;
2391 	uint32_t ipv4_addr_gw;
2392 	uint32_t ipv6_addr_gw[IPA_WAN_MSG_IPv6_ADDR_GW_LEN];
2393 };
2394 
2395 /**
2396  * struct ipa_ioc_rm_dependency - parameters for add/delete dependency
2397  * @resource_name: name of dependent resource
2398  * @depends_on_name: name of its dependency
2399  */
2400 struct ipa_ioc_rm_dependency {
2401 	enum ipa_rm_resource_name resource_name;
2402 	enum ipa_rm_resource_name depends_on_name;
2403 };
2404 
2405 struct ipa_ioc_generate_flt_eq {
2406 	enum ipa_ip_type ip;
2407 	struct ipa_rule_attrib attrib;
2408 	struct ipa_ipfltri_rule_eq eq_attrib;
2409 };
2410 
2411 /**
2412  * struct ipa_ioc_write_qmapid - to write mux id to endpoint meta register
2413  * @mux_id: mux id of wan
2414  */
2415 struct ipa_ioc_write_qmapid {
2416 	enum ipa_client_type client;
2417 	uint8_t qmap_id;
2418 };
2419 
2420 /**
2421  * struct ipa_flt_rt_counter_alloc - flt/rt counter id allocation
2422  * @num_counters: input param, num of counters need to be allocated
2423  * @allow_less: input param, if true, success even few counter than request
2424  * @start_id: output param, allocated start_id, 0 when allocation fails
2425  * @end_id: output param, allocated start_id, 0 when allocation fails
2426  */
2427 struct ipa_flt_rt_counter_alloc {
2428 	uint8_t num_counters;
2429 	uint8_t allow_less;
2430 	uint8_t start_id;
2431 	uint8_t end_id;
2432 };
2433 
2434 /**
2435  * struct ipa_ioc_flt_rt_counter_alloc - flt/rt counter id allocation ioctl
2436  * @hdl: output param, hdl used for deallocation, negative if allocation fails
2437  * @hw_counter: HW counters for HW process
2438  * @sw_counter: SW counters for uC / non-HW process
2439  */
2440 struct ipa_ioc_flt_rt_counter_alloc {
2441 	int hdl;
2442 	struct ipa_flt_rt_counter_alloc hw_counter;
2443 	struct ipa_flt_rt_counter_alloc sw_counter;
2444 };
2445 
2446 /**
2447  * struct ipa_flt_rt_stats - flt/rt stats info
2448  * @num_pkts: number of packets
2449  * @num_pkts_hash: number of packets in hash entry
2450  * @num_bytes: number of bytes
2451  */
2452 struct ipa_flt_rt_stats {
2453 	uint32_t num_pkts;
2454 	uint32_t num_pkts_hash;
2455 	uint64_t num_bytes;
2456 };
2457 
2458 /**
2459  * struct ipa_ioc_flt_rt_query - flt/rt counter id query
2460  * @start_id: start counter id for query
2461  * @end_id: end counter id for query
2462  * @reset: this query need hw counter to be reset or not
2463  * @stats_size: sizeof(ipa_flt_rt_stats)
2464  * @reserved: reserved bits for alignment
2465  * @stats: structure contains the query result
2466  */
2467 struct ipa_ioc_flt_rt_query {
2468 	uint8_t start_id;
2469 	uint8_t end_id;
2470 	uint8_t reset;
2471 	uint32_t stats_size;
2472 	uint8_t reserved;
2473 	uint64_t stats;
2474 };
2475 
2476 enum ipacm_client_enum {
2477 	IPACM_CLIENT_USB = 1,
2478 	IPACM_CLIENT_WLAN,
2479 	IPACM_CLIENT_MAX
2480 };
2481 
2482 #define IPACM_SUPPORT_OF_LAN_STATS_FOR_ODU_CLIENTS
2483 
2484 enum ipacm_per_client_device_type {
2485 	IPACM_CLIENT_DEVICE_TYPE_USB = 0,
2486 	IPACM_CLIENT_DEVICE_TYPE_WLAN = 1,
2487 	IPACM_CLIENT_DEVICE_TYPE_ETH = 2,
2488 	IPACM_CLIENT_DEVICE_TYPE_ODU = 3,
2489 	IPACM_CLIENT_DEVICE_MAX
2490 };
2491 
2492 /**
2493  * max number of device types supported.
2494  */
2495 #define IPACM_MAX_CLIENT_DEVICE_TYPES IPACM_CLIENT_DEVICE_MAX
2496 
2497 /**
2498  * @lanIface - Name of the lan interface
2499  * @mac: Mac address of the client.
2500  */
2501 struct ipa_lan_client_msg {
2502 	char lanIface[IPA_RESOURCE_NAME_MAX];
2503 	uint8_t mac[IPA_MAC_ADDR_SIZE];
2504 };
2505 
2506 /**
2507  * struct ipa_lan_client - lan client data
2508  * @mac: MAC Address of the client.
2509  * @client_idx: Client Index.
2510  * @inited: Bool to indicate whether client info is set.
2511  */
2512 struct ipa_lan_client {
2513 	uint8_t mac[IPA_MAC_ADDR_SIZE];
2514 	int8_t client_idx;
2515 	uint8_t inited;
2516 };
2517 
2518 /**
2519  * struct ipa_tether_device_info - tether device info indicated from IPACM
2520  * @ul_src_pipe: Source pipe of the lan client.
2521  * @hdr_len: Header length of the client.
2522  * @num_clients: Number of clients connected.
2523  */
2524 struct ipa_tether_device_info {
2525 	int32_t ul_src_pipe;
2526 	uint8_t hdr_len;
2527 	uint32_t num_clients;
2528 	struct ipa_lan_client lan_client[IPA_MAX_NUM_HW_PATH_CLIENTS];
2529 };
2530 
2531 /**
2532  * enum ipa_vlan_ifaces - vlan interfaces types
2533  */
2534 enum ipa_vlan_ifaces {
2535 	IPA_VLAN_IF_ETH,
2536 	IPA_VLAN_IF_RNDIS,
2537 	IPA_VLAN_IF_ECM
2538 };
2539 
2540 #define IPA_VLAN_IF_EMAC IPA_VLAN_IF_ETH
2541 #define IPA_VLAN_IF_MAX (IPA_VLAN_IF_ECM + 1)
2542 
2543 /**
2544  * struct ipa_get_vlan_mode - get vlan mode of a Lan interface
2545  * @iface: Lan interface type to be queried.
2546  * @is_vlan_mode: output parameter, is interface in vlan mode, valid only when
2547  *		ioctl return val is non-negative
2548  */
2549 struct ipa_ioc_get_vlan_mode {
2550 	enum ipa_vlan_ifaces iface;
2551 	uint32_t is_vlan_mode;
2552 };
2553 
2554 /**
2555  * struct ipa_ioc_bridge_vlan_mapping_info - vlan to bridge mapping info
2556  * @bridge_name: bridge interface name
2557  * @vlan_id: vlan ID bridge is mapped to
2558  * @bridge_ipv4: bridge interface ipv4 address
2559  * @subnet_mask: bridge interface subnet mask
2560  */
2561 struct ipa_ioc_bridge_vlan_mapping_info {
2562 	char bridge_name[IPA_RESOURCE_NAME_MAX];
2563 	uint16_t vlan_id;
2564 	uint32_t bridge_ipv4;
2565 	uint32_t subnet_mask;
2566 };
2567 
2568 struct ipa_coalesce_info {
2569 	uint8_t qmap_id;
2570 	uint8_t tcp_enable;
2571 	uint8_t udp_enable;
2572 };
2573 
2574 struct ipa_odl_ep_info {
2575 	__u32 cons_pipe_num;
2576 	__u32 prod_pipe_num;
2577 	__u32 peripheral_iface_id;
2578 	__u32 ep_type;
2579 };
2580 
2581 struct odl_agg_pipe_info {
2582 	__u16 agg_byte_limit;
2583 };
2584 
2585 struct ipa_odl_modem_config {
2586 	__u8 config_status;
2587 };
2588 
2589 struct ipa_ioc_fnr_index_info {
2590 	uint8_t hw_counter_offset;
2591 	uint8_t sw_counter_offset;
2592 };
2593 
2594 enum ipacm_hw_index_counter_type {
2595 	UL_HW = 0,
2596 	DL_HW,
2597 	DL_ALL,
2598 	UL_ALL,
2599 };
2600 
2601 enum ipacm_hw_index_counter_virtual_type {
2602 	UL_HW_CACHE = 0,
2603 	DL_HW_CACHE,
2604 	UL_WLAN_TX,
2605 	DL_WLAN_TX
2606 };
2607 
2608 /**
2609  *   actual IOCTLs supported by IPA driver
2610  */
2611 #define IPA_IOC_ADD_HDR _IOWR(IPA_IOC_MAGIC, \
2612 					IPA_IOCTL_ADD_HDR, \
2613 					struct ipa_ioc_add_hdr *)
2614 #define IPA_IOC_DEL_HDR _IOWR(IPA_IOC_MAGIC, \
2615 					IPA_IOCTL_DEL_HDR, \
2616 					struct ipa_ioc_del_hdr *)
2617 #define IPA_IOC_ADD_RT_RULE _IOWR(IPA_IOC_MAGIC, \
2618 					IPA_IOCTL_ADD_RT_RULE, \
2619 					struct ipa_ioc_add_rt_rule *)
2620 #define IPA_IOC_ADD_RT_RULE_V2 _IOWR(IPA_IOC_MAGIC, \
2621 					IPA_IOCTL_ADD_RT_RULE_V2, \
2622 					struct ipa_ioc_add_rt_rule_v2 *)
2623 #define IPA_IOC_ADD_RT_RULE_EXT _IOWR(IPA_IOC_MAGIC, \
2624 					IPA_IOCTL_ADD_RT_RULE_EXT, \
2625 					struct ipa_ioc_add_rt_rule_ext *)
2626 #define IPA_IOC_ADD_RT_RULE_EXT_V2 _IOWR(IPA_IOC_MAGIC, \
2627 					IPA_IOCTL_ADD_RT_RULE_EXT_V2, \
2628 					struct ipa_ioc_add_rt_rule_ext_v2 *)
2629 #define IPA_IOC_ADD_RT_RULE_AFTER _IOWR(IPA_IOC_MAGIC, \
2630 					IPA_IOCTL_ADD_RT_RULE_AFTER, \
2631 					struct ipa_ioc_add_rt_rule_after *)
2632 #define IPA_IOC_ADD_RT_RULE_AFTER_V2 _IOWR(IPA_IOC_MAGIC, \
2633 					IPA_IOCTL_ADD_RT_RULE_AFTER_V2, \
2634 					struct ipa_ioc_add_rt_rule_after_v2 *)
2635 #define IPA_IOC_DEL_RT_RULE _IOWR(IPA_IOC_MAGIC, \
2636 					IPA_IOCTL_DEL_RT_RULE, \
2637 					struct ipa_ioc_del_rt_rule *)
2638 #define IPA_IOC_ADD_FLT_RULE _IOWR(IPA_IOC_MAGIC, \
2639 					IPA_IOCTL_ADD_FLT_RULE, \
2640 					struct ipa_ioc_add_flt_rule *)
2641 #define IPA_IOC_ADD_FLT_RULE_V2 _IOWR(IPA_IOC_MAGIC, \
2642 					IPA_IOCTL_ADD_FLT_RULE_V2, \
2643 					struct ipa_ioc_add_flt_rule_v2 *)
2644 #define IPA_IOC_ADD_FLT_RULE_AFTER _IOWR(IPA_IOC_MAGIC, \
2645 					IPA_IOCTL_ADD_FLT_RULE_AFTER, \
2646 					struct ipa_ioc_add_flt_rule_after *)
2647 #define IPA_IOC_ADD_FLT_RULE_AFTER_V2 _IOWR(IPA_IOC_MAGIC, \
2648 					IPA_IOCTL_ADD_FLT_RULE_AFTER_V2, \
2649 					struct ipa_ioc_add_flt_rule_after_v2 *)
2650 #define IPA_IOC_DEL_FLT_RULE _IOWR(IPA_IOC_MAGIC, \
2651 					IPA_IOCTL_DEL_FLT_RULE, \
2652 					struct ipa_ioc_del_flt_rule *)
2653 #define IPA_IOC_COMMIT_HDR _IO(IPA_IOC_MAGIC,\
2654 					IPA_IOCTL_COMMIT_HDR)
2655 #define IPA_IOC_RESET_HDR _IO(IPA_IOC_MAGIC,\
2656 					IPA_IOCTL_RESET_HDR)
2657 #define IPA_IOC_COMMIT_RT _IOW(IPA_IOC_MAGIC, \
2658 					IPA_IOCTL_COMMIT_RT, \
2659 					enum ipa_ip_type)
2660 #define IPA_IOC_RESET_RT _IOW(IPA_IOC_MAGIC, \
2661 					IPA_IOCTL_RESET_RT, \
2662 					enum ipa_ip_type)
2663 #define IPA_IOC_COMMIT_FLT _IOW(IPA_IOC_MAGIC, \
2664 					IPA_IOCTL_COMMIT_FLT, \
2665 					enum ipa_ip_type)
2666 #define IPA_IOC_RESET_FLT _IOW(IPA_IOC_MAGIC, \
2667 			IPA_IOCTL_RESET_FLT, \
2668 			enum ipa_ip_type)
2669 #define IPA_IOC_DUMP _IO(IPA_IOC_MAGIC, \
2670 			IPA_IOCTL_DUMP)
2671 #define IPA_IOC_GET_RT_TBL _IOWR(IPA_IOC_MAGIC, \
2672 				IPA_IOCTL_GET_RT_TBL, \
2673 				struct ipa_ioc_get_rt_tbl *)
2674 #define IPA_IOC_PUT_RT_TBL _IOW(IPA_IOC_MAGIC, \
2675 				IPA_IOCTL_PUT_RT_TBL, \
2676 				uint32_t)
2677 #define IPA_IOC_COPY_HDR _IOWR(IPA_IOC_MAGIC, \
2678 				IPA_IOCTL_COPY_HDR, \
2679 				struct ipa_ioc_copy_hdr *)
2680 #define IPA_IOC_QUERY_INTF _IOWR(IPA_IOC_MAGIC, \
2681 				IPA_IOCTL_QUERY_INTF, \
2682 				struct ipa_ioc_query_intf *)
2683 #define IPA_IOC_QUERY_INTF_TX_PROPS _IOWR(IPA_IOC_MAGIC, \
2684 				IPA_IOCTL_QUERY_INTF_TX_PROPS, \
2685 				struct ipa_ioc_query_intf_tx_props *)
2686 #define IPA_IOC_QUERY_INTF_RX_PROPS _IOWR(IPA_IOC_MAGIC, \
2687 					IPA_IOCTL_QUERY_INTF_RX_PROPS, \
2688 					struct ipa_ioc_query_intf_rx_props *)
2689 #define IPA_IOC_QUERY_INTF_EXT_PROPS _IOWR(IPA_IOC_MAGIC, \
2690 					IPA_IOCTL_QUERY_INTF_EXT_PROPS, \
2691 					struct ipa_ioc_query_intf_ext_props *)
2692 #define IPA_IOC_GET_HDR _IOWR(IPA_IOC_MAGIC, \
2693 				IPA_IOCTL_GET_HDR, \
2694 				struct ipa_ioc_get_hdr *)
2695 #define IPA_IOC_PUT_HDR _IOW(IPA_IOC_MAGIC, \
2696 				IPA_IOCTL_PUT_HDR, \
2697 				uint32_t)
2698 #define IPA_IOC_ALLOC_NAT_MEM _IOWR(IPA_IOC_MAGIC, \
2699 				IPA_IOCTL_ALLOC_NAT_MEM, \
2700 				struct ipa_ioc_nat_alloc_mem *)
2701 #define IPA_IOC_ALLOC_NAT_TABLE _IOWR(IPA_IOC_MAGIC, \
2702 				IPA_IOCTL_ALLOC_NAT_TABLE, \
2703 				struct ipa_ioc_nat_ipv6ct_table_alloc *)
2704 #define IPA_IOC_ALLOC_IPV6CT_TABLE _IOWR(IPA_IOC_MAGIC, \
2705 				IPA_IOCTL_ALLOC_IPV6CT_TABLE, \
2706 				struct ipa_ioc_nat_ipv6ct_table_alloc *)
2707 #define IPA_IOC_V4_INIT_NAT _IOWR(IPA_IOC_MAGIC, \
2708 				IPA_IOCTL_V4_INIT_NAT, \
2709 				struct ipa_ioc_v4_nat_init *)
2710 #define IPA_IOC_INIT_IPV6CT_TABLE _IOWR(IPA_IOC_MAGIC, \
2711 				IPA_IOCTL_INIT_IPV6CT_TABLE, \
2712 				struct ipa_ioc_ipv6ct_init *)
2713 #define IPA_IOC_NAT_DMA _IOWR(IPA_IOC_MAGIC, \
2714 				IPA_IOCTL_NAT_DMA, \
2715 				struct ipa_ioc_nat_dma_cmd *)
2716 #define IPA_IOC_TABLE_DMA_CMD _IOWR(IPA_IOC_MAGIC, \
2717 				IPA_IOCTL_TABLE_DMA_CMD, \
2718 				struct ipa_ioc_nat_dma_cmd *)
2719 #define IPA_IOC_V4_DEL_NAT _IOWR(IPA_IOC_MAGIC, \
2720 				IPA_IOCTL_V4_DEL_NAT, \
2721 				struct ipa_ioc_v4_nat_del *)
2722 #define IPA_IOC_DEL_NAT_TABLE _IOWR(IPA_IOC_MAGIC, \
2723 				IPA_IOCTL_DEL_NAT_TABLE, \
2724 				struct ipa_ioc_nat_ipv6ct_table_del *)
2725 #define IPA_IOC_DEL_IPV6CT_TABLE _IOWR(IPA_IOC_MAGIC, \
2726 				IPA_IOCTL_DEL_IPV6CT_TABLE, \
2727 				struct ipa_ioc_nat_ipv6ct_table_del *)
2728 #define IPA_IOC_GET_NAT_OFFSET _IOWR(IPA_IOC_MAGIC, \
2729 				IPA_IOCTL_GET_NAT_OFFSET, \
2730 				uint32_t *)
2731 #define IPA_IOC_NAT_MODIFY_PDN _IOWR(IPA_IOC_MAGIC, \
2732 				IPA_IOCTL_NAT_MODIFY_PDN, \
2733 				struct ipa_ioc_nat_pdn_entry *)
2734 #define IPA_IOC_SET_FLT _IOW(IPA_IOC_MAGIC, \
2735 			IPA_IOCTL_SET_FLT, \
2736 			uint32_t)
2737 #define IPA_IOC_PULL_MSG _IOWR(IPA_IOC_MAGIC, \
2738 				IPA_IOCTL_PULL_MSG, \
2739 				struct ipa_msg_meta *)
2740 #define IPA_IOC_RM_ADD_DEPENDENCY _IOWR(IPA_IOC_MAGIC, \
2741 				IPA_IOCTL_RM_ADD_DEPENDENCY, \
2742 				struct ipa_ioc_rm_dependency *)
2743 #define IPA_IOC_RM_DEL_DEPENDENCY _IOWR(IPA_IOC_MAGIC, \
2744 				IPA_IOCTL_RM_DEL_DEPENDENCY, \
2745 				struct ipa_ioc_rm_dependency *)
2746 #define IPA_IOC_GENERATE_FLT_EQ _IOWR(IPA_IOC_MAGIC, \
2747 				IPA_IOCTL_GENERATE_FLT_EQ, \
2748 				struct ipa_ioc_generate_flt_eq *)
2749 #define IPA_IOC_QUERY_EP_MAPPING _IOR(IPA_IOC_MAGIC, \
2750 				IPA_IOCTL_QUERY_EP_MAPPING, \
2751 				uint32_t)
2752 #define IPA_IOC_QUERY_RT_TBL_INDEX _IOWR(IPA_IOC_MAGIC, \
2753 				IPA_IOCTL_QUERY_RT_TBL_INDEX, \
2754 				struct ipa_ioc_get_rt_tbl_indx *)
2755 #define IPA_IOC_WRITE_QMAPID  _IOWR(IPA_IOC_MAGIC, \
2756 				IPA_IOCTL_WRITE_QMAPID, \
2757 				struct ipa_ioc_write_qmapid *)
2758 #define IPA_IOC_MDFY_FLT_RULE _IOWR(IPA_IOC_MAGIC, \
2759 					IPA_IOCTL_MDFY_FLT_RULE, \
2760 					struct ipa_ioc_mdfy_flt_rule *)
2761 #define IPA_IOC_MDFY_FLT_RULE_V2 _IOWR(IPA_IOC_MAGIC, \
2762 					IPA_IOCTL_MDFY_FLT_RULE_V2, \
2763 					struct ipa_ioc_mdfy_flt_rule_v2 *)
2764 #define IPA_IOC_MDFY_RT_RULE _IOWR(IPA_IOC_MAGIC, \
2765 					IPA_IOCTL_MDFY_RT_RULE, \
2766 					struct ipa_ioc_mdfy_rt_rule *)
2767 #define IPA_IOC_MDFY_RT_RULE_V2 _IOWR(IPA_IOC_MAGIC, \
2768 					IPA_IOCTL_MDFY_RT_RULE_V2, \
2769 					struct ipa_ioc_mdfy_rt_rule_v2 *)
2770 
2771 #define IPA_IOC_NOTIFY_WAN_UPSTREAM_ROUTE_ADD _IOWR(IPA_IOC_MAGIC, \
2772 				IPA_IOCTL_NOTIFY_WAN_UPSTREAM_ROUTE_ADD, \
2773 				struct ipa_wan_msg *)
2774 
2775 #define IPA_IOC_NOTIFY_WAN_UPSTREAM_ROUTE_DEL _IOWR(IPA_IOC_MAGIC, \
2776 				IPA_IOCTL_NOTIFY_WAN_UPSTREAM_ROUTE_DEL, \
2777 				struct ipa_wan_msg *)
2778 #define IPA_IOC_NOTIFY_WAN_EMBMS_CONNECTED _IOWR(IPA_IOC_MAGIC, \
2779 				IPA_IOCTL_NOTIFY_WAN_EMBMS_CONNECTED, \
2780 				struct ipa_wan_msg *)
2781 #define IPA_IOC_ADD_HDR_PROC_CTX _IOWR(IPA_IOC_MAGIC, \
2782 				IPA_IOCTL_ADD_HDR_PROC_CTX, \
2783 				struct ipa_ioc_add_hdr_proc_ctx *)
2784 #define IPA_IOC_DEL_HDR_PROC_CTX _IOWR(IPA_IOC_MAGIC, \
2785 				IPA_IOCTL_DEL_HDR_PROC_CTX, \
2786 				struct ipa_ioc_del_hdr_proc_ctx *)
2787 
2788 #define IPA_IOC_GET_HW_VERSION _IOWR(IPA_IOC_MAGIC, \
2789 				IPA_IOCTL_GET_HW_VERSION, \
2790 				enum ipa_hw_type *)
2791 
2792 #define IPA_IOC_ADD_VLAN_IFACE _IOWR(IPA_IOC_MAGIC, \
2793 				IPA_IOCTL_ADD_VLAN_IFACE, \
2794 				struct ipa_ioc_vlan_iface_info *)
2795 
2796 #define IPA_IOC_DEL_VLAN_IFACE _IOWR(IPA_IOC_MAGIC, \
2797 				IPA_IOCTL_DEL_VLAN_IFACE, \
2798 				struct ipa_ioc_vlan_iface_info *)
2799 
2800 #define IPA_IOC_ADD_L2TP_VLAN_MAPPING _IOWR(IPA_IOC_MAGIC, \
2801 				IPA_IOCTL_ADD_L2TP_VLAN_MAPPING, \
2802 				struct ipa_ioc_l2tp_vlan_mapping_info *)
2803 
2804 #define IPA_IOC_DEL_L2TP_VLAN_MAPPING _IOWR(IPA_IOC_MAGIC, \
2805 				IPA_IOCTL_DEL_L2TP_VLAN_MAPPING, \
2806 				struct ipa_ioc_l2tp_vlan_mapping_info *)
2807 #define IPA_IOC_GET_VLAN_MODE _IOWR(IPA_IOC_MAGIC, \
2808 				IPA_IOCTL_GET_VLAN_MODE, \
2809 				struct ipa_ioc_get_vlan_mode *)
2810 #define IPA_IOC_ADD_BRIDGE_VLAN_MAPPING _IOWR(IPA_IOC_MAGIC, \
2811 				IPA_IOCTL_ADD_BRIDGE_VLAN_MAPPING, \
2812 				struct ipa_ioc_bridge_vlan_mapping_info)
2813 
2814 #define IPA_IOC_DEL_BRIDGE_VLAN_MAPPING _IOWR(IPA_IOC_MAGIC, \
2815 				IPA_IOCTL_DEL_BRIDGE_VLAN_MAPPING, \
2816 				struct ipa_ioc_bridge_vlan_mapping_info)
2817 #define IPA_IOC_CLEANUP _IO(IPA_IOC_MAGIC,\
2818 					IPA_IOCTL_CLEANUP)
2819 #define IPA_IOC_QUERY_WLAN_CLIENT _IO(IPA_IOC_MAGIC,\
2820 					IPA_IOCTL_QUERY_WLAN_CLIENT)
2821 
2822 #define IPA_IOC_ODL_QUERY_ADAPL_EP_INFO _IOWR(IPA_IOC_MAGIC, \
2823 				IPA_IOCTL_ODL_QUERY_ADAPL_EP_INFO, \
2824 				struct ipa_odl_ep_info)
2825 #define IPA_IOC_ODL_GET_AGG_BYTE_LIMIT _IOWR(IPA_IOC_MAGIC, \
2826 				IPA_IOCTL_ODL_GET_AGG_BYTE_LIMIT, \
2827 				struct odl_agg_pipe_info)
2828 
2829 #define IPA_IOC_ODL_QUERY_MODEM_CONFIG _IOWR(IPA_IOC_MAGIC, \
2830 				IPA_IOCTL_ODL_QUERY_MODEM_CONFIG, \
2831 				struct ipa_odl_modem_config)
2832 
2833 #define IPA_IOC_GSB_CONNECT _IOWR(IPA_IOC_MAGIC, \
2834 				IPA_IOCTL_GSB_CONNECT, \
2835 				struct ipa_ioc_gsb_info)
2836 
2837 #define IPA_IOC_GSB_DISCONNECT _IOWR(IPA_IOC_MAGIC, \
2838 				IPA_IOCTL_GSB_DISCONNECT, \
2839 				struct ipa_ioc_gsb_info)
2840 
2841 #define IPA_IOC_WIGIG_FST_SWITCH _IOWR(IPA_IOC_MAGIC, \
2842 				IPA_IOCTL_WIGIG_FST_SWITCH, \
2843 				struct ipa_ioc_wigig_fst_switch)
2844 
2845 #define IPA_IOC_FNR_COUNTER_ALLOC _IOWR(IPA_IOC_MAGIC, \
2846 				IPA_IOCTL_FNR_COUNTER_ALLOC, \
2847 				struct ipa_ioc_flt_rt_counter_alloc)
2848 
2849 #define IPA_IOC_FNR_COUNTER_DEALLOC _IOWR(IPA_IOC_MAGIC, \
2850 				IPA_IOCTL_FNR_COUNTER_DEALLOC, \
2851 				int)
2852 
2853 #define IPA_IOC_FNR_COUNTER_QUERY _IOWR(IPA_IOC_MAGIC, \
2854 				IPA_IOCTL_FNR_COUNTER_QUERY, \
2855 				struct ipa_ioc_flt_rt_query)
2856 
2857 #define IPA_IOC_SET_FNR_COUNTER_INFO _IOWR(IPA_IOC_MAGIC, \
2858 				IPA_IOCTL_SET_FNR_COUNTER_INFO, \
2859 				struct ipa_ioc_fnr_index_info)
2860 
2861 #define IPA_IOC_GET_NAT_IN_SRAM_INFO _IOWR(IPA_IOC_MAGIC, \
2862 				IPA_IOCTL_GET_NAT_IN_SRAM_INFO, \
2863 				struct ipa_nat_in_sram_info)
2864 
2865 #define IPA_IOC_APP_CLOCK_VOTE _IOWR(IPA_IOC_MAGIC, \
2866 				IPA_IOCTL_APP_CLOCK_VOTE, \
2867 				uint32_t)
2868 
2869 /*
2870  * unique magic number of the Tethering bridge ioctls
2871  */
2872 #define TETH_BRIDGE_IOC_MAGIC 0xCE
2873 
2874 /*
2875  * Ioctls supported by Tethering bridge driver
2876  */
2877 #define TETH_BRIDGE_IOCTL_SET_BRIDGE_MODE	0
2878 #define TETH_BRIDGE_IOCTL_SET_AGGR_PARAMS	1
2879 #define TETH_BRIDGE_IOCTL_GET_AGGR_PARAMS	2
2880 #define TETH_BRIDGE_IOCTL_GET_AGGR_CAPABILITIES	3
2881 #define TETH_BRIDGE_IOCTL_MAX			4
2882 
2883 
2884 /**
2885  * enum teth_link_protocol_type - link protocol (IP / Ethernet)
2886  */
2887 enum teth_link_protocol_type {
2888 	TETH_LINK_PROTOCOL_IP,
2889 	TETH_LINK_PROTOCOL_ETHERNET,
2890 	TETH_LINK_PROTOCOL_MAX,
2891 };
2892 
2893 /**
2894  * enum teth_aggr_protocol_type - Aggregation protocol (MBIM / TLP)
2895  */
2896 enum teth_aggr_protocol_type {
2897 	TETH_AGGR_PROTOCOL_NONE,
2898 	TETH_AGGR_PROTOCOL_MBIM,
2899 	TETH_AGGR_PROTOCOL_TLP,
2900 	TETH_AGGR_PROTOCOL_MAX,
2901 };
2902 
2903 /**
2904  * struct teth_aggr_params_link - Aggregation parameters for uplink/downlink
2905  * @aggr_prot:			Aggregation protocol (MBIM / TLP)
2906  * @max_transfer_size_byte:	Maximal size of aggregated packet in bytes.
2907  *				Default value is 16*1024.
2908  * @max_datagrams:		Maximal number of IP packets in an aggregated
2909  *				packet. Default value is 16
2910  */
2911 struct teth_aggr_params_link {
2912 	enum teth_aggr_protocol_type aggr_prot;
2913 	uint32_t max_transfer_size_byte;
2914 	uint32_t max_datagrams;
2915 };
2916 
2917 
2918 /**
2919  * struct teth_aggr_params - Aggregation parmeters
2920  * @ul:	Uplink parameters
2921  * @dl: Downlink parmaeters
2922  */
2923 struct teth_aggr_params {
2924 	struct teth_aggr_params_link ul;
2925 	struct teth_aggr_params_link dl;
2926 };
2927 
2928 /**
2929  * struct teth_aggr_capabilities - Aggregation capabilities
2930  * @num_protocols:		Number of protocols described in the array
2931  * @prot_caps[]:		Array of aggregation capabilities per protocol
2932  */
2933 struct teth_aggr_capabilities {
2934 	uint16_t num_protocols;
2935 	struct teth_aggr_params_link prot_caps[0];
2936 };
2937 
2938 /**
2939  * struct teth_ioc_set_bridge_mode
2940  * @link_protocol: link protocol (IP / Ethernet)
2941  * @lcid: logical channel number
2942  */
2943 struct teth_ioc_set_bridge_mode {
2944 	enum teth_link_protocol_type link_protocol;
2945 	uint16_t lcid;
2946 };
2947 
2948 /**
2949  * struct teth_ioc_set_aggr_params
2950  * @aggr_params: Aggregation parmeters
2951  * @lcid: logical channel number
2952  */
2953 struct teth_ioc_aggr_params {
2954 	struct teth_aggr_params aggr_params;
2955 	uint16_t lcid;
2956 };
2957 
2958 /**
2959  * struct ipa_nat_in_sram_info - query for nat in sram particulars
2960  * @sram_mem_available_for_nat: Amount SRAM available to fit nat table
2961  * @nat_table_offset_into_mmap: Offset into mmap'd vm where table will be
2962  * @best_nat_in_sram_size_rqst: The size to request for mmap
2963  *
2964  * The last two elements above are required to deal with situations
2965  * where the SRAM's physical address and size don't play nice with
2966  * mmap'ings page size and boundary attributes.
2967  */
2968 struct ipa_nat_in_sram_info {
2969 	uint32_t sram_mem_available_for_nat;
2970 	uint32_t nat_table_offset_into_mmap;
2971 	uint32_t best_nat_in_sram_size_rqst;
2972 };
2973 
2974 /**
2975  * enum ipa_app_clock_vote_type
2976  *
2977  * The types of votes that can be accepted by the
2978  * IPA_IOC_APP_CLOCK_VOTE ioctl
2979  */
2980 enum ipa_app_clock_vote_type {
2981 	IPA_APP_CLK_DEVOTE     = 0,
2982 	IPA_APP_CLK_VOTE       = 1,
2983 	IPA_APP_CLK_RESET_VOTE = 2,
2984 };
2985 
2986 #define TETH_BRIDGE_IOC_SET_BRIDGE_MODE _IOW(TETH_BRIDGE_IOC_MAGIC, \
2987 				TETH_BRIDGE_IOCTL_SET_BRIDGE_MODE, \
2988 				struct teth_ioc_set_bridge_mode *)
2989 #define TETH_BRIDGE_IOC_SET_AGGR_PARAMS _IOW(TETH_BRIDGE_IOC_MAGIC, \
2990 				TETH_BRIDGE_IOCTL_SET_AGGR_PARAMS, \
2991 				struct teth_ioc_aggr_params *)
2992 #define TETH_BRIDGE_IOC_GET_AGGR_PARAMS _IOR(TETH_BRIDGE_IOC_MAGIC, \
2993 				TETH_BRIDGE_IOCTL_GET_AGGR_PARAMS, \
2994 				struct teth_ioc_aggr_params *)
2995 #define TETH_BRIDGE_IOC_GET_AGGR_CAPABILITIES _IOWR(TETH_BRIDGE_IOC_MAGIC, \
2996 				TETH_BRIDGE_IOCTL_GET_AGGR_CAPABILITIES, \
2997 				struct teth_aggr_capabilities *)
2998 
2999 /*
3000  * unique magic number of the ODU bridge ioctls
3001  */
3002 #define ODU_BRIDGE_IOC_MAGIC 0xCD
3003 
3004 /*
3005  * Ioctls supported by ODU bridge driver
3006  */
3007 #define ODU_BRIDGE_IOCTL_SET_MODE	0
3008 #define ODU_BRIDGE_IOCTL_SET_LLV6_ADDR	1
3009 #define ODU_BRIDGE_IOCTL_MAX		2
3010 
3011 /**
3012  * enum odu_bridge_mode - bridge mode
3013  *			(ROUTER MODE / BRIDGE MODE)
3014  */
3015 enum odu_bridge_mode {
3016 	ODU_BRIDGE_MODE_ROUTER,
3017 	ODU_BRIDGE_MODE_BRIDGE,
3018 	ODU_BRIDGE_MODE_MAX,
3019 };
3020 
3021 #define ODU_BRIDGE_IOC_SET_MODE _IOW(ODU_BRIDGE_IOC_MAGIC, \
3022 				ODU_BRIDGE_IOCTL_SET_MODE, \
3023 				enum odu_bridge_mode)
3024 
3025 #define ODU_BRIDGE_IOC_SET_LLV6_ADDR _IOW(ODU_BRIDGE_IOC_MAGIC, \
3026 				ODU_BRIDGE_IOCTL_SET_LLV6_ADDR, \
3027 				struct in6_addr *)
3028 
3029 #endif /* _MSM_IPA_H_ */
3030