msm_ipa.h 27 KB

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