xref: /wlan-dirver/qca-wifi-host-cmn/spectral/core/spectral_defs_i.h (revision 3149adf58a329e17232a4c0e58d460d025edd55a)
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_DEFS_I_H_
21 #define _SPECTRAL_DEFS_I_H_
22 
23 #include <wlan_objmgr_cmn.h>
24 #include <wlan_objmgr_global_obj.h>
25 #include <wlan_objmgr_psoc_obj.h>
26 #include <wlan_objmgr_pdev_obj.h>
27 #include <wlan_objmgr_vdev_obj.h>
28 #include <qdf_list.h>
29 #include <qdf_timer.h>
30 #include <qdf_util.h>
31 #include <wlan_spectral_public_structs.h>
32 #include <wlan_spectral_utils_api.h>
33 #ifdef CONFIG_WIN
34 #include <if_athioctl.h>
35 #endif /*CONFIG_WIN*/
36 #include <spectral_ioctl.h>
37 
38 #define spectral_log(level, args...) \
39 QDF_PRINT_INFO(QDF_PRINT_IDX_SHARED, QDF_MODULE_ID_SPECTRAL, level, ## args)
40 
41 #define spectral_logfl(level, format, args...) \
42 	spectral_log(level, FL(format), ## args)
43 
44 #define spectral_fatal(format, args...) \
45 	spectral_logfl(QDF_TRACE_LEVEL_FATAL, format, ## args)
46 #define spectral_err(format, args...) \
47 	spectral_logfl(QDF_TRACE_LEVEL_ERROR, format, ## args)
48 #define spectral_warn(format, args...) \
49 	spectral_logfl(QDF_TRACE_LEVEL_WARN, format, ## args)
50 #define spectral_info(format, args...) \
51 	spectral_logfl(QDF_TRACE_LEVEL_INFO, format, ## args)
52 #define spectral_debug(format, args...) \
53 	spectral_logfl(QDF_TRACE_LEVEL_DEBUG, format, ## args)
54 
55 /**
56  * struct pdev_spectral - Radio specific spectral object
57  * @psptrl_pdev:          Back-pointer to struct wlan_objmgr_pdev
58  * @spectral_sock:        Spectral Netlink socket for sending samples to
59  *                        applications
60  * @psptrl_target_handle: reference to spectral lmac object
61  * @skb:                  Socket buffer for sending samples to applications
62  * @spectral_pid :        Spectral port ID
63  */
64 struct pdev_spectral {
65 	struct wlan_objmgr_pdev *psptrl_pdev;
66 	struct sock *spectral_sock;
67 	void *psptrl_target_handle;
68 	struct sk_buff *skb;
69 	uint32_t spectral_pid;
70 };
71 
72 struct wmi_spectral_cmd_ops;
73 /**
74  * struct spectral_context - spectral global context
75  * @psoc_obj:               Reference to psoc global object
76  * @spectral_legacy_cbacks: Spectral legacy callbacks
77  *
78  * Call back functions to invoke independent of OL/DA
79  * @sptrlc_ucfg_phyerr_config:     ucfg handler for phyerr
80  * @sptrlc_pdev_spectral_init:     Init spectral
81  * @sptrlc_pdev_spectral_deinit:   Deinit spectral
82  * @sptrlc_set_spectral_config:    Set spectral configurations
83  * @sptrlc_get_spectral_config:    Get spectral configurations
84  * @sptrlc_start_spectral_scan:    Start spectral scan
85  * @sptrlc_stop_spectral_scan:     Stop spectral scan
86  * @sptrlc_is_spectral_active:     Check if spectral scan is active
87  * @sptrlc_is_spectral_enabled:    Check if spectral is enabled
88  * @sptrlc_set_debug_level:        Set debug level
89  * @sptrlc_get_debug_level:        Get debug level
90  * @sptrlc_get_spectral_capinfo:   Get spectral capability info
91  * @sptrlc_get_spectral_diagstats: Get spectral diag status
92  * @sptrlc_register_wmi_spectral_cmd_ops: Register wmi_spectral_cmd operations
93  * @sptrlc_register_netlink_cb: Register Netlink callbacks
94  * @sptrlc_use_nl_bcast: Check whether to use Netlink broadcast/unicast
95  * @sptrlc_deregister_netlink_cb: De-register Netlink callbacks
96  */
97 struct spectral_context {
98 	struct wlan_objmgr_psoc *psoc_obj;
99 	struct spectral_legacy_cbacks legacy_cbacks;
100 	int (*sptrlc_spectral_control)(struct wlan_objmgr_pdev *pdev,
101 				       u_int id, void *indata,
102 				       uint32_t insize, void *outdata,
103 				       uint32_t *outsize);
104 	int (*sptrlc_ucfg_phyerr_config)(struct wlan_objmgr_pdev *pdev,
105 					 void *ad);
106 	void * (*sptrlc_pdev_spectral_init)(struct wlan_objmgr_pdev *pdev);
107 	void (*sptrlc_pdev_spectral_deinit)(struct wlan_objmgr_pdev *pdev);
108 	int (*sptrlc_set_spectral_config)(struct wlan_objmgr_pdev *pdev,
109 					  const uint32_t threshtype,
110 					  const uint32_t value);
111 	void (*sptrlc_get_spectral_config)(
112 			struct wlan_objmgr_pdev *pdev,
113 			struct spectral_config *sptrl_config);
114 	int (*sptrlc_start_spectral_scan)(struct wlan_objmgr_pdev *pdev);
115 	void (*sptrlc_stop_spectral_scan)(struct wlan_objmgr_pdev *pdev);
116 	bool (*sptrlc_is_spectral_active)(struct wlan_objmgr_pdev *pdev);
117 	bool (*sptrlc_is_spectral_enabled)(struct wlan_objmgr_pdev *pdev);
118 	int (*sptrlc_set_debug_level)(struct wlan_objmgr_pdev *pdev,
119 				       uint32_t debug_level);
120 	uint32_t (*sptrlc_get_debug_level)(struct wlan_objmgr_pdev *pdev);
121 	void (*sptrlc_get_spectral_capinfo)(struct wlan_objmgr_pdev *pdev,
122 					     void *outdata);
123 	void (*sptrlc_get_spectral_diagstats)(struct wlan_objmgr_pdev *pdev,
124 					       void *outdata);
125 	void (*sptrlc_register_wmi_spectral_cmd_ops)(
126 			struct wlan_objmgr_pdev *pdev,
127 			struct wmi_spectral_cmd_ops *cmd_ops);
128 	void (*sptrlc_register_netlink_cb)(
129 		struct wlan_objmgr_pdev *pdev,
130 		struct spectral_nl_cb *nl_cb);
131 	bool (*sptrlc_use_nl_bcast)(struct wlan_objmgr_pdev *pdev);
132 	void (*sptrlc_deregister_netlink_cb)(struct wlan_objmgr_pdev *pdev);
133 };
134 
135 #endif				/* _SPECTRAL_DEFS_I_H_ */
136