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