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