ipa_api.h 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (c) 2015-2020, The Linux Foundation. All rights reserved.
  4. */
  5. #include <linux/ipa_mhi.h>
  6. #include <linux/ipa_uc_offload.h>
  7. #include <linux/ipa_wdi3.h>
  8. #include "ipa_common_i.h"
  9. #ifndef _IPA_API_H_
  10. #define _IPA_API_H_
  11. struct ipa_api_controller {
  12. int (*ipa_cfg_ep)(u32 clnt_hdl, const struct ipa_ep_cfg *ipa_ep_cfg);
  13. int (*ipa_cfg_ep_nat)(u32 clnt_hdl,
  14. const struct ipa_ep_cfg_nat *ipa_ep_cfg);
  15. int (*ipa_cfg_ep_conn_track)(u32 clnt_hdl,
  16. const struct ipa_ep_cfg_conn_track *ipa_ep_cfg);
  17. int (*ipa_cfg_ep_hdr)(u32 clnt_hdl,
  18. const struct ipa_ep_cfg_hdr *ipa_ep_cfg);
  19. int (*ipa_cfg_ep_hdr_ext)(u32 clnt_hdl,
  20. const struct ipa_ep_cfg_hdr_ext *ipa_ep_cfg);
  21. int (*ipa_cfg_ep_mode)(u32 clnt_hdl,
  22. const struct ipa_ep_cfg_mode *ipa_ep_cfg);
  23. int (*ipa_cfg_ep_aggr)(u32 clnt_hdl,
  24. const struct ipa_ep_cfg_aggr *ipa_ep_cfg);
  25. int (*ipa_cfg_ep_deaggr)(u32 clnt_hdl,
  26. const struct ipa_ep_cfg_deaggr *ipa_ep_cfg);
  27. int (*ipa_cfg_ep_route)(u32 clnt_hdl,
  28. const struct ipa_ep_cfg_route *ipa_ep_cfg);
  29. int (*ipa_cfg_ep_holb)(u32 clnt_hdl,
  30. const struct ipa_ep_cfg_holb *ipa_ep_cfg);
  31. int (*ipa_cfg_ep_cfg)(u32 clnt_hdl,
  32. const struct ipa_ep_cfg_cfg *ipa_ep_cfg);
  33. int (*ipa_cfg_ep_metadata_mask)(u32 clnt_hdl,
  34. const struct ipa_ep_cfg_metadata_mask *ipa_ep_cfg);
  35. int (*ipa_cfg_ep_holb_by_client)(enum ipa_client_type client,
  36. const struct ipa_ep_cfg_holb *ipa_ep_cfg);
  37. int (*ipa_add_hdr_usr)(struct ipa_ioc_add_hdr *hdrs, bool user_only);
  38. int (*ipa_reset_hdr)(bool user_only);
  39. int (*ipa_add_hdr_proc_ctx)(struct ipa_ioc_add_hdr_proc_ctx *proc_ctxs,
  40. bool user_only);
  41. int (*ipa_del_hdr_proc_ctx)(struct ipa_ioc_del_hdr_proc_ctx *hdls);
  42. int (*ipa_add_rt_rule_v2)(struct ipa_ioc_add_rt_rule_v2 *rules);
  43. int (*ipa_add_rt_rule_usr)(struct ipa_ioc_add_rt_rule *rules,
  44. bool user_only);
  45. int (*ipa_add_rt_rule_usr_v2)(struct ipa_ioc_add_rt_rule_v2 *rules,
  46. bool user_only);
  47. int (*ipa_del_rt_rule)(struct ipa_ioc_del_rt_rule *hdls);
  48. int (*ipa_commit_rt)(enum ipa_ip_type ip);
  49. int (*ipa_reset_rt)(enum ipa_ip_type ip, bool user_only);
  50. int (*ipa_get_rt_tbl)(struct ipa_ioc_get_rt_tbl *lookup);
  51. int (*ipa_query_rt_index)(struct ipa_ioc_get_rt_tbl_indx *in);
  52. int (*ipa_mdfy_rt_rule)(struct ipa_ioc_mdfy_rt_rule *rules);
  53. int (*ipa_mdfy_rt_rule_v2)(struct ipa_ioc_mdfy_rt_rule_v2 *rules);
  54. int (*ipa_add_flt_rule)(struct ipa_ioc_add_flt_rule *rules);
  55. int (*ipa_add_flt_rule_v2)(struct ipa_ioc_add_flt_rule_v2 *rules);
  56. int (*ipa_add_flt_rule_usr)(struct ipa_ioc_add_flt_rule *rules,
  57. bool user_only);
  58. int (*ipa_add_flt_rule_usr_v2)
  59. (struct ipa_ioc_add_flt_rule_v2 *rules, bool user_only);
  60. int (*ipa_del_flt_rule)(struct ipa_ioc_del_flt_rule *hdls);
  61. int (*ipa_mdfy_flt_rule)(struct ipa_ioc_mdfy_flt_rule *rules);
  62. int (*ipa_mdfy_flt_rule_v2)(struct ipa_ioc_mdfy_flt_rule_v2 *rules);
  63. int (*ipa_commit_flt)(enum ipa_ip_type ip);
  64. int (*ipa_reset_flt)(enum ipa_ip_type ip, bool user_only);
  65. int (*ipa_allocate_nat_device)(struct ipa_ioc_nat_alloc_mem *mem);
  66. int (*ipa_allocate_nat_table)(
  67. struct ipa_ioc_nat_ipv6ct_table_alloc *table_alloc);
  68. int (*ipa_allocate_ipv6ct_table)(
  69. struct ipa_ioc_nat_ipv6ct_table_alloc *table_alloc);
  70. int (*ipa_nat_init_cmd)(struct ipa_ioc_v4_nat_init *init);
  71. int (*ipa_ipv6ct_init_cmd)(struct ipa_ioc_ipv6ct_init *init);
  72. int (*ipa_nat_dma_cmd)(struct ipa_ioc_nat_dma_cmd *dma);
  73. int (*ipa_table_dma_cmd)(struct ipa_ioc_nat_dma_cmd *dma);
  74. int (*ipa_nat_del_cmd)(struct ipa_ioc_v4_nat_del *del);
  75. int (*ipa_del_nat_table)(struct ipa_ioc_nat_ipv6ct_table_del *del);
  76. int (*ipa_del_ipv6ct_table)(struct ipa_ioc_nat_ipv6ct_table_del *del);
  77. int (*ipa_nat_mdfy_pdn)(struct ipa_ioc_nat_pdn_entry *mdfy_pdn);
  78. int (*ipa_sys_setup)(struct ipa_sys_connect_params *sys_in,
  79. unsigned long *ipa_bam_hdl,
  80. u32 *ipa_pipe_num, u32 *clnt_hdl, bool en_status);
  81. int (*ipa_sys_teardown)(u32 clnt_hdl);
  82. int (*ipa_sys_update_gsi_hdls)(u32 clnt_hdl, unsigned long gsi_ch_hdl,
  83. unsigned long gsi_ev_hdl);
  84. int (*ipa_set_wlan_tx_info)(struct ipa_wdi_tx_info *info);
  85. int (*teth_bridge_init)(struct teth_bridge_init_params *params);
  86. int (*teth_bridge_disconnect)(enum ipa_client_type client);
  87. int (*teth_bridge_connect)(
  88. struct teth_bridge_connect_params *connect_params);
  89. void (*ipa_set_client)(
  90. int index, enum ipacm_client_enum client, bool uplink);
  91. enum ipacm_client_enum (*ipa_get_client)(int pipe_idx);
  92. bool (*ipa_get_client_uplink)(int pipe_idx);
  93. bool (*ipa_has_open_aggr_frame)(enum ipa_client_type client);
  94. int (*ipa_generate_tag_process)(void);
  95. int (*ipa_disable_sps_pipe)(enum ipa_client_type client);
  96. void (*ipa_set_tag_process_before_gating)(bool val);
  97. int (*ipa_mhi_init_engine)(struct ipa_mhi_init_engine *params);
  98. int (*ipa_connect_mhi_pipe)(struct ipa_mhi_connect_params_internal *in,
  99. u32 *clnt_hdl);
  100. int (*ipa_disconnect_mhi_pipe)(u32 clnt_hdl);
  101. bool (*ipa_mhi_stop_gsi_channel)(enum ipa_client_type client);
  102. int (*ipa_qmi_disable_force_clear)(u32 request_id);
  103. int (*ipa_qmi_enable_force_clear_datapath_send)(
  104. struct ipa_enable_force_clear_datapath_req_msg_v01 *req);
  105. int (*ipa_qmi_disable_force_clear_datapath_send)(
  106. struct ipa_disable_force_clear_datapath_req_msg_v01 *req);
  107. bool (*ipa_mhi_sps_channel_empty)(enum ipa_client_type client);
  108. int (*ipa_mhi_reset_channel_internal)(enum ipa_client_type client);
  109. int (*ipa_mhi_start_channel_internal)(enum ipa_client_type client);
  110. void (*ipa_get_holb)(int ep_idx, struct ipa_ep_cfg_holb *holb);
  111. int (*ipa_mhi_query_ch_info)(enum ipa_client_type client,
  112. struct gsi_chan_info *ch_info);
  113. int (*ipa_mhi_resume_channels_internal)(
  114. enum ipa_client_type client,
  115. bool LPTransitionRejected,
  116. bool brstmode_enabled,
  117. union __packed gsi_channel_scratch ch_scratch,
  118. u8 index);
  119. int (*ipa_mhi_destroy_channel)(enum ipa_client_type client);
  120. int (*ipa_uc_mhi_send_dl_ul_sync_info)
  121. (union IpaHwMhiDlUlSyncCmdData_t *cmd);
  122. int (*ipa_uc_mhi_init)
  123. (void (*ready_cb)(void), void (*wakeup_request_cb)(void));
  124. void (*ipa_uc_mhi_cleanup)(void);
  125. int (*ipa_uc_mhi_print_stats)(char *dbg_buff, int size);
  126. int (*ipa_uc_mhi_reset_channel)(int channelHandle);
  127. int (*ipa_uc_mhi_suspend_channel)(int channelHandle);
  128. int (*ipa_uc_mhi_stop_event_update_channel)(int channelHandle);
  129. int (*ipa_uc_state_check)(void);
  130. int (*ipa_write_qmap_id)(struct ipa_ioc_write_qmapid *param_in);
  131. int (*ipa_remove_interrupt_handler)(enum ipa_irq_type interrupt);
  132. int (*ipa_ap_suspend)(struct device *dev);
  133. int (*ipa_ap_resume)(struct device *dev);
  134. int (*ipa_start_gsi_channel)(u32 clnt_hdl);
  135. void (*ipa_inc_client_enable_clks)(
  136. struct ipa_active_client_logging_info *id);
  137. void (*ipa_dec_client_disable_clks)(
  138. struct ipa_active_client_logging_info *id);
  139. int (*ipa_inc_client_enable_clks_no_block)(
  140. struct ipa_active_client_logging_info *id);
  141. int (*ipa_suspend_resource_no_block)(
  142. enum ipa_rm_resource_name resource);
  143. int (*ipa_resume_resource)(enum ipa_rm_resource_name name);
  144. int (*ipa_suspend_resource_sync)(enum ipa_rm_resource_name resource);
  145. int (*ipa_set_required_perf_profile)(
  146. enum ipa_voltage_level floor_voltage, u32 bandwidth_mbps);
  147. void *(*ipa_get_ipc_logbuf)(void);
  148. void *(*ipa_get_ipc_logbuf_low)(void);
  149. int (*ipa_rx_poll)(u32 clnt_hdl, int budget);
  150. void (*ipa_recycle_wan_skb)(struct sk_buff *skb);
  151. int (*ipa_setup_uc_ntn_pipes)(struct ipa_ntn_conn_in_params *in,
  152. ipa_notify_cb notify, void *priv, u8 hdr_len,
  153. struct ipa_ntn_conn_out_params *outp);
  154. int (*ipa_tear_down_uc_offload_pipes)(int ipa_ep_idx_ul,
  155. int ipa_ep_idx_dl, struct ipa_ntn_conn_in_params *params);
  156. struct device *(*ipa_get_pdev)(void);
  157. int (*ipa_ntn_uc_reg_rdyCB)(void (*ipauc_ready_cb)(void *user_data),
  158. void *user_data);
  159. void (*ipa_ntn_uc_dereg_rdyCB)(void);
  160. int (*ipa_conn_wdi_pipes)(struct ipa_wdi_conn_in_params *in,
  161. struct ipa_wdi_conn_out_params *out,
  162. ipa_wdi_meter_notifier_cb wdi_notify);
  163. int (*ipa_disconn_wdi_pipes)(int ipa_ep_idx_tx,
  164. int ipa_ep_idx_rx);
  165. int (*ipa_enable_wdi_pipes)(int ipa_ep_idx_tx,
  166. int ipa_ep_idx_rx);
  167. int (*ipa_disable_wdi_pipes)(int ipa_ep_idx_tx,
  168. int ipa_ep_idx_rx);
  169. int (*ipa_tz_unlock_reg)(struct ipa_tz_unlock_reg_info *reg_info,
  170. u16 num_regs);
  171. int (*ipa_get_smmu_params)(struct ipa_smmu_in_params *in,
  172. struct ipa_smmu_out_params *out);
  173. int (*ipa_is_vlan_mode)(enum ipa_vlan_ifaces iface, bool *res);
  174. int (*ipa_wigig_internal_init)(
  175. struct ipa_wdi_uc_ready_params *inout,
  176. ipa_wigig_misc_int_cb int_notify,
  177. phys_addr_t *uc_db_pa);
  178. int (*ipa_conn_wigig_rx_pipe_i)(void *in,
  179. struct ipa_wigig_conn_out_params *out,
  180. struct dentry **parent);
  181. int (*ipa_conn_wigig_client_i)(void *in,
  182. struct ipa_wigig_conn_out_params *out,
  183. ipa_notify_cb tx_notify,
  184. void *priv);
  185. int (*ipa_disconn_wigig_pipe_i)(enum ipa_client_type client,
  186. struct ipa_wigig_pipe_setup_info_smmu *pipe_smmu,
  187. void *dbuff);
  188. int (*ipa_wigig_uc_msi_init)(bool init,
  189. phys_addr_t periph_baddr_pa,
  190. phys_addr_t pseudo_cause_pa,
  191. phys_addr_t int_gen_tx_pa,
  192. phys_addr_t int_gen_rx_pa,
  193. phys_addr_t dma_ep_misc_pa);
  194. int (*ipa_enable_wigig_pipe_i)(enum ipa_client_type client);
  195. int (*ipa_disable_wigig_pipe_i)(enum ipa_client_type client);
  196. void (*ipa_register_client_callback)(
  197. int (*client_cb)(bool is_lock),
  198. bool (*teth_port_state)(void), enum ipa_client_type client);
  199. void (*ipa_deregister_client_callback)(enum ipa_client_type client);
  200. int (*ipa_uc_debug_stats_alloc)(
  201. struct IpaHwOffloadStatsAllocCmdData_t cmdinfo);
  202. int (*ipa_uc_debug_stats_dealloc)(uint32_t prot_id);
  203. void (*ipa_get_gsi_stats)(int prot_id,
  204. struct ipa_uc_dbg_ring_stats *stats);
  205. int (*ipa_get_prot_id)(enum ipa_client_type client);
  206. };
  207. #if IS_ENABLED(CONFIG_IPA3)
  208. int ipa3_plat_drv_probe(struct platform_device *pdev_p,
  209. struct ipa_api_controller *api_ctrl,
  210. const struct of_device_id *pdrv_match);
  211. int ipa3_pci_drv_probe(
  212. struct pci_dev *pci_dev,
  213. struct ipa_api_controller *api_ctrl,
  214. const struct of_device_id *pdrv_match);
  215. #else /* IS_ENABLED(CONFIG_IPA3) */
  216. static inline int ipa3_plat_drv_probe(struct platform_device *pdev_p,
  217. struct ipa_api_controller *api_ctrl,
  218. const struct of_device_id *pdrv_match)
  219. {
  220. return -ENODEV;
  221. }
  222. static inline int ipa3_pci_drv_probe(
  223. struct pci_dev *pci_dev,
  224. struct ipa_api_controller *api_ctrl,
  225. const struct of_device_id *pdrv_match)
  226. {
  227. return -ENODEV;
  228. }
  229. #endif /* IS_ENABLED(CONFIG_IPA3) */
  230. #endif /* _IPA_API_H_ */