1 /*
2  * Copyright (c) 2017-2020 The Linux Foundation. All rights reserved.
3  * Copyright (c) 2022-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: contains scan manager 6 GHz-specific functionality
22  */
23 
24 #ifndef _WLAN_SCAN_MANAGER_6GHZ_API_H_
25 #define _WLAN_SCAN_MANAGER_6GHZ_API_H_
26 
27 #include "wlan_scan_main.h"
28 
29 #ifdef CONFIG_BAND_6GHZ
30 
31 /*
32  * Userspace/framework tracks last few days(e.g: 10 days) history of
33  * connected APs and maintains best 10 channels out of that list by
34  * considering multiple parameters like scoring, location etc.
35  * It's likely to find an AP in one of these channels when a scan issued.
36  * So, framework issues first scan request with a maximum of 10 channels
37  * Any scan request which consist of more than 10 channels can be considered as
38  * full scan
39  */
40 #define FULL_SCAN_CH_COUNT_MIN_BY_USERSPACE 11
41 
42 /*
43  * This can used to set the RNR_ONLY flag to certain type(PSC/non-PSC) or
44  * all channels.
45  */
46 #define SET_RNR_FLAG_TO_PSC_CHANNEL 0x1
47 #define SET_RNR_FLAG_TO_NON_PSC_CHANNEL 0x2
48 #define SET_RNR_FLAG_TO_ALL_6G_CHANNELS 0x3
49 
50 /**
51  * scm_add_channel_flags() - Update 6 GHz channel flags in active/pno scan req
52  * @vdev: vdev
53  * @chan_list: channel list
54  * @num_chan: number channels
55  * @is_colocated_6ghz_scan_enabled: Colocated 6 GHz flag
56  * @is_pno_scan: is pno scan
57  *
58  * Add channel flags for 6 GHz channels from active/pno scan request
59  * based on ini
60  *
61  * Return: None
62  */
63 void
64 scm_add_channel_flags(struct wlan_objmgr_vdev *vdev,
65 		      struct chan_list *chan_list,
66 		      uint8_t *num_chan,
67 		      bool is_colocated_6ghz_scan_enabled,
68 		      bool is_pno_scan);
69 
70 /**
71  * scm_update_6ghz_channel_list() - Update 6 GHz channel list in the scan req
72  * @req: scan start request
73  * @scan_obj: scan component object
74  *
75  * Filter out the unsupported 6 GHz channels from scan request and add supported
76  * 6 GHz channels based on the ini.
77  *
78  * Return: None
79  */
80 void
81 scm_update_6ghz_channel_list(struct scan_start_request *req,
82 			     struct wlan_scan_obj *scan_obj);
83 
84 /**
85  * scm_is_6ghz_scan_optimization_supported() - Check firmware capability
86  * @psoc: psoc
87  *
88  * Check if firmware supports 6 GHz scan optimization from fw_ext_caps of psoc.
89  *
90  * Return: None
91  */
92 bool
93 scm_is_6ghz_scan_optimization_supported(struct wlan_objmgr_psoc *psoc);
94 
95 /**
96  * scm_add_all_valid_6g_channels() - Add all valid 6 GHz channels to scan
97  *                                   request
98  * @pdev: pdev on which scan request is issued
99  * @chan_list: Scan channel list
100  * @num_scan_ch: Total number of scan channels
101  * @is_colocated_6ghz_scan_enabled: colocated 6 GHz scan flag enabled in
102  *                                  scan request
103  *
104  * If @is_colocated_6ghz_scan_enabled is true or if at least one 6 GHz
105  * channel is present in the host scan request, then this API fills
106  * all remaining (other than channel(s) present in host scan req)
107  * valid 6 GHz channel(s) to scan requests channel list and set the
108  * flag FLAG_SCAN_ONLY_IF_RNR_FOUND for each of those added channels.
109  * By this driver allows Firmware to scan 6 GHz channels based on RNR
110  * IEs only.
111  *
112  * Return: None
113  */
114 void scm_add_all_valid_6g_channels(struct wlan_objmgr_pdev *pdev,
115 				   struct chan_list *chan_list,
116 				   uint8_t *num_scan_ch,
117 				   bool is_colocated_6ghz_scan_enabled);
118 
119 #else
120 static inline void
scm_add_channel_flags(struct wlan_objmgr_vdev * vdev,struct chan_list * pno_chan_list,uint8_t * num_chan,bool is_colocated_6ghz,bool is_pno_scan)121 scm_add_channel_flags(struct wlan_objmgr_vdev *vdev,
122 		      struct chan_list *pno_chan_list,
123 		      uint8_t *num_chan,
124 		      bool is_colocated_6ghz,
125 		      bool is_pno_scan)
126 {
127 }
128 
129 static inline void
scm_update_6ghz_channel_list(struct scan_start_request * req,struct wlan_scan_obj * scan_obj)130 scm_update_6ghz_channel_list(struct scan_start_request *req,
131 			     struct wlan_scan_obj *scan_obj)
132 {
133 }
134 
135 static inline bool
scm_is_6ghz_scan_optimization_supported(struct wlan_objmgr_psoc * psoc)136 scm_is_6ghz_scan_optimization_supported(struct wlan_objmgr_psoc *psoc)
137 {
138 	return false;
139 }
140 
141 static inline
scm_add_all_valid_6g_channels(struct wlan_objmgr_pdev * pdev,struct chan_list * chan_list,uint8_t * num_scan_ch,bool is_colocated_6ghz)142 void scm_add_all_valid_6g_channels(struct wlan_objmgr_pdev *pdev,
143 				   struct chan_list *chan_list,
144 				   uint8_t *num_scan_ch,
145 				   bool is_colocated_6ghz)
146 {
147 }
148 #endif
149 
150 #endif
151