xref: /wlan-dirver/qca-wifi-host-cmn/umac/regulatory/core/src/reg_opclass.h (revision bea437e2293c3d4fb1b5704fcf633aedac996962)
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 #ifdef CONFIG_CHAN_FREQ_API
93 
94 /**
95  * reg_freq_width_to_chan_op_class() - convert frequency to oper class,
96  *                                     channel
97  * @pdev: pdev pointer
98  * @freq: channel frequency in mhz
99  * @chan_width: channel width
100  * @global_tbl_lookup: whether to lookup global op class tbl
101  * @behav_limit: behavior limit
102  * @op_class: operating class
103  * @chan_num: channel number
104  *
105  * Return: Void.
106  */
107 void reg_freq_width_to_chan_op_class(struct wlan_objmgr_pdev *pdev,
108 				     qdf_freq_t freq,
109 				     uint16_t chan_width,
110 				     bool global_tbl_lookup,
111 				     uint16_t behav_limit,
112 				     uint8_t *op_class,
113 				     uint8_t *chan_num);
114 
115 /**
116  * reg_freq_to_chan_op_class() - convert frequency to oper class,
117  *                                   channel
118  * @pdev: pdev pointer
119  * @freq: channel frequency in mhz
120  * @global_tbl_lookup: whether to lookup global op class tbl
121  * @behav_limit: behavior limit
122  * @op_class: operating class
123  * @chan_num: channel number
124  *
125  * Return: Void.
126  */
127 void reg_freq_to_chan_op_class(struct wlan_objmgr_pdev *pdev,
128 			       qdf_freq_t freq,
129 			       bool global_tbl_lookup,
130 			       uint16_t behav_limit,
131 			       uint8_t *op_class,
132 			       uint8_t *chan_num);
133 #endif
134 
135 /**
136  * reg_get_op_class_width() - get oper class width
137  *
138  * @pdev: pdev pointer
139  * @global_tbl_lookup: whether to lookup global op class tbl
140  * @op_class: operating class
141  * Return: uint16
142  */
143 uint16_t reg_get_op_class_width(struct wlan_objmgr_pdev *pdev,
144 				uint8_t op_class,
145 				bool global_tbl_lookup);
146 
147 /**
148  * reg_chan_opclass_to_freq() - Convert channel number and opclass to frequency
149  * @chan: IEEE Channel Number.
150  * @op_class: Opclass.
151  * @global_tbl_lookup: Global table lookup.
152  *
153  * Return: Channel center frequency else return 0.
154  */
155 uint16_t reg_chan_opclass_to_freq(uint8_t chan,
156 				  uint8_t op_class,
157 				  bool global_tbl_lookup);
158 #else
159 
160 static inline uint16_t reg_dmn_get_chanwidth_from_opclass(
161 		uint8_t *country, uint8_t channel, uint8_t opclass)
162 {
163 	return 0;
164 }
165 
166 static inline uint16_t reg_dmn_set_curr_opclasses(
167 		uint8_t num_classes, uint8_t *class)
168 {
169 	return 0;
170 }
171 
172 static inline uint16_t reg_dmn_get_curr_opclasses(
173 		uint8_t *num_classes, uint8_t *class)
174 {
175 	return 0;
176 }
177 
178 static inline uint16_t reg_dmn_get_opclass_from_channel(
179 		uint8_t *country, uint8_t channel, uint8_t offset)
180 {
181 	return 0;
182 }
183 
184 static inline
185 uint8_t reg_dmn_get_opclass_from_freq_width(uint8_t *country,
186 					    qdf_freq_t freq,
187 					    uint8_t ch_width,
188 					    uint16_t behav_limit)
189 {
190 	return 0;
191 }
192 
193 static inline void reg_dmn_print_channels_in_opclass(uint8_t *country,
194 						     uint8_t op_class)
195 {
196 }
197 
198 #ifdef CONFIG_CHAN_FREQ_API
199 
200 static inline void
201 reg_freq_width_to_chan_op_class(struct wlan_objmgr_pdev *pdev,
202 				qdf_freq_t freq,
203 				uint16_t chan_width,
204 				bool global_tbl_lookup,
205 				uint16_t behav_limit,
206 				uint8_t *op_class,
207 				uint8_t *chan_num)
208 {
209 }
210 
211 static inline void
212 reg_freq_to_chan_op_class(struct wlan_objmgr_pdev *pdev,
213 			  qdf_freq_t freq,
214 			  bool global_tbl_lookup,
215 			  uint16_t behav_limit,
216 			  uint8_t *op_class,
217 			  uint8_t *chan_num)
218 {
219 }
220 
221 #endif
222 
223 static inline uint16_t reg_get_op_class_width(struct wlan_objmgr_pdev *pdev,
224 					      uint8_t op_class,
225 					      bool global_tbl_lookup)
226 {
227 	return 0;
228 }
229 
230 static inline uint16_t
231 reg_chan_opclass_to_freq(uint8_t chan,
232 			 uint8_t op_class,
233 			 bool global_tbl_lookup)
234 {
235 	return 0;
236 }
237 
238 #endif
239 #endif
240