Linux-libre 5.3.12-gnu
[librecmc/linux-libre.git] / drivers / net / wireless / intel / iwlwifi / fw / api / stats.h
1 /******************************************************************************
2  *
3  * This file is provided under a dual BSD/GPLv2 license.  When using or
4  * redistributing this file, you may do so under either license.
5  *
6  * GPL LICENSE SUMMARY
7  *
8  * Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved.
9  * Copyright(c) 2013 - 2015 Intel Mobile Communications GmbH
10  * Copyright(c) 2016 - 2017 Intel Deutschland GmbH
11  * Copyright (C) 2018 Intel Corporation
12  *
13  * This program is free software; you can redistribute it and/or modify
14  * it under the terms of version 2 of the GNU General Public License as
15  * published by the Free Software Foundation.
16  *
17  * This program is distributed in the hope that it will be useful, but
18  * WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
20  * General Public License for more details.
21  *
22  * The full GNU General Public License is included in this distribution
23  * in the file called COPYING.
24  *
25  * Contact Information:
26  *  Intel Linux Wireless <linuxwifi@intel.com>
27  * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
28  *
29  * BSD LICENSE
30  *
31  * Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved.
32  * Copyright(c) 2013 - 2015 Intel Mobile Communications GmbH
33  * Copyright (C) 2018 Intel Corporation
34  * All rights reserved.
35  *
36  * Redistribution and use in source and binary forms, with or without
37  * modification, are permitted provided that the following conditions
38  * are met:
39  *
40  *  * Redistributions of source code must retain the above copyright
41  *    notice, this list of conditions and the following disclaimer.
42  *  * Redistributions in binary form must reproduce the above copyright
43  *    notice, this list of conditions and the following disclaimer in
44  *    the documentation and/or other materials provided with the
45  *    distribution.
46  *  * Neither the name Intel Corporation nor the names of its
47  *    contributors may be used to endorse or promote products derived
48  *    from this software without specific prior written permission.
49  *
50  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
51  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
52  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
53  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
54  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
55  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
56  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
57  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
58  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
59  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
60  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
61  *
62  *****************************************************************************/
63
64 #ifndef __iwl_fw_api_stats_h__
65 #define __iwl_fw_api_stats_h__
66 #include "mac.h"
67
68 struct mvm_statistics_dbg {
69         __le32 burst_check;
70         __le32 burst_count;
71         __le32 wait_for_silence_timeout_cnt;
72         u8 reserved[12];
73 } __packed; /* STATISTICS_DEBUG_API_S_VER_2 */
74
75 struct mvm_statistics_div {
76         __le32 tx_on_a;
77         __le32 tx_on_b;
78         __le32 exec_time;
79         __le32 probe_time;
80         __le32 rssi_ant;
81         __le32 reserved2;
82 } __packed; /* STATISTICS_SLOW_DIV_API_S_VER_2 */
83
84 /**
85  * struct mvm_statistics_rx_non_phy
86  * @bogus_cts: CTS received when not expecting CTS
87  * @bogus_ack: ACK received when not expecting ACK
88  * @non_channel_beacons: beacons with our bss id but not on our serving channel
89  * @channel_beacons: beacons with our bss id and in our serving channel
90  * @num_missed_bcon: number of missed beacons
91  * @adc_rx_saturation_time: count in 0.8us units the time the ADC was in
92  *      saturation
93  * @ina_detection_search_time: total time (in 0.8us) searched for INA
94  * @beacon_silence_rssi_a: RSSI silence after beacon frame
95  * @beacon_silence_rssi_b: RSSI silence after beacon frame
96  * @beacon_silence_rssi_c: RSSI silence after beacon frame
97  * @interference_data_flag: flag for interference data availability. 1 when data
98  *      is available.
99  * @channel_load: counts RX Enable time in uSec
100  * @beacon_rssi_a: beacon RSSI on anntena A
101  * @beacon_rssi_b: beacon RSSI on antenna B
102  * @beacon_rssi_c: beacon RSSI on antenna C
103  * @beacon_energy_a: beacon energy on antenna A
104  * @beacon_energy_b: beacon energy on antenna B
105  * @beacon_energy_c: beacon energy on antenna C
106  * @num_bt_kills: number of BT "kills" (frame TX aborts)
107  * @mac_id: mac ID
108  */
109 struct mvm_statistics_rx_non_phy {
110         __le32 bogus_cts;
111         __le32 bogus_ack;
112         __le32 non_channel_beacons;
113         __le32 channel_beacons;
114         __le32 num_missed_bcon;
115         __le32 adc_rx_saturation_time;
116         __le32 ina_detection_search_time;
117         __le32 beacon_silence_rssi_a;
118         __le32 beacon_silence_rssi_b;
119         __le32 beacon_silence_rssi_c;
120         __le32 interference_data_flag;
121         __le32 channel_load;
122         __le32 beacon_rssi_a;
123         __le32 beacon_rssi_b;
124         __le32 beacon_rssi_c;
125         __le32 beacon_energy_a;
126         __le32 beacon_energy_b;
127         __le32 beacon_energy_c;
128         __le32 num_bt_kills;
129         __le32 mac_id;
130 } __packed; /* STATISTICS_RX_NON_PHY_API_S_VER_4 */
131
132 struct mvm_statistics_rx_non_phy_v3 {
133         __le32 bogus_cts;       /* CTS received when not expecting CTS */
134         __le32 bogus_ack;       /* ACK received when not expecting ACK */
135         __le32 non_bssid_frames;        /* number of frames with BSSID that
136                                          * doesn't belong to the STA BSSID */
137         __le32 filtered_frames; /* count frames that were dumped in the
138                                  * filtering process */
139         __le32 non_channel_beacons;     /* beacons with our bss id but not on
140                                          * our serving channel */
141         __le32 channel_beacons; /* beacons with our bss id and in our
142                                  * serving channel */
143         __le32 num_missed_bcon; /* number of missed beacons */
144         __le32 adc_rx_saturation_time;  /* count in 0.8us units the time the
145                                          * ADC was in saturation */
146         __le32 ina_detection_search_time;/* total time (in 0.8us) searched
147                                           * for INA */
148         __le32 beacon_silence_rssi_a;   /* RSSI silence after beacon frame */
149         __le32 beacon_silence_rssi_b;   /* RSSI silence after beacon frame */
150         __le32 beacon_silence_rssi_c;   /* RSSI silence after beacon frame */
151         __le32 interference_data_flag;  /* flag for interference data
152                                          * availability. 1 when data is
153                                          * available. */
154         __le32 channel_load;            /* counts RX Enable time in uSec */
155         __le32 dsp_false_alarms;        /* DSP false alarm (both OFDM
156                                          * and CCK) counter */
157         __le32 beacon_rssi_a;
158         __le32 beacon_rssi_b;
159         __le32 beacon_rssi_c;
160         __le32 beacon_energy_a;
161         __le32 beacon_energy_b;
162         __le32 beacon_energy_c;
163         __le32 num_bt_kills;
164         __le32 mac_id;
165         __le32 directed_data_mpdu;
166 } __packed; /* STATISTICS_RX_NON_PHY_API_S_VER_3 */
167
168 struct mvm_statistics_rx_phy {
169         __le32 unresponded_rts;
170         __le32 rxe_frame_lmt_overrun;
171         __le32 sent_ba_rsp_cnt;
172         __le32 dsp_self_kill;
173         __le32 reserved;
174 } __packed; /* STATISTICS_RX_PHY_API_S_VER_3 */
175
176 struct mvm_statistics_rx_phy_v2 {
177         __le32 ina_cnt;
178         __le32 fina_cnt;
179         __le32 plcp_err;
180         __le32 crc32_err;
181         __le32 overrun_err;
182         __le32 early_overrun_err;
183         __le32 crc32_good;
184         __le32 false_alarm_cnt;
185         __le32 fina_sync_err_cnt;
186         __le32 sfd_timeout;
187         __le32 fina_timeout;
188         __le32 unresponded_rts;
189         __le32 rxe_frame_lmt_overrun;
190         __le32 sent_ack_cnt;
191         __le32 sent_cts_cnt;
192         __le32 sent_ba_rsp_cnt;
193         __le32 dsp_self_kill;
194         __le32 mh_format_err;
195         __le32 re_acq_main_rssi_sum;
196         __le32 reserved;
197 } __packed; /* STATISTICS_RX_PHY_API_S_VER_2 */
198
199 struct mvm_statistics_rx_ht_phy_v1 {
200         __le32 plcp_err;
201         __le32 overrun_err;
202         __le32 early_overrun_err;
203         __le32 crc32_good;
204         __le32 crc32_err;
205         __le32 mh_format_err;
206         __le32 agg_crc32_good;
207         __le32 agg_mpdu_cnt;
208         __le32 agg_cnt;
209         __le32 unsupport_mcs;
210 } __packed;  /* STATISTICS_HT_RX_PHY_API_S_VER_1 */
211
212 struct mvm_statistics_rx_ht_phy {
213         __le32 mh_format_err;
214         __le32 agg_mpdu_cnt;
215         __le32 agg_cnt;
216         __le32 unsupport_mcs;
217 } __packed;  /* STATISTICS_HT_RX_PHY_API_S_VER_2 */
218
219 struct mvm_statistics_tx_non_phy_v3 {
220         __le32 preamble_cnt;
221         __le32 rx_detected_cnt;
222         __le32 bt_prio_defer_cnt;
223         __le32 bt_prio_kill_cnt;
224         __le32 few_bytes_cnt;
225         __le32 cts_timeout;
226         __le32 ack_timeout;
227         __le32 expected_ack_cnt;
228         __le32 actual_ack_cnt;
229         __le32 dump_msdu_cnt;
230         __le32 burst_abort_next_frame_mismatch_cnt;
231         __le32 burst_abort_missing_next_frame_cnt;
232         __le32 cts_timeout_collision;
233         __le32 ack_or_ba_timeout_collision;
234 } __packed; /* STATISTICS_TX_NON_PHY_API_S_VER_3 */
235
236 struct mvm_statistics_tx_non_phy {
237         __le32 bt_prio_defer_cnt;
238         __le32 bt_prio_kill_cnt;
239         __le32 few_bytes_cnt;
240         __le32 cts_timeout;
241         __le32 ack_timeout;
242         __le32 dump_msdu_cnt;
243         __le32 burst_abort_next_frame_mismatch_cnt;
244         __le32 burst_abort_missing_next_frame_cnt;
245         __le32 cts_timeout_collision;
246         __le32 ack_or_ba_timeout_collision;
247 } __packed; /* STATISTICS_TX_NON_PHY_API_S_VER_4 */
248
249 #define MAX_CHAINS 3
250
251 struct mvm_statistics_tx_non_phy_agg {
252         __le32 ba_timeout;
253         __le32 ba_reschedule_frames;
254         __le32 scd_query_agg_frame_cnt;
255         __le32 scd_query_no_agg;
256         __le32 scd_query_agg;
257         __le32 scd_query_mismatch;
258         __le32 frame_not_ready;
259         __le32 underrun;
260         __le32 bt_prio_kill;
261         __le32 rx_ba_rsp_cnt;
262         __s8 txpower[MAX_CHAINS];
263         __s8 reserved;
264         __le32 reserved2;
265 } __packed; /* STATISTICS_TX_NON_PHY_AGG_API_S_VER_1 */
266
267 struct mvm_statistics_tx_channel_width {
268         __le32 ext_cca_narrow_ch20[1];
269         __le32 ext_cca_narrow_ch40[2];
270         __le32 ext_cca_narrow_ch80[3];
271         __le32 ext_cca_narrow_ch160[4];
272         __le32 last_tx_ch_width_indx;
273         __le32 rx_detected_per_ch_width[4];
274         __le32 success_per_ch_width[4];
275         __le32 fail_per_ch_width[4];
276 }; /* STATISTICS_TX_CHANNEL_WIDTH_API_S_VER_1 */
277
278 struct mvm_statistics_tx_v4 {
279         struct mvm_statistics_tx_non_phy_v3 general;
280         struct mvm_statistics_tx_non_phy_agg agg;
281         struct mvm_statistics_tx_channel_width channel_width;
282 } __packed; /* STATISTICS_TX_API_S_VER_4 */
283
284 struct mvm_statistics_tx {
285         struct mvm_statistics_tx_non_phy general;
286         struct mvm_statistics_tx_non_phy_agg agg;
287         struct mvm_statistics_tx_channel_width channel_width;
288 } __packed; /* STATISTICS_TX_API_S_VER_5 */
289
290
291 struct mvm_statistics_bt_activity {
292         __le32 hi_priority_tx_req_cnt;
293         __le32 hi_priority_tx_denied_cnt;
294         __le32 lo_priority_tx_req_cnt;
295         __le32 lo_priority_tx_denied_cnt;
296         __le32 hi_priority_rx_req_cnt;
297         __le32 hi_priority_rx_denied_cnt;
298         __le32 lo_priority_rx_req_cnt;
299         __le32 lo_priority_rx_denied_cnt;
300 } __packed;  /* STATISTICS_BT_ACTIVITY_API_S_VER_1 */
301
302 struct mvm_statistics_general_common_v19 {
303         __le32 radio_temperature;
304         __le32 radio_voltage;
305         struct mvm_statistics_dbg dbg;
306         __le32 sleep_time;
307         __le32 slots_out;
308         __le32 slots_idle;
309         __le32 ttl_timestamp;
310         struct mvm_statistics_div slow_div;
311         __le32 rx_enable_counter;
312         /*
313          * num_of_sos_states:
314          *  count the number of times we have to re-tune
315          *  in order to get out of bad PHY status
316          */
317         __le32 num_of_sos_states;
318         __le32 beacon_filtered;
319         __le32 missed_beacons;
320         u8 beacon_filter_average_energy;
321         u8 beacon_filter_reason;
322         u8 beacon_filter_current_energy;
323         u8 beacon_filter_reserved;
324         __le32 beacon_filter_delta_time;
325         struct mvm_statistics_bt_activity bt_activity;
326         __le64 rx_time;
327         __le64 on_time_rf;
328         __le64 on_time_scan;
329         __le64 tx_time;
330 } __packed;
331
332 struct mvm_statistics_general_common {
333         __le32 radio_temperature;
334         struct mvm_statistics_dbg dbg;
335         __le32 sleep_time;
336         __le32 slots_out;
337         __le32 slots_idle;
338         __le32 ttl_timestamp;
339         struct mvm_statistics_div slow_div;
340         __le32 rx_enable_counter;
341         /*
342          * num_of_sos_states:
343          *  count the number of times we have to re-tune
344          *  in order to get out of bad PHY status
345          */
346         __le32 num_of_sos_states;
347         __le32 beacon_filtered;
348         __le32 missed_beacons;
349         u8 beacon_filter_average_energy;
350         u8 beacon_filter_reason;
351         u8 beacon_filter_current_energy;
352         u8 beacon_filter_reserved;
353         __le32 beacon_filter_delta_time;
354         struct mvm_statistics_bt_activity bt_activity;
355         __le64 rx_time;
356         __le64 on_time_rf;
357         __le64 on_time_scan;
358         __le64 tx_time;
359 } __packed; /* STATISTICS_GENERAL_API_S_VER_10 */
360
361 struct mvm_statistics_general_v8 {
362         struct mvm_statistics_general_common_v19 common;
363         __le32 beacon_counter[NUM_MAC_INDEX];
364         u8 beacon_average_energy[NUM_MAC_INDEX];
365         u8 reserved[4 - (NUM_MAC_INDEX % 4)];
366 } __packed; /* STATISTICS_GENERAL_API_S_VER_8 */
367
368 struct mvm_statistics_general {
369         struct mvm_statistics_general_common common;
370         __le32 beacon_counter[MAC_INDEX_AUX];
371         u8 beacon_average_energy[MAC_INDEX_AUX];
372         u8 reserved[8 - MAC_INDEX_AUX];
373 } __packed; /* STATISTICS_GENERAL_API_S_VER_10 */
374
375 /**
376  * struct mvm_statistics_load - RX statistics for multi-queue devices
377  * @air_time: accumulated air time, per mac
378  * @byte_count: accumulated byte count, per mac
379  * @pkt_count: accumulated packet count, per mac
380  * @avg_energy: average RSSI, per station
381  */
382 struct mvm_statistics_load {
383         __le32 air_time[MAC_INDEX_AUX];
384         __le32 byte_count[MAC_INDEX_AUX];
385         __le32 pkt_count[MAC_INDEX_AUX];
386         u8 avg_energy[IWL_MVM_STATION_COUNT];
387 } __packed; /* STATISTICS_RX_MAC_STATION_S_VER_3 */
388
389 struct mvm_statistics_load_v1 {
390         __le32 air_time[NUM_MAC_INDEX];
391         __le32 byte_count[NUM_MAC_INDEX];
392         __le32 pkt_count[NUM_MAC_INDEX];
393         u8 avg_energy[IWL_MVM_STATION_COUNT];
394 } __packed; /* STATISTICS_RX_MAC_STATION_S_VER_1 */
395
396 struct mvm_statistics_rx {
397         struct mvm_statistics_rx_phy ofdm;
398         struct mvm_statistics_rx_phy cck;
399         struct mvm_statistics_rx_non_phy general;
400         struct mvm_statistics_rx_ht_phy ofdm_ht;
401 } __packed; /* STATISTICS_RX_API_S_VER_4 */
402
403 struct mvm_statistics_rx_v3 {
404         struct mvm_statistics_rx_phy_v2 ofdm;
405         struct mvm_statistics_rx_phy_v2 cck;
406         struct mvm_statistics_rx_non_phy_v3 general;
407         struct mvm_statistics_rx_ht_phy_v1 ofdm_ht;
408 } __packed; /* STATISTICS_RX_API_S_VER_3 */
409
410 /*
411  * STATISTICS_NOTIFICATION = 0x9d (notification only, not a command)
412  *
413  * By default, uCode issues this notification after receiving a beacon
414  * while associated.  To disable this behavior, set DISABLE_NOTIF flag in the
415  * STATISTICS_CMD (0x9c), below.
416  */
417
418 struct iwl_notif_statistics_v10 {
419         __le32 flag;
420         struct mvm_statistics_rx_v3 rx;
421         struct mvm_statistics_tx_v4 tx;
422         struct mvm_statistics_general_v8 general;
423 } __packed; /* STATISTICS_NTFY_API_S_VER_10 */
424
425 struct iwl_notif_statistics_v11 {
426         __le32 flag;
427         struct mvm_statistics_rx_v3 rx;
428         struct mvm_statistics_tx_v4 tx;
429         struct mvm_statistics_general_v8 general;
430         struct mvm_statistics_load_v1 load_stats;
431 } __packed; /* STATISTICS_NTFY_API_S_VER_11 */
432
433 struct iwl_notif_statistics {
434         __le32 flag;
435         struct mvm_statistics_rx rx;
436         struct mvm_statistics_tx tx;
437         struct mvm_statistics_general general;
438         struct mvm_statistics_load load_stats;
439 } __packed; /* STATISTICS_NTFY_API_S_VER_13 */
440
441 /**
442  * enum iwl_statistics_notif_flags - flags used in statistics notification
443  * @IWL_STATISTICS_REPLY_FLG_CLEAR: statistics were cleared after this report
444  */
445 enum iwl_statistics_notif_flags {
446         IWL_STATISTICS_REPLY_FLG_CLEAR          = 0x1,
447 };
448
449 /**
450  * enum iwl_statistics_cmd_flags - flags used in statistics command
451  * @IWL_STATISTICS_FLG_CLEAR: request to clear statistics after the report
452  *      that's sent after this command
453  * @IWL_STATISTICS_FLG_DISABLE_NOTIF: disable unilateral statistics
454  *      notifications
455  */
456 enum iwl_statistics_cmd_flags {
457         IWL_STATISTICS_FLG_CLEAR                = 0x1,
458         IWL_STATISTICS_FLG_DISABLE_NOTIF        = 0x2,
459 };
460
461 /**
462  * struct iwl_statistics_cmd - statistics config command
463  * @flags: flags from &enum iwl_statistics_cmd_flags
464  */
465 struct iwl_statistics_cmd {
466         __le32 flags;
467 } __packed; /* STATISTICS_CMD_API_S_VER_1 */
468
469 #endif /* __iwl_fw_api_stats_h__ */