1 /*
2  * Copyright (c) 2012-2021 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: This file contains centralized definitions of converged configuration.
22  */
23 
24 #ifndef __CFG_MLME_ACS_H
25 #define __CFG_MLME_ACS_H
26 
27 /*
28  * <ini>
29  * acs_with_more_param- Enable acs calculation with more param.
30  * @Min: 0
31  * @Max: 1
32  * @Default: 1
33  *
34  * This ini is used to enable acs calculation with more param.
35  *
36  * Related: NA
37  *
38  * Supported Feature: ACS
39  *
40  * Usage: External
41  *
42  * </ini>
43  */
44 
45 #define CFG_ACS_WITH_MORE_PARAM CFG_INI_BOOL( \
46 		"acs_with_more_param", \
47 		1, \
48 		"Enable ACS with more param")
49 
50 /*
51  * <ini>
52  * AutoChannelSelectWeight - ACS channel weight
53  * @Min: 0
54  * @Max: 0xFFFFFFFF
55  * @Default: 0x00fafafa
56  *
57  * This ini is used to adjust weight of factors in
58  * acs algorithm.
59  *
60  * Supported Feature: ACS
61  *
62  * Usage: External
63  *
64  * bits 0-3:   rssi weight
65  * bits 4-7:   bss count weight
66  * bits 8-11:  noise floor weight
67  * bits 12-15: channel free weight
68  * bits 16-19: tx power range weight
69  * bits 20-23: tx power throughput weight
70  * bits 24-31: reserved
71  *
72  * </ini>
73  */
74 
75 #define CFG_AUTO_CHANNEL_SELECT_WEIGHT CFG_INI_UINT( \
76 		"AutoChannelSelectWeight", \
77 		0, \
78 		0xFFFFFFFF, \
79 		0x00fafafa, \
80 		CFG_VALUE_OR_DEFAULT, \
81 		"Adjust weight factor in ACS")
82 
83 /*
84  * <ini>
85  * gvendor_acs_support - vendor based channel selection manager
86  * @Min: 0
87  * @Max: 1
88  * @Default: 0
89  *
90  * Enabling this parameter will force driver to use user application based
91  * channel selection algo instead of driver based auto channel selection
92  * logic.
93  *
94  * Supported Feature: ACS
95  *
96  * Usage: External
97  *
98  * </ini>
99  */
100 
101 #define CFG_USER_AUTO_CHANNEL_SELECTION CFG_INI_BOOL( \
102 		"gvendor_acs_support", \
103 		0, \
104 		"Vendor channel selection manager")
105 
106 /*
107  * <ini>
108  * gacs_support_for_dfs_lte_coex - acs support for lte coex and dfs event
109  * @Min: 0
110  * @Max: 1
111  * @Default: 0
112  *
113  * Enabling this parameter will force driver to use user application based
114  * channel selection algo for channel selection in case of dfs and lte
115  * coex event.
116  *
117  * Supported Feature: ACS
118  *
119  * Usage: Internal
120  *
121  * </ini>
122  */
123 
124 #define CFG_USER_ACS_DFS_LTE CFG_INI_BOOL( \
125 		"gacs_support_for_dfs_lte_coex", \
126 		0, \
127 		"Acs support for lte coex and dfs")
128 
129 /*
130  * <ini>
131  * acs_policy - External ACS policy control
132  * @Min: 0
133  * @Max: 1
134  * @Default: 1
135  *
136  * Values are per enum hdd_external_acs_policy.
137  *
138  * This ini is used to control the external ACS policy.
139  *
140  * 0 -Preferable for ACS to select a
141  *    channel with non-zero pcl weight.
142  * 1 -Mandatory for ACS to select a
143  *    channel with non-zero pcl weight.
144  *
145  * Related: None
146  *
147  * Supported Feature: ACS
148  *
149  * Usage: External
150  *
151  * </ini>
152  */
153 
154 #define CFG_EXTERNAL_ACS_POLICY CFG_INI_BOOL( \
155 		"acs_policy", \
156 		1, \
157 		"External ACS Policy Control")
158 
159 #define ACS_WEIGHT_MAX_STR_LEN            500
160 
161 /*
162  * <ini>
163  * normalize_acs_weight - Used to control the ACS channel weightage.
164  *
165  * This ini is used to specify the weight percentage of the channel. Channel
166  * weights can be controlled by user to prioritize or de-prioritize channels.
167  *
168  * Related: ACS
169  *
170  * Supported Feature: ACS
171  *
172  * Usage: External
173  *
174  * </ini>
175  */
176 #define CFG_NORMALIZE_ACS_WEIGHT CFG_INI_STRING( \
177 		"normalize_acs_weight", \
178 		0, \
179 		ACS_WEIGHT_MAX_STR_LEN, \
180 		"2407-5875=40, 5945-7125=90, 5975=100, 6055=100, 6135=100, 6215=100, 6295=100, 6375=100, 6615=100, 6695=100, 6775=100, 6855=100", \
181 		"Used to specify the channel weights")
182 
183 /*
184  * <ini>
185  * force_start_sap- Enable the SAP even if no channel is suitable for SAP
186  * @Min: 0
187  * @Max: 1
188  * @Default: 0
189  *
190  * This ini is used to enable the SAP even if no channel is found suitable
191  * for SAP by ACS.
192  *
193  * Related: NA
194  *
195  * Supported Feature: ACS
196  *
197  * Usage: Internal
198  *
199  * </ini>
200  */
201 #define CFG_ACS_FORCE_START_SAP CFG_INI_BOOL( \
202 		"force_start_sap", \
203 		0, \
204 		"Force start SAP")
205 
206 /*
207  * <ini>
208  * acs_prefer_6ghz_psc - Select 6 GHz PSC channel as priority
209  * @Min: 0
210  * @Max: 1
211  * @Default: 1
212  *
213  * This config is used to configure ACS logic to select PSC channel as
214  * perefered result. "normalize_acs_weight" INI can make the PSC
215  * channel priority higher than NON PSC, but it is for a single channel's
216  * weight, for bw 160 or bw 80 combined channel weight, it has less
217  * help.
218  *
219  * Related: None
220  *
221  * Supported Feature: ACS
222  *
223  * Usage: Internal
224  *
225  * </ini>
226  */
227 #define CFG_ACS_PREFER_6GHZ_PSC CFG_BOOL( \
228 				"acs_prefer_6ghz_psc", \
229 				1, \
230 				"Select 6 GHz PSC channel as priority")
231 
232 /*
233  * <ini>
234  * np_chan_weight - chan weightage for non preferred channels
235  * @Min: 0x00000000
236  * @Max: 0x64646464
237  * @Default: 0x00000000
238  *
239  * This INI give percentage value of weights to be considered in the ACS algo
240  * for the non preferred channels. the distribution of the channel type is:-
241  * Example:- If the percentage of lets say DFS channels is set to 50%, and
242  * the weight comes out to be x, then we would increase the weight of DFS
243  * channels by 50% ( 100 - y% set in INI), so that it gets de-prioritized in
244  * the ACS sorted channel list, the lesser the weight, the better the channel.
245  * So the channel with more weight is less likely to be selected. So by default
246  * the np chan weightage for DFS is set to 0, that is it will be assigned max
247  * weightage, so no probality of getting selected, as for standlaone, DFS is not
248  * recommended (it takes 60 sec/10min to start depending upon channel type).
249  *
250  * Indexes are defined in this way.
251  *     0 Index (BITS 0-7): DFS - Def 1%
252  *     1 Index (BITS 8-15): Reserved
253  *     2 Index (BITS 16-23): Reserved
254  *     3 Index (BITS 24-31): Reserved
255  * These percentage values are stored in HEX. Max can be 0x64
256  * Supported Feature: ACS
257  *
258  * Usage: External
259  *
260  * </ini>
261  */
262 #define CFG_ACS_NP_CHAN_WEIGHT CFG_INI_UINT( \
263 		"np_chan_weight", \
264 		0x00000000, \
265 		0x64646464, \
266 		0x00000001, \
267 		CFG_VALUE_OR_DEFAULT, \
268 		"np chan weight")
269 
270 #define CFG_ACS_ALL \
271 	CFG(CFG_ACS_WITH_MORE_PARAM) \
272 	CFG(CFG_AUTO_CHANNEL_SELECT_WEIGHT) \
273 	CFG(CFG_USER_AUTO_CHANNEL_SELECTION) \
274 	CFG(CFG_USER_ACS_DFS_LTE) \
275 	CFG(CFG_EXTERNAL_ACS_POLICY) \
276 	CFG(CFG_NORMALIZE_ACS_WEIGHT) \
277 	CFG(CFG_ACS_PREFER_6GHZ_PSC) \
278 	CFG(CFG_ACS_FORCE_START_SAP) \
279 	CFG(CFG_ACS_NP_CHAN_WEIGHT)
280 
281 #endif /* __CFG_MLME_ACS_H */
282