1  /*
2   * Copyright (c) 2017, 2019-2021 The Linux Foundation. All rights reserved.
3   * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved.
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  /**
21   * DOC: declares driver functions interfacing with linux kernel
22   */
23  
24  #ifndef _WLAN_CFG80211_SPECTRAL_H_
25  #define _WLAN_CFG80211_SPECTRAL_H_
26  
27  #include <linux/version.h>
28  #include <linux/netdevice.h>
29  #include <net/cfg80211.h>
30  #include <qca_vendor.h>
31  #include <qdf_list.h>
32  #include <qdf_types.h>
33  #include <spectral_ioctl.h>
34  #include <wlan_spectral_public_structs.h>
35  
36  extern const struct nla_policy
37  	spectral_scan_policy
38  	[QCA_WLAN_VENDOR_ATTR_SPECTRAL_SCAN_CONFIG_MAX + 1];
39  
40  extern const struct nla_policy
41  	spectral_scan_get_status_policy
42  	[QCA_WLAN_VENDOR_ATTR_SPECTRAL_SCAN_STATUS_MAX + 1];
43  
44  #define CONFIG_REQUESTED(type)    ((type == \
45  	QCA_WLAN_VENDOR_ATTR_SPECTRAL_SCAN_REQUEST_TYPE_SCAN_AND_CONFIG) || \
46  	(type == QCA_WLAN_VENDOR_ATTR_SPECTRAL_SCAN_REQUEST_TYPE_CONFIG))
47  
48  #define SCAN_REQUESTED(type)    ((type == \
49  	QCA_WLAN_VENDOR_ATTR_SPECTRAL_SCAN_REQUEST_TYPE_SCAN_AND_CONFIG) || \
50  	(type == QCA_WLAN_VENDOR_ATTR_SPECTRAL_SCAN_REQUEST_TYPE_SCAN))
51  
52  /**
53   * wlan_spectral_get_nl80211_chwidth() - Get nl80211_chan_width value for
54   * channel width from enum phy_ch_width
55   * @phy_chwidth: enum phy_ch_width channel width value
56   *
57   * Return: channel width converted to nl80211_chan_width
58   */
59  int
60  wlan_spectral_get_nl80211_chwidth(uint8_t phy_chwidth);
61  
62  /**
63   * wlan_spectral_get_phy_ch_width() - Convert channel width from
64   * nl80211_chan_width to enum phy_ch_width
65   * @nl_chwidth: nl80211 channel width value
66   *
67   * Return: channel width converted to phy_ch_width
68   */
69  uint8_t
70  wlan_spectral_get_phy_ch_width(uint8_t nl_chwidth);
71  
72  /**
73   * wlan_cfg80211_register_spectral_cmd_handler() - Registration api for spectral
74   * @pdev:    Pointer to pdev
75   * @handlers: Pointer to handlers
76   *
77   * Return: 0 on success, negative value on failure
78   */
79  void wlan_cfg80211_register_spectral_cmd_handler(
80  			struct wlan_objmgr_pdev *pdev,
81  			struct spectral_cfg80211_vendor_cmd_handlers *handlers);
82  
83  /**
84   * wlan_cfg80211_spectral_scan_config_and_start() - Start spectral scan
85   * @wiphy:    Pointer to wiphy
86   * @pdev:     Pointer to pdev
87   * @vdev:     Pointer to vdev
88   * @data:     Reference to data
89   * @data_len: Length of @data
90   *
91   * Return: 0 on success, negative value on failure
92   */
93  int wlan_cfg80211_spectral_scan_config_and_start(struct wiphy *wiphy,
94  						 struct wlan_objmgr_pdev *pdev,
95  						 struct wlan_objmgr_vdev *vdev,
96  						 const void *data,
97  						 int data_len);
98  
99  /**
100   * wlan_cfg80211_spectral_scan_stop() - Stop spectral scan
101   * @wiphy:    Pointer to wiphy
102   * @pdev:     Pointer to pdev
103   * @vdev:     Pointer to vdev
104   * @data:     Reference to data
105   * @data_len: Length of @data
106   *
107   * Return: 0 on success, negative value on failure
108   */
109  int wlan_cfg80211_spectral_scan_stop(struct wiphy *wiphy,
110  				     struct wlan_objmgr_pdev *pdev,
111  				     struct wlan_objmgr_vdev *vdev,
112  				     const void *data,
113  				     int data_len);
114  
115  /**
116   * wlan_cfg80211_spectral_scan_get_config() - Get spectral scan config
117   * @wiphy:    Pointer to wiphy
118   * @pdev:     Pointer to pdev
119   * @vdev:     Pointer to vdev
120   * @data:     Reference to data
121   * @data_len: Length of @data
122   *
123   * Return: 0 on success, negative value on failure
124   */
125  int wlan_cfg80211_spectral_scan_get_config(struct wiphy *wiphy,
126  					   struct wlan_objmgr_pdev *pdev,
127  					   struct wlan_objmgr_vdev *vdev,
128  					   const void *data,
129  					   int data_len);
130  
131  /**
132   * wlan_cfg80211_spectral_scan_get_cap() - Get spectral system capabilities
133   * @wiphy:    Pointer to wiphy
134   * @pdev:     Pointer to pdev
135   * @vdev:     Pointer to vdev
136   * @data:     Reference to data
137   * @data_len: Length of @data
138   *
139   * Return: 0 on success, negative value on failure
140   */
141  int wlan_cfg80211_spectral_scan_get_cap(struct wiphy *wiphy,
142  					struct wlan_objmgr_pdev *pdev,
143  					struct wlan_objmgr_vdev *vdev,
144  					const void *data,
145  					int data_len);
146  
147  /**
148   * wlan_cfg80211_spectral_scan_get_diag_stats() - Get spectral diag stats
149   * @wiphy:    Pointer to wiphy
150   * @pdev:     Pointer to pdev
151   * @vdev:     Pointer to vdev
152   * @data:     Reference to data
153   * @data_len: Length of @data
154   *
155   * Return: 0 on success, negative value on failure
156   */
157  int wlan_cfg80211_spectral_scan_get_diag_stats(struct wiphy *wiphy,
158  					       struct wlan_objmgr_pdev *pdev,
159  					       struct wlan_objmgr_vdev *vdev,
160  					       const void *data,
161  					       int data_len);
162  
163  /**
164   * wlan_cfg80211_spectral_scan_get_status() - Get spectral scan status
165   * @wiphy:    Pointer to wiphy
166   * @pdev:     Pointer to pdev
167   * @vdev:     Pointer to vdev
168   * @data:     Reference to data
169   * @data_len: Length of @data
170   *
171   * Return: 0 on success, negative value on failure
172   */
173  int wlan_cfg80211_spectral_scan_get_status(struct wiphy *wiphy,
174  					   struct wlan_objmgr_pdev *pdev,
175  					   struct wlan_objmgr_vdev *vdev,
176  					   const void *data,
177  					   int data_len);
178  
179  /**
180   * wlan_cfg80211_spectral_scan_dma_debug_config() - configure DMA debug
181   * @pdev:       Pointer to pdev
182   * @vdev:       Pointer to vdev
183   * @tb:         Pointer to Spectral Scan config attribute
184   * @sscan_mode: Spectral scan mode
185   *
186   * Return QDF_STATUS_SUCCESS on success, QDF_STATUS_E_FAILURE on failure
187   */
188  QDF_STATUS wlan_cfg80211_spectral_scan_dma_debug_config(
189  		struct wlan_objmgr_pdev *pdev,
190  		struct wlan_objmgr_vdev *vdev,
191  		struct nlattr **tb,
192  		enum spectral_scan_mode sscan_mode);
193  #endif
194