1 /* 2 * Copyright (c) 2017-2019 The Linux Foundation. All rights reserved. 3 * 4 * Permission to use, copy, modify, and/or distribute this software for 5 * any purpose with or without fee is hereby granted, provided that the 6 * above copyright notice and this permission notice appear in all 7 * copies. 8 * 9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL 10 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED 11 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE 12 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL 13 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR 14 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER 15 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 16 * PERFORMANCE OF THIS SOFTWARE. 17 */ 18 19 /** 20 * DOC: dfs_process_radar_found_ind.h 21 * This file provides prototypes of the routines needed for the 22 * external components to utilize the services provided by the 23 * DFS component. 24 */ 25 26 #ifndef _DFS_PROCESS_RADAR_FOUND_IND_H_ 27 #define _DFS_PROCESS_RADAR_FOUND_IND_H_ 28 29 /* Number of channel marking offsets */ 30 #define DFS_NUM_FREQ_OFFSET 3 31 32 /* Lower channel from 20 Mhz center channel */ 33 #define DFS_20MHZ_LOWER_CHANNEL(_f) ((_f) - 20) 34 /* Upper channel from 20 Mhz center channel */ 35 #define DFS_20MHZ_UPPER_CHANNEL(_f) ((_f) + 20) 36 /* 1st lower channel from center channel of bandwidth 40/80/160Mhz */ 37 #define DFS_FIRST_LOWER_CHANNEL(_f) ((_f) - 10) 38 /* 2nd lower channel from center channel of bandwidth 40/80/160Mhz */ 39 #define DFS_SECOND_LOWER_CHANNEL(_f) ((_f) - 30) 40 /* 3rd lower channel from center channel of bandwidth 80/160Mhz */ 41 #define DFS_THIRD_LOWER_CHANNEL(_f) ((_f) - 50) 42 /* 1st upper channel from center channel of bandwidth 40/80/160Mhz */ 43 #define DFS_FIRST_UPPER_CHANNEL(_f) ((_f) + 10) 44 /* 2nd upper channel from center channel of bandwidth 40/80/160Mhz */ 45 #define DFS_SECOND_UPPER_CHANNEL(_f) ((_f) + 30) 46 /* 3rd upper channel from center channel of bandwidth 80/160Mhz */ 47 #define DFS_THIRD_UPPER_CHANNEL(_f) ((_f) + 50) 48 49 /* 20 Mhz freq_offset lower */ 50 #define DFS_20MZ_OFFSET_LOWER (-10) 51 /* 20 Mhz freq_offset upper */ 52 #define DFS_20MZ_OFFSET_UPPER (10) 53 /* 40/80 Mhz freq_offset first lower */ 54 #define DFS_OFFSET_FIRST_LOWER (-20) 55 /* 40/80 Mhz freq_offset second lower */ 56 #define DFS_OFFSET_SECOND_LOWER (-40) 57 /* 40/80 Mhz freq_offset first upper */ 58 #define DFS_OFFSET_FIRST_UPPER (20) 59 /* 40/80 Mhz freq_offset second upper */ 60 #define DFS_OFFSET_SECOND_UPPER (40) 61 62 /* Frequency offset to sidx */ 63 #define DFS_FREQ_OFFSET_TO_SIDX(_f) ((32 * (_f)) / 10) 64 /* Sidx to frequency offset */ 65 #define DFS_SIDX_TO_FREQ_OFFSET(_s) ((10 * (_s)) / 32) 66 /* sidx offset boundary */ 67 #define DFS_BOUNDARY_SIDX 32 68 /* freq offset for chirp */ 69 #define DFS_CHIRP_OFFSET 10 70 /* second segment freq offset */ 71 #define DFS_160MHZ_SECOND_SEG_OFFSET 40 72 /*Primary segment id is 0 */ 73 #define PRIMARY_SEG 0 74 75 /* Frequency offset indices */ 76 #define CENTER_CH 0 77 #define LEFT_CH 1 78 #define RIGHT_CH 2 79 80 #ifdef CONFIG_CHAN_NUM_API 81 /* Next channel number offset's from center channel number */ 82 #define DFS_5GHZ_NEXT_CHAN_OFFSET 2 83 #define DFS_5GHZ_2ND_CHAN_OFFSET 6 84 #define DFS_5GHZ_3RD_CHAN_OFFSET 10 85 #define DFS_5GHZ_4TH_CHAN_OFFSET 14 86 #endif 87 88 #ifdef CONFIG_CHAN_FREQ_API 89 /* Next channel frequency offsets from center channel frequency */ 90 #define DFS_5GHZ_NEXT_CHAN_FREQ_OFFSET 10 91 #define DFS_5GHZ_2ND_CHAN_FREQ_OFFSET 30 92 #define DFS_5GHZ_3RD_CHAN_FREQ_OFFSET 50 93 #define DFS_5GHZ_4TH_CHAN_FREQ_OFFSET 70 94 #endif 95 /* Max number of bonding channels in 160 MHz segment */ 96 #define NUM_CHANNELS_160MHZ 8 97 98 /** 99 * struct freqs_offsets - frequency and offset information 100 * @freq: channel frequency in mhz. 101 * @offset: offset from center frequency. 102 * 103 * Index 0 - Center channel affected by RADAR. 104 * Index 1 - Left of Center channel affected by RADAR. 105 * Index 2 - Right of Center channel affected by RADAR. 106 * 107 * This information is needed to find and mark radar infected 108 * channels in NOL and regulatory database. 109 */ 110 struct freqs_offsets { 111 uint32_t freq[DFS_NUM_FREQ_OFFSET]; 112 int32_t offset[DFS_NUM_FREQ_OFFSET]; 113 }; 114 115 /** 116 * dfs_process_radar_found_indication() - Process radar found indication 117 * @dfs: Pointer to wlan_dfs structure. 118 * @radar_found: radar found info. 119 * 120 * Process radar found indication and update radar effected channel in NOL 121 * and regulatory. 122 * 123 * Return: None 124 */ 125 void dfs_process_radar_found_indication(struct wlan_dfs *dfs, 126 struct radar_found_info *radar_found); 127 128 /** 129 * dfs_process_radar_ind() - Process radar indication event 130 * @dfs: Pointer to wlan_dfs structure. 131 * @radar_found: Pointer to radar_found_info structure. 132 * 133 * Wrapper function of dfs_process_radar_found_indication(). 134 * 135 * Return: QDF_STATUS 136 */ 137 QDF_STATUS dfs_process_radar_ind(struct wlan_dfs *dfs, 138 struct radar_found_info *radar_found); 139 140 /** 141 * dfs_radarfound_action_generic() - The dfs action on radar detection by host 142 * for domains other than FCC. 143 * @dfs: Pointer to wlan_dfs structure. 144 * @seg_id: segment id. 145 * 146 * Return: None 147 */ 148 void dfs_radarfound_action_generic(struct wlan_dfs *dfs, uint8_t seg_id); 149 150 /** 151 * dfs_get_bonding_channels() - Get bonding channels. 152 * @dfs: Pointer to wlan_dfs structure. 153 * @curchan: Pointer to dfs_channels to know width and primary channel. 154 * @segment_id: Segment id, useful for 80+80/160 MHz operating band. 155 * @detector_id: Detector id, used to find if radar is detected on 156 * Agile detector. 157 * @channels: Pointer to save radar affected channels. 158 * 159 * Return: Number of channels. 160 */ 161 #ifdef CONFIG_CHAN_NUM_API 162 uint8_t dfs_get_bonding_channels(struct wlan_dfs *dfs, 163 struct dfs_channel *curchan, 164 uint32_t segment_id, 165 uint8_t detector_id, 166 uint8_t *channels); 167 #endif 168 169 /** 170 * dfs_get_bonding_channels_for_freq() - Get bonding channels. 171 * @dfs: Pointer to wlan_dfs structure. 172 * @curchan: Pointer to dfs_channels to know width and primary channel. 173 * @segment_id: Segment id, useful for 80+80/160 MHz operating band. 174 * @detector_id: Detector id, used to find if radar is detected on 175 * Agile detector. 176 * @freq_list: Pointer to save radar affected channel's frequency. 177 * 178 * Return: Number of channels. 179 */ 180 #ifdef CONFIG_CHAN_FREQ_API 181 uint8_t dfs_get_bonding_channels_for_freq(struct wlan_dfs *dfs, 182 struct dfs_channel *curchan, 183 uint32_t segment_id, 184 uint8_t detector_id, 185 uint16_t *freq_list); 186 #endif 187 188 /** 189 * dfs_get_bonding_channels_without_seg_info() - Get bonding channels in chan 190 * @chan: Pointer to dfs_channel structure. 191 * @channels: channel array holding list of bonded channels. 192 * 193 * Return: number of sub channels in the input channel. 194 */ 195 #ifdef CONFIG_CHAN_NUM_API 196 uint8_t dfs_get_bonding_channels_without_seg_info(struct dfs_channel *chan, 197 uint8_t *channels); 198 #endif 199 200 /** 201 * dfs_get_bonding_channel_without_seg_info_for_freq() - Get bonding channels 202 * in chan. 203 * @chan: Pointer to dfs_channel structure. 204 * @freq_list: channel array holding list of bonded channel's frequency. 205 * 206 * Return: number of sub channels in the input channel. 207 */ 208 #ifdef CONFIG_CHAN_FREQ_API 209 uint8_t 210 dfs_get_bonding_channel_without_seg_info_for_freq(struct dfs_channel *chan, 211 uint16_t *freq_list); 212 #endif 213 214 /** 215 * dfs_set_nol_subchannel_marking() - Set or unset NOL subchannel marking. 216 * @dfs: Pointer to wlan_dfs structure. 217 * @nol_subchannel_marking - Configure NOL subchannel marking. 218 * 219 * Return: Status of the configuration. 220 */ 221 int 222 dfs_set_nol_subchannel_marking(struct wlan_dfs *dfs, 223 bool nol_subchannel_marking); 224 225 /** 226 * dfs_get_nol_subchannel_marking() - Get the value of NOL subchannel marking. 227 * @dfs: Pointer to wlan_dfs structure. 228 * @nol_subchannel_marking - Read and store the value of NOL subchannel marking 229 * config. 230 * 231 * Return: Status of the read. 232 */ 233 int 234 dfs_get_nol_subchannel_marking(struct wlan_dfs *dfs, 235 bool *nol_subchannel_marking); 236 #endif /*_DFS_PROCESS_RADAR_FOUND_IND_H_ */ 237