blob: 5151654b9a576af2b3a55b2a1496d64f3a52c0bf [file] [log] [blame]
Talel Atias8390f262012-11-15 16:33:18 +02001#ifndef _MSM_IPA_H_
2#define _MSM_IPA_H_
3
4#ifndef __KERNEL__
5#include <stdint.h>
6#include <stddef.h>
7#include <sys/stat.h>
8#endif
9#include <linux/ioctl.h>
10
11/**
12 * unique magic number of the IPA device
13 */
14#define IPA_IOC_MAGIC 0xCF
15
16/**
17 * name of the default routing tables for v4 and v6
18 */
19#define IPA_DFLT_RT_TBL_NAME "ipa_dflt_rt"
20
21/**
22 * the commands supported by IPA driver
23 */
24#define IPA_IOCTL_ADD_HDR 0
25#define IPA_IOCTL_DEL_HDR 1
26#define IPA_IOCTL_ADD_RT_RULE 2
27#define IPA_IOCTL_DEL_RT_RULE 3
28#define IPA_IOCTL_ADD_FLT_RULE 4
29#define IPA_IOCTL_DEL_FLT_RULE 5
30#define IPA_IOCTL_COMMIT_HDR 6
31#define IPA_IOCTL_RESET_HDR 7
32#define IPA_IOCTL_COMMIT_RT 8
33#define IPA_IOCTL_RESET_RT 9
34#define IPA_IOCTL_COMMIT_FLT 10
35#define IPA_IOCTL_RESET_FLT 11
36#define IPA_IOCTL_DUMP 12
37#define IPA_IOCTL_GET_RT_TBL 13
38#define IPA_IOCTL_PUT_RT_TBL 14
39#define IPA_IOCTL_COPY_HDR 15
40#define IPA_IOCTL_QUERY_INTF 16
41#define IPA_IOCTL_QUERY_INTF_TX_PROPS 17
42#define IPA_IOCTL_QUERY_INTF_RX_PROPS 18
43#define IPA_IOCTL_GET_HDR 19
44#define IPA_IOCTL_PUT_HDR 20
45#define IPA_IOCTL_SET_FLT 21
46#define IPA_IOCTL_ALLOC_NAT_MEM 22
47#define IPA_IOCTL_V4_INIT_NAT 23
48#define IPA_IOCTL_NAT_DMA 24
49#define IPA_IOCTL_V4_DEL_NAT 26
Talel Atias9bc53892013-02-10 15:10:07 +020050#define IPA_IOCTL_PULL_MSG 27
Talel Atias8390f262012-11-15 16:33:18 +020051#define IPA_IOCTL_GET_NAT_OFFSET 28
Vladislav Mordohovichc76217e2013-03-10 17:45:05 +020052#define IPA_IOCTL_RM_ADD_DEPENDENCY 29
53#define IPA_IOCTL_RM_DEL_DEPENDENCY 30
54#define IPA_IOCTL_MAX 31
Talel Atias8390f262012-11-15 16:33:18 +020055
56/**
57 * max size of the header to be inserted
58 */
59#define IPA_HDR_MAX_SIZE 64
60
61/**
62 * max size of the name of the resource (routing table, header)
63 */
64#define IPA_RESOURCE_NAME_MAX 20
65
66/**
Talel Atias9bc53892013-02-10 15:10:07 +020067 * size of the mac address
68 */
69#define IPA_MAC_ADDR_SIZE 6
70
71/**
Talel Atias8390f262012-11-15 16:33:18 +020072 * the attributes of the rule (routing or filtering)
73 */
74#define IPA_FLT_TOS (1ul << 0)
75#define IPA_FLT_PROTOCOL (1ul << 1)
76#define IPA_FLT_SRC_ADDR (1ul << 2)
77#define IPA_FLT_DST_ADDR (1ul << 3)
78#define IPA_FLT_SRC_PORT_RANGE (1ul << 4)
79#define IPA_FLT_DST_PORT_RANGE (1ul << 5)
80#define IPA_FLT_TYPE (1ul << 6)
81#define IPA_FLT_CODE (1ul << 7)
82#define IPA_FLT_SPI (1ul << 8)
83#define IPA_FLT_SRC_PORT (1ul << 9)
84#define IPA_FLT_DST_PORT (1ul << 10)
85#define IPA_FLT_TC (1ul << 11)
86#define IPA_FLT_FLOW_LABEL (1ul << 12)
87#define IPA_FLT_NEXT_HDR (1ul << 13)
88#define IPA_FLT_META_DATA (1ul << 14)
89#define IPA_FLT_FRAGMENT (1ul << 15)
90
91/**
92 * enum ipa_client_type - names for the various IPA "clients"
93 * these are from the perspective of the clients, for e.g.
94 * HSIC1_PROD means HSIC client is the producer and IPA is the
95 * consumer
96 */
97enum ipa_client_type {
98 IPA_CLIENT_PROD,
99 IPA_CLIENT_HSIC1_PROD = IPA_CLIENT_PROD,
100 IPA_CLIENT_HSIC2_PROD,
101 IPA_CLIENT_HSIC3_PROD,
102 IPA_CLIENT_HSIC4_PROD,
103 IPA_CLIENT_HSIC5_PROD,
104 IPA_CLIENT_USB_PROD,
105 IPA_CLIENT_A5_WLAN_AMPDU_PROD,
106 IPA_CLIENT_A2_EMBEDDED_PROD,
107 IPA_CLIENT_A2_TETHERED_PROD,
108 IPA_CLIENT_A5_LAN_WAN_PROD,
109 IPA_CLIENT_A5_CMD_PROD,
110 IPA_CLIENT_Q6_LAN_PROD,
111
112 IPA_CLIENT_CONS,
113 IPA_CLIENT_HSIC1_CONS = IPA_CLIENT_CONS,
114 IPA_CLIENT_HSIC2_CONS,
115 IPA_CLIENT_HSIC3_CONS,
116 IPA_CLIENT_HSIC4_CONS,
117 IPA_CLIENT_HSIC5_CONS,
118 IPA_CLIENT_USB_CONS,
119 IPA_CLIENT_A2_EMBEDDED_CONS,
120 IPA_CLIENT_A2_TETHERED_CONS,
121 IPA_CLIENT_A5_LAN_WAN_CONS,
122 IPA_CLIENT_Q6_LAN_CONS,
123
124 IPA_CLIENT_MAX,
125};
126
127/**
128 * enum ipa_ip_type - Address family: IPv4 or IPv6
129 */
130enum ipa_ip_type {
131 IPA_IP_v4,
132 IPA_IP_v6,
133 IPA_IP_MAX
134};
135
136/**
137 * enum ipa_flt_action - action field of filtering rule
138 *
139 * Pass to routing: 5'd0
140 * Pass to source NAT: 5'd1
141 * Pass to destination NAT: 5'd2
142 * Pass to default output pipe (e.g., A5): 5'd3
143 */
144enum ipa_flt_action {
145 IPA_PASS_TO_ROUTING,
146 IPA_PASS_TO_SRC_NAT,
147 IPA_PASS_TO_DST_NAT,
148 IPA_PASS_TO_EXCEPTION
149};
150
151/**
Talel Atias9bc53892013-02-10 15:10:07 +0200152 * enum ipa_wlan_event - Events for wlan client
153 *
154 * wlan client connect: New wlan client connected
155 * wlan client disconnect: wlan client disconnected
156 * wlan client power save: wlan client moved to power save
157 * wlan client normal: wlan client moved out of power save
158 * sw routing enable: ipa routing is disabled
159 * sw routing disable: ipa routing is enabled
Ravi Gummadidala16f65812013-03-04 16:35:54 -0800160 * wlan ap connect: wlan AP(access point) is up
161 * wlan ap disconnect: wlan AP(access point) is down
162 * wlan sta connect: wlan STA(station) is up
163 * wlan sta disconnect: wlan STA(station) is down
Talel Atias9bc53892013-02-10 15:10:07 +0200164 */
165enum ipa_wlan_event {
166 WLAN_CLIENT_CONNECT,
167 WLAN_CLIENT_DISCONNECT,
168 WLAN_CLIENT_POWER_SAVE_MODE,
169 WLAN_CLIENT_NORMAL_MODE,
170 SW_ROUTING_ENABLE,
171 SW_ROUTING_DISABLE,
Ravi Gummadidala16f65812013-03-04 16:35:54 -0800172 WLAN_AP_CONNECT,
173 WLAN_AP_DISCONNECT,
174 WLAN_STA_CONNECT,
175 WLAN_STA_DISCONNECT,
Ravi Gummadidala43946232013-03-18 14:44:47 -0700176 IPA_EVENT_MAX
Talel Atias9bc53892013-02-10 15:10:07 +0200177};
178
Vladislav Mordohovichc76217e2013-03-10 17:45:05 +0200179/**
180 * enum ipa_rm_resource_name - IPA RM clients identification names
181 *
182 * Add new mapping to ipa_rm_dep_prod_index() / ipa_rm_dep_cons_index()
183 * when adding new entry to this enum.
184 */
185enum ipa_rm_resource_name {
186 IPA_RM_RESOURCE_PROD = 0,
187 IPA_RM_RESOURCE_BRIDGE_PROD = IPA_RM_RESOURCE_PROD,
188 IPA_RM_RESOURCE_A2_PROD,
189 IPA_RM_RESOURCE_USB_PROD,
190 IPA_RM_RESOURCE_HSIC_PROD,
191 IPA_RM_RESOURCE_STD_ECM_PROD,
192 IPA_RM_RESOURCE_WWAN_0_PROD,
193 IPA_RM_RESOURCE_WWAN_1_PROD,
194 IPA_RM_RESOURCE_WWAN_2_PROD,
195 IPA_RM_RESOURCE_WWAN_3_PROD,
196 IPA_RM_RESOURCE_WWAN_4_PROD,
197 IPA_RM_RESOURCE_WWAN_5_PROD,
198 IPA_RM_RESOURCE_WWAN_6_PROD,
199 IPA_RM_RESOURCE_WWAN_7_PROD,
200 IPA_RM_RESOURCE_WLAN_PROD,
201 IPA_RM_RESOURCE_PROD_MAX,
202
203 IPA_RM_RESOURCE_A2_CONS = IPA_RM_RESOURCE_PROD_MAX,
204 IPA_RM_RESOURCE_USB_CONS,
205 IPA_RM_RESOURCE_HSIC_CONS,
206 IPA_RM_RESOURCE_MAX
207};
Talel Atias9bc53892013-02-10 15:10:07 +0200208
209/**
Talel Atias8390f262012-11-15 16:33:18 +0200210 * struct ipa_rule_attrib - attributes of a routing/filtering
211 * rule, all in LE
212 * @attrib_mask: what attributes are valid
213 * @src_port_lo: low port of src port range
214 * @src_port_hi: high port of src port range
215 * @dst_port_lo: low port of dst port range
216 * @dst_port_hi: high port of dst port range
217 * @type: ICMP/IGMP type
218 * @code: ICMP/IGMP code
219 * @spi: IPSec SPI
220 * @src_port: exact src port
221 * @dst_port: exact dst port
222 * @meta_data: meta-data val
223 * @meta_data_mask: meta-data mask
224 * @u.v4.tos: type of service
225 * @u.v4.protocol: protocol
226 * @u.v4.src_addr: src address value
227 * @u.v4.src_addr_mask: src address mask
228 * @u.v4.dst_addr: dst address value
229 * @u.v4.dst_addr_mask: dst address mask
230 * @u.v6.tc: traffic class
231 * @u.v6.flow_label: flow label
232 * @u.v6.next_hdr: next header
233 * @u.v6.src_addr: src address val
234 * @u.v6.src_addr_mask: src address mask
235 * @u.v6.dst_addr: dst address val
236 * @u.v6.dst_addr_mask: dst address mask
237 */
238struct ipa_rule_attrib {
239 uint32_t attrib_mask;
240 uint16_t src_port_lo;
241 uint16_t src_port_hi;
242 uint16_t dst_port_lo;
243 uint16_t dst_port_hi;
244 uint8_t type;
245 uint8_t code;
246 uint32_t spi;
247 uint16_t src_port;
248 uint16_t dst_port;
249 uint32_t meta_data;
250 uint32_t meta_data_mask;
251 union {
252 struct {
253 uint8_t tos;
254 uint8_t protocol;
255 uint32_t src_addr;
256 uint32_t src_addr_mask;
257 uint32_t dst_addr;
258 uint32_t dst_addr_mask;
259 } v4;
260 struct {
261 uint8_t tc;
262 uint32_t flow_label;
263 uint8_t next_hdr;
264 uint32_t src_addr[4];
265 uint32_t src_addr_mask[4];
266 uint32_t dst_addr[4];
267 uint32_t dst_addr_mask[4];
268 } v6;
269 } u;
270};
271
272/**
273 * struct ipa_flt_rule - attributes of a filtering rule
274 * @action: action field
275 * @rt_tbl_hdl: handle of table from "get"
276 * @attrib: attributes of the rule
277 */
278struct ipa_flt_rule {
279 enum ipa_flt_action action;
280 uint32_t rt_tbl_hdl;
281 struct ipa_rule_attrib attrib;
282};
283
284/**
285 * struct ipa_rt_rule - attributes of a routing rule
286 * @dst: dst "client"
287 * @hdr_hdl: handle to the dynamic header
288 it is not an index or an offset
289 * @attrib: attributes of the rule
290 */
291struct ipa_rt_rule {
292 enum ipa_client_type dst;
293 uint32_t hdr_hdl;
294 struct ipa_rule_attrib attrib;
295};
296
297/**
298 * struct ipa_hdr_add - header descriptor includes in and out
299 * parameters
300 * @name: name of the header
301 * @hdr: actual header to be inserted
302 * @hdr_len: size of above header
303 * @is_partial: header not fully specified
304 * @hdr_hdl: out paramerer, handle to header, valid when status is 0
305 * @status: out paramerer, status of header add operation,
306 * 0 for success,
307 * -1 for failure
308 */
309struct ipa_hdr_add {
310 char name[IPA_RESOURCE_NAME_MAX];
311 uint8_t hdr[IPA_HDR_MAX_SIZE];
312 uint8_t hdr_len;
313 uint8_t is_partial;
314 uint32_t hdr_hdl;
315 int status;
316};
317
318/**
319 * struct ipa_ioc_add_hdr - header addition parameters (support
320 * multiple headers and commit)
321 * @commit: should headers be written to IPA HW also?
322 * @num_hdrs: num of headers that follow
323 * @ipa_hdr_add hdr: all headers need to go here back to
324 * back, no pointers
325 */
326struct ipa_ioc_add_hdr {
327 uint8_t commit;
328 uint8_t num_hdrs;
329 struct ipa_hdr_add hdr[0];
330};
331
332/**
333 * struct ipa_ioc_copy_hdr - retrieve a copy of the specified
334 * header - caller can then derive the complete header
335 * @name: name of the header resource
336 * @hdr: out parameter, contents of specified header,
337 * valid only when ioctl return val is non-negative
338 * @hdr_len: out parameter, size of above header
339 * valid only when ioctl return val is non-negative
340 * @is_partial: out parameter, indicates whether specified header is partial
341 * valid only when ioctl return val is non-negative
342 */
343struct ipa_ioc_copy_hdr {
344 char name[IPA_RESOURCE_NAME_MAX];
345 uint8_t hdr[IPA_HDR_MAX_SIZE];
346 uint8_t hdr_len;
347 uint8_t is_partial;
348};
349
350/**
351 * struct ipa_ioc_get_hdr - header entry lookup parameters, if lookup was
352 * successful caller must call put to release the reference count when done
353 * @name: name of the header resource
354 * @hdl: out parameter, handle of header entry
355 * valid only when ioctl return val is non-negative
356 */
357struct ipa_ioc_get_hdr {
358 char name[IPA_RESOURCE_NAME_MAX];
359 uint32_t hdl;
360};
361
362/**
363 * struct ipa_hdr_del - header descriptor includes in and out
364 * parameters
365 *
366 * @hdl: handle returned from header add operation
367 * @status: out parameter, status of header remove operation,
368 * 0 for success,
369 * -1 for failure
370 */
371struct ipa_hdr_del {
372 uint32_t hdl;
373 int status;
374};
375
376/**
377 * struct ipa_ioc_del_hdr - header deletion parameters (support
378 * multiple headers and commit)
379 * @commit: should headers be removed from IPA HW also?
380 * @num_hdls: num of headers being removed
381 * @ipa_hdr_del hdl: all handles need to go here back to back, no pointers
382 */
383struct ipa_ioc_del_hdr {
384 uint8_t commit;
385 uint8_t num_hdls;
386 struct ipa_hdr_del hdl[0];
387};
388
389/**
390 * struct ipa_rt_rule_add - routing rule descriptor includes in
391 * and out parameters
392 * @rule: actual rule to be added
393 * @at_rear: add at back of routing table, it is NOT possible to add rules at
394 * the rear of the "default" routing tables
395 * @rt_rule_hdl: output parameter, handle to rule, valid when status is 0
396 * @status: output parameter, status of routing rule add operation,
397 * 0 for success,
398 * -1 for failure
399 */
400struct ipa_rt_rule_add {
401 struct ipa_rt_rule rule;
402 uint8_t at_rear;
403 uint32_t rt_rule_hdl;
404 int status;
405};
406
407/**
408 * struct ipa_ioc_add_rt_rule - routing rule addition parameters (supports
409 * multiple rules and commit);
410 *
411 * all rules MUST be added to same table
412 * @commit: should rules be written to IPA HW also?
413 * @ip: IP family of rule
414 * @rt_tbl_name: name of routing table resource
415 * @num_rules: number of routing rules that follow
416 * @ipa_rt_rule_add rules: all rules need to go back to back here, no pointers
417 */
418struct ipa_ioc_add_rt_rule {
419 uint8_t commit;
420 enum ipa_ip_type ip;
421 char rt_tbl_name[IPA_RESOURCE_NAME_MAX];
422 uint8_t num_rules;
423 struct ipa_rt_rule_add rules[0];
424};
425
426/**
427 * struct ipa_rt_rule_del - routing rule descriptor includes in
428 * and out parameters
429 * @hdl: handle returned from route rule add operation
430 * @status: output parameter, status of route rule delete operation,
431 * 0 for success,
432 * -1 for failure
433 */
434struct ipa_rt_rule_del {
435 uint32_t hdl;
436 int status;
437};
438
439/**
440 * struct ipa_ioc_del_rt_rule - routing rule deletion parameters (supports
441 * multiple headers and commit)
442 * @commit: should rules be removed from IPA HW also?
443 * @ip: IP family of rules
444 * @num_hdls: num of rules being removed
445 * @ipa_rt_rule_del hdl: all handles need to go back to back here, no pointers
446 */
447struct ipa_ioc_del_rt_rule {
448 uint8_t commit;
449 enum ipa_ip_type ip;
450 uint8_t num_hdls;
451 struct ipa_rt_rule_del hdl[0];
452};
453
454/**
455 * struct ipa_flt_rule_add - filtering rule descriptor includes
456 * in and out parameters
457 * @rule: actual rule to be added
458 * @at_rear: add at back of filtering table?
459 * @flt_rule_hdl: out parameter, handle to rule, valid when status is 0
460 * @status: output parameter, status of filtering rule add operation,
461 * 0 for success,
462 * -1 for failure
463 *
464 */
465struct ipa_flt_rule_add {
466 struct ipa_flt_rule rule;
467 uint8_t at_rear;
468 uint32_t flt_rule_hdl;
469 int status;
470};
471
472/**
473 * struct ipa_ioc_add_flt_rule - filtering rule addition parameters (supports
474 * multiple rules and commit)
475 * all rules MUST be added to same table
476 * @commit: should rules be written to IPA HW also?
477 * @ip: IP family of rule
478 * @ep: which "clients" pipe does this rule apply to?
479 * valid only when global is 0
480 * @global: does this apply to global filter table of specific IP family
481 * @num_rules: number of filtering rules that follow
482 * @rules: all rules need to go back to back here, no pointers
483 */
484struct ipa_ioc_add_flt_rule {
485 uint8_t commit;
486 enum ipa_ip_type ip;
487 enum ipa_client_type ep;
488 uint8_t global;
489 uint8_t num_rules;
490 struct ipa_flt_rule_add rules[0];
491};
492
493/**
494 * struct ipa_flt_rule_del - filtering rule descriptor includes
495 * in and out parameters
496 *
497 * @hdl: handle returned from filtering rule add operation
498 * @status: output parameter, status of filtering rule delete operation,
499 * 0 for success,
500 * -1 for failure
501 */
502struct ipa_flt_rule_del {
503 uint32_t hdl;
504 int status;
505};
506
507/**
508 * struct ipa_ioc_del_flt_rule - filtering rule deletion parameters (supports
509 * multiple headers and commit)
510 * @commit: should rules be removed from IPA HW also?
511 * @ip: IP family of rules
512 * @num_hdls: num of rules being removed
513 * @hdl: all handles need to go back to back here, no pointers
514 */
515struct ipa_ioc_del_flt_rule {
516 uint8_t commit;
517 enum ipa_ip_type ip;
518 uint8_t num_hdls;
519 struct ipa_flt_rule_del hdl[0];
520};
521
522/**
523 * struct ipa_ioc_get_rt_tbl - routing table lookup parameters, if lookup was
524 * successful caller must call put to release the reference
525 * count when done
526 * @ip: IP family of table
527 * @name: name of routing table resource
528 * @htl: output parameter, handle of routing table, valid only when ioctl
529 * return val is non-negative
530 */
531struct ipa_ioc_get_rt_tbl {
532 enum ipa_ip_type ip;
533 char name[IPA_RESOURCE_NAME_MAX];
534 uint32_t hdl;
535};
536
537/**
538 * struct ipa_ioc_query_intf - used to lookup number of tx and
539 * rx properties of interface
540 * @name: name of interface
541 * @num_tx_props: output parameter, number of tx properties
542 * valid only when ioctl return val is non-negative
543 * @num_rx_props: output parameter, number of rx properties
544 * valid only when ioctl return val is non-negative
545 */
546struct ipa_ioc_query_intf {
547 char name[IPA_RESOURCE_NAME_MAX];
548 uint32_t num_tx_props;
549 uint32_t num_rx_props;
550};
551
552/**
553 * struct ipa_ioc_tx_intf_prop - interface tx property
554 * @ip: IP family of routing rule
555 * @attrib: routing rule
556 * @dst_pipe: routing output pipe
557 * @hdr_name: name of associated header if any, empty string when no header
558 */
559struct ipa_ioc_tx_intf_prop {
560 enum ipa_ip_type ip;
561 struct ipa_rule_attrib attrib;
562 enum ipa_client_type dst_pipe;
563 char hdr_name[IPA_RESOURCE_NAME_MAX];
564};
565
566/**
567 * struct ipa_ioc_query_intf_tx_props - interface tx propertie
568 * @name: name of interface
Talel Atias9bc53892013-02-10 15:10:07 +0200569 * @num_tx_props: number of TX properties
Talel Atias8390f262012-11-15 16:33:18 +0200570 * @tx[0]: output parameter, the tx properties go here back to back
571 */
572struct ipa_ioc_query_intf_tx_props {
573 char name[IPA_RESOURCE_NAME_MAX];
Talel Atias9bc53892013-02-10 15:10:07 +0200574 uint32_t num_tx_props;
Talel Atias8390f262012-11-15 16:33:18 +0200575 struct ipa_ioc_tx_intf_prop tx[0];
576};
577
578/**
579 * struct ipa_ioc_rx_intf_prop - interface rx property
580 * @ip: IP family of filtering rule
581 * @attrib: filtering rule
582 * @src_pipe: input pipe
583 */
584struct ipa_ioc_rx_intf_prop {
585 enum ipa_ip_type ip;
586 struct ipa_rule_attrib attrib;
587 enum ipa_client_type src_pipe;
588};
589
590/**
591 * struct ipa_ioc_query_intf_rx_props - interface rx propertie
592 * @name: name of interface
Talel Atias9bc53892013-02-10 15:10:07 +0200593 * @num_rx_props: number of RX properties
Talel Atias8390f262012-11-15 16:33:18 +0200594 * @rx: output parameter, the rx properties go here back to back
595 */
596struct ipa_ioc_query_intf_rx_props {
597 char name[IPA_RESOURCE_NAME_MAX];
Talel Atias9bc53892013-02-10 15:10:07 +0200598 uint32_t num_rx_props;
Talel Atias8390f262012-11-15 16:33:18 +0200599 struct ipa_ioc_rx_intf_prop rx[0];
600};
601
602/**
603 * struct ipa_ioc_nat_alloc_mem - nat table memory allocation
604 * properties
605 * @dev_name: input parameter, the name of table
606 * @size: input parameter, size of table in bytes
607 * @offset: output parameter, offset into page in case of system memory
608 */
609struct ipa_ioc_nat_alloc_mem {
610 char dev_name[IPA_RESOURCE_NAME_MAX];
611 size_t size;
612 off_t offset;
613};
614
615/**
616 * struct ipa_ioc_v4_nat_init - nat table initialization
617 * parameters
618 * @tbl_index: input parameter, index of the table
619 * @ipv4_rules_offset: input parameter, ipv4 rules address offset
620 * @expn_rules_offset: input parameter, ipv4 expansion rules address offset
621 * @index_offset: input parameter, index rules offset
622 * @index_expn_offset: input parameter, index expansion rules offset
623 * @table_entries: input parameter, ipv4 rules table size in entries
624 * @expn_table_entries: input parameter, ipv4 expansion rules table size
625 * @ip_addr: input parameter, public ip address
626 */
627struct ipa_ioc_v4_nat_init {
628 uint8_t tbl_index;
629 uint32_t ipv4_rules_offset;
630 uint32_t expn_rules_offset;
631
632 uint32_t index_offset;
633 uint32_t index_expn_offset;
634
635 uint16_t table_entries;
636 uint16_t expn_table_entries;
637 uint32_t ip_addr;
638};
639
640/**
641 * struct ipa_ioc_v4_nat_del - nat table delete parameter
642 * @table_index: input parameter, index of the table
643 * @public_ip_addr: input parameter, public ip address
644 */
645struct ipa_ioc_v4_nat_del {
646 uint8_t table_index;
647 uint32_t public_ip_addr;
648};
649
650/**
651 * struct ipa_ioc_nat_dma_one - nat dma command parameter
652 * @table_index: input parameter, index of the table
653 * @base_addr: type of table, from which the base address of the table
654 * can be inferred
655 * @offset: destination offset within the NAT table
656 * @data: data to be written.
657 */
658struct ipa_ioc_nat_dma_one {
659 uint8_t table_index;
660 uint8_t base_addr;
661
662 uint32_t offset;
663 uint16_t data;
664
665};
666
667/**
668 * struct ipa_ioc_nat_dma_cmd - To hold multiple nat dma commands
669 * @entries: number of dma commands in use
670 * @dma: data pointer to the dma commands
671 */
672struct ipa_ioc_nat_dma_cmd {
673 uint8_t entries;
674 struct ipa_ioc_nat_dma_one dma[0];
675
676};
677
678/**
679 * struct ipa_msg_meta - Format of the message meta-data.
680 * @msg_type: the type of the message
Talel Atias8390f262012-11-15 16:33:18 +0200681 * @rsvd: reserved bits for future use.
Talel Atias9bc53892013-02-10 15:10:07 +0200682 * @msg_len: the length of the message in bytes
Talel Atias8390f262012-11-15 16:33:18 +0200683 *
Talel Atias9bc53892013-02-10 15:10:07 +0200684 * For push model:
Talel Atias8390f262012-11-15 16:33:18 +0200685 * Client in user-space should issue a read on the device (/dev/ipa) with a
Talel Atias9bc53892013-02-10 15:10:07 +0200686 * sufficiently large buffer in a continuous loop, call will block when there is
687 * no message to read. Upon return, client can read the ipa_msg_meta from start
688 * of buffer to find out type and length of message
689 * size of buffer supplied >= (size of largest message + size of metadata)
Talel Atias8390f262012-11-15 16:33:18 +0200690 *
Talel Atias9bc53892013-02-10 15:10:07 +0200691 * For pull model:
692 * Client in user-space can also issue a pull msg IOCTL to device (/dev/ipa)
693 * with a payload containing space for the ipa_msg_meta and the message specific
694 * payload length.
695 * size of buffer supplied == (len of specific message + size of metadata)
Talel Atias8390f262012-11-15 16:33:18 +0200696 */
697struct ipa_msg_meta {
698 uint8_t msg_type;
Talel Atias8390f262012-11-15 16:33:18 +0200699 uint8_t rsvd;
Talel Atias9bc53892013-02-10 15:10:07 +0200700 uint16_t msg_len;
Talel Atias8390f262012-11-15 16:33:18 +0200701};
702
703/**
Talel Atias9bc53892013-02-10 15:10:07 +0200704 * struct ipa_wlan_msg - To hold information about wlan client
705 * @name: name of the wlan interface
706 * @mac_addr: mac address of wlan client
707 *
708 * wlan drivers need to pass name of wlan iface and mac address of
709 * wlan client along with ipa_wlan_event, whenever a wlan client is
710 * connected/disconnected/moved to power save/come out of power save
711 */
712struct ipa_wlan_msg {
713 char name[IPA_RESOURCE_NAME_MAX];
714 uint8_t mac_addr[IPA_MAC_ADDR_SIZE];
715};
716
Vladislav Mordohovichc76217e2013-03-10 17:45:05 +0200717/**
718 * struct ipa_ioc_rm_dependency - parameters for add/delete dependency
719 * @resource_name: name of dependent resource
720 * @depends_on_name: name of its dependency
721 */
722struct ipa_ioc_rm_dependency {
723 enum ipa_rm_resource_name resource_name;
724 enum ipa_rm_resource_name depends_on_name;
725};
Talel Atias9bc53892013-02-10 15:10:07 +0200726
727
728/**
Talel Atias8390f262012-11-15 16:33:18 +0200729 * actual IOCTLs supported by IPA driver
730 */
731#define IPA_IOC_ADD_HDR _IOWR(IPA_IOC_MAGIC, \
732 IPA_IOCTL_ADD_HDR, \
733 struct ipa_ioc_add_hdr *)
734#define IPA_IOC_DEL_HDR _IOWR(IPA_IOC_MAGIC, \
735 IPA_IOCTL_DEL_HDR, \
736 struct ipa_ioc_del_hdr *)
737#define IPA_IOC_ADD_RT_RULE _IOWR(IPA_IOC_MAGIC, \
738 IPA_IOCTL_ADD_RT_RULE, \
739 struct ipa_ioc_add_rt_rule *)
740#define IPA_IOC_DEL_RT_RULE _IOWR(IPA_IOC_MAGIC, \
741 IPA_IOCTL_DEL_RT_RULE, \
742 struct ipa_ioc_del_rt_rule *)
743#define IPA_IOC_ADD_FLT_RULE _IOWR(IPA_IOC_MAGIC, \
744 IPA_IOCTL_ADD_FLT_RULE, \
745 struct ipa_ioc_add_flt_rule *)
746#define IPA_IOC_DEL_FLT_RULE _IOWR(IPA_IOC_MAGIC, \
747 IPA_IOCTL_DEL_FLT_RULE, \
748 struct ipa_ioc_del_flt_rule *)
749#define IPA_IOC_COMMIT_HDR _IO(IPA_IOC_MAGIC,\
750 IPA_IOCTL_COMMIT_HDR)
751#define IPA_IOC_RESET_HDR _IO(IPA_IOC_MAGIC,\
752 IPA_IOCTL_RESET_HDR)
753#define IPA_IOC_COMMIT_RT _IOW(IPA_IOC_MAGIC, \
754 IPA_IOCTL_COMMIT_RT, \
755 enum ipa_ip_type)
756#define IPA_IOC_RESET_RT _IOW(IPA_IOC_MAGIC, \
757 IPA_IOCTL_RESET_RT, \
758 enum ipa_ip_type)
759#define IPA_IOC_COMMIT_FLT _IOW(IPA_IOC_MAGIC, \
760 IPA_IOCTL_COMMIT_FLT, \
761 enum ipa_ip_type)
762#define IPA_IOC_RESET_FLT _IOW(IPA_IOC_MAGIC, \
763 IPA_IOCTL_RESET_FLT, \
764 enum ipa_ip_type)
765#define IPA_IOC_DUMP _IO(IPA_IOC_MAGIC, \
766 IPA_IOCTL_DUMP)
767#define IPA_IOC_GET_RT_TBL _IOWR(IPA_IOC_MAGIC, \
768 IPA_IOCTL_GET_RT_TBL, \
769 struct ipa_ioc_get_rt_tbl *)
770#define IPA_IOC_PUT_RT_TBL _IOW(IPA_IOC_MAGIC, \
771 IPA_IOCTL_PUT_RT_TBL, \
772 uint32_t)
773#define IPA_IOC_COPY_HDR _IOWR(IPA_IOC_MAGIC, \
774 IPA_IOCTL_COPY_HDR, \
775 struct ipa_ioc_copy_hdr *)
776#define IPA_IOC_QUERY_INTF _IOWR(IPA_IOC_MAGIC, \
777 IPA_IOCTL_QUERY_INTF, \
778 struct ipa_ioc_query_intf *)
779#define IPA_IOC_QUERY_INTF_TX_PROPS _IOWR(IPA_IOC_MAGIC, \
780 IPA_IOCTL_QUERY_INTF_TX_PROPS, \
781 struct ipa_ioc_query_intf_tx_props *)
782#define IPA_IOC_QUERY_INTF_RX_PROPS _IOWR(IPA_IOC_MAGIC, \
783 IPA_IOCTL_QUERY_INTF_RX_PROPS, \
784 struct ipa_ioc_query_intf_rx_props *)
785#define IPA_IOC_GET_HDR _IOWR(IPA_IOC_MAGIC, \
786 IPA_IOCTL_GET_HDR, \
787 struct ipa_ioc_get_hdr *)
788#define IPA_IOC_PUT_HDR _IOW(IPA_IOC_MAGIC, \
789 IPA_IOCTL_PUT_HDR, \
790 uint32_t)
791#define IPA_IOC_ALLOC_NAT_MEM _IOWR(IPA_IOC_MAGIC, \
792 IPA_IOCTL_ALLOC_NAT_MEM, \
793 struct ipa_ioc_nat_alloc_mem *)
794#define IPA_IOC_V4_INIT_NAT _IOWR(IPA_IOC_MAGIC, \
795 IPA_IOCTL_V4_INIT_NAT, \
796 struct ipa_ioc_v4_nat_init *)
797#define IPA_IOC_NAT_DMA _IOWR(IPA_IOC_MAGIC, \
798 IPA_IOCTL_NAT_DMA, \
799 struct ipa_ioc_nat_dma_cmd *)
800#define IPA_IOC_V4_DEL_NAT _IOWR(IPA_IOC_MAGIC, \
801 IPA_IOCTL_V4_DEL_NAT, \
802 struct ipa_ioc_v4_nat_del *)
803#define IPA_IOC_GET_NAT_OFFSET _IOWR(IPA_IOC_MAGIC, \
804 IPA_IOCTL_GET_NAT_OFFSET, \
805 uint32_t *)
806#define IPA_IOC_SET_FLT _IOW(IPA_IOC_MAGIC, \
807 IPA_IOCTL_SET_FLT, \
808 uint32_t)
Talel Atias9bc53892013-02-10 15:10:07 +0200809#define IPA_IOC_PULL_MSG _IOWR(IPA_IOC_MAGIC, \
810 IPA_IOCTL_PULL_MSG, \
Talel Atias8390f262012-11-15 16:33:18 +0200811 struct ipa_msg_meta *)
Vladislav Mordohovichc76217e2013-03-10 17:45:05 +0200812#define IPA_IOC_RM_ADD_DEPENDENCY _IOWR(IPA_IOC_MAGIC, \
813 IPA_IOCTL_RM_ADD_DEPENDENCY, \
814 struct ipa_ioc_rm_dependency *)
815#define IPA_IOC_RM_DEL_DEPENDENCY _IOWR(IPA_IOC_MAGIC, \
816 IPA_IOCTL_RM_DEL_DEPENDENCY, \
817 struct ipa_ioc_rm_dependency *)
Talel Atias8390f262012-11-15 16:33:18 +0200818
Gidon Studinskia83ef572013-03-04 18:38:16 +0200819/*
820 * unique magic number of the Tethering bridge ioctls
821 */
822#define TETH_BRIDGE_IOC_MAGIC 0xCE
823
824/*
825 * Ioctls supported by Tethering bridge driver
826 */
827#define TETH_BRIDGE_IOCTL_SET_BRIDGE_MODE 0
828#define TETH_BRIDGE_IOCTL_SET_AGGR_PARAMS 1
829#define TETH_BRIDGE_IOCTL_GET_AGGR_PARAMS 2
830#define TETH_BRIDGE_IOCTL_GET_AGGR_CAPABILITIES 3
831#define TETH_BRIDGE_IOCTL_MAX 4
832
833
834/**
835 * enum teth_link_protocol_type - link protocol (IP / Ethernet)
836 */
837enum teth_link_protocol_type {
838 TETH_LINK_PROTOCOL_IP,
839 TETH_LINK_PROTOCOL_ETHERNET,
840 TETH_LINK_PROTOCOL_MAX,
841};
842
843/**
844 * enum teth_aggr_protocol_type - Aggregation protocol (MBIM / TLP)
845 */
846enum teth_aggr_protocol_type {
847 TETH_AGGR_PROTOCOL_NONE,
848 TETH_AGGR_PROTOCOL_MBIM,
849 TETH_AGGR_PROTOCOL_TLP,
850 TETH_AGGR_PROTOCOL_MAX,
851};
852
853/**
854 * struct teth_aggr_params_link - Aggregation parameters for uplink/downlink
855 * @aggr_prot: Aggregation protocol (MBIM / TLP)
856 * @max_transfer_size_byte: Maximal size of aggregated packet in bytes.
857 * Default value is 16*1024.
858 * @max_datagrams: Maximal number of IP packets in an aggregated
859 * packet. Default value is 16
860 */
861struct teth_aggr_params_link {
862 enum teth_aggr_protocol_type aggr_prot;
863 uint32_t max_transfer_size_byte;
864 uint32_t max_datagrams;
865};
866
867
868/**
869 * struct teth_aggr_params - Aggregation parmeters
870 * @ul: Uplink parameters
871 * @dl: Downlink parmaeters
872 */
873struct teth_aggr_params {
874 struct teth_aggr_params_link ul;
875 struct teth_aggr_params_link dl;
876};
877
878/**
879 * struct teth_aggr_capabilities - Aggregation capabilities
880 * @num_protocols: Number of protocols described in the array
881 * @prot_caps[]: Array of aggregation capabilities per protocol
882 */
883struct teth_aggr_capabilities {
884 uint16_t num_protocols;
885 struct teth_aggr_params_link prot_caps[0];
886};
887
888
889#define TETH_BRIDGE_IOC_SET_BRIDGE_MODE _IOW(TETH_BRIDGE_IOC_MAGIC, \
890 TETH_BRIDGE_IOCTL_SET_BRIDGE_MODE, \
891 enum teth_link_protocol_type)
892#define TETH_BRIDGE_IOC_SET_AGGR_PARAMS _IOW(TETH_BRIDGE_IOC_MAGIC, \
893 TETH_BRIDGE_IOCTL_SET_AGGR_PARAMS, \
894 struct teth_aggr_params *)
895#define TETH_BRIDGE_IOC_GET_AGGR_PARAMS _IOR(TETH_BRIDGE_IOC_MAGIC, \
896 TETH_BRIDGE_IOCTL_GET_AGGR_PARAMS, \
897 struct teth_aggr_params *)
898#define TETH_BRIDGE_IOC_GET_AGGR_CAPABILITIES _IOWR(TETH_BRIDGE_IOC_MAGIC, \
899 TETH_BRIDGE_IOCTL_GET_AGGR_CAPABILITIES, \
900 struct teth_aggr_capabilities *)
901
Talel Atias8390f262012-11-15 16:33:18 +0200902#endif /* _MSM_IPA_H_ */