-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathbss_stats.h
More file actions
257 lines (232 loc) · 6.72 KB
/
Copy pathbss_stats.h
File metadata and controls
257 lines (232 loc) · 6.72 KB
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
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
/*
* Copyright 2025 Morse Micro
*
* SPDX-License-Identifier: GPL-2.0-or-later
*
*/
#ifndef _MORSE_BSS_STATS_H_
#define _MORSE_BSS_STATS_H_
#include "morse.h"
#include "linux/list.h"
/** Default BSS Statistics event period in msec */
#define DEFAULT_BSS_STATS_MONITOR_WINDOW_MS 1000
/** Minimum BSS Statistics event period in msec */
#define MIN_BSS_STATS_MONITOR_WINDOW_MS 500
/** Maximum BSS Statistics event period in msec */
#define MAX_BSS_STATS_MONITOR_WINDOW_MS 20000
/** Reset Interval for Tx & Rx MCS histograms in msec */
#define TX_RX_HIST_RESET_INTVL_SECS 60000
/** Inactive STA, without traffic in monitoring window */
#define MORSE_STA_TYPE_INACTIVE 0
/** Inactive STA, with traffic in monitoring window */
#define MORSE_STA_TYPE_ACTIVE 1
struct morse_sta_stats_mcs_hist {
u32 h[MMRC_SUPP_NUM_MCS][MMRC_SUPP_NUM_BW];
};
/** Station statistics info */
struct morse_sta_stats {
u32 num_tx_bytes[IEEE80211_NUM_ACS];
u32 num_rx_bytes[IEEE80211_NUM_ACS];
u32 num_tx_pkts[IEEE80211_NUM_ACS];
u32 num_rx_pkts[IEEE80211_NUM_ACS];
u32 avg_tx_pkt_size;
u32 avg_rx_pkt_size;
u32 avg_tx_iat_us;
u32 avg_rx_iat_us;
u32 avg_tx_jitter_us;
u32 avg_rx_jitter_us;
u32 last_tx_iat_us;
u32 last_rx_iat_us;
u64 last_tx_timestamp_us;
u64 last_rx_timestamp_us;
u32 num_tx_retries;
u32 num_rx_retries;
/*
* Keep the following fields at the end of this struct to do the partial reset
* remaining fields and preserve the MCS histograms for longer interval.
*/
u64 last_reset_time;
u32 hist_last_reset_jiffies;
#ifdef CONFIG_MORSE_RC
/* MCS histograms (reset only every 60s, not every monitor window) */
struct morse_sta_stats_mcs_hist tx_mcs_hist;
struct morse_sta_stats_mcs_hist rx_mcs_hist;
#endif
};
struct morse_bss_stats_config {
/** Flag to keep track of enable/disable */
bool enabled;
/** Flag to keep track of pause/resume */
bool paused;
/** Statistics event interval */
u32 monitor_window_ms;
};
/** BSS statistics context */
struct morse_bss_stats_context {
/** Pointer to the globally stored config */
struct morse_bss_stats_config *config;
/** Serialize stats update and timer functions */
spinlock_t lock;
/** Stations List */
struct list_head stas;
/** Station statistics reporting timer */
struct timer_list timer;
/** back pointer to morse */
struct morse *mors;
/** back pointer to morse_vif */
struct morse_vif *mors_vif;
};
/** BSS statistics STA specific context */
struct morse_bss_stats_sta {
struct morse_sta_stats *stats;
struct list_head list;
unsigned long last_update;
};
struct morse_bss_stats_mcs_info {
u8 mcs : 4;
u8 bw : 3;
u8 short_gi : 1;
} __packed;
/** Morse event data for active STA statistics */
struct morse_active_sta_stats {
u8 mac_addr[ETH_ALEN];
u8 raw_priority;
u16 aid;
s16 avg_rssi;
/* Pad to align to a 4-byte boundary */
u8 __pad_align0;
u32 num_tx_bytes[IEEE80211_NUM_ACS];
u32 num_rx_bytes[IEEE80211_NUM_ACS];
u32 num_tx_pkts[IEEE80211_NUM_ACS];
u32 num_rx_pkts[IEEE80211_NUM_ACS];
u32 avg_tx_pkt_size;
u32 avg_rx_pkt_size;
u32 avg_tx_iat_us;
u32 avg_rx_iat_us;
u32 avg_tx_jitter_us;
u32 avg_rx_jitter_us;
u32 num_tx_retries;
u32 num_rx_retries;
u32 last_tx_rate_kbps;
u32 last_rx_rate_kbps;
u32 monitor_window_us;
struct morse_bss_stats_mcs_info avg_tx_mcs_info;
struct morse_bss_stats_mcs_info avg_rx_mcs_info;
} __packed;
/** Morse event data for inactive STA statistics */
struct morse_inactive_sta_info {
u8 mac_addr[ETH_ALEN];
u8 raw_priority;
u16 aid;
s16 avg_rssi;
} __packed;
/** Morse station entry data for BSS statistics */
struct morse_sta_entry {
/* 0 = inactive (basic info), 1 = active (full stats) */
u8 is_active;
union {
struct morse_inactive_sta_info sta_info;
struct morse_active_sta_stats sta_stats;
};
} __packed;
/** Morse event data for BSS statistics for all STAs */
struct morse_evt_bss_stats {
/* Num of connected STAs */
u16 num_stas;
/* Num of active STAs */
u16 num_active_stas;
/* variable STA entry data */
u8 data[];
} __packed;
/**
* morse_bss_stats_init() - Initialize BSS stats
*
* @mors_vif: Morse VIF structure
*
* Return: 0 - OK
*/
int morse_bss_stats_init(struct morse_vif *mors_vif);
/**
* morse_bss_stats_deinit() - Clean up BSS stats
*
* @mors_vif: Morse VIF structure
*/
void morse_bss_stats_deinit(struct morse_vif *mors_vif);
/**
* morse_bss_stats_is_enabled() - Is BSS stats module enabled to pass up stats
*
* @mors_vif: Morse VIF
*
* Return: true if enabled, otherwise false
*/
bool morse_bss_stats_is_enabled(struct morse_vif *mors_vif);
/**
* morse_bss_stats_update_tx() - Update STA statistics for Tx
*
* @vif: pointer to ieee80211_vif
* @skb: Tx skbuff
* @sta: pointer to ieee80211_sta
* @tx_status: Tx status
* @tx_attempts: Number of Tx attempts
*/
void morse_bss_stats_update_tx(struct ieee80211_vif *vif, struct sk_buff *skb,
struct ieee80211_sta *sta, struct morse_skb_tx_status *tx_status,
int tx_attempts);
/**
* morse_bss_stats_update_rx() - Update STA statistics for Rx
*
* @vif: pointer to ieee80211_vif
* @skb: Rx skbuff
* @sta: pointer to ieee80211_sta
* @rx_status: Rx status
*/
void morse_bss_stats_update_rx(struct ieee80211_vif *vif, struct sk_buff *skb,
struct ieee80211_sta *sta, struct morse_skb_rx_status *rx_status);
/**
* morse_bss_stats_update_sta_state() - Add/remove STA from the BSS stats STA list
*
* @mors: Global morse struct
* @mors_vif: Morse VIF
* @sta: pointer to ieee80211_sta
* @old_state: Old state of STA
* @new_state: New state of STA
*/
void morse_bss_stats_update_sta_state(struct morse *mors,
struct ieee80211_vif *vif, struct ieee80211_sta *sta,
enum ieee80211_sta_state old_state,
enum ieee80211_sta_state new_state);
/**
* morse_cmd_process_bss_stats_conf() - Stats config to enable and configure interval
*
* @mors: Global Morse structure
* @mors_vif: Morse VIF
* @config: pointer to BSS stats config
*
* Return: 0 if command was processed successfully, otherwise error code
*/
int morse_cmd_process_bss_stats_conf(struct morse *mors, struct morse_vif *mors_vif,
struct morse_cmd_req_config_bss_stats *config);
/**
* morse_bss_stats_reconfig() - Restore BSS stats from the stored global config
*
* @mors: Global Morse structure
* @mors_vif: Morse VIF
*/
void morse_bss_stats_reconfig(struct morse *mors, struct morse_vif *mors_vif);
/**
* morse_bss_stats_pause() - Pause BSS Stats module, if it's enabled
*
* @mors_vif: Morse VIF
*
* Return: 0 if processed successfully, otherwise error code
*/
int morse_bss_stats_pause(struct morse_vif *mors_vif);
/**
* morse_bss_stats_resume() - Resume BSS Stats module, if it's enabled
*
* @mors_vif: Morse VIF
*
* Return: 0 if processed successfully, otherwise error code
*/
int morse_bss_stats_resume(struct morse_vif *mors_vif);
#endif /* !_MORSE_BSS_STATS_H_ */