Sravan Kumar Kairam | d01b445 | 2018-03-07 17:37:09 +0530 | [diff] [blame] | 1 | /* |
Sravan Kumar Kairam | 7887022 | 2018-12-31 12:47:17 +0530 | [diff] [blame] | 2 | * Copyright (c) 2013-2019 The Linux Foundation. All rights reserved. |
Sravan Kumar Kairam | d01b445 | 2018-03-07 17:37:09 +0530 | [diff] [blame] | 3 | * |
Sravan Kumar Kairam | d01b445 | 2018-03-07 17:37:09 +0530 | [diff] [blame] | 4 | * Permission to use, copy, modify, and/or distribute this software for |
| 5 | * any purpose with or without fee is hereby granted, provided that the |
| 6 | * above copyright notice and this permission notice appear in all |
| 7 | * copies. |
| 8 | * |
| 9 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL |
| 10 | * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED |
| 11 | * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE |
| 12 | * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL |
| 13 | * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR |
| 14 | * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER |
| 15 | * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR |
| 16 | * PERFORMANCE OF THIS SOFTWARE. |
| 17 | */ |
| 18 | |
Sravan Kumar Kairam | d01b445 | 2018-03-07 17:37:09 +0530 | [diff] [blame] | 19 | /* Include Files */ |
| 20 | #include "wlan_ipa_core.h" |
| 21 | #include "wlan_ipa_main.h" |
| 22 | #include <ol_txrx.h> |
| 23 | #include "cdp_txrx_ipa.h" |
| 24 | #include "wal_rx_desc.h" |
Sravan Kumar Kairam | ce792eb | 2018-06-15 15:07:11 +0530 | [diff] [blame] | 25 | #include "qdf_str.h" |
Jeff Johnson | 8feaa63 | 2018-12-07 11:56:02 -0800 | [diff] [blame] | 26 | #include "sir_api.h" |
| 27 | #include "host_diag_core_event.h" |
Abhishek Singh | 682cf6f | 2019-08-19 11:45:00 +0530 | [diff] [blame] | 28 | #include "wlan_objmgr_vdev_obj.h" |
Sravan Kumar Kairam | d01b445 | 2018-03-07 17:37:09 +0530 | [diff] [blame] | 29 | |
| 30 | static struct wlan_ipa_priv *gp_ipa; |
| 31 | |
| 32 | static struct wlan_ipa_iface_2_client { |
| 33 | qdf_ipa_client_type_t cons_client; |
| 34 | qdf_ipa_client_type_t prod_client; |
Chaoli Zhou | b11e18a | 2019-07-08 15:14:20 +0800 | [diff] [blame] | 35 | } wlan_ipa_iface_2_client[WLAN_IPA_CLIENT_MAX_IFACE] = { |
Sravan Kumar Kairam | d01b445 | 2018-03-07 17:37:09 +0530 | [diff] [blame] | 36 | { |
| 37 | QDF_IPA_CLIENT_WLAN2_CONS, QDF_IPA_CLIENT_WLAN1_PROD |
| 38 | }, { |
| 39 | QDF_IPA_CLIENT_WLAN3_CONS, QDF_IPA_CLIENT_WLAN1_PROD |
| 40 | }, { |
| 41 | QDF_IPA_CLIENT_WLAN4_CONS, QDF_IPA_CLIENT_WLAN1_PROD |
| 42 | } |
| 43 | }; |
| 44 | |
Sravan Kumar Kairam | 1309e7e | 2018-03-13 09:29:52 +0530 | [diff] [blame] | 45 | /* Local Function Prototypes */ |
| 46 | static void wlan_ipa_i2w_cb(void *priv, qdf_ipa_dp_evt_type_t evt, |
| 47 | unsigned long data); |
| 48 | static void wlan_ipa_w2i_cb(void *priv, qdf_ipa_dp_evt_type_t evt, |
| 49 | unsigned long data); |
| 50 | |
Sravan Kumar Kairam | d01b445 | 2018-03-07 17:37:09 +0530 | [diff] [blame] | 51 | /** |
| 52 | * wlan_ipa_uc_sta_is_enabled() - Is STA mode IPA uC offload enabled? |
| 53 | * @ipa_cfg: IPA config |
| 54 | * |
| 55 | * Return: true if STA mode IPA uC offload is enabled, false otherwise |
| 56 | */ |
| 57 | static inline bool wlan_ipa_uc_sta_is_enabled(struct wlan_ipa_config *ipa_cfg) |
| 58 | { |
| 59 | return WLAN_IPA_IS_CONFIG_ENABLED(ipa_cfg, WLAN_IPA_UC_STA_ENABLE_MASK); |
| 60 | } |
| 61 | |
| 62 | /** |
| 63 | * wlan_ipa_is_pre_filter_enabled() - Is IPA pre-filter enabled? |
| 64 | * @ipa_cfg: IPA config |
| 65 | * |
| 66 | * Return: true if pre-filter is enabled, otherwise false |
| 67 | */ |
| 68 | static inline |
| 69 | bool wlan_ipa_is_pre_filter_enabled(struct wlan_ipa_config *ipa_cfg) |
| 70 | { |
| 71 | return WLAN_IPA_IS_CONFIG_ENABLED(ipa_cfg, |
| 72 | WLAN_IPA_PRE_FILTER_ENABLE_MASK); |
| 73 | } |
| 74 | |
| 75 | /** |
| 76 | * wlan_ipa_is_ipv6_enabled() - Is IPA IPv6 enabled? |
| 77 | * @ipa_cfg: IPA config |
| 78 | * |
| 79 | * Return: true if IPv6 is enabled, otherwise false |
| 80 | */ |
| 81 | static inline bool wlan_ipa_is_ipv6_enabled(struct wlan_ipa_config *ipa_cfg) |
| 82 | { |
| 83 | return WLAN_IPA_IS_CONFIG_ENABLED(ipa_cfg, WLAN_IPA_IPV6_ENABLE_MASK); |
| 84 | } |
| 85 | |
| 86 | /** |
jiad | 72b69a9 | 2019-04-11 17:23:10 +0800 | [diff] [blame] | 87 | * wlan_ipa_is_sta_only_offload_enabled() - Is IPA STA only offload enabled |
| 88 | * |
| 89 | * STA only IPA offload is needed on MDM platforms to support |
| 90 | * tethering scenarios in STA-SAP configurations when SAP is idle. |
| 91 | * |
| 92 | * Currently in STA-SAP configurations, IPA pipes are enabled only |
| 93 | * when a wifi client is connected to SAP. |
| 94 | * |
| 95 | * Impact of this API is only limited to when IPA pipes are enabled |
| 96 | * and disabled. To take effect, WLAN_IPA_UC_STA_ENABLE_MASK needs to |
| 97 | * set to 1. |
| 98 | * |
| 99 | * Return: true if MDM_PLATFORM is defined, false otherwise |
| 100 | */ |
| 101 | #ifdef MDM_PLATFORM |
| 102 | static inline bool wlan_ipa_is_sta_only_offload_enabled(void) |
| 103 | { |
| 104 | return true; |
| 105 | } |
| 106 | #else |
| 107 | static inline bool wlan_ipa_is_sta_only_offload_enabled(void) |
| 108 | { |
| 109 | return false; |
| 110 | } |
| 111 | #endif |
| 112 | |
| 113 | /** |
Sravan Kumar Kairam | d01b445 | 2018-03-07 17:37:09 +0530 | [diff] [blame] | 114 | * wlan_ipa_msg_free_fn() - Free an IPA message |
| 115 | * @buff: pointer to the IPA message |
| 116 | * @len: length of the IPA message |
| 117 | * @type: type of IPA message |
| 118 | * |
| 119 | * Return: None |
| 120 | */ |
| 121 | static void wlan_ipa_msg_free_fn(void *buff, uint32_t len, uint32_t type) |
| 122 | { |
| 123 | ipa_debug("msg type:%d, len:%d", type, len); |
| 124 | qdf_mem_free(buff); |
| 125 | } |
| 126 | |
| 127 | /** |
| 128 | * wlan_ipa_uc_loaded_uc_cb() - IPA UC loaded event callback |
| 129 | * @priv_ctxt: IPA context |
| 130 | * |
| 131 | * Will be called by IPA context. |
| 132 | * It's atomic context, then should be scheduled to kworker thread |
| 133 | * |
| 134 | * Return: None |
| 135 | */ |
| 136 | static void wlan_ipa_uc_loaded_uc_cb(void *priv_ctxt) |
| 137 | { |
| 138 | struct wlan_ipa_priv *ipa_ctx; |
| 139 | struct op_msg_type *msg; |
| 140 | struct uc_op_work_struct *uc_op_work; |
| 141 | |
| 142 | if (!priv_ctxt) { |
| 143 | ipa_err("Invalid IPA context"); |
| 144 | return; |
| 145 | } |
| 146 | |
| 147 | ipa_ctx = priv_ctxt; |
Sravan Kumar Kairam | 7eb6e4c | 2018-04-26 15:35:47 +0530 | [diff] [blame] | 148 | ipa_ctx->uc_loaded = true; |
| 149 | |
| 150 | uc_op_work = &ipa_ctx->uc_op_work[WLAN_IPA_UC_OPCODE_UC_READY]; |
| 151 | if (!list_empty(&uc_op_work->work.work.entry)) { |
| 152 | /* uc_op_work is not initialized yet */ |
| 153 | return; |
| 154 | } |
Sravan Kumar Kairam | d01b445 | 2018-03-07 17:37:09 +0530 | [diff] [blame] | 155 | |
| 156 | msg = qdf_mem_malloc(sizeof(*msg)); |
| 157 | if (!msg) { |
| 158 | ipa_err("op_msg allocation fails"); |
| 159 | return; |
| 160 | } |
| 161 | |
| 162 | msg->op_code = WLAN_IPA_UC_OPCODE_UC_READY; |
| 163 | |
Sravan Kumar Kairam | d01b445 | 2018-03-07 17:37:09 +0530 | [diff] [blame] | 164 | /* When the same uC OPCODE is already pended, just return */ |
| 165 | if (uc_op_work->msg) |
| 166 | goto done; |
| 167 | |
| 168 | uc_op_work->msg = msg; |
| 169 | qdf_sched_work(0, &uc_op_work->work); |
Sravan Kumar Kairam | 7eb6e4c | 2018-04-26 15:35:47 +0530 | [diff] [blame] | 170 | |
Sravan Kumar Kairam | d01b445 | 2018-03-07 17:37:09 +0530 | [diff] [blame] | 171 | /* work handler will free the msg buffer */ |
| 172 | return; |
| 173 | |
| 174 | done: |
| 175 | qdf_mem_free(msg); |
| 176 | } |
| 177 | |
| 178 | /** |
| 179 | * wlan_ipa_uc_send_wdi_control_msg() - Set WDI control message |
| 180 | * @ctrl: WDI control value |
| 181 | * |
| 182 | * Send WLAN_WDI_ENABLE for ctrl = true and WLAN_WDI_DISABLE otherwise. |
| 183 | * |
| 184 | * Return: QDF_STATUS |
| 185 | */ |
| 186 | static QDF_STATUS wlan_ipa_uc_send_wdi_control_msg(bool ctrl) |
| 187 | { |
jiad | 629b217 | 2018-05-11 15:34:22 +0800 | [diff] [blame] | 188 | struct wlan_ipa_priv *ipa_ctx = gp_ipa; |
Sravan Kumar Kairam | d01b445 | 2018-03-07 17:37:09 +0530 | [diff] [blame] | 189 | qdf_ipa_msg_meta_t meta; |
| 190 | qdf_ipa_wlan_msg_t *ipa_msg; |
| 191 | int ret = 0; |
| 192 | |
| 193 | /* WDI enable message to IPA */ |
| 194 | QDF_IPA_MSG_META_MSG_LEN(&meta) = sizeof(*ipa_msg); |
| 195 | ipa_msg = qdf_mem_malloc(QDF_IPA_MSG_META_MSG_LEN(&meta)); |
| 196 | if (!ipa_msg) { |
| 197 | ipa_err("msg allocation failed"); |
| 198 | return QDF_STATUS_E_NOMEM; |
| 199 | } |
| 200 | |
jiad | 629b217 | 2018-05-11 15:34:22 +0800 | [diff] [blame] | 201 | if (ctrl) { |
Sravan Kumar Kairam | d01b445 | 2018-03-07 17:37:09 +0530 | [diff] [blame] | 202 | QDF_IPA_SET_META_MSG_TYPE(&meta, QDF_WDI_ENABLE); |
jiad | 629b217 | 2018-05-11 15:34:22 +0800 | [diff] [blame] | 203 | ipa_ctx->stats.event[QDF_WDI_ENABLE]++; |
| 204 | } else { |
Sravan Kumar Kairam | d01b445 | 2018-03-07 17:37:09 +0530 | [diff] [blame] | 205 | QDF_IPA_SET_META_MSG_TYPE(&meta, QDF_WDI_DISABLE); |
jiad | 629b217 | 2018-05-11 15:34:22 +0800 | [diff] [blame] | 206 | ipa_ctx->stats.event[QDF_WDI_DISABLE]++; |
| 207 | } |
Sravan Kumar Kairam | d01b445 | 2018-03-07 17:37:09 +0530 | [diff] [blame] | 208 | |
| 209 | ipa_debug("ipa_send_msg(Evt:%d)", QDF_IPA_MSG_META_MSG_TYPE(&meta)); |
| 210 | ret = qdf_ipa_send_msg(&meta, ipa_msg, wlan_ipa_msg_free_fn); |
| 211 | if (ret) { |
| 212 | ipa_err("ipa_send_msg(Evt:%d)-fail=%d", |
| 213 | QDF_IPA_MSG_META_MSG_TYPE(&meta), ret); |
| 214 | qdf_mem_free(ipa_msg); |
| 215 | return QDF_STATUS_E_FAILURE; |
| 216 | } |
| 217 | |
| 218 | return QDF_STATUS_SUCCESS; |
| 219 | } |
| 220 | |
Sravan Kumar Kairam | 271fab2 | 2018-03-07 18:57:41 +0530 | [diff] [blame] | 221 | struct wlan_ipa_priv *wlan_ipa_get_obj_context(void) |
| 222 | { |
| 223 | return gp_ipa; |
| 224 | } |
| 225 | |
Yun Park | e74e609 | 2018-04-27 11:36:34 -0700 | [diff] [blame] | 226 | /** |
| 227 | * wlan_ipa_send_pkt_to_tl() - Send an IPA packet to TL |
| 228 | * @iface_context: interface-specific IPA context |
| 229 | * @ipa_tx_desc: packet data descriptor |
| 230 | * |
| 231 | * Return: None |
| 232 | */ |
| 233 | static void wlan_ipa_send_pkt_to_tl( |
| 234 | struct wlan_ipa_iface_context *iface_context, |
| 235 | qdf_ipa_rx_data_t *ipa_tx_desc) |
| 236 | { |
| 237 | struct wlan_ipa_priv *ipa_ctx = iface_context->ipa_ctx; |
| 238 | qdf_nbuf_t skb; |
| 239 | struct wlan_ipa_tx_desc *tx_desc; |
| 240 | |
| 241 | qdf_spin_lock_bh(&iface_context->interface_lock); |
| 242 | /* |
| 243 | * During CAC period, data packets shouldn't be sent over the air so |
| 244 | * drop all the packets here |
| 245 | */ |
| 246 | if (iface_context->device_mode == QDF_SAP_MODE || |
| 247 | iface_context->device_mode == QDF_P2P_GO_MODE) { |
| 248 | if (ipa_ctx->dfs_cac_block_tx) { |
| 249 | ipa_free_skb(ipa_tx_desc); |
| 250 | qdf_spin_unlock_bh(&iface_context->interface_lock); |
| 251 | iface_context->stats.num_tx_cac_drop++; |
| 252 | wlan_ipa_wdi_rm_try_release(ipa_ctx); |
| 253 | return; |
| 254 | } |
| 255 | } |
| 256 | qdf_spin_unlock_bh(&iface_context->interface_lock); |
| 257 | |
| 258 | skb = QDF_IPA_RX_DATA_SKB(ipa_tx_desc); |
| 259 | |
hangtian | 127c953 | 2019-01-12 13:29:07 +0800 | [diff] [blame] | 260 | qdf_mem_zero(skb->cb, sizeof(skb->cb)); |
Yun Park | e74e609 | 2018-04-27 11:36:34 -0700 | [diff] [blame] | 261 | |
| 262 | /* Store IPA Tx buffer ownership into SKB CB */ |
| 263 | qdf_nbuf_ipa_owned_set(skb); |
| 264 | if (wlan_ipa_uc_sta_is_enabled(ipa_ctx->config)) { |
| 265 | qdf_nbuf_mapped_paddr_set(skb, |
jiad | af210c0 | 2018-11-20 09:40:34 +0800 | [diff] [blame] | 266 | QDF_IPA_RX_DATA_DMA_ADDR(ipa_tx_desc) |
| 267 | + WLAN_IPA_WLAN_FRAG_HEADER |
| 268 | + WLAN_IPA_WLAN_IPA_HEADER); |
Yun Park | e74e609 | 2018-04-27 11:36:34 -0700 | [diff] [blame] | 269 | QDF_IPA_RX_DATA_SKB_LEN(ipa_tx_desc) -= |
| 270 | WLAN_IPA_WLAN_FRAG_HEADER + WLAN_IPA_WLAN_IPA_HEADER; |
jiad | af210c0 | 2018-11-20 09:40:34 +0800 | [diff] [blame] | 271 | } else |
| 272 | qdf_nbuf_mapped_paddr_set(skb, ipa_tx_desc->dma_addr); |
Yun Park | e74e609 | 2018-04-27 11:36:34 -0700 | [diff] [blame] | 273 | |
| 274 | qdf_spin_lock_bh(&ipa_ctx->q_lock); |
| 275 | /* get free Tx desc and assign ipa_tx_desc pointer */ |
Sravan Kumar Kairam | 1f8f8b3 | 2018-07-06 16:05:24 +0530 | [diff] [blame] | 276 | if (qdf_list_remove_front(&ipa_ctx->tx_desc_free_list, |
| 277 | (qdf_list_node_t **)&tx_desc) == |
Yun Park | e74e609 | 2018-04-27 11:36:34 -0700 | [diff] [blame] | 278 | QDF_STATUS_SUCCESS) { |
| 279 | tx_desc->ipa_tx_desc_ptr = ipa_tx_desc; |
| 280 | ipa_ctx->stats.num_tx_desc_q_cnt++; |
| 281 | qdf_spin_unlock_bh(&ipa_ctx->q_lock); |
| 282 | /* Store Tx Desc index into SKB CB */ |
| 283 | QDF_NBUF_CB_TX_IPA_PRIV(skb) = tx_desc->id; |
| 284 | } else { |
| 285 | ipa_ctx->stats.num_tx_desc_error++; |
| 286 | qdf_spin_unlock_bh(&ipa_ctx->q_lock); |
| 287 | qdf_ipa_free_skb(ipa_tx_desc); |
| 288 | wlan_ipa_wdi_rm_try_release(ipa_ctx); |
| 289 | return; |
| 290 | } |
| 291 | |
| 292 | skb = cdp_ipa_tx_send_data_frame(cds_get_context(QDF_MODULE_ID_SOC), |
| 293 | (struct cdp_vdev *)iface_context->tl_context, |
| 294 | QDF_IPA_RX_DATA_SKB(ipa_tx_desc)); |
| 295 | if (skb) { |
| 296 | qdf_nbuf_free(skb); |
| 297 | iface_context->stats.num_tx_err++; |
| 298 | return; |
| 299 | } |
| 300 | |
| 301 | atomic_inc(&ipa_ctx->tx_ref_cnt); |
| 302 | |
| 303 | iface_context->stats.num_tx++; |
| 304 | } |
| 305 | |
jiad | 90b1725 | 2019-03-25 15:22:42 +0800 | [diff] [blame] | 306 | /** |
| 307 | * wlan_ipa_forward() - handle packet forwarding to wlan tx |
| 308 | * @ipa_ctx: pointer to ipa ipa context |
| 309 | * @iface_ctx: interface context |
| 310 | * @skb: data pointer |
| 311 | * |
| 312 | * if exception packet has set forward bit, copied new packet should be |
| 313 | * forwarded to wlan tx. if wlan subsystem is in suspend state, packet should |
| 314 | * put into pm queue and tx procedure will be differed |
| 315 | * |
| 316 | * Return: None |
| 317 | */ |
| 318 | static void wlan_ipa_forward(struct wlan_ipa_priv *ipa_ctx, |
| 319 | struct wlan_ipa_iface_context *iface_ctx, |
| 320 | qdf_nbuf_t skb) |
| 321 | { |
| 322 | struct wlan_ipa_pm_tx_cb *pm_tx_cb; |
| 323 | |
| 324 | qdf_spin_lock_bh(&ipa_ctx->pm_lock); |
| 325 | |
| 326 | /* Set IPA ownership for intra-BSS Tx packets to avoid skb_orphan */ |
| 327 | qdf_nbuf_ipa_owned_set(skb); |
| 328 | |
| 329 | /* WLAN subsystem is in suspend, put in queue */ |
| 330 | if (ipa_ctx->suspended) { |
| 331 | qdf_spin_unlock_bh(&ipa_ctx->pm_lock); |
| 332 | ipa_info_rl("Tx in suspend, put in queue"); |
| 333 | qdf_mem_zero(skb->cb, sizeof(skb->cb)); |
| 334 | pm_tx_cb = (struct wlan_ipa_pm_tx_cb *)skb->cb; |
| 335 | pm_tx_cb->exception = true; |
| 336 | pm_tx_cb->iface_context = iface_ctx; |
| 337 | qdf_spin_lock_bh(&ipa_ctx->pm_lock); |
| 338 | qdf_nbuf_queue_add(&ipa_ctx->pm_queue_head, skb); |
| 339 | qdf_spin_unlock_bh(&ipa_ctx->pm_lock); |
| 340 | ipa_ctx->stats.num_tx_queued++; |
| 341 | } else { |
| 342 | /* Resume, put packet into WLAN TX */ |
| 343 | qdf_spin_unlock_bh(&ipa_ctx->pm_lock); |
| 344 | |
| 345 | if (ipa_ctx->softap_xmit) { |
| 346 | if (ipa_ctx->softap_xmit(skb, iface_ctx->dev)) { |
| 347 | ipa_err_rl("packet Tx fail"); |
| 348 | ipa_ctx->stats.num_tx_fwd_err++; |
| 349 | } else { |
| 350 | ipa_ctx->stats.num_tx_fwd_ok++; |
| 351 | } |
| 352 | } else { |
| 353 | dev_kfree_skb_any(skb); |
| 354 | } |
| 355 | } |
| 356 | } |
| 357 | |
| 358 | /** |
| 359 | * wlan_ipa_intrabss_forward() - Forward intra bss packets. |
| 360 | * @ipa_ctx: pointer to IPA IPA struct |
| 361 | * @iface_ctx: ipa interface context |
| 362 | * @desc: Firmware descriptor |
| 363 | * @skb: Data buffer |
| 364 | * |
| 365 | * Return: |
| 366 | * WLAN_IPA_FORWARD_PKT_NONE |
| 367 | * WLAN_IPA_FORWARD_PKT_DISCARD |
| 368 | * WLAN_IPA_FORWARD_PKT_LOCAL_STACK |
| 369 | * |
| 370 | */ |
| 371 | |
| 372 | static enum wlan_ipa_forward_type wlan_ipa_intrabss_forward( |
| 373 | struct wlan_ipa_priv *ipa_ctx, |
| 374 | struct wlan_ipa_iface_context *iface_ctx, |
| 375 | uint8_t desc, |
| 376 | qdf_nbuf_t skb) |
| 377 | { |
| 378 | int ret = WLAN_IPA_FORWARD_PKT_NONE; |
| 379 | void *soc = cds_get_context(QDF_MODULE_ID_SOC); |
| 380 | void *pdev = cds_get_context(QDF_MODULE_ID_TXRX); |
| 381 | |
| 382 | if ((desc & FW_RX_DESC_FORWARD_M)) { |
| 383 | void *vdev = cdp_get_vdev_from_vdev_id(soc, pdev, |
| 384 | iface_ctx->session_id); |
Mohit Khanna | e1b8602 | 2019-04-12 10:04:57 -0700 | [diff] [blame] | 385 | if (!vdev) |
| 386 | goto drop_pkt; |
| 387 | |
jiad | 90b1725 | 2019-03-25 15:22:42 +0800 | [diff] [blame] | 388 | if (cdp_tx_desc_thresh_reached(soc, vdev)) { |
| 389 | /* Drop the packet*/ |
| 390 | ipa_ctx->stats.num_tx_fwd_err++; |
Mohit Khanna | e1b8602 | 2019-04-12 10:04:57 -0700 | [diff] [blame] | 391 | goto drop_pkt; |
jiad | 90b1725 | 2019-03-25 15:22:42 +0800 | [diff] [blame] | 392 | } |
Mohit Khanna | e1b8602 | 2019-04-12 10:04:57 -0700 | [diff] [blame] | 393 | |
jiad | 90b1725 | 2019-03-25 15:22:42 +0800 | [diff] [blame] | 394 | ipa_debug_rl("Forward packet to Tx (fw_desc=%d)", desc); |
| 395 | ipa_ctx->ipa_tx_forward++; |
| 396 | |
| 397 | if ((desc & FW_RX_DESC_DISCARD_M)) { |
| 398 | wlan_ipa_forward(ipa_ctx, iface_ctx, skb); |
| 399 | ipa_ctx->ipa_rx_internal_drop_count++; |
| 400 | ipa_ctx->ipa_rx_discard++; |
| 401 | ret = WLAN_IPA_FORWARD_PKT_DISCARD; |
| 402 | } else { |
| 403 | struct sk_buff *cloned_skb = skb_clone(skb, GFP_ATOMIC); |
| 404 | |
| 405 | if (cloned_skb) |
| 406 | wlan_ipa_forward(ipa_ctx, iface_ctx, |
| 407 | cloned_skb); |
| 408 | else |
| 409 | ipa_err_rl("tx skb alloc failed"); |
| 410 | ret = WLAN_IPA_FORWARD_PKT_LOCAL_STACK; |
| 411 | } |
| 412 | } |
Mohit Khanna | e1b8602 | 2019-04-12 10:04:57 -0700 | [diff] [blame] | 413 | return ret; |
jiad | 90b1725 | 2019-03-25 15:22:42 +0800 | [diff] [blame] | 414 | |
Mohit Khanna | e1b8602 | 2019-04-12 10:04:57 -0700 | [diff] [blame] | 415 | drop_pkt: |
| 416 | dev_kfree_skb_any(skb); |
| 417 | ret = WLAN_IPA_FORWARD_PKT_DISCARD; |
jiad | 90b1725 | 2019-03-25 15:22:42 +0800 | [diff] [blame] | 418 | return ret; |
| 419 | } |
| 420 | |
Sravan Kumar Kairam | d01b445 | 2018-03-07 17:37:09 +0530 | [diff] [blame] | 421 | #ifdef CONFIG_IPA_WDI_UNIFIED_API |
Sravan Kumar Kairam | d01b445 | 2018-03-07 17:37:09 +0530 | [diff] [blame] | 422 | /* |
| 423 | * TODO: Get WDI version through FW capabilities |
| 424 | */ |
Mohit Khanna | cabf5e7 | 2018-07-24 13:28:43 -0700 | [diff] [blame] | 425 | #if defined(QCA_WIFI_QCA6290) || defined(QCA_WIFI_QCA6390) |
Sravan Kumar Kairam | d01b445 | 2018-03-07 17:37:09 +0530 | [diff] [blame] | 426 | static inline void wlan_ipa_wdi_get_wdi_version(struct wlan_ipa_priv *ipa_ctx) |
| 427 | { |
| 428 | ipa_ctx->wdi_version = IPA_WDI_3; |
| 429 | } |
| 430 | #elif defined(QCA_WIFI_3_0) |
| 431 | static inline void wlan_ipa_wdi_get_wdi_version(struct wlan_ipa_priv *ipa_ctx) |
| 432 | { |
| 433 | ipa_ctx->wdi_version = IPA_WDI_2; |
| 434 | } |
| 435 | #else |
| 436 | static inline void wlan_ipa_wdi_get_wdi_version(struct wlan_ipa_priv *ipa_ctx) |
| 437 | { |
| 438 | ipa_ctx->wdi_version = IPA_WDI_1; |
| 439 | } |
| 440 | #endif |
| 441 | |
Sravan Kumar Kairam | 1309e7e | 2018-03-13 09:29:52 +0530 | [diff] [blame] | 442 | static inline bool wlan_ipa_wdi_is_smmu_enabled(struct wlan_ipa_priv *ipa_ctx, |
| 443 | qdf_device_t osdev) |
| 444 | { |
Sravan Kumar Kairam | 983a445 | 2018-03-20 13:30:22 +0530 | [diff] [blame] | 445 | return ipa_ctx->is_smmu_enabled && qdf_mem_smmu_s1_enabled(osdev); |
Sravan Kumar Kairam | 1309e7e | 2018-03-13 09:29:52 +0530 | [diff] [blame] | 446 | } |
| 447 | |
| 448 | static inline QDF_STATUS wlan_ipa_wdi_setup(struct wlan_ipa_priv *ipa_ctx, |
| 449 | qdf_device_t osdev) |
| 450 | { |
| 451 | qdf_ipa_sys_connect_params_t sys_in[WLAN_IPA_MAX_IFACE]; |
| 452 | int i; |
| 453 | |
| 454 | for (i = 0; i < WLAN_IPA_MAX_IFACE; i++) |
| 455 | qdf_mem_copy(&sys_in[i], |
| 456 | &ipa_ctx->sys_pipe[i].ipa_sys_params, |
| 457 | sizeof(qdf_ipa_sys_connect_params_t)); |
| 458 | |
| 459 | return cdp_ipa_setup(ipa_ctx->dp_soc, ipa_ctx->dp_pdev, |
| 460 | wlan_ipa_i2w_cb, wlan_ipa_w2i_cb, |
| 461 | wlan_ipa_wdi_meter_notifier_cb, |
| 462 | ipa_ctx->config->desc_size, |
| 463 | ipa_ctx, wlan_ipa_is_rm_enabled(ipa_ctx->config), |
| 464 | &ipa_ctx->tx_pipe_handle, |
| 465 | &ipa_ctx->rx_pipe_handle, |
| 466 | wlan_ipa_wdi_is_smmu_enabled(ipa_ctx, osdev), |
Sravan Kumar Kairam | c047d29 | 2018-11-19 18:43:15 +0530 | [diff] [blame] | 467 | sys_in, ipa_ctx->over_gsi); |
Sravan Kumar Kairam | 1309e7e | 2018-03-13 09:29:52 +0530 | [diff] [blame] | 468 | } |
| 469 | |
Sravan Kumar Kairam | 271fab2 | 2018-03-07 18:57:41 +0530 | [diff] [blame] | 470 | #ifdef FEATURE_METERING |
| 471 | /** |
| 472 | * wlan_ipa_wdi_init_metering() - IPA WDI metering init |
| 473 | * @ipa_ctx: IPA context |
| 474 | * @in: IPA WDI in param |
| 475 | * |
| 476 | * Return: QDF_STATUS |
| 477 | */ |
| 478 | static inline void wlan_ipa_wdi_init_metering(struct wlan_ipa_priv *ipa_ctxt, |
| 479 | qdf_ipa_wdi_init_in_params_t *in) |
| 480 | { |
| 481 | QDF_IPA_WDI_INIT_IN_PARAMS_WDI_NOTIFY(in) = |
| 482 | wlan_ipa_wdi_meter_notifier_cb; |
| 483 | } |
| 484 | #else |
| 485 | static inline void wlan_ipa_wdi_init_metering(struct wlan_ipa_priv *ipa_ctxt, |
| 486 | qdf_ipa_wdi_init_in_params_t *in) |
| 487 | { |
| 488 | } |
| 489 | #endif |
| 490 | |
| 491 | /** |
| 492 | * wlan_ipa_wdi_init() - IPA WDI init |
| 493 | * @ipa_ctx: IPA context |
| 494 | * |
| 495 | * Return: QDF_STATUS |
| 496 | */ |
Sravan Kumar Kairam | d01b445 | 2018-03-07 17:37:09 +0530 | [diff] [blame] | 497 | static inline QDF_STATUS wlan_ipa_wdi_init(struct wlan_ipa_priv *ipa_ctx) |
| 498 | { |
| 499 | qdf_ipa_wdi_init_in_params_t in; |
| 500 | qdf_ipa_wdi_init_out_params_t out; |
| 501 | int ret; |
| 502 | |
| 503 | ipa_ctx->uc_loaded = false; |
| 504 | |
Sravan Kumar Kairam | eab90a0 | 2018-10-03 17:24:57 +0530 | [diff] [blame] | 505 | qdf_mem_zero(&in, sizeof(in)); |
| 506 | qdf_mem_zero(&out, sizeof(out)); |
| 507 | |
Sravan Kumar Kairam | d01b445 | 2018-03-07 17:37:09 +0530 | [diff] [blame] | 508 | QDF_IPA_WDI_INIT_IN_PARAMS_WDI_VERSION(&in) = ipa_ctx->wdi_version; |
| 509 | QDF_IPA_WDI_INIT_IN_PARAMS_NOTIFY(&in) = wlan_ipa_uc_loaded_uc_cb; |
Sravan Kumar Kairam | 271fab2 | 2018-03-07 18:57:41 +0530 | [diff] [blame] | 510 | QDF_IPA_WDI_INIT_IN_PARAMS_PRIV(&in) = ipa_ctx; |
| 511 | wlan_ipa_wdi_init_metering(ipa_ctx, &in); |
Sravan Kumar Kairam | d01b445 | 2018-03-07 17:37:09 +0530 | [diff] [blame] | 512 | |
| 513 | ret = qdf_ipa_wdi_init(&in, &out); |
| 514 | if (ret) { |
| 515 | ipa_err("ipa_wdi_init failed with ret=%d", ret); |
| 516 | return QDF_STATUS_E_FAILURE; |
| 517 | } |
| 518 | |
Sravan Kumar Kairam | c047d29 | 2018-11-19 18:43:15 +0530 | [diff] [blame] | 519 | ipa_ctx->over_gsi = |
| 520 | QDF_IPA_WDI_INIT_OUT_PARAMS_IS_OVER_GSI(&out); |
| 521 | ipa_ctx->is_smmu_enabled = |
| 522 | QDF_IPA_WDI_INIT_OUT_PARAMS_IS_SMMU_ENABLED(&out); |
| 523 | ipa_info("ipa_over_gsi: %d, is_smmu_enabled: %d", |
| 524 | ipa_ctx->over_gsi, ipa_ctx->is_smmu_enabled); |
| 525 | |
Sravan Kumar Kairam | d01b445 | 2018-03-07 17:37:09 +0530 | [diff] [blame] | 526 | if (QDF_IPA_WDI_INIT_OUT_PARAMS_IS_UC_READY(&out)) { |
Dustin Brown | 7e761c7 | 2018-07-31 13:50:17 -0700 | [diff] [blame] | 527 | ipa_debug("IPA uC READY"); |
Sravan Kumar Kairam | d01b445 | 2018-03-07 17:37:09 +0530 | [diff] [blame] | 528 | ipa_ctx->uc_loaded = true; |
Sravan Kumar Kairam | d01b445 | 2018-03-07 17:37:09 +0530 | [diff] [blame] | 529 | } else { |
Sravan Kumar Kairam | c047d29 | 2018-11-19 18:43:15 +0530 | [diff] [blame] | 530 | ipa_info("IPA uc not ready"); |
Sravan Kumar Kairam | d01b445 | 2018-03-07 17:37:09 +0530 | [diff] [blame] | 531 | return QDF_STATUS_E_BUSY; |
| 532 | } |
| 533 | |
| 534 | return QDF_STATUS_SUCCESS; |
| 535 | } |
| 536 | |
| 537 | static inline int wlan_ipa_wdi_cleanup(void) |
| 538 | { |
| 539 | int ret; |
| 540 | |
| 541 | ret = qdf_ipa_wdi_cleanup(); |
| 542 | if (ret) |
| 543 | ipa_info("ipa_wdi_cleanup failed ret=%d", ret); |
| 544 | return ret; |
| 545 | } |
| 546 | |
| 547 | static inline int wlan_ipa_wdi_setup_sys_pipe(struct wlan_ipa_priv *ipa_ctx, |
| 548 | struct ipa_sys_connect_params *sys, |
| 549 | uint32_t *handle) |
| 550 | { |
| 551 | return 0; |
| 552 | } |
| 553 | |
| 554 | static inline int wlan_ipa_wdi_teardown_sys_pipe(struct wlan_ipa_priv *ipa_ctx, |
| 555 | uint32_t handle) |
| 556 | { |
| 557 | return 0; |
| 558 | } |
| 559 | |
Yun Park | e74e609 | 2018-04-27 11:36:34 -0700 | [diff] [blame] | 560 | /** |
| 561 | * wlan_ipa_pm_flush() - flush queued packets |
| 562 | * @work: pointer to the scheduled work |
| 563 | * |
| 564 | * Called during PM resume to send packets to TL which were queued |
| 565 | * while host was in the process of suspending. |
| 566 | * |
| 567 | * Return: None |
| 568 | */ |
| 569 | static void wlan_ipa_pm_flush(void *data) |
| 570 | { |
| 571 | struct wlan_ipa_priv *ipa_ctx = (struct wlan_ipa_priv *)data; |
| 572 | struct wlan_ipa_pm_tx_cb *pm_tx_cb = NULL; |
| 573 | qdf_nbuf_t skb; |
| 574 | uint32_t dequeued = 0; |
| 575 | |
| 576 | qdf_spin_lock_bh(&ipa_ctx->pm_lock); |
| 577 | while (((skb = qdf_nbuf_queue_remove(&ipa_ctx->pm_queue_head)) != |
| 578 | NULL)) { |
| 579 | qdf_spin_unlock_bh(&ipa_ctx->pm_lock); |
| 580 | |
| 581 | pm_tx_cb = (struct wlan_ipa_pm_tx_cb *)skb->cb; |
| 582 | dequeued++; |
| 583 | |
jiad | ab8cea0 | 2018-05-24 09:16:14 +0800 | [diff] [blame] | 584 | if (pm_tx_cb->exception) { |
| 585 | if (ipa_ctx->softap_xmit && |
| 586 | pm_tx_cb->iface_context->dev) { |
| 587 | ipa_ctx->softap_xmit(skb, |
| 588 | pm_tx_cb->iface_context->dev); |
| 589 | ipa_ctx->stats.num_tx_fwd_ok++; |
| 590 | } else { |
| 591 | dev_kfree_skb_any(skb); |
| 592 | } |
| 593 | } else { |
| 594 | wlan_ipa_send_pkt_to_tl(pm_tx_cb->iface_context, |
| 595 | pm_tx_cb->ipa_tx_desc); |
| 596 | } |
Yun Park | e74e609 | 2018-04-27 11:36:34 -0700 | [diff] [blame] | 597 | |
| 598 | qdf_spin_lock_bh(&ipa_ctx->pm_lock); |
| 599 | } |
| 600 | qdf_spin_unlock_bh(&ipa_ctx->pm_lock); |
| 601 | |
| 602 | ipa_ctx->stats.num_tx_dequeued += dequeued; |
| 603 | if (dequeued > ipa_ctx->stats.num_max_pm_queue) |
| 604 | ipa_ctx->stats.num_max_pm_queue = dequeued; |
| 605 | } |
| 606 | |
jiad | ae9959f | 2018-05-08 11:19:07 +0800 | [diff] [blame] | 607 | int wlan_ipa_uc_smmu_map(bool map, uint32_t num_buf, qdf_mem_info_t *buf_arr) |
| 608 | { |
| 609 | if (!num_buf) { |
| 610 | ipa_info("No buffers to map/unmap"); |
| 611 | return 0; |
| 612 | } |
| 613 | |
| 614 | if (map) |
| 615 | return qdf_ipa_wdi_create_smmu_mapping(num_buf, buf_arr); |
| 616 | else |
| 617 | return qdf_ipa_wdi_release_smmu_mapping(num_buf, buf_arr); |
| 618 | } |
| 619 | |
Jia Ding | 70deca7 | 2019-07-24 18:18:57 +0800 | [diff] [blame] | 620 | #ifdef MDM_PLATFORM |
| 621 | /** |
| 622 | * is_rx_dest_bridge_dev() - is RX skb bridge device terminated |
| 623 | * @iface_ctx: pointer to WLAN IPA interface context |
| 624 | * @nbuf: skb buffer |
| 625 | * |
| 626 | * Check if skb is destined for bridge device, where SAP is a bridge |
| 627 | * port of it. |
| 628 | * |
| 629 | * FIXME: If there's a BH lockless API to check if destination MAC |
| 630 | * address is a valid peer, this check can be deleted. Currently |
| 631 | * dp_find_peer_by_addr() is used to check if destination MAC |
| 632 | * is a valid peer. Since WLAN IPA RX is in process context, |
| 633 | * qdf_spin_lock_bh in dp_find_peer_by_addr() turns to spin_lock_bh |
| 634 | * and this BH lock hurts netif_rx. |
| 635 | * |
| 636 | * Return: true/false |
| 637 | */ |
| 638 | static bool is_rx_dest_bridge_dev(struct wlan_ipa_iface_context *iface_ctx, |
| 639 | qdf_nbuf_t nbuf) |
| 640 | { |
| 641 | qdf_netdev_t master_ndev; |
| 642 | qdf_netdev_t ndev; |
| 643 | struct ethhdr *eh; |
| 644 | uint8_t da_is_bcmc; |
| 645 | bool ret; |
| 646 | |
| 647 | if (iface_ctx->device_mode != QDF_SAP_MODE) |
| 648 | return false; |
| 649 | |
| 650 | /* |
| 651 | * WDI 3.0 skb->cb[] info from IPA driver |
| 652 | * skb->cb[0] = vdev_id |
| 653 | * skb->cb[1].bit#1 = da_is_bcmc |
| 654 | */ |
| 655 | da_is_bcmc = ((uint8_t)nbuf->cb[1]) & 0x2; |
| 656 | if (da_is_bcmc) |
| 657 | return false; |
| 658 | |
| 659 | ndev = iface_ctx->dev; |
| 660 | if (!ndev) |
| 661 | return false; |
| 662 | |
| 663 | if (!netif_is_bridge_port(ndev)) |
| 664 | return false; |
| 665 | |
| 666 | rcu_read_lock(); |
| 667 | |
| 668 | master_ndev = netdev_master_upper_dev_get_rcu(ndev); |
| 669 | if (!master_ndev) { |
| 670 | ret = false; |
| 671 | goto out; |
| 672 | } |
| 673 | |
| 674 | eh = (struct ethhdr *)qdf_nbuf_data(nbuf); |
| 675 | if (qdf_mem_cmp(eh->h_dest, master_ndev->dev_addr, QDF_MAC_ADDR_SIZE)) { |
| 676 | ret = false; |
| 677 | goto out; |
| 678 | } |
| 679 | |
| 680 | ret = true; |
| 681 | |
| 682 | out: |
| 683 | rcu_read_unlock(); |
| 684 | return ret; |
| 685 | } |
| 686 | #else /* !MDM_PLATFORM */ |
| 687 | static bool is_rx_dest_bridge_dev(struct wlan_ipa_iface_context *iface_ctx, |
| 688 | qdf_nbuf_t nbuf) |
| 689 | { |
| 690 | return false; |
| 691 | } |
| 692 | #endif /* MDM_PLATFORM */ |
| 693 | |
jiad | 90b1725 | 2019-03-25 15:22:42 +0800 | [diff] [blame] | 694 | static enum wlan_ipa_forward_type |
| 695 | wlan_ipa_rx_intrabss_fwd(struct wlan_ipa_priv *ipa_ctx, |
| 696 | struct wlan_ipa_iface_context *iface_ctx, |
| 697 | qdf_nbuf_t nbuf) |
| 698 | { |
| 699 | uint8_t fw_desc = 0; |
| 700 | bool fwd_success; |
| 701 | int ret; |
| 702 | |
| 703 | /* legacy intra-bss fowarding for WDI 1.0 and 2.0 */ |
| 704 | if (ipa_ctx->wdi_version != IPA_WDI_3) { |
| 705 | fw_desc = (uint8_t)nbuf->cb[1]; |
| 706 | return wlan_ipa_intrabss_forward(ipa_ctx, iface_ctx, fw_desc, |
| 707 | nbuf); |
| 708 | } |
| 709 | |
Jia Ding | 70deca7 | 2019-07-24 18:18:57 +0800 | [diff] [blame] | 710 | if (is_rx_dest_bridge_dev(iface_ctx, nbuf)) { |
| 711 | fwd_success = 0; |
| 712 | ret = WLAN_IPA_FORWARD_PKT_LOCAL_STACK; |
| 713 | goto exit; |
| 714 | } |
| 715 | |
jiad | 90b1725 | 2019-03-25 15:22:42 +0800 | [diff] [blame] | 716 | if (cdp_ipa_rx_intrabss_fwd(ipa_ctx->dp_soc, iface_ctx->tl_context, |
| 717 | nbuf, &fwd_success)) { |
| 718 | ipa_ctx->ipa_rx_internal_drop_count++; |
| 719 | ipa_ctx->ipa_rx_discard++; |
| 720 | |
| 721 | ret = WLAN_IPA_FORWARD_PKT_DISCARD; |
| 722 | } else { |
| 723 | ret = WLAN_IPA_FORWARD_PKT_LOCAL_STACK; |
| 724 | } |
| 725 | |
Jia Ding | 70deca7 | 2019-07-24 18:18:57 +0800 | [diff] [blame] | 726 | exit: |
jiad | 90b1725 | 2019-03-25 15:22:42 +0800 | [diff] [blame] | 727 | if (fwd_success) |
| 728 | ipa_ctx->stats.num_tx_fwd_ok++; |
| 729 | else |
| 730 | ipa_ctx->stats.num_tx_fwd_err++; |
| 731 | |
| 732 | return ret; |
| 733 | } |
| 734 | |
Sravan Kumar Kairam | d01b445 | 2018-03-07 17:37:09 +0530 | [diff] [blame] | 735 | #else /* CONFIG_IPA_WDI_UNIFIED_API */ |
| 736 | |
| 737 | static inline void wlan_ipa_wdi_get_wdi_version(struct wlan_ipa_priv *ipa_ctx) |
| 738 | { |
| 739 | } |
| 740 | |
Sravan Kumar Kairam | 983a445 | 2018-03-20 13:30:22 +0530 | [diff] [blame] | 741 | static inline int wlan_ipa_wdi_is_smmu_enabled(struct wlan_ipa_priv *ipa_ctx, |
| 742 | qdf_device_t osdev) |
| 743 | { |
| 744 | return qdf_mem_smmu_s1_enabled(osdev); |
| 745 | } |
| 746 | |
Sravan Kumar Kairam | 1309e7e | 2018-03-13 09:29:52 +0530 | [diff] [blame] | 747 | static inline QDF_STATUS wlan_ipa_wdi_setup(struct wlan_ipa_priv *ipa_ctx, |
| 748 | qdf_device_t osdev) |
| 749 | { |
| 750 | return cdp_ipa_setup(ipa_ctx->dp_soc, ipa_ctx->dp_pdev, |
| 751 | wlan_ipa_i2w_cb, wlan_ipa_w2i_cb, |
| 752 | wlan_ipa_wdi_meter_notifier_cb, |
| 753 | ipa_ctx->config->desc_size, |
| 754 | ipa_ctx, wlan_ipa_is_rm_enabled(ipa_ctx->config), |
| 755 | &ipa_ctx->tx_pipe_handle, |
| 756 | &ipa_ctx->rx_pipe_handle); |
| 757 | } |
| 758 | |
Sravan Kumar Kairam | d01b445 | 2018-03-07 17:37:09 +0530 | [diff] [blame] | 759 | static inline QDF_STATUS wlan_ipa_wdi_init(struct wlan_ipa_priv *ipa_ctx) |
| 760 | { |
| 761 | struct ipa_wdi_uc_ready_params uc_ready_param; |
| 762 | |
| 763 | ipa_ctx->uc_loaded = false; |
| 764 | uc_ready_param.priv = (void *)ipa_ctx; |
| 765 | uc_ready_param.notify = wlan_ipa_uc_loaded_uc_cb; |
| 766 | if (qdf_ipa_uc_reg_rdyCB(&uc_ready_param)) { |
| 767 | ipa_info("UC Ready CB register fail"); |
| 768 | return QDF_STATUS_E_FAILURE; |
| 769 | } |
| 770 | |
| 771 | if (true == uc_ready_param.is_uC_ready) { |
| 772 | ipa_info("UC Ready"); |
| 773 | ipa_ctx->uc_loaded = true; |
| 774 | } else { |
| 775 | return QDF_STATUS_E_BUSY; |
| 776 | } |
| 777 | |
| 778 | return QDF_STATUS_SUCCESS; |
| 779 | } |
| 780 | |
| 781 | static inline int wlan_ipa_wdi_cleanup(void) |
| 782 | { |
| 783 | int ret; |
| 784 | |
| 785 | ret = qdf_ipa_uc_dereg_rdyCB(); |
| 786 | if (ret) |
| 787 | ipa_info("UC Ready CB deregister fail"); |
| 788 | return ret; |
| 789 | } |
| 790 | |
| 791 | static inline int wlan_ipa_wdi_setup_sys_pipe( |
| 792 | struct wlan_ipa_priv *ipa_ctx, |
| 793 | struct ipa_sys_connect_params *sys, uint32_t *handle) |
| 794 | { |
| 795 | return qdf_ipa_setup_sys_pipe(sys, handle); |
| 796 | } |
| 797 | |
| 798 | static inline int wlan_ipa_wdi_teardown_sys_pipe( |
| 799 | struct wlan_ipa_priv *ipa_ctx, |
| 800 | uint32_t handle) |
| 801 | { |
| 802 | return qdf_ipa_teardown_sys_pipe(handle); |
| 803 | } |
| 804 | |
Yun Park | e74e609 | 2018-04-27 11:36:34 -0700 | [diff] [blame] | 805 | /** |
| 806 | * wlan_ipa_pm_flush() - flush queued packets |
| 807 | * @work: pointer to the scheduled work |
| 808 | * |
| 809 | * Called during PM resume to send packets to TL which were queued |
| 810 | * while host was in the process of suspending. |
| 811 | * |
| 812 | * Return: None |
| 813 | */ |
| 814 | static void wlan_ipa_pm_flush(void *data) |
| 815 | { |
| 816 | struct wlan_ipa_priv *ipa_ctx = (struct wlan_ipa_priv *)data; |
| 817 | struct wlan_ipa_pm_tx_cb *pm_tx_cb = NULL; |
| 818 | qdf_nbuf_t skb; |
| 819 | uint32_t dequeued = 0; |
| 820 | |
| 821 | qdf_wake_lock_acquire(&ipa_ctx->wake_lock, |
| 822 | WIFI_POWER_EVENT_WAKELOCK_IPA); |
| 823 | qdf_spin_lock_bh(&ipa_ctx->pm_lock); |
| 824 | while (((skb = qdf_nbuf_queue_remove(&ipa_ctx->pm_queue_head)) != |
| 825 | NULL)) { |
| 826 | qdf_spin_unlock_bh(&ipa_ctx->pm_lock); |
| 827 | |
| 828 | pm_tx_cb = (struct wlan_ipa_pm_tx_cb *)skb->cb; |
| 829 | dequeued++; |
| 830 | |
jiad | ab8cea0 | 2018-05-24 09:16:14 +0800 | [diff] [blame] | 831 | if (pm_tx_cb->exception) { |
| 832 | if (ipa_ctx->softap_xmit && |
| 833 | pm_tx_cb->iface_context->dev) { |
| 834 | ipa_ctx->softap_xmit(skb, |
| 835 | pm_tx_cb->iface_context->dev); |
| 836 | ipa_ctx->stats.num_tx_fwd_ok++; |
| 837 | } else { |
| 838 | dev_kfree_skb_any(skb); |
| 839 | } |
| 840 | } else { |
| 841 | wlan_ipa_send_pkt_to_tl(pm_tx_cb->iface_context, |
| 842 | pm_tx_cb->ipa_tx_desc); |
| 843 | } |
Yun Park | e74e609 | 2018-04-27 11:36:34 -0700 | [diff] [blame] | 844 | |
| 845 | qdf_spin_lock_bh(&ipa_ctx->pm_lock); |
| 846 | } |
| 847 | qdf_spin_unlock_bh(&ipa_ctx->pm_lock); |
| 848 | qdf_wake_lock_release(&ipa_ctx->wake_lock, |
| 849 | WIFI_POWER_EVENT_WAKELOCK_IPA); |
| 850 | |
| 851 | ipa_ctx->stats.num_tx_dequeued += dequeued; |
| 852 | if (dequeued > ipa_ctx->stats.num_max_pm_queue) |
| 853 | ipa_ctx->stats.num_max_pm_queue = dequeued; |
| 854 | } |
| 855 | |
jiad | ae9959f | 2018-05-08 11:19:07 +0800 | [diff] [blame] | 856 | int wlan_ipa_uc_smmu_map(bool map, uint32_t num_buf, qdf_mem_info_t *buf_arr) |
| 857 | { |
| 858 | if (!num_buf) { |
| 859 | ipa_info("No buffers to map/unmap"); |
| 860 | return 0; |
| 861 | } |
| 862 | |
| 863 | if (map) |
| 864 | return qdf_ipa_create_wdi_mapping(num_buf, buf_arr); |
| 865 | else |
| 866 | return qdf_ipa_release_wdi_mapping(num_buf, buf_arr); |
| 867 | } |
| 868 | |
jiad | 90b1725 | 2019-03-25 15:22:42 +0800 | [diff] [blame] | 869 | static enum wlan_ipa_forward_type |
| 870 | wlan_ipa_rx_intrabss_fwd(struct wlan_ipa_priv *ipa_ctx, |
| 871 | struct wlan_ipa_iface_context *iface_ctx, |
| 872 | qdf_nbuf_t nbuf) |
| 873 | { |
| 874 | uint8_t fw_desc; |
| 875 | |
| 876 | fw_desc = (uint8_t)nbuf->cb[1]; |
| 877 | |
| 878 | return wlan_ipa_intrabss_forward(ipa_ctx, iface_ctx, fw_desc, nbuf); |
| 879 | } |
| 880 | |
Sravan Kumar Kairam | d01b445 | 2018-03-07 17:37:09 +0530 | [diff] [blame] | 881 | #endif /* CONFIG_IPA_WDI_UNIFIED_API */ |
| 882 | |
Sravan Kumar Kairam | 1309e7e | 2018-03-13 09:29:52 +0530 | [diff] [blame] | 883 | /** |
| 884 | * wlan_ipa_send_skb_to_network() - Send skb to kernel |
| 885 | * @skb: network buffer |
| 886 | * @iface_ctx: IPA interface context |
| 887 | * |
| 888 | * Called when a network buffer is received which should not be routed |
| 889 | * to the IPA module. |
| 890 | * |
| 891 | * Return: None |
| 892 | */ |
| 893 | static void |
| 894 | wlan_ipa_send_skb_to_network(qdf_nbuf_t skb, |
| 895 | struct wlan_ipa_iface_context *iface_ctx) |
| 896 | { |
| 897 | struct wlan_ipa_priv *ipa_ctx = gp_ipa; |
| 898 | |
| 899 | if (!iface_ctx->dev) { |
jiad | f3ecc75 | 2018-07-05 14:36:03 +0800 | [diff] [blame] | 900 | ipa_debug_rl("Invalid interface"); |
Sravan Kumar Kairam | 1309e7e | 2018-03-13 09:29:52 +0530 | [diff] [blame] | 901 | ipa_ctx->ipa_rx_internal_drop_count++; |
jiad | f3ecc75 | 2018-07-05 14:36:03 +0800 | [diff] [blame] | 902 | dev_kfree_skb_any(skb); |
Sravan Kumar Kairam | 1309e7e | 2018-03-13 09:29:52 +0530 | [diff] [blame] | 903 | return; |
| 904 | } |
| 905 | |
| 906 | skb->destructor = wlan_ipa_uc_rt_debug_destructor; |
| 907 | |
| 908 | if (ipa_ctx->send_to_nw) |
| 909 | ipa_ctx->send_to_nw(skb, iface_ctx->dev); |
| 910 | |
| 911 | ipa_ctx->ipa_rx_net_send_count++; |
| 912 | } |
| 913 | |
| 914 | /** |
jitiphil | fdcaaba | 2018-09-03 16:19:52 +0530 | [diff] [blame] | 915 | * __wlan_ipa_w2i_cb() - WLAN to IPA callback handler |
Sravan Kumar Kairam | 1309e7e | 2018-03-13 09:29:52 +0530 | [diff] [blame] | 916 | * @priv: pointer to private data registered with IPA (we register a |
| 917 | * pointer to the global IPA context) |
| 918 | * @evt: the IPA event which triggered the callback |
| 919 | * @data: data associated with the event |
| 920 | * |
| 921 | * Return: None |
| 922 | */ |
jitiphil | fdcaaba | 2018-09-03 16:19:52 +0530 | [diff] [blame] | 923 | static void __wlan_ipa_w2i_cb(void *priv, qdf_ipa_dp_evt_type_t evt, |
| 924 | unsigned long data) |
Sravan Kumar Kairam | 1309e7e | 2018-03-13 09:29:52 +0530 | [diff] [blame] | 925 | { |
| 926 | struct wlan_ipa_priv *ipa_ctx = NULL; |
| 927 | qdf_nbuf_t skb; |
| 928 | uint8_t iface_id; |
Mohit Khanna | cabf5e7 | 2018-07-24 13:28:43 -0700 | [diff] [blame] | 929 | uint8_t session_id = 0xff; |
Sravan Kumar Kairam | 1309e7e | 2018-03-13 09:29:52 +0530 | [diff] [blame] | 930 | struct wlan_ipa_iface_context *iface_context; |
Sravan Kumar Kairam | 1309e7e | 2018-03-13 09:29:52 +0530 | [diff] [blame] | 931 | |
Sravan Kumar Kairam | 9cd68d0 | 2019-01-14 12:51:59 +0530 | [diff] [blame] | 932 | ipa_ctx = (struct wlan_ipa_priv *)priv; |
| 933 | if (!ipa_ctx) { |
| 934 | if (evt == IPA_RECEIVE) { |
| 935 | skb = (qdf_nbuf_t)data; |
| 936 | dev_kfree_skb_any(skb); |
| 937 | } |
jitiphil | fdcaaba | 2018-09-03 16:19:52 +0530 | [diff] [blame] | 938 | return; |
| 939 | } |
| 940 | |
Sravan Kumar Kairam | 1309e7e | 2018-03-13 09:29:52 +0530 | [diff] [blame] | 941 | switch (evt) { |
| 942 | case IPA_RECEIVE: |
| 943 | skb = (qdf_nbuf_t) data; |
Sravan Kumar Kairam | 1309e7e | 2018-03-13 09:29:52 +0530 | [diff] [blame] | 944 | if (wlan_ipa_uc_is_enabled(ipa_ctx->config)) { |
| 945 | session_id = (uint8_t)skb->cb[0]; |
| 946 | iface_id = ipa_ctx->vdev_to_iface[session_id]; |
Sravan Kumar Kairam | 1309e7e | 2018-03-13 09:29:52 +0530 | [diff] [blame] | 947 | } else { |
| 948 | iface_id = WLAN_IPA_GET_IFACE_ID(skb->data); |
| 949 | } |
| 950 | if (iface_id >= WLAN_IPA_MAX_IFACE) { |
Mohit Khanna | cabf5e7 | 2018-07-24 13:28:43 -0700 | [diff] [blame] | 951 | ipa_err_rl("Invalid iface_id: %u,session id: %x %x %x %x. Dropped!", |
| 952 | iface_id, session_id, (uint8_t)skb->cb[1], |
| 953 | (uint8_t)skb->cb[2], (uint8_t)skb->cb[3]); |
Sravan Kumar Kairam | 1309e7e | 2018-03-13 09:29:52 +0530 | [diff] [blame] | 954 | ipa_ctx->ipa_rx_internal_drop_count++; |
jiad | ab8cea0 | 2018-05-24 09:16:14 +0800 | [diff] [blame] | 955 | dev_kfree_skb_any(skb); |
Sravan Kumar Kairam | 1309e7e | 2018-03-13 09:29:52 +0530 | [diff] [blame] | 956 | return; |
| 957 | } |
| 958 | |
| 959 | iface_context = &ipa_ctx->iface_context[iface_id]; |
| 960 | if (!iface_context->tl_context) { |
jiad | f3ecc75 | 2018-07-05 14:36:03 +0800 | [diff] [blame] | 961 | ipa_err_rl("TL context of iface_id %u is NULL", |
| 962 | iface_id); |
Sravan Kumar Kairam | 1309e7e | 2018-03-13 09:29:52 +0530 | [diff] [blame] | 963 | ipa_ctx->ipa_rx_internal_drop_count++; |
jiad | ab8cea0 | 2018-05-24 09:16:14 +0800 | [diff] [blame] | 964 | dev_kfree_skb_any(skb); |
Sravan Kumar Kairam | 1309e7e | 2018-03-13 09:29:52 +0530 | [diff] [blame] | 965 | return; |
| 966 | } |
| 967 | |
| 968 | if (wlan_ipa_uc_is_enabled(ipa_ctx->config)) { |
| 969 | ipa_ctx->stats.num_rx_excep++; |
| 970 | qdf_nbuf_pull_head(skb, WLAN_IPA_UC_WLAN_CLD_HDR_LEN); |
| 971 | } else { |
| 972 | qdf_nbuf_pull_head(skb, WLAN_IPA_WLAN_CLD_HDR_LEN); |
| 973 | } |
Sravan Kumar Kairam | 1309e7e | 2018-03-13 09:29:52 +0530 | [diff] [blame] | 974 | iface_context->stats.num_rx_ipa_excep++; |
| 975 | |
| 976 | /* Disable to forward Intra-BSS Rx packets when |
| 977 | * ap_isolate=1 in hostapd.conf |
| 978 | */ |
| 979 | if (!ipa_ctx->ap_intrabss_fwd) { |
| 980 | /* |
| 981 | * When INTRA_BSS_FWD_OFFLOAD is enabled, FW will send |
| 982 | * all Rx packets to IPA uC, which need to be forwarded |
| 983 | * to other interface. |
| 984 | * And, IPA driver will send back to WLAN host driver |
| 985 | * through exception pipe with fw_desc field set by FW. |
| 986 | * Here we are checking fw_desc field for FORWARD bit |
| 987 | * set, and forward to Tx. Then copy to kernel stack |
| 988 | * only when DISCARD bit is not set. |
| 989 | */ |
Sravan Kumar Kairam | 1309e7e | 2018-03-13 09:29:52 +0530 | [diff] [blame] | 990 | if (WLAN_IPA_FORWARD_PKT_DISCARD == |
jiad | 90b1725 | 2019-03-25 15:22:42 +0800 | [diff] [blame] | 991 | wlan_ipa_rx_intrabss_fwd(ipa_ctx, iface_context, |
| 992 | skb)) |
Sravan Kumar Kairam | 1309e7e | 2018-03-13 09:29:52 +0530 | [diff] [blame] | 993 | break; |
| 994 | } else { |
jiad | f3ecc75 | 2018-07-05 14:36:03 +0800 | [diff] [blame] | 995 | ipa_debug_rl("Intra-BSS forwarding is disabled"); |
Sravan Kumar Kairam | 1309e7e | 2018-03-13 09:29:52 +0530 | [diff] [blame] | 996 | } |
| 997 | |
| 998 | wlan_ipa_send_skb_to_network(skb, iface_context); |
| 999 | break; |
| 1000 | |
| 1001 | default: |
jiad | f3ecc75 | 2018-07-05 14:36:03 +0800 | [diff] [blame] | 1002 | ipa_err_rl("w2i cb wrong event: 0x%x", evt); |
Sravan Kumar Kairam | 1309e7e | 2018-03-13 09:29:52 +0530 | [diff] [blame] | 1003 | return; |
| 1004 | } |
| 1005 | } |
| 1006 | |
jiad | 7bac1ef | 2019-07-03 11:30:24 +0800 | [diff] [blame] | 1007 | #ifndef MDM_PLATFORM |
Sravan Kumar Kairam | 1309e7e | 2018-03-13 09:29:52 +0530 | [diff] [blame] | 1008 | /** |
jitiphil | fdcaaba | 2018-09-03 16:19:52 +0530 | [diff] [blame] | 1009 | * wlan_ipa_w2i_cb() - SSR wrapper for __wlan_ipa_w2i_cb |
| 1010 | * @priv: pointer to private data registered with IPA (we register a |
| 1011 | * pointer to the global IPA context) |
| 1012 | * @evt: the IPA event which triggered the callback |
| 1013 | * @data: data associated with the event |
| 1014 | * |
| 1015 | * Return: None |
| 1016 | */ |
| 1017 | static void wlan_ipa_w2i_cb(void *priv, qdf_ipa_dp_evt_type_t evt, |
| 1018 | unsigned long data) |
| 1019 | { |
Dustin Brown | 3fdaaf6 | 2019-03-18 14:00:16 -0700 | [diff] [blame] | 1020 | struct qdf_op_sync *op_sync; |
| 1021 | |
| 1022 | if (qdf_op_protect(&op_sync)) { |
| 1023 | if (evt == IPA_RECEIVE) { |
| 1024 | struct wlan_ipa_priv *ipa_ctx = priv; |
| 1025 | qdf_nbuf_t skb = (qdf_nbuf_t)data; |
| 1026 | |
| 1027 | ipa_ctx->ipa_rx_internal_drop_count++; |
| 1028 | dev_kfree_skb_any(skb); |
| 1029 | } |
| 1030 | |
| 1031 | return; |
| 1032 | } |
| 1033 | |
jitiphil | fdcaaba | 2018-09-03 16:19:52 +0530 | [diff] [blame] | 1034 | __wlan_ipa_w2i_cb(priv, evt, data); |
Dustin Brown | 3fdaaf6 | 2019-03-18 14:00:16 -0700 | [diff] [blame] | 1035 | |
| 1036 | qdf_op_unprotect(op_sync); |
jitiphil | fdcaaba | 2018-09-03 16:19:52 +0530 | [diff] [blame] | 1037 | } |
jiad | 7bac1ef | 2019-07-03 11:30:24 +0800 | [diff] [blame] | 1038 | #else /* MDM_PLATFORM */ |
| 1039 | static void wlan_ipa_w2i_cb(void *priv, qdf_ipa_dp_evt_type_t evt, |
| 1040 | unsigned long data) |
| 1041 | { |
| 1042 | __wlan_ipa_w2i_cb(priv, evt, data); |
| 1043 | } |
| 1044 | #endif /* MDM_PLATFORM */ |
jitiphil | fdcaaba | 2018-09-03 16:19:52 +0530 | [diff] [blame] | 1045 | |
| 1046 | /** |
| 1047 | * __wlan_ipa_i2w_cb() - IPA to WLAN callback |
Sravan Kumar Kairam | 1309e7e | 2018-03-13 09:29:52 +0530 | [diff] [blame] | 1048 | * @priv: pointer to private data registered with IPA (we register a |
| 1049 | * pointer to the interface-specific IPA context) |
| 1050 | * @evt: the IPA event which triggered the callback |
| 1051 | * @data: data associated with the event |
| 1052 | * |
| 1053 | * Return: None |
| 1054 | */ |
jitiphil | fdcaaba | 2018-09-03 16:19:52 +0530 | [diff] [blame] | 1055 | static void __wlan_ipa_i2w_cb(void *priv, qdf_ipa_dp_evt_type_t evt, |
| 1056 | unsigned long data) |
Sravan Kumar Kairam | 1309e7e | 2018-03-13 09:29:52 +0530 | [diff] [blame] | 1057 | { |
| 1058 | struct wlan_ipa_priv *ipa_ctx = NULL; |
| 1059 | qdf_ipa_rx_data_t *ipa_tx_desc; |
| 1060 | struct wlan_ipa_iface_context *iface_context; |
| 1061 | qdf_nbuf_t skb; |
| 1062 | struct wlan_ipa_pm_tx_cb *pm_tx_cb = NULL; |
| 1063 | |
| 1064 | iface_context = (struct wlan_ipa_iface_context *)priv; |
| 1065 | ipa_tx_desc = (qdf_ipa_rx_data_t *)data; |
| 1066 | ipa_ctx = iface_context->ipa_ctx; |
| 1067 | |
| 1068 | if (evt != IPA_RECEIVE) { |
jiad | f3ecc75 | 2018-07-05 14:36:03 +0800 | [diff] [blame] | 1069 | ipa_err_rl("Event is not IPA_RECEIVE"); |
Sravan Kumar Kairam | 1309e7e | 2018-03-13 09:29:52 +0530 | [diff] [blame] | 1070 | ipa_free_skb(ipa_tx_desc); |
| 1071 | iface_context->stats.num_tx_drop++; |
| 1072 | return; |
| 1073 | } |
| 1074 | |
| 1075 | skb = QDF_IPA_RX_DATA_SKB(ipa_tx_desc); |
| 1076 | |
| 1077 | /* |
| 1078 | * If PROD resource is not requested here then there may be cases where |
| 1079 | * IPA hardware may be clocked down because of not having proper |
| 1080 | * dependency graph between WLAN CONS and modem PROD pipes. Adding the |
| 1081 | * workaround to request PROD resource while data is going over CONS |
| 1082 | * pipe to prevent the IPA hardware clockdown. |
| 1083 | */ |
| 1084 | wlan_ipa_wdi_rm_request(ipa_ctx); |
| 1085 | |
| 1086 | qdf_spin_lock_bh(&ipa_ctx->pm_lock); |
| 1087 | /* |
| 1088 | * If host is still suspended then queue the packets and these will be |
| 1089 | * drained later when resume completes. When packet is arrived here and |
| 1090 | * host is suspended, this means that there is already resume is in |
| 1091 | * progress. |
| 1092 | */ |
| 1093 | if (ipa_ctx->suspended) { |
hangtian | 127c953 | 2019-01-12 13:29:07 +0800 | [diff] [blame] | 1094 | qdf_mem_zero(skb->cb, sizeof(skb->cb)); |
Sravan Kumar Kairam | 1309e7e | 2018-03-13 09:29:52 +0530 | [diff] [blame] | 1095 | pm_tx_cb = (struct wlan_ipa_pm_tx_cb *)skb->cb; |
| 1096 | pm_tx_cb->iface_context = iface_context; |
| 1097 | pm_tx_cb->ipa_tx_desc = ipa_tx_desc; |
| 1098 | qdf_nbuf_queue_add(&ipa_ctx->pm_queue_head, skb); |
| 1099 | ipa_ctx->stats.num_tx_queued++; |
| 1100 | |
| 1101 | qdf_spin_unlock_bh(&ipa_ctx->pm_lock); |
| 1102 | return; |
| 1103 | } |
| 1104 | |
| 1105 | qdf_spin_unlock_bh(&ipa_ctx->pm_lock); |
| 1106 | |
| 1107 | /* |
| 1108 | * If we are here means, host is not suspended, wait for the work queue |
| 1109 | * to finish. |
| 1110 | */ |
| 1111 | qdf_flush_work(&ipa_ctx->pm_work); |
| 1112 | |
| 1113 | return wlan_ipa_send_pkt_to_tl(iface_context, ipa_tx_desc); |
| 1114 | } |
| 1115 | |
jitiphil | fdcaaba | 2018-09-03 16:19:52 +0530 | [diff] [blame] | 1116 | /** |
| 1117 | * wlan_ipa_i2w_cb() - IPA to WLAN callback |
| 1118 | * @priv: pointer to private data registered with IPA (we register a |
| 1119 | * pointer to the interface-specific IPA context) |
| 1120 | * @evt: the IPA event which triggered the callback |
| 1121 | * @data: data associated with the event |
| 1122 | * |
| 1123 | * Return: None |
| 1124 | */ |
| 1125 | static void wlan_ipa_i2w_cb(void *priv, qdf_ipa_dp_evt_type_t evt, |
| 1126 | unsigned long data) |
| 1127 | { |
Dustin Brown | 3fdaaf6 | 2019-03-18 14:00:16 -0700 | [diff] [blame] | 1128 | struct qdf_op_sync *op_sync; |
| 1129 | |
| 1130 | if (qdf_op_protect(&op_sync)) { |
| 1131 | qdf_ipa_rx_data_t *ipa_tx_desc = (qdf_ipa_rx_data_t *)data; |
| 1132 | struct wlan_ipa_iface_context *iface_context = priv; |
| 1133 | |
| 1134 | ipa_free_skb(ipa_tx_desc); |
| 1135 | iface_context->stats.num_tx_drop++; |
| 1136 | |
| 1137 | return; |
| 1138 | } |
| 1139 | |
jitiphil | fdcaaba | 2018-09-03 16:19:52 +0530 | [diff] [blame] | 1140 | __wlan_ipa_i2w_cb(priv, evt, data); |
Dustin Brown | 3fdaaf6 | 2019-03-18 14:00:16 -0700 | [diff] [blame] | 1141 | |
| 1142 | qdf_op_unprotect(op_sync); |
jitiphil | fdcaaba | 2018-09-03 16:19:52 +0530 | [diff] [blame] | 1143 | } |
| 1144 | |
Sravan Kumar Kairam | 1309e7e | 2018-03-13 09:29:52 +0530 | [diff] [blame] | 1145 | QDF_STATUS wlan_ipa_suspend(struct wlan_ipa_priv *ipa_ctx) |
| 1146 | { |
| 1147 | /* |
| 1148 | * Check if IPA is ready for suspend, If we are here means, there is |
| 1149 | * high chance that suspend would go through but just to avoid any race |
| 1150 | * condition after suspend started, these checks are conducted before |
| 1151 | * allowing to suspend. |
| 1152 | */ |
| 1153 | if (atomic_read(&ipa_ctx->tx_ref_cnt)) |
| 1154 | return QDF_STATUS_E_AGAIN; |
| 1155 | |
Yun Park | e74e609 | 2018-04-27 11:36:34 -0700 | [diff] [blame] | 1156 | if (!wlan_ipa_is_rm_released(ipa_ctx)) |
Sravan Kumar Kairam | 1309e7e | 2018-03-13 09:29:52 +0530 | [diff] [blame] | 1157 | return QDF_STATUS_E_AGAIN; |
Sravan Kumar Kairam | 1309e7e | 2018-03-13 09:29:52 +0530 | [diff] [blame] | 1158 | |
| 1159 | qdf_spin_lock_bh(&ipa_ctx->pm_lock); |
| 1160 | ipa_ctx->suspended = true; |
| 1161 | qdf_spin_unlock_bh(&ipa_ctx->pm_lock); |
| 1162 | |
| 1163 | return QDF_STATUS_SUCCESS; |
| 1164 | } |
| 1165 | |
| 1166 | QDF_STATUS wlan_ipa_resume(struct wlan_ipa_priv *ipa_ctx) |
| 1167 | { |
| 1168 | qdf_sched_work(0, &ipa_ctx->pm_work); |
| 1169 | |
| 1170 | qdf_spin_lock_bh(&ipa_ctx->pm_lock); |
| 1171 | ipa_ctx->suspended = false; |
| 1172 | qdf_spin_unlock_bh(&ipa_ctx->pm_lock); |
| 1173 | |
| 1174 | return QDF_STATUS_SUCCESS; |
| 1175 | } |
| 1176 | |
Sravan Kumar Kairam | 2e7aae9 | 2018-03-06 19:32:49 +0530 | [diff] [blame] | 1177 | QDF_STATUS wlan_ipa_uc_enable_pipes(struct wlan_ipa_priv *ipa_ctx) |
| 1178 | { |
| 1179 | int result; |
| 1180 | |
| 1181 | ipa_debug("enter"); |
| 1182 | |
| 1183 | if (!ipa_ctx->ipa_pipes_down) { |
| 1184 | /* |
| 1185 | * IPA WDI Pipes are already activated due to |
| 1186 | * rm deferred resources grant |
| 1187 | */ |
| 1188 | ipa_warn("IPA WDI Pipes are already activated"); |
| 1189 | goto end; |
| 1190 | } |
| 1191 | |
| 1192 | result = cdp_ipa_enable_pipes(ipa_ctx->dp_soc, |
| 1193 | ipa_ctx->dp_pdev); |
| 1194 | if (result) { |
| 1195 | ipa_err("Enable IPA WDI PIPE failed: ret=%d", result); |
| 1196 | return QDF_STATUS_E_FAILURE; |
| 1197 | } |
| 1198 | |
| 1199 | qdf_event_reset(&ipa_ctx->ipa_resource_comp); |
| 1200 | ipa_ctx->ipa_pipes_down = false; |
| 1201 | |
| 1202 | cdp_ipa_enable_autonomy(ipa_ctx->dp_soc, |
| 1203 | ipa_ctx->dp_pdev); |
| 1204 | |
| 1205 | end: |
| 1206 | ipa_debug("exit: ipa_pipes_down=%d", ipa_ctx->ipa_pipes_down); |
| 1207 | |
| 1208 | return QDF_STATUS_SUCCESS; |
| 1209 | } |
| 1210 | |
| 1211 | QDF_STATUS wlan_ipa_uc_disable_pipes(struct wlan_ipa_priv *ipa_ctx) |
| 1212 | { |
| 1213 | int result; |
| 1214 | |
| 1215 | ipa_debug("enter"); |
| 1216 | |
| 1217 | if (ipa_ctx->ipa_pipes_down) { |
Sravan Kumar Kairam | 2e7aae9 | 2018-03-06 19:32:49 +0530 | [diff] [blame] | 1218 | ipa_warn("IPA WDI Pipes are already deactivated"); |
| 1219 | goto end; |
| 1220 | } |
| 1221 | |
Rakshith Suresh Patkar | 785b845 | 2019-03-18 13:36:02 +0530 | [diff] [blame] | 1222 | qdf_spin_lock_bh(&ipa_ctx->pipes_down_lock); |
| 1223 | if (ipa_ctx->pipes_down_in_progress || ipa_ctx->ipa_pipes_down) { |
| 1224 | ipa_warn("IPA WDI Pipes down already in progress"); |
| 1225 | qdf_spin_unlock_bh(&ipa_ctx->pipes_down_lock); |
| 1226 | return QDF_STATUS_E_ALREADY; |
| 1227 | } |
| 1228 | ipa_ctx->pipes_down_in_progress = true; |
| 1229 | qdf_spin_unlock_bh(&ipa_ctx->pipes_down_lock); |
| 1230 | |
Sravan Kumar Kairam | 2e7aae9 | 2018-03-06 19:32:49 +0530 | [diff] [blame] | 1231 | cdp_ipa_disable_autonomy(ipa_ctx->dp_soc, |
| 1232 | ipa_ctx->dp_pdev); |
| 1233 | |
| 1234 | result = cdp_ipa_disable_pipes(ipa_ctx->dp_soc, |
| 1235 | ipa_ctx->dp_pdev); |
| 1236 | if (result) { |
| 1237 | ipa_err("Disable IPA WDI PIPE failed: ret=%d", result); |
Rakshith Suresh Patkar | 785b845 | 2019-03-18 13:36:02 +0530 | [diff] [blame] | 1238 | ipa_ctx->pipes_down_in_progress = false; |
Sravan Kumar Kairam | 2e7aae9 | 2018-03-06 19:32:49 +0530 | [diff] [blame] | 1239 | return QDF_STATUS_E_FAILURE; |
| 1240 | } |
| 1241 | |
| 1242 | ipa_ctx->ipa_pipes_down = true; |
Rakshith Suresh Patkar | 785b845 | 2019-03-18 13:36:02 +0530 | [diff] [blame] | 1243 | ipa_ctx->pipes_down_in_progress = false; |
Sravan Kumar Kairam | 2e7aae9 | 2018-03-06 19:32:49 +0530 | [diff] [blame] | 1244 | |
| 1245 | end: |
| 1246 | ipa_debug("exit: ipa_pipes_down=%d", ipa_ctx->ipa_pipes_down); |
| 1247 | |
| 1248 | return QDF_STATUS_SUCCESS; |
| 1249 | } |
| 1250 | |
Sravan Kumar Kairam | d01b445 | 2018-03-07 17:37:09 +0530 | [diff] [blame] | 1251 | /** |
Sravan Kumar Kairam | 5214f65 | 2018-03-13 09:52:31 +0530 | [diff] [blame] | 1252 | * wlan_ipa_uc_find_add_assoc_sta() - Find associated station |
| 1253 | * @ipa_ctx: Global IPA IPA context |
| 1254 | * @sta_add: Should station be added |
Rakshith Suresh Patkar | 96703f6 | 2019-08-06 14:34:36 +0530 | [diff] [blame] | 1255 | * @mac_addr: mac address of station being queried |
Sravan Kumar Kairam | 5214f65 | 2018-03-13 09:52:31 +0530 | [diff] [blame] | 1256 | * |
| 1257 | * Return: true if the station was found |
| 1258 | */ |
| 1259 | static bool wlan_ipa_uc_find_add_assoc_sta(struct wlan_ipa_priv *ipa_ctx, |
Rakshith Suresh Patkar | 96703f6 | 2019-08-06 14:34:36 +0530 | [diff] [blame] | 1260 | bool sta_add, |
Sravan Kumar Kairam | 5214f65 | 2018-03-13 09:52:31 +0530 | [diff] [blame] | 1261 | uint8_t *mac_addr) |
| 1262 | { |
| 1263 | bool sta_found = false; |
| 1264 | uint8_t idx; |
| 1265 | |
| 1266 | for (idx = 0; idx < WLAN_IPA_MAX_STA_COUNT; idx++) { |
| 1267 | if ((ipa_ctx->assoc_stas_map[idx].is_reserved) && |
Rakshith Suresh Patkar | 96703f6 | 2019-08-06 14:34:36 +0530 | [diff] [blame] | 1268 | (qdf_is_macaddr_equal( |
| 1269 | &ipa_ctx->assoc_stas_map[idx].mac_addr, |
| 1270 | (struct qdf_mac_addr *)mac_addr))) { |
Sravan Kumar Kairam | 5214f65 | 2018-03-13 09:52:31 +0530 | [diff] [blame] | 1271 | sta_found = true; |
| 1272 | break; |
| 1273 | } |
| 1274 | } |
| 1275 | if (sta_add && sta_found) { |
Rakshith Suresh Patkar | 96703f6 | 2019-08-06 14:34:36 +0530 | [diff] [blame] | 1276 | ipa_err("STA already exist, cannot add: " QDF_MAC_ADDR_STR, |
| 1277 | QDF_MAC_ADDR_ARRAY(mac_addr)); |
Sravan Kumar Kairam | 5214f65 | 2018-03-13 09:52:31 +0530 | [diff] [blame] | 1278 | return sta_found; |
| 1279 | } |
| 1280 | if (sta_add) { |
| 1281 | for (idx = 0; idx < WLAN_IPA_MAX_STA_COUNT; idx++) { |
| 1282 | if (!ipa_ctx->assoc_stas_map[idx].is_reserved) { |
| 1283 | ipa_ctx->assoc_stas_map[idx].is_reserved = true; |
Sravan Kumar Kairam | 5214f65 | 2018-03-13 09:52:31 +0530 | [diff] [blame] | 1284 | qdf_mem_copy(&ipa_ctx->assoc_stas_map[idx]. |
| 1285 | mac_addr, mac_addr, |
| 1286 | QDF_NET_ETH_LEN); |
| 1287 | return sta_found; |
| 1288 | } |
| 1289 | } |
| 1290 | } |
| 1291 | if (!sta_add && !sta_found) { |
Rakshith Suresh Patkar | 96703f6 | 2019-08-06 14:34:36 +0530 | [diff] [blame] | 1292 | ipa_err("STA does not exist, cannot delete: " QDF_MAC_ADDR_STR, |
| 1293 | QDF_MAC_ADDR_ARRAY(mac_addr)); |
Sravan Kumar Kairam | 5214f65 | 2018-03-13 09:52:31 +0530 | [diff] [blame] | 1294 | return sta_found; |
| 1295 | } |
| 1296 | if (!sta_add) { |
| 1297 | for (idx = 0; idx < WLAN_IPA_MAX_STA_COUNT; idx++) { |
| 1298 | if ((ipa_ctx->assoc_stas_map[idx].is_reserved) && |
Rakshith Suresh Patkar | 96703f6 | 2019-08-06 14:34:36 +0530 | [diff] [blame] | 1299 | (qdf_is_macaddr_equal( |
| 1300 | &ipa_ctx->assoc_stas_map[idx].mac_addr, |
| 1301 | (struct qdf_mac_addr *)mac_addr))) { |
Sravan Kumar Kairam | 5214f65 | 2018-03-13 09:52:31 +0530 | [diff] [blame] | 1302 | ipa_ctx->assoc_stas_map[idx].is_reserved = |
| 1303 | false; |
hangtian | 127c953 | 2019-01-12 13:29:07 +0800 | [diff] [blame] | 1304 | qdf_mem_zero( |
| 1305 | &ipa_ctx->assoc_stas_map[idx].mac_addr, |
| 1306 | QDF_NET_ETH_LEN); |
Sravan Kumar Kairam | 5214f65 | 2018-03-13 09:52:31 +0530 | [diff] [blame] | 1307 | return sta_found; |
| 1308 | } |
| 1309 | } |
| 1310 | } |
| 1311 | |
| 1312 | return sta_found; |
| 1313 | } |
| 1314 | |
| 1315 | /** |
| 1316 | * wlan_ipa_get_ifaceid() - Get IPA context interface ID |
| 1317 | * @ipa_ctx: IPA context |
| 1318 | * @session_id: Session ID |
| 1319 | * |
| 1320 | * Return: None |
| 1321 | */ |
| 1322 | static int wlan_ipa_get_ifaceid(struct wlan_ipa_priv *ipa_ctx, |
| 1323 | uint8_t session_id) |
| 1324 | { |
| 1325 | struct wlan_ipa_iface_context *iface_ctx; |
| 1326 | int i; |
| 1327 | |
| 1328 | for (i = 0; i < WLAN_IPA_MAX_IFACE; i++) { |
| 1329 | iface_ctx = &ipa_ctx->iface_context[i]; |
| 1330 | if (iface_ctx->session_id == session_id) |
| 1331 | break; |
| 1332 | } |
| 1333 | |
| 1334 | return i; |
| 1335 | } |
| 1336 | |
| 1337 | /** |
| 1338 | * wlan_ipa_cleanup_iface() - Cleanup IPA on a given interface |
| 1339 | * @iface_context: interface-specific IPA context |
| 1340 | * |
| 1341 | * Return: None |
| 1342 | */ |
| 1343 | static void wlan_ipa_cleanup_iface(struct wlan_ipa_iface_context *iface_context) |
| 1344 | { |
| 1345 | struct wlan_ipa_priv *ipa_ctx = iface_context->ipa_ctx; |
| 1346 | |
| 1347 | ipa_debug("enter"); |
| 1348 | |
| 1349 | if (!iface_context->tl_context) |
| 1350 | return; |
| 1351 | |
| 1352 | cdp_ipa_cleanup_iface(ipa_ctx->dp_soc, |
| 1353 | iface_context->dev->name, |
| 1354 | wlan_ipa_is_ipv6_enabled(ipa_ctx->config)); |
| 1355 | |
| 1356 | qdf_spin_lock_bh(&iface_context->interface_lock); |
| 1357 | iface_context->tl_context = NULL; |
| 1358 | iface_context->dev = NULL; |
| 1359 | iface_context->device_mode = QDF_MAX_NO_OF_MODE; |
| 1360 | iface_context->session_id = WLAN_IPA_MAX_SESSION; |
Sravan Kumar Kairam | 5214f65 | 2018-03-13 09:52:31 +0530 | [diff] [blame] | 1361 | qdf_spin_unlock_bh(&iface_context->interface_lock); |
| 1362 | iface_context->ifa_address = 0; |
| 1363 | if (!iface_context->ipa_ctx->num_iface) { |
| 1364 | ipa_err("NUM INTF 0, Invalid"); |
| 1365 | QDF_ASSERT(0); |
| 1366 | } |
| 1367 | iface_context->ipa_ctx->num_iface--; |
| 1368 | ipa_debug("exit: num_iface=%d", iface_context->ipa_ctx->num_iface); |
| 1369 | } |
| 1370 | |
| 1371 | /** |
Sravan Kumar Kairam | 1f8f8b3 | 2018-07-06 16:05:24 +0530 | [diff] [blame] | 1372 | * wlan_ipa_nbuf_cb() - IPA TX complete callback |
| 1373 | * @skb: packet buffer which was transmitted |
| 1374 | * |
| 1375 | * Return: None |
| 1376 | */ |
| 1377 | static void wlan_ipa_nbuf_cb(qdf_nbuf_t skb) |
| 1378 | { |
| 1379 | struct wlan_ipa_priv *ipa_ctx = gp_ipa; |
| 1380 | qdf_ipa_rx_data_t *ipa_tx_desc; |
| 1381 | struct wlan_ipa_tx_desc *tx_desc; |
| 1382 | uint16_t id; |
| 1383 | |
| 1384 | if (!qdf_nbuf_ipa_owned_get(skb)) { |
| 1385 | dev_kfree_skb_any(skb); |
| 1386 | return; |
| 1387 | } |
| 1388 | |
| 1389 | /* Get Tx desc pointer from SKB CB */ |
| 1390 | id = QDF_NBUF_CB_TX_IPA_PRIV(skb); |
| 1391 | tx_desc = &ipa_ctx->tx_desc_pool[id]; |
| 1392 | ipa_tx_desc = tx_desc->ipa_tx_desc_ptr; |
| 1393 | |
| 1394 | /* Return Tx Desc to IPA */ |
| 1395 | qdf_ipa_free_skb(ipa_tx_desc); |
| 1396 | |
| 1397 | /* Return to free tx desc list */ |
| 1398 | qdf_spin_lock_bh(&ipa_ctx->q_lock); |
| 1399 | tx_desc->ipa_tx_desc_ptr = NULL; |
| 1400 | qdf_list_insert_back(&ipa_ctx->tx_desc_free_list, &tx_desc->node); |
| 1401 | ipa_ctx->stats.num_tx_desc_q_cnt--; |
| 1402 | qdf_spin_unlock_bh(&ipa_ctx->q_lock); |
| 1403 | |
| 1404 | ipa_ctx->stats.num_tx_comp_cnt++; |
| 1405 | |
| 1406 | qdf_atomic_dec(&ipa_ctx->tx_ref_cnt); |
| 1407 | |
| 1408 | wlan_ipa_wdi_rm_try_release(ipa_ctx); |
| 1409 | } |
| 1410 | |
| 1411 | /** |
Sravan Kumar Kairam | 5214f65 | 2018-03-13 09:52:31 +0530 | [diff] [blame] | 1412 | * wlan_ipa_setup_iface() - Setup IPA on a given interface |
| 1413 | * @ipa_ctx: IPA IPA global context |
| 1414 | * @net_dev: Interface net device |
| 1415 | * @device_mode: Net interface device mode |
| 1416 | * @adapter: Interface upon which IPA is being setup |
Sravan Kumar Kairam | 5214f65 | 2018-03-13 09:52:31 +0530 | [diff] [blame] | 1417 | * @session_id: Station ID of the API instance |
| 1418 | * |
| 1419 | * Return: QDF STATUS |
| 1420 | */ |
| 1421 | static QDF_STATUS wlan_ipa_setup_iface(struct wlan_ipa_priv *ipa_ctx, |
| 1422 | qdf_netdev_t net_dev, |
Rakshith Suresh Patkar | 96703f6 | 2019-08-06 14:34:36 +0530 | [diff] [blame] | 1423 | uint8_t device_mode, |
Sravan Kumar Kairam | 5214f65 | 2018-03-13 09:52:31 +0530 | [diff] [blame] | 1424 | uint8_t session_id) |
| 1425 | { |
| 1426 | struct wlan_ipa_iface_context *iface_context = NULL; |
| 1427 | void *tl_context = NULL; |
| 1428 | int i; |
| 1429 | QDF_STATUS status; |
| 1430 | |
| 1431 | /* Lower layer may send multiple START_BSS_EVENT in DFS mode or during |
| 1432 | * channel change indication. Since these indications are sent by lower |
| 1433 | * layer as SAP updates and IPA doesn't have to do anything for these |
| 1434 | * updates so ignoring! |
| 1435 | */ |
| 1436 | if (device_mode == QDF_SAP_MODE) { |
| 1437 | for (i = 0; i < WLAN_IPA_MAX_IFACE; i++) { |
| 1438 | iface_context = &(ipa_ctx->iface_context[i]); |
Mohit Khanna | cabf5e7 | 2018-07-24 13:28:43 -0700 | [diff] [blame] | 1439 | if (iface_context->dev == net_dev) { |
| 1440 | ipa_debug("found iface %u device_mode %u", |
| 1441 | i, device_mode); |
Sravan Kumar Kairam | 5214f65 | 2018-03-13 09:52:31 +0530 | [diff] [blame] | 1442 | return QDF_STATUS_SUCCESS; |
Mohit Khanna | cabf5e7 | 2018-07-24 13:28:43 -0700 | [diff] [blame] | 1443 | } |
Sravan Kumar Kairam | 5214f65 | 2018-03-13 09:52:31 +0530 | [diff] [blame] | 1444 | } |
| 1445 | } |
| 1446 | |
Yun Park | 21ec490 | 2018-04-24 12:11:01 -0700 | [diff] [blame] | 1447 | if (WLAN_IPA_MAX_IFACE == ipa_ctx->num_iface) { |
| 1448 | ipa_err("Max interface reached %d", WLAN_IPA_MAX_IFACE); |
| 1449 | status = QDF_STATUS_E_NOMEM; |
| 1450 | QDF_ASSERT(0); |
| 1451 | goto end; |
| 1452 | } |
| 1453 | |
Sravan Kumar Kairam | 5214f65 | 2018-03-13 09:52:31 +0530 | [diff] [blame] | 1454 | for (i = 0; i < WLAN_IPA_MAX_IFACE; i++) { |
Jeff Johnson | 1d44fee5 | 2019-03-18 14:02:06 -0700 | [diff] [blame] | 1455 | if (!ipa_ctx->iface_context[i].tl_context) { |
Sravan Kumar Kairam | 5214f65 | 2018-03-13 09:52:31 +0530 | [diff] [blame] | 1456 | iface_context = &(ipa_ctx->iface_context[i]); |
| 1457 | break; |
| 1458 | } |
| 1459 | } |
| 1460 | |
Jeff Johnson | 1d44fee5 | 2019-03-18 14:02:06 -0700 | [diff] [blame] | 1461 | if (!iface_context) { |
Sravan Kumar Kairam | 5214f65 | 2018-03-13 09:52:31 +0530 | [diff] [blame] | 1462 | ipa_err("All the IPA interfaces are in use"); |
| 1463 | status = QDF_STATUS_E_NOMEM; |
Yun Park | 21ec490 | 2018-04-24 12:11:01 -0700 | [diff] [blame] | 1464 | QDF_ASSERT(0); |
Sravan Kumar Kairam | 5214f65 | 2018-03-13 09:52:31 +0530 | [diff] [blame] | 1465 | goto end; |
| 1466 | } |
| 1467 | |
Rakshith Suresh Patkar | 96703f6 | 2019-08-06 14:34:36 +0530 | [diff] [blame] | 1468 | tl_context = (void *)cdp_get_vdev_from_vdev_id(ipa_ctx->dp_soc, |
| 1469 | ipa_ctx->dp_pdev, |
| 1470 | session_id); |
Jeff Johnson | 1d44fee5 | 2019-03-18 14:02:06 -0700 | [diff] [blame] | 1471 | if (!tl_context) { |
Rakshith Suresh Patkar | 96703f6 | 2019-08-06 14:34:36 +0530 | [diff] [blame] | 1472 | ipa_err("Not able to get TL context session_id: %d", |
| 1473 | session_id); |
Sravan Kumar Kairam | 5214f65 | 2018-03-13 09:52:31 +0530 | [diff] [blame] | 1474 | status = QDF_STATUS_E_INVAL; |
| 1475 | goto end; |
| 1476 | } |
| 1477 | |
| 1478 | iface_context->tl_context = tl_context; |
| 1479 | iface_context->dev = net_dev; |
| 1480 | iface_context->device_mode = device_mode; |
| 1481 | iface_context->session_id = session_id; |
| 1482 | |
| 1483 | status = cdp_ipa_setup_iface(ipa_ctx->dp_soc, net_dev->name, |
| 1484 | net_dev->dev_addr, |
| 1485 | iface_context->prod_client, |
| 1486 | iface_context->cons_client, |
| 1487 | session_id, |
| 1488 | wlan_ipa_is_ipv6_enabled(ipa_ctx->config)); |
| 1489 | if (status != QDF_STATUS_SUCCESS) |
| 1490 | goto end; |
| 1491 | |
Sravan Kumar Kairam | 1f8f8b3 | 2018-07-06 16:05:24 +0530 | [diff] [blame] | 1492 | /* Register IPA Tx desc free callback */ |
| 1493 | qdf_nbuf_reg_free_cb(wlan_ipa_nbuf_cb); |
| 1494 | |
Sravan Kumar Kairam | 5214f65 | 2018-03-13 09:52:31 +0530 | [diff] [blame] | 1495 | ipa_ctx->num_iface++; |
| 1496 | |
| 1497 | ipa_debug("exit: num_iface=%d", ipa_ctx->num_iface); |
| 1498 | |
| 1499 | return status; |
| 1500 | |
| 1501 | end: |
| 1502 | if (iface_context) |
| 1503 | wlan_ipa_cleanup_iface(iface_context); |
| 1504 | |
| 1505 | return status; |
| 1506 | } |
| 1507 | |
Sravan Kumar Kairam | 361f410 | 2018-12-17 18:47:04 +0530 | [diff] [blame] | 1508 | #if defined(QCA_WIFI_QCA6290) || defined(QCA_WIFI_QCA6390) |
| 1509 | /** |
| 1510 | * wlan_ipa_uc_handle_first_con() - Handle first uC IPA connection |
| 1511 | * @ipa_ctx: IPA context |
| 1512 | * |
| 1513 | * Return: QDF STATUS |
| 1514 | */ |
| 1515 | static QDF_STATUS wlan_ipa_uc_handle_first_con(struct wlan_ipa_priv *ipa_ctx) |
| 1516 | { |
| 1517 | ipa_debug("enter"); |
| 1518 | |
| 1519 | if (wlan_ipa_uc_enable_pipes(ipa_ctx) != QDF_STATUS_SUCCESS) { |
| 1520 | ipa_err("IPA WDI Pipe activation failed"); |
| 1521 | return QDF_STATUS_E_BUSY; |
| 1522 | } |
| 1523 | |
| 1524 | ipa_debug("exit"); |
| 1525 | |
| 1526 | return QDF_STATUS_SUCCESS; |
| 1527 | } |
| 1528 | |
| 1529 | /** |
| 1530 | * wlan_ipa_uc_handle_last_discon() - Handle last uC IPA disconnection |
| 1531 | * @ipa_ctx: IPA context |
| 1532 | * |
| 1533 | * Return: None |
| 1534 | */ |
| 1535 | static void wlan_ipa_uc_handle_last_discon(struct wlan_ipa_priv *ipa_ctx) |
| 1536 | { |
| 1537 | ipa_debug("enter"); |
| 1538 | |
| 1539 | wlan_ipa_uc_disable_pipes(ipa_ctx); |
| 1540 | |
| 1541 | ipa_debug("exit: IPA WDI Pipes deactivated"); |
| 1542 | } |
Sravan Kumar Kairam | 7887022 | 2018-12-31 12:47:17 +0530 | [diff] [blame] | 1543 | |
| 1544 | bool wlan_ipa_is_fw_wdi_activated(struct wlan_ipa_priv *ipa_ctx) |
| 1545 | { |
| 1546 | return !ipa_ctx->ipa_pipes_down; |
| 1547 | } |
Sravan Kumar Kairam | 361f410 | 2018-12-17 18:47:04 +0530 | [diff] [blame] | 1548 | #else |
| 1549 | |
Sravan Kumar Kairam | 5214f65 | 2018-03-13 09:52:31 +0530 | [diff] [blame] | 1550 | /** |
| 1551 | * wlan_ipa_uc_handle_first_con() - Handle first uC IPA connection |
| 1552 | * @ipa_ctx: IPA context |
| 1553 | * |
| 1554 | * Return: QDF STATUS |
| 1555 | */ |
| 1556 | static QDF_STATUS wlan_ipa_uc_handle_first_con(struct wlan_ipa_priv *ipa_ctx) |
| 1557 | { |
| 1558 | ipa_debug("enter"); |
| 1559 | |
| 1560 | ipa_ctx->activated_fw_pipe = 0; |
| 1561 | ipa_ctx->resource_loading = true; |
| 1562 | |
| 1563 | /* If RM feature enabled |
| 1564 | * Request PROD Resource first |
| 1565 | * PROD resource may return sync or async manners |
| 1566 | */ |
| 1567 | if (wlan_ipa_is_rm_enabled(ipa_ctx->config)) { |
Yun Park | e114fbf | 2018-04-05 20:02:12 -0700 | [diff] [blame] | 1568 | if (!wlan_ipa_wdi_rm_request_resource(ipa_ctx, |
| 1569 | IPA_RM_RESOURCE_WLAN_PROD)) { |
Sravan Kumar Kairam | 5214f65 | 2018-03-13 09:52:31 +0530 | [diff] [blame] | 1570 | /* RM PROD request sync return |
| 1571 | * enable pipe immediately |
| 1572 | */ |
| 1573 | if (wlan_ipa_uc_enable_pipes(ipa_ctx)) { |
| 1574 | ipa_err("IPA WDI Pipe activation failed"); |
| 1575 | ipa_ctx->resource_loading = false; |
| 1576 | return QDF_STATUS_E_BUSY; |
| 1577 | } |
| 1578 | } else { |
| 1579 | ipa_err("IPA WDI Pipe activation deferred"); |
| 1580 | } |
| 1581 | } else { |
| 1582 | /* RM Disabled |
| 1583 | * Just enabled all the PIPEs |
| 1584 | */ |
| 1585 | if (wlan_ipa_uc_enable_pipes(ipa_ctx)) { |
| 1586 | ipa_err("IPA WDI Pipe activation failed"); |
| 1587 | ipa_ctx->resource_loading = false; |
| 1588 | return QDF_STATUS_E_BUSY; |
| 1589 | } |
| 1590 | ipa_ctx->resource_loading = false; |
| 1591 | } |
| 1592 | |
| 1593 | ipa_debug("exit"); |
| 1594 | |
| 1595 | return QDF_STATUS_SUCCESS; |
| 1596 | } |
| 1597 | |
| 1598 | /** |
| 1599 | * wlan_ipa_uc_handle_last_discon() - Handle last uC IPA disconnection |
| 1600 | * @ipa_ctx: IPA context |
| 1601 | * |
| 1602 | * Return: None |
| 1603 | */ |
| 1604 | static void wlan_ipa_uc_handle_last_discon(struct wlan_ipa_priv *ipa_ctx) |
| 1605 | { |
| 1606 | ipa_debug("enter"); |
| 1607 | |
| 1608 | ipa_ctx->resource_unloading = true; |
| 1609 | qdf_event_reset(&ipa_ctx->ipa_resource_comp); |
| 1610 | ipa_info("Disable FW RX PIPE"); |
| 1611 | cdp_ipa_set_active(ipa_ctx->dp_soc, ipa_ctx->dp_pdev, false, false); |
Sravan Kumar Kairam | 5214f65 | 2018-03-13 09:52:31 +0530 | [diff] [blame] | 1612 | |
| 1613 | ipa_debug("exit: IPA WDI Pipes deactivated"); |
| 1614 | } |
Sravan Kumar Kairam | 7887022 | 2018-12-31 12:47:17 +0530 | [diff] [blame] | 1615 | |
| 1616 | bool wlan_ipa_is_fw_wdi_activated(struct wlan_ipa_priv *ipa_ctx) |
| 1617 | { |
| 1618 | return (WLAN_IPA_UC_NUM_WDI_PIPE == ipa_ctx->activated_fw_pipe); |
| 1619 | } |
Sravan Kumar Kairam | 361f410 | 2018-12-17 18:47:04 +0530 | [diff] [blame] | 1620 | #endif |
Sravan Kumar Kairam | 5214f65 | 2018-03-13 09:52:31 +0530 | [diff] [blame] | 1621 | |
Vevek Venkatesan | ed315cd | 2019-06-10 23:35:19 +0530 | [diff] [blame] | 1622 | static inline |
| 1623 | bool wlan_sap_no_client_connected(struct wlan_ipa_priv *ipa_ctx) |
| 1624 | { |
| 1625 | return !(ipa_ctx->sap_num_connected_sta); |
| 1626 | } |
| 1627 | |
| 1628 | static inline |
| 1629 | bool wlan_sta_is_connected(struct wlan_ipa_priv *ipa_ctx) |
| 1630 | { |
| 1631 | return ipa_ctx->sta_connected; |
| 1632 | } |
| 1633 | |
| 1634 | static inline |
| 1635 | bool wlan_ipa_uc_is_loaded(struct wlan_ipa_priv *ipa_ctx) |
| 1636 | { |
| 1637 | return ipa_ctx->uc_loaded; |
| 1638 | } |
| 1639 | |
Sravan Kumar Kairam | 5214f65 | 2018-03-13 09:52:31 +0530 | [diff] [blame] | 1640 | /** |
| 1641 | * wlan_ipa_uc_offload_enable_disable() - wdi enable/disable notify to fw |
| 1642 | * @ipa_ctx: global IPA context |
| 1643 | * @offload_type: MCC or SCC |
| 1644 | * @session_id: Session Id |
| 1645 | * @enable: TX offload enable or disable |
| 1646 | * |
| 1647 | * Return: none |
| 1648 | */ |
| 1649 | static void wlan_ipa_uc_offload_enable_disable(struct wlan_ipa_priv *ipa_ctx, |
| 1650 | uint32_t offload_type, |
| 1651 | uint8_t session_id, |
| 1652 | bool enable) |
| 1653 | { |
| 1654 | |
| 1655 | struct ipa_uc_offload_control_params req = {0}; |
| 1656 | |
| 1657 | if (session_id >= WLAN_IPA_MAX_SESSION) { |
| 1658 | ipa_err("invalid session id: %d", session_id); |
| 1659 | return; |
| 1660 | } |
| 1661 | |
| 1662 | if (enable == ipa_ctx->vdev_offload_enabled[session_id]) { |
Sravan Kumar Kairam | cd430b6 | 2018-08-23 18:35:50 +0530 | [diff] [blame] | 1663 | ipa_info("IPA offload status is already set"); |
| 1664 | ipa_info("offload_type=%d, vdev_id=%d, enable=%d", |
Sravan Kumar Kairam | 5214f65 | 2018-03-13 09:52:31 +0530 | [diff] [blame] | 1665 | offload_type, session_id, enable); |
| 1666 | return; |
| 1667 | } |
| 1668 | |
| 1669 | ipa_info("offload_type=%d, session_id=%d, enable=%d", |
| 1670 | offload_type, session_id, enable); |
| 1671 | |
| 1672 | req.offload_type = offload_type; |
| 1673 | req.vdev_id = session_id; |
| 1674 | req.enable = enable; |
| 1675 | |
| 1676 | if (QDF_STATUS_SUCCESS != |
| 1677 | ipa_send_uc_offload_enable_disable(ipa_ctx->pdev, &req)) { |
| 1678 | ipa_err("Fail to enable IPA offload"); |
| 1679 | ipa_err("offload type=%d, vdev_id=%d, enable=%d", |
| 1680 | offload_type, session_id, enable); |
| 1681 | } else { |
| 1682 | ipa_ctx->vdev_offload_enabled[session_id] = enable; |
| 1683 | } |
| 1684 | } |
| 1685 | |
| 1686 | /** |
| 1687 | * __wlan_ipa_wlan_evt() - IPA event handler |
| 1688 | * @net_dev: Interface net device |
| 1689 | * @device_mode: Net interface device mode |
Sravan Kumar Kairam | 5214f65 | 2018-03-13 09:52:31 +0530 | [diff] [blame] | 1690 | * @session_id: session id for the event |
| 1691 | * @type: event enum of type ipa_wlan_event |
| 1692 | * @mac_address: MAC address associated with the event |
| 1693 | * |
| 1694 | * This function is meant to be called from within wlan_ipa_ctx.c |
| 1695 | * |
| 1696 | * Return: QDF STATUS |
| 1697 | */ |
| 1698 | static QDF_STATUS __wlan_ipa_wlan_evt(qdf_netdev_t net_dev, uint8_t device_mode, |
Rakshith Suresh Patkar | 96703f6 | 2019-08-06 14:34:36 +0530 | [diff] [blame] | 1699 | uint8_t session_id, |
Sravan Kumar Kairam | 5214f65 | 2018-03-13 09:52:31 +0530 | [diff] [blame] | 1700 | qdf_ipa_wlan_event type, |
| 1701 | uint8_t *mac_addr) |
| 1702 | { |
| 1703 | struct wlan_ipa_priv *ipa_ctx = gp_ipa; |
| 1704 | struct wlan_ipa_iface_context *iface_ctx = NULL; |
| 1705 | qdf_ipa_msg_meta_t meta; |
| 1706 | qdf_ipa_wlan_msg_t *msg; |
| 1707 | qdf_ipa_wlan_msg_ex_t *msg_ex = NULL; |
| 1708 | int i; |
| 1709 | QDF_STATUS status; |
Ryan Hsu | b5783cf | 2018-05-14 12:13:15 -0700 | [diff] [blame] | 1710 | uint8_t sta_session_id = WLAN_IPA_MAX_SESSION; |
Rakshith Suresh Patkar | 107a659 | 2019-02-08 16:17:27 +0530 | [diff] [blame] | 1711 | struct wlan_objmgr_pdev *pdev; |
| 1712 | struct wlan_objmgr_psoc *psoc; |
| 1713 | struct wlan_objmgr_vdev *vdev; |
Sravan Kumar Kairam | 5214f65 | 2018-03-13 09:52:31 +0530 | [diff] [blame] | 1714 | |
Rakshith Suresh Patkar | 96703f6 | 2019-08-06 14:34:36 +0530 | [diff] [blame] | 1715 | ipa_debug("%s: EVT: %d, MAC: %pM, session_id: %u", |
| 1716 | net_dev->name, type, mac_addr, session_id); |
Sravan Kumar Kairam | 5214f65 | 2018-03-13 09:52:31 +0530 | [diff] [blame] | 1717 | |
| 1718 | if (type >= QDF_IPA_WLAN_EVENT_MAX) |
| 1719 | return QDF_STATUS_E_INVAL; |
| 1720 | |
| 1721 | if (wlan_ipa_uc_is_enabled(ipa_ctx->config) && |
| 1722 | !wlan_ipa_uc_sta_is_enabled(ipa_ctx->config) && |
| 1723 | (device_mode != QDF_SAP_MODE)) { |
| 1724 | return QDF_STATUS_SUCCESS; |
| 1725 | } |
| 1726 | |
Rakshith Suresh Patkar | 107a659 | 2019-02-08 16:17:27 +0530 | [diff] [blame] | 1727 | pdev = ipa_ctx->pdev; |
| 1728 | psoc = wlan_pdev_get_psoc(pdev); |
| 1729 | vdev = wlan_objmgr_get_vdev_by_id_from_psoc(psoc, session_id, |
| 1730 | WLAN_IPA_ID); |
Rakshith Suresh Patkar | 8009443 | 2019-04-15 18:15:07 +0530 | [diff] [blame] | 1731 | QDF_BUG(session_id < WLAN_IPA_MAX_SESSION); |
| 1732 | |
Rakshith Suresh Patkar | 107a659 | 2019-02-08 16:17:27 +0530 | [diff] [blame] | 1733 | if (vdev) |
| 1734 | wlan_objmgr_vdev_release_ref(vdev, WLAN_IPA_ID); |
Rakshith Suresh Patkar | 8009443 | 2019-04-15 18:15:07 +0530 | [diff] [blame] | 1735 | else |
| 1736 | ipa_err("vdev is NULL, session_id: %u", session_id); |
Rakshith Suresh Patkar | 107a659 | 2019-02-08 16:17:27 +0530 | [diff] [blame] | 1737 | |
Ryan Hsu | b5783cf | 2018-05-14 12:13:15 -0700 | [diff] [blame] | 1738 | if (ipa_ctx->sta_connected) { |
| 1739 | iface_ctx = wlan_ipa_get_iface(ipa_ctx, QDF_STA_MODE); |
| 1740 | if (iface_ctx) |
| 1741 | sta_session_id = iface_ctx->session_id; |
| 1742 | else |
| 1743 | ipa_err("sta iface_ctx is NULL"); |
| 1744 | } |
| 1745 | |
Sravan Kumar Kairam | 5214f65 | 2018-03-13 09:52:31 +0530 | [diff] [blame] | 1746 | /* |
| 1747 | * During IPA UC resource loading/unloading new events can be issued. |
| 1748 | */ |
| 1749 | if (wlan_ipa_uc_is_enabled(ipa_ctx->config) && |
| 1750 | (ipa_ctx->resource_loading || ipa_ctx->resource_unloading)) { |
| 1751 | unsigned int pending_event_count; |
| 1752 | struct wlan_ipa_uc_pending_event *pending_event = NULL; |
| 1753 | |
| 1754 | ipa_info("Event:%d IPA resource %s inprogress", type, |
| 1755 | ipa_ctx->resource_loading ? |
| 1756 | "load" : "unload"); |
| 1757 | |
| 1758 | /* Wait until completion of the long/unloading */ |
| 1759 | status = qdf_wait_for_event_completion( |
| 1760 | &ipa_ctx->ipa_resource_comp, |
jiad | a8c542c | 2018-05-29 16:24:13 +0800 | [diff] [blame] | 1761 | IPA_RESOURCE_COMP_WAIT_TIME); |
Sravan Kumar Kairam | 5214f65 | 2018-03-13 09:52:31 +0530 | [diff] [blame] | 1762 | if (status != QDF_STATUS_SUCCESS) { |
| 1763 | /* |
| 1764 | * If timed out, store the events separately and |
| 1765 | * handle them later. |
| 1766 | */ |
| 1767 | ipa_info("IPA resource %s timed out", |
| 1768 | ipa_ctx->resource_loading ? |
| 1769 | "load" : "unload"); |
| 1770 | |
Vevek Venkatesan | ed315cd | 2019-06-10 23:35:19 +0530 | [diff] [blame] | 1771 | if (type == QDF_IPA_AP_DISCONNECT) { |
Sravan Kumar Kairam | cd430b6 | 2018-08-23 18:35:50 +0530 | [diff] [blame] | 1772 | wlan_ipa_uc_offload_enable_disable(ipa_ctx, |
| 1773 | SIR_AP_RX_DATA_OFFLOAD, |
| 1774 | session_id, false); |
Vevek Venkatesan | ed315cd | 2019-06-10 23:35:19 +0530 | [diff] [blame] | 1775 | } else if (type == QDF_IPA_CLIENT_CONNECT_EX && |
| 1776 | wlan_sap_no_client_connected(ipa_ctx)) { |
| 1777 | if (wlan_sta_is_connected(ipa_ctx) && |
| 1778 | wlan_ipa_uc_is_loaded(ipa_ctx) && |
| 1779 | wlan_ipa_uc_sta_is_enabled(ipa_ctx-> |
| 1780 | config) && |
| 1781 | !wlan_ipa_is_sta_only_offload_enabled()) { |
| 1782 | wlan_ipa_uc_offload_enable_disable( |
| 1783 | ipa_ctx, |
| 1784 | SIR_STA_RX_DATA_OFFLOAD, |
| 1785 | sta_session_id, true); |
| 1786 | } |
| 1787 | } |
Sravan Kumar Kairam | cd430b6 | 2018-08-23 18:35:50 +0530 | [diff] [blame] | 1788 | |
Sravan Kumar Kairam | 5214f65 | 2018-03-13 09:52:31 +0530 | [diff] [blame] | 1789 | qdf_mutex_acquire(&ipa_ctx->ipa_lock); |
| 1790 | |
| 1791 | pending_event_count = |
| 1792 | qdf_list_size(&ipa_ctx->pending_event); |
| 1793 | if (pending_event_count >= |
| 1794 | WLAN_IPA_MAX_PENDING_EVENT_COUNT) { |
| 1795 | ipa_info("Reached max pending evt count"); |
| 1796 | qdf_list_remove_front( |
| 1797 | &ipa_ctx->pending_event, |
| 1798 | (qdf_list_node_t **)&pending_event); |
| 1799 | } else { |
| 1800 | pending_event = |
| 1801 | (struct wlan_ipa_uc_pending_event *) |
| 1802 | qdf_mem_malloc(sizeof( |
| 1803 | struct wlan_ipa_uc_pending_event)); |
| 1804 | } |
| 1805 | |
| 1806 | if (!pending_event) { |
| 1807 | ipa_err("Pending event memory alloc fail"); |
| 1808 | qdf_mutex_release(&ipa_ctx->ipa_lock); |
| 1809 | return QDF_STATUS_E_NOMEM; |
| 1810 | } |
| 1811 | |
| 1812 | pending_event->net_dev = net_dev; |
| 1813 | pending_event->device_mode = device_mode; |
Sravan Kumar Kairam | 5214f65 | 2018-03-13 09:52:31 +0530 | [diff] [blame] | 1814 | pending_event->session_id = session_id; |
| 1815 | pending_event->type = type; |
| 1816 | pending_event->is_loading = ipa_ctx->resource_loading; |
| 1817 | qdf_mem_copy(pending_event->mac_addr, |
| 1818 | mac_addr, QDF_MAC_ADDR_SIZE); |
| 1819 | qdf_list_insert_back(&ipa_ctx->pending_event, |
| 1820 | &pending_event->node); |
| 1821 | |
| 1822 | qdf_mutex_release(&ipa_ctx->ipa_lock); |
| 1823 | |
Yun Park | 21ec490 | 2018-04-24 12:11:01 -0700 | [diff] [blame] | 1824 | /* Cleanup interface */ |
| 1825 | if (type == QDF_IPA_STA_DISCONNECT || |
| 1826 | type == QDF_IPA_AP_DISCONNECT) { |
| 1827 | for (i = 0; i < WLAN_IPA_MAX_IFACE; i++) { |
| 1828 | iface_ctx = &ipa_ctx->iface_context[i]; |
| 1829 | |
| 1830 | if (iface_ctx->dev == net_dev) |
| 1831 | break; |
| 1832 | } |
| 1833 | if (iface_ctx) |
| 1834 | wlan_ipa_cleanup_iface(iface_ctx); |
| 1835 | } |
| 1836 | |
Sravan Kumar Kairam | 5214f65 | 2018-03-13 09:52:31 +0530 | [diff] [blame] | 1837 | return QDF_STATUS_SUCCESS; |
| 1838 | } |
| 1839 | ipa_info("IPA resource %s completed", |
| 1840 | ipa_ctx->resource_loading ? |
| 1841 | "load" : "unload"); |
| 1842 | } |
| 1843 | |
| 1844 | ipa_ctx->stats.event[type]++; |
| 1845 | |
| 1846 | QDF_IPA_SET_META_MSG_TYPE(&meta, type); |
| 1847 | switch (type) { |
| 1848 | case QDF_IPA_STA_CONNECT: |
| 1849 | qdf_mutex_acquire(&ipa_ctx->event_lock); |
| 1850 | |
| 1851 | /* STA already connected and without disconnect, connect again |
| 1852 | * This is Roaming scenario |
| 1853 | */ |
| 1854 | if (ipa_ctx->sta_connected) { |
| 1855 | iface_ctx = wlan_ipa_get_iface(ipa_ctx, QDF_STA_MODE); |
| 1856 | if (iface_ctx) |
| 1857 | wlan_ipa_cleanup_iface(iface_ctx); |
| 1858 | } |
| 1859 | |
| 1860 | status = wlan_ipa_setup_iface(ipa_ctx, net_dev, device_mode, |
Rakshith Suresh Patkar | 96703f6 | 2019-08-06 14:34:36 +0530 | [diff] [blame] | 1861 | session_id); |
Sravan Kumar Kairam | 5214f65 | 2018-03-13 09:52:31 +0530 | [diff] [blame] | 1862 | if (status != QDF_STATUS_SUCCESS) { |
Mohit Khanna | cabf5e7 | 2018-07-24 13:28:43 -0700 | [diff] [blame] | 1863 | ipa_err("wlan_ipa_setup_iface failed %u", status); |
Sravan Kumar Kairam | 5214f65 | 2018-03-13 09:52:31 +0530 | [diff] [blame] | 1864 | qdf_mutex_release(&ipa_ctx->event_lock); |
| 1865 | goto end; |
| 1866 | } |
| 1867 | |
| 1868 | if (wlan_ipa_uc_sta_is_enabled(ipa_ctx->config) && |
jiad | 72b69a9 | 2019-04-11 17:23:10 +0800 | [diff] [blame] | 1869 | (ipa_ctx->sap_num_connected_sta > 0 || |
| 1870 | wlan_ipa_is_sta_only_offload_enabled()) && |
Sravan Kumar Kairam | 5214f65 | 2018-03-13 09:52:31 +0530 | [diff] [blame] | 1871 | !ipa_ctx->sta_connected) { |
| 1872 | qdf_mutex_release(&ipa_ctx->event_lock); |
| 1873 | wlan_ipa_uc_offload_enable_disable(ipa_ctx, |
| 1874 | SIR_STA_RX_DATA_OFFLOAD, session_id, |
| 1875 | true); |
| 1876 | qdf_mutex_acquire(&ipa_ctx->event_lock); |
| 1877 | } |
| 1878 | |
jiad | 72b69a9 | 2019-04-11 17:23:10 +0800 | [diff] [blame] | 1879 | if (!wlan_ipa_is_sta_only_offload_enabled()) { |
| 1880 | ipa_debug("IPA STA only offload not enabled"); |
| 1881 | } else if (ipa_ctx->uc_loaded && |
| 1882 | !ipa_ctx->sap_num_connected_sta && |
| 1883 | !ipa_ctx->sta_connected) { |
| 1884 | status = wlan_ipa_uc_handle_first_con(ipa_ctx); |
| 1885 | if (status) { |
| 1886 | qdf_mutex_release(&ipa_ctx->event_lock); |
| 1887 | ipa_info("handle 1st conn failed %d", status); |
| 1888 | wlan_ipa_uc_offload_enable_disable( |
| 1889 | ipa_ctx, |
| 1890 | SIR_STA_RX_DATA_OFFLOAD, |
| 1891 | session_id, |
| 1892 | false); |
| 1893 | goto end; |
| 1894 | } |
| 1895 | } |
| 1896 | |
Sravan Kumar Kairam | 5214f65 | 2018-03-13 09:52:31 +0530 | [diff] [blame] | 1897 | ipa_ctx->vdev_to_iface[session_id] = |
| 1898 | wlan_ipa_get_ifaceid(ipa_ctx, session_id); |
| 1899 | |
| 1900 | ipa_ctx->sta_connected = 1; |
| 1901 | |
| 1902 | qdf_mutex_release(&ipa_ctx->event_lock); |
| 1903 | |
Mohit Khanna | cabf5e7 | 2018-07-24 13:28:43 -0700 | [diff] [blame] | 1904 | ipa_debug("sta_connected=%d vdev_to_iface[%u] %u", |
| 1905 | ipa_ctx->sta_connected, |
| 1906 | session_id, |
| 1907 | ipa_ctx->vdev_to_iface[session_id]); |
Sravan Kumar Kairam | 5214f65 | 2018-03-13 09:52:31 +0530 | [diff] [blame] | 1908 | break; |
| 1909 | |
| 1910 | case QDF_IPA_AP_CONNECT: |
| 1911 | qdf_mutex_acquire(&ipa_ctx->event_lock); |
| 1912 | |
| 1913 | /* For DFS channel we get two start_bss event (before and after |
| 1914 | * CAC). Also when ACS range includes both DFS and non DFS |
| 1915 | * channels, we could possibly change channel many times due to |
| 1916 | * RADAR detection and chosen channel may not be a DFS channels. |
| 1917 | * So dont return error here. Just discard the event. |
| 1918 | */ |
jiad | c908ada | 2018-05-11 14:40:54 +0800 | [diff] [blame] | 1919 | if (ipa_ctx->vdev_to_iface[session_id] != |
| 1920 | WLAN_IPA_MAX_SESSION) { |
Sravan Kumar Kairam | 5214f65 | 2018-03-13 09:52:31 +0530 | [diff] [blame] | 1921 | qdf_mutex_release(&ipa_ctx->event_lock); |
| 1922 | return 0; |
| 1923 | } |
| 1924 | |
| 1925 | status = wlan_ipa_setup_iface(ipa_ctx, net_dev, device_mode, |
Rakshith Suresh Patkar | 96703f6 | 2019-08-06 14:34:36 +0530 | [diff] [blame] | 1926 | session_id); |
Sravan Kumar Kairam | 5214f65 | 2018-03-13 09:52:31 +0530 | [diff] [blame] | 1927 | if (status != QDF_STATUS_SUCCESS) { |
| 1928 | qdf_mutex_release(&ipa_ctx->event_lock); |
| 1929 | ipa_err("%s: Evt: %d, Interface setup failed", |
| 1930 | msg_ex->name, QDF_IPA_MSG_META_MSG_TYPE(&meta)); |
| 1931 | goto end; |
| 1932 | } |
| 1933 | |
| 1934 | if (wlan_ipa_uc_is_enabled(ipa_ctx->config)) { |
| 1935 | qdf_mutex_release(&ipa_ctx->event_lock); |
| 1936 | wlan_ipa_uc_offload_enable_disable(ipa_ctx, |
| 1937 | SIR_AP_RX_DATA_OFFLOAD, session_id, true); |
| 1938 | qdf_mutex_acquire(&ipa_ctx->event_lock); |
| 1939 | } |
| 1940 | |
| 1941 | ipa_ctx->vdev_to_iface[session_id] = |
| 1942 | wlan_ipa_get_ifaceid(ipa_ctx, session_id); |
Mohit Khanna | cabf5e7 | 2018-07-24 13:28:43 -0700 | [diff] [blame] | 1943 | ipa_debug("vdev_to_iface[%u]=%u", |
| 1944 | session_id, |
| 1945 | ipa_ctx->vdev_to_iface[session_id]); |
Sravan Kumar Kairam | 5214f65 | 2018-03-13 09:52:31 +0530 | [diff] [blame] | 1946 | qdf_mutex_release(&ipa_ctx->event_lock); |
| 1947 | break; |
| 1948 | |
| 1949 | case QDF_IPA_STA_DISCONNECT: |
| 1950 | qdf_mutex_acquire(&ipa_ctx->event_lock); |
| 1951 | |
| 1952 | if (!ipa_ctx->sta_connected) { |
Sravan Kumar Kairam | 4757819 | 2019-01-14 17:13:09 +0530 | [diff] [blame] | 1953 | struct wlan_ipa_iface_context *iface; |
| 1954 | |
Sravan Kumar Kairam | 5214f65 | 2018-03-13 09:52:31 +0530 | [diff] [blame] | 1955 | qdf_mutex_release(&ipa_ctx->event_lock); |
| 1956 | ipa_err("%s: Evt: %d, STA already disconnected", |
| 1957 | msg_ex->name, QDF_IPA_MSG_META_MSG_TYPE(&meta)); |
Sravan Kumar Kairam | 4757819 | 2019-01-14 17:13:09 +0530 | [diff] [blame] | 1958 | |
| 1959 | iface = wlan_ipa_get_iface(ipa_ctx, QDF_STA_MODE); |
| 1960 | if (iface && (iface->dev == net_dev)) |
| 1961 | wlan_ipa_cleanup_iface(iface); |
| 1962 | |
Sravan Kumar Kairam | 5214f65 | 2018-03-13 09:52:31 +0530 | [diff] [blame] | 1963 | return QDF_STATUS_E_INVAL; |
| 1964 | } |
| 1965 | |
| 1966 | ipa_ctx->sta_connected = 0; |
| 1967 | |
| 1968 | if (!wlan_ipa_uc_is_enabled(ipa_ctx->config)) { |
| 1969 | ipa_debug("%s: IPA UC OFFLOAD NOT ENABLED", |
| 1970 | msg_ex->name); |
| 1971 | } else { |
jiad | 72b69a9 | 2019-04-11 17:23:10 +0800 | [diff] [blame] | 1972 | /* |
| 1973 | * Disable IPA pipes when |
| 1974 | * 1. STA is the last interface or |
| 1975 | * 2. STA only offload enabled and no clients connected |
| 1976 | * to SAP |
| 1977 | */ |
| 1978 | if ((ipa_ctx->num_iface == 1 || |
| 1979 | (wlan_ipa_is_sta_only_offload_enabled() && |
| 1980 | !ipa_ctx->sap_num_connected_sta)) && |
Yun Park | a29974a | 2018-04-09 12:05:49 -0700 | [diff] [blame] | 1981 | wlan_ipa_is_fw_wdi_activated(ipa_ctx) && |
jiad | fa131fe | 2018-08-06 13:41:36 +0800 | [diff] [blame] | 1982 | !ipa_ctx->ipa_pipes_down && |
| 1983 | (ipa_ctx->resource_unloading == false)) { |
jiad | 3a321f3 | 2018-07-16 18:16:39 +0800 | [diff] [blame] | 1984 | if (cds_is_driver_unloading()) { |
| 1985 | /* |
| 1986 | * We disable WDI pipes directly here |
| 1987 | * since IPA_OPCODE_TX/RX_SUSPEND |
| 1988 | * message will not be processed when |
| 1989 | * unloading WLAN driver is in progress |
| 1990 | */ |
| 1991 | wlan_ipa_uc_disable_pipes(ipa_ctx); |
| 1992 | } else { |
| 1993 | wlan_ipa_uc_handle_last_discon(ipa_ctx); |
| 1994 | } |
| 1995 | } |
Sravan Kumar Kairam | 5214f65 | 2018-03-13 09:52:31 +0530 | [diff] [blame] | 1996 | } |
| 1997 | |
| 1998 | if (wlan_ipa_uc_sta_is_enabled(ipa_ctx->config) && |
jiad | 72b69a9 | 2019-04-11 17:23:10 +0800 | [diff] [blame] | 1999 | (ipa_ctx->sap_num_connected_sta > 0 || |
| 2000 | wlan_ipa_is_sta_only_offload_enabled())) { |
Sravan Kumar Kairam | 5214f65 | 2018-03-13 09:52:31 +0530 | [diff] [blame] | 2001 | qdf_mutex_release(&ipa_ctx->event_lock); |
| 2002 | wlan_ipa_uc_offload_enable_disable(ipa_ctx, |
| 2003 | SIR_STA_RX_DATA_OFFLOAD, session_id, false); |
| 2004 | qdf_mutex_acquire(&ipa_ctx->event_lock); |
| 2005 | ipa_ctx->vdev_to_iface[session_id] = |
| 2006 | WLAN_IPA_MAX_SESSION; |
Mohit Khanna | cabf5e7 | 2018-07-24 13:28:43 -0700 | [diff] [blame] | 2007 | ipa_debug("vdev_to_iface[%u]=%u", |
| 2008 | session_id, |
| 2009 | ipa_ctx->vdev_to_iface[session_id]); |
Sravan Kumar Kairam | 5214f65 | 2018-03-13 09:52:31 +0530 | [diff] [blame] | 2010 | } |
| 2011 | |
| 2012 | for (i = 0; i < WLAN_IPA_MAX_IFACE; i++) { |
| 2013 | iface_ctx = &ipa_ctx->iface_context[i]; |
| 2014 | |
| 2015 | if (iface_ctx->dev == net_dev) |
| 2016 | break; |
| 2017 | } |
| 2018 | if (i < WLAN_IPA_MAX_IFACE) |
| 2019 | wlan_ipa_cleanup_iface(iface_ctx); |
| 2020 | |
| 2021 | qdf_mutex_release(&ipa_ctx->event_lock); |
| 2022 | |
| 2023 | ipa_debug("sta_connected=%d", ipa_ctx->sta_connected); |
| 2024 | break; |
| 2025 | |
| 2026 | case QDF_IPA_AP_DISCONNECT: |
| 2027 | qdf_mutex_acquire(&ipa_ctx->event_lock); |
| 2028 | |
| 2029 | if ((ipa_ctx->num_iface == 1) && |
Yun Park | a29974a | 2018-04-09 12:05:49 -0700 | [diff] [blame] | 2030 | wlan_ipa_is_fw_wdi_activated(ipa_ctx) && |
jiad | fa131fe | 2018-08-06 13:41:36 +0800 | [diff] [blame] | 2031 | !ipa_ctx->ipa_pipes_down && |
| 2032 | (ipa_ctx->resource_unloading == false)) { |
Sravan Kumar Kairam | 5214f65 | 2018-03-13 09:52:31 +0530 | [diff] [blame] | 2033 | if (cds_is_driver_unloading()) { |
| 2034 | /* |
| 2035 | * We disable WDI pipes directly here since |
| 2036 | * IPA_OPCODE_TX/RX_SUSPEND message will not be |
| 2037 | * processed when unloading WLAN driver is in |
| 2038 | * progress |
| 2039 | */ |
| 2040 | wlan_ipa_uc_disable_pipes(ipa_ctx); |
| 2041 | } else { |
| 2042 | /* |
| 2043 | * This shouldn't happen : |
| 2044 | * No interface left but WDI pipes are still |
| 2045 | * active - force close WDI pipes |
| 2046 | */ |
| 2047 | ipa_err("No interface left but WDI pipes are still active"); |
| 2048 | wlan_ipa_uc_handle_last_discon(ipa_ctx); |
| 2049 | } |
| 2050 | } |
| 2051 | |
| 2052 | if (wlan_ipa_uc_is_enabled(ipa_ctx->config)) { |
| 2053 | qdf_mutex_release(&ipa_ctx->event_lock); |
| 2054 | wlan_ipa_uc_offload_enable_disable(ipa_ctx, |
| 2055 | SIR_AP_RX_DATA_OFFLOAD, session_id, false); |
| 2056 | qdf_mutex_acquire(&ipa_ctx->event_lock); |
| 2057 | ipa_ctx->vdev_to_iface[session_id] = |
| 2058 | WLAN_IPA_MAX_SESSION; |
Mohit Khanna | cabf5e7 | 2018-07-24 13:28:43 -0700 | [diff] [blame] | 2059 | ipa_debug("vdev_to_iface[%u]=%u", |
| 2060 | session_id, |
| 2061 | ipa_ctx->vdev_to_iface[session_id]); |
Sravan Kumar Kairam | 5214f65 | 2018-03-13 09:52:31 +0530 | [diff] [blame] | 2062 | } |
| 2063 | |
| 2064 | for (i = 0; i < WLAN_IPA_MAX_IFACE; i++) { |
| 2065 | iface_ctx = &ipa_ctx->iface_context[i]; |
| 2066 | |
| 2067 | if (iface_ctx->dev == net_dev) |
| 2068 | break; |
| 2069 | } |
| 2070 | if (i < WLAN_IPA_MAX_IFACE) |
| 2071 | wlan_ipa_cleanup_iface(iface_ctx); |
| 2072 | |
| 2073 | qdf_mutex_release(&ipa_ctx->event_lock); |
| 2074 | break; |
| 2075 | |
| 2076 | case QDF_IPA_CLIENT_CONNECT_EX: |
| 2077 | if (!wlan_ipa_uc_is_enabled(ipa_ctx->config)) { |
| 2078 | ipa_debug("%s: Evt: %d, IPA UC OFFLOAD NOT ENABLED", |
| 2079 | net_dev->name, type); |
| 2080 | return QDF_STATUS_SUCCESS; |
| 2081 | } |
| 2082 | |
| 2083 | qdf_mutex_acquire(&ipa_ctx->event_lock); |
Rakshith Suresh Patkar | 96703f6 | 2019-08-06 14:34:36 +0530 | [diff] [blame] | 2084 | if (wlan_ipa_uc_find_add_assoc_sta(ipa_ctx, true, |
Sravan Kumar Kairam | 5214f65 | 2018-03-13 09:52:31 +0530 | [diff] [blame] | 2085 | mac_addr)) { |
| 2086 | qdf_mutex_release(&ipa_ctx->event_lock); |
Rakshith Suresh Patkar | 96703f6 | 2019-08-06 14:34:36 +0530 | [diff] [blame] | 2087 | ipa_err("%s: STA found, addr: " QDF_MAC_ADDR_STR, |
| 2088 | net_dev->name, |
| 2089 | QDF_MAC_ADDR_ARRAY(mac_addr)); |
Sravan Kumar Kairam | 5214f65 | 2018-03-13 09:52:31 +0530 | [diff] [blame] | 2090 | return QDF_STATUS_SUCCESS; |
| 2091 | } |
| 2092 | |
| 2093 | /* Enable IPA UC Data PIPEs when first STA connected */ |
| 2094 | if (ipa_ctx->sap_num_connected_sta == 0 && |
| 2095 | ipa_ctx->uc_loaded == true) { |
Sravan Kumar Kairam | f59aec1 | 2018-03-23 19:35:01 +0530 | [diff] [blame] | 2096 | |
Sravan Kumar Kairam | 5214f65 | 2018-03-13 09:52:31 +0530 | [diff] [blame] | 2097 | if (wlan_ipa_uc_sta_is_enabled(ipa_ctx->config) && |
jiad | 72b69a9 | 2019-04-11 17:23:10 +0800 | [diff] [blame] | 2098 | ipa_ctx->sta_connected && |
| 2099 | !wlan_ipa_is_sta_only_offload_enabled()) { |
Sravan Kumar Kairam | 5214f65 | 2018-03-13 09:52:31 +0530 | [diff] [blame] | 2100 | qdf_mutex_release(&ipa_ctx->event_lock); |
| 2101 | wlan_ipa_uc_offload_enable_disable(ipa_ctx, |
| 2102 | SIR_STA_RX_DATA_OFFLOAD, |
Sravan Kumar Kairam | f59aec1 | 2018-03-23 19:35:01 +0530 | [diff] [blame] | 2103 | sta_session_id, true); |
Sravan Kumar Kairam | 5214f65 | 2018-03-13 09:52:31 +0530 | [diff] [blame] | 2104 | qdf_mutex_acquire(&ipa_ctx->event_lock); |
| 2105 | } |
| 2106 | |
jiad | 72b69a9 | 2019-04-11 17:23:10 +0800 | [diff] [blame] | 2107 | /* |
| 2108 | * IPA pipes already enabled if STA only offload |
| 2109 | * is enabled and STA is connected to remote AP. |
| 2110 | */ |
| 2111 | if (wlan_ipa_is_sta_only_offload_enabled() && |
| 2112 | ipa_ctx->sta_connected) { |
| 2113 | ipa_debug("IPA pipes already enabled"); |
| 2114 | } else if (wlan_ipa_uc_handle_first_con(ipa_ctx)) { |
Sravan Kumar Kairam | 5214f65 | 2018-03-13 09:52:31 +0530 | [diff] [blame] | 2115 | ipa_info("%s: handle 1st con fail", |
| 2116 | net_dev->name); |
| 2117 | |
| 2118 | if (wlan_ipa_uc_sta_is_enabled( |
| 2119 | ipa_ctx->config) && |
jiad | 72b69a9 | 2019-04-11 17:23:10 +0800 | [diff] [blame] | 2120 | ipa_ctx->sta_connected && |
| 2121 | !wlan_ipa_is_sta_only_offload_enabled()) { |
Sravan Kumar Kairam | 5214f65 | 2018-03-13 09:52:31 +0530 | [diff] [blame] | 2122 | qdf_mutex_release(&ipa_ctx->event_lock); |
| 2123 | wlan_ipa_uc_offload_enable_disable( |
| 2124 | ipa_ctx, |
| 2125 | SIR_STA_RX_DATA_OFFLOAD, |
Sravan Kumar Kairam | f59aec1 | 2018-03-23 19:35:01 +0530 | [diff] [blame] | 2126 | sta_session_id, false); |
Sravan Kumar Kairam | 5214f65 | 2018-03-13 09:52:31 +0530 | [diff] [blame] | 2127 | } else { |
| 2128 | qdf_mutex_release(&ipa_ctx->event_lock); |
| 2129 | } |
| 2130 | |
jiad | 72b69a9 | 2019-04-11 17:23:10 +0800 | [diff] [blame] | 2131 | return QDF_STATUS_E_BUSY; |
| 2132 | } |
Sravan Kumar Kairam | 5214f65 | 2018-03-13 09:52:31 +0530 | [diff] [blame] | 2133 | } |
| 2134 | |
| 2135 | ipa_ctx->sap_num_connected_sta++; |
| 2136 | |
| 2137 | qdf_mutex_release(&ipa_ctx->event_lock); |
| 2138 | |
| 2139 | QDF_IPA_SET_META_MSG_TYPE(&meta, type); |
| 2140 | QDF_IPA_MSG_META_MSG_LEN(&meta) = |
| 2141 | (sizeof(qdf_ipa_wlan_msg_ex_t) + |
| 2142 | sizeof(qdf_ipa_wlan_hdr_attrib_val_t)); |
| 2143 | msg_ex = qdf_mem_malloc(QDF_IPA_MSG_META_MSG_LEN(&meta)); |
| 2144 | |
Jeff Johnson | 1d44fee5 | 2019-03-18 14:02:06 -0700 | [diff] [blame] | 2145 | if (!msg_ex) { |
Sravan Kumar Kairam | 5214f65 | 2018-03-13 09:52:31 +0530 | [diff] [blame] | 2146 | ipa_err("msg_ex allocation failed"); |
| 2147 | return QDF_STATUS_E_NOMEM; |
| 2148 | } |
| 2149 | strlcpy(msg_ex->name, net_dev->name, |
| 2150 | IPA_RESOURCE_NAME_MAX); |
| 2151 | msg_ex->num_of_attribs = 1; |
| 2152 | msg_ex->attribs[0].attrib_type = WLAN_HDR_ATTRIB_MAC_ADDR; |
| 2153 | if (wlan_ipa_uc_is_enabled(ipa_ctx->config)) { |
| 2154 | msg_ex->attribs[0].offset = |
| 2155 | WLAN_IPA_UC_WLAN_HDR_DES_MAC_OFFSET; |
| 2156 | } else { |
| 2157 | msg_ex->attribs[0].offset = |
| 2158 | WLAN_IPA_WLAN_HDR_DES_MAC_OFFSET; |
| 2159 | } |
| 2160 | memcpy(msg_ex->attribs[0].u.mac_addr, mac_addr, |
| 2161 | IPA_MAC_ADDR_SIZE); |
| 2162 | |
| 2163 | if (qdf_ipa_send_msg(&meta, msg_ex, wlan_ipa_msg_free_fn)) { |
| 2164 | ipa_info("%s: Evt: %d send ipa msg fail", |
| 2165 | net_dev->name, type); |
| 2166 | qdf_mem_free(msg_ex); |
| 2167 | return QDF_STATUS_E_FAILURE; |
| 2168 | } |
| 2169 | ipa_ctx->stats.num_send_msg++; |
| 2170 | |
| 2171 | ipa_info("sap_num_connected_sta=%d", |
| 2172 | ipa_ctx->sap_num_connected_sta); |
| 2173 | |
| 2174 | return QDF_STATUS_SUCCESS; |
| 2175 | |
| 2176 | case WLAN_CLIENT_DISCONNECT: |
| 2177 | if (!wlan_ipa_uc_is_enabled(ipa_ctx->config)) { |
| 2178 | ipa_debug("%s: IPA UC OFFLOAD NOT ENABLED", |
| 2179 | msg_ex->name); |
| 2180 | return QDF_STATUS_SUCCESS; |
| 2181 | } |
| 2182 | |
| 2183 | qdf_mutex_acquire(&ipa_ctx->event_lock); |
| 2184 | if (!ipa_ctx->sap_num_connected_sta) { |
| 2185 | qdf_mutex_release(&ipa_ctx->event_lock); |
| 2186 | ipa_err("%s: Evt: %d, Client already disconnected", |
| 2187 | msg_ex->name, |
| 2188 | QDF_IPA_MSG_META_MSG_TYPE(&meta)); |
| 2189 | |
| 2190 | return QDF_STATUS_SUCCESS; |
| 2191 | } |
| 2192 | if (!wlan_ipa_uc_find_add_assoc_sta(ipa_ctx, false, |
Rakshith Suresh Patkar | 96703f6 | 2019-08-06 14:34:36 +0530 | [diff] [blame] | 2193 | mac_addr)) { |
Sravan Kumar Kairam | 5214f65 | 2018-03-13 09:52:31 +0530 | [diff] [blame] | 2194 | qdf_mutex_release(&ipa_ctx->event_lock); |
Rakshith Suresh Patkar | 96703f6 | 2019-08-06 14:34:36 +0530 | [diff] [blame] | 2195 | ipa_err("%s: STA NOT found, not valid: " |
| 2196 | QDF_MAC_ADDR_STR, |
| 2197 | msg_ex->name, QDF_MAC_ADDR_ARRAY(mac_addr)); |
Sravan Kumar Kairam | 5214f65 | 2018-03-13 09:52:31 +0530 | [diff] [blame] | 2198 | |
| 2199 | return QDF_STATUS_SUCCESS; |
| 2200 | } |
| 2201 | ipa_ctx->sap_num_connected_sta--; |
| 2202 | |
jiad | 72b69a9 | 2019-04-11 17:23:10 +0800 | [diff] [blame] | 2203 | /* |
| 2204 | * Disable IPA pipes when |
| 2205 | * 1. last client disconnected and |
| 2206 | * 2. STA is not connected if STA only offload is enabled |
| 2207 | */ |
Sravan Kumar Kairam | 5214f65 | 2018-03-13 09:52:31 +0530 | [diff] [blame] | 2208 | if (!ipa_ctx->sap_num_connected_sta && |
jiad | 72b69a9 | 2019-04-11 17:23:10 +0800 | [diff] [blame] | 2209 | ipa_ctx->uc_loaded && |
| 2210 | !(wlan_ipa_is_sta_only_offload_enabled() && |
| 2211 | ipa_ctx->sta_connected)) { |
Yun Park | a29974a | 2018-04-09 12:05:49 -0700 | [diff] [blame] | 2212 | if ((false == ipa_ctx->resource_unloading) && |
| 2213 | wlan_ipa_is_fw_wdi_activated(ipa_ctx) && |
| 2214 | !ipa_ctx->ipa_pipes_down) { |
jiad | 3a321f3 | 2018-07-16 18:16:39 +0800 | [diff] [blame] | 2215 | if (cds_is_driver_unloading()) { |
| 2216 | /* |
| 2217 | * We disable WDI pipes directly here |
| 2218 | * since IPA_OPCODE_TX/RX_SUSPEND |
| 2219 | * message will not be processed when |
| 2220 | * unloading WLAN driver is in progress |
| 2221 | */ |
| 2222 | wlan_ipa_uc_disable_pipes(ipa_ctx); |
| 2223 | } else { |
| 2224 | wlan_ipa_uc_handle_last_discon(ipa_ctx); |
| 2225 | } |
Sravan Kumar Kairam | 5214f65 | 2018-03-13 09:52:31 +0530 | [diff] [blame] | 2226 | } |
| 2227 | |
| 2228 | if (wlan_ipa_uc_sta_is_enabled(ipa_ctx->config) && |
jiad | 72b69a9 | 2019-04-11 17:23:10 +0800 | [diff] [blame] | 2229 | ipa_ctx->sta_connected && |
| 2230 | !wlan_ipa_is_sta_only_offload_enabled()) { |
Sravan Kumar Kairam | 5214f65 | 2018-03-13 09:52:31 +0530 | [diff] [blame] | 2231 | qdf_mutex_release(&ipa_ctx->event_lock); |
| 2232 | wlan_ipa_uc_offload_enable_disable(ipa_ctx, |
| 2233 | SIR_STA_RX_DATA_OFFLOAD, |
Sravan Kumar Kairam | f59aec1 | 2018-03-23 19:35:01 +0530 | [diff] [blame] | 2234 | sta_session_id, false); |
Sravan Kumar Kairam | 5214f65 | 2018-03-13 09:52:31 +0530 | [diff] [blame] | 2235 | } else { |
| 2236 | qdf_mutex_release(&ipa_ctx->event_lock); |
| 2237 | } |
| 2238 | } else { |
| 2239 | qdf_mutex_release(&ipa_ctx->event_lock); |
| 2240 | } |
| 2241 | |
| 2242 | ipa_info("sap_num_connected_sta=%d", |
| 2243 | ipa_ctx->sap_num_connected_sta); |
| 2244 | break; |
| 2245 | |
| 2246 | default: |
| 2247 | return QDF_STATUS_SUCCESS; |
| 2248 | } |
| 2249 | |
| 2250 | QDF_IPA_MSG_META_MSG_LEN(&meta) = sizeof(qdf_ipa_wlan_msg_t); |
| 2251 | msg = qdf_mem_malloc(QDF_IPA_MSG_META_MSG_LEN(&meta)); |
| 2252 | if (!msg) { |
| 2253 | ipa_err("msg allocation failed"); |
| 2254 | return QDF_STATUS_E_NOMEM; |
| 2255 | } |
| 2256 | |
| 2257 | QDF_IPA_SET_META_MSG_TYPE(&meta, type); |
| 2258 | strlcpy(QDF_IPA_WLAN_MSG_NAME(msg), net_dev->name, |
| 2259 | IPA_RESOURCE_NAME_MAX); |
| 2260 | qdf_mem_copy(QDF_IPA_WLAN_MSG_MAC_ADDR(msg), mac_addr, QDF_NET_ETH_LEN); |
| 2261 | |
| 2262 | ipa_debug("%s: Evt: %d", QDF_IPA_WLAN_MSG_NAME(msg), |
| 2263 | QDF_IPA_MSG_META_MSG_TYPE(&meta)); |
| 2264 | |
| 2265 | if (qdf_ipa_send_msg(&meta, msg, wlan_ipa_msg_free_fn)) { |
| 2266 | |
| 2267 | ipa_err("%s: Evt: %d fail", |
| 2268 | QDF_IPA_WLAN_MSG_NAME(msg), |
| 2269 | QDF_IPA_MSG_META_MSG_TYPE(&meta)); |
| 2270 | qdf_mem_free(msg); |
| 2271 | |
| 2272 | return QDF_STATUS_E_FAILURE; |
| 2273 | } |
| 2274 | |
| 2275 | ipa_ctx->stats.num_send_msg++; |
| 2276 | |
| 2277 | end: |
| 2278 | return QDF_STATUS_SUCCESS; |
| 2279 | } |
| 2280 | |
| 2281 | /** |
| 2282 | * wlan_host_to_ipa_wlan_event() - convert wlan_ipa_wlan_event to ipa_wlan_event |
Yun Park | 84fbb27 | 2018-04-02 15:31:01 -0700 | [diff] [blame] | 2283 | * @wlan_ipa_event_type: event to be converted to an ipa_wlan_event |
Sravan Kumar Kairam | 5214f65 | 2018-03-13 09:52:31 +0530 | [diff] [blame] | 2284 | * |
| 2285 | * Return: qdf_ipa_wlan_event representing the wlan_ipa_wlan_event |
| 2286 | */ |
| 2287 | static qdf_ipa_wlan_event |
| 2288 | wlan_host_to_ipa_wlan_event(enum wlan_ipa_wlan_event wlan_ipa_event_type) |
| 2289 | { |
Yun Park | 84fbb27 | 2018-04-02 15:31:01 -0700 | [diff] [blame] | 2290 | qdf_ipa_wlan_event ipa_event; |
Sravan Kumar Kairam | 5214f65 | 2018-03-13 09:52:31 +0530 | [diff] [blame] | 2291 | |
| 2292 | switch (wlan_ipa_event_type) { |
| 2293 | case WLAN_IPA_CLIENT_CONNECT: |
| 2294 | ipa_event = QDF_IPA_CLIENT_CONNECT; |
| 2295 | break; |
| 2296 | case WLAN_IPA_CLIENT_DISCONNECT: |
| 2297 | ipa_event = QDF_IPA_CLIENT_DISCONNECT; |
| 2298 | break; |
| 2299 | case WLAN_IPA_AP_CONNECT: |
| 2300 | ipa_event = QDF_IPA_AP_CONNECT; |
| 2301 | break; |
| 2302 | case WLAN_IPA_AP_DISCONNECT: |
| 2303 | ipa_event = QDF_IPA_AP_DISCONNECT; |
| 2304 | break; |
| 2305 | case WLAN_IPA_STA_CONNECT: |
| 2306 | ipa_event = QDF_IPA_STA_CONNECT; |
| 2307 | break; |
| 2308 | case WLAN_IPA_STA_DISCONNECT: |
| 2309 | ipa_event = QDF_IPA_STA_DISCONNECT; |
| 2310 | break; |
| 2311 | case WLAN_IPA_CLIENT_CONNECT_EX: |
| 2312 | ipa_event = QDF_IPA_CLIENT_CONNECT_EX; |
| 2313 | break; |
| 2314 | case WLAN_IPA_WLAN_EVENT_MAX: |
| 2315 | default: |
| 2316 | ipa_event = QDF_IPA_WLAN_EVENT_MAX; |
| 2317 | break; |
| 2318 | } |
| 2319 | |
| 2320 | return ipa_event; |
| 2321 | } |
| 2322 | |
| 2323 | /** |
| 2324 | * wlan_ipa_wlan_evt() - SSR wrapper for __wlan_ipa_wlan_evt |
| 2325 | * @net_dev: Interface net device |
| 2326 | * @device_mode: Net interface device mode |
Sravan Kumar Kairam | 5214f65 | 2018-03-13 09:52:31 +0530 | [diff] [blame] | 2327 | * @session_id: session id for the event |
| 2328 | * @ipa_event_type: event enum of type wlan_ipa_wlan_event |
| 2329 | * @mac_address: MAC address associated with the event |
| 2330 | * |
| 2331 | * Return: QDF_STATUS |
| 2332 | */ |
| 2333 | QDF_STATUS wlan_ipa_wlan_evt(qdf_netdev_t net_dev, uint8_t device_mode, |
Rakshith Suresh Patkar | 96703f6 | 2019-08-06 14:34:36 +0530 | [diff] [blame] | 2334 | uint8_t session_id, |
Sravan Kumar Kairam | 5214f65 | 2018-03-13 09:52:31 +0530 | [diff] [blame] | 2335 | enum wlan_ipa_wlan_event ipa_event_type, |
| 2336 | uint8_t *mac_addr) |
| 2337 | { |
| 2338 | qdf_ipa_wlan_event type = wlan_host_to_ipa_wlan_event(ipa_event_type); |
| 2339 | QDF_STATUS status = QDF_STATUS_SUCCESS; |
| 2340 | |
| 2341 | /* Data path offload only support for STA and SAP mode */ |
| 2342 | if ((device_mode == QDF_STA_MODE) || |
| 2343 | (device_mode == QDF_SAP_MODE)) |
Rakshith Suresh Patkar | 96703f6 | 2019-08-06 14:34:36 +0530 | [diff] [blame] | 2344 | status = __wlan_ipa_wlan_evt(net_dev, device_mode, |
Sravan Kumar Kairam | 5214f65 | 2018-03-13 09:52:31 +0530 | [diff] [blame] | 2345 | session_id, type, mac_addr); |
| 2346 | |
| 2347 | return status; |
| 2348 | } |
| 2349 | |
| 2350 | /** |
| 2351 | * wlan_ipa_uc_proc_pending_event() - Process IPA uC pending events |
| 2352 | * @ipa_ctx: Global IPA IPA context |
| 2353 | * @is_loading: Indicate if invoked during loading |
| 2354 | * |
| 2355 | * Return: None |
| 2356 | */ |
| 2357 | static void |
| 2358 | wlan_ipa_uc_proc_pending_event(struct wlan_ipa_priv *ipa_ctx, bool is_loading) |
| 2359 | { |
| 2360 | unsigned int pending_event_count; |
| 2361 | struct wlan_ipa_uc_pending_event *pending_event = NULL; |
| 2362 | |
| 2363 | pending_event_count = qdf_list_size(&ipa_ctx->pending_event); |
| 2364 | ipa_debug("Pending Event Count %d", pending_event_count); |
| 2365 | if (!pending_event_count) { |
| 2366 | ipa_debug("No Pending Event"); |
| 2367 | return; |
| 2368 | } |
| 2369 | |
| 2370 | qdf_list_remove_front(&ipa_ctx->pending_event, |
| 2371 | (qdf_list_node_t **)&pending_event); |
Jeff Johnson | 1d44fee5 | 2019-03-18 14:02:06 -0700 | [diff] [blame] | 2372 | while (pending_event) { |
Sravan Kumar Kairam | 8c151e2 | 2018-06-15 16:35:39 +0530 | [diff] [blame] | 2373 | struct wlan_objmgr_pdev *pdev = ipa_ctx->pdev; |
| 2374 | struct wlan_objmgr_psoc *psoc = wlan_pdev_get_psoc(pdev); |
| 2375 | struct wlan_objmgr_vdev *vdev = |
| 2376 | wlan_objmgr_get_vdev_by_id_from_psoc(psoc, |
| 2377 | pending_event->session_id, |
| 2378 | WLAN_IPA_ID); |
| 2379 | if (pending_event->is_loading == is_loading && vdev) { |
Sravan Kumar Kairam | 5214f65 | 2018-03-13 09:52:31 +0530 | [diff] [blame] | 2380 | __wlan_ipa_wlan_evt(pending_event->net_dev, |
| 2381 | pending_event->device_mode, |
Sravan Kumar Kairam | 5214f65 | 2018-03-13 09:52:31 +0530 | [diff] [blame] | 2382 | pending_event->session_id, |
| 2383 | pending_event->type, |
| 2384 | pending_event->mac_addr); |
| 2385 | } |
Sravan Kumar Kairam | 8c151e2 | 2018-06-15 16:35:39 +0530 | [diff] [blame] | 2386 | |
| 2387 | if (vdev) |
| 2388 | wlan_objmgr_vdev_release_ref(vdev, WLAN_IPA_ID); |
Sravan Kumar Kairam | 5214f65 | 2018-03-13 09:52:31 +0530 | [diff] [blame] | 2389 | qdf_mem_free(pending_event); |
| 2390 | pending_event = NULL; |
| 2391 | qdf_list_remove_front(&ipa_ctx->pending_event, |
| 2392 | (qdf_list_node_t **)&pending_event); |
| 2393 | } |
| 2394 | } |
| 2395 | |
| 2396 | /** |
Ryan Hsu | b5783cf | 2018-05-14 12:13:15 -0700 | [diff] [blame] | 2397 | * wlan_ipa_free_tx_desc_list() - Free IPA Tx desc list |
| 2398 | * @ipa_ctx: IPA context |
| 2399 | * |
| 2400 | * Return: None |
| 2401 | */ |
| 2402 | static inline void wlan_ipa_free_tx_desc_list(struct wlan_ipa_priv *ipa_ctx) |
| 2403 | { |
Sravan Kumar Kairam | 1f8f8b3 | 2018-07-06 16:05:24 +0530 | [diff] [blame] | 2404 | int i; |
Ryan Hsu | b5783cf | 2018-05-14 12:13:15 -0700 | [diff] [blame] | 2405 | qdf_ipa_rx_data_t *ipa_tx_desc; |
Sravan Kumar Kairam | 1f8f8b3 | 2018-07-06 16:05:24 +0530 | [diff] [blame] | 2406 | uint32_t pool_size; |
Ryan Hsu | b5783cf | 2018-05-14 12:13:15 -0700 | [diff] [blame] | 2407 | |
Sravan Kumar Kairam | 1f8f8b3 | 2018-07-06 16:05:24 +0530 | [diff] [blame] | 2408 | if (!ipa_ctx->tx_desc_pool) |
| 2409 | return; |
Ryan Hsu | b5783cf | 2018-05-14 12:13:15 -0700 | [diff] [blame] | 2410 | |
Sravan Kumar Kairam | 1f8f8b3 | 2018-07-06 16:05:24 +0530 | [diff] [blame] | 2411 | qdf_spin_lock_bh(&ipa_ctx->q_lock); |
| 2412 | pool_size = ipa_ctx->tx_desc_free_list.max_size; |
| 2413 | for (i = 0; i < pool_size; i++) { |
| 2414 | ipa_tx_desc = ipa_ctx->tx_desc_pool[i].ipa_tx_desc_ptr; |
Ryan Hsu | b5783cf | 2018-05-14 12:13:15 -0700 | [diff] [blame] | 2415 | if (ipa_tx_desc) |
| 2416 | qdf_ipa_free_skb(ipa_tx_desc); |
| 2417 | |
Sravan Kumar Kairam | 1f8f8b3 | 2018-07-06 16:05:24 +0530 | [diff] [blame] | 2418 | if (qdf_list_remove_node(&ipa_ctx->tx_desc_free_list, |
| 2419 | &ipa_ctx->tx_desc_pool[i].node) != |
| 2420 | QDF_STATUS_SUCCESS) |
| 2421 | ipa_err("Failed to remove node from tx desc freelist"); |
Ryan Hsu | b5783cf | 2018-05-14 12:13:15 -0700 | [diff] [blame] | 2422 | } |
Sravan Kumar Kairam | 1f8f8b3 | 2018-07-06 16:05:24 +0530 | [diff] [blame] | 2423 | qdf_spin_unlock_bh(&ipa_ctx->q_lock); |
| 2424 | |
| 2425 | qdf_list_destroy(&ipa_ctx->tx_desc_free_list); |
| 2426 | qdf_mem_free(ipa_ctx->tx_desc_pool); |
| 2427 | ipa_ctx->tx_desc_pool = NULL; |
| 2428 | |
| 2429 | ipa_ctx->stats.num_tx_desc_q_cnt = 0; |
| 2430 | ipa_ctx->stats.num_tx_desc_error = 0; |
Ryan Hsu | b5783cf | 2018-05-14 12:13:15 -0700 | [diff] [blame] | 2431 | } |
| 2432 | |
| 2433 | /** |
Sravan Kumar Kairam | 1f8f8b3 | 2018-07-06 16:05:24 +0530 | [diff] [blame] | 2434 | * wlan_ipa_alloc_tx_desc_free_list() - Allocate IPA Tx desc list |
Sravan Kumar Kairam | d01b445 | 2018-03-07 17:37:09 +0530 | [diff] [blame] | 2435 | * @ipa_ctx: IPA context |
| 2436 | * |
| 2437 | * Return: QDF_STATUS |
| 2438 | */ |
Sravan Kumar Kairam | 1f8f8b3 | 2018-07-06 16:05:24 +0530 | [diff] [blame] | 2439 | static QDF_STATUS |
| 2440 | wlan_ipa_alloc_tx_desc_free_list(struct wlan_ipa_priv *ipa_ctx) |
Sravan Kumar Kairam | d01b445 | 2018-03-07 17:37:09 +0530 | [diff] [blame] | 2441 | { |
| 2442 | int i; |
| 2443 | uint32_t max_desc_cnt; |
Sravan Kumar Kairam | d01b445 | 2018-03-07 17:37:09 +0530 | [diff] [blame] | 2444 | |
| 2445 | max_desc_cnt = ipa_ctx->config->txbuf_count; |
| 2446 | |
Sravan Kumar Kairam | 1f8f8b3 | 2018-07-06 16:05:24 +0530 | [diff] [blame] | 2447 | ipa_ctx->tx_desc_pool = qdf_mem_malloc(sizeof(struct wlan_ipa_tx_desc) * |
| 2448 | max_desc_cnt); |
| 2449 | |
| 2450 | if (!ipa_ctx->tx_desc_pool) { |
| 2451 | ipa_err("Free Tx descriptor allocation failed"); |
| 2452 | return QDF_STATUS_E_NOMEM; |
| 2453 | } |
| 2454 | |
| 2455 | qdf_list_create(&ipa_ctx->tx_desc_free_list, max_desc_cnt); |
Sravan Kumar Kairam | d01b445 | 2018-03-07 17:37:09 +0530 | [diff] [blame] | 2456 | |
| 2457 | qdf_spin_lock_bh(&ipa_ctx->q_lock); |
| 2458 | for (i = 0; i < max_desc_cnt; i++) { |
Sravan Kumar Kairam | 1f8f8b3 | 2018-07-06 16:05:24 +0530 | [diff] [blame] | 2459 | ipa_ctx->tx_desc_pool[i].id = i; |
| 2460 | ipa_ctx->tx_desc_pool[i].ipa_tx_desc_ptr = NULL; |
| 2461 | qdf_list_insert_back(&ipa_ctx->tx_desc_free_list, |
| 2462 | &ipa_ctx->tx_desc_pool[i].node); |
Sravan Kumar Kairam | d01b445 | 2018-03-07 17:37:09 +0530 | [diff] [blame] | 2463 | } |
| 2464 | |
| 2465 | ipa_ctx->stats.num_tx_desc_q_cnt = 0; |
| 2466 | ipa_ctx->stats.num_tx_desc_error = 0; |
| 2467 | |
| 2468 | qdf_spin_unlock_bh(&ipa_ctx->q_lock); |
| 2469 | |
| 2470 | return QDF_STATUS_SUCCESS; |
| 2471 | } |
| 2472 | |
| 2473 | #ifndef QCA_LL_TX_FLOW_CONTROL_V2 |
| 2474 | /** |
| 2475 | * wlan_ipa_setup_tx_sys_pipe() - Setup IPA Tx system pipes |
| 2476 | * @ipa_ctx: Global IPA IPA context |
| 2477 | * @desc_fifo_sz: Number of descriptors |
| 2478 | * |
| 2479 | * Return: 0 on success, negative errno on error |
| 2480 | */ |
| 2481 | static int wlan_ipa_setup_tx_sys_pipe(struct wlan_ipa_priv *ipa_ctx, |
| 2482 | int32_t desc_fifo_sz) |
| 2483 | { |
| 2484 | int i, ret = 0; |
| 2485 | qdf_ipa_sys_connect_params_t *ipa; |
| 2486 | |
| 2487 | /*setup TX pipes */ |
| 2488 | for (i = 0; i < WLAN_IPA_MAX_IFACE; i++) { |
| 2489 | ipa = &ipa_ctx->sys_pipe[i].ipa_sys_params; |
| 2490 | |
| 2491 | ipa->client = wlan_ipa_iface_2_client[i].cons_client; |
| 2492 | ipa->desc_fifo_sz = desc_fifo_sz; |
| 2493 | ipa->priv = &ipa_ctx->iface_context[i]; |
Sravan Kumar Kairam | 1309e7e | 2018-03-13 09:29:52 +0530 | [diff] [blame] | 2494 | ipa->notify = wlan_ipa_i2w_cb; |
Sravan Kumar Kairam | d01b445 | 2018-03-07 17:37:09 +0530 | [diff] [blame] | 2495 | |
| 2496 | if (wlan_ipa_uc_sta_is_enabled(ipa_ctx->config)) { |
| 2497 | ipa->ipa_ep_cfg.hdr.hdr_len = |
| 2498 | WLAN_IPA_UC_WLAN_TX_HDR_LEN; |
| 2499 | ipa->ipa_ep_cfg.nat.nat_en = IPA_BYPASS_NAT; |
| 2500 | ipa->ipa_ep_cfg.hdr.hdr_ofst_pkt_size_valid = 1; |
| 2501 | ipa->ipa_ep_cfg.hdr.hdr_ofst_pkt_size = 0; |
| 2502 | ipa->ipa_ep_cfg.hdr.hdr_additional_const_len = |
| 2503 | WLAN_IPA_UC_WLAN_8023_HDR_SIZE; |
| 2504 | ipa->ipa_ep_cfg.hdr_ext.hdr_little_endian = true; |
| 2505 | } else { |
| 2506 | ipa->ipa_ep_cfg.hdr.hdr_len = WLAN_IPA_WLAN_TX_HDR_LEN; |
| 2507 | } |
| 2508 | ipa->ipa_ep_cfg.mode.mode = IPA_BASIC; |
| 2509 | |
| 2510 | ret = wlan_ipa_wdi_setup_sys_pipe(ipa_ctx, ipa, |
| 2511 | &ipa_ctx->sys_pipe[i].conn_hdl); |
| 2512 | if (ret) { |
| 2513 | ipa_err("Failed for pipe %d ret: %d", i, ret); |
| 2514 | return ret; |
| 2515 | } |
| 2516 | ipa_ctx->sys_pipe[i].conn_hdl_valid = 1; |
| 2517 | } |
| 2518 | |
| 2519 | return ret; |
| 2520 | } |
| 2521 | #else |
| 2522 | /** |
| 2523 | * wlan_ipa_setup_tx_sys_pipe() - Setup IPA Tx system pipes |
Sravan Kumar Kairam | c047d29 | 2018-11-19 18:43:15 +0530 | [diff] [blame] | 2524 | * @ipa_ctx: IPA context |
Sravan Kumar Kairam | d01b445 | 2018-03-07 17:37:09 +0530 | [diff] [blame] | 2525 | * @desc_fifo_sz: Number of descriptors |
| 2526 | * |
| 2527 | * Return: 0 on success, negative errno on error |
| 2528 | */ |
| 2529 | static int wlan_ipa_setup_tx_sys_pipe(struct wlan_ipa_priv *ipa_ctx, |
| 2530 | int32_t desc_fifo_sz) |
| 2531 | { |
| 2532 | /* |
| 2533 | * The Tx system pipes are not needed for MCC when TX_FLOW_CONTROL_V2 |
| 2534 | * is enabled, where per vdev descriptors are supported in firmware. |
| 2535 | */ |
| 2536 | return 0; |
| 2537 | } |
| 2538 | #endif |
| 2539 | |
Sravan Kumar Kairam | 7efc013 | 2019-03-25 16:13:46 +0530 | [diff] [blame] | 2540 | #if defined(CONFIG_IPA_WDI_UNIFIED_API) && defined(IPA_WDI3_GSI) |
Sravan Kumar Kairam | c047d29 | 2018-11-19 18:43:15 +0530 | [diff] [blame] | 2541 | /** |
| 2542 | * wlan_ipa_get_rx_ipa_client() - Get IPA RX ipa client |
| 2543 | * @ipa_ctx: IPA context |
| 2544 | * |
| 2545 | * Return: rx ipa sys client |
| 2546 | */ |
| 2547 | static inline uint8_t wlan_ipa_get_rx_ipa_client(struct wlan_ipa_priv *ipa_ctx) |
| 2548 | { |
| 2549 | if (ipa_ctx->over_gsi) |
| 2550 | return IPA_CLIENT_WLAN2_PROD; |
| 2551 | else |
| 2552 | return IPA_CLIENT_WLAN1_PROD; |
| 2553 | } |
| 2554 | #else |
| 2555 | static inline uint8_t wlan_ipa_get_rx_ipa_client(struct wlan_ipa_priv *ipa_ctx) |
| 2556 | { |
| 2557 | return IPA_CLIENT_WLAN1_PROD; |
| 2558 | } |
| 2559 | #endif |
| 2560 | |
Sravan Kumar Kairam | d01b445 | 2018-03-07 17:37:09 +0530 | [diff] [blame] | 2561 | /** |
| 2562 | * wlan_ipa_setup_rx_sys_pipe() - Setup IPA Rx system pipes |
| 2563 | * @ipa_ctx: Global IPA IPA context |
| 2564 | * @desc_fifo_sz: Number of descriptors |
| 2565 | * |
| 2566 | * Return: 0 on success, negative errno on error |
| 2567 | */ |
| 2568 | static int wlan_ipa_setup_rx_sys_pipe(struct wlan_ipa_priv *ipa_ctx, |
| 2569 | int32_t desc_fifo_sz) |
| 2570 | { |
| 2571 | int ret = 0; |
| 2572 | qdf_ipa_sys_connect_params_t *ipa; |
| 2573 | |
| 2574 | /* |
| 2575 | * Hard code it here, this can be extended if in case |
| 2576 | * PROD pipe is also per interface. |
| 2577 | * Right now there is no advantage of doing this. |
| 2578 | */ |
| 2579 | ipa = &ipa_ctx->sys_pipe[WLAN_IPA_RX_PIPE].ipa_sys_params; |
| 2580 | |
Sravan Kumar Kairam | c047d29 | 2018-11-19 18:43:15 +0530 | [diff] [blame] | 2581 | ipa->client = wlan_ipa_get_rx_ipa_client(ipa_ctx); |
Sravan Kumar Kairam | d01b445 | 2018-03-07 17:37:09 +0530 | [diff] [blame] | 2582 | ipa->desc_fifo_sz = desc_fifo_sz; |
| 2583 | ipa->priv = ipa_ctx; |
Sravan Kumar Kairam | 1309e7e | 2018-03-13 09:29:52 +0530 | [diff] [blame] | 2584 | ipa->notify = wlan_ipa_w2i_cb; |
Sravan Kumar Kairam | d01b445 | 2018-03-07 17:37:09 +0530 | [diff] [blame] | 2585 | |
| 2586 | ipa->ipa_ep_cfg.nat.nat_en = IPA_BYPASS_NAT; |
| 2587 | ipa->ipa_ep_cfg.hdr.hdr_len = WLAN_IPA_WLAN_RX_HDR_LEN; |
| 2588 | ipa->ipa_ep_cfg.hdr.hdr_ofst_metadata_valid = 1; |
| 2589 | ipa->ipa_ep_cfg.mode.mode = IPA_BASIC; |
| 2590 | |
| 2591 | ret = qdf_ipa_setup_sys_pipe(ipa, |
| 2592 | &ipa_ctx->sys_pipe[WLAN_IPA_RX_PIPE].conn_hdl); |
| 2593 | if (ret) { |
| 2594 | ipa_err("Failed for RX pipe: %d", ret); |
| 2595 | return ret; |
| 2596 | } |
| 2597 | ipa_ctx->sys_pipe[WLAN_IPA_RX_PIPE].conn_hdl_valid = 1; |
| 2598 | |
| 2599 | return ret; |
| 2600 | } |
| 2601 | |
| 2602 | /** |
Ryan Hsu | b5783cf | 2018-05-14 12:13:15 -0700 | [diff] [blame] | 2603 | * wlan_ipa_teardown_sys_pipe() - Tear down all IPA Sys pipes |
| 2604 | * @ipa_ctx: Global IPA IPA context |
| 2605 | * |
| 2606 | * Return: None |
| 2607 | */ |
| 2608 | static void wlan_ipa_teardown_sys_pipe(struct wlan_ipa_priv *ipa_ctx) |
| 2609 | { |
| 2610 | int ret, i; |
| 2611 | |
| 2612 | if (!ipa_ctx) |
| 2613 | return; |
| 2614 | |
| 2615 | for (i = 0; i < WLAN_IPA_MAX_SYSBAM_PIPE; i++) { |
| 2616 | if (ipa_ctx->sys_pipe[i].conn_hdl_valid) { |
| 2617 | ret = wlan_ipa_wdi_teardown_sys_pipe(ipa_ctx, |
| 2618 | ipa_ctx->sys_pipe[i].conn_hdl); |
| 2619 | if (ret) |
| 2620 | ipa_err("Failed:%d", ret); |
| 2621 | |
| 2622 | ipa_ctx->sys_pipe[i].conn_hdl_valid = 0; |
| 2623 | } |
| 2624 | } |
| 2625 | |
| 2626 | wlan_ipa_free_tx_desc_list(ipa_ctx); |
| 2627 | } |
| 2628 | |
| 2629 | /** |
Sravan Kumar Kairam | d01b445 | 2018-03-07 17:37:09 +0530 | [diff] [blame] | 2630 | * wlan_ipa_setup_sys_pipe() - Setup all IPA system pipes |
| 2631 | * @ipa_ctx: Global IPA IPA context |
| 2632 | * |
| 2633 | * Return: 0 on success, negative errno on error |
| 2634 | */ |
| 2635 | static int wlan_ipa_setup_sys_pipe(struct wlan_ipa_priv *ipa_ctx) |
| 2636 | { |
Ryan Hsu | b5783cf | 2018-05-14 12:13:15 -0700 | [diff] [blame] | 2637 | int ret = 0; |
Sravan Kumar Kairam | d01b445 | 2018-03-07 17:37:09 +0530 | [diff] [blame] | 2638 | uint32_t desc_fifo_sz; |
| 2639 | |
| 2640 | /* The maximum number of descriptors that can be provided to a BAM at |
| 2641 | * once is one less than the total number of descriptors that the buffer |
| 2642 | * can contain. |
| 2643 | * If max_num_of_descriptors = (BAM_PIPE_DESCRIPTOR_FIFO_SIZE / sizeof |
| 2644 | * (SPS_DESCRIPTOR)), then (max_num_of_descriptors - 1) descriptors can |
| 2645 | * be provided at once. |
| 2646 | * Because of above requirement, one extra descriptor will be added to |
| 2647 | * make sure hardware always has one descriptor. |
| 2648 | */ |
| 2649 | desc_fifo_sz = ipa_ctx->config->desc_size |
| 2650 | + SPS_DESC_SIZE; |
| 2651 | |
| 2652 | ret = wlan_ipa_setup_tx_sys_pipe(ipa_ctx, desc_fifo_sz); |
| 2653 | if (ret) { |
| 2654 | ipa_err("Failed for TX pipe: %d", ret); |
| 2655 | goto setup_sys_pipe_fail; |
| 2656 | } |
| 2657 | |
| 2658 | if (!wlan_ipa_uc_sta_is_enabled(ipa_ctx->config)) { |
| 2659 | ret = wlan_ipa_setup_rx_sys_pipe(ipa_ctx, desc_fifo_sz); |
| 2660 | if (ret) { |
| 2661 | ipa_err("Failed for RX pipe: %d", ret); |
| 2662 | goto setup_sys_pipe_fail; |
| 2663 | } |
| 2664 | } |
| 2665 | |
| 2666 | /* Allocate free Tx desc list */ |
Sravan Kumar Kairam | 1f8f8b3 | 2018-07-06 16:05:24 +0530 | [diff] [blame] | 2667 | ret = wlan_ipa_alloc_tx_desc_free_list(ipa_ctx); |
Sravan Kumar Kairam | d01b445 | 2018-03-07 17:37:09 +0530 | [diff] [blame] | 2668 | if (ret) |
| 2669 | goto setup_sys_pipe_fail; |
| 2670 | |
| 2671 | return ret; |
| 2672 | |
| 2673 | setup_sys_pipe_fail: |
Ryan Hsu | b5783cf | 2018-05-14 12:13:15 -0700 | [diff] [blame] | 2674 | wlan_ipa_teardown_sys_pipe(ipa_ctx); |
Sravan Kumar Kairam | d01b445 | 2018-03-07 17:37:09 +0530 | [diff] [blame] | 2675 | |
| 2676 | return ret; |
| 2677 | } |
| 2678 | |
jiad | bb47e13 | 2018-03-30 16:28:30 +0800 | [diff] [blame] | 2679 | #ifndef QCA_LL_TX_FLOW_CONTROL_V2 |
| 2680 | QDF_STATUS wlan_ipa_send_mcc_scc_msg(struct wlan_ipa_priv *ipa_ctx, |
| 2681 | bool mcc_mode) |
| 2682 | { |
| 2683 | qdf_ipa_msg_meta_t meta; |
| 2684 | qdf_ipa_wlan_msg_t *msg; |
| 2685 | int ret; |
| 2686 | |
| 2687 | if (!wlan_ipa_uc_sta_is_enabled(ipa_ctx->config)) |
| 2688 | return QDF_STATUS_SUCCESS; |
| 2689 | |
| 2690 | /* Send SCC/MCC Switching event to IPA */ |
| 2691 | QDF_IPA_MSG_META_MSG_LEN(&meta) = sizeof(*msg); |
| 2692 | msg = qdf_mem_malloc(QDF_IPA_MSG_META_MSG_LEN(&meta)); |
Jeff Johnson | 1d44fee5 | 2019-03-18 14:02:06 -0700 | [diff] [blame] | 2693 | if (!msg) { |
jiad | bb47e13 | 2018-03-30 16:28:30 +0800 | [diff] [blame] | 2694 | ipa_err("msg allocation failed"); |
| 2695 | return QDF_STATUS_E_NOMEM; |
| 2696 | } |
| 2697 | |
jiad | 629b217 | 2018-05-11 15:34:22 +0800 | [diff] [blame] | 2698 | if (mcc_mode) { |
jiad | bb47e13 | 2018-03-30 16:28:30 +0800 | [diff] [blame] | 2699 | QDF_IPA_SET_META_MSG_TYPE(&meta, QDF_SWITCH_TO_MCC); |
jiad | 629b217 | 2018-05-11 15:34:22 +0800 | [diff] [blame] | 2700 | ipa_ctx->stats.event[QDF_SWITCH_TO_MCC]++; |
| 2701 | } else { |
jiad | bb47e13 | 2018-03-30 16:28:30 +0800 | [diff] [blame] | 2702 | QDF_IPA_SET_META_MSG_TYPE(&meta, QDF_SWITCH_TO_SCC); |
jiad | 629b217 | 2018-05-11 15:34:22 +0800 | [diff] [blame] | 2703 | ipa_ctx->stats.event[QDF_SWITCH_TO_SCC]++; |
| 2704 | } |
| 2705 | |
jiad | bb47e13 | 2018-03-30 16:28:30 +0800 | [diff] [blame] | 2706 | WLAN_IPA_LOG(QDF_TRACE_LEVEL_DEBUG, |
| 2707 | "ipa_send_msg(Evt:%d)", |
| 2708 | QDF_IPA_MSG_META_MSG_TYPE(&meta)); |
| 2709 | |
| 2710 | ret = qdf_ipa_send_msg(&meta, msg, wlan_ipa_msg_free_fn); |
| 2711 | |
| 2712 | if (ret) { |
| 2713 | ipa_err("ipa_send_msg(Evt:%d) - fail=%d", |
| 2714 | QDF_IPA_MSG_META_MSG_TYPE(&meta), ret); |
| 2715 | qdf_mem_free(msg); |
| 2716 | return QDF_STATUS_E_FAILURE; |
| 2717 | } |
| 2718 | |
| 2719 | return QDF_STATUS_SUCCESS; |
| 2720 | } |
| 2721 | |
| 2722 | static void wlan_ipa_mcc_work_handler(void *data) |
| 2723 | { |
| 2724 | struct wlan_ipa_priv *ipa_ctx = (struct wlan_ipa_priv *)data; |
| 2725 | |
| 2726 | wlan_ipa_send_mcc_scc_msg(ipa_ctx, ipa_ctx->mcc_mode); |
| 2727 | } |
| 2728 | #endif |
| 2729 | |
Sravan Kumar Kairam | d01b445 | 2018-03-07 17:37:09 +0530 | [diff] [blame] | 2730 | /** |
| 2731 | * wlan_ipa_setup() - IPA initialization function |
| 2732 | * @ipa_ctx: IPA context |
| 2733 | * @ipa_cfg: IPA config |
| 2734 | * |
| 2735 | * Allocate ipa_ctx resources, ipa pipe resource and register |
| 2736 | * wlan interface with IPA module. |
| 2737 | * |
| 2738 | * Return: QDF_STATUS enumeration |
| 2739 | */ |
| 2740 | QDF_STATUS wlan_ipa_setup(struct wlan_ipa_priv *ipa_ctx, |
| 2741 | struct wlan_ipa_config *ipa_cfg) |
| 2742 | { |
| 2743 | int ret, i; |
| 2744 | struct wlan_ipa_iface_context *iface_context = NULL; |
| 2745 | QDF_STATUS status; |
| 2746 | |
| 2747 | ipa_debug("enter"); |
| 2748 | |
| 2749 | gp_ipa = ipa_ctx; |
| 2750 | ipa_ctx->num_iface = 0; |
| 2751 | ipa_ctx->config = ipa_cfg; |
| 2752 | |
| 2753 | wlan_ipa_wdi_get_wdi_version(ipa_ctx); |
| 2754 | |
| 2755 | /* Create the interface context */ |
| 2756 | for (i = 0; i < WLAN_IPA_MAX_IFACE; i++) { |
| 2757 | iface_context = &ipa_ctx->iface_context[i]; |
| 2758 | iface_context->ipa_ctx = ipa_ctx; |
| 2759 | iface_context->cons_client = |
| 2760 | wlan_ipa_iface_2_client[i].cons_client; |
| 2761 | iface_context->prod_client = |
| 2762 | wlan_ipa_iface_2_client[i].prod_client; |
| 2763 | iface_context->iface_id = i; |
| 2764 | iface_context->dev = NULL; |
| 2765 | iface_context->device_mode = QDF_MAX_NO_OF_MODE; |
| 2766 | iface_context->tl_context = NULL; |
| 2767 | qdf_spinlock_create(&iface_context->interface_lock); |
| 2768 | } |
| 2769 | |
Sravan Kumar Kairam | 1309e7e | 2018-03-13 09:29:52 +0530 | [diff] [blame] | 2770 | qdf_create_work(0, &ipa_ctx->pm_work, wlan_ipa_pm_flush, ipa_ctx); |
Sravan Kumar Kairam | d01b445 | 2018-03-07 17:37:09 +0530 | [diff] [blame] | 2771 | qdf_spinlock_create(&ipa_ctx->pm_lock); |
| 2772 | qdf_spinlock_create(&ipa_ctx->q_lock); |
Rakshith Suresh Patkar | 785b845 | 2019-03-18 13:36:02 +0530 | [diff] [blame] | 2773 | qdf_spinlock_create(&ipa_ctx->pipes_down_lock); |
Sravan Kumar Kairam | d01b445 | 2018-03-07 17:37:09 +0530 | [diff] [blame] | 2774 | qdf_nbuf_queue_init(&ipa_ctx->pm_queue_head); |
| 2775 | qdf_list_create(&ipa_ctx->pending_event, 1000); |
| 2776 | qdf_mutex_create(&ipa_ctx->event_lock); |
| 2777 | qdf_mutex_create(&ipa_ctx->ipa_lock); |
| 2778 | |
Sravan Kumar Kairam | 2e7aae9 | 2018-03-06 19:32:49 +0530 | [diff] [blame] | 2779 | status = wlan_ipa_wdi_setup_rm(ipa_ctx); |
| 2780 | if (status != QDF_STATUS_SUCCESS) |
| 2781 | goto fail_setup_rm; |
| 2782 | |
Sravan Kumar Kairam | d01b445 | 2018-03-07 17:37:09 +0530 | [diff] [blame] | 2783 | for (i = 0; i < WLAN_IPA_MAX_SYSBAM_PIPE; i++) |
| 2784 | qdf_mem_zero(&ipa_ctx->sys_pipe[i], |
| 2785 | sizeof(struct wlan_ipa_sys_pipe)); |
| 2786 | |
| 2787 | if (wlan_ipa_uc_is_enabled(ipa_ctx->config)) { |
| 2788 | qdf_mem_zero(&ipa_ctx->stats, sizeof(ipa_ctx->stats)); |
| 2789 | ipa_ctx->sap_num_connected_sta = 0; |
| 2790 | ipa_ctx->ipa_tx_packets_diff = 0; |
| 2791 | ipa_ctx->ipa_rx_packets_diff = 0; |
| 2792 | ipa_ctx->ipa_p_tx_packets = 0; |
| 2793 | ipa_ctx->ipa_p_rx_packets = 0; |
| 2794 | ipa_ctx->resource_loading = false; |
| 2795 | ipa_ctx->resource_unloading = false; |
| 2796 | ipa_ctx->sta_connected = 0; |
| 2797 | ipa_ctx->ipa_pipes_down = true; |
Rakshith Suresh Patkar | 785b845 | 2019-03-18 13:36:02 +0530 | [diff] [blame] | 2798 | ipa_ctx->pipes_down_in_progress = false; |
Sravan Kumar Kairam | d01b445 | 2018-03-07 17:37:09 +0530 | [diff] [blame] | 2799 | ipa_ctx->wdi_enabled = false; |
| 2800 | /* Setup IPA system pipes */ |
| 2801 | if (wlan_ipa_uc_sta_is_enabled(ipa_ctx->config)) { |
| 2802 | ret = wlan_ipa_setup_sys_pipe(ipa_ctx); |
| 2803 | if (ret) |
| 2804 | goto fail_create_sys_pipe; |
jiad | bb47e13 | 2018-03-30 16:28:30 +0800 | [diff] [blame] | 2805 | |
| 2806 | qdf_create_work(0, &ipa_ctx->mcc_work, |
| 2807 | wlan_ipa_mcc_work_handler, ipa_ctx); |
Sravan Kumar Kairam | d01b445 | 2018-03-07 17:37:09 +0530 | [diff] [blame] | 2808 | } |
| 2809 | |
| 2810 | status = wlan_ipa_wdi_init(ipa_ctx); |
| 2811 | if (status == QDF_STATUS_E_BUSY) |
| 2812 | status = wlan_ipa_uc_send_wdi_control_msg(false); |
| 2813 | if (status != QDF_STATUS_SUCCESS) { |
Ryan Hsu | b5783cf | 2018-05-14 12:13:15 -0700 | [diff] [blame] | 2814 | ipa_err("IPA WDI init failed: ret=%d", status); |
Sravan Kumar Kairam | d01b445 | 2018-03-07 17:37:09 +0530 | [diff] [blame] | 2815 | goto fail_create_sys_pipe; |
| 2816 | } |
| 2817 | } else { |
| 2818 | ret = wlan_ipa_setup_sys_pipe(ipa_ctx); |
| 2819 | if (ret) |
| 2820 | goto fail_create_sys_pipe; |
| 2821 | } |
| 2822 | |
| 2823 | qdf_event_create(&ipa_ctx->ipa_resource_comp); |
| 2824 | |
| 2825 | ipa_debug("exit: success"); |
| 2826 | |
| 2827 | return QDF_STATUS_SUCCESS; |
| 2828 | |
| 2829 | fail_create_sys_pipe: |
Sravan Kumar Kairam | 2e7aae9 | 2018-03-06 19:32:49 +0530 | [diff] [blame] | 2830 | wlan_ipa_wdi_destroy_rm(ipa_ctx); |
| 2831 | |
| 2832 | fail_setup_rm: |
Sravan Kumar Kairam | d01b445 | 2018-03-07 17:37:09 +0530 | [diff] [blame] | 2833 | qdf_spinlock_destroy(&ipa_ctx->pm_lock); |
Sravan Kumar Kairam | 2e7aae9 | 2018-03-06 19:32:49 +0530 | [diff] [blame] | 2834 | qdf_spinlock_destroy(&ipa_ctx->q_lock); |
Rakshith Suresh Patkar | 785b845 | 2019-03-18 13:36:02 +0530 | [diff] [blame] | 2835 | qdf_spinlock_destroy(&ipa_ctx->pipes_down_lock); |
Sravan Kumar Kairam | 2e7aae9 | 2018-03-06 19:32:49 +0530 | [diff] [blame] | 2836 | for (i = 0; i < WLAN_IPA_MAX_IFACE; i++) { |
| 2837 | iface_context = &ipa_ctx->iface_context[i]; |
| 2838 | qdf_spinlock_destroy(&iface_context->interface_lock); |
| 2839 | } |
| 2840 | qdf_mutex_destroy(&ipa_ctx->event_lock); |
| 2841 | qdf_mutex_destroy(&ipa_ctx->ipa_lock); |
| 2842 | qdf_list_destroy(&ipa_ctx->pending_event); |
Sravan Kumar Kairam | d01b445 | 2018-03-07 17:37:09 +0530 | [diff] [blame] | 2843 | gp_ipa = NULL; |
| 2844 | ipa_debug("exit: fail"); |
| 2845 | |
| 2846 | return QDF_STATUS_E_FAILURE; |
| 2847 | } |
| 2848 | |
Sravan Kumar Kairam | 1309e7e | 2018-03-13 09:29:52 +0530 | [diff] [blame] | 2849 | void wlan_ipa_flush(struct wlan_ipa_priv *ipa_ctx) |
| 2850 | { |
| 2851 | qdf_nbuf_t skb; |
| 2852 | struct wlan_ipa_pm_tx_cb *pm_tx_cb; |
| 2853 | |
| 2854 | if (!wlan_ipa_is_enabled(ipa_ctx->config)) |
| 2855 | return; |
| 2856 | |
| 2857 | qdf_cancel_work(&ipa_ctx->pm_work); |
| 2858 | |
| 2859 | qdf_spin_lock_bh(&ipa_ctx->pm_lock); |
| 2860 | |
| 2861 | while (((skb = qdf_nbuf_queue_remove(&ipa_ctx->pm_queue_head)) |
| 2862 | != NULL)) { |
| 2863 | qdf_spin_unlock_bh(&ipa_ctx->pm_lock); |
| 2864 | |
| 2865 | pm_tx_cb = (struct wlan_ipa_pm_tx_cb *)skb->cb; |
jiad | ab8cea0 | 2018-05-24 09:16:14 +0800 | [diff] [blame] | 2866 | |
| 2867 | if (pm_tx_cb->exception) { |
| 2868 | dev_kfree_skb_any(skb); |
| 2869 | } else { |
| 2870 | if (pm_tx_cb->ipa_tx_desc) |
| 2871 | ipa_free_skb(pm_tx_cb->ipa_tx_desc); |
| 2872 | } |
Sravan Kumar Kairam | 1309e7e | 2018-03-13 09:29:52 +0530 | [diff] [blame] | 2873 | |
| 2874 | qdf_spin_lock_bh(&ipa_ctx->pm_lock); |
| 2875 | } |
| 2876 | qdf_spin_unlock_bh(&ipa_ctx->pm_lock); |
| 2877 | } |
| 2878 | |
Sravan Kumar Kairam | d01b445 | 2018-03-07 17:37:09 +0530 | [diff] [blame] | 2879 | QDF_STATUS wlan_ipa_cleanup(struct wlan_ipa_priv *ipa_ctx) |
| 2880 | { |
Sravan Kumar Kairam | 1309e7e | 2018-03-13 09:29:52 +0530 | [diff] [blame] | 2881 | struct wlan_ipa_iface_context *iface_context; |
Sravan Kumar Kairam | d01b445 | 2018-03-07 17:37:09 +0530 | [diff] [blame] | 2882 | int i; |
| 2883 | |
| 2884 | if (!wlan_ipa_uc_is_enabled(ipa_ctx->config)) |
| 2885 | wlan_ipa_teardown_sys_pipe(ipa_ctx); |
| 2886 | |
| 2887 | /* Teardown IPA sys_pipe for MCC */ |
jiad | bb47e13 | 2018-03-30 16:28:30 +0800 | [diff] [blame] | 2888 | if (wlan_ipa_uc_sta_is_enabled(ipa_ctx->config)) { |
Sravan Kumar Kairam | d01b445 | 2018-03-07 17:37:09 +0530 | [diff] [blame] | 2889 | wlan_ipa_teardown_sys_pipe(ipa_ctx); |
jiad | bb47e13 | 2018-03-30 16:28:30 +0800 | [diff] [blame] | 2890 | qdf_cancel_work(&ipa_ctx->mcc_work); |
| 2891 | } |
Sravan Kumar Kairam | d01b445 | 2018-03-07 17:37:09 +0530 | [diff] [blame] | 2892 | |
Sravan Kumar Kairam | 2e7aae9 | 2018-03-06 19:32:49 +0530 | [diff] [blame] | 2893 | wlan_ipa_wdi_destroy_rm(ipa_ctx); |
| 2894 | |
Sravan Kumar Kairam | 1309e7e | 2018-03-13 09:29:52 +0530 | [diff] [blame] | 2895 | wlan_ipa_flush(ipa_ctx); |
| 2896 | |
Sravan Kumar Kairam | d01b445 | 2018-03-07 17:37:09 +0530 | [diff] [blame] | 2897 | qdf_spinlock_destroy(&ipa_ctx->pm_lock); |
| 2898 | qdf_spinlock_destroy(&ipa_ctx->q_lock); |
Rakshith Suresh Patkar | 785b845 | 2019-03-18 13:36:02 +0530 | [diff] [blame] | 2899 | qdf_spinlock_destroy(&ipa_ctx->pipes_down_lock); |
Sravan Kumar Kairam | d01b445 | 2018-03-07 17:37:09 +0530 | [diff] [blame] | 2900 | |
| 2901 | /* destroy the interface lock */ |
| 2902 | for (i = 0; i < WLAN_IPA_MAX_IFACE; i++) { |
| 2903 | iface_context = &ipa_ctx->iface_context[i]; |
| 2904 | qdf_spinlock_destroy(&iface_context->interface_lock); |
| 2905 | } |
| 2906 | |
| 2907 | if (wlan_ipa_uc_is_enabled(ipa_ctx->config)) { |
| 2908 | wlan_ipa_wdi_cleanup(); |
| 2909 | qdf_mutex_destroy(&ipa_ctx->event_lock); |
| 2910 | qdf_mutex_destroy(&ipa_ctx->ipa_lock); |
| 2911 | qdf_list_destroy(&ipa_ctx->pending_event); |
| 2912 | |
| 2913 | } |
| 2914 | |
| 2915 | gp_ipa = NULL; |
| 2916 | |
| 2917 | return QDF_STATUS_SUCCESS; |
| 2918 | } |
Sravan Kumar Kairam | 271fab2 | 2018-03-07 18:57:41 +0530 | [diff] [blame] | 2919 | |
| 2920 | struct wlan_ipa_iface_context |
| 2921 | *wlan_ipa_get_iface(struct wlan_ipa_priv *ipa_ctx, uint8_t mode) |
| 2922 | { |
| 2923 | struct wlan_ipa_iface_context *iface_ctx = NULL; |
| 2924 | int i; |
| 2925 | |
| 2926 | for (i = 0; i < WLAN_IPA_MAX_IFACE; i++) { |
| 2927 | iface_ctx = &ipa_ctx->iface_context[i]; |
| 2928 | |
| 2929 | if (iface_ctx->device_mode == mode) |
| 2930 | return iface_ctx; |
| 2931 | } |
| 2932 | |
| 2933 | return NULL; |
| 2934 | } |
Sravan Kumar Kairam | 1309e7e | 2018-03-13 09:29:52 +0530 | [diff] [blame] | 2935 | |
jiad | bb47e13 | 2018-03-30 16:28:30 +0800 | [diff] [blame] | 2936 | void wlan_ipa_set_mcc_mode(struct wlan_ipa_priv *ipa_ctx, bool mcc_mode) |
Sravan Kumar Kairam | 7d931ff | 2018-03-13 09:42:02 +0530 | [diff] [blame] | 2937 | { |
Sravan Kumar Kairam | 7d931ff | 2018-03-13 09:42:02 +0530 | [diff] [blame] | 2938 | if (!wlan_ipa_uc_sta_is_enabled(ipa_ctx->config)) |
jiad | bb47e13 | 2018-03-30 16:28:30 +0800 | [diff] [blame] | 2939 | return; |
Sravan Kumar Kairam | 7d931ff | 2018-03-13 09:42:02 +0530 | [diff] [blame] | 2940 | |
jiad | bb47e13 | 2018-03-30 16:28:30 +0800 | [diff] [blame] | 2941 | if (ipa_ctx->mcc_mode == mcc_mode) |
| 2942 | return; |
Sravan Kumar Kairam | 7d931ff | 2018-03-13 09:42:02 +0530 | [diff] [blame] | 2943 | |
jiad | bb47e13 | 2018-03-30 16:28:30 +0800 | [diff] [blame] | 2944 | ipa_ctx->mcc_mode = mcc_mode; |
| 2945 | qdf_sched_work(0, &ipa_ctx->mcc_work); |
Sravan Kumar Kairam | 7d931ff | 2018-03-13 09:42:02 +0530 | [diff] [blame] | 2946 | } |
Sravan Kumar Kairam | 7d931ff | 2018-03-13 09:42:02 +0530 | [diff] [blame] | 2947 | |
| 2948 | /** |
| 2949 | * wlan_ipa_uc_loaded_handler() - Process IPA uC loaded indication |
| 2950 | * @ipa_ctx: ipa ipa local context |
| 2951 | * |
| 2952 | * Will handle IPA UC image loaded indication comes from IPA kernel |
| 2953 | * |
| 2954 | * Return: None |
| 2955 | */ |
| 2956 | static void wlan_ipa_uc_loaded_handler(struct wlan_ipa_priv *ipa_ctx) |
| 2957 | { |
| 2958 | struct wlan_objmgr_pdev *pdev = ipa_ctx->pdev; |
| 2959 | struct wlan_objmgr_psoc *psoc = wlan_pdev_get_psoc(pdev); |
| 2960 | qdf_device_t qdf_dev = wlan_psoc_get_qdf_dev(psoc); |
| 2961 | QDF_STATUS status; |
| 2962 | |
| 2963 | ipa_info("UC READY"); |
Ryan Hsu | b5783cf | 2018-05-14 12:13:15 -0700 | [diff] [blame] | 2964 | |
| 2965 | if (!qdf_dev) { |
| 2966 | ipa_err("qdf device is NULL!"); |
| 2967 | return; |
| 2968 | } |
| 2969 | |
Sravan Kumar Kairam | 7d931ff | 2018-03-13 09:42:02 +0530 | [diff] [blame] | 2970 | if (true == ipa_ctx->uc_loaded) { |
| 2971 | ipa_info("UC already loaded"); |
| 2972 | return; |
| 2973 | } |
| 2974 | |
Lihua Liu | 15f6e45 | 2018-05-30 17:31:06 +0800 | [diff] [blame] | 2975 | if (!qdf_dev) { |
| 2976 | ipa_err("qdf_dev is null"); |
| 2977 | return; |
| 2978 | } |
Sravan Kumar Kairam | 7d931ff | 2018-03-13 09:42:02 +0530 | [diff] [blame] | 2979 | /* Connect pipe */ |
| 2980 | status = wlan_ipa_wdi_setup(ipa_ctx, qdf_dev); |
| 2981 | if (status) { |
| 2982 | ipa_err("Failure to setup IPA pipes (status=%d)", |
| 2983 | status); |
| 2984 | return; |
| 2985 | } |
| 2986 | |
| 2987 | cdp_ipa_set_doorbell_paddr(ipa_ctx->dp_soc, ipa_ctx->dp_pdev); |
Sravan Kumar Kairam | 5214f65 | 2018-03-13 09:52:31 +0530 | [diff] [blame] | 2988 | |
jiad | 72b69a9 | 2019-04-11 17:23:10 +0800 | [diff] [blame] | 2989 | /* |
| 2990 | * Enable IPA/FW PIPEs if |
| 2991 | * 1. any clients connected to SAP or |
| 2992 | * 2. STA connected to remote AP if STA only offload is enabled |
| 2993 | */ |
| 2994 | if (ipa_ctx->sap_num_connected_sta || |
| 2995 | (wlan_ipa_is_sta_only_offload_enabled() && |
| 2996 | ipa_ctx->sta_connected)) { |
Sravan Kumar Kairam | 5214f65 | 2018-03-13 09:52:31 +0530 | [diff] [blame] | 2997 | ipa_debug("Client already connected, enable IPA/FW PIPEs"); |
| 2998 | wlan_ipa_uc_handle_first_con(ipa_ctx); |
| 2999 | } |
Sravan Kumar Kairam | 7d931ff | 2018-03-13 09:42:02 +0530 | [diff] [blame] | 3000 | } |
| 3001 | |
| 3002 | /** |
| 3003 | * wlan_ipa_uc_op_cb() - IPA uC operation callback |
| 3004 | * @op_msg: operation message received from firmware |
| 3005 | * @usr_ctxt: user context registered with TL (we register the IPA Global |
| 3006 | * context) |
| 3007 | * |
| 3008 | * Return: None |
| 3009 | */ |
| 3010 | static void wlan_ipa_uc_op_cb(struct op_msg_type *op_msg, |
| 3011 | struct wlan_ipa_priv *ipa_ctx) |
| 3012 | { |
| 3013 | struct op_msg_type *msg = op_msg; |
| 3014 | struct ipa_uc_fw_stats *uc_fw_stat; |
| 3015 | |
| 3016 | if (!op_msg) { |
| 3017 | ipa_err("INVALID ARG"); |
| 3018 | return; |
| 3019 | } |
| 3020 | |
| 3021 | if (msg->op_code >= WLAN_IPA_UC_OPCODE_MAX) { |
| 3022 | ipa_err("INVALID OPCODE %d", msg->op_code); |
| 3023 | qdf_mem_free(op_msg); |
| 3024 | return; |
| 3025 | } |
| 3026 | |
| 3027 | ipa_debug("OPCODE=%d", msg->op_code); |
| 3028 | |
| 3029 | if ((msg->op_code == WLAN_IPA_UC_OPCODE_TX_RESUME) || |
| 3030 | (msg->op_code == WLAN_IPA_UC_OPCODE_RX_RESUME)) { |
| 3031 | qdf_mutex_acquire(&ipa_ctx->ipa_lock); |
| 3032 | ipa_ctx->activated_fw_pipe++; |
Yun Park | a29974a | 2018-04-09 12:05:49 -0700 | [diff] [blame] | 3033 | if (wlan_ipa_is_fw_wdi_activated(ipa_ctx)) { |
Sravan Kumar Kairam | 7d931ff | 2018-03-13 09:42:02 +0530 | [diff] [blame] | 3034 | ipa_ctx->resource_loading = false; |
| 3035 | qdf_event_set(&ipa_ctx->ipa_resource_comp); |
| 3036 | if (ipa_ctx->wdi_enabled == false) { |
| 3037 | ipa_ctx->wdi_enabled = true; |
| 3038 | if (wlan_ipa_uc_send_wdi_control_msg(true) == 0) |
| 3039 | wlan_ipa_send_mcc_scc_msg(ipa_ctx, |
| 3040 | ipa_ctx->mcc_mode); |
| 3041 | } |
Sravan Kumar Kairam | 5214f65 | 2018-03-13 09:52:31 +0530 | [diff] [blame] | 3042 | wlan_ipa_uc_proc_pending_event(ipa_ctx, true); |
Sravan Kumar Kairam | 7d931ff | 2018-03-13 09:42:02 +0530 | [diff] [blame] | 3043 | if (ipa_ctx->pending_cons_req) |
Yun Park | e114fbf | 2018-04-05 20:02:12 -0700 | [diff] [blame] | 3044 | wlan_ipa_wdi_rm_notify_completion( |
Sravan Kumar Kairam | 7d931ff | 2018-03-13 09:42:02 +0530 | [diff] [blame] | 3045 | QDF_IPA_RM_RESOURCE_GRANTED, |
| 3046 | QDF_IPA_RM_RESOURCE_WLAN_CONS); |
| 3047 | ipa_ctx->pending_cons_req = false; |
| 3048 | } |
| 3049 | qdf_mutex_release(&ipa_ctx->ipa_lock); |
| 3050 | } else if ((msg->op_code == WLAN_IPA_UC_OPCODE_TX_SUSPEND) || |
| 3051 | (msg->op_code == WLAN_IPA_UC_OPCODE_RX_SUSPEND)) { |
| 3052 | qdf_mutex_acquire(&ipa_ctx->ipa_lock); |
Sravan Kumar Kairam | a61e5a9 | 2018-06-18 13:01:05 +0530 | [diff] [blame] | 3053 | |
| 3054 | if (msg->op_code == WLAN_IPA_UC_OPCODE_RX_SUSPEND) { |
| 3055 | wlan_ipa_uc_disable_pipes(ipa_ctx); |
| 3056 | ipa_info("Disable FW TX PIPE"); |
| 3057 | cdp_ipa_set_active(ipa_ctx->dp_soc, ipa_ctx->dp_pdev, |
| 3058 | false, true); |
| 3059 | } |
| 3060 | |
Sravan Kumar Kairam | 7d931ff | 2018-03-13 09:42:02 +0530 | [diff] [blame] | 3061 | ipa_ctx->activated_fw_pipe--; |
| 3062 | if (!ipa_ctx->activated_fw_pipe) { |
| 3063 | /* |
| 3064 | * Async return success from FW |
| 3065 | * Disable/suspend all the PIPEs |
| 3066 | */ |
| 3067 | ipa_ctx->resource_unloading = false; |
| 3068 | qdf_event_set(&ipa_ctx->ipa_resource_comp); |
Sravan Kumar Kairam | 7d931ff | 2018-03-13 09:42:02 +0530 | [diff] [blame] | 3069 | if (wlan_ipa_is_rm_enabled(ipa_ctx->config)) |
Yun Park | e114fbf | 2018-04-05 20:02:12 -0700 | [diff] [blame] | 3070 | wlan_ipa_wdi_rm_release_resource(ipa_ctx, |
| 3071 | QDF_IPA_RM_RESOURCE_WLAN_PROD); |
Sravan Kumar Kairam | 5214f65 | 2018-03-13 09:52:31 +0530 | [diff] [blame] | 3072 | wlan_ipa_uc_proc_pending_event(ipa_ctx, false); |
Sravan Kumar Kairam | 7d931ff | 2018-03-13 09:42:02 +0530 | [diff] [blame] | 3073 | ipa_ctx->pending_cons_req = false; |
| 3074 | } |
| 3075 | qdf_mutex_release(&ipa_ctx->ipa_lock); |
| 3076 | } else if ((msg->op_code == WLAN_IPA_UC_OPCODE_STATS) && |
| 3077 | (ipa_ctx->stat_req_reason == WLAN_IPA_UC_STAT_REASON_DEBUG)) { |
| 3078 | uc_fw_stat = (struct ipa_uc_fw_stats *) |
| 3079 | ((uint8_t *)op_msg + sizeof(struct op_msg_type)); |
| 3080 | |
| 3081 | /* WLAN FW WDI stats */ |
| 3082 | wlan_ipa_print_fw_wdi_stats(ipa_ctx, uc_fw_stat); |
| 3083 | } else if ((msg->op_code == WLAN_IPA_UC_OPCODE_STATS) && |
| 3084 | (ipa_ctx->stat_req_reason == WLAN_IPA_UC_STAT_REASON_BW_CAL)) { |
| 3085 | /* STATs from FW */ |
| 3086 | uc_fw_stat = (struct ipa_uc_fw_stats *) |
| 3087 | ((uint8_t *)op_msg + sizeof(struct op_msg_type)); |
| 3088 | qdf_mutex_acquire(&ipa_ctx->ipa_lock); |
| 3089 | ipa_ctx->ipa_tx_packets_diff = BW_GET_DIFF( |
| 3090 | uc_fw_stat->tx_pkts_completed, |
| 3091 | ipa_ctx->ipa_p_tx_packets); |
| 3092 | ipa_ctx->ipa_rx_packets_diff = BW_GET_DIFF( |
| 3093 | (uc_fw_stat->rx_num_ind_drop_no_space + |
| 3094 | uc_fw_stat->rx_num_ind_drop_no_buf + |
| 3095 | uc_fw_stat->rx_num_pkts_indicated), |
| 3096 | ipa_ctx->ipa_p_rx_packets); |
| 3097 | |
| 3098 | ipa_ctx->ipa_p_tx_packets = uc_fw_stat->tx_pkts_completed; |
| 3099 | ipa_ctx->ipa_p_rx_packets = |
| 3100 | (uc_fw_stat->rx_num_ind_drop_no_space + |
| 3101 | uc_fw_stat->rx_num_ind_drop_no_buf + |
| 3102 | uc_fw_stat->rx_num_pkts_indicated); |
| 3103 | qdf_mutex_release(&ipa_ctx->ipa_lock); |
| 3104 | } else if (msg->op_code == WLAN_IPA_UC_OPCODE_UC_READY) { |
| 3105 | qdf_mutex_acquire(&ipa_ctx->ipa_lock); |
| 3106 | wlan_ipa_uc_loaded_handler(ipa_ctx); |
| 3107 | qdf_mutex_release(&ipa_ctx->ipa_lock); |
| 3108 | } else if (wlan_ipa_uc_op_metering(ipa_ctx, op_msg)) { |
| 3109 | ipa_err("Invalid message: op_code=%d, reason=%d", |
| 3110 | msg->op_code, ipa_ctx->stat_req_reason); |
| 3111 | } |
| 3112 | |
| 3113 | qdf_mem_free(op_msg); |
| 3114 | } |
| 3115 | |
| 3116 | /** |
jitiphil | fdcaaba | 2018-09-03 16:19:52 +0530 | [diff] [blame] | 3117 | * __wlan_ipa_uc_fw_op_event_handler - IPA uC FW OPvent handler |
| 3118 | * @data: uC OP work |
Sravan Kumar Kairam | 7d931ff | 2018-03-13 09:42:02 +0530 | [diff] [blame] | 3119 | * |
| 3120 | * Return: None |
| 3121 | */ |
jitiphil | fdcaaba | 2018-09-03 16:19:52 +0530 | [diff] [blame] | 3122 | static void __wlan_ipa_uc_fw_op_event_handler(void *data) |
Sravan Kumar Kairam | 7d931ff | 2018-03-13 09:42:02 +0530 | [diff] [blame] | 3123 | { |
| 3124 | struct op_msg_type *msg; |
| 3125 | struct uc_op_work_struct *uc_op_work = |
| 3126 | (struct uc_op_work_struct *)data; |
| 3127 | struct wlan_ipa_priv *ipa_ctx = gp_ipa; |
| 3128 | |
| 3129 | msg = uc_op_work->msg; |
| 3130 | uc_op_work->msg = NULL; |
| 3131 | ipa_debug("posted msg %d", msg->op_code); |
| 3132 | |
| 3133 | wlan_ipa_uc_op_cb(msg, ipa_ctx); |
| 3134 | } |
| 3135 | |
| 3136 | /** |
jitiphil | fdcaaba | 2018-09-03 16:19:52 +0530 | [diff] [blame] | 3137 | * wlan_ipa_uc_fw_op_event_handler - SSR wrapper for |
| 3138 | * __wlan_ipa_uc_fw_op_event_handler |
| 3139 | * @data: uC OP work |
| 3140 | * |
| 3141 | * Return: None |
| 3142 | */ |
| 3143 | static void wlan_ipa_uc_fw_op_event_handler(void *data) |
| 3144 | { |
Dustin Brown | 3fdaaf6 | 2019-03-18 14:00:16 -0700 | [diff] [blame] | 3145 | struct qdf_op_sync *op_sync; |
| 3146 | |
| 3147 | if (qdf_op_protect(&op_sync)) |
| 3148 | return; |
| 3149 | |
jitiphil | fdcaaba | 2018-09-03 16:19:52 +0530 | [diff] [blame] | 3150 | __wlan_ipa_uc_fw_op_event_handler(data); |
Dustin Brown | 3fdaaf6 | 2019-03-18 14:00:16 -0700 | [diff] [blame] | 3151 | |
| 3152 | qdf_op_unprotect(op_sync); |
jitiphil | fdcaaba | 2018-09-03 16:19:52 +0530 | [diff] [blame] | 3153 | } |
| 3154 | |
| 3155 | /** |
Sravan Kumar Kairam | 7d931ff | 2018-03-13 09:42:02 +0530 | [diff] [blame] | 3156 | * wlan_ipa_uc_op_event_handler() - IPA UC OP event handler |
| 3157 | * @op_msg: operation message received from firmware |
| 3158 | * @ipa_ctx: Global IPA context |
| 3159 | * |
| 3160 | * Return: None |
| 3161 | */ |
| 3162 | static void wlan_ipa_uc_op_event_handler(uint8_t *op_msg, void *ctx) |
| 3163 | { |
| 3164 | struct wlan_ipa_priv *ipa_ctx = (struct wlan_ipa_priv *)ctx; |
| 3165 | struct op_msg_type *msg; |
| 3166 | struct uc_op_work_struct *uc_op_work; |
| 3167 | |
| 3168 | if (!ipa_ctx) |
| 3169 | goto end; |
| 3170 | |
| 3171 | msg = (struct op_msg_type *)op_msg; |
| 3172 | |
| 3173 | if (msg->op_code >= WLAN_IPA_UC_OPCODE_MAX) { |
| 3174 | ipa_err("Invalid OP Code (%d)", msg->op_code); |
| 3175 | goto end; |
| 3176 | } |
| 3177 | |
| 3178 | uc_op_work = &ipa_ctx->uc_op_work[msg->op_code]; |
| 3179 | if (uc_op_work->msg) { |
| 3180 | /* When the same uC OPCODE is already pended, just return */ |
| 3181 | goto end; |
| 3182 | } |
| 3183 | |
| 3184 | uc_op_work->msg = msg; |
| 3185 | qdf_sched_work(0, &uc_op_work->work); |
| 3186 | return; |
| 3187 | |
| 3188 | end: |
| 3189 | qdf_mem_free(op_msg); |
| 3190 | } |
| 3191 | |
Sravan Kumar Kairam | 1309e7e | 2018-03-13 09:29:52 +0530 | [diff] [blame] | 3192 | QDF_STATUS wlan_ipa_uc_ol_init(struct wlan_ipa_priv *ipa_ctx, |
| 3193 | qdf_device_t osdev) |
| 3194 | { |
| 3195 | uint8_t i; |
| 3196 | QDF_STATUS status = QDF_STATUS_SUCCESS; |
| 3197 | |
| 3198 | if (!wlan_ipa_uc_is_enabled(ipa_ctx->config)) |
| 3199 | return QDF_STATUS_SUCCESS; |
| 3200 | |
| 3201 | ipa_debug("enter"); |
| 3202 | |
Sravan Kumar Kairam | 02a761e | 2019-07-05 17:06:27 +0530 | [diff] [blame] | 3203 | if (!osdev) { |
| 3204 | ipa_err("osdev null"); |
| 3205 | status = QDF_STATUS_E_FAILURE; |
| 3206 | goto fail_return; |
| 3207 | } |
| 3208 | |
Sravan Kumar Kairam | 1309e7e | 2018-03-13 09:29:52 +0530 | [diff] [blame] | 3209 | for (i = 0; i < WLAN_IPA_MAX_SESSION; i++) { |
| 3210 | ipa_ctx->vdev_to_iface[i] = WLAN_IPA_MAX_SESSION; |
| 3211 | ipa_ctx->vdev_offload_enabled[i] = false; |
| 3212 | } |
| 3213 | |
Sravan Kumar Kairam | 1309e7e | 2018-03-13 09:29:52 +0530 | [diff] [blame] | 3214 | if (cdp_ipa_get_resource(ipa_ctx->dp_soc, ipa_ctx->dp_pdev)) { |
| 3215 | ipa_err("IPA UC resource alloc fail"); |
| 3216 | status = QDF_STATUS_E_FAILURE; |
| 3217 | goto fail_return; |
| 3218 | } |
| 3219 | |
| 3220 | if (true == ipa_ctx->uc_loaded) { |
| 3221 | status = wlan_ipa_wdi_setup(ipa_ctx, osdev); |
| 3222 | if (status) { |
| 3223 | ipa_err("Failure to setup IPA pipes (status=%d)", |
| 3224 | status); |
| 3225 | status = QDF_STATUS_E_FAILURE; |
| 3226 | goto fail_return; |
| 3227 | } |
| 3228 | |
| 3229 | cdp_ipa_set_doorbell_paddr(ipa_ctx->dp_soc, ipa_ctx->dp_pdev); |
| 3230 | wlan_ipa_init_metering(ipa_ctx); |
jiad | f977118 | 2018-06-12 12:43:40 +0800 | [diff] [blame] | 3231 | |
| 3232 | if (wlan_ipa_init_perf_level(ipa_ctx) != QDF_STATUS_SUCCESS) |
| 3233 | ipa_err("Failed to init perf level"); |
Sravan Kumar Kairam | 1309e7e | 2018-03-13 09:29:52 +0530 | [diff] [blame] | 3234 | } |
| 3235 | |
Sravan Kumar Kairam | 7d931ff | 2018-03-13 09:42:02 +0530 | [diff] [blame] | 3236 | cdp_ipa_register_op_cb(ipa_ctx->dp_soc, ipa_ctx->dp_pdev, |
| 3237 | wlan_ipa_uc_op_event_handler, (void *)ipa_ctx); |
| 3238 | |
| 3239 | for (i = 0; i < WLAN_IPA_UC_OPCODE_MAX; i++) { |
| 3240 | qdf_create_work(0, &ipa_ctx->uc_op_work[i].work, |
| 3241 | wlan_ipa_uc_fw_op_event_handler, |
| 3242 | &ipa_ctx->uc_op_work[i]); |
| 3243 | ipa_ctx->uc_op_work[i].msg = NULL; |
| 3244 | } |
| 3245 | |
Sravan Kumar Kairam | 1309e7e | 2018-03-13 09:29:52 +0530 | [diff] [blame] | 3246 | fail_return: |
| 3247 | ipa_debug("exit: status=%d", status); |
| 3248 | return status; |
| 3249 | } |
| 3250 | |
Sravan Kumar Kairam | 7d931ff | 2018-03-13 09:42:02 +0530 | [diff] [blame] | 3251 | /** |
| 3252 | * wlan_ipa_cleanup_pending_event() - Cleanup IPA pending event list |
| 3253 | * @ipa_ctx: pointer to IPA IPA struct |
| 3254 | * |
| 3255 | * Return: none |
| 3256 | */ |
| 3257 | static void wlan_ipa_cleanup_pending_event(struct wlan_ipa_priv *ipa_ctx) |
| 3258 | { |
| 3259 | struct wlan_ipa_uc_pending_event *pending_event = NULL; |
| 3260 | |
| 3261 | while (qdf_list_remove_front(&ipa_ctx->pending_event, |
| 3262 | (qdf_list_node_t **)&pending_event) == QDF_STATUS_SUCCESS) |
| 3263 | qdf_mem_free(pending_event); |
| 3264 | } |
| 3265 | |
Sravan Kumar Kairam | 1309e7e | 2018-03-13 09:29:52 +0530 | [diff] [blame] | 3266 | QDF_STATUS wlan_ipa_uc_ol_deinit(struct wlan_ipa_priv *ipa_ctx) |
| 3267 | { |
| 3268 | QDF_STATUS status = QDF_STATUS_SUCCESS; |
Sravan Kumar Kairam | 7d931ff | 2018-03-13 09:42:02 +0530 | [diff] [blame] | 3269 | int i; |
Sravan Kumar Kairam | 1309e7e | 2018-03-13 09:29:52 +0530 | [diff] [blame] | 3270 | |
| 3271 | ipa_debug("enter"); |
| 3272 | |
| 3273 | if (!wlan_ipa_uc_is_enabled(ipa_ctx->config)) |
| 3274 | return status; |
| 3275 | |
| 3276 | if (!ipa_ctx->ipa_pipes_down) |
| 3277 | wlan_ipa_uc_disable_pipes(ipa_ctx); |
| 3278 | |
| 3279 | if (true == ipa_ctx->uc_loaded) { |
| 3280 | status = cdp_ipa_cleanup(ipa_ctx->dp_soc, |
| 3281 | ipa_ctx->tx_pipe_handle, |
| 3282 | ipa_ctx->rx_pipe_handle); |
| 3283 | if (status) |
| 3284 | ipa_err("Failure to cleanup IPA pipes (status=%d)", |
| 3285 | status); |
| 3286 | } |
| 3287 | |
Sravan Kumar Kairam | 7d931ff | 2018-03-13 09:42:02 +0530 | [diff] [blame] | 3288 | qdf_mutex_acquire(&ipa_ctx->ipa_lock); |
| 3289 | wlan_ipa_cleanup_pending_event(ipa_ctx); |
| 3290 | qdf_mutex_release(&ipa_ctx->ipa_lock); |
| 3291 | |
| 3292 | for (i = 0; i < WLAN_IPA_UC_OPCODE_MAX; i++) { |
| 3293 | qdf_cancel_work(&ipa_ctx->uc_op_work[i].work); |
| 3294 | qdf_mem_free(ipa_ctx->uc_op_work[i].msg); |
| 3295 | ipa_ctx->uc_op_work[i].msg = NULL; |
| 3296 | } |
| 3297 | |
Sravan Kumar Kairam | 1309e7e | 2018-03-13 09:29:52 +0530 | [diff] [blame] | 3298 | ipa_debug("exit: ret=%d", status); |
| 3299 | return status; |
| 3300 | } |
Sravan Kumar Kairam | 983a445 | 2018-03-20 13:30:22 +0530 | [diff] [blame] | 3301 | |
Sravan Kumar Kairam | ce792eb | 2018-06-15 15:07:11 +0530 | [diff] [blame] | 3302 | /** |
| 3303 | * wlan_ipa_uc_send_evt() - send event to ipa |
| 3304 | * @net_dev: Interface net device |
| 3305 | * @type: event type |
| 3306 | * @mac_addr: pointer to mac address |
| 3307 | * |
| 3308 | * Send event to IPA driver |
| 3309 | * |
| 3310 | * Return: QDF_STATUS |
| 3311 | */ |
| 3312 | static QDF_STATUS wlan_ipa_uc_send_evt(qdf_netdev_t net_dev, |
| 3313 | qdf_ipa_wlan_event type, |
| 3314 | uint8_t *mac_addr) |
| 3315 | { |
| 3316 | struct wlan_ipa_priv *ipa_ctx = gp_ipa; |
| 3317 | qdf_ipa_msg_meta_t meta; |
| 3318 | qdf_ipa_wlan_msg_t *msg; |
| 3319 | |
| 3320 | QDF_IPA_MSG_META_MSG_LEN(&meta) = sizeof(qdf_ipa_wlan_msg_t); |
| 3321 | msg = qdf_mem_malloc(QDF_IPA_MSG_META_MSG_LEN(&meta)); |
| 3322 | if (!msg) { |
| 3323 | ipa_err("msg allocation failed"); |
| 3324 | return QDF_STATUS_E_NOMEM; |
| 3325 | } |
| 3326 | |
| 3327 | QDF_IPA_SET_META_MSG_TYPE(&meta, type); |
| 3328 | qdf_str_lcopy(QDF_IPA_WLAN_MSG_NAME(msg), net_dev->name, |
| 3329 | IPA_RESOURCE_NAME_MAX); |
| 3330 | qdf_mem_copy(QDF_IPA_WLAN_MSG_MAC_ADDR(msg), mac_addr, QDF_NET_ETH_LEN); |
| 3331 | |
| 3332 | if (qdf_ipa_send_msg(&meta, msg, wlan_ipa_msg_free_fn)) { |
| 3333 | ipa_err("%s: Evt: %d fail", |
| 3334 | QDF_IPA_WLAN_MSG_NAME(msg), |
| 3335 | QDF_IPA_MSG_META_MSG_TYPE(&meta)); |
| 3336 | qdf_mem_free(msg); |
| 3337 | |
| 3338 | return QDF_STATUS_E_FAILURE; |
| 3339 | } |
| 3340 | |
| 3341 | ipa_ctx->stats.num_send_msg++; |
| 3342 | |
| 3343 | return QDF_STATUS_SUCCESS; |
| 3344 | } |
| 3345 | |
Vevek Venkatesan | e81bca8 | 2019-08-12 22:25:15 +0530 | [diff] [blame^] | 3346 | void wlan_ipa_uc_cleanup_sta(struct wlan_ipa_priv *ipa_ctx, |
| 3347 | qdf_netdev_t net_dev) |
| 3348 | { |
| 3349 | struct wlan_ipa_iface_context *iface_ctx; |
| 3350 | int i; |
| 3351 | |
| 3352 | ipa_debug("enter"); |
| 3353 | |
| 3354 | for (i = 0; i < WLAN_IPA_MAX_IFACE; i++) { |
| 3355 | iface_ctx = &ipa_ctx->iface_context[i]; |
| 3356 | if (iface_ctx && iface_ctx->device_mode == QDF_STA_MODE && |
| 3357 | iface_ctx->dev == net_dev && iface_ctx->tl_context) { |
| 3358 | wlan_ipa_uc_send_evt(net_dev, QDF_IPA_STA_DISCONNECT, |
| 3359 | net_dev->dev_addr); |
| 3360 | wlan_ipa_cleanup_iface(iface_ctx); |
| 3361 | } |
| 3362 | } |
| 3363 | |
| 3364 | ipa_debug("exit"); |
| 3365 | } |
| 3366 | |
Sravan Kumar Kairam | ce792eb | 2018-06-15 15:07:11 +0530 | [diff] [blame] | 3367 | QDF_STATUS wlan_ipa_uc_disconnect_ap(struct wlan_ipa_priv *ipa_ctx, |
| 3368 | qdf_netdev_t net_dev) |
| 3369 | { |
| 3370 | struct wlan_ipa_iface_context *iface_ctx; |
| 3371 | QDF_STATUS status; |
| 3372 | |
| 3373 | ipa_debug("enter"); |
| 3374 | |
| 3375 | iface_ctx = wlan_ipa_get_iface(ipa_ctx, QDF_SAP_MODE); |
| 3376 | if (iface_ctx) |
| 3377 | status = wlan_ipa_uc_send_evt(net_dev, QDF_IPA_AP_DISCONNECT, |
| 3378 | net_dev->dev_addr); |
| 3379 | else |
| 3380 | return QDF_STATUS_E_INVAL; |
| 3381 | |
| 3382 | ipa_debug("exit :%d", status); |
| 3383 | |
| 3384 | return status; |
| 3385 | } |
| 3386 | |
| 3387 | void wlan_ipa_cleanup_dev_iface(struct wlan_ipa_priv *ipa_ctx, |
| 3388 | qdf_netdev_t net_dev) |
| 3389 | { |
| 3390 | struct wlan_ipa_iface_context *iface_ctx; |
| 3391 | int i; |
| 3392 | |
| 3393 | for (i = 0; i < WLAN_IPA_MAX_IFACE; i++) { |
| 3394 | iface_ctx = &ipa_ctx->iface_context[i]; |
| 3395 | if (iface_ctx->dev == net_dev) |
| 3396 | break; |
| 3397 | } |
| 3398 | |
| 3399 | if (iface_ctx) |
| 3400 | wlan_ipa_cleanup_iface(iface_ctx); |
| 3401 | } |
Sravan Kumar Kairam | 657f89e | 2018-09-18 10:13:37 +0530 | [diff] [blame] | 3402 | |
| 3403 | void wlan_ipa_uc_ssr_cleanup(struct wlan_ipa_priv *ipa_ctx) |
| 3404 | { |
| 3405 | struct wlan_ipa_iface_context *iface; |
| 3406 | int i; |
| 3407 | |
| 3408 | ipa_info("enter"); |
| 3409 | |
| 3410 | for (i = 0; i < WLAN_IPA_MAX_IFACE; i++) { |
| 3411 | iface = &ipa_ctx->iface_context[i]; |
| 3412 | if (iface->dev) { |
| 3413 | if (iface->device_mode == QDF_SAP_MODE) |
| 3414 | wlan_ipa_uc_send_evt(iface->dev, |
| 3415 | QDF_IPA_AP_DISCONNECT, |
| 3416 | iface->dev->dev_addr); |
| 3417 | else if (iface->device_mode == QDF_STA_MODE) |
| 3418 | wlan_ipa_uc_send_evt(iface->dev, |
| 3419 | QDF_IPA_STA_DISCONNECT, |
| 3420 | iface->dev->dev_addr); |
| 3421 | wlan_ipa_cleanup_iface(iface); |
| 3422 | } |
| 3423 | } |
| 3424 | } |
jitiphil | 0e3b592 | 2018-07-24 18:43:50 +0530 | [diff] [blame] | 3425 | |
| 3426 | void wlan_ipa_fw_rejuvenate_send_msg(struct wlan_ipa_priv *ipa_ctx) |
| 3427 | { |
| 3428 | qdf_ipa_msg_meta_t meta; |
| 3429 | qdf_ipa_wlan_msg_t *msg; |
| 3430 | int ret; |
| 3431 | |
| 3432 | meta.msg_len = sizeof(*msg); |
| 3433 | msg = qdf_mem_malloc(meta.msg_len); |
| 3434 | if (!msg) { |
| 3435 | ipa_debug("msg allocation failed"); |
| 3436 | return; |
| 3437 | } |
| 3438 | |
| 3439 | QDF_IPA_SET_META_MSG_TYPE(&meta, QDF_FWR_SSR_BEFORE_SHUTDOWN); |
| 3440 | ipa_debug("ipa_send_msg(Evt:%d)", |
| 3441 | meta.msg_type); |
| 3442 | ret = qdf_ipa_send_msg(&meta, msg, wlan_ipa_msg_free_fn); |
| 3443 | |
| 3444 | if (ret) { |
| 3445 | ipa_err("ipa_send_msg(Evt:%d)-fail=%d", |
| 3446 | meta.msg_type, ret); |
| 3447 | qdf_mem_free(msg); |
| 3448 | } |
| 3449 | ipa_ctx->stats.num_send_msg++; |
| 3450 | } |