xref: /wlan-driver/qca-wifi-host-cmn/umac/cmn_services/regulatory/inc/wlan_reg_afc.h (revision 5113495b16420b49004c444715d2daae2066e7dc)
1 /*
2  * Copyright (c) 2021, The Linux Foundation. All rights reserved.
3  * Copyright (c) 2022-2024 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_freq_range_obj - Structure for frequency range query.
31  * @lowfreq:  Lower limit(in MHz) for frequency range query.
32  * @highfreq: Higher limit(in MHz) for frequency range query.
33  */
34 struct wlan_afc_freq_range_obj {
35 	uint16_t lowfreq;
36 	uint16_t highfreq;
37 };
38 
39 /**
40  * struct wlan_afc_frange_list - Structure to send freq range list to AFC app.
41  * @num_ranges: Number of queried frequency ranges.
42  * @range_objs: List of queried frequency ranges.
43  */
44 struct wlan_afc_frange_list {
45 	uint32_t num_ranges;
46 	struct wlan_afc_freq_range_obj *range_objs;
47 };
48 
49 /**
50  * struct wlan_afc_opclass_obj - Structure for opclass/channel query.
51  * @opclass_num_cfis: Number of channels to be required for given opclass.
52  * @opclass:          Operating class to be queried.
53  * @cfis:             List of Channels to be queried for given Global opclass.
54  */
55 struct wlan_afc_opclass_obj {
56 	uint8_t opclass_num_cfis;
57 	uint8_t opclass;
58 	uint8_t *cfis;
59 };
60 
61 /**
62  * struct wlan_afc_opclass_obj_list - Structure to send opclass object list
63  * to AFC app.
64  * @num_opclass_objs: Number of opclass objects.
65  * @opclass_objs: Pointer to list of opclass objects.
66  */
67 struct wlan_afc_opclass_obj_list {
68 	uint8_t num_opclass_objs;
69 	struct wlan_afc_opclass_obj *opclass_objs;
70 };
71 
72 /**
73  * struct wlan_afc_host_request - Structure to send AFC request info.
74  * @req_id:        Unique request ID from FW to be used as AFC request ID
75  *                 to server.
76  * @version_minor: Lower 16 bits for the AFC request version.
77  * @version_major: Higher 16 bits for the AFC request version.
78  * @min_des_power: Minimum desired power(in dbm) for queried spectrum.
79  * @freq_lst: Pointer to the list of frequency ranges.
80  * @opclass_obj_lst: Pointer to opclass objects list.
81  * @afc_location: Pointer to the AFC location structure,
82  */
83 struct wlan_afc_host_request {
84 	uint64_t req_id;
85 	uint16_t version_minor;
86 	uint16_t version_major;
87 	int16_t  min_des_power;
88 	struct wlan_afc_frange_list *freq_lst;
89 	struct wlan_afc_opclass_obj_list *opclass_obj_lst;
90 	struct wlan_afc_location *afc_location;
91 };
92 
93 /**
94  * enum reg_afc_dev_deploy_type - Deployment type of AP
95  * @AFC_DEPLOYMENT_UNKNOWN: Unknown
96  * @AFC_DEPLOYMENT_INDOOR: Located Indoor
97  * @AFC_DEPLOYMENT_OUTDOOR: Located Outdoor
98  */
99 enum reg_afc_dev_deploy_type {
100 	AFC_DEPLOYMENT_UNKNOWN = 0,
101 	AFC_DEPLOYMENT_INDOOR  = 1,
102 	AFC_DEPLOYMENT_OUTDOOR = 2,
103 };
104 
105 /**
106  * enum reg_afc_resp_format_type - Response type supported by AP
107  *
108  * @AFC_RESP_TYPE_JSON_RESP: JSON format
109  * @AFC_RESP_TYPE_BIN_RESP: Binary format
110  */
111 enum reg_afc_resp_format_type {
112 	AFC_RESP_TYPE_JSON_RESP = 0,
113 	AFC_RESP_TYPE_BIN_RESP = 1,
114 };
115 
116 /**
117  * enum afc_object_type - AFC Request object types
118  * @AFC_OBJ_LOCATION: Location object
119  */
120 enum afc_object_type {
121 	AFC_OBJ_LOCATION = 1
122 };
123 
124 /**
125  * struct wlan_afc_location - Structure for afc location info.
126  * @deployment_type: Deployment type of enum reg_afc_dev_deploy_type
127  */
128 struct wlan_afc_location {
129 	uint32_t deployment_type;
130 };
131 
132 /**
133  * struct wlan_afc_host_resp - Structure for AFC Host response to FW
134  * @header:       Header for compatibility.
135  *                Valid value: 0
136  * @status:       Flag to indicate validity of data. To be updated by TZ
137  *                1:  Success
138  *                -1: Failure
139  * @time_to_live: Period(in seconds) the data is valid for
140  * @length:       Length of the response message
141  * @resp_format:  AFC response format.
142  *                0: JSON format
143  *                1: Binary data format
144  * @afc_resp:     Response message from the AFC server for queried parameters
145  *
146  * The following is the layout of the AFC response.
147  *
148  * struct wlan_afc_host_resp {
149  *     header;
150  *     status;
151  *     time_to_live;
152  *     length;
153  *     resp_format;
154  *     afc_resp {
155  *          struct wlan_afc_bin_resp_data fixed_params;
156  *          struct wlan_afc_resp_freq_psd_info obj[0];
157  *          ....
158  *          struct wlan_afc_resp_freq_psd_info obj[num_frequency_obj - 1];
159  *          struct wlan_afc_resp_opclass_info opclass[0];
160  *          {
161  *              struct wlan_afc_resp_eirp_info eirp[0];
162  *              ....
163  *              struct wlan_afc_resp_eirp_info eirp[num_channels - 1];
164  *          }
165  *          .
166  *          .
167  *          struct wlan_afc_resp_opclass_info opclass[num_channel_obj - 1];
168  *          {
169  *              struct wlan_afc_resp_eirp_info eirp[0];
170  *              ....
171  *              struct wlan_afc_resp_eirp_info eirp[num_channels - 1];
172  *          }
173  *     }
174  * }
175  *
176  */
177 struct wlan_afc_host_resp {
178 	uint32_t header;
179 	int32_t  status;
180 	uint32_t time_to_live;
181 	uint32_t length;
182 	uint32_t resp_format;
183 	uint8_t afc_resp[];
184 } qdf_packed;
185 
186 /**
187  * struct wlan_afc_resp_opclass_info - Structure to populate operating class
188  *                                     and channel information from AFC
189  *                                     response.
190  * @opclass:        Operating class
191  * @num_channels:   Number of channels received in AFC response
192  */
193 struct wlan_afc_resp_opclass_info {
194 	uint32_t opclass;
195 	uint32_t num_channels;
196 } qdf_packed;
197 
198 /**
199  * struct wlan_afc_resp_eirp_info - Structure to update EIRP values for channels
200  * @channel_cfi:  Channel center frequency index
201  * @max_eirp_pwr: Maximum permissible EIRP(in dBm) for the Channel
202  */
203 struct wlan_afc_resp_eirp_info {
204 	uint32_t channel_cfi;
205 	int32_t  max_eirp_pwr;
206 } qdf_packed;
207 
208 /**
209  * struct wlan_afc_resp_freq_psd_info - Structure to update PSD values for
210  *                                      queried frequency ranges
211  * @freq_info: Frequency range in MHz:- bits 15:0  = u16 start_freq,
212  *                                      bits 31:16 = u16 end_freq
213  * @max_psd:   Maximum PSD in dbm/MHz
214  */
215 struct wlan_afc_resp_freq_psd_info {
216 	uint32_t freq_info;
217 	uint32_t max_psd;
218 } qdf_packed;
219 
220 /**
221  * struct wlan_afc_bin_resp_data - Structure to populate AFC binary response
222  * @local_err_code:     Internal error code between AFC app and FW
223  *                      0 - Success
224  *                      1 - General failure
225  * @version:            Internal version between AFC app and FW
226  *                      Current version: 1
227  * @afc_wfa_version:    AFC spec version info. Bits 15:0  - Minor version
228  *                                             Bits 31:16 - Major version
229  * @request_id:         AFC unique request ID
230  * @avail_exp_time_d:   Availability expiry date in UTC.
231  *                      Date format: bits 7:0   - DD (Day 1-31)
232  *                                   bits 15:8  - MM (Month 1-12)
233  *                                   bits 31:16 - YYYY (Year)
234  * @avail_exp_time_t:   Availability expiry time in UTC.
235  *                      Time format: bits 7:0   - SS (Seconds 0-59)
236  *                                   bits 15:8  - MM (Minutes 0-59)
237  *                                   bits 23:16 - HH (Hours 0-23)
238  *                                   bits 31:24 - Reserved
239  * @afc_serv_resp_code: AFC server response code. The AFC server response codes
240  *                      are defined in the WiFi Spec doc for AFC as follows:
241  *                      0: Success.
242  *                      100 - 199: General errors related to protocol.
243  *                      300 - 399: Error events specific to message exchange
244  *                                 for the available Spectrum Inquiry.
245  * @num_frequency_obj:  Number of frequency objects
246  * @num_channel_obj:    Number of channel objects
247  * @shortdesc:          Short description corresponding to resp_code field
248  * @reserved:           Reserved for future use
249  */
250 struct wlan_afc_bin_resp_data {
251 	uint32_t local_err_code;
252 	uint32_t version;
253 	uint32_t afc_wfa_version;
254 	uint32_t request_id;
255 	uint32_t avail_exp_time_d;
256 	uint32_t avail_exp_time_t;
257 	uint32_t afc_serv_resp_code;
258 	uint32_t num_frequency_obj;
259 	uint32_t num_channel_obj;
260 	uint8_t  shortdesc[64];
261 	uint32_t reserved[2];
262 } qdf_packed;
263 #endif
264