blob: c37b518ba1b17285cb13953dc12b5dcd19d84429 [file] [log] [blame]
Talel Atias8390f262012-11-15 16:33:18 +02001/* Copyright (c) 2012, The Linux Foundation. All rights reserved.
2 *
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License version 2 and
5 * only version 2 as published by the Free Software Foundation.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 */
12
13#ifndef _IPA_H_
14#define _IPA_H_
15
16#include <linux/msm_ipa.h>
17#include <linux/skbuff.h>
18#include <linux/types.h>
19#include <mach/sps.h>
20
21/**
22 * enum ipa_nat_en_type - NAT setting type in IPA end-point
23 */
24enum ipa_nat_en_type {
25 IPA_BYPASS_NAT,
26 IPA_SRC_NAT,
27 IPA_DST_NAT,
28};
29
30/**
31 * enum ipa_mode_type - mode setting type in IPA end-point
32 * @BASIC: basic mode
33 * @ENABLE_FRAMING_HDLC: not currently supported
34 * @ENABLE_DEFRAMING_HDLC: not currently supported
35 */
36enum ipa_mode_type {
37 IPA_BASIC,
38 IPA_ENABLE_FRAMING_HDLC,
39 IPA_ENABLE_DEFRAMING_HDLC,
40 IPA_DMA,
41};
42
43/**
44 * enum ipa_aggr_en_type - aggregation setting type in IPA
45 * end-point
46 */
47enum ipa_aggr_en_type {
48 IPA_BYPASS_AGGR,
49 IPA_ENABLE_AGGR,
50 IPA_ENABLE_DEAGGR,
51};
52
53/**
54 * enum ipa_aggr_type - type of aggregation in IPA end-point
55 */
56enum ipa_aggr_type {
57 IPA_MBIM_16,
58 IPA_MBIM_32,
59 IPA_TLP,
60};
61
62/**
63 * enum ipa_aggr_mode - global aggregation mode
64 */
65enum ipa_aggr_mode {
66 IPA_MBIM,
67 IPA_QCNCM,
68};
69
70/**
71 * enum ipa_dp_evt_type - type of event client callback is
72 * invoked for on data path
73 * @IPA_RECEIVE: data is struct sk_buff
74 * @IPA_WRITE_DONE: data is struct sk_buff
75 */
76enum ipa_dp_evt_type {
77 IPA_RECEIVE,
78 IPA_WRITE_DONE,
79};
80
81/**
82 * struct ipa_ep_cfg_nat - NAT configuration in IPA end-point
83 * @nat_en: This defines the default NAT mode for the pipe: in case of
84 * filter miss - the default NAT mode defines the NATing operation
85 * on the packet. Valid for Input Pipes only (IPA consumer)
86 */
87struct ipa_ep_cfg_nat {
88 enum ipa_nat_en_type nat_en;
89};
90
91/**
92 * struct ipa_ep_cfg_hdr - header configuration in IPA end-point
93 * @hdr_len: Header length in bytes to be added/removed. Assuming header len
94 * is constant per endpoint. Valid for both Input and Output Pipes
95 * @hdr_ofst_metadata_valid: 0: Metadata_Ofst value is invalid, i.e., no
96 * metadata within header.
97 * 1: Metadata_Ofst value is valid, i.e., metadata
98 * within header is in offset Metadata_Ofst Valid
99 * for Input Pipes only (IPA Consumer) (for output
100 * pipes, metadata already set within the header)
101 * @hdr_ofst_metadata: Offset within header in which metadata resides
102 * Size of metadata - 4bytes
103 * Example - Stream ID/SSID/mux ID.
104 * Valid for Input Pipes only (IPA Consumer) (for output
105 * pipes, metadata already set within the header)
106 * @hdr_additional_const_len: Defines the constant length that should be added
107 * to the payload length in order for IPA to update
108 * correctly the length field within the header
109 * (valid only in case Hdr_Ofst_Pkt_Size_Valid=1)
110 * Valid for Output Pipes (IPA Producer)
111 * @hdr_ofst_pkt_size_valid: 0: Hdr_Ofst_Pkt_Size value is invalid, i.e., no
112 * length field within the inserted header
113 * 1: Hdr_Ofst_Pkt_Size value is valid, i.e., a
114 * packet length field resides within the header
115 * Valid for Output Pipes (IPA Producer)
116 * @hdr_ofst_pkt_size: Offset within header in which packet size reside. Upon
117 * Header Insertion, IPA will update this field within the
118 * header with the packet length . Assumption is that
119 * header length field size is constant and is 2Bytes
120 * Valid for Output Pipes (IPA Producer)
121 * @hdr_a5_mux: Determines whether A5 Mux header should be added to the packet.
122 * This bit is valid only when Hdr_En=01(Header Insertion)
123 * SW should set this bit for IPA-to-A5 pipes.
124 * 0: Do not insert A5 Mux Header
125 * 1: Insert A5 Mux Header
126 * Valid for Output Pipes (IPA Producer)
127 */
128struct ipa_ep_cfg_hdr {
129 u32 hdr_len;
130 u32 hdr_ofst_metadata_valid;
131 u32 hdr_ofst_metadata;
132 u32 hdr_additional_const_len;
133 u32 hdr_ofst_pkt_size_valid;
134 u32 hdr_ofst_pkt_size;
135 u32 hdr_a5_mux;
136};
137
138/**
139 * struct ipa_ep_cfg_mode - mode configuration in IPA end-point
140 * @mode: Valid for Input Pipes only (IPA Consumer)
141 * @dst: This parameter specifies the output pipe to which the packets
142 * will be routed to.
143 * This parameter is valid for Mode=DMA and not valid for
144 * Mode=Basic
145 * Valid for Input Pipes only (IPA Consumer)
146 */
147struct ipa_ep_cfg_mode {
148 enum ipa_mode_type mode;
149 enum ipa_client_type dst;
150};
151
152/**
153 * struct ipa_ep_cfg_aggr - aggregation configuration in IPA end-point
154 * @aggr_en: Valid for both Input and Output Pipes
155 * @aggr: Valid for both Input and Output Pipes
156 * @aggr_byte_limit: Limit of aggregated packet size in KB (<=32KB) When set
157 * to 0, there is no size limitation on the aggregation.
158 * When both, Aggr_Byte_Limit and Aggr_Time_Limit are set
159 * to 0, there is no aggregation, every packet is sent
160 * independently according to the aggregation structure
161 * Valid for Output Pipes only (IPA Producer )
162 * @aggr_time_limit: Timer to close aggregated packet (<=32ms) When set to 0,
163 * there is no time limitation on the aggregation. When
164 * both, Aggr_Byte_Limit and Aggr_Time_Limit are set to 0,
165 * there is no aggregation, every packet is sent
166 * independently according to the aggregation structure
167 * Valid for Output Pipes only (IPA Producer)
168 */
169struct ipa_ep_cfg_aggr {
170 enum ipa_aggr_en_type aggr_en;
171 enum ipa_aggr_type aggr;
172 u32 aggr_byte_limit;
173 u32 aggr_time_limit;
174};
175
176/**
177 * struct ipa_ep_cfg_route - route configuration in IPA end-point
178 * @rt_tbl_hdl: Defines the default routing table index to be used in case there
179 * is no filter rule matching, valid for Input Pipes only (IPA
180 * Consumer). Clients should set this to 0 which will cause default
181 * v4 and v6 routes setup internally by IPA driver to be used for
182 * this end-point
183 */
184struct ipa_ep_cfg_route {
185 u32 rt_tbl_hdl;
186};
187
188/**
189 * struct ipa_ep_cfg - configuration of IPA end-point
190 * @nat: NAT parmeters
191 * @hdr: Header parameters
192 * @mode: Mode parameters
193 * @aggr: Aggregation parameters
194 * @route: Routing parameters
195 */
196struct ipa_ep_cfg {
197 struct ipa_ep_cfg_nat nat;
198 struct ipa_ep_cfg_hdr hdr;
199 struct ipa_ep_cfg_mode mode;
200 struct ipa_ep_cfg_aggr aggr;
201 struct ipa_ep_cfg_route route;
202};
203
204/**
205 * struct ipa_connect_params - low-level client connect input parameters. Either
206 * client allocates the data and desc FIFO and specifies that in data+desc OR
207 * specifies sizes and pipe_mem pref and IPA does the allocation.
208 *
209 * @ipa_ep_cfg: IPA EP configuration
210 * @client: type of "client"
211 * @client_bam_hdl: client SPS handle
212 * @client_ep_idx: client PER EP index
213 * @priv: callback cookie
214 * @notify: callback
215 * priv - callback cookie evt - type of event data - data relevant
216 * to event. May not be valid. See event_type enum for valid
217 * cases.
218 * @desc_fifo_sz: size of desc FIFO
219 * @data_fifo_sz: size of data FIFO
220 * @pipe_mem_preferred: if true, try to alloc the FIFOs in pipe mem, fallback
221 * to sys mem if pipe mem alloc fails
222 * @desc: desc FIFO meta-data when client has allocated it
223 * @data: data FIFO meta-data when client has allocated it
224 */
225struct ipa_connect_params {
226 struct ipa_ep_cfg ipa_ep_cfg;
227 enum ipa_client_type client;
228 u32 client_bam_hdl;
229 u32 client_ep_idx;
230 void *priv;
231 void (*notify)(void *priv, enum ipa_dp_evt_type evt,
232 unsigned long data);
233 u32 desc_fifo_sz;
234 u32 data_fifo_sz;
235 bool pipe_mem_preferred;
236 struct sps_mem_buffer desc;
237 struct sps_mem_buffer data;
238};
239
240/**
241 * struct ipa_sps_params - SPS related output parameters resulting from
242 * low/high level client connect
243 * @ipa_bam_hdl: IPA SPS handle
244 * @ipa_ep_idx: IPA PER EP index
245 * @desc: desc FIFO meta-data
246 * @data: data FIFO meta-data
247 */
248struct ipa_sps_params {
249 u32 ipa_bam_hdl;
250 u32 ipa_ep_idx;
251 struct sps_mem_buffer desc;
252 struct sps_mem_buffer data;
253};
254
255/**
256 * struct ipa_tx_intf - interface tx properties
257 * @num_props: number of tx properties
258 * @prop: the tx properties array
259 */
260struct ipa_tx_intf {
261 u32 num_props;
262 struct ipa_ioc_tx_intf_prop *prop;
263};
264
265/**
266 * struct ipa_rx_intf - interface rx properties
267 * @num_props: number of rx properties
268 * @prop: the rx properties array
269 */
270struct ipa_rx_intf {
271 u32 num_props;
272 struct ipa_ioc_rx_intf_prop *prop;
273};
274
275/**
276 * struct ipa_sys_connect_params - information needed to setup an IPA end-point
277 * in system-BAM mode
278 * @ipa_ep_cfg: IPA EP configuration
279 * @client: the type of client who "owns" the EP
280 * @desc_fifo_sz: size of desc FIFO
281 * @priv: callback cookie
282 * @notify: callback
283 * priv - callback cookie
284 * evt - type of event
285 * data - data relevant to event. May not be valid. See event_type
286 * enum for valid cases.
287 */
288struct ipa_sys_connect_params {
289 struct ipa_ep_cfg ipa_ep_cfg;
290 enum ipa_client_type client;
291 u32 desc_fifo_sz;
292 void *priv;
293 void (*notify)(void *priv,
294 enum ipa_dp_evt_type evt,
295 unsigned long data);
296};
297
298/**
299 * struct ipa_msg_meta_wrapper - message meta-data wrapper
300 * @meta: the meta-data itself
301 * @link: opaque to client
302 * @meta_wrapper_free: function to free the metadata wrapper when IPA driver
303 * is done with it
304 */
305struct ipa_msg_meta_wrapper {
306 struct ipa_msg_meta meta;
307 struct list_head link;
308 void (*meta_wrapper_free)(struct ipa_msg_meta_wrapper *buff);
309};
310
311/**
312 * struct ipa_tx_meta - meta-data for the TX packet
313 * @mbim_stream_id: the stream ID used in NDP signature
314 * @mbim_stream_id_valid: is above field valid?
315 */
316struct ipa_tx_meta {
317 u8 mbim_stream_id;
318 bool mbim_stream_id_valid;
319};
320
321/**
322 * struct ipa_msg_wrapper - message wrapper
323 * @msg: the message buffer itself, MUST exist after call returns, will
324 * be freed by IPA driver when it is done with it
325 * @link: opaque to client
326 * @msg_free: function to free the message when IPA driver is done with it
327 * @msg_wrapper_free: function to free the message wrapper when IPA driver is
328 * done with it
329 */
330struct ipa_msg_wrapper {
331 void *msg;
332 struct list_head link;
333 void (*msg_free)(void *msg);
334 void (*msg_wrapper_free)(struct ipa_msg_wrapper *buff);
335};
336
337/**
338 * typedef ipa_pull_fn - callback function
339 * @buf - [in] the buffer to populate the message into
340 * @sz - [in] the size of the buffer
341 *
342 * callback function registered by kernel client with IPA driver for IPA driver
343 * to be able to pull messages from the kernel client asynchronously.
344 *
345 * Returns how many bytes were copied into the buffer, negative on failure.
346 */
347typedef int (*ipa_pull_fn)(void *buf, uint16_t sz);
348
Talel Atias8a6ec102012-11-21 20:22:29 +0200349#ifdef CONFIG_IPA
350
Talel Atias8390f262012-11-15 16:33:18 +0200351/*
352 * Connect / Disconnect
353 */
354int ipa_connect(const struct ipa_connect_params *in, struct ipa_sps_params *sps,
355 u32 *clnt_hdl);
356int ipa_disconnect(u32 clnt_hdl);
357
358/*
359 * Configuration
360 */
361int ipa_cfg_ep(u32 clnt_hdl, const struct ipa_ep_cfg *ipa_ep_cfg);
362
363int ipa_cfg_ep_nat(u32 clnt_hdl, const struct ipa_ep_cfg_nat *ipa_ep_cfg);
364
365int ipa_cfg_ep_hdr(u32 clnt_hdl, const struct ipa_ep_cfg_hdr *ipa_ep_cfg);
366
367int ipa_cfg_ep_mode(u32 clnt_hdl, const struct ipa_ep_cfg_mode *ipa_ep_cfg);
368
369int ipa_cfg_ep_aggr(u32 clnt_hdl, const struct ipa_ep_cfg_aggr *ipa_ep_cfg);
370
371int ipa_cfg_ep_route(u32 clnt_hdl, const struct ipa_ep_cfg_route *ipa_ep_cfg);
372
373/*
374 * Header removal / addition
375 */
376int ipa_add_hdr(struct ipa_ioc_add_hdr *hdrs);
377
378int ipa_del_hdr(struct ipa_ioc_del_hdr *hdls);
379
380int ipa_commit_hdr(void);
381
382int ipa_reset_hdr(void);
383
384int ipa_get_hdr(struct ipa_ioc_get_hdr *lookup);
385
386int ipa_put_hdr(u32 hdr_hdl);
387
388int ipa_copy_hdr(struct ipa_ioc_copy_hdr *copy);
389
390/*
391 * Routing
392 */
393int ipa_add_rt_rule(struct ipa_ioc_add_rt_rule *rules);
394
395int ipa_del_rt_rule(struct ipa_ioc_del_rt_rule *hdls);
396
397int ipa_commit_rt(enum ipa_ip_type ip);
398
399int ipa_reset_rt(enum ipa_ip_type ip);
400
401int ipa_get_rt_tbl(struct ipa_ioc_get_rt_tbl *lookup);
402
403int ipa_put_rt_tbl(u32 rt_tbl_hdl);
404
405/*
406 * Filtering
407 */
408int ipa_add_flt_rule(struct ipa_ioc_add_flt_rule *rules);
409
410int ipa_del_flt_rule(struct ipa_ioc_del_flt_rule *hdls);
411
412int ipa_commit_flt(enum ipa_ip_type ip);
413
414int ipa_reset_flt(enum ipa_ip_type ip);
415
416/*
417 * NAT
418 */
419int allocate_nat_device(struct ipa_ioc_nat_alloc_mem *mem);
420
421int ipa_nat_init_cmd(struct ipa_ioc_v4_nat_init *init);
422
423int ipa_nat_dma_cmd(struct ipa_ioc_nat_dma_cmd *dma);
424
425int ipa_nat_del_cmd(struct ipa_ioc_v4_nat_del *del);
426
427/*
428 * Aggregation
429 */
430int ipa_set_aggr_mode(enum ipa_aggr_mode mode);
431
432int ipa_set_qcncm_ndp_sig(char sig[3]);
433
434int ipa_set_single_ndp_per_mbim(bool enable);
435
436/*
437 * rmnet bridge
438 */
439int rmnet_bridge_init(void);
440
441int rmnet_bridge_disconnect(void);
442
443int rmnet_bridge_connect(u32 producer_hdl,
444 u32 consumer_hdl,
445 int wwan_logical_channel_id);
446
447/*
448 * Data path
449 */
450int ipa_tx_dp(enum ipa_client_type dst, struct sk_buff *skb,
451 struct ipa_tx_meta *metadata);
452
453/*
454 * System pipes
455 */
456int ipa_setup_sys_pipe(struct ipa_sys_connect_params *sys_in, u32 *clnt_hdl);
457
458int ipa_teardown_sys_pipe(u32 clnt_hdl);
459
Talel Atias6d842bf2012-12-06 16:58:35 +0200460#else /* CONFIG_IPA */
Talel Atias8a6ec102012-11-21 20:22:29 +0200461
462/*
463 * Connect / Disconnect
464 */
465static inline int ipa_connect(const struct ipa_connect_params *in,
466 struct ipa_sps_params *sps, u32 *clnt_hdl)
467{
468 return -EPERM;
469}
470
471static inline int ipa_disconnect(u32 clnt_hdl)
472{
473 return -EPERM;
474}
475
476
477/*
478 * Configuration
479 */
480static inline int ipa_cfg_ep(u32 clnt_hdl,
481 const struct ipa_ep_cfg *ipa_ep_cfg)
482{
483 return -EPERM;
484}
485
486
487static inline int ipa_cfg_ep_nat(u32 clnt_hdl,
488 const struct ipa_ep_cfg_nat *ipa_ep_cfg)
489{
490 return -EPERM;
491}
492
493
494static inline int ipa_cfg_ep_hdr(u32 clnt_hdl,
495 const struct ipa_ep_cfg_hdr *ipa_ep_cfg)
496{
497 return -EPERM;
498}
499
500
501static inline int ipa_cfg_ep_mode(u32 clnt_hdl,
502 const struct ipa_ep_cfg_mode *ipa_ep_cfg)
503{
504 return -EPERM;
505}
506
507
508static inline int ipa_cfg_ep_aggr(u32 clnt_hdl,
509 const struct ipa_ep_cfg_aggr *ipa_ep_cfg)
510{
511 return -EPERM;
512}
513
514
515static inline int ipa_cfg_ep_route(u32 clnt_hdl,
516 const struct ipa_ep_cfg_route *ipa_ep_cfg)
517{
518 return -EPERM;
519}
520
521
522/*
523 * Header removal / addition
524 */
525static inline int ipa_add_hdr(struct ipa_ioc_add_hdr *hdrs)
526{
527 return -EPERM;
528}
529
530
531static inline int ipa_del_hdr(struct ipa_ioc_del_hdr *hdls)
532{
533 return -EPERM;
534}
535
536
537static inline int ipa_commit_hdr(void)
538{
539 return -EPERM;
540}
541
542
543static inline int ipa_reset_hdr(void)
544{
545 return -EPERM;
546}
547
548
549static inline int ipa_get_hdr(struct ipa_ioc_get_hdr *lookup)
550{
551 return -EPERM;
552}
553
554
555static inline int ipa_put_hdr(u32 hdr_hdl)
556{
557 return -EPERM;
558}
559
560
561static inline int ipa_copy_hdr(struct ipa_ioc_copy_hdr *copy)
562{
563 return -EPERM;
564}
565
566
567/*
568 * Routing
569 */
570static inline int ipa_add_rt_rule(struct ipa_ioc_add_rt_rule *rules)
571{
572 return -EPERM;
573}
574
575
576static inline int ipa_del_rt_rule(struct ipa_ioc_del_rt_rule *hdls)
577{
578 return -EPERM;
579}
580
581
582static inline int ipa_commit_rt(enum ipa_ip_type ip)
583{
584 return -EPERM;
585}
586
587
588static inline int ipa_reset_rt(enum ipa_ip_type ip)
589{
590 return -EPERM;
591}
592
593
594static inline int ipa_get_rt_tbl(struct ipa_ioc_get_rt_tbl *lookup)
595{
596 return -EPERM;
597}
598
599
600static inline int ipa_put_rt_tbl(u32 rt_tbl_hdl)
601{
602 return -EPERM;
603}
604
605
606/*
607 * Filtering
608 */
609static inline int ipa_add_flt_rule(struct ipa_ioc_add_flt_rule *rules)
610{
611 return -EPERM;
612}
613
614
615static inline int ipa_del_flt_rule(struct ipa_ioc_del_flt_rule *hdls)
616{
617 return -EPERM;
618}
619
620
621static inline int ipa_commit_flt(enum ipa_ip_type ip)
622{
623 return -EPERM;
624}
625
626
627static inline int ipa_reset_flt(enum ipa_ip_type ip)
628{
629 return -EPERM;
630}
631
632
633/*
634 * NAT
635 */
636static inline int allocate_nat_device(struct ipa_ioc_nat_alloc_mem *mem)
637{
638 return -EPERM;
639}
640
641
642static inline int ipa_nat_init_cmd(struct ipa_ioc_v4_nat_init *init)
643{
644 return -EPERM;
645}
646
647
648static inline int ipa_nat_dma_cmd(struct ipa_ioc_nat_dma_cmd *dma)
649{
650 return -EPERM;
651}
652
653
654static inline int ipa_nat_del_cmd(struct ipa_ioc_v4_nat_del *del)
655{
656 return -EPERM;
657}
658
659
660/*
661 * Aggregation
662 */
663static inline int ipa_set_aggr_mode(enum ipa_aggr_mode mode)
664{
665 return -EPERM;
666}
667
668
669static inline int ipa_set_qcncm_ndp_sig(char sig[3])
670{
671 return -EPERM;
672}
673
674
675static inline int ipa_set_single_ndp_per_mbim(bool enable)
676{
677 return -EPERM;
678}
679
680
681/*
682 * rmnet bridge
683 */
684static inline int rmnet_bridge_init(void)
685{
686 return -EPERM;
687}
688
689
690static inline int rmnet_bridge_disconnect(void)
691{
692 return -EPERM;
693}
694
695
696static inline int rmnet_bridge_connect(u32 producer_hdl,
697 u32 consumer_hdl,
698 int wwan_logical_channel_id)
699{
700 return -EPERM;
701}
702
703
704/*
705 * Data path
706 */
707static inline int ipa_tx_dp(enum ipa_client_type dst, struct sk_buff *skb,
708 struct ipa_tx_meta *metadata)
709{
710 return -EPERM;
711}
712
713
714/*
715 * System pipes
716 */
717static inline int ipa_setup_sys_pipe(struct ipa_sys_connect_params *sys_in,
718 u32 *clnt_hdl)
719{
720 return -EPERM;
721}
722
723
724static inline int ipa_teardown_sys_pipe(u32 clnt_hdl)
725{
726 return -EPERM;
727}
728
729
730#endif /* CONFIG_IPA*/
731
Talel Atias8390f262012-11-15 16:33:18 +0200732#endif /* _IPA_H_ */