1 #ifndef _MSM_IPA_H_
2 #define _MSM_IPA_H_
3 
4 #include <stdint.h>
5 #include <stddef.h>
6 #include <sys/stat.h>
7 #include <linux/ioctl.h>
8 #include <linux/types.h>
9 #include <linux/if_ether.h>
10 
11 /**
12  * unique magic number of the IPA device
13  */
14 #define IPA_IOC_MAGIC 0xCF
15 
16 /**
17  * IPA device full path
18  */
19 #define IPA_DEV_NAME "/dev/ipa"
20 
21 /**
22  * IPA NAT table character device name
23  */
24 #define IPA_NAT_DEV_NAME "ipaNatTable"
25 
26 /**
27  * IPA IPv6CT table character device name
28  */
29 #define IPA_IPV6CT_DEV_NAME "ipaIpv6CTTable"
30 
31  /**
32  * name of the default routing tables for v4 and v6
33  */
34 #define IPA_DFLT_RT_TBL_NAME "ipa_dflt_rt"
35 
36 /**
37  * commands supported by IPA driver
38  */
39 #define IPA_IOCTL_ADD_HDR                       0
40 #define IPA_IOCTL_DEL_HDR                       1
41 #define IPA_IOCTL_ADD_RT_RULE                   2
42 #define IPA_IOCTL_DEL_RT_RULE                   3
43 #define IPA_IOCTL_ADD_FLT_RULE                  4
44 #define IPA_IOCTL_DEL_FLT_RULE                  5
45 #define IPA_IOCTL_COMMIT_HDR                    6
46 #define IPA_IOCTL_RESET_HDR                     7
47 #define IPA_IOCTL_COMMIT_RT                     8
48 #define IPA_IOCTL_RESET_RT                      9
49 #define IPA_IOCTL_COMMIT_FLT                    10
50 #define IPA_IOCTL_RESET_FLT                     11
51 #define IPA_IOCTL_DUMP                          12
52 #define IPA_IOCTL_GET_RT_TBL                    13
53 #define IPA_IOCTL_PUT_RT_TBL                    14
54 #define IPA_IOCTL_COPY_HDR                      15
55 #define IPA_IOCTL_QUERY_INTF                    16
56 #define IPA_IOCTL_QUERY_INTF_TX_PROPS           17
57 #define IPA_IOCTL_QUERY_INTF_RX_PROPS           18
58 #define IPA_IOCTL_GET_HDR                       19
59 #define IPA_IOCTL_PUT_HDR                       20
60 #define IPA_IOCTL_SET_FLT                       21
61 #define IPA_IOCTL_ALLOC_NAT_MEM                 22
62 #define IPA_IOCTL_V4_INIT_NAT                   23
63 #define IPA_IOCTL_TABLE_DMA_CMD                 24
64 #define IPA_IOCTL_NAT_DMA                       IPA_IOCTL_TABLE_DMA_CMD
65 #define IPA_IOCTL_INIT_IPV6CT_TABLE             25
66 #define IPA_IOCTL_V4_DEL_NAT                    26
67 #define IPA_IOCTL_PULL_MSG                      27
68 #define IPA_IOCTL_GET_NAT_OFFSET                28
69 #define IPA_IOCTL_RM_ADD_DEPENDENCY             29
70 #define IPA_IOCTL_RM_DEL_DEPENDENCY             30
71 #define IPA_IOCTL_GENERATE_FLT_EQ               31
72 #define IPA_IOCTL_QUERY_INTF_EXT_PROPS          32
73 #define IPA_IOCTL_QUERY_EP_MAPPING              33
74 #define IPA_IOCTL_QUERY_RT_TBL_INDEX            34
75 #define IPA_IOCTL_WRITE_QMAPID                  35
76 #define IPA_IOCTL_MDFY_FLT_RULE                 36
77 #define IPA_IOCTL_NOTIFY_WAN_UPSTREAM_ROUTE_ADD 37
78 #define IPA_IOCTL_NOTIFY_WAN_UPSTREAM_ROUTE_DEL 38
79 #define IPA_IOCTL_NOTIFY_WAN_EMBMS_CONNECTED    39
80 #define IPA_IOCTL_ADD_HDR_PROC_CTX              40
81 #define IPA_IOCTL_DEL_HDR_PROC_CTX              41
82 #define IPA_IOCTL_MDFY_RT_RULE                  42
83 #define IPA_IOCTL_ADD_RT_RULE_AFTER             43
84 #define IPA_IOCTL_ADD_FLT_RULE_AFTER            44
85 #define IPA_IOCTL_GET_HW_VERSION                45
86 #define IPA_IOCTL_ADD_RT_RULE_EXT               46
87 #define IPA_IOCTL_ADD_VLAN_IFACE                47
88 #define IPA_IOCTL_DEL_VLAN_IFACE                48
89 #define IPA_IOCTL_ADD_L2TP_VLAN_MAPPING         49
90 #define IPA_IOCTL_DEL_L2TP_VLAN_MAPPING         50
91 #define IPA_IOCTL_NAT_MODIFY_PDN                51
92 #define IPA_IOCTL_ALLOC_NAT_TABLE               52
93 #define IPA_IOCTL_ALLOC_IPV6CT_TABLE            53
94 #define IPA_IOCTL_DEL_NAT_TABLE                 54
95 #define IPA_IOCTL_DEL_IPV6CT_TABLE              55
96 #define IPA_IOCTL_CLEANUP                       56
97 #define IPA_IOCTL_QUERY_WLAN_CLIENT             57
98 #define IPA_IOCTL_GET_VLAN_MODE                 58
99 
100 /**
101  * max size of the header to be inserted
102  */
103 #define IPA_HDR_MAX_SIZE 64
104 
105 /**
106  * max size of the name of the resource (routing table, header)
107  */
108 #define IPA_RESOURCE_NAME_MAX 32
109 
110 /**
111  * max number of interface properties
112  */
113 #define IPA_NUM_PROPS_MAX 35
114 
115 /**
116  * size of the mac address
117  */
118 #define IPA_MAC_ADDR_SIZE  6
119 
120 /**
121  * max number of mbim streams
122  */
123 #define IPA_MBIM_MAX_STREAM_NUM 8
124 
125 /**
126  *  size of the ipv6 address
127  */
128 #define IPA_WAN_MSG_IPv6_ADDR_GW_LEN 4
129 
130 /**
131  * max number of lan clients supported per device type
132  * for LAN stats via HW.
133  */
134 #define IPA_MAX_NUM_HW_PATH_CLIENTS 16
135 
136 /**
137  * max number of destination pipes possible for a client.
138  */
139 #define QMI_IPA_MAX_CLIENT_DST_PIPES 4
140 
141 /**
142  * the attributes of the rule (routing or filtering)
143  */
144 #define IPA_FLT_TOS			(1ul << 0)
145 #define IPA_FLT_PROTOCOL		(1ul << 1)
146 #define IPA_FLT_SRC_ADDR		(1ul << 2)
147 #define IPA_FLT_DST_ADDR		(1ul << 3)
148 #define IPA_FLT_SRC_PORT_RANGE		(1ul << 4)
149 #define IPA_FLT_DST_PORT_RANGE		(1ul << 5)
150 #define IPA_FLT_TYPE			(1ul << 6)
151 #define IPA_FLT_CODE			(1ul << 7)
152 #define IPA_FLT_SPI			(1ul << 8)
153 #define IPA_FLT_SRC_PORT		(1ul << 9)
154 #define IPA_FLT_DST_PORT		(1ul << 10)
155 #define IPA_FLT_TC			(1ul << 11)
156 #define IPA_FLT_FLOW_LABEL		(1ul << 12)
157 #define IPA_FLT_NEXT_HDR		(1ul << 13)
158 #define IPA_FLT_META_DATA		(1ul << 14)
159 #define IPA_FLT_FRAGMENT		(1ul << 15)
160 #define IPA_FLT_TOS_MASKED		(1ul << 16)
161 #define IPA_FLT_MAC_SRC_ADDR_ETHER_II	(1ul << 17)
162 #define IPA_FLT_MAC_DST_ADDR_ETHER_II	(1ul << 18)
163 #define IPA_FLT_MAC_SRC_ADDR_802_3	(1ul << 19)
164 #define IPA_FLT_MAC_DST_ADDR_802_3	(1ul << 20)
165 #define IPA_FLT_MAC_ETHER_TYPE		(1ul << 21)
166 #define IPA_FLT_MAC_DST_ADDR_L2TP	(1ul << 22)
167 #define IPA_FLT_TCP_SYN			(1ul << 23)
168 #define IPA_FLT_TCP_SYN_L2TP		(1ul << 24)
169 #define IPA_FLT_L2TP_INNER_IP_TYPE  (1ul << 25)
170 #define IPA_FLT_L2TP_INNER_IPV4_DST_ADDR (1ul << 26)
171 
172 /**
173  * maximal number of NAT PDNs in the PDN config table
174  */
175 #define IPA_MAX_PDN_NUM 5
176 
177 /**
178  * enum ipa_client_type - names for the various IPA "clients"
179  * these are from the perspective of the clients, for e.g.
180  * HSIC1_PROD means HSIC client is the producer and IPA is the
181  * consumer.
182  * PROD clients are always even, and CONS clients are always odd.
183  * Add new clients in the end of the list and update IPA_CLIENT_MAX
184  */
185 enum ipa_client_type {
186 	IPA_CLIENT_HSIC1_PROD			= 0,
187 	IPA_CLIENT_HSIC1_CONS			= 1,
188 
189 	IPA_CLIENT_HSIC2_PROD			= 2,
190 	IPA_CLIENT_HSIC2_CONS			= 3,
191 
192 	IPA_CLIENT_HSIC3_PROD			= 4,
193 	IPA_CLIENT_HSIC3_CONS			= 5,
194 
195 	IPA_CLIENT_HSIC4_PROD			= 6,
196 	IPA_CLIENT_HSIC4_CONS			= 7,
197 
198 	IPA_CLIENT_HSIC5_PROD			= 8,
199 	IPA_CLIENT_HSIC5_CONS			= 9,
200 
201 	IPA_CLIENT_WLAN1_PROD			= 10,
202 	IPA_CLIENT_WLAN1_CONS			= 11,
203 
204 	IPA_CLIENT_A5_WLAN_AMPDU_PROD		= 12,
205 	IPA_CLIENT_WLAN2_CONS			= 13,
206 
207 	/* RESERVERD PROD			= 14, */
208 	IPA_CLIENT_WLAN3_CONS			= 15,
209 
210 	/* RESERVERD PROD			= 16, */
211 	IPA_CLIENT_WLAN4_CONS			= 17,
212 
213 	IPA_CLIENT_USB_PROD			= 18,
214 	IPA_CLIENT_USB_CONS			= 19,
215 
216 	IPA_CLIENT_USB2_PROD			= 20,
217 	IPA_CLIENT_USB2_CONS			= 21,
218 
219 	IPA_CLIENT_USB3_PROD			= 22,
220 	IPA_CLIENT_USB3_CONS			= 23,
221 
222 	IPA_CLIENT_USB4_PROD			= 24,
223 	IPA_CLIENT_USB4_CONS			= 25,
224 
225 	IPA_CLIENT_UC_USB_PROD			= 26,
226 	IPA_CLIENT_USB_DPL_CONS			= 27,
227 
228 	IPA_CLIENT_A2_EMBEDDED_PROD		= 28,
229 	IPA_CLIENT_A2_EMBEDDED_CONS		= 29,
230 
231 	IPA_CLIENT_A2_TETHERED_PROD		= 30,
232 	IPA_CLIENT_A2_TETHERED_CONS		= 31,
233 
234 	IPA_CLIENT_APPS_LAN_PROD		= 32,
235 	IPA_CLIENT_APPS_LAN_CONS		= 33,
236 
237 	IPA_CLIENT_APPS_WAN_PROD		= 34,
238 	IPA_CLIENT_APPS_LAN_WAN_PROD = IPA_CLIENT_APPS_WAN_PROD,
239 	IPA_CLIENT_APPS_WAN_CONS		= 35,
240 
241 	IPA_CLIENT_APPS_CMD_PROD		= 36,
242 	IPA_CLIENT_A5_LAN_WAN_CONS		= 37,
243 
244 	IPA_CLIENT_ODU_PROD			= 38,
245 	IPA_CLIENT_ODU_EMB_CONS			= 39,
246 
247 	/* RESERVERD PROD			= 40, */
248 	IPA_CLIENT_ODU_TETH_CONS		= 41,
249 
250 	IPA_CLIENT_MHI_PROD			= 42,
251 	IPA_CLIENT_MHI_CONS			= 43,
252 
253 	IPA_CLIENT_MEMCPY_DMA_SYNC_PROD		= 44,
254 	IPA_CLIENT_MEMCPY_DMA_SYNC_CONS		= 45,
255 
256 	IPA_CLIENT_MEMCPY_DMA_ASYNC_PROD	= 46,
257 	IPA_CLIENT_MEMCPY_DMA_ASYNC_CONS	= 47,
258 
259 	IPA_CLIENT_ETHERNET_PROD		= 48,
260 	IPA_CLIENT_ETHERNET_CONS		= 49,
261 
262 	IPA_CLIENT_Q6_LAN_PROD			= 50,
263 	IPA_CLIENT_Q6_LAN_CONS			= 51,
264 
265 	IPA_CLIENT_Q6_WAN_PROD			= 52,
266 	IPA_CLIENT_Q6_WAN_CONS			= 53,
267 
268 	IPA_CLIENT_Q6_CMD_PROD			= 54,
269 	IPA_CLIENT_Q6_DUN_CONS			= 55,
270 
271 	IPA_CLIENT_Q6_DECOMP_PROD		= 56,
272 	IPA_CLIENT_Q6_DECOMP_CONS		= 57,
273 
274 	IPA_CLIENT_Q6_DECOMP2_PROD		= 58,
275 	IPA_CLIENT_Q6_DECOMP2_CONS		= 59,
276 
277 	/* RESERVERD PROD			= 60, */
278 	IPA_CLIENT_Q6_LTE_WIFI_AGGR_CONS	= 61,
279 
280 	IPA_CLIENT_TEST_PROD			= 62,
281 	IPA_CLIENT_TEST_CONS			= 63,
282 
283 	IPA_CLIENT_TEST1_PROD			= 64,
284 	IPA_CLIENT_TEST1_CONS			= 65,
285 
286 	IPA_CLIENT_TEST2_PROD			= 66,
287 	IPA_CLIENT_TEST2_CONS			= 67,
288 
289 	IPA_CLIENT_TEST3_PROD			= 68,
290 	IPA_CLIENT_TEST3_CONS			= 69,
291 
292 	IPA_CLIENT_TEST4_PROD			= 70,
293 	IPA_CLIENT_TEST4_CONS			= 71,
294 
295 	/* RESERVERD PROD				= 72, */
296 	IPA_CLIENT_DUMMY_CONS			= 73
297 };
298 
299 #define IPA_CLIENT_MAX (IPA_CLIENT_DUMMY_CONS + 1)
300 
301 #define IPA_CLIENT_IS_APPS_CONS(client) \
302 	((client) == IPA_CLIENT_APPS_LAN_CONS || \
303 	(client) == IPA_CLIENT_APPS_WAN_CONS)
304 
305 #define IPA_CLIENT_IS_USB_CONS(client) \
306 	((client) == IPA_CLIENT_USB_CONS || \
307 	(client) == IPA_CLIENT_USB2_CONS || \
308 	(client) == IPA_CLIENT_USB3_CONS || \
309 	(client) == IPA_CLIENT_USB_DPL_CONS || \
310 	(client) == IPA_CLIENT_USB4_CONS)
311 
312 #define IPA_CLIENT_IS_WLAN_CONS(client) \
313 	((client) == IPA_CLIENT_WLAN1_CONS || \
314 	(client) == IPA_CLIENT_WLAN2_CONS || \
315 	(client) == IPA_CLIENT_WLAN3_CONS || \
316 	(client) == IPA_CLIENT_WLAN4_CONS)
317 
318 #define IPA_CLIENT_IS_ODU_CONS(client) \
319 	((client) == IPA_CLIENT_ODU_EMB_CONS || \
320 	(client) == IPA_CLIENT_ODU_TETH_CONS)
321 
322 #define IPA_CLIENT_IS_Q6_CONS(client) \
323 	((client) == IPA_CLIENT_Q6_LAN_CONS || \
324 	(client) == IPA_CLIENT_Q6_WAN_CONS || \
325 	(client) == IPA_CLIENT_Q6_DUN_CONS || \
326 	(client) == IPA_CLIENT_Q6_DECOMP_CONS || \
327 	(client) == IPA_CLIENT_Q6_DECOMP2_CONS || \
328 	(client) == IPA_CLIENT_Q6_LTE_WIFI_AGGR_CONS)
329 
330 #define IPA_CLIENT_IS_Q6_PROD(client) \
331 	((client) == IPA_CLIENT_Q6_LAN_PROD || \
332 	(client) == IPA_CLIENT_Q6_WAN_PROD || \
333 	(client) == IPA_CLIENT_Q6_CMD_PROD || \
334 	(client) == IPA_CLIENT_Q6_DECOMP_PROD || \
335 	(client) == IPA_CLIENT_Q6_DECOMP2_PROD)
336 
337 #define IPA_CLIENT_IS_Q6_NON_ZIP_CONS(client) \
338 	((client) == IPA_CLIENT_Q6_LAN_CONS || \
339 	(client) == IPA_CLIENT_Q6_WAN_CONS || \
340 	(client) == IPA_CLIENT_Q6_DUN_CONS || \
341 	(client) == IPA_CLIENT_Q6_LTE_WIFI_AGGR_CONS)
342 
343 #define IPA_CLIENT_IS_Q6_ZIP_CONS(client) \
344 	((client) == IPA_CLIENT_Q6_DECOMP_CONS || \
345 	(client) == IPA_CLIENT_Q6_DECOMP2_CONS)
346 
347 #define IPA_CLIENT_IS_Q6_NON_ZIP_PROD(client) \
348 	((client) == IPA_CLIENT_Q6_LAN_PROD || \
349 	(client) == IPA_CLIENT_Q6_WAN_PROD || \
350 	(client) == IPA_CLIENT_Q6_CMD_PROD)
351 
352 #define IPA_CLIENT_IS_Q6_ZIP_PROD(client) \
353 	((client) == IPA_CLIENT_Q6_DECOMP_PROD || \
354 	(client) == IPA_CLIENT_Q6_DECOMP2_PROD)
355 
356 #define IPA_CLIENT_IS_MEMCPY_DMA_CONS(client) \
357 	((client) == IPA_CLIENT_MEMCPY_DMA_SYNC_CONS || \
358 	(client) == IPA_CLIENT_MEMCPY_DMA_ASYNC_CONS)
359 
360 #define IPA_CLIENT_IS_MEMCPY_DMA_PROD(client) \
361 	((client) == IPA_CLIENT_MEMCPY_DMA_SYNC_PROD || \
362 	(client) == IPA_CLIENT_MEMCPY_DMA_ASYNC_PROD)
363 
364 #define IPA_CLIENT_IS_MHI_CONS(client) \
365 	((client) == IPA_CLIENT_MHI_CONS)
366 
367 #define IPA_CLIENT_IS_MHI(client) \
368 	((client) == IPA_CLIENT_MHI_CONS || \
369 	(client) == IPA_CLIENT_MHI_PROD)
370 
371 #define IPA_CLIENT_IS_TEST_PROD(client) \
372 	((client) == IPA_CLIENT_TEST_PROD || \
373 	(client) == IPA_CLIENT_TEST1_PROD || \
374 	(client) == IPA_CLIENT_TEST2_PROD || \
375 	(client) == IPA_CLIENT_TEST3_PROD || \
376 	(client) == IPA_CLIENT_TEST4_PROD)
377 
378 #define IPA_CLIENT_IS_TEST_CONS(client) \
379 	((client) == IPA_CLIENT_TEST_CONS || \
380 	(client) == IPA_CLIENT_TEST1_CONS || \
381 	(client) == IPA_CLIENT_TEST2_CONS || \
382 	(client) == IPA_CLIENT_TEST3_CONS || \
383 	(client) == IPA_CLIENT_TEST4_CONS)
384 
385 #define IPA_CLIENT_IS_TEST(client) \
386 	(IPA_CLIENT_IS_TEST_PROD(client) || IPA_CLIENT_IS_TEST_CONS(client))
387 
388 /**
389  * enum ipa_ip_type - Address family: IPv4 or IPv6
390  */
391 enum ipa_ip_type {
392 	IPA_IP_v4,
393 	IPA_IP_v6,
394 	IPA_IP_MAX
395 };
396 
397 /**
398  * enum ipa_rule_type - Type of routing or filtering rule
399  * Hashable: Rule will be located at the hashable tables
400  * Non_Hashable: Rule will be located at the non-hashable tables
401  */
402 enum ipa_rule_type {
403 	IPA_RULE_HASHABLE,
404 	IPA_RULE_NON_HASHABLE,
405 };
406 #define IPA_RULE_TYPE_MAX (IPA_RULE_NON_HASHABLE + 1)
407 
408 /**
409  * enum ipa_flt_action - action field of filtering rule
410  *
411  * Pass to routing: 5'd0
412  * Pass to source NAT: 5'd1
413  * Pass to destination NAT: 5'd2
414  * Pass to default output pipe (e.g., Apps or Modem): 5'd3
415  */
416 enum ipa_flt_action {
417 	IPA_PASS_TO_ROUTING,
418 	IPA_PASS_TO_SRC_NAT,
419 	IPA_PASS_TO_DST_NAT,
420 	IPA_PASS_TO_EXCEPTION
421 };
422 
423 /**
424  * enum ipa_wlan_event - Events for wlan client
425  *
426  * wlan client connect: New wlan client connected
427  * wlan client disconnect: wlan client disconnected
428  * wlan client power save: wlan client moved to power save
429  * wlan client normal: wlan client moved out of power save
430  * sw routing enable: ipa routing is disabled
431  * sw routing disable: ipa routing is enabled
432  * wlan ap connect: wlan AP(access point) is up
433  * wlan ap disconnect: wlan AP(access point) is down
434  * wlan sta connect: wlan STA(station) is up
435  * wlan sta disconnect: wlan STA(station) is down
436  * wlan client connect ex: new wlan client connected
437  * wlan scc switch: wlan interfaces in scc mode
438  * wlan mcc switch: wlan interfaces in mcc mode
439  * wlan wdi enable: wdi data path completed
440  * wlan wdi disable: wdi data path teardown
441  */
442 enum ipa_wlan_event {
443 	WLAN_CLIENT_CONNECT,
444 	WLAN_CLIENT_DISCONNECT,
445 	WLAN_CLIENT_POWER_SAVE_MODE,
446 	WLAN_CLIENT_NORMAL_MODE,
447 	SW_ROUTING_ENABLE,
448 	SW_ROUTING_DISABLE,
449 	WLAN_AP_CONNECT,
450 	WLAN_AP_DISCONNECT,
451 	WLAN_STA_CONNECT,
452 	WLAN_STA_DISCONNECT,
453 	WLAN_CLIENT_CONNECT_EX,
454 	WLAN_SWITCH_TO_SCC,
455 	WLAN_SWITCH_TO_MCC,
456 	WLAN_WDI_ENABLE,
457 	WLAN_WDI_DISABLE,
458 	IPA_WLAN_EVENT_MAX
459 };
460 
461 /**
462  * enum ipa_wan_event - Events for wan client
463  *
464  * wan default route add/del
465  * wan embms connect: New wan embms interface connected
466  */
467 enum ipa_wan_event {
468 	WAN_UPSTREAM_ROUTE_ADD = IPA_WLAN_EVENT_MAX,
469 	WAN_UPSTREAM_ROUTE_DEL,
470 	WAN_EMBMS_CONNECT,
471 	WAN_XLAT_CONNECT,
472 	IPA_WAN_EVENT_MAX
473 };
474 
475 enum ipa_ecm_event {
476 	ECM_CONNECT = IPA_WAN_EVENT_MAX,
477 	ECM_DISCONNECT,
478 	IPA_ECM_EVENT_MAX,
479 };
480 
481 enum ipa_tethering_stats_event {
482 	IPA_TETHERING_STATS_UPDATE_STATS = IPA_ECM_EVENT_MAX,
483 	IPA_TETHERING_STATS_UPDATE_NETWORK_STATS,
484 	IPA_TETHERING_STATS_EVENT_MAX,
485 };
486 
487 
488 enum ipa_quota_event {
489 	IPA_QUOTA_REACH = IPA_TETHERING_STATS_EVENT_MAX,
490 	IPA_QUOTA_EVENT_MAX,
491 };
492 
493 enum ipa_ssr_event {
494 	IPA_SSR_BEFORE_SHUTDOWN = IPA_QUOTA_EVENT_MAX,
495 	IPA_SSR_AFTER_POWERUP,
496 	IPA_SSR_EVENT_MAX
497 };
498 
499 enum ipa_vlan_l2tp_event {
500 	ADD_VLAN_IFACE = IPA_SSR_EVENT_MAX,
501 	DEL_VLAN_IFACE,
502 	ADD_L2TP_VLAN_MAPPING,
503 	DEL_L2TP_VLAN_MAPPING,
504 	IPA_VLAN_L2TP_EVENT_MAX,
505 };
506 
507 enum ipa_per_client_stats_event {
508 	IPA_PER_CLIENT_STATS_CONNECT_EVENT = IPA_VLAN_L2TP_EVENT_MAX,
509 	IPA_PER_CLIENT_STATS_DISCONNECT_EVENT,
510 	IPA_PER_CLIENT_STATS_EVENT_MAX
511 };
512 
513 enum ipa_wlan_fw_ssr_event {
514 	WLAN_FWR_SSR_BEFORE_SHUTDOWN = IPA_PER_CLIENT_STATS_EVENT_MAX,
515 	IPA_WLAN_FW_SSR_EVENT_MAX,
516 #define IPA_WLAN_FW_SSR_EVENT_MAX IPA_WLAN_FW_SSR_EVENT_MAX
517 };
518 
519 #define IPA_EVENT_MAX_NUM (IPA_WLAN_FW_SSR_EVENT_MAX)
520 #define IPA_EVENT_MAX ((int)IPA_EVENT_MAX_NUM)
521 
522 /**
523  * enum ipa_rm_resource_name - IPA RM clients identification names
524  *
525  * PROD resources are always even, and CONS resources are always odd.
526  * Add new clients in the end of the list and update IPA_RM_RESOURCE_MAX
527  */
528 enum ipa_rm_resource_name {
529 	IPA_RM_RESOURCE_Q6_PROD				= 0,
530 	IPA_RM_RESOURCE_Q6_CONS				= 1,
531 
532 	IPA_RM_RESOURCE_USB_PROD			= 2,
533 	IPA_RM_RESOURCE_USB_CONS			= 3,
534 
535 	IPA_RM_RESOURCE_USB_DPL_DUMMY_PROD		= 4,
536 	IPA_RM_RESOURCE_USB_DPL_CONS			= 5,
537 
538 	IPA_RM_RESOURCE_HSIC_PROD			= 6,
539 	IPA_RM_RESOURCE_HSIC_CONS			= 7,
540 
541 	IPA_RM_RESOURCE_STD_ECM_PROD			= 8,
542 	IPA_RM_RESOURCE_APPS_CONS			= 9,
543 
544 	IPA_RM_RESOURCE_RNDIS_PROD			= 10,
545 	/* RESERVED CONS				= 11, */
546 
547 	IPA_RM_RESOURCE_WWAN_0_PROD			= 12,
548 	/* RESERVED CONS				= 13, */
549 
550 	IPA_RM_RESOURCE_WLAN_PROD			= 14,
551 	IPA_RM_RESOURCE_WLAN_CONS			= 15,
552 
553 	IPA_RM_RESOURCE_ODU_ADAPT_PROD			= 16,
554 	IPA_RM_RESOURCE_ODU_ADAPT_CONS			= 17,
555 
556 	IPA_RM_RESOURCE_MHI_PROD			= 18,
557 	IPA_RM_RESOURCE_MHI_CONS			= 19,
558 
559 	IPA_RM_RESOURCE_ETHERNET_PROD			= 20,
560 	IPA_RM_RESOURCE_ETHERNET_CONS			= 21,
561 };
562 #define IPA_RM_RESOURCE_MAX (IPA_RM_RESOURCE_ETHERNET_CONS + 1)
563 
564 /**
565  * enum ipa_hw_type - IPA hardware version type
566  * @IPA_HW_None: IPA hardware version not defined
567  * @IPA_HW_v1_0: IPA hardware version 1.0
568  * @IPA_HW_v1_1: IPA hardware version 1.1
569  * @IPA_HW_v2_0: IPA hardware version 2.0
570  * @IPA_HW_v2_1: IPA hardware version 2.1
571  * @IPA_HW_v2_5: IPA hardware version 2.5
572  * @IPA_HW_v2_6: IPA hardware version 2.6
573  * @IPA_HW_v2_6L: IPA hardware version 2.6L
574  * @IPA_HW_v3_0: IPA hardware version 3.0
575  * @IPA_HW_v3_1: IPA hardware version 3.1
576  * @IPA_HW_v3_5: IPA hardware version 3.5
577  * @IPA_HW_v3_5_1: IPA hardware version 3.5.1
578  * @IPA_HW_v4_0: IPA hardware version 4.0
579  */
580 enum ipa_hw_type {
581 	IPA_HW_None = 0,
582 	IPA_HW_v1_0 = 1,
583 	IPA_HW_v1_1 = 2,
584 	IPA_HW_v2_0 = 3,
585 	IPA_HW_v2_1 = 4,
586 	IPA_HW_v2_5 = 5,
587 	IPA_HW_v2_6 = IPA_HW_v2_5,
588 	IPA_HW_v2_6L = 6,
589 	IPA_HW_v3_0 = 10,
590 	IPA_HW_v3_1 = 11,
591 	IPA_HW_v3_5 = 12,
592 	IPA_HW_v3_5_1 = 13,
593 	IPA_HW_v4_0 = 14,
594 };
595 #define IPA_HW_MAX (IPA_HW_v4_0 + 1)
596 
597 #define IPA_HW_v4_0 IPA_HW_v4_0
598 
599 /**
600  * struct ipa_rule_attrib - attributes of a routing/filtering
601  * rule, all in LE
602  * @attrib_mask: what attributes are valid
603  * @src_port_lo: low port of src port range
604  * @src_port_hi: high port of src port range
605  * @dst_port_lo: low port of dst port range
606  * @dst_port_hi: high port of dst port range
607  * @type: ICMP/IGMP type
608  * @code: ICMP/IGMP code
609  * @spi: IPSec SPI
610  * @src_port: exact src port
611  * @dst_port: exact dst port
612  * @meta_data: meta-data val
613  * @meta_data_mask: meta-data mask
614  * @u.v4.tos: type of service
615  * @u.v4.protocol: protocol
616  * @u.v4.src_addr: src address value
617  * @u.v4.src_addr_mask: src address mask
618  * @u.v4.dst_addr: dst address value
619  * @u.v4.dst_addr_mask: dst address mask
620  * @u.v6.tc: traffic class
621  * @u.v6.flow_label: flow label
622  * @u.v6.next_hdr: next header
623  * @u.v6.src_addr: src address val
624  * @u.v6.src_addr_mask: src address mask
625  * @u.v6.dst_addr: dst address val
626  * @u.v6.dst_addr_mask: dst address mask
627  */
628 struct ipa_rule_attrib {
629 	uint32_t attrib_mask;
630 	uint16_t src_port_lo;
631 	uint16_t src_port_hi;
632 	uint16_t dst_port_lo;
633 	uint16_t dst_port_hi;
634 	uint8_t type;
635 	uint8_t code;
636 	uint8_t tos_value;
637 	uint8_t tos_mask;
638 	uint32_t spi;
639 	uint16_t src_port;
640 	uint16_t dst_port;
641 	uint32_t meta_data;
642 	uint32_t meta_data_mask;
643 	uint8_t src_mac_addr[ETH_ALEN];
644 	uint8_t src_mac_addr_mask[ETH_ALEN];
645 	uint8_t dst_mac_addr[ETH_ALEN];
646 	uint8_t dst_mac_addr_mask[ETH_ALEN];
647 	uint16_t ether_type;
648 	union {
649 		struct {
650 			uint8_t tos;
651 			uint8_t protocol;
652 			uint32_t src_addr;
653 			uint32_t src_addr_mask;
654 			uint32_t dst_addr;
655 			uint32_t dst_addr_mask;
656 		} v4;
657 		struct {
658 			uint8_t tc;
659 			uint32_t flow_label;
660 			uint8_t next_hdr;
661 			uint32_t src_addr[4];
662 			uint32_t src_addr_mask[4];
663 			uint32_t dst_addr[4];
664 			uint32_t dst_addr_mask[4];
665 		} v6;
666 	} u;
667 };
668 
669 /*! @brief The maximum number of Mask Equal 32 Eqns */
670 #define IPA_IPFLTR_NUM_MEQ_32_EQNS 2
671 
672 /*! @brief The maximum number of IHL offset Mask Equal 32 Eqns */
673 #define IPA_IPFLTR_NUM_IHL_MEQ_32_EQNS 2
674 
675 /*! @brief The maximum number of Mask Equal 128 Eqns */
676 #define IPA_IPFLTR_NUM_MEQ_128_EQNS 2
677 
678 /*! @brief The maximum number of IHL offset Range Check 16 Eqns */
679 #define IPA_IPFLTR_NUM_IHL_RANGE_16_EQNS 2
680 
681 /*! @brief Offset and 16 bit comparison equation */
682 struct ipa_ipfltr_eq_16 {
683 	int8_t offset;
684 	uint16_t value;
685 };
686 
687 /*! @brief Offset and 32 bit comparison equation */
688 struct ipa_ipfltr_eq_32 {
689 	int8_t offset;
690 	uint32_t value;
691 };
692 
693 /*! @brief Offset and 128 bit masked comparison equation */
694 struct ipa_ipfltr_mask_eq_128 {
695 	int8_t offset;
696 	uint8_t mask[16];
697 	uint8_t value[16];
698 };
699 
700 /*! @brief Offset and 32 bit masked comparison equation */
701 struct ipa_ipfltr_mask_eq_32 {
702 	int8_t offset;
703 	uint32_t mask;
704 	uint32_t value;
705 };
706 
707 /*! @brief Equation for identifying a range. Ranges are inclusive */
708 struct ipa_ipfltr_range_eq_16 {
709 	int8_t offset;
710 	uint16_t range_low;
711 	uint16_t range_high;
712 };
713 
714 /*! @brief Rule equations which are set according to DS filter installation */
715 struct ipa_ipfltri_rule_eq {
716 	/*! 16-bit Bitmask to indicate how many eqs are valid in this rule  */
717 	uint16_t rule_eq_bitmap;
718 	/*! Specifies if a type of service check rule is present */
719 	uint8_t tos_eq_present;
720 	/*! The value to check against the type of service (ipv4) field */
721 	uint8_t tos_eq;
722 	/*! Specifies if a protocol check rule is present */
723 	uint8_t protocol_eq_present;
724 	/*! The value to check against the protocol (ipv6) field */
725 	uint8_t protocol_eq;
726 	/*! The number of ip header length offset 16 bit range check
727 	 * rules in this rule
728 	 */
729 	uint8_t num_ihl_offset_range_16;
730 	/*! An array of the registered ip header length offset 16 bit
731 	* range check rules
732 	*/
733 	struct ipa_ipfltr_range_eq_16
734 		ihl_offset_range_16[IPA_IPFLTR_NUM_IHL_RANGE_16_EQNS];
735 	/*! The number of mask equal 32 rules present in this rule */
736 	uint8_t num_offset_meq_32;
737 	/*! An array of all the possible mask equal 32 rules in this rule */
738 	struct ipa_ipfltr_mask_eq_32
739 		offset_meq_32[IPA_IPFLTR_NUM_MEQ_32_EQNS];
740 	/*! Specifies if the traffic class rule is present in this rule */
741 	uint8_t tc_eq_present;
742 	/*! The value to check the traffic class (ipv4) field against */
743 	uint8_t tc_eq;
744 	/*! Specifies if the flow equals rule is present in this rule */
745 	uint8_t fl_eq_present;
746 	/*! The value to check the flow (ipv6) field against */
747 	uint32_t fl_eq;
748 	/*! The number of ip header length offset 16 bit equations in this
749 	* rule
750 	*/
751 	uint8_t ihl_offset_eq_16_present;
752 	/*! The ip header length offset 16 bit equation */
753 	struct ipa_ipfltr_eq_16 ihl_offset_eq_16;
754 	/*! The number of ip header length offset 32 bit equations in this
755 	 * rule
756 	 */
757 	uint8_t ihl_offset_eq_32_present;
758 	/*! The ip header length offset 32 bit equation */
759 	struct ipa_ipfltr_eq_32 ihl_offset_eq_32;
760 	/*! The number of ip header length offset 32 bit mask equations in
761 	 * this rule
762 	 */
763 	uint8_t num_ihl_offset_meq_32;
764 	/*! The ip header length offset 32 bit mask equation */
765 	struct ipa_ipfltr_mask_eq_32
766 		ihl_offset_meq_32[IPA_IPFLTR_NUM_IHL_MEQ_32_EQNS];
767 	/*! The number of ip header length offset 128 bit equations in this
768 	 * rule
769 	 */
770 	uint8_t num_offset_meq_128;
771 	/*! The ip header length offset 128 bit equation */
772 	struct ipa_ipfltr_mask_eq_128
773 		offset_meq_128[IPA_IPFLTR_NUM_MEQ_128_EQNS];
774 	/*! The metadata 32 bit masked comparison equation present or not */
775 	/* Metadata based rules are added internally by IPA driver */
776 	uint8_t metadata_meq32_present;
777 	/*! The metadata 32 bit masked comparison equation */
778 	struct ipa_ipfltr_mask_eq_32 metadata_meq32;
779 	/*! Specifies if the Fragment equation is present in this rule */
780 	uint8_t ipv4_frag_eq_present;
781 };
782 
783 /**
784  * struct ipa_flt_rule - attributes of a filtering rule
785  * @retain_hdr: bool switch to instruct IPA core to add back to the packet
786  *  the header removed as part of header removal
787  * @to_uc: bool switch to pass packet to micro-controller
788  * @action: action field
789  * @rt_tbl_hdl: handle of table from "get"
790  * @attrib: attributes of the rule
791  * @eq_attrib: attributes of the rule in equation form (valid when
792  * eq_attrib_type is true)
793  * @rt_tbl_idx: index of RT table referred to by filter rule (valid when
794  * eq_attrib_type is true and non-exception action)
795  * @eq_attrib_type: true if equation level form used to specify attributes
796  * @max_prio: bool switch. is this rule with Max priority? meaning on rule hit,
797  *  IPA will use the rule and will not look for other rules that may have
798  *  higher priority
799  * @hashable: bool switch. is this rule hashable or not?
800  *  ipa uses hashable rules to cache their hit results to be used in
801  *  consecutive packets
802  * @rule_id: rule_id to be assigned to the filter rule. In case client specifies
803  *  rule_id as 0 the driver will assign a new rule_id
804  * @set_metadata: bool switch. should metadata replacement at the NAT block
805  *  take place?
806  * @pdn_idx: if action is "pass to source\destination NAT" then a comparison
807  * against the PDN index in the matching PDN entry will take place as an
808  * additional condition for NAT hit.
809  */
810 struct ipa_flt_rule {
811 	uint8_t retain_hdr;
812 	uint8_t to_uc;
813 	enum ipa_flt_action action;
814 	uint32_t rt_tbl_hdl;
815 	struct ipa_rule_attrib attrib;
816 	struct ipa_ipfltri_rule_eq eq_attrib;
817 	uint32_t rt_tbl_idx;
818 	uint8_t eq_attrib_type;
819 	uint8_t max_prio;
820 	uint8_t hashable;
821 	uint16_t rule_id;
822 	uint8_t set_metadata;
823 	uint8_t pdn_idx;
824 };
825 
826 /**
827  * enum ipa_hdr_l2_type - L2 header type
828  * IPA_HDR_L2_NONE: L2 header which isn't Ethernet II and isn't 802_3
829  * IPA_HDR_L2_ETHERNET_II: L2 header of type Ethernet II
830  * IPA_HDR_L2_802_3: L2 header of type 802_3
831  * IPA_HDR_L2_802_1Q: L2 header of type 802_1Q
832  */
833 enum ipa_hdr_l2_type {
834 	IPA_HDR_L2_NONE,
835 	IPA_HDR_L2_ETHERNET_II,
836 	IPA_HDR_L2_802_3,
837 	IPA_HDR_L2_802_1Q,
838 };
839 #define IPA_HDR_L2_MAX (IPA_HDR_L2_802_1Q + 1)
840 
841 #define IPA_HDR_L2_802_1Q IPA_HDR_L2_802_1Q
842 
843 /**
844  * enum ipa_hdr_l2_type - Processing context type
845  * IPA_HDR_PROC_NONE: No processing context
846  * IPA_HDR_PROC_ETHII_TO_ETHII: Process Ethernet II to Ethernet II
847  * IPA_HDR_PROC_ETHII_TO_802_3: Process Ethernet II to 802_3
848  * IPA_HDR_PROC_802_3_TO_ETHII: Process 802_3 to Ethernet II
849  * IPA_HDR_PROC_802_3_TO_802_3: Process 802_3 to 802_3
850  */
851 enum ipa_hdr_proc_type {
852 	IPA_HDR_PROC_NONE,
853 	IPA_HDR_PROC_ETHII_TO_ETHII,
854 	IPA_HDR_PROC_ETHII_TO_802_3,
855 	IPA_HDR_PROC_802_3_TO_ETHII,
856 	IPA_HDR_PROC_802_3_TO_802_3,
857 	IPA_HDR_PROC_L2TP_HEADER_ADD,
858 	IPA_HDR_PROC_L2TP_HEADER_REMOVE
859 };
860 #define IPA_HDR_PROC_MAX (IPA_HDR_PROC_L2TP_HEADER_REMOVE + 1)
861 
862 /**
863  * struct ipa_rt_rule - attributes of a routing rule
864  * @dst: dst "client"
865  * @hdr_hdl: handle to the dynamic header
866 	it is not an index or an offset
867  * @hdr_proc_ctx_hdl: handle to header processing context. if it is provided
868 	hdr_hdl shall be 0
869  * @attrib: attributes of the rule
870  * @max_prio: bool switch. is this rule with Max priority? meaning on rule hit,
871  *  IPA will use the rule and will not look for other rules that may have
872  *  higher priority
873  * @hashable: bool switch. is this rule hashable or not?
874  *  ipa uses hashable rules to cache their hit results to be used in
875  *  consecutive packets
876  * @retain_hdr: bool switch to instruct IPA core to add back to the packet
877  *  the header removed as part of header removal
878  */
879 struct ipa_rt_rule {
880 	enum ipa_client_type dst;
881 	uint32_t hdr_hdl;
882 	uint32_t hdr_proc_ctx_hdl;
883 	struct ipa_rule_attrib attrib;
884 	uint8_t max_prio;
885 	uint8_t hashable;
886 	uint8_t retain_hdr;
887 };
888 
889 /**
890  * struct ipa_hdr_add - header descriptor includes in and out
891  * parameters
892  * @name: name of the header
893  * @hdr: actual header to be inserted
894  * @hdr_len: size of above header
895  * @type: l2 header type
896  * @is_partial: header not fully specified
897  * @hdr_hdl: out parameter, handle to header, valid when status is 0
898  * @status:	out parameter, status of header add operation,
899  *		0 for success,
900  *		-1 for failure
901  * @is_eth2_ofst_valid: is eth2_ofst field valid?
902  * @eth2_ofst: offset to start of Ethernet-II/802.3 header
903  */
904 struct ipa_hdr_add {
905 	char name[IPA_RESOURCE_NAME_MAX];
906 	uint8_t hdr[IPA_HDR_MAX_SIZE];
907 	uint8_t hdr_len;
908 	enum ipa_hdr_l2_type type;
909 	uint8_t is_partial;
910 	uint32_t hdr_hdl;
911 	int status;
912 	uint8_t is_eth2_ofst_valid;
913 	uint16_t eth2_ofst;
914 };
915 
916 /**
917  * struct ipa_ioc_add_hdr - header addition parameters (support
918  * multiple headers and commit)
919  * @commit: should headers be written to IPA HW also?
920  * @num_hdrs: num of headers that follow
921  * @ipa_hdr_add hdr:	all headers need to go here back to
922  *			back, no pointers
923  */
924 struct ipa_ioc_add_hdr {
925 	uint8_t commit;
926 	uint8_t num_hdrs;
927 	struct ipa_hdr_add hdr[0];
928 };
929 
930 /**
931  * struct ipa_l2tp_header_add_procparams -
932  * @eth_hdr_retained: Specifies if Ethernet header is retained or not
933  * @input_ip_version: Specifies if Input header is IPV4(0) or IPV6(1)
934  * @output_ip_version: Specifies if template header is IPV4(0) or IPV6(1)
935  */
936 struct ipa_l2tp_header_add_procparams {
937 	uint32_t eth_hdr_retained:1;
938 	uint32_t input_ip_version:1;
939 	uint32_t output_ip_version:1;
940 	uint32_t reserved:29;
941 };
942 
943 /**
944  * struct ipa_l2tp_header_remove_procparams -
945  * @hdr_len_remove: Specifies how much of the header needs to
946 		be removed in bytes
947  * @eth_hdr_retained: Specifies if Ethernet header is retained or not
948  * @hdr_ofst_pkt_size_valid: Specifies if the Header offset is valid
949  * @hdr_ofst_pkt_size: If hdr_ofst_pkt_size_valid =1, this indicates where the
950 		packet size field (2bytes) resides
951  * @hdr_endianness: 0:little endian, 1:big endian
952  */
953 struct ipa_l2tp_header_remove_procparams {
954 	uint32_t hdr_len_remove:8;
955 	uint32_t eth_hdr_retained:1;
956 	/* Following fields are valid if eth_hdr_retained =1 ( bridge mode) */
957 	uint32_t hdr_ofst_pkt_size_valid:1;
958 	uint32_t hdr_ofst_pkt_size:6;
959 	uint32_t hdr_endianness:1;
960 	uint32_t reserved:15;
961 };
962 
963 /**
964  * struct ipa_l2tp_hdr_proc_ctx_params -
965  * @hdr_add_param: parameters for header add
966  * @hdr_remove_param: parameters for header remove
967  * @is_dst_pipe_valid: if dst pipe is valid
968  * @dst_pipe: destination pipe
969  */
970 struct ipa_l2tp_hdr_proc_ctx_params {
971 	struct ipa_l2tp_header_add_procparams hdr_add_param;
972 	struct ipa_l2tp_header_remove_procparams hdr_remove_param;
973 	uint8_t is_dst_pipe_valid;
974 	enum ipa_client_type dst_pipe;
975 };
976 
977 #define L2TP_USER_SPACE_SPECIFY_DST_PIPE
978 
979 /**
980  * struct ipa_hdr_proc_ctx_add - processing context descriptor includes
981  * in and out parameters
982  * @type: processing context type
983  * @hdr_hdl: in parameter, handle to header
984  * @l2tp_params: l2tp parameters
985  * @proc_ctx_hdl: out parameter, handle to proc_ctx, valid when status is 0
986  * @status:	out parameter, status of header add operation,
987  *		0 for success,
988  *		-1 for failure
989  */
990 struct ipa_hdr_proc_ctx_add {
991 	enum ipa_hdr_proc_type type;
992 	uint32_t hdr_hdl;
993 	uint32_t proc_ctx_hdl;
994 	int status;
995 	struct ipa_l2tp_hdr_proc_ctx_params l2tp_params;
996 };
997 
998 #define IPA_L2TP_HDR_PROC_SUPPORT
999 
1000 /**
1001  * struct ipa_ioc_add_hdr - processing context addition parameters (support
1002  * multiple processing context and commit)
1003  * @commit: should processing context be written to IPA HW also?
1004  * @num_proc_ctxs: num of processing context that follow
1005  * @proc_ctx:	all processing context need to go here back to
1006  *			back, no pointers
1007  */
1008 struct ipa_ioc_add_hdr_proc_ctx {
1009 	uint8_t commit;
1010 	uint8_t num_proc_ctxs;
1011 	struct ipa_hdr_proc_ctx_add proc_ctx[0];
1012 };
1013 
1014 /**
1015  * struct ipa_ioc_copy_hdr - retrieve a copy of the specified
1016  * header - caller can then derive the complete header
1017  * @name: name of the header resource
1018  * @hdr:	out parameter, contents of specified header,
1019  *	valid only when ioctl return val is non-negative
1020  * @hdr_len: out parameter, size of above header
1021  *	valid only when ioctl return val is non-negative
1022  * @type: l2 header type
1023  *	valid only when ioctl return val is non-negative
1024  * @is_partial:	out parameter, indicates whether specified header is partial
1025  *		valid only when ioctl return val is non-negative
1026  * @is_eth2_ofst_valid: is eth2_ofst field valid?
1027  * @eth2_ofst: offset to start of Ethernet-II/802.3 header
1028  */
1029 struct ipa_ioc_copy_hdr {
1030 	char name[IPA_RESOURCE_NAME_MAX];
1031 	uint8_t hdr[IPA_HDR_MAX_SIZE];
1032 	uint8_t hdr_len;
1033 	enum ipa_hdr_l2_type type;
1034 	uint8_t is_partial;
1035 	uint8_t is_eth2_ofst_valid;
1036 	uint16_t eth2_ofst;
1037 };
1038 
1039 /**
1040  * struct ipa_ioc_get_hdr - header entry lookup parameters, if lookup was
1041  * successful caller must call put to release the reference count when done
1042  * @name: name of the header resource
1043  * @hdl:	out parameter, handle of header entry
1044  *		valid only when ioctl return val is non-negative
1045  */
1046 struct ipa_ioc_get_hdr {
1047 	char name[IPA_RESOURCE_NAME_MAX];
1048 	uint32_t hdl;
1049 };
1050 
1051 /**
1052  * struct ipa_hdr_del - header descriptor includes in and out
1053  * parameters
1054  *
1055  * @hdl: handle returned from header add operation
1056  * @status:	out parameter, status of header remove operation,
1057  *		0 for success,
1058  *		-1 for failure
1059  */
1060 struct ipa_hdr_del {
1061 	uint32_t hdl;
1062 	int status;
1063 };
1064 
1065 /**
1066  * struct ipa_ioc_del_hdr - header deletion parameters (support
1067  * multiple headers and commit)
1068  * @commit: should headers be removed from IPA HW also?
1069  * @num_hdls: num of headers being removed
1070  * @ipa_hdr_del hdl: all handles need to go here back to back, no pointers
1071  */
1072 struct ipa_ioc_del_hdr {
1073 	uint8_t commit;
1074 	uint8_t num_hdls;
1075 	struct ipa_hdr_del hdl[0];
1076 };
1077 
1078 /**
1079  * struct ipa_hdr_proc_ctx_del - processing context descriptor includes
1080  * in and out parameters
1081  * @hdl: handle returned from processing context add operation
1082  * @status:	out parameter, status of header remove operation,
1083  *		0 for success,
1084  *		-1 for failure
1085  */
1086 struct ipa_hdr_proc_ctx_del {
1087 	uint32_t hdl;
1088 	int status;
1089 };
1090 
1091 /**
1092  * ipa_ioc_del_hdr_proc_ctx - processing context deletion parameters (support
1093  * multiple headers and commit)
1094  * @commit: should processing contexts be removed from IPA HW also?
1095  * @num_hdls: num of processing contexts being removed
1096  * @ipa_hdr_proc_ctx_del hdl:	all handles need to go here back to back,
1097   *				no pointers
1098  */
1099 struct ipa_ioc_del_hdr_proc_ctx {
1100 	uint8_t commit;
1101 	uint8_t num_hdls;
1102 	struct ipa_hdr_proc_ctx_del hdl[0];
1103 };
1104 
1105 /**
1106  * struct ipa_rt_rule_add - routing rule descriptor includes in
1107  * and out parameters
1108  * @rule: actual rule to be added
1109  * @at_rear:	add at back of routing table, it is NOT possible to add rules at
1110  *		the rear of the "default" routing tables
1111  * @rt_rule_hdl: output parameter, handle to rule, valid when status is 0
1112  * @status:	output parameter, status of routing rule add operation,
1113  *		0 for success,
1114  *		-1 for failure
1115  */
1116 struct ipa_rt_rule_add {
1117 	struct ipa_rt_rule rule;
1118 	uint8_t at_rear;
1119 	uint32_t rt_rule_hdl;
1120 	int status;
1121 };
1122 
1123 /**
1124  * struct ipa_ioc_add_rt_rule - routing rule addition parameters (supports
1125  * multiple rules and commit);
1126  *
1127  * all rules MUST be added to same table
1128  * @commit: should rules be written to IPA HW also?
1129  * @ip: IP family of rule
1130  * @rt_tbl_name: name of routing table resource
1131  * @num_rules: number of routing rules that follow
1132  * @ipa_rt_rule_add rules: all rules need to go back to back here, no pointers
1133  */
1134 struct ipa_ioc_add_rt_rule {
1135 	uint8_t commit;
1136 	enum ipa_ip_type ip;
1137 	char rt_tbl_name[IPA_RESOURCE_NAME_MAX];
1138 	uint8_t num_rules;
1139 	struct ipa_rt_rule_add rules[0];
1140 };
1141 
1142 /**
1143  * struct ipa_ioc_add_rt_rule_after - routing rule addition after a specific
1144  * rule parameters(supports multiple rules and commit);
1145  *
1146  * all rules MUST be added to same table
1147  * @commit: should rules be written to IPA HW also?
1148  * @ip: IP family of rule
1149  * @rt_tbl_name: name of routing table resource
1150  * @num_rules: number of routing rules that follow
1151  * @add_after_hdl: the rules will be added after this specific rule
1152  * @ipa_rt_rule_add rules: all rules need to go back to back here, no pointers
1153  *			   at_rear field will be ignored when using this IOCTL
1154  */
1155 struct ipa_ioc_add_rt_rule_after {
1156 	uint8_t commit;
1157 	enum ipa_ip_type ip;
1158 	char rt_tbl_name[IPA_RESOURCE_NAME_MAX];
1159 	uint8_t num_rules;
1160 	uint32_t add_after_hdl;
1161 	struct ipa_rt_rule_add rules[0];
1162 };
1163 
1164 /**
1165  * struct ipa_rt_rule_mdfy - routing rule descriptor includes
1166  * in and out parameters
1167  * @rule: actual rule to be added
1168  * @rt_rule_hdl: handle to rule which supposed to modify
1169  * @status:	output parameter, status of routing rule modify  operation,
1170  *		0 for success,
1171  *		-1 for failure
1172  *
1173  */
1174 struct ipa_rt_rule_mdfy {
1175 	struct ipa_rt_rule rule;
1176 	uint32_t rt_rule_hdl;
1177 	int status;
1178 };
1179 
1180 /**
1181  * struct ipa_ioc_mdfy_rt_rule - routing rule modify parameters (supports
1182  * multiple rules and commit)
1183  * @commit: should rules be written to IPA HW also?
1184  * @ip: IP family of rule
1185  * @num_rules: number of routing rules that follow
1186  * @rules: all rules need to go back to back here, no pointers
1187  */
1188 struct ipa_ioc_mdfy_rt_rule {
1189 	uint8_t commit;
1190 	enum ipa_ip_type ip;
1191 	uint8_t num_rules;
1192 	struct ipa_rt_rule_mdfy rules[0];
1193 };
1194 
1195 /**
1196  * struct ipa_rt_rule_del - routing rule descriptor includes in
1197  * and out parameters
1198  * @hdl: handle returned from route rule add operation
1199  * @status:	output parameter, status of route rule delete operation,
1200  *		0 for success,
1201  *		-1 for failure
1202  */
1203 struct ipa_rt_rule_del {
1204 	uint32_t hdl;
1205 	int status;
1206 };
1207 
1208 /**
1209  * struct ipa_rt_rule_add_ext - routing rule descriptor includes in
1210  * and out parameters
1211  * @rule: actual rule to be added
1212  * @at_rear:	add at back of routing table, it is NOT possible to add rules at
1213  *		the rear of the "default" routing tables
1214  * @rt_rule_hdl: output parameter, handle to rule, valid when status is 0
1215  * @status:	output parameter, status of routing rule add operation,
1216  * @rule_id: rule_id to be assigned to the routing rule. In case client
1217  *  specifies rule_id as 0 the driver will assign a new rule_id
1218  *		0 for success,
1219  *		-1 for failure
1220  */
1221 struct ipa_rt_rule_add_ext {
1222 	struct ipa_rt_rule rule;
1223 	uint8_t at_rear;
1224 	uint32_t rt_rule_hdl;
1225 	int status;
1226 	uint16_t rule_id;
1227 };
1228 
1229 /**
1230  * struct ipa_ioc_add_rt_rule - routing rule addition parameters (supports
1231  * multiple rules and commit with rule_id);
1232  *
1233  * all rules MUST be added to same table
1234  * @commit: should rules be written to IPA HW also?
1235  * @ip: IP family of rule
1236  * @rt_tbl_name: name of routing table resource
1237  * @num_rules: number of routing rules that follow
1238  * @ipa_rt_rule_add_ext rules: all rules need to go back to back here,
1239  *  no pointers
1240  */
1241 struct ipa_ioc_add_rt_rule_ext {
1242 	uint8_t commit;
1243 	enum ipa_ip_type ip;
1244 	char rt_tbl_name[IPA_RESOURCE_NAME_MAX];
1245 	uint8_t num_rules;
1246 	struct ipa_rt_rule_add_ext rules[0];
1247 };
1248 
1249 
1250 /**
1251  * struct ipa_ioc_del_rt_rule - routing rule deletion parameters (supports
1252  * multiple headers and commit)
1253  * @commit: should rules be removed from IPA HW also?
1254  * @ip: IP family of rules
1255  * @num_hdls: num of rules being removed
1256  * @ipa_rt_rule_del hdl: all handles need to go back to back here, no pointers
1257  */
1258 struct ipa_ioc_del_rt_rule {
1259 	uint8_t commit;
1260 	enum ipa_ip_type ip;
1261 	uint8_t num_hdls;
1262 	struct ipa_rt_rule_del hdl[0];
1263 };
1264 
1265 /**
1266  * struct ipa_ioc_get_rt_tbl_indx - routing table index lookup parameters
1267  * @ip: IP family of table
1268  * @name: name of routing table resource
1269  * @index:	output parameter, routing table index, valid only when ioctl
1270  *		return val is non-negative
1271  */
1272 struct ipa_ioc_get_rt_tbl_indx {
1273 	enum ipa_ip_type ip;
1274 	char name[IPA_RESOURCE_NAME_MAX];
1275 	uint32_t idx;
1276 };
1277 
1278 /**
1279  * struct ipa_flt_rule_add - filtering rule descriptor includes
1280  * in and out parameters
1281  * @rule: actual rule to be added
1282  * @at_rear: add at back of filtering table?
1283  * @flt_rule_hdl: out parameter, handle to rule, valid when status is 0
1284  * @status:	output parameter, status of filtering rule add   operation,
1285  *		0 for success,
1286  *		-1 for failure
1287  *
1288  */
1289 struct ipa_flt_rule_add {
1290 	struct ipa_flt_rule rule;
1291 	uint8_t at_rear;
1292 	uint32_t flt_rule_hdl;
1293 	int status;
1294 };
1295 
1296 /**
1297  * struct ipa_ioc_add_flt_rule - filtering rule addition parameters (supports
1298  * multiple rules and commit)
1299  * all rules MUST be added to same table
1300  * @commit: should rules be written to IPA HW also?
1301  * @ip: IP family of rule
1302  * @ep:	which "clients" pipe does this rule apply to?
1303  *	valid only when global is 0
1304  * @global: does this apply to global filter table of specific IP family
1305  * @num_rules: number of filtering rules that follow
1306  * @rules: all rules need to go back to back here, no pointers
1307  */
1308 struct ipa_ioc_add_flt_rule {
1309 	uint8_t commit;
1310 	enum ipa_ip_type ip;
1311 	enum ipa_client_type ep;
1312 	uint8_t global;
1313 	uint8_t num_rules;
1314 	struct ipa_flt_rule_add rules[0];
1315 };
1316 
1317 /**
1318  * struct ipa_ioc_add_flt_rule_after - filtering rule addition after specific
1319  * rule parameters (supports multiple rules and commit)
1320  * all rules MUST be added to same table
1321  * @commit: should rules be written to IPA HW also?
1322  * @ip: IP family of rule
1323  * @ep:	which "clients" pipe does this rule apply to?
1324  * @num_rules: number of filtering rules that follow
1325  * @add_after_hdl: rules will be added after the rule with this handle
1326  * @rules: all rules need to go back to back here, no pointers. at rear field
1327  *	   is ignored when using this IOCTL
1328  */
1329 struct ipa_ioc_add_flt_rule_after {
1330 	uint8_t commit;
1331 	enum ipa_ip_type ip;
1332 	enum ipa_client_type ep;
1333 	uint8_t num_rules;
1334 	uint32_t add_after_hdl;
1335 	struct ipa_flt_rule_add rules[0];
1336 };
1337 
1338 /**
1339  * struct ipa_flt_rule_mdfy - filtering rule descriptor includes
1340  * in and out parameters
1341  * @rule: actual rule to be added
1342  * @flt_rule_hdl: handle to rule
1343  * @status:	output parameter, status of filtering rule modify  operation,
1344  *		0 for success,
1345  *		-1 for failure
1346  *
1347  */
1348 struct ipa_flt_rule_mdfy {
1349 	struct ipa_flt_rule rule;
1350 	uint32_t rule_hdl;
1351 	int status;
1352 };
1353 
1354 /**
1355  * struct ipa_ioc_mdfy_flt_rule - filtering rule modify parameters (supports
1356  * multiple rules and commit)
1357  * @commit: should rules be written to IPA HW also?
1358  * @ip: IP family of rule
1359  * @num_rules: number of filtering rules that follow
1360  * @rules: all rules need to go back to back here, no pointers
1361  */
1362 struct ipa_ioc_mdfy_flt_rule {
1363 	uint8_t commit;
1364 	enum ipa_ip_type ip;
1365 	uint8_t num_rules;
1366 	struct ipa_flt_rule_mdfy rules[0];
1367 };
1368 
1369 /**
1370  * struct ipa_flt_rule_del - filtering rule descriptor includes
1371  * in and out parameters
1372  *
1373  * @hdl: handle returned from filtering rule add operation
1374  * @status:	output parameter, status of filtering rule delete operation,
1375  *		0 for success,
1376  *		-1 for failure
1377  */
1378 struct ipa_flt_rule_del {
1379 	uint32_t hdl;
1380 	int status;
1381 };
1382 
1383 /**
1384  * struct ipa_ioc_del_flt_rule - filtering rule deletion parameters (supports
1385  * multiple headers and commit)
1386  * @commit: should rules be removed from IPA HW also?
1387  * @ip: IP family of rules
1388  * @num_hdls: num of rules being removed
1389  * @hdl: all handles need to go back to back here, no pointers
1390  */
1391 struct ipa_ioc_del_flt_rule {
1392 	uint8_t commit;
1393 	enum ipa_ip_type ip;
1394 	uint8_t num_hdls;
1395 	struct ipa_flt_rule_del hdl[0];
1396 };
1397 
1398 /**
1399  * struct ipa_ioc_get_rt_tbl - routing table lookup parameters, if lookup was
1400  * successful caller must call put to release the reference
1401  * count when done
1402  * @ip: IP family of table
1403  * @name: name of routing table resource
1404  * @htl:	output parameter, handle of routing table, valid only when ioctl
1405  *		return val is non-negative
1406  */
1407 struct ipa_ioc_get_rt_tbl {
1408 	enum ipa_ip_type ip;
1409 	char name[IPA_RESOURCE_NAME_MAX];
1410 	uint32_t hdl;
1411 };
1412 
1413 /**
1414  * struct ipa_ioc_query_intf - used to lookup number of tx and
1415  * rx properties of interface
1416  * @name: name of interface
1417  * @num_tx_props:	output parameter, number of tx properties
1418  *			valid only when ioctl return val is non-negative
1419  * @num_rx_props:	output parameter, number of rx properties
1420  *			valid only when ioctl return val is non-negative
1421  * @num_ext_props:	output parameter, number of ext properties
1422  *			valid only when ioctl return val is non-negative
1423  * @excp_pipe:		exception packets of this interface should be
1424  *			routed to this pipe
1425  */
1426 struct ipa_ioc_query_intf {
1427 	char name[IPA_RESOURCE_NAME_MAX];
1428 	uint32_t num_tx_props;
1429 	uint32_t num_rx_props;
1430 	uint32_t num_ext_props;
1431 	enum ipa_client_type excp_pipe;
1432 };
1433 
1434 /**
1435  * struct ipa_ioc_tx_intf_prop - interface tx property
1436  * @ip: IP family of routing rule
1437  * @attrib: routing rule
1438  * @dst_pipe: routing output pipe
1439  * @alt_dst_pipe: alternate routing output pipe
1440  * @hdr_name: name of associated header if any, empty string when no header
1441  * @hdr_l2_type: type of associated header if any, use NONE when no header
1442  */
1443 struct ipa_ioc_tx_intf_prop {
1444 	enum ipa_ip_type ip;
1445 	struct ipa_rule_attrib attrib;
1446 	enum ipa_client_type dst_pipe;
1447 	enum ipa_client_type alt_dst_pipe;
1448 	char hdr_name[IPA_RESOURCE_NAME_MAX];
1449 	enum ipa_hdr_l2_type hdr_l2_type;
1450 };
1451 
1452 /**
1453  * struct ipa_ioc_query_intf_tx_props - interface tx propertie
1454  * @name: name of interface
1455  * @num_tx_props: number of TX properties
1456  * @tx[0]: output parameter, the tx properties go here back to back
1457  */
1458 struct ipa_ioc_query_intf_tx_props {
1459 	char name[IPA_RESOURCE_NAME_MAX];
1460 	uint32_t num_tx_props;
1461 	struct ipa_ioc_tx_intf_prop tx[0];
1462 };
1463 
1464 /**
1465  * struct ipa_ioc_ext_intf_prop - interface extended property
1466  * @ip: IP family of routing rule
1467  * @eq_attrib: attributes of the rule in equation form
1468  * @action: action field
1469  * @rt_tbl_idx: index of RT table referred to by filter rule
1470  * @mux_id: MUX_ID
1471  * @filter_hdl: handle of filter (as specified by provider of filter rule)
1472  * @is_xlat_rule: it is xlat flt rule or not
1473  */
1474 struct ipa_ioc_ext_intf_prop {
1475 	enum ipa_ip_type ip;
1476 	struct ipa_ipfltri_rule_eq eq_attrib;
1477 	enum ipa_flt_action action;
1478 	uint32_t rt_tbl_idx;
1479 	uint8_t mux_id;
1480 	uint32_t filter_hdl;
1481 	uint8_t is_xlat_rule;
1482 	uint32_t rule_id;
1483 	uint8_t is_rule_hashable;
1484 };
1485 
1486 /**
1487  * struct ipa_ioc_query_intf_ext_props - interface ext propertie
1488  * @name: name of interface
1489  * @num_ext_props: number of EXT properties
1490  * @ext[0]: output parameter, the ext properties go here back to back
1491  */
1492 struct ipa_ioc_query_intf_ext_props {
1493 	char name[IPA_RESOURCE_NAME_MAX];
1494 	uint32_t num_ext_props;
1495 	struct ipa_ioc_ext_intf_prop ext[0];
1496 };
1497 
1498 /**
1499  * struct ipa_ioc_rx_intf_prop - interface rx property
1500  * @ip: IP family of filtering rule
1501  * @attrib: filtering rule
1502  * @src_pipe: input pipe
1503  * @hdr_l2_type: type of associated header if any, use NONE when no header
1504  */
1505 struct ipa_ioc_rx_intf_prop {
1506 	enum ipa_ip_type ip;
1507 	struct ipa_rule_attrib attrib;
1508 	enum ipa_client_type src_pipe;
1509 	enum ipa_hdr_l2_type hdr_l2_type;
1510 };
1511 
1512 /**
1513  * struct ipa_ioc_query_intf_rx_props - interface rx propertie
1514  * @name: name of interface
1515  * @num_rx_props: number of RX properties
1516  * @rx: output parameter, the rx properties go here back to back
1517  */
1518 struct ipa_ioc_query_intf_rx_props {
1519 	char name[IPA_RESOURCE_NAME_MAX];
1520 	uint32_t num_rx_props;
1521 	struct ipa_ioc_rx_intf_prop rx[0];
1522 };
1523 
1524 /**
1525  * struct ipa_ioc_nat_alloc_mem - nat table memory allocation
1526  * properties
1527  * @dev_name: input parameter, the name of table
1528  * @size: input parameter, size of table in bytes
1529  * @offset: output parameter, offset into page in case of system memory
1530  */
1531 struct ipa_ioc_nat_alloc_mem {
1532 	char dev_name[IPA_RESOURCE_NAME_MAX];
1533 	size_t size;
1534 	off_t offset;
1535 };
1536 
1537 /**
1538  * struct ipa_ioc_nat_ipv6ct_table_alloc - NAT/IPv6CT table memory allocation
1539  * properties
1540  * @size: input parameter, size of table in bytes
1541  * @offset: output parameter, offset into page in case of system memory
1542  */
1543 struct ipa_ioc_nat_ipv6ct_table_alloc {
1544 	size_t size;
1545 	off_t offset;
1546 };
1547 
1548 /**
1549  * struct ipa_ioc_v4_nat_init - nat table initialization parameters
1550  * @tbl_index: input parameter, index of the table
1551  * @ipv4_rules_offset: input parameter, ipv4 rules address offset
1552  * @expn_rules_offset: input parameter, ipv4 expansion rules address offset
1553  * @index_offset: input parameter, index rules offset
1554  * @index_expn_offset: input parameter, index expansion rules offset
1555  * @table_entries: input parameter, ipv4 rules table number of entries
1556  * @expn_table_entries: input parameter, ipv4 expansion rules table number of
1557  *                      entries
1558  * @ip_addr: input parameter, public ip address
1559  */
1560 struct ipa_ioc_v4_nat_init {
1561 	uint8_t tbl_index;
1562 	uint32_t ipv4_rules_offset;
1563 	uint32_t expn_rules_offset;
1564 
1565 	uint32_t index_offset;
1566 	uint32_t index_expn_offset;
1567 
1568 	uint16_t table_entries;
1569 	uint16_t expn_table_entries;
1570 	uint32_t ip_addr;
1571 };
1572 
1573 /**
1574  * struct ipa_ioc_ipv6ct_init - IPv6CT table initialization parameters
1575  * @base_table_offset: input parameter, IPv6CT base table address offset
1576  * @expn_table_offset: input parameter, IPv6CT expansion table address offset
1577  * @table_entries: input parameter, IPv6CT table number of entries
1578  * @expn_table_entries: input parameter, IPv6CT expansion table number of
1579  *                      entries
1580  * @tbl_index: input parameter, index of the table
1581  */
1582 struct ipa_ioc_ipv6ct_init {
1583 	uint32_t base_table_offset;
1584 	uint32_t expn_table_offset;
1585 	uint16_t table_entries;
1586 	uint16_t expn_table_entries;
1587 	uint8_t tbl_index;
1588 };
1589 
1590 /**
1591  * struct ipa_ioc_v4_nat_del - nat table delete parameter
1592  * @table_index: input parameter, index of the table
1593  * @public_ip_addr: input parameter, public ip address
1594  */
1595 struct ipa_ioc_v4_nat_del {
1596 	uint8_t table_index;
1597 	uint32_t public_ip_addr;
1598 };
1599 
1600 /**
1601  * struct ipa_ioc_nat_ipv6ct_table_del - NAT/IPv6CT table delete parameter
1602  * @table_index: input parameter, index of the table
1603  */
1604 struct ipa_ioc_nat_ipv6ct_table_del {
1605 	uint8_t table_index;
1606 };
1607 
1608 /**
1609  * struct ipa_ioc_nat_dma_one - nat/ipv6ct dma command parameter
1610  * @table_index: input parameter, index of the table
1611  * @base_addr:	type of table, from which the base address of the table
1612  *		can be inferred
1613  * @offset: destination offset within the NAT table
1614  * @data: data to be written.
1615  */
1616 struct ipa_ioc_nat_dma_one {
1617 	uint8_t table_index;
1618 	uint8_t base_addr;
1619 
1620 	uint32_t offset;
1621 	uint16_t data;
1622 
1623 };
1624 
1625 /**
1626  * struct ipa_ioc_nat_dma_cmd - To hold multiple nat/ipv6ct dma commands
1627  * @entries: number of dma commands in use
1628  * @dma: data pointer to the dma commands
1629  */
1630 struct ipa_ioc_nat_dma_cmd {
1631 	uint8_t entries;
1632 	struct ipa_ioc_nat_dma_one dma[0];
1633 
1634 };
1635 
1636 /**
1637  * struct ipa_ioc_nat_pdn_entry - PDN entry modification data
1638  * @pdn_index: index of the entry in the PDN config table to be changed
1639  * @public_ip: PDN's public ip
1640  * @src_metadata: PDN's source NAT metadata for metadata replacement
1641  * @dst_metadata: PDN's destination NAT metadata for metadata replacement
1642  */
1643 struct ipa_ioc_nat_pdn_entry {
1644 	uint8_t pdn_index;
1645 	uint32_t public_ip;
1646 	uint32_t src_metadata;
1647 	uint32_t dst_metadata;
1648 };
1649 
1650 /**
1651  * struct ipa_ioc_vlan_iface_info - add vlan interface
1652  * @name: interface name
1653  * @vlan_id: VLAN ID
1654  */
1655 struct ipa_ioc_vlan_iface_info {
1656 	char name[IPA_RESOURCE_NAME_MAX];
1657 	uint8_t vlan_id;
1658 };
1659 
1660 /**
1661  * struct ipa_ioc_l2tp_vlan_mapping_info - l2tp->vlan mapping info
1662  * @iptype: l2tp tunnel IP type
1663  * @l2tp_iface_name: l2tp interface name
1664  * @l2tp_session_id: l2tp session id
1665  * @vlan_iface_name: vlan interface name
1666  */
1667 struct ipa_ioc_l2tp_vlan_mapping_info {
1668 	enum ipa_ip_type iptype;
1669 	char l2tp_iface_name[IPA_RESOURCE_NAME_MAX];
1670 	uint8_t l2tp_session_id;
1671 	char vlan_iface_name[IPA_RESOURCE_NAME_MAX];
1672 };
1673 
1674 /**
1675  * struct ipa_msg_meta - Format of the message meta-data.
1676  * @msg_type: the type of the message
1677  * @rsvd: reserved bits for future use.
1678  * @msg_len: the length of the message in bytes
1679  *
1680  * For push model:
1681  * Client in user-space should issue a read on the device (/dev/ipa) with a
1682  * sufficiently large buffer in a continuous loop, call will block when there is
1683  * no message to read. Upon return, client can read the ipa_msg_meta from start
1684  * of buffer to find out type and length of message
1685  * size of buffer supplied >= (size of largest message + size of metadata)
1686  *
1687  * For pull model:
1688  * Client in user-space can also issue a pull msg IOCTL to device (/dev/ipa)
1689  * with a payload containing space for the ipa_msg_meta and the message specific
1690  * payload length.
1691  * size of buffer supplied == (len of specific message  + size of metadata)
1692  */
1693 struct ipa_msg_meta {
1694 	uint8_t msg_type;
1695 	uint8_t rsvd;
1696 	uint16_t msg_len;
1697 };
1698 
1699 /**
1700  * struct ipa_wlan_msg - To hold information about wlan client
1701  * @name: name of the wlan interface
1702  * @mac_addr: mac address of wlan client
1703  *
1704  * wlan drivers need to pass name of wlan iface and mac address of
1705  * wlan client along with ipa_wlan_event, whenever a wlan client is
1706  * connected/disconnected/moved to power save/come out of power save
1707  */
1708 struct ipa_wlan_msg {
1709 	char name[IPA_RESOURCE_NAME_MAX];
1710 	uint8_t mac_addr[IPA_MAC_ADDR_SIZE];
1711 };
1712 
1713 /**
1714  * enum ipa_wlan_hdr_attrib_type - attribute type
1715  * in wlan client header
1716  *
1717  * WLAN_HDR_ATTRIB_MAC_ADDR: attrib type mac address
1718  * WLAN_HDR_ATTRIB_STA_ID: attrib type station id
1719  */
1720 enum ipa_wlan_hdr_attrib_type {
1721 	WLAN_HDR_ATTRIB_MAC_ADDR,
1722 	WLAN_HDR_ATTRIB_STA_ID
1723 };
1724 
1725 /**
1726  * struct ipa_wlan_hdr_attrib_val - header attribute value
1727  * @attrib_type: type of attribute
1728  * @offset: offset of attribute within header
1729  * @u.mac_addr: mac address
1730  * @u.sta_id: station id
1731  */
1732 struct ipa_wlan_hdr_attrib_val {
1733 	enum ipa_wlan_hdr_attrib_type attrib_type;
1734 	uint8_t offset;
1735 	union {
1736 		uint8_t mac_addr[IPA_MAC_ADDR_SIZE];
1737 		uint8_t sta_id;
1738 	} u;
1739 };
1740 
1741 /**
1742  * struct ipa_wlan_msg_ex - To hold information about wlan client
1743  * @name: name of the wlan interface
1744  * @num_of_attribs: number of attributes
1745  * @attrib_val: holds attribute values
1746  *
1747  * wlan drivers need to pass name of wlan iface and mac address
1748  * of wlan client or station id along with ipa_wlan_event,
1749  * whenever a wlan client is connected/disconnected/moved to
1750  * power save/come out of power save
1751  */
1752 struct ipa_wlan_msg_ex {
1753 	char name[IPA_RESOURCE_NAME_MAX];
1754 	uint8_t num_of_attribs;
1755 	struct ipa_wlan_hdr_attrib_val attribs[0];
1756 };
1757 
1758 struct ipa_ecm_msg {
1759 	char name[IPA_RESOURCE_NAME_MAX];
1760 	int ifindex;
1761 };
1762 
1763 /**
1764  * struct ipa_wan_msg - To hold information about wan client
1765  * @name: name of the wan interface
1766  *
1767  * CnE need to pass the name of default wan iface when connected/disconnected.
1768  * CNE need to pass the gw info in wlan AP+STA mode.
1769  * netmgr need to pass the name of wan eMBMS iface when connected.
1770  */
1771 struct ipa_wan_msg {
1772 	char upstream_ifname[IPA_RESOURCE_NAME_MAX];
1773 	char tethered_ifname[IPA_RESOURCE_NAME_MAX];
1774 	enum ipa_ip_type ip;
1775 	uint32_t ipv4_addr_gw;
1776 	uint32_t ipv6_addr_gw[IPA_WAN_MSG_IPv6_ADDR_GW_LEN];
1777 };
1778 
1779 /**
1780  * struct ipa_ioc_rm_dependency - parameters for add/delete dependency
1781  * @resource_name: name of dependent resource
1782  * @depends_on_name: name of its dependency
1783  */
1784 struct ipa_ioc_rm_dependency {
1785 	enum ipa_rm_resource_name resource_name;
1786 	enum ipa_rm_resource_name depends_on_name;
1787 };
1788 
1789 struct ipa_ioc_generate_flt_eq {
1790 	enum ipa_ip_type ip;
1791 	struct ipa_rule_attrib attrib;
1792 	struct ipa_ipfltri_rule_eq eq_attrib;
1793 };
1794 
1795 /**
1796  * struct ipa_ioc_write_qmapid - to write mux id to endpoint meta register
1797  * @mux_id: mux id of wan
1798  */
1799 struct ipa_ioc_write_qmapid {
1800 	enum ipa_client_type client;
1801 	uint8_t qmap_id;
1802 };
1803 
1804 enum ipacm_client_enum {
1805 	IPACM_CLIENT_USB = 1,
1806 	IPACM_CLIENT_WLAN,
1807 	IPACM_CLIENT_MAX
1808 };
1809 
1810 enum ipacm_per_client_device_type {
1811 	IPACM_CLIENT_DEVICE_TYPE_USB = 0,
1812 	IPACM_CLIENT_DEVICE_TYPE_WLAN = 1,
1813 	IPACM_CLIENT_DEVICE_TYPE_ETH = 2
1814 };
1815 
1816 /**
1817  * max number of device types supported.
1818  */
1819 #define IPACM_MAX_CLIENT_DEVICE_TYPES 3
1820 
1821 /**
1822  * @lanIface - Name of the lan interface
1823  * @mac: Mac address of the client.
1824  */
1825 struct ipa_lan_client_msg {
1826 	char lanIface[IPA_RESOURCE_NAME_MAX];
1827 	uint8_t mac[IPA_MAC_ADDR_SIZE];
1828 };
1829 
1830 /**
1831  * struct ipa_lan_client - lan client data
1832  * @mac: MAC Address of the client.
1833  * @client_idx: Client Index.
1834  * @inited: Bool to indicate whether client info is set.
1835  */
1836 struct ipa_lan_client {
1837 	uint8_t mac[IPA_MAC_ADDR_SIZE];
1838 	int8_t client_idx;
1839 	uint8_t inited;
1840 };
1841 
1842 /**
1843  * struct ipa_tether_device_info - tether device info indicated from IPACM
1844  * @ul_src_pipe: Source pipe of the lan client.
1845  * @hdr_len: Header length of the client.
1846  * @num_clients: Number of clients connected.
1847  */
1848 struct ipa_tether_device_info {
1849 	int32_t ul_src_pipe;
1850 	uint8_t hdr_len;
1851 	uint32_t num_clients;
1852 	struct ipa_lan_client lan_client[IPA_MAX_NUM_HW_PATH_CLIENTS];
1853 };
1854 
1855 /**
1856  * enum ipa_vlan_ifaces - vlan interfaces types
1857  */
1858 enum ipa_vlan_ifaces {
1859 	IPA_VLAN_IF_ETH,
1860 	IPA_VLAN_IF_RNDIS,
1861 	IPA_VLAN_IF_ECM
1862 };
1863 
1864 #define IPA_VLAN_IF_EMAC IPA_VLAN_IF_ETH
1865 #define IPA_VLAN_IF_MAX (IPA_VLAN_IF_ECM + 1)
1866 
1867 /**
1868  * struct ipa_get_vlan_mode - get vlan mode of a Lan interface
1869  * @iface: Lan interface type to be queried.
1870  * @is_vlan_mode: output parameter, is interface in vlan mode, valid only when
1871  *		ioctl return val is non-negative
1872  */
1873 struct ipa_ioc_get_vlan_mode {
1874 	enum ipa_vlan_ifaces iface;
1875 	uint32_t is_vlan_mode;
1876 };
1877 
1878 /**
1879  *   actual IOCTLs supported by IPA driver
1880  */
1881 #define IPA_IOC_ADD_HDR _IOWR(IPA_IOC_MAGIC, \
1882 					IPA_IOCTL_ADD_HDR, \
1883 					struct ipa_ioc_add_hdr *)
1884 #define IPA_IOC_DEL_HDR _IOWR(IPA_IOC_MAGIC, \
1885 					IPA_IOCTL_DEL_HDR, \
1886 					struct ipa_ioc_del_hdr *)
1887 #define IPA_IOC_ADD_RT_RULE _IOWR(IPA_IOC_MAGIC, \
1888 					IPA_IOCTL_ADD_RT_RULE, \
1889 					struct ipa_ioc_add_rt_rule *)
1890 #define IPA_IOC_ADD_RT_RULE_EXT _IOWR(IPA_IOC_MAGIC, \
1891 					IPA_IOCTL_ADD_RT_RULE_EXT, \
1892 					struct ipa_ioc_add_rt_rule_ext *)
1893 #define IPA_IOC_ADD_RT_RULE_AFTER _IOWR(IPA_IOC_MAGIC, \
1894 					IPA_IOCTL_ADD_RT_RULE_AFTER, \
1895 					struct ipa_ioc_add_rt_rule_after *)
1896 #define IPA_IOC_DEL_RT_RULE _IOWR(IPA_IOC_MAGIC, \
1897 					IPA_IOCTL_DEL_RT_RULE, \
1898 					struct ipa_ioc_del_rt_rule *)
1899 #define IPA_IOC_ADD_FLT_RULE _IOWR(IPA_IOC_MAGIC, \
1900 					IPA_IOCTL_ADD_FLT_RULE, \
1901 					struct ipa_ioc_add_flt_rule *)
1902 #define IPA_IOC_ADD_FLT_RULE_AFTER _IOWR(IPA_IOC_MAGIC, \
1903 					IPA_IOCTL_ADD_FLT_RULE_AFTER, \
1904 					struct ipa_ioc_add_flt_rule_after *)
1905 #define IPA_IOC_DEL_FLT_RULE _IOWR(IPA_IOC_MAGIC, \
1906 					IPA_IOCTL_DEL_FLT_RULE, \
1907 					struct ipa_ioc_del_flt_rule *)
1908 #define IPA_IOC_COMMIT_HDR _IO(IPA_IOC_MAGIC,\
1909 					IPA_IOCTL_COMMIT_HDR)
1910 #define IPA_IOC_RESET_HDR _IO(IPA_IOC_MAGIC,\
1911 					IPA_IOCTL_RESET_HDR)
1912 #define IPA_IOC_COMMIT_RT _IOW(IPA_IOC_MAGIC, \
1913 					IPA_IOCTL_COMMIT_RT, \
1914 					enum ipa_ip_type)
1915 #define IPA_IOC_RESET_RT _IOW(IPA_IOC_MAGIC, \
1916 					IPA_IOCTL_RESET_RT, \
1917 					enum ipa_ip_type)
1918 #define IPA_IOC_COMMIT_FLT _IOW(IPA_IOC_MAGIC, \
1919 					IPA_IOCTL_COMMIT_FLT, \
1920 					enum ipa_ip_type)
1921 #define IPA_IOC_RESET_FLT _IOW(IPA_IOC_MAGIC, \
1922 			IPA_IOCTL_RESET_FLT, \
1923 			enum ipa_ip_type)
1924 #define IPA_IOC_DUMP _IO(IPA_IOC_MAGIC, \
1925 			IPA_IOCTL_DUMP)
1926 #define IPA_IOC_GET_RT_TBL _IOWR(IPA_IOC_MAGIC, \
1927 				IPA_IOCTL_GET_RT_TBL, \
1928 				struct ipa_ioc_get_rt_tbl *)
1929 #define IPA_IOC_PUT_RT_TBL _IOW(IPA_IOC_MAGIC, \
1930 				IPA_IOCTL_PUT_RT_TBL, \
1931 				uint32_t)
1932 #define IPA_IOC_COPY_HDR _IOWR(IPA_IOC_MAGIC, \
1933 				IPA_IOCTL_COPY_HDR, \
1934 				struct ipa_ioc_copy_hdr *)
1935 #define IPA_IOC_QUERY_INTF _IOWR(IPA_IOC_MAGIC, \
1936 				IPA_IOCTL_QUERY_INTF, \
1937 				struct ipa_ioc_query_intf *)
1938 #define IPA_IOC_QUERY_INTF_TX_PROPS _IOWR(IPA_IOC_MAGIC, \
1939 				IPA_IOCTL_QUERY_INTF_TX_PROPS, \
1940 				struct ipa_ioc_query_intf_tx_props *)
1941 #define IPA_IOC_QUERY_INTF_RX_PROPS _IOWR(IPA_IOC_MAGIC, \
1942 					IPA_IOCTL_QUERY_INTF_RX_PROPS, \
1943 					struct ipa_ioc_query_intf_rx_props *)
1944 #define IPA_IOC_QUERY_INTF_EXT_PROPS _IOWR(IPA_IOC_MAGIC, \
1945 					IPA_IOCTL_QUERY_INTF_EXT_PROPS, \
1946 					struct ipa_ioc_query_intf_ext_props *)
1947 #define IPA_IOC_GET_HDR _IOWR(IPA_IOC_MAGIC, \
1948 				IPA_IOCTL_GET_HDR, \
1949 				struct ipa_ioc_get_hdr *)
1950 #define IPA_IOC_PUT_HDR _IOW(IPA_IOC_MAGIC, \
1951 				IPA_IOCTL_PUT_HDR, \
1952 				uint32_t)
1953 #define IPA_IOC_ALLOC_NAT_MEM _IOWR(IPA_IOC_MAGIC, \
1954 				IPA_IOCTL_ALLOC_NAT_MEM, \
1955 				struct ipa_ioc_nat_alloc_mem *)
1956 #define IPA_IOC_ALLOC_NAT_TABLE _IOWR(IPA_IOC_MAGIC, \
1957 				IPA_IOCTL_ALLOC_NAT_TABLE, \
1958 				struct ipa_ioc_nat_ipv6ct_table_alloc *)
1959 #define IPA_IOC_ALLOC_IPV6CT_TABLE _IOWR(IPA_IOC_MAGIC, \
1960 				IPA_IOCTL_ALLOC_IPV6CT_TABLE, \
1961 				struct ipa_ioc_nat_ipv6ct_table_alloc *)
1962 #define IPA_IOC_V4_INIT_NAT _IOWR(IPA_IOC_MAGIC, \
1963 				IPA_IOCTL_V4_INIT_NAT, \
1964 				struct ipa_ioc_v4_nat_init *)
1965 #define IPA_IOC_INIT_IPV6CT_TABLE _IOWR(IPA_IOC_MAGIC, \
1966 				IPA_IOCTL_INIT_IPV6CT_TABLE, \
1967 				struct ipa_ioc_ipv6ct_init *)
1968 #define IPA_IOC_NAT_DMA _IOWR(IPA_IOC_MAGIC, \
1969 				IPA_IOCTL_NAT_DMA, \
1970 				struct ipa_ioc_nat_dma_cmd *)
1971 #define IPA_IOC_TABLE_DMA_CMD _IOWR(IPA_IOC_MAGIC, \
1972 				IPA_IOCTL_TABLE_DMA_CMD, \
1973 				struct ipa_ioc_nat_dma_cmd *)
1974 #define IPA_IOC_V4_DEL_NAT _IOWR(IPA_IOC_MAGIC, \
1975 				IPA_IOCTL_V4_DEL_NAT, \
1976 				struct ipa_ioc_v4_nat_del *)
1977 #define IPA_IOC_DEL_NAT_TABLE _IOWR(IPA_IOC_MAGIC, \
1978 				IPA_IOCTL_DEL_NAT_TABLE, \
1979 				struct ipa_ioc_nat_ipv6ct_table_del *)
1980 #define IPA_IOC_DEL_IPV6CT_TABLE _IOWR(IPA_IOC_MAGIC, \
1981 				IPA_IOCTL_DEL_IPV6CT_TABLE, \
1982 				struct ipa_ioc_nat_ipv6ct_table_del *)
1983 #define IPA_IOC_GET_NAT_OFFSET _IOWR(IPA_IOC_MAGIC, \
1984 				IPA_IOCTL_GET_NAT_OFFSET, \
1985 				uint32_t *)
1986 #define IPA_IOC_NAT_MODIFY_PDN _IOWR(IPA_IOC_MAGIC, \
1987 				IPA_IOCTL_NAT_MODIFY_PDN, \
1988 				struct ipa_ioc_nat_pdn_entry *)
1989 #define IPA_IOC_SET_FLT _IOW(IPA_IOC_MAGIC, \
1990 			IPA_IOCTL_SET_FLT, \
1991 			uint32_t)
1992 #define IPA_IOC_PULL_MSG _IOWR(IPA_IOC_MAGIC, \
1993 				IPA_IOCTL_PULL_MSG, \
1994 				struct ipa_msg_meta *)
1995 #define IPA_IOC_RM_ADD_DEPENDENCY _IOWR(IPA_IOC_MAGIC, \
1996 				IPA_IOCTL_RM_ADD_DEPENDENCY, \
1997 				struct ipa_ioc_rm_dependency *)
1998 #define IPA_IOC_RM_DEL_DEPENDENCY _IOWR(IPA_IOC_MAGIC, \
1999 				IPA_IOCTL_RM_DEL_DEPENDENCY, \
2000 				struct ipa_ioc_rm_dependency *)
2001 #define IPA_IOC_GENERATE_FLT_EQ _IOWR(IPA_IOC_MAGIC, \
2002 				IPA_IOCTL_GENERATE_FLT_EQ, \
2003 				struct ipa_ioc_generate_flt_eq *)
2004 #define IPA_IOC_QUERY_EP_MAPPING _IOR(IPA_IOC_MAGIC, \
2005 				IPA_IOCTL_QUERY_EP_MAPPING, \
2006 				uint32_t)
2007 #define IPA_IOC_QUERY_RT_TBL_INDEX _IOWR(IPA_IOC_MAGIC, \
2008 				IPA_IOCTL_QUERY_RT_TBL_INDEX, \
2009 				struct ipa_ioc_get_rt_tbl_indx *)
2010 #define IPA_IOC_WRITE_QMAPID  _IOWR(IPA_IOC_MAGIC, \
2011 				IPA_IOCTL_WRITE_QMAPID, \
2012 				struct ipa_ioc_write_qmapid *)
2013 #define IPA_IOC_MDFY_FLT_RULE _IOWR(IPA_IOC_MAGIC, \
2014 					IPA_IOCTL_MDFY_FLT_RULE, \
2015 					struct ipa_ioc_mdfy_flt_rule *)
2016 #define IPA_IOC_MDFY_RT_RULE _IOWR(IPA_IOC_MAGIC, \
2017 					IPA_IOCTL_MDFY_RT_RULE, \
2018 					struct ipa_ioc_mdfy_rt_rule *)
2019 
2020 #define IPA_IOC_NOTIFY_WAN_UPSTREAM_ROUTE_ADD _IOWR(IPA_IOC_MAGIC, \
2021 				IPA_IOCTL_NOTIFY_WAN_UPSTREAM_ROUTE_ADD, \
2022 				struct ipa_wan_msg *)
2023 
2024 #define IPA_IOC_NOTIFY_WAN_UPSTREAM_ROUTE_DEL _IOWR(IPA_IOC_MAGIC, \
2025 				IPA_IOCTL_NOTIFY_WAN_UPSTREAM_ROUTE_DEL, \
2026 				struct ipa_wan_msg *)
2027 #define IPA_IOC_NOTIFY_WAN_EMBMS_CONNECTED _IOWR(IPA_IOC_MAGIC, \
2028 				IPA_IOCTL_NOTIFY_WAN_EMBMS_CONNECTED, \
2029 				struct ipa_wan_msg *)
2030 #define IPA_IOC_ADD_HDR_PROC_CTX _IOWR(IPA_IOC_MAGIC, \
2031 				IPA_IOCTL_ADD_HDR_PROC_CTX, \
2032 				struct ipa_ioc_add_hdr_proc_ctx *)
2033 #define IPA_IOC_DEL_HDR_PROC_CTX _IOWR(IPA_IOC_MAGIC, \
2034 				IPA_IOCTL_DEL_HDR_PROC_CTX, \
2035 				struct ipa_ioc_del_hdr_proc_ctx *)
2036 
2037 #define IPA_IOC_GET_HW_VERSION _IOWR(IPA_IOC_MAGIC, \
2038 				IPA_IOCTL_GET_HW_VERSION, \
2039 				enum ipa_hw_type *)
2040 
2041 #define IPA_IOC_ADD_VLAN_IFACE _IOWR(IPA_IOC_MAGIC, \
2042 				IPA_IOCTL_ADD_VLAN_IFACE, \
2043 				struct ipa_ioc_vlan_iface_info *)
2044 
2045 #define IPA_IOC_DEL_VLAN_IFACE _IOWR(IPA_IOC_MAGIC, \
2046 				IPA_IOCTL_DEL_VLAN_IFACE, \
2047 				struct ipa_ioc_vlan_iface_info *)
2048 
2049 #define IPA_IOC_ADD_L2TP_VLAN_MAPPING _IOWR(IPA_IOC_MAGIC, \
2050 				IPA_IOCTL_ADD_L2TP_VLAN_MAPPING, \
2051 				struct ipa_ioc_l2tp_vlan_mapping_info *)
2052 
2053 #define IPA_IOC_DEL_L2TP_VLAN_MAPPING _IOWR(IPA_IOC_MAGIC, \
2054 				IPA_IOCTL_DEL_L2TP_VLAN_MAPPING, \
2055 				struct ipa_ioc_l2tp_vlan_mapping_info *)
2056 #define IPA_IOC_CLEANUP _IO(IPA_IOC_MAGIC,\
2057 					IPA_IOCTL_CLEANUP)
2058 #define IPA_IOC_QUERY_WLAN_CLIENT _IO(IPA_IOC_MAGIC,\
2059 					IPA_IOCTL_QUERY_WLAN_CLIENT)
2060 #define IPA_IOC_GET_VLAN_MODE _IOWR(IPA_IOC_MAGIC, \
2061 				IPA_IOCTL_GET_VLAN_MODE, \
2062 				struct ipa_ioc_get_vlan_mode *)
2063 /*
2064  * unique magic number of the Tethering bridge ioctls
2065  */
2066 #define TETH_BRIDGE_IOC_MAGIC 0xCE
2067 
2068 /*
2069  * Ioctls supported by Tethering bridge driver
2070  */
2071 #define TETH_BRIDGE_IOCTL_SET_BRIDGE_MODE	0
2072 #define TETH_BRIDGE_IOCTL_SET_AGGR_PARAMS	1
2073 #define TETH_BRIDGE_IOCTL_GET_AGGR_PARAMS	2
2074 #define TETH_BRIDGE_IOCTL_GET_AGGR_CAPABILITIES	3
2075 #define TETH_BRIDGE_IOCTL_MAX			4
2076 
2077 
2078 /**
2079  * enum teth_link_protocol_type - link protocol (IP / Ethernet)
2080  */
2081 enum teth_link_protocol_type {
2082 	TETH_LINK_PROTOCOL_IP,
2083 	TETH_LINK_PROTOCOL_ETHERNET,
2084 	TETH_LINK_PROTOCOL_MAX,
2085 };
2086 
2087 /**
2088  * enum teth_aggr_protocol_type - Aggregation protocol (MBIM / TLP)
2089  */
2090 enum teth_aggr_protocol_type {
2091 	TETH_AGGR_PROTOCOL_NONE,
2092 	TETH_AGGR_PROTOCOL_MBIM,
2093 	TETH_AGGR_PROTOCOL_TLP,
2094 	TETH_AGGR_PROTOCOL_MAX,
2095 };
2096 
2097 /**
2098  * struct teth_aggr_params_link - Aggregation parameters for uplink/downlink
2099  * @aggr_prot:			Aggregation protocol (MBIM / TLP)
2100  * @max_transfer_size_byte:	Maximal size of aggregated packet in bytes.
2101  *				Default value is 16*1024.
2102  * @max_datagrams:		Maximal number of IP packets in an aggregated
2103  *				packet. Default value is 16
2104  */
2105 struct teth_aggr_params_link {
2106 	enum teth_aggr_protocol_type aggr_prot;
2107 	uint32_t max_transfer_size_byte;
2108 	uint32_t max_datagrams;
2109 };
2110 
2111 
2112 /**
2113  * struct teth_aggr_params - Aggregation parmeters
2114  * @ul:	Uplink parameters
2115  * @dl: Downlink parmaeters
2116  */
2117 struct teth_aggr_params {
2118 	struct teth_aggr_params_link ul;
2119 	struct teth_aggr_params_link dl;
2120 };
2121 
2122 /**
2123  * struct teth_aggr_capabilities - Aggregation capabilities
2124  * @num_protocols:		Number of protocols described in the array
2125  * @prot_caps[]:		Array of aggregation capabilities per protocol
2126  */
2127 struct teth_aggr_capabilities {
2128 	uint16_t num_protocols;
2129 	struct teth_aggr_params_link prot_caps[0];
2130 };
2131 
2132 /**
2133  * struct teth_ioc_set_bridge_mode
2134  * @link_protocol: link protocol (IP / Ethernet)
2135  * @lcid: logical channel number
2136  */
2137 struct teth_ioc_set_bridge_mode {
2138 	enum teth_link_protocol_type link_protocol;
2139 	uint16_t lcid;
2140 };
2141 
2142 /**
2143  * struct teth_ioc_set_aggr_params
2144  * @aggr_params: Aggregation parmeters
2145  * @lcid: logical channel number
2146  */
2147 struct teth_ioc_aggr_params {
2148 	struct teth_aggr_params aggr_params;
2149 	uint16_t lcid;
2150 };
2151 
2152 
2153 #define TETH_BRIDGE_IOC_SET_BRIDGE_MODE _IOW(TETH_BRIDGE_IOC_MAGIC, \
2154 				TETH_BRIDGE_IOCTL_SET_BRIDGE_MODE, \
2155 				struct teth_ioc_set_bridge_mode *)
2156 #define TETH_BRIDGE_IOC_SET_AGGR_PARAMS _IOW(TETH_BRIDGE_IOC_MAGIC, \
2157 				TETH_BRIDGE_IOCTL_SET_AGGR_PARAMS, \
2158 				struct teth_ioc_aggr_params *)
2159 #define TETH_BRIDGE_IOC_GET_AGGR_PARAMS _IOR(TETH_BRIDGE_IOC_MAGIC, \
2160 				TETH_BRIDGE_IOCTL_GET_AGGR_PARAMS, \
2161 				struct teth_ioc_aggr_params *)
2162 #define TETH_BRIDGE_IOC_GET_AGGR_CAPABILITIES _IOWR(TETH_BRIDGE_IOC_MAGIC, \
2163 				TETH_BRIDGE_IOCTL_GET_AGGR_CAPABILITIES, \
2164 				struct teth_aggr_capabilities *)
2165 
2166 /*
2167  * unique magic number of the ODU bridge ioctls
2168  */
2169 #define ODU_BRIDGE_IOC_MAGIC 0xCD
2170 
2171 /*
2172  * Ioctls supported by ODU bridge driver
2173  */
2174 #define ODU_BRIDGE_IOCTL_SET_MODE	0
2175 #define ODU_BRIDGE_IOCTL_SET_LLV6_ADDR	1
2176 #define ODU_BRIDGE_IOCTL_MAX		2
2177 
2178 /**
2179  * enum odu_bridge_mode - bridge mode
2180  *			(ROUTER MODE / BRIDGE MODE)
2181  */
2182 enum odu_bridge_mode {
2183 	ODU_BRIDGE_MODE_ROUTER,
2184 	ODU_BRIDGE_MODE_BRIDGE,
2185 	ODU_BRIDGE_MODE_MAX,
2186 };
2187 
2188 #define ODU_BRIDGE_IOC_SET_MODE _IOW(ODU_BRIDGE_IOC_MAGIC, \
2189 				ODU_BRIDGE_IOCTL_SET_MODE, \
2190 				enum odu_bridge_mode)
2191 
2192 #define ODU_BRIDGE_IOC_SET_LLV6_ADDR _IOW(ODU_BRIDGE_IOC_MAGIC, \
2193 				ODU_BRIDGE_IOCTL_SET_LLV6_ADDR, \
2194 				struct in6_addr *)
2195 
2196 #endif /* _MSM_IPA_H_ */
2197