1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 /*
3 	Copyright (C) 2004 - 2009 Ivo van Doorn <IvDoorn@gmail.com>
4 	<http://rt2x00.serialmonkey.com>
5 
6  */
7 
8 /*
9 	Module: rt2x00dump
10 	Abstract:
11 		Data structures for the rt2x00debug & userspace.
12 
13 		The declarations in this file can be used by both rt2x00
14 		and userspace and therefore should be kept together in
15 		this file.
16  */
17 
18 #ifndef RT2X00DUMP_H
19 #define RT2X00DUMP_H
20 
21 /**
22  * DOC: Introduction
23  *
24  * This header is intended to be exported to userspace,
25  * to make the structures and enumerations available to userspace
26  * applications. This means that all data types should be exportable.
27  *
28  * When rt2x00 is compiled with debugfs support enabled,
29  * it is possible to capture all data coming in and out of the device
30  * by reading the frame dump file. This file can have only a single reader.
31  * The following frames will be reported:
32  *   - All incoming frames (rx)
33  *   - All outgoing frames (tx, including beacon and atim)
34  *   - All completed frames (txdone including atim)
35  *
36  * The data is send to the file using the following format:
37  *
38  *   [rt2x00dump header][hardware descriptor][ieee802.11 frame]
39  *
40  * rt2x00dump header: The description of the dumped frame, as well as
41  *	additional information useful for debugging. See &rt2x00dump_hdr.
42  * hardware descriptor: Descriptor that was used to receive or transmit
43  *	the frame.
44  * ieee802.11 frame: The actual frame that was received or transmitted.
45  */
46 
47 /**
48  * enum rt2x00_dump_type - Frame type
49  *
50  * These values are used for the @type member of &rt2x00dump_hdr.
51  * @DUMP_FRAME_RXDONE: This frame has been received by the hardware.
52  * @DUMP_FRAME_TX: This frame is queued for transmission to the hardware.
53  * @DUMP_FRAME_TXDONE: This frame indicates the device has handled
54  *	the tx event which has either succeeded or failed. A frame
55  *	with this type should also have been reported with as a
56  *	%DUMP_FRAME_TX frame.
57  * @DUMP_FRAME_BEACON: This beacon frame is queued for transmission to the
58  *	hardware.
59  */
60 enum rt2x00_dump_type {
61 	DUMP_FRAME_RXDONE = 1,
62 	DUMP_FRAME_TX = 2,
63 	DUMP_FRAME_TXDONE = 3,
64 	DUMP_FRAME_BEACON = 4,
65 };
66 
67 /**
68  * struct rt2x00dump_hdr - Dump frame header
69  *
70  * Each frame dumped to the debugfs file starts with this header
71  * attached. This header contains the description of the actual
72  * frame which was dumped.
73  *
74  * New fields inside the structure must be appended to the end of
75  * the structure. This way userspace tools compiled for earlier
76  * header versions can still correctly handle the frame dump
77  * (although they will not handle all data passed to them in the dump).
78  *
79  * @version: Header version should always be set to %DUMP_HEADER_VERSION.
80  *	This field must be checked by userspace to determine if it can
81  *	handle this frame.
82  * @header_length: The length of the &rt2x00dump_hdr structure. This is
83  *	used for compatibility reasons so userspace can easily determine
84  *	the location of the next field in the dump.
85  * @desc_length: The length of the device descriptor.
86  * @data_length: The length of the frame data (including the ieee802.11 header.
87  * @chip_rt: RT chipset
88  * @chip_rf: RF chipset
89  * @chip_rev: Chipset revision
90  * @type: The frame type (&rt2x00_dump_type)
91  * @queue_index: The index number of the data queue.
92  * @entry_index: The index number of the entry inside the data queue.
93  * @timestamp_sec: Timestamp - seconds
94  * @timestamp_usec: Timestamp - microseconds
95  */
96 struct rt2x00dump_hdr {
97 	__le32 version;
98 #define DUMP_HEADER_VERSION	3
99 
100 	__le32 header_length;
101 	__le32 desc_length;
102 	__le32 data_length;
103 
104 	__le16 chip_rt;
105 	__le16 chip_rf;
106 	__le16 chip_rev;
107 
108 	__le16 type;
109 	__u8 queue_index;
110 	__u8 entry_index;
111 
112 	__le32 timestamp_sec;
113 	__le32 timestamp_usec;
114 };
115 
116 #endif /* RT2X00DUMP_H */
117