Chandana Kishori Chiluveru | 50a2184 | 2017-11-06 14:54:24 +0530 | [diff] [blame] | 1 | /* Copyright (c) 2014,2016 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 __U_DATA_IPA_H |
| 14 | #define __U_DATA_IPA_H |
| 15 | |
| 16 | #include <linux/usb/composite.h> |
| 17 | #include <linux/rndis_ipa.h> |
| 18 | #include <linux/usb/gadget.h> |
| 19 | #include <linux/cdev.h> |
| 20 | #include <linux/ipa_usb.h> |
| 21 | #include <linux/usb_bam.h> |
| 22 | |
| 23 | #include "u_rmnet.h" |
| 24 | |
| 25 | enum ipa_func_type { |
| 26 | USB_IPA_FUNC_ECM, |
| 27 | USB_IPA_FUNC_MBIM, |
| 28 | USB_IPA_FUNC_RMNET, |
| 29 | USB_IPA_FUNC_RNDIS, |
| 30 | USB_IPA_FUNC_DPL, |
| 31 | USB_IPA_NUM_FUNCS, |
| 32 | }; |
| 33 | |
| 34 | /* Max Number of IPA data ports supported */ |
| 35 | #define IPA_N_PORTS USB_IPA_NUM_FUNCS |
| 36 | |
| 37 | struct gadget_ipa_port { |
| 38 | struct usb_composite_dev *cdev; |
| 39 | struct usb_function *func; |
| 40 | int rx_buffer_size; |
| 41 | struct usb_ep *in; |
| 42 | struct usb_ep *out; |
| 43 | int ipa_consumer_ep; |
| 44 | int ipa_producer_ep; |
| 45 | const struct usb_endpoint_descriptor *in_ep_desc_backup; |
| 46 | const struct usb_endpoint_descriptor *out_ep_desc_backup; |
| 47 | |
| 48 | }; |
| 49 | |
| 50 | struct ipa_function_bind_info { |
| 51 | struct usb_string *string_defs; |
| 52 | int data_str_idx; |
| 53 | struct usb_interface_descriptor *data_desc; |
| 54 | struct usb_endpoint_descriptor *fs_in_desc; |
| 55 | struct usb_endpoint_descriptor *fs_out_desc; |
| 56 | struct usb_endpoint_descriptor *fs_notify_desc; |
| 57 | struct usb_endpoint_descriptor *hs_in_desc; |
| 58 | struct usb_endpoint_descriptor *hs_out_desc; |
| 59 | struct usb_endpoint_descriptor *hs_notify_desc; |
| 60 | struct usb_endpoint_descriptor *ss_in_desc; |
| 61 | struct usb_endpoint_descriptor *ss_out_desc; |
| 62 | struct usb_endpoint_descriptor *ss_notify_desc; |
| 63 | |
| 64 | struct usb_descriptor_header **fs_desc_hdr; |
| 65 | struct usb_descriptor_header **hs_desc_hdr; |
| 66 | struct usb_descriptor_header **ss_desc_hdr; |
| 67 | }; |
| 68 | |
| 69 | /* for configfs support */ |
| 70 | #define MAX_INST_NAME_LEN 40 |
| 71 | |
| 72 | struct f_rndis_qc_opts { |
| 73 | struct usb_function_instance func_inst; |
| 74 | struct f_rndis_qc *rndis; |
| 75 | u32 vendor_id; |
| 76 | const char *manufacturer; |
| 77 | struct net_device *net; |
| 78 | int refcnt; |
| 79 | }; |
| 80 | |
| 81 | struct f_rmnet_opts { |
| 82 | struct usb_function_instance func_inst; |
| 83 | struct f_rmnet *dev; |
| 84 | int refcnt; |
| 85 | }; |
| 86 | |
| 87 | void ipa_data_port_select(enum ipa_func_type func); |
| 88 | void ipa_data_disconnect(struct gadget_ipa_port *gp, enum ipa_func_type func); |
| 89 | int ipa_data_connect(struct gadget_ipa_port *gp, enum ipa_func_type func, |
| 90 | u8 src_connection_idx, u8 dst_connection_idx); |
| 91 | int ipa_data_setup(enum ipa_func_type func); |
| 92 | void ipa_data_free(enum ipa_func_type func); |
| 93 | |
| 94 | void ipa_data_flush_workqueue(void); |
| 95 | void ipa_data_resume(struct gadget_ipa_port *gp, enum ipa_func_type func, |
| 96 | bool remote_wakeup_enabled); |
| 97 | void ipa_data_suspend(struct gadget_ipa_port *gp, enum ipa_func_type func, |
| 98 | bool remote_wakeup_enabled); |
| 99 | |
| 100 | void ipa_data_set_ul_max_xfer_size(u32 ul_max_xfer_size); |
| 101 | |
| 102 | void ipa_data_set_dl_max_xfer_size(u32 dl_max_transfer_size); |
| 103 | |
| 104 | void ipa_data_set_ul_max_pkt_num(u8 ul_max_packets_number); |
| 105 | |
| 106 | void ipa_data_start_rx_tx(enum ipa_func_type func); |
| 107 | |
| 108 | void ipa_data_start_rndis_ipa(enum ipa_func_type func); |
| 109 | |
| 110 | void ipa_data_stop_rndis_ipa(enum ipa_func_type func); |
| 111 | |
| 112 | void *rndis_qc_get_ipa_priv(void); |
| 113 | void *rndis_qc_get_ipa_rx_cb(void); |
| 114 | bool rndis_qc_get_skip_ep_config(void); |
| 115 | void *rndis_qc_get_ipa_tx_cb(void); |
| 116 | void rndis_ipa_reset_trigger(void); |
| 117 | #if IS_ENABLED(CONFIG_USB_CONFIGFS_RMNET_BAM) |
| 118 | void gqti_ctrl_update_ipa_pipes(void *gr, enum qti_port_type qport, |
| 119 | u32 ipa_prod, u32 ipa_cons); |
| 120 | #else |
| 121 | static inline void gqti_ctrl_update_ipa_pipes(void *gr, |
| 122 | enum qti_port_type qport, |
| 123 | u32 ipa_prod, u32 ipa_cons) |
| 124 | { |
| 125 | } |
| 126 | #endif /* CONFIG_USB_CONFIGFS_RMNET_BAM */ |
| 127 | #endif |