lin
2025-07-31 065ea569db06206874bbfa18eb25ff6121aec09b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
/* SPDX-License-Identifier: GPL-2.0 */
 
/******************************************************************************
 *
 * Copyright (C) 2020 SeekWave Technology Co.,Ltd.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of version 2 of the GNU General Public License as
 * published by the Free Software Foundation;
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 ******************************************************************************/
 
#ifndef __SKW_DFS_H__
#define __SKW_DFS_H__
 
#include <linux/ieee80211.h>
#include <net/cfg80211.h>
#include <linux/inetdevice.h>
 
#define SKW_PRI_TOLERANCE                     16
 
#define SKW_DFS_FLAG_CAC_MODE                 1
#define SKW_DFS_FLAG_MONITOR_MODE             2
 
struct skw_pri_detector {
   u64 last_ts;
   u32 window_size;
   u32 count, max_count;
 
   struct list_head sequences;
   struct list_head pulses;
};
 
struct skw_radar_rule {
   u8 type_id;
   u8 width_min;
   u8 width_max;
   u16 pri_min;
   u16 pri_max;
   u8 nr_pri;
   u8 ppb;
   u8 ppb_thresh;
   u8 max_pri_tolerance;
   bool chirp;
};
 
struct skw_radar_cfg {
   const struct skw_radar_rule rule;
   struct skw_pri_detector pri;
};
 
struct skw_radar_info {
   int nr_cfg;
   struct skw_radar_cfg *cfgs;
};
 
enum SKW_DFS_ACTION {
   SKW_DFS_START_CAC = 1,
   SKW_DFS_STOP_CAC,
   SKW_DFS_START_MONITOR,
   SKW_DFS_STOP_MONITOR,
};
 
struct skw_cac_params {
   u8 chn;
   u8 center_chn1;
   u8 center_chn2;
   u8 band_width;
 
   u32 time_ms;
   u8 region;
} __packed;
 
struct skw_dfs_cac {
   u16 type;
   u16 len;
   struct skw_cac_params params;
};
 
struct skw_pulse_data {
   u64 chirp: 1;
   u64 rssi: 5;
   u64 width: 8;
   u64 ts: 24;
   u64 resv:26;
};
 
struct skw_radar_pulse {
   u8 nr_pulse;
   u8 resv;
   struct skw_pulse_data data[0];
} __packed;
 
struct skw_pulse_info {
   u64 ts;
   u16 freq;
   u8 width;
   s8 rssi;
   bool chirp;
};
 
struct skw_pulse_elem {
   struct list_head head;
   u64 ts;
};
 
struct skw_pri_sequence {
   struct list_head head;
   u32 pri;
   u32 dur;
   u32 count;
   u32 count_falses;
   u64 first_ts;
   u64 last_ts;
   u64 deadline_ts;
};
 
#ifdef CONFIG_SWT6621S_DFS_MASTER
int skw_dfs_chan_init(struct wiphy *wiphy, struct net_device *dev,
             struct cfg80211_chan_def *chandef, u32 cac_time_ms);
 
int skw_dfs_add_pulse(struct wiphy *wiphy, struct net_device *dev,
           struct skw_pulse_info *pulse);
 
int skw_dfs_start_cac(struct wiphy *wiphy, struct net_device *dev);
int skw_dfs_stop_cac(struct wiphy *wiphy, struct net_device *ndev);
int skw_dfs_start_monitor(struct wiphy *wiphy, struct net_device *dev);
int skw_dfs_stop_monitor(struct wiphy *wiphy, struct net_device *dev);
int skw_dfs_init(struct wiphy *wiphy, struct net_device *dev);
int skw_dfs_deinit(struct wiphy *wiphy, struct net_device *dev);
#else
static inline int skw_dfs_chan_init(struct wiphy *wiphy, struct net_device *dev,
               struct cfg80211_chan_def *chandef, u32 cac_time_ms)
{
   return -ENOTSUPP;
}
 
static inline int skw_dfs_add_pulse(struct wiphy *wiphy, struct net_device *dev,
               struct skw_pulse_info *pulse)
{
   return 0;
}
 
static inline int skw_dfs_start_cac(struct wiphy *wiphy, struct net_device *dev)
{
   return -ENOTSUPP;
}
 
static inline int skw_dfs_stop_cac(struct wiphy *wiphy, struct net_device *ndev)
{
   return 0;
}
 
static inline int skw_dfs_start_monitor(struct wiphy *wiphy, struct net_device *dev)
{
   return -ENOTSUPP;
}
 
static inline int skw_dfs_stop_monitor(struct wiphy *wiphy, struct net_device *dev)
{
   return 0;
}
static inline int skw_dfs_init(struct wiphy *wiphy, struct net_device *dev)
{
   return 0;
}
 
static inline int skw_dfs_deinit(struct wiphy *wiphy, struct net_device *dev)
{
   return 0;
}
#endif
 
#endif