]> git.kernelconcepts.de Git - karo-tx-linux.git/blob - drivers/net/wireless/iwlwifi/iwl-fw-error-dump.h
Merge tag 'scsi-misc' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi
[karo-tx-linux.git] / drivers / net / wireless / iwlwifi / iwl-fw-error-dump.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) 2014 Intel Corporation. All rights reserved.
9  * Copyright(c) 2014 - 2015 Intel Mobile Communications GmbH
10  *
11  * This program is free software; you can redistribute it and/or modify
12  * it under the terms of version 2 of the GNU General Public License as
13  * published by the Free Software Foundation.
14  *
15  * This program is distributed in the hope that it will be useful, but
16  * WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
18  * General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program; if not, write to the Free Software
22  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110,
23  * USA
24  *
25  * The full GNU General Public License is included in this distribution
26  * in the file called COPYING.
27  *
28  * Contact Information:
29  *  Intel Linux Wireless <ilw@linux.intel.com>
30  * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
31  *
32  * BSD LICENSE
33  *
34  * Copyright(c) 2014 Intel Corporation. All rights reserved.
35  * Copyright(c) 2014 - 2015 Intel Mobile Communications GmbH
36  * All rights reserved.
37  *
38  * Redistribution and use in source and binary forms, with or without
39  * modification, are permitted provided that the following conditions
40  * are met:
41  *
42  *  * Redistributions of source code must retain the above copyright
43  *    notice, this list of conditions and the following disclaimer.
44  *  * Redistributions in binary form must reproduce the above copyright
45  *    notice, this list of conditions and the following disclaimer in
46  *    the documentation and/or other materials provided with the
47  *    distribution.
48  *  * Neither the name Intel Corporation nor the names of its
49  *    contributors may be used to endorse or promote products derived
50  *    from this software without specific prior written permission.
51  *
52  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
53  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
54  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
55  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
56  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
57  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
58  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
59  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
60  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
61  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
62  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
63  *****************************************************************************/
64
65 #ifndef __fw_error_dump_h__
66 #define __fw_error_dump_h__
67
68 #include <linux/types.h>
69
70 #define IWL_FW_ERROR_DUMP_BARKER        0x14789632
71
72 /**
73  * enum iwl_fw_error_dump_type - types of data in the dump file
74  * @IWL_FW_ERROR_DUMP_CSR: Control Status Registers - from offset 0
75  * @IWL_FW_ERROR_DUMP_RXF:
76  * @IWL_FW_ERROR_DUMP_TXCMD: last TX command data, structured as
77  *      &struct iwl_fw_error_dump_txcmd packets
78  * @IWL_FW_ERROR_DUMP_DEV_FW_INFO:  struct %iwl_fw_error_dump_info
79  *      info on the device / firmware.
80  * @IWL_FW_ERROR_DUMP_FW_MONITOR: firmware monitor
81  * @IWL_FW_ERROR_DUMP_PRPH: range of periphery registers - there can be several
82  *      sections like this in a single file.
83  * @IWL_FW_ERROR_DUMP_FH_REGS: range of FH registers
84  * @IWL_FW_ERROR_DUMP_MEM: chunk of memory
85  * @IWL_FW_ERROR_DUMP_ERROR_INFO: description of what triggered this dump.
86  *      Structured as &struct iwl_fw_error_dump_trigger_desc.
87  * @IWL_FW_ERROR_DUMP_RB: the content of an RB structured as
88  *      &struct iwl_fw_error_dump_rb
89  */
90 enum iwl_fw_error_dump_type {
91         /* 0 is deprecated */
92         IWL_FW_ERROR_DUMP_CSR = 1,
93         IWL_FW_ERROR_DUMP_RXF = 2,
94         IWL_FW_ERROR_DUMP_TXCMD = 3,
95         IWL_FW_ERROR_DUMP_DEV_FW_INFO = 4,
96         IWL_FW_ERROR_DUMP_FW_MONITOR = 5,
97         IWL_FW_ERROR_DUMP_PRPH = 6,
98         IWL_FW_ERROR_DUMP_TXF = 7,
99         IWL_FW_ERROR_DUMP_FH_REGS = 8,
100         IWL_FW_ERROR_DUMP_MEM = 9,
101         IWL_FW_ERROR_DUMP_ERROR_INFO = 10,
102         IWL_FW_ERROR_DUMP_RB = 11,
103
104         IWL_FW_ERROR_DUMP_MAX,
105 };
106
107 /**
108  * struct iwl_fw_error_dump_data - data for one type
109  * @type: %enum iwl_fw_error_dump_type
110  * @len: the length starting from %data
111  * @data: the data itself
112  */
113 struct iwl_fw_error_dump_data {
114         __le32 type;
115         __le32 len;
116         __u8 data[];
117 } __packed;
118
119 /**
120  * struct iwl_fw_error_dump_file - the layout of the header of the file
121  * @barker: must be %IWL_FW_ERROR_DUMP_BARKER
122  * @file_len: the length of all the file starting from %barker
123  * @data: array of %struct iwl_fw_error_dump_data
124  */
125 struct iwl_fw_error_dump_file {
126         __le32 barker;
127         __le32 file_len;
128         u8 data[0];
129 } __packed;
130
131 /**
132  * struct iwl_fw_error_dump_txcmd - TX command data
133  * @cmdlen: original length of command
134  * @caplen: captured length of command (may be less)
135  * @data: captured command data, @caplen bytes
136  */
137 struct iwl_fw_error_dump_txcmd {
138         __le32 cmdlen;
139         __le32 caplen;
140         u8 data[];
141 } __packed;
142
143 /**
144  * struct iwl_fw_error_dump_fifo - RX/TX FIFO data
145  * @fifo_num: number of FIFO (starting from 0)
146  * @available_bytes: num of bytes available in FIFO (may be less than FIFO size)
147  * @wr_ptr: position of write pointer
148  * @rd_ptr: position of read pointer
149  * @fence_ptr: position of fence pointer
150  * @fence_mode: the current mode of the fence (before locking) -
151  *      0=follow RD pointer ; 1 = freeze
152  * @data: all of the FIFO's data
153  */
154 struct iwl_fw_error_dump_fifo {
155         __le32 fifo_num;
156         __le32 available_bytes;
157         __le32 wr_ptr;
158         __le32 rd_ptr;
159         __le32 fence_ptr;
160         __le32 fence_mode;
161         u8 data[];
162 } __packed;
163
164 enum iwl_fw_error_dump_family {
165         IWL_FW_ERROR_DUMP_FAMILY_7 = 7,
166         IWL_FW_ERROR_DUMP_FAMILY_8 = 8,
167 };
168
169 /**
170  * struct iwl_fw_error_dump_info - info on the device / firmware
171  * @device_family: the family of the device (7 / 8)
172  * @hw_step: the step of the device
173  * @fw_human_readable: human readable FW version
174  * @dev_human_readable: name of the device
175  * @bus_human_readable: name of the bus used
176  */
177 struct iwl_fw_error_dump_info {
178         __le32 device_family;
179         __le32 hw_step;
180         u8 fw_human_readable[FW_VER_HUMAN_READABLE_SZ];
181         u8 dev_human_readable[64];
182         u8 bus_human_readable[8];
183 } __packed;
184
185 /**
186  * struct iwl_fw_error_dump_fw_mon - FW monitor data
187  * @fw_mon_wr_ptr: the position of the write pointer in the cyclic buffer
188  * @fw_mon_base_ptr: base pointer of the data
189  * @fw_mon_cycle_cnt: number of wraparounds
190  * @reserved: for future use
191  * @data: captured data
192  */
193 struct iwl_fw_error_dump_fw_mon {
194         __le32 fw_mon_wr_ptr;
195         __le32 fw_mon_base_ptr;
196         __le32 fw_mon_cycle_cnt;
197         __le32 reserved[3];
198         u8 data[];
199 } __packed;
200
201 /**
202  * struct iwl_fw_error_dump_prph - periphery registers data
203  * @prph_start: address of the first register in this chunk
204  * @data: the content of the registers
205  */
206 struct iwl_fw_error_dump_prph {
207         __le32 prph_start;
208         __le32 data[];
209 };
210
211 enum iwl_fw_error_dump_mem_type {
212         IWL_FW_ERROR_DUMP_MEM_SRAM,
213         IWL_FW_ERROR_DUMP_MEM_SMEM,
214 };
215
216 /**
217  * struct iwl_fw_error_dump_mem - chunk of memory
218  * @type: %enum iwl_fw_error_dump_mem_type
219  * @offset: the offset from which the memory was read
220  * @data: the content of the memory
221  */
222 struct iwl_fw_error_dump_mem {
223         __le32 type;
224         __le32 offset;
225         u8 data[];
226 };
227
228 /**
229  * struct iwl_fw_error_dump_rb - content of an Receive Buffer
230  * @index: the index of the Receive Buffer in the Rx queue
231  * @rxq: the RB's Rx queue
232  * @reserved:
233  * @data: the content of the Receive Buffer
234  */
235 struct iwl_fw_error_dump_rb {
236         __le32 index;
237         __le32 rxq;
238         __le32 reserved;
239         u8 data[];
240 };
241
242 /**
243  * iwl_fw_error_next_data - advance fw error dump data pointer
244  * @data: previous data block
245  * Returns: next data block
246  */
247 static inline struct iwl_fw_error_dump_data *
248 iwl_fw_error_next_data(struct iwl_fw_error_dump_data *data)
249 {
250         return (void *)(data->data + le32_to_cpu(data->len));
251 }
252
253 /**
254  * enum iwl_fw_dbg_trigger - triggers available
255  *
256  * @FW_DBG_TRIGGER_USER: trigger log collection by user
257  *      This should not be defined as a trigger to the driver, but a value the
258  *      driver should set to indicate that the trigger was initiated by the
259  *      user.
260  * @FW_DBG_TRIGGER_FW_ASSERT: trigger log collection when the firmware asserts
261  * @FW_DBG_TRIGGER_MISSED_BEACONS: trigger log collection when beacons are
262  *      missed.
263  * @FW_DBG_TRIGGER_CHANNEL_SWITCH: trigger log collection upon channel switch.
264  * @FW_DBG_TRIGGER_FW_NOTIF: trigger log collection when the firmware sends a
265  *      command response or a notification.
266  * @FW_DBG_TRIGGER_MLME: trigger log collection upon MLME event.
267  * @FW_DBG_TRIGGER_STATS: trigger log collection upon statistics threshold.
268  * @FW_DBG_TRIGGER_RSSI: trigger log collection when the rssi of the beacon
269  *      goes below a threshold.
270  * @FW_DBG_TRIGGER_TXQ_TIMERS: configures the timers for the Tx queue hang
271  *      detection.
272  * @FW_DBG_TRIGGER_TIME_EVENT: trigger log collection upon time events related
273  *      events.
274  * @FW_DBG_TRIGGER_BA: trigger log collection upon BlockAck related events.
275  */
276 enum iwl_fw_dbg_trigger {
277         FW_DBG_TRIGGER_INVALID = 0,
278         FW_DBG_TRIGGER_USER,
279         FW_DBG_TRIGGER_FW_ASSERT,
280         FW_DBG_TRIGGER_MISSED_BEACONS,
281         FW_DBG_TRIGGER_CHANNEL_SWITCH,
282         FW_DBG_TRIGGER_FW_NOTIF,
283         FW_DBG_TRIGGER_MLME,
284         FW_DBG_TRIGGER_STATS,
285         FW_DBG_TRIGGER_RSSI,
286         FW_DBG_TRIGGER_TXQ_TIMERS,
287         FW_DBG_TRIGGER_TIME_EVENT,
288         FW_DBG_TRIGGER_BA,
289
290         /* must be last */
291         FW_DBG_TRIGGER_MAX,
292 };
293
294 /**
295  * struct iwl_fw_error_dump_trigger_desc - describes the trigger condition
296  * @type: %enum iwl_fw_dbg_trigger
297  * @data: raw data about what happened
298  */
299 struct iwl_fw_error_dump_trigger_desc {
300         __le32 type;
301         u8 data[];
302 };
303
304 #endif /* __fw_error_dump_h__ */