xref: /wlan-dirver/qca-wifi-host-cmn/umac/cmn_services/regulatory/inc/wlan_reg_afc.h (revision 8cfe6b10058a04cafb17eed051f2ddf11bee8931)
1 /*
2  * Copyright (c) 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 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  * struct wlan_afc_host_partial_request - Structure to send AFC request info
95  *
96  * @fixed_params: AFC request fixed params (req_id, length, min_des_power)
97  *
98  * The following is the layout of the AFC host request
99  * It is not a C structure as some of the structures are not of fixed size.
100  *
101  * struct wlan_afc_host_partial_request {
102  *      <fixed-size>    struct wlan_afc_host_req_fixed_params fixed_parms;
103  *      <variable-size> struct wlan_afc_freq_list freq_lst;
104  *      <fixed-size>    struct wlan_afc_num_opclasses opclss_list_size;
105  *      <variable-size> struct wlan_afc_opclass_obj obj[0];
106  *      <variable-size> struct wlan_afc_opclass_obj obj[1];
107  *      ....
108  *      <variable-size> struct wlan_afc_opclass_obj obj[opclass_list_size-1];
109  *      <fixed-size>    struct wlan_afc_location afc_location;
110  * };
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  * struct wlan_afc_host_resp - Structure for AFC Host response to FW
154  *
155  * @header:       Header for compatibility.
156  *                Valid value: 0
157  * @status:       Flag to indicate validity of data. To be updated by TZ
158  *                1:  Success
159  *                -1: Failure
160  * @time_to_live: Period(in seconds) the data is valid for
161  * @length:       Length of the response message
162  * @resp_format:  AFC response format.
163  *                0: JSON format
164  *                1: Binary data format
165  * @afc_resp:     Response message from the AFC server for queried parameters
166  *
167  * The following is the layout of the AFC response.
168  *
169  * struct wlan_afc_host_resp {
170  *     header;
171  *     status;
172  *     time_to_live;
173  *     length;
174  *     resp_format;
175  *     afc_resp {
176  *          struct wlan_afc_bin_resp_data fixed_params;
177  *          struct wlan_afc_resp_freq_psd_info obj[0];
178  *          ....
179  *          struct wlan_afc_resp_freq_psd_info obj[num_frequency_obj - 1];
180  *          struct wlan_afc_resp_opclass_info opclass[0];
181  *          {
182  *              struct wlan_afc_resp_eirp_info eirp[0];
183  *              ....
184  *              struct wlan_afc_resp_eirp_info eirp[num_channels - 1];
185  *          }
186  *          .
187  *          .
188  *          struct wlan_afc_resp_opclass_info opclass[num_channel_obj - 1];
189  *          {
190  *              struct wlan_afc_resp_eirp_info eirp[0];
191  *              ....
192  *              struct wlan_afc_resp_eirp_info eirp[num_channels - 1];
193  *          }
194  *     }
195  * }
196  *
197  */
198 struct wlan_afc_host_resp {
199 	uint32_t header;
200 	int32_t  status;
201 	uint32_t time_to_live;
202 	uint32_t length;
203 	uint32_t resp_format;
204 	uint8_t  afc_resp[0];
205 } qdf_packed;
206 
207 /**
208  * struct wlan_afc_resp_opclass_info - Structure to populate operating class
209  *                                     and channel information from AFC
210  *                                     response.
211  *
212  * @opclass:        Operating class
213  * @num_channels:   Number of channels received in AFC response
214  */
215 struct wlan_afc_resp_opclass_info {
216 	uint32_t opclass;
217 	uint32_t num_channels;
218 } qdf_packed;
219 
220 /**
221  * struct wlan_afc_resp_eirp_info - Structure to update EIRP values for channels
222  *
223  * @channel_cfi:  Channel center frequency index
224  * @max_eirp_pwr: Maximum permissible EIRP(in dBm) for the Channel
225  */
226 struct wlan_afc_resp_eirp_info {
227 	uint32_t channel_cfi;
228 	uint32_t max_eirp_pwr;
229 } qdf_packed;
230 
231 /**
232  * struct wlan_afc_resp_freq_psd_info - Structure to update PSD values for
233  *                                      queried frequency ranges
234  *
235  * @freq_info: Frequency range in MHz:- bits 15:0  = u16 start_freq,
236  *                                      bits 31:16 = u16 end_freq
237  * @max_psd:   Maximum PSD in dbm/MHz
238  */
239 struct wlan_afc_resp_freq_psd_info {
240 	uint32_t freq_info;
241 	uint32_t max_psd;
242 } qdf_packed;
243 
244 /**
245  * struct wlan_afc_bin_resp_data - Structure to populate AFC binary response
246  *
247  * @local_err_code:     Internal error code between AFC app and FW
248  *                      0 - Success
249  *                      1 - General failure
250  * @version:            Internal version between AFC app and FW
251  *                      Current version: 1
252  * @afc_wfa_version:    AFC spec version info. Bits 15:0  - Minor version
253  *                                             Bits 31:16 - Major version
254  * @request_id:         AFC unique request ID
255  * @avail_exp_time_d:   Availability expiry date in UTC.
256  *                      Date format: bits 7:0   - DD (Day 1-31)
257  *                                   bits 15:8  - MM (Month 1-12)
258  *                                   bits 31:16 - YYYY (Year)
259  * @avail_exp_time_t:   Availability expiry time in UTC.
260  *                      Time format: bits 7:0   - SS (Seconds 0-59)
261  *                                   bits 15:8  - MM (Minutes 0-59)
262  *                                   bits 23:16 - HH (Hours 0-23)
263  *                                   bits 31:24 - Reserved
264  * @afc_serv_resp_code: AFC server response code. The AFC server response codes
265  *                      are defined in the WiFi Spec doc for AFC as follows:
266  *                      0: Success.
267  *                      100 - 199: General errors related to protocol.
268  *                      300 - 399: Error events specific to message exchange
269  *                                 for the available Spectrum Inquiry.
270  * @num_frequency_obj:  Number of frequency objects
271  * @num_channel_obj:    Number of channel objects
272  * @shortdesc:          Short description corresponding to resp_code field
273  * @reserved:           Reserved for future use
274  */
275 struct wlan_afc_bin_resp_data {
276 	uint32_t local_err_code;
277 	uint32_t version;
278 	uint32_t afc_wfa_version;
279 	uint32_t request_id;
280 	uint32_t avail_exp_time_d;
281 	uint32_t avail_exp_time_t;
282 	uint32_t afc_serv_resp_code;
283 	uint32_t num_frequency_obj;
284 	uint32_t num_channel_obj;
285 	uint8_t  shortdesc[64];
286 	uint32_t reserved[2];
287 } qdf_packed;
288 #endif
289