1 /* 2 * Copyright (c) 2017-2018 The Linux Foundation. All rights reserved. 3 * 4 * 5 * Permission to use, copy, modify, and/or distribute this software for 6 * any purpose with or without fee is hereby granted, provided that the 7 * above copyright notice and this permission notice appear in all 8 * copies. 9 * 10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL 11 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED 12 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE 13 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL 14 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR 15 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER 16 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 17 * PERFORMANCE OF THIS SOFTWARE. 18 */ 19 20 #ifndef _SPECTRAL_CMN_API_I_H_ 21 #define _SPECTRAL_CMN_API_I_H_ 22 23 #include "spectral_defs_i.h" 24 25 /** 26 * wlan_spectral_psoc_obj_create_handler() - handler for psoc object create 27 * @psoc: reference to global psoc object 28 * @arg: reference to argument provided during registration of handler 29 * 30 * This is a handler to indicate psoc object created. Hence spectral_context 31 * object can be created and attached to psoc component list. 32 * 33 * Return: QDF_STATUS_SUCCESS on success 34 * QDF_STATUS_E_FAILURE if psoc is null 35 * QDF_STATUS_E_NOMEM on failure of spectral object allocation 36 */ 37 QDF_STATUS wlan_spectral_psoc_obj_create_handler(struct wlan_objmgr_psoc *psoc, 38 void *arg); 39 40 /** 41 * wlan_spectral_psoc_obj_destroy_handler() - handler for psoc object delete 42 * @psoc: reference to global psoc object 43 * @arg: reference to argument provided during registration of handler 44 * 45 * This is a handler to indicate psoc object going to be deleted. 46 * Hence spectral_context object can be detached from psoc component list. 47 * Then spectral_context object can be deleted. 48 * 49 * Return: QDF_STATUS_SUCCESS on success 50 * QDF_STATUS_E_FAILURE on failure 51 */ 52 QDF_STATUS wlan_spectral_psoc_obj_destroy_handler(struct wlan_objmgr_psoc *psoc, 53 void *arg); 54 55 /** 56 * wlan_spectral_pdev_obj_create_handler() - handler for pdev object create 57 * @pdev: reference to global pdev object 58 * @arg: reference to argument provided during registration of handler 59 * 60 * This is a handler to indicate pdev object created. Hence pdev specific 61 * spectral object can be created and attached to pdev component list. 62 * 63 * Return: QDF_STATUS_SUCCESS on success 64 * QDF_STATUS_E_FAILURE if pdev is null 65 * QDF_STATUS_E_NOMEM on failure of spectral object allocation 66 */ 67 QDF_STATUS wlan_spectral_pdev_obj_create_handler(struct wlan_objmgr_pdev *pdev, 68 void *arg); 69 70 /** 71 * wlan_spectral_pdev_obj_destroy_handler() - handler for pdev object delete 72 * @pdev: reference to global pdev object 73 * @arg: reference to argument provided during registration of handler 74 * 75 * This is a handler to indicate pdev object going to be deleted. 76 * Hence pdev specific spectral object can be detached from pdev component list. 77 * Then pdev_spectral object can be deleted. 78 * 79 * Return: QDF_STATUS_SUCCESS on success 80 * QDF_STATUS_E_FAILURE on failure 81 */ 82 QDF_STATUS wlan_spectral_pdev_obj_destroy_handler(struct wlan_objmgr_pdev *pdev, 83 void *arg); 84 85 /** 86 * spectral_control_cmn()- common handler for demultiplexing requests from 87 * higher layer 88 * @pdev: reference to global pdev object 89 * @id: spectral config command id 90 * @indata: reference to input data 91 * @insize: input data size 92 * @outdata: reference to output data 93 * @outsize: reference to output data size 94 * 95 * This function processes the spectral config command 96 * and appropriate handlers are invoked. 97 * 98 * Return: 0 success else failure 99 */ 100 int spectral_control_cmn(struct wlan_objmgr_pdev *pdev, 101 u_int id, 102 void *indata, 103 uint32_t insize, void *outdata, uint32_t *outsize); 104 105 /** 106 * spectral_control_ol(): Offload handler for demultiplexing requests from 107 * higher layer 108 * @pdev: reference to global pdev object 109 * @id: spectral config command id 110 * @indata: reference to input data 111 * @insize: input data size 112 * @outdata: reference to output data 113 * @outsize: reference to output data size 114 * 115 * This function processes the spectral config command 116 * and appropriate handlers are invoked. 117 * 118 * Return: 0 success else failure 119 */ 120 int spectral_control_ol( 121 struct wlan_objmgr_pdev *pdev, u_int id, 122 void *indata, uint32_t insize, void *outdata, uint32_t *outsize); 123 124 /** 125 * spectral_get_spectral_ctx_from_pdev() - API to get spectral context object 126 * from pdev 127 * @pdev : Reference to pdev global object 128 * 129 * This API used to get spectral context object from global pdev reference. 130 * Null check should be done before invoking this inline function. 131 * 132 * Return : Reference to spectral_context object 133 */ 134 static inline struct spectral_context * 135 spectral_get_spectral_ctx_from_pdev(struct wlan_objmgr_pdev *pdev) 136 { 137 struct wlan_objmgr_psoc *psoc = NULL; 138 struct spectral_context *sc = NULL; 139 140 psoc = wlan_pdev_get_psoc(pdev); 141 if (psoc) { 142 sc = wlan_objmgr_psoc_get_comp_private_obj( 143 psoc, 144 WLAN_UMAC_COMP_SPECTRAL); 145 } 146 147 return sc; 148 } 149 150 /** 151 * spectral_get_spectral_ctx_from_pscoc() - API to get spectral context object 152 * from psoc 153 * @psoc : Reference to psoc global object 154 * 155 * This API used to get spectral context object from global psoc reference. 156 * Null check should be done before invoking this inline function. 157 * 158 * Return : Reference to spectral_context object 159 */ 160 static inline struct spectral_context * 161 spectral_get_spectral_ctx_from_psoc(struct wlan_objmgr_psoc *psoc) 162 { 163 struct spectral_context *sc = NULL; 164 165 if (psoc) { 166 sc = wlan_objmgr_psoc_get_comp_private_obj( 167 psoc, 168 WLAN_UMAC_COMP_SPECTRAL); 169 } 170 171 return sc; 172 } 173 174 /** 175 * spectral_get_spectral_ctx_from_vdev() - API to get spectral context object 176 * from vdev 177 * @vdev : Reference to vdev global object 178 * 179 * This API used to get spectral context object from global vdev reference. 180 * Null check should be done before invoking this inline function. 181 * 182 * Return : Reference to spectral_context object 183 */ 184 static inline struct spectral_context * 185 spectral_get_spectral_ctx_from_vdev(struct wlan_objmgr_vdev *vdev) 186 { 187 struct wlan_objmgr_psoc *psoc = NULL; 188 struct spectral_context *sc = NULL; 189 190 psoc = wlan_vdev_get_psoc(vdev); 191 if (psoc) { 192 sc = wlan_objmgr_psoc_get_comp_private_obj( 193 psoc, 194 WLAN_UMAC_COMP_SPECTRAL); 195 } 196 197 return sc; 198 } 199 #endif /* _SPECTRAL_CMN_API_I_H_ */ 200