-
Notifications
You must be signed in to change notification settings - Fork 25
/
fft_eval.h
170 lines (131 loc) · 3.09 KB
/
fft_eval.h
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
/* SPDX-License-Identifier: GPL-2.0-only */
/* SPDX-FileCopyrightText: 2012 Simon Wunderlich <[email protected]>
* SPDX-FileCopyrightText: 2012 Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V.
* SPDX-FileCopyrightText: 2013 Gui Iribarren <[email protected]>
* SPDX-FileCopyrightText: 2017 Nico Pace <[email protected]>
*/
#ifndef _FFT_EVAL_H
#define _FFT_EVAL_H
#include <stdint.h>
typedef int8_t s8;
typedef uint8_t u8;
typedef uint16_t u16;
typedef uint64_t u64;
enum ath_fft_sample_type {
ATH_FFT_SAMPLE_HT20 = 1,
ATH_FFT_SAMPLE_HT20_40 = 2,
ATH_FFT_SAMPLE_ATH10K = 3,
ATH_FFT_SAMPLE_ATH11K = 4,
};
enum nl80211_channel_type {
NL80211_CHAN_NO_HT,
NL80211_CHAN_HT20,
NL80211_CHAN_HT40MINUS,
NL80211_CHAN_HT40PLUS
};
/*
* ath9k spectral definition
*/
#define SPECTRAL_HT20_NUM_BINS 56
#define SPECTRAL_HT20_40_NUM_BINS 128
#if defined(__WIN32__)
#pragma pack(push,1)
#endif
struct fft_sample_tlv {
u8 type; /* see ath_fft_sample */
u16 length;
/* type dependent data follows */
} __attribute__((packed));
struct fft_sample_ht20 {
struct fft_sample_tlv tlv;
u8 max_exp;
u16 freq;
s8 rssi;
s8 noise;
u16 max_magnitude;
u8 max_index;
u8 bitmap_weight;
u64 tsf;
u8 data[SPECTRAL_HT20_NUM_BINS];
} __attribute__((packed));
struct fft_sample_ht20_40 {
struct fft_sample_tlv tlv;
u8 channel_type;
u16 freq;
s8 lower_rssi;
s8 upper_rssi;
u64 tsf;
s8 lower_noise;
s8 upper_noise;
u16 lower_max_magnitude;
u16 upper_max_magnitude;
u8 lower_max_index;
u8 upper_max_index;
u8 lower_bitmap_weight;
u8 upper_bitmap_weight;
u8 max_exp;
u8 data[SPECTRAL_HT20_40_NUM_BINS];
} __attribute__((packed));
/*
* ath10k spectral sample definition
*/
#define SPECTRAL_ATH10K_MAX_NUM_BINS 256
struct fft_sample_ath10k {
struct fft_sample_tlv tlv;
u8 chan_width_mhz;
uint16_t freq1;
uint16_t freq2;
int16_t noise;
uint16_t max_magnitude;
uint16_t total_gain_db;
uint16_t base_pwr_db;
uint64_t tsf;
s8 max_index;
u8 rssi;
u8 relpwr_db;
u8 avgpwr_db;
u8 max_exp;
u8 data[0];
} __attribute__((packed));
/*
* ath11k spectral sample definition
*/
#define SPECTRAL_ATH11K_MAX_NUM_BINS 512
struct fft_sample_ath11k {
struct fft_sample_tlv tlv;
u8 chan_width_mhz;
s8 max_index;
u8 max_exp;
uint16_t freq1;
uint16_t freq2;
uint16_t max_magnitude;
uint16_t rssi;
uint32_t tsf;
int32_t noise;
u8 data[0];
} __attribute__((packed));
#if defined(__WIN32__)
#pragma pack(pop)
#endif
struct scanresult {
union {
struct fft_sample_tlv tlv;
struct fft_sample_ht20 ht20;
struct fft_sample_ht20_40 ht40;
struct {
struct fft_sample_ath10k header;
u8 data[SPECTRAL_ATH10K_MAX_NUM_BINS];
} ath10k;
struct {
struct fft_sample_ath11k header;
u8 data[SPECTRAL_ATH11K_MAX_NUM_BINS];
} ath11k;
} sample;
struct scanresult *next;
};
int fft_eval_init(char *fname);
void fft_eval_exit(void);
void fft_eval_usage(const char *prog);
extern struct scanresult *result_list;
extern int scanresults_n;
#endif