xref: /wlan-dirver/qca-wifi-host-cmn/umac/regulatory/core/src/reg_opclass.h (revision f28396d060cff5c6519f883cb28ae0116ce479f1)
1 /*
2  * Copyright (c) 2017-2019 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 /**
21  * DOC: reg_opclass.h
22  * This file provides prototypes of the regulatory opclass functions
23  */
24 
25 #ifndef __REG_OPCLASS_H__
26 #define __REG_OPCLASS_H__
27 
28 #ifdef HOST_OPCLASS
29 /**
30  * reg_dmn_get_chanwidth_from_opclass() - Get channel width from opclass.
31  * @country: Country code
32  * @channel: Channel number
33  * @opclass: Operating class
34  *
35  * Return: Channel width
36  */
37 uint16_t reg_dmn_get_chanwidth_from_opclass(uint8_t *country, uint8_t channel,
38 					    uint8_t opclass);
39 
40 /**
41  * reg_dmn_get_opclass_from_channel() - Get operating class from channel.
42  * @country: Country code.
43  * @channel: Channel number.
44  * @offset: Operating class offset.
45  *
46  * Return: Error code.
47  */
48 uint16_t reg_dmn_get_opclass_from_channel(uint8_t *country, uint8_t channel,
49 					  uint8_t offset);
50 
51 /**
52  * reg_dmn_get_opclass_from_freq_width() - Get operating class from frequency
53  * @country: Country code.
54  * @freq: Channel center frequency.
55  * @ch_width: Channel width.
56  * @behav_limit: Behaviour limit.
57  *
58  * Return: Error code.
59  */
60 uint8_t reg_dmn_get_opclass_from_freq_width(uint8_t *country,
61 					    qdf_freq_t freq,
62 					    uint8_t ch_width,
63 					    uint16_t behav_limit);
64 
65 /**
66  * reg_dmn_get_opclass_from_channe() - Print channels in op class.
67  * @country: Country code.
68  * @opclass: opclass.
69  *
70  * Return: Void.
71  */
72 void reg_dmn_print_channels_in_opclass(uint8_t *country, uint8_t op_class);
73 
74 /**
75  * reg_dmn_set_curr_opclasses() - Set current operating class
76  * @num_classes: Number of classes
77  * @class: Pointer to operating class.
78  *
79  * Return: Error code.
80  */
81 uint16_t reg_dmn_set_curr_opclasses(uint8_t num_classes, uint8_t *class);
82 
83 /**
84  * reg_dmn_get_curr_opclasses() - Get current supported operating classes.
85  * @num_classes: Number of classes.
86  * @class: Pointer to operating class.
87  *
88  * Return: Error code.
89  */
90 uint16_t reg_dmn_get_curr_opclasses(uint8_t *num_classes, uint8_t *class);
91 
92 /**
93  * reg_get_opclass_details() - Get details about the current opclass table.
94  * @pdev: Pointer to pdev.
95  * @reg_ap_cap: Pointer to reg_ap_cap.
96  * @n_opclasses: Pointer to number of opclasses.
97  * @max_supp_op_class: Maximum number of operating classes supported.
98  * @global_tbl_lookup: Whether to lookup global op class table.
99  *
100  * Return: QDF_STATUS_SUCCESS if success, else return QDF_STATUS_FAILURE.
101  */
102 QDF_STATUS reg_get_opclass_details(struct wlan_objmgr_pdev *pdev,
103 				   struct regdmn_ap_cap_opclass_t *reg_ap_cap,
104 				   uint8_t *n_opclasses,
105 				   uint8_t max_supp_op_class,
106 				   bool global_tbl_lookup);
107 #ifdef CONFIG_CHAN_FREQ_API
108 
109 /**
110  * reg_freq_width_to_chan_op_class() - convert frequency to oper class,
111  *                                     channel
112  * @pdev: pdev pointer
113  * @freq: channel frequency in mhz
114  * @chan_width: channel width
115  * @global_tbl_lookup: whether to lookup global op class tbl
116  * @behav_limit: behavior limit
117  * @op_class: operating class
118  * @chan_num: channel number
119  *
120  * Return: Void.
121  */
122 void reg_freq_width_to_chan_op_class(struct wlan_objmgr_pdev *pdev,
123 				     qdf_freq_t freq,
124 				     uint16_t chan_width,
125 				     bool global_tbl_lookup,
126 				     uint16_t behav_limit,
127 				     uint8_t *op_class,
128 				     uint8_t *chan_num);
129 
130 /**
131  * reg_freq_to_chan_op_class() - convert frequency to oper class,
132  *                                   channel
133  * @pdev: pdev pointer
134  * @freq: channel frequency in mhz
135  * @global_tbl_lookup: whether to lookup global op class tbl
136  * @behav_limit: behavior limit
137  * @op_class: operating class
138  * @chan_num: channel number
139  *
140  * Return: Void.
141  */
142 void reg_freq_to_chan_op_class(struct wlan_objmgr_pdev *pdev,
143 			       qdf_freq_t freq,
144 			       bool global_tbl_lookup,
145 			       uint16_t behav_limit,
146 			       uint8_t *op_class,
147 			       uint8_t *chan_num);
148 #endif
149 
150 /**
151  * reg_get_op_class_width() - get oper class width
152  *
153  * @pdev: pdev pointer
154  * @global_tbl_lookup: whether to lookup global op class tbl
155  * @op_class: operating class
156  * Return: uint16
157  */
158 uint16_t reg_get_op_class_width(struct wlan_objmgr_pdev *pdev,
159 				uint8_t op_class,
160 				bool global_tbl_lookup);
161 
162 /**
163  * reg_chan_opclass_to_freq() - Convert channel number and opclass to frequency
164  * @chan: IEEE Channel Number.
165  * @op_class: Opclass.
166  * @global_tbl_lookup: Global table lookup.
167  *
168  * Return: Channel center frequency else return 0.
169  */
170 uint16_t reg_chan_opclass_to_freq(uint8_t chan,
171 				  uint8_t op_class,
172 				  bool global_tbl_lookup);
173 #else
174 
175 static inline uint16_t reg_dmn_get_chanwidth_from_opclass(
176 		uint8_t *country, uint8_t channel, uint8_t opclass)
177 {
178 	return 0;
179 }
180 
181 static inline uint16_t reg_dmn_set_curr_opclasses(
182 		uint8_t num_classes, uint8_t *class)
183 {
184 	return 0;
185 }
186 
187 static inline uint16_t reg_dmn_get_curr_opclasses(
188 		uint8_t *num_classes, uint8_t *class)
189 {
190 	return 0;
191 }
192 
193 static inline uint16_t reg_dmn_get_opclass_from_channel(
194 		uint8_t *country, uint8_t channel, uint8_t offset)
195 {
196 	return 0;
197 }
198 
199 static inline
200 uint8_t reg_dmn_get_opclass_from_freq_width(uint8_t *country,
201 					    qdf_freq_t freq,
202 					    uint8_t ch_width,
203 					    uint16_t behav_limit)
204 {
205 	return 0;
206 }
207 
208 static inline void reg_dmn_print_channels_in_opclass(uint8_t *country,
209 						     uint8_t op_class)
210 {
211 }
212 
213 static inline
214 QDF_STATUS reg_get_opclass_details(struct wlan_objmgr_pdev *pdev,
215 				   struct regdmn_ap_cap_opclass_t *reg_ap_cap,
216 				   uint8_t *n_opclasses,
217 				   uint8_t max_supp_op_class,
218 				   bool global_tbl_lookup)
219 {
220 	return QDF_STATUS_E_FAILURE;
221 }
222 
223 #ifdef CONFIG_CHAN_FREQ_API
224 
225 static inline void
226 reg_freq_width_to_chan_op_class(struct wlan_objmgr_pdev *pdev,
227 				qdf_freq_t freq,
228 				uint16_t chan_width,
229 				bool global_tbl_lookup,
230 				uint16_t behav_limit,
231 				uint8_t *op_class,
232 				uint8_t *chan_num)
233 {
234 }
235 
236 static inline void
237 reg_freq_to_chan_op_class(struct wlan_objmgr_pdev *pdev,
238 			  qdf_freq_t freq,
239 			  bool global_tbl_lookup,
240 			  uint16_t behav_limit,
241 			  uint8_t *op_class,
242 			  uint8_t *chan_num)
243 {
244 }
245 
246 #endif
247 
248 static inline uint16_t reg_get_op_class_width(struct wlan_objmgr_pdev *pdev,
249 					      uint8_t op_class,
250 					      bool global_tbl_lookup)
251 {
252 	return 0;
253 }
254 
255 static inline uint16_t
256 reg_chan_opclass_to_freq(uint8_t chan,
257 			 uint8_t op_class,
258 			 bool global_tbl_lookup)
259 {
260 	return 0;
261 }
262 
263 #endif
264 #endif
265