1 /* 2 * Copyright (c) 2017-2020, 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 #define IPA_TCL_DATA_RING_IDX 2 21 #ifdef IPA_OFFLOAD 22 23 #define DP_IPA_MAX_IFACE 3 24 #define IPA_REO_DEST_RING_IDX 3 25 #define IPA_RX_REFILL_BUF_RING_IDX 2 26 27 /* Adding delay before disabling ipa pipes if any Tx Completions are pending */ 28 #define TX_COMP_DRAIN_WAIT_MS 50 29 #define TX_COMP_DRAIN_WAIT_TIMEOUT_MS 100 30 31 /** 32 * struct dp_ipa_uc_tx_hdr - full tx header registered to IPA hardware 33 * @eth: ether II header 34 */ 35 struct dp_ipa_uc_tx_hdr { 36 struct ethhdr eth; 37 } __packed; 38 39 /** 40 * struct dp_ipa_uc_rx_hdr - full rx header registered to IPA hardware 41 * @eth: ether II header 42 */ 43 struct dp_ipa_uc_rx_hdr { 44 struct ethhdr eth; 45 } __packed; 46 47 #define DP_IPA_UC_WLAN_TX_HDR_LEN sizeof(struct dp_ipa_uc_tx_hdr) 48 #define DP_IPA_UC_WLAN_RX_HDR_LEN sizeof(struct dp_ipa_uc_rx_hdr) 49 #define DP_IPA_UC_WLAN_HDR_DES_MAC_OFFSET 0 50 51 /** 52 * dp_ipa_get_resource() - Client request resource information 53 * @soc_hdl - data path soc handle 54 * @pdev_id - device instance id 55 * 56 * IPA client will request IPA UC related resource information 57 * Resource information will be distributed to IPA module 58 * All of the required resources should be pre-allocated 59 * 60 * Return: QDF_STATUS 61 */ 62 QDF_STATUS dp_ipa_get_resource(struct cdp_soc_t *soc_hdl, uint8_t pdev_id); 63 64 /** 65 * dp_ipa_set_doorbell_paddr () - Set doorbell register physical address to SRNG 66 * @soc_hdl - data path soc handle 67 * @pdev_id - device instance id 68 * 69 * Set TX_COMP_DOORBELL register physical address to WBM Head_Ptr_MemAddr_LSB 70 * Set RX_READ_DOORBELL register physical address to REO Head_Ptr_MemAddr_LSB 71 * 72 * Return: none 73 */ 74 QDF_STATUS dp_ipa_set_doorbell_paddr(struct cdp_soc_t *soc_hdl, 75 uint8_t pdev_id); 76 QDF_STATUS dp_ipa_uc_set_active(struct cdp_soc_t *soc_hdl, uint8_t pdev_id, 77 bool uc_active, bool is_tx); 78 79 /** 80 * dp_ipa_op_response() - Handle OP command response from firmware 81 * @soc_hdl - data path soc handle 82 * @pdev_id - device instance id 83 * @op_msg: op response message from firmware 84 * 85 * Return: none 86 */ 87 QDF_STATUS dp_ipa_op_response(struct cdp_soc_t *soc_hdl, uint8_t pdev_id, 88 uint8_t *op_msg); 89 90 /** 91 * dp_ipa_register_op_cb() - Register OP handler function 92 * @soc_hdl - data path soc handle 93 * @pdev_id - device instance id 94 * @op_cb: handler function pointer 95 * 96 * Return: none 97 */ 98 QDF_STATUS dp_ipa_register_op_cb(struct cdp_soc_t *soc_hdl, uint8_t pdev_id, 99 ipa_uc_op_cb_type op_cb, void *usr_ctxt); 100 101 /** 102 * dp_ipa_register_op_cb() - Deregister OP handler function 103 * @soc_hdl - data path soc handle 104 * @pdev_id - device instance id 105 * 106 * Return: none 107 */ 108 void dp_ipa_deregister_op_cb(struct cdp_soc_t *soc_hdl, uint8_t pdev_id); 109 110 /** 111 * dp_ipa_get_stat() - Get firmware wdi status 112 * @soc_hdl - data path soc handle 113 * @pdev_id - device instance id 114 * 115 * Return: none 116 */ 117 QDF_STATUS dp_ipa_get_stat(struct cdp_soc_t *soc_hdl, uint8_t pdev_id); 118 119 /** 120 * dp_tx_send_ipa_data_frame() - send IPA data frame 121 * @soc_hdl: datapath soc handle 122 * @vdev_id: virtual device/interface id 123 * @skb: skb 124 * 125 * Return: skb/ NULL is for success 126 */ 127 qdf_nbuf_t dp_tx_send_ipa_data_frame(struct cdp_soc_t *soc_hdl, uint8_t vdev_id, 128 qdf_nbuf_t skb); 129 130 /** 131 * dp_ipa_enable_autonomy() – Enable autonomy RX path 132 * @soc_hdl - data path soc handle 133 * @pdev_id - device instance id 134 * 135 * Set all RX packet route to IPA REO ring 136 * Program Destination_Ring_Ctrl_IX_0 REO register to point IPA REO ring 137 * Return: none 138 */ 139 QDF_STATUS dp_ipa_enable_autonomy(struct cdp_soc_t *soc_hdl, uint8_t pdev_id); 140 141 /** 142 * dp_ipa_disable_autonomy() – Disable autonomy RX path 143 * @soc_hdl - data path soc handle 144 * @pdev_id - device instance id 145 * 146 * Disable RX packet routing to IPA REO 147 * Program Destination_Ring_Ctrl_IX_0 REO register to disable 148 * Return: none 149 */ 150 QDF_STATUS dp_ipa_disable_autonomy(struct cdp_soc_t *soc_hdl, uint8_t pdev_id); 151 152 #ifdef CONFIG_IPA_WDI_UNIFIED_API 153 /** 154 * dp_ipa_setup() - Setup and connect IPA pipes 155 * @soc_hdl - data path soc handle 156 * @pdev_id - device instance id 157 * @ipa_i2w_cb: IPA to WLAN callback 158 * @ipa_w2i_cb: WLAN to IPA callback 159 * @ipa_wdi_meter_notifier_cb: IPA WDI metering callback 160 * @ipa_desc_size: IPA descriptor size 161 * @ipa_priv: handle to the HTT instance 162 * @is_rm_enabled: Is IPA RM enabled or not 163 * @tx_pipe_handle: pointer to Tx pipe handle 164 * @rx_pipe_handle: pointer to Rx pipe handle 165 * @is_smmu_enabled: Is SMMU enabled or not 166 * @sys_in: parameters to setup sys pipe in mcc mode 167 * 168 * Return: QDF_STATUS 169 */ 170 QDF_STATUS dp_ipa_setup(struct cdp_soc_t *soc_hdl, uint8_t pdev_id, 171 void *ipa_i2w_cb, void *ipa_w2i_cb, 172 void *ipa_wdi_meter_notifier_cb, 173 uint32_t ipa_desc_size, void *ipa_priv, 174 bool is_rm_enabled, uint32_t *tx_pipe_handle, 175 uint32_t *rx_pipe_handle, 176 bool is_smmu_enabled, 177 qdf_ipa_sys_connect_params_t *sys_in, bool over_gsi); 178 #else /* CONFIG_IPA_WDI_UNIFIED_API */ 179 /** 180 * dp_ipa_setup() - Setup and connect IPA pipes 181 * @soc_hdl - data path soc handle 182 * @pdev_id - device instance id 183 * @ipa_i2w_cb: IPA to WLAN callback 184 * @ipa_w2i_cb: WLAN to IPA callback 185 * @ipa_wdi_meter_notifier_cb: IPA WDI metering callback 186 * @ipa_desc_size: IPA descriptor size 187 * @ipa_priv: handle to the HTT instance 188 * @is_rm_enabled: Is IPA RM enabled or not 189 * @tx_pipe_handle: pointer to Tx pipe handle 190 * @rx_pipe_handle: pointer to Rx pipe handle 191 * 192 * Return: QDF_STATUS 193 */ 194 QDF_STATUS dp_ipa_setup(struct cdp_soc_t *soc_hdl, uint8_t pdev_id, 195 void *ipa_i2w_cb, void *ipa_w2i_cb, 196 void *ipa_wdi_meter_notifier_cb, 197 uint32_t ipa_desc_size, void *ipa_priv, 198 bool is_rm_enabled, uint32_t *tx_pipe_handle, 199 uint32_t *rx_pipe_handle); 200 #endif /* CONFIG_IPA_WDI_UNIFIED_API */ 201 QDF_STATUS dp_ipa_cleanup(struct cdp_soc_t *soc_hdl, uint8_t pdev_id, 202 uint32_t tx_pipe_handle, 203 uint32_t rx_pipe_handle); 204 QDF_STATUS dp_ipa_remove_header(char *name); 205 int dp_ipa_add_header_info(char *ifname, uint8_t *mac_addr, 206 uint8_t session_id, bool is_ipv6_enabled); 207 int dp_ipa_register_interface(char *ifname, bool is_ipv6_enabled); 208 QDF_STATUS dp_ipa_setup_iface(char *ifname, uint8_t *mac_addr, 209 qdf_ipa_client_type_t prod_client, 210 qdf_ipa_client_type_t cons_client, 211 uint8_t session_id, bool is_ipv6_enabled); 212 QDF_STATUS dp_ipa_cleanup_iface(char *ifname, bool is_ipv6_enabled); 213 214 /** 215 * dp_ipa_uc_enable_pipes() - Enable and resume traffic on Tx/Rx pipes 216 * @soc_hdl - handle to the soc 217 * @pdev_id - pdev id number, to get the handle 218 * 219 * Return: QDF_STATUS 220 */ 221 QDF_STATUS dp_ipa_enable_pipes(struct cdp_soc_t *soc_hdl, uint8_t pdev_id); 222 223 /** 224 * dp_ipa_disable_pipes() – Suspend traffic and disable Tx/Rx pipes 225 * @soc_hdl - handle to the soc 226 * @pdev_id - pdev id number, to get the handle 227 * 228 * Return: QDF_STATUS 229 */ 230 QDF_STATUS dp_ipa_disable_pipes(struct cdp_soc_t *soc_hdl, uint8_t pdev_id); 231 QDF_STATUS dp_ipa_set_perf_level(int client, 232 uint32_t max_supported_bw_mbps); 233 234 /** 235 * dp_ipa_rx_intrabss_fwd() - Perform intra-bss fwd for IPA RX path 236 * 237 * @soc_hdl: data path soc handle 238 * @vdev_id: virtual device/interface id 239 * @nbuf: pointer to skb of ethernet packet received from IPA RX path 240 * @fwd_success: pointer to indicate if skb succeeded in intra-bss TX 241 * 242 * This function performs intra-bss forwarding for WDI 3.0 IPA RX path. 243 * 244 * Return: true if packet is intra-bss fwd-ed and no need to pass to 245 * network stack. false if packet needs to be passed to network stack. 246 */ 247 bool dp_ipa_rx_intrabss_fwd(struct cdp_soc_t *soc_hdl, uint8_t vdev_id, 248 qdf_nbuf_t nbuf, bool *fwd_success); 249 int dp_ipa_uc_detach(struct dp_soc *soc, struct dp_pdev *pdev); 250 int dp_ipa_uc_attach(struct dp_soc *soc, struct dp_pdev *pdev); 251 int dp_ipa_ring_resource_setup(struct dp_soc *soc, 252 struct dp_pdev *pdev); 253 QDF_STATUS dp_ipa_handle_rx_buf_smmu_mapping(struct dp_soc *soc, 254 qdf_nbuf_t nbuf, 255 uint32_t size, 256 bool create); 257 258 bool dp_reo_remap_config(struct dp_soc *soc, uint32_t *remap1, 259 uint32_t *remap2); 260 bool dp_ipa_is_mdm_platform(void); 261 262 qdf_nbuf_t dp_ipa_handle_rx_reo_reinject(struct dp_soc *soc, qdf_nbuf_t nbuf); 263 264 /** 265 * dp_ipa_tx_buf_smmu_mapping() - Create SMMU mappings for IPA 266 * allocated TX buffers 267 * @soc_hdl: handle to the soc 268 * @pdev_id: pdev id number, to get the handle 269 * 270 * Return: QDF_STATUS 271 */ 272 QDF_STATUS dp_ipa_tx_buf_smmu_mapping( 273 struct cdp_soc_t *soc_hdl, uint8_t pdev_id); 274 275 /** 276 * dp_ipa_tx_buf_smmu_unmapping() - Release SMMU mappings for IPA 277 * allocated TX buffers 278 * @soc_hdl: handle to the soc 279 * @pdev_id: pdev id number, to get the handle 280 * 281 * Return: QDF_STATUS 282 */ 283 QDF_STATUS dp_ipa_tx_buf_smmu_unmapping( 284 struct cdp_soc_t *soc_hdl, uint8_t pdev_id); 285 286 #else 287 static inline int dp_ipa_uc_detach(struct dp_soc *soc, struct dp_pdev *pdev) 288 { 289 return QDF_STATUS_SUCCESS; 290 } 291 292 static inline int dp_ipa_uc_attach(struct dp_soc *soc, struct dp_pdev *pdev) 293 { 294 return QDF_STATUS_SUCCESS; 295 } 296 297 static inline int dp_ipa_ring_resource_setup(struct dp_soc *soc, 298 struct dp_pdev *pdev) 299 { 300 return 0; 301 } 302 303 static inline QDF_STATUS dp_ipa_handle_rx_buf_smmu_mapping(struct dp_soc *soc, 304 qdf_nbuf_t nbuf, 305 uint32_t size, 306 bool create) 307 { 308 return QDF_STATUS_SUCCESS; 309 } 310 311 static inline qdf_nbuf_t dp_ipa_handle_rx_reo_reinject(struct dp_soc *soc, 312 qdf_nbuf_t nbuf) 313 { 314 return nbuf; 315 } 316 317 static inline QDF_STATUS dp_ipa_tx_buf_smmu_mapping(struct cdp_soc_t *soc_hdl, 318 uint8_t pdev_id) 319 { 320 return QDF_STATUS_SUCCESS; 321 } 322 323 static inline QDF_STATUS dp_ipa_tx_buf_smmu_unmapping(struct cdp_soc_t *soc_hdl, 324 uint8_t pdev_id) 325 { 326 return QDF_STATUS_SUCCESS; 327 } 328 329 #endif 330 #endif /* _DP_IPA_H_ */ 331