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