Talel Atias | 8390f26 | 2012-11-15 16:33:18 +0200 | [diff] [blame] | 1 | /* 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 | */ |
| 24 | enum 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 | */ |
| 36 | enum 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 | */ |
| 47 | enum 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 | */ |
| 56 | enum 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 | */ |
| 65 | enum 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 | */ |
| 76 | enum 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 | */ |
| 87 | struct 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 | */ |
| 128 | struct 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 | */ |
| 147 | struct 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 | */ |
| 169 | struct 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 | */ |
| 184 | struct 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 | */ |
| 196 | struct 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 | */ |
| 225 | struct 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 | */ |
| 248 | struct 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 | */ |
| 260 | struct 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 | */ |
| 270 | struct 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 | */ |
| 288 | struct 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 | */ |
| 305 | struct 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 | */ |
| 316 | struct 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 | */ |
| 330 | struct 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 | */ |
| 347 | typedef int (*ipa_pull_fn)(void *buf, uint16_t sz); |
| 348 | |
| 349 | /* |
| 350 | * Connect / Disconnect |
| 351 | */ |
| 352 | int ipa_connect(const struct ipa_connect_params *in, struct ipa_sps_params *sps, |
| 353 | u32 *clnt_hdl); |
| 354 | int ipa_disconnect(u32 clnt_hdl); |
| 355 | |
| 356 | /* |
| 357 | * Configuration |
| 358 | */ |
| 359 | int ipa_cfg_ep(u32 clnt_hdl, const struct ipa_ep_cfg *ipa_ep_cfg); |
| 360 | |
| 361 | int ipa_cfg_ep_nat(u32 clnt_hdl, const struct ipa_ep_cfg_nat *ipa_ep_cfg); |
| 362 | |
| 363 | int ipa_cfg_ep_hdr(u32 clnt_hdl, const struct ipa_ep_cfg_hdr *ipa_ep_cfg); |
| 364 | |
| 365 | int ipa_cfg_ep_mode(u32 clnt_hdl, const struct ipa_ep_cfg_mode *ipa_ep_cfg); |
| 366 | |
| 367 | int ipa_cfg_ep_aggr(u32 clnt_hdl, const struct ipa_ep_cfg_aggr *ipa_ep_cfg); |
| 368 | |
| 369 | int ipa_cfg_ep_route(u32 clnt_hdl, const struct ipa_ep_cfg_route *ipa_ep_cfg); |
| 370 | |
| 371 | /* |
| 372 | * Header removal / addition |
| 373 | */ |
| 374 | int ipa_add_hdr(struct ipa_ioc_add_hdr *hdrs); |
| 375 | |
| 376 | int ipa_del_hdr(struct ipa_ioc_del_hdr *hdls); |
| 377 | |
| 378 | int ipa_commit_hdr(void); |
| 379 | |
| 380 | int ipa_reset_hdr(void); |
| 381 | |
| 382 | int ipa_get_hdr(struct ipa_ioc_get_hdr *lookup); |
| 383 | |
| 384 | int ipa_put_hdr(u32 hdr_hdl); |
| 385 | |
| 386 | int ipa_copy_hdr(struct ipa_ioc_copy_hdr *copy); |
| 387 | |
| 388 | /* |
| 389 | * Routing |
| 390 | */ |
| 391 | int ipa_add_rt_rule(struct ipa_ioc_add_rt_rule *rules); |
| 392 | |
| 393 | int ipa_del_rt_rule(struct ipa_ioc_del_rt_rule *hdls); |
| 394 | |
| 395 | int ipa_commit_rt(enum ipa_ip_type ip); |
| 396 | |
| 397 | int ipa_reset_rt(enum ipa_ip_type ip); |
| 398 | |
| 399 | int ipa_get_rt_tbl(struct ipa_ioc_get_rt_tbl *lookup); |
| 400 | |
| 401 | int ipa_put_rt_tbl(u32 rt_tbl_hdl); |
| 402 | |
| 403 | /* |
| 404 | * Filtering |
| 405 | */ |
| 406 | int ipa_add_flt_rule(struct ipa_ioc_add_flt_rule *rules); |
| 407 | |
| 408 | int ipa_del_flt_rule(struct ipa_ioc_del_flt_rule *hdls); |
| 409 | |
| 410 | int ipa_commit_flt(enum ipa_ip_type ip); |
| 411 | |
| 412 | int ipa_reset_flt(enum ipa_ip_type ip); |
| 413 | |
| 414 | /* |
| 415 | * NAT |
| 416 | */ |
| 417 | int allocate_nat_device(struct ipa_ioc_nat_alloc_mem *mem); |
| 418 | |
| 419 | int ipa_nat_init_cmd(struct ipa_ioc_v4_nat_init *init); |
| 420 | |
| 421 | int ipa_nat_dma_cmd(struct ipa_ioc_nat_dma_cmd *dma); |
| 422 | |
| 423 | int ipa_nat_del_cmd(struct ipa_ioc_v4_nat_del *del); |
| 424 | |
| 425 | /* |
| 426 | * Aggregation |
| 427 | */ |
| 428 | int ipa_set_aggr_mode(enum ipa_aggr_mode mode); |
| 429 | |
| 430 | int ipa_set_qcncm_ndp_sig(char sig[3]); |
| 431 | |
| 432 | int ipa_set_single_ndp_per_mbim(bool enable); |
| 433 | |
| 434 | /* |
| 435 | * rmnet bridge |
| 436 | */ |
| 437 | int rmnet_bridge_init(void); |
| 438 | |
| 439 | int rmnet_bridge_disconnect(void); |
| 440 | |
| 441 | int rmnet_bridge_connect(u32 producer_hdl, |
| 442 | u32 consumer_hdl, |
| 443 | int wwan_logical_channel_id); |
| 444 | |
| 445 | /* |
| 446 | * Data path |
| 447 | */ |
| 448 | int ipa_tx_dp(enum ipa_client_type dst, struct sk_buff *skb, |
| 449 | struct ipa_tx_meta *metadata); |
| 450 | |
| 451 | /* |
| 452 | * System pipes |
| 453 | */ |
| 454 | int ipa_setup_sys_pipe(struct ipa_sys_connect_params *sys_in, u32 *clnt_hdl); |
| 455 | |
| 456 | int ipa_teardown_sys_pipe(u32 clnt_hdl); |
| 457 | |
| 458 | #endif /* _IPA_H_ */ |