xref: /wlan-dirver/qca-wifi-host-cmn/umac/cmn_services/regulatory/inc/wlan_reg_afc.h (revision 901120c066e139c7f8a2c8e4820561fdd83c67ef)
1 /*
2  * Copyright (c) 2021, The Linux Foundation. All rights reserved.
3  * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
4  *
5  * Permission to use, copy, modify, and/or distribute this software for any
6  * purpose with or without fee is hereby granted, provided that the above
7  * copyright notice and this permission notice appear in all copies.
8  *
9  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16  */
17 
18 /**
19  * DOC: Define the data structure for AFC implementation
20  */
21 
22 #ifndef __WLAN_REG_AFC_H
23 #define __WLAN_REG_AFC_H
24 
25 /* All the structures in this header will be packed and will follow network
26  * byte order
27  */
28 
29 /**
30  * struct wlan_afc_host_req_fixed_params - Structure to send the list of AFC
31  *                                          requests to AFC app to query the
32  *                                          AFC server.
33  *
34  * @req_id:        Unique request ID from FW to be used as AFC request ID
35  *                 to server.
36  * @version_minor  Lower 16 bits for the AFC request version.
37  * @version_major  Higher 16 bits for the AFC request version.
38  * @req_length:    Length of entire AFC request message.
39  * @min_des_power: Minimum desired power(in dbm) for queried spectrum.
40  */
41 struct wlan_afc_host_req_fixed_params {
42 	uint64_t req_id;
43 	uint16_t version_minor;
44 	uint16_t version_major;
45 	uint16_t req_length;
46 	int16_t  min_des_power;
47 } qdf_packed;
48 
49 /**
50  * struct wlan_afc_freq_range_obj - Structure for frequency range query.
51  *
52  * @lowfreq:  Lower limit(in MHz) for frequency range query.
53  * @highfreq: Higher limit(in MHz) for frequency range query.
54  */
55 struct wlan_afc_freq_range_obj {
56 	uint16_t lowfreq;
57 	uint16_t highfreq;
58 } qdf_packed;
59 
60 /**
61  * struct wlan_afc_frange_list - Structure to send freq range list to AFC app.
62  *
63  * @num_ranges: Number of queried frequency ranges.
64  * @range_objs: List of queried frequency ranges.
65  */
66 struct wlan_afc_frange_list {
67 	uint32_t num_ranges;
68 	struct wlan_afc_freq_range_obj range_objs[0];
69 } qdf_packed;
70 
71 /**
72  * struct wlan_afc_opclass_obj - Structure for opclass/channel query.
73  *
74  * @opclass_num_cfis: Number of channels to be required for given opclass.
75  * @opclass:          Operating class to be queried.
76  * @cfis:             List of Channels to be queried for given Global opclass.
77  */
78 struct wlan_afc_opclass_obj {
79 	uint8_t opclass_num_cfis;
80 	uint8_t opclass;
81 	uint8_t cfis[0];
82 } qdf_packed;
83 
84 /**
85  * struct wlan_afc_num_opclasses - Structure for opclass list
86  *
87  * @num_opclasses: Number of opclass to be queried.
88  */
89 struct wlan_afc_num_opclasses {
90 	uint8_t num_opclasses;
91 } qdf_packed;
92 
93 /**
94  * The following is the layout of the AFC host request
95  * It is not a C structure as some of the structures are not of fixed size.
96  *
97  * struct wlan_afc_host_partial_request {
98  *      <fixed-size>    struct wlan_afc_host_req_fixed_params fixed_parms;
99  *      <variable-size> struct wlan_afc_freq_list freq_lst;
100  *      <fixed-size>    struct wlan_afc_num_opclasses opclss_list_size;
101  *      <variable-size> struct wlan_afc_opclass_obj obj[0];
102  *      <variable-size> struct wlan_afc_opclass_obj obj[1];
103  *      ....
104  *      <variable-size> struct wlan_afc_opclass_obj obj[opclass_list_size-1];
105  *      <fixed-size>    struct wlan_afc_location afc_location;
106  * };
107  *
108  * struct wlan_afc_host_partial_request - Structure to send AFC request info
109  *
110  * @fixed_params: AFC request fixed params (req_id, length, min_des_power)
111  */
112 struct wlan_afc_host_partial_request {
113 	struct wlan_afc_host_req_fixed_params fixed_params;
114 	/* Other structures to follow. See the layout in the comment above */
115 } qdf_packed;
116 
117 /**
118  * enum reg_afc_dev_deploy_type - Deployment type of AP
119  *
120  * @AFC_DEPLOYMENT_UNKNOWN: Unknown
121  * @AFC_DEPLOYMENT_INDOOR: Located Indoor
122  * @AFC_DEPLOYMENT_OUTDOOR: Located Outdoor
123  */
124 enum reg_afc_dev_deploy_type {
125 	AFC_DEPLOYMENT_UNKNOWN = 0,
126 	AFC_DEPLOYMENT_INDOOR  = 1,
127 	AFC_DEPLOYMENT_OUTDOOR = 2,
128 };
129 
130 /**
131  * enum afc_object_type - AFC Request object types
132  *
133  * @AFC_OBJ_LOCATION: Location object
134  */
135 enum afc_object_type {
136 	AFC_OBJ_LOCATION = 1
137 };
138 
139 /**
140  * struct wlan_afc_location - Structure for afc location info.
141  *
142  * @afc_elem_type: AFC element type of enum afc_object_type
143  * @afc_elem_len: AFC element length
144  * @deployment_type: Deployment type of enum reg_afc_dev_deploy_type
145  */
146 struct wlan_afc_location {
147 	uint32_t afc_elem_type;
148 	uint32_t afc_elem_len;
149 	uint32_t deployment_type;
150 } qdf_packed;
151 
152 /**
153  * The following is the layout of the AFC response.
154  *
155  * struct wlan_afc_host_resp {
156  *     header;
157  *     status;
158  *     time_to_live;
159  *     length;
160  *     resp_format;
161  *     afc_resp {
162  *          struct wlan_afc_bin_resp_data fixed_params;
163  *          struct wlan_afc_resp_freq_psd_info obj[0];
164  *          ....
165  *          struct wlan_afc_resp_freq_psd_info obj[num_frequency_obj - 1];
166  *          struct wlan_afc_resp_opclass_info opclass[0];
167  *          {
168  *              struct wlan_afc_resp_eirp_info eirp[0];
169  *              ....
170  *              struct wlan_afc_resp_eirp_info eirp[num_channels - 1];
171  *          }
172  *          .
173  *          .
174  *          struct wlan_afc_resp_opclass_info opclass[num_channel_obj - 1];
175  *          {
176  *              struct wlan_afc_resp_eirp_info eirp[0];
177  *              ....
178  *              struct wlan_afc_resp_eirp_info eirp[num_channels - 1];
179  *          }
180  *     }
181  * }
182  *
183  * struct wlan_afc_host_resp - Structure for AFC Host response to FW
184  *
185  * @header:       Header for compatibility.
186  *                Valid value: 0
187  * @status:       Flag to indicate validity of data. To be updated by TZ
188  *                1:  Success
189  *                -1: Failure
190  * @time_to_live: Period(in seconds) the data is valid for
191  * @length:       Length of the response message
192  * @resp_format:  AFC response format.
193  *                0: JSON format
194  *                1: Binary data format
195  * @afc_resp:     Response message from the AFC server for queried parameters
196  */
197 struct wlan_afc_host_resp {
198 	uint32_t header;
199 	int32_t  status;
200 	uint32_t time_to_live;
201 	uint32_t length;
202 	uint32_t resp_format;
203 	uint8_t  afc_resp[0];
204 } qdf_packed;
205 
206 /**
207  * struct wlan_afc_resp_opclass_info - Structure to populate operating class
208  *                                     and channel information from AFC
209  *                                     response.
210  *
211  * @opclass:        Operating class
212  * @num_channels:   Number of channels received in AFC response
213  */
214 struct wlan_afc_resp_opclass_info {
215 	uint32_t opclass;
216 	uint32_t num_channels;
217 } qdf_packed;
218 
219 /**
220  * struct wlan_afc_eirp_info - Structure to update EIRP values for channels
221  *
222  * @channel_cfi:  Channel center frequency index
223  * @max_eirp_pwr: Maximum permissible EIRP(in dBm) for the Channel
224  */
225 struct wlan_afc_resp_eirp_info {
226 	uint32_t channel_cfi;
227 	uint32_t max_eirp_pwr;
228 } qdf_packed;
229 
230 /**
231  * struct wlan_afc_freq_info - Structure to update PSD values for queried
232  *                             frequency ranges
233  *
234  * @freq_info: Frequency range in MHz:- bits 15:0  = u16 start_freq,
235  *                                      bits 31:16 = u16 end_freq
236  * @max_psd:   Maximum PSD in dbm/MHz
237  */
238 struct wlan_afc_resp_freq_psd_info {
239 	uint32_t freq_info;
240 	uint32_t max_psd;
241 } qdf_packed;
242 
243 /**
244  * struct wlan_afc_bin_resp_data - Structure to populate AFC binary response
245  *
246  * @local_err_code:     Internal error code between AFC app and FW
247  *                      0 - Success
248  *                      1 - General failure
249  * @version:            Internal version between AFC app and FW
250  *                      Current version: 1
251  * @afc_wfa_version:    AFC spec version info. Bits 15:0  - Minor version
252  *                                             Bits 31:16 - Major version
253  * @request_id:         AFC unique request ID
254  * @avail_exp_time_d:   Availability expiry date in UTC.
255  *                      Date format: bits 7:0   - DD (Day 1-31)
256  *                                   bits 15:8  - MM (Month 1-12)
257  *                                   bits 31:16 - YYYY (Year)
258  * @avail_exp_time_t:   Availability expiry time in UTC.
259  *                      Time format: bits 7:0   - SS (Seconds 0-59)
260  *                                   bits 15:8  - MM (Minutes 0-59)
261  *                                   bits 23:16 - HH (Hours 0-23)
262  *                                   bits 31:24 - Reserved
263  * @afc_serv_resp_code: AFC server response code. The AFC server response codes
264  *                      are defined in the WiFi Spec doc for AFC as follows:
265  *                      0: Success.
266  *                      100 - 199: General errors related to protocol.
267  *                      300 - 399: Error events specific to message exchange
268  *                                 for the available Spectrum Inquiry.
269  * @num_frequency_obj:  Number of frequency objects
270  * @num_channel_obj:    Number of channel objects
271  * @shortdesc:          Short description corresponding to resp_code field
272  */
273 struct wlan_afc_bin_resp_data {
274 	uint32_t local_err_code;
275 	uint32_t version;
276 	uint32_t afc_wfa_version;
277 	uint32_t request_id;
278 	uint32_t avail_exp_time_d;
279 	uint32_t avail_exp_time_t;
280 	uint32_t afc_serv_resp_code;
281 	uint32_t num_frequency_obj;
282 	uint32_t num_channel_obj;
283 	uint8_t  shortdesc[64];
284 	uint32_t reserved[2];
285 } qdf_packed;
286 #endif
287