xref: /wlan-driver/qca-wifi-host-cmn/spectral/core/spectral_defs_i.h (revision 5113495b16420b49004c444715d2daae2066e7dc) !
1 /*
2  * Copyright (c) 2017-2020 The Linux Foundation. All rights reserved.
3  * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved.
4  *
5  *
6  * Permission to use, copy, modify, and/or distribute this software for
7  * any purpose with or without fee is hereby granted, provided that the
8  * above copyright notice and this permission notice appear in all
9  * copies.
10  *
11  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
12  * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
13  * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
14  * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
15  * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
16  * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
17  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
18  * PERFORMANCE OF THIS SOFTWARE.
19  */
20 
21 #ifndef _SPECTRAL_DEFS_I_H_
22 #define _SPECTRAL_DEFS_I_H_
23 
24 #include <wlan_objmgr_cmn.h>
25 #include <wlan_objmgr_global_obj.h>
26 #include <wlan_objmgr_psoc_obj.h>
27 #include <wlan_objmgr_pdev_obj.h>
28 #include <wlan_objmgr_vdev_obj.h>
29 #include <qdf_list.h>
30 #include <qdf_timer.h>
31 #include <qdf_util.h>
32 #include <wlan_spectral_public_structs.h>
33 #include <wlan_spectral_utils_api.h>
34 #include <spectral_ioctl.h>
35 
36 #define spectral_fatal(format, args...) \
37 	QDF_TRACE_FATAL(QDF_MODULE_ID_SPECTRAL, format, ## args)
38 #define spectral_err(format, args...) \
39 	QDF_TRACE_ERROR(QDF_MODULE_ID_SPECTRAL, format, ## args)
40 #define spectral_warn(format, args...) \
41 	QDF_TRACE_WARN(QDF_MODULE_ID_SPECTRAL, format, ## args)
42 #define spectral_info(format, args...) \
43 	QDF_TRACE_INFO(QDF_MODULE_ID_SPECTRAL, format, ## args)
44 #define spectral_debug(format, args...) \
45 	QDF_TRACE_DEBUG(QDF_MODULE_ID_SPECTRAL, format, ## args)
46 
47 #define spectral_fatal_nofl(format, args...) \
48 	QDF_TRACE_FATAL_NO_FL(QDF_MODULE_ID_SPECTRAL, format, ## args)
49 #define spectral_err_nofl(format, args...) \
50 	QDF_TRACE_ERROR_NO_FL(QDF_MODULE_ID_SPECTRAL, format, ## args)
51 #define spectral_warn_nofl(format, args...) \
52 	QDF_TRACE_WARN_NO_FL(QDF_MODULE_ID_SPECTRAL, format, ## args)
53 #define spectral_info_nofl(format, args...) \
54 	QDF_TRACE_INFO_NO_FL(QDF_MODULE_ID_SPECTRAL, format, ## args)
55 #define spectral_debug_nofl(format, args...) \
56 	QDF_TRACE_DEBUG_NO_FL(QDF_MODULE_ID_SPECTRAL, format, ## args)
57 
58 #define spectral_fatal_rl(format, args...) \
59 	QDF_TRACE_FATAL_RL(QDF_MODULE_ID_SPECTRAL, format, ## args)
60 #define spectral_err_rl(format, args...) \
61 	QDF_TRACE_ERROR_RL(QDF_MODULE_ID_SPECTRAL, format, ## args)
62 #define spectral_warn_rl(format, args...) \
63 	QDF_TRACE_WARN_RL(QDF_MODULE_ID_SPECTRAL, format, ## args)
64 #define spectral_info_rl(format, args...) \
65 	QDF_TRACE_INFO_RL(QDF_MODULE_ID_SPECTRAL, format, ## args)
66 #define spectral_debug_rl(format, args...) \
67 	QDF_TRACE_DEBUG_RL(QDF_MODULE_ID_SPECTRAL, format, ## args)
68 
69 #define spectral_fatal_rl_nofl(format, args...) \
70 	QDF_TRACE_FATAL_RL_NO_FL(QDF_MODULE_ID_SPECTRAL, format, ## args)
71 #define spectral_err_rl_nofl(format, args...) \
72 	QDF_TRACE_ERROR_RL_NO_FL(QDF_MODULE_ID_SPECTRAL, format, ## args)
73 #define spectral_warn_rl_nofl(format, args...) \
74 	QDF_TRACE_WARN_RL_NO_FL(QDF_MODULE_ID_SPECTRAL, format, ## args)
75 #define spectral_info_rl_nofl(format, args...) \
76 	QDF_TRACE_INFO_RL_NO_FL(QDF_MODULE_ID_SPECTRAL, format, ## args)
77 #define spectral_debug_rl_nofl(format, args...) \
78 	QDF_TRACE_DEBUG_RL_NO_FL(QDF_MODULE_ID_SPECTRAL, format, ## args)
79 
80 /**
81  * struct pdev_spectral - Radio specific spectral object
82  * @psptrl_pdev:          Back-pointer to struct wlan_objmgr_pdev
83  * @spectral_sock:        Spectral Netlink socket for sending samples to
84  *                        applications
85  * @psptrl_target_handle: reference to spectral lmac object
86  * @skb:                  Socket buffer for sending samples to applications
87  * @spectral_pid :        Spectral port ID
88  */
89 struct pdev_spectral {
90 	struct wlan_objmgr_pdev *psptrl_pdev;
91 	struct sock *spectral_sock;
92 	void *psptrl_target_handle;
93 	struct sk_buff *skb[SPECTRAL_MSG_TYPE_MAX];
94 	uint32_t spectral_pid;
95 };
96 
97 struct spectral_wmi_ops;
98 struct spectral_tgt_ops;
99 
100 /**
101  * struct spectral_context - spectral global context
102  * @psoc_obj:               Reference to psoc global object
103  * @psoc_target_handle: Reference to psoc target_if object
104  * @legacy_cbacks: Spectral legacy callbacks
105  *
106  * Call back functions to invoke independent of OL/DA
107  * @sptrlc_spectral_control:
108  * @sptrlc_ucfg_phyerr_config:     ucfg handler for phyerr
109  * @sptrlc_pdev_spectral_init: Init pdev Spectral
110  * @sptrlc_pdev_spectral_deinit: Deinit pdev Spectral
111  * @sptrlc_psoc_spectral_init: Spectral psoc init
112  * @sptrlc_psoc_spectral_deinit: Spectral psoc deinit
113  * @sptrlc_set_spectral_config:    Set spectral configurations
114  * @sptrlc_get_spectral_config:    Get spectral configurations
115  * @sptrlc_start_spectral_scan:    Start spectral scan
116  * @sptrlc_stop_spectral_scan:     Stop spectral scan
117  * @sptrlc_is_spectral_active:     Check if spectral scan is active
118  * @sptrlc_is_spectral_enabled:    Check if spectral is enabled
119  * @sptrlc_set_debug_level:        Set debug level
120  * @sptrlc_get_debug_level:        Get debug level
121  * @sptrlc_get_spectral_capinfo:   Get spectral capability info
122  * @sptrlc_get_spectral_diagstats: Get spectral diag status
123  * @sptrlc_register_spectral_wmi_ops: Register Spectral WMI operations
124  * @sptrlc_register_spectral_tgt_ops: Register Spectral target operations
125  * @sptrlc_register_netlink_cb: Register Netlink callbacks
126  * @sptrlc_use_nl_bcast: Check whether to use Netlink broadcast/unicast
127  * @sptrlc_deregister_netlink_cb: De-register Netlink callbacks
128  * @sptrlc_process_spectral_report: Process spectral report
129  * @sptrlc_set_dma_debug: Set DMA debug
130  */
131 struct spectral_context {
132 	struct wlan_objmgr_psoc *psoc_obj;
133 	void *psoc_target_handle;
134 	struct spectral_legacy_cbacks legacy_cbacks;
135 	QDF_STATUS (*sptrlc_spectral_control)
136 					(struct wlan_objmgr_pdev *pdev,
137 					 struct spectral_cp_request *sscan_req);
138 	int (*sptrlc_ucfg_phyerr_config)(struct wlan_objmgr_pdev *pdev,
139 					 void *ad);
140 	void * (*sptrlc_pdev_spectral_init)(struct wlan_objmgr_pdev *pdev);
141 	void (*sptrlc_pdev_spectral_deinit)(struct wlan_objmgr_pdev *pdev);
142 	void * (*sptrlc_psoc_spectral_init)(struct wlan_objmgr_psoc *psoc);
143 	void (*sptrlc_psoc_spectral_deinit)(struct wlan_objmgr_psoc *psoc);
144 	QDF_STATUS (*sptrlc_set_spectral_config)
145 				(struct wlan_objmgr_pdev *pdev,
146 				 const struct spectral_cp_param *param,
147 				 const enum spectral_scan_mode smode,
148 				 enum spectral_cp_error_code *err);
149 	QDF_STATUS (*sptrlc_get_spectral_config)
150 					(struct wlan_objmgr_pdev *pdev,
151 					 struct spectral_config *sptrl_config,
152 					 const enum spectral_scan_mode smode);
153 	QDF_STATUS (*sptrlc_start_spectral_scan)
154 					(struct wlan_objmgr_pdev *pdev,
155 					 uint8_t vdev_id,
156 					 const enum spectral_scan_mode smode,
157 					 enum spectral_cp_error_code *err);
158 	QDF_STATUS (*sptrlc_stop_spectral_scan)
159 					(struct wlan_objmgr_pdev *pdev,
160 					 enum spectral_scan_mode smode,
161 					 enum spectral_cp_error_code *err);
162 	bool (*sptrlc_is_spectral_active)(struct wlan_objmgr_pdev *pdev,
163 					  enum spectral_scan_mode smode);
164 	bool (*sptrlc_is_spectral_enabled)(struct wlan_objmgr_pdev *pdev,
165 					   enum spectral_scan_mode smode);
166 	QDF_STATUS (*sptrlc_set_debug_level)(struct wlan_objmgr_pdev *pdev,
167 					     uint32_t debug_level);
168 	uint32_t (*sptrlc_get_debug_level)(struct wlan_objmgr_pdev *pdev);
169 	QDF_STATUS (*sptrlc_get_spectral_capinfo)(struct wlan_objmgr_pdev *pdev,
170 						  struct spectral_caps *scaps);
171 	QDF_STATUS (*sptrlc_get_spectral_diagstats)
172 					(struct wlan_objmgr_pdev *pdev,
173 					 struct spectral_diag_stats *stats);
174 	QDF_STATUS (*sptrlc_register_spectral_wmi_ops)(
175 					struct wlan_objmgr_psoc *psoc,
176 					struct spectral_wmi_ops *wmi_ops);
177 	QDF_STATUS (*sptrlc_register_spectral_tgt_ops)(
178 					struct wlan_objmgr_psoc *psoc,
179 					struct spectral_tgt_ops *tgt_ops);
180 	void (*sptrlc_register_netlink_cb)(
181 			struct wlan_objmgr_pdev *pdev,
182 			struct spectral_nl_cb *nl_cb);
183 	bool (*sptrlc_use_nl_bcast)(struct wlan_objmgr_pdev *pdev);
184 	void (*sptrlc_deregister_netlink_cb)(struct wlan_objmgr_pdev *pdev);
185 	int (*sptrlc_process_spectral_report)(
186 			struct wlan_objmgr_pdev *pdev,
187 			void *payload);
188 	QDF_STATUS (*sptrlc_set_dma_debug)(
189 			struct wlan_objmgr_pdev *pdev,
190 			enum spectral_dma_debug dma_debug_type,
191 			bool dma_debug_enable);
192 };
193 
194 #endif /* _SPECTRAL_DEFS_I_H_ */
195