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