1 /* SPDX-License-Identifier: ISC */
3 * Copyright (C) 2016 Lorenzo Bianconi <lorenzo.bianconi83@gmail.com>
6 #ifndef __MT76x02_DFS_H
7 #define __MT76x02_DFS_H
9 #include <linux/types.h>
10 #include <linux/nl80211.h>
12 #define MT_DFS_GP_INTERVAL (10 << 4) /* 64 us unit */
13 #define MT_DFS_NUM_ENGINES 4
16 #define MT_DFS_SYM_ROUND 0
17 #define MT_DFS_DELTA_DELAY 2
18 #define MT_DFS_VGA_MASK 0
19 #define MT_DFS_PWR_GAIN_OFFSET 3
20 #define MT_DFS_PWR_DOWN_TIME 0xf
21 #define MT_DFS_RX_PE_MASK 0xff
22 #define MT_DFS_PKT_END_MASK 0
23 #define MT_DFS_CH_EN 0xf
25 /* sw detector params */
26 #define MT_DFS_EVENT_LOOP 64
27 #define MT_DFS_SW_TIMEOUT (HZ / 20)
28 #define MT_DFS_EVENT_WINDOW (HZ / 5)
29 #define MT_DFS_SEQUENCE_WINDOW (200 * (1 << 20))
30 #define MT_DFS_EVENT_TIME_MARGIN 2000
31 #define MT_DFS_PRI_MARGIN 4
32 #define MT_DFS_SEQUENCE_TH 6
34 #define MT_DFS_FCC_MAX_PRI ((28570 << 1) + 1000)
35 #define MT_DFS_FCC_MIN_PRI (3000 - 2)
36 #define MT_DFS_JP_MAX_PRI ((80000 << 1) + 1000)
37 #define MT_DFS_JP_MIN_PRI (28500 - 2)
38 #define MT_DFS_ETSI_MAX_PRI (133333 + 125000 + 117647 + 1000)
39 #define MT_DFS_ETSI_MIN_PRI (4500 - 20)
41 struct mt76x02_radar_specs
{
58 #define MT_DFS_CHECK_EVENT(x) ((x) != GENMASK(31, 0))
59 #define MT_DFS_EVENT_ENGINE(x) (((x) & BIT(31)) ? 2 : 0)
60 #define MT_DFS_EVENT_TIMESTAMP(x) ((x) & GENMASK(21, 0))
61 #define MT_DFS_EVENT_WIDTH(x) ((x) & GENMASK(11, 0))
62 struct mt76x02_dfs_event
{
63 unsigned long fetch_ts
;
69 #define MT_DFS_EVENT_BUFLEN 256
70 struct mt76x02_dfs_event_rb
{
71 struct mt76x02_dfs_event data
[MT_DFS_EVENT_BUFLEN
];
75 struct mt76x02_dfs_sequence
{
76 struct list_head head
;
84 struct mt76x02_dfs_hw_pulse
{
92 struct mt76x02_dfs_sw_detector_params
{
98 struct mt76x02_dfs_engine_stats
{
100 u32 hw_pulse_discarded
;
104 struct mt76x02_dfs_seq_stats
{
109 struct mt76x02_dfs_pattern_detector
{
113 struct mt76x02_dfs_sw_detector_params sw_dpd_params
;
114 struct mt76x02_dfs_event_rb event_rb
[2];
116 struct list_head sequences
;
117 struct list_head seq_pool
;
118 struct mt76x02_dfs_seq_stats seq_stats
;
120 unsigned long last_sw_check
;
123 struct mt76x02_dfs_engine_stats stats
[MT_DFS_NUM_ENGINES
];
124 struct tasklet_struct dfs_tasklet
;
127 void mt76x02_dfs_init_params(struct mt76x02_dev
*dev
);
128 void mt76x02_dfs_init_detector(struct mt76x02_dev
*dev
);
129 void mt76x02_regd_notifier(struct wiphy
*wiphy
,
130 struct regulatory_request
*request
);
131 void mt76x02_phy_dfs_adjust_agc(struct mt76x02_dev
*dev
);
132 #endif /* __MT76x02_DFS_H */