1 /* 2 * Copyright (c) 2018 The Linux Foundation. All rights reserved. 3 * 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 19 /** 20 * DOC: wlan_cp_stats_ol_api.c 21 * 22 * This file provide definitions for following 23 * - (de)init cp stat global ctx obj 24 * - (de)init common specific ucfg handler 25 * - (de)register to WMI events for psoc open 26 */ 27 #include <wlan_objmgr_cmn.h> 28 #include "wlan_cp_stats_defs.h" 29 #include "wlan_cp_stats_ol_api.h" 30 #include "wlan_cp_stats_cmn_api_i.h" 31 #include <wlan_cp_stats_ucfg_api.h> 32 33 #include "wlan_cp_stats_ic_ucfg_handler.h" 34 #include <wlan_cp_stats_utils_api.h> 35 #include <target_if_cp_stats.h> 36 37 QDF_STATUS wlan_cp_stats_psoc_obj_init_ol(struct psoc_cp_stats *psoc_cs) 38 { 39 qdf_spinlock_create(&psoc_cs->psoc_cp_stats_lock); 40 wlan_cp_stats_psoc_cs_init(psoc_cs); 41 return QDF_STATUS_SUCCESS; 42 } 43 44 QDF_STATUS wlan_cp_stats_psoc_obj_deinit_ol(struct psoc_cp_stats *psoc_cs) 45 { 46 wlan_cp_stats_psoc_cs_deinit(psoc_cs); 47 qdf_spinlock_destroy(&psoc_cs->psoc_cp_stats_lock); 48 return QDF_STATUS_SUCCESS; 49 } 50 51 QDF_STATUS wlan_cp_stats_pdev_obj_init_ol(struct pdev_cp_stats *pdev_cs) 52 { 53 qdf_spinlock_create(&pdev_cs->pdev_cp_stats_lock); 54 wlan_cp_stats_pdev_cs_init(pdev_cs); 55 return QDF_STATUS_SUCCESS; 56 } 57 58 QDF_STATUS wlan_cp_stats_pdev_obj_deinit_ol(struct pdev_cp_stats *pdev_cs) 59 { 60 wlan_cp_stats_pdev_cs_deinit(pdev_cs); 61 qdf_spinlock_destroy(&pdev_cs->pdev_cp_stats_lock); 62 return QDF_STATUS_SUCCESS; 63 } 64 65 QDF_STATUS wlan_cp_stats_vdev_obj_init_ol(struct vdev_cp_stats *vdev_cs) 66 { 67 qdf_spinlock_create(&vdev_cs->vdev_cp_stats_lock); 68 wlan_cp_stats_vdev_cs_init(vdev_cs); 69 return QDF_STATUS_SUCCESS; 70 } 71 72 QDF_STATUS wlan_cp_stats_vdev_obj_deinit_ol(struct vdev_cp_stats *vdev_cs) 73 { 74 wlan_cp_stats_vdev_cs_deinit(vdev_cs); 75 qdf_spinlock_destroy(&vdev_cs->vdev_cp_stats_lock); 76 return QDF_STATUS_SUCCESS; 77 } 78 79 QDF_STATUS wlan_cp_stats_peer_obj_init_ol(struct peer_cp_stats *peer_cs) 80 { 81 qdf_spinlock_create(&peer_cs->peer_cp_stats_lock); 82 wlan_cp_stats_peer_cs_init(peer_cs); 83 return QDF_STATUS_SUCCESS; 84 } 85 86 QDF_STATUS wlan_cp_stats_peer_obj_deinit_ol(struct peer_cp_stats *peer_cs) 87 { 88 wlan_cp_stats_peer_cs_deinit(peer_cs); 89 qdf_spinlock_destroy(&peer_cs->peer_cp_stats_lock); 90 return QDF_STATUS_SUCCESS; 91 } 92 93 QDF_STATUS wlan_cp_stats_open_ol(struct wlan_objmgr_psoc *psoc) 94 { 95 if (!psoc) { 96 cp_stats_err("PSOC is null!"); 97 return QDF_STATUS_E_INVAL; 98 } 99 100 return QDF_STATUS_SUCCESS; 101 } 102 103 QDF_STATUS wlan_cp_stats_close_ol(struct wlan_objmgr_psoc *psoc) 104 { 105 if (!psoc) { 106 cp_stats_err("PSOC is null!"); 107 return QDF_STATUS_E_INVAL; 108 } 109 110 return QDF_STATUS_SUCCESS; 111 } 112 113 QDF_STATUS wlan_cp_stats_enable_ol(struct wlan_objmgr_psoc *psoc) 114 { 115 struct wlan_lmac_if_cp_stats_tx_ops *tx_ops; 116 117 if (!psoc) { 118 cp_stats_err("PSOC is null!"); 119 return QDF_STATUS_E_INVAL; 120 } 121 122 tx_ops = target_if_cp_stats_get_tx_ops(psoc); 123 if (!tx_ops) { 124 cp_stats_err("tx_ops is null!"); 125 return QDF_STATUS_E_NULL_VALUE; 126 } 127 128 if (!tx_ops->cp_stats_attach) { 129 cp_stats_err("cp_stats_attach function ptr is null!"); 130 return QDF_STATUS_E_NULL_VALUE; 131 } 132 133 tx_ops->cp_stats_attach(psoc); 134 return QDF_STATUS_SUCCESS; 135 } 136 137 QDF_STATUS wlan_cp_stats_disable_ol(struct wlan_objmgr_psoc *psoc) 138 { 139 struct wlan_lmac_if_cp_stats_tx_ops *tx_ops; 140 141 if (!psoc) { 142 cp_stats_err("PSOC is null!"); 143 return QDF_STATUS_E_INVAL; 144 } 145 146 tx_ops = target_if_cp_stats_get_tx_ops(psoc); 147 if (!tx_ops) { 148 cp_stats_err("tx_ops is null!"); 149 return QDF_STATUS_E_NULL_VALUE; 150 } 151 152 if (!tx_ops->cp_stats_detach) { 153 cp_stats_err("cp_stats_detach function ptr is null!"); 154 return QDF_STATUS_E_NULL_VALUE; 155 } 156 157 tx_ops->cp_stats_detach(psoc); 158 return QDF_STATUS_SUCCESS; 159 } 160 161 QDF_STATUS wlan_cp_stats_ctx_init_ol(struct cp_stats_context *csc) 162 { 163 csc->cp_stats_open = wlan_cp_stats_open_ol; 164 csc->cp_stats_close = wlan_cp_stats_close_ol; 165 csc->cp_stats_enable = wlan_cp_stats_enable_ol; 166 csc->cp_stats_disable = wlan_cp_stats_disable_ol; 167 csc->cp_stats_psoc_obj_init = wlan_cp_stats_psoc_obj_init_ol; 168 csc->cp_stats_psoc_obj_deinit = wlan_cp_stats_psoc_obj_deinit_ol; 169 csc->cp_stats_pdev_obj_init = wlan_cp_stats_pdev_obj_init_ol; 170 csc->cp_stats_pdev_obj_deinit = wlan_cp_stats_pdev_obj_deinit_ol; 171 csc->cp_stats_vdev_obj_init = wlan_cp_stats_vdev_obj_init_ol; 172 csc->cp_stats_vdev_obj_deinit = wlan_cp_stats_vdev_obj_deinit_ol; 173 csc->cp_stats_peer_obj_init = wlan_cp_stats_peer_obj_init_ol; 174 csc->cp_stats_peer_obj_deinit = wlan_cp_stats_peer_obj_deinit_ol; 175 176 return QDF_STATUS_SUCCESS; 177 } 178 179 QDF_STATUS wlan_cp_stats_ctx_deinit_ol(struct cp_stats_context *csc) 180 { 181 csc->cp_stats_open = NULL; 182 csc->cp_stats_close = NULL; 183 csc->cp_stats_enable = NULL; 184 csc->cp_stats_disable = NULL; 185 csc->cp_stats_psoc_obj_init = NULL; 186 csc->cp_stats_psoc_obj_deinit = NULL; 187 csc->cp_stats_pdev_obj_init = NULL; 188 csc->cp_stats_pdev_obj_deinit = NULL; 189 csc->cp_stats_vdev_obj_init = NULL; 190 csc->cp_stats_vdev_obj_deinit = NULL; 191 csc->cp_stats_peer_obj_init = NULL; 192 csc->cp_stats_peer_obj_deinit = NULL; 193 194 return QDF_STATUS_SUCCESS; 195 } 196