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 #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 return QDF_STATUS_SUCCESS; 133 } 134 135 QDF_STATUS wlan_cp_stats_disable_ol(struct wlan_objmgr_psoc *psoc) 136 { 137 struct wlan_lmac_if_cp_stats_tx_ops *tx_ops; 138 139 if (!psoc) { 140 cp_stats_err("PSOC is null!"); 141 return QDF_STATUS_E_INVAL; 142 } 143 144 tx_ops = target_if_cp_stats_get_tx_ops(psoc); 145 if (!tx_ops) { 146 cp_stats_err("tx_ops is null!"); 147 return QDF_STATUS_E_NULL_VALUE; 148 } 149 150 if (!tx_ops->cp_stats_detach) { 151 cp_stats_err("cp_stats_detach function ptr is null!"); 152 return QDF_STATUS_E_NULL_VALUE; 153 } 154 155 tx_ops->cp_stats_detach(psoc); 156 return QDF_STATUS_SUCCESS; 157 } 158 159 QDF_STATUS wlan_cp_stats_ctx_init_ol(struct cp_stats_context *csc) 160 { 161 csc->cp_stats_open = wlan_cp_stats_open_ol; 162 csc->cp_stats_close = wlan_cp_stats_close_ol; 163 csc->cp_stats_enable = wlan_cp_stats_enable_ol; 164 csc->cp_stats_disable = wlan_cp_stats_disable_ol; 165 csc->cp_stats_psoc_obj_init = wlan_cp_stats_psoc_obj_init_ol; 166 csc->cp_stats_psoc_obj_deinit = wlan_cp_stats_psoc_obj_deinit_ol; 167 csc->cp_stats_pdev_obj_init = wlan_cp_stats_pdev_obj_init_ol; 168 csc->cp_stats_pdev_obj_deinit = wlan_cp_stats_pdev_obj_deinit_ol; 169 csc->cp_stats_vdev_obj_init = wlan_cp_stats_vdev_obj_init_ol; 170 csc->cp_stats_vdev_obj_deinit = wlan_cp_stats_vdev_obj_deinit_ol; 171 csc->cp_stats_peer_obj_init = wlan_cp_stats_peer_obj_init_ol; 172 csc->cp_stats_peer_obj_deinit = wlan_cp_stats_peer_obj_deinit_ol; 173 174 return QDF_STATUS_SUCCESS; 175 } 176 177 QDF_STATUS wlan_cp_stats_ctx_deinit_ol(struct cp_stats_context *csc) 178 { 179 csc->cp_stats_open = NULL; 180 csc->cp_stats_close = NULL; 181 csc->cp_stats_enable = NULL; 182 csc->cp_stats_disable = NULL; 183 csc->cp_stats_psoc_obj_init = NULL; 184 csc->cp_stats_psoc_obj_deinit = NULL; 185 csc->cp_stats_pdev_obj_init = NULL; 186 csc->cp_stats_pdev_obj_deinit = NULL; 187 csc->cp_stats_vdev_obj_init = NULL; 188 csc->cp_stats_vdev_obj_deinit = NULL; 189 csc->cp_stats_peer_obj_init = NULL; 190 csc->cp_stats_peer_obj_deinit = NULL; 191 192 return QDF_STATUS_SUCCESS; 193 } 194