xref: /wlan-dirver/qca-wifi-host-cmn/umac/dfs/core/src/dfs_process_radar_found_ind.h (revision 87a8e4458319c60b618522e263ed900e36aab528)
1 /*
2  * Copyright (c) 2017-2018 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 /* Number of channel marking offsets */
27 #define DFS_NUM_FREQ_OFFSET   3
28 
29 /* Lower channel from 20 Mhz center channel */
30 #define DFS_20MHZ_LOWER_CHANNEL(_f)    ((_f) - 20)
31 /* Upper channel from 20 Mhz center channel */
32 #define DFS_20MHZ_UPPER_CHANNEL(_f)    ((_f) + 20)
33 /* 1st lower channel from center channel of bandwidth 40/80/160Mhz */
34 #define DFS_FIRST_LOWER_CHANNEL(_f)    ((_f) - 10)
35 /* 2nd lower channel from center channel of bandwidth 40/80/160Mhz */
36 #define DFS_SECOND_LOWER_CHANNEL(_f)   ((_f) - 30)
37 /* 3rd lower channel from center channel of bandwidth 80/160Mhz */
38 #define DFS_THIRD_LOWER_CHANNEL(_f)    ((_f) - 50)
39 /* 1st upper channel from center channel of bandwidth 40/80/160Mhz */
40 #define DFS_FIRST_UPPER_CHANNEL(_f)    ((_f) + 10)
41 /* 2nd upper channel from center channel of bandwidth 40/80/160Mhz */
42 #define DFS_SECOND_UPPER_CHANNEL(_f)   ((_f) + 30)
43 /* 3rd upper channel from center channel of bandwidth 80/160Mhz */
44 #define DFS_THIRD_UPPER_CHANNEL(_f)    ((_f) + 50)
45 
46 /* 20 Mhz freq_offset lower */
47 #define DFS_20MZ_OFFSET_LOWER    (-10)
48 /* 20 Mhz freq_offset upper */
49 #define DFS_20MZ_OFFSET_UPPER     (10)
50 /* 40/80 Mhz freq_offset first lower */
51 #define DFS_OFFSET_FIRST_LOWER    (-20)
52 /* 40/80 Mhz freq_offset second lower */
53 #define DFS_OFFSET_SECOND_LOWER   (-40)
54 /* 40/80 Mhz freq_offset first upper */
55 #define DFS_OFFSET_FIRST_UPPER     (20)
56 /* 40/80 Mhz freq_offset second upper */
57 #define DFS_OFFSET_SECOND_UPPER    (40)
58 
59 /* Frequency offset to sidx */
60 #define DFS_FREQ_OFFSET_TO_SIDX(_f)  ((32 * (_f)) / 10)
61 /* Sidx to frequency offset */
62 #define DFS_SIDX_TO_FREQ_OFFSET(_s)  ((10 * (_s)) / 32)
63 /* sidx offset boundary */
64 #define DFS_BOUNDARY_SIDX  32
65 /* freq offset for chirp */
66 #define DFS_CHIRP_OFFSET  10
67 /* second segment freq offset */
68 #define DFS_160MHZ_SECOND_SEG_OFFSET  40
69 
70 /* Frequency offset indices */
71 #define CENTER_CH 0
72 #define LEFT_CH   1
73 #define RIGHT_CH  2
74 
75 /* Next channel number offset's from center channel number */
76 #define DFS_5GHZ_NEXT_CHAN_OFFSET  2
77 #define DFS_5GHZ_2ND_CHAN_OFFSET   6
78 #define DFS_5GHZ_3RD_CHAN_OFFSET  10
79 #define DFS_5GHZ_4TH_CHAN_OFFSET  14
80 
81 /* Max number of bonding channels in 160 MHz segment */
82 #define NUM_CHANNELS_160MHZ 8
83 
84 /**
85  * struct freqs_offsets - frequency and offset information
86  * @freq: channel frequency in mhz.
87  * @offset: offset from center frequency.
88  *
89  * Index 0 - Center channel affected by RADAR.
90  * Index 1 - Left of Center channel affected by RADAR.
91  * Index 2 - Right of Center channel affected by RADAR.
92  *
93  * This information is needed to find and mark radar infected
94  * channels in NOL and regulatory database.
95  */
96 struct freqs_offsets {
97 	uint32_t freq[DFS_NUM_FREQ_OFFSET];
98 	int32_t offset[DFS_NUM_FREQ_OFFSET];
99 };
100 
101 /**
102  * dfs_process_radar_found_indication() - Process radar found indication
103  * @dfs: Pointer to wlan_dfs structure.
104  * @radar_found: radar found info.
105  *
106  * Process radar found indication and update radar effected channel in NOL
107  * and regulatory.
108  *
109  * Return: None
110  */
111 void dfs_process_radar_found_indication(struct wlan_dfs *dfs,
112 		struct radar_found_info *radar_found);
113 
114 /**
115  * dfs_process_radar_ind() - Process radar indication event
116  * @dfs: Pointer to wlan_dfs structure.
117  * @radar_found: Pointer to radar_found_info structure.
118  *
119  * Wrapper function of dfs_process_radar_found_indication().
120  *
121  * Return: QDF_STATUS
122  */
123 QDF_STATUS dfs_process_radar_ind(struct wlan_dfs *dfs,
124 		struct radar_found_info *radar_found);
125 
126 /**
127  * dfs_radarfound_action_generic() - The dfs action on radar detection by host
128  * for domains other than FCC.
129  * @dfs: Pointer to wlan_dfs structure.
130  * @seg_id: segment id.
131  *
132  * Return: None
133  */
134 void dfs_radarfound_action_generic(struct wlan_dfs *dfs, uint8_t seg_id);
135 
136 /**
137  * dfs_get_bonding_channels() - Get bonding channels.
138  * @curchan: Pointer to dfs_channels to know width and primary channel.
139  * @segment_id: Segment id, useful for 80+80/160 MHz operating band.
140  * @channels: Pointer to save radar affected channels.
141  *
142  * Return: Number of channels.
143  */
144 uint8_t dfs_get_bonding_channels(struct dfs_channel *curchan,
145 				 uint32_t segment_id,
146 				 uint8_t *channels);
147