Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1 | /* |
Kabilan Kannan | 973744a | 2018-01-03 10:28:50 -0800 | [diff] [blame] | 2 | * Copyright (c) 2012-2018 The Linux Foundation. All rights reserved. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3 | * |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [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 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19 | /** |
| 20 | * DOC: cds_api.c |
| 21 | * |
| 22 | * Connectivity driver services APIs |
| 23 | */ |
| 24 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 25 | #include <cds_api.h> |
| 26 | #include "sir_types.h" |
| 27 | #include "sir_api.h" |
| 28 | #include "sir_mac_prot_def.h" |
| 29 | #include "sme_api.h" |
| 30 | #include "mac_init_api.h" |
| 31 | #include "wlan_qct_sys.h" |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 32 | #include "i_cds_packet.h" |
| 33 | #include "cds_reg_service.h" |
| 34 | #include "wma_types.h" |
| 35 | #include "wlan_hdd_main.h" |
Jeff Johnson | 7b3c98f | 2018-07-08 20:52:37 -0700 | [diff] [blame] | 36 | #include "wlan_hdd_power.h" |
Yu Wang | 66a250b | 2017-07-19 11:46:40 +0800 | [diff] [blame] | 37 | #include "wlan_hdd_tsf.h" |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 38 | #include <linux/vmalloc.h> |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 39 | |
Yuanyuan Liu | 0e0aa93 | 2016-05-12 10:17:58 -0700 | [diff] [blame] | 40 | #include "pld_common.h" |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 41 | #include "sap_api.h" |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 42 | #include "bmi.h" |
| 43 | #include "ol_fw.h" |
| 44 | #include "ol_if_athvar.h" |
| 45 | #include "hif.h" |
Tushnim Bhattacharyya | 12b4874 | 2017-03-13 12:46:45 -0700 | [diff] [blame] | 46 | #include "wlan_policy_mgr_api.h" |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 47 | #include "cds_utils.h" |
| 48 | #include "wlan_logging_sock_svc.h" |
| 49 | #include "wma.h" |
Nirav Shah | 7f337db | 2016-05-25 10:49:02 +0530 | [diff] [blame] | 50 | #include "pktlog_ac.h" |
Pramod Simha | 0d3b936 | 2017-03-27 14:59:58 -0700 | [diff] [blame] | 51 | #include "wlan_policy_mgr_api.h" |
Leo Chang | 9b09703 | 2016-10-28 11:03:17 -0700 | [diff] [blame] | 52 | |
| 53 | #include <cdp_txrx_cmn_reg.h> |
| 54 | #include <cdp_txrx_cfg.h> |
| 55 | #include <cdp_txrx_misc.h> |
Rajeev Kumar | 97767a0 | 2016-11-30 11:20:40 -0800 | [diff] [blame] | 56 | #include <dispatcher_init_deinit.h> |
Venkata Sharath Chandra Manchala | 0d44d45 | 2016-11-23 17:48:15 -0800 | [diff] [blame] | 57 | #include <cdp_txrx_handle.h> |
Govind Singh | 27a7403 | 2017-11-10 15:08:19 +0530 | [diff] [blame] | 58 | #include "target_type.h" |
Zhang Qian | 47e22ce | 2018-01-04 15:38:38 +0800 | [diff] [blame] | 59 | #include "wlan_ocb_ucfg_api.h" |
Sravan Kumar Kairam | d01b445 | 2018-03-07 17:37:09 +0530 | [diff] [blame] | 60 | #include "wlan_ipa_ucfg_api.h" |
Venkata Sharath Chandra Manchala | 0d44d45 | 2016-11-23 17:48:15 -0800 | [diff] [blame] | 61 | |
Himanshu Agarwal | edf30dc | 2017-06-05 15:54:27 +0530 | [diff] [blame] | 62 | #ifdef ENABLE_SMMU_S1_TRANSLATION |
| 63 | #include "pld_common.h" |
| 64 | #include <asm/dma-iommu.h> |
| 65 | #include <linux/iommu.h> |
| 66 | #endif |
Sravan Kumar Kairam | b8bdf52 | 2018-05-30 22:14:50 +0530 | [diff] [blame^] | 67 | |
| 68 | #ifdef QCA_WIFI_QCA8074 |
| 69 | #include <target_if_dp.h> |
| 70 | #endif |
| 71 | |
Himanshu Agarwal | edf30dc | 2017-06-05 15:54:27 +0530 | [diff] [blame] | 72 | /* Preprocessor Definitions and Constants */ |
| 73 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 74 | /* Preprocessor Definitions and Constants */ |
| 75 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 76 | /* Data definitions */ |
Jeff Johnson | 2b6982c | 2018-05-29 14:56:11 -0700 | [diff] [blame] | 77 | static struct cds_context g_cds_context; |
| 78 | static struct cds_context *gp_cds_context; |
Anurag Chouhan | df2b268 | 2016-02-29 14:15:27 +0530 | [diff] [blame] | 79 | static struct __qdf_device g_qdf_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 80 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 81 | static uint8_t cds_multicast_logging; |
| 82 | |
Sravan Kumar Kairam | b8bdf52 | 2018-05-30 22:14:50 +0530 | [diff] [blame^] | 83 | #ifdef QCA_WIFI_QCA8074 |
Leo Chang | 9b09703 | 2016-10-28 11:03:17 -0700 | [diff] [blame] | 84 | static struct ol_if_ops dp_ol_if_ops = { |
Sravan Kumar Kairam | b8bdf52 | 2018-05-30 22:14:50 +0530 | [diff] [blame^] | 85 | .peer_set_default_routing = target_if_peer_set_default_routing, |
| 86 | .peer_rx_reorder_queue_setup = target_if_peer_rx_reorder_queue_setup, |
| 87 | .peer_rx_reorder_queue_remove = target_if_peer_rx_reorder_queue_remove, |
Dhanashri Atre | f5e0212 | 2017-04-13 15:36:42 -0700 | [diff] [blame] | 88 | .is_hw_dbs_2x2_capable = policy_mgr_is_hw_dbs_2x2_capable, |
Sravan Kumar Kairam | b8bdf52 | 2018-05-30 22:14:50 +0530 | [diff] [blame^] | 89 | .lro_hash_config = target_if_lro_hash_config, |
jiad | cd49ec7 | 2017-12-05 13:33:11 +0800 | [diff] [blame] | 90 | .rx_mic_error = wma_rx_mic_error_ind |
Leo Chang | 9b09703 | 2016-10-28 11:03:17 -0700 | [diff] [blame] | 91 | /* TODO: Add any other control path calls required to OL_IF/WMA layer */ |
| 92 | }; |
Sravan Kumar Kairam | b8bdf52 | 2018-05-30 22:14:50 +0530 | [diff] [blame^] | 93 | #else |
| 94 | static struct ol_if_ops dp_ol_if_ops; |
| 95 | #endif |
Leo Chang | 9b09703 | 2016-10-28 11:03:17 -0700 | [diff] [blame] | 96 | |
Srinivas Girigowda | 161b9f2 | 2017-07-24 17:38:09 -0700 | [diff] [blame] | 97 | static void cds_trigger_recovery_work(void *param); |
| 98 | |
| 99 | /** |
| 100 | * cds_recovery_work_init() - Initialize recovery work queue |
| 101 | * |
| 102 | * Return: none |
| 103 | */ |
| 104 | static QDF_STATUS cds_recovery_work_init(void) |
| 105 | { |
| 106 | qdf_create_work(0, &gp_cds_context->cds_recovery_work, |
| 107 | cds_trigger_recovery_work, NULL); |
| 108 | gp_cds_context->cds_recovery_wq = |
| 109 | qdf_create_workqueue("cds_recovery_workqueue"); |
| 110 | if (NULL == gp_cds_context->cds_recovery_wq) { |
| 111 | cds_err("Failed to create cds_recovery_workqueue"); |
| 112 | return QDF_STATUS_E_FAILURE; |
| 113 | } |
| 114 | |
| 115 | return QDF_STATUS_SUCCESS; |
| 116 | } |
| 117 | |
| 118 | /** |
| 119 | * cds_recovery_work_deinit() - Initialize recovery work queue |
| 120 | * |
| 121 | * Return: none |
| 122 | */ |
| 123 | static void cds_recovery_work_deinit(void) |
| 124 | { |
| 125 | if (gp_cds_context->cds_recovery_wq) { |
| 126 | qdf_flush_workqueue(0, gp_cds_context->cds_recovery_wq); |
| 127 | qdf_destroy_workqueue(0, gp_cds_context->cds_recovery_wq); |
| 128 | } |
| 129 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 130 | |
Venkata Sharath Chandra Manchala | 8398563 | 2017-02-28 14:16:22 -0800 | [diff] [blame] | 131 | /** cds_get_datapath_handles - Initialize pdev, vdev and soc |
| 132 | * @soc - soc handle |
| 133 | * @vdev - virtual handle |
| 134 | * @pdev - physical handle |
| 135 | */ |
| 136 | uint8_t cds_get_datapath_handles(void **soc, struct cdp_pdev **pdev, |
| 137 | struct cdp_vdev **vdev, uint8_t sessionId) |
| 138 | { |
| 139 | |
| 140 | (*soc) = cds_get_context(QDF_MODULE_ID_SOC); |
| 141 | |
| 142 | if (!(*soc)) { |
Jeff Johnson | d0a6b2c | 2018-05-30 22:57:39 -0700 | [diff] [blame] | 143 | cds_err("soc handle is invalid"); |
Venkata Sharath Chandra Manchala | 8398563 | 2017-02-28 14:16:22 -0800 | [diff] [blame] | 144 | return -EINVAL; |
| 145 | } |
| 146 | |
| 147 | (*pdev) = cds_get_context(QDF_MODULE_ID_TXRX); |
| 148 | |
| 149 | if (!(*pdev)) { |
Jeff Johnson | d0a6b2c | 2018-05-30 22:57:39 -0700 | [diff] [blame] | 150 | cds_err("pdev handle is invalid"); |
Venkata Sharath Chandra Manchala | 8398563 | 2017-02-28 14:16:22 -0800 | [diff] [blame] | 151 | return -EINVAL; |
| 152 | } |
| 153 | |
| 154 | (*vdev) = cdp_get_vdev_from_vdev_id((*soc), (*pdev), |
| 155 | sessionId); |
| 156 | |
| 157 | if (!(*vdev)) { |
Jeff Johnson | d0a6b2c | 2018-05-30 22:57:39 -0700 | [diff] [blame] | 158 | cds_err("vdev handle is invalid"); |
Venkata Sharath Chandra Manchala | 8398563 | 2017-02-28 14:16:22 -0800 | [diff] [blame] | 159 | return -EINVAL; |
| 160 | } |
| 161 | return 0; |
| 162 | } |
| 163 | |
| 164 | |
Jeff Johnson | 7aaeeea | 2017-09-26 13:16:24 -0700 | [diff] [blame] | 165 | QDF_STATUS cds_init(void) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 166 | { |
wadesong | ae4ffd1 | 2017-10-24 16:45:54 +0800 | [diff] [blame] | 167 | QDF_STATUS ret; |
| 168 | |
| 169 | ret = qdf_debugfs_init(); |
Rajeev Kumar | 3f5c593 | 2018-03-09 13:14:46 -0800 | [diff] [blame] | 170 | if (ret != QDF_STATUS_SUCCESS) |
wadesong | ae4ffd1 | 2017-10-24 16:45:54 +0800 | [diff] [blame] | 171 | cds_err("Failed to init debugfs"); |
wadesong | ae4ffd1 | 2017-10-24 16:45:54 +0800 | [diff] [blame] | 172 | |
Houston Hoffman | 1a77757 | 2017-01-13 12:43:48 -0800 | [diff] [blame] | 173 | qdf_lock_stats_init(); |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 174 | qdf_mem_init(); |
Houston Hoffman | 9e06e54 | 2016-12-12 12:06:26 -0800 | [diff] [blame] | 175 | qdf_mc_timer_manager_init(); |
Nachiket Kukade | 0396b73 | 2017-11-14 16:35:16 +0530 | [diff] [blame] | 176 | qdf_event_list_init(); |
Dustin Brown | a2dcb5f | 2017-10-20 17:36:19 -0700 | [diff] [blame] | 177 | qdf_cpuhp_init(); |
Dustin Brown | 100201e | 2017-07-10 11:48:40 -0700 | [diff] [blame] | 178 | qdf_register_self_recovery_callback(cds_trigger_recovery); |
Rajeev Kumar | 807c5f5 | 2018-03-08 13:29:08 -0800 | [diff] [blame] | 179 | qdf_register_fw_down_callback(cds_is_fw_down); |
Ryan Hsu | d0327d5 | 2018-05-29 15:07:25 -0700 | [diff] [blame] | 180 | qdf_register_ssr_protect_callbacks(cds_ssr_protect, |
| 181 | cds_ssr_unprotect); |
| 182 | qdf_register_module_state_query_callback( |
| 183 | cds_is_module_state_transitioning); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 184 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 185 | gp_cds_context = &g_cds_context; |
| 186 | |
Anurag Chouhan | df2b268 | 2016-02-29 14:15:27 +0530 | [diff] [blame] | 187 | gp_cds_context->qdf_ctx = &g_qdf_ctx; |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 188 | qdf_mem_zero(&g_qdf_ctx, sizeof(g_qdf_ctx)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 189 | |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 190 | qdf_trace_spin_lock_init(); |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 191 | qdf_trace_init(); |
Rachit Kankane | 0baf6e7 | 2018-01-19 15:01:50 +0530 | [diff] [blame] | 192 | |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 193 | qdf_register_debugcb_init(); |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 194 | |
| 195 | cds_ssr_protect_init(); |
| 196 | |
wadesong | ae4ffd1 | 2017-10-24 16:45:54 +0800 | [diff] [blame] | 197 | ret = cds_recovery_work_init(); |
| 198 | if (ret != QDF_STATUS_SUCCESS) { |
| 199 | cds_err("Failed to init recovery work"); |
| 200 | goto deinit; |
| 201 | } |
Srinivas Girigowda | 161b9f2 | 2017-07-24 17:38:09 -0700 | [diff] [blame] | 202 | |
wadesong | ae4ffd1 | 2017-10-24 16:45:54 +0800 | [diff] [blame] | 203 | return QDF_STATUS_SUCCESS; |
| 204 | deinit: |
Rachit Kankane | 45d8b8c | 2018-06-26 19:34:02 +0530 | [diff] [blame] | 205 | qdf_trace_deinit(); |
wadesong | ae4ffd1 | 2017-10-24 16:45:54 +0800 | [diff] [blame] | 206 | qdf_mc_timer_manager_exit(); |
| 207 | qdf_mem_exit(); |
| 208 | qdf_lock_stats_deinit(); |
| 209 | qdf_debugfs_exit(); |
| 210 | gp_cds_context->qdf_ctx = NULL; |
| 211 | gp_cds_context = NULL; |
| 212 | qdf_mem_zero(&g_cds_context, sizeof(g_cds_context)); |
wadesong | ae4ffd1 | 2017-10-24 16:45:54 +0800 | [diff] [blame] | 213 | return ret; |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 214 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 215 | |
| 216 | /** |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 217 | * cds_deinit() - Deinitialize CDS |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 218 | * |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 219 | * This function frees the CDS resources |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 220 | */ |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 221 | void cds_deinit(void) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 222 | { |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 223 | if (gp_cds_context == NULL) |
| 224 | return; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 225 | |
Srinivas Girigowda | 161b9f2 | 2017-07-24 17:38:09 -0700 | [diff] [blame] | 226 | cds_recovery_work_deinit(); |
Rachit Kankane | 45d8b8c | 2018-06-26 19:34:02 +0530 | [diff] [blame] | 227 | qdf_trace_deinit(); |
Dustin Brown | a2dcb5f | 2017-10-20 17:36:19 -0700 | [diff] [blame] | 228 | qdf_cpuhp_deinit(); |
Arunk Khandavalli | 4cc97a9 | 2016-09-14 23:13:07 +0530 | [diff] [blame] | 229 | qdf_mc_timer_manager_exit(); |
| 230 | qdf_mem_exit(); |
Houston Hoffman | 1a77757 | 2017-01-13 12:43:48 -0800 | [diff] [blame] | 231 | qdf_lock_stats_deinit(); |
Mahesh Kumar Kalikot Veetil | 319dbcd | 2016-10-27 15:03:48 -0700 | [diff] [blame] | 232 | qdf_debugfs_exit(); |
Nachiket Kukade | 0396b73 | 2017-11-14 16:35:16 +0530 | [diff] [blame] | 233 | qdf_event_list_destroy(); |
Arunk Khandavalli | 4cc97a9 | 2016-09-14 23:13:07 +0530 | [diff] [blame] | 234 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 235 | gp_cds_context->qdf_ctx = NULL; |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 236 | gp_cds_context = NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 237 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 238 | qdf_mem_zero(&g_cds_context, sizeof(g_cds_context)); |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 239 | return; |
| 240 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 241 | |
Abhishek Singh | 437606a | 2016-04-27 13:51:49 +0530 | [diff] [blame] | 242 | #ifdef FEATURE_WLAN_DIAG_SUPPORT |
| 243 | /** |
| 244 | * cds_tdls_tx_rx_mgmt_event()- send tdls mgmt rx tx event |
| 245 | * @event_id: event id |
| 246 | * @tx_rx: tx or rx |
| 247 | * @type: type of frame |
| 248 | * @action_sub_type: action frame type |
| 249 | * @peer_mac: peer mac |
| 250 | * |
| 251 | * This Function sends tdls mgmt rx tx diag event |
| 252 | * |
| 253 | * Return: void. |
| 254 | */ |
| 255 | void cds_tdls_tx_rx_mgmt_event(uint8_t event_id, uint8_t tx_rx, |
| 256 | uint8_t type, uint8_t action_sub_type, uint8_t *peer_mac) |
| 257 | { |
| 258 | WLAN_HOST_DIAG_EVENT_DEF(tdls_tx_rx_mgmt, |
| 259 | struct host_event_tdls_tx_rx_mgmt); |
| 260 | |
| 261 | tdls_tx_rx_mgmt.event_id = event_id; |
| 262 | tdls_tx_rx_mgmt.tx_rx = tx_rx; |
| 263 | tdls_tx_rx_mgmt.type = type; |
| 264 | tdls_tx_rx_mgmt.action_sub_type = action_sub_type; |
| 265 | qdf_mem_copy(tdls_tx_rx_mgmt.peer_mac, |
| 266 | peer_mac, CDS_MAC_ADDRESS_LEN); |
| 267 | WLAN_HOST_DIAG_EVENT_REPORT(&tdls_tx_rx_mgmt, |
| 268 | EVENT_WLAN_TDLS_TX_RX_MGMT); |
| 269 | } |
| 270 | #endif |
| 271 | |
Leo Chang | 9b09703 | 2016-10-28 11:03:17 -0700 | [diff] [blame] | 272 | /** |
gbian | 62edd7e | 2017-03-07 13:12:13 +0800 | [diff] [blame] | 273 | * cds_cfg_update_ac_specs_params() - update ac_specs params |
| 274 | * @olcfg: cfg handle |
| 275 | * @mac_params: mac params |
| 276 | * |
| 277 | * Return: none |
| 278 | */ |
| 279 | static void |
| 280 | cds_cfg_update_ac_specs_params(struct txrx_pdev_cfg_param_t *olcfg, |
| 281 | struct cds_config_info *cds_cfg) |
| 282 | { |
| 283 | int i; |
| 284 | |
| 285 | if (NULL == olcfg) |
| 286 | return; |
| 287 | |
| 288 | if (NULL == cds_cfg) |
| 289 | return; |
| 290 | |
| 291 | for (i = 0; i < OL_TX_NUM_WMM_AC; i++) { |
| 292 | olcfg->ac_specs[i].wrr_skip_weight = |
| 293 | cds_cfg->ac_specs[i].wrr_skip_weight; |
| 294 | olcfg->ac_specs[i].credit_threshold = |
| 295 | cds_cfg->ac_specs[i].credit_threshold; |
| 296 | olcfg->ac_specs[i].send_limit = |
| 297 | cds_cfg->ac_specs[i].send_limit; |
| 298 | olcfg->ac_specs[i].credit_reserve = |
| 299 | cds_cfg->ac_specs[i].credit_reserve; |
| 300 | olcfg->ac_specs[i].discard_weight = |
| 301 | cds_cfg->ac_specs[i].discard_weight; |
| 302 | } |
| 303 | } |
| 304 | |
Nirav Shah | e6c8e64 | 2018-03-25 11:42:48 +0530 | [diff] [blame] | 305 | #ifdef QCA_LL_TX_FLOW_CONTROL_V2 |
| 306 | static inline void |
| 307 | cds_cdp_set_flow_control_params(struct cds_config_info *cds_cfg, |
| 308 | struct txrx_pdev_cfg_param_t *cdp_cfg) |
| 309 | { |
| 310 | cdp_cfg->tx_flow_stop_queue_th = cds_cfg->tx_flow_stop_queue_th; |
| 311 | cdp_cfg->tx_flow_start_queue_offset = |
| 312 | cds_cfg->tx_flow_start_queue_offset; |
| 313 | } |
| 314 | #else |
| 315 | static inline void |
| 316 | cds_cdp_set_flow_control_params(struct cds_config_info *cds_cfg, |
| 317 | struct txrx_pdev_cfg_param_t *cdp_cfg) |
| 318 | {} |
| 319 | #endif |
| 320 | |
gbian | 62edd7e | 2017-03-07 13:12:13 +0800 | [diff] [blame] | 321 | /** |
Leo Chang | 9b09703 | 2016-10-28 11:03:17 -0700 | [diff] [blame] | 322 | * cds_cdp_cfg_attach() - attach data path config module |
| 323 | * @cds_cfg: generic platform level config instance |
| 324 | * |
| 325 | * Return: none |
| 326 | */ |
| 327 | static void cds_cdp_cfg_attach(struct cds_config_info *cds_cfg) |
| 328 | { |
| 329 | struct txrx_pdev_cfg_param_t cdp_cfg = {0}; |
| 330 | void *soc = cds_get_context(QDF_MODULE_ID_SOC); |
| 331 | |
Kiran Kumar Lokere | 52d8dc3 | 2016-12-05 19:20:40 -0800 | [diff] [blame] | 332 | cdp_cfg.is_full_reorder_offload = cds_cfg->reorder_offload; |
Leo Chang | 9b09703 | 2016-10-28 11:03:17 -0700 | [diff] [blame] | 333 | cdp_cfg.is_uc_offload_enabled = cds_cfg->uc_offload_enabled; |
| 334 | cdp_cfg.uc_tx_buffer_count = cds_cfg->uc_txbuf_count; |
| 335 | cdp_cfg.uc_tx_buffer_size = cds_cfg->uc_txbuf_size; |
| 336 | cdp_cfg.uc_rx_indication_ring_count = cds_cfg->uc_rxind_ringcount; |
| 337 | cdp_cfg.uc_tx_partition_base = cds_cfg->uc_tx_partition_base; |
| 338 | cdp_cfg.enable_rxthread = cds_cfg->enable_rxthread; |
| 339 | cdp_cfg.ip_tcp_udp_checksum_offload = |
| 340 | cds_cfg->ip_tcp_udp_checksum_offload; |
| 341 | cdp_cfg.ce_classify_enabled = cds_cfg->ce_classify_enabled; |
| 342 | |
gbian | 62edd7e | 2017-03-07 13:12:13 +0800 | [diff] [blame] | 343 | cds_cfg_update_ac_specs_params(&cdp_cfg, cds_cfg); |
Kiran Kumar Lokere | 9aecfee | 2016-11-23 17:37:42 -0800 | [diff] [blame] | 344 | gp_cds_context->cfg_ctx = cdp_cfg_attach(soc, gp_cds_context->qdf_ctx, |
| 345 | (void *)(&cdp_cfg)); |
| 346 | if (!gp_cds_context->cfg_ctx) { |
| 347 | WMA_LOGP("%s: failed to init cfg handle", __func__); |
| 348 | return; |
| 349 | } |
| 350 | |
Leo Chang | 9b09703 | 2016-10-28 11:03:17 -0700 | [diff] [blame] | 351 | /* Configure Receive flow steering */ |
Venkata Sharath Chandra Manchala | 0d44d45 | 2016-11-23 17:48:15 -0800 | [diff] [blame] | 352 | cdp_cfg_set_flow_steering(soc, gp_cds_context->cfg_ctx, |
Leo Chang | 9b09703 | 2016-10-28 11:03:17 -0700 | [diff] [blame] | 353 | cds_cfg->flow_steering_enabled); |
| 354 | |
Nirav Shah | e6c8e64 | 2018-03-25 11:42:48 +0530 | [diff] [blame] | 355 | cds_cdp_set_flow_control_params(cds_cfg, &cdp_cfg); |
Venkata Sharath Chandra Manchala | 0d44d45 | 2016-11-23 17:48:15 -0800 | [diff] [blame] | 356 | cdp_cfg_set_flow_control_parameters(soc, gp_cds_context->cfg_ctx, |
Nirav Shah | e6c8e64 | 2018-03-25 11:42:48 +0530 | [diff] [blame] | 357 | (void *)&cdp_cfg); |
Leo Chang | 9b09703 | 2016-10-28 11:03:17 -0700 | [diff] [blame] | 358 | |
| 359 | /* adjust the cfg_ctx default value based on setting */ |
| 360 | cdp_cfg_set_rx_fwd_disabled(soc, gp_cds_context->cfg_ctx, |
| 361 | (uint8_t) cds_cfg->ap_disable_intrabss_fwd); |
| 362 | |
| 363 | /* |
| 364 | * adjust the packet log enable default value |
| 365 | * based on CFG INI setting |
| 366 | */ |
| 367 | cdp_cfg_set_packet_log_enabled(soc, gp_cds_context->cfg_ctx, |
| 368 | (uint8_t)cds_is_packet_log_enabled()); |
Yu Wang | 66a250b | 2017-07-19 11:46:40 +0800 | [diff] [blame] | 369 | |
| 370 | /* adjust the ptp rx option default value based on CFG INI setting */ |
| 371 | cdp_cfg_set_ptp_rx_opt_enabled(soc, gp_cds_context->cfg_ctx, |
| 372 | (uint8_t)cds_is_ptp_rx_opt_enabled()); |
Leo Chang | 9b09703 | 2016-10-28 11:03:17 -0700 | [diff] [blame] | 373 | } |
Krunal Soni | d32c6bc | 2016-10-18 18:00:21 -0700 | [diff] [blame] | 374 | static QDF_STATUS cds_register_all_modules(void) |
| 375 | { |
| 376 | QDF_STATUS status; |
| 377 | |
| 378 | scheduler_register_wma_legacy_handler(&wma_mc_process_handler); |
| 379 | scheduler_register_sys_legacy_handler(&sys_mc_process_handler); |
| 380 | |
| 381 | /* Register message queues in given order such that queue priority is |
| 382 | * intact: |
| 383 | * 1) QDF_MODULE_ID_SYS: Timer queue(legacy SYS queue) |
| 384 | * 2) QDF_MODULE_ID_TARGET_IF: Target interface queue |
| 385 | * 3) QDF_MODULE_ID_PE: Legacy PE message queue |
| 386 | * 4) QDF_MODULE_ID_SME: Legacy SME message queue |
| 387 | * 5) QDF_MODULE_ID_OS_IF: OS IF message queue for new components |
| 388 | */ |
| 389 | status = scheduler_register_module(QDF_MODULE_ID_SYS, |
| 390 | &scheduler_timer_q_mq_handler); |
| 391 | status = scheduler_register_module(QDF_MODULE_ID_TARGET_IF, |
| 392 | &scheduler_target_if_mq_handler); |
| 393 | status = scheduler_register_module(QDF_MODULE_ID_PE, |
| 394 | &pe_mc_process_handler); |
| 395 | status = scheduler_register_module(QDF_MODULE_ID_SME, |
| 396 | &sme_mc_process_handler); |
| 397 | status = scheduler_register_module(QDF_MODULE_ID_OS_IF, |
| 398 | &scheduler_os_if_mq_handler); |
Vignesh Viswanathan | cad9132 | 2018-04-04 17:44:28 +0530 | [diff] [blame] | 399 | status = scheduler_register_module(QDF_MODULE_ID_SCAN, |
| 400 | &scheduler_scan_mq_handler); |
Krunal Soni | d32c6bc | 2016-10-18 18:00:21 -0700 | [diff] [blame] | 401 | return status; |
| 402 | } |
| 403 | |
| 404 | static QDF_STATUS cds_deregister_all_modules(void) |
| 405 | { |
| 406 | QDF_STATUS status; |
Krunal Soni | e339990 | 2017-02-01 09:51:42 -0800 | [diff] [blame] | 407 | |
| 408 | scheduler_deregister_wma_legacy_handler(); |
| 409 | scheduler_deregister_sys_legacy_handler(); |
Krunal Soni | d32c6bc | 2016-10-18 18:00:21 -0700 | [diff] [blame] | 410 | status = scheduler_deregister_module(QDF_MODULE_ID_SYS); |
Rajeev Kumar | a88b2dc | 2017-01-30 16:35:14 -0800 | [diff] [blame] | 411 | status = scheduler_deregister_module(QDF_MODULE_ID_TARGET_IF); |
Krunal Soni | d32c6bc | 2016-10-18 18:00:21 -0700 | [diff] [blame] | 412 | status = scheduler_deregister_module(QDF_MODULE_ID_PE); |
| 413 | status = scheduler_deregister_module(QDF_MODULE_ID_SME); |
| 414 | status = scheduler_deregister_module(QDF_MODULE_ID_OS_IF); |
Krunal Soni | e339990 | 2017-02-01 09:51:42 -0800 | [diff] [blame] | 415 | |
Krunal Soni | d32c6bc | 2016-10-18 18:00:21 -0700 | [diff] [blame] | 416 | return status; |
| 417 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 418 | |
| 419 | /** |
gbian | 62edd7e | 2017-03-07 13:12:13 +0800 | [diff] [blame] | 420 | * cds_set_ac_specs_params() - set ac_specs params in cds_config_info |
| 421 | * @cds_cfg: Pointer to cds_config_info |
| 422 | * @hdd_ctx: Pointer to hdd context |
| 423 | * |
| 424 | * Return: none |
| 425 | */ |
| 426 | static void |
| 427 | cds_set_ac_specs_params(struct cds_config_info *cds_cfg) |
| 428 | { |
| 429 | int i; |
Jeff Johnson | 2b6982c | 2018-05-29 14:56:11 -0700 | [diff] [blame] | 430 | struct cds_context *cds_ctx; |
gbian | 62edd7e | 2017-03-07 13:12:13 +0800 | [diff] [blame] | 431 | |
| 432 | if (NULL == cds_cfg) |
| 433 | return; |
| 434 | |
| 435 | cds_ctx = cds_get_context(QDF_MODULE_ID_QDF); |
| 436 | |
| 437 | if (!cds_ctx) { |
Jeff Johnson | d0a6b2c | 2018-05-30 22:57:39 -0700 | [diff] [blame] | 438 | cds_err("Invalid CDS Context"); |
gbian | 62edd7e | 2017-03-07 13:12:13 +0800 | [diff] [blame] | 439 | return; |
| 440 | } |
| 441 | |
| 442 | for (i = 0; i < OL_TX_NUM_WMM_AC; i++) { |
| 443 | cds_cfg->ac_specs[i] = cds_ctx->ac_specs[i]; |
| 444 | } |
| 445 | } |
| 446 | |
| 447 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 448 | * cds_open() - open the CDS Module |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 449 | * |
| 450 | * cds_open() function opens the CDS Scheduler |
| 451 | * Upon successful initialization: |
| 452 | * - All CDS submodules should have been initialized |
| 453 | * |
| 454 | * - The CDS scheduler should have opened |
| 455 | * |
| 456 | * - All the WLAN SW components should have been opened. This includes |
| 457 | * SYS, MAC, SME, WMA and TL. |
| 458 | * |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 459 | * Return: QDF status |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 460 | */ |
Selvaraj, Sridhar | 0672a12 | 2016-12-29 16:11:48 +0530 | [diff] [blame] | 461 | QDF_STATUS cds_open(struct wlan_objmgr_psoc *psoc) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 462 | { |
Dustin Brown | f797119 | 2017-10-25 14:54:37 -0700 | [diff] [blame] | 463 | QDF_STATUS status; |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 464 | struct cds_config_info *cds_cfg; |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 465 | qdf_device_t qdf_ctx; |
Manikandan Mohan | 83c939c | 2017-04-13 20:23:07 -0700 | [diff] [blame] | 466 | struct htc_init_info htcInfo; |
Komal Seelam | d910649 | 2016-02-15 10:31:44 +0530 | [diff] [blame] | 467 | struct ol_context *ol_ctx; |
Komal Seelam | 3d20286 | 2016-02-24 18:43:24 +0530 | [diff] [blame] | 468 | struct hif_opaque_softc *scn; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 469 | void *HTCHandle; |
Jeff Johnson | c18b26c | 2017-09-03 08:46:45 -0700 | [diff] [blame] | 470 | struct hdd_context *hdd_ctx; |
Jeff Johnson | 2b6982c | 2018-05-29 14:56:11 -0700 | [diff] [blame] | 471 | struct cds_context *cds_ctx; |
Jeff Johnson | ec56395 | 2018-06-11 09:57:09 -0700 | [diff] [blame] | 472 | mac_handle_t mac_handle; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 473 | |
Jeff Johnson | d0a6b2c | 2018-05-30 22:57:39 -0700 | [diff] [blame] | 474 | cds_debug("Opening CDS"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 475 | |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 476 | cds_ctx = cds_get_context(QDF_MODULE_ID_QDF); |
| 477 | if (!cds_ctx) { |
Jeff Johnson | d0a6b2c | 2018-05-30 22:57:39 -0700 | [diff] [blame] | 478 | cds_alert("Trying to open CDS without a PreOpen"); |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 479 | QDF_ASSERT(0); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 480 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 481 | } |
| 482 | |
| 483 | /* Initialize the timer module */ |
Anurag Chouhan | 210db07 | 2016-02-22 18:42:15 +0530 | [diff] [blame] | 484 | qdf_timer_module_init(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 485 | |
| 486 | /* Initialize bug reporting structure */ |
| 487 | cds_init_log_completion(); |
| 488 | |
Jeff Johnson | 2ccd815 | 2018-05-29 16:02:23 -0700 | [diff] [blame] | 489 | status = qdf_event_create(&gp_cds_context->wma_complete_event); |
Dustin Brown | f797119 | 2017-10-25 14:54:37 -0700 | [diff] [blame] | 490 | if (QDF_IS_STATUS_ERROR(status)) { |
Jeff Johnson | d0a6b2c | 2018-05-30 22:57:39 -0700 | [diff] [blame] | 491 | cds_alert("Unable to init wma_complete_event"); |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 492 | QDF_ASSERT(0); |
Dustin Brown | a22671a | 2018-05-29 12:13:51 -0700 | [diff] [blame] | 493 | return status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 494 | } |
| 495 | |
Jeff Johnson | 323a6f0 | 2018-05-29 15:09:12 -0700 | [diff] [blame] | 496 | hdd_ctx = (struct hdd_context *)(gp_cds_context->hdd_context); |
Dustin Brown | f797119 | 2017-10-25 14:54:37 -0700 | [diff] [blame] | 497 | if (!hdd_ctx || !hdd_ctx->config) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 498 | /* Critical Error ... Cannot proceed further */ |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 499 | cds_err("Hdd Context is Null"); |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 500 | QDF_ASSERT(0); |
Dustin Brown | f797119 | 2017-10-25 14:54:37 -0700 | [diff] [blame] | 501 | |
| 502 | status = QDF_STATUS_E_FAILURE; |
Rajeev Kumar | 3e5ef0d | 2017-01-03 14:45:31 -0800 | [diff] [blame] | 503 | goto err_wma_complete_event; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 504 | } |
Kabilan Kannan | 15cc6ac | 2016-11-12 22:25:14 -0800 | [diff] [blame] | 505 | |
Dustin Brown | 44cde35 | 2017-12-04 13:14:46 -0800 | [diff] [blame] | 506 | status = dispatcher_enable(); |
| 507 | if (QDF_IS_STATUS_ERROR(status)) { |
| 508 | cds_err("Failed to enable dispatcher; status:%d", status); |
| 509 | goto err_wma_complete_event; |
| 510 | } |
| 511 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 512 | /* Now Open the CDS Scheduler */ |
Dustin Brown | 0707ddf | 2017-09-20 15:31:56 -0700 | [diff] [blame] | 513 | status = cds_sched_open(gp_cds_context, |
| 514 | &gp_cds_context->qdf_sched, |
| 515 | sizeof(cds_sched_context)); |
Dustin Brown | 0707ddf | 2017-09-20 15:31:56 -0700 | [diff] [blame] | 516 | if (QDF_IS_STATUS_ERROR(status)) { |
| 517 | /* Critical Error ... Cannot proceed further */ |
| 518 | cds_alert("Failed to open CDS Scheduler"); |
| 519 | QDF_ASSERT(0); |
Dustin Brown | 44cde35 | 2017-12-04 13:14:46 -0800 | [diff] [blame] | 520 | goto err_dispatcher_disable; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 521 | } |
| 522 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 523 | scn = cds_get_context(QDF_MODULE_ID_HIF); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 524 | if (!scn) { |
Jeff Johnson | d0a6b2c | 2018-05-30 22:57:39 -0700 | [diff] [blame] | 525 | cds_alert("scn is null!"); |
Dustin Brown | f797119 | 2017-10-25 14:54:37 -0700 | [diff] [blame] | 526 | |
| 527 | status = QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 528 | goto err_sched_close; |
| 529 | } |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 530 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 531 | cds_cfg = cds_get_ini_config(); |
| 532 | if (!cds_cfg) { |
| 533 | cds_err("Cds config is NULL"); |
| 534 | QDF_ASSERT(0); |
Dustin Brown | f797119 | 2017-10-25 14:54:37 -0700 | [diff] [blame] | 535 | |
| 536 | status = QDF_STATUS_E_FAILURE; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 537 | goto err_sched_close; |
| 538 | } |
Dustin Brown | f797119 | 2017-10-25 14:54:37 -0700 | [diff] [blame] | 539 | |
Jeff Johnson | c18b26c | 2017-09-03 08:46:45 -0700 | [diff] [blame] | 540 | hdd_enable_fastpath(hdd_ctx->config, scn); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 541 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 542 | /* Initialize BMI and Download firmware */ |
Dustin Brown | f797119 | 2017-10-25 14:54:37 -0700 | [diff] [blame] | 543 | ol_ctx = cds_get_context(QDF_MODULE_ID_BMI); |
| 544 | status = bmi_download_firmware(ol_ctx); |
| 545 | if (QDF_IS_STATUS_ERROR(status)) { |
Jeff Johnson | d0a6b2c | 2018-05-30 22:57:39 -0700 | [diff] [blame] | 546 | cds_alert("BMI FIALED status:%d", status); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 547 | goto err_bmi_close; |
| 548 | } |
Tiger Yu | 086b699 | 2017-11-20 16:33:43 +0800 | [diff] [blame] | 549 | |
| 550 | hdd_wlan_update_target_info(hdd_ctx, scn); |
| 551 | |
Komal Seelam | 0863349 | 2016-02-24 18:05:07 +0530 | [diff] [blame] | 552 | htcInfo.pContext = ol_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 553 | htcInfo.TargetFailure = ol_target_failure; |
Mukul Sharma | 4c60a7e | 2017-03-06 19:42:18 +0530 | [diff] [blame] | 554 | htcInfo.TargetSendSuspendComplete = |
| 555 | pmo_ucfg_psoc_target_suspend_acknowledge; |
| 556 | htcInfo.target_initial_wakeup_cb = pmo_ucfg_psoc_handle_initial_wake_up; |
| 557 | htcInfo.target_psoc = (void *)psoc; |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 558 | qdf_ctx = cds_get_context(QDF_MODULE_ID_QDF_DEVICE); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 559 | |
| 560 | /* Create HTC */ |
| 561 | gp_cds_context->htc_ctx = |
Yue Ma | 1e11d79 | 2016-02-26 18:58:44 -0800 | [diff] [blame] | 562 | htc_create(scn, &htcInfo, qdf_ctx, cds_get_conparam()); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 563 | if (!gp_cds_context->htc_ctx) { |
Jeff Johnson | d0a6b2c | 2018-05-30 22:57:39 -0700 | [diff] [blame] | 564 | cds_alert("Failed to Create HTC"); |
Dustin Brown | f797119 | 2017-10-25 14:54:37 -0700 | [diff] [blame] | 565 | |
| 566 | status = QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 567 | goto err_bmi_close; |
| 568 | } |
Mukul Sharma | 4c60a7e | 2017-03-06 19:42:18 +0530 | [diff] [blame] | 569 | pmo_ucfg_psoc_update_htc_handle(psoc, (void *)gp_cds_context->htc_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 570 | |
Dustin Brown | f797119 | 2017-10-25 14:54:37 -0700 | [diff] [blame] | 571 | status = bmi_done(ol_ctx); |
| 572 | if (QDF_IS_STATUS_ERROR(status)) { |
Jeff Johnson | d0a6b2c | 2018-05-30 22:57:39 -0700 | [diff] [blame] | 573 | cds_alert("Failed to complete BMI phase"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 574 | goto err_htc_close; |
| 575 | } |
| 576 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 577 | /*Open the WMA module */ |
bings | 482bae2 | 2018-01-17 16:25:31 +0800 | [diff] [blame] | 578 | status = wma_open(psoc, hdd_update_tgt_cfg, cds_cfg, |
| 579 | hdd_ctx->target_type); |
Dustin Brown | f797119 | 2017-10-25 14:54:37 -0700 | [diff] [blame] | 580 | if (QDF_IS_STATUS_ERROR(status)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 581 | /* Critical Error ... Cannot proceed further */ |
Jeff Johnson | d0a6b2c | 2018-05-30 22:57:39 -0700 | [diff] [blame] | 582 | cds_alert("Failed to open WMA module"); |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 583 | QDF_ASSERT(0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 584 | goto err_htc_close; |
| 585 | } |
| 586 | |
| 587 | /* Number of peers limit differs in each chip version. If peer max |
| 588 | * limit configured in ini exceeds more than supported, WMA adjusts |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 589 | * and keeps correct limit in cds_cfg.max_station. So, make sure |
Jeff Johnson | c18b26c | 2017-09-03 08:46:45 -0700 | [diff] [blame] | 590 | * config entry hdd_ctx->config->maxNumberOfPeers has adjusted value |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 591 | */ |
Hanumanth Reddy Pothula | 47d2926 | 2016-10-03 16:08:04 +0530 | [diff] [blame] | 592 | /* In FTM mode cds_cfg->max_stations will be zero. On updating same |
| 593 | * into hdd context config entry, leads to pe_open() to fail, if |
| 594 | * con_mode change happens from FTM mode to any other mode. |
| 595 | */ |
Srinivas Girigowda | 35b0031 | 2017-06-27 21:52:03 -0700 | [diff] [blame] | 596 | if (QDF_DRIVER_TYPE_PRODUCTION == cds_cfg->driver_type) |
Jeff Johnson | c18b26c | 2017-09-03 08:46:45 -0700 | [diff] [blame] | 597 | hdd_ctx->config->maxNumberOfPeers = cds_cfg->max_station; |
Hanumanth Reddy Pothula | 47d2926 | 2016-10-03 16:08:04 +0530 | [diff] [blame] | 598 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 599 | HTCHandle = cds_get_context(QDF_MODULE_ID_HTC); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 600 | if (!HTCHandle) { |
Jeff Johnson | d0a6b2c | 2018-05-30 22:57:39 -0700 | [diff] [blame] | 601 | cds_alert("HTCHandle is null!"); |
Dustin Brown | f797119 | 2017-10-25 14:54:37 -0700 | [diff] [blame] | 602 | |
| 603 | status = QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 604 | goto err_wma_close; |
| 605 | } |
Nachiket Kukade | f44b33e | 2017-09-06 16:49:29 +0530 | [diff] [blame] | 606 | |
Dustin Brown | f797119 | 2017-10-25 14:54:37 -0700 | [diff] [blame] | 607 | status = htc_wait_target(HTCHandle); |
| 608 | if (QDF_IS_STATUS_ERROR(status)) { |
| 609 | cds_alert("Failed to complete BMI phase. status: %d", status); |
Nachiket Kukade | 8003d25 | 2017-03-30 15:55:58 +0530 | [diff] [blame] | 610 | |
Dustin Brown | f797119 | 2017-10-25 14:54:37 -0700 | [diff] [blame] | 611 | if (status != QDF_STATUS_E_NOMEM && !cds_is_fw_down()) |
Nachiket Kukade | 8003d25 | 2017-03-30 15:55:58 +0530 | [diff] [blame] | 612 | QDF_BUG(0); |
| 613 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 614 | goto err_wma_close; |
| 615 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 616 | |
Jeff Johnson | d0a6b2c | 2018-05-30 22:57:39 -0700 | [diff] [blame] | 617 | cds_debug("target_type %d 8074:%d 6290:%d", hdd_ctx->target_type, |
| 618 | TARGET_TYPE_QCA8074, TARGET_TYPE_QCA6290); |
Ravi Joshi | fc2ed78 | 2016-11-22 17:36:50 -0800 | [diff] [blame] | 619 | |
Jeff Johnson | c18b26c | 2017-09-03 08:46:45 -0700 | [diff] [blame] | 620 | if (TARGET_TYPE_QCA6290 == hdd_ctx->target_type) |
Leo Chang | 9b09703 | 2016-10-28 11:03:17 -0700 | [diff] [blame] | 621 | gp_cds_context->dp_soc = cdp_soc_attach(LITHIUM_DP, |
Jeff Johnson | a40e21c | 2018-05-29 15:59:57 -0700 | [diff] [blame] | 622 | gp_cds_context->hif_context, psoc, |
Leo Chang | 9b09703 | 2016-10-28 11:03:17 -0700 | [diff] [blame] | 623 | gp_cds_context->htc_ctx, gp_cds_context->qdf_ctx, |
Arunk Khandavalli | a6305a3 | 2018-01-25 11:19:18 +0530 | [diff] [blame] | 624 | &dp_ol_if_ops); |
Leo Chang | 9b09703 | 2016-10-28 11:03:17 -0700 | [diff] [blame] | 625 | else |
| 626 | gp_cds_context->dp_soc = cdp_soc_attach(MOB_DRV_LEGACY_DP, |
Jeff Johnson | a40e21c | 2018-05-29 15:59:57 -0700 | [diff] [blame] | 627 | gp_cds_context->hif_context, psoc, |
Leo Chang | 9b09703 | 2016-10-28 11:03:17 -0700 | [diff] [blame] | 628 | gp_cds_context->htc_ctx, gp_cds_context->qdf_ctx, |
Arunk Khandavalli | a6305a3 | 2018-01-25 11:19:18 +0530 | [diff] [blame] | 629 | &dp_ol_if_ops); |
Leo Chang | 9b09703 | 2016-10-28 11:03:17 -0700 | [diff] [blame] | 630 | |
Dustin Brown | f797119 | 2017-10-25 14:54:37 -0700 | [diff] [blame] | 631 | if (!gp_cds_context->dp_soc) { |
| 632 | status = QDF_STATUS_E_FAILURE; |
Manikandan Mohan | fb9d2b5 | 2017-05-10 15:01:28 -0700 | [diff] [blame] | 633 | goto err_wma_close; |
Dustin Brown | f797119 | 2017-10-25 14:54:37 -0700 | [diff] [blame] | 634 | } |
Manikandan Mohan | fb9d2b5 | 2017-05-10 15:01:28 -0700 | [diff] [blame] | 635 | |
Lin Bai | 362e52b | 2018-05-07 14:42:50 +0800 | [diff] [blame] | 636 | wlan_psoc_set_dp_handle(psoc, gp_cds_context->dp_soc); |
Sravan Kumar Kairam | 2729678 | 2017-04-21 22:04:18 +0530 | [diff] [blame] | 637 | pmo_ucfg_psoc_update_dp_handle(psoc, gp_cds_context->dp_soc); |
Zhang Qian | 47e22ce | 2018-01-04 15:38:38 +0800 | [diff] [blame] | 638 | ucfg_ocb_update_dp_handle(psoc, gp_cds_context->dp_soc); |
Sravan Kumar Kairam | 2729678 | 2017-04-21 22:04:18 +0530 | [diff] [blame] | 639 | |
gbian | 62edd7e | 2017-03-07 13:12:13 +0800 | [diff] [blame] | 640 | cds_set_ac_specs_params(cds_cfg); |
| 641 | |
Leo Chang | 9b09703 | 2016-10-28 11:03:17 -0700 | [diff] [blame] | 642 | cds_cdp_cfg_attach(cds_cfg); |
| 643 | |
Nirav Shah | eb017be | 2018-02-15 11:20:58 +0530 | [diff] [blame] | 644 | bmi_target_ready(scn, gp_cds_context->cfg_ctx); |
| 645 | |
Jeff Johnson | d9f0860 | 2016-12-02 11:31:30 -0800 | [diff] [blame] | 646 | /* Now proceed to open the MAC */ |
Jeff Johnson | ec56395 | 2018-06-11 09:57:09 -0700 | [diff] [blame] | 647 | status = mac_open(psoc, &mac_handle, |
Jeff Johnson | ac99e47 | 2018-06-07 23:00:08 -0700 | [diff] [blame] | 648 | gp_cds_context->hdd_context, cds_cfg); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 649 | |
Jeff Johnson | ac99e47 | 2018-06-07 23:00:08 -0700 | [diff] [blame] | 650 | if (QDF_STATUS_SUCCESS != status) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 651 | /* Critical Error ... Cannot proceed further */ |
Jeff Johnson | d0a6b2c | 2018-05-30 22:57:39 -0700 | [diff] [blame] | 652 | cds_alert("Failed to open MAC"); |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 653 | QDF_ASSERT(0); |
Houston Hoffman | 59c9c91 | 2017-03-29 14:10:39 -0700 | [diff] [blame] | 654 | goto err_soc_detach; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 655 | } |
Jeff Johnson | ec56395 | 2018-06-11 09:57:09 -0700 | [diff] [blame] | 656 | gp_cds_context->mac_context = mac_handle; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 657 | |
| 658 | /* Now proceed to open the SME */ |
Jeff Johnson | ec56395 | 2018-06-11 09:57:09 -0700 | [diff] [blame] | 659 | status = sme_open(mac_handle); |
Dustin Brown | f797119 | 2017-10-25 14:54:37 -0700 | [diff] [blame] | 660 | if (QDF_IS_STATUS_ERROR(status)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 661 | /* Critical Error ... Cannot proceed further */ |
Jeff Johnson | d0a6b2c | 2018-05-30 22:57:39 -0700 | [diff] [blame] | 662 | cds_alert("Failed to open SME"); |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 663 | QDF_ASSERT(0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 664 | goto err_mac_close; |
| 665 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 666 | |
Krunal Soni | d32c6bc | 2016-10-18 18:00:21 -0700 | [diff] [blame] | 667 | cds_register_all_modules(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 668 | |
Selvaraj, Sridhar | a7dc238 | 2017-01-27 18:29:39 +0530 | [diff] [blame] | 669 | return dispatcher_psoc_open(psoc); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 670 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 671 | err_mac_close: |
Jeff Johnson | ec56395 | 2018-06-11 09:57:09 -0700 | [diff] [blame] | 672 | mac_close(mac_handle); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 673 | |
Houston Hoffman | 59c9c91 | 2017-03-29 14:10:39 -0700 | [diff] [blame] | 674 | err_soc_detach: |
| 675 | /* todo: add propper error handling */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 676 | err_wma_close: |
Rajeev Kumar | 662d75d | 2017-03-13 18:11:29 -0700 | [diff] [blame] | 677 | cds_shutdown_notifier_purge(); |
Jeff Johnson | 542da35 | 2017-09-13 09:17:28 -0700 | [diff] [blame] | 678 | wma_close(); |
Jeff Johnson | 7b3ddc2 | 2017-09-13 09:42:44 -0700 | [diff] [blame] | 679 | wma_wmi_service_close(); |
Sravan Kumar Kairam | 2729678 | 2017-04-21 22:04:18 +0530 | [diff] [blame] | 680 | pmo_ucfg_psoc_update_dp_handle(psoc, NULL); |
Lin Bai | 362e52b | 2018-05-07 14:42:50 +0800 | [diff] [blame] | 681 | wlan_psoc_set_dp_handle(psoc, NULL); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 682 | |
| 683 | err_htc_close: |
| 684 | if (gp_cds_context->htc_ctx) { |
| 685 | htc_destroy(gp_cds_context->htc_ctx); |
| 686 | gp_cds_context->htc_ctx = NULL; |
Sravan Kumar Kairam | 2729678 | 2017-04-21 22:04:18 +0530 | [diff] [blame] | 687 | pmo_ucfg_psoc_update_htc_handle(psoc, NULL); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 688 | } |
| 689 | |
| 690 | err_bmi_close: |
Komal Seelam | 5a6e508 | 2016-02-24 17:59:09 +0530 | [diff] [blame] | 691 | bmi_cleanup(ol_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 692 | |
| 693 | err_sched_close: |
Dustin Brown | 0707ddf | 2017-09-20 15:31:56 -0700 | [diff] [blame] | 694 | if (QDF_IS_STATUS_ERROR(cds_sched_close())) { |
| 695 | cds_err("Failed to close CDS Scheduler"); |
| 696 | QDF_ASSERT(false); |
Hanumanth Reddy Pothula | 0b57143 | 2017-02-23 17:15:37 +0530 | [diff] [blame] | 697 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 698 | |
Dustin Brown | 44cde35 | 2017-12-04 13:14:46 -0800 | [diff] [blame] | 699 | err_dispatcher_disable: |
| 700 | if (QDF_IS_STATUS_ERROR(dispatcher_disable())) |
| 701 | cds_err("Failed to disable dispatcher"); |
| 702 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 703 | err_wma_complete_event: |
Jeff Johnson | 2ccd815 | 2018-05-29 16:02:23 -0700 | [diff] [blame] | 704 | qdf_event_destroy(&gp_cds_context->wma_complete_event); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 705 | |
Dustin Brown | f797119 | 2017-10-25 14:54:37 -0700 | [diff] [blame] | 706 | return status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 707 | } /* cds_open() */ |
| 708 | |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 709 | QDF_STATUS cds_dp_open(struct wlan_objmgr_psoc *psoc) |
| 710 | { |
| 711 | if (cdp_txrx_intr_attach(gp_cds_context->dp_soc) |
| 712 | != QDF_STATUS_SUCCESS) { |
Jeff Johnson | d0a6b2c | 2018-05-30 22:57:39 -0700 | [diff] [blame] | 713 | cds_alert("Failed to attach interrupts"); |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 714 | goto close; |
| 715 | } |
| 716 | |
| 717 | cds_set_context(QDF_MODULE_ID_TXRX, |
| 718 | cdp_pdev_attach(cds_get_context(QDF_MODULE_ID_SOC), |
Sravan Kumar Kairam | 1cbfb00 | 2018-06-14 18:28:48 +0530 | [diff] [blame] | 719 | (struct cdp_ctrl_objmgr_pdev *)gp_cds_context->cfg_ctx, |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 720 | gp_cds_context->htc_ctx, |
| 721 | gp_cds_context->qdf_ctx, 0)); |
| 722 | if (!gp_cds_context->pdev_txrx_ctx) { |
| 723 | /* Critical Error ... Cannot proceed further */ |
Jeff Johnson | d0a6b2c | 2018-05-30 22:57:39 -0700 | [diff] [blame] | 724 | cds_alert("Failed to open TXRX"); |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 725 | QDF_ASSERT(0); |
| 726 | goto intr_close; |
| 727 | } |
| 728 | |
| 729 | pmo_ucfg_psoc_set_txrx_handle(psoc, gp_cds_context->pdev_txrx_ctx); |
Zhang Qian | 47e22ce | 2018-01-04 15:38:38 +0800 | [diff] [blame] | 730 | ucfg_ocb_set_txrx_handle(psoc, gp_cds_context->pdev_txrx_ctx); |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 731 | |
Jeff Johnson | d0a6b2c | 2018-05-30 22:57:39 -0700 | [diff] [blame] | 732 | cds_debug("CDS successfully Opened"); |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 733 | |
| 734 | return 0; |
| 735 | |
| 736 | intr_close: |
| 737 | cdp_txrx_intr_detach(gp_cds_context->dp_soc); |
| 738 | close: |
| 739 | return QDF_STATUS_E_FAILURE; |
| 740 | } |
| 741 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 742 | /** |
| 743 | * cds_pre_enable() - pre enable cds |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 744 | * |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 745 | * Return: QDF status |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 746 | */ |
Jeff Johnson | 3a28012 | 2017-09-13 07:42:00 -0700 | [diff] [blame] | 747 | QDF_STATUS cds_pre_enable(void) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 748 | { |
Dustin Brown | 9746bd6 | 2018-05-25 15:15:27 -0700 | [diff] [blame] | 749 | QDF_STATUS status; |
| 750 | int errno; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 751 | void *scn; |
Jeff Johnson | 3a28012 | 2017-09-13 07:42:00 -0700 | [diff] [blame] | 752 | void *soc; |
Tiger Yu | 9973e36 | 2018-06-06 13:54:22 +0800 | [diff] [blame] | 753 | void *hif_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 754 | |
Dustin Brown | 9746bd6 | 2018-05-25 15:15:27 -0700 | [diff] [blame] | 755 | cds_enter(); |
Jeff Johnson | 3a28012 | 2017-09-13 07:42:00 -0700 | [diff] [blame] | 756 | |
| 757 | if (!gp_cds_context) { |
Dustin Brown | 9746bd6 | 2018-05-25 15:15:27 -0700 | [diff] [blame] | 758 | cds_err("cds context is null"); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 759 | return QDF_STATUS_E_INVAL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 760 | } |
| 761 | |
Jeff Johnson | 830f322 | 2018-05-29 15:58:18 -0700 | [diff] [blame] | 762 | if (!gp_cds_context->wma_context) { |
Dustin Brown | 9746bd6 | 2018-05-25 15:15:27 -0700 | [diff] [blame] | 763 | cds_err("wma context is null"); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 764 | return QDF_STATUS_E_INVAL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 765 | } |
| 766 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 767 | scn = cds_get_context(QDF_MODULE_ID_HIF); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 768 | if (!scn) { |
Dustin Brown | 9746bd6 | 2018-05-25 15:15:27 -0700 | [diff] [blame] | 769 | cds_err("hif context is null"); |
| 770 | return QDF_STATUS_E_INVAL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 771 | } |
| 772 | |
Jeff Johnson | 3a28012 | 2017-09-13 07:42:00 -0700 | [diff] [blame] | 773 | soc = cds_get_context(QDF_MODULE_ID_SOC); |
| 774 | if (!soc) { |
Dustin Brown | 9746bd6 | 2018-05-25 15:15:27 -0700 | [diff] [blame] | 775 | cds_err("soc context is null"); |
| 776 | return QDF_STATUS_E_INVAL; |
Jeff Johnson | 3a28012 | 2017-09-13 07:42:00 -0700 | [diff] [blame] | 777 | } |
| 778 | |
Nirav Shah | 7f337db | 2016-05-25 10:49:02 +0530 | [diff] [blame] | 779 | /* call Packetlog connect service */ |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 780 | if (QDF_GLOBAL_FTM_MODE != cds_get_conparam() && |
Leo Chang | 9b09703 | 2016-10-28 11:03:17 -0700 | [diff] [blame] | 781 | QDF_GLOBAL_EPPING_MODE != cds_get_conparam()) |
Dustin Brown | 9746bd6 | 2018-05-25 15:15:27 -0700 | [diff] [blame] | 782 | cdp_pkt_log_con_service(soc, gp_cds_context->pdev_txrx_ctx, |
| 783 | scn); |
Nirav Shah | 7f337db | 2016-05-25 10:49:02 +0530 | [diff] [blame] | 784 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 785 | /* Reset wma wait event */ |
Jeff Johnson | 2ccd815 | 2018-05-29 16:02:23 -0700 | [diff] [blame] | 786 | qdf_event_reset(&gp_cds_context->wma_complete_event); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 787 | |
| 788 | /*call WMA pre start */ |
Dustin Brown | 9746bd6 | 2018-05-25 15:15:27 -0700 | [diff] [blame] | 789 | status = wma_pre_start(); |
| 790 | if (QDF_IS_STATUS_ERROR(status)) { |
| 791 | cds_err("Failed to WMA prestart"); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 792 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 793 | } |
| 794 | |
| 795 | /* Need to update time out of complete */ |
Dustin Brown | 9746bd6 | 2018-05-25 15:15:27 -0700 | [diff] [blame] | 796 | status = qdf_wait_for_event_completion( |
Jeff Johnson | 2ccd815 | 2018-05-29 16:02:23 -0700 | [diff] [blame] | 797 | &gp_cds_context->wma_complete_event, |
Nachiket Kukade | 0396b73 | 2017-11-14 16:35:16 +0530 | [diff] [blame] | 798 | CDS_WMA_TIMEOUT); |
Dustin Brown | 9746bd6 | 2018-05-25 15:15:27 -0700 | [diff] [blame] | 799 | if (QDF_IS_STATUS_ERROR(status)) { |
| 800 | cds_err("Failed to wait for WMA complete; status:%u", status); |
Dustin Brown | c30f393 | 2018-05-25 16:48:23 -0700 | [diff] [blame] | 801 | cds_trigger_recovery(QDF_REASON_UNSPECIFIED); |
Dustin Brown | 9746bd6 | 2018-05-25 15:15:27 -0700 | [diff] [blame] | 802 | goto exit_with_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 803 | } |
| 804 | |
Dustin Brown | 9746bd6 | 2018-05-25 15:15:27 -0700 | [diff] [blame] | 805 | status = htc_start(gp_cds_context->htc_ctx); |
| 806 | if (QDF_IS_STATUS_ERROR(status)) { |
| 807 | cds_err("Failed to Start HTC"); |
| 808 | goto exit_with_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 809 | } |
| 810 | |
Jeff Johnson | 830f322 | 2018-05-29 15:58:18 -0700 | [diff] [blame] | 811 | status = wma_wait_for_ready_event(gp_cds_context->wma_context); |
Dustin Brown | 9746bd6 | 2018-05-25 15:15:27 -0700 | [diff] [blame] | 812 | if (QDF_IS_STATUS_ERROR(status)) { |
| 813 | cds_err("Failed to wait for ready event; status: %u", status); |
| 814 | cds_trigger_recovery(QDF_REASON_UNSPECIFIED); |
| 815 | goto stop_wmi; |
| 816 | } |
| 817 | |
| 818 | errno = cdp_pdev_post_attach(soc, gp_cds_context->pdev_txrx_ctx); |
| 819 | if (errno) { |
| 820 | cds_err("Failed to attach pdev"); |
| 821 | status = qdf_status_from_os_return(errno); |
| 822 | goto stop_wmi; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 823 | } |
| 824 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 825 | return QDF_STATUS_SUCCESS; |
Dustin Brown | 9746bd6 | 2018-05-25 15:15:27 -0700 | [diff] [blame] | 826 | |
| 827 | stop_wmi: |
Tiger Yu | 9973e36 | 2018-06-06 13:54:22 +0800 | [diff] [blame] | 828 | hif_ctx = cds_get_context(QDF_MODULE_ID_HIF); |
| 829 | if (!hif_ctx) |
| 830 | cds_err("%s: Failed to get hif_handle!", __func__); |
| 831 | |
Dustin Brown | 9746bd6 | 2018-05-25 15:15:27 -0700 | [diff] [blame] | 832 | wma_wmi_stop(); |
Tiger Yu | 9973e36 | 2018-06-06 13:54:22 +0800 | [diff] [blame] | 833 | |
| 834 | if (hif_ctx) { |
| 835 | cds_err("%s: Disable the isr & reset the soc!", __func__); |
| 836 | hif_disable_isr(hif_ctx); |
| 837 | hif_reset_soc(hif_ctx); |
| 838 | } |
Dustin Brown | 9746bd6 | 2018-05-25 15:15:27 -0700 | [diff] [blame] | 839 | htc_stop(gp_cds_context->htc_ctx); |
| 840 | |
| 841 | exit_with_status: |
| 842 | return status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 843 | } |
| 844 | |
| 845 | /** |
| 846 | * cds_enable() - start/enable cds module |
Selvaraj, Sridhar | 0672a12 | 2016-12-29 16:11:48 +0530 | [diff] [blame] | 847 | * @psoc: Psoc pointer |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 848 | * @cds_context: CDS context |
| 849 | * |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 850 | * Return: QDF status |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 851 | */ |
Jeff Johnson | 8f9dd5f | 2017-09-13 14:16:08 -0700 | [diff] [blame] | 852 | QDF_STATUS cds_enable(struct wlan_objmgr_psoc *psoc) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 853 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 854 | QDF_STATUS qdf_status = QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 855 | tHalMacStartParameters halStartParams; |
| 856 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 857 | /* We support only one instance for now ... */ |
Jeff Johnson | 8f9dd5f | 2017-09-13 14:16:08 -0700 | [diff] [blame] | 858 | if (!gp_cds_context) { |
Jeff Johnson | d0a6b2c | 2018-05-30 22:57:39 -0700 | [diff] [blame] | 859 | cds_err("Invalid CDS context"); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 860 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 861 | } |
| 862 | |
Jeff Johnson | 830f322 | 2018-05-29 15:58:18 -0700 | [diff] [blame] | 863 | if ((!gp_cds_context->wma_context) || |
Jeff Johnson | 528c2cf | 2018-05-29 15:55:58 -0700 | [diff] [blame] | 864 | (gp_cds_context->mac_context == NULL)) { |
Jeff Johnson | 830f322 | 2018-05-29 15:58:18 -0700 | [diff] [blame] | 865 | if (!gp_cds_context->wma_context) |
Jeff Johnson | d0a6b2c | 2018-05-30 22:57:39 -0700 | [diff] [blame] | 866 | cds_err("WMA NULL context"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 867 | else |
Jeff Johnson | d0a6b2c | 2018-05-30 22:57:39 -0700 | [diff] [blame] | 868 | cds_err("MAC NULL context"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 869 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 870 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 871 | } |
| 872 | |
| 873 | /* Start the wma */ |
Jeff Johnson | d489255 | 2017-09-13 08:41:31 -0700 | [diff] [blame] | 874 | qdf_status = wma_start(); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 875 | if (qdf_status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | d0a6b2c | 2018-05-30 22:57:39 -0700 | [diff] [blame] | 876 | cds_err("Failed to start wma"); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 877 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 878 | } |
Jeff Johnson | d0a6b2c | 2018-05-30 22:57:39 -0700 | [diff] [blame] | 879 | cds_info("wma correctly started"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 880 | |
| 881 | /* Start the MAC */ |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 882 | qdf_mem_zero(&halStartParams, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 883 | sizeof(tHalMacStartParameters)); |
| 884 | |
| 885 | /* Start the MAC */ |
Jeff Johnson | ac99e47 | 2018-06-07 23:00:08 -0700 | [diff] [blame] | 886 | qdf_status = mac_start(gp_cds_context->mac_context, &halStartParams); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 887 | |
Jeff Johnson | ac99e47 | 2018-06-07 23:00:08 -0700 | [diff] [blame] | 888 | if (QDF_STATUS_SUCCESS != qdf_status) { |
Jeff Johnson | d0a6b2c | 2018-05-30 22:57:39 -0700 | [diff] [blame] | 889 | cds_alert("Failed to start MAC"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 890 | goto err_wma_stop; |
| 891 | } |
| 892 | |
Jeff Johnson | d0a6b2c | 2018-05-30 22:57:39 -0700 | [diff] [blame] | 893 | cds_info("MAC correctly started"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 894 | |
| 895 | /* START SME */ |
Jeff Johnson | 528c2cf | 2018-05-29 15:55:58 -0700 | [diff] [blame] | 896 | qdf_status = sme_start(gp_cds_context->mac_context); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 897 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 898 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
Jeff Johnson | d0a6b2c | 2018-05-30 22:57:39 -0700 | [diff] [blame] | 899 | cds_alert("Failed to start SME"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 900 | goto err_mac_stop; |
| 901 | } |
| 902 | |
Jeff Johnson | d0a6b2c | 2018-05-30 22:57:39 -0700 | [diff] [blame] | 903 | cds_info("SME correctly started"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 904 | |
Leo Chang | 9b09703 | 2016-10-28 11:03:17 -0700 | [diff] [blame] | 905 | if (cdp_soc_attach_target(cds_get_context(QDF_MODULE_ID_SOC))) { |
Jeff Johnson | d0a6b2c | 2018-05-30 22:57:39 -0700 | [diff] [blame] | 906 | cds_alert("Failed to attach soc target"); |
Leo Chang | 9b09703 | 2016-10-28 11:03:17 -0700 | [diff] [blame] | 907 | goto err_sme_stop; |
| 908 | } |
| 909 | |
| 910 | if (cdp_pdev_attach_target(cds_get_context(QDF_MODULE_ID_SOC), |
Venkata Sharath Chandra Manchala | 0d44d45 | 2016-11-23 17:48:15 -0800 | [diff] [blame] | 911 | (struct cdp_pdev *)cds_get_context(QDF_MODULE_ID_TXRX))) { |
Jeff Johnson | d0a6b2c | 2018-05-30 22:57:39 -0700 | [diff] [blame] | 912 | cds_alert("Failed to attach pdev target"); |
Leo Chang | 9b09703 | 2016-10-28 11:03:17 -0700 | [diff] [blame] | 913 | goto err_soc_target_detach; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 914 | } |
| 915 | |
Jeff Johnson | d0a6b2c | 2018-05-30 22:57:39 -0700 | [diff] [blame] | 916 | cds_info("CDS Start is successful!!"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 917 | |
Min Liu | 81f2ed3 | 2018-01-08 14:21:02 +0800 | [diff] [blame] | 918 | qdf_status = dispatcher_psoc_enable(psoc); |
| 919 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
Jeff Johnson | d0a6b2c | 2018-05-30 22:57:39 -0700 | [diff] [blame] | 920 | cds_alert("dispatcher_psoc_enable failed"); |
Min Liu | 81f2ed3 | 2018-01-08 14:21:02 +0800 | [diff] [blame] | 921 | goto err_soc_target_detach; |
| 922 | } |
Rajeev Kumar | 97767a0 | 2016-11-30 11:20:40 -0800 | [diff] [blame] | 923 | |
Nachiket Kukade | 98f562a | 2017-12-15 12:18:07 +0530 | [diff] [blame] | 924 | /* Trigger psoc enable for CLD components */ |
| 925 | hdd_component_psoc_enable(psoc); |
| 926 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 927 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 928 | |
Leo Chang | 9b09703 | 2016-10-28 11:03:17 -0700 | [diff] [blame] | 929 | err_soc_target_detach: |
| 930 | /* NOOP */ |
| 931 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 932 | err_sme_stop: |
Jeff Johnson | 528c2cf | 2018-05-29 15:55:58 -0700 | [diff] [blame] | 933 | sme_stop(gp_cds_context->mac_context, HAL_STOP_TYPE_SYS_RESET); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 934 | |
| 935 | err_mac_stop: |
Jeff Johnson | 528c2cf | 2018-05-29 15:55:58 -0700 | [diff] [blame] | 936 | mac_stop(gp_cds_context->mac_context, HAL_STOP_TYPE_SYS_RESET); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 937 | |
| 938 | err_wma_stop: |
Jeff Johnson | 2ccd815 | 2018-05-29 16:02:23 -0700 | [diff] [blame] | 939 | qdf_event_reset(&gp_cds_context->wma_complete_event); |
Jeff Johnson | acc1cc7 | 2017-09-13 08:47:49 -0700 | [diff] [blame] | 940 | qdf_status = wma_stop(HAL_STOP_TYPE_RF_KILL); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 941 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
Jeff Johnson | d0a6b2c | 2018-05-30 22:57:39 -0700 | [diff] [blame] | 942 | cds_err("Failed to stop wma"); |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 943 | QDF_ASSERT(QDF_IS_STATUS_SUCCESS(qdf_status)); |
Jeff Johnson | 1f8d0a0 | 2017-09-13 08:09:05 -0700 | [diff] [blame] | 944 | wma_setneedshutdown(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 945 | } else { |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 946 | qdf_status = |
Nachiket Kukade | 0396b73 | 2017-11-14 16:35:16 +0530 | [diff] [blame] | 947 | qdf_wait_for_event_completion( |
Jeff Johnson | 2ccd815 | 2018-05-29 16:02:23 -0700 | [diff] [blame] | 948 | &gp_cds_context->wma_complete_event, |
Nachiket Kukade | 0396b73 | 2017-11-14 16:35:16 +0530 | [diff] [blame] | 949 | CDS_WMA_TIMEOUT); |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 950 | if (qdf_status != QDF_STATUS_SUCCESS) { |
| 951 | if (qdf_status == QDF_STATUS_E_TIMEOUT) { |
Jeff Johnson | d0a6b2c | 2018-05-30 22:57:39 -0700 | [diff] [blame] | 952 | cds_alert("Timeout occurred before WMA_stop complete"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 953 | } else { |
Jeff Johnson | d0a6b2c | 2018-05-30 22:57:39 -0700 | [diff] [blame] | 954 | cds_alert("WMA_stop reporting other error"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 955 | } |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 956 | QDF_ASSERT(0); |
Jeff Johnson | 1f8d0a0 | 2017-09-13 08:09:05 -0700 | [diff] [blame] | 957 | wma_setneedshutdown(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 958 | } |
| 959 | } |
| 960 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 961 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 962 | } /* cds_enable() */ |
| 963 | |
| 964 | /** |
| 965 | * cds_disable() - stop/disable cds module |
Selvaraj, Sridhar | 0672a12 | 2016-12-29 16:11:48 +0530 | [diff] [blame] | 966 | * @psoc: Psoc pointer |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 967 | * |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 968 | * Return: QDF status |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 969 | */ |
Jeff Johnson | ea5c2aa1 | 2017-09-13 14:18:59 -0700 | [diff] [blame] | 970 | QDF_STATUS cds_disable(struct wlan_objmgr_psoc *psoc) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 971 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 972 | QDF_STATUS qdf_status; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 973 | void *handle; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 974 | |
Rajeev Kumar | 97767a0 | 2016-11-30 11:20:40 -0800 | [diff] [blame] | 975 | /* PSOC disable for all new components. It needs to happen before |
| 976 | * target is PDEV suspended such that a component can abort all its |
| 977 | * ongoing transaction with FW. Always keep it before wma_stop() as |
| 978 | * wma_stop() does target PDEV suspend. |
| 979 | */ |
Rajeev Kumar | 97767a0 | 2016-11-30 11:20:40 -0800 | [diff] [blame] | 980 | |
Nachiket Kukade | 98f562a | 2017-12-15 12:18:07 +0530 | [diff] [blame] | 981 | /* Trigger psoc disable for CLD components */ |
| 982 | if (psoc) { |
| 983 | hdd_component_psoc_disable(psoc); |
Jiachao Wu | 341d075 | 2018-01-02 15:20:32 +0800 | [diff] [blame] | 984 | dispatcher_psoc_disable(psoc); |
Nachiket Kukade | 98f562a | 2017-12-15 12:18:07 +0530 | [diff] [blame] | 985 | } |
Rajeev Kumar | 97767a0 | 2016-11-30 11:20:40 -0800 | [diff] [blame] | 986 | |
Jeff Johnson | acc1cc7 | 2017-09-13 08:47:49 -0700 | [diff] [blame] | 987 | qdf_status = wma_stop(HAL_STOP_TYPE_RF_KILL); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 988 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 989 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 990 | cds_err("Failed to stop wma"); |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 991 | QDF_ASSERT(QDF_IS_STATUS_SUCCESS(qdf_status)); |
Jeff Johnson | 1f8d0a0 | 2017-09-13 08:09:05 -0700 | [diff] [blame] | 992 | wma_setneedshutdown(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 993 | } |
| 994 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 995 | handle = cds_get_context(QDF_MODULE_ID_PE); |
| 996 | if (!handle) { |
| 997 | cds_err("Invalid PE context return!"); |
| 998 | return QDF_STATUS_E_INVAL; |
| 999 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1000 | |
Naveen Rawat | bcd3d01 | 2017-12-05 11:11:55 -0800 | [diff] [blame] | 1001 | umac_stop(); |
Arun Khandavalli | 55f890b | 2016-08-31 18:14:56 +0530 | [diff] [blame] | 1002 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 1003 | return qdf_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1004 | } |
| 1005 | |
Govind Singh | b048e87 | 2016-09-27 22:07:43 +0530 | [diff] [blame] | 1006 | #ifdef HIF_USB |
| 1007 | static inline void cds_suspend_target(tp_wma_handle wma_handle) |
| 1008 | { |
| 1009 | QDF_STATUS status; |
| 1010 | /* Suspend the target and disable interrupt */ |
Mukul Sharma | 4c60a7e | 2017-03-06 19:42:18 +0530 | [diff] [blame] | 1011 | status = pmo_ucfg_psoc_suspend_target(wma_handle->psoc, 0); |
Govind Singh | b048e87 | 2016-09-27 22:07:43 +0530 | [diff] [blame] | 1012 | if (status) |
| 1013 | cds_err("Failed to suspend target, status = %d", status); |
| 1014 | } |
| 1015 | #else |
| 1016 | static inline void cds_suspend_target(tp_wma_handle wma_handle) |
| 1017 | { |
| 1018 | QDF_STATUS status; |
| 1019 | /* Suspend the target and disable interrupt */ |
Mukul Sharma | 4c60a7e | 2017-03-06 19:42:18 +0530 | [diff] [blame] | 1020 | status = pmo_ucfg_psoc_suspend_target(wma_handle->psoc, 1); |
Govind Singh | b048e87 | 2016-09-27 22:07:43 +0530 | [diff] [blame] | 1021 | if (status) |
| 1022 | cds_err("Failed to suspend target, status = %d", status); |
| 1023 | } |
| 1024 | #endif /* HIF_USB */ |
| 1025 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1026 | /** |
Govind Singh | b048e87 | 2016-09-27 22:07:43 +0530 | [diff] [blame] | 1027 | * cds_post_disable() - post disable cds module |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1028 | * |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 1029 | * Return: QDF status |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1030 | */ |
Rajeev Kumar | be02124 | 2017-02-16 16:12:23 -0800 | [diff] [blame] | 1031 | QDF_STATUS cds_post_disable(void) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1032 | { |
Arun Khandavalli | 55f890b | 2016-08-31 18:14:56 +0530 | [diff] [blame] | 1033 | tp_wma_handle wma_handle; |
Govind Singh | b048e87 | 2016-09-27 22:07:43 +0530 | [diff] [blame] | 1034 | struct hif_opaque_softc *hif_ctx; |
Himanshu Agarwal | 0b9bbc3 | 2017-02-23 16:23:05 +0530 | [diff] [blame] | 1035 | struct cdp_pdev *txrx_pdev; |
| 1036 | |
Arun Khandavalli | 55f890b | 2016-08-31 18:14:56 +0530 | [diff] [blame] | 1037 | wma_handle = cds_get_context(QDF_MODULE_ID_WMA); |
| 1038 | if (!wma_handle) { |
| 1039 | cds_err("Failed to get wma_handle!"); |
| 1040 | return QDF_STATUS_E_INVAL; |
| 1041 | } |
| 1042 | |
Govind Singh | b048e87 | 2016-09-27 22:07:43 +0530 | [diff] [blame] | 1043 | hif_ctx = cds_get_context(QDF_MODULE_ID_HIF); |
| 1044 | if (!hif_ctx) { |
| 1045 | cds_err("Failed to get hif_handle!"); |
| 1046 | return QDF_STATUS_E_INVAL; |
| 1047 | } |
| 1048 | |
Himanshu Agarwal | 0b9bbc3 | 2017-02-23 16:23:05 +0530 | [diff] [blame] | 1049 | txrx_pdev = cds_get_context(QDF_MODULE_ID_TXRX); |
| 1050 | if (!txrx_pdev) { |
| 1051 | cds_err("Failed to get txrx pdev!"); |
| 1052 | return QDF_STATUS_E_INVAL; |
| 1053 | } |
| 1054 | |
Arun Khandavalli | 55f890b | 2016-08-31 18:14:56 +0530 | [diff] [blame] | 1055 | /* |
| 1056 | * With new state machine changes cds_close can be invoked without |
| 1057 | * cds_disable. So, send the following clean up prerequisites to fw, |
| 1058 | * So Fw and host are in sync for cleanup indication: |
| 1059 | * - Send PDEV_SUSPEND indication to firmware |
| 1060 | * - Disable HIF Interrupts. |
| 1061 | * - Clean up CE tasklets. |
| 1062 | */ |
| 1063 | |
Hanumanth Reddy Pothula | 2a8a740 | 2017-07-03 14:06:11 +0530 | [diff] [blame] | 1064 | cds_info("send deinit sequence to firmware"); |
| 1065 | if (!(cds_is_driver_recovering() || cds_is_driver_in_bad_state())) |
Govind Singh | b048e87 | 2016-09-27 22:07:43 +0530 | [diff] [blame] | 1066 | cds_suspend_target(wma_handle); |
| 1067 | hif_disable_isr(hif_ctx); |
| 1068 | hif_reset_soc(hif_ctx); |
| 1069 | |
Wu Gao | 9a24fa7 | 2017-07-28 18:32:22 +0800 | [diff] [blame] | 1070 | if (gp_cds_context->htc_ctx) { |
Kabilan Kannan | fc3a8c0 | 2018-02-21 13:36:29 -0800 | [diff] [blame] | 1071 | wma_wmi_stop(); |
Wu Gao | 9a24fa7 | 2017-07-28 18:32:22 +0800 | [diff] [blame] | 1072 | htc_stop(gp_cds_context->htc_ctx); |
| 1073 | } |
| 1074 | |
Himanshu Agarwal | 0b9bbc3 | 2017-02-23 16:23:05 +0530 | [diff] [blame] | 1075 | cdp_pdev_pre_detach(cds_get_context(QDF_MODULE_ID_SOC), |
| 1076 | (struct cdp_pdev *)txrx_pdev, 1); |
| 1077 | |
Govind Singh | b048e87 | 2016-09-27 22:07:43 +0530 | [diff] [blame] | 1078 | return QDF_STATUS_SUCCESS; |
| 1079 | } |
| 1080 | |
| 1081 | /** |
| 1082 | * cds_close() - close cds module |
Selvaraj, Sridhar | 0672a12 | 2016-12-29 16:11:48 +0530 | [diff] [blame] | 1083 | * @psoc: Psoc pointer |
Govind Singh | b048e87 | 2016-09-27 22:07:43 +0530 | [diff] [blame] | 1084 | * |
| 1085 | * This API allows user to close modules registered |
| 1086 | * with connectivity device services. |
| 1087 | * |
| 1088 | * Return: QDF status |
| 1089 | */ |
Jeff Johnson | e4b1459 | 2017-09-13 14:23:33 -0700 | [diff] [blame] | 1090 | QDF_STATUS cds_close(struct wlan_objmgr_psoc *psoc) |
Govind Singh | b048e87 | 2016-09-27 22:07:43 +0530 | [diff] [blame] | 1091 | { |
| 1092 | QDF_STATUS qdf_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1093 | |
Dustin Brown | d33276b | 2017-11-29 11:08:11 -0800 | [diff] [blame] | 1094 | qdf_status = cds_sched_close(); |
| 1095 | QDF_ASSERT(QDF_IS_STATUS_SUCCESS(qdf_status)); |
| 1096 | if (QDF_IS_STATUS_ERROR(qdf_status)) |
| 1097 | cds_err("Failed to close CDS Scheduler"); |
| 1098 | |
Dustin Brown | 44cde35 | 2017-12-04 13:14:46 -0800 | [diff] [blame] | 1099 | qdf_status = dispatcher_disable(); |
| 1100 | QDF_ASSERT(QDF_IS_STATUS_SUCCESS(qdf_status)); |
| 1101 | if (QDF_IS_STATUS_ERROR(qdf_status)) |
| 1102 | cds_err("Failed to disable dispatcher; status:%d", qdf_status); |
| 1103 | |
Amar Singhal | 966397f | 2017-04-06 18:28:56 -0700 | [diff] [blame] | 1104 | dispatcher_psoc_close(psoc); |
| 1105 | |
Jeff Johnson | 6b8473d | 2017-09-13 09:20:53 -0700 | [diff] [blame] | 1106 | qdf_status = wma_wmi_work_close(); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1107 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
Jeff Johnson | d0a6b2c | 2018-05-30 22:57:39 -0700 | [diff] [blame] | 1108 | cds_err("Failed to close wma_wmi_work"); |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 1109 | QDF_ASSERT(0); |
Xun Luo | a858a47 | 2015-11-10 08:24:45 -0800 | [diff] [blame] | 1110 | } |
| 1111 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1112 | if (gp_cds_context->htc_ctx) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1113 | htc_destroy(gp_cds_context->htc_ctx); |
Mukul Sharma | 4c60a7e | 2017-03-06 19:42:18 +0530 | [diff] [blame] | 1114 | pmo_ucfg_psoc_update_htc_handle(psoc, NULL); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1115 | gp_cds_context->htc_ctx = NULL; |
| 1116 | } |
| 1117 | |
Jeff Johnson | 528c2cf | 2018-05-29 15:55:58 -0700 | [diff] [blame] | 1118 | qdf_status = sme_close(gp_cds_context->mac_context); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1119 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
Jeff Johnson | d0a6b2c | 2018-05-30 22:57:39 -0700 | [diff] [blame] | 1120 | cds_err("Failed to close SME"); |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 1121 | QDF_ASSERT(QDF_IS_STATUS_SUCCESS(qdf_status)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1122 | } |
| 1123 | |
Jeff Johnson | 528c2cf | 2018-05-29 15:55:58 -0700 | [diff] [blame] | 1124 | qdf_status = mac_close(gp_cds_context->mac_context); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1125 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
Jeff Johnson | d0a6b2c | 2018-05-30 22:57:39 -0700 | [diff] [blame] | 1126 | cds_err("Failed to close MAC"); |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 1127 | QDF_ASSERT(QDF_IS_STATUS_SUCCESS(qdf_status)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1128 | } |
| 1129 | |
Jeff Johnson | 528c2cf | 2018-05-29 15:55:58 -0700 | [diff] [blame] | 1130 | gp_cds_context->mac_context = NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1131 | |
Houston Hoffman | be58cc5 | 2016-12-19 16:26:44 -0800 | [diff] [blame] | 1132 | cdp_soc_detach(gp_cds_context->dp_soc); |
Sravan Kumar Kairam | 2729678 | 2017-04-21 22:04:18 +0530 | [diff] [blame] | 1133 | pmo_ucfg_psoc_update_dp_handle(psoc, NULL); |
Lin Bai | 362e52b | 2018-05-07 14:42:50 +0800 | [diff] [blame] | 1134 | wlan_psoc_set_dp_handle(psoc, NULL); |
Houston Hoffman | be58cc5 | 2016-12-19 16:26:44 -0800 | [diff] [blame] | 1135 | |
Rajeev Kumar | 662d75d | 2017-03-13 18:11:29 -0700 | [diff] [blame] | 1136 | cds_shutdown_notifier_purge(); |
| 1137 | |
Jeff Johnson | 1b5404e | 2017-09-13 08:04:46 -0700 | [diff] [blame] | 1138 | if (true == wma_needshutdown()) { |
Jeff Johnson | d0a6b2c | 2018-05-30 22:57:39 -0700 | [diff] [blame] | 1139 | cds_err("Failed to shutdown wma"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1140 | } else { |
Jeff Johnson | 542da35 | 2017-09-13 09:17:28 -0700 | [diff] [blame] | 1141 | qdf_status = wma_close(); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1142 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
Jeff Johnson | d0a6b2c | 2018-05-30 22:57:39 -0700 | [diff] [blame] | 1143 | cds_err("Failed to close wma"); |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 1144 | QDF_ASSERT(QDF_IS_STATUS_SUCCESS(qdf_status)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1145 | } |
| 1146 | } |
| 1147 | |
Jeff Johnson | 7b3ddc2 | 2017-09-13 09:42:44 -0700 | [diff] [blame] | 1148 | qdf_status = wma_wmi_service_close(); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1149 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
Jeff Johnson | d0a6b2c | 2018-05-30 22:57:39 -0700 | [diff] [blame] | 1150 | cds_err("Failed to close wma_wmi_service"); |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 1151 | QDF_ASSERT(QDF_IS_STATUS_SUCCESS(qdf_status)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1152 | } |
| 1153 | |
Jeff Johnson | 2ccd815 | 2018-05-29 16:02:23 -0700 | [diff] [blame] | 1154 | qdf_status = qdf_event_destroy(&gp_cds_context->wma_complete_event); |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 1155 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
Jeff Johnson | d0a6b2c | 2018-05-30 22:57:39 -0700 | [diff] [blame] | 1156 | cds_err("failed to destroy wma_complete_event"); |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 1157 | QDF_ASSERT(QDF_IS_STATUS_SUCCESS(qdf_status)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1158 | } |
| 1159 | |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 1160 | cds_deinit_ini_config(); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 1161 | qdf_timer_module_deinit(); |
| 1162 | |
Krunal Soni | d32c6bc | 2016-10-18 18:00:21 -0700 | [diff] [blame] | 1163 | cds_deregister_all_modules(); |
Rajeev Kumar | 97767a0 | 2016-11-30 11:20:40 -0800 | [diff] [blame] | 1164 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1165 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1166 | } |
| 1167 | |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 1168 | QDF_STATUS cds_dp_close(struct wlan_objmgr_psoc *psoc) |
| 1169 | { |
| 1170 | void *ctx; |
| 1171 | |
| 1172 | cdp_txrx_intr_detach(gp_cds_context->dp_soc); |
| 1173 | |
| 1174 | ctx = cds_get_context(QDF_MODULE_ID_TXRX); |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 1175 | cdp_pdev_detach(cds_get_context(QDF_MODULE_ID_SOC), |
| 1176 | (struct cdp_pdev *)ctx, 1); |
psimha | deea0a1 | 2017-12-18 14:50:02 -0800 | [diff] [blame] | 1177 | cds_set_context(QDF_MODULE_ID_TXRX, NULL); |
| 1178 | pmo_ucfg_psoc_set_txrx_handle(psoc, NULL); |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 1179 | |
| 1180 | return QDF_STATUS_SUCCESS; |
| 1181 | } |
| 1182 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1183 | /** |
| 1184 | * cds_get_context() - get context data area |
| 1185 | * |
Jeff Johnson | b3be6a6 | 2018-05-30 18:50:12 -0700 | [diff] [blame] | 1186 | * @module_id: ID of the module who's context data is being retrieved. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1187 | * |
| 1188 | * Each module in the system has a context / data area that is allocated |
| 1189 | * and managed by CDS. This API allows any user to get a pointer to its |
| 1190 | * allocated context data area from the CDS global context. |
| 1191 | * |
| 1192 | * Return: pointer to the context data area of the module ID |
| 1193 | * specified, or NULL if the context data is not allocated for |
| 1194 | * the module ID specified |
| 1195 | */ |
Jeff Johnson | b3be6a6 | 2018-05-30 18:50:12 -0700 | [diff] [blame] | 1196 | void *cds_get_context(QDF_MODULE_ID module_id) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1197 | { |
Jeff Johnson | 835b760 | 2018-05-30 19:06:24 -0700 | [diff] [blame] | 1198 | void *context = NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1199 | |
| 1200 | if (gp_cds_context == NULL) { |
Jeff Johnson | d0a6b2c | 2018-05-30 22:57:39 -0700 | [diff] [blame] | 1201 | cds_err("cds context pointer is null"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1202 | return NULL; |
| 1203 | } |
| 1204 | |
Jeff Johnson | b3be6a6 | 2018-05-30 18:50:12 -0700 | [diff] [blame] | 1205 | switch (module_id) { |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 1206 | case QDF_MODULE_ID_HDD: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1207 | { |
Jeff Johnson | 835b760 | 2018-05-30 19:06:24 -0700 | [diff] [blame] | 1208 | context = gp_cds_context->hdd_context; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1209 | break; |
| 1210 | } |
| 1211 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 1212 | case QDF_MODULE_ID_SME: |
| 1213 | case QDF_MODULE_ID_PE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1214 | { |
| 1215 | /* In all these cases, we just return the MAC Context */ |
Jeff Johnson | 835b760 | 2018-05-30 19:06:24 -0700 | [diff] [blame] | 1216 | context = gp_cds_context->mac_context; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1217 | break; |
| 1218 | } |
| 1219 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 1220 | case QDF_MODULE_ID_WMA: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1221 | { |
| 1222 | /* For wma module */ |
Jeff Johnson | 835b760 | 2018-05-30 19:06:24 -0700 | [diff] [blame] | 1223 | context = gp_cds_context->wma_context; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1224 | break; |
| 1225 | } |
| 1226 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 1227 | case QDF_MODULE_ID_QDF: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1228 | { |
| 1229 | /* For SYS this is CDS itself */ |
Jeff Johnson | 835b760 | 2018-05-30 19:06:24 -0700 | [diff] [blame] | 1230 | context = gp_cds_context; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1231 | break; |
| 1232 | } |
| 1233 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 1234 | case QDF_MODULE_ID_HIF: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1235 | { |
Jeff Johnson | 835b760 | 2018-05-30 19:06:24 -0700 | [diff] [blame] | 1236 | context = gp_cds_context->hif_context; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1237 | break; |
| 1238 | } |
| 1239 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 1240 | case QDF_MODULE_ID_HTC: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1241 | { |
Jeff Johnson | 835b760 | 2018-05-30 19:06:24 -0700 | [diff] [blame] | 1242 | context = gp_cds_context->htc_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1243 | break; |
| 1244 | } |
| 1245 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 1246 | case QDF_MODULE_ID_QDF_DEVICE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1247 | { |
Jeff Johnson | 835b760 | 2018-05-30 19:06:24 -0700 | [diff] [blame] | 1248 | context = gp_cds_context->qdf_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1249 | break; |
| 1250 | } |
| 1251 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 1252 | case QDF_MODULE_ID_BMI: |
Komal Seelam | d910649 | 2016-02-15 10:31:44 +0530 | [diff] [blame] | 1253 | { |
Jeff Johnson | 835b760 | 2018-05-30 19:06:24 -0700 | [diff] [blame] | 1254 | context = gp_cds_context->g_ol_context; |
Komal Seelam | d910649 | 2016-02-15 10:31:44 +0530 | [diff] [blame] | 1255 | break; |
| 1256 | } |
| 1257 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 1258 | case QDF_MODULE_ID_TXRX: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1259 | { |
Jeff Johnson | 835b760 | 2018-05-30 19:06:24 -0700 | [diff] [blame] | 1260 | context = (void *)gp_cds_context->pdev_txrx_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1261 | break; |
| 1262 | } |
| 1263 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 1264 | case QDF_MODULE_ID_CFG: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1265 | { |
Jeff Johnson | 835b760 | 2018-05-30 19:06:24 -0700 | [diff] [blame] | 1266 | context = gp_cds_context->cfg_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1267 | break; |
| 1268 | } |
| 1269 | |
Leo Chang | 9b09703 | 2016-10-28 11:03:17 -0700 | [diff] [blame] | 1270 | case QDF_MODULE_ID_SOC: |
| 1271 | { |
Jeff Johnson | 835b760 | 2018-05-30 19:06:24 -0700 | [diff] [blame] | 1272 | context = gp_cds_context->dp_soc; |
Leo Chang | 9b09703 | 2016-10-28 11:03:17 -0700 | [diff] [blame] | 1273 | break; |
| 1274 | } |
| 1275 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1276 | default: |
| 1277 | { |
Jeff Johnson | d0a6b2c | 2018-05-30 22:57:39 -0700 | [diff] [blame] | 1278 | cds_err("Module ID %i does not have its context maintained by CDS", |
| 1279 | module_id); |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 1280 | QDF_ASSERT(0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1281 | return NULL; |
| 1282 | } |
| 1283 | } |
| 1284 | |
Jeff Johnson | 835b760 | 2018-05-30 19:06:24 -0700 | [diff] [blame] | 1285 | if (!context) |
Jeff Johnson | d0a6b2c | 2018-05-30 22:57:39 -0700 | [diff] [blame] | 1286 | cds_err("Module ID %i context is Null", module_id); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1287 | |
Jeff Johnson | 835b760 | 2018-05-30 19:06:24 -0700 | [diff] [blame] | 1288 | return context; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1289 | } /* cds_get_context() */ |
| 1290 | |
| 1291 | /** |
| 1292 | * cds_get_global_context() - get CDS global Context |
| 1293 | * |
| 1294 | * This API allows any user to get the CDS Global Context pointer from a |
| 1295 | * module context data area. |
| 1296 | * |
| 1297 | * Return: pointer to the CDS global context, NULL if the function is |
Jeff Johnson | 6bb5d78 | 2018-05-11 14:52:18 -0700 | [diff] [blame] | 1298 | * unable to retrieve the CDS context. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1299 | */ |
Jeff Johnson | 31a6758 | 2017-09-26 14:54:28 -0700 | [diff] [blame] | 1300 | void *cds_get_global_context(void) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1301 | { |
| 1302 | if (gp_cds_context == NULL) { |
Ryan Hsu | ceddceb | 2016-04-28 10:20:14 -0700 | [diff] [blame] | 1303 | /* |
| 1304 | * To avoid recursive call, this should not change to |
| 1305 | * QDF_TRACE(). |
| 1306 | */ |
| 1307 | pr_err("%s: global cds context is NULL", __func__); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1308 | } |
| 1309 | |
| 1310 | return gp_cds_context; |
| 1311 | } /* cds_get_global_context() */ |
| 1312 | |
| 1313 | /** |
Prashanth Bhatta | 9e14305 | 2015-12-04 11:56:47 -0800 | [diff] [blame] | 1314 | * cds_get_driver_state() - Get current driver state |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1315 | * |
Prashanth Bhatta | 9e14305 | 2015-12-04 11:56:47 -0800 | [diff] [blame] | 1316 | * This API returns current driver state stored in global context. |
| 1317 | * |
| 1318 | * Return: Driver state enum |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1319 | */ |
Prashanth Bhatta | 9e14305 | 2015-12-04 11:56:47 -0800 | [diff] [blame] | 1320 | enum cds_driver_state cds_get_driver_state(void) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1321 | { |
| 1322 | if (gp_cds_context == NULL) { |
Jeff Johnson | d0a6b2c | 2018-05-30 22:57:39 -0700 | [diff] [blame] | 1323 | cds_err("global cds context is NULL"); |
Prashanth Bhatta | 9e14305 | 2015-12-04 11:56:47 -0800 | [diff] [blame] | 1324 | |
| 1325 | return CDS_DRIVER_STATE_UNINITIALIZED; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1326 | } |
| 1327 | |
Prashanth Bhatta | 9e14305 | 2015-12-04 11:56:47 -0800 | [diff] [blame] | 1328 | return gp_cds_context->driver_state; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1329 | } |
| 1330 | |
| 1331 | /** |
Prashanth Bhatta | 9e14305 | 2015-12-04 11:56:47 -0800 | [diff] [blame] | 1332 | * cds_set_driver_state() - Set current driver state |
| 1333 | * @state: Driver state to be set to. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1334 | * |
Prashanth Bhatta | 9e14305 | 2015-12-04 11:56:47 -0800 | [diff] [blame] | 1335 | * This API sets driver state to state. This API only sets the state and doesn't |
| 1336 | * clear states, please make sure to use cds_clear_driver_state to clear any |
| 1337 | * state if required. |
| 1338 | * |
| 1339 | * Return: None |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1340 | */ |
Prashanth Bhatta | 9e14305 | 2015-12-04 11:56:47 -0800 | [diff] [blame] | 1341 | void cds_set_driver_state(enum cds_driver_state state) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1342 | { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1343 | if (gp_cds_context == NULL) { |
Jeff Johnson | d0a6b2c | 2018-05-30 22:57:39 -0700 | [diff] [blame] | 1344 | cds_err("global cds context is NULL: %x", state); |
Prashanth Bhatta | 9e14305 | 2015-12-04 11:56:47 -0800 | [diff] [blame] | 1345 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1346 | return; |
| 1347 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1348 | |
Prashanth Bhatta | 9e14305 | 2015-12-04 11:56:47 -0800 | [diff] [blame] | 1349 | gp_cds_context->driver_state |= state; |
| 1350 | } |
| 1351 | |
| 1352 | /** |
| 1353 | * cds_clear_driver_state() - Clear current driver state |
| 1354 | * @state: Driver state to be cleared. |
| 1355 | * |
| 1356 | * This API clears driver state. This API only clears the state, please make |
| 1357 | * sure to use cds_set_driver_state to set any new states. |
| 1358 | * |
| 1359 | * Return: None |
| 1360 | */ |
| 1361 | void cds_clear_driver_state(enum cds_driver_state state) |
| 1362 | { |
| 1363 | if (gp_cds_context == NULL) { |
Jeff Johnson | d0a6b2c | 2018-05-30 22:57:39 -0700 | [diff] [blame] | 1364 | cds_err("global cds context is NULL: %x", state); |
Prashanth Bhatta | 9e14305 | 2015-12-04 11:56:47 -0800 | [diff] [blame] | 1365 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1366 | return; |
| 1367 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1368 | |
Prashanth Bhatta | 9e14305 | 2015-12-04 11:56:47 -0800 | [diff] [blame] | 1369 | gp_cds_context->driver_state &= ~state; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1370 | } |
| 1371 | |
Nachiket Kukade | 8003d25 | 2017-03-30 15:55:58 +0530 | [diff] [blame] | 1372 | enum cds_fw_state cds_get_fw_state(void) |
| 1373 | { |
| 1374 | if (gp_cds_context == NULL) { |
Jeff Johnson | d0a6b2c | 2018-05-30 22:57:39 -0700 | [diff] [blame] | 1375 | cds_err("global cds context is NULL"); |
Nachiket Kukade | 8003d25 | 2017-03-30 15:55:58 +0530 | [diff] [blame] | 1376 | |
| 1377 | return CDS_FW_STATE_UNINITIALIZED; |
| 1378 | } |
| 1379 | |
| 1380 | return gp_cds_context->fw_state; |
| 1381 | } |
| 1382 | |
| 1383 | void cds_set_fw_state(enum cds_fw_state state) |
| 1384 | { |
| 1385 | if (gp_cds_context == NULL) { |
Jeff Johnson | d0a6b2c | 2018-05-30 22:57:39 -0700 | [diff] [blame] | 1386 | cds_err("global cds context is NULL: %d", state); |
Nachiket Kukade | 8003d25 | 2017-03-30 15:55:58 +0530 | [diff] [blame] | 1387 | |
| 1388 | return; |
| 1389 | } |
| 1390 | |
| 1391 | qdf_atomic_set_bit(state, &gp_cds_context->fw_state); |
| 1392 | } |
| 1393 | |
| 1394 | void cds_clear_fw_state(enum cds_fw_state state) |
| 1395 | { |
| 1396 | if (gp_cds_context == NULL) { |
Jeff Johnson | d0a6b2c | 2018-05-30 22:57:39 -0700 | [diff] [blame] | 1397 | cds_err("global cds context is NULL: %d", state); |
Nachiket Kukade | 8003d25 | 2017-03-30 15:55:58 +0530 | [diff] [blame] | 1398 | |
| 1399 | return; |
| 1400 | } |
| 1401 | |
| 1402 | qdf_atomic_clear_bit(state, &gp_cds_context->fw_state); |
| 1403 | } |
| 1404 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1405 | /** |
| 1406 | * cds_alloc_context() - allocate a context within the CDS global Context |
Jeff Johnson | b3be6a6 | 2018-05-30 18:50:12 -0700 | [diff] [blame] | 1407 | * @module_id: module ID who's context area is being allocated. |
Jeff Johnson | 1326996 | 2018-05-30 19:16:46 -0700 | [diff] [blame] | 1408 | * @module_context: pointer to location where the pointer to the |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1409 | * allocated context is returned. Note this output pointer |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1410 | * is valid only if the API returns QDF_STATUS_SUCCESS |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1411 | * @param size: size of the context area to be allocated. |
| 1412 | * |
| 1413 | * This API allows any user to allocate a user context area within the |
| 1414 | * CDS Global Context. |
| 1415 | * |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 1416 | * Return: QDF status |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1417 | */ |
Jeff Johnson | b3be6a6 | 2018-05-30 18:50:12 -0700 | [diff] [blame] | 1418 | QDF_STATUS cds_alloc_context(QDF_MODULE_ID module_id, |
Jeff Johnson | 1326996 | 2018-05-30 19:16:46 -0700 | [diff] [blame] | 1419 | void **module_context, uint32_t size) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1420 | { |
Jeff Johnson | 835b760 | 2018-05-30 19:06:24 -0700 | [diff] [blame] | 1421 | void **cds_mod_context = NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1422 | |
Jeff Johnson | adb3b1c | 2017-09-13 10:42:36 -0700 | [diff] [blame] | 1423 | if (!gp_cds_context) { |
Jeff Johnson | d0a6b2c | 2018-05-30 22:57:39 -0700 | [diff] [blame] | 1424 | cds_err("cds context is null"); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1425 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1426 | } |
| 1427 | |
Jeff Johnson | 1326996 | 2018-05-30 19:16:46 -0700 | [diff] [blame] | 1428 | if (!module_context) { |
Jeff Johnson | d0a6b2c | 2018-05-30 22:57:39 -0700 | [diff] [blame] | 1429 | cds_err("null param passed"); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1430 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1431 | } |
| 1432 | |
Jeff Johnson | b3be6a6 | 2018-05-30 18:50:12 -0700 | [diff] [blame] | 1433 | switch (module_id) { |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 1434 | case QDF_MODULE_ID_WMA: |
Jeff Johnson | 835b760 | 2018-05-30 19:06:24 -0700 | [diff] [blame] | 1435 | cds_mod_context = &gp_cds_context->wma_context; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1436 | break; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1437 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 1438 | case QDF_MODULE_ID_HIF: |
Jeff Johnson | 835b760 | 2018-05-30 19:06:24 -0700 | [diff] [blame] | 1439 | cds_mod_context = &gp_cds_context->hif_context; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1440 | break; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1441 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 1442 | case QDF_MODULE_ID_BMI: |
Jeff Johnson | 835b760 | 2018-05-30 19:06:24 -0700 | [diff] [blame] | 1443 | cds_mod_context = &gp_cds_context->g_ol_context; |
Komal Seelam | d910649 | 2016-02-15 10:31:44 +0530 | [diff] [blame] | 1444 | break; |
Komal Seelam | d910649 | 2016-02-15 10:31:44 +0530 | [diff] [blame] | 1445 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1446 | default: |
Jeff Johnson | d0a6b2c | 2018-05-30 22:57:39 -0700 | [diff] [blame] | 1447 | cds_err("Module ID %i does not have its context allocated by CDS", |
| 1448 | module_id); |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 1449 | QDF_ASSERT(0); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1450 | return QDF_STATUS_E_INVAL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1451 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1452 | |
Jeff Johnson | 835b760 | 2018-05-30 19:06:24 -0700 | [diff] [blame] | 1453 | if (*cds_mod_context) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1454 | /* Context has already been allocated! |
| 1455 | * Prevent double allocation |
| 1456 | */ |
Jeff Johnson | d0a6b2c | 2018-05-30 22:57:39 -0700 | [diff] [blame] | 1457 | cds_err("Module ID %i context has already been allocated", |
| 1458 | module_id); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1459 | return QDF_STATUS_E_EXISTS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1460 | } |
| 1461 | |
| 1462 | /* Dynamically allocate the context for module */ |
| 1463 | |
Jeff Johnson | 1326996 | 2018-05-30 19:16:46 -0700 | [diff] [blame] | 1464 | *module_context = qdf_mem_malloc(size); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1465 | |
Jeff Johnson | 1326996 | 2018-05-30 19:16:46 -0700 | [diff] [blame] | 1466 | if (!*module_context) { |
Jeff Johnson | d0a6b2c | 2018-05-30 22:57:39 -0700 | [diff] [blame] | 1467 | cds_err("Failed to allocate Context for module ID %i", |
| 1468 | module_id); |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 1469 | QDF_ASSERT(0); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1470 | return QDF_STATUS_E_NOMEM; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1471 | } |
| 1472 | |
Jeff Johnson | 1326996 | 2018-05-30 19:16:46 -0700 | [diff] [blame] | 1473 | *cds_mod_context = *module_context; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1474 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1475 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1476 | } /* cds_alloc_context() */ |
| 1477 | |
| 1478 | /** |
Komal Seelam | ad5a90d | 2016-02-16 13:50:03 +0530 | [diff] [blame] | 1479 | * cds_set_context() - API to set context in global CDS Context |
Komal Seelam | 1aac198 | 2016-03-02 15:57:26 +0530 | [diff] [blame] | 1480 | * @module_id: Module ID |
Komal Seelam | ad5a90d | 2016-02-16 13:50:03 +0530 | [diff] [blame] | 1481 | * @context: Pointer to the Module Context |
| 1482 | * |
Komal Seelam | 1aac198 | 2016-03-02 15:57:26 +0530 | [diff] [blame] | 1483 | * API to set a MODULE Context in global CDS Context |
Komal Seelam | ad5a90d | 2016-02-16 13:50:03 +0530 | [diff] [blame] | 1484 | * |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1485 | * Return: QDF_STATUS |
Komal Seelam | ad5a90d | 2016-02-16 13:50:03 +0530 | [diff] [blame] | 1486 | */ |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 1487 | QDF_STATUS cds_set_context(QDF_MODULE_ID module_id, void *context) |
Komal Seelam | ad5a90d | 2016-02-16 13:50:03 +0530 | [diff] [blame] | 1488 | { |
Jeff Johnson | 2b6982c | 2018-05-29 14:56:11 -0700 | [diff] [blame] | 1489 | struct cds_context *p_cds_context = cds_get_global_context(); |
Komal Seelam | ad5a90d | 2016-02-16 13:50:03 +0530 | [diff] [blame] | 1490 | |
| 1491 | if (!p_cds_context) { |
Jeff Johnson | d0a6b2c | 2018-05-30 22:57:39 -0700 | [diff] [blame] | 1492 | cds_err("cds context is Invalid"); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1493 | return QDF_STATUS_NOT_INITIALIZED; |
Komal Seelam | ad5a90d | 2016-02-16 13:50:03 +0530 | [diff] [blame] | 1494 | } |
| 1495 | |
| 1496 | switch (module_id) { |
Jeff Johnson | 3543fb2 | 2017-09-24 13:44:13 -0700 | [diff] [blame] | 1497 | case QDF_MODULE_ID_HDD: |
Jeff Johnson | 323a6f0 | 2018-05-29 15:09:12 -0700 | [diff] [blame] | 1498 | p_cds_context->hdd_context = context; |
Jeff Johnson | 3543fb2 | 2017-09-24 13:44:13 -0700 | [diff] [blame] | 1499 | break; |
Houston Hoffman | 57c36d7 | 2017-01-30 12:47:02 -0800 | [diff] [blame] | 1500 | case QDF_MODULE_ID_TXRX: |
| 1501 | p_cds_context->pdev_txrx_ctx = context; |
| 1502 | break; |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 1503 | case QDF_MODULE_ID_HIF: |
Jeff Johnson | a40e21c | 2018-05-29 15:59:57 -0700 | [diff] [blame] | 1504 | p_cds_context->hif_context = context; |
Komal Seelam | ad5a90d | 2016-02-16 13:50:03 +0530 | [diff] [blame] | 1505 | break; |
| 1506 | default: |
Jeff Johnson | d0a6b2c | 2018-05-30 22:57:39 -0700 | [diff] [blame] | 1507 | cds_err("Module ID %i does not have its context managed by CDS", |
| 1508 | module_id); |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 1509 | QDF_ASSERT(0); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1510 | return QDF_STATUS_E_INVAL; |
Komal Seelam | ad5a90d | 2016-02-16 13:50:03 +0530 | [diff] [blame] | 1511 | } |
| 1512 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1513 | return QDF_STATUS_SUCCESS; |
Komal Seelam | ad5a90d | 2016-02-16 13:50:03 +0530 | [diff] [blame] | 1514 | } |
| 1515 | |
| 1516 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1517 | * cds_free_context() - free an allocated context within the |
| 1518 | * CDS global Context |
Jeff Johnson | b3be6a6 | 2018-05-30 18:50:12 -0700 | [diff] [blame] | 1519 | * @module_id: module ID who's context area is being free |
Jeff Johnson | 1326996 | 2018-05-30 19:16:46 -0700 | [diff] [blame] | 1520 | * @module_context: pointer to module context area to be free'd. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1521 | * |
| 1522 | * This API allows a user to free the user context area within the |
| 1523 | * CDS Global Context. |
| 1524 | * |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 1525 | * Return: QDF status |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1526 | */ |
Jeff Johnson | 1326996 | 2018-05-30 19:16:46 -0700 | [diff] [blame] | 1527 | QDF_STATUS cds_free_context(QDF_MODULE_ID module_id, void *module_context) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1528 | { |
Jeff Johnson | 835b760 | 2018-05-30 19:06:24 -0700 | [diff] [blame] | 1529 | void **cds_mod_context = NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1530 | |
Jeff Johnson | adb3b1c | 2017-09-13 10:42:36 -0700 | [diff] [blame] | 1531 | if (!gp_cds_context) { |
Jeff Johnson | d0a6b2c | 2018-05-30 22:57:39 -0700 | [diff] [blame] | 1532 | cds_err("cds context is null"); |
Jeff Johnson | adb3b1c | 2017-09-13 10:42:36 -0700 | [diff] [blame] | 1533 | return QDF_STATUS_E_FAILURE; |
| 1534 | } |
| 1535 | |
Jeff Johnson | 1326996 | 2018-05-30 19:16:46 -0700 | [diff] [blame] | 1536 | if (!module_context) { |
Jeff Johnson | d0a6b2c | 2018-05-30 22:57:39 -0700 | [diff] [blame] | 1537 | cds_err("Null param"); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1538 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1539 | } |
| 1540 | |
Jeff Johnson | b3be6a6 | 2018-05-30 18:50:12 -0700 | [diff] [blame] | 1541 | switch (module_id) { |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 1542 | case QDF_MODULE_ID_WMA: |
Jeff Johnson | 835b760 | 2018-05-30 19:06:24 -0700 | [diff] [blame] | 1543 | cds_mod_context = &gp_cds_context->wma_context; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1544 | break; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1545 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 1546 | case QDF_MODULE_ID_HIF: |
Jeff Johnson | 835b760 | 2018-05-30 19:06:24 -0700 | [diff] [blame] | 1547 | cds_mod_context = &gp_cds_context->hif_context; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1548 | break; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1549 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 1550 | case QDF_MODULE_ID_TXRX: |
Jeff Johnson | 835b760 | 2018-05-30 19:06:24 -0700 | [diff] [blame] | 1551 | cds_mod_context = (void **)&gp_cds_context->pdev_txrx_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1552 | break; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1553 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 1554 | case QDF_MODULE_ID_BMI: |
Jeff Johnson | 835b760 | 2018-05-30 19:06:24 -0700 | [diff] [blame] | 1555 | cds_mod_context = &gp_cds_context->g_ol_context; |
Komal Seelam | d910649 | 2016-02-15 10:31:44 +0530 | [diff] [blame] | 1556 | break; |
Komal Seelam | d910649 | 2016-02-15 10:31:44 +0530 | [diff] [blame] | 1557 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1558 | default: |
Jeff Johnson | d0a6b2c | 2018-05-30 22:57:39 -0700 | [diff] [blame] | 1559 | cds_err("Module ID %i does not have its context allocated by CDS", |
| 1560 | module_id); |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 1561 | QDF_ASSERT(0); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1562 | return QDF_STATUS_E_INVAL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1563 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1564 | |
Jeff Johnson | 835b760 | 2018-05-30 19:06:24 -0700 | [diff] [blame] | 1565 | if (!*cds_mod_context) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1566 | /* Context has not been allocated or freed already! */ |
Jeff Johnson | d0a6b2c | 2018-05-30 22:57:39 -0700 | [diff] [blame] | 1567 | cds_err("Module ID %i context has not been allocated or freed already", |
| 1568 | module_id); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1569 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1570 | } |
| 1571 | |
Jeff Johnson | 1326996 | 2018-05-30 19:16:46 -0700 | [diff] [blame] | 1572 | if (*cds_mod_context != module_context) { |
Jeff Johnson | d0a6b2c | 2018-05-30 22:57:39 -0700 | [diff] [blame] | 1573 | cds_err("cds_mod_context != module_context"); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1574 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1575 | } |
| 1576 | |
Jeff Johnson | 1326996 | 2018-05-30 19:16:46 -0700 | [diff] [blame] | 1577 | qdf_mem_free(module_context); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1578 | |
Jeff Johnson | 835b760 | 2018-05-30 19:06:24 -0700 | [diff] [blame] | 1579 | *cds_mod_context = NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1580 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1581 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1582 | } /* cds_free_context() */ |
| 1583 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1584 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1585 | * cds_wma_complete_cback() - wma complete callback |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1586 | * |
| 1587 | * Return: none |
| 1588 | */ |
Jeff Johnson | f7ab814 | 2017-09-13 09:04:23 -0700 | [diff] [blame] | 1589 | void cds_wma_complete_cback(void) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1590 | { |
Jeff Johnson | f7ab814 | 2017-09-13 09:04:23 -0700 | [diff] [blame] | 1591 | if (!gp_cds_context) { |
Jeff Johnson | d0a6b2c | 2018-05-30 22:57:39 -0700 | [diff] [blame] | 1592 | cds_err("invalid gp_cds_context"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1593 | return; |
| 1594 | } |
| 1595 | |
Jeff Johnson | 2ccd815 | 2018-05-29 16:02:23 -0700 | [diff] [blame] | 1596 | if (qdf_event_set(&gp_cds_context->wma_complete_event) != |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 1597 | QDF_STATUS_SUCCESS) { |
Jeff Johnson | d0a6b2c | 2018-05-30 22:57:39 -0700 | [diff] [blame] | 1598 | cds_err("qdf_event_set failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1599 | return; |
| 1600 | } |
| 1601 | } /* cds_wma_complete_cback() */ |
| 1602 | |
| 1603 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1604 | * cds_get_vdev_types() - get vdev type |
| 1605 | * @mode: mode |
| 1606 | * @type: type |
| 1607 | * @sub_type: sub_type |
| 1608 | * |
| 1609 | * Return: WMI vdev type |
| 1610 | */ |
Jeff Johnson | c1e6278 | 2017-11-09 09:50:17 -0800 | [diff] [blame] | 1611 | QDF_STATUS cds_get_vdev_types(enum QDF_OPMODE mode, uint32_t *type, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1612 | uint32_t *sub_type) |
| 1613 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1614 | QDF_STATUS status = QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1615 | *type = 0; |
| 1616 | *sub_type = 0; |
| 1617 | |
| 1618 | switch (mode) { |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 1619 | case QDF_STA_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1620 | *type = WMI_VDEV_TYPE_STA; |
| 1621 | break; |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 1622 | case QDF_SAP_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1623 | *type = WMI_VDEV_TYPE_AP; |
| 1624 | break; |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 1625 | case QDF_P2P_DEVICE_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1626 | *type = WMI_VDEV_TYPE_AP; |
| 1627 | *sub_type = WMI_UNIFIED_VDEV_SUBTYPE_P2P_DEVICE; |
| 1628 | break; |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 1629 | case QDF_P2P_CLIENT_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1630 | *type = WMI_VDEV_TYPE_STA; |
| 1631 | *sub_type = WMI_UNIFIED_VDEV_SUBTYPE_P2P_CLIENT; |
| 1632 | break; |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 1633 | case QDF_P2P_GO_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1634 | *type = WMI_VDEV_TYPE_AP; |
| 1635 | *sub_type = WMI_UNIFIED_VDEV_SUBTYPE_P2P_GO; |
| 1636 | break; |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 1637 | case QDF_OCB_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1638 | *type = WMI_VDEV_TYPE_OCB; |
| 1639 | break; |
Krunal Soni | 8c37e32 | 2016-02-03 16:08:37 -0800 | [diff] [blame] | 1640 | case QDF_IBSS_MODE: |
| 1641 | *type = WMI_VDEV_TYPE_IBSS; |
| 1642 | break; |
Manjunathappa Prakash | b757372 | 2016-04-21 11:24:07 -0700 | [diff] [blame] | 1643 | case QDF_MONITOR_MODE: |
| 1644 | *type = WMI_VDEV_TYPE_MONITOR; |
| 1645 | break; |
Deepak Dhamdhere | e2dd544 | 2016-05-27 15:05:51 -0700 | [diff] [blame] | 1646 | case QDF_NDI_MODE: |
| 1647 | *type = WMI_VDEV_TYPE_NDI; |
| 1648 | break; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1649 | default: |
Jeff Johnson | d0a6b2c | 2018-05-30 22:57:39 -0700 | [diff] [blame] | 1650 | cds_err("Invalid device mode %d", mode); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1651 | status = QDF_STATUS_E_INVAL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1652 | break; |
| 1653 | } |
| 1654 | return status; |
| 1655 | } |
| 1656 | |
| 1657 | /** |
| 1658 | * cds_flush_work() - flush pending works |
| 1659 | * @work: pointer to work |
| 1660 | * |
| 1661 | * Return: none |
| 1662 | */ |
| 1663 | void cds_flush_work(void *work) |
| 1664 | { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1665 | cancel_work_sync(work); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1666 | } |
| 1667 | |
| 1668 | /** |
| 1669 | * cds_flush_delayed_work() - flush delayed works |
| 1670 | * @dwork: pointer to delayed work |
| 1671 | * |
| 1672 | * Return: none |
| 1673 | */ |
| 1674 | void cds_flush_delayed_work(void *dwork) |
| 1675 | { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1676 | cancel_delayed_work_sync(dwork); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1677 | } |
| 1678 | |
Nirav Shah | bb8e47c | 2018-05-17 16:56:41 +0530 | [diff] [blame] | 1679 | #ifndef REMOVE_PKT_LOG |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1680 | /** |
| 1681 | * cds_is_packet_log_enabled() - check if packet log is enabled |
| 1682 | * |
| 1683 | * Return: true if packet log is enabled else false |
| 1684 | */ |
| 1685 | bool cds_is_packet_log_enabled(void) |
| 1686 | { |
Jeff Johnson | c18b26c | 2017-09-03 08:46:45 -0700 | [diff] [blame] | 1687 | struct hdd_context *hdd_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1688 | |
Jeff Johnson | 323a6f0 | 2018-05-29 15:09:12 -0700 | [diff] [blame] | 1689 | hdd_ctx = gp_cds_context->hdd_context; |
Jeff Johnson | c18b26c | 2017-09-03 08:46:45 -0700 | [diff] [blame] | 1690 | if ((NULL == hdd_ctx) || (NULL == hdd_ctx->config)) { |
Jeff Johnson | d0a6b2c | 2018-05-30 22:57:39 -0700 | [diff] [blame] | 1691 | cds_alert("Hdd Context is Null"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1692 | return false; |
| 1693 | } |
Jeff Johnson | c18b26c | 2017-09-03 08:46:45 -0700 | [diff] [blame] | 1694 | return hdd_ctx->config->enablePacketLog; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1695 | } |
Nirav Shah | bb8e47c | 2018-05-17 16:56:41 +0530 | [diff] [blame] | 1696 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1697 | |
Dustin Brown | 100201e | 2017-07-10 11:48:40 -0700 | [diff] [blame] | 1698 | static int cds_force_assert_target_via_pld(qdf_device_t qdf) |
Mukul Sharma | b7b575b | 2016-10-02 23:37:07 +0530 | [diff] [blame] | 1699 | { |
Dustin Brown | 100201e | 2017-07-10 11:48:40 -0700 | [diff] [blame] | 1700 | int errno; |
| 1701 | |
| 1702 | errno = pld_force_assert_target(qdf->dev); |
| 1703 | if (errno == -EOPNOTSUPP) |
| 1704 | cds_info("PLD does not support target force assert"); |
| 1705 | else if (errno) |
| 1706 | cds_err("Failed PLD target force assert; errno %d", errno); |
| 1707 | else |
| 1708 | cds_info("Target force assert triggered via PLD"); |
| 1709 | |
| 1710 | return errno; |
Mukul Sharma | b7b575b | 2016-10-02 23:37:07 +0530 | [diff] [blame] | 1711 | } |
| 1712 | |
Dustin Brown | 100201e | 2017-07-10 11:48:40 -0700 | [diff] [blame] | 1713 | static QDF_STATUS cds_force_assert_target_via_wmi(qdf_device_t qdf) |
Rajeev Kumar | db60f16 | 2017-07-25 20:27:59 -0700 | [diff] [blame] | 1714 | { |
Dustin Brown | 100201e | 2017-07-10 11:48:40 -0700 | [diff] [blame] | 1715 | QDF_STATUS status; |
| 1716 | t_wma_handle *wma; |
| 1717 | |
| 1718 | wma = cds_get_context(QDF_MODULE_ID_WMA); |
| 1719 | if (!wma) { |
| 1720 | cds_err("wma is null"); |
| 1721 | return QDF_STATUS_E_INVAL; |
| 1722 | } |
| 1723 | |
| 1724 | status = wma_crash_inject(wma, RECOVERY_SIM_SELF_RECOVERY, 0); |
| 1725 | if (QDF_IS_STATUS_ERROR(status)) { |
| 1726 | cds_err("Failed target force assert; status %d", status); |
| 1727 | return status; |
| 1728 | } |
| 1729 | |
Nachiket Kukade | 0396b73 | 2017-11-14 16:35:16 +0530 | [diff] [blame] | 1730 | status = qdf_wait_for_event_completion(&wma->recovery_event, |
Dustin Brown | 100201e | 2017-07-10 11:48:40 -0700 | [diff] [blame] | 1731 | WMA_CRASH_INJECT_TIMEOUT); |
| 1732 | if (QDF_IS_STATUS_ERROR(status)) { |
| 1733 | cds_err("Failed target force assert wait; status %d", status); |
| 1734 | return status; |
| 1735 | } |
| 1736 | |
| 1737 | return QDF_STATUS_SUCCESS; |
| 1738 | } |
| 1739 | |
| 1740 | /** |
| 1741 | * cds_force_assert_target() - Send assert command to firmware |
| 1742 | * @qdf: QDF device instance to assert |
| 1743 | * |
| 1744 | * An out-of-band recovery mechanism will cleanup and restart the entire wlan |
| 1745 | * subsystem in the event of a firmware crash. This API injects a firmware |
| 1746 | * crash to start this process when the wlan driver is known to be in a bad |
| 1747 | * state. If a firmware assert inject fails, the wlan driver will schedule |
| 1748 | * the driver recovery anyway, as a best effort attempt to return to a working |
| 1749 | * state. |
| 1750 | * |
| 1751 | * Return: QDF_STATUS |
| 1752 | */ |
| 1753 | static QDF_STATUS cds_force_assert_target(qdf_device_t qdf) |
| 1754 | { |
| 1755 | int errno; |
| 1756 | QDF_STATUS status; |
| 1757 | |
| 1758 | /* first, try target assert inject via pld */ |
| 1759 | errno = cds_force_assert_target_via_pld(qdf); |
| 1760 | if (!errno) |
| 1761 | return QDF_STATUS_SUCCESS; |
| 1762 | if (errno != -EOPNOTSUPP) |
| 1763 | return QDF_STATUS_E_FAILURE; |
| 1764 | |
| 1765 | /* pld assert is not supported, try target assert inject via wmi */ |
| 1766 | status = cds_force_assert_target_via_wmi(qdf); |
| 1767 | if (QDF_IS_STATUS_SUCCESS(status)) |
| 1768 | return QDF_STATUS_SUCCESS; |
| 1769 | |
| 1770 | /* wmi assert failed, start recovery without the firmware assert */ |
| 1771 | cds_err("Scheduling recovery work without firmware assert"); |
| 1772 | cds_set_recovery_in_progress(true); |
| 1773 | pld_schedule_recovery_work(qdf->dev, PLD_REASON_DEFAULT); |
| 1774 | |
| 1775 | return status; |
Rajeev Kumar | db60f16 | 2017-07-25 20:27:59 -0700 | [diff] [blame] | 1776 | } |
| 1777 | |
Mukul Sharma | b7b575b | 2016-10-02 23:37:07 +0530 | [diff] [blame] | 1778 | /** |
Srinivas Girigowda | 161b9f2 | 2017-07-24 17:38:09 -0700 | [diff] [blame] | 1779 | * cds_trigger_recovery_work() - trigger self recovery work |
Mukul Sharma | b7b575b | 2016-10-02 23:37:07 +0530 | [diff] [blame] | 1780 | * |
| 1781 | * Return: none |
| 1782 | */ |
Srinivas Girigowda | 161b9f2 | 2017-07-24 17:38:09 -0700 | [diff] [blame] | 1783 | static void cds_trigger_recovery_work(void *param) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1784 | { |
Dustin Brown | 100201e | 2017-07-10 11:48:40 -0700 | [diff] [blame] | 1785 | QDF_STATUS status; |
| 1786 | qdf_runtime_lock_t rtl; |
| 1787 | qdf_device_t qdf; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1788 | |
Zhu Jianmin | 26b9b8a | 2018-05-15 09:04:45 +0800 | [diff] [blame] | 1789 | if (cds_is_driver_unloading()) { |
| 1790 | cds_err("Unloading in progress; ignoring recovery trigger"); |
| 1791 | return; |
| 1792 | } |
| 1793 | |
Kabilan Kannan | 973744a | 2018-01-03 10:28:50 -0800 | [diff] [blame] | 1794 | if (cds_is_driver_recovering()) { |
| 1795 | cds_err("Recovery in progress; ignoring recovery trigger"); |
Sameer Thalappil | ec2e9c7 | 2017-02-08 15:45:49 -0800 | [diff] [blame] | 1796 | return; |
| 1797 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1798 | |
Kabilan Kannan | 973744a | 2018-01-03 10:28:50 -0800 | [diff] [blame] | 1799 | if (cds_is_driver_in_bad_state()) { |
| 1800 | cds_err("Driver is in bad state; ignoring recovery trigger"); |
Houston Hoffman | c7c72a8 | 2015-12-07 15:30:48 -0800 | [diff] [blame] | 1801 | return; |
| 1802 | } |
| 1803 | |
Rajeev Kumar | 6dd45a8 | 2017-10-20 14:43:05 -0700 | [diff] [blame] | 1804 | if (cds_is_fw_down()) { |
| 1805 | cds_err("FW is down; ignoring recovery trigger"); |
| 1806 | return; |
| 1807 | } |
| 1808 | |
Kabilan Kannan | 973744a | 2018-01-03 10:28:50 -0800 | [diff] [blame] | 1809 | if (!cds_is_self_recovery_enabled()) { |
| 1810 | cds_err("Recovery is not enabled"); |
| 1811 | QDF_BUG(0); |
| 1812 | return; |
| 1813 | } |
| 1814 | |
Dustin Brown | 100201e | 2017-07-10 11:48:40 -0700 | [diff] [blame] | 1815 | qdf = cds_get_context(QDF_MODULE_ID_QDF_DEVICE); |
| 1816 | if (!qdf) { |
| 1817 | cds_err("Qdf context is null"); |
| 1818 | return; |
Sameer Thalappil | ac5d26e | 2017-01-10 15:32:58 -0800 | [diff] [blame] | 1819 | } |
| 1820 | |
Dustin Brown | 100201e | 2017-07-10 11:48:40 -0700 | [diff] [blame] | 1821 | status = qdf_runtime_lock_init(&rtl); |
| 1822 | if (QDF_IS_STATUS_ERROR(status)) { |
Srinivas Girigowda | 161b9f2 | 2017-07-24 17:38:09 -0700 | [diff] [blame] | 1823 | cds_err("qdf_runtime_lock_init failed, status: %d", status); |
Dustin Brown | 100201e | 2017-07-10 11:48:40 -0700 | [diff] [blame] | 1824 | return; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1825 | } |
Houston Hoffman | c7c72a8 | 2015-12-07 15:30:48 -0800 | [diff] [blame] | 1826 | |
Dustin Brown | 100201e | 2017-07-10 11:48:40 -0700 | [diff] [blame] | 1827 | status = qdf_runtime_pm_prevent_suspend(&rtl); |
| 1828 | if (QDF_IS_STATUS_ERROR(status)) { |
| 1829 | cds_err("Failed to acquire runtime pm lock"); |
| 1830 | goto deinit_rtl; |
| 1831 | } |
| 1832 | |
| 1833 | cds_force_assert_target(qdf); |
| 1834 | |
| 1835 | status = qdf_runtime_pm_allow_suspend(&rtl); |
| 1836 | if (QDF_IS_STATUS_ERROR(status)) |
| 1837 | cds_err("Failed to release runtime pm lock"); |
| 1838 | |
| 1839 | deinit_rtl: |
| 1840 | qdf_runtime_lock_deinit(&rtl); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1841 | } |
| 1842 | |
| 1843 | /** |
Anurag Chouhan | 4085ff7 | 2017-10-05 18:09:56 +0530 | [diff] [blame] | 1844 | * cds_get_recovery_reason() - get self recovery reason |
| 1845 | * @reason: recovery reason |
| 1846 | * |
| 1847 | * Return: None |
| 1848 | */ |
| 1849 | void cds_get_recovery_reason(enum qdf_hang_reason *reason) |
| 1850 | { |
| 1851 | if (!gp_cds_context) { |
| 1852 | cds_err("gp_cds_context is null"); |
| 1853 | return; |
| 1854 | } |
| 1855 | |
| 1856 | *reason = gp_cds_context->recovery_reason; |
| 1857 | } |
| 1858 | |
| 1859 | /** |
| 1860 | * cds_reset_recovery_reason() - reset the reason to unspecified |
| 1861 | * |
| 1862 | * Return: None |
| 1863 | */ |
| 1864 | void cds_reset_recovery_reason(void) |
| 1865 | { |
| 1866 | if (!gp_cds_context) { |
| 1867 | cds_err("gp_cds_context is null"); |
| 1868 | return; |
| 1869 | } |
| 1870 | |
| 1871 | gp_cds_context->recovery_reason = QDF_REASON_UNSPECIFIED; |
| 1872 | } |
| 1873 | |
| 1874 | /** |
Srinivas Girigowda | 161b9f2 | 2017-07-24 17:38:09 -0700 | [diff] [blame] | 1875 | * cds_trigger_recovery() - trigger self recovery |
Anurag Chouhan | 4085ff7 | 2017-10-05 18:09:56 +0530 | [diff] [blame] | 1876 | * @reason: recovery reason |
Srinivas Girigowda | 161b9f2 | 2017-07-24 17:38:09 -0700 | [diff] [blame] | 1877 | * |
| 1878 | * Return: none |
| 1879 | */ |
Anurag Chouhan | 4085ff7 | 2017-10-05 18:09:56 +0530 | [diff] [blame] | 1880 | void cds_trigger_recovery(enum qdf_hang_reason reason) |
Srinivas Girigowda | 161b9f2 | 2017-07-24 17:38:09 -0700 | [diff] [blame] | 1881 | { |
Anurag Chouhan | 4085ff7 | 2017-10-05 18:09:56 +0530 | [diff] [blame] | 1882 | if (!gp_cds_context) { |
| 1883 | cds_err("gp_cds_context is null"); |
| 1884 | return; |
| 1885 | } |
| 1886 | |
| 1887 | gp_cds_context->recovery_reason = reason; |
Srinivas Girigowda | 161b9f2 | 2017-07-24 17:38:09 -0700 | [diff] [blame] | 1888 | if (in_atomic()) { |
| 1889 | qdf_queue_work(0, gp_cds_context->cds_recovery_wq, |
| 1890 | &gp_cds_context->cds_recovery_work); |
| 1891 | return; |
| 1892 | } |
| 1893 | cds_trigger_recovery_work(NULL); |
| 1894 | } |
| 1895 | |
| 1896 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1897 | * cds_get_monotonic_boottime() - Get kernel boot time. |
| 1898 | * |
| 1899 | * Return: Time in microseconds |
| 1900 | */ |
| 1901 | |
| 1902 | uint64_t cds_get_monotonic_boottime(void) |
| 1903 | { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1904 | struct timespec ts; |
| 1905 | |
Yuanyuan Liu | 2e03b41 | 2016-04-06 14:36:15 -0700 | [diff] [blame] | 1906 | get_monotonic_boottime(&ts); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1907 | return ((uint64_t) ts.tv_sec * 1000000) + (ts.tv_nsec / 1000); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1908 | } |
| 1909 | |
| 1910 | /** |
| 1911 | * cds_set_wakelock_logging() - Logging of wakelock enabled/disabled |
| 1912 | * @value: Boolean value |
| 1913 | * |
| 1914 | * This function is used to set the flag which will indicate whether |
| 1915 | * logging of wakelock is enabled or not |
| 1916 | * |
| 1917 | * Return: None |
| 1918 | */ |
| 1919 | void cds_set_wakelock_logging(bool value) |
| 1920 | { |
Jeff Johnson | 2b6982c | 2018-05-29 14:56:11 -0700 | [diff] [blame] | 1921 | struct cds_context *p_cds_context; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1922 | |
| 1923 | p_cds_context = cds_get_global_context(); |
| 1924 | if (!p_cds_context) { |
Jeff Johnson | d0a6b2c | 2018-05-30 22:57:39 -0700 | [diff] [blame] | 1925 | cds_err("cds context is Invald"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1926 | return; |
| 1927 | } |
| 1928 | p_cds_context->is_wakelock_log_enabled = value; |
| 1929 | } |
| 1930 | |
| 1931 | /** |
| 1932 | * cds_is_wakelock_enabled() - Check if logging of wakelock is enabled/disabled |
| 1933 | * @value: Boolean value |
| 1934 | * |
| 1935 | * This function is used to check whether logging of wakelock is enabled or not |
| 1936 | * |
| 1937 | * Return: true if logging of wakelock is enabled |
| 1938 | */ |
| 1939 | bool cds_is_wakelock_enabled(void) |
| 1940 | { |
Jeff Johnson | 2b6982c | 2018-05-29 14:56:11 -0700 | [diff] [blame] | 1941 | struct cds_context *p_cds_context; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1942 | |
| 1943 | p_cds_context = cds_get_global_context(); |
| 1944 | if (!p_cds_context) { |
Jeff Johnson | d0a6b2c | 2018-05-30 22:57:39 -0700 | [diff] [blame] | 1945 | cds_err("cds context is Invald"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1946 | return false; |
| 1947 | } |
| 1948 | return p_cds_context->is_wakelock_log_enabled; |
| 1949 | } |
| 1950 | |
| 1951 | /** |
| 1952 | * cds_set_ring_log_level() - Sets the log level of a particular ring |
| 1953 | * @ring_id: ring_id |
| 1954 | * @log_levelvalue: Log level specificed |
| 1955 | * |
| 1956 | * This function converts HLOS values to driver log levels and sets the log |
| 1957 | * level of a particular ring accordingly. |
| 1958 | * |
| 1959 | * Return: None |
| 1960 | */ |
| 1961 | void cds_set_ring_log_level(uint32_t ring_id, uint32_t log_level) |
| 1962 | { |
Jeff Johnson | 2b6982c | 2018-05-29 14:56:11 -0700 | [diff] [blame] | 1963 | struct cds_context *p_cds_context; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1964 | uint32_t log_val; |
| 1965 | |
| 1966 | p_cds_context = cds_get_global_context(); |
| 1967 | if (!p_cds_context) { |
Jeff Johnson | d0a6b2c | 2018-05-30 22:57:39 -0700 | [diff] [blame] | 1968 | cds_err("cds context is Invald"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1969 | return; |
| 1970 | } |
| 1971 | |
| 1972 | switch (log_level) { |
| 1973 | case LOG_LEVEL_NO_COLLECTION: |
| 1974 | log_val = WLAN_LOG_LEVEL_OFF; |
| 1975 | break; |
| 1976 | case LOG_LEVEL_NORMAL_COLLECT: |
| 1977 | log_val = WLAN_LOG_LEVEL_NORMAL; |
| 1978 | break; |
| 1979 | case LOG_LEVEL_ISSUE_REPRO: |
| 1980 | log_val = WLAN_LOG_LEVEL_REPRO; |
| 1981 | break; |
| 1982 | case LOG_LEVEL_ACTIVE: |
| 1983 | default: |
| 1984 | log_val = WLAN_LOG_LEVEL_ACTIVE; |
| 1985 | break; |
| 1986 | } |
| 1987 | |
| 1988 | if (ring_id == RING_ID_WAKELOCK) { |
| 1989 | p_cds_context->wakelock_log_level = log_val; |
| 1990 | return; |
| 1991 | } else if (ring_id == RING_ID_CONNECTIVITY) { |
| 1992 | p_cds_context->connectivity_log_level = log_val; |
| 1993 | return; |
| 1994 | } else if (ring_id == RING_ID_PER_PACKET_STATS) { |
| 1995 | p_cds_context->packet_stats_log_level = log_val; |
| 1996 | return; |
Chandrasekaran, Manishekar | 907c2af | 2015-11-13 12:50:04 +0530 | [diff] [blame] | 1997 | } else if (ring_id == RING_ID_DRIVER_DEBUG) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1998 | p_cds_context->driver_debug_log_level = log_val; |
| 1999 | return; |
| 2000 | } else if (ring_id == RING_ID_FIRMWARE_DEBUG) { |
| 2001 | p_cds_context->fw_debug_log_level = log_val; |
| 2002 | return; |
| 2003 | } |
| 2004 | } |
| 2005 | |
| 2006 | /** |
| 2007 | * cds_get_ring_log_level() - Get the a ring id's log level |
| 2008 | * @ring_id: Ring id |
| 2009 | * |
| 2010 | * Fetch and return the log level corresponding to a ring id |
| 2011 | * |
| 2012 | * Return: Log level corresponding to the ring ID |
| 2013 | */ |
| 2014 | enum wifi_driver_log_level cds_get_ring_log_level(uint32_t ring_id) |
| 2015 | { |
Jeff Johnson | 2b6982c | 2018-05-29 14:56:11 -0700 | [diff] [blame] | 2016 | struct cds_context *p_cds_context; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2017 | |
| 2018 | p_cds_context = cds_get_global_context(); |
| 2019 | if (!p_cds_context) { |
Jeff Johnson | d0a6b2c | 2018-05-30 22:57:39 -0700 | [diff] [blame] | 2020 | cds_err("cds context is Invald"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2021 | return WLAN_LOG_LEVEL_OFF; |
| 2022 | } |
| 2023 | |
| 2024 | if (ring_id == RING_ID_WAKELOCK) |
| 2025 | return p_cds_context->wakelock_log_level; |
| 2026 | else if (ring_id == RING_ID_CONNECTIVITY) |
| 2027 | return p_cds_context->connectivity_log_level; |
| 2028 | else if (ring_id == RING_ID_PER_PACKET_STATS) |
| 2029 | return p_cds_context->packet_stats_log_level; |
Chandrasekaran, Manishekar | 907c2af | 2015-11-13 12:50:04 +0530 | [diff] [blame] | 2030 | else if (ring_id == RING_ID_DRIVER_DEBUG) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2031 | return p_cds_context->driver_debug_log_level; |
| 2032 | else if (ring_id == RING_ID_FIRMWARE_DEBUG) |
| 2033 | return p_cds_context->fw_debug_log_level; |
| 2034 | |
| 2035 | return WLAN_LOG_LEVEL_OFF; |
| 2036 | } |
| 2037 | |
| 2038 | /** |
| 2039 | * cds_set_multicast_logging() - Set mutlicast logging value |
| 2040 | * @value: Value of multicast logging |
| 2041 | * |
| 2042 | * Set the multicast logging value which will indicate |
| 2043 | * whether to multicast host and fw messages even |
| 2044 | * without any registration by userspace entity |
| 2045 | * |
| 2046 | * Return: None |
| 2047 | */ |
| 2048 | void cds_set_multicast_logging(uint8_t value) |
| 2049 | { |
| 2050 | cds_multicast_logging = value; |
| 2051 | } |
| 2052 | |
| 2053 | /** |
| 2054 | * cds_is_multicast_logging() - Get multicast logging value |
| 2055 | * |
| 2056 | * Get the multicast logging value which will indicate |
| 2057 | * whether to multicast host and fw messages even |
| 2058 | * without any registration by userspace entity |
| 2059 | * |
| 2060 | * Return: 0 - Multicast logging disabled, 1 - Multicast logging enabled |
| 2061 | */ |
| 2062 | uint8_t cds_is_multicast_logging(void) |
| 2063 | { |
| 2064 | return cds_multicast_logging; |
| 2065 | } |
| 2066 | |
| 2067 | /* |
| 2068 | * cds_init_log_completion() - Initialize log param structure |
| 2069 | * |
| 2070 | * This function is used to initialize the logging related |
| 2071 | * parameters |
| 2072 | * |
| 2073 | * Return: None |
| 2074 | */ |
| 2075 | void cds_init_log_completion(void) |
| 2076 | { |
Jeff Johnson | 2b6982c | 2018-05-29 14:56:11 -0700 | [diff] [blame] | 2077 | struct cds_context *p_cds_context; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2078 | |
| 2079 | p_cds_context = cds_get_global_context(); |
| 2080 | if (!p_cds_context) { |
Jeff Johnson | d0a6b2c | 2018-05-30 22:57:39 -0700 | [diff] [blame] | 2081 | cds_err("cds context is Invalid"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2082 | return; |
| 2083 | } |
| 2084 | |
| 2085 | p_cds_context->log_complete.is_fatal = WLAN_LOG_TYPE_NON_FATAL; |
| 2086 | p_cds_context->log_complete.indicator = WLAN_LOG_INDICATOR_UNUSED; |
| 2087 | p_cds_context->log_complete.reason_code = WLAN_LOG_REASON_CODE_UNUSED; |
| 2088 | p_cds_context->log_complete.is_report_in_progress = false; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2089 | } |
| 2090 | |
| 2091 | /** |
| 2092 | * cds_set_log_completion() - Store the logging params |
| 2093 | * @is_fatal: Indicates if the event triggering bug report is fatal or not |
| 2094 | * @indicator: Source which trigerred the bug report |
| 2095 | * @reason_code: Reason for triggering bug report |
Abhishek Singh | 5ea8653 | 2016-04-27 14:10:53 +0530 | [diff] [blame] | 2096 | * @recovery_needed: If recovery is needed after bug report |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2097 | * |
| 2098 | * This function is used to set the logging parameters based on the |
| 2099 | * caller |
| 2100 | * |
| 2101 | * Return: 0 if setting of params is successful |
| 2102 | */ |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2103 | QDF_STATUS cds_set_log_completion(uint32_t is_fatal, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2104 | uint32_t indicator, |
Abhishek Singh | 5ea8653 | 2016-04-27 14:10:53 +0530 | [diff] [blame] | 2105 | uint32_t reason_code, |
| 2106 | bool recovery_needed) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2107 | { |
Jeff Johnson | 2b6982c | 2018-05-29 14:56:11 -0700 | [diff] [blame] | 2108 | struct cds_context *p_cds_context; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2109 | |
| 2110 | p_cds_context = cds_get_global_context(); |
| 2111 | if (!p_cds_context) { |
Jeff Johnson | d0a6b2c | 2018-05-30 22:57:39 -0700 | [diff] [blame] | 2112 | cds_err("cds context is Invalid"); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2113 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2114 | } |
| 2115 | |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 2116 | qdf_spinlock_acquire(&p_cds_context->bug_report_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2117 | p_cds_context->log_complete.is_fatal = is_fatal; |
| 2118 | p_cds_context->log_complete.indicator = indicator; |
| 2119 | p_cds_context->log_complete.reason_code = reason_code; |
Abhishek Singh | 5ea8653 | 2016-04-27 14:10:53 +0530 | [diff] [blame] | 2120 | p_cds_context->log_complete.recovery_needed = recovery_needed; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2121 | p_cds_context->log_complete.is_report_in_progress = true; |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 2122 | qdf_spinlock_release(&p_cds_context->bug_report_lock); |
Jeff Johnson | d0a6b2c | 2018-05-30 22:57:39 -0700 | [diff] [blame] | 2123 | cds_debug("is_fatal %d indicator %d reason_code %d recovery needed %d", |
| 2124 | is_fatal, indicator, reason_code, recovery_needed); |
Rajeev Kumar | dcce809 | 2018-05-02 15:48:17 -0700 | [diff] [blame] | 2125 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2126 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2127 | } |
| 2128 | |
| 2129 | /** |
Abhishek Singh | 5ea8653 | 2016-04-27 14:10:53 +0530 | [diff] [blame] | 2130 | * cds_get_and_reset_log_completion() - Get and reset logging related params |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2131 | * @is_fatal: Indicates if the event triggering bug report is fatal or not |
| 2132 | * @indicator: Source which trigerred the bug report |
| 2133 | * @reason_code: Reason for triggering bug report |
Abhishek Singh | 5ea8653 | 2016-04-27 14:10:53 +0530 | [diff] [blame] | 2134 | * @recovery_needed: If recovery is needed after bug report |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2135 | * |
| 2136 | * This function is used to get the logging related parameters |
| 2137 | * |
| 2138 | * Return: None |
| 2139 | */ |
Abhishek Singh | 5ea8653 | 2016-04-27 14:10:53 +0530 | [diff] [blame] | 2140 | void cds_get_and_reset_log_completion(uint32_t *is_fatal, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2141 | uint32_t *indicator, |
Abhishek Singh | 5ea8653 | 2016-04-27 14:10:53 +0530 | [diff] [blame] | 2142 | uint32_t *reason_code, |
| 2143 | bool *recovery_needed) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2144 | { |
Jeff Johnson | 2b6982c | 2018-05-29 14:56:11 -0700 | [diff] [blame] | 2145 | struct cds_context *p_cds_context; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2146 | |
| 2147 | p_cds_context = cds_get_global_context(); |
| 2148 | if (!p_cds_context) { |
Jeff Johnson | d0a6b2c | 2018-05-30 22:57:39 -0700 | [diff] [blame] | 2149 | cds_err("cds context is Invalid"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2150 | return; |
| 2151 | } |
| 2152 | |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 2153 | qdf_spinlock_acquire(&p_cds_context->bug_report_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2154 | *is_fatal = p_cds_context->log_complete.is_fatal; |
| 2155 | *indicator = p_cds_context->log_complete.indicator; |
| 2156 | *reason_code = p_cds_context->log_complete.reason_code; |
Abhishek Singh | 5ea8653 | 2016-04-27 14:10:53 +0530 | [diff] [blame] | 2157 | *recovery_needed = p_cds_context->log_complete.recovery_needed; |
| 2158 | |
| 2159 | /* reset */ |
| 2160 | p_cds_context->log_complete.indicator = WLAN_LOG_INDICATOR_UNUSED; |
| 2161 | p_cds_context->log_complete.is_fatal = WLAN_LOG_TYPE_NON_FATAL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2162 | p_cds_context->log_complete.is_report_in_progress = false; |
Abhishek Singh | 5ea8653 | 2016-04-27 14:10:53 +0530 | [diff] [blame] | 2163 | p_cds_context->log_complete.reason_code = WLAN_LOG_REASON_CODE_UNUSED; |
| 2164 | p_cds_context->log_complete.recovery_needed = false; |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 2165 | qdf_spinlock_release(&p_cds_context->bug_report_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2166 | } |
| 2167 | |
| 2168 | /** |
| 2169 | * cds_is_log_report_in_progress() - Check if bug reporting is in progress |
| 2170 | * |
| 2171 | * This function is used to check if the bug reporting is already in progress |
| 2172 | * |
| 2173 | * Return: true if the bug reporting is in progress |
| 2174 | */ |
| 2175 | bool cds_is_log_report_in_progress(void) |
| 2176 | { |
Jeff Johnson | 2b6982c | 2018-05-29 14:56:11 -0700 | [diff] [blame] | 2177 | struct cds_context *p_cds_context; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2178 | |
| 2179 | p_cds_context = cds_get_global_context(); |
| 2180 | if (!p_cds_context) { |
Jeff Johnson | d0a6b2c | 2018-05-30 22:57:39 -0700 | [diff] [blame] | 2181 | cds_err("cds context is Invalid"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2182 | return true; |
| 2183 | } |
| 2184 | return p_cds_context->log_complete.is_report_in_progress; |
| 2185 | } |
| 2186 | |
| 2187 | /** |
Abhishek Singh | 5ea8653 | 2016-04-27 14:10:53 +0530 | [diff] [blame] | 2188 | * cds_is_fatal_event_enabled() - Return if fatal event is enabled |
| 2189 | * |
| 2190 | * Return true if fatal event is enabled. |
| 2191 | */ |
| 2192 | bool cds_is_fatal_event_enabled(void) |
| 2193 | { |
Jeff Johnson | 2b6982c | 2018-05-29 14:56:11 -0700 | [diff] [blame] | 2194 | struct cds_context *p_cds_context; |
Abhishek Singh | 5ea8653 | 2016-04-27 14:10:53 +0530 | [diff] [blame] | 2195 | |
| 2196 | p_cds_context = cds_get_global_context(); |
| 2197 | if (!p_cds_context) { |
Jeff Johnson | d0a6b2c | 2018-05-30 22:57:39 -0700 | [diff] [blame] | 2198 | cds_err("cds context is Invalid"); |
Abhishek Singh | 5ea8653 | 2016-04-27 14:10:53 +0530 | [diff] [blame] | 2199 | return false; |
| 2200 | } |
| 2201 | |
| 2202 | |
| 2203 | return p_cds_context->enable_fatal_event; |
| 2204 | } |
| 2205 | |
Yu Wang | 66a250b | 2017-07-19 11:46:40 +0800 | [diff] [blame] | 2206 | #ifdef WLAN_FEATURE_TSF_PLUS |
| 2207 | bool cds_is_ptp_rx_opt_enabled(void) |
| 2208 | { |
| 2209 | struct hdd_context *hdd_ctx; |
Jeff Johnson | 2b6982c | 2018-05-29 14:56:11 -0700 | [diff] [blame] | 2210 | struct cds_context *p_cds_context; |
Yu Wang | 66a250b | 2017-07-19 11:46:40 +0800 | [diff] [blame] | 2211 | |
| 2212 | p_cds_context = cds_get_global_context(); |
| 2213 | if (!p_cds_context) { |
Jeff Johnson | d0a6b2c | 2018-05-30 22:57:39 -0700 | [diff] [blame] | 2214 | cds_err("cds context is Invalid"); |
Yu Wang | 66a250b | 2017-07-19 11:46:40 +0800 | [diff] [blame] | 2215 | return false; |
| 2216 | } |
| 2217 | |
Jeff Johnson | 323a6f0 | 2018-05-29 15:09:12 -0700 | [diff] [blame] | 2218 | hdd_ctx = (struct hdd_context *)(p_cds_context->hdd_context); |
Yu Wang | 66a250b | 2017-07-19 11:46:40 +0800 | [diff] [blame] | 2219 | if ((NULL == hdd_ctx) || (NULL == hdd_ctx->config)) { |
Jeff Johnson | d0a6b2c | 2018-05-30 22:57:39 -0700 | [diff] [blame] | 2220 | cds_err("Hdd Context is Null"); |
Yu Wang | 66a250b | 2017-07-19 11:46:40 +0800 | [diff] [blame] | 2221 | return false; |
| 2222 | } |
| 2223 | |
| 2224 | return HDD_TSF_IS_RX_SET(hdd_ctx); |
| 2225 | } |
| 2226 | |
| 2227 | bool cds_is_ptp_tx_opt_enabled(void) |
| 2228 | { |
| 2229 | struct hdd_context *hdd_ctx; |
Jeff Johnson | 2b6982c | 2018-05-29 14:56:11 -0700 | [diff] [blame] | 2230 | struct cds_context *p_cds_context; |
Yu Wang | 66a250b | 2017-07-19 11:46:40 +0800 | [diff] [blame] | 2231 | |
| 2232 | p_cds_context = cds_get_global_context(); |
| 2233 | if (!p_cds_context) { |
Jeff Johnson | d0a6b2c | 2018-05-30 22:57:39 -0700 | [diff] [blame] | 2234 | cds_err("cds context is Invalid"); |
Yu Wang | 66a250b | 2017-07-19 11:46:40 +0800 | [diff] [blame] | 2235 | return false; |
| 2236 | } |
| 2237 | |
Jeff Johnson | 323a6f0 | 2018-05-29 15:09:12 -0700 | [diff] [blame] | 2238 | hdd_ctx = (struct hdd_context *)(p_cds_context->hdd_context); |
Yu Wang | 66a250b | 2017-07-19 11:46:40 +0800 | [diff] [blame] | 2239 | if ((NULL == hdd_ctx) || (NULL == hdd_ctx->config)) { |
Jeff Johnson | d0a6b2c | 2018-05-30 22:57:39 -0700 | [diff] [blame] | 2240 | cds_err("Hdd Context is Null"); |
Yu Wang | 66a250b | 2017-07-19 11:46:40 +0800 | [diff] [blame] | 2241 | return false; |
| 2242 | } |
| 2243 | |
| 2244 | return HDD_TSF_IS_TX_SET(hdd_ctx); |
| 2245 | } |
| 2246 | #endif |
| 2247 | |
Abhishek Singh | 5ea8653 | 2016-04-27 14:10:53 +0530 | [diff] [blame] | 2248 | /** |
| 2249 | * cds_get_log_indicator() - Get the log flush indicator |
| 2250 | * |
| 2251 | * This function is used to get the log flush indicator |
| 2252 | * |
| 2253 | * Return: log indicator |
| 2254 | */ |
| 2255 | uint32_t cds_get_log_indicator(void) |
| 2256 | { |
Jeff Johnson | 2b6982c | 2018-05-29 14:56:11 -0700 | [diff] [blame] | 2257 | struct cds_context *p_cds_context; |
Abhishek Singh | 5ea8653 | 2016-04-27 14:10:53 +0530 | [diff] [blame] | 2258 | uint32_t indicator; |
| 2259 | |
| 2260 | p_cds_context = cds_get_global_context(); |
| 2261 | if (!p_cds_context) { |
Jeff Johnson | d0a6b2c | 2018-05-30 22:57:39 -0700 | [diff] [blame] | 2262 | cds_err("cds context is Invalid"); |
Abhishek Singh | 5ea8653 | 2016-04-27 14:10:53 +0530 | [diff] [blame] | 2263 | return WLAN_LOG_INDICATOR_UNUSED; |
| 2264 | } |
| 2265 | |
| 2266 | if (cds_is_load_or_unload_in_progress() || |
Hanumanth Reddy Pothula | 2a8a740 | 2017-07-03 14:06:11 +0530 | [diff] [blame] | 2267 | cds_is_driver_recovering() || cds_is_driver_in_bad_state()) { |
Abhishek Singh | 5ea8653 | 2016-04-27 14:10:53 +0530 | [diff] [blame] | 2268 | return WLAN_LOG_INDICATOR_UNUSED; |
| 2269 | } |
| 2270 | |
| 2271 | qdf_spinlock_acquire(&p_cds_context->bug_report_lock); |
| 2272 | indicator = p_cds_context->log_complete.indicator; |
| 2273 | qdf_spinlock_release(&p_cds_context->bug_report_lock); |
| 2274 | return indicator; |
| 2275 | } |
| 2276 | |
| 2277 | /** |
| 2278 | * cds_wlan_flush_host_logs_for_fatal() - Wrapper to flush host logs |
| 2279 | * |
| 2280 | * This function is used to send signal to the logger thread to |
| 2281 | * flush the host logs. |
| 2282 | * |
| 2283 | * Return: None |
| 2284 | * |
| 2285 | */ |
| 2286 | void cds_wlan_flush_host_logs_for_fatal(void) |
| 2287 | { |
| 2288 | wlan_flush_host_logs_for_fatal(); |
| 2289 | } |
| 2290 | |
| 2291 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2292 | * cds_flush_logs() - Report fatal event to userspace |
| 2293 | * @is_fatal: Indicates if the event triggering bug report is fatal or not |
| 2294 | * @indicator: Source which trigerred the bug report |
| 2295 | * @reason_code: Reason for triggering bug report |
Abhishek Singh | 5ea8653 | 2016-04-27 14:10:53 +0530 | [diff] [blame] | 2296 | * @dump_mac_trace: If mac trace are needed in logs. |
| 2297 | * @recovery_needed: If recovery is needed after bug report |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2298 | * |
| 2299 | * This function sets the log related params and send the WMI command to the |
| 2300 | * FW to flush its logs. On receiving the flush completion event from the FW |
| 2301 | * the same will be conveyed to userspace |
| 2302 | * |
| 2303 | * Return: 0 on success |
| 2304 | */ |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2305 | QDF_STATUS cds_flush_logs(uint32_t is_fatal, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2306 | uint32_t indicator, |
Abhishek Singh | 5ea8653 | 2016-04-27 14:10:53 +0530 | [diff] [blame] | 2307 | uint32_t reason_code, |
| 2308 | bool dump_mac_trace, |
| 2309 | bool recovery_needed) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2310 | { |
| 2311 | uint32_t ret; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2312 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2313 | |
Jeff Johnson | 2b6982c | 2018-05-29 14:56:11 -0700 | [diff] [blame] | 2314 | struct cds_context *p_cds_context; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2315 | |
| 2316 | p_cds_context = cds_get_global_context(); |
| 2317 | if (!p_cds_context) { |
Jeff Johnson | d0a6b2c | 2018-05-30 22:57:39 -0700 | [diff] [blame] | 2318 | cds_err("cds context is Invalid"); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2319 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2320 | } |
Abhishek Singh | 5ea8653 | 2016-04-27 14:10:53 +0530 | [diff] [blame] | 2321 | if (!p_cds_context->enable_fatal_event) { |
Jeff Johnson | d0a6b2c | 2018-05-30 22:57:39 -0700 | [diff] [blame] | 2322 | cds_err("Fatal event not enabled"); |
Abhishek Singh | 5ea8653 | 2016-04-27 14:10:53 +0530 | [diff] [blame] | 2323 | return QDF_STATUS_E_FAILURE; |
| 2324 | } |
| 2325 | if (cds_is_load_or_unload_in_progress() || |
Hanumanth Reddy Pothula | 2a8a740 | 2017-07-03 14:06:11 +0530 | [diff] [blame] | 2326 | cds_is_driver_recovering() || cds_is_driver_in_bad_state()) { |
Jeff Johnson | d0a6b2c | 2018-05-30 22:57:39 -0700 | [diff] [blame] | 2327 | cds_err("un/Load/SSR in progress"); |
Abhishek Singh | 5ea8653 | 2016-04-27 14:10:53 +0530 | [diff] [blame] | 2328 | return QDF_STATUS_E_FAILURE; |
| 2329 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2330 | |
Jeff Johnson | d0a6b2c | 2018-05-30 22:57:39 -0700 | [diff] [blame] | 2331 | if (cds_is_log_report_in_progress()) { |
| 2332 | cds_err("Bug report already in progress - dropping! type:%d, indicator=%d reason_code=%d", |
| 2333 | is_fatal, indicator, reason_code); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2334 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2335 | } |
| 2336 | |
Abhishek Singh | 5ea8653 | 2016-04-27 14:10:53 +0530 | [diff] [blame] | 2337 | status = cds_set_log_completion(is_fatal, indicator, |
| 2338 | reason_code, recovery_needed); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2339 | if (QDF_STATUS_SUCCESS != status) { |
Jeff Johnson | d0a6b2c | 2018-05-30 22:57:39 -0700 | [diff] [blame] | 2340 | cds_err("Failed to set log trigger params"); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2341 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2342 | } |
| 2343 | |
Jeff Johnson | d0a6b2c | 2018-05-30 22:57:39 -0700 | [diff] [blame] | 2344 | cds_info("Triggering bug report: type:%d, indicator=%d reason_code=%d", |
| 2345 | is_fatal, indicator, reason_code); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2346 | |
Abhishek Singh | 5ea8653 | 2016-04-27 14:10:53 +0530 | [diff] [blame] | 2347 | if (dump_mac_trace) |
Jeff Johnson | 528c2cf | 2018-05-29 15:55:58 -0700 | [diff] [blame] | 2348 | qdf_trace_dump_all(p_cds_context->mac_context, 0, 0, 500, 0); |
Abhishek Singh | 5ea8653 | 2016-04-27 14:10:53 +0530 | [diff] [blame] | 2349 | |
| 2350 | if (WLAN_LOG_INDICATOR_HOST_ONLY == indicator) { |
| 2351 | cds_wlan_flush_host_logs_for_fatal(); |
| 2352 | return QDF_STATUS_SUCCESS; |
| 2353 | } |
| 2354 | |
Jeff Johnson | 528c2cf | 2018-05-29 15:55:58 -0700 | [diff] [blame] | 2355 | ret = sme_send_flush_logs_cmd_to_fw(p_cds_context->mac_context); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2356 | if (0 != ret) { |
Jeff Johnson | d0a6b2c | 2018-05-30 22:57:39 -0700 | [diff] [blame] | 2357 | cds_err("Failed to send flush FW log"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2358 | cds_init_log_completion(); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2359 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2360 | } |
| 2361 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2362 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2363 | } |
| 2364 | |
| 2365 | /** |
| 2366 | * cds_logging_set_fw_flush_complete() - Wrapper for FW log flush completion |
| 2367 | * |
| 2368 | * This function is used to send signal to the logger thread to indicate |
| 2369 | * that the flushing of FW logs is complete by the FW |
| 2370 | * |
| 2371 | * Return: None |
| 2372 | * |
| 2373 | */ |
| 2374 | void cds_logging_set_fw_flush_complete(void) |
| 2375 | { |
| 2376 | wlan_logging_set_fw_flush_complete(); |
| 2377 | } |
Abhishek Singh | 5ea8653 | 2016-04-27 14:10:53 +0530 | [diff] [blame] | 2378 | |
| 2379 | /** |
| 2380 | * cds_set_fatal_event() - set fatal event status |
| 2381 | * @value: pending statue to set |
| 2382 | * |
| 2383 | * Return: None |
| 2384 | */ |
| 2385 | void cds_set_fatal_event(bool value) |
| 2386 | { |
Jeff Johnson | 2b6982c | 2018-05-29 14:56:11 -0700 | [diff] [blame] | 2387 | struct cds_context *p_cds_context; |
Abhishek Singh | 5ea8653 | 2016-04-27 14:10:53 +0530 | [diff] [blame] | 2388 | |
| 2389 | p_cds_context = cds_get_global_context(); |
| 2390 | if (!p_cds_context) { |
Jeff Johnson | d0a6b2c | 2018-05-30 22:57:39 -0700 | [diff] [blame] | 2391 | cds_err("cds context is Invalid"); |
Abhishek Singh | 5ea8653 | 2016-04-27 14:10:53 +0530 | [diff] [blame] | 2392 | return; |
| 2393 | } |
| 2394 | p_cds_context->enable_fatal_event = value; |
| 2395 | } |
| 2396 | |
Ryan Hsu | ceddceb | 2016-04-28 10:20:14 -0700 | [diff] [blame] | 2397 | /** |
| 2398 | * cds_get_radio_index() - get radio index |
| 2399 | * |
| 2400 | * Return: radio index otherwise, -EINVAL |
| 2401 | */ |
| 2402 | int cds_get_radio_index(void) |
| 2403 | { |
Jeff Johnson | 2b6982c | 2018-05-29 14:56:11 -0700 | [diff] [blame] | 2404 | struct cds_context *p_cds_context; |
Ryan Hsu | ceddceb | 2016-04-28 10:20:14 -0700 | [diff] [blame] | 2405 | |
| 2406 | p_cds_context = cds_get_global_context(); |
| 2407 | if (!p_cds_context) { |
| 2408 | /* |
| 2409 | * To avoid recursive call, this should not change to |
| 2410 | * QDF_TRACE(). |
| 2411 | */ |
| 2412 | pr_err("%s: cds context is invalid\n", __func__); |
| 2413 | return -EINVAL; |
| 2414 | } |
| 2415 | |
| 2416 | return p_cds_context->radio_index; |
| 2417 | } |
| 2418 | |
| 2419 | /** |
| 2420 | * cds_set_radio_index() - set radio index |
| 2421 | * @radio_index: the radio index to set |
| 2422 | * |
| 2423 | * Return: QDF status |
| 2424 | */ |
| 2425 | QDF_STATUS cds_set_radio_index(int radio_index) |
| 2426 | { |
Jeff Johnson | 2b6982c | 2018-05-29 14:56:11 -0700 | [diff] [blame] | 2427 | struct cds_context *p_cds_context; |
Ryan Hsu | ceddceb | 2016-04-28 10:20:14 -0700 | [diff] [blame] | 2428 | |
| 2429 | p_cds_context = cds_get_global_context(); |
| 2430 | if (!p_cds_context) { |
| 2431 | pr_err("%s: cds context is invalid\n", __func__); |
| 2432 | return QDF_STATUS_E_FAILURE; |
| 2433 | } |
| 2434 | |
| 2435 | p_cds_context->radio_index = radio_index; |
| 2436 | |
| 2437 | return QDF_STATUS_SUCCESS; |
| 2438 | } |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 2439 | |
| 2440 | /** |
| 2441 | * cds_init_ini_config() - API to initialize CDS configuration parameters |
| 2442 | * @cfg: CDS Configuration |
| 2443 | * |
| 2444 | * Return: void |
| 2445 | */ |
| 2446 | |
| 2447 | void cds_init_ini_config(struct cds_config_info *cfg) |
| 2448 | { |
Jeff Johnson | 2b6982c | 2018-05-29 14:56:11 -0700 | [diff] [blame] | 2449 | struct cds_context *cds_ctx; |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 2450 | |
| 2451 | cds_ctx = cds_get_context(QDF_MODULE_ID_QDF); |
| 2452 | if (!cds_ctx) { |
| 2453 | cds_err("Invalid CDS Context"); |
| 2454 | return; |
| 2455 | } |
| 2456 | |
| 2457 | cds_ctx->cds_cfg = cfg; |
| 2458 | } |
| 2459 | |
| 2460 | /** |
| 2461 | * cds_deinit_ini_config() - API to free CDS configuration parameters |
| 2462 | * |
| 2463 | * Return: void |
| 2464 | */ |
| 2465 | void cds_deinit_ini_config(void) |
| 2466 | { |
Jeff Johnson | 2b6982c | 2018-05-29 14:56:11 -0700 | [diff] [blame] | 2467 | struct cds_context *cds_ctx; |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 2468 | |
| 2469 | cds_ctx = cds_get_context(QDF_MODULE_ID_QDF); |
| 2470 | if (!cds_ctx) { |
| 2471 | cds_err("Invalid CDS Context"); |
| 2472 | return; |
| 2473 | } |
| 2474 | |
Arun Khandavalli | f624663 | 2016-08-17 17:43:06 +0530 | [diff] [blame] | 2475 | if (cds_ctx->cds_cfg) |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 2476 | qdf_mem_free(cds_ctx->cds_cfg); |
| 2477 | |
| 2478 | cds_ctx->cds_cfg = NULL; |
| 2479 | } |
| 2480 | |
| 2481 | /** |
| 2482 | * cds_get_ini_config() - API to get CDS configuration parameters |
| 2483 | * |
| 2484 | * Return: cds config structure |
| 2485 | */ |
| 2486 | struct cds_config_info *cds_get_ini_config(void) |
| 2487 | { |
Jeff Johnson | 2b6982c | 2018-05-29 14:56:11 -0700 | [diff] [blame] | 2488 | struct cds_context *cds_ctx; |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 2489 | |
| 2490 | cds_ctx = cds_get_context(QDF_MODULE_ID_QDF); |
| 2491 | if (!cds_ctx) { |
| 2492 | cds_err("Invalid CDS Context"); |
| 2493 | return NULL; |
| 2494 | } |
| 2495 | |
| 2496 | return cds_ctx->cds_cfg; |
| 2497 | } |
Naveen Rawat | 64e477e | 2016-05-20 10:34:56 -0700 | [diff] [blame] | 2498 | |
| 2499 | /** |
| 2500 | * cds_is_5_mhz_enabled() - API to get 5MHZ enabled |
| 2501 | * |
| 2502 | * Return: true if 5 mhz is enabled, false otherwise |
| 2503 | */ |
| 2504 | bool cds_is_5_mhz_enabled(void) |
| 2505 | { |
Jeff Johnson | 2b6982c | 2018-05-29 14:56:11 -0700 | [diff] [blame] | 2506 | struct cds_context *p_cds_context; |
Naveen Rawat | 64e477e | 2016-05-20 10:34:56 -0700 | [diff] [blame] | 2507 | |
| 2508 | p_cds_context = cds_get_context(QDF_MODULE_ID_QDF); |
| 2509 | if (!p_cds_context) { |
| 2510 | cds_err("%s: cds context is invalid", __func__); |
| 2511 | return false; |
| 2512 | } |
| 2513 | |
| 2514 | if (p_cds_context->cds_cfg) |
| 2515 | return (p_cds_context->cds_cfg->sub_20_channel_width == |
| 2516 | WLAN_SUB_20_CH_WIDTH_5); |
| 2517 | |
| 2518 | return false; |
| 2519 | } |
| 2520 | |
| 2521 | /** |
| 2522 | * cds_is_10_mhz_enabled() - API to get 10-MHZ enabled |
| 2523 | * |
| 2524 | * Return: true if 10 mhz is enabled, false otherwise |
| 2525 | */ |
| 2526 | bool cds_is_10_mhz_enabled(void) |
| 2527 | { |
Jeff Johnson | 2b6982c | 2018-05-29 14:56:11 -0700 | [diff] [blame] | 2528 | struct cds_context *p_cds_context; |
Naveen Rawat | 64e477e | 2016-05-20 10:34:56 -0700 | [diff] [blame] | 2529 | |
| 2530 | p_cds_context = cds_get_context(QDF_MODULE_ID_QDF); |
| 2531 | if (!p_cds_context) { |
| 2532 | cds_err("%s: cds context is invalid", __func__); |
| 2533 | return false; |
| 2534 | } |
| 2535 | |
| 2536 | if (p_cds_context->cds_cfg) |
| 2537 | return (p_cds_context->cds_cfg->sub_20_channel_width == |
| 2538 | WLAN_SUB_20_CH_WIDTH_10); |
| 2539 | |
| 2540 | return false; |
| 2541 | } |
| 2542 | |
| 2543 | /** |
| 2544 | * cds_is_sub_20_mhz_enabled() - API to get sub 20-MHZ enabled |
| 2545 | * |
| 2546 | * Return: true if 5 or 10 mhz is enabled, false otherwise |
| 2547 | */ |
| 2548 | bool cds_is_sub_20_mhz_enabled(void) |
| 2549 | { |
Jeff Johnson | 2b6982c | 2018-05-29 14:56:11 -0700 | [diff] [blame] | 2550 | struct cds_context *p_cds_context; |
Naveen Rawat | 64e477e | 2016-05-20 10:34:56 -0700 | [diff] [blame] | 2551 | |
| 2552 | p_cds_context = cds_get_context(QDF_MODULE_ID_QDF); |
| 2553 | if (!p_cds_context) { |
| 2554 | cds_err("%s: cds context is invalid", __func__); |
| 2555 | return false; |
| 2556 | } |
| 2557 | |
| 2558 | if (p_cds_context->cds_cfg) |
| 2559 | return p_cds_context->cds_cfg->sub_20_channel_width; |
| 2560 | |
| 2561 | return false; |
| 2562 | } |
| 2563 | |
Komal Seelam | 78ff65a | 2016-08-18 15:25:24 +0530 | [diff] [blame] | 2564 | /** |
Naveen Rawat | 91df30a | 2016-10-12 21:26:18 -0700 | [diff] [blame] | 2565 | * cds_is_self_recovery_enabled() - API to get self recovery enabled |
| 2566 | * |
| 2567 | * Return: true if self recovery enabled, false otherwise |
| 2568 | */ |
| 2569 | bool cds_is_self_recovery_enabled(void) |
| 2570 | { |
Jeff Johnson | 2b6982c | 2018-05-29 14:56:11 -0700 | [diff] [blame] | 2571 | struct cds_context *p_cds_context; |
Naveen Rawat | 91df30a | 2016-10-12 21:26:18 -0700 | [diff] [blame] | 2572 | |
| 2573 | p_cds_context = cds_get_context(QDF_MODULE_ID_QDF); |
| 2574 | if (!p_cds_context) { |
| 2575 | cds_err("%s: cds context is invalid", __func__); |
| 2576 | return false; |
| 2577 | } |
| 2578 | |
| 2579 | if (p_cds_context->cds_cfg) |
| 2580 | return p_cds_context->cds_cfg->self_recovery_enabled; |
| 2581 | |
| 2582 | return false; |
| 2583 | } |
| 2584 | |
| 2585 | /** |
Komal Seelam | 78ff65a | 2016-08-18 15:25:24 +0530 | [diff] [blame] | 2586 | * cds_svc_fw_shutdown_ind() - API to send userspace about FW crash |
| 2587 | * |
| 2588 | * @dev: Device Pointer |
| 2589 | * |
| 2590 | * Return: None |
| 2591 | */ |
| 2592 | void cds_svc_fw_shutdown_ind(struct device *dev) |
| 2593 | { |
| 2594 | hdd_svc_fw_shutdown_ind(dev); |
| 2595 | } |
Himanshu Agarwal | 46956a5 | 2016-07-26 19:46:25 +0530 | [diff] [blame] | 2596 | |
Nirav Shah | eb017be | 2018-02-15 11:20:58 +0530 | [diff] [blame] | 2597 | #ifdef WLAN_LOGGING_SOCK_SVC_ENABLE |
Himanshu Agarwal | 46956a5 | 2016-07-26 19:46:25 +0530 | [diff] [blame] | 2598 | /* |
| 2599 | * cds_pkt_stats_to_logger_thread() - send pktstats to user |
| 2600 | * @pl_hdr: Pointer to pl_hdr |
| 2601 | * @pkt_dump: Pointer to pkt_dump data structure. |
| 2602 | * @data: Pointer to data |
| 2603 | * |
| 2604 | * This function is used to send the pkt stats to SVC module. |
| 2605 | * |
| 2606 | * Return: None |
| 2607 | */ |
| 2608 | inline void cds_pkt_stats_to_logger_thread(void *pl_hdr, void *pkt_dump, |
| 2609 | void *data) |
| 2610 | { |
| 2611 | if (cds_get_ring_log_level(RING_ID_PER_PACKET_STATS) != |
| 2612 | WLAN_LOG_LEVEL_ACTIVE) |
| 2613 | return; |
| 2614 | |
| 2615 | wlan_pkt_stats_to_logger_thread(pl_hdr, pkt_dump, data); |
| 2616 | } |
Nirav Shah | eb017be | 2018-02-15 11:20:58 +0530 | [diff] [blame] | 2617 | #endif |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 2618 | |
| 2619 | /** |
| 2620 | * cds_get_conparam() - Get the connection mode parameters |
| 2621 | * |
| 2622 | * Return the connection mode parameter set by insmod or set during statically |
| 2623 | * linked driver |
| 2624 | * |
Jeff Johnson | 876c1a6 | 2017-12-12 10:43:07 -0800 | [diff] [blame] | 2625 | * Return: enum QDF_GLOBAL_MODE |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 2626 | */ |
Jeff Johnson | 876c1a6 | 2017-12-12 10:43:07 -0800 | [diff] [blame] | 2627 | enum QDF_GLOBAL_MODE cds_get_conparam(void) |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 2628 | { |
Jeff Johnson | 876c1a6 | 2017-12-12 10:43:07 -0800 | [diff] [blame] | 2629 | enum QDF_GLOBAL_MODE con_mode; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 2630 | |
| 2631 | con_mode = hdd_get_conparam(); |
| 2632 | |
| 2633 | return con_mode; |
| 2634 | } |
Dustin Brown | 8d2d0f5 | 2017-04-03 17:02:08 -0700 | [diff] [blame] | 2635 | |
Rachit Kankane | b103562 | 2018-01-24 18:41:35 +0530 | [diff] [blame] | 2636 | #ifdef FEATURE_HTC_CREDIT_HISTORY |
Dustin Brown | 8d2d0f5 | 2017-04-03 17:02:08 -0700 | [diff] [blame] | 2637 | inline void |
| 2638 | cds_print_htc_credit_history(uint32_t count, qdf_abstract_print *print, |
| 2639 | void *print_priv) |
| 2640 | { |
| 2641 | htc_print_credit_history(gp_cds_context->htc_ctx, count, |
| 2642 | print, print_priv); |
| 2643 | } |
| 2644 | #endif |
Sravan Kumar Kairam | c1ae71c | 2017-02-24 12:27:27 +0530 | [diff] [blame] | 2645 | |
Poddar, Siddarth | 3906e17 | 2018-01-09 11:24:58 +0530 | [diff] [blame] | 2646 | uint32_t cds_get_connectivity_stats_pkt_bitmap(void *context) |
| 2647 | { |
| 2648 | struct hdd_adapter *adapter = NULL; |
| 2649 | |
Alok Kumar | fa826fd | 2018-02-19 15:10:34 +0530 | [diff] [blame] | 2650 | if (!context) |
| 2651 | return 0; |
| 2652 | |
Poddar, Siddarth | 3906e17 | 2018-01-09 11:24:58 +0530 | [diff] [blame] | 2653 | adapter = (struct hdd_adapter *)context; |
| 2654 | if (unlikely(adapter->magic != WLAN_HDD_ADAPTER_MAGIC)) { |
Jeff Johnson | d0a6b2c | 2018-05-30 22:57:39 -0700 | [diff] [blame] | 2655 | cds_err("Magic cookie(%x) for adapter sanity verification is invalid", |
| 2656 | adapter->magic); |
Alok Kumar | d27a9ed | 2018-04-17 10:36:24 +0530 | [diff] [blame] | 2657 | return 0; |
Poddar, Siddarth | 3906e17 | 2018-01-09 11:24:58 +0530 | [diff] [blame] | 2658 | } |
| 2659 | return adapter->pkt_type_bitmap; |
| 2660 | } |
| 2661 | |
| 2662 | /** |
| 2663 | * cds_get_arp_stats_gw_ip() - get arp stats track IP |
| 2664 | * |
| 2665 | * Return: ARP stats IP to track |
| 2666 | */ |
Poddar, Siddarth | 31797fa | 2018-01-22 17:24:15 +0530 | [diff] [blame] | 2667 | uint32_t cds_get_arp_stats_gw_ip(void *context) |
Sravan Kumar Kairam | c1ae71c | 2017-02-24 12:27:27 +0530 | [diff] [blame] | 2668 | { |
Alok Kumar | fa826fd | 2018-02-19 15:10:34 +0530 | [diff] [blame] | 2669 | struct hdd_adapter *adapter = NULL; |
| 2670 | |
| 2671 | if (!context) |
| 2672 | return 0; |
| 2673 | |
| 2674 | adapter = (struct hdd_adapter *)context; |
Sravan Kumar Kairam | c1ae71c | 2017-02-24 12:27:27 +0530 | [diff] [blame] | 2675 | |
Poddar, Siddarth | 31797fa | 2018-01-22 17:24:15 +0530 | [diff] [blame] | 2676 | if (unlikely(adapter->magic != WLAN_HDD_ADAPTER_MAGIC)) { |
Jeff Johnson | d0a6b2c | 2018-05-30 22:57:39 -0700 | [diff] [blame] | 2677 | cds_err("Magic cookie(%x) for adapter sanity verification is invalid", |
| 2678 | adapter->magic); |
Sravan Kumar Kairam | c1ae71c | 2017-02-24 12:27:27 +0530 | [diff] [blame] | 2679 | return 0; |
| 2680 | } |
| 2681 | |
Poddar, Siddarth | 31797fa | 2018-01-22 17:24:15 +0530 | [diff] [blame] | 2682 | return adapter->track_arp_ip; |
Sravan Kumar Kairam | c1ae71c | 2017-02-24 12:27:27 +0530 | [diff] [blame] | 2683 | } |
| 2684 | |
| 2685 | /** |
| 2686 | * cds_incr_arp_stats_tx_tgt_delivered() - increment ARP stats |
| 2687 | * |
| 2688 | * Return: none |
| 2689 | */ |
| 2690 | void cds_incr_arp_stats_tx_tgt_delivered(void) |
| 2691 | { |
| 2692 | struct hdd_context *hdd_ctx; |
| 2693 | struct hdd_adapter *adapter = NULL; |
| 2694 | |
Jeff Johnson | 323a6f0 | 2018-05-29 15:09:12 -0700 | [diff] [blame] | 2695 | hdd_ctx = gp_cds_context->hdd_context; |
Sravan Kumar Kairam | c1ae71c | 2017-02-24 12:27:27 +0530 | [diff] [blame] | 2696 | if (!hdd_ctx) { |
| 2697 | cds_err("Hdd Context is Null"); |
| 2698 | return; |
| 2699 | } |
| 2700 | |
| 2701 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 2702 | if (QDF_STA_MODE == adapter->device_mode) |
| 2703 | break; |
| 2704 | } |
| 2705 | |
| 2706 | if (adapter) |
| 2707 | adapter->hdd_stats.hdd_arp_stats.tx_host_fw_sent++; |
| 2708 | } |
| 2709 | |
| 2710 | /** |
| 2711 | * cds_incr_arp_stats_tx_tgt_acked() - increment ARP stats |
| 2712 | * |
| 2713 | * Return: none |
| 2714 | */ |
| 2715 | void cds_incr_arp_stats_tx_tgt_acked(void) |
| 2716 | { |
| 2717 | struct hdd_context *hdd_ctx; |
| 2718 | struct hdd_adapter *adapter = NULL; |
| 2719 | |
Jeff Johnson | 323a6f0 | 2018-05-29 15:09:12 -0700 | [diff] [blame] | 2720 | hdd_ctx = gp_cds_context->hdd_context; |
Sravan Kumar Kairam | c1ae71c | 2017-02-24 12:27:27 +0530 | [diff] [blame] | 2721 | if (!hdd_ctx) { |
| 2722 | cds_err("Hdd Context is Null"); |
| 2723 | return; |
| 2724 | } |
| 2725 | |
| 2726 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 2727 | if (QDF_STA_MODE == adapter->device_mode) |
| 2728 | break; |
| 2729 | } |
| 2730 | |
| 2731 | if (adapter) |
| 2732 | adapter->hdd_stats.hdd_arp_stats.tx_ack_cnt++; |
| 2733 | } |
Himanshu Agarwal | edf30dc | 2017-06-05 15:54:27 +0530 | [diff] [blame] | 2734 | |
| 2735 | #ifdef ENABLE_SMMU_S1_TRANSLATION |
Yun Park | 45d3597 | 2018-03-02 09:57:54 -0800 | [diff] [blame] | 2736 | QDF_STATUS cds_smmu_mem_map_setup(qdf_device_t osdev, bool ipa_present) |
Himanshu Agarwal | edf30dc | 2017-06-05 15:54:27 +0530 | [diff] [blame] | 2737 | { |
| 2738 | int attr = 0; |
Yun Park | 45d3597 | 2018-03-02 09:57:54 -0800 | [diff] [blame] | 2739 | bool ipa_smmu_enable = false; |
Himanshu Agarwal | edf30dc | 2017-06-05 15:54:27 +0530 | [diff] [blame] | 2740 | struct dma_iommu_mapping *mapping = pld_smmu_get_mapping(osdev->dev); |
| 2741 | |
| 2742 | osdev->smmu_s1_enabled = false; |
Himanshu Agarwal | a89ce24 | 2017-11-17 17:36:34 +0530 | [diff] [blame] | 2743 | |
Yun Park | 45d3597 | 2018-03-02 09:57:54 -0800 | [diff] [blame] | 2744 | if (ipa_present) { |
| 2745 | ipa_smmu_enable = qdf_get_ipa_smmu_enabled(); |
| 2746 | if (ipa_smmu_enable) |
| 2747 | cds_info("SMMU enabled from IPA side"); |
| 2748 | else |
| 2749 | cds_info("SMMU not enabled from IPA side"); |
| 2750 | } |
Himanshu Agarwal | a89ce24 | 2017-11-17 17:36:34 +0530 | [diff] [blame] | 2751 | |
| 2752 | if (mapping && ((iommu_domain_get_attr(mapping->domain, |
| 2753 | DOMAIN_ATTR_S1_BYPASS, &attr) == 0) && |
| 2754 | !attr)) { |
| 2755 | cds_info("SMMU enabled from WLAN side"); |
Yun Park | 45d3597 | 2018-03-02 09:57:54 -0800 | [diff] [blame] | 2756 | |
| 2757 | if (ipa_present) { |
| 2758 | if (ipa_smmu_enable) { |
| 2759 | cds_info("SMMU enabled from both IPA and WLAN side"); |
| 2760 | osdev->smmu_s1_enabled = true; |
| 2761 | } else { |
| 2762 | cds_err("SMMU mismatch: IPA: disable, WLAN: enable"); |
| 2763 | return QDF_STATUS_E_FAILURE; |
| 2764 | } |
Himanshu Agarwal | a89ce24 | 2017-11-17 17:36:34 +0530 | [diff] [blame] | 2765 | } else { |
Yun Park | 45d3597 | 2018-03-02 09:57:54 -0800 | [diff] [blame] | 2766 | osdev->smmu_s1_enabled = true; |
Himanshu Agarwal | a89ce24 | 2017-11-17 17:36:34 +0530 | [diff] [blame] | 2767 | } |
Yun Park | 45d3597 | 2018-03-02 09:57:54 -0800 | [diff] [blame] | 2768 | |
Himanshu Agarwal | a89ce24 | 2017-11-17 17:36:34 +0530 | [diff] [blame] | 2769 | } else { |
| 2770 | cds_info("No SMMU mapping present or SMMU disabled from WLAN side"); |
Yun Park | 45d3597 | 2018-03-02 09:57:54 -0800 | [diff] [blame] | 2771 | |
| 2772 | if (ipa_present) { |
| 2773 | if (ipa_smmu_enable) { |
| 2774 | cds_err("SMMU mismatch: IPA: enable, WLAN: disable"); |
| 2775 | return QDF_STATUS_E_FAILURE; |
| 2776 | } else { |
Jeff Johnson | f2cf659 | 2018-05-06 16:27:44 -0700 | [diff] [blame] | 2777 | cds_info("SMMU disabled from both IPA and WLAN side"); |
Yun Park | 45d3597 | 2018-03-02 09:57:54 -0800 | [diff] [blame] | 2778 | } |
Himanshu Agarwal | a89ce24 | 2017-11-17 17:36:34 +0530 | [diff] [blame] | 2779 | } |
Himanshu Agarwal | edf30dc | 2017-06-05 15:54:27 +0530 | [diff] [blame] | 2780 | } |
Sravan Kumar Kairam | 5a8c4ba | 2018-04-12 11:54:31 +0530 | [diff] [blame] | 2781 | osdev->iommu_mapping = mapping; |
Himanshu Agarwal | edf30dc | 2017-06-05 15:54:27 +0530 | [diff] [blame] | 2782 | |
Himanshu Agarwal | a89ce24 | 2017-11-17 17:36:34 +0530 | [diff] [blame] | 2783 | return QDF_STATUS_SUCCESS; |
Himanshu Agarwal | edf30dc | 2017-06-05 15:54:27 +0530 | [diff] [blame] | 2784 | } |
| 2785 | |
Sravan Kumar Kairam | 4329c5f | 2018-03-02 11:26:29 +0530 | [diff] [blame] | 2786 | #ifdef IPA_OFFLOAD |
Himanshu Agarwal | edf30dc | 2017-06-05 15:54:27 +0530 | [diff] [blame] | 2787 | int cds_smmu_map_unmap(bool map, uint32_t num_buf, qdf_mem_info_t *buf_arr) |
| 2788 | { |
Sravan Kumar Kairam | 983a445 | 2018-03-20 13:30:22 +0530 | [diff] [blame] | 2789 | return ucfg_ipa_uc_smmu_map(map, num_buf, buf_arr); |
Himanshu Agarwal | edf30dc | 2017-06-05 15:54:27 +0530 | [diff] [blame] | 2790 | } |
| 2791 | #else |
Sravan Kumar Kairam | 4329c5f | 2018-03-02 11:26:29 +0530 | [diff] [blame] | 2792 | int cds_smmu_map_unmap(bool map, uint32_t num_buf, qdf_mem_info_t *buf_arr) |
| 2793 | { |
| 2794 | return 0; |
| 2795 | } |
| 2796 | #endif |
| 2797 | |
| 2798 | #else |
Yun Park | 45d3597 | 2018-03-02 09:57:54 -0800 | [diff] [blame] | 2799 | QDF_STATUS cds_smmu_mem_map_setup(qdf_device_t osdev, bool ipa_present) |
Himanshu Agarwal | edf30dc | 2017-06-05 15:54:27 +0530 | [diff] [blame] | 2800 | { |
Sravan Kumar Kairam | b664b6c | 2018-02-27 17:43:10 +0530 | [diff] [blame] | 2801 | osdev->smmu_s1_enabled = false; |
Sravan Kumar Kairam | 5a8c4ba | 2018-04-12 11:54:31 +0530 | [diff] [blame] | 2802 | osdev->iommu_mapping = NULL; |
Himanshu Agarwal | a89ce24 | 2017-11-17 17:36:34 +0530 | [diff] [blame] | 2803 | return QDF_STATUS_SUCCESS; |
Himanshu Agarwal | edf30dc | 2017-06-05 15:54:27 +0530 | [diff] [blame] | 2804 | } |
| 2805 | |
| 2806 | int cds_smmu_map_unmap(bool map, uint32_t num_buf, qdf_mem_info_t *buf_arr) |
| 2807 | { |
| 2808 | return 0; |
| 2809 | } |
| 2810 | #endif |