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