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