blob: b377a6c63e59120cccc8c4956da581bd5d5fd7c8 [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,
Talel Atias9bc53892013-02-10 15:10:07 +0200176};
177
Vladislav Mordohovichc76217e2013-03-10 17:45:05 +0200178/**
179 * enum ipa_rm_resource_name - IPA RM clients identification names
180 *
181 * Add new mapping to ipa_rm_dep_prod_index() / ipa_rm_dep_cons_index()
182 * when adding new entry to this enum.
183 */
184enum ipa_rm_resource_name {
185 IPA_RM_RESOURCE_PROD = 0,
186 IPA_RM_RESOURCE_BRIDGE_PROD = IPA_RM_RESOURCE_PROD,
187 IPA_RM_RESOURCE_A2_PROD,
188 IPA_RM_RESOURCE_USB_PROD,
189 IPA_RM_RESOURCE_HSIC_PROD,
190 IPA_RM_RESOURCE_STD_ECM_PROD,
191 IPA_RM_RESOURCE_WWAN_0_PROD,
192 IPA_RM_RESOURCE_WWAN_1_PROD,
193 IPA_RM_RESOURCE_WWAN_2_PROD,
194 IPA_RM_RESOURCE_WWAN_3_PROD,
195 IPA_RM_RESOURCE_WWAN_4_PROD,
196 IPA_RM_RESOURCE_WWAN_5_PROD,
197 IPA_RM_RESOURCE_WWAN_6_PROD,
198 IPA_RM_RESOURCE_WWAN_7_PROD,
199 IPA_RM_RESOURCE_WLAN_PROD,
200 IPA_RM_RESOURCE_PROD_MAX,
201
202 IPA_RM_RESOURCE_A2_CONS = IPA_RM_RESOURCE_PROD_MAX,
203 IPA_RM_RESOURCE_USB_CONS,
204 IPA_RM_RESOURCE_HSIC_CONS,
205 IPA_RM_RESOURCE_MAX
206};
Talel Atias9bc53892013-02-10 15:10:07 +0200207
208/**
Talel Atias8390f262012-11-15 16:33:18 +0200209 * struct ipa_rule_attrib - attributes of a routing/filtering
210 * rule, all in LE
211 * @attrib_mask: what attributes are valid
212 * @src_port_lo: low port of src port range
213 * @src_port_hi: high port of src port range
214 * @dst_port_lo: low port of dst port range
215 * @dst_port_hi: high port of dst port range
216 * @type: ICMP/IGMP type
217 * @code: ICMP/IGMP code
218 * @spi: IPSec SPI
219 * @src_port: exact src port
220 * @dst_port: exact dst port
221 * @meta_data: meta-data val
222 * @meta_data_mask: meta-data mask
223 * @u.v4.tos: type of service
224 * @u.v4.protocol: protocol
225 * @u.v4.src_addr: src address value
226 * @u.v4.src_addr_mask: src address mask
227 * @u.v4.dst_addr: dst address value
228 * @u.v4.dst_addr_mask: dst address mask
229 * @u.v6.tc: traffic class
230 * @u.v6.flow_label: flow label
231 * @u.v6.next_hdr: next header
232 * @u.v6.src_addr: src address val
233 * @u.v6.src_addr_mask: src address mask
234 * @u.v6.dst_addr: dst address val
235 * @u.v6.dst_addr_mask: dst address mask
236 */
237struct ipa_rule_attrib {
238 uint32_t attrib_mask;
239 uint16_t src_port_lo;
240 uint16_t src_port_hi;
241 uint16_t dst_port_lo;
242 uint16_t dst_port_hi;
243 uint8_t type;
244 uint8_t code;
245 uint32_t spi;
246 uint16_t src_port;
247 uint16_t dst_port;
248 uint32_t meta_data;
249 uint32_t meta_data_mask;
250 union {
251 struct {
252 uint8_t tos;
253 uint8_t protocol;
254 uint32_t src_addr;
255 uint32_t src_addr_mask;
256 uint32_t dst_addr;
257 uint32_t dst_addr_mask;
258 } v4;
259 struct {
260 uint8_t tc;
261 uint32_t flow_label;
262 uint8_t next_hdr;
263 uint32_t src_addr[4];
264 uint32_t src_addr_mask[4];
265 uint32_t dst_addr[4];
266 uint32_t dst_addr_mask[4];
267 } v6;
268 } u;
269};
270
271/**
272 * struct ipa_flt_rule - attributes of a filtering rule
273 * @action: action field
274 * @rt_tbl_hdl: handle of table from "get"
275 * @attrib: attributes of the rule
276 */
277struct ipa_flt_rule {
278 enum ipa_flt_action action;
279 uint32_t rt_tbl_hdl;
280 struct ipa_rule_attrib attrib;
281};
282
283/**
284 * struct ipa_rt_rule - attributes of a routing rule
285 * @dst: dst "client"
286 * @hdr_hdl: handle to the dynamic header
287 it is not an index or an offset
288 * @attrib: attributes of the rule
289 */
290struct ipa_rt_rule {
291 enum ipa_client_type dst;
292 uint32_t hdr_hdl;
293 struct ipa_rule_attrib attrib;
294};
295
296/**
297 * struct ipa_hdr_add - header descriptor includes in and out
298 * parameters
299 * @name: name of the header
300 * @hdr: actual header to be inserted
301 * @hdr_len: size of above header
302 * @is_partial: header not fully specified
303 * @hdr_hdl: out paramerer, handle to header, valid when status is 0
304 * @status: out paramerer, status of header add operation,
305 * 0 for success,
306 * -1 for failure
307 */
308struct ipa_hdr_add {
309 char name[IPA_RESOURCE_NAME_MAX];
310 uint8_t hdr[IPA_HDR_MAX_SIZE];
311 uint8_t hdr_len;
312 uint8_t is_partial;
313 uint32_t hdr_hdl;
314 int status;
315};
316
317/**
318 * struct ipa_ioc_add_hdr - header addition parameters (support
319 * multiple headers and commit)
320 * @commit: should headers be written to IPA HW also?
321 * @num_hdrs: num of headers that follow
322 * @ipa_hdr_add hdr: all headers need to go here back to
323 * back, no pointers
324 */
325struct ipa_ioc_add_hdr {
326 uint8_t commit;
327 uint8_t num_hdrs;
328 struct ipa_hdr_add hdr[0];
329};
330
331/**
332 * struct ipa_ioc_copy_hdr - retrieve a copy of the specified
333 * header - caller can then derive the complete header
334 * @name: name of the header resource
335 * @hdr: out parameter, contents of specified header,
336 * valid only when ioctl return val is non-negative
337 * @hdr_len: out parameter, size of above header
338 * valid only when ioctl return val is non-negative
339 * @is_partial: out parameter, indicates whether specified header is partial
340 * valid only when ioctl return val is non-negative
341 */
342struct ipa_ioc_copy_hdr {
343 char name[IPA_RESOURCE_NAME_MAX];
344 uint8_t hdr[IPA_HDR_MAX_SIZE];
345 uint8_t hdr_len;
346 uint8_t is_partial;
347};
348
349/**
350 * struct ipa_ioc_get_hdr - header entry lookup parameters, if lookup was
351 * successful caller must call put to release the reference count when done
352 * @name: name of the header resource
353 * @hdl: out parameter, handle of header entry
354 * valid only when ioctl return val is non-negative
355 */
356struct ipa_ioc_get_hdr {
357 char name[IPA_RESOURCE_NAME_MAX];
358 uint32_t hdl;
359};
360
361/**
362 * struct ipa_hdr_del - header descriptor includes in and out
363 * parameters
364 *
365 * @hdl: handle returned from header add operation
366 * @status: out parameter, status of header remove operation,
367 * 0 for success,
368 * -1 for failure
369 */
370struct ipa_hdr_del {
371 uint32_t hdl;
372 int status;
373};
374
375/**
376 * struct ipa_ioc_del_hdr - header deletion parameters (support
377 * multiple headers and commit)
378 * @commit: should headers be removed from IPA HW also?
379 * @num_hdls: num of headers being removed
380 * @ipa_hdr_del hdl: all handles need to go here back to back, no pointers
381 */
382struct ipa_ioc_del_hdr {
383 uint8_t commit;
384 uint8_t num_hdls;
385 struct ipa_hdr_del hdl[0];
386};
387
388/**
389 * struct ipa_rt_rule_add - routing rule descriptor includes in
390 * and out parameters
391 * @rule: actual rule to be added
392 * @at_rear: add at back of routing table, it is NOT possible to add rules at
393 * the rear of the "default" routing tables
394 * @rt_rule_hdl: output parameter, handle to rule, valid when status is 0
395 * @status: output parameter, status of routing rule add operation,
396 * 0 for success,
397 * -1 for failure
398 */
399struct ipa_rt_rule_add {
400 struct ipa_rt_rule rule;
401 uint8_t at_rear;
402 uint32_t rt_rule_hdl;
403 int status;
404};
405
406/**
407 * struct ipa_ioc_add_rt_rule - routing rule addition parameters (supports
408 * multiple rules and commit);
409 *
410 * all rules MUST be added to same table
411 * @commit: should rules be written to IPA HW also?
412 * @ip: IP family of rule
413 * @rt_tbl_name: name of routing table resource
414 * @num_rules: number of routing rules that follow
415 * @ipa_rt_rule_add rules: all rules need to go back to back here, no pointers
416 */
417struct ipa_ioc_add_rt_rule {
418 uint8_t commit;
419 enum ipa_ip_type ip;
420 char rt_tbl_name[IPA_RESOURCE_NAME_MAX];
421 uint8_t num_rules;
422 struct ipa_rt_rule_add rules[0];
423};
424
425/**
426 * struct ipa_rt_rule_del - routing rule descriptor includes in
427 * and out parameters
428 * @hdl: handle returned from route rule add operation
429 * @status: output parameter, status of route rule delete operation,
430 * 0 for success,
431 * -1 for failure
432 */
433struct ipa_rt_rule_del {
434 uint32_t hdl;
435 int status;
436};
437
438/**
439 * struct ipa_ioc_del_rt_rule - routing rule deletion parameters (supports
440 * multiple headers and commit)
441 * @commit: should rules be removed from IPA HW also?
442 * @ip: IP family of rules
443 * @num_hdls: num of rules being removed
444 * @ipa_rt_rule_del hdl: all handles need to go back to back here, no pointers
445 */
446struct ipa_ioc_del_rt_rule {
447 uint8_t commit;
448 enum ipa_ip_type ip;
449 uint8_t num_hdls;
450 struct ipa_rt_rule_del hdl[0];
451};
452
453/**
454 * struct ipa_flt_rule_add - filtering rule descriptor includes
455 * in and out parameters
456 * @rule: actual rule to be added
457 * @at_rear: add at back of filtering table?
458 * @flt_rule_hdl: out parameter, handle to rule, valid when status is 0
459 * @status: output parameter, status of filtering rule add operation,
460 * 0 for success,
461 * -1 for failure
462 *
463 */
464struct ipa_flt_rule_add {
465 struct ipa_flt_rule rule;
466 uint8_t at_rear;
467 uint32_t flt_rule_hdl;
468 int status;
469};
470
471/**
472 * struct ipa_ioc_add_flt_rule - filtering rule addition parameters (supports
473 * multiple rules and commit)
474 * all rules MUST be added to same table
475 * @commit: should rules be written to IPA HW also?
476 * @ip: IP family of rule
477 * @ep: which "clients" pipe does this rule apply to?
478 * valid only when global is 0
479 * @global: does this apply to global filter table of specific IP family
480 * @num_rules: number of filtering rules that follow
481 * @rules: all rules need to go back to back here, no pointers
482 */
483struct ipa_ioc_add_flt_rule {
484 uint8_t commit;
485 enum ipa_ip_type ip;
486 enum ipa_client_type ep;
487 uint8_t global;
488 uint8_t num_rules;
489 struct ipa_flt_rule_add rules[0];
490};
491
492/**
493 * struct ipa_flt_rule_del - filtering rule descriptor includes
494 * in and out parameters
495 *
496 * @hdl: handle returned from filtering rule add operation
497 * @status: output parameter, status of filtering rule delete operation,
498 * 0 for success,
499 * -1 for failure
500 */
501struct ipa_flt_rule_del {
502 uint32_t hdl;
503 int status;
504};
505
506/**
507 * struct ipa_ioc_del_flt_rule - filtering rule deletion parameters (supports
508 * multiple headers and commit)
509 * @commit: should rules be removed from IPA HW also?
510 * @ip: IP family of rules
511 * @num_hdls: num of rules being removed
512 * @hdl: all handles need to go back to back here, no pointers
513 */
514struct ipa_ioc_del_flt_rule {
515 uint8_t commit;
516 enum ipa_ip_type ip;
517 uint8_t num_hdls;
518 struct ipa_flt_rule_del hdl[0];
519};
520
521/**
522 * struct ipa_ioc_get_rt_tbl - routing table lookup parameters, if lookup was
523 * successful caller must call put to release the reference
524 * count when done
525 * @ip: IP family of table
526 * @name: name of routing table resource
527 * @htl: output parameter, handle of routing table, valid only when ioctl
528 * return val is non-negative
529 */
530struct ipa_ioc_get_rt_tbl {
531 enum ipa_ip_type ip;
532 char name[IPA_RESOURCE_NAME_MAX];
533 uint32_t hdl;
534};
535
536/**
537 * struct ipa_ioc_query_intf - used to lookup number of tx and
538 * rx properties of interface
539 * @name: name of interface
540 * @num_tx_props: output parameter, number of tx properties
541 * valid only when ioctl return val is non-negative
542 * @num_rx_props: output parameter, number of rx properties
543 * valid only when ioctl return val is non-negative
544 */
545struct ipa_ioc_query_intf {
546 char name[IPA_RESOURCE_NAME_MAX];
547 uint32_t num_tx_props;
548 uint32_t num_rx_props;
549};
550
551/**
552 * struct ipa_ioc_tx_intf_prop - interface tx property
553 * @ip: IP family of routing rule
554 * @attrib: routing rule
555 * @dst_pipe: routing output pipe
556 * @hdr_name: name of associated header if any, empty string when no header
557 */
558struct ipa_ioc_tx_intf_prop {
559 enum ipa_ip_type ip;
560 struct ipa_rule_attrib attrib;
561 enum ipa_client_type dst_pipe;
562 char hdr_name[IPA_RESOURCE_NAME_MAX];
563};
564
565/**
566 * struct ipa_ioc_query_intf_tx_props - interface tx propertie
567 * @name: name of interface
Talel Atias9bc53892013-02-10 15:10:07 +0200568 * @num_tx_props: number of TX properties
Talel Atias8390f262012-11-15 16:33:18 +0200569 * @tx[0]: output parameter, the tx properties go here back to back
570 */
571struct ipa_ioc_query_intf_tx_props {
572 char name[IPA_RESOURCE_NAME_MAX];
Talel Atias9bc53892013-02-10 15:10:07 +0200573 uint32_t num_tx_props;
Talel Atias8390f262012-11-15 16:33:18 +0200574 struct ipa_ioc_tx_intf_prop tx[0];
575};
576
577/**
578 * struct ipa_ioc_rx_intf_prop - interface rx property
579 * @ip: IP family of filtering rule
580 * @attrib: filtering rule
581 * @src_pipe: input pipe
582 */
583struct ipa_ioc_rx_intf_prop {
584 enum ipa_ip_type ip;
585 struct ipa_rule_attrib attrib;
586 enum ipa_client_type src_pipe;
587};
588
589/**
590 * struct ipa_ioc_query_intf_rx_props - interface rx propertie
591 * @name: name of interface
Talel Atias9bc53892013-02-10 15:10:07 +0200592 * @num_rx_props: number of RX properties
Talel Atias8390f262012-11-15 16:33:18 +0200593 * @rx: output parameter, the rx properties go here back to back
594 */
595struct ipa_ioc_query_intf_rx_props {
596 char name[IPA_RESOURCE_NAME_MAX];
Talel Atias9bc53892013-02-10 15:10:07 +0200597 uint32_t num_rx_props;
Talel Atias8390f262012-11-15 16:33:18 +0200598 struct ipa_ioc_rx_intf_prop rx[0];
599};
600
601/**
602 * struct ipa_ioc_nat_alloc_mem - nat table memory allocation
603 * properties
604 * @dev_name: input parameter, the name of table
605 * @size: input parameter, size of table in bytes
606 * @offset: output parameter, offset into page in case of system memory
607 */
608struct ipa_ioc_nat_alloc_mem {
609 char dev_name[IPA_RESOURCE_NAME_MAX];
610 size_t size;
611 off_t offset;
612};
613
614/**
615 * struct ipa_ioc_v4_nat_init - nat table initialization
616 * parameters
617 * @tbl_index: input parameter, index of the table
618 * @ipv4_rules_offset: input parameter, ipv4 rules address offset
619 * @expn_rules_offset: input parameter, ipv4 expansion rules address offset
620 * @index_offset: input parameter, index rules offset
621 * @index_expn_offset: input parameter, index expansion rules offset
622 * @table_entries: input parameter, ipv4 rules table size in entries
623 * @expn_table_entries: input parameter, ipv4 expansion rules table size
624 * @ip_addr: input parameter, public ip address
625 */
626struct ipa_ioc_v4_nat_init {
627 uint8_t tbl_index;
628 uint32_t ipv4_rules_offset;
629 uint32_t expn_rules_offset;
630
631 uint32_t index_offset;
632 uint32_t index_expn_offset;
633
634 uint16_t table_entries;
635 uint16_t expn_table_entries;
636 uint32_t ip_addr;
637};
638
639/**
640 * struct ipa_ioc_v4_nat_del - nat table delete parameter
641 * @table_index: input parameter, index of the table
642 * @public_ip_addr: input parameter, public ip address
643 */
644struct ipa_ioc_v4_nat_del {
645 uint8_t table_index;
646 uint32_t public_ip_addr;
647};
648
649/**
650 * struct ipa_ioc_nat_dma_one - nat dma command parameter
651 * @table_index: input parameter, index of the table
652 * @base_addr: type of table, from which the base address of the table
653 * can be inferred
654 * @offset: destination offset within the NAT table
655 * @data: data to be written.
656 */
657struct ipa_ioc_nat_dma_one {
658 uint8_t table_index;
659 uint8_t base_addr;
660
661 uint32_t offset;
662 uint16_t data;
663
664};
665
666/**
667 * struct ipa_ioc_nat_dma_cmd - To hold multiple nat dma commands
668 * @entries: number of dma commands in use
669 * @dma: data pointer to the dma commands
670 */
671struct ipa_ioc_nat_dma_cmd {
672 uint8_t entries;
673 struct ipa_ioc_nat_dma_one dma[0];
674
675};
676
677/**
678 * struct ipa_msg_meta - Format of the message meta-data.
679 * @msg_type: the type of the message
Talel Atias8390f262012-11-15 16:33:18 +0200680 * @rsvd: reserved bits for future use.
Talel Atias9bc53892013-02-10 15:10:07 +0200681 * @msg_len: the length of the message in bytes
Talel Atias8390f262012-11-15 16:33:18 +0200682 *
Talel Atias9bc53892013-02-10 15:10:07 +0200683 * For push model:
Talel Atias8390f262012-11-15 16:33:18 +0200684 * Client in user-space should issue a read on the device (/dev/ipa) with a
Talel Atias9bc53892013-02-10 15:10:07 +0200685 * sufficiently large buffer in a continuous loop, call will block when there is
686 * no message to read. Upon return, client can read the ipa_msg_meta from start
687 * of buffer to find out type and length of message
688 * size of buffer supplied >= (size of largest message + size of metadata)
Talel Atias8390f262012-11-15 16:33:18 +0200689 *
Talel Atias9bc53892013-02-10 15:10:07 +0200690 * For pull model:
691 * Client in user-space can also issue a pull msg IOCTL to device (/dev/ipa)
692 * with a payload containing space for the ipa_msg_meta and the message specific
693 * payload length.
694 * size of buffer supplied == (len of specific message + size of metadata)
Talel Atias8390f262012-11-15 16:33:18 +0200695 */
696struct ipa_msg_meta {
697 uint8_t msg_type;
Talel Atias8390f262012-11-15 16:33:18 +0200698 uint8_t rsvd;
Talel Atias9bc53892013-02-10 15:10:07 +0200699 uint16_t msg_len;
Talel Atias8390f262012-11-15 16:33:18 +0200700};
701
702/**
Talel Atias9bc53892013-02-10 15:10:07 +0200703 * struct ipa_wlan_msg - To hold information about wlan client
704 * @name: name of the wlan interface
705 * @mac_addr: mac address of wlan client
706 *
707 * wlan drivers need to pass name of wlan iface and mac address of
708 * wlan client along with ipa_wlan_event, whenever a wlan client is
709 * connected/disconnected/moved to power save/come out of power save
710 */
711struct ipa_wlan_msg {
712 char name[IPA_RESOURCE_NAME_MAX];
713 uint8_t mac_addr[IPA_MAC_ADDR_SIZE];
714};
715
Vladislav Mordohovichc76217e2013-03-10 17:45:05 +0200716/**
717 * struct ipa_ioc_rm_dependency - parameters for add/delete dependency
718 * @resource_name: name of dependent resource
719 * @depends_on_name: name of its dependency
720 */
721struct ipa_ioc_rm_dependency {
722 enum ipa_rm_resource_name resource_name;
723 enum ipa_rm_resource_name depends_on_name;
724};
Talel Atias9bc53892013-02-10 15:10:07 +0200725
726
727/**
Talel Atias8390f262012-11-15 16:33:18 +0200728 * actual IOCTLs supported by IPA driver
729 */
730#define IPA_IOC_ADD_HDR _IOWR(IPA_IOC_MAGIC, \
731 IPA_IOCTL_ADD_HDR, \
732 struct ipa_ioc_add_hdr *)
733#define IPA_IOC_DEL_HDR _IOWR(IPA_IOC_MAGIC, \
734 IPA_IOCTL_DEL_HDR, \
735 struct ipa_ioc_del_hdr *)
736#define IPA_IOC_ADD_RT_RULE _IOWR(IPA_IOC_MAGIC, \
737 IPA_IOCTL_ADD_RT_RULE, \
738 struct ipa_ioc_add_rt_rule *)
739#define IPA_IOC_DEL_RT_RULE _IOWR(IPA_IOC_MAGIC, \
740 IPA_IOCTL_DEL_RT_RULE, \
741 struct ipa_ioc_del_rt_rule *)
742#define IPA_IOC_ADD_FLT_RULE _IOWR(IPA_IOC_MAGIC, \
743 IPA_IOCTL_ADD_FLT_RULE, \
744 struct ipa_ioc_add_flt_rule *)
745#define IPA_IOC_DEL_FLT_RULE _IOWR(IPA_IOC_MAGIC, \
746 IPA_IOCTL_DEL_FLT_RULE, \
747 struct ipa_ioc_del_flt_rule *)
748#define IPA_IOC_COMMIT_HDR _IO(IPA_IOC_MAGIC,\
749 IPA_IOCTL_COMMIT_HDR)
750#define IPA_IOC_RESET_HDR _IO(IPA_IOC_MAGIC,\
751 IPA_IOCTL_RESET_HDR)
752#define IPA_IOC_COMMIT_RT _IOW(IPA_IOC_MAGIC, \
753 IPA_IOCTL_COMMIT_RT, \
754 enum ipa_ip_type)
755#define IPA_IOC_RESET_RT _IOW(IPA_IOC_MAGIC, \
756 IPA_IOCTL_RESET_RT, \
757 enum ipa_ip_type)
758#define IPA_IOC_COMMIT_FLT _IOW(IPA_IOC_MAGIC, \
759 IPA_IOCTL_COMMIT_FLT, \
760 enum ipa_ip_type)
761#define IPA_IOC_RESET_FLT _IOW(IPA_IOC_MAGIC, \
762 IPA_IOCTL_RESET_FLT, \
763 enum ipa_ip_type)
764#define IPA_IOC_DUMP _IO(IPA_IOC_MAGIC, \
765 IPA_IOCTL_DUMP)
766#define IPA_IOC_GET_RT_TBL _IOWR(IPA_IOC_MAGIC, \
767 IPA_IOCTL_GET_RT_TBL, \
768 struct ipa_ioc_get_rt_tbl *)
769#define IPA_IOC_PUT_RT_TBL _IOW(IPA_IOC_MAGIC, \
770 IPA_IOCTL_PUT_RT_TBL, \
771 uint32_t)
772#define IPA_IOC_COPY_HDR _IOWR(IPA_IOC_MAGIC, \
773 IPA_IOCTL_COPY_HDR, \
774 struct ipa_ioc_copy_hdr *)
775#define IPA_IOC_QUERY_INTF _IOWR(IPA_IOC_MAGIC, \
776 IPA_IOCTL_QUERY_INTF, \
777 struct ipa_ioc_query_intf *)
778#define IPA_IOC_QUERY_INTF_TX_PROPS _IOWR(IPA_IOC_MAGIC, \
779 IPA_IOCTL_QUERY_INTF_TX_PROPS, \
780 struct ipa_ioc_query_intf_tx_props *)
781#define IPA_IOC_QUERY_INTF_RX_PROPS _IOWR(IPA_IOC_MAGIC, \
782 IPA_IOCTL_QUERY_INTF_RX_PROPS, \
783 struct ipa_ioc_query_intf_rx_props *)
784#define IPA_IOC_GET_HDR _IOWR(IPA_IOC_MAGIC, \
785 IPA_IOCTL_GET_HDR, \
786 struct ipa_ioc_get_hdr *)
787#define IPA_IOC_PUT_HDR _IOW(IPA_IOC_MAGIC, \
788 IPA_IOCTL_PUT_HDR, \
789 uint32_t)
790#define IPA_IOC_ALLOC_NAT_MEM _IOWR(IPA_IOC_MAGIC, \
791 IPA_IOCTL_ALLOC_NAT_MEM, \
792 struct ipa_ioc_nat_alloc_mem *)
793#define IPA_IOC_V4_INIT_NAT _IOWR(IPA_IOC_MAGIC, \
794 IPA_IOCTL_V4_INIT_NAT, \
795 struct ipa_ioc_v4_nat_init *)
796#define IPA_IOC_NAT_DMA _IOWR(IPA_IOC_MAGIC, \
797 IPA_IOCTL_NAT_DMA, \
798 struct ipa_ioc_nat_dma_cmd *)
799#define IPA_IOC_V4_DEL_NAT _IOWR(IPA_IOC_MAGIC, \
800 IPA_IOCTL_V4_DEL_NAT, \
801 struct ipa_ioc_v4_nat_del *)
802#define IPA_IOC_GET_NAT_OFFSET _IOWR(IPA_IOC_MAGIC, \
803 IPA_IOCTL_GET_NAT_OFFSET, \
804 uint32_t *)
805#define IPA_IOC_SET_FLT _IOW(IPA_IOC_MAGIC, \
806 IPA_IOCTL_SET_FLT, \
807 uint32_t)
Talel Atias9bc53892013-02-10 15:10:07 +0200808#define IPA_IOC_PULL_MSG _IOWR(IPA_IOC_MAGIC, \
809 IPA_IOCTL_PULL_MSG, \
Talel Atias8390f262012-11-15 16:33:18 +0200810 struct ipa_msg_meta *)
Vladislav Mordohovichc76217e2013-03-10 17:45:05 +0200811#define IPA_IOC_RM_ADD_DEPENDENCY _IOWR(IPA_IOC_MAGIC, \
812 IPA_IOCTL_RM_ADD_DEPENDENCY, \
813 struct ipa_ioc_rm_dependency *)
814#define IPA_IOC_RM_DEL_DEPENDENCY _IOWR(IPA_IOC_MAGIC, \
815 IPA_IOCTL_RM_DEL_DEPENDENCY, \
816 struct ipa_ioc_rm_dependency *)
Talel Atias8390f262012-11-15 16:33:18 +0200817
Gidon Studinskia83ef572013-03-04 18:38:16 +0200818/*
819 * unique magic number of the Tethering bridge ioctls
820 */
821#define TETH_BRIDGE_IOC_MAGIC 0xCE
822
823/*
824 * Ioctls supported by Tethering bridge driver
825 */
826#define TETH_BRIDGE_IOCTL_SET_BRIDGE_MODE 0
827#define TETH_BRIDGE_IOCTL_SET_AGGR_PARAMS 1
828#define TETH_BRIDGE_IOCTL_GET_AGGR_PARAMS 2
829#define TETH_BRIDGE_IOCTL_GET_AGGR_CAPABILITIES 3
830#define TETH_BRIDGE_IOCTL_MAX 4
831
832
833/**
834 * enum teth_link_protocol_type - link protocol (IP / Ethernet)
835 */
836enum teth_link_protocol_type {
837 TETH_LINK_PROTOCOL_IP,
838 TETH_LINK_PROTOCOL_ETHERNET,
839 TETH_LINK_PROTOCOL_MAX,
840};
841
842/**
843 * enum teth_aggr_protocol_type - Aggregation protocol (MBIM / TLP)
844 */
845enum teth_aggr_protocol_type {
846 TETH_AGGR_PROTOCOL_NONE,
847 TETH_AGGR_PROTOCOL_MBIM,
848 TETH_AGGR_PROTOCOL_TLP,
849 TETH_AGGR_PROTOCOL_MAX,
850};
851
852/**
853 * struct teth_aggr_params_link - Aggregation parameters for uplink/downlink
854 * @aggr_prot: Aggregation protocol (MBIM / TLP)
855 * @max_transfer_size_byte: Maximal size of aggregated packet in bytes.
856 * Default value is 16*1024.
857 * @max_datagrams: Maximal number of IP packets in an aggregated
858 * packet. Default value is 16
859 */
860struct teth_aggr_params_link {
861 enum teth_aggr_protocol_type aggr_prot;
862 uint32_t max_transfer_size_byte;
863 uint32_t max_datagrams;
864};
865
866
867/**
868 * struct teth_aggr_params - Aggregation parmeters
869 * @ul: Uplink parameters
870 * @dl: Downlink parmaeters
871 */
872struct teth_aggr_params {
873 struct teth_aggr_params_link ul;
874 struct teth_aggr_params_link dl;
875};
876
877/**
878 * struct teth_aggr_capabilities - Aggregation capabilities
879 * @num_protocols: Number of protocols described in the array
880 * @prot_caps[]: Array of aggregation capabilities per protocol
881 */
882struct teth_aggr_capabilities {
883 uint16_t num_protocols;
884 struct teth_aggr_params_link prot_caps[0];
885};
886
887
888#define TETH_BRIDGE_IOC_SET_BRIDGE_MODE _IOW(TETH_BRIDGE_IOC_MAGIC, \
889 TETH_BRIDGE_IOCTL_SET_BRIDGE_MODE, \
890 enum teth_link_protocol_type)
891#define TETH_BRIDGE_IOC_SET_AGGR_PARAMS _IOW(TETH_BRIDGE_IOC_MAGIC, \
892 TETH_BRIDGE_IOCTL_SET_AGGR_PARAMS, \
893 struct teth_aggr_params *)
894#define TETH_BRIDGE_IOC_GET_AGGR_PARAMS _IOR(TETH_BRIDGE_IOC_MAGIC, \
895 TETH_BRIDGE_IOCTL_GET_AGGR_PARAMS, \
896 struct teth_aggr_params *)
897#define TETH_BRIDGE_IOC_GET_AGGR_CAPABILITIES _IOWR(TETH_BRIDGE_IOC_MAGIC, \
898 TETH_BRIDGE_IOCTL_GET_AGGR_CAPABILITIES, \
899 struct teth_aggr_capabilities *)
900
Talel Atias8390f262012-11-15 16:33:18 +0200901#endif /* _MSM_IPA_H_ */