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