1 /* 2 * Copyright (c) 2017-2019, The Linux Foundation. All rights reserved. 3 * 4 * Permission to use, copy, modify, and/or distribute this software for any 5 * purpose with or without fee is hereby granted, provided that the above 6 * copyright notice and this permission notice appear in all copies. 7 * 8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 11 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 13 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15 */ 16 17 #ifndef _DP_IPA_H_ 18 #define _DP_IPA_H_ 19 20 #ifdef IPA_OFFLOAD 21 22 #define DP_IPA_MAX_IFACE 3 23 #define IPA_TCL_DATA_RING_IDX 2 24 #define IPA_TX_COMP_RING_IDX 2 25 #define IPA_REO_DEST_RING_IDX 3 26 #define IPA_RX_REFILL_BUF_RING_IDX 2 27 28 /** 29 * struct dp_ipa_uc_tx_hdr - full tx header registered to IPA hardware 30 * @eth: ether II header 31 */ 32 struct dp_ipa_uc_tx_hdr { 33 struct ethhdr eth; 34 } __packed; 35 36 /** 37 * struct dp_ipa_uc_rx_hdr - full rx header registered to IPA hardware 38 * @eth: ether II header 39 */ 40 struct dp_ipa_uc_rx_hdr { 41 struct ethhdr eth; 42 } __packed; 43 44 #define DP_IPA_UC_WLAN_TX_HDR_LEN sizeof(struct dp_ipa_uc_tx_hdr) 45 #define DP_IPA_UC_WLAN_RX_HDR_LEN sizeof(struct dp_ipa_uc_rx_hdr) 46 #define DP_IPA_UC_WLAN_HDR_DES_MAC_OFFSET 0 47 48 /** 49 * dp_ipa_get_resource() - Client request resource information 50 * @soc_hdl - data path soc handle 51 * @pdev_id - device instance id 52 * 53 * IPA client will request IPA UC related resource information 54 * Resource information will be distributed to IPA module 55 * All of the required resources should be pre-allocated 56 * 57 * Return: QDF_STATUS 58 */ 59 QDF_STATUS dp_ipa_get_resource(struct cdp_soc_t *soc_hdl, uint8_t pdev_id); 60 61 /** 62 * dp_ipa_set_doorbell_paddr () - Set doorbell register physical address to SRNG 63 * @soc_hdl - data path soc handle 64 * @pdev_id - device instance id 65 * 66 * Set TX_COMP_DOORBELL register physical address to WBM Head_Ptr_MemAddr_LSB 67 * Set RX_READ_DOORBELL register physical address to REO Head_Ptr_MemAddr_LSB 68 * 69 * Return: none 70 */ 71 QDF_STATUS dp_ipa_set_doorbell_paddr(struct cdp_soc_t *soc_hdl, 72 uint8_t pdev_id); 73 QDF_STATUS dp_ipa_uc_set_active(struct cdp_soc_t *soc_hdl, uint8_t pdev_id, 74 bool uc_active, bool is_tx); 75 76 /** 77 * dp_ipa_op_response() - Handle OP command response from firmware 78 * @soc_hdl - data path soc handle 79 * @pdev_id - device instance id 80 * @op_msg: op response message from firmware 81 * 82 * Return: none 83 */ 84 QDF_STATUS dp_ipa_op_response(struct cdp_soc_t *soc_hdl, uint8_t pdev_id, 85 uint8_t *op_msg); 86 87 /** 88 * dp_ipa_register_op_cb() - Register OP handler function 89 * @soc_hdl - data path soc handle 90 * @pdev_id - device instance id 91 * @op_cb: handler function pointer 92 * 93 * Return: none 94 */ 95 QDF_STATUS dp_ipa_register_op_cb(struct cdp_soc_t *soc_hdl, uint8_t pdev_id, 96 ipa_uc_op_cb_type op_cb, void *usr_ctxt); 97 98 /** 99 * dp_ipa_get_stat() - Get firmware wdi status 100 * @soc_hdl - data path soc handle 101 * @pdev_id - device instance id 102 * 103 * Return: none 104 */ 105 QDF_STATUS dp_ipa_get_stat(struct cdp_soc_t *soc_hdl, uint8_t pdev_id); 106 107 /** 108 * dp_tx_send_ipa_data_frame() - send IPA data frame 109 * @soc_hdl: datapath soc handle 110 * @vdev_id: virtual device/interface id 111 * @skb: skb 112 * 113 * Return: skb/ NULL is for success 114 */ 115 qdf_nbuf_t dp_tx_send_ipa_data_frame(struct cdp_soc_t *soc_hdl, uint8_t vdev_id, 116 qdf_nbuf_t skb); 117 118 /** 119 * dp_ipa_enable_autonomy() – Enable autonomy RX path 120 * @soc_hdl - data path soc handle 121 * @pdev_id - device instance id 122 * 123 * Set all RX packet route to IPA REO ring 124 * Program Destination_Ring_Ctrl_IX_0 REO register to point IPA REO ring 125 * Return: none 126 */ 127 QDF_STATUS dp_ipa_enable_autonomy(struct cdp_soc_t *soc_hdl, uint8_t pdev_id); 128 129 /** 130 * dp_ipa_disable_autonomy() – Disable autonomy RX path 131 * @soc_hdl - data path soc handle 132 * @pdev_id - device instance id 133 * 134 * Disable RX packet routing to IPA REO 135 * Program Destination_Ring_Ctrl_IX_0 REO register to disable 136 * Return: none 137 */ 138 QDF_STATUS dp_ipa_disable_autonomy(struct cdp_soc_t *soc_hdl, uint8_t pdev_id); 139 140 #ifdef CONFIG_IPA_WDI_UNIFIED_API 141 /** 142 * dp_ipa_setup() - Setup and connect IPA pipes 143 * @soc_hdl - data path soc handle 144 * @pdev_id - device instance id 145 * @ipa_i2w_cb: IPA to WLAN callback 146 * @ipa_w2i_cb: WLAN to IPA callback 147 * @ipa_wdi_meter_notifier_cb: IPA WDI metering callback 148 * @ipa_desc_size: IPA descriptor size 149 * @ipa_priv: handle to the HTT instance 150 * @is_rm_enabled: Is IPA RM enabled or not 151 * @tx_pipe_handle: pointer to Tx pipe handle 152 * @rx_pipe_handle: pointer to Rx pipe handle 153 * @is_smmu_enabled: Is SMMU enabled or not 154 * @sys_in: parameters to setup sys pipe in mcc mode 155 * 156 * Return: QDF_STATUS 157 */ 158 QDF_STATUS dp_ipa_setup(struct cdp_soc_t *soc_hdl, uint8_t pdev_id, 159 void *ipa_i2w_cb, void *ipa_w2i_cb, 160 void *ipa_wdi_meter_notifier_cb, 161 uint32_t ipa_desc_size, void *ipa_priv, 162 bool is_rm_enabled, uint32_t *tx_pipe_handle, 163 uint32_t *rx_pipe_handle, 164 bool is_smmu_enabled, 165 qdf_ipa_sys_connect_params_t *sys_in, bool over_gsi); 166 #else /* CONFIG_IPA_WDI_UNIFIED_API */ 167 /** 168 * dp_ipa_setup() - Setup and connect IPA pipes 169 * @soc_hdl - data path soc handle 170 * @pdev_id - device instance id 171 * @ipa_i2w_cb: IPA to WLAN callback 172 * @ipa_w2i_cb: WLAN to IPA callback 173 * @ipa_wdi_meter_notifier_cb: IPA WDI metering callback 174 * @ipa_desc_size: IPA descriptor size 175 * @ipa_priv: handle to the HTT instance 176 * @is_rm_enabled: Is IPA RM enabled or not 177 * @tx_pipe_handle: pointer to Tx pipe handle 178 * @rx_pipe_handle: pointer to Rx pipe handle 179 * 180 * Return: QDF_STATUS 181 */ 182 QDF_STATUS dp_ipa_setup(struct cdp_soc_t *soc_hdl, uint8_t pdev_id, 183 void *ipa_i2w_cb, void *ipa_w2i_cb, 184 void *ipa_wdi_meter_notifier_cb, 185 uint32_t ipa_desc_size, void *ipa_priv, 186 bool is_rm_enabled, uint32_t *tx_pipe_handle, 187 uint32_t *rx_pipe_handle); 188 #endif /* CONFIG_IPA_WDI_UNIFIED_API */ 189 QDF_STATUS dp_ipa_cleanup(uint32_t tx_pipe_handle, 190 uint32_t rx_pipe_handle); 191 QDF_STATUS dp_ipa_remove_header(char *name); 192 int dp_ipa_add_header_info(char *ifname, uint8_t *mac_addr, 193 uint8_t session_id, bool is_ipv6_enabled); 194 int dp_ipa_register_interface(char *ifname, bool is_ipv6_enabled); 195 QDF_STATUS dp_ipa_setup_iface(char *ifname, uint8_t *mac_addr, 196 qdf_ipa_client_type_t prod_client, 197 qdf_ipa_client_type_t cons_client, 198 uint8_t session_id, bool is_ipv6_enabled); 199 QDF_STATUS dp_ipa_cleanup_iface(char *ifname, bool is_ipv6_enabled); 200 201 /** 202 * dp_ipa_uc_enable_pipes() - Enable and resume traffic on Tx/Rx pipes 203 * @soc_hdl - handle to the soc 204 * @pdev_id - pdev id number, to get the handle 205 * 206 * Return: QDF_STATUS 207 */ 208 QDF_STATUS dp_ipa_enable_pipes(struct cdp_soc_t *soc_hdl, uint8_t pdev_id); 209 210 /** 211 * dp_ipa_disable_pipes() – Suspend traffic and disable Tx/Rx pipes 212 * @soc_hdl - handle to the soc 213 * @pdev_id - pdev id number, to get the handle 214 * 215 * Return: QDF_STATUS 216 */ 217 QDF_STATUS dp_ipa_disable_pipes(struct cdp_soc_t *soc_hdl, uint8_t pdev_id); 218 QDF_STATUS dp_ipa_set_perf_level(int client, 219 uint32_t max_supported_bw_mbps); 220 221 /** 222 * dp_ipa_rx_intrabss_fwd() - Perform intra-bss fwd for IPA RX path 223 * 224 * @soc_hdl: data path soc handle 225 * @vdev_id: virtual device/interface id 226 * @nbuf: pointer to skb of ethernet packet received from IPA RX path 227 * @fwd_success: pointer to indicate if skb succeeded in intra-bss TX 228 * 229 * This function performs intra-bss forwarding for WDI 3.0 IPA RX path. 230 * 231 * Return: true if packet is intra-bss fwd-ed and no need to pass to 232 * network stack. false if packet needs to be passed to network stack. 233 */ 234 bool dp_ipa_rx_intrabss_fwd(struct cdp_soc_t *soc_hdl, uint8_t vdev_id, 235 qdf_nbuf_t nbuf, bool *fwd_success); 236 int dp_ipa_uc_detach(struct dp_soc *soc, struct dp_pdev *pdev); 237 int dp_ipa_uc_attach(struct dp_soc *soc, struct dp_pdev *pdev); 238 int dp_ipa_ring_resource_setup(struct dp_soc *soc, 239 struct dp_pdev *pdev); 240 QDF_STATUS dp_ipa_handle_rx_buf_smmu_mapping(struct dp_soc *soc, 241 qdf_nbuf_t nbuf, 242 bool create); 243 244 bool dp_reo_remap_config(struct dp_soc *soc, uint32_t *remap1, 245 uint32_t *remap2); 246 bool dp_ipa_is_mdm_platform(void); 247 248 qdf_nbuf_t dp_ipa_handle_rx_reo_reinject(struct dp_soc *soc, qdf_nbuf_t nbuf); 249 250 #else 251 static inline int dp_ipa_uc_detach(struct dp_soc *soc, struct dp_pdev *pdev) 252 { 253 return QDF_STATUS_SUCCESS; 254 } 255 256 static inline int dp_ipa_uc_attach(struct dp_soc *soc, struct dp_pdev *pdev) 257 { 258 return QDF_STATUS_SUCCESS; 259 } 260 261 static inline int dp_ipa_ring_resource_setup(struct dp_soc *soc, 262 struct dp_pdev *pdev) 263 { 264 return 0; 265 } 266 267 static inline QDF_STATUS dp_ipa_handle_rx_buf_smmu_mapping(struct dp_soc *soc, 268 qdf_nbuf_t nbuf, 269 bool create) 270 { 271 return QDF_STATUS_SUCCESS; 272 } 273 274 static inline qdf_nbuf_t dp_ipa_handle_rx_reo_reinject(struct dp_soc *soc, 275 qdf_nbuf_t nbuf) 276 { 277 return nbuf; 278 } 279 280 #endif 281 #endif /* _DP_IPA_H_ */ 282